@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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { splitOutsideParenthesesAndArrays, joinParenthesesAndArrays, } from "../../../../../../packages/ai/index.js";
|
|
2
2
|
import { cleanKnownObjectFunctionsFromMapping } from "../../../../../../packages/ai/index.js";
|
|
3
|
+
import { transformationTracer } from "./TransformationTracer.js";
|
|
3
4
|
function cleanFunctionName(functionName) {
|
|
4
5
|
return functionName?.split('<')[0];
|
|
5
6
|
}
|
|
@@ -24,6 +25,50 @@ function getTypeParameter(functionName) {
|
|
|
24
25
|
}
|
|
25
26
|
return null;
|
|
26
27
|
}
|
|
28
|
+
// Primitive types that should not have child paths
|
|
29
|
+
const PRIMITIVE_TYPES = new Set([
|
|
30
|
+
'number',
|
|
31
|
+
'string',
|
|
32
|
+
'boolean',
|
|
33
|
+
'null',
|
|
34
|
+
'undefined',
|
|
35
|
+
]);
|
|
36
|
+
// Check if a type string represents a primitive type
|
|
37
|
+
// Handles union types like "string | undefined" or "number | null"
|
|
38
|
+
function isPrimitiveType(typeStr) {
|
|
39
|
+
if (PRIMITIVE_TYPES.has(typeStr)) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
// Check union types - if ALL parts of the union are primitives, it's primitive
|
|
43
|
+
// e.g., "string | undefined" -> ["string", "undefined"] -> both are primitive -> true
|
|
44
|
+
// e.g., "object | null" -> ["object", "null"] -> object is not primitive -> false
|
|
45
|
+
if (typeStr.includes('|')) {
|
|
46
|
+
const parts = typeStr.split('|').map((p) => p.trim());
|
|
47
|
+
return parts.every((part) => PRIMITIVE_TYPES.has(part));
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
// Extract signature index from a path like "signature[0]" or "signature[0].foo"
|
|
52
|
+
// Returns the index number or undefined if not a signature path
|
|
53
|
+
function extractSignatureIndex(path) {
|
|
54
|
+
const match = path.match(/^signature\[(\d+)\]/);
|
|
55
|
+
return match ? parseInt(match[1], 10) : undefined;
|
|
56
|
+
}
|
|
57
|
+
// Check if a new schema path would go through a primitive type
|
|
58
|
+
// e.g., if schema has 'entities[].scenarioCount': 'number', then
|
|
59
|
+
// 'entities[].scenarioCount.sha' would go through a primitive and should be rejected
|
|
60
|
+
function wouldGoThroughPrimitive(newPath, schema) {
|
|
61
|
+
const pathParts = splitOutsideParenthesesAndArrays(newPath);
|
|
62
|
+
// Check each prefix of the path (excluding the full path itself)
|
|
63
|
+
for (let i = 1; i < pathParts.length; i++) {
|
|
64
|
+
const prefixPath = joinParenthesesAndArrays(pathParts.slice(0, i));
|
|
65
|
+
const prefixType = schema[prefixPath];
|
|
66
|
+
if (prefixType && isPrimitiveType(prefixType)) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
27
72
|
// Check if schemaPathPart matches or is a function call variant of pathPart
|
|
28
73
|
// e.g., 'isEntityBeingAnalyzed(entity.sha)' matches 'isEntityBeingAnalyzed'
|
|
29
74
|
function pathPartMatches(pathPart, schemaPathPart) {
|
|
@@ -39,11 +84,13 @@ function pathPartMatches(pathPart, schemaPathPart) {
|
|
|
39
84
|
function bestValueFromOptions(options) {
|
|
40
85
|
options = options.filter(Boolean);
|
|
41
86
|
const known = options.find((o) => !o.includes('unknown'));
|
|
42
|
-
if (known)
|
|
87
|
+
if (known) {
|
|
43
88
|
return known;
|
|
89
|
+
}
|
|
44
90
|
const notUnknown = options.find((o) => o !== 'unknown');
|
|
45
|
-
if (notUnknown)
|
|
91
|
+
if (notUnknown) {
|
|
46
92
|
return notUnknown;
|
|
93
|
+
}
|
|
47
94
|
return options[0] ?? 'unknown';
|
|
48
95
|
}
|
|
49
96
|
export default function mergeInDependentDataStructure({ importedExports, dependentAnalyses, rootScopeName, dataStructure, dependencySchemas, }) {
|
|
@@ -88,8 +135,17 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
88
135
|
}
|
|
89
136
|
}
|
|
90
137
|
let equivalentSchemaPaths = [];
|
|
138
|
+
// Pre-build a lookup map from cleaned function name to dependency for O(1) lookups.
|
|
139
|
+
// This avoids O(n) linear search in findRelevantDependency which was causing O(n²) performance.
|
|
140
|
+
const dependencyByCleanedName = new Map();
|
|
141
|
+
for (const dep of importedExports) {
|
|
142
|
+
const cleanedName = cleanFunctionName(dep.name);
|
|
143
|
+
if (!dependencyByCleanedName.has(cleanedName)) {
|
|
144
|
+
dependencyByCleanedName.set(cleanedName, dep);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
91
147
|
const findRelevantDependency = (functionName) => {
|
|
92
|
-
return
|
|
148
|
+
return dependencyByCleanedName.get(cleanFunctionName(functionName));
|
|
93
149
|
};
|
|
94
150
|
const findRelevantDependentDataStructure = (functionName) => {
|
|
95
151
|
const dependency = findRelevantDependency(functionName);
|
|
@@ -117,8 +173,8 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
117
173
|
});
|
|
118
174
|
return mergedDataStructure.dependencySchemas[filePath][name];
|
|
119
175
|
};
|
|
120
|
-
const cleanSchema = (schema) => {
|
|
121
|
-
cleanKnownObjectFunctionsFromMapping
|
|
176
|
+
const cleanSchema = (schema, context) => {
|
|
177
|
+
transformationTracer.traceSchemaTransform(rootScopeName, 'cleanKnownObjectFunctionsFromMapping', schema, cleanKnownObjectFunctionsFromMapping, context);
|
|
122
178
|
};
|
|
123
179
|
const translatePath = (path, dependencyName) => {
|
|
124
180
|
if (path.startsWith(dependencyName)) {
|
|
@@ -169,19 +225,100 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
169
225
|
: findRelevantDependency(p.functionName),
|
|
170
226
|
}));
|
|
171
227
|
let equivalentSchemaPathsEntry;
|
|
228
|
+
// Collect the signature indices from the new roots we want to add
|
|
229
|
+
const newRootSignatureIndices = new Set();
|
|
230
|
+
for (const root of equivalentRoots) {
|
|
231
|
+
const idx = extractSignatureIndex(root.schemaRootPath);
|
|
232
|
+
if (idx !== undefined) {
|
|
233
|
+
newRootSignatureIndices.add(idx);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
172
236
|
for (const pathInfo of allPaths) {
|
|
173
237
|
if (!equivalentSchemaPathsEntry) {
|
|
174
|
-
equivalentSchemaPathsEntry = equivalentSchemaPaths.find((esp) =>
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
(
|
|
178
|
-
cleanFunctionName(pathInfo.functionName)
|
|
179
|
-
|
|
238
|
+
equivalentSchemaPathsEntry = equivalentSchemaPaths.find((esp) => {
|
|
239
|
+
// First check: does this entry have a matching root?
|
|
240
|
+
const hasMatchingRoot = esp.equivalentRoots.some((er) => er.schemaRootPath === pathInfo.path &&
|
|
241
|
+
(er.function?.name ===
|
|
242
|
+
cleanFunctionName(pathInfo.functionName) ||
|
|
243
|
+
(!er.function &&
|
|
244
|
+
cleanFunctionName(pathInfo.functionName) ===
|
|
245
|
+
rootScopeName)));
|
|
246
|
+
if (!hasMatchingRoot)
|
|
247
|
+
return false;
|
|
248
|
+
// Second check: would adding our new roots create a signature index conflict?
|
|
249
|
+
// An entry should NOT contain roots with different signature indices from the same function.
|
|
250
|
+
if (newRootSignatureIndices.size > 0) {
|
|
251
|
+
// Get all signature indices in the existing entry (grouped by function)
|
|
252
|
+
const existingIndicesByFunction = new Map();
|
|
253
|
+
for (const er of esp.equivalentRoots) {
|
|
254
|
+
const funcKey = er.function
|
|
255
|
+
? `${er.function.name}::${er.function.filePath}`
|
|
256
|
+
: '__self__';
|
|
257
|
+
const idx = extractSignatureIndex(er.schemaRootPath);
|
|
258
|
+
if (idx !== undefined) {
|
|
259
|
+
if (!existingIndicesByFunction.has(funcKey)) {
|
|
260
|
+
existingIndicesByFunction.set(funcKey, new Set());
|
|
261
|
+
}
|
|
262
|
+
existingIndicesByFunction.get(funcKey).add(idx);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
// Check if adding our new roots would create a conflict
|
|
266
|
+
for (const newRoot of equivalentRoots) {
|
|
267
|
+
const funcKey = newRoot.function
|
|
268
|
+
? `${newRoot.function.name}::${newRoot.function.filePath}`
|
|
269
|
+
: '__self__';
|
|
270
|
+
const newIdx = extractSignatureIndex(newRoot.schemaRootPath);
|
|
271
|
+
if (newIdx !== undefined) {
|
|
272
|
+
const existingIndices = existingIndicesByFunction.get(funcKey);
|
|
273
|
+
if (existingIndices && existingIndices.size > 0) {
|
|
274
|
+
// If this function already has signature indices, check for conflict
|
|
275
|
+
if (!existingIndices.has(newIdx)) {
|
|
276
|
+
// Conflict: entry has indices like [1] but we want to add [2]
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return true;
|
|
284
|
+
});
|
|
180
285
|
}
|
|
181
286
|
}
|
|
182
287
|
if (!equivalentSchemaPathsEntry) {
|
|
288
|
+
// Before creating a new entry, filter out roots that have conflicting
|
|
289
|
+
// signature indices from the same function. An entry should never contain
|
|
290
|
+
// roots with different signature indices from the same function.
|
|
291
|
+
// This prevents the bug where signature[1], signature[2], signature[4]
|
|
292
|
+
// all get merged together due to incorrect sourceEquivalencies.
|
|
293
|
+
let filteredRoots = equivalentRoots;
|
|
294
|
+
if (newRootSignatureIndices.size > 1) {
|
|
295
|
+
// There are multiple signature indices - we need to filter to keep only
|
|
296
|
+
// one consistent set. We'll keep the roots that match the PRIMARY index
|
|
297
|
+
// (the first signature index we encounter from self, or the lowest index).
|
|
298
|
+
// First, determine the primary index - prefer the self root's index
|
|
299
|
+
let primaryIndex;
|
|
300
|
+
for (const root of equivalentRoots) {
|
|
301
|
+
if (!root.function) {
|
|
302
|
+
// This is a self root
|
|
303
|
+
const idx = extractSignatureIndex(root.schemaRootPath);
|
|
304
|
+
if (idx !== undefined) {
|
|
305
|
+
primaryIndex = idx;
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
// If no self root has a signature index, use the lowest index
|
|
311
|
+
if (primaryIndex === undefined) {
|
|
312
|
+
primaryIndex = Math.min(...newRootSignatureIndices);
|
|
313
|
+
}
|
|
314
|
+
// Filter roots: keep if no signature index OR signature index matches primary
|
|
315
|
+
filteredRoots = equivalentRoots.filter((root) => {
|
|
316
|
+
const idx = extractSignatureIndex(root.schemaRootPath);
|
|
317
|
+
return idx === undefined || idx === primaryIndex;
|
|
318
|
+
});
|
|
319
|
+
}
|
|
183
320
|
equivalentSchemaPathsEntry = {
|
|
184
|
-
equivalentRoots,
|
|
321
|
+
equivalentRoots: filteredRoots,
|
|
185
322
|
equivalentPostfixes: {},
|
|
186
323
|
};
|
|
187
324
|
equivalentSchemaPaths.push(equivalentSchemaPathsEntry);
|
|
@@ -189,10 +326,16 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
189
326
|
else {
|
|
190
327
|
equivalentSchemaPathsEntry.equivalentRoots.push(...equivalentRoots);
|
|
191
328
|
}
|
|
329
|
+
// Deduplicate roots using a Set for O(n) instead of O(n²)
|
|
330
|
+
const seenRoots = new Set();
|
|
192
331
|
equivalentSchemaPathsEntry.equivalentRoots =
|
|
193
|
-
equivalentSchemaPathsEntry.equivalentRoots.filter((er
|
|
194
|
-
|
|
195
|
-
|
|
332
|
+
equivalentSchemaPathsEntry.equivalentRoots.filter((er) => {
|
|
333
|
+
const key = er.schemaRootPath + '::' + (er.function?.name ?? '');
|
|
334
|
+
if (seenRoots.has(key))
|
|
335
|
+
return false;
|
|
336
|
+
seenRoots.add(key);
|
|
337
|
+
return true;
|
|
338
|
+
});
|
|
196
339
|
return equivalentSchemaPathsEntry;
|
|
197
340
|
};
|
|
198
341
|
// Helper to extract function name from a path that starts with a function call.
|
|
@@ -321,6 +464,25 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
321
464
|
}
|
|
322
465
|
allPaths.push(...derivedBasePaths);
|
|
323
466
|
const entry = findOrCreateEquivalentSchemaPathsEntry(allPaths);
|
|
467
|
+
// Trace equivalency gathering - helps debug why paths may not be connected
|
|
468
|
+
if (allPaths.length > 1) {
|
|
469
|
+
transformationTracer.operation(rootScopeName, {
|
|
470
|
+
operation: 'gatherEquivalency',
|
|
471
|
+
stage: 'gathering',
|
|
472
|
+
path: translatedPath,
|
|
473
|
+
context: {
|
|
474
|
+
sourceFunction: functionName,
|
|
475
|
+
equivalentPaths: allPaths.map((p) => ({
|
|
476
|
+
path: p.path,
|
|
477
|
+
function: p.functionName,
|
|
478
|
+
})),
|
|
479
|
+
equivalentRoots: entry.equivalentRoots.map((r) => ({
|
|
480
|
+
path: r.schemaRootPath,
|
|
481
|
+
function: r.function?.name,
|
|
482
|
+
})),
|
|
483
|
+
},
|
|
484
|
+
});
|
|
485
|
+
}
|
|
324
486
|
for (const equivalentRoot of entry.equivalentRoots) {
|
|
325
487
|
const dataStructures = equivalentRoot.function &&
|
|
326
488
|
equivalentRoot.function.name !== rootScopeName
|
|
@@ -419,13 +581,27 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
419
581
|
else {
|
|
420
582
|
// Regular exact match - use the standard postfix logic
|
|
421
583
|
const postfix = joinParenthesesAndArrays(schemaPathParts.slice(matchedUpToIndex));
|
|
422
|
-
entry.equivalentPostfixes[postfix]
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
584
|
+
const previousValue = entry.equivalentPostfixes[postfix];
|
|
585
|
+
const newValue = schema[schemaPath];
|
|
586
|
+
entry.equivalentPostfixes[postfix] = previousValue
|
|
587
|
+
? bestValueFromOptions([previousValue, newValue])
|
|
588
|
+
: newValue;
|
|
589
|
+
// Trace postfix gathering - shows where type info comes from
|
|
590
|
+
if (entry.equivalentPostfixes[postfix] !== previousValue) {
|
|
591
|
+
transformationTracer.operation(rootScopeName, {
|
|
592
|
+
operation: 'gatherPostfix',
|
|
593
|
+
stage: 'gathering',
|
|
594
|
+
path: postfix || '(root)',
|
|
595
|
+
before: previousValue,
|
|
596
|
+
after: entry.equivalentPostfixes[postfix],
|
|
597
|
+
context: {
|
|
598
|
+
sourceSchemaPath: schemaPath,
|
|
599
|
+
sourceFunction: equivalentRoot.function?.name || rootScopeName,
|
|
600
|
+
equivalentRootPath: equivalentRoot.schemaRootPath,
|
|
601
|
+
rawValue: newValue,
|
|
602
|
+
},
|
|
603
|
+
});
|
|
604
|
+
}
|
|
429
605
|
}
|
|
430
606
|
}
|
|
431
607
|
}
|
|
@@ -474,12 +650,13 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
474
650
|
continue;
|
|
475
651
|
}
|
|
476
652
|
const postfix = joinParenthesesAndArrays(schemaPathParts.slice(basePathParts.length));
|
|
477
|
-
|
|
653
|
+
const newValue = entry.equivalentPostfixes[postfix]
|
|
478
654
|
? bestValueFromOptions([
|
|
479
655
|
entry.equivalentPostfixes[postfix],
|
|
480
656
|
dataStructure.returnValueSchema[schemaPath],
|
|
481
657
|
])
|
|
482
658
|
: dataStructure.returnValueSchema[schemaPath];
|
|
659
|
+
entry.equivalentPostfixes[postfix] = newValue;
|
|
483
660
|
}
|
|
484
661
|
}
|
|
485
662
|
}
|
|
@@ -518,6 +695,8 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
518
695
|
}
|
|
519
696
|
const findEquivalentSchemaPathEntry = (schemaSubPath, equivalentRootFunction) => {
|
|
520
697
|
let postfix;
|
|
698
|
+
// Get the signature index we're looking for (if any)
|
|
699
|
+
const lookingForSignatureIndex = extractSignatureIndex(schemaSubPath);
|
|
521
700
|
const equivalentEntry = mergedEquivalentSchemaPaths.find((esp) => esp.equivalentRoots.some((er) => {
|
|
522
701
|
if ((schemaSubPath.startsWith('returnValue') ||
|
|
523
702
|
schemaSubPath.startsWith('signature[')) &&
|
|
@@ -526,6 +705,26 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
526
705
|
return false;
|
|
527
706
|
}
|
|
528
707
|
if (schemaSubPath === er.schemaRootPath) {
|
|
708
|
+
// Additional check: if we're looking for a signature path, make sure
|
|
709
|
+
// the entry doesn't already have DIFFERENT signature indices.
|
|
710
|
+
// This prevents entries with signature[1], signature[2], signature[4]
|
|
711
|
+
// from all being merged together.
|
|
712
|
+
if (lookingForSignatureIndex !== undefined) {
|
|
713
|
+
const hasConflictingSignatureIndex = esp.equivalentRoots.some((otherRoot) => {
|
|
714
|
+
// Only check roots from the same function
|
|
715
|
+
if (otherRoot.function?.name !== equivalentRootFunction?.name ||
|
|
716
|
+
otherRoot.function?.filePath !==
|
|
717
|
+
equivalentRootFunction?.filePath) {
|
|
718
|
+
return false;
|
|
719
|
+
}
|
|
720
|
+
const otherIndex = extractSignatureIndex(otherRoot.schemaRootPath);
|
|
721
|
+
return (otherIndex !== undefined &&
|
|
722
|
+
otherIndex !== lookingForSignatureIndex);
|
|
723
|
+
});
|
|
724
|
+
if (hasConflictingSignatureIndex) {
|
|
725
|
+
return false;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
529
728
|
postfix = er.postfix;
|
|
530
729
|
return true;
|
|
531
730
|
}
|
|
@@ -612,7 +811,42 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
612
811
|
}
|
|
613
812
|
equivalentSchemaPaths = mergeAllEquivalentSchemaPaths();
|
|
614
813
|
for (const esp of equivalentSchemaPaths) {
|
|
615
|
-
|
|
814
|
+
// Pre-compute which postfixes have children to avoid O(n²) lookups in the inner loop.
|
|
815
|
+
// A postfix "has children" if there are other postfixes that extend it.
|
|
816
|
+
const postfixesWithChildren = new Set();
|
|
817
|
+
const postfixKeys = Object.keys(esp.equivalentPostfixes);
|
|
818
|
+
// Check for empty postfix having children (any other postfixes exist)
|
|
819
|
+
if (postfixKeys.length > 1 && '' in esp.equivalentPostfixes) {
|
|
820
|
+
postfixesWithChildren.add('');
|
|
821
|
+
}
|
|
822
|
+
// Check for array element postfixes having children using a prefix set.
|
|
823
|
+
// This avoids O(n²) scans across large postfix lists.
|
|
824
|
+
// e.g., 'currentEntities[]' has children if a path like 'currentEntities[].sha' exists.
|
|
825
|
+
const postfixPrefixSet = new Set();
|
|
826
|
+
for (const postfixPath of postfixKeys) {
|
|
827
|
+
if (!postfixPath)
|
|
828
|
+
continue;
|
|
829
|
+
const parts = splitOutsideParenthesesAndArrays(postfixPath);
|
|
830
|
+
for (let i = 1; i < parts.length; i++) {
|
|
831
|
+
postfixPrefixSet.add(joinParenthesesAndArrays(parts.slice(0, i)));
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
for (const postfixPath of postfixKeys) {
|
|
835
|
+
if (postfixPath.endsWith('[]') && postfixPrefixSet.has(postfixPath)) {
|
|
836
|
+
postfixesWithChildren.add(postfixPath);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
// Deduplicate equivalentRoots that would write to the same schema paths.
|
|
840
|
+
// Roots with the same (function, schemaRootPath, postfix) are redundant.
|
|
841
|
+
const seenRootKeys = new Set();
|
|
842
|
+
const uniqueRoots = esp.equivalentRoots.filter((root) => {
|
|
843
|
+
const key = `${root.function?.filePath ?? ''}::${root.function?.name ?? ''}::${root.schemaRootPath}::${root.postfix ?? ''}`;
|
|
844
|
+
if (seenRootKeys.has(key))
|
|
845
|
+
return false;
|
|
846
|
+
seenRootKeys.add(key);
|
|
847
|
+
return true;
|
|
848
|
+
});
|
|
849
|
+
for (const equivalentRoot of uniqueRoots) {
|
|
616
850
|
let merged;
|
|
617
851
|
if (equivalentRoot.function) {
|
|
618
852
|
merged = findOrCreateDependentSchemas(equivalentRoot.function);
|
|
@@ -628,9 +862,21 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
628
862
|
for (const [postfixPath, postfixValue] of Object.entries(esp.equivalentPostfixes)) {
|
|
629
863
|
let relevantPostfix = postfixPath;
|
|
630
864
|
if (equivalentRoot.postfix) {
|
|
865
|
+
// Check if postfixPath starts with equivalentRoot.postfix at a path boundary.
|
|
866
|
+
// Must ensure exact path part match - "entityCode" should NOT match "entity" prefix.
|
|
867
|
+
// Valid: "entity.foo" starts with "entity" (boundary at '.')
|
|
868
|
+
// Valid: "entity[0]" starts with "entity" (boundary at '[')
|
|
869
|
+
// Invalid: "entityCode" starts with "entity" (no boundary, different property)
|
|
631
870
|
if (!postfixPath.startsWith(equivalentRoot.postfix)) {
|
|
632
871
|
continue;
|
|
633
872
|
}
|
|
873
|
+
// Additional check: ensure the match is at a path boundary
|
|
874
|
+
const nextChar = postfixPath[equivalentRoot.postfix.length];
|
|
875
|
+
if (nextChar !== undefined && nextChar !== '.' && nextChar !== '[') {
|
|
876
|
+
// The postfixPath continues with more characters that aren't a path separator.
|
|
877
|
+
// This means "entity" matched "entityCode" which is wrong - they're different properties.
|
|
878
|
+
continue;
|
|
879
|
+
}
|
|
634
880
|
const postFixPathParts = splitOutsideParenthesesAndArrays(postfixPath);
|
|
635
881
|
const equivalentRootPostFixParts = splitOutsideParenthesesAndArrays(equivalentRoot.postfix);
|
|
636
882
|
relevantPostfix = joinParenthesesAndArrays(postFixPathParts.slice(equivalentRootPostFixParts.length));
|
|
@@ -639,9 +885,81 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
639
885
|
equivalentRoot.schemaRootPath,
|
|
640
886
|
relevantPostfix,
|
|
641
887
|
]);
|
|
888
|
+
// Skip paths that would go through a primitive type
|
|
889
|
+
// e.g., if schema has 'entities[].scenarioCount': 'number', skip 'entities[].scenarioCount.sha'
|
|
890
|
+
if (wouldGoThroughPrimitive(newSchemaPath, schema)) {
|
|
891
|
+
transformationTracer.operation(rootScopeName, {
|
|
892
|
+
operation: 'skipPrimitivePath',
|
|
893
|
+
stage: 'merged',
|
|
894
|
+
path: newSchemaPath,
|
|
895
|
+
context: {
|
|
896
|
+
reason: 'would go through primitive type',
|
|
897
|
+
postfixValue,
|
|
898
|
+
},
|
|
899
|
+
});
|
|
900
|
+
continue;
|
|
901
|
+
}
|
|
902
|
+
// Skip setting primitive type when there are child postfixes that indicate structure.
|
|
903
|
+
// This prevents downgrading an object/array element to a primitive type.
|
|
904
|
+
// Uses pre-computed postfixesWithChildren Set for O(1) lookup instead of O(n) iteration.
|
|
905
|
+
const hasChildPostfixes = (relevantPostfix === '' || relevantPostfix.endsWith('[]')) &&
|
|
906
|
+
postfixesWithChildren.has(postfixPath);
|
|
907
|
+
if (PRIMITIVE_TYPES.has(postfixValue) && hasChildPostfixes) {
|
|
908
|
+
continue;
|
|
909
|
+
}
|
|
910
|
+
// Don't overwrite a more specific type with a less specific one
|
|
911
|
+
// This can happen when nested roots share entries with their parent roots
|
|
912
|
+
const existingType = schema[newSchemaPath];
|
|
913
|
+
if (existingType) {
|
|
914
|
+
// Don't overwrite a primitive type with 'object' or 'array'
|
|
915
|
+
// e.g., if schema has 'entities[].scenarioCount': 'number', don't overwrite with 'object'
|
|
916
|
+
if (PRIMITIVE_TYPES.has(existingType) &&
|
|
917
|
+
(postfixValue === 'object' || postfixValue === 'array')) {
|
|
918
|
+
transformationTracer.operation(rootScopeName, {
|
|
919
|
+
operation: 'skipTypeDowngrade',
|
|
920
|
+
stage: 'merged',
|
|
921
|
+
path: newSchemaPath,
|
|
922
|
+
context: {
|
|
923
|
+
reason: 'would overwrite primitive with object/array',
|
|
924
|
+
existingType,
|
|
925
|
+
newType: postfixValue,
|
|
926
|
+
},
|
|
927
|
+
});
|
|
928
|
+
continue;
|
|
929
|
+
}
|
|
930
|
+
// Don't overwrite a complex/union type with a primitive
|
|
931
|
+
// e.g., if schema has 'scenarios[]': 'Scenario | null', don't overwrite with 'string'
|
|
932
|
+
if (!PRIMITIVE_TYPES.has(existingType) &&
|
|
933
|
+
PRIMITIVE_TYPES.has(postfixValue)) {
|
|
934
|
+
transformationTracer.operation(rootScopeName, {
|
|
935
|
+
operation: 'skipTypeDowngrade',
|
|
936
|
+
stage: 'merged',
|
|
937
|
+
path: newSchemaPath,
|
|
938
|
+
context: {
|
|
939
|
+
reason: 'would overwrite complex type with primitive',
|
|
940
|
+
existingType,
|
|
941
|
+
newType: postfixValue,
|
|
942
|
+
},
|
|
943
|
+
});
|
|
944
|
+
continue;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
// Log the successful postfix merge
|
|
948
|
+
transformationTracer.operation(rootScopeName, {
|
|
949
|
+
operation: 'mergePostfix',
|
|
950
|
+
stage: 'merged',
|
|
951
|
+
path: newSchemaPath,
|
|
952
|
+
before: existingType,
|
|
953
|
+
after: postfixValue,
|
|
954
|
+
context: {
|
|
955
|
+
schemaRootPath: equivalentRoot.schemaRootPath,
|
|
956
|
+
postfix: relevantPostfix,
|
|
957
|
+
dependency: equivalentRoot.function?.name,
|
|
958
|
+
},
|
|
959
|
+
});
|
|
642
960
|
schema[newSchemaPath] = postfixValue;
|
|
643
961
|
}
|
|
644
|
-
cleanSchema(schema);
|
|
962
|
+
cleanSchema(schema, { stage: 'afterMergePostfix' });
|
|
645
963
|
}
|
|
646
964
|
}
|
|
647
965
|
// Propagate equivalency-derived attributes to generic function call variants.
|
|
@@ -740,6 +1058,14 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
740
1058
|
// e.g., returnValue[].label -> getOptions().functionCallReturnValue[].label
|
|
741
1059
|
normalizedPath = path.replace(/^returnValue/, `${dependency.name}().functionCallReturnValue`);
|
|
742
1060
|
}
|
|
1061
|
+
transformationTracer.operation(rootScopeName, {
|
|
1062
|
+
operation: 'normalizeReturnValuePath',
|
|
1063
|
+
stage: 'merged',
|
|
1064
|
+
path: normalizedPath,
|
|
1065
|
+
before: path,
|
|
1066
|
+
after: normalizedPath,
|
|
1067
|
+
context: { dependency: dependency.name, value },
|
|
1068
|
+
});
|
|
743
1069
|
depSchema.returnValueSchema[normalizedPath] = value;
|
|
744
1070
|
}
|
|
745
1071
|
// Now copy paths from the source schema (dependencySchemas)
|
|
@@ -806,7 +1132,10 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
806
1132
|
}
|
|
807
1133
|
}
|
|
808
1134
|
}
|
|
809
|
-
cleanSchema(depSchema.returnValueSchema
|
|
1135
|
+
cleanSchema(depSchema.returnValueSchema, {
|
|
1136
|
+
stage: 'afterMockedDependencyMerge',
|
|
1137
|
+
dependency: dependency.name,
|
|
1138
|
+
});
|
|
810
1139
|
// Pull signature requirements from downstream functions into the mocked return value.
|
|
811
1140
|
// When a mocked function's return flows into another function's signature (via usageEquivalencies),
|
|
812
1141
|
// we need to include that function's signature requirements in the mock.
|
|
@@ -871,7 +1200,10 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
871
1200
|
}
|
|
872
1201
|
}
|
|
873
1202
|
}
|
|
874
|
-
cleanSchema(depSchema.returnValueSchema
|
|
1203
|
+
cleanSchema(depSchema.returnValueSchema, {
|
|
1204
|
+
stage: 'afterSignatureRequirementsMerge',
|
|
1205
|
+
dependency: dependency.name,
|
|
1206
|
+
});
|
|
875
1207
|
}
|
|
876
1208
|
// Process the input dependencySchemas FIRST (before child dependentAnalyses).
|
|
877
1209
|
// This ensures the parent entity's direct usage of dependencies takes precedence.
|
|
@@ -907,7 +1239,38 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
907
1239
|
// from the copied schema. Without this, method call paths on primitives like
|
|
908
1240
|
// "projectSlug.replace(...)" would cause convertDotNotation to create nested
|
|
909
1241
|
// object structures instead of preserving the primitive type.
|
|
910
|
-
cleanSchema(depSchema.returnValueSchema
|
|
1242
|
+
cleanSchema(depSchema.returnValueSchema, {
|
|
1243
|
+
stage: 'afterDependencySchemaCopy',
|
|
1244
|
+
filePath,
|
|
1245
|
+
dependency: name,
|
|
1246
|
+
});
|
|
1247
|
+
}
|
|
1248
|
+
// TYPE REFINEMENT: Check if dependentAnalyses has a more specific type for this dependency.
|
|
1249
|
+
// When a parent passes `entity.filePath` (string | undefined) to a child component
|
|
1250
|
+
// that requires `filePath: string`, we should use the child's more specific type.
|
|
1251
|
+
// This prevents mock data from having undefined values for required props.
|
|
1252
|
+
//
|
|
1253
|
+
// This runs REGARDLESS of whether equivalencies already processed the schema,
|
|
1254
|
+
// because equivalencies copy the parent's type (string | undefined), not the child's
|
|
1255
|
+
// required type (string).
|
|
1256
|
+
const depSchema = findOrCreateDependentSchemas({ filePath, name });
|
|
1257
|
+
const childAnalysis = dependentAnalyses[filePath]?.[name];
|
|
1258
|
+
const childSignatureSchema = childAnalysis?.metadata?.mergedDataStructure?.signatureSchema;
|
|
1259
|
+
if (childSignatureSchema) {
|
|
1260
|
+
for (const path in depSchema.signatureSchema) {
|
|
1261
|
+
const parentType = depSchema.signatureSchema[path];
|
|
1262
|
+
const childType = childSignatureSchema[path];
|
|
1263
|
+
if (parentType && childType) {
|
|
1264
|
+
// Check if parent has optional type and child has required type
|
|
1265
|
+
const parentIsOptional = parentType.includes('| undefined') ||
|
|
1266
|
+
parentType.includes('| null');
|
|
1267
|
+
const childIsOptional = childType.includes('| undefined') || childType.includes('| null');
|
|
1268
|
+
// If child requires a more specific type (not optional), use it
|
|
1269
|
+
if (parentIsOptional && !childIsOptional) {
|
|
1270
|
+
depSchema.signatureSchema[path] = childType;
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
911
1274
|
}
|
|
912
1275
|
// For functions with multiple different type parameters, also create separate entries
|
|
913
1276
|
// for each type-parameterized variant. This allows gatherDataForMocks to look up
|
|
@@ -939,7 +1302,12 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
939
1302
|
srcSchema.returnValueSchema[path];
|
|
940
1303
|
}
|
|
941
1304
|
}
|
|
942
|
-
cleanSchema(variantSchema.returnValueSchema
|
|
1305
|
+
cleanSchema(variantSchema.returnValueSchema, {
|
|
1306
|
+
stage: 'afterTypeVariantCopy',
|
|
1307
|
+
filePath,
|
|
1308
|
+
dependency: name,
|
|
1309
|
+
variant,
|
|
1310
|
+
});
|
|
943
1311
|
}
|
|
944
1312
|
}
|
|
945
1313
|
}
|
|
@@ -990,8 +1358,8 @@ export default function mergeInDependentDataStructure({ importedExports, depende
|
|
|
990
1358
|
// Merge in the nested dependency schemas
|
|
991
1359
|
for (const path in nestedDepSchema.returnValueSchema) {
|
|
992
1360
|
if (!(path in targetDepSchema.returnValueSchema)) {
|
|
993
|
-
|
|
994
|
-
|
|
1361
|
+
const value = nestedDepSchema.returnValueSchema[path];
|
|
1362
|
+
targetDepSchema.returnValueSchema[path] = value;
|
|
995
1363
|
}
|
|
996
1364
|
}
|
|
997
1365
|
for (const path in nestedDepSchema.signatureSchema) {
|