@codeyam/codeyam-cli 0.1.0-staging.842873f → 0.1.0-staging.8df382d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/analyzer-template/.build-info.json +8 -8
- package/analyzer-template/common/execAsync.ts +1 -1
- package/analyzer-template/log.txt +3 -3
- package/analyzer-template/package.json +31 -27
- package/analyzer-template/packages/ai/index.ts +21 -5
- package/analyzer-template/packages/ai/package.json +5 -5
- package/analyzer-template/packages/ai/src/lib/__mocks__/completionCall.ts +122 -0
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +228 -24
- package/analyzer-template/packages/ai/src/lib/astScopes/arrayDerivationDetector.ts +199 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +205 -10
- package/analyzer-template/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.ts +644 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +181 -23
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.ts +10 -17
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.ts +18 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.ts +38 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.ts +181 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +1619 -125
- package/analyzer-template/packages/ai/src/lib/astScopes/sharedPatterns.ts +28 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +324 -5
- package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +29 -10
- package/analyzer-template/packages/ai/src/lib/completionCall.ts +235 -66
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +2761 -390
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +21 -4
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +976 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +243 -77
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.ts +16 -3
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.ts +6 -4
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +71 -2
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +161 -19
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.ts +70 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +163 -14
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.ts +98 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.ts +179 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.ts +40 -30
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +441 -82
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.ts +129 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/stripNullableMarkers.ts +35 -0
- package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +183 -0
- package/analyzer-template/packages/ai/src/lib/deepEqual.ts +30 -0
- package/analyzer-template/packages/ai/src/lib/e2eDataTracking.ts +334 -0
- package/analyzer-template/packages/ai/src/lib/extractCriticalDataKeys.ts +120 -0
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarioData.ts +74 -7
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +89 -112
- package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +63 -2
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +1421 -92
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +216 -109
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +710 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +528 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +2484 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +239 -0
- package/analyzer-template/packages/ai/src/lib/getConditionalUsagesFromCode.ts +143 -31
- package/analyzer-template/packages/ai/src/lib/guessScenarioDataFromDescription.ts +8 -2
- package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +328 -7
- package/analyzer-template/packages/ai/src/lib/mergeJsonTypeDefinitions.ts +5 -0
- package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +111 -87
- package/analyzer-template/packages/ai/src/lib/promptGenerators/collapseNullableObjects.ts +118 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +17 -7
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.ts +1 -1
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +32 -102
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChunkPrompt.ts +82 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateCriticalKeysPrompt.ts +103 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +110 -6
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.ts +14 -53
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.ts +58 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.ts +28 -2
- package/analyzer-template/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.ts +391 -0
- package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +824 -0
- package/analyzer-template/packages/ai/src/lib/splitOutsideParentheses.ts +5 -1
- package/analyzer-template/packages/ai/src/lib/validateExecutionFlowPaths.ts +531 -0
- package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +127 -3
- package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +121 -2
- package/analyzer-template/packages/analyze/index.ts +2 -0
- package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +79 -59
- package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +113 -26
- package/analyzer-template/packages/analyze/src/lib/analysisContext.ts +44 -4
- package/analyzer-template/packages/analyze/src/lib/asts/nodes/getNodeType.ts +1 -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/asts/sourceFiles/getAllDeclaredEntityNodes.ts +19 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.ts +19 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllExports.ts +11 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.ts +8 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.ts +49 -1
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.ts +2 -1
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +570 -180
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +54 -1
- package/analyzer-template/packages/analyze/src/lib/files/analyze/dependencyResolver.ts +6 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +3 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/gatherEntityMap.ts +4 -2
- package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +33 -10
- package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +31 -15
- package/analyzer-template/packages/analyze/src/lib/files/analyzeEntity.ts +11 -7
- package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +11 -12
- package/analyzer-template/packages/analyze/src/lib/files/analyzeRemixRoute.ts +4 -5
- package/analyzer-template/packages/analyze/src/lib/files/enums/steps.ts +1 -1
- package/analyzer-template/packages/analyze/src/lib/files/getImportedExports.ts +22 -13
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/TransformationTracer.ts +1315 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +313 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.ts +102 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +689 -89
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.ts +1 -1
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.ts +28 -62
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +550 -137
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +264 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +78 -83
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +4 -8
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +1067 -167
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.ts +56 -11
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/propagateArrayItemSchemas.ts +474 -0
- package/analyzer-template/packages/analyze/src/lib/files/setImportedExports.ts +2 -1
- package/analyzer-template/packages/analyze/src/lib/index.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/utils/getFileByPath.ts +19 -0
- package/analyzer-template/packages/aws/codebuild/index.ts +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts +11 -1
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js +29 -18
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts +2 -2
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js +2 -2
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts +8 -18
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js +17 -61
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts +15 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts.map +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js +31 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js.map +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js +8 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js.map +1 -1
- package/analyzer-template/packages/aws/package.json +10 -10
- package/analyzer-template/packages/aws/s3/index.ts +1 -0
- package/analyzer-template/packages/aws/src/lib/codebuild/waitForBuild.ts +43 -19
- package/analyzer-template/packages/aws/src/lib/ecs/ecsDefineContainer.ts +3 -3
- package/analyzer-template/packages/aws/src/lib/ecs/ecsTaskFactory.ts +17 -69
- package/analyzer-template/packages/aws/src/lib/s3/checkS3ObjectExists.ts +47 -0
- package/analyzer-template/packages/aws/src/lib/s3/uploadFileToS3.ts +8 -1
- package/analyzer-template/packages/database/package.json +1 -1
- package/analyzer-template/packages/database/src/lib/analysisBranchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/analysisToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/branchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/commitBranchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/commitToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/fileToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/kysely/db.ts +18 -5
- package/analyzer-template/packages/database/src/lib/kysely/tableRelations.ts +2 -2
- package/analyzer-template/packages/database/src/lib/kysely/tables/commitsTable.ts +6 -0
- package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +36 -9
- package/analyzer-template/packages/database/src/lib/kysely/tables/labsRequestsTable.ts +52 -0
- package/analyzer-template/packages/database/src/lib/loadAnalyses.ts +58 -1
- package/analyzer-template/packages/database/src/lib/loadAnalysis.ts +13 -0
- package/analyzer-template/packages/database/src/lib/loadBranch.ts +16 -1
- package/analyzer-template/packages/database/src/lib/loadCommit.ts +11 -0
- package/analyzer-template/packages/database/src/lib/loadCommits.ts +28 -0
- package/analyzer-template/packages/database/src/lib/loadEntities.ts +26 -3
- package/analyzer-template/packages/database/src/lib/loadEntityBranches.ts +12 -0
- package/analyzer-template/packages/database/src/lib/loadReadyToBeCapturedAnalyses.ts +30 -5
- package/analyzer-template/packages/database/src/lib/projectToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/saveFiles.ts +1 -1
- package/analyzer-template/packages/database/src/lib/scenarioToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +7 -14
- package/analyzer-template/packages/database/src/lib/userScenarioToDb.ts +1 -1
- package/analyzer-template/packages/generate/index.ts +3 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.ts +17 -1
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.ts +193 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.ts +73 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.ts +9 -4
- package/analyzer-template/packages/generate/src/lib/deepMerge.ts +26 -1
- package/analyzer-template/packages/generate/src/lib/directExecutionScript.ts +17 -2
- package/analyzer-template/packages/generate/src/lib/getComponentScenarioPath.ts +8 -3
- package/analyzer-template/packages/generate/src/lib/scenarioComponentForServer.ts +114 -0
- package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts +4 -2
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +13 -3
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tableRelations.d.ts +2 -2
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts +1 -11
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js +3 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +30 -7
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.d.ts +23 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js +35 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts +2 -6
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts +2 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js +45 -2
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js +8 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js +11 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js +7 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts +3 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js +22 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts +3 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js +23 -4
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js +9 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js +23 -5
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts +2 -2
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js +5 -4
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/index.d.ts +3 -0
- package/analyzer-template/packages/github/dist/generate/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/index.js +3 -0
- package/analyzer-template/packages/github/dist/generate/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts +9 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts +20 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js +27 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/directExecutionScript.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/directExecutionScript.js +10 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/directExecutionScript.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/getComponentScenarioPath.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/getComponentScenarioPath.js +7 -3
- package/analyzer-template/packages/github/dist/generate/src/lib/getComponentScenarioPath.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts +8 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js +89 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js.map +1 -0
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js +10 -0
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js +3 -0
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.d.ts +2 -2
- package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +87 -13
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts +7 -0
- package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts +11 -6
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +199 -3
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/applyUniversalMocks.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/applyUniversalMocks.js +26 -2
- package/analyzer-template/packages/github/dist/utils/src/lib/applyUniversalMocks.js.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
- package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts +9 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js +29 -3
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js.map +1 -1
- package/analyzer-template/packages/github/package.json +1 -1
- package/analyzer-template/packages/github/src/lib/loadOrCreateCommit.ts +14 -0
- package/analyzer-template/packages/github/src/lib/syncPrimaryBranch.ts +2 -0
- package/analyzer-template/packages/process/index.ts +2 -0
- package/analyzer-template/packages/process/package.json +12 -0
- package/analyzer-template/packages/process/tsconfig.json +8 -0
- package/analyzer-template/packages/types/index.ts +5 -0
- package/analyzer-template/packages/types/src/types/Analysis.ts +104 -13
- package/analyzer-template/packages/types/src/types/Commit.ts +2 -0
- package/analyzer-template/packages/types/src/types/Entity.ts +2 -0
- package/analyzer-template/packages/types/src/types/ProjectMetadata.ts +7 -0
- package/analyzer-template/packages/types/src/types/Scenario.ts +11 -10
- package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +228 -3
- package/analyzer-template/packages/types/src/types/ScopeAnalysis.ts +6 -1
- package/analyzer-template/packages/types/src/types/StatementInfo.ts +2 -0
- package/analyzer-template/packages/ui-components/package.json +4 -4
- package/analyzer-template/packages/ui-components/src/components/ScenarioDetailInteractiveView.tsx +23 -7
- package/analyzer-template/packages/utils/dist/types/index.d.ts +2 -2
- package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +87 -13
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts +7 -0
- package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts +11 -6
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +199 -3
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/applyUniversalMocks.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/applyUniversalMocks.js +26 -2
- package/analyzer-template/packages/utils/dist/utils/src/lib/applyUniversalMocks.js.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js +98 -3
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
- package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts +9 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js +29 -3
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js.map +1 -1
- package/analyzer-template/packages/utils/src/lib/applyUniversalMocks.ts +28 -2
- package/analyzer-template/packages/utils/src/lib/fs/rsyncCopy.ts +121 -3
- package/analyzer-template/packages/utils/src/lib/lightweightEntityExtractor.ts +27 -0
- package/analyzer-template/packages/utils/src/lib/safeFileName.ts +48 -3
- package/analyzer-template/playwright/capture.ts +57 -26
- package/analyzer-template/playwright/captureStatic.ts +1 -1
- package/analyzer-template/playwright/getCodeYamInfo.ts +12 -7
- package/analyzer-template/playwright/takeElementScreenshot.ts +26 -11
- package/analyzer-template/playwright/takeScreenshot.ts +9 -7
- package/analyzer-template/playwright/waitForServer.ts +21 -6
- package/analyzer-template/project/TESTING.md +83 -0
- package/analyzer-template/project/analyzeBaselineCommit.ts +9 -0
- package/analyzer-template/project/analyzeBranchCommit.ts +4 -0
- package/analyzer-template/project/analyzeFileEntities.ts +4 -0
- package/analyzer-template/project/analyzeRegularCommit.ts +9 -0
- package/analyzer-template/project/captureLibraryFunctionDirect.ts +29 -26
- package/analyzer-template/project/constructMockCode.ts +1342 -169
- package/analyzer-template/project/controller/startController.ts +16 -1
- package/analyzer-template/project/createEntitiesAndSortFiles.ts +83 -0
- package/analyzer-template/project/executeLibraryFunctionDirect.ts +7 -3
- package/analyzer-template/project/loadReadyToBeCaptured.ts +82 -42
- package/analyzer-template/project/mocks/analyzeFileMock.ts +8 -7
- package/analyzer-template/project/orchestrateCapture/AwsCaptureTaskRunner.ts +12 -4
- package/analyzer-template/project/orchestrateCapture/KyselyAnalysisLoader.ts +13 -9
- package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +93 -42
- package/analyzer-template/project/orchestrateCapture/taskRunner.ts +4 -2
- package/analyzer-template/project/orchestrateCapture.ts +88 -11
- package/analyzer-template/project/reconcileMockDataKeys.ts +245 -2
- package/analyzer-template/project/runAnalysis.ts +11 -0
- package/analyzer-template/project/runMultiScenarioServer.ts +11 -10
- package/analyzer-template/project/serverOnlyModules.ts +413 -0
- package/analyzer-template/project/start.ts +61 -15
- package/analyzer-template/project/startScenarioCapture.ts +79 -41
- package/analyzer-template/project/writeMockDataTsx.ts +454 -67
- package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
- package/analyzer-template/project/writeScenarioComponents.ts +1500 -237
- package/analyzer-template/project/writeScenarioFiles.ts +26 -0
- package/analyzer-template/project/writeSimpleRoot.ts +56 -22
- package/analyzer-template/project/writeUniversalMocks.ts +32 -11
- package/analyzer-template/scripts/comboWorkerLoop.cjs +99 -50
- package/analyzer-template/scripts/defaultCmd.sh +9 -0
- package/analyzer-template/tsconfig.json +2 -1
- package/background/src/lib/local/createLocalAnalyzer.js +2 -30
- package/background/src/lib/local/createLocalAnalyzer.js.map +1 -1
- package/background/src/lib/local/execAsync.js +1 -1
- package/background/src/lib/local/execAsync.js.map +1 -1
- package/background/src/lib/virtualized/common/execAsync.js +1 -1
- package/background/src/lib/virtualized/common/execAsync.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeBaselineCommit.js +7 -1
- package/background/src/lib/virtualized/project/analyzeBaselineCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeBranchCommit.js +2 -1
- package/background/src/lib/virtualized/project/analyzeBranchCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeFileEntities.js +2 -1
- package/background/src/lib/virtualized/project/analyzeFileEntities.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeRegularCommit.js +7 -1
- package/background/src/lib/virtualized/project/analyzeRegularCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js +3 -3
- package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js.map +1 -1
- package/background/src/lib/virtualized/project/constructMockCode.js +1190 -130
- package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
- package/background/src/lib/virtualized/project/controller/startController.js +11 -1
- package/background/src/lib/virtualized/project/controller/startController.js.map +1 -1
- package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js +73 -1
- package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js.map +1 -1
- package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js +6 -3
- package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js.map +1 -1
- package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js +34 -9
- package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js.map +1 -1
- package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js +7 -7
- package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js +2 -2
- package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js +12 -6
- package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +73 -36
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture.js +72 -12
- package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +204 -2
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
- package/background/src/lib/virtualized/project/runAnalysis.js +9 -0
- package/background/src/lib/virtualized/project/runAnalysis.js.map +1 -1
- package/background/src/lib/virtualized/project/runMultiScenarioServer.js +11 -9
- package/background/src/lib/virtualized/project/runMultiScenarioServer.js.map +1 -1
- package/background/src/lib/virtualized/project/serverOnlyModules.js +338 -0
- package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -0
- package/background/src/lib/virtualized/project/start.js +53 -15
- package/background/src/lib/virtualized/project/start.js.map +1 -1
- package/background/src/lib/virtualized/project/startScenarioCapture.js +61 -31
- package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/writeMockDataTsx.js +392 -56
- 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 +1107 -161
- package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioFiles.js +19 -0
- package/background/src/lib/virtualized/project/writeScenarioFiles.js.map +1 -1
- package/background/src/lib/virtualized/project/writeSimpleRoot.js +57 -20
- package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
- package/background/src/lib/virtualized/project/writeUniversalMocks.js +27 -12
- package/background/src/lib/virtualized/project/writeUniversalMocks.js.map +1 -1
- package/codeyam-cli/scripts/apply-setup.js +180 -0
- package/codeyam-cli/scripts/apply-setup.js.map +1 -1
- package/codeyam-cli/src/cli.js +37 -22
- package/codeyam-cli/src/cli.js.map +1 -1
- package/codeyam-cli/src/codeyam-cli.js +18 -2
- package/codeyam-cli/src/codeyam-cli.js.map +1 -1
- package/codeyam-cli/src/commands/analyze.js +5 -3
- package/codeyam-cli/src/commands/analyze.js.map +1 -1
- package/codeyam-cli/src/commands/baseline.js +176 -0
- package/codeyam-cli/src/commands/baseline.js.map +1 -0
- package/codeyam-cli/src/commands/debug.js +44 -18
- package/codeyam-cli/src/commands/debug.js.map +1 -1
- package/codeyam-cli/src/commands/default.js +30 -34
- package/codeyam-cli/src/commands/default.js.map +1 -1
- package/codeyam-cli/src/commands/init.js +49 -257
- package/codeyam-cli/src/commands/init.js.map +1 -1
- package/codeyam-cli/src/commands/memory.js +254 -0
- package/codeyam-cli/src/commands/memory.js.map +1 -0
- package/codeyam-cli/src/commands/recapture.js +228 -0
- package/codeyam-cli/src/commands/recapture.js.map +1 -0
- package/codeyam-cli/src/commands/report.js +72 -24
- package/codeyam-cli/src/commands/report.js.map +1 -1
- package/codeyam-cli/src/commands/setup-sandbox.js +2 -0
- package/codeyam-cli/src/commands/setup-sandbox.js.map +1 -1
- package/codeyam-cli/src/commands/setup-simulations.js +284 -0
- package/codeyam-cli/src/commands/setup-simulations.js.map +1 -0
- package/codeyam-cli/src/commands/start.js +8 -12
- package/codeyam-cli/src/commands/start.js.map +1 -1
- package/codeyam-cli/src/commands/status.js +23 -1
- package/codeyam-cli/src/commands/status.js.map +1 -1
- package/codeyam-cli/src/commands/test-startup.js +3 -1
- package/codeyam-cli/src/commands/test-startup.js.map +1 -1
- package/codeyam-cli/src/commands/verify.js +14 -2
- package/codeyam-cli/src/commands/verify.js.map +1 -1
- package/codeyam-cli/src/commands/wipe.js +108 -0
- package/codeyam-cli/src/commands/wipe.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/npmVersionCheck.test.js +185 -0
- package/codeyam-cli/src/utils/__tests__/npmVersionCheck.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js +81 -0
- package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +128 -82
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
- package/codeyam-cli/src/utils/analysisRunner.js +29 -15
- package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
- package/codeyam-cli/src/utils/analyzer.js +7 -0
- package/codeyam-cli/src/utils/analyzer.js.map +1 -1
- package/codeyam-cli/src/utils/backgroundServer.js +104 -23
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/database.js +91 -5
- package/codeyam-cli/src/utils/database.js.map +1 -1
- package/codeyam-cli/src/utils/generateReport.js +253 -106
- package/codeyam-cli/src/utils/generateReport.js.map +1 -1
- package/codeyam-cli/src/utils/git.js +79 -0
- package/codeyam-cli/src/utils/git.js.map +1 -0
- package/codeyam-cli/src/utils/install-skills.js +78 -44
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/labsAutoCheck.js +19 -0
- package/codeyam-cli/src/utils/labsAutoCheck.js.map +1 -0
- package/codeyam-cli/src/utils/npmVersionCheck.js +76 -0
- package/codeyam-cli/src/utils/npmVersionCheck.js.map +1 -0
- package/codeyam-cli/src/utils/progress.js +7 -0
- package/codeyam-cli/src/utils/progress.js.map +1 -1
- package/codeyam-cli/src/utils/queue/__tests__/manager.test.js +38 -0
- package/codeyam-cli/src/utils/queue/__tests__/manager.test.js.map +1 -1
- package/codeyam-cli/src/utils/queue/job.js +249 -16
- package/codeyam-cli/src/utils/queue/job.js.map +1 -1
- package/codeyam-cli/src/utils/queue/manager.js +103 -7
- package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
- package/codeyam-cli/src/utils/queue/persistence.js.map +1 -1
- package/codeyam-cli/src/utils/requireSimulations.js +10 -0
- package/codeyam-cli/src/utils/requireSimulations.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js +82 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js +229 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js +67 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js +105 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js +34 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js +162 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js +74 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js +376 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js +113 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js +127 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js +50 -0
- package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js +116 -0
- package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/index.js +5 -0
- package/codeyam-cli/src/utils/ruleReflection/index.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js +44 -0
- package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js +85 -0
- package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/types.js +5 -0
- package/codeyam-cli/src/utils/ruleReflection/types.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/parser.test.js +83 -0
- package/codeyam-cli/src/utils/rules/__tests__/parser.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/pathMatcher.test.js +118 -0
- package/codeyam-cli/src/utils/rules/__tests__/pathMatcher.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/rulePlacement.test.js +72 -0
- package/codeyam-cli/src/utils/rules/__tests__/rulePlacement.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js +293 -0
- package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/sourceFiles.test.js +76 -0
- package/codeyam-cli/src/utils/rules/__tests__/sourceFiles.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/index.js +7 -0
- package/codeyam-cli/src/utils/rules/index.js.map +1 -0
- package/codeyam-cli/src/utils/rules/parser.js +93 -0
- package/codeyam-cli/src/utils/rules/parser.js.map +1 -0
- package/codeyam-cli/src/utils/rules/pathMatcher.js +49 -0
- package/codeyam-cli/src/utils/rules/pathMatcher.js.map +1 -0
- package/codeyam-cli/src/utils/rules/rulePlacement.js +65 -0
- package/codeyam-cli/src/utils/rules/rulePlacement.js.map +1 -0
- package/codeyam-cli/src/utils/rules/ruleState.js +150 -0
- package/codeyam-cli/src/utils/rules/ruleState.js.map +1 -0
- package/codeyam-cli/src/utils/rules/sourceFiles.js +43 -0
- package/codeyam-cli/src/utils/rules/sourceFiles.js.map +1 -0
- package/codeyam-cli/src/utils/rules/staleness.js +137 -0
- package/codeyam-cli/src/utils/rules/staleness.js.map +1 -0
- package/codeyam-cli/src/utils/serverState.js +37 -10
- package/codeyam-cli/src/utils/serverState.js.map +1 -1
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +21 -42
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
- package/codeyam-cli/src/utils/simulationGateMiddleware.js +159 -0
- package/codeyam-cli/src/utils/simulationGateMiddleware.js.map +1 -0
- package/codeyam-cli/src/utils/syncMocksMiddleware.js +5 -24
- package/codeyam-cli/src/utils/syncMocksMiddleware.js.map +1 -1
- package/codeyam-cli/src/utils/versionInfo.js +67 -15
- package/codeyam-cli/src/utils/versionInfo.js.map +1 -1
- package/codeyam-cli/src/utils/wipe.js +128 -0
- package/codeyam-cli/src/utils/wipe.js.map +1 -0
- package/codeyam-cli/src/webserver/__tests__/dependency-smoke.test.js +66 -0
- package/codeyam-cli/src/webserver/__tests__/dependency-smoke.test.js.map +1 -0
- package/codeyam-cli/src/webserver/app/lib/database.js +118 -6
- package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
- package/codeyam-cli/src/webserver/app/lib/dbNotifier.js.map +1 -1
- package/codeyam-cli/src/webserver/app/routes/api.agent-transcripts.js +486 -0
- package/codeyam-cli/src/webserver/app/routes/api.agent-transcripts.js.map +1 -0
- package/codeyam-cli/src/webserver/backgroundServer.js +65 -10
- package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/webserver/bootstrap.js +60 -0
- package/codeyam-cli/src/webserver/bootstrap.js.map +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/CopyButton-CtmbP4Gl.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-DlMph_Hm.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-kykTbcnD.js → EntityTypeBadge-B-0PjGOU.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-DN9eiJAO.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-C1rIyZdV.js +34 -0
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-rE_fI2h2.js +25 -0
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-CnatsCw2.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/LoadingDots-CSP6DZrh.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/LogViewer-CMK8Q7yk.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-TCV_HBjy.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-CG2uh31y.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-CU_TDYd8.js +10 -0
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-C06nsHKY.js → TruncatedFilePath-D7IoaWUW.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/_index-B8z7mjR-.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-DZu78RI1.js +27 -0
- package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-DxCa1oBt.js +23 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.agent-transcripts-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.health-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.labs-unlock-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.memory-profile-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.restart-server-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.rule-path-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.save-fixture-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/book-open-Bp5FLkd4.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/chevron-down-DQJA9f4o.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/chunk-JZWAC4HX-7VptmeIr.js +51 -0
- package/codeyam-cli/src/webserver/build/client/assets/circle-check-B6C4LY9o.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/copy-6nzYCu0G.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-D-QUFOwe.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-DmzSmblj.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-CYqBrC9s.js → entity._sha._--zvFJ4OH.js} +22 -15
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-DVTcUnur.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-BVgNO76F.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-C7ysA4Jq.js +5 -0
- package/codeyam-cli/src/webserver/build/client/assets/entry.client-CU6EUArK.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-EWpfFU4X.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/files-CrxAoWIL.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/git-BldHtKeW.js +15 -0
- package/codeyam-cli/src/webserver/build/client/assets/globals-B4MPiL7S.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-7-1FmlHo.js +9 -0
- package/codeyam-cli/src/webserver/build/client/assets/index-DuYcwYp_.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/labs-CPPVOSWB.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/loader-circle-BnDcD54R.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/manifest-c1fc3656.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-CfpYxpNu.js +93 -0
- package/codeyam-cli/src/webserver/build/client/assets/pause-DhQX2g22.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/preload-helper-ckwbz45p.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/root-CAAbm4U5.js +62 -0
- package/codeyam-cli/src/webserver/build/client/assets/scenarioStatus-B_8jpV3e.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/search-DborVoKD.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/settings-BpLDWmGh.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/simulations-BtrtCYJg.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/terminal-Bs4NC-VZ.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-DTf3Jojp.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-D_bDZyDU.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-Blr5oZDE.js → useLastLogLine-DZp6rrQD.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-BsQb6rFd.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useToast-Bbf4Hokd.js → useToast-BOur3mUv.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-B8A_aaGG.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-69rRZnZo.js +286 -0
- package/codeyam-cli/src/webserver/build/server/index.js +1 -1
- package/codeyam-cli/src/webserver/build-info.json +5 -5
- package/codeyam-cli/src/webserver/devServer.js +1 -3
- package/codeyam-cli/src/webserver/devServer.js.map +1 -1
- package/codeyam-cli/src/webserver/server.js +35 -25
- package/codeyam-cli/src/webserver/server.js.map +1 -1
- package/codeyam-cli/templates/{codeyam-debug-skill.md → codeyam-debug.md} +48 -4
- package/codeyam-cli/templates/codeyam-diagnose.md +481 -0
- package/codeyam-cli/templates/codeyam-memory-hook.sh +199 -0
- package/codeyam-cli/templates/codeyam-memory.md +396 -0
- package/codeyam-cli/templates/codeyam-new-rule.md +11 -0
- package/codeyam-cli/templates/{codeyam-setup-skill.md → codeyam-setup.md} +151 -4
- package/codeyam-cli/templates/{codeyam-sim-skill.md → codeyam-sim.md} +1 -1
- package/codeyam-cli/templates/{codeyam-test-skill.md → codeyam-test.md} +1 -1
- package/codeyam-cli/templates/{codeyam-verify-skill.md → codeyam-verify.md} +1 -1
- package/codeyam-cli/templates/hooks/staleness-check.sh +43 -0
- package/codeyam-cli/templates/prompts/conversation-guidance.txt +32 -0
- package/codeyam-cli/templates/prompts/conversation-prompt.txt +28 -0
- package/codeyam-cli/templates/prompts/interruption-prompt.txt +31 -0
- package/codeyam-cli/templates/prompts/stale-rules-prompt.txt +24 -0
- package/codeyam-cli/templates/rule-notification-hook.py +56 -0
- package/codeyam-cli/templates/rule-reflection-hook.py +627 -0
- package/codeyam-cli/templates/rules-instructions.md +77 -0
- package/package.json +26 -23
- package/packages/ai/index.js +8 -6
- package/packages/ai/index.js.map +1 -1
- package/packages/ai/src/lib/analyzeScope.js +181 -13
- package/packages/ai/src/lib/analyzeScope.js.map +1 -1
- package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js +150 -0
- package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js.map +1 -0
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +154 -9
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
- package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js +435 -0
- package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js.map +1 -0
- package/packages/ai/src/lib/astScopes/methodSemantics.js +138 -23
- package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js +10 -14
- package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js +8 -0
- package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js +23 -0
- package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js +138 -1
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/processExpression.js +1235 -104
- package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
- package/packages/ai/src/lib/astScopes/sharedPatterns.js +25 -0
- package/packages/ai/src/lib/astScopes/sharedPatterns.js.map +1 -1
- package/packages/ai/src/lib/checkAllAttributes.js +24 -9
- package/packages/ai/src/lib/checkAllAttributes.js.map +1 -1
- package/packages/ai/src/lib/completionCall.js +178 -36
- package/packages/ai/src/lib/completionCall.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +2171 -224
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +19 -4
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +661 -0
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +180 -56
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js +13 -3
- package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js +6 -4
- package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +66 -2
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +139 -13
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js +63 -0
- package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +142 -12
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js +86 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js +173 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js +37 -20
- package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +371 -73
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js +107 -0
- package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructureChunking.js +130 -0
- package/packages/ai/src/lib/dataStructureChunking.js.map +1 -0
- package/packages/ai/src/lib/deepEqual.js +32 -0
- package/packages/ai/src/lib/deepEqual.js.map +1 -0
- package/packages/ai/src/lib/e2eDataTracking.js +241 -0
- package/packages/ai/src/lib/e2eDataTracking.js.map +1 -0
- package/packages/ai/src/lib/extractCriticalDataKeys.js +96 -0
- package/packages/ai/src/lib/extractCriticalDataKeys.js.map +1 -0
- package/packages/ai/src/lib/generateChangesEntityScenarioData.js +62 -5
- package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateChangesEntityScenarios.js +81 -90
- package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateEntityDataStructure.js +50 -1
- package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarioData.js +1128 -85
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarios.js +193 -83
- package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +495 -0
- package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js +380 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +1807 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js +194 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js.map +1 -0
- package/packages/ai/src/lib/getConditionalUsagesFromCode.js +84 -14
- package/packages/ai/src/lib/getConditionalUsagesFromCode.js.map +1 -1
- package/packages/ai/src/lib/guessScenarioDataFromDescription.js +2 -1
- package/packages/ai/src/lib/guessScenarioDataFromDescription.js.map +1 -1
- package/packages/ai/src/lib/isolateScopes.js +270 -7
- package/packages/ai/src/lib/isolateScopes.js.map +1 -1
- package/packages/ai/src/lib/mergeJsonTypeDefinitions.js +5 -0
- package/packages/ai/src/lib/mergeJsonTypeDefinitions.js.map +1 -1
- package/packages/ai/src/lib/mergeStatements.js +88 -46
- package/packages/ai/src/lib/mergeStatements.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js +97 -0
- package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +16 -4
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +21 -64
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js +54 -0
- package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +83 -6
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js +10 -34
- package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js +45 -0
- package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js +16 -3
- package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js +335 -0
- package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js.map +1 -0
- package/packages/ai/src/lib/resolvePathToControllable.js +677 -0
- package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -0
- package/packages/ai/src/lib/splitOutsideParentheses.js +3 -1
- package/packages/ai/src/lib/splitOutsideParentheses.js.map +1 -1
- package/packages/ai/src/lib/worker/SerializableDataStructure.js +29 -0
- package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js +98 -1
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js.map +1 -1
- package/packages/analyze/index.js +1 -0
- package/packages/analyze/index.js.map +1 -1
- package/packages/analyze/src/lib/FileAnalyzer.js +75 -36
- package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/ProjectAnalyzer.js +96 -26
- package/packages/analyze/src/lib/ProjectAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/analysisContext.js +30 -5
- package/packages/analyze/src/lib/analysisContext.js.map +1 -1
- package/packages/analyze/src/lib/asts/nodes/getNodeType.js +1 -0
- package/packages/analyze/src/lib/asts/nodes/getNodeType.js.map +1 -1
- package/packages/analyze/src/lib/asts/nodes/index.js +1 -0
- package/packages/analyze/src/lib/asts/nodes/index.js.map +1 -1
- package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js +52 -0
- package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js.map +1 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js +14 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js +14 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js +6 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js +6 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js +39 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js +2 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +428 -123
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +42 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/dependencyResolver.js +5 -0
- package/packages/analyze/src/lib/files/analyze/dependencyResolver.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +2 -0
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js +2 -1
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +31 -10
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeChange.js +21 -11
- package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeEntity.js +9 -8
- package/packages/analyze/src/lib/files/analyzeEntity.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeInitial.js +9 -10
- package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeRemixRoute.js +3 -2
- package/packages/analyze/src/lib/files/analyzeRemixRoute.js.map +1 -1
- package/packages/analyze/src/lib/files/enums/steps.js +1 -1
- package/packages/analyze/src/lib/files/enums/steps.js.map +1 -1
- package/packages/analyze/src/lib/files/getImportedExports.js +17 -8
- package/packages/analyze/src/lib/files/getImportedExports.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js +880 -0
- package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +255 -0
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js +85 -0
- package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +536 -73
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js +29 -34
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +404 -85
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +144 -0
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +56 -69
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +4 -8
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +875 -141
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js +46 -9
- package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/setImportedExports.js +2 -1
- package/packages/analyze/src/lib/files/setImportedExports.js.map +1 -1
- package/packages/analyze/src/lib/index.js +1 -0
- package/packages/analyze/src/lib/index.js.map +1 -1
- package/packages/analyze/src/lib/utils/getFileByPath.js +12 -0
- package/packages/analyze/src/lib/utils/getFileByPath.js.map +1 -0
- package/packages/aws/src/lib/ecs/ecsDefineContainer.js +2 -2
- package/packages/aws/src/lib/ecs/ecsDefineContainer.js.map +1 -1
- package/packages/aws/src/lib/ecs/ecsTaskFactory.js +17 -61
- package/packages/aws/src/lib/ecs/ecsTaskFactory.js.map +1 -1
- package/packages/database/src/lib/analysisBranchToDb.js +1 -1
- package/packages/database/src/lib/analysisBranchToDb.js.map +1 -1
- package/packages/database/src/lib/analysisToDb.js +1 -1
- package/packages/database/src/lib/analysisToDb.js.map +1 -1
- package/packages/database/src/lib/branchToDb.js +1 -1
- package/packages/database/src/lib/branchToDb.js.map +1 -1
- package/packages/database/src/lib/commitBranchToDb.js +1 -1
- package/packages/database/src/lib/commitBranchToDb.js.map +1 -1
- package/packages/database/src/lib/commitToDb.js +1 -1
- package/packages/database/src/lib/commitToDb.js.map +1 -1
- package/packages/database/src/lib/fileToDb.js +1 -1
- package/packages/database/src/lib/fileToDb.js.map +1 -1
- package/packages/database/src/lib/kysely/db.js +13 -3
- package/packages/database/src/lib/kysely/db.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/commitsTable.js +3 -0
- package/packages/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
- package/packages/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/labsRequestsTable.js +35 -0
- package/packages/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
- package/packages/database/src/lib/loadAnalyses.js +45 -2
- package/packages/database/src/lib/loadAnalyses.js.map +1 -1
- package/packages/database/src/lib/loadAnalysis.js +8 -0
- package/packages/database/src/lib/loadAnalysis.js.map +1 -1
- package/packages/database/src/lib/loadBranch.js +11 -1
- package/packages/database/src/lib/loadBranch.js.map +1 -1
- package/packages/database/src/lib/loadCommit.js +7 -0
- package/packages/database/src/lib/loadCommit.js.map +1 -1
- package/packages/database/src/lib/loadCommits.js +22 -1
- package/packages/database/src/lib/loadCommits.js.map +1 -1
- package/packages/database/src/lib/loadEntities.js +23 -4
- package/packages/database/src/lib/loadEntities.js.map +1 -1
- package/packages/database/src/lib/loadEntityBranches.js +9 -0
- package/packages/database/src/lib/loadEntityBranches.js.map +1 -1
- package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js +23 -5
- package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
- package/packages/database/src/lib/projectToDb.js +1 -1
- package/packages/database/src/lib/projectToDb.js.map +1 -1
- package/packages/database/src/lib/saveFiles.js +1 -1
- package/packages/database/src/lib/saveFiles.js.map +1 -1
- package/packages/database/src/lib/scenarioToDb.js +1 -1
- package/packages/database/src/lib/scenarioToDb.js.map +1 -1
- package/packages/database/src/lib/updateCommitMetadata.js +5 -4
- package/packages/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/packages/generate/index.js +3 -0
- package/packages/generate/index.js.map +1 -1
- package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
- package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
- package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
- package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
- package/packages/generate/src/lib/deepMerge.js +27 -1
- package/packages/generate/src/lib/deepMerge.js.map +1 -1
- package/packages/generate/src/lib/directExecutionScript.js +10 -1
- package/packages/generate/src/lib/directExecutionScript.js.map +1 -1
- package/packages/generate/src/lib/getComponentScenarioPath.js +7 -3
- package/packages/generate/src/lib/getComponentScenarioPath.js.map +1 -1
- package/packages/generate/src/lib/scenarioComponentForServer.js +89 -0
- package/packages/generate/src/lib/scenarioComponentForServer.js.map +1 -0
- package/packages/github/src/lib/loadOrCreateCommit.js +10 -0
- package/packages/github/src/lib/loadOrCreateCommit.js.map +1 -1
- package/packages/github/src/lib/syncPrimaryBranch.js +3 -0
- package/packages/github/src/lib/syncPrimaryBranch.js.map +1 -1
- package/packages/process/index.js +3 -0
- package/packages/process/index.js.map +1 -0
- package/packages/process/src/GlobalProcessManager.js.map +1 -0
- package/{background/src/lib/process → packages/process/src}/ProcessManager.js +1 -1
- package/packages/process/src/ProcessManager.js.map +1 -0
- package/packages/process/src/index.js.map +1 -0
- package/packages/process/src/managedExecAsync.js.map +1 -0
- package/packages/types/index.js.map +1 -1
- package/packages/utils/src/lib/applyUniversalMocks.js +26 -2
- package/packages/utils/src/lib/applyUniversalMocks.js.map +1 -1
- package/packages/utils/src/lib/fs/rsyncCopy.js +98 -3
- package/packages/utils/src/lib/fs/rsyncCopy.js.map +1 -1
- package/packages/utils/src/lib/lightweightEntityExtractor.js +25 -0
- package/packages/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
- package/packages/utils/src/lib/safeFileName.js +29 -3
- package/packages/utils/src/lib/safeFileName.js.map +1 -1
- package/scripts/finalize-analyzer.cjs +8 -74
- package/analyzer-template/packages/ai/src/lib/findMatchingAttribute.ts +0 -102
- package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +0 -197
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +0 -271
- package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +0 -294
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.ts +0 -67
- package/analyzer-template/packages/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/commands/detect-universal-mocks.js +0 -118
- package/codeyam-cli/src/commands/detect-universal-mocks.js.map +0 -1
- package/codeyam-cli/src/commands/list.js +0 -31
- package/codeyam-cli/src/commands/list.js.map +0 -1
- package/codeyam-cli/src/commands/webapp-info.js +0 -146
- package/codeyam-cli/src/commands/webapp-info.js.map +0 -1
- package/codeyam-cli/src/utils/universal-mocks.js +0 -152
- package/codeyam-cli/src/utils/universal-mocks.js.map +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-D4htqD-x.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-Catz6XEN.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-TlHocYno.js +0 -26
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-CVMmGuIc.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/LogViewer-JkfQ-VaI.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-CVZ0H4BL.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-BrMAP1nP.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-CJhE4cCv.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/_index-faVIcr_i.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-CLMa2sgx.js +0 -7
- package/codeyam-cli/src/webserver/build/client/assets/chevron-down-DwYjrK_h.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/chunk-WWGJGFF6-CgXbbZRx.js +0 -26
- package/codeyam-cli/src/webserver/build/client/assets/circle-check-B2oHQ-zo.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-BBYuR56H.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-CT0Q5lVu.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-Bj5GHkhb.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-eW5z9AyZ.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/entry.client-B9tSboXM.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-CmO-EZAB.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-DLinnTOx.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/git-CIxwBQvb.js +0 -12
- package/codeyam-cli/src/webserver/build/client/assets/globals-xPz593l2.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-XQCGvadH.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/index-_LjBsTxX.js +0 -8
- package/codeyam-cli/src/webserver/build/client/assets/loader-circle-D_EGChhq.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-ca438c41.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/root-CHHYHuzL.js +0 -16
- package/codeyam-cli/src/webserver/build/client/assets/search-DY8yoDpH.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/server-build-CMKNK2uU.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/settings-BT6wVHd5.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/simulations-gv3H7JV7.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-BthANBVv.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-CANr3QJ5.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-BtBPtyHx.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-N2cTnejq.js +0 -166
- package/codeyam-cli/templates/codeyam-stop-hook.sh +0 -284
- package/codeyam-cli/templates/debug-command.md +0 -141
- package/packages/ai/src/lib/findMatchingAttribute.js +0 -77
- package/packages/ai/src/lib/findMatchingAttribute.js.map +0 -1
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +0 -136
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +0 -220
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateEntityKeyAttributes.js +0 -241
- package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/isFrontend.js +0 -5
- package/packages/ai/src/lib/isFrontend.js.map +0 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js +0 -40
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js.map +0 -1
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +0 -72
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +0 -1
- /package/analyzer-template/{process → packages/process/src}/GlobalProcessManager.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/ProcessManager.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/index.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/managedExecAsync.ts +0 -0
- /package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-CMKNK2uU.css → styles-CMKNK2uU.css} +0 -0
- /package/{background/src/lib/process → packages/process/src}/GlobalProcessManager.js +0 -0
- /package/{background/src/lib/process → packages/process/src}/index.js +0 -0
- /package/{background/src/lib/process → packages/process/src}/managedExecAsync.js +0 -0
|
@@ -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,29 +285,54 @@ 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
|
|
|
297
|
+
/**
|
|
298
|
+
* Known hooks that return tuples [value, setter] instead of arrays.
|
|
299
|
+
* These should NOT use the .map() pattern even when the schema has generic array access ([]).
|
|
300
|
+
* Instead, they should return [data, () => {}] where data is from scenarios().
|
|
301
|
+
*/
|
|
302
|
+
const TUPLE_RETURNING_HOOKS = new Set([
|
|
303
|
+
'useAtom', // Jotai
|
|
304
|
+
'useState', // React
|
|
305
|
+
'useReducer', // React
|
|
306
|
+
'useRecoilState', // Recoil
|
|
307
|
+
'useImmerAtom', // Jotai with Immer
|
|
308
|
+
]);
|
|
309
|
+
|
|
205
310
|
export default function constructMockCode(
|
|
206
311
|
mockName: string,
|
|
207
312
|
dependencySchemas: DeepReadonly<DataStructure['dependencySchemas']>,
|
|
208
313
|
entityType?: EntityType,
|
|
314
|
+
_canonicalKey?: string, // DEPRECATED: No longer used, kept for API compatibility
|
|
315
|
+
options?: {
|
|
316
|
+
keepOriginalFunctionName?: boolean;
|
|
317
|
+
uniqueFunctionSuffix?: string;
|
|
318
|
+
skipOriginalSpread?: boolean; // Skip spreading from __cyOriginal when it won't be defined
|
|
319
|
+
},
|
|
209
320
|
) {
|
|
210
|
-
// Check
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
? variableQualifierMatch[1]
|
|
321
|
+
// Check if mockName is a call signature (e.g., "useFetcher<User>()", "db.select(query)")
|
|
322
|
+
const mockNameIsCallSignature = isCallSignature(mockName);
|
|
323
|
+
|
|
324
|
+
// For call signatures, use the original signature for data access but generate
|
|
325
|
+
// a valid JS function name from it
|
|
326
|
+
const derivedFunctionName = mockNameIsCallSignature
|
|
327
|
+
? callSignatureToFunctionName(mockName)
|
|
218
328
|
: null;
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
329
|
+
|
|
330
|
+
// The baseMockName is the function name without type params and args
|
|
331
|
+
// e.g., "useFetcher<User>()" -> "useFetcher", "db.select(query)" -> "db"
|
|
332
|
+
const baseMockName = mockName.split(/[<(]/)[0];
|
|
333
|
+
|
|
334
|
+
// The data key is the mockName (call signature) for data access
|
|
335
|
+
let dataKey: string;
|
|
222
336
|
|
|
223
337
|
const mockNameParts = splitOutsideParenthesesAndArrays(baseMockName);
|
|
224
338
|
|
|
@@ -228,33 +342,12 @@ export default function constructMockCode(
|
|
|
228
342
|
let foundEntityWithSignature = false;
|
|
229
343
|
let signatureSchema: DataStructure['signatureSchema'] | undefined;
|
|
230
344
|
|
|
231
|
-
for (const filePath in dependencySchemas) {
|
|
345
|
+
entitySearch: for (const filePath in dependencySchemas) {
|
|
232
346
|
for (const entityName in dependencySchemas[filePath]) {
|
|
233
|
-
//
|
|
234
|
-
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
: mockNameParts[0];
|
|
238
|
-
|
|
239
|
-
// Check for direct match
|
|
240
|
-
let matches =
|
|
241
|
-
entityName === targetEntityName || entityName === mockNameParts[0];
|
|
242
|
-
|
|
243
|
-
// If no direct match and no qualifier was provided, check if the entity
|
|
244
|
-
// is stored under a variable-qualified key (e.g., "stateBadge <- getStateBadge")
|
|
245
|
-
// This handles the case where gatherDataForMocks stored the entity with a variable
|
|
246
|
-
// qualifier but writeScenarioComponents called constructMockCode without one.
|
|
247
|
-
if (!matches && !variableQualifier) {
|
|
248
|
-
const qualifiedKeyMatch = entityName.match(
|
|
249
|
-
new RegExp(`^([a-zA-Z_][a-zA-Z0-9_]*)\\s*<-\\s*${mockNameParts[0]}$`),
|
|
250
|
-
);
|
|
251
|
-
if (qualifiedKeyMatch) {
|
|
252
|
-
matches = true;
|
|
253
|
-
// Extract the variable qualifier from the entity name so we can use
|
|
254
|
-
// it for the data lookup key later
|
|
255
|
-
variableQualifier = qualifiedKeyMatch[1];
|
|
256
|
-
}
|
|
257
|
-
}
|
|
347
|
+
// Match entity by base name (without generics/args)
|
|
348
|
+
const entityBaseName = entityName.split(/[<(]/)[0];
|
|
349
|
+
const matches =
|
|
350
|
+
entityBaseName === baseMockName || entityName === mockNameParts[0];
|
|
258
351
|
|
|
259
352
|
if (!matches) continue;
|
|
260
353
|
|
|
@@ -293,11 +386,49 @@ export default function constructMockCode(
|
|
|
293
386
|
// However, we still need to remove duplicate function calls that create invalid syntax
|
|
294
387
|
removeDuplicateFunctionCalls(relevantReturnValueSchema);
|
|
295
388
|
dataStructureValue = relevantReturnValueSchema?.[dataStructurePath];
|
|
296
|
-
break;
|
|
389
|
+
break entitySearch;
|
|
297
390
|
}
|
|
298
391
|
}
|
|
299
392
|
}
|
|
300
393
|
|
|
394
|
+
// Check if the entity is used as a function (called with ()) vs an object/namespace.
|
|
395
|
+
// Look for paths in the schema that start with "baseMockName(" or "baseMockName<" indicating function calls.
|
|
396
|
+
// The "<" handles generic type parameters like useLoaderData<T>().
|
|
397
|
+
// Also check dataStructurePath === 'returnValue' which indicates a function return value.
|
|
398
|
+
const entityIsFunction =
|
|
399
|
+
foundEntityWithSignature ||
|
|
400
|
+
dataStructurePath === 'returnValue' ||
|
|
401
|
+
Object.keys(relevantReturnValueSchema ?? {}).some(
|
|
402
|
+
(key) =>
|
|
403
|
+
key.startsWith(`${baseMockName}(`) ||
|
|
404
|
+
key.startsWith(`${baseMockName}<`),
|
|
405
|
+
);
|
|
406
|
+
|
|
407
|
+
// Calculate the data key - use the call signature (mockName) for data access
|
|
408
|
+
// For simple names without parentheses:
|
|
409
|
+
// - Append () ONLY if the entity is a function/hook (detected above)
|
|
410
|
+
// - Don't append () for object/namespace mocks like "supabase"
|
|
411
|
+
if (mockNameIsCallSignature || mockName.includes('(')) {
|
|
412
|
+
dataKey = mockName;
|
|
413
|
+
} else if (entityIsFunction) {
|
|
414
|
+
// Entity is a function/hook - append () to match call signature format
|
|
415
|
+
dataKey = `${mockName}()`;
|
|
416
|
+
} else {
|
|
417
|
+
// Entity is an object/namespace - use bare name as key
|
|
418
|
+
dataKey = mockName;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// Helper to wrap key in appropriate quotes for computed property access
|
|
422
|
+
// Use single quotes when key contains double quotes to avoid syntax errors
|
|
423
|
+
const quotePropertyKey = (key: string): string => {
|
|
424
|
+
const escaped = key.replace(/\n/g, '\\n');
|
|
425
|
+
if (escaped.includes('"')) {
|
|
426
|
+
// Use single quotes, escaping any single quotes in the key
|
|
427
|
+
return `['${escaped.replace(/'/g, "\\'")}']`;
|
|
428
|
+
}
|
|
429
|
+
return `["${escaped}"]`;
|
|
430
|
+
};
|
|
431
|
+
|
|
301
432
|
// Check if the return value schema only contains function type markers
|
|
302
433
|
// (e.g., "validateInputs()": "function") without actual return data
|
|
303
434
|
// (no functionCallReturnValue entries)
|
|
@@ -326,6 +457,8 @@ export default function constructMockCode(
|
|
|
326
457
|
key.startsWith('signature['),
|
|
327
458
|
).length;
|
|
328
459
|
const args = Array.from({ length: argCount }, (_, i) => `arg${i + 1}`);
|
|
460
|
+
// Always add ...rest to accept extra arguments beyond the signature
|
|
461
|
+
args.push('...rest');
|
|
329
462
|
const argsString = args.join(', ');
|
|
330
463
|
|
|
331
464
|
// Generate empty mock function
|
|
@@ -350,8 +483,38 @@ export default function constructMockCode(
|
|
|
350
483
|
key.startsWith('signature['),
|
|
351
484
|
).length;
|
|
352
485
|
const args = Array.from({ length: argCount }, (_, i) => `arg${i + 1}`);
|
|
486
|
+
// Always add ...rest to accept extra arguments beyond the signature
|
|
487
|
+
args.push('...rest');
|
|
353
488
|
const argsString = args.join(', ');
|
|
354
489
|
|
|
490
|
+
// Check for Higher-Order Component (HOC) pattern:
|
|
491
|
+
// - First argument is a function (component) or unknown (couldn't trace type)
|
|
492
|
+
// - Returns a function
|
|
493
|
+
// HOCs like memo, forwardRef, createContext should return their first argument
|
|
494
|
+
//
|
|
495
|
+
// The return value key can be either:
|
|
496
|
+
// - 'memo()' (clean format)
|
|
497
|
+
// - 'memo(({ value, width }: Props) => { ... })' (full component code format)
|
|
498
|
+
const firstArgIsFunctionOrUnknown =
|
|
499
|
+
signatureSchema['signature[0]'] === 'function' ||
|
|
500
|
+
signatureSchema['signature[0]'] === 'unknown';
|
|
501
|
+
const returnsFunction = relevantReturnValueSchema
|
|
502
|
+
? Object.entries(relevantReturnValueSchema).some(([key, value]) => {
|
|
503
|
+
// Check if key represents a function call that returns a function
|
|
504
|
+
// Key should start with the mock name, contain '(', end with ')', and have value 'function'
|
|
505
|
+
const isFunctionCall =
|
|
506
|
+
key.startsWith(mockName + '(') && key.endsWith(')');
|
|
507
|
+
return isFunctionCall && value === 'function';
|
|
508
|
+
})
|
|
509
|
+
: false;
|
|
510
|
+
|
|
511
|
+
if (firstArgIsFunctionOrUnknown && returnsFunction) {
|
|
512
|
+
// HOC pattern detected - return the first argument
|
|
513
|
+
return `function ${mockName}(${argsString}) {
|
|
514
|
+
return arg1;
|
|
515
|
+
}`;
|
|
516
|
+
}
|
|
517
|
+
|
|
355
518
|
// Generate empty mock function
|
|
356
519
|
return `function ${mockName}(${argsString}) {
|
|
357
520
|
// Empty mock - original function mocked out
|
|
@@ -380,6 +543,99 @@ export default function constructMockCode(
|
|
|
380
543
|
dataStructureValue === 'array' &&
|
|
381
544
|
(dataStructurePath === 'returnValue' || pathDepth <= mockNameParts.length);
|
|
382
545
|
|
|
546
|
+
// OPTIMIZATION: Early return for tuple-returning hooks (useAtom, useState, etc.)
|
|
547
|
+
// These hooks have simple [value, setter] return patterns that don't need the full
|
|
548
|
+
// 9216-key schema processing. Check if this is a tuple-returning hook and generate
|
|
549
|
+
// the mock code directly without iterating over all schema keys.
|
|
550
|
+
if (TUPLE_RETURNING_HOOKS.has(baseMockName) && isFunction) {
|
|
551
|
+
// Check if schema has generic array pattern (indicates tuple return like [value, setter])
|
|
552
|
+
const schemaKeys = Object.keys(relevantReturnValueSchema ?? {});
|
|
553
|
+
const hasGenericArrayInSchema = schemaKeys.some(
|
|
554
|
+
(k) =>
|
|
555
|
+
k.includes('.functionCallReturnValue[]') ||
|
|
556
|
+
k === `${dataKey}.functionCallReturnValue[]` ||
|
|
557
|
+
k === 'returnValue[]',
|
|
558
|
+
);
|
|
559
|
+
|
|
560
|
+
// Check for differentiated tuple indices (e.g., functionCallReturnValue[2], [3]) which would NOT be a standard tuple
|
|
561
|
+
// We only check indices immediately after functionCallReturnValue, not nested indices like signature[2]
|
|
562
|
+
const tupleHasDifferentiatedIndices = schemaKeys.some((k) => {
|
|
563
|
+
// Look for .functionCallReturnValue[N] where N >= 2
|
|
564
|
+
const match = k.match(/\.functionCallReturnValue\[(\d+)\]/);
|
|
565
|
+
if (!match) return false;
|
|
566
|
+
const idx = parseInt(match[1], 10);
|
|
567
|
+
return idx >= 2;
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
const isTupleReturningHook =
|
|
571
|
+
hasGenericArrayInSchema && !tupleHasDifferentiatedIndices;
|
|
572
|
+
|
|
573
|
+
if (isTupleReturningHook) {
|
|
574
|
+
// Find all call patterns for this hook (e.g., useAtom(quoteFilterAtom), useAtom(supplierAtom))
|
|
575
|
+
const hookCallPatterns = Object.keys(relevantReturnValueSchema ?? {})
|
|
576
|
+
.filter((k) => {
|
|
577
|
+
const regex = new RegExp(`^${baseMockName}\\([^)]+\\)$`);
|
|
578
|
+
return regex.test(k);
|
|
579
|
+
})
|
|
580
|
+
.map((k) => {
|
|
581
|
+
const match = k.match(/\(([^)]+)\)/);
|
|
582
|
+
return { key: k, arg: match?.[1] ?? '' };
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
let tupleReturnCode: string;
|
|
586
|
+
if (hookCallPatterns.length > 1) {
|
|
587
|
+
// Multiple patterns - generate conditional dispatch
|
|
588
|
+
const conditions = hookCallPatterns
|
|
589
|
+
.map(
|
|
590
|
+
({ key, arg }) =>
|
|
591
|
+
`if (argLabel === '${arg}' || argStr.includes('${arg}')) {\n return [scenarios().data()?.["${key}"]?.[0] ?? [], () => {}];\n }`,
|
|
592
|
+
)
|
|
593
|
+
.join('\n ');
|
|
594
|
+
const fallbackKey = hookCallPatterns[0]?.key ?? dataKey;
|
|
595
|
+
tupleReturnCode = `(() => {
|
|
596
|
+
// Dynamic dispatch for tuple-returning hook with multiple argument patterns
|
|
597
|
+
const argLabel = args[0]?.debugLabel ?? '';
|
|
598
|
+
const argStr = args[0]?.toString?.() ?? String(args[0] ?? '');
|
|
599
|
+
${conditions}
|
|
600
|
+
return [scenarios().data()?.["${fallbackKey}"]?.[0] ?? [], () => {}];
|
|
601
|
+
})()`;
|
|
602
|
+
} else {
|
|
603
|
+
// Single or no patterns - use dynamic dispatch
|
|
604
|
+
const fallbackKey = hookCallPatterns[0]?.key ?? `${baseMockName}()`;
|
|
605
|
+
tupleReturnCode = `(() => {
|
|
606
|
+
// Dynamic dispatch for tuple-returning hook
|
|
607
|
+
const argLabel = args[0]?.debugLabel ?? '';
|
|
608
|
+
const argStr = args[0]?.toString?.() ?? '';
|
|
609
|
+
const allData = scenarios().data() ?? {};
|
|
610
|
+
if (argLabel) {
|
|
611
|
+
const labelKey = '${baseMockName}(' + argLabel + ')';
|
|
612
|
+
if (allData[labelKey]) {
|
|
613
|
+
return [allData[labelKey]?.[0] ?? [], () => {}];
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
const keys = Object.keys(allData).filter(k => k.startsWith('${baseMockName}('));
|
|
617
|
+
for (const key of keys) {
|
|
618
|
+
const keyArg = key.slice(${baseMockName.length + 1}, -1);
|
|
619
|
+
if (argStr.includes(keyArg)) {
|
|
620
|
+
return [allData[key]?.[0] ?? [], () => {}];
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
return [allData[keys[0] ?? '${fallbackKey}']?.[0] ?? [], () => {}];
|
|
624
|
+
})()`;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
const safeFunctionName = options?.uniqueFunctionSuffix
|
|
628
|
+
? `${baseMockName}_${options.uniqueFunctionSuffix}`
|
|
629
|
+
: options?.keepOriginalFunctionName
|
|
630
|
+
? baseMockName
|
|
631
|
+
: mockNameIsCallSignature && derivedFunctionName
|
|
632
|
+
? derivedFunctionName
|
|
633
|
+
: baseMockName;
|
|
634
|
+
|
|
635
|
+
return `function ${safeFunctionName}(...args) {\n return ${tupleReturnCode};\n}`;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
|
|
383
639
|
const returnValueParts: ReturnValuePart = {
|
|
384
640
|
name: dataStructureName,
|
|
385
641
|
isArray: isRootArray,
|
|
@@ -412,22 +668,21 @@ export default function constructMockCode(
|
|
|
412
668
|
// so "useLoaderData<typeof loader>()" becomes "useLoaderData()"
|
|
413
669
|
name = cleanOutTypes(name);
|
|
414
670
|
|
|
415
|
-
// For
|
|
416
|
-
// This
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
//
|
|
420
|
-
|
|
421
|
-
|
|
671
|
+
// For root data access, use the dataKey (original call signature or canonical key)
|
|
672
|
+
// This preserves the original call signature for LLM clarity
|
|
673
|
+
if (isRootAccess) {
|
|
674
|
+
// For call signature format, use the original mockName as the data key
|
|
675
|
+
// e.g., scenarios().data()?.["useFetcher<User>()"]
|
|
676
|
+
// e.g., scenarios().data()?.["db.select(usersQuery)"]
|
|
677
|
+
return `?.${quotePropertyKey(dataKey)}`;
|
|
422
678
|
}
|
|
423
679
|
|
|
424
680
|
// Only use unquoted array access syntax for pure array indices like [0], [1]
|
|
425
|
-
|
|
426
|
-
if (name.match(/^\[\d+\]$/) && !name.includes(' <- ')) {
|
|
681
|
+
if (name.match(/^\[\d+\]$/)) {
|
|
427
682
|
return `?.${name}`;
|
|
428
683
|
}
|
|
429
684
|
|
|
430
|
-
return
|
|
685
|
+
return `?.${quotePropertyKey(name)}`;
|
|
431
686
|
};
|
|
432
687
|
|
|
433
688
|
const constructDataPaths = () => {
|
|
@@ -495,7 +750,20 @@ export default function constructMockCode(
|
|
|
495
750
|
hasNoReturnData,
|
|
496
751
|
} = returnValue;
|
|
497
752
|
|
|
498
|
-
|
|
753
|
+
// When an array has differentiated indices ([0], [1], etc.), filter out any
|
|
754
|
+
// non-index items from nested. These non-index items come from generic [] paths
|
|
755
|
+
// like [].filter or [].sort, which describe element properties, not array elements.
|
|
756
|
+
// Including them would generate invalid syntax like "sort: ..." inside an array literal.
|
|
757
|
+
const hasDifferentiatedIndices =
|
|
758
|
+
isArray &&
|
|
759
|
+
nested &&
|
|
760
|
+
nested.some((n) => n.name.match(/^\[\d+\]$/) && n.name !== '[0]');
|
|
761
|
+
const filteredNested =
|
|
762
|
+
hasDifferentiatedIndices && nested
|
|
763
|
+
? nested.filter((n) => n.name.match(/^\[\d+\]$/))
|
|
764
|
+
: nested;
|
|
765
|
+
|
|
766
|
+
const nestedContent: (string | undefined)[] = (filteredNested ?? []).map(
|
|
499
767
|
(nestedItem) => {
|
|
500
768
|
const nestedContent = constructReturnValueString(
|
|
501
769
|
nestedItem,
|
|
@@ -579,53 +847,114 @@ export default function constructMockCode(
|
|
|
579
847
|
) {
|
|
580
848
|
levelContentItems.push(...dataPaths.map((path) => `...${path}`));
|
|
581
849
|
}
|
|
582
|
-
|
|
850
|
+
// Filter out nested content that would be invalid as object properties
|
|
851
|
+
// (e.g., bare arrow functions like "() => {...}" without a property name)
|
|
852
|
+
// Only apply this filter when building object content, not array content.
|
|
853
|
+
// Bare arrow functions ARE valid as array elements (like [0] = {...}, [1] = () => {...})
|
|
854
|
+
// Check both isArray (item IS an array) and returnsFunctionArray (item returns an array)
|
|
855
|
+
const inArrayContext = isArray || returnsFunctionArray;
|
|
856
|
+
const validNestedContent = nestedContent.filter((content) => {
|
|
857
|
+
if (!content) return false;
|
|
858
|
+
// Only filter bare arrow functions when NOT in array context
|
|
859
|
+
// In arrays, bare arrow functions are valid elements
|
|
860
|
+
if (!inArrayContext && content.match(/^\s*\([^)]*\)\s*=>/)) {
|
|
861
|
+
return false;
|
|
862
|
+
}
|
|
863
|
+
return true;
|
|
864
|
+
});
|
|
865
|
+
levelContentItems.push(...validNestedContent);
|
|
583
866
|
|
|
584
867
|
let levelContents: string = levelContentItems.filter(Boolean).join(',\n');
|
|
585
868
|
if (returnsFunctionArgs) {
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
869
|
+
// When returnsFunctionArgs is empty [] OR has a single literal string argument,
|
|
870
|
+
// the function returns a callable function (e.g., getTranslate() returns t,
|
|
871
|
+
// where t('key') looks up translations)
|
|
872
|
+
// Generate a dispatch function that looks up keys based on the argument
|
|
873
|
+
//
|
|
874
|
+
// Detect translation-like pattern:
|
|
875
|
+
// - Data path ends with ["('some.literal')"] - a literal string key
|
|
876
|
+
// - This means the mock data has keys like "('common.surveys')": "Surveys"
|
|
877
|
+
// - Exclude ["()"] which is an empty function call (not a translation pattern)
|
|
878
|
+
const dataPath = dataPaths[0];
|
|
879
|
+
// Pattern matches ?.["('...')"] at end of path, but NOT ?.["()"] (empty args)
|
|
880
|
+
const literalKeyPattern = dataPath?.match(/\?\.\["\('.+'\)"\]$/);
|
|
881
|
+
|
|
882
|
+
if (
|
|
883
|
+
!returnsFunctionArray &&
|
|
884
|
+
dataPaths.length === 1 &&
|
|
885
|
+
literalKeyPattern // Only dispatch when there's a literal key pattern
|
|
886
|
+
) {
|
|
887
|
+
// Function returns a function - generate dispatch function
|
|
888
|
+
// Strip the literal key from the path and use dynamic lookup
|
|
889
|
+
const dataPathBase = literalKeyPattern
|
|
890
|
+
? dataPath.replace(/\?\.\["\('.+'\)"\]$/, '')
|
|
891
|
+
: dataPath;
|
|
892
|
+
const funcContents = `return ${dataPathBase}?.[\`('\${arg1}')\`]`;
|
|
893
|
+
levelContents = `(arg1) => {\n${indent(funcContents)}\n}`;
|
|
894
|
+
|
|
895
|
+
if (!isArray) {
|
|
896
|
+
return levelContents;
|
|
602
897
|
}
|
|
603
898
|
} else {
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
if (
|
|
611
|
-
hasNoReturnData ||
|
|
612
|
-
(hasNestedItems && !hasActualNestedContent)
|
|
613
|
-
) {
|
|
899
|
+
const argsString = returnsFunctionArgs
|
|
900
|
+
.map((_, index) => `arg${index + 1}`)
|
|
901
|
+
.join(', ');
|
|
902
|
+
let funcContents = '';
|
|
903
|
+
if (returnsFunctionArray) {
|
|
904
|
+
if (hasNoReturnData) {
|
|
614
905
|
// Function has no return data (only signatures) - return empty array
|
|
615
906
|
funcContents = 'return []';
|
|
616
|
-
} else {
|
|
617
|
-
//
|
|
907
|
+
} else if (levelContents.length === 0 && dataPaths.length === 1) {
|
|
908
|
+
// When returning an array with no nested content, return the data path directly
|
|
909
|
+
// (the data path points to the array in scenario data)
|
|
618
910
|
funcContents = `return ${dataPaths[0]}`;
|
|
911
|
+
} else if (levelContents.length === 0) {
|
|
912
|
+
funcContents = 'return []';
|
|
913
|
+
} else {
|
|
914
|
+
funcContents = `return [\n${indent(levelContents)}\n]`;
|
|
619
915
|
}
|
|
620
916
|
} else {
|
|
621
|
-
|
|
917
|
+
// Check if function has no actual return data (only signatures)
|
|
918
|
+
const hasNestedItems = nested && nested.length > 0;
|
|
919
|
+
const hasActualNestedContent =
|
|
920
|
+
nestedContent.filter(Boolean).length > 0;
|
|
921
|
+
|
|
922
|
+
if (levelContentItems.length === 1 && dataPaths.length === 1) {
|
|
923
|
+
if (
|
|
924
|
+
hasNoReturnData ||
|
|
925
|
+
(hasNestedItems && !hasActualNestedContent)
|
|
926
|
+
) {
|
|
927
|
+
// Function has no return data (only signatures) - return empty array
|
|
928
|
+
funcContents = 'return []';
|
|
929
|
+
} else {
|
|
930
|
+
// Has return data - return data path
|
|
931
|
+
funcContents = `return ${dataPaths[0]}`;
|
|
932
|
+
}
|
|
933
|
+
} else {
|
|
934
|
+
funcContents = `return {\n${indent(levelContents)}\n}`;
|
|
935
|
+
}
|
|
622
936
|
}
|
|
623
|
-
}
|
|
624
937
|
|
|
625
|
-
|
|
938
|
+
levelContents = `(${argsString}) => {\n${indent(funcContents)}\n}`;
|
|
939
|
+
|
|
940
|
+
if (!isArray) {
|
|
941
|
+
return levelContents;
|
|
942
|
+
}
|
|
943
|
+
}
|
|
626
944
|
|
|
627
|
-
|
|
628
|
-
|
|
945
|
+
// For generic arrays of functions WITH nested properties (e.g., functionCallReturnValue[] = "function"
|
|
946
|
+
// with nested .filter, .sort, etc.), the levelContents would be a bare arrow function "() => {...}"
|
|
947
|
+
// that wraps object content. Using this in a .map(({...})) creates invalid syntax like "({ () => {...} })".
|
|
948
|
+
// When isGenericArray is true AND there are nested properties, we're accessing data from the elements,
|
|
949
|
+
// not calling them - so skip the function wrapping.
|
|
950
|
+
// But if there are NO nested properties, keep the wrapper because callers may want to call the elements.
|
|
951
|
+
const hasNonStructuralNestedItems =
|
|
952
|
+
nested &&
|
|
953
|
+
nested.length > 0 &&
|
|
954
|
+
nested.some((n) => !n.name.match(/^\[\d*\]$/));
|
|
955
|
+
if (isGenericArray && hasNonStructuralNestedItems) {
|
|
956
|
+
// Skip the arrow function wrapper - just use the nested content directly
|
|
957
|
+
levelContents = levelContentItems.filter(Boolean).join(',\n');
|
|
629
958
|
}
|
|
630
959
|
}
|
|
631
960
|
|
|
@@ -641,7 +970,123 @@ export default function constructMockCode(
|
|
|
641
970
|
});
|
|
642
971
|
|
|
643
972
|
let returnValueContents = '';
|
|
644
|
-
|
|
973
|
+
|
|
974
|
+
// Check if this is a known tuple-returning hook (useAtom, useState, etc.)
|
|
975
|
+
// These should return [value, setter] tuples, not arrays or data paths
|
|
976
|
+
// Check isGenericArray from current context OR from schema for root level calls
|
|
977
|
+
// (at root level, isGenericArray might not be set yet but the schema contains [] pattern)
|
|
978
|
+
const hasGenericArrayInSchema =
|
|
979
|
+
root &&
|
|
980
|
+
TUPLE_RETURNING_HOOKS.has(baseMockName) &&
|
|
981
|
+
Object.keys(relevantReturnValueSchema ?? {}).some((k) =>
|
|
982
|
+
k.includes('.functionCallReturnValue[]'),
|
|
983
|
+
);
|
|
984
|
+
// Check if there are array indices beyond what a standard 2-element tuple would have
|
|
985
|
+
// For tuple-returning hooks, [0] and [1] are expected (value and setter)
|
|
986
|
+
// Only consider it "differentiated" if there are indices >= 2 (e.g., [2], [3])
|
|
987
|
+
const tupleHasDifferentiatedIndices = nested?.some((n) => {
|
|
988
|
+
const indexMatch = n.name.match(/^\[(\d+)\]$/);
|
|
989
|
+
if (!indexMatch) return false;
|
|
990
|
+
const index = parseInt(indexMatch[1], 10);
|
|
991
|
+
return index >= 2;
|
|
992
|
+
});
|
|
993
|
+
const isTupleReturningHook =
|
|
994
|
+
TUPLE_RETURNING_HOOKS.has(baseMockName) &&
|
|
995
|
+
(isGenericArray || hasGenericArrayInSchema) &&
|
|
996
|
+
!tupleHasDifferentiatedIndices;
|
|
997
|
+
|
|
998
|
+
// Debug logging for tuple-returning hooks
|
|
999
|
+
if (TUPLE_RETURNING_HOOKS.has(baseMockName) && root) {
|
|
1000
|
+
const schemaKeys = Object.keys(relevantReturnValueSchema ?? {});
|
|
1001
|
+
const hasArrayPattern = schemaKeys.some((k) =>
|
|
1002
|
+
k.includes('.functionCallReturnValue[]'),
|
|
1003
|
+
);
|
|
1004
|
+
console.log(
|
|
1005
|
+
`CodeYam: Tuple hook check for ${baseMockName} (root):`,
|
|
1006
|
+
`hasGenericArrayInSchema=${hasGenericArrayInSchema}`,
|
|
1007
|
+
`hasArrayPattern=${hasArrayPattern}`,
|
|
1008
|
+
`tupleHasDifferentiatedIndices=${tupleHasDifferentiatedIndices}`,
|
|
1009
|
+
`isTupleReturningHook=${isTupleReturningHook}`,
|
|
1010
|
+
`schemaKeysSample=${schemaKeys.slice(0, 5).join(', ')}`,
|
|
1011
|
+
);
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
if (isTupleReturningHook) {
|
|
1015
|
+
// Tuple-returning hooks should return [value, setter] tuple
|
|
1016
|
+
// The value is the first element from scenarios data, setter is a no-op
|
|
1017
|
+
// Default to [] when data is undefined to prevent errors like ".includes is not a function"
|
|
1018
|
+
|
|
1019
|
+
// Check if there are multiple call patterns for this hook in the schema
|
|
1020
|
+
// (e.g., useAtom(quoteFilterAtom) and useAtom(supplierAtom))
|
|
1021
|
+
const hookCallPatterns = Object.keys(relevantReturnValueSchema ?? {})
|
|
1022
|
+
.filter((k) => {
|
|
1023
|
+
// Match patterns like "useAtom(someArg)" but not nested paths like "useAtom(x).foo"
|
|
1024
|
+
const regex = new RegExp(`^${baseMockName}\\([^)]+\\)$`);
|
|
1025
|
+
return regex.test(k);
|
|
1026
|
+
})
|
|
1027
|
+
.map((k) => {
|
|
1028
|
+
// Extract the argument from the key like "useAtom(quoteFilterAtom)" -> "quoteFilterAtom"
|
|
1029
|
+
const match = k.match(/\(([^)]+)\)/);
|
|
1030
|
+
return { key: k, arg: match?.[1] ?? '' };
|
|
1031
|
+
});
|
|
1032
|
+
|
|
1033
|
+
if (hookCallPatterns.length > 1) {
|
|
1034
|
+
// Multiple patterns - generate conditional dispatch based on first argument
|
|
1035
|
+
// For Jotai atoms, we use debugLabel; for others, we try to match the argument string
|
|
1036
|
+
const conditions = hookCallPatterns
|
|
1037
|
+
.map(
|
|
1038
|
+
({ key, arg }) =>
|
|
1039
|
+
`if (argLabel === '${arg}' || argStr.includes('${arg}')) {\n return [scenarios().data()?.["${key}"]?.[0] ?? [], () => {}];\n }`,
|
|
1040
|
+
)
|
|
1041
|
+
.join('\n ');
|
|
1042
|
+
|
|
1043
|
+
// Use the first pattern as fallback
|
|
1044
|
+
const fallbackKey = hookCallPatterns[0]?.key ?? dataKey;
|
|
1045
|
+
|
|
1046
|
+
returnValueContents = `(() => {
|
|
1047
|
+
// Dynamic dispatch for tuple-returning hook with multiple argument patterns
|
|
1048
|
+
const argLabel = args[0]?.debugLabel ?? '';
|
|
1049
|
+
const argStr = args[0]?.toString?.() ?? String(args[0] ?? '');
|
|
1050
|
+
${conditions}
|
|
1051
|
+
// Fallback to first pattern
|
|
1052
|
+
return [scenarios().data()?.["${fallbackKey}"]?.[0] ?? [], () => {}];
|
|
1053
|
+
})()`;
|
|
1054
|
+
} else {
|
|
1055
|
+
// Single pattern or no patterns - use dynamic dispatch to handle case where
|
|
1056
|
+
// the mock is used with different atoms than what was captured in the schema.
|
|
1057
|
+
// Use the first argument to construct the data key dynamically.
|
|
1058
|
+
const fallbackKey = hookCallPatterns[0]?.key ?? `${baseMockName}()`;
|
|
1059
|
+
|
|
1060
|
+
returnValueContents = `(() => {
|
|
1061
|
+
// Dynamic dispatch for tuple-returning hook
|
|
1062
|
+
// Try to construct key from argument's debugLabel (Jotai atoms) or toString
|
|
1063
|
+
const argLabel = args[0]?.debugLabel ?? '';
|
|
1064
|
+
const argStr = args[0]?.toString?.() ?? '';
|
|
1065
|
+
const allData = scenarios().data() ?? {};
|
|
1066
|
+
|
|
1067
|
+
// Try to find a matching key using debugLabel first
|
|
1068
|
+
if (argLabel) {
|
|
1069
|
+
const labelKey = '${baseMockName}(' + argLabel + ')';
|
|
1070
|
+
if (allData[labelKey]) {
|
|
1071
|
+
return [allData[labelKey]?.[0] ?? [], () => {}];
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
// Try to find any matching key that contains part of the argument string
|
|
1076
|
+
const keys = Object.keys(allData).filter(k => k.startsWith('${baseMockName}('));
|
|
1077
|
+
for (const key of keys) {
|
|
1078
|
+
const keyArg = key.slice(${baseMockName.length + 1}, -1);
|
|
1079
|
+
if (argStr.includes(keyArg)) {
|
|
1080
|
+
return [allData[key]?.[0] ?? [], () => {}];
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
// Fallback to first matching key or default
|
|
1085
|
+
const fallback = keys[0] ?? '${fallbackKey}';
|
|
1086
|
+
return [allData[fallback]?.[0] ?? [], () => {}];
|
|
1087
|
+
})()`;
|
|
1088
|
+
}
|
|
1089
|
+
} else if (
|
|
645
1090
|
!returnsFunctionArgs &&
|
|
646
1091
|
nestedContent.length === 0 &&
|
|
647
1092
|
dataPaths.length === 1
|
|
@@ -662,31 +1107,438 @@ export default function constructMockCode(
|
|
|
662
1107
|
// When GENERIC array (using []) has nested content (like functions that need wrapping),
|
|
663
1108
|
// use .map() to transform ALL elements instead of just creating [0]
|
|
664
1109
|
// For DIFFERENTIATED arrays (using [0], [1], etc.), keep the static array structure
|
|
1110
|
+
//
|
|
1111
|
+
// IMPORTANT: If the nested content contains differentiated indices like [0], [1],
|
|
1112
|
+
// we MUST use static array pattern, not .map(). The presence of differentiated
|
|
1113
|
+
// indices means the array elements have different types/structures, so .map()
|
|
1114
|
+
// would generate invalid code trying to treat them uniformly.
|
|
1115
|
+
const hasDifferentiatedIndices =
|
|
1116
|
+
nested &&
|
|
1117
|
+
nested.some((n) => n.name.match(/^\[\d+\]$/) && n.name !== '[0]');
|
|
665
1118
|
if (
|
|
666
1119
|
isGenericArray &&
|
|
667
1120
|
nestedContent.length > 0 &&
|
|
668
|
-
dataPaths.length > 0
|
|
1121
|
+
dataPaths.length > 0 &&
|
|
1122
|
+
!hasDifferentiatedIndices
|
|
669
1123
|
) {
|
|
670
1124
|
// Get the array base path (without the [0])
|
|
671
1125
|
const arrayBasePath = dataPaths[0].replace(/\?\.\[0\]$/, '');
|
|
672
1126
|
// Replace [0] references with [__idx__] in level contents
|
|
673
|
-
|
|
1127
|
+
let mappedContents = levelContents.replace(
|
|
674
1128
|
/\?\.\[0\]/g,
|
|
675
1129
|
'?.[__idx__]',
|
|
676
1130
|
);
|
|
677
1131
|
// levelContents may already be wrapped in {...} from structural [0] element,
|
|
678
1132
|
// so check if we need to add the wrapper or not
|
|
679
1133
|
const needsWrapper = !mappedContents.trim().startsWith('{');
|
|
1134
|
+
|
|
1135
|
+
// Helper to check if a position is inside a string literal
|
|
1136
|
+
// Returns the end position of the string if inside one, -1 otherwise
|
|
1137
|
+
// Defined here so it's accessible in both needsWrapper branches
|
|
1138
|
+
const skipStringLiteral = (
|
|
1139
|
+
content: string,
|
|
1140
|
+
pos: number,
|
|
1141
|
+
): number => {
|
|
1142
|
+
const char = content[pos];
|
|
1143
|
+
if (char !== '"' && char !== "'" && char !== '`') return -1;
|
|
1144
|
+
// Find the matching closing quote
|
|
1145
|
+
let j = pos + 1;
|
|
1146
|
+
while (j < content.length) {
|
|
1147
|
+
if (content[j] === '\\') {
|
|
1148
|
+
j += 2; // Skip escaped character
|
|
1149
|
+
continue;
|
|
1150
|
+
}
|
|
1151
|
+
if (content[j] === char) {
|
|
1152
|
+
return j + 1; // Return position after closing quote
|
|
1153
|
+
}
|
|
1154
|
+
j++;
|
|
1155
|
+
}
|
|
1156
|
+
return content.length; // Unclosed string, skip to end
|
|
1157
|
+
};
|
|
1158
|
+
|
|
1159
|
+
// Filter out bare arrow functions which are invalid as object properties.
|
|
1160
|
+
// Arrow functions can be multi-line, so we need to match the entire function body, not just the first line.
|
|
1161
|
+
// Pattern: starts with "(args) =>", followed by either:
|
|
1162
|
+
// - A single-line body: "() => expression"
|
|
1163
|
+
// - A multi-line body: "() => { ... }" (with matching braces)
|
|
1164
|
+
// IMPORTANT: Only filter BARE arrow functions (without property names).
|
|
1165
|
+
// "() => {...}" is invalid, but "get: (arg1) => {...}" is valid.
|
|
1166
|
+
// We use a function to properly handle nested braces.
|
|
1167
|
+
// Defined here so it's accessible in both needsWrapper branches
|
|
1168
|
+
const filterOutArrowFunctions = (content: string): string => {
|
|
1169
|
+
const result: string[] = [];
|
|
1170
|
+
let i = 0;
|
|
1171
|
+
while (i < content.length) {
|
|
1172
|
+
// Skip over string literals entirely
|
|
1173
|
+
const stringEnd = skipStringLiteral(content, i);
|
|
1174
|
+
if (stringEnd !== -1) {
|
|
1175
|
+
result.push(content.slice(i, stringEnd));
|
|
1176
|
+
i = stringEnd;
|
|
1177
|
+
continue;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
// Check if we're at the start of an arrow function (with optional leading whitespace)
|
|
1181
|
+
const arrowMatch = content
|
|
1182
|
+
.slice(i)
|
|
1183
|
+
.match(/^(\s*)\([^)]*\)\s*=>\s*/);
|
|
1184
|
+
if (arrowMatch) {
|
|
1185
|
+
// Check if this is a bare arrow function or a named property with arrow function value
|
|
1186
|
+
// Look back to see if there's a "key:" pattern before this position
|
|
1187
|
+
const before = content.slice(0, i);
|
|
1188
|
+
const beforeTrimmed = before.trim();
|
|
1189
|
+
// Valid patterns where arrow function is NOT bare:
|
|
1190
|
+
// 1. Property value: "key: (arg) => ..." - ends with ':'
|
|
1191
|
+
// 2. Function argument: ".map((arg) => ..." - ends with '('
|
|
1192
|
+
// 3. Method call: "?.map" followed directly by the arrow function
|
|
1193
|
+
// In this case, the '(' is consumed by the arrow function regex match,
|
|
1194
|
+
// so beforeTrimmed ends with the method name (e.g., 'map'), not '('.
|
|
1195
|
+
// We detect this by checking if beforeTrimmed ends with an identifier
|
|
1196
|
+
// that could be a method name (preceded by '.' or '?.').
|
|
1197
|
+
// NOTE: We don't include ',' because "{ prop, () => {} }" is invalid
|
|
1198
|
+
// (can't distinguish function argument from object property context)
|
|
1199
|
+
const isPropertyValue = beforeTrimmed.endsWith(':');
|
|
1200
|
+
const isFunctionArg = beforeTrimmed.endsWith('(');
|
|
1201
|
+
// Check if before ends with a method call pattern like ".map" or "?.map"
|
|
1202
|
+
// The '(' after the method name is consumed by the arrow function regex
|
|
1203
|
+
const isMethodCallArg = /\??\.\w+$/.test(beforeTrimmed);
|
|
1204
|
+
const hasPropertyName =
|
|
1205
|
+
isPropertyValue || isFunctionArg || isMethodCallArg;
|
|
1206
|
+
|
|
1207
|
+
if (!hasPropertyName) {
|
|
1208
|
+
// This is a bare arrow function - filter it out
|
|
1209
|
+
// Found arrow function start, need to find its end
|
|
1210
|
+
const afterArrow = i + arrowMatch[0].length;
|
|
1211
|
+
if (content[afterArrow] === '{') {
|
|
1212
|
+
// Multi-line arrow function - find matching closing brace
|
|
1213
|
+
// Must respect string literals when counting braces
|
|
1214
|
+
let braceCount = 1;
|
|
1215
|
+
let j = afterArrow + 1;
|
|
1216
|
+
while (j < content.length && braceCount > 0) {
|
|
1217
|
+
const strEnd = skipStringLiteral(content, j);
|
|
1218
|
+
if (strEnd !== -1) {
|
|
1219
|
+
j = strEnd;
|
|
1220
|
+
continue;
|
|
1221
|
+
}
|
|
1222
|
+
if (content[j] === '{') braceCount++;
|
|
1223
|
+
if (content[j] === '}') braceCount--;
|
|
1224
|
+
j++;
|
|
1225
|
+
}
|
|
1226
|
+
// Skip past the arrow function
|
|
1227
|
+
i = j;
|
|
1228
|
+
// Only skip trailing comma, keep newlines
|
|
1229
|
+
while (i < content.length && content[i] === ' ') {
|
|
1230
|
+
i++;
|
|
1231
|
+
}
|
|
1232
|
+
if (content[i] === ',') {
|
|
1233
|
+
i++; // Skip the comma after the arrow function
|
|
1234
|
+
}
|
|
1235
|
+
} else {
|
|
1236
|
+
// Single expression arrow function - skip to next comma or newline
|
|
1237
|
+
let j = afterArrow;
|
|
1238
|
+
while (
|
|
1239
|
+
j < content.length &&
|
|
1240
|
+
content[j] !== ',' &&
|
|
1241
|
+
content[j] !== '\n'
|
|
1242
|
+
) {
|
|
1243
|
+
j++;
|
|
1244
|
+
}
|
|
1245
|
+
i = j;
|
|
1246
|
+
if (content[i] === ',') i++; // Skip the comma
|
|
1247
|
+
}
|
|
1248
|
+
continue;
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
// Not a bare arrow function, keep this character
|
|
1252
|
+
result.push(content[i]);
|
|
1253
|
+
i++;
|
|
1254
|
+
}
|
|
1255
|
+
return result.join('');
|
|
1256
|
+
};
|
|
1257
|
+
|
|
1258
|
+
// Filter out bare object blocks (e.g., "{ ...spread, props }," without a property name)
|
|
1259
|
+
// These are invalid in object literal context - you need "key: { ... }" not just "{ ... }"
|
|
1260
|
+
// Defined here so it's accessible in both needsWrapper branches
|
|
1261
|
+
// The skipFirstBrace parameter allows the else branch to preserve the outer object
|
|
1262
|
+
const filterOutBareObjects = (
|
|
1263
|
+
content: string,
|
|
1264
|
+
skipFirstBrace = false,
|
|
1265
|
+
): string => {
|
|
1266
|
+
const result: string[] = [];
|
|
1267
|
+
let i = 0;
|
|
1268
|
+
let firstBraceSkipped = false;
|
|
1269
|
+
while (i < content.length) {
|
|
1270
|
+
// Skip over string literals entirely - braces inside strings should not be processed
|
|
1271
|
+
const stringEnd = skipStringLiteral(content, i);
|
|
1272
|
+
if (stringEnd !== -1) {
|
|
1273
|
+
result.push(content.slice(i, stringEnd));
|
|
1274
|
+
i = stringEnd;
|
|
1275
|
+
continue;
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
// Check if we're at a bare object start (newline/comma followed by { without : before it)
|
|
1279
|
+
// Look back to see if there's a colon (property assignment) before this brace
|
|
1280
|
+
const isStartOfLine =
|
|
1281
|
+
i === 0 ||
|
|
1282
|
+
content[i - 1] === '\n' ||
|
|
1283
|
+
content.slice(0, i).trim().endsWith(',');
|
|
1284
|
+
if (content[i] === '{' && isStartOfLine) {
|
|
1285
|
+
// Check if this is actually a bare object (not "key: {")
|
|
1286
|
+
const beforeTrimmed = content.slice(0, i).trim();
|
|
1287
|
+
const isBareObject =
|
|
1288
|
+
beforeTrimmed.endsWith(',') ||
|
|
1289
|
+
beforeTrimmed === '' ||
|
|
1290
|
+
beforeTrimmed.endsWith('(');
|
|
1291
|
+
|
|
1292
|
+
if (isBareObject) {
|
|
1293
|
+
// If skipFirstBrace is true and this is the first bare brace at position 0,
|
|
1294
|
+
// don't filter it - it's the intentional outer object wrapper
|
|
1295
|
+
if (skipFirstBrace && !firstBraceSkipped && i === 0) {
|
|
1296
|
+
firstBraceSkipped = true;
|
|
1297
|
+
result.push(content[i]);
|
|
1298
|
+
i++;
|
|
1299
|
+
continue;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
// Find matching closing brace, respecting string literals
|
|
1303
|
+
let braceCount = 1;
|
|
1304
|
+
let j = i + 1;
|
|
1305
|
+
while (j < content.length && braceCount > 0) {
|
|
1306
|
+
const strEnd = skipStringLiteral(content, j);
|
|
1307
|
+
if (strEnd !== -1) {
|
|
1308
|
+
j = strEnd;
|
|
1309
|
+
continue;
|
|
1310
|
+
}
|
|
1311
|
+
if (content[j] === '{') braceCount++;
|
|
1312
|
+
if (content[j] === '}') braceCount--;
|
|
1313
|
+
j++;
|
|
1314
|
+
}
|
|
1315
|
+
// Skip past the object
|
|
1316
|
+
i = j;
|
|
1317
|
+
// Skip trailing comma
|
|
1318
|
+
while (i < content.length && content[i] === ' ') {
|
|
1319
|
+
i++;
|
|
1320
|
+
}
|
|
1321
|
+
if (content[i] === ',') {
|
|
1322
|
+
i++;
|
|
1323
|
+
}
|
|
1324
|
+
continue;
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
result.push(content[i]);
|
|
1328
|
+
i++;
|
|
1329
|
+
}
|
|
1330
|
+
return result.join('');
|
|
1331
|
+
};
|
|
1332
|
+
|
|
1333
|
+
// Helper to clean up formatting issues after filtering
|
|
1334
|
+
const cleanupContent = (content: string): string => {
|
|
1335
|
+
return (
|
|
1336
|
+
content
|
|
1337
|
+
.replace(/,\s*,/g, ',') // Double commas
|
|
1338
|
+
.replace(/,(\s*\n\s*\})/g, '$1') // Trailing comma before closing brace
|
|
1339
|
+
.replace(/\{\s*\n\s*,/g, '{\n') // Leading comma after opening brace
|
|
1340
|
+
// Remove incomplete .map calls where callback was filtered out
|
|
1341
|
+
// Pattern: ".map" followed by newline/whitespace without "(" for args
|
|
1342
|
+
.replace(/\?\.map(?=\s*[\n\r,}\]])/g, '')
|
|
1343
|
+
.replace(/\.map(?=\s*[\n\r,}\]])/g, '')
|
|
1344
|
+
// Clean up orphan })) sequences (from nested filtered map callbacks)
|
|
1345
|
+
.replace(/\s*\}\)\)\s*\n\s*\}/g, '\n}')
|
|
1346
|
+
.replace(/^\s*\n/gm, '') // Empty lines
|
|
1347
|
+
.trim()
|
|
1348
|
+
);
|
|
1349
|
+
};
|
|
1350
|
+
|
|
680
1351
|
if (needsWrapper) {
|
|
681
|
-
|
|
1352
|
+
// Apply filters to remove invalid content
|
|
1353
|
+
mappedContents = filterOutArrowFunctions(mappedContents);
|
|
1354
|
+
mappedContents = filterOutBareObjects(mappedContents);
|
|
1355
|
+
mappedContents = cleanupContent(mappedContents);
|
|
1356
|
+
|
|
1357
|
+
// If mappedContents is empty after filtering, don't generate .map() at all
|
|
1358
|
+
// Just use the array path directly with spread or as-is
|
|
1359
|
+
// This prevents orphan )) from empty .map() callbacks
|
|
1360
|
+
const cleanedForEmptyCheck = mappedContents
|
|
1361
|
+
.replace(/\s+/g, '')
|
|
1362
|
+
.replace(/,+/g, '');
|
|
1363
|
+
if (cleanedForEmptyCheck.length === 0) {
|
|
1364
|
+
// Content is empty - just return the array directly
|
|
1365
|
+
returnValueContents = arrayBasePath;
|
|
1366
|
+
} else {
|
|
1367
|
+
// Check if mappedContents is just a bare expression (no property names)
|
|
1368
|
+
// A bare expression like "scenarios().data()?.["key"]?.[__idx__]," cannot be
|
|
1369
|
+
// wrapped in ({ }) because it's not a valid object property.
|
|
1370
|
+
// Pattern: content has no ":" that's not inside brackets/parens/strings
|
|
1371
|
+
const hasBareExpression = (() => {
|
|
1372
|
+
const trimmed = mappedContents.trim().replace(/,\s*$/, ''); // Remove trailing comma
|
|
1373
|
+
let depth = 0;
|
|
1374
|
+
let inString = false;
|
|
1375
|
+
let stringChar = '';
|
|
1376
|
+
for (let i = 0; i < trimmed.length; i++) {
|
|
1377
|
+
const char = trimmed[i];
|
|
1378
|
+
if (inString) {
|
|
1379
|
+
if (char === '\\') {
|
|
1380
|
+
i++; // Skip escaped char
|
|
1381
|
+
continue;
|
|
1382
|
+
}
|
|
1383
|
+
if (char === stringChar) {
|
|
1384
|
+
inString = false;
|
|
1385
|
+
}
|
|
1386
|
+
continue;
|
|
1387
|
+
}
|
|
1388
|
+
if (char === '"' || char === "'" || char === '`') {
|
|
1389
|
+
inString = true;
|
|
1390
|
+
stringChar = char;
|
|
1391
|
+
continue;
|
|
1392
|
+
}
|
|
1393
|
+
if (char === '(' || char === '[' || char === '{') {
|
|
1394
|
+
depth++;
|
|
1395
|
+
continue;
|
|
1396
|
+
}
|
|
1397
|
+
if (char === ')' || char === ']' || char === '}') {
|
|
1398
|
+
depth--;
|
|
1399
|
+
continue;
|
|
1400
|
+
}
|
|
1401
|
+
// Found a colon at depth 0 = has property name
|
|
1402
|
+
if (char === ':' && depth === 0) {
|
|
1403
|
+
return false;
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
return true;
|
|
1407
|
+
})();
|
|
1408
|
+
|
|
1409
|
+
if (hasBareExpression) {
|
|
1410
|
+
// Content is just an expression - return it directly without object wrapper
|
|
1411
|
+
const trimmedContent = mappedContents
|
|
1412
|
+
.trim()
|
|
1413
|
+
.replace(/,\s*$/, '');
|
|
1414
|
+
returnValueContents = `${arrayBasePath}?.map((__item__, __idx__) => (\n${indent(trimmedContent)}\n))`;
|
|
1415
|
+
} else {
|
|
1416
|
+
// When generating object-wrapped .map(), ensure original item data is preserved.
|
|
1417
|
+
// If no data spread was included (e.g., because this is a plain array property,
|
|
1418
|
+
// not a function return), add ...__item__ to spread the original item properties.
|
|
1419
|
+
// Without this, the .map() would create new objects with only nested function
|
|
1420
|
+
// properties, losing data like filePath, frontmatter, body, etc.
|
|
1421
|
+
const hasDataSpread =
|
|
1422
|
+
mappedContents.includes('...scenarios()') ||
|
|
1423
|
+
mappedContents.includes('...__item__');
|
|
1424
|
+
if (!hasDataSpread) {
|
|
1425
|
+
mappedContents = `...__item__,\n${mappedContents}`;
|
|
1426
|
+
}
|
|
1427
|
+
returnValueContents = `${arrayBasePath}?.map((__item__, __idx__) => ({\n${indent(mappedContents)}\n}))`;
|
|
1428
|
+
}
|
|
1429
|
+
} // Close the empty content check else block
|
|
682
1430
|
} else {
|
|
1431
|
+
// Content already starts with '{'. Check if there are additional properties after the inner object.
|
|
1432
|
+
// If so, we need to merge them INTO the object, not leave them outside.
|
|
1433
|
+
// Pattern: "{ ...spread, props },\nfilter: ...,\nsort: ..."
|
|
1434
|
+
// Should become: "{ ...spread, props, filter: ..., sort: ... }"
|
|
1435
|
+
const trimmed = mappedContents.trim();
|
|
1436
|
+
|
|
1437
|
+
// Find first }, at depth 0 that is NOT inside a string literal
|
|
1438
|
+
// This prevents splitting keys like ?.["useQuery({ id }, { enabled })"]
|
|
1439
|
+
// and also prevents finding }, inside nested arrow functions
|
|
1440
|
+
const findBraceCommaOutsideStrings = (
|
|
1441
|
+
content: string,
|
|
1442
|
+
): number => {
|
|
1443
|
+
let i = 0;
|
|
1444
|
+
let depth = 0; // Track brace depth to find the outer object's },
|
|
1445
|
+
while (i < content.length - 1) {
|
|
1446
|
+
// Skip over string literals
|
|
1447
|
+
const strEnd = skipStringLiteral(content, i);
|
|
1448
|
+
if (strEnd !== -1) {
|
|
1449
|
+
i = strEnd;
|
|
1450
|
+
continue;
|
|
1451
|
+
}
|
|
1452
|
+
// Track brace depth
|
|
1453
|
+
if (content[i] === '{') {
|
|
1454
|
+
depth++;
|
|
1455
|
+
i++;
|
|
1456
|
+
continue;
|
|
1457
|
+
}
|
|
1458
|
+
// Check for }, pattern at depth 1 (the outer object level)
|
|
1459
|
+
// We're looking for the outer object's closing brace, which is at depth 1
|
|
1460
|
+
// (we started at depth 0, opened { at depth 0 -> 1)
|
|
1461
|
+
if (content[i] === '}') {
|
|
1462
|
+
depth--;
|
|
1463
|
+
if (
|
|
1464
|
+
depth === 0 &&
|
|
1465
|
+
i + 1 < content.length &&
|
|
1466
|
+
content[i + 1] === ','
|
|
1467
|
+
) {
|
|
1468
|
+
return i;
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
i++;
|
|
1472
|
+
}
|
|
1473
|
+
return -1;
|
|
1474
|
+
};
|
|
1475
|
+
|
|
1476
|
+
const firstBraceEnd = findBraceCommaOutsideStrings(trimmed);
|
|
1477
|
+
if (firstBraceEnd !== -1) {
|
|
1478
|
+
// Found pattern "{ ... }," followed by more content
|
|
1479
|
+
// Extract the inner object and the trailing properties
|
|
1480
|
+
const innerObject = trimmed.slice(0, firstBraceEnd);
|
|
1481
|
+
const trailingContent = trimmed.slice(firstBraceEnd + 2).trim();
|
|
1482
|
+
if (trailingContent) {
|
|
1483
|
+
// Merge trailing properties into the inner object
|
|
1484
|
+
mappedContents = `${innerObject},\n${trailingContent}\n}`;
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
// Even when content starts with {, we need to filter out invalid properties inside
|
|
1488
|
+
// (arrow functions and bare objects that were generated from the schema)
|
|
1489
|
+
// Pass skipFirstBrace=true because the content's outer { is the intentional wrapper
|
|
1490
|
+
mappedContents = filterOutArrowFunctions(mappedContents);
|
|
1491
|
+
mappedContents = filterOutBareObjects(mappedContents, true);
|
|
1492
|
+
mappedContents = cleanupContent(mappedContents);
|
|
1493
|
+
// Same as needsWrapper branch: ensure item data is preserved in .map()
|
|
1494
|
+
const hasDataSpreadInner =
|
|
1495
|
+
mappedContents.includes('...scenarios()') ||
|
|
1496
|
+
mappedContents.includes('...__item__');
|
|
1497
|
+
if (!hasDataSpreadInner && mappedContents.trim().length > 0) {
|
|
1498
|
+
// Insert ...__item__ after the opening brace
|
|
1499
|
+
mappedContents = mappedContents.replace(
|
|
1500
|
+
/^\s*\{/,
|
|
1501
|
+
'{\n...__item__,',
|
|
1502
|
+
);
|
|
1503
|
+
}
|
|
683
1504
|
returnValueContents = `${arrayBasePath}?.map((__item__, __idx__) => (\n${indent(mappedContents)}\n))`;
|
|
684
1505
|
}
|
|
685
1506
|
} else {
|
|
686
1507
|
returnValueContents = `[\n${indent(levelContents)}\n]`;
|
|
687
1508
|
}
|
|
688
1509
|
} else {
|
|
689
|
-
|
|
1510
|
+
// When we have a single data path and nested content that creates an object structure,
|
|
1511
|
+
// and we're NOT at the root level, we need to handle the case where the parent data
|
|
1512
|
+
// value is null or undefined. Without this check, `{ ...null, prop: null?.["prop"] }`
|
|
1513
|
+
// creates `{ prop: undefined }` instead of `null`, causing errors like
|
|
1514
|
+
// "Cannot read properties of undefined (reading 'some')" when code does
|
|
1515
|
+
// data?.prop.some(...) because data is an object with prop: undefined, not null.
|
|
1516
|
+
// We only apply this to non-root cases because root-level mocks are expected to exist.
|
|
1517
|
+
// We also skip structural elements (like [0] inside arrays) because the null check
|
|
1518
|
+
// syntax doesn't work inside .map() callbacks where structural elements are used.
|
|
1519
|
+
// We also skip array index elements ([0], [1], etc.) because they represent tuple/array
|
|
1520
|
+
// elements, not properties that could be null.
|
|
1521
|
+
// We also only apply this when we're inside a function return value context - i.e.,
|
|
1522
|
+
// when the data path contains a function call pattern like ?.["someFunction(...)"].
|
|
1523
|
+
// This prevents adding null checks to intermediate objects in chains like supabase.auth.
|
|
1524
|
+
const hasNestedContent = nestedContent.filter(Boolean).length > 0;
|
|
1525
|
+
const isArrayIndexElement = name.match(/^\[\d*\]$/);
|
|
1526
|
+
// Check if data path contains a function call pattern, indicating we're inside a function return value
|
|
1527
|
+
const isInsideFunctionReturnValue =
|
|
1528
|
+
dataPaths.length === 1 &&
|
|
1529
|
+
dataPaths[0].match(/\?\.\["\w+\([^"]*\)"\]/);
|
|
1530
|
+
if (
|
|
1531
|
+
!root &&
|
|
1532
|
+
!returnValue.isStructural &&
|
|
1533
|
+
!isArrayIndexElement &&
|
|
1534
|
+
isInsideFunctionReturnValue &&
|
|
1535
|
+
hasNestedContent
|
|
1536
|
+
) {
|
|
1537
|
+
// Wrap with null check: if parent is null/undefined, return it directly; otherwise create object
|
|
1538
|
+
returnValueContents = `${dataPaths[0]} == null ? ${dataPaths[0]} : {\n${indent(levelContents)}\n}`;
|
|
1539
|
+
} else {
|
|
1540
|
+
returnValueContents = `{\n${indent(levelContents)}\n}`;
|
|
1541
|
+
}
|
|
690
1542
|
}
|
|
691
1543
|
}
|
|
692
1544
|
|
|
@@ -698,6 +1550,13 @@ export default function constructMockCode(
|
|
|
698
1550
|
if (args && args.length > 0) {
|
|
699
1551
|
if (!isValidKey(name)) return;
|
|
700
1552
|
|
|
1553
|
+
// Skip array index patterns like [], [0], [1] when they have args
|
|
1554
|
+
// These represent function calls on array elements, not property keys
|
|
1555
|
+
// e.g., customSizes[].(args) means each array element is callable, not a property named "[]"
|
|
1556
|
+
if (name.match(/^\[\d*\]$/)) {
|
|
1557
|
+
return;
|
|
1558
|
+
}
|
|
1559
|
+
|
|
701
1560
|
const mostArgs = args.sort(
|
|
702
1561
|
(a: string[], b: string[]) => b.length - a.length,
|
|
703
1562
|
)[0];
|
|
@@ -757,8 +1616,18 @@ export default function constructMockCode(
|
|
|
757
1616
|
// Use all paths for fallback (existing behavior)
|
|
758
1617
|
fallbackContent = `return ${returnValueContents}`;
|
|
759
1618
|
} else {
|
|
760
|
-
//
|
|
761
|
-
|
|
1619
|
+
// No explicit fallback paths - return the first literal's value as default
|
|
1620
|
+
// Returning spread of all values is dangerous because if values are primitives (strings),
|
|
1621
|
+
// spreading them creates objects with numeric keys like {0:'a', 1:'b', ...}
|
|
1622
|
+
// which causes "Objects are not valid as React child" errors
|
|
1623
|
+
const firstLiteralValue = literalKeys[0];
|
|
1624
|
+
const firstGroupPaths = argGroups.get(firstLiteralValue);
|
|
1625
|
+
if (firstGroupPaths && firstGroupPaths.length === 1) {
|
|
1626
|
+
fallbackContent = `return ${firstGroupPaths[0]}`;
|
|
1627
|
+
} else {
|
|
1628
|
+
// Multiple paths for first literal - return undefined as safe fallback
|
|
1629
|
+
fallbackContent = `return undefined`;
|
|
1630
|
+
}
|
|
762
1631
|
}
|
|
763
1632
|
|
|
764
1633
|
const funcContents =
|
|
@@ -768,14 +1637,29 @@ export default function constructMockCode(
|
|
|
768
1637
|
content = `${cleanOutTypes(name)}: ${isAsyncFunction ? 'async ' : ''}(${argsString}) => {\n${indent(funcContents)}\n}`;
|
|
769
1638
|
} else {
|
|
770
1639
|
// No argument variants - use existing behavior
|
|
771
|
-
|
|
1640
|
+
// But if there's nested content, we need to include it in the return object
|
|
1641
|
+
// (similar to how argument variant branches handle this at line 1070-1072)
|
|
1642
|
+
const hasNestedContent = validNestedContent.length > 0;
|
|
1643
|
+
let funcReturnContents: string;
|
|
1644
|
+
if (hasNestedContent && levelContentItems.length > 1) {
|
|
1645
|
+
// Include both spread and nested content in the return
|
|
1646
|
+
funcReturnContents = `{\n${indent(levelContents)}\n}`;
|
|
1647
|
+
} else {
|
|
1648
|
+
funcReturnContents = returnValueContents;
|
|
1649
|
+
}
|
|
1650
|
+
const funcContents = `return ${funcReturnContents}`;
|
|
772
1651
|
content = `${cleanOutTypes(name)}: ${isAsyncFunction ? 'async ' : ''}(${argsString}) => {\n${indent(funcContents)}\n}`;
|
|
773
1652
|
}
|
|
774
1653
|
} else {
|
|
775
1654
|
if (!isValidKey(name)) {
|
|
776
1655
|
return;
|
|
777
1656
|
} else if (name.match(/\[\d*\]/)) {
|
|
1657
|
+
// Numeric array index like [0], [1] - can be used as computed property
|
|
778
1658
|
content = returnValueContents;
|
|
1659
|
+
} else if (name.match(/^\[[a-zA-Z_]\w*\]$/)) {
|
|
1660
|
+
// Variable-based index like [currentItemIndex] - must be quoted string key
|
|
1661
|
+
// Otherwise JavaScript would try to evaluate the variable name
|
|
1662
|
+
content = `"${safeString(name)}": ${returnValueContents}`;
|
|
779
1663
|
} else {
|
|
780
1664
|
content = `${safeString(name)}: ${returnValueContents}`;
|
|
781
1665
|
}
|
|
@@ -790,34 +1674,91 @@ export default function constructMockCode(
|
|
|
790
1674
|
};
|
|
791
1675
|
|
|
792
1676
|
// Create the return value structure
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
1677
|
+
// OPTIMIZATION: Filter keys to only those starting with baseMockName before sorting.
|
|
1678
|
+
// This dramatically reduces processing time for large schemas (e.g., 9216 keys -> ~100 relevant keys).
|
|
1679
|
+
// Without this filter, the loop would call splitOutsideParenthesesAndArrays on every key
|
|
1680
|
+
// even though most are filtered out later by the baseMockName check.
|
|
1681
|
+
const allSchemaKeys = Object.keys(relevantReturnValueSchema ?? {});
|
|
1682
|
+
const relevantKeys = allSchemaKeys.filter((key) => {
|
|
1683
|
+
// Fast prefix check - key must start with baseMockName followed by ( or < or .
|
|
1684
|
+
// This matches: "useAtom()", "useAtom<T>()", "useAtom.something", but not "useAtomValue()"
|
|
1685
|
+
if (key === baseMockName) return true;
|
|
1686
|
+
if (key.startsWith(baseMockName + '(')) return true;
|
|
1687
|
+
if (key.startsWith(baseMockName + '<')) return true;
|
|
1688
|
+
if (key.startsWith(baseMockName + '.')) return true;
|
|
1689
|
+
// Also include 'returnValue' paths which are normalized later
|
|
1690
|
+
if (
|
|
1691
|
+
key === 'returnValue' ||
|
|
1692
|
+
key.startsWith('returnValue.') ||
|
|
1693
|
+
key.startsWith('returnValue[')
|
|
1694
|
+
)
|
|
1695
|
+
return true;
|
|
1696
|
+
return false;
|
|
1697
|
+
});
|
|
1698
|
+
|
|
1699
|
+
const schemaKeyCount = relevantKeys.length;
|
|
1700
|
+
const sortedKeys = relevantKeys.sort((a: string, b: string) => {
|
|
1701
|
+
const aParts = splitOutsideParenthesesAndArrays(a);
|
|
1702
|
+
const bParts = splitOutsideParenthesesAndArrays(b);
|
|
1703
|
+
|
|
1704
|
+
const maxLength = Math.max(aParts.length, bParts.length);
|
|
1705
|
+
for (let i = 0; i < maxLength; ++i) {
|
|
1706
|
+
const aPart = aParts[i];
|
|
1707
|
+
const bPart = bParts[i];
|
|
1708
|
+
|
|
1709
|
+
if (!aPart) return -1;
|
|
1710
|
+
if (!bPart) return 1;
|
|
1711
|
+
|
|
1712
|
+
if (aPart === bPart) continue;
|
|
1713
|
+
|
|
1714
|
+
const aName = aPart.split('(')[0];
|
|
1715
|
+
const bName = bPart.split('(')[0];
|
|
1716
|
+
|
|
1717
|
+
if (aName !== bName) {
|
|
1718
|
+
return aName.localeCompare(bName);
|
|
1719
|
+
} else {
|
|
1720
|
+
return aPart.localeCompare(bPart);
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
810
1723
|
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
1724
|
+
return 0;
|
|
1725
|
+
});
|
|
1726
|
+
|
|
1727
|
+
// OPTIMIZATION: Pre-compute prefix indexes for O(1) lookups instead of O(n) scans.
|
|
1728
|
+
// This reduces complexity from O(n²) to O(n) for large schemas (9k+ keys).
|
|
1729
|
+
//
|
|
1730
|
+
// 1. extendedReturnValuePrefixes: Set of all path prefixes that have a .functionCallReturnValue extension
|
|
1731
|
+
// Used by hasExtendedFunctionCallReturnValue check at line ~1754
|
|
1732
|
+
// 2. functionCallsWithReturnValue: Set of function call paths where .functionCallReturnValue IMMEDIATELY follows
|
|
1733
|
+
// Used by hasProperFunctionCallPath check at line ~1787
|
|
1734
|
+
// IMPORTANT: Only includes paths where the function call is directly followed by .functionCallReturnValue
|
|
1735
|
+
// e.g., "a.b().functionCallReturnValue" -> adds "a.b()" but NOT "a" even if "a" ends with ")"
|
|
1736
|
+
const extendedReturnValuePrefixes = new Set<string>();
|
|
1737
|
+
const functionCallsWithReturnValue = new Set<string>();
|
|
1738
|
+
|
|
1739
|
+
for (const k of relevantKeys) {
|
|
1740
|
+
const parts = splitOutsideParenthesesAndArrays(k);
|
|
1741
|
+
const returnValueIndex = parts.findIndex((part) =>
|
|
1742
|
+
part.startsWith(RETURN_VALUE),
|
|
1743
|
+
);
|
|
1744
|
+
if (returnValueIndex !== -1) {
|
|
1745
|
+
// Add all prefixes of k up to (but not including) functionCallReturnValue
|
|
1746
|
+
const prefix = joinParenthesesAndArrays(parts.slice(0, returnValueIndex));
|
|
1747
|
+
extendedReturnValuePrefixes.add(prefix);
|
|
1748
|
+
|
|
1749
|
+
// ONLY add to functionCallsWithReturnValue if functionCallReturnValue IMMEDIATELY follows
|
|
1750
|
+
if (prefix.endsWith(')')) {
|
|
1751
|
+
functionCallsWithReturnValue.add(prefix);
|
|
816
1752
|
}
|
|
817
1753
|
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
1754
|
+
// Also add intermediate prefixes for nested paths to extendedReturnValuePrefixes
|
|
1755
|
+
// This helps hasExtendedFunctionCallReturnValue which checks key + '.'
|
|
1756
|
+
for (let i = 1; i < returnValueIndex; i++) {
|
|
1757
|
+
const partialPrefix = joinParenthesesAndArrays(parts.slice(0, i));
|
|
1758
|
+
extendedReturnValuePrefixes.add(partialPrefix);
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
821
1762
|
|
|
822
1763
|
for (const key of sortedKeys) {
|
|
823
1764
|
const value = relevantReturnValueSchema[key];
|
|
@@ -852,7 +1793,9 @@ export default function constructMockCode(
|
|
|
852
1793
|
}
|
|
853
1794
|
}
|
|
854
1795
|
|
|
855
|
-
|
|
1796
|
+
// Compare against baseMockName (without generics/args), not the full mockName
|
|
1797
|
+
// e.g., for "useFetcher<User>()", baseMockName is "useFetcher"
|
|
1798
|
+
if (parts[0].split('(')[0] !== baseMockName) continue;
|
|
856
1799
|
|
|
857
1800
|
// Include paths with functionCallReturnValue OR function-typed paths that need mocking
|
|
858
1801
|
const hasFunctionCallReturnValue = parts.some((p) =>
|
|
@@ -873,9 +1816,10 @@ export default function constructMockCode(
|
|
|
873
1816
|
// nested inside (e.g., methods on array elements passed as arguments).
|
|
874
1817
|
if (hasSignaturePath) continue;
|
|
875
1818
|
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
1819
|
+
// OPTIMIZATION: Use pre-computed index instead of O(n) scan
|
|
1820
|
+
// Old code: Object.keys(relevantReturnValueSchema).some((k) => k.startsWith(key + '.') && k.includes('.functionCallReturnValue'))
|
|
1821
|
+
const hasExtendedFunctionCallReturnValue =
|
|
1822
|
+
extendedReturnValuePrefixes.has(key);
|
|
879
1823
|
|
|
880
1824
|
// Skip JSX components - they look like function calls (e.g., Context.Provider())
|
|
881
1825
|
// but they're React components used in JSX, not functions that need mocking
|
|
@@ -886,6 +1830,38 @@ export default function constructMockCode(
|
|
|
886
1830
|
'jsx-component';
|
|
887
1831
|
if (isJsxComponent) continue;
|
|
888
1832
|
|
|
1833
|
+
// Skip paths that bypass .functionCallReturnValue when there's a corresponding path with it.
|
|
1834
|
+
// Example: If we have both:
|
|
1835
|
+
// - trpc.customer.useQuery(...).data (incorrect - no .functionCallReturnValue)
|
|
1836
|
+
// - trpc.customer.useQuery(...).functionCallReturnValue.data (correct)
|
|
1837
|
+
// We should skip the first path because the second one properly captures the return value.
|
|
1838
|
+
// This can happen when the analyzer sees both the raw property access and the return value structure.
|
|
1839
|
+
if (!hasFunctionCallReturnValue) {
|
|
1840
|
+
// This path has no .functionCallReturnValue. Check if any function call in this path
|
|
1841
|
+
// has a corresponding .functionCallReturnValue path in the schema.
|
|
1842
|
+
let shouldSkipKey = false;
|
|
1843
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
1844
|
+
const part = parts[i];
|
|
1845
|
+
if (part.endsWith(')') && !isFunctionCallReturnValue(parts[i + 1])) {
|
|
1846
|
+
// This part is a function call, and the next part is NOT .functionCallReturnValue
|
|
1847
|
+
// Check if there's any path with .functionCallReturnValue for this function call
|
|
1848
|
+
const functionCallPath = joinParenthesesAndArrays(
|
|
1849
|
+
parts.slice(0, i + 1),
|
|
1850
|
+
);
|
|
1851
|
+
// OPTIMIZATION: Use pre-computed index instead of O(n) scan
|
|
1852
|
+
// Old code: Object.keys(relevantReturnValueSchema).some((k) => k.startsWith(functionCallPath + '.functionCallReturnValue'))
|
|
1853
|
+
const hasProperFunctionCallPath =
|
|
1854
|
+
functionCallsWithReturnValue.has(functionCallPath);
|
|
1855
|
+
if (hasProperFunctionCallPath) {
|
|
1856
|
+
// Skip this path - the .functionCallReturnValue path will handle it correctly
|
|
1857
|
+
shouldSkipKey = true;
|
|
1858
|
+
break;
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
if (shouldSkipKey) continue;
|
|
1863
|
+
}
|
|
1864
|
+
|
|
889
1865
|
const isFunctionPath =
|
|
890
1866
|
['function', 'async-function'].includes(value) &&
|
|
891
1867
|
parts[parts.length - 1].endsWith(')') &&
|
|
@@ -934,6 +1910,17 @@ export default function constructMockCode(
|
|
|
934
1910
|
const nextIsArray = !!nextPart?.match(/^\[\d*\]/);
|
|
935
1911
|
const isDifferentiatedArray = !!part?.match(/^\[\d+\]/);
|
|
936
1912
|
const nextIsDifferentiatedArray = !!nextPart?.match(/^\[\d+\]/);
|
|
1913
|
+
|
|
1914
|
+
// Variable index patterns like [currentItemIndex] or [targetIndex] indicate array access
|
|
1915
|
+
// but don't represent actual data structure - they're markers from variable-based index tracking.
|
|
1916
|
+
// Skip them AND all remaining parts to avoid creating spurious nested structure that breaks array iteration.
|
|
1917
|
+
// The remaining parts (e.g., .missing_attributes) describe properties of array elements, which are
|
|
1918
|
+
// already handled by the generic [] accessor path.
|
|
1919
|
+
const isVariableIndex = !!part?.match(/^\[[a-zA-Z_]\w*\]$/);
|
|
1920
|
+
if (isVariableIndex) {
|
|
1921
|
+
// Break out of the loop entirely - don't process any remaining parts
|
|
1922
|
+
break;
|
|
1923
|
+
}
|
|
937
1924
|
// Find the correct value for the current part being processed
|
|
938
1925
|
let partValue = value; // default to the final value
|
|
939
1926
|
if (isFunctionCallReturnValue(part) && nextIsArray) {
|
|
@@ -1041,7 +2028,52 @@ export default function constructMockCode(
|
|
|
1041
2028
|
}
|
|
1042
2029
|
}
|
|
1043
2030
|
} else {
|
|
1044
|
-
|
|
2031
|
+
// Before setting returnsFunctionArgs on the parent (for generic [] = function),
|
|
2032
|
+
// check if there are specific array indices (like [0], [1]) that are NOT functions.
|
|
2033
|
+
// If so, don't set returnsFunctionArgs because those specific indices take precedence.
|
|
2034
|
+
// This prevents adding ["()"] to paths like [0] when [0] is 'unknown' but [] is 'function'.
|
|
2035
|
+
//
|
|
2036
|
+
// Use parts.slice(0, i + 1) to get the current path INCLUDING functionCallReturnValue.
|
|
2037
|
+
// For example, if parts = ['useAtom()','functionCallReturnValue','[]']
|
|
2038
|
+
// and i = 1, we want to check 'useAtom().functionCallReturnValue[0]' etc.
|
|
2039
|
+
const arrayContainerPath = joinParenthesesAndArrays(
|
|
2040
|
+
parts.slice(0, i + 1),
|
|
2041
|
+
);
|
|
2042
|
+
|
|
2043
|
+
const hasNonFunctionSpecificIndices = Object.entries(
|
|
2044
|
+
relevantReturnValueSchema,
|
|
2045
|
+
).some(([k, v]) => {
|
|
2046
|
+
// Look for paths like "arrayContainerPath[0]", "arrayContainerPath[1]" etc.
|
|
2047
|
+
const indexMatch = k.match(
|
|
2048
|
+
new RegExp(
|
|
2049
|
+
`^${arrayContainerPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\[(\\d+)\\]$`,
|
|
2050
|
+
),
|
|
2051
|
+
);
|
|
2052
|
+
// If found and it's NOT a function type, we have a conflict
|
|
2053
|
+
return (
|
|
2054
|
+
indexMatch &&
|
|
2055
|
+
!['function', 'async-function'].includes(v as string)
|
|
2056
|
+
);
|
|
2057
|
+
});
|
|
2058
|
+
|
|
2059
|
+
// Also check if [] has nested object properties (like [].filter, [].name)
|
|
2060
|
+
// If so, [] items are objects with properties, not pure functions to be called
|
|
2061
|
+
// This handles cases where the schema shows [].filter = object but doesn't
|
|
2062
|
+
// have explicit [0] entries
|
|
2063
|
+
const genericArrayPath = `${arrayContainerPath}[]`;
|
|
2064
|
+
const hasNestedProperties = Object.keys(
|
|
2065
|
+
relevantReturnValueSchema,
|
|
2066
|
+
).some((k) => {
|
|
2067
|
+
// Check for paths like "arrayContainerPath[].propertyName" (not [].())
|
|
2068
|
+
return (
|
|
2069
|
+
k.startsWith(genericArrayPath + '.') &&
|
|
2070
|
+
!k.startsWith(genericArrayPath + '.(')
|
|
2071
|
+
);
|
|
2072
|
+
});
|
|
2073
|
+
|
|
2074
|
+
if (!hasNonFunctionSpecificIndices && !hasNestedProperties) {
|
|
2075
|
+
returnValueSection.returnsFunctionArgs = [];
|
|
2076
|
+
}
|
|
1045
2077
|
}
|
|
1046
2078
|
}
|
|
1047
2079
|
}
|
|
@@ -1066,7 +2098,8 @@ export default function constructMockCode(
|
|
|
1066
2098
|
}
|
|
1067
2099
|
// If the next part is an object with nested content, continue processing
|
|
1068
2100
|
// This handles paths like functionCallReturnValue.selectedOptions.elementOptions[]
|
|
1069
|
-
|
|
2101
|
+
// Also handles union types like 'array | undefined' or 'object | undefined'
|
|
2102
|
+
if (nextValue?.includes('object') || nextValue?.includes('array')) {
|
|
1070
2103
|
continue;
|
|
1071
2104
|
}
|
|
1072
2105
|
}
|
|
@@ -1195,17 +2228,22 @@ export default function constructMockCode(
|
|
|
1195
2228
|
) {
|
|
1196
2229
|
returnValueSection.nested.push(relevantPart);
|
|
1197
2230
|
}
|
|
1198
|
-
} else
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
const
|
|
1203
|
-
|
|
1204
|
-
|
|
2231
|
+
} else {
|
|
2232
|
+
// Add args to existing entry if current part has function arguments
|
|
2233
|
+
// This handles the case where bare `t` is processed first (creating {name: 't', args: undefined})
|
|
2234
|
+
// and then `t("common.close")` is processed - we need to add its args to the existing entry
|
|
2235
|
+
const currentArgs = funcArgs(part);
|
|
2236
|
+
const hasNewArgs = currentArgs.length > 0 || part.includes('(');
|
|
2237
|
+
|
|
2238
|
+
if (hasNewArgs) {
|
|
2239
|
+
const existingArgs = relevantPart.args?.find(
|
|
2240
|
+
(args) => args.join(',') === currentArgs.join(','),
|
|
2241
|
+
);
|
|
1205
2242
|
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
2243
|
+
if (!existingArgs) {
|
|
2244
|
+
relevantPart.args ||= [];
|
|
2245
|
+
relevantPart.args.push(currentArgs);
|
|
2246
|
+
}
|
|
1209
2247
|
}
|
|
1210
2248
|
}
|
|
1211
2249
|
|
|
@@ -1215,7 +2253,14 @@ export default function constructMockCode(
|
|
|
1215
2253
|
relevantPart.isGenericArray = true;
|
|
1216
2254
|
}
|
|
1217
2255
|
|
|
1218
|
-
if
|
|
2256
|
+
// Check if there are remaining parts after functionCallReturnValue that need processing
|
|
2257
|
+
// (e.g., data properties like useQuery().functionCallReturnValue.data)
|
|
2258
|
+
const hasRemainingPartsAfterReturnValue =
|
|
2259
|
+
nextPart &&
|
|
2260
|
+
(isFunctionCallReturnValue(nextPart) ||
|
|
2261
|
+
(isFunctionCallReturnValue(parts[i]) && i < parts.length - 1));
|
|
2262
|
+
|
|
2263
|
+
if (!hasNestedFunction && !hasRemainingPartsAfterReturnValue) {
|
|
1219
2264
|
// Before breaking, check if this function returns an array
|
|
1220
2265
|
// by looking for a functionCallReturnValue: 'array' entry in the schema
|
|
1221
2266
|
if (relevantPart && part.endsWith(')')) {
|
|
@@ -1243,10 +2288,28 @@ export default function constructMockCode(
|
|
|
1243
2288
|
}
|
|
1244
2289
|
}
|
|
1245
2290
|
|
|
2291
|
+
// Post-processing: When the root functionCallReturnValue is typed as "function" but the
|
|
2292
|
+
// return value also has nested properties (methods like .from(), .auth, etc.), it's actually
|
|
2293
|
+
// an object, not a function to be called. Clear returnsFunctionArgs to prevent double-wrapping
|
|
2294
|
+
// (adding an extra () => { return { ... } } wrapper and ["()"] data paths).
|
|
2295
|
+
// This handles cases like Supabase's createClient() which returns an object with methods.
|
|
2296
|
+
// Only applied to the root level - nested parts that are functions with methods (like
|
|
2297
|
+
// useSearchParams()[1] which is a setter function with .set() and .delete()) should keep
|
|
2298
|
+
// their returnsFunctionArgs since they genuinely ARE functions.
|
|
2299
|
+
if (
|
|
2300
|
+
returnValueParts.returnsFunctionArgs &&
|
|
2301
|
+
returnValueParts.returnsFunctionArgs.length === 0 &&
|
|
2302
|
+
returnValueParts.nested &&
|
|
2303
|
+
returnValueParts.nested.length > 0
|
|
2304
|
+
) {
|
|
2305
|
+
returnValueParts.returnsFunctionArgs = undefined;
|
|
2306
|
+
}
|
|
2307
|
+
|
|
1246
2308
|
const contents = constructReturnValueString(returnValueParts);
|
|
1247
2309
|
|
|
1248
2310
|
if (mockNameParts.length > 1) {
|
|
1249
2311
|
const originalLib = `${mockNameParts[0]}__cyOriginal`;
|
|
2312
|
+
const skipOriginalSpread = options?.skipOriginalSpread;
|
|
1250
2313
|
|
|
1251
2314
|
const subPart = (
|
|
1252
2315
|
parts: string[],
|
|
@@ -1258,7 +2321,9 @@ export default function constructMockCode(
|
|
|
1258
2321
|
|
|
1259
2322
|
const partContents = isLast
|
|
1260
2323
|
? contents
|
|
1261
|
-
:
|
|
2324
|
+
: skipOriginalSpread
|
|
2325
|
+
? subPart(parts, originalLib)
|
|
2326
|
+
: `...${originalLib}.${part},\n${subPart(parts, originalLib)}`;
|
|
1262
2327
|
|
|
1263
2328
|
let code = `${part}: {\n${indent(partContents)}\n}`;
|
|
1264
2329
|
|
|
@@ -1272,27 +2337,31 @@ export default function constructMockCode(
|
|
|
1272
2337
|
return code;
|
|
1273
2338
|
};
|
|
1274
2339
|
|
|
1275
|
-
const returnParts =
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
2340
|
+
const returnParts = skipOriginalSpread
|
|
2341
|
+
? [subPart(mockNameParts.slice(1), originalLib)]
|
|
2342
|
+
: [
|
|
2343
|
+
`...${mockNameParts[0]}__cyOriginal`,
|
|
2344
|
+
subPart(mockNameParts.slice(1), originalLib),
|
|
2345
|
+
];
|
|
1279
2346
|
|
|
1280
|
-
return `const ${mockNameParts[0]} = {\n${indent(returnParts.join(',\n'))}\n};`;
|
|
2347
|
+
return `const ${mockNameParts[0]} = {\n${indent(returnParts.filter(Boolean).join(',\n'))}\n};`;
|
|
1281
2348
|
} else if (isFunction) {
|
|
1282
2349
|
// For headers() and cookies() from next/headers, add common iterator methods
|
|
1283
2350
|
// These are needed when the mock is passed to functions that use .entries(), .keys(), etc.
|
|
1284
2351
|
// (e.g., Object.fromEntries(headers.entries()) in buildLegacyHeaders)
|
|
1285
2352
|
const needsIteratorMethods =
|
|
1286
|
-
|
|
2353
|
+
baseMockName === 'headers' || baseMockName === 'cookies';
|
|
1287
2354
|
let enhancedContents = contents;
|
|
1288
2355
|
if (needsIteratorMethods && contents.trim().startsWith('{')) {
|
|
1289
2356
|
// Add iterator methods that operate on the scenario data
|
|
2357
|
+
// Use the dataKey (original call signature or canonical key)
|
|
2358
|
+
const quotedDataKey = quotePropertyKey(dataKey);
|
|
1290
2359
|
const iteratorMethods = `,
|
|
1291
|
-
entries: () => Object.entries(scenarios().data()
|
|
1292
|
-
keys: () => Object.keys(scenarios().data()
|
|
1293
|
-
values: () => Object.values(scenarios().data()
|
|
1294
|
-
forEach: (fn) => Object.entries(scenarios().data()
|
|
1295
|
-
has: (key) => Object.prototype.hasOwnProperty.call(scenarios().data()
|
|
2360
|
+
entries: () => Object.entries(scenarios().data()?.${quotedDataKey} || {}),
|
|
2361
|
+
keys: () => Object.keys(scenarios().data()?.${quotedDataKey} || {}),
|
|
2362
|
+
values: () => Object.values(scenarios().data()?.${quotedDataKey} || {}),
|
|
2363
|
+
forEach: (fn) => Object.entries(scenarios().data()?.${quotedDataKey} || {}).forEach(([k, v]) => fn(v, k)),
|
|
2364
|
+
has: (key) => Object.prototype.hasOwnProperty.call(scenarios().data()?.${quotedDataKey} || {}, key)`;
|
|
1296
2365
|
// Insert before the closing brace (handle trailing whitespace)
|
|
1297
2366
|
enhancedContents = contents.replace(/\}\s*$/, iteratorMethods + '\n}');
|
|
1298
2367
|
}
|
|
@@ -1303,36 +2372,140 @@ export default function constructMockCode(
|
|
|
1303
2372
|
// `new ClassName("arg")` wouldn't create the expected instance.
|
|
1304
2373
|
// For Error subclasses (detected by name ending in "Error"), extend Error for proper error handling.
|
|
1305
2374
|
if (entityType === 'class') {
|
|
1306
|
-
const isErrorSubclass =
|
|
1307
|
-
const baseClass = isErrorSubclass ? 'Error' : 'Object';
|
|
2375
|
+
const isErrorSubclass = baseMockName.endsWith('Error');
|
|
1308
2376
|
const superCall = isErrorSubclass ? 'super(message);' : '';
|
|
1309
2377
|
const nameAssignment = isErrorSubclass
|
|
1310
|
-
? `this.name = '${
|
|
2378
|
+
? `this.name = '${baseMockName}';`
|
|
1311
2379
|
: '';
|
|
1312
|
-
|
|
1313
|
-
|
|
2380
|
+
// Use the base class name for the class definition, not the call-signature-derived name.
|
|
2381
|
+
// When mockName is "StatsCalculator(supabase)", baseMockName is "StatsCalculator"
|
|
2382
|
+
// and derivedFunctionName would be "StatsCalculator_supabase" which is wrong.
|
|
2383
|
+
// Classes are instantiated with `new ClassName(args)` so the name must match the original.
|
|
2384
|
+
const className = baseMockName;
|
|
2385
|
+
|
|
2386
|
+
// Use the already-generated contents (which has proper function wrappers for methods)
|
|
2387
|
+
// instead of raw scenarios().data() which would create non-callable string-keyed properties.
|
|
2388
|
+
// For classes with methods like calculateStats(), the contents will have:
|
|
2389
|
+
// { calculateStats: (...args) => scenarios().data()?.["key"]?.["calculateStats(...)"], ... }
|
|
2390
|
+
// which makes methods callable on the instance.
|
|
2391
|
+
const classContents = enhancedContents.trim().startsWith('{')
|
|
2392
|
+
? enhancedContents
|
|
2393
|
+
: `scenarios().data()?.${quotePropertyKey(dataKey)} || {}`;
|
|
2394
|
+
|
|
2395
|
+
return `class ${className}${isErrorSubclass ? ' extends Error' : ''} {
|
|
1314
2396
|
constructor(message) {
|
|
1315
2397
|
${superCall}
|
|
1316
2398
|
${nameAssignment}
|
|
1317
|
-
Object.assign(this,
|
|
2399
|
+
Object.assign(this, ${classContents});
|
|
1318
2400
|
}
|
|
1319
2401
|
}`;
|
|
1320
2402
|
}
|
|
1321
2403
|
|
|
1322
|
-
//
|
|
1323
|
-
//
|
|
1324
|
-
//
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
2404
|
+
// Generate safe function name:
|
|
2405
|
+
// 1. For call signatures: use derivedFunctionName
|
|
2406
|
+
// e.g., "useFetcher<User>()" becomes "useFetcher_User"
|
|
2407
|
+
// e.g., "db.select(usersQuery)" becomes "db_select_usersQuery"
|
|
2408
|
+
// 2. With uniqueFunctionSuffix option: append suffix for unique naming
|
|
2409
|
+
// e.g., baseMockName = "useFetcher", suffix = "entityDiffFetcher" -> "useFetcher_entityDiffFetcher"
|
|
2410
|
+
// 3. EXCEPTION: When keepOriginalFunctionName is true (for single-call cases), use the base name
|
|
2411
|
+
let safeFunctionName: string;
|
|
2412
|
+
if (options?.keepOriginalFunctionName) {
|
|
2413
|
+
safeFunctionName = baseMockName;
|
|
2414
|
+
} else if (options?.uniqueFunctionSuffix) {
|
|
2415
|
+
safeFunctionName = `${baseMockName}_${options.uniqueFunctionSuffix}`;
|
|
2416
|
+
} else if (mockNameIsCallSignature && derivedFunctionName) {
|
|
2417
|
+
safeFunctionName = derivedFunctionName;
|
|
2418
|
+
} else {
|
|
2419
|
+
safeFunctionName = baseMockName;
|
|
2420
|
+
}
|
|
1328
2421
|
|
|
1329
|
-
|
|
2422
|
+
// Check if this function returns a function (detected by double-call pattern: mockName(args)())
|
|
2423
|
+
// This happens when the schema has keys like "wrapThrows(() => JSON.parse(savedFilters))()"
|
|
2424
|
+
// where the function call is immediately followed by another call.
|
|
2425
|
+
// Example usage: const result = wrapThrows(() => JSON.parse(x))(); // double call
|
|
2426
|
+
const isHigherOrderFunction = Object.keys(
|
|
2427
|
+
relevantReturnValueSchema ?? {},
|
|
2428
|
+
).some((key) => {
|
|
2429
|
+
if (!key.startsWith(baseMockName)) return false;
|
|
2430
|
+
|
|
2431
|
+
// Find the first ( after baseMockName (the start of the function call)
|
|
2432
|
+
const firstOpenParen = key.indexOf('(', baseMockName.length);
|
|
2433
|
+
if (firstOpenParen === -1) return false;
|
|
2434
|
+
|
|
2435
|
+
// Skip if the ( is not immediately after the mock name
|
|
2436
|
+
// (there might be type params like func<T>() - handle by checking for < or ()
|
|
2437
|
+
const between = key.slice(baseMockName.length, firstOpenParen);
|
|
2438
|
+
if (between.length > 0 && !between.startsWith('<')) return false;
|
|
2439
|
+
|
|
2440
|
+
// Find the matching ) for the first ( using depth counting
|
|
2441
|
+
let depth = 1;
|
|
2442
|
+
let i = firstOpenParen + 1;
|
|
2443
|
+
while (i < key.length && depth > 0) {
|
|
2444
|
+
if (key[i] === '(') depth++;
|
|
2445
|
+
if (key[i] === ')') depth--;
|
|
2446
|
+
i++;
|
|
2447
|
+
}
|
|
2448
|
+
|
|
2449
|
+
if (depth !== 0) return false; // Unbalanced parentheses
|
|
2450
|
+
|
|
2451
|
+
// Now i points just after the matching )
|
|
2452
|
+
// Check if there's another ( immediately (indicating double call)
|
|
2453
|
+
const remaining = key.slice(i);
|
|
2454
|
+
if (remaining.startsWith('(')) return true;
|
|
2455
|
+
|
|
2456
|
+
return false;
|
|
2457
|
+
});
|
|
2458
|
+
|
|
2459
|
+
// Use ...args to accept any number of arguments - prevents TypeScript errors
|
|
2460
|
+
// like "Expected 0 arguments, but got X" when caller passes arguments
|
|
2461
|
+
// For higher-order functions, wrap the return in an arrow function
|
|
2462
|
+
// so that mockFunc(arg)() works correctly (outer call returns a function, inner call gets the data)
|
|
2463
|
+
const returnValue = isHigherOrderFunction
|
|
2464
|
+
? `() => (${enhancedContents})`
|
|
2465
|
+
: enhancedContents;
|
|
2466
|
+
|
|
2467
|
+
// Inline the return value directly in the function to avoid module-level const
|
|
2468
|
+
// that would be evaluated before scenario context is ready
|
|
2469
|
+
// Add fallback for simple data path returns to prevent undefined errors (e.g., createTheme)
|
|
2470
|
+
// Only add fallback if returnValue is a simple data accessor (starts with scenarios().data())
|
|
2471
|
+
// and doesn't already have nested structure (object literal, array, or method chains like .map())
|
|
2472
|
+
const isSimpleDataPath =
|
|
2473
|
+
returnValue.startsWith('scenarios().data()') &&
|
|
2474
|
+
!returnValue.trim().startsWith('{') &&
|
|
2475
|
+
!returnValue.trim().startsWith('[') &&
|
|
2476
|
+
!returnValue.includes('.map('); // Exclude method chains
|
|
2477
|
+
const safeReturnValue = isSimpleDataPath
|
|
2478
|
+
? `${returnValue} ?? {}`
|
|
2479
|
+
: returnValue;
|
|
2480
|
+
const refName = `_${safeFunctionName}Ref`;
|
|
2481
|
+
const assignment = `${refName}.current = ${safeReturnValue};`;
|
|
2482
|
+
const ifBlock = `if (!${refName}.current) {\n${indent(assignment)}\n}`;
|
|
2483
|
+
const body = `${ifBlock}\nreturn ${refName}.current;`;
|
|
2484
|
+
|
|
2485
|
+
return [
|
|
2486
|
+
`// PATCHED: memoize to return stable reference (prevents infinite useEffect re-triggers)`,
|
|
2487
|
+
`const ${refName} = {`,
|
|
2488
|
+
` current: null,`,
|
|
2489
|
+
`};`,
|
|
2490
|
+
`${isRootAsyncFunction ? 'async ' : ''}function ${safeFunctionName}(...args) {`,
|
|
2491
|
+
indent(body),
|
|
2492
|
+
`}`,
|
|
2493
|
+
].join('\n');
|
|
1330
2494
|
} else {
|
|
1331
|
-
//
|
|
1332
|
-
//
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
2495
|
+
// Generate safe const name:
|
|
2496
|
+
// 1. For call signatures: use derivedFunctionName
|
|
2497
|
+
// 2. With uniqueFunctionSuffix option: append suffix for unique naming
|
|
2498
|
+
// 3. EXCEPTION: When keepOriginalFunctionName is true (for single-call cases), use the base name
|
|
2499
|
+
let safeName: string;
|
|
2500
|
+
if (options?.keepOriginalFunctionName) {
|
|
2501
|
+
safeName = baseMockName;
|
|
2502
|
+
} else if (options?.uniqueFunctionSuffix) {
|
|
2503
|
+
safeName = `${baseMockName}_${options.uniqueFunctionSuffix}`;
|
|
2504
|
+
} else if (mockNameIsCallSignature && derivedFunctionName) {
|
|
2505
|
+
safeName = derivedFunctionName;
|
|
2506
|
+
} else {
|
|
2507
|
+
safeName = baseMockName;
|
|
2508
|
+
}
|
|
1336
2509
|
|
|
1337
2510
|
// Get any jsx-component properties that need to be preserved from the original
|
|
1338
2511
|
const jsxProperties = getJsxComponentProperties(
|