@codeyam/codeyam-cli 0.1.0-staging.15d0f46 → 0.1.0-staging.1669d45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/analyzer-template/.build-info.json +7 -7
- package/analyzer-template/common/execAsync.ts +1 -1
- package/analyzer-template/log.txt +3 -3
- package/analyzer-template/package.json +9 -5
- package/analyzer-template/packages/ai/index.ts +5 -3
- package/analyzer-template/packages/ai/package.json +1 -1
- package/analyzer-template/packages/ai/src/lib/__mocks__/completionCall.ts +122 -0
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +152 -6
- package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +107 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.ts +644 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +42 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.ts +18 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.ts +38 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.ts +301 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +972 -106
- package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +232 -0
- package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +29 -10
- package/analyzer-template/packages/ai/src/lib/completionCall.ts +18 -2
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +1409 -138
- 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 +771 -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 +39 -4
- 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 +42 -2
- package/analyzer-template/packages/ai/src/lib/deepEqual.ts +30 -0
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarioData.ts +74 -7
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +89 -112
- package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +6 -0
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +486 -86
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +182 -104
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +201 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +528 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +1019 -0
- package/analyzer-template/packages/ai/src/lib/getConditionalUsagesFromCode.ts +143 -31
- package/analyzer-template/packages/ai/src/lib/guessScenarioDataFromDescription.ts +8 -2
- package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +276 -3
- package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +33 -3
- package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +7 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.ts +1 -1
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +32 -102
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +71 -4
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.ts +14 -53
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.ts +58 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.ts +28 -2
- package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +690 -0
- package/analyzer-template/packages/ai/src/lib/splitOutsideParentheses.ts +5 -1
- package/analyzer-template/packages/ai/src/lib/validateExecutionFlowPaths.ts +531 -0
- package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +102 -0
- package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +8 -1
- package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +14 -0
- package/analyzer-template/packages/analyze/src/lib/asts/nodes/index.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/asts/nodes/isAsyncFunction.ts +67 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +458 -267
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +18 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +3 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +31 -15
- package/analyzer-template/packages/analyze/src/lib/files/analyzeEntity.ts +11 -7
- package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +11 -12
- package/analyzer-template/packages/analyze/src/lib/files/enums/steps.ts +1 -1
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +196 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.ts +102 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +588 -52
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.ts +1 -1
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.ts +28 -62
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +299 -133
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +156 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +78 -83
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +4 -8
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +384 -94
- package/analyzer-template/packages/aws/codebuild/index.ts +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts +11 -1
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js +29 -18
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts +2 -2
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js +2 -2
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts +8 -18
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js +17 -61
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts +15 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts.map +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js +31 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js.map +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js +8 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js.map +1 -1
- package/analyzer-template/packages/aws/package.json +2 -2
- package/analyzer-template/packages/aws/s3/index.ts +1 -0
- package/analyzer-template/packages/aws/src/lib/codebuild/waitForBuild.ts +43 -19
- package/analyzer-template/packages/aws/src/lib/ecs/ecsDefineContainer.ts +3 -3
- package/analyzer-template/packages/aws/src/lib/ecs/ecsTaskFactory.ts +17 -69
- package/analyzer-template/packages/aws/src/lib/s3/checkS3ObjectExists.ts +47 -0
- package/analyzer-template/packages/aws/src/lib/s3/uploadFileToS3.ts +8 -1
- package/analyzer-template/packages/database/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 +36 -9
- package/analyzer-template/packages/database/src/lib/loadReadyToBeCapturedAnalyses.ts +7 -3
- package/analyzer-template/packages/generate/index.ts +3 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.ts +17 -1
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.ts +193 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.ts +73 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.ts +9 -4
- package/analyzer-template/packages/generate/src/lib/deepMerge.ts +26 -1
- package/analyzer-template/packages/generate/src/lib/scenarioComponentForServer.ts +114 -0
- 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 +1 -11
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +30 -7
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts +2 -6
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js +7 -4
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/index.d.ts +3 -0
- package/analyzer-template/packages/github/dist/generate/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/index.js +3 -0
- package/analyzer-template/packages/github/dist/generate/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts +9 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts +20 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js +27 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts +8 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js +89 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js.map +1 -0
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js +10 -0
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js +3 -0
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.d.ts +2 -2
- package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +63 -13
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts +11 -6
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +146 -0
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts.map +1 -1
- package/analyzer-template/packages/github/src/lib/loadOrCreateCommit.ts +14 -0
- package/analyzer-template/packages/github/src/lib/syncPrimaryBranch.ts +2 -0
- package/analyzer-template/packages/process/index.ts +2 -0
- package/analyzer-template/packages/process/package.json +12 -0
- package/analyzer-template/packages/process/tsconfig.json +8 -0
- package/analyzer-template/packages/types/index.ts +4 -0
- package/analyzer-template/packages/types/src/types/Analysis.ts +79 -13
- package/analyzer-template/packages/types/src/types/Entity.ts +2 -0
- package/analyzer-template/packages/types/src/types/Scenario.ts +11 -10
- package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +161 -0
- package/analyzer-template/packages/types/src/types/StatementInfo.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/index.d.ts +2 -2
- package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +63 -13
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts +11 -6
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +146 -0
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts.map +1 -1
- package/analyzer-template/playwright/capture.ts +37 -18
- package/analyzer-template/playwright/getCodeYamInfo.ts +12 -7
- package/analyzer-template/playwright/takeElementScreenshot.ts +26 -11
- package/analyzer-template/playwright/waitForServer.ts +21 -6
- package/analyzer-template/project/analyzeBaselineCommit.ts +4 -0
- package/analyzer-template/project/analyzeBranchCommit.ts +4 -0
- package/analyzer-template/project/analyzeFileEntities.ts +4 -0
- package/analyzer-template/project/analyzeRegularCommit.ts +4 -0
- package/analyzer-template/project/constructMockCode.ts +868 -132
- package/analyzer-template/project/controller/startController.ts +16 -1
- package/analyzer-template/project/executeLibraryFunctionDirect.ts +7 -3
- package/analyzer-template/project/mocks/analyzeFileMock.ts +8 -7
- package/analyzer-template/project/orchestrateCapture/KyselyAnalysisLoader.ts +3 -6
- package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +49 -33
- package/analyzer-template/project/orchestrateCapture.ts +10 -3
- package/analyzer-template/project/reconcileMockDataKeys.ts +102 -2
- package/analyzer-template/project/runAnalysis.ts +7 -0
- package/analyzer-template/project/serverOnlyModules.ts +127 -2
- package/analyzer-template/project/start.ts +26 -4
- package/analyzer-template/project/startScenarioCapture.ts +72 -40
- package/analyzer-template/project/writeMockDataTsx.ts +118 -55
- package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
- package/analyzer-template/project/writeScenarioComponents.ts +263 -92
- package/analyzer-template/project/writeScenarioFiles.ts +26 -0
- package/analyzer-template/project/writeSimpleRoot.ts +13 -15
- package/analyzer-template/scripts/comboWorkerLoop.cjs +1 -0
- package/analyzer-template/scripts/defaultCmd.sh +9 -0
- package/analyzer-template/tsconfig.json +2 -1
- package/background/src/lib/local/createLocalAnalyzer.js +1 -29
- package/background/src/lib/local/createLocalAnalyzer.js.map +1 -1
- package/background/src/lib/local/execAsync.js +1 -1
- package/background/src/lib/local/execAsync.js.map +1 -1
- package/background/src/lib/virtualized/common/execAsync.js +1 -1
- package/background/src/lib/virtualized/common/execAsync.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeBaselineCommit.js +2 -1
- package/background/src/lib/virtualized/project/analyzeBaselineCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeBranchCommit.js +2 -1
- package/background/src/lib/virtualized/project/analyzeBranchCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeFileEntities.js +2 -1
- package/background/src/lib/virtualized/project/analyzeFileEntities.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeRegularCommit.js +2 -1
- package/background/src/lib/virtualized/project/analyzeRegularCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/constructMockCode.js +799 -121
- package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
- package/background/src/lib/virtualized/project/controller/startController.js +11 -1
- package/background/src/lib/virtualized/project/controller/startController.js.map +1 -1
- package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js +6 -3
- package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js.map +1 -1
- package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js +7 -7
- package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js +3 -2
- package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +42 -28
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture.js +7 -4
- package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +87 -2
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
- package/background/src/lib/virtualized/project/runAnalysis.js +6 -0
- package/background/src/lib/virtualized/project/runAnalysis.js.map +1 -1
- package/background/src/lib/virtualized/project/serverOnlyModules.js +106 -3
- package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -1
- package/background/src/lib/virtualized/project/start.js +21 -4
- package/background/src/lib/virtualized/project/start.js.map +1 -1
- package/background/src/lib/virtualized/project/startScenarioCapture.js +56 -30
- package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/writeMockDataTsx.js +110 -48
- package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js +15 -0
- package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js.map +1 -0
- package/background/src/lib/virtualized/project/writeScenarioComponents.js +211 -75
- package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioFiles.js +19 -0
- package/background/src/lib/virtualized/project/writeScenarioFiles.js.map +1 -1
- package/background/src/lib/virtualized/project/writeSimpleRoot.js +13 -13
- package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
- package/codeyam-cli/src/cli.js +5 -1
- package/codeyam-cli/src/cli.js.map +1 -1
- package/codeyam-cli/src/commands/analyze.js +1 -1
- package/codeyam-cli/src/commands/analyze.js.map +1 -1
- package/codeyam-cli/src/commands/baseline.js +174 -0
- package/codeyam-cli/src/commands/baseline.js.map +1 -0
- package/codeyam-cli/src/commands/debug.js +28 -18
- package/codeyam-cli/src/commands/debug.js.map +1 -1
- package/codeyam-cli/src/commands/default.js +0 -15
- package/codeyam-cli/src/commands/default.js.map +1 -1
- package/codeyam-cli/src/commands/recapture.js +44 -23
- package/codeyam-cli/src/commands/recapture.js.map +1 -1
- package/codeyam-cli/src/commands/report.js +72 -24
- package/codeyam-cli/src/commands/report.js.map +1 -1
- package/codeyam-cli/src/commands/start.js +8 -12
- package/codeyam-cli/src/commands/start.js.map +1 -1
- package/codeyam-cli/src/commands/status.js +23 -1
- package/codeyam-cli/src/commands/status.js.map +1 -1
- package/codeyam-cli/src/commands/test-startup.js +1 -1
- package/codeyam-cli/src/commands/test-startup.js.map +1 -1
- package/codeyam-cli/src/commands/wipe.js +108 -0
- package/codeyam-cli/src/commands/wipe.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js +81 -0
- package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +27 -27
- package/codeyam-cli/src/utils/analysisRunner.js +8 -13
- package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
- package/codeyam-cli/src/utils/backgroundServer.js +12 -2
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/database.js +91 -5
- package/codeyam-cli/src/utils/database.js.map +1 -1
- package/codeyam-cli/src/utils/generateReport.js +253 -106
- package/codeyam-cli/src/utils/generateReport.js.map +1 -1
- package/codeyam-cli/src/utils/git.js +79 -0
- package/codeyam-cli/src/utils/git.js.map +1 -0
- package/codeyam-cli/src/utils/install-skills.js +11 -11
- 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 +239 -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/utils/serverState.js.map +1 -1
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +5 -5
- package/codeyam-cli/src/utils/versionInfo.js +25 -19
- package/codeyam-cli/src/utils/versionInfo.js.map +1 -1
- package/codeyam-cli/src/utils/wipe.js +128 -0
- package/codeyam-cli/src/utils/wipe.js.map +1 -0
- package/codeyam-cli/src/webserver/app/lib/database.js +96 -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 +2 -5
- package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-vauWK972.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-DKdsUF7Y.js → EntityTypeBadge-COi5OvsN.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-BwdQv49w.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-CEleMv_j.js +34 -0
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-D68KarMg.js +25 -0
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-L75Wvqgw.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/LoadingDots-C53WM8qn.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/LogViewer-CrNkmy4i.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-DzJRkCkr.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-CQifa1n-.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-CyaBFX7l.js +20 -0
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-CWjSsLqY.js → TruncatedFilePath-D36O1rzU.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/_index-Be83mo_j.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-BN6wu6Y-.js +37 -0
- package/codeyam-cli/src/webserver/build/client/assets/chevron-down-DgTPh8H-.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/chunk-EPOLDU6W-DdQKK6on.js +51 -0
- package/codeyam-cli/src/webserver/build/client/assets/circle-check-Dmr2bb1R.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-Do4ZLUYa.js +21 -0
- package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-C1gnJVOL.svg → cy-logo-cli-CCKUIm0S.svg} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DcX-ZS3p.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-Bn6aCAy_.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-CbdFyxZh.js +23 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-B4iCfs5M.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-wDWZZO1W.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-BMbl7MeQ.js +5 -0
- package/codeyam-cli/src/webserver/build/client/assets/entry.client-5wRKRIH9.js +29 -0
- package/codeyam-cli/src/webserver/build/client/assets/executionFlowCoverage-BWhdfn70.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-DD3SDH7t.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/files-DKyMFI90.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/git-zXjT7J0G.js +15 -0
- package/codeyam-cli/src/webserver/build/client/assets/globals-DTTQ3gY7.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-DLbXwndH.js +9 -0
- package/codeyam-cli/src/webserver/build/client/assets/index-gPZ-lad1.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/loader-circle-BsPXJ81F.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/manifest-22590fcf.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-BsAarjAM.js +57 -0
- package/codeyam-cli/src/webserver/build/client/assets/scenarioStatus-B_8jpV3e.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/search-P2FKIUql.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/settings-B2eDuBj8.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/simulations-L18M6-kN.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-BDz7kbVA.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-29dDmbH8.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-CmrTPlIB.js → useLastLogLine-BUm0UVJm.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-CkIOKTrZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useToast-C1ig_BmP.js → useToast-KKw5kTn-.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-BND5I5fv.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-CFXnd7MG.js +228 -0
- package/codeyam-cli/src/webserver/build/server/index.js +1 -1
- package/codeyam-cli/src/webserver/build-info.json +5 -5
- package/codeyam-cli/src/webserver/devServer.js +1 -3
- package/codeyam-cli/src/webserver/devServer.js.map +1 -1
- package/codeyam-cli/src/webserver/server.js +35 -25
- package/codeyam-cli/src/webserver/server.js.map +1 -1
- package/codeyam-cli/templates/{codeyam-debug-skill.md → codeyam:debug.md} +1 -1
- package/codeyam-cli/templates/codeyam:diagnose.md +625 -0
- package/codeyam-cli/templates/{codeyam-setup-skill.md → codeyam:setup.md} +139 -4
- package/codeyam-cli/templates/{codeyam-sim-skill.md → codeyam:sim.md} +1 -1
- package/codeyam-cli/templates/{codeyam-test-skill.md → codeyam:test.md} +1 -1
- package/codeyam-cli/templates/{codeyam-verify-skill.md → codeyam:verify.md} +1 -1
- package/package.json +8 -8
- package/packages/ai/index.js +2 -4
- package/packages/ai/index.js.map +1 -1
- package/packages/ai/src/lib/analyzeScope.js +107 -0
- package/packages/ai/src/lib/analyzeScope.js.map +1 -1
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +76 -1
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
- package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js +435 -0
- package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js.map +1 -0
- package/packages/ai/src/lib/astScopes/methodSemantics.js +29 -0
- package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js +8 -0
- package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js +23 -0
- package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js +239 -1
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/processExpression.js +728 -87
- package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
- package/packages/ai/src/lib/checkAllAttributes.js +24 -9
- package/packages/ai/src/lib/checkAllAttributes.js.map +1 -1
- package/packages/ai/src/lib/completionCall.js +17 -1
- package/packages/ai/src/lib/completionCall.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +1126 -82
- 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 +482 -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 +35 -2
- 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 +34 -3
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
- package/packages/ai/src/lib/deepEqual.js +32 -0
- package/packages/ai/src/lib/deepEqual.js.map +1 -0
- package/packages/ai/src/lib/generateChangesEntityScenarioData.js +62 -5
- package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateChangesEntityScenarios.js +81 -90
- package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateEntityDataStructure.js +5 -0
- package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarioData.js +398 -81
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarios.js +168 -82
- package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +123 -0
- package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js +380 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +742 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -0
- package/packages/ai/src/lib/getConditionalUsagesFromCode.js +84 -14
- package/packages/ai/src/lib/getConditionalUsagesFromCode.js.map +1 -1
- package/packages/ai/src/lib/guessScenarioDataFromDescription.js +2 -1
- package/packages/ai/src/lib/guessScenarioDataFromDescription.js.map +1 -1
- package/packages/ai/src/lib/isolateScopes.js +231 -4
- package/packages/ai/src/lib/isolateScopes.js.map +1 -1
- package/packages/ai/src/lib/mergeStatements.js +26 -3
- package/packages/ai/src/lib/mergeStatements.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/generateChangesEntityScenarioDataGenerator.js +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +21 -64
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +58 -4
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js +10 -34
- package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js +45 -0
- package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js +16 -3
- package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js.map +1 -1
- package/packages/ai/src/lib/resolvePathToControllable.js +563 -0
- package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -0
- package/packages/ai/src/lib/splitOutsideParentheses.js +3 -1
- package/packages/ai/src/lib/splitOutsideParentheses.js.map +1 -1
- package/packages/ai/src/lib/worker/SerializableDataStructure.js +22 -0
- 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/FileAnalyzer.js +15 -0
- package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/asts/nodes/index.js +1 -0
- package/packages/analyze/src/lib/asts/nodes/index.js.map +1 -1
- package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js +52 -0
- package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js.map +1 -0
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +214 -50
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +10 -0
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +2 -0
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeChange.js +21 -11
- package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeEntity.js +9 -8
- package/packages/analyze/src/lib/files/analyzeEntity.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeInitial.js +9 -10
- package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
- package/packages/analyze/src/lib/files/enums/steps.js +1 -1
- package/packages/analyze/src/lib/files/enums/steps.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +159 -0
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js +85 -0
- package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +458 -48
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js +29 -34
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +235 -81
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +96 -0
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +56 -69
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +4 -8
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +307 -89
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
- package/packages/aws/src/lib/ecs/ecsDefineContainer.js +2 -2
- package/packages/aws/src/lib/ecs/ecsDefineContainer.js.map +1 -1
- package/packages/aws/src/lib/ecs/ecsTaskFactory.js +17 -61
- package/packages/aws/src/lib/ecs/ecsTaskFactory.js.map +1 -1
- package/packages/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/database/src/lib/loadReadyToBeCapturedAnalyses.js +7 -4
- package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
- package/packages/generate/index.js +3 -0
- package/packages/generate/index.js.map +1 -1
- package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
- package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
- package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
- package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
- package/packages/generate/src/lib/deepMerge.js +27 -1
- package/packages/generate/src/lib/deepMerge.js.map +1 -1
- package/packages/generate/src/lib/scenarioComponentForServer.js +89 -0
- package/packages/generate/src/lib/scenarioComponentForServer.js.map +1 -0
- package/packages/github/src/lib/loadOrCreateCommit.js +10 -0
- package/packages/github/src/lib/loadOrCreateCommit.js.map +1 -1
- package/packages/github/src/lib/syncPrimaryBranch.js +3 -0
- package/packages/github/src/lib/syncPrimaryBranch.js.map +1 -1
- package/packages/process/index.js +3 -0
- package/packages/process/index.js.map +1 -0
- package/packages/process/src/GlobalProcessManager.js.map +1 -0
- package/{background/src/lib/process → packages/process/src}/ProcessManager.js +1 -1
- package/packages/process/src/ProcessManager.js.map +1 -0
- package/packages/process/src/index.js.map +1 -0
- package/packages/process/src/managedExecAsync.js.map +1 -0
- package/packages/types/index.js.map +1 -1
- package/scripts/finalize-analyzer.cjs +3 -1
- package/analyzer-template/packages/ai/src/lib/findMatchingAttribute.ts +0 -102
- package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +0 -197
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +0 -271
- package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +0 -294
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.ts +0 -67
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +0 -115
- package/analyzer-template/process/INTEGRATION_COMPLETE.md +0 -333
- package/analyzer-template/process/INTEGRATION_EXAMPLE.md +0 -525
- package/analyzer-template/process/README.md +0 -507
- package/background/src/lib/process/GlobalProcessManager.js.map +0 -1
- package/background/src/lib/process/ProcessManager.js.map +0 -1
- package/background/src/lib/process/index.js.map +0 -1
- package/background/src/lib/process/managedExecAsync.js.map +0 -1
- package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js +0 -238
- package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js.map +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-D0VW1-W7.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-BAk4S4pI.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-Y756iZxZ.js +0 -25
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-zzrrjW1p.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/LogViewer-QMn7bJg6.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-DmP5mRxX.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-BXwvsbLw.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-DAmUX_1y.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/_index-Df-nk4J5.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-_ZUyFdie.js +0 -7
- package/codeyam-cli/src/webserver/build/client/assets/chevron-down-Eoh0PhcW.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/chunk-WWGJGFF6-CZgPLy5i.js +0 -26
- package/codeyam-cli/src/webserver/build/client/assets/circle-check-DI-p9ZLZ.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-DvyV2x6y.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-DURu2qlF.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-DDobn9Xh.js +0 -16
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-CGdWnLD_.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-DgMmzrKs.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/entry.client-DEVXuhkn.js +0 -13
- package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-WPRQyc68.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-B9u3lJer.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/git-YGnKIuHU.js +0 -11
- package/codeyam-cli/src/webserver/build/client/assets/globals-28lrWTTo.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-CJ0uPJjV.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/index-CfqeA2XG.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/loader-circle-DIjSvh6B.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-8125c15c.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/preload-helper-BXl3LOEh.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/root-C-g286WP.js +0 -16
- package/codeyam-cli/src/webserver/build/client/assets/search-xBKWfOxd.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/settings-DVY_wGOx.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/simulations-Be1pJo5A.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-CR-FkSvx.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-DABetnSj.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-DcR7DH9q.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-BDBrfp7e.js +0 -175
- package/codeyam-cli/templates/debug-codeyam.md +0 -527
- package/packages/ai/src/lib/findMatchingAttribute.js +0 -77
- package/packages/ai/src/lib/findMatchingAttribute.js.map +0 -1
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +0 -136
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +0 -220
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateEntityKeyAttributes.js +0 -241
- package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/isFrontend.js +0 -5
- package/packages/ai/src/lib/isFrontend.js.map +0 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js +0 -40
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js.map +0 -1
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +0 -72
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +0 -1
- /package/analyzer-template/{process → packages/process/src}/GlobalProcessManager.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/ProcessManager.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/index.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/managedExecAsync.ts +0 -0
- /package/{background/src/lib/process → packages/process/src}/GlobalProcessManager.js +0 -0
- /package/{background/src/lib/process → packages/process/src}/index.js +0 -0
- /package/{background/src/lib/process → packages/process/src}/managedExecAsync.js +0 -0
|
@@ -25,13 +25,102 @@ interface ReturnValuePart {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* Converts a
|
|
29
|
-
*
|
|
28
|
+
* Converts a call signature to a valid JavaScript identifier (function name).
|
|
29
|
+
* The original signature is preserved for data access - this only creates the function name.
|
|
30
|
+
*
|
|
31
|
+
* Examples:
|
|
32
|
+
* - "useAuth()" → "useAuth"
|
|
33
|
+
* - "db.select(usersQuery)" → "db_select_usersQuery"
|
|
34
|
+
* - "db.select(postsQuery)" → "db_select_postsQuery"
|
|
35
|
+
* - "useFetcher<User>()" → "useFetcher_User"
|
|
36
|
+
* - "useFetcher<{ data: UserData | null }>()" → "useFetcher_data_UserData_null"
|
|
37
|
+
* - "eq('user_id', value)" → "eq_user_id_value"
|
|
38
|
+
* - "from('workouts')" → "from_workouts"
|
|
30
39
|
*/
|
|
31
|
-
function
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
function callSignatureToFunctionName(signature: string): string {
|
|
41
|
+
// Extract components from the signature
|
|
42
|
+
const components: string[] = [];
|
|
43
|
+
|
|
44
|
+
// 1. Extract function path (parts separated by dots outside parens/brackets)
|
|
45
|
+
const pathMatch = signature.match(/^([^<(]+)/);
|
|
46
|
+
if (pathMatch) {
|
|
47
|
+
const path = pathMatch[1];
|
|
48
|
+
// Split on dots but preserve the parts
|
|
49
|
+
components.push(...path.split('.').filter(Boolean));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 2. Extract generic type parameters (content between < and >)
|
|
53
|
+
const genericMatch = signature.match(/<([^>]+)>/);
|
|
54
|
+
if (genericMatch) {
|
|
55
|
+
const genericContent = genericMatch[1];
|
|
56
|
+
// Extract meaningful identifiers from generic type
|
|
57
|
+
// Handle complex types like "{ data: UserData | null }"
|
|
58
|
+
const typeIdentifiers = genericContent
|
|
59
|
+
.replace(/[{}:;,]/g, ' ') // Remove structural chars
|
|
60
|
+
.replace(/\|/g, ' ') // Handle union types
|
|
61
|
+
.split(/\s+/)
|
|
62
|
+
.filter(Boolean)
|
|
63
|
+
.filter((s) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(s)) // Only valid identifiers
|
|
64
|
+
.filter(
|
|
65
|
+
(s) =>
|
|
66
|
+
![
|
|
67
|
+
'null',
|
|
68
|
+
'undefined',
|
|
69
|
+
'void',
|
|
70
|
+
'never',
|
|
71
|
+
'any',
|
|
72
|
+
'unknown',
|
|
73
|
+
'data',
|
|
74
|
+
'typeof',
|
|
75
|
+
].includes(s),
|
|
76
|
+
); // Skip common non-meaningful keywords
|
|
77
|
+
|
|
78
|
+
if (typeIdentifiers.length > 0) {
|
|
79
|
+
components.push(...typeIdentifiers.slice(0, 2)); // Limit to first 2 for reasonable length
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 3. Extract function arguments (first 2 for disambiguation)
|
|
84
|
+
const argsMatch = signature.match(/\(([^)]*)\)/);
|
|
85
|
+
if (argsMatch && argsMatch[1]) {
|
|
86
|
+
const argsContent = argsMatch[1].trim();
|
|
87
|
+
if (argsContent) {
|
|
88
|
+
const args = argsContent.split(',').map((arg) => arg.trim());
|
|
89
|
+
for (const arg of args.slice(0, 2)) {
|
|
90
|
+
// For quoted strings, extract the content
|
|
91
|
+
const stringMatch = arg.match(/^['"`](.+)['"`]$/);
|
|
92
|
+
if (stringMatch) {
|
|
93
|
+
// Split on dots for string paths like 'users.id'
|
|
94
|
+
const parts = stringMatch[1].split('.').filter(Boolean);
|
|
95
|
+
components.push(...parts);
|
|
96
|
+
} else if (/^[A-Za-z_][A-Za-z0-9_]*$/.test(arg)) {
|
|
97
|
+
// Valid identifier - use as-is
|
|
98
|
+
components.push(arg);
|
|
99
|
+
} else if (/^\d+$/.test(arg)) {
|
|
100
|
+
// Number - use as-is
|
|
101
|
+
components.push(arg);
|
|
102
|
+
}
|
|
103
|
+
// Skip complex expressions
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Build the function name from components
|
|
109
|
+
const functionName = components
|
|
110
|
+
.join('_')
|
|
111
|
+
.replace(/[^a-zA-Z0-9_]/g, '_') // Sanitize special chars
|
|
112
|
+
.replace(/_+/g, '_') // Collapse multiple underscores
|
|
113
|
+
.replace(/^_|_$/g, ''); // Trim underscores
|
|
114
|
+
|
|
115
|
+
return functionName || 'mock';
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Check if a mock name is a call signature (e.g., "useFetcher<User>()", "db.select(query)")
|
|
120
|
+
*/
|
|
121
|
+
function isCallSignature(mockName: string): boolean {
|
|
122
|
+
// Call signatures contain parentheses (function calls)
|
|
123
|
+
return mockName.includes('(');
|
|
35
124
|
}
|
|
36
125
|
|
|
37
126
|
/**
|
|
@@ -196,9 +285,12 @@ function funcArgs(functionSignature: string): string[] {
|
|
|
196
285
|
|
|
197
286
|
// isValidKey ensures that the key does not contain any characters that would make it invalid in a JavaScript object.
|
|
198
287
|
// For example, it should not contain spaces, special characters, or start with a number.
|
|
288
|
+
// Also rejects keys that are pure function calls like "()" or "(args)" - these aren't property names.
|
|
199
289
|
function isValidKey(key: string) {
|
|
200
290
|
if (!key || key.length === 0) return false;
|
|
201
291
|
const keyWithOutArguments = key.split('(')[0];
|
|
292
|
+
// Reject empty keys (happens when key is "()" or "(args)") - these are function calls, not property names
|
|
293
|
+
if (!keyWithOutArguments || keyWithOutArguments.length === 0) return false;
|
|
202
294
|
return !/\s/.test(keyWithOutArguments);
|
|
203
295
|
}
|
|
204
296
|
|
|
@@ -206,20 +298,28 @@ export default function constructMockCode(
|
|
|
206
298
|
mockName: string,
|
|
207
299
|
dependencySchemas: DeepReadonly<DataStructure['dependencySchemas']>,
|
|
208
300
|
entityType?: EntityType,
|
|
209
|
-
|
|
301
|
+
_canonicalKey?: string, // DEPRECATED: No longer used, kept for API compatibility
|
|
302
|
+
options?: {
|
|
303
|
+
keepOriginalFunctionName?: boolean;
|
|
304
|
+
uniqueFunctionSuffix?: string;
|
|
305
|
+
skipOriginalSpread?: boolean; // Skip spreading from __cyOriginal when it won't be defined
|
|
306
|
+
},
|
|
210
307
|
) {
|
|
211
|
-
// Check
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
? variableQualifierMatch[1]
|
|
308
|
+
// Check if mockName is a call signature (e.g., "useFetcher<User>()", "db.select(query)")
|
|
309
|
+
const mockNameIsCallSignature = isCallSignature(mockName);
|
|
310
|
+
|
|
311
|
+
// For call signatures, use the original signature for data access but generate
|
|
312
|
+
// a valid JS function name from it
|
|
313
|
+
const derivedFunctionName = mockNameIsCallSignature
|
|
314
|
+
? callSignatureToFunctionName(mockName)
|
|
219
315
|
: null;
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
316
|
+
|
|
317
|
+
// The baseMockName is the function name without type params and args
|
|
318
|
+
// e.g., "useFetcher<User>()" -> "useFetcher", "db.select(query)" -> "db"
|
|
319
|
+
const baseMockName = mockName.split(/[<(]/)[0];
|
|
320
|
+
|
|
321
|
+
// The data key is the mockName (call signature) for data access
|
|
322
|
+
let dataKey: string;
|
|
223
323
|
|
|
224
324
|
const mockNameParts = splitOutsideParenthesesAndArrays(baseMockName);
|
|
225
325
|
|
|
@@ -231,31 +331,10 @@ export default function constructMockCode(
|
|
|
231
331
|
|
|
232
332
|
for (const filePath in dependencySchemas) {
|
|
233
333
|
for (const entityName in dependencySchemas[filePath]) {
|
|
234
|
-
//
|
|
235
|
-
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
: mockNameParts[0];
|
|
239
|
-
|
|
240
|
-
// Check for direct match
|
|
241
|
-
let matches =
|
|
242
|
-
entityName === targetEntityName || entityName === mockNameParts[0];
|
|
243
|
-
|
|
244
|
-
// If no direct match and no qualifier was provided, check if the entity
|
|
245
|
-
// is stored under a variable-qualified key (e.g., "stateBadge <- getStateBadge")
|
|
246
|
-
// This handles the case where gatherDataForMocks stored the entity with a variable
|
|
247
|
-
// qualifier but writeScenarioComponents called constructMockCode without one.
|
|
248
|
-
if (!matches && !variableQualifier) {
|
|
249
|
-
const qualifiedKeyMatch = entityName.match(
|
|
250
|
-
new RegExp(`^([a-zA-Z_][a-zA-Z0-9_]*)\\s*<-\\s*${mockNameParts[0]}$`),
|
|
251
|
-
);
|
|
252
|
-
if (qualifiedKeyMatch) {
|
|
253
|
-
matches = true;
|
|
254
|
-
// Extract the variable qualifier from the entity name so we can use
|
|
255
|
-
// it for the data lookup key later
|
|
256
|
-
variableQualifier = qualifiedKeyMatch[1];
|
|
257
|
-
}
|
|
258
|
-
}
|
|
334
|
+
// Match entity by base name (without generics/args)
|
|
335
|
+
const entityBaseName = entityName.split(/[<(]/)[0];
|
|
336
|
+
const matches =
|
|
337
|
+
entityBaseName === baseMockName || entityName === mockNameParts[0];
|
|
259
338
|
|
|
260
339
|
if (!matches) continue;
|
|
261
340
|
|
|
@@ -299,6 +378,44 @@ export default function constructMockCode(
|
|
|
299
378
|
}
|
|
300
379
|
}
|
|
301
380
|
|
|
381
|
+
// Check if the entity is used as a function (called with ()) vs an object/namespace.
|
|
382
|
+
// Look for paths in the schema that start with "baseMockName(" or "baseMockName<" indicating function calls.
|
|
383
|
+
// The "<" handles generic type parameters like useLoaderData<T>().
|
|
384
|
+
// Also check dataStructurePath === 'returnValue' which indicates a function return value.
|
|
385
|
+
const entityIsFunction =
|
|
386
|
+
foundEntityWithSignature ||
|
|
387
|
+
dataStructurePath === 'returnValue' ||
|
|
388
|
+
Object.keys(relevantReturnValueSchema ?? {}).some(
|
|
389
|
+
(key) =>
|
|
390
|
+
key.startsWith(`${baseMockName}(`) ||
|
|
391
|
+
key.startsWith(`${baseMockName}<`),
|
|
392
|
+
);
|
|
393
|
+
|
|
394
|
+
// Calculate the data key - use the call signature (mockName) for data access
|
|
395
|
+
// For simple names without parentheses:
|
|
396
|
+
// - Append () ONLY if the entity is a function/hook (detected above)
|
|
397
|
+
// - Don't append () for object/namespace mocks like "supabase"
|
|
398
|
+
if (mockNameIsCallSignature || mockName.includes('(')) {
|
|
399
|
+
dataKey = mockName;
|
|
400
|
+
} else if (entityIsFunction) {
|
|
401
|
+
// Entity is a function/hook - append () to match call signature format
|
|
402
|
+
dataKey = `${mockName}()`;
|
|
403
|
+
} else {
|
|
404
|
+
// Entity is an object/namespace - use bare name as key
|
|
405
|
+
dataKey = mockName;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// Helper to wrap key in appropriate quotes for computed property access
|
|
409
|
+
// Use single quotes when key contains double quotes to avoid syntax errors
|
|
410
|
+
const quotePropertyKey = (key: string): string => {
|
|
411
|
+
const escaped = key.replace(/\n/g, '\\n');
|
|
412
|
+
if (escaped.includes('"')) {
|
|
413
|
+
// Use single quotes, escaping any single quotes in the key
|
|
414
|
+
return `['${escaped.replace(/'/g, "\\'")}']`;
|
|
415
|
+
}
|
|
416
|
+
return `["${escaped}"]`;
|
|
417
|
+
};
|
|
418
|
+
|
|
302
419
|
// Check if the return value schema only contains function type markers
|
|
303
420
|
// (e.g., "validateInputs()": "function") without actual return data
|
|
304
421
|
// (no functionCallReturnValue entries)
|
|
@@ -327,6 +444,8 @@ export default function constructMockCode(
|
|
|
327
444
|
key.startsWith('signature['),
|
|
328
445
|
).length;
|
|
329
446
|
const args = Array.from({ length: argCount }, (_, i) => `arg${i + 1}`);
|
|
447
|
+
// Always add ...rest to accept extra arguments beyond the signature
|
|
448
|
+
args.push('...rest');
|
|
330
449
|
const argsString = args.join(', ');
|
|
331
450
|
|
|
332
451
|
// Generate empty mock function
|
|
@@ -351,8 +470,38 @@ export default function constructMockCode(
|
|
|
351
470
|
key.startsWith('signature['),
|
|
352
471
|
).length;
|
|
353
472
|
const args = Array.from({ length: argCount }, (_, i) => `arg${i + 1}`);
|
|
473
|
+
// Always add ...rest to accept extra arguments beyond the signature
|
|
474
|
+
args.push('...rest');
|
|
354
475
|
const argsString = args.join(', ');
|
|
355
476
|
|
|
477
|
+
// Check for Higher-Order Component (HOC) pattern:
|
|
478
|
+
// - First argument is a function (component) or unknown (couldn't trace type)
|
|
479
|
+
// - Returns a function
|
|
480
|
+
// HOCs like memo, forwardRef, createContext should return their first argument
|
|
481
|
+
//
|
|
482
|
+
// The return value key can be either:
|
|
483
|
+
// - 'memo()' (clean format)
|
|
484
|
+
// - 'memo(({ value, width }: Props) => { ... })' (full component code format)
|
|
485
|
+
const firstArgIsFunctionOrUnknown =
|
|
486
|
+
signatureSchema['signature[0]'] === 'function' ||
|
|
487
|
+
signatureSchema['signature[0]'] === 'unknown';
|
|
488
|
+
const returnsFunction = relevantReturnValueSchema
|
|
489
|
+
? Object.entries(relevantReturnValueSchema).some(([key, value]) => {
|
|
490
|
+
// Check if key represents a function call that returns a function
|
|
491
|
+
// Key should start with the mock name, contain '(', end with ')', and have value 'function'
|
|
492
|
+
const isFunctionCall =
|
|
493
|
+
key.startsWith(mockName + '(') && key.endsWith(')');
|
|
494
|
+
return isFunctionCall && value === 'function';
|
|
495
|
+
})
|
|
496
|
+
: false;
|
|
497
|
+
|
|
498
|
+
if (firstArgIsFunctionOrUnknown && returnsFunction) {
|
|
499
|
+
// HOC pattern detected - return the first argument
|
|
500
|
+
return `function ${mockName}(${argsString}) {
|
|
501
|
+
return arg1;
|
|
502
|
+
}`;
|
|
503
|
+
}
|
|
504
|
+
|
|
356
505
|
// Generate empty mock function
|
|
357
506
|
return `function ${mockName}(${argsString}) {
|
|
358
507
|
// Empty mock - original function mocked out
|
|
@@ -413,22 +562,21 @@ export default function constructMockCode(
|
|
|
413
562
|
// so "useLoaderData<typeof loader>()" becomes "useLoaderData()"
|
|
414
563
|
name = cleanOutTypes(name);
|
|
415
564
|
|
|
416
|
-
// For
|
|
417
|
-
// This
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
//
|
|
421
|
-
|
|
422
|
-
|
|
565
|
+
// For root data access, use the dataKey (original call signature or canonical key)
|
|
566
|
+
// This preserves the original call signature for LLM clarity
|
|
567
|
+
if (isRootAccess) {
|
|
568
|
+
// For call signature format, use the original mockName as the data key
|
|
569
|
+
// e.g., scenarios().data()?.["useFetcher<User>()"]
|
|
570
|
+
// e.g., scenarios().data()?.["db.select(usersQuery)"]
|
|
571
|
+
return `?.${quotePropertyKey(dataKey)}`;
|
|
423
572
|
}
|
|
424
573
|
|
|
425
574
|
// Only use unquoted array access syntax for pure array indices like [0], [1]
|
|
426
|
-
|
|
427
|
-
if (name.match(/^\[\d+\]$/) && !name.includes(' <- ')) {
|
|
575
|
+
if (name.match(/^\[\d+\]$/)) {
|
|
428
576
|
return `?.${name}`;
|
|
429
577
|
}
|
|
430
578
|
|
|
431
|
-
return
|
|
579
|
+
return `?.${quotePropertyKey(name)}`;
|
|
432
580
|
};
|
|
433
581
|
|
|
434
582
|
const constructDataPaths = () => {
|
|
@@ -496,7 +644,20 @@ export default function constructMockCode(
|
|
|
496
644
|
hasNoReturnData,
|
|
497
645
|
} = returnValue;
|
|
498
646
|
|
|
499
|
-
|
|
647
|
+
// When an array has differentiated indices ([0], [1], etc.), filter out any
|
|
648
|
+
// non-index items from nested. These non-index items come from generic [] paths
|
|
649
|
+
// like [].filter or [].sort, which describe element properties, not array elements.
|
|
650
|
+
// Including them would generate invalid syntax like "sort: ..." inside an array literal.
|
|
651
|
+
const hasDifferentiatedIndices =
|
|
652
|
+
isArray &&
|
|
653
|
+
nested &&
|
|
654
|
+
nested.some((n) => n.name.match(/^\[\d+\]$/) && n.name !== '[0]');
|
|
655
|
+
const filteredNested =
|
|
656
|
+
hasDifferentiatedIndices && nested
|
|
657
|
+
? nested.filter((n) => n.name.match(/^\[\d+\]$/))
|
|
658
|
+
: nested;
|
|
659
|
+
|
|
660
|
+
const nestedContent: (string | undefined)[] = (filteredNested ?? []).map(
|
|
500
661
|
(nestedItem) => {
|
|
501
662
|
const nestedContent = constructReturnValueString(
|
|
502
663
|
nestedItem,
|
|
@@ -580,53 +741,114 @@ export default function constructMockCode(
|
|
|
580
741
|
) {
|
|
581
742
|
levelContentItems.push(...dataPaths.map((path) => `...${path}`));
|
|
582
743
|
}
|
|
583
|
-
|
|
744
|
+
// Filter out nested content that would be invalid as object properties
|
|
745
|
+
// (e.g., bare arrow functions like "() => {...}" without a property name)
|
|
746
|
+
// Only apply this filter when building object content, not array content.
|
|
747
|
+
// Bare arrow functions ARE valid as array elements (like [0] = {...}, [1] = () => {...})
|
|
748
|
+
// Check both isArray (item IS an array) and returnsFunctionArray (item returns an array)
|
|
749
|
+
const inArrayContext = isArray || returnsFunctionArray;
|
|
750
|
+
const validNestedContent = nestedContent.filter((content) => {
|
|
751
|
+
if (!content) return false;
|
|
752
|
+
// Only filter bare arrow functions when NOT in array context
|
|
753
|
+
// In arrays, bare arrow functions are valid elements
|
|
754
|
+
if (!inArrayContext && content.match(/^\s*\([^)]*\)\s*=>/)) {
|
|
755
|
+
return false;
|
|
756
|
+
}
|
|
757
|
+
return true;
|
|
758
|
+
});
|
|
759
|
+
levelContentItems.push(...validNestedContent);
|
|
584
760
|
|
|
585
761
|
let levelContents: string = levelContentItems.filter(Boolean).join(',\n');
|
|
586
762
|
if (returnsFunctionArgs) {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
763
|
+
// When returnsFunctionArgs is empty [] OR has a single literal string argument,
|
|
764
|
+
// the function returns a callable function (e.g., getTranslate() returns t,
|
|
765
|
+
// where t('key') looks up translations)
|
|
766
|
+
// Generate a dispatch function that looks up keys based on the argument
|
|
767
|
+
//
|
|
768
|
+
// Detect translation-like pattern:
|
|
769
|
+
// - Data path ends with ["('some.literal')"] - a literal string key
|
|
770
|
+
// - This means the mock data has keys like "('common.surveys')": "Surveys"
|
|
771
|
+
// - Exclude ["()"] which is an empty function call (not a translation pattern)
|
|
772
|
+
const dataPath = dataPaths[0];
|
|
773
|
+
// Pattern matches ?.["('...')"] at end of path, but NOT ?.["()"] (empty args)
|
|
774
|
+
const literalKeyPattern = dataPath?.match(/\?\.\["\('.+'\)"\]$/);
|
|
775
|
+
|
|
776
|
+
if (
|
|
777
|
+
!returnsFunctionArray &&
|
|
778
|
+
dataPaths.length === 1 &&
|
|
779
|
+
literalKeyPattern // Only dispatch when there's a literal key pattern
|
|
780
|
+
) {
|
|
781
|
+
// Function returns a function - generate dispatch function
|
|
782
|
+
// Strip the literal key from the path and use dynamic lookup
|
|
783
|
+
const dataPathBase = literalKeyPattern
|
|
784
|
+
? dataPath.replace(/\?\.\["\('.+'\)"\]$/, '')
|
|
785
|
+
: dataPath;
|
|
786
|
+
const funcContents = `return ${dataPathBase}?.[\`('\${arg1}')\`]`;
|
|
787
|
+
levelContents = `(arg1) => {\n${indent(funcContents)}\n}`;
|
|
788
|
+
|
|
789
|
+
if (!isArray) {
|
|
790
|
+
return levelContents;
|
|
603
791
|
}
|
|
604
792
|
} else {
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
if (
|
|
612
|
-
hasNoReturnData ||
|
|
613
|
-
(hasNestedItems && !hasActualNestedContent)
|
|
614
|
-
) {
|
|
793
|
+
const argsString = returnsFunctionArgs
|
|
794
|
+
.map((_, index) => `arg${index + 1}`)
|
|
795
|
+
.join(', ');
|
|
796
|
+
let funcContents = '';
|
|
797
|
+
if (returnsFunctionArray) {
|
|
798
|
+
if (hasNoReturnData) {
|
|
615
799
|
// Function has no return data (only signatures) - return empty array
|
|
616
800
|
funcContents = 'return []';
|
|
617
|
-
} else {
|
|
618
|
-
//
|
|
801
|
+
} else if (levelContents.length === 0 && dataPaths.length === 1) {
|
|
802
|
+
// When returning an array with no nested content, return the data path directly
|
|
803
|
+
// (the data path points to the array in scenario data)
|
|
619
804
|
funcContents = `return ${dataPaths[0]}`;
|
|
805
|
+
} else if (levelContents.length === 0) {
|
|
806
|
+
funcContents = 'return []';
|
|
807
|
+
} else {
|
|
808
|
+
funcContents = `return [\n${indent(levelContents)}\n]`;
|
|
620
809
|
}
|
|
621
810
|
} else {
|
|
622
|
-
|
|
811
|
+
// Check if function has no actual return data (only signatures)
|
|
812
|
+
const hasNestedItems = nested && nested.length > 0;
|
|
813
|
+
const hasActualNestedContent =
|
|
814
|
+
nestedContent.filter(Boolean).length > 0;
|
|
815
|
+
|
|
816
|
+
if (levelContentItems.length === 1 && dataPaths.length === 1) {
|
|
817
|
+
if (
|
|
818
|
+
hasNoReturnData ||
|
|
819
|
+
(hasNestedItems && !hasActualNestedContent)
|
|
820
|
+
) {
|
|
821
|
+
// Function has no return data (only signatures) - return empty array
|
|
822
|
+
funcContents = 'return []';
|
|
823
|
+
} else {
|
|
824
|
+
// Has return data - return data path
|
|
825
|
+
funcContents = `return ${dataPaths[0]}`;
|
|
826
|
+
}
|
|
827
|
+
} else {
|
|
828
|
+
funcContents = `return {\n${indent(levelContents)}\n}`;
|
|
829
|
+
}
|
|
623
830
|
}
|
|
624
|
-
}
|
|
625
831
|
|
|
626
|
-
|
|
832
|
+
levelContents = `(${argsString}) => {\n${indent(funcContents)}\n}`;
|
|
833
|
+
|
|
834
|
+
if (!isArray) {
|
|
835
|
+
return levelContents;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
627
838
|
|
|
628
|
-
|
|
629
|
-
|
|
839
|
+
// For generic arrays of functions WITH nested properties (e.g., functionCallReturnValue[] = "function"
|
|
840
|
+
// with nested .filter, .sort, etc.), the levelContents would be a bare arrow function "() => {...}"
|
|
841
|
+
// that wraps object content. Using this in a .map(({...})) creates invalid syntax like "({ () => {...} })".
|
|
842
|
+
// When isGenericArray is true AND there are nested properties, we're accessing data from the elements,
|
|
843
|
+
// not calling them - so skip the function wrapping.
|
|
844
|
+
// But if there are NO nested properties, keep the wrapper because callers may want to call the elements.
|
|
845
|
+
const hasNonStructuralNestedItems =
|
|
846
|
+
nested &&
|
|
847
|
+
nested.length > 0 &&
|
|
848
|
+
nested.some((n) => !n.name.match(/^\[\d*\]$/));
|
|
849
|
+
if (isGenericArray && hasNonStructuralNestedItems) {
|
|
850
|
+
// Skip the arrow function wrapper - just use the nested content directly
|
|
851
|
+
levelContents = levelContentItems.filter(Boolean).join(',\n');
|
|
630
852
|
}
|
|
631
853
|
}
|
|
632
854
|
|
|
@@ -663,24 +885,369 @@ export default function constructMockCode(
|
|
|
663
885
|
// When GENERIC array (using []) has nested content (like functions that need wrapping),
|
|
664
886
|
// use .map() to transform ALL elements instead of just creating [0]
|
|
665
887
|
// For DIFFERENTIATED arrays (using [0], [1], etc.), keep the static array structure
|
|
888
|
+
//
|
|
889
|
+
// IMPORTANT: If the nested content contains differentiated indices like [0], [1],
|
|
890
|
+
// we MUST use static array pattern, not .map(). The presence of differentiated
|
|
891
|
+
// indices means the array elements have different types/structures, so .map()
|
|
892
|
+
// would generate invalid code trying to treat them uniformly.
|
|
893
|
+
const hasDifferentiatedIndices =
|
|
894
|
+
nested &&
|
|
895
|
+
nested.some((n) => n.name.match(/^\[\d+\]$/) && n.name !== '[0]');
|
|
666
896
|
if (
|
|
667
897
|
isGenericArray &&
|
|
668
898
|
nestedContent.length > 0 &&
|
|
669
|
-
dataPaths.length > 0
|
|
899
|
+
dataPaths.length > 0 &&
|
|
900
|
+
!hasDifferentiatedIndices
|
|
670
901
|
) {
|
|
671
902
|
// Get the array base path (without the [0])
|
|
672
903
|
const arrayBasePath = dataPaths[0].replace(/\?\.\[0\]$/, '');
|
|
673
904
|
// Replace [0] references with [__idx__] in level contents
|
|
674
|
-
|
|
905
|
+
let mappedContents = levelContents.replace(
|
|
675
906
|
/\?\.\[0\]/g,
|
|
676
907
|
'?.[__idx__]',
|
|
677
908
|
);
|
|
678
909
|
// levelContents may already be wrapped in {...} from structural [0] element,
|
|
679
910
|
// so check if we need to add the wrapper or not
|
|
680
911
|
const needsWrapper = !mappedContents.trim().startsWith('{');
|
|
912
|
+
|
|
913
|
+
// Helper to check if a position is inside a string literal
|
|
914
|
+
// Returns the end position of the string if inside one, -1 otherwise
|
|
915
|
+
// Defined here so it's accessible in both needsWrapper branches
|
|
916
|
+
const skipStringLiteral = (
|
|
917
|
+
content: string,
|
|
918
|
+
pos: number,
|
|
919
|
+
): number => {
|
|
920
|
+
const char = content[pos];
|
|
921
|
+
if (char !== '"' && char !== "'" && char !== '`') return -1;
|
|
922
|
+
// Find the matching closing quote
|
|
923
|
+
let j = pos + 1;
|
|
924
|
+
while (j < content.length) {
|
|
925
|
+
if (content[j] === '\\') {
|
|
926
|
+
j += 2; // Skip escaped character
|
|
927
|
+
continue;
|
|
928
|
+
}
|
|
929
|
+
if (content[j] === char) {
|
|
930
|
+
return j + 1; // Return position after closing quote
|
|
931
|
+
}
|
|
932
|
+
j++;
|
|
933
|
+
}
|
|
934
|
+
return content.length; // Unclosed string, skip to end
|
|
935
|
+
};
|
|
936
|
+
|
|
937
|
+
// Filter out bare arrow functions which are invalid as object properties.
|
|
938
|
+
// Arrow functions can be multi-line, so we need to match the entire function body, not just the first line.
|
|
939
|
+
// Pattern: starts with "(args) =>", followed by either:
|
|
940
|
+
// - A single-line body: "() => expression"
|
|
941
|
+
// - A multi-line body: "() => { ... }" (with matching braces)
|
|
942
|
+
// IMPORTANT: Only filter BARE arrow functions (without property names).
|
|
943
|
+
// "() => {...}" is invalid, but "get: (arg1) => {...}" is valid.
|
|
944
|
+
// We use a function to properly handle nested braces.
|
|
945
|
+
// Defined here so it's accessible in both needsWrapper branches
|
|
946
|
+
const filterOutArrowFunctions = (content: string): string => {
|
|
947
|
+
const result: string[] = [];
|
|
948
|
+
let i = 0;
|
|
949
|
+
while (i < content.length) {
|
|
950
|
+
// Skip over string literals entirely
|
|
951
|
+
const stringEnd = skipStringLiteral(content, i);
|
|
952
|
+
if (stringEnd !== -1) {
|
|
953
|
+
result.push(content.slice(i, stringEnd));
|
|
954
|
+
i = stringEnd;
|
|
955
|
+
continue;
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
// Check if we're at the start of an arrow function (with optional leading whitespace)
|
|
959
|
+
const arrowMatch = content
|
|
960
|
+
.slice(i)
|
|
961
|
+
.match(/^(\s*)\([^)]*\)\s*=>\s*/);
|
|
962
|
+
if (arrowMatch) {
|
|
963
|
+
// Check if this is a bare arrow function or a named property with arrow function value
|
|
964
|
+
// Look back to see if there's a "key:" pattern before this position
|
|
965
|
+
const before = content.slice(0, i);
|
|
966
|
+
const beforeTrimmed = before.trim();
|
|
967
|
+
// Valid patterns where arrow function is NOT bare:
|
|
968
|
+
// 1. Property value: "key: (arg) => ..." - ends with ':'
|
|
969
|
+
// 2. Function argument: ".map((arg) => ..." - ends with '('
|
|
970
|
+
// NOTE: We don't include ',' because "{ prop, () => {} }" is invalid
|
|
971
|
+
// (can't distinguish function argument from object property context)
|
|
972
|
+
const isPropertyValue = beforeTrimmed.endsWith(':');
|
|
973
|
+
const isFunctionArg = beforeTrimmed.endsWith('(');
|
|
974
|
+
const hasPropertyName = isPropertyValue || isFunctionArg;
|
|
975
|
+
|
|
976
|
+
if (!hasPropertyName) {
|
|
977
|
+
// This is a bare arrow function - filter it out
|
|
978
|
+
// Found arrow function start, need to find its end
|
|
979
|
+
const afterArrow = i + arrowMatch[0].length;
|
|
980
|
+
if (content[afterArrow] === '{') {
|
|
981
|
+
// Multi-line arrow function - find matching closing brace
|
|
982
|
+
// Must respect string literals when counting braces
|
|
983
|
+
let braceCount = 1;
|
|
984
|
+
let j = afterArrow + 1;
|
|
985
|
+
while (j < content.length && braceCount > 0) {
|
|
986
|
+
const strEnd = skipStringLiteral(content, j);
|
|
987
|
+
if (strEnd !== -1) {
|
|
988
|
+
j = strEnd;
|
|
989
|
+
continue;
|
|
990
|
+
}
|
|
991
|
+
if (content[j] === '{') braceCount++;
|
|
992
|
+
if (content[j] === '}') braceCount--;
|
|
993
|
+
j++;
|
|
994
|
+
}
|
|
995
|
+
// Skip past the arrow function
|
|
996
|
+
i = j;
|
|
997
|
+
// Only skip trailing comma, keep newlines
|
|
998
|
+
while (i < content.length && content[i] === ' ') {
|
|
999
|
+
i++;
|
|
1000
|
+
}
|
|
1001
|
+
if (content[i] === ',') {
|
|
1002
|
+
i++; // Skip the comma after the arrow function
|
|
1003
|
+
}
|
|
1004
|
+
} else {
|
|
1005
|
+
// Single expression arrow function - skip to next comma or newline
|
|
1006
|
+
let j = afterArrow;
|
|
1007
|
+
while (
|
|
1008
|
+
j < content.length &&
|
|
1009
|
+
content[j] !== ',' &&
|
|
1010
|
+
content[j] !== '\n'
|
|
1011
|
+
) {
|
|
1012
|
+
j++;
|
|
1013
|
+
}
|
|
1014
|
+
i = j;
|
|
1015
|
+
if (content[i] === ',') i++; // Skip the comma
|
|
1016
|
+
}
|
|
1017
|
+
continue;
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
// Not a bare arrow function, keep this character
|
|
1021
|
+
result.push(content[i]);
|
|
1022
|
+
i++;
|
|
1023
|
+
}
|
|
1024
|
+
return result.join('');
|
|
1025
|
+
};
|
|
1026
|
+
|
|
1027
|
+
// Filter out bare object blocks (e.g., "{ ...spread, props }," without a property name)
|
|
1028
|
+
// These are invalid in object literal context - you need "key: { ... }" not just "{ ... }"
|
|
1029
|
+
// Defined here so it's accessible in both needsWrapper branches
|
|
1030
|
+
// The skipFirstBrace parameter allows the else branch to preserve the outer object
|
|
1031
|
+
const filterOutBareObjects = (
|
|
1032
|
+
content: string,
|
|
1033
|
+
skipFirstBrace = false,
|
|
1034
|
+
): string => {
|
|
1035
|
+
const result: string[] = [];
|
|
1036
|
+
let i = 0;
|
|
1037
|
+
let firstBraceSkipped = false;
|
|
1038
|
+
while (i < content.length) {
|
|
1039
|
+
// Skip over string literals entirely - braces inside strings should not be processed
|
|
1040
|
+
const stringEnd = skipStringLiteral(content, i);
|
|
1041
|
+
if (stringEnd !== -1) {
|
|
1042
|
+
result.push(content.slice(i, stringEnd));
|
|
1043
|
+
i = stringEnd;
|
|
1044
|
+
continue;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
// Check if we're at a bare object start (newline/comma followed by { without : before it)
|
|
1048
|
+
// Look back to see if there's a colon (property assignment) before this brace
|
|
1049
|
+
const isStartOfLine =
|
|
1050
|
+
i === 0 ||
|
|
1051
|
+
content[i - 1] === '\n' ||
|
|
1052
|
+
content.slice(0, i).trim().endsWith(',');
|
|
1053
|
+
if (content[i] === '{' && isStartOfLine) {
|
|
1054
|
+
// Check if this is actually a bare object (not "key: {")
|
|
1055
|
+
const beforeTrimmed = content.slice(0, i).trim();
|
|
1056
|
+
const isBareObject =
|
|
1057
|
+
beforeTrimmed.endsWith(',') ||
|
|
1058
|
+
beforeTrimmed === '' ||
|
|
1059
|
+
beforeTrimmed.endsWith('(');
|
|
1060
|
+
|
|
1061
|
+
if (isBareObject) {
|
|
1062
|
+
// If skipFirstBrace is true and this is the first bare brace at position 0,
|
|
1063
|
+
// don't filter it - it's the intentional outer object wrapper
|
|
1064
|
+
if (skipFirstBrace && !firstBraceSkipped && i === 0) {
|
|
1065
|
+
firstBraceSkipped = true;
|
|
1066
|
+
result.push(content[i]);
|
|
1067
|
+
i++;
|
|
1068
|
+
continue;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
// Find matching closing brace, respecting string literals
|
|
1072
|
+
let braceCount = 1;
|
|
1073
|
+
let j = i + 1;
|
|
1074
|
+
while (j < content.length && braceCount > 0) {
|
|
1075
|
+
const strEnd = skipStringLiteral(content, j);
|
|
1076
|
+
if (strEnd !== -1) {
|
|
1077
|
+
j = strEnd;
|
|
1078
|
+
continue;
|
|
1079
|
+
}
|
|
1080
|
+
if (content[j] === '{') braceCount++;
|
|
1081
|
+
if (content[j] === '}') braceCount--;
|
|
1082
|
+
j++;
|
|
1083
|
+
}
|
|
1084
|
+
// Skip past the object
|
|
1085
|
+
i = j;
|
|
1086
|
+
// Skip trailing comma
|
|
1087
|
+
while (i < content.length && content[i] === ' ') {
|
|
1088
|
+
i++;
|
|
1089
|
+
}
|
|
1090
|
+
if (content[i] === ',') {
|
|
1091
|
+
i++;
|
|
1092
|
+
}
|
|
1093
|
+
continue;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
result.push(content[i]);
|
|
1097
|
+
i++;
|
|
1098
|
+
}
|
|
1099
|
+
return result.join('');
|
|
1100
|
+
};
|
|
1101
|
+
|
|
1102
|
+
// Helper to clean up formatting issues after filtering
|
|
1103
|
+
const cleanupContent = (content: string): string => {
|
|
1104
|
+
return (
|
|
1105
|
+
content
|
|
1106
|
+
.replace(/,\s*,/g, ',') // Double commas
|
|
1107
|
+
.replace(/,(\s*\n\s*\})/g, '$1') // Trailing comma before closing brace
|
|
1108
|
+
.replace(/\{\s*\n\s*,/g, '{\n') // Leading comma after opening brace
|
|
1109
|
+
// Remove incomplete .map calls where callback was filtered out
|
|
1110
|
+
// Pattern: ".map" followed by newline/whitespace without "(" for args
|
|
1111
|
+
.replace(/\?\.map(?=\s*[\n\r,}\]])/g, '')
|
|
1112
|
+
.replace(/\.map(?=\s*[\n\r,}\]])/g, '')
|
|
1113
|
+
// Clean up orphan })) sequences (from nested filtered map callbacks)
|
|
1114
|
+
.replace(/\s*\}\)\)\s*\n\s*\}/g, '\n}')
|
|
1115
|
+
.replace(/^\s*\n/gm, '') // Empty lines
|
|
1116
|
+
.trim()
|
|
1117
|
+
);
|
|
1118
|
+
};
|
|
1119
|
+
|
|
681
1120
|
if (needsWrapper) {
|
|
682
|
-
|
|
1121
|
+
// Apply filters to remove invalid content
|
|
1122
|
+
mappedContents = filterOutArrowFunctions(mappedContents);
|
|
1123
|
+
mappedContents = filterOutBareObjects(mappedContents);
|
|
1124
|
+
mappedContents = cleanupContent(mappedContents);
|
|
1125
|
+
|
|
1126
|
+
// If mappedContents is empty after filtering, don't generate .map() at all
|
|
1127
|
+
// Just use the array path directly with spread or as-is
|
|
1128
|
+
// This prevents orphan )) from empty .map() callbacks
|
|
1129
|
+
const cleanedForEmptyCheck = mappedContents
|
|
1130
|
+
.replace(/\s+/g, '')
|
|
1131
|
+
.replace(/,+/g, '');
|
|
1132
|
+
if (cleanedForEmptyCheck.length === 0) {
|
|
1133
|
+
// Content is empty - just return the array directly
|
|
1134
|
+
returnValueContents = arrayBasePath;
|
|
1135
|
+
} else {
|
|
1136
|
+
// Check if mappedContents is just a bare expression (no property names)
|
|
1137
|
+
// A bare expression like "scenarios().data()?.["key"]?.[__idx__]," cannot be
|
|
1138
|
+
// wrapped in ({ }) because it's not a valid object property.
|
|
1139
|
+
// Pattern: content has no ":" that's not inside brackets/parens/strings
|
|
1140
|
+
const hasBareExpression = (() => {
|
|
1141
|
+
const trimmed = mappedContents.trim().replace(/,\s*$/, ''); // Remove trailing comma
|
|
1142
|
+
let depth = 0;
|
|
1143
|
+
let inString = false;
|
|
1144
|
+
let stringChar = '';
|
|
1145
|
+
for (let i = 0; i < trimmed.length; i++) {
|
|
1146
|
+
const char = trimmed[i];
|
|
1147
|
+
if (inString) {
|
|
1148
|
+
if (char === '\\') {
|
|
1149
|
+
i++; // Skip escaped char
|
|
1150
|
+
continue;
|
|
1151
|
+
}
|
|
1152
|
+
if (char === stringChar) {
|
|
1153
|
+
inString = false;
|
|
1154
|
+
}
|
|
1155
|
+
continue;
|
|
1156
|
+
}
|
|
1157
|
+
if (char === '"' || char === "'" || char === '`') {
|
|
1158
|
+
inString = true;
|
|
1159
|
+
stringChar = char;
|
|
1160
|
+
continue;
|
|
1161
|
+
}
|
|
1162
|
+
if (char === '(' || char === '[' || char === '{') {
|
|
1163
|
+
depth++;
|
|
1164
|
+
continue;
|
|
1165
|
+
}
|
|
1166
|
+
if (char === ')' || char === ']' || char === '}') {
|
|
1167
|
+
depth--;
|
|
1168
|
+
continue;
|
|
1169
|
+
}
|
|
1170
|
+
// Found a colon at depth 0 = has property name
|
|
1171
|
+
if (char === ':' && depth === 0) {
|
|
1172
|
+
return false;
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
return true;
|
|
1176
|
+
})();
|
|
1177
|
+
|
|
1178
|
+
if (hasBareExpression) {
|
|
1179
|
+
// Content is just an expression - return it directly without object wrapper
|
|
1180
|
+
const trimmedContent = mappedContents
|
|
1181
|
+
.trim()
|
|
1182
|
+
.replace(/,\s*$/, '');
|
|
1183
|
+
returnValueContents = `${arrayBasePath}?.map((__item__, __idx__) => (\n${indent(trimmedContent)}\n))`;
|
|
1184
|
+
} else {
|
|
1185
|
+
returnValueContents = `${arrayBasePath}?.map((__item__, __idx__) => ({\n${indent(mappedContents)}\n}))`;
|
|
1186
|
+
}
|
|
1187
|
+
} // Close the empty content check else block
|
|
683
1188
|
} else {
|
|
1189
|
+
// Content already starts with '{'. Check if there are additional properties after the inner object.
|
|
1190
|
+
// If so, we need to merge them INTO the object, not leave them outside.
|
|
1191
|
+
// Pattern: "{ ...spread, props },\nfilter: ...,\nsort: ..."
|
|
1192
|
+
// Should become: "{ ...spread, props, filter: ..., sort: ... }"
|
|
1193
|
+
const trimmed = mappedContents.trim();
|
|
1194
|
+
|
|
1195
|
+
// Find first }, at depth 0 that is NOT inside a string literal
|
|
1196
|
+
// This prevents splitting keys like ?.["useQuery({ id }, { enabled })"]
|
|
1197
|
+
// and also prevents finding }, inside nested arrow functions
|
|
1198
|
+
const findBraceCommaOutsideStrings = (
|
|
1199
|
+
content: string,
|
|
1200
|
+
): number => {
|
|
1201
|
+
let i = 0;
|
|
1202
|
+
let depth = 0; // Track brace depth to find the outer object's },
|
|
1203
|
+
while (i < content.length - 1) {
|
|
1204
|
+
// Skip over string literals
|
|
1205
|
+
const strEnd = skipStringLiteral(content, i);
|
|
1206
|
+
if (strEnd !== -1) {
|
|
1207
|
+
i = strEnd;
|
|
1208
|
+
continue;
|
|
1209
|
+
}
|
|
1210
|
+
// Track brace depth
|
|
1211
|
+
if (content[i] === '{') {
|
|
1212
|
+
depth++;
|
|
1213
|
+
i++;
|
|
1214
|
+
continue;
|
|
1215
|
+
}
|
|
1216
|
+
// Check for }, pattern at depth 1 (the outer object level)
|
|
1217
|
+
// We're looking for the outer object's closing brace, which is at depth 1
|
|
1218
|
+
// (we started at depth 0, opened { at depth 0 -> 1)
|
|
1219
|
+
if (content[i] === '}') {
|
|
1220
|
+
depth--;
|
|
1221
|
+
if (
|
|
1222
|
+
depth === 0 &&
|
|
1223
|
+
i + 1 < content.length &&
|
|
1224
|
+
content[i + 1] === ','
|
|
1225
|
+
) {
|
|
1226
|
+
return i;
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
i++;
|
|
1230
|
+
}
|
|
1231
|
+
return -1;
|
|
1232
|
+
};
|
|
1233
|
+
|
|
1234
|
+
const firstBraceEnd = findBraceCommaOutsideStrings(trimmed);
|
|
1235
|
+
if (firstBraceEnd !== -1) {
|
|
1236
|
+
// Found pattern "{ ... }," followed by more content
|
|
1237
|
+
// Extract the inner object and the trailing properties
|
|
1238
|
+
const innerObject = trimmed.slice(0, firstBraceEnd);
|
|
1239
|
+
const trailingContent = trimmed.slice(firstBraceEnd + 2).trim();
|
|
1240
|
+
if (trailingContent) {
|
|
1241
|
+
// Merge trailing properties into the inner object
|
|
1242
|
+
mappedContents = `${innerObject},\n${trailingContent}\n}`;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
// Even when content starts with {, we need to filter out invalid properties inside
|
|
1246
|
+
// (arrow functions and bare objects that were generated from the schema)
|
|
1247
|
+
// Pass skipFirstBrace=true because the content's outer { is the intentional wrapper
|
|
1248
|
+
mappedContents = filterOutArrowFunctions(mappedContents);
|
|
1249
|
+
mappedContents = filterOutBareObjects(mappedContents, true);
|
|
1250
|
+
mappedContents = cleanupContent(mappedContents);
|
|
684
1251
|
returnValueContents = `${arrayBasePath}?.map((__item__, __idx__) => (\n${indent(mappedContents)}\n))`;
|
|
685
1252
|
}
|
|
686
1253
|
} else {
|
|
@@ -699,6 +1266,13 @@ export default function constructMockCode(
|
|
|
699
1266
|
if (args && args.length > 0) {
|
|
700
1267
|
if (!isValidKey(name)) return;
|
|
701
1268
|
|
|
1269
|
+
// Skip array index patterns like [], [0], [1] when they have args
|
|
1270
|
+
// These represent function calls on array elements, not property keys
|
|
1271
|
+
// e.g., customSizes[].(args) means each array element is callable, not a property named "[]"
|
|
1272
|
+
if (name.match(/^\[\d*\]$/)) {
|
|
1273
|
+
return;
|
|
1274
|
+
}
|
|
1275
|
+
|
|
702
1276
|
const mostArgs = args.sort(
|
|
703
1277
|
(a: string[], b: string[]) => b.length - a.length,
|
|
704
1278
|
)[0];
|
|
@@ -758,8 +1332,18 @@ export default function constructMockCode(
|
|
|
758
1332
|
// Use all paths for fallback (existing behavior)
|
|
759
1333
|
fallbackContent = `return ${returnValueContents}`;
|
|
760
1334
|
} else {
|
|
761
|
-
//
|
|
762
|
-
|
|
1335
|
+
// No explicit fallback paths - return the first literal's value as default
|
|
1336
|
+
// Returning spread of all values is dangerous because if values are primitives (strings),
|
|
1337
|
+
// spreading them creates objects with numeric keys like {0:'a', 1:'b', ...}
|
|
1338
|
+
// which causes "Objects are not valid as React child" errors
|
|
1339
|
+
const firstLiteralValue = literalKeys[0];
|
|
1340
|
+
const firstGroupPaths = argGroups.get(firstLiteralValue);
|
|
1341
|
+
if (firstGroupPaths && firstGroupPaths.length === 1) {
|
|
1342
|
+
fallbackContent = `return ${firstGroupPaths[0]}`;
|
|
1343
|
+
} else {
|
|
1344
|
+
// Multiple paths for first literal - return undefined as safe fallback
|
|
1345
|
+
fallbackContent = `return undefined`;
|
|
1346
|
+
}
|
|
763
1347
|
}
|
|
764
1348
|
|
|
765
1349
|
const funcContents =
|
|
@@ -769,14 +1353,29 @@ export default function constructMockCode(
|
|
|
769
1353
|
content = `${cleanOutTypes(name)}: ${isAsyncFunction ? 'async ' : ''}(${argsString}) => {\n${indent(funcContents)}\n}`;
|
|
770
1354
|
} else {
|
|
771
1355
|
// No argument variants - use existing behavior
|
|
772
|
-
|
|
1356
|
+
// But if there's nested content, we need to include it in the return object
|
|
1357
|
+
// (similar to how argument variant branches handle this at line 1070-1072)
|
|
1358
|
+
const hasNestedContent = validNestedContent.length > 0;
|
|
1359
|
+
let funcReturnContents: string;
|
|
1360
|
+
if (hasNestedContent && levelContentItems.length > 1) {
|
|
1361
|
+
// Include both spread and nested content in the return
|
|
1362
|
+
funcReturnContents = `{\n${indent(levelContents)}\n}`;
|
|
1363
|
+
} else {
|
|
1364
|
+
funcReturnContents = returnValueContents;
|
|
1365
|
+
}
|
|
1366
|
+
const funcContents = `return ${funcReturnContents}`;
|
|
773
1367
|
content = `${cleanOutTypes(name)}: ${isAsyncFunction ? 'async ' : ''}(${argsString}) => {\n${indent(funcContents)}\n}`;
|
|
774
1368
|
}
|
|
775
1369
|
} else {
|
|
776
1370
|
if (!isValidKey(name)) {
|
|
777
1371
|
return;
|
|
778
1372
|
} else if (name.match(/\[\d*\]/)) {
|
|
1373
|
+
// Numeric array index like [0], [1] - can be used as computed property
|
|
779
1374
|
content = returnValueContents;
|
|
1375
|
+
} else if (name.match(/^\[[a-zA-Z_]\w*\]$/)) {
|
|
1376
|
+
// Variable-based index like [currentItemIndex] - must be quoted string key
|
|
1377
|
+
// Otherwise JavaScript would try to evaluate the variable name
|
|
1378
|
+
content = `"${safeString(name)}": ${returnValueContents}`;
|
|
780
1379
|
} else {
|
|
781
1380
|
content = `${safeString(name)}: ${returnValueContents}`;
|
|
782
1381
|
}
|
|
@@ -853,8 +1452,8 @@ export default function constructMockCode(
|
|
|
853
1452
|
}
|
|
854
1453
|
}
|
|
855
1454
|
|
|
856
|
-
//
|
|
857
|
-
//
|
|
1455
|
+
// Compare against baseMockName (without generics/args), not the full mockName
|
|
1456
|
+
// e.g., for "useFetcher<User>()", baseMockName is "useFetcher"
|
|
858
1457
|
if (parts[0].split('(')[0] !== baseMockName) continue;
|
|
859
1458
|
|
|
860
1459
|
// Include paths with functionCallReturnValue OR function-typed paths that need mocking
|
|
@@ -970,6 +1569,17 @@ export default function constructMockCode(
|
|
|
970
1569
|
const nextIsArray = !!nextPart?.match(/^\[\d*\]/);
|
|
971
1570
|
const isDifferentiatedArray = !!part?.match(/^\[\d+\]/);
|
|
972
1571
|
const nextIsDifferentiatedArray = !!nextPart?.match(/^\[\d+\]/);
|
|
1572
|
+
|
|
1573
|
+
// Variable index patterns like [currentItemIndex] or [targetIndex] indicate array access
|
|
1574
|
+
// but don't represent actual data structure - they're markers from variable-based index tracking.
|
|
1575
|
+
// Skip them AND all remaining parts to avoid creating spurious nested structure that breaks array iteration.
|
|
1576
|
+
// The remaining parts (e.g., .missing_attributes) describe properties of array elements, which are
|
|
1577
|
+
// already handled by the generic [] accessor path.
|
|
1578
|
+
const isVariableIndex = !!part?.match(/^\[[a-zA-Z_]\w*\]$/);
|
|
1579
|
+
if (isVariableIndex) {
|
|
1580
|
+
// Break out of the loop entirely - don't process any remaining parts
|
|
1581
|
+
break;
|
|
1582
|
+
}
|
|
973
1583
|
// Find the correct value for the current part being processed
|
|
974
1584
|
let partValue = value; // default to the final value
|
|
975
1585
|
if (isFunctionCallReturnValue(part) && nextIsArray) {
|
|
@@ -1077,7 +1687,52 @@ export default function constructMockCode(
|
|
|
1077
1687
|
}
|
|
1078
1688
|
}
|
|
1079
1689
|
} else {
|
|
1080
|
-
|
|
1690
|
+
// Before setting returnsFunctionArgs on the parent (for generic [] = function),
|
|
1691
|
+
// check if there are specific array indices (like [0], [1]) that are NOT functions.
|
|
1692
|
+
// If so, don't set returnsFunctionArgs because those specific indices take precedence.
|
|
1693
|
+
// This prevents adding ["()"] to paths like [0] when [0] is 'unknown' but [] is 'function'.
|
|
1694
|
+
//
|
|
1695
|
+
// Use parts.slice(0, i + 1) to get the current path INCLUDING functionCallReturnValue.
|
|
1696
|
+
// For example, if parts = ['useAtom()','functionCallReturnValue','[]']
|
|
1697
|
+
// and i = 1, we want to check 'useAtom().functionCallReturnValue[0]' etc.
|
|
1698
|
+
const arrayContainerPath = joinParenthesesAndArrays(
|
|
1699
|
+
parts.slice(0, i + 1),
|
|
1700
|
+
);
|
|
1701
|
+
|
|
1702
|
+
const hasNonFunctionSpecificIndices = Object.entries(
|
|
1703
|
+
relevantReturnValueSchema,
|
|
1704
|
+
).some(([k, v]) => {
|
|
1705
|
+
// Look for paths like "arrayContainerPath[0]", "arrayContainerPath[1]" etc.
|
|
1706
|
+
const indexMatch = k.match(
|
|
1707
|
+
new RegExp(
|
|
1708
|
+
`^${arrayContainerPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\[(\\d+)\\]$`,
|
|
1709
|
+
),
|
|
1710
|
+
);
|
|
1711
|
+
// If found and it's NOT a function type, we have a conflict
|
|
1712
|
+
return (
|
|
1713
|
+
indexMatch &&
|
|
1714
|
+
!['function', 'async-function'].includes(v as string)
|
|
1715
|
+
);
|
|
1716
|
+
});
|
|
1717
|
+
|
|
1718
|
+
// Also check if [] has nested object properties (like [].filter, [].name)
|
|
1719
|
+
// If so, [] items are objects with properties, not pure functions to be called
|
|
1720
|
+
// This handles cases where the schema shows [].filter = object but doesn't
|
|
1721
|
+
// have explicit [0] entries
|
|
1722
|
+
const genericArrayPath = `${arrayContainerPath}[]`;
|
|
1723
|
+
const hasNestedProperties = Object.keys(
|
|
1724
|
+
relevantReturnValueSchema,
|
|
1725
|
+
).some((k) => {
|
|
1726
|
+
// Check for paths like "arrayContainerPath[].propertyName" (not [].())
|
|
1727
|
+
return (
|
|
1728
|
+
k.startsWith(genericArrayPath + '.') &&
|
|
1729
|
+
!k.startsWith(genericArrayPath + '.(')
|
|
1730
|
+
);
|
|
1731
|
+
});
|
|
1732
|
+
|
|
1733
|
+
if (!hasNonFunctionSpecificIndices && !hasNestedProperties) {
|
|
1734
|
+
returnValueSection.returnsFunctionArgs = [];
|
|
1735
|
+
}
|
|
1081
1736
|
}
|
|
1082
1737
|
}
|
|
1083
1738
|
}
|
|
@@ -1102,7 +1757,8 @@ export default function constructMockCode(
|
|
|
1102
1757
|
}
|
|
1103
1758
|
// If the next part is an object with nested content, continue processing
|
|
1104
1759
|
// This handles paths like functionCallReturnValue.selectedOptions.elementOptions[]
|
|
1105
|
-
|
|
1760
|
+
// Also handles union types like 'array | undefined' or 'object | undefined'
|
|
1761
|
+
if (nextValue?.includes('object') || nextValue?.includes('array')) {
|
|
1106
1762
|
continue;
|
|
1107
1763
|
}
|
|
1108
1764
|
}
|
|
@@ -1256,7 +1912,14 @@ export default function constructMockCode(
|
|
|
1256
1912
|
relevantPart.isGenericArray = true;
|
|
1257
1913
|
}
|
|
1258
1914
|
|
|
1259
|
-
if
|
|
1915
|
+
// Check if there are remaining parts after functionCallReturnValue that need processing
|
|
1916
|
+
// (e.g., data properties like useQuery().functionCallReturnValue.data)
|
|
1917
|
+
const hasRemainingPartsAfterReturnValue =
|
|
1918
|
+
nextPart &&
|
|
1919
|
+
(isFunctionCallReturnValue(nextPart) ||
|
|
1920
|
+
(isFunctionCallReturnValue(parts[i]) && i < parts.length - 1));
|
|
1921
|
+
|
|
1922
|
+
if (!hasNestedFunction && !hasRemainingPartsAfterReturnValue) {
|
|
1260
1923
|
// Before breaking, check if this function returns an array
|
|
1261
1924
|
// by looking for a functionCallReturnValue: 'array' entry in the schema
|
|
1262
1925
|
if (relevantPart && part.endsWith(')')) {
|
|
@@ -1288,6 +1951,7 @@ export default function constructMockCode(
|
|
|
1288
1951
|
|
|
1289
1952
|
if (mockNameParts.length > 1) {
|
|
1290
1953
|
const originalLib = `${mockNameParts[0]}__cyOriginal`;
|
|
1954
|
+
const skipOriginalSpread = options?.skipOriginalSpread;
|
|
1291
1955
|
|
|
1292
1956
|
const subPart = (
|
|
1293
1957
|
parts: string[],
|
|
@@ -1299,7 +1963,9 @@ export default function constructMockCode(
|
|
|
1299
1963
|
|
|
1300
1964
|
const partContents = isLast
|
|
1301
1965
|
? contents
|
|
1302
|
-
:
|
|
1966
|
+
: skipOriginalSpread
|
|
1967
|
+
? subPart(parts, originalLib)
|
|
1968
|
+
: `...${originalLib}.${part},\n${subPart(parts, originalLib)}`;
|
|
1303
1969
|
|
|
1304
1970
|
let code = `${part}: {\n${indent(partContents)}\n}`;
|
|
1305
1971
|
|
|
@@ -1313,27 +1979,31 @@ export default function constructMockCode(
|
|
|
1313
1979
|
return code;
|
|
1314
1980
|
};
|
|
1315
1981
|
|
|
1316
|
-
const returnParts =
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1982
|
+
const returnParts = skipOriginalSpread
|
|
1983
|
+
? [subPart(mockNameParts.slice(1), originalLib)]
|
|
1984
|
+
: [
|
|
1985
|
+
`...${mockNameParts[0]}__cyOriginal`,
|
|
1986
|
+
subPart(mockNameParts.slice(1), originalLib),
|
|
1987
|
+
];
|
|
1320
1988
|
|
|
1321
|
-
return `const ${mockNameParts[0]} = {\n${indent(returnParts.join(',\n'))}\n};`;
|
|
1989
|
+
return `const ${mockNameParts[0]} = {\n${indent(returnParts.filter(Boolean).join(',\n'))}\n};`;
|
|
1322
1990
|
} else if (isFunction) {
|
|
1323
1991
|
// For headers() and cookies() from next/headers, add common iterator methods
|
|
1324
1992
|
// These are needed when the mock is passed to functions that use .entries(), .keys(), etc.
|
|
1325
1993
|
// (e.g., Object.fromEntries(headers.entries()) in buildLegacyHeaders)
|
|
1326
1994
|
const needsIteratorMethods =
|
|
1327
|
-
|
|
1995
|
+
baseMockName === 'headers' || baseMockName === 'cookies';
|
|
1328
1996
|
let enhancedContents = contents;
|
|
1329
1997
|
if (needsIteratorMethods && contents.trim().startsWith('{')) {
|
|
1330
1998
|
// Add iterator methods that operate on the scenario data
|
|
1999
|
+
// Use the dataKey (original call signature or canonical key)
|
|
2000
|
+
const quotedDataKey = quotePropertyKey(dataKey);
|
|
1331
2001
|
const iteratorMethods = `,
|
|
1332
|
-
entries: () => Object.entries(scenarios().data()
|
|
1333
|
-
keys: () => Object.keys(scenarios().data()
|
|
1334
|
-
values: () => Object.values(scenarios().data()
|
|
1335
|
-
forEach: (fn) => Object.entries(scenarios().data()
|
|
1336
|
-
has: (key) => Object.prototype.hasOwnProperty.call(scenarios().data()
|
|
2002
|
+
entries: () => Object.entries(scenarios().data()?.${quotedDataKey} || {}),
|
|
2003
|
+
keys: () => Object.keys(scenarios().data()?.${quotedDataKey} || {}),
|
|
2004
|
+
values: () => Object.values(scenarios().data()?.${quotedDataKey} || {}),
|
|
2005
|
+
forEach: (fn) => Object.entries(scenarios().data()?.${quotedDataKey} || {}).forEach(([k, v]) => fn(v, k)),
|
|
2006
|
+
has: (key) => Object.prototype.hasOwnProperty.call(scenarios().data()?.${quotedDataKey} || {}, key)`;
|
|
1337
2007
|
// Insert before the closing brace (handle trailing whitespace)
|
|
1338
2008
|
enhancedContents = contents.replace(/\}\s*$/, iteratorMethods + '\n}');
|
|
1339
2009
|
}
|
|
@@ -1344,40 +2014,106 @@ export default function constructMockCode(
|
|
|
1344
2014
|
// `new ClassName("arg")` wouldn't create the expected instance.
|
|
1345
2015
|
// For Error subclasses (detected by name ending in "Error"), extend Error for proper error handling.
|
|
1346
2016
|
if (entityType === 'class') {
|
|
1347
|
-
const isErrorSubclass =
|
|
1348
|
-
const baseClass = isErrorSubclass ? 'Error' : 'Object';
|
|
2017
|
+
const isErrorSubclass = baseMockName.endsWith('Error');
|
|
1349
2018
|
const superCall = isErrorSubclass ? 'super(message);' : '';
|
|
1350
2019
|
const nameAssignment = isErrorSubclass
|
|
1351
|
-
? `this.name = '${
|
|
2020
|
+
? `this.name = '${baseMockName}';`
|
|
1352
2021
|
: '';
|
|
2022
|
+
// Use the safe function name for the class definition
|
|
2023
|
+
const className = mockNameIsCallSignature
|
|
2024
|
+
? derivedFunctionName
|
|
2025
|
+
: baseMockName;
|
|
1353
2026
|
|
|
1354
|
-
return `class ${
|
|
2027
|
+
return `class ${className}${isErrorSubclass ? ' extends Error' : ''} {
|
|
1355
2028
|
constructor(message) {
|
|
1356
2029
|
${superCall}
|
|
1357
2030
|
${nameAssignment}
|
|
1358
|
-
Object.assign(this, scenarios().data()
|
|
2031
|
+
Object.assign(this, scenarios().data()?.${quotePropertyKey(dataKey)} || {});
|
|
1359
2032
|
}
|
|
1360
2033
|
}`;
|
|
1361
2034
|
}
|
|
1362
2035
|
|
|
1363
|
-
//
|
|
1364
|
-
//
|
|
1365
|
-
//
|
|
1366
|
-
//
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
2036
|
+
// Generate safe function name:
|
|
2037
|
+
// 1. For call signatures: use derivedFunctionName
|
|
2038
|
+
// e.g., "useFetcher<User>()" becomes "useFetcher_User"
|
|
2039
|
+
// e.g., "db.select(usersQuery)" becomes "db_select_usersQuery"
|
|
2040
|
+
// 2. With uniqueFunctionSuffix option: append suffix for unique naming
|
|
2041
|
+
// e.g., baseMockName = "useFetcher", suffix = "entityDiffFetcher" -> "useFetcher_entityDiffFetcher"
|
|
2042
|
+
// 3. EXCEPTION: When keepOriginalFunctionName is true (for single-call cases), use the base name
|
|
2043
|
+
let safeFunctionName: string;
|
|
2044
|
+
if (options?.keepOriginalFunctionName) {
|
|
2045
|
+
safeFunctionName = baseMockName;
|
|
2046
|
+
} else if (options?.uniqueFunctionSuffix) {
|
|
2047
|
+
safeFunctionName = `${baseMockName}_${options.uniqueFunctionSuffix}`;
|
|
2048
|
+
} else if (mockNameIsCallSignature && derivedFunctionName) {
|
|
2049
|
+
safeFunctionName = derivedFunctionName;
|
|
2050
|
+
} else {
|
|
2051
|
+
safeFunctionName = baseMockName;
|
|
2052
|
+
}
|
|
2053
|
+
|
|
2054
|
+
// Check if this function returns a function (detected by double-call pattern: mockName(args)())
|
|
2055
|
+
// This happens when the schema has keys like "wrapThrows(() => JSON.parse(savedFilters))()"
|
|
2056
|
+
// where the function call is immediately followed by another call.
|
|
2057
|
+
// Example usage: const result = wrapThrows(() => JSON.parse(x))(); // double call
|
|
2058
|
+
const isHigherOrderFunction = Object.keys(
|
|
2059
|
+
relevantReturnValueSchema ?? {},
|
|
2060
|
+
).some((key) => {
|
|
2061
|
+
if (!key.startsWith(baseMockName)) return false;
|
|
2062
|
+
|
|
2063
|
+
// Find the first ( after baseMockName (the start of the function call)
|
|
2064
|
+
const firstOpenParen = key.indexOf('(', baseMockName.length);
|
|
2065
|
+
if (firstOpenParen === -1) return false;
|
|
2066
|
+
|
|
2067
|
+
// Skip if the ( is not immediately after the mock name
|
|
2068
|
+
// (there might be type params like func<T>() - handle by checking for < or ()
|
|
2069
|
+
const between = key.slice(baseMockName.length, firstOpenParen);
|
|
2070
|
+
if (between.length > 0 && !between.startsWith('<')) return false;
|
|
2071
|
+
|
|
2072
|
+
// Find the matching ) for the first ( using depth counting
|
|
2073
|
+
let depth = 1;
|
|
2074
|
+
let i = firstOpenParen + 1;
|
|
2075
|
+
while (i < key.length && depth > 0) {
|
|
2076
|
+
if (key[i] === '(') depth++;
|
|
2077
|
+
if (key[i] === ')') depth--;
|
|
2078
|
+
i++;
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
if (depth !== 0) return false; // Unbalanced parentheses
|
|
2082
|
+
|
|
2083
|
+
// Now i points just after the matching )
|
|
2084
|
+
// Check if there's another ( immediately (indicating double call)
|
|
2085
|
+
const remaining = key.slice(i);
|
|
2086
|
+
if (remaining.startsWith('(')) return true;
|
|
2087
|
+
|
|
2088
|
+
return false;
|
|
2089
|
+
});
|
|
1371
2090
|
|
|
1372
|
-
|
|
2091
|
+
// Use ...args to accept any number of arguments - prevents TypeScript errors
|
|
2092
|
+
// like "Expected 0 arguments, but got X" when caller passes arguments
|
|
2093
|
+
// For higher-order functions, wrap the return in an arrow function
|
|
2094
|
+
// so that mockFunc(arg)() works correctly (outer call returns a function, inner call gets the data)
|
|
2095
|
+
const returnValue = isHigherOrderFunction
|
|
2096
|
+
? `() => (${enhancedContents})`
|
|
2097
|
+
: enhancedContents;
|
|
2098
|
+
|
|
2099
|
+
// Inline the return value directly in the function to avoid module-level const
|
|
2100
|
+
// that would be evaluated before scenario context is ready
|
|
2101
|
+
return `${isRootAsyncFunction ? 'async ' : ''}function ${safeFunctionName}(...args) {\n${indent(`return ${returnValue};`)}\n}`;
|
|
1373
2102
|
} else {
|
|
1374
|
-
//
|
|
1375
|
-
//
|
|
1376
|
-
//
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
2103
|
+
// Generate safe const name:
|
|
2104
|
+
// 1. For call signatures: use derivedFunctionName
|
|
2105
|
+
// 2. With uniqueFunctionSuffix option: append suffix for unique naming
|
|
2106
|
+
// 3. EXCEPTION: When keepOriginalFunctionName is true (for single-call cases), use the base name
|
|
2107
|
+
let safeName: string;
|
|
2108
|
+
if (options?.keepOriginalFunctionName) {
|
|
2109
|
+
safeName = baseMockName;
|
|
2110
|
+
} else if (options?.uniqueFunctionSuffix) {
|
|
2111
|
+
safeName = `${baseMockName}_${options.uniqueFunctionSuffix}`;
|
|
2112
|
+
} else if (mockNameIsCallSignature && derivedFunctionName) {
|
|
2113
|
+
safeName = derivedFunctionName;
|
|
2114
|
+
} else {
|
|
2115
|
+
safeName = baseMockName;
|
|
2116
|
+
}
|
|
1381
2117
|
|
|
1382
2118
|
// Get any jsx-component properties that need to be preserved from the original
|
|
1383
2119
|
const jsxProperties = getJsxComponentProperties(
|