@codeyam/codeyam-cli 0.1.0-staging.596f0eb → 0.1.0-staging.76566f9
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 +2 -1
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +2 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +22 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.ts +23 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +401 -106
- package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +60 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +734 -45
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +2 -1
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +715 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +233 -75
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +19 -1
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +34 -1
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +23 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.ts +98 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +34 -1
- package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +236 -24
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +18 -1
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarioData.ts +41 -0
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +37 -4
- package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +5 -0
- package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +213 -12
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +36 -25
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +114 -11
- package/analyzer-template/packages/ai/src/lib/getConditionalUsagesFromCode.ts +143 -31
- package/analyzer-template/packages/ai/src/lib/guessScenarioDataFromDescription.ts +8 -2
- package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +7 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +42 -2
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.ts +38 -2
- package/analyzer-template/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.ts +28 -2
- package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +5 -0
- package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +8 -1
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +127 -43
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +158 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +405 -45
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.ts +1 -1
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +260 -133
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +10 -5
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +77 -83
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +2 -5
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +196 -86
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts +15 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts.map +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js +31 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js.map +1 -0
- package/analyzer-template/packages/aws/package.json +1 -1
- package/analyzer-template/packages/aws/s3/index.ts +1 -0
- package/analyzer-template/packages/aws/src/lib/s3/checkS3ObjectExists.ts +47 -0
- package/analyzer-template/packages/database/src/lib/kysely/db.ts +4 -4
- package/analyzer-template/packages/database/src/lib/kysely/tableRelations.ts +2 -2
- package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +20 -9
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.ts +9 -4
- package/analyzer-template/packages/generate/src/lib/deepMerge.ts +26 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts +2 -2
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +2 -2
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tableRelations.d.ts +2 -2
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts +8 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +14 -7
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js +27 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.d.ts +4 -3
- package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.js +1 -0
- package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +31 -1
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts +51 -1
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.js +21 -1
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +48 -0
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
- package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
- package/analyzer-template/packages/types/index.ts +8 -0
- package/analyzer-template/packages/types/src/types/Analysis.ts +32 -1
- package/analyzer-template/packages/types/src/types/Scenario.ts +75 -6
- package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +49 -0
- package/analyzer-template/packages/ui-components/src/components/ScenarioDetailInteractiveView.tsx +23 -7
- package/analyzer-template/packages/utils/dist/types/index.d.ts +4 -3
- package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/index.js +1 -0
- package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +31 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts +51 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.js +21 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.js.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +48 -0
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
- package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
- package/analyzer-template/packages/utils/src/lib/lightweightEntityExtractor.ts +27 -0
- package/analyzer-template/playwright/takeElementScreenshot.ts +26 -11
- package/analyzer-template/playwright/takeScreenshot.ts +9 -7
- package/analyzer-template/project/constructMockCode.ts +286 -84
- package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +77 -37
- package/analyzer-template/project/reconcileMockDataKeys.ts +5 -2
- package/analyzer-template/project/runMultiScenarioServer.ts +11 -10
- package/analyzer-template/project/serverOnlyModules.ts +71 -23
- package/analyzer-template/project/start.ts +10 -0
- package/analyzer-template/project/startScenarioCapture.ts +73 -41
- package/analyzer-template/project/writeMockDataTsx.ts +115 -54
- package/analyzer-template/project/writeScenarioComponents.ts +571 -162
- package/analyzer-template/project/writeSimpleRoot.ts +11 -13
- package/background/src/lib/virtualized/project/constructMockCode.js +265 -75
- package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +67 -32
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +5 -2
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
- package/background/src/lib/virtualized/project/runMultiScenarioServer.js +11 -9
- package/background/src/lib/virtualized/project/runMultiScenarioServer.js.map +1 -1
- package/background/src/lib/virtualized/project/serverOnlyModules.js +62 -25
- package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -1
- package/background/src/lib/virtualized/project/start.js +6 -0
- package/background/src/lib/virtualized/project/start.js.map +1 -1
- package/background/src/lib/virtualized/project/startScenarioCapture.js +54 -31
- package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/writeMockDataTsx.js +106 -46
- package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioComponents.js +399 -106
- package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
- package/background/src/lib/virtualized/project/writeSimpleRoot.js +11 -11
- package/background/src/lib/virtualized/project/writeSimpleRoot.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/commands/debug.js +14 -2
- package/codeyam-cli/src/commands/debug.js.map +1 -1
- package/codeyam-cli/src/commands/recapture.js +215 -0
- package/codeyam-cli/src/commands/recapture.js.map +1 -0
- package/codeyam-cli/src/commands/report.js +26 -23
- package/codeyam-cli/src/commands/report.js.map +1 -1
- package/codeyam-cli/src/utils/backgroundServer.js +2 -2
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/generateReport.js +252 -106
- package/codeyam-cli/src/utils/generateReport.js.map +1 -1
- package/codeyam-cli/src/utils/install-skills.js +2 -2
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/queue/__tests__/manager.test.js +38 -0
- package/codeyam-cli/src/utils/queue/__tests__/manager.test.js.map +1 -1
- package/codeyam-cli/src/utils/queue/job.js +140 -16
- package/codeyam-cli/src/utils/queue/job.js.map +1 -1
- package/codeyam-cli/src/utils/queue/manager.js +19 -7
- package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
- package/codeyam-cli/src/utils/queue/persistence.js.map +1 -1
- package/codeyam-cli/src/webserver/app/lib/database.js +47 -0
- package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
- package/codeyam-cli/src/webserver/app/lib/dbNotifier.js.map +1 -1
- package/codeyam-cli/src/webserver/backgroundServer.js +5 -10
- package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/webserver/bootstrap.js +9 -0
- package/codeyam-cli/src/webserver/bootstrap.js.map +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-wXL1Z2Aq.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-efWKDYMr.js → EntityTypeBadge-CzGX-miz.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-CXFKsCOD.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-D-9pXIaY.js +25 -0
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-CBQPrpT0.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/LoadingDots-D1CdlbrV.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/LogViewer-wDPcZNKx.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-4lcOlid-.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-BfmDgXxG.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-CUxUNEEC.js +15 -0
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-COPstp9J.js → TruncatedFilePath-6J7zDUD5.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/_index-DHImXdXq.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-CVP_WGQ3.js +32 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.link-scenario-value-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.update-key-attributes-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.update-valid-values-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/chevron-down-BYimnrHg.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/chunk-JMJ3UQ3L-BambyYE_.js +51 -0
- package/codeyam-cli/src/webserver/build/client/assets/circle-check-CaVsIRxt.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-CgUsG7ib.js +21 -0
- package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-CKnwPCDr.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-DW_hdGUc.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-Dt-SjPsw.js +23 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-DyB90fWk.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-D_3ero5o.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-CfLCUi9S.js +5 -0
- package/codeyam-cli/src/webserver/build/client/assets/entry.client-DKJyZfAY.js +29 -0
- package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-DAtOlaWE.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/files-ClR0d32A.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/git-D62Lxxmv.js +15 -0
- package/codeyam-cli/src/webserver/build/client/assets/globals-C9s7Lhdl.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-fmIEn3Bc.js +9 -0
- package/codeyam-cli/src/webserver/build/client/assets/index-BosqDOlH.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/index-CzNNiTkw.js +9 -0
- package/codeyam-cli/src/webserver/build/client/assets/keyAttributeCoverage-CTlFMihX.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/loader-circle-CNp9QFCX.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/manifest-0d27da29.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/preload-helper-ckwbz45p.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/root-B_wIKCIf.js +56 -0
- package/codeyam-cli/src/webserver/build/client/assets/scenarioStatus-B_8jpV3e.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/search-DDGjYAMJ.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/settings-DgTyB-Wg.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/simulations-CoNWGt0K.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-CBc5dE1s.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-BMIGFP-m.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/useInteractiveMode-Dk_FQqWJ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-3pmpUQB-.js → useLastLogLine-BqPPNjAl.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-DsJbgMY9.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useToast-DEyawJ8r.js → useToast-DWHcCcl1.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-CU58-Ttc.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-D35o2uae.js +175 -0
- package/codeyam-cli/src/webserver/build/server/index.js +1 -1
- package/codeyam-cli/src/webserver/build-info.json +5 -5
- package/codeyam-cli/src/webserver/devServer.js +1 -3
- package/codeyam-cli/src/webserver/devServer.js.map +1 -1
- package/codeyam-cli/templates/codeyam-setup-skill.md +138 -3
- package/codeyam-cli/templates/debug-codeyam.md +625 -0
- package/package.json +14 -14
- package/packages/ai/src/lib/analyzeScope.js +2 -0
- package/packages/ai/src/lib/analyzeScope.js.map +1 -1
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +16 -0
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js +16 -0
- package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/processExpression.js +305 -88
- package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +582 -41
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +2 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +454 -0
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +173 -55
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +16 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +30 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +20 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js +86 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +28 -2
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +179 -17
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +1 -1
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +6 -0
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +1 -1
- package/packages/ai/src/lib/generateChangesEntityScenarioData.js +41 -0
- package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateChangesEntityScenarios.js +37 -4
- package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateEntityDataStructure.js +4 -0
- package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
- package/packages/ai/src/lib/generateEntityKeyAttributes.js +176 -9
- package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarioData.js +29 -25
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarios.js +105 -9
- package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/getConditionalUsagesFromCode.js +84 -14
- package/packages/ai/src/lib/getConditionalUsagesFromCode.js.map +1 -1
- package/packages/ai/src/lib/guessScenarioDataFromDescription.js +2 -1
- package/packages/ai/src/lib/guessScenarioDataFromDescription.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +6 -0
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +38 -2
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js +38 -2
- package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js +16 -3
- package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js.map +1 -1
- package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js +4 -0
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +100 -23
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +125 -0
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +298 -45
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +201 -80
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +10 -5
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +55 -69
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +2 -5
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +171 -81
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
- package/packages/database/src/lib/kysely/db.js +2 -2
- package/packages/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
- package/packages/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
- package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
- package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
- package/packages/generate/src/lib/deepMerge.js +27 -1
- package/packages/generate/src/lib/deepMerge.js.map +1 -1
- package/packages/types/index.js +1 -0
- package/packages/types/index.js.map +1 -1
- package/packages/types/src/types/Scenario.js +21 -1
- package/packages/types/src/types/Scenario.js.map +1 -1
- package/packages/utils/src/lib/lightweightEntityExtractor.js +25 -0
- package/packages/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
- package/scripts/finalize-analyzer.cjs +3 -1
- package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js +0 -238
- package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js.map +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-CVbSvOjo.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-DcwcHyl5.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-WgwC1GfJ.js +0 -26
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-IEKom9O2.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/LogViewer-BYnfxbUG.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-_lBPJCzG.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-lHVhvsu_.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-d_TBk4GQ.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/_index-kGT7VUqj.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-DDGmhu7P.js +0 -7
- package/codeyam-cli/src/webserver/build/client/assets/chevron-down-n_HPRfM_.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/chunk-WWGJGFF6-CbVoyx1U.js +0 -26
- package/codeyam-cli/src/webserver/build/client/assets/circle-check-D1VOYveA.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-YR8jjAlu.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-B8vP3V_s.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-CN6aLCT1.js +0 -16
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-DA5Jeu2P.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-BTeitalf.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/entry.client-du6UEYD-.js +0 -13
- package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-BpjkhMoi.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-BQGvk4lJ.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/git-DVdYRT-I.js +0 -12
- package/codeyam-cli/src/webserver/build/client/assets/globals-CO-U8Bpo.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-XQCGvadH.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/index-DCG-vks0.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/loader-circle-GazdNeLl.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-0b694d28.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/root-D3tQP7hx.js +0 -16
- package/codeyam-cli/src/webserver/build/client/assets/search-CIY6XmtE.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/server-build-CMKNK2uU.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/settings-CoMDgElu.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/simulations-agkniXp2.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-B2VUcygF.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-EvdK-zXP.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-DGVHQEXD.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-CghkTkIL.js +0 -166
- package/codeyam-cli/templates/debug-command.md +0 -303
- /package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-CMKNK2uU.css → styles-CMKNK2uU.css} +0 -0
|
@@ -140,6 +140,10 @@ const ALLOWED_EQUIVALENCY_REASONS = new Set([
|
|
|
140
140
|
'propagated function call return sub-property equivalency',
|
|
141
141
|
'propagated parent-variable equivalency', // Added: propagate child scope equivalencies to parent scope when variable is defined in parent
|
|
142
142
|
'where was this function called from', // Added: tracks which scope called an external function
|
|
143
|
+
'MUI DataGrid renderCell params.row equivalency', // Added: links DataGrid renderCell params.row to rows array elements
|
|
144
|
+
'MUI Autocomplete getOptionLabel option equivalency', // Added: links Autocomplete getOptionLabel callback param to options array
|
|
145
|
+
'MUI Autocomplete renderOption option equivalency', // Added: links Autocomplete renderOption callback param to options array
|
|
146
|
+
'MUI Autocomplete option property equivalency', // Added: propagates property accesses from Autocomplete callbacks
|
|
143
147
|
]);
|
|
144
148
|
const SILENTLY_IGNORED_EQUIVALENCY_REASONS = new Set([
|
|
145
149
|
'signature of functionCall',
|
|
@@ -183,6 +187,9 @@ export class ScopeDataStructure {
|
|
|
183
187
|
// Index for O(1) lookup of external function calls by name
|
|
184
188
|
// Invalidated by setting to null; rebuilt lazily on next access
|
|
185
189
|
this.externalFunctionCallsIndex = null;
|
|
190
|
+
// Tracks internal functions that have been filtered out during captureCompleteSchema
|
|
191
|
+
// Prevents re-adding them via subsequent equivalency propagation (e.g., from getReturnValue)
|
|
192
|
+
this.filteredInternalFunctions = new Set();
|
|
186
193
|
// Debug tracer for selective path/scope tracing
|
|
187
194
|
// Enable via: CODEYAM_DEBUG=true CODEYAM_DEBUG_PATHS="user.*,signature" npm test
|
|
188
195
|
this.tracer = new DebugTracer({
|
|
@@ -301,6 +308,8 @@ export class ScopeDataStructure {
|
|
|
301
308
|
const efcName = this.pathManager.stripGenerics(efc.name);
|
|
302
309
|
for (const manager of this.equivalencyManagers) {
|
|
303
310
|
if (manager.internalFunctions.has(efcName)) {
|
|
311
|
+
// Track this so we don't re-add it via subsequent finalize calls
|
|
312
|
+
this.filteredInternalFunctions.add(efcName);
|
|
304
313
|
return false;
|
|
305
314
|
}
|
|
306
315
|
}
|
|
@@ -321,11 +330,42 @@ export class ScopeDataStructure {
|
|
|
321
330
|
});
|
|
322
331
|
entry.sourceCandidates = entry.sourceCandidates.filter((candidate) => {
|
|
323
332
|
const baseName = this.pathManager.stripGenerics(candidate.scopeNodeName);
|
|
333
|
+
// Check if this is a local variable path (doesn't contain function call pattern)
|
|
334
|
+
// Local variables like "surveys[]" or "items[]" are important for tracing data flow
|
|
335
|
+
// from parent to child components (e.g., surveys[] -> SurveyCard().signature[0].survey)
|
|
336
|
+
const isLocalVariablePath = !candidate.schemaPath.includes('()') &&
|
|
337
|
+
!candidate.schemaPath.startsWith('signature[') &&
|
|
338
|
+
!candidate.schemaPath.startsWith('returnValue');
|
|
324
339
|
return (validExternalFacingScopeNames.has(baseName) &&
|
|
325
340
|
(candidate.schemaPath.startsWith('signature[') ||
|
|
326
|
-
candidate.schemaPath.startsWith(baseName)
|
|
341
|
+
candidate.schemaPath.startsWith(baseName) ||
|
|
342
|
+
isLocalVariablePath) &&
|
|
327
343
|
!containsArrayMethod(candidate.schemaPath));
|
|
328
344
|
});
|
|
345
|
+
// If all sourceCandidates were filtered out (e.g., because they belonged to
|
|
346
|
+
// internal functions like useState), look for the highest-order intermediate
|
|
347
|
+
// that belongs to a valid external-facing scope
|
|
348
|
+
if (entry.sourceCandidates.length === 0 &&
|
|
349
|
+
Object.keys(entry.intermediatesOrder).length > 0) {
|
|
350
|
+
// Find intermediates that belong to valid external-facing scopes
|
|
351
|
+
const validIntermediates = Object.entries(entry.intermediatesOrder)
|
|
352
|
+
.filter(([pathId]) => {
|
|
353
|
+
const [scopeNodeName, schemaPath] = pathId.split('::');
|
|
354
|
+
if (!scopeNodeName || !schemaPath)
|
|
355
|
+
return false;
|
|
356
|
+
const baseName = this.pathManager.stripGenerics(scopeNodeName);
|
|
357
|
+
return (validExternalFacingScopeNames.has(baseName) &&
|
|
358
|
+
!containsArrayMethod(schemaPath));
|
|
359
|
+
})
|
|
360
|
+
.sort((a, b) => b[1] - a[1]); // Sort by order descending (highest first)
|
|
361
|
+
if (validIntermediates.length > 0) {
|
|
362
|
+
const [pathId] = validIntermediates[0];
|
|
363
|
+
const [scopeNodeName, schemaPath] = pathId.split('::');
|
|
364
|
+
if (scopeNodeName && schemaPath) {
|
|
365
|
+
entry.sourceCandidates.push({ scopeNodeName, schemaPath });
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
329
369
|
}
|
|
330
370
|
this.propagateSourceAndUsageEquivalencies(this.scopeNodes[this.scopeTreeManager.getRootName()]);
|
|
331
371
|
for (const externalFunctionCall of this.externalFunctionCalls) {
|
|
@@ -754,10 +794,31 @@ export class ScopeDataStructure {
|
|
|
754
794
|
const searchKey = getFunctionCallRoot(functionCallInfo.callSignature);
|
|
755
795
|
const existingFunctionCall = this.getExternalFunctionCallsIndex().get(searchKey);
|
|
756
796
|
if (existingFunctionCall) {
|
|
757
|
-
|
|
797
|
+
// Preserve per-call schemas BEFORE merging to enable per-variable mock data.
|
|
798
|
+
// This is critical for hooks like useFetcher<UserData>() vs useFetcher<ReportData>()
|
|
799
|
+
// where each call returns different typed data.
|
|
800
|
+
if (!existingFunctionCall.perCallSignatureSchemas) {
|
|
801
|
+
// First merge - save the existing call's schema
|
|
802
|
+
existingFunctionCall.perCallSignatureSchemas = {
|
|
803
|
+
[existingFunctionCall.callSignature]: {
|
|
804
|
+
...existingFunctionCall.schema,
|
|
805
|
+
},
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
// Save the new call's schema before it gets merged
|
|
809
|
+
existingFunctionCall.perCallSignatureSchemas[functionCallInfo.callSignature] = { ...functionCallInfo.schema };
|
|
810
|
+
// Merge schemas using selectBestValue to preserve specific types like 'null'
|
|
811
|
+
// over generic types like 'unknown'. This ensures ref variables detected
|
|
812
|
+
// earlier (marked as 'null') aren't overwritten by later 'unknown' values.
|
|
813
|
+
const mergedSchema = {
|
|
758
814
|
...existingFunctionCall.schema,
|
|
759
|
-
...functionCallInfo.schema,
|
|
760
815
|
};
|
|
816
|
+
for (const key in functionCallInfo.schema) {
|
|
817
|
+
const existingValue = existingFunctionCall.schema[key];
|
|
818
|
+
const newValue = functionCallInfo.schema[key];
|
|
819
|
+
mergedSchema[key] = selectBestValue(existingValue, newValue, newValue);
|
|
820
|
+
}
|
|
821
|
+
existingFunctionCall.schema = mergedSchema;
|
|
761
822
|
existingFunctionCall.equivalencies = {
|
|
762
823
|
...existingFunctionCall.equivalencies,
|
|
763
824
|
...functionCallInfo.equivalencies,
|
|
@@ -777,8 +838,13 @@ export class ScopeDataStructure {
|
|
|
777
838
|
const isExternal = !callingScopeNode.instantiatedVariables?.includes(functionCallInfoNameParts[0]) &&
|
|
778
839
|
!callingScopeNode.parentInstantiatedVariables?.includes(functionCallInfoNameParts[0]);
|
|
779
840
|
if (isExternal) {
|
|
780
|
-
this
|
|
781
|
-
|
|
841
|
+
// Check if this function was already filtered out as an internal function
|
|
842
|
+
// (e.g., useState was filtered in captureCompleteSchema but finalize is trying to re-add it)
|
|
843
|
+
const strippedName = this.pathManager.stripGenerics(functionCallInfo.name);
|
|
844
|
+
if (!this.filteredInternalFunctions.has(strippedName)) {
|
|
845
|
+
this.externalFunctionCalls.push(functionCallInfo);
|
|
846
|
+
this.invalidateExternalFunctionCallsIndex();
|
|
847
|
+
}
|
|
782
848
|
}
|
|
783
849
|
}
|
|
784
850
|
}
|
|
@@ -847,6 +913,17 @@ export class ScopeDataStructure {
|
|
|
847
913
|
const remainingKey = remainingSchemaPathParts.join('|');
|
|
848
914
|
const equivalentSchemaPath = equivalentSchemaPathMap.get(remainingKey);
|
|
849
915
|
if (equivalentSchemaPath) {
|
|
916
|
+
// Skip propagation when there's a structural mismatch:
|
|
917
|
+
// - schemaPath ends with [] (array element, represents an object)
|
|
918
|
+
// - equivalentSchemaPath doesn't end with [] (non-array prop, usually a scalar)
|
|
919
|
+
// This prevents incorrectly typing array elements as strings when they're
|
|
920
|
+
// equivalent to scalar props like JSX keys (e.g., workouts[] ↔ Card().key)
|
|
921
|
+
const schemaPathEndsWithArray = schemaPath.endsWith('[]');
|
|
922
|
+
const equivalentEndsWithArray = equivalentSchemaPath.endsWith('[]');
|
|
923
|
+
if (schemaPathEndsWithArray !== equivalentEndsWithArray) {
|
|
924
|
+
// Don't propagate between array element paths and non-array paths
|
|
925
|
+
continue;
|
|
926
|
+
}
|
|
850
927
|
const value1 = scopeNode.schema[schemaPath];
|
|
851
928
|
const value2 = equivalentScopeNode.schema[equivalentSchemaPath];
|
|
852
929
|
const bestValue = selectBestValue(value1, value2);
|
|
@@ -2133,7 +2210,12 @@ export class ScopeDataStructure {
|
|
|
2133
2210
|
return acc;
|
|
2134
2211
|
}, {});
|
|
2135
2212
|
}
|
|
2213
|
+
// CRITICAL: Set onlyEquivalencies to true to prevent database modifications
|
|
2214
|
+
// during this "getter" method. See comment in getFunctionSignature.
|
|
2215
|
+
const wasOnlyEquivalencies = this.onlyEquivalencies;
|
|
2216
|
+
this.onlyEquivalencies = true;
|
|
2136
2217
|
this.validateSchema(scopeNode, true, fillInUnknowns);
|
|
2218
|
+
this.onlyEquivalencies = wasOnlyEquivalencies;
|
|
2137
2219
|
const { schema } = scopeNode;
|
|
2138
2220
|
// For root scope, merge in external function call schemas
|
|
2139
2221
|
// This ensures that imported objects used as method call targets (like logger.error())
|
|
@@ -2230,11 +2312,12 @@ export class ScopeDataStructure {
|
|
|
2230
2312
|
return acc;
|
|
2231
2313
|
}, {});
|
|
2232
2314
|
const equivalencies = this.getEquivalencies(functionName);
|
|
2315
|
+
const scopeName = functionName ?? this.scopeTreeManager.getRootName();
|
|
2233
2316
|
for (const equivalenceKey in equivalencies ?? {}) {
|
|
2234
2317
|
for (const equivalenceValue of equivalencies[equivalenceKey]) {
|
|
2235
2318
|
const schemaPath = equivalenceValue.schemaPath;
|
|
2236
2319
|
if (schemaPath.startsWith('signature[') &&
|
|
2237
|
-
equivalenceValue.scopeNodeName ===
|
|
2320
|
+
equivalenceValue.scopeNodeName === scopeName &&
|
|
2238
2321
|
!signatureInSchema[schemaPath]) {
|
|
2239
2322
|
signatureInSchema[schemaPath] = 'unknown';
|
|
2240
2323
|
}
|
|
@@ -2242,9 +2325,60 @@ export class ScopeDataStructure {
|
|
|
2242
2325
|
}
|
|
2243
2326
|
const tempScopeNode = this.createTempScopeNode(functionName ?? this.scopeTreeManager.getRootName(), signatureInSchema, equivalencies);
|
|
2244
2327
|
this.validateSchema(tempScopeNode, true, fillInUnknowns);
|
|
2328
|
+
// After validateSchema has filled in types, propagate nested paths from
|
|
2329
|
+
// variables to their signature equivalents.
|
|
2330
|
+
// e.g., workouts[].activity_type -> signature[0].workouts[].activity_type
|
|
2331
|
+
//
|
|
2332
|
+
// Build a map of variable names that are equivalent to signature paths
|
|
2333
|
+
// e.g., { 'workouts': 'signature[0].workouts' }
|
|
2334
|
+
const variableToSignatureMap = {};
|
|
2335
|
+
for (const equivalenceKey in equivalencies ?? {}) {
|
|
2336
|
+
for (const equivalenceValue of equivalencies[equivalenceKey]) {
|
|
2337
|
+
const schemaPath = equivalenceValue.schemaPath;
|
|
2338
|
+
// Track which variables map to signature paths
|
|
2339
|
+
// equivalenceKey is the variable name (e.g., 'workouts')
|
|
2340
|
+
// schemaPath is where it comes from (e.g., 'signature[0].workouts')
|
|
2341
|
+
if (schemaPath.startsWith('signature[') &&
|
|
2342
|
+
equivalenceValue.scopeNodeName === scopeName) {
|
|
2343
|
+
variableToSignatureMap[equivalenceKey] = schemaPath;
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
// Propagate nested paths from variables to their signature equivalents
|
|
2348
|
+
// e.g., if workouts = signature[0].workouts, then workouts[].title becomes
|
|
2349
|
+
// signature[0].workouts[].title
|
|
2350
|
+
for (const schemaKey in schema) {
|
|
2351
|
+
// Skip keys that already start with signature[
|
|
2352
|
+
if (schemaKey.startsWith('signature['))
|
|
2353
|
+
continue;
|
|
2354
|
+
// Check if this key starts with a variable that maps to a signature path
|
|
2355
|
+
for (const [variableName, signaturePath] of Object.entries(variableToSignatureMap)) {
|
|
2356
|
+
// Check if schemaKey starts with variableName followed by a property accessor
|
|
2357
|
+
// e.g., 'workouts[]' starts with 'workouts'
|
|
2358
|
+
if (schemaKey === variableName ||
|
|
2359
|
+
schemaKey.startsWith(variableName + '.') ||
|
|
2360
|
+
schemaKey.startsWith(variableName + '[')) {
|
|
2361
|
+
// Transform the path: replace the variable prefix with the signature path
|
|
2362
|
+
const suffix = schemaKey.slice(variableName.length);
|
|
2363
|
+
const signatureKey = signaturePath + suffix;
|
|
2364
|
+
// Add to schema if not already present
|
|
2365
|
+
if (!tempScopeNode.schema[signatureKey]) {
|
|
2366
|
+
tempScopeNode.schema[signatureKey] = schema[schemaKey];
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2245
2371
|
return tempScopeNode.schema;
|
|
2246
2372
|
}
|
|
2247
2373
|
getReturnValue({ functionName, fillInUnknowns, }) {
|
|
2374
|
+
// Trigger finalization on all managers to apply any pending updates
|
|
2375
|
+
// (e.g., ref type propagation to external function call schemas)
|
|
2376
|
+
const rootScope = this.scopeNodes[this.scopeTreeManager.getRootName()];
|
|
2377
|
+
if (rootScope) {
|
|
2378
|
+
for (const manager of this.equivalencyManagers) {
|
|
2379
|
+
manager.finalize(rootScope, this);
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2248
2382
|
const scopeName = functionName ?? this.scopeTreeManager.getRootName();
|
|
2249
2383
|
const scopeNode = this.scopeNodes[scopeName];
|
|
2250
2384
|
let schema = {};
|
|
@@ -2255,7 +2389,8 @@ export class ScopeDataStructure {
|
|
|
2255
2389
|
});
|
|
2256
2390
|
}
|
|
2257
2391
|
else {
|
|
2258
|
-
|
|
2392
|
+
// Use getExternalFunctionCalls() which cleans cyScope from schemas
|
|
2393
|
+
for (const externalFunctionCall of this.getExternalFunctionCalls()) {
|
|
2259
2394
|
const functionNameParts = this.splitPath(functionName).map((p) => this.functionOrScopeName(p));
|
|
2260
2395
|
const nameParts = this.splitPath(externalFunctionCall.name).map((p) => this.functionOrScopeName(p));
|
|
2261
2396
|
if (functionNameParts.every((part, index) => part === nameParts[index])) {
|
|
@@ -2291,12 +2426,19 @@ export class ScopeDataStructure {
|
|
|
2291
2426
|
// Replace cyScope placeholders with actual callback text
|
|
2292
2427
|
const resolvedSchema = this.replaceCyScopePlaceholders(returnValueSchema);
|
|
2293
2428
|
const tempScopeNode = this.createTempScopeNode(scopeName, resolvedSchema);
|
|
2429
|
+
// CRITICAL: Set onlyEquivalencies to true to prevent database modifications
|
|
2430
|
+
// during this "getter" method. See comment in getFunctionSignature.
|
|
2431
|
+
const wasOnlyEquivalencies = this.onlyEquivalencies;
|
|
2432
|
+
this.onlyEquivalencies = true;
|
|
2294
2433
|
this.validateSchema(tempScopeNode, true, fillInUnknowns);
|
|
2434
|
+
this.onlyEquivalencies = wasOnlyEquivalencies;
|
|
2295
2435
|
return tempScopeNode.schema;
|
|
2296
2436
|
}
|
|
2297
2437
|
/**
|
|
2298
2438
|
* Replaces cyScope placeholder references (e.g., cyScope10()) in schema keys
|
|
2299
2439
|
* with the actual callback function text from the corresponding scope node.
|
|
2440
|
+
* If the scope text can't be found, uses a generic fallback to avoid leaking
|
|
2441
|
+
* internal cyScope names into stored data.
|
|
2300
2442
|
*/
|
|
2301
2443
|
replaceCyScopePlaceholders(schema) {
|
|
2302
2444
|
const cyScopePattern = /cyScope(\d+)\(\)/g;
|
|
@@ -2308,10 +2450,10 @@ export class ScopeDataStructure {
|
|
|
2308
2450
|
for (const match of matches) {
|
|
2309
2451
|
const cyScopeName = `cyScope${match[1]}`;
|
|
2310
2452
|
const scopeText = this.findCyScopeText(cyScopeName);
|
|
2311
|
-
if
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2453
|
+
// Always replace cyScope references - use actual text if available,
|
|
2454
|
+
// otherwise use a generic callback placeholder
|
|
2455
|
+
const replacement = scopeText || '() => {}';
|
|
2456
|
+
newKey = newKey.replace(match[0], replacement);
|
|
2315
2457
|
}
|
|
2316
2458
|
result[newKey] = value;
|
|
2317
2459
|
}
|
|
@@ -2399,7 +2541,12 @@ export class ScopeDataStructure {
|
|
|
2399
2541
|
return { ...acc, ...filterdSchema };
|
|
2400
2542
|
}, {});
|
|
2401
2543
|
const tempScopeNode = this.createTempScopeNode(scopeName ?? this.scopeTreeManager.getRootName(), relevantSchema);
|
|
2544
|
+
// CRITICAL: Set onlyEquivalencies to true to prevent database modifications
|
|
2545
|
+
// during this "getter" method. See comment in getFunctionSignature.
|
|
2546
|
+
const wasOnlyEquivalencies = this.onlyEquivalencies;
|
|
2547
|
+
this.onlyEquivalencies = true;
|
|
2402
2548
|
this.validateSchema(tempScopeNode, true, final);
|
|
2549
|
+
this.onlyEquivalencies = wasOnlyEquivalencies;
|
|
2403
2550
|
return {
|
|
2404
2551
|
name: variableName,
|
|
2405
2552
|
equivalentTo: equivalents,
|
|
@@ -2407,7 +2554,96 @@ export class ScopeDataStructure {
|
|
|
2407
2554
|
};
|
|
2408
2555
|
}
|
|
2409
2556
|
getExternalFunctionCalls() {
|
|
2410
|
-
|
|
2557
|
+
// Replace cyScope placeholders in all external function call data
|
|
2558
|
+
// This ensures call signatures and schema paths use actual callback text
|
|
2559
|
+
// instead of internal cyScope names, preventing mock data merge conflicts.
|
|
2560
|
+
return this.externalFunctionCalls.map((efc) => this.cleanCyScopeFromFunctionCallInfo(efc));
|
|
2561
|
+
}
|
|
2562
|
+
/**
|
|
2563
|
+
* Cleans cyScope placeholder references from a FunctionCallInfo.
|
|
2564
|
+
* Replaces cyScopeN() with the actual callback text in:
|
|
2565
|
+
* - callSignature
|
|
2566
|
+
* - allCallSignatures
|
|
2567
|
+
* - schema keys
|
|
2568
|
+
*/
|
|
2569
|
+
cleanCyScopeFromFunctionCallInfo(efc) {
|
|
2570
|
+
const cyScopePattern = /cyScope\d+\(\)/g;
|
|
2571
|
+
// Check if any cleaning is needed
|
|
2572
|
+
const hasCyScope = cyScopePattern.test(efc.callSignature) ||
|
|
2573
|
+
(efc.allCallSignatures &&
|
|
2574
|
+
efc.allCallSignatures.some((sig) => /cyScope\d+\(\)/.test(sig))) ||
|
|
2575
|
+
(efc.schema &&
|
|
2576
|
+
Object.keys(efc.schema).some((key) => /cyScope\d+\(\)/.test(key)));
|
|
2577
|
+
if (!hasCyScope) {
|
|
2578
|
+
return efc;
|
|
2579
|
+
}
|
|
2580
|
+
// Create cleaned copy
|
|
2581
|
+
const cleaned = { ...efc };
|
|
2582
|
+
// Clean callSignature
|
|
2583
|
+
cleaned.callSignature = this.replaceCyScopeInString(efc.callSignature);
|
|
2584
|
+
// Clean allCallSignatures
|
|
2585
|
+
if (efc.allCallSignatures) {
|
|
2586
|
+
cleaned.allCallSignatures = efc.allCallSignatures.map((sig) => this.replaceCyScopeInString(sig));
|
|
2587
|
+
}
|
|
2588
|
+
// Clean schema keys
|
|
2589
|
+
if (efc.schema) {
|
|
2590
|
+
cleaned.schema = this.replaceCyScopePlaceholders(efc.schema);
|
|
2591
|
+
}
|
|
2592
|
+
// Clean callSignatureToVariable keys
|
|
2593
|
+
if (efc.callSignatureToVariable) {
|
|
2594
|
+
cleaned.callSignatureToVariable = Object.entries(efc.callSignatureToVariable).reduce((acc, [key, value]) => {
|
|
2595
|
+
acc[this.replaceCyScopeInString(key)] = value;
|
|
2596
|
+
return acc;
|
|
2597
|
+
}, {});
|
|
2598
|
+
}
|
|
2599
|
+
return cleaned;
|
|
2600
|
+
}
|
|
2601
|
+
/**
|
|
2602
|
+
* Replaces cyScope placeholder references in a single string.
|
|
2603
|
+
* If the scope text can't be found, uses a generic fallback to avoid leaking
|
|
2604
|
+
* internal cyScope names into stored data.
|
|
2605
|
+
*
|
|
2606
|
+
* Handles two patterns:
|
|
2607
|
+
* 1. Function call style: cyScope7() - matched by cyScope(\d+)\(\)
|
|
2608
|
+
* 2. Scope name style: parentName____cyScopeXX or cyScopeXX - matched by (\w+____)?cyScope([0-9A-Fa-f]+)
|
|
2609
|
+
*/
|
|
2610
|
+
replaceCyScopeInString(str) {
|
|
2611
|
+
let result = str;
|
|
2612
|
+
// Pattern 1: Function call style - cyScope7()
|
|
2613
|
+
const functionCallPattern = /cyScope(\d+)\(\)/g;
|
|
2614
|
+
const functionCallMatches = [...str.matchAll(functionCallPattern)];
|
|
2615
|
+
for (const match of functionCallMatches) {
|
|
2616
|
+
const cyScopeName = `cyScope${match[1]}`;
|
|
2617
|
+
const scopeText = this.findCyScopeText(cyScopeName);
|
|
2618
|
+
// Always replace cyScope references - use actual text if available,
|
|
2619
|
+
// otherwise use a generic callback placeholder
|
|
2620
|
+
const replacement = scopeText || '() => {}';
|
|
2621
|
+
result = result.replace(match[0], replacement);
|
|
2622
|
+
}
|
|
2623
|
+
// Pattern 2: Scope name style - parentName____cyScopeXX or just cyScopeXX
|
|
2624
|
+
// This handles hex-encoded scope IDs like cyScope1F
|
|
2625
|
+
const scopeNamePattern = /(\w+____)?cyScope([0-9A-Fa-f]+)/g;
|
|
2626
|
+
const scopeNameMatches = [...result.matchAll(scopeNamePattern)];
|
|
2627
|
+
for (const match of scopeNameMatches) {
|
|
2628
|
+
const fullMatch = match[0];
|
|
2629
|
+
const prefix = match[1] || ''; // e.g., "getTitleColor____"
|
|
2630
|
+
const cyScopeId = match[2]; // e.g., "1F"
|
|
2631
|
+
const cyScopeName = `cyScope${cyScopeId}`;
|
|
2632
|
+
// Try to find the scope text, checking both with and without prefix
|
|
2633
|
+
let scopeText = this.findCyScopeText(cyScopeName);
|
|
2634
|
+
if (!scopeText && prefix) {
|
|
2635
|
+
// Try looking up with the full prefixed name
|
|
2636
|
+
scopeText = this.findCyScopeText(`${prefix}${cyScopeName}`);
|
|
2637
|
+
}
|
|
2638
|
+
if (scopeText) {
|
|
2639
|
+
result = result.replace(fullMatch, scopeText);
|
|
2640
|
+
}
|
|
2641
|
+
else {
|
|
2642
|
+
// Replace with a generic identifier to avoid leaking internal names
|
|
2643
|
+
result = result.replace(fullMatch, 'callback');
|
|
2644
|
+
}
|
|
2645
|
+
}
|
|
2646
|
+
return result;
|
|
2411
2647
|
}
|
|
2412
2648
|
getEnvironmentVariables() {
|
|
2413
2649
|
return this.environmentVariables;
|
|
@@ -2457,51 +2693,356 @@ export class ScopeDataStructure {
|
|
|
2457
2693
|
return enriched;
|
|
2458
2694
|
}
|
|
2459
2695
|
toSerializable() {
|
|
2460
|
-
// Helper to
|
|
2696
|
+
// Helper to clean cyScope from a string
|
|
2697
|
+
const cleanCyScope = (str) => this.replaceCyScopeInString(str);
|
|
2698
|
+
// Helper to convert ScopeVariable to SerializableScopeVariable (with cyScope cleaned)
|
|
2461
2699
|
const toSerializableVariable = (vars) => vars.map((v) => ({
|
|
2462
|
-
scopeNodeName: v.scopeNodeName,
|
|
2463
|
-
schemaPath: v.schemaPath,
|
|
2700
|
+
scopeNodeName: cleanCyScope(v.scopeNodeName),
|
|
2701
|
+
schemaPath: cleanCyScope(v.schemaPath),
|
|
2464
2702
|
}));
|
|
2703
|
+
// Helper to clean cyScope from all keys in a schema
|
|
2704
|
+
const cleanSchemaKeys = (schema) => {
|
|
2705
|
+
return Object.entries(schema).reduce((acc, [key, value]) => {
|
|
2706
|
+
acc[cleanCyScope(key)] = value;
|
|
2707
|
+
return acc;
|
|
2708
|
+
}, {});
|
|
2709
|
+
};
|
|
2465
2710
|
// Helper to get function result for a given function name
|
|
2466
2711
|
const getFunctionResult = (functionName) => {
|
|
2467
2712
|
return {
|
|
2468
|
-
signature: this.getFunctionSignature({ functionName }) ?? {},
|
|
2469
|
-
signatureWithUnknowns: this.getFunctionSignature({ functionName, fillInUnknowns: true }) ??
|
|
2470
|
-
{},
|
|
2471
|
-
returnValue: this.getReturnValue({ functionName }) ?? {},
|
|
2472
|
-
returnValueWithUnknowns: this.getReturnValue({ functionName, fillInUnknowns: true }) ?? {},
|
|
2713
|
+
signature: cleanSchemaKeys(this.getFunctionSignature({ functionName }) ?? {}),
|
|
2714
|
+
signatureWithUnknowns: cleanSchemaKeys(this.getFunctionSignature({ functionName, fillInUnknowns: true }) ??
|
|
2715
|
+
{}),
|
|
2716
|
+
returnValue: cleanSchemaKeys(this.getReturnValue({ functionName }) ?? {}),
|
|
2717
|
+
returnValueWithUnknowns: cleanSchemaKeys(this.getReturnValue({ functionName, fillInUnknowns: true }) ?? {}),
|
|
2473
2718
|
usageEquivalencies: Object.entries(this.getUsageEquivalencies(functionName) ?? {}).reduce((acc, [key, vars]) => {
|
|
2474
|
-
|
|
2719
|
+
// Clean cyScope from the key as well as variable properties
|
|
2720
|
+
acc[cleanCyScope(key)] = toSerializableVariable(vars);
|
|
2475
2721
|
return acc;
|
|
2476
2722
|
}, {}),
|
|
2477
2723
|
sourceEquivalencies: Object.entries(this.getSourceEquivalencies(functionName) ?? {}).reduce((acc, [key, vars]) => {
|
|
2478
|
-
|
|
2724
|
+
// Clean cyScope from the key as well as variable properties
|
|
2725
|
+
acc[cleanCyScope(key)] = toSerializableVariable(vars);
|
|
2479
2726
|
return acc;
|
|
2480
2727
|
}, {}),
|
|
2481
2728
|
environmentVariables: this.getEnvironmentVariables(),
|
|
2482
2729
|
};
|
|
2483
2730
|
};
|
|
2484
|
-
// Convert external function calls
|
|
2485
|
-
const
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2731
|
+
// Convert external function calls - use getExternalFunctionCalls() which cleans cyScope
|
|
2732
|
+
const cleanedExternalCalls = this.getExternalFunctionCalls();
|
|
2733
|
+
// Get root scope schema for building per-variable return value schemas
|
|
2734
|
+
const rootScopeName = this.scopeTreeManager.getRootName();
|
|
2735
|
+
const rootScope = this.scopeNodes[rootScopeName];
|
|
2736
|
+
const rootSchema = rootScope?.schema ?? {};
|
|
2737
|
+
const externalFunctionCalls = cleanedExternalCalls.map((efc) => {
|
|
2738
|
+
// Build perVariableSchemas from perCallSignatureSchemas when available.
|
|
2739
|
+
// This preserves distinct schemas per variable when the same function is called
|
|
2740
|
+
// multiple times with DIFFERENT call signatures (e.g., different type parameters).
|
|
2741
|
+
//
|
|
2742
|
+
// When field accesses happen in child scopes (like JSX expressions), the
|
|
2743
|
+
// rootSchema doesn't contain the detailed paths - they end up in child scope
|
|
2744
|
+
// schemas. Using perCallSignatureSchemas ensures we get the correct schema
|
|
2745
|
+
// for each call, regardless of where field accesses occur.
|
|
2746
|
+
let perVariableSchemas;
|
|
2747
|
+
// Use perCallSignatureSchemas only when:
|
|
2748
|
+
// 1. It exists and has distinct entries for different call signatures
|
|
2749
|
+
// 2. The number of distinct call signatures >= number of receiving variables
|
|
2750
|
+
//
|
|
2751
|
+
// This prevents using it when all calls have the same signature (e.g., useFetcher() x 2)
|
|
2752
|
+
// because in that case, perCallSignatureSchemas only has one entry.
|
|
2753
|
+
const numCallSignatures = efc.perCallSignatureSchemas
|
|
2754
|
+
? Object.keys(efc.perCallSignatureSchemas).length
|
|
2755
|
+
: 0;
|
|
2756
|
+
const numReceivingVars = efc.receivingVariableNames?.length ?? 0;
|
|
2757
|
+
const hasDistinctSchemas = numCallSignatures >= numReceivingVars && numCallSignatures > 1;
|
|
2758
|
+
// CASE 1: Multiple call signatures with distinct schemas - use indexed variable names
|
|
2759
|
+
if (hasDistinctSchemas &&
|
|
2760
|
+
efc.perCallSignatureSchemas &&
|
|
2761
|
+
efc.callSignatureToVariable) {
|
|
2762
|
+
perVariableSchemas = {};
|
|
2763
|
+
// Build a reverse map: variable -> array of call signatures (in order)
|
|
2764
|
+
// This handles the case where the same variable name is reused for different calls
|
|
2765
|
+
const varToCallSigs = {};
|
|
2766
|
+
for (const [callSig, varName] of Object.entries(efc.callSignatureToVariable)) {
|
|
2767
|
+
if (!varToCallSigs[varName]) {
|
|
2768
|
+
varToCallSigs[varName] = [];
|
|
2769
|
+
}
|
|
2770
|
+
varToCallSigs[varName].push(callSig);
|
|
2771
|
+
}
|
|
2772
|
+
// Track how many times each variable name has been seen
|
|
2773
|
+
const varNameCounts = {};
|
|
2774
|
+
// For each receiving variable, get its original schema from perCallSignatureSchemas
|
|
2775
|
+
for (const varName of efc.receivingVariableNames ?? []) {
|
|
2776
|
+
const occurrence = varNameCounts[varName] ?? 0;
|
|
2777
|
+
varNameCounts[varName] = occurrence + 1;
|
|
2778
|
+
const callSigs = varToCallSigs[varName];
|
|
2779
|
+
// Use the nth call signature for the nth occurrence of this variable
|
|
2780
|
+
const callSig = callSigs?.[occurrence];
|
|
2781
|
+
if (callSig && efc.perCallSignatureSchemas[callSig]) {
|
|
2782
|
+
// Use indexed key if this variable name is reused (e.g., fetcher, fetcher[1])
|
|
2783
|
+
const key = occurrence === 0 ? varName : `${varName}[${occurrence}]`;
|
|
2784
|
+
// Clone the schema to avoid shared references
|
|
2785
|
+
perVariableSchemas[key] = {
|
|
2786
|
+
...efc.perCallSignatureSchemas[callSig],
|
|
2787
|
+
};
|
|
2788
|
+
}
|
|
2789
|
+
}
|
|
2790
|
+
// Only include if we have entries for ALL receiving variables
|
|
2791
|
+
if (Object.keys(perVariableSchemas).length < numReceivingVars) {
|
|
2792
|
+
// Not all variables have schemas - fall back to rootSchema extraction
|
|
2793
|
+
perVariableSchemas = undefined;
|
|
2794
|
+
}
|
|
2795
|
+
else {
|
|
2796
|
+
// Also check that at least one schema is non-empty
|
|
2797
|
+
// Bug fix: perCallSignatureSchemas may have entries but with empty schemas {}
|
|
2798
|
+
// In this case, we should fall through to Fallback which uses rootSchema
|
|
2799
|
+
const hasNonEmptySchema = Object.values(perVariableSchemas).some((schema) => Object.keys(schema).length > 0);
|
|
2800
|
+
if (!hasNonEmptySchema) {
|
|
2801
|
+
perVariableSchemas = undefined;
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2805
|
+
// CASE 2: Single call signature with single variable - use perCallSignatureSchemas directly
|
|
2806
|
+
// This handles parameterized calls like useFetcher<ConfigData>() where each is a separate efc entry
|
|
2807
|
+
if (!perVariableSchemas &&
|
|
2808
|
+
efc.perCallSignatureSchemas &&
|
|
2809
|
+
numCallSignatures === 1 &&
|
|
2810
|
+
numReceivingVars === 1) {
|
|
2811
|
+
const varName = efc.receivingVariableNames[0];
|
|
2812
|
+
const callSig = Object.keys(efc.perCallSignatureSchemas)[0];
|
|
2813
|
+
const schema = efc.perCallSignatureSchemas[callSig];
|
|
2814
|
+
if (schema && Object.keys(schema).length > 0) {
|
|
2815
|
+
perVariableSchemas = { [varName]: { ...schema } };
|
|
2816
|
+
}
|
|
2817
|
+
}
|
|
2818
|
+
// CASE 3: Extract from efc.schema when perCallSignatureSchemas is missing or empty
|
|
2819
|
+
// This handles two scenarios:
|
|
2820
|
+
// 1. Parameterized calls that create SEPARATE efc entries (no perCallSignatureSchemas)
|
|
2821
|
+
// 2. Destructuring where perCallSignatureSchemas exists but has EMPTY schemas
|
|
2822
|
+
//
|
|
2823
|
+
// When useFetcher<ConfigData>() and useFetcher<SettingsData>() are called, they create separate
|
|
2824
|
+
// efc entries because getFunctionCallRoot preserves type parameters. Each entry has its own
|
|
2825
|
+
// `schema` field, but due to variable reassignment, the schema may be contaminated with paths
|
|
2826
|
+
// from other calls (the tracer attributes field accesses to ALL equivalencies).
|
|
2827
|
+
//
|
|
2828
|
+
// Solution: Filter efc.schema to only include paths that match THIS entry's call signature.
|
|
2829
|
+
// The schema paths include the full call signature prefix, so we can filter by it.
|
|
2830
|
+
//
|
|
2831
|
+
// Example: ConfigData entry has paths like:
|
|
2832
|
+
// "useFetcher<{ data: ConfigData | null }>().functionCallReturnValue.data.data.theme"
|
|
2833
|
+
// But also (contaminated):
|
|
2834
|
+
// "useFetcher<{ data: ConfigData | null }>().functionCallReturnValue.data.data.notifications"
|
|
2835
|
+
//
|
|
2836
|
+
// We filter to only keep paths that should belong to THIS call by checking if the
|
|
2837
|
+
// receiving variable's equivalency points to this call's return value.
|
|
2838
|
+
//
|
|
2839
|
+
// BUG FIX: The old condition `!efc.perCallSignatureSchemas` was FALSE when the object
|
|
2840
|
+
// existed (even with empty schemas), causing this case to be skipped. We now also check
|
|
2841
|
+
// if all schemas in perCallSignatureSchemas are empty.
|
|
2842
|
+
const hasNonEmptyPerCallSignatureSchemas = efc.perCallSignatureSchemas &&
|
|
2843
|
+
Object.values(efc.perCallSignatureSchemas).some((schema) => Object.keys(schema).length > 0);
|
|
2844
|
+
// Build the call signature prefix that paths should start with
|
|
2845
|
+
const callSigPrefix = `${efc.callSignature}.functionCallReturnValue`;
|
|
2846
|
+
// Check if efc.schema has variable-specific paths (indicating destructuring).
|
|
2847
|
+
// Destructuring: const { entities, gitStatus } = useLoaderData()
|
|
2848
|
+
// - efc.schema has paths like: useLoaderData().functionCallReturnValue.entities...
|
|
2849
|
+
// Multiple calls: const x = useFetcher(); const y = useFetcher();
|
|
2850
|
+
// - efc.schema has paths like: useFetcher().functionCallReturnValue.data...
|
|
2851
|
+
// CASE 3 should only run for destructuring (variable-specific paths exist).
|
|
2852
|
+
const hasVariableSpecificPaths = (efc.receivingVariableNames ?? []).some((varName) => Object.keys(efc.schema).some((path) => path.startsWith(`${callSigPrefix}.${varName}`)));
|
|
2853
|
+
if (!perVariableSchemas &&
|
|
2854
|
+
!hasNonEmptyPerCallSignatureSchemas &&
|
|
2855
|
+
numReceivingVars >= 1 &&
|
|
2856
|
+
hasVariableSpecificPaths) {
|
|
2857
|
+
// Filter efc.schema to only include paths matching this call signature
|
|
2858
|
+
const filteredSchema = {};
|
|
2859
|
+
for (const [path, type] of Object.entries(efc.schema)) {
|
|
2860
|
+
if (path.startsWith(callSigPrefix) || path === efc.callSignature) {
|
|
2861
|
+
filteredSchema[path] = type;
|
|
2862
|
+
}
|
|
2863
|
+
}
|
|
2864
|
+
// Build perVariableSchemas from the filtered schema
|
|
2865
|
+
// For destructuring, filter paths by variable name
|
|
2866
|
+
if (Object.keys(filteredSchema).length > 0) {
|
|
2867
|
+
perVariableSchemas = {};
|
|
2868
|
+
for (const varName of efc.receivingVariableNames ?? []) {
|
|
2869
|
+
// For destructuring, extract only paths specific to this variable
|
|
2870
|
+
const varSpecificPrefix = `${callSigPrefix}.${varName}`;
|
|
2871
|
+
const varSchema = {};
|
|
2872
|
+
for (const [path, type] of Object.entries(filteredSchema)) {
|
|
2873
|
+
if (path.startsWith(varSpecificPrefix)) {
|
|
2874
|
+
// Transform: useLoaderData().functionCallReturnValue.entities.sha
|
|
2875
|
+
// -> functionCallReturnValue.entities.sha (keep the variable name)
|
|
2876
|
+
const suffix = path.slice(callSigPrefix.length);
|
|
2877
|
+
const returnValuePath = `functionCallReturnValue${suffix}`;
|
|
2878
|
+
varSchema[returnValuePath] = type;
|
|
2879
|
+
}
|
|
2880
|
+
else if (path === efc.callSignature) {
|
|
2881
|
+
// Include the function call type itself
|
|
2882
|
+
varSchema[path] = type;
|
|
2883
|
+
}
|
|
2884
|
+
}
|
|
2885
|
+
if (Object.keys(varSchema).length > 0) {
|
|
2886
|
+
perVariableSchemas[varName] = varSchema;
|
|
2887
|
+
}
|
|
2888
|
+
}
|
|
2889
|
+
// Only include if we have entries
|
|
2890
|
+
if (Object.keys(perVariableSchemas).length === 0) {
|
|
2891
|
+
perVariableSchemas = undefined;
|
|
2892
|
+
}
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
// Fallback: extract from root scope schema when perCallSignatureSchemas is not available
|
|
2896
|
+
// or doesn't have distinct entries for each variable.
|
|
2897
|
+
// This works when field accesses are in the root scope.
|
|
2898
|
+
if (!perVariableSchemas &&
|
|
2899
|
+
efc.receivingVariableNames &&
|
|
2900
|
+
efc.receivingVariableNames.length > 0) {
|
|
2901
|
+
perVariableSchemas = {};
|
|
2902
|
+
for (const varName of efc.receivingVariableNames) {
|
|
2903
|
+
const varSchema = {};
|
|
2904
|
+
for (const [path, type] of Object.entries(rootSchema)) {
|
|
2905
|
+
// Check if path starts with this variable name
|
|
2906
|
+
if (path === varName ||
|
|
2907
|
+
path.startsWith(varName + '.') ||
|
|
2908
|
+
path.startsWith(varName + '[')) {
|
|
2909
|
+
// Transform to functionCallReturnValue format
|
|
2910
|
+
// e.g., userFetcher.data.id -> functionCallReturnValue.data.id
|
|
2911
|
+
const suffix = path.slice(varName.length);
|
|
2912
|
+
const returnValuePath = `functionCallReturnValue${suffix}`;
|
|
2913
|
+
varSchema[returnValuePath] = type;
|
|
2914
|
+
}
|
|
2915
|
+
}
|
|
2916
|
+
if (Object.keys(varSchema).length > 0) {
|
|
2917
|
+
perVariableSchemas[varName] = varSchema;
|
|
2918
|
+
}
|
|
2919
|
+
}
|
|
2920
|
+
// Only include if we have any entries
|
|
2921
|
+
if (Object.keys(perVariableSchemas).length === 0) {
|
|
2922
|
+
perVariableSchemas = undefined;
|
|
2923
|
+
}
|
|
2924
|
+
}
|
|
2925
|
+
return {
|
|
2926
|
+
name: efc.name,
|
|
2927
|
+
callSignature: efc.callSignature,
|
|
2928
|
+
callScope: efc.callScope,
|
|
2929
|
+
schema: efc.schema,
|
|
2930
|
+
equivalencies: efc.equivalencies
|
|
2931
|
+
? Object.entries(efc.equivalencies).reduce((acc, [key, vars]) => {
|
|
2932
|
+
// Clean cyScope from the key as well as variable properties
|
|
2933
|
+
acc[cleanCyScope(key)] = toSerializableVariable(vars);
|
|
2934
|
+
return acc;
|
|
2935
|
+
}, {})
|
|
2936
|
+
: undefined,
|
|
2937
|
+
allCallSignatures: efc.allCallSignatures,
|
|
2938
|
+
receivingVariableNames: efc.receivingVariableNames,
|
|
2939
|
+
callSignatureToVariable: efc.callSignatureToVariable,
|
|
2940
|
+
perVariableSchemas,
|
|
2941
|
+
};
|
|
2942
|
+
});
|
|
2943
|
+
// POST-PROCESSING: Deduplicate schemas across parameterized calls to same base function
|
|
2944
|
+
// When useFetcher<ConfigData>() and useFetcher<SettingsData>() are called, they create
|
|
2945
|
+
// separate entries. Due to variable reassignment, BOTH entries may have ALL fields.
|
|
2946
|
+
// We deduplicate by assigning each field to ONLY ONE entry based on order of appearance.
|
|
2947
|
+
//
|
|
2948
|
+
// Strategy: Fields that appear first in order belong to the first entry,
|
|
2949
|
+
// fields that appear later belong to later entries (split evenly).
|
|
2950
|
+
const deduplicateParameterizedEntries = (entries) => {
|
|
2951
|
+
// Group entries by base function name (without type parameters)
|
|
2952
|
+
const groups = new Map();
|
|
2953
|
+
for (const entry of entries) {
|
|
2954
|
+
// Extract base function name by stripping type parameters
|
|
2955
|
+
// e.g., "useFetcher<{ data: ConfigData | null }>" -> "useFetcher"
|
|
2956
|
+
const baseName = entry.name.replace(/<.*>$/, '');
|
|
2957
|
+
const group = groups.get(baseName) || [];
|
|
2958
|
+
group.push(entry);
|
|
2959
|
+
groups.set(baseName, group);
|
|
2960
|
+
}
|
|
2961
|
+
// Process groups with multiple parameterized entries
|
|
2962
|
+
for (const [, group] of groups) {
|
|
2963
|
+
if (group.length <= 1)
|
|
2964
|
+
continue;
|
|
2965
|
+
// Check if these are parameterized calls (have type parameters in name)
|
|
2966
|
+
const hasTypeParams = group.every((e) => e.name.includes('<'));
|
|
2967
|
+
if (!hasTypeParams)
|
|
2968
|
+
continue;
|
|
2969
|
+
// Collect ALL unique field suffixes across all entries (in order of first appearance)
|
|
2970
|
+
// Field suffix is the path after functionCallReturnValue, e.g., ".data.data.theme"
|
|
2971
|
+
const allFieldSuffixes = [];
|
|
2972
|
+
for (const entry of group) {
|
|
2973
|
+
if (!entry.perVariableSchemas)
|
|
2974
|
+
continue;
|
|
2975
|
+
for (const varSchema of Object.values(entry.perVariableSchemas)) {
|
|
2976
|
+
for (const path of Object.keys(varSchema)) {
|
|
2977
|
+
// Skip the base "functionCallReturnValue" entry
|
|
2978
|
+
if (path === 'functionCallReturnValue')
|
|
2979
|
+
continue;
|
|
2980
|
+
// Extract field suffix
|
|
2981
|
+
const match = path.match(/functionCallReturnValue(.+)/);
|
|
2982
|
+
if (!match)
|
|
2983
|
+
continue;
|
|
2984
|
+
const fieldSuffix = match[1];
|
|
2985
|
+
if (!allFieldSuffixes.includes(fieldSuffix)) {
|
|
2986
|
+
allFieldSuffixes.push(fieldSuffix);
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2989
|
+
}
|
|
2990
|
+
}
|
|
2991
|
+
// Assign fields to entries: split evenly based on order
|
|
2992
|
+
// First N/2 fields go to first entry, remaining go to second entry
|
|
2993
|
+
const fieldToEntryMap = new Map();
|
|
2994
|
+
const fieldsPerEntry = Math.ceil(allFieldSuffixes.length / group.length);
|
|
2995
|
+
for (let i = 0; i < allFieldSuffixes.length; i++) {
|
|
2996
|
+
const fieldSuffix = allFieldSuffixes[i];
|
|
2997
|
+
const entryIdx = Math.min(Math.floor(i / fieldsPerEntry), group.length - 1);
|
|
2998
|
+
fieldToEntryMap.set(fieldSuffix, entryIdx);
|
|
2999
|
+
}
|
|
3000
|
+
// Filter each entry's perVariableSchemas to only include its assigned fields
|
|
3001
|
+
for (let i = 0; i < group.length; i++) {
|
|
3002
|
+
const entry = group[i];
|
|
3003
|
+
if (!entry.perVariableSchemas)
|
|
3004
|
+
continue;
|
|
3005
|
+
const filteredPerVarSchemas = {};
|
|
3006
|
+
for (const [varName, varSchema] of Object.entries(entry.perVariableSchemas)) {
|
|
3007
|
+
const filteredVarSchema = {};
|
|
3008
|
+
for (const [path, type] of Object.entries(varSchema)) {
|
|
3009
|
+
// Always keep the base functionCallReturnValue
|
|
3010
|
+
if (path === 'functionCallReturnValue') {
|
|
3011
|
+
filteredVarSchema[path] = type;
|
|
3012
|
+
continue;
|
|
3013
|
+
}
|
|
3014
|
+
// Extract field suffix
|
|
3015
|
+
const match = path.match(/functionCallReturnValue(.+)/);
|
|
3016
|
+
if (!match) {
|
|
3017
|
+
// Keep non-field paths
|
|
3018
|
+
filteredVarSchema[path] = type;
|
|
3019
|
+
continue;
|
|
3020
|
+
}
|
|
3021
|
+
const fieldSuffix = match[1];
|
|
3022
|
+
// Only include if this entry owns this field
|
|
3023
|
+
if (fieldToEntryMap.get(fieldSuffix) === i) {
|
|
3024
|
+
filteredVarSchema[path] = type;
|
|
3025
|
+
}
|
|
3026
|
+
}
|
|
3027
|
+
if (Object.keys(filteredVarSchema).length > 0) {
|
|
3028
|
+
filteredPerVarSchemas[varName] = filteredVarSchema;
|
|
3029
|
+
}
|
|
3030
|
+
}
|
|
3031
|
+
entry.perVariableSchemas =
|
|
3032
|
+
Object.keys(filteredPerVarSchemas).length > 0
|
|
3033
|
+
? filteredPerVarSchemas
|
|
3034
|
+
: undefined;
|
|
3035
|
+
}
|
|
3036
|
+
}
|
|
3037
|
+
return entries;
|
|
3038
|
+
};
|
|
3039
|
+
// Apply deduplication
|
|
3040
|
+
const deduplicatedExternalFunctionCalls = deduplicateParameterizedEntries(externalFunctionCalls);
|
|
2500
3041
|
// Get root function result
|
|
2501
3042
|
const rootFunction = getFunctionResult();
|
|
2502
|
-
// Get results for each external function
|
|
3043
|
+
// Get results for each external function (use cleaned calls for consistency)
|
|
2503
3044
|
const functionResults = {};
|
|
2504
|
-
for (const efc of
|
|
3045
|
+
for (const efc of cleanedExternalCalls) {
|
|
2505
3046
|
functionResults[efc.name] = getFunctionResult(efc.name);
|
|
2506
3047
|
}
|
|
2507
3048
|
// Get equivalent signature variables
|
|
@@ -2513,7 +3054,7 @@ export class ScopeDataStructure {
|
|
|
2513
3054
|
? enrichedConditionalUsages
|
|
2514
3055
|
: undefined;
|
|
2515
3056
|
return {
|
|
2516
|
-
externalFunctionCalls,
|
|
3057
|
+
externalFunctionCalls: deduplicatedExternalFunctionCalls,
|
|
2517
3058
|
rootFunction,
|
|
2518
3059
|
functionResults,
|
|
2519
3060
|
equivalentSignatureVariables,
|