@codeyam/codeyam-cli 0.1.0-staging.b8a55ba → 0.1.0-staging.c1c8678
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 +15 -12
- package/analyzer-template/packages/ai/index.ts +21 -5
- package/analyzer-template/packages/ai/package.json +3 -3
- package/analyzer-template/packages/ai/src/lib/__mocks__/completionCall.ts +122 -0
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +226 -24
- package/analyzer-template/packages/ai/src/lib/astScopes/arrayDerivationDetector.ts +199 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +183 -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 +15 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.ts +181 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +1229 -30
- package/analyzer-template/packages/ai/src/lib/astScopes/sharedPatterns.ts +28 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +265 -6
- package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +29 -10
- package/analyzer-template/packages/ai/src/lib/completionCall.ts +216 -36
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +1867 -334
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +7 -2
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +296 -35
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +120 -76
- 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 +54 -3
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +140 -20
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.ts +70 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +140 -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 +393 -90
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.ts +129 -0
- package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +174 -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 +86 -142
- package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +59 -3
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +1421 -88
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +200 -196
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +614 -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/guessScenarioDataFromDescription.ts +5 -5
- 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 +10 -7
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.ts +1 -1
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +32 -142
- 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 -89
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.ts +58 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.ts +11 -11
- 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 +122 -3
- package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +114 -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/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 +466 -270
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +34 -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 +14 -12
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/TransformationTracer.ts +1315 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +201 -46
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.ts +102 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +593 -84
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.ts +28 -62
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +377 -84
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +264 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +35 -129
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +2 -3
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +970 -140
- 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/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 +3 -3
- 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/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 +14 -1
- package/analyzer-template/packages/database/src/lib/kysely/tables/commitsTable.ts +6 -0
- package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +17 -1
- 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 +7 -3
- 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/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 +2 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +11 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts +1 -18
- 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 +17 -1
- 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.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 +7 -4
- 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/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 +3 -4
- package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.js +0 -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 +71 -27
- 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 +9 -54
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.js +1 -21
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +153 -5
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/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/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 +3 -6
- package/analyzer-template/packages/types/src/types/Analysis.ts +87 -27
- 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 +9 -77
- package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +181 -5
- 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/utils/dist/types/index.d.ts +3 -4
- package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/index.js +0 -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 +71 -27
- 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 +9 -54
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.js +1 -21
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.js.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +153 -5
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
- package/analyzer-template/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/fs/rsyncCopy.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js +93 -2
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.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/fs/rsyncCopy.ts +108 -2
- 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/waitForServer.ts +21 -6
- 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 +1201 -178
- 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 +65 -41
- 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 +3 -6
- package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +18 -7
- package/analyzer-template/project/orchestrateCapture/taskRunner.ts +4 -2
- package/analyzer-template/project/orchestrateCapture.ts +81 -9
- package/analyzer-template/project/reconcileMockDataKeys.ts +220 -78
- package/analyzer-template/project/runAnalysis.ts +11 -0
- package/analyzer-template/project/serverOnlyModules.ts +127 -2
- package/analyzer-template/project/start.ts +51 -15
- package/analyzer-template/project/startScenarioCapture.ts +6 -0
- package/analyzer-template/project/writeMockDataTsx.ts +345 -32
- package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
- package/analyzer-template/project/writeScenarioComponents.ts +358 -118
- package/analyzer-template/project/writeScenarioFiles.ts +26 -0
- package/analyzer-template/project/writeSimpleRoot.ts +28 -42
- 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 +1062 -134
- 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 +19 -8
- 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 +3 -2
- package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +7 -5
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture.js +65 -10
- package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +188 -47
- 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/serverOnlyModules.js +106 -3
- package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -1
- package/background/src/lib/virtualized/project/start.js +47 -15
- package/background/src/lib/virtualized/project/start.js.map +1 -1
- package/background/src/lib/virtualized/project/startScenarioCapture.js +7 -0
- package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/writeMockDataTsx.js +301 -27
- 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 +278 -100
- 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 +28 -41
- package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
- package/codeyam-cli/scripts/apply-setup.js +180 -0
- package/codeyam-cli/scripts/apply-setup.js.map +1 -1
- package/codeyam-cli/src/cli.js +9 -1
- 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 +37 -23
- 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/detect-universal-mocks.js +2 -0
- package/codeyam-cli/src/commands/detect-universal-mocks.js.map +1 -1
- package/codeyam-cli/src/commands/init.js +49 -257
- package/codeyam-cli/src/commands/init.js.map +1 -1
- package/codeyam-cli/src/commands/memory.js +264 -0
- package/codeyam-cli/src/commands/memory.js.map +1 -0
- package/codeyam-cli/src/commands/recapture.js +31 -18
- package/codeyam-cli/src/commands/recapture.js.map +1 -1
- package/codeyam-cli/src/commands/report.js +46 -1
- 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__/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 +112 -21
- 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 +4 -3
- 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 +76 -37
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/labsAutoCheck.js +19 -0
- package/codeyam-cli/src/utils/labsAutoCheck.js.map +1 -0
- package/codeyam-cli/src/utils/progress.js +7 -0
- package/codeyam-cli/src/utils/progress.js.map +1 -1
- package/codeyam-cli/src/utils/queue/job.js +109 -0
- package/codeyam-cli/src/utils/queue/job.js.map +1 -1
- package/codeyam-cli/src/utils/queue/manager.js +6 -0
- 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 +230 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js +67 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js +105 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js +34 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js +162 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js +75 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js +378 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js +115 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js +127 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js +50 -0
- package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js +116 -0
- package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/index.js +5 -0
- package/codeyam-cli/src/utils/ruleReflection/index.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js +44 -0
- package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js +85 -0
- package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/types.js +5 -0
- package/codeyam-cli/src/utils/ruleReflection/types.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js +293 -0
- package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/index.js +6 -0
- package/codeyam-cli/src/utils/rules/index.js.map +1 -0
- package/codeyam-cli/src/utils/rules/parser.js +83 -0
- package/codeyam-cli/src/utils/rules/parser.js.map +1 -0
- package/codeyam-cli/src/utils/rules/pathMatcher.js +18 -0
- package/codeyam-cli/src/utils/rules/pathMatcher.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/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/versionInfo.js +25 -19
- package/codeyam-cli/src/utils/versionInfo.js.map +1 -1
- package/codeyam-cli/src/utils/wipe.js +128 -0
- package/codeyam-cli/src/utils/wipe.js.map +1 -0
- package/codeyam-cli/src/webserver/app/lib/database.js +88 -23
- package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
- package/codeyam-cli/src/webserver/app/lib/dbNotifier.js.map +1 -1
- package/codeyam-cli/src/webserver/backgroundServer.js +50 -0
- package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/webserver/bootstrap.js +51 -0
- package/codeyam-cli/src/webserver/bootstrap.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/CopyButton-D9i_zSlY.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-BLlhOa3C.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-CzGX-miz.js → EntityTypeBadge-De5b5pC7.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-CzdG5I7z.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-Bclf8Hka.js +34 -0
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-Ce-byqKl.js +25 -0
- package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-CBQPrpT0.js → LibraryFunctionPreview-DEMHrl7v.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-D1CdlbrV.js → LoadingDots-B1LNGboS.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-wDPcZNKx.js → LogViewer-B0Ll1DjK.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-CVOvmCKb.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-BfmDgXxG.js → SafeScreenshot-L0DWHa_L.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-D54Mmpwi.js +10 -0
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-6J7zDUD5.js → TruncatedFilePath-C7PFQfXy.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/_index-CKTtYlBU.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-CdziRIWU.js +27 -0
- package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-CPXtdaWm.js +17 -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.save-fixture-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/book-open-Ch8b7GyQ.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-BYimnrHg.js → chevron-down-vJHJExlT.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/chunk-JZWAC4HX-BEyX4X6_.js +51 -0
- package/codeyam-cli/src/webserver/build/client/assets/{circle-check-CaVsIRxt.js → circle-check-rwynPZTW.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/copy-BBSpeBYf.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-CgUsG7ib.js → createLucideIcon-DHVDauuc.js} +1 -1
- 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-B9_ZqelV.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-BOPComvD.js +16 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-Cfw__yQa.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-BIDUUrI3.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-CfLCUi9S.js → entity._sha_.edit._scenarioId-BEqewwtZ.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entry.client-DKJyZfAY.js → entry.client-Dxqz8ygt.js} +6 -6
- package/codeyam-cli/src/webserver/build/client/assets/executionFlowCoverage-BWhdfn70.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{fileTableUtils-DAtOlaWE.js → fileTableUtils-CYnF5KWN.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-B_dAq2PQ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{git-D62Lxxmv.js → git-BHPqH3Ch.js} +8 -8
- package/codeyam-cli/src/webserver/build/client/assets/globals-BJGhRykz.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{index-BosqDOlH.js → index-DgAAopZk.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{index-CzNNiTkw.js → index-viijWaN6.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/labs-ChoAe3xq.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-CNp9QFCX.js → loader-circle-LGi2eKI5.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-87493a32.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-D9eA6kTo.js +78 -0
- package/codeyam-cli/src/webserver/build/client/assets/pause-DxJFmMsK.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/root-C3r0p_7H.js +62 -0
- package/codeyam-cli/src/webserver/build/client/assets/{search-DDGjYAMJ.js → search-Cu3QE9E5.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/settings-KH9TdArD.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/simulations-D9Fkx0-d.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/terminal-dAhIBEcd.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-CBc5dE1s.js → triangle-alert-C4CYTEeP.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-CLPnITMB.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-BqPPNjAl.js → useLastLogLine-DmGI38Et.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-BK0S88PB.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useToast-DWHcCcl1.js → useToast-CJ-JqR0l.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-CkkmL6r5.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-iBGjHYtO.js +259 -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/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 +13 -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/rule-notification-hook.py +56 -0
- package/codeyam-cli/templates/rule-reflection-hook.py +627 -0
- package/codeyam-cli/templates/rules-instructions.md +132 -0
- package/package.json +17 -14
- package/packages/ai/index.js +8 -6
- package/packages/ai/index.js.map +1 -1
- package/packages/ai/src/lib/analyzeScope.js +179 -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 +138 -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 +7 -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 +944 -30
- 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 -31
- package/packages/ai/src/lib/completionCall.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +1461 -205
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +7 -2
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +230 -23
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +77 -55
- 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 +52 -3
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +122 -14
- 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 +122 -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 +333 -81
- 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 +126 -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 +78 -120
- package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateEntityDataStructure.js +47 -2
- package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarioData.js +1130 -83
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarios.js +177 -163
- package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +414 -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/guessScenarioDataFromDescription.js +2 -2
- 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 +10 -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 -100
- 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 -70
- 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 +9 -9
- 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 +94 -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/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 +211 -54
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +24 -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 +11 -7
- package/packages/analyze/src/lib/files/getImportedExports.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js +880 -0
- package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +170 -40
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -1
- 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 +480 -71
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.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 +268 -66
- 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 +27 -98
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +2 -3
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +801 -118
- 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 +11 -1
- 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.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 +7 -4
- 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/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 +0 -1
- package/packages/types/index.js.map +1 -1
- package/packages/types/src/types/Scenario.js +1 -21
- package/packages/types/src/types/Scenario.js.map +1 -1
- package/packages/utils/src/lib/fs/rsyncCopy.js +93 -2
- package/packages/utils/src/lib/fs/rsyncCopy.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 -76
- package/analyzer-template/packages/ai/src/lib/findMatchingAttribute.ts +0 -102
- package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +0 -409
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +0 -288
- package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +0 -495
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.ts +0 -67
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +0 -120
- 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/scripts/fixtures/formbricks/universal-mocks/apps/web/lib/instance/service.js +0 -7
- package/codeyam-cli/scripts/fixtures/formbricks/universal-mocks/apps/web/lib/instance/service.js.map +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-wXL1Z2Aq.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-CXFKsCOD.js +0 -41
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-D-9pXIaY.js +0 -25
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-4lcOlid-.js +0 -11
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-CUxUNEEC.js +0 -15
- package/codeyam-cli/src/webserver/build/client/assets/_index-DHImXdXq.js +0 -11
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-2mG6mjVb.js +0 -32
- package/codeyam-cli/src/webserver/build/client/assets/chunk-JMJ3UQ3L-BambyYE_.js +0 -51
- package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-CKnwPCDr.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-DW_hdGUc.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha._-zUEpfPsu.js +0 -23
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-DyB90fWk.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-D_3ero5o.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-ClR0d32A.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/globals-C6vQASxy.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/keyAttributeCoverage-CTlFMihX.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-09d684be.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/root-BxJUvKau.js +0 -56
- package/codeyam-cli/src/webserver/build/client/assets/settings-DgTyB-Wg.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/simulations-CoNWGt0K.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-BMIGFP-m.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useInteractiveMode-Dk_FQqWJ.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-DsJbgMY9.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-CV6i1S1A.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-BDlyhfrv.js +0 -175
- package/codeyam-cli/templates/debug-codeyam.md +0 -620
- 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 -298
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +0 -226
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateEntityKeyAttributes.js +0 -408
- 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 -77
- 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/{api.link-scenario-value-l0sNRNKZ.js → api.agent-transcripts-l0sNRNKZ.js} +0 -0
- /package/codeyam-cli/src/webserver/build/client/assets/{api.update-key-attributes-l0sNRNKZ.js → api.health-l0sNRNKZ.js} +0 -0
- /package/codeyam-cli/src/webserver/build/client/assets/{api.update-valid-values-l0sNRNKZ.js → api.labs-unlock-l0sNRNKZ.js} +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
|
@@ -1,12 +1,93 @@
|
|
|
1
1
|
import { joinParenthesesAndArrays, splitOutsideParenthesesAndArrays, functionArguments, cleanOutBoundary, fillInDirectSchemaGapsAndUnknowns, removeDuplicateFunctionCalls, } from "../../../../../packages/ai/index.js";
|
|
2
2
|
/**
|
|
3
|
-
* Converts a
|
|
4
|
-
*
|
|
3
|
+
* Converts a call signature to a valid JavaScript identifier (function name).
|
|
4
|
+
* The original signature is preserved for data access - this only creates the function name.
|
|
5
|
+
*
|
|
6
|
+
* Examples:
|
|
7
|
+
* - "useAuth()" → "useAuth"
|
|
8
|
+
* - "db.select(usersQuery)" → "db_select_usersQuery"
|
|
9
|
+
* - "db.select(postsQuery)" → "db_select_postsQuery"
|
|
10
|
+
* - "useFetcher<User>()" → "useFetcher_User"
|
|
11
|
+
* - "useFetcher<{ data: UserData | null }>()" → "useFetcher_data_UserData_null"
|
|
12
|
+
* - "eq('user_id', value)" → "eq_user_id_value"
|
|
13
|
+
* - "from('workouts')" → "from_workouts"
|
|
5
14
|
*/
|
|
6
|
-
function
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
|
|
15
|
+
function callSignatureToFunctionName(signature) {
|
|
16
|
+
// Extract components from the signature
|
|
17
|
+
const components = [];
|
|
18
|
+
// 1. Extract function path (parts separated by dots outside parens/brackets)
|
|
19
|
+
const pathMatch = signature.match(/^([^<(]+)/);
|
|
20
|
+
if (pathMatch) {
|
|
21
|
+
const path = pathMatch[1];
|
|
22
|
+
// Split on dots but preserve the parts
|
|
23
|
+
components.push(...path.split('.').filter(Boolean));
|
|
24
|
+
}
|
|
25
|
+
// 2. Extract generic type parameters (content between < and >)
|
|
26
|
+
const genericMatch = signature.match(/<([^>]+)>/);
|
|
27
|
+
if (genericMatch) {
|
|
28
|
+
const genericContent = genericMatch[1];
|
|
29
|
+
// Extract meaningful identifiers from generic type
|
|
30
|
+
// Handle complex types like "{ data: UserData | null }"
|
|
31
|
+
const typeIdentifiers = genericContent
|
|
32
|
+
.replace(/[{}:;,]/g, ' ') // Remove structural chars
|
|
33
|
+
.replace(/\|/g, ' ') // Handle union types
|
|
34
|
+
.split(/\s+/)
|
|
35
|
+
.filter(Boolean)
|
|
36
|
+
.filter((s) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(s)) // Only valid identifiers
|
|
37
|
+
.filter((s) => ![
|
|
38
|
+
'null',
|
|
39
|
+
'undefined',
|
|
40
|
+
'void',
|
|
41
|
+
'never',
|
|
42
|
+
'any',
|
|
43
|
+
'unknown',
|
|
44
|
+
'data',
|
|
45
|
+
'typeof',
|
|
46
|
+
].includes(s)); // Skip common non-meaningful keywords
|
|
47
|
+
if (typeIdentifiers.length > 0) {
|
|
48
|
+
components.push(...typeIdentifiers.slice(0, 2)); // Limit to first 2 for reasonable length
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// 3. Extract function arguments (first 2 for disambiguation)
|
|
52
|
+
const argsMatch = signature.match(/\(([^)]*)\)/);
|
|
53
|
+
if (argsMatch && argsMatch[1]) {
|
|
54
|
+
const argsContent = argsMatch[1].trim();
|
|
55
|
+
if (argsContent) {
|
|
56
|
+
const args = argsContent.split(',').map((arg) => arg.trim());
|
|
57
|
+
for (const arg of args.slice(0, 2)) {
|
|
58
|
+
// For quoted strings, extract the content
|
|
59
|
+
const stringMatch = arg.match(/^['"`](.+)['"`]$/);
|
|
60
|
+
if (stringMatch) {
|
|
61
|
+
// Split on dots for string paths like 'users.id'
|
|
62
|
+
const parts = stringMatch[1].split('.').filter(Boolean);
|
|
63
|
+
components.push(...parts);
|
|
64
|
+
}
|
|
65
|
+
else if (/^[A-Za-z_][A-Za-z0-9_]*$/.test(arg)) {
|
|
66
|
+
// Valid identifier - use as-is
|
|
67
|
+
components.push(arg);
|
|
68
|
+
}
|
|
69
|
+
else if (/^\d+$/.test(arg)) {
|
|
70
|
+
// Number - use as-is
|
|
71
|
+
components.push(arg);
|
|
72
|
+
}
|
|
73
|
+
// Skip complex expressions
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// Build the function name from components
|
|
78
|
+
const functionName = components
|
|
79
|
+
.join('_')
|
|
80
|
+
.replace(/[^a-zA-Z0-9_]/g, '_') // Sanitize special chars
|
|
81
|
+
.replace(/_+/g, '_') // Collapse multiple underscores
|
|
82
|
+
.replace(/^_|_$/g, ''); // Trim underscores
|
|
83
|
+
return functionName || 'mock';
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Check if a mock name is a call signature (e.g., "useFetcher<User>()", "db.select(query)")
|
|
87
|
+
*/
|
|
88
|
+
function isCallSignature(mockName) {
|
|
89
|
+
// Call signatures contain parentheses (function calls)
|
|
90
|
+
return mockName.includes('(');
|
|
10
91
|
}
|
|
11
92
|
/**
|
|
12
93
|
* Extract property names that are jsx-components and should be preserved from original.
|
|
@@ -134,51 +215,53 @@ function funcArgs(functionSignature) {
|
|
|
134
215
|
}
|
|
135
216
|
// isValidKey ensures that the key does not contain any characters that would make it invalid in a JavaScript object.
|
|
136
217
|
// For example, it should not contain spaces, special characters, or start with a number.
|
|
218
|
+
// Also rejects keys that are pure function calls like "()" or "(args)" - these aren't property names.
|
|
137
219
|
function isValidKey(key) {
|
|
138
220
|
if (!key || key.length === 0)
|
|
139
221
|
return false;
|
|
140
222
|
const keyWithOutArguments = key.split('(')[0];
|
|
223
|
+
// Reject empty keys (happens when key is "()" or "(args)") - these are function calls, not property names
|
|
224
|
+
if (!keyWithOutArguments || keyWithOutArguments.length === 0)
|
|
225
|
+
return false;
|
|
141
226
|
return !/\s/.test(keyWithOutArguments);
|
|
142
227
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
228
|
+
/**
|
|
229
|
+
* Known hooks that return tuples [value, setter] instead of arrays.
|
|
230
|
+
* These should NOT use the .map() pattern even when the schema has generic array access ([]).
|
|
231
|
+
* Instead, they should return [data, () => {}] where data is from scenarios().
|
|
232
|
+
*/
|
|
233
|
+
const TUPLE_RETURNING_HOOKS = new Set([
|
|
234
|
+
'useAtom', // Jotai
|
|
235
|
+
'useState', // React
|
|
236
|
+
'useReducer', // React
|
|
237
|
+
'useRecoilState', // Recoil
|
|
238
|
+
'useImmerAtom', // Jotai with Immer
|
|
239
|
+
]);
|
|
240
|
+
export default function constructMockCode(mockName, dependencySchemas, entityType, _canonicalKey, // DEPRECATED: No longer used, kept for API compatibility
|
|
241
|
+
options) {
|
|
242
|
+
// Check if mockName is a call signature (e.g., "useFetcher<User>()", "db.select(query)")
|
|
243
|
+
const mockNameIsCallSignature = isCallSignature(mockName);
|
|
244
|
+
// For call signatures, use the original signature for data access but generate
|
|
245
|
+
// a valid JS function name from it
|
|
246
|
+
const derivedFunctionName = mockNameIsCallSignature
|
|
247
|
+
? callSignatureToFunctionName(mockName)
|
|
150
248
|
: null;
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
249
|
+
// The baseMockName is the function name without type params and args
|
|
250
|
+
// e.g., "useFetcher<User>()" -> "useFetcher", "db.select(query)" -> "db"
|
|
251
|
+
const baseMockName = mockName.split(/[<(]/)[0];
|
|
252
|
+
// The data key is the mockName (call signature) for data access
|
|
253
|
+
let dataKey;
|
|
154
254
|
const mockNameParts = splitOutsideParenthesesAndArrays(baseMockName);
|
|
155
255
|
let relevantReturnValueSchema;
|
|
156
256
|
let dataStructurePath;
|
|
157
257
|
let dataStructureValue;
|
|
158
258
|
let foundEntityWithSignature = false;
|
|
159
259
|
let signatureSchema;
|
|
160
|
-
for (const filePath in dependencySchemas) {
|
|
260
|
+
entitySearch: for (const filePath in dependencySchemas) {
|
|
161
261
|
for (const entityName in dependencySchemas[filePath]) {
|
|
162
|
-
//
|
|
163
|
-
|
|
164
|
-
const
|
|
165
|
-
? `${variableQualifier} <- ${baseMockName}`
|
|
166
|
-
: mockNameParts[0];
|
|
167
|
-
// Check for direct match
|
|
168
|
-
let matches = entityName === targetEntityName || entityName === mockNameParts[0];
|
|
169
|
-
// If no direct match and no qualifier was provided, check if the entity
|
|
170
|
-
// is stored under a variable-qualified key (e.g., "stateBadge <- getStateBadge")
|
|
171
|
-
// This handles the case where gatherDataForMocks stored the entity with a variable
|
|
172
|
-
// qualifier but writeScenarioComponents called constructMockCode without one.
|
|
173
|
-
if (!matches && !variableQualifier) {
|
|
174
|
-
const qualifiedKeyMatch = entityName.match(new RegExp(`^([a-zA-Z_][a-zA-Z0-9_]*)\\s*<-\\s*${mockNameParts[0]}$`));
|
|
175
|
-
if (qualifiedKeyMatch) {
|
|
176
|
-
matches = true;
|
|
177
|
-
// Extract the variable qualifier from the entity name so we can use
|
|
178
|
-
// it for the data lookup key later
|
|
179
|
-
variableQualifier = qualifiedKeyMatch[1];
|
|
180
|
-
}
|
|
181
|
-
}
|
|
262
|
+
// Match entity by base name (without generics/args)
|
|
263
|
+
const entityBaseName = entityName.split(/[<(]/)[0];
|
|
264
|
+
const matches = entityBaseName === baseMockName || entityName === mockNameParts[0];
|
|
182
265
|
if (!matches)
|
|
183
266
|
continue;
|
|
184
267
|
// Track if we found the entity and it has a signature (is a function)
|
|
@@ -206,10 +289,43 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
206
289
|
// However, we still need to remove duplicate function calls that create invalid syntax
|
|
207
290
|
removeDuplicateFunctionCalls(relevantReturnValueSchema);
|
|
208
291
|
dataStructureValue = relevantReturnValueSchema?.[dataStructurePath];
|
|
209
|
-
break;
|
|
292
|
+
break entitySearch;
|
|
210
293
|
}
|
|
211
294
|
}
|
|
212
295
|
}
|
|
296
|
+
// Check if the entity is used as a function (called with ()) vs an object/namespace.
|
|
297
|
+
// Look for paths in the schema that start with "baseMockName(" or "baseMockName<" indicating function calls.
|
|
298
|
+
// The "<" handles generic type parameters like useLoaderData<T>().
|
|
299
|
+
// Also check dataStructurePath === 'returnValue' which indicates a function return value.
|
|
300
|
+
const entityIsFunction = foundEntityWithSignature ||
|
|
301
|
+
dataStructurePath === 'returnValue' ||
|
|
302
|
+
Object.keys(relevantReturnValueSchema ?? {}).some((key) => key.startsWith(`${baseMockName}(`) ||
|
|
303
|
+
key.startsWith(`${baseMockName}<`));
|
|
304
|
+
// Calculate the data key - use the call signature (mockName) for data access
|
|
305
|
+
// For simple names without parentheses:
|
|
306
|
+
// - Append () ONLY if the entity is a function/hook (detected above)
|
|
307
|
+
// - Don't append () for object/namespace mocks like "supabase"
|
|
308
|
+
if (mockNameIsCallSignature || mockName.includes('(')) {
|
|
309
|
+
dataKey = mockName;
|
|
310
|
+
}
|
|
311
|
+
else if (entityIsFunction) {
|
|
312
|
+
// Entity is a function/hook - append () to match call signature format
|
|
313
|
+
dataKey = `${mockName}()`;
|
|
314
|
+
}
|
|
315
|
+
else {
|
|
316
|
+
// Entity is an object/namespace - use bare name as key
|
|
317
|
+
dataKey = mockName;
|
|
318
|
+
}
|
|
319
|
+
// Helper to wrap key in appropriate quotes for computed property access
|
|
320
|
+
// Use single quotes when key contains double quotes to avoid syntax errors
|
|
321
|
+
const quotePropertyKey = (key) => {
|
|
322
|
+
const escaped = key.replace(/\n/g, '\\n');
|
|
323
|
+
if (escaped.includes('"')) {
|
|
324
|
+
// Use single quotes, escaping any single quotes in the key
|
|
325
|
+
return `['${escaped.replace(/'/g, "\\'")}']`;
|
|
326
|
+
}
|
|
327
|
+
return `["${escaped}"]`;
|
|
328
|
+
};
|
|
213
329
|
// Check if the return value schema only contains function type markers
|
|
214
330
|
// (e.g., "validateInputs()": "function") without actual return data
|
|
215
331
|
// (no functionCallReturnValue entries)
|
|
@@ -232,6 +348,8 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
232
348
|
// Count the number of arguments from signature schema
|
|
233
349
|
const argCount = Object.keys(signatureSchema).filter((key) => key.startsWith('signature[')).length;
|
|
234
350
|
const args = Array.from({ length: argCount }, (_, i) => `arg${i + 1}`);
|
|
351
|
+
// Always add ...rest to accept extra arguments beyond the signature
|
|
352
|
+
args.push('...rest');
|
|
235
353
|
const argsString = args.join(', ');
|
|
236
354
|
// Generate empty mock function
|
|
237
355
|
return `function ${mockName}(${argsString}) {
|
|
@@ -250,7 +368,33 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
250
368
|
!hasMeaningfulReturnData(relevantReturnValueSchema)) {
|
|
251
369
|
const argCount = Object.keys(signatureSchema).filter((key) => key.startsWith('signature[')).length;
|
|
252
370
|
const args = Array.from({ length: argCount }, (_, i) => `arg${i + 1}`);
|
|
371
|
+
// Always add ...rest to accept extra arguments beyond the signature
|
|
372
|
+
args.push('...rest');
|
|
253
373
|
const argsString = args.join(', ');
|
|
374
|
+
// Check for Higher-Order Component (HOC) pattern:
|
|
375
|
+
// - First argument is a function (component) or unknown (couldn't trace type)
|
|
376
|
+
// - Returns a function
|
|
377
|
+
// HOCs like memo, forwardRef, createContext should return their first argument
|
|
378
|
+
//
|
|
379
|
+
// The return value key can be either:
|
|
380
|
+
// - 'memo()' (clean format)
|
|
381
|
+
// - 'memo(({ value, width }: Props) => { ... })' (full component code format)
|
|
382
|
+
const firstArgIsFunctionOrUnknown = signatureSchema['signature[0]'] === 'function' ||
|
|
383
|
+
signatureSchema['signature[0]'] === 'unknown';
|
|
384
|
+
const returnsFunction = relevantReturnValueSchema
|
|
385
|
+
? Object.entries(relevantReturnValueSchema).some(([key, value]) => {
|
|
386
|
+
// Check if key represents a function call that returns a function
|
|
387
|
+
// Key should start with the mock name, contain '(', end with ')', and have value 'function'
|
|
388
|
+
const isFunctionCall = key.startsWith(mockName + '(') && key.endsWith(')');
|
|
389
|
+
return isFunctionCall && value === 'function';
|
|
390
|
+
})
|
|
391
|
+
: false;
|
|
392
|
+
if (firstArgIsFunctionOrUnknown && returnsFunction) {
|
|
393
|
+
// HOC pattern detected - return the first argument
|
|
394
|
+
return `function ${mockName}(${argsString}) {
|
|
395
|
+
return arg1;
|
|
396
|
+
}`;
|
|
397
|
+
}
|
|
254
398
|
// Generate empty mock function
|
|
255
399
|
return `function ${mockName}(${argsString}) {
|
|
256
400
|
// Empty mock - original function mocked out
|
|
@@ -267,6 +411,87 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
267
411
|
const pathDepth = splitOutsideParenthesesAndArrays(dataStructurePath).length;
|
|
268
412
|
const isRootArray = dataStructureValue === 'array' &&
|
|
269
413
|
(dataStructurePath === 'returnValue' || pathDepth <= mockNameParts.length);
|
|
414
|
+
// OPTIMIZATION: Early return for tuple-returning hooks (useAtom, useState, etc.)
|
|
415
|
+
// These hooks have simple [value, setter] return patterns that don't need the full
|
|
416
|
+
// 9216-key schema processing. Check if this is a tuple-returning hook and generate
|
|
417
|
+
// the mock code directly without iterating over all schema keys.
|
|
418
|
+
if (TUPLE_RETURNING_HOOKS.has(baseMockName) && isFunction) {
|
|
419
|
+
// Check if schema has generic array pattern (indicates tuple return like [value, setter])
|
|
420
|
+
const schemaKeys = Object.keys(relevantReturnValueSchema ?? {});
|
|
421
|
+
const hasGenericArrayInSchema = schemaKeys.some((k) => k.includes('.functionCallReturnValue[]') ||
|
|
422
|
+
k === `${dataKey}.functionCallReturnValue[]` ||
|
|
423
|
+
k === 'returnValue[]');
|
|
424
|
+
// Check for differentiated tuple indices (e.g., functionCallReturnValue[2], [3]) which would NOT be a standard tuple
|
|
425
|
+
// We only check indices immediately after functionCallReturnValue, not nested indices like signature[2]
|
|
426
|
+
const tupleHasDifferentiatedIndices = schemaKeys.some((k) => {
|
|
427
|
+
// Look for .functionCallReturnValue[N] where N >= 2
|
|
428
|
+
const match = k.match(/\.functionCallReturnValue\[(\d+)\]/);
|
|
429
|
+
if (!match)
|
|
430
|
+
return false;
|
|
431
|
+
const idx = parseInt(match[1], 10);
|
|
432
|
+
return idx >= 2;
|
|
433
|
+
});
|
|
434
|
+
const isTupleReturningHook = hasGenericArrayInSchema && !tupleHasDifferentiatedIndices;
|
|
435
|
+
if (isTupleReturningHook) {
|
|
436
|
+
// Find all call patterns for this hook (e.g., useAtom(quoteFilterAtom), useAtom(supplierAtom))
|
|
437
|
+
const hookCallPatterns = Object.keys(relevantReturnValueSchema ?? {})
|
|
438
|
+
.filter((k) => {
|
|
439
|
+
const regex = new RegExp(`^${baseMockName}\\([^)]+\\)$`);
|
|
440
|
+
return regex.test(k);
|
|
441
|
+
})
|
|
442
|
+
.map((k) => {
|
|
443
|
+
const match = k.match(/\(([^)]+)\)/);
|
|
444
|
+
return { key: k, arg: match?.[1] ?? '' };
|
|
445
|
+
});
|
|
446
|
+
let tupleReturnCode;
|
|
447
|
+
if (hookCallPatterns.length > 1) {
|
|
448
|
+
// Multiple patterns - generate conditional dispatch
|
|
449
|
+
const conditions = hookCallPatterns
|
|
450
|
+
.map(({ key, arg }) => `if (argLabel === '${arg}' || argStr.includes('${arg}')) {\n return [scenarios().data()?.["${key}"]?.[0] ?? [], () => {}];\n }`)
|
|
451
|
+
.join('\n ');
|
|
452
|
+
const fallbackKey = hookCallPatterns[0]?.key ?? dataKey;
|
|
453
|
+
tupleReturnCode = `(() => {
|
|
454
|
+
// Dynamic dispatch for tuple-returning hook with multiple argument patterns
|
|
455
|
+
const argLabel = args[0]?.debugLabel ?? '';
|
|
456
|
+
const argStr = args[0]?.toString?.() ?? String(args[0] ?? '');
|
|
457
|
+
${conditions}
|
|
458
|
+
return [scenarios().data()?.["${fallbackKey}"]?.[0] ?? [], () => {}];
|
|
459
|
+
})()`;
|
|
460
|
+
}
|
|
461
|
+
else {
|
|
462
|
+
// Single or no patterns - use dynamic dispatch
|
|
463
|
+
const fallbackKey = hookCallPatterns[0]?.key ?? `${baseMockName}()`;
|
|
464
|
+
tupleReturnCode = `(() => {
|
|
465
|
+
// Dynamic dispatch for tuple-returning hook
|
|
466
|
+
const argLabel = args[0]?.debugLabel ?? '';
|
|
467
|
+
const argStr = args[0]?.toString?.() ?? '';
|
|
468
|
+
const allData = scenarios().data() ?? {};
|
|
469
|
+
if (argLabel) {
|
|
470
|
+
const labelKey = '${baseMockName}(' + argLabel + ')';
|
|
471
|
+
if (allData[labelKey]) {
|
|
472
|
+
return [allData[labelKey]?.[0] ?? [], () => {}];
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
const keys = Object.keys(allData).filter(k => k.startsWith('${baseMockName}('));
|
|
476
|
+
for (const key of keys) {
|
|
477
|
+
const keyArg = key.slice(${baseMockName.length + 1}, -1);
|
|
478
|
+
if (argStr.includes(keyArg)) {
|
|
479
|
+
return [allData[key]?.[0] ?? [], () => {}];
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
return [allData[keys[0] ?? '${fallbackKey}']?.[0] ?? [], () => {}];
|
|
483
|
+
})()`;
|
|
484
|
+
}
|
|
485
|
+
const safeFunctionName = options?.uniqueFunctionSuffix
|
|
486
|
+
? `${baseMockName}_${options.uniqueFunctionSuffix}`
|
|
487
|
+
: options?.keepOriginalFunctionName
|
|
488
|
+
? baseMockName
|
|
489
|
+
: mockNameIsCallSignature && derivedFunctionName
|
|
490
|
+
? derivedFunctionName
|
|
491
|
+
: baseMockName;
|
|
492
|
+
return `function ${safeFunctionName}(...args) {\n return ${tupleReturnCode};\n}`;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
270
495
|
const returnValueParts = {
|
|
271
496
|
name: dataStructureName,
|
|
272
497
|
isArray: isRootArray,
|
|
@@ -287,23 +512,19 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
287
512
|
// Strip type parameters like <typeof loader> from function names
|
|
288
513
|
// so "useLoaderData<typeof loader>()" becomes "useLoaderData()"
|
|
289
514
|
name = cleanOutTypes(name);
|
|
290
|
-
// For root data access, use the canonical key
|
|
291
|
-
//
|
|
292
|
-
if (isRootAccess
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
if (isRootAccess && variableQualifier) {
|
|
298
|
-
const baseName = name.replace(/\(\)$/, '');
|
|
299
|
-
name = `${variableQualifier} <- ${baseName}`;
|
|
515
|
+
// For root data access, use the dataKey (original call signature or canonical key)
|
|
516
|
+
// This preserves the original call signature for LLM clarity
|
|
517
|
+
if (isRootAccess) {
|
|
518
|
+
// For call signature format, use the original mockName as the data key
|
|
519
|
+
// e.g., scenarios().data()?.["useFetcher<User>()"]
|
|
520
|
+
// e.g., scenarios().data()?.["db.select(usersQuery)"]
|
|
521
|
+
return `?.${quotePropertyKey(dataKey)}`;
|
|
300
522
|
}
|
|
301
523
|
// Only use unquoted array access syntax for pure array indices like [0], [1]
|
|
302
|
-
|
|
303
|
-
if (name.match(/^\[\d+\]$/) && !name.includes(' <- ')) {
|
|
524
|
+
if (name.match(/^\[\d+\]$/)) {
|
|
304
525
|
return `?.${name}`;
|
|
305
526
|
}
|
|
306
|
-
return
|
|
527
|
+
return `?.${quotePropertyKey(name)}`;
|
|
307
528
|
};
|
|
308
529
|
const constructDataPaths = () => {
|
|
309
530
|
// For structural elements, return modified base paths for children
|
|
@@ -351,7 +572,17 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
351
572
|
};
|
|
352
573
|
const constructContent = (dataPaths) => {
|
|
353
574
|
const { name, args, nested, isArray, isGenericArray, returnsFunctionArgs, returnsFunctionArray, isAsyncFunction, hasNoReturnData, } = returnValue;
|
|
354
|
-
|
|
575
|
+
// When an array has differentiated indices ([0], [1], etc.), filter out any
|
|
576
|
+
// non-index items from nested. These non-index items come from generic [] paths
|
|
577
|
+
// like [].filter or [].sort, which describe element properties, not array elements.
|
|
578
|
+
// Including them would generate invalid syntax like "sort: ..." inside an array literal.
|
|
579
|
+
const hasDifferentiatedIndices = isArray &&
|
|
580
|
+
nested &&
|
|
581
|
+
nested.some((n) => n.name.match(/^\[\d+\]$/) && n.name !== '[0]');
|
|
582
|
+
const filteredNested = hasDifferentiatedIndices && nested
|
|
583
|
+
? nested.filter((n) => n.name.match(/^\[\d+\]$/))
|
|
584
|
+
: nested;
|
|
585
|
+
const nestedContent = (filteredNested ?? []).map((nestedItem) => {
|
|
355
586
|
const nestedContent = constructReturnValueString(nestedItem, dataPaths);
|
|
356
587
|
return nestedContent;
|
|
357
588
|
});
|
|
@@ -425,52 +656,110 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
425
656
|
(!returnValue.isStructural || isStructuralArrayElementWithNested)) {
|
|
426
657
|
levelContentItems.push(...dataPaths.map((path) => `...${path}`));
|
|
427
658
|
}
|
|
428
|
-
|
|
659
|
+
// Filter out nested content that would be invalid as object properties
|
|
660
|
+
// (e.g., bare arrow functions like "() => {...}" without a property name)
|
|
661
|
+
// Only apply this filter when building object content, not array content.
|
|
662
|
+
// Bare arrow functions ARE valid as array elements (like [0] = {...}, [1] = () => {...})
|
|
663
|
+
// Check both isArray (item IS an array) and returnsFunctionArray (item returns an array)
|
|
664
|
+
const inArrayContext = isArray || returnsFunctionArray;
|
|
665
|
+
const validNestedContent = nestedContent.filter((content) => {
|
|
666
|
+
if (!content)
|
|
667
|
+
return false;
|
|
668
|
+
// Only filter bare arrow functions when NOT in array context
|
|
669
|
+
// In arrays, bare arrow functions are valid elements
|
|
670
|
+
if (!inArrayContext && content.match(/^\s*\([^)]*\)\s*=>/)) {
|
|
671
|
+
return false;
|
|
672
|
+
}
|
|
673
|
+
return true;
|
|
674
|
+
});
|
|
675
|
+
levelContentItems.push(...validNestedContent);
|
|
429
676
|
let levelContents = levelContentItems.filter(Boolean).join(',\n');
|
|
430
677
|
if (returnsFunctionArgs) {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
678
|
+
// When returnsFunctionArgs is empty [] OR has a single literal string argument,
|
|
679
|
+
// the function returns a callable function (e.g., getTranslate() returns t,
|
|
680
|
+
// where t('key') looks up translations)
|
|
681
|
+
// Generate a dispatch function that looks up keys based on the argument
|
|
682
|
+
//
|
|
683
|
+
// Detect translation-like pattern:
|
|
684
|
+
// - Data path ends with ["('some.literal')"] - a literal string key
|
|
685
|
+
// - This means the mock data has keys like "('common.surveys')": "Surveys"
|
|
686
|
+
// - Exclude ["()"] which is an empty function call (not a translation pattern)
|
|
687
|
+
const dataPath = dataPaths[0];
|
|
688
|
+
// Pattern matches ?.["('...')"] at end of path, but NOT ?.["()"] (empty args)
|
|
689
|
+
const literalKeyPattern = dataPath?.match(/\?\.\["\('.+'\)"\]$/);
|
|
690
|
+
if (!returnsFunctionArray &&
|
|
691
|
+
dataPaths.length === 1 &&
|
|
692
|
+
literalKeyPattern // Only dispatch when there's a literal key pattern
|
|
693
|
+
) {
|
|
694
|
+
// Function returns a function - generate dispatch function
|
|
695
|
+
// Strip the literal key from the path and use dynamic lookup
|
|
696
|
+
const dataPathBase = literalKeyPattern
|
|
697
|
+
? dataPath.replace(/\?\.\["\('.+'\)"\]$/, '')
|
|
698
|
+
: dataPath;
|
|
699
|
+
const funcContents = `return ${dataPathBase}?.[\`('\${arg1}')\`]`;
|
|
700
|
+
levelContents = `(arg1) => {\n${indent(funcContents)}\n}`;
|
|
701
|
+
if (!isArray) {
|
|
702
|
+
return levelContents;
|
|
450
703
|
}
|
|
451
704
|
}
|
|
452
705
|
else {
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
706
|
+
const argsString = returnsFunctionArgs
|
|
707
|
+
.map((_, index) => `arg${index + 1}`)
|
|
708
|
+
.join(', ');
|
|
709
|
+
let funcContents = '';
|
|
710
|
+
if (returnsFunctionArray) {
|
|
711
|
+
if (hasNoReturnData) {
|
|
459
712
|
// Function has no return data (only signatures) - return empty array
|
|
460
713
|
funcContents = 'return []';
|
|
461
714
|
}
|
|
462
|
-
else {
|
|
463
|
-
//
|
|
715
|
+
else if (levelContents.length === 0 && dataPaths.length === 1) {
|
|
716
|
+
// When returning an array with no nested content, return the data path directly
|
|
717
|
+
// (the data path points to the array in scenario data)
|
|
464
718
|
funcContents = `return ${dataPaths[0]}`;
|
|
465
719
|
}
|
|
720
|
+
else if (levelContents.length === 0) {
|
|
721
|
+
funcContents = 'return []';
|
|
722
|
+
}
|
|
723
|
+
else {
|
|
724
|
+
funcContents = `return [\n${indent(levelContents)}\n]`;
|
|
725
|
+
}
|
|
466
726
|
}
|
|
467
727
|
else {
|
|
468
|
-
|
|
728
|
+
// Check if function has no actual return data (only signatures)
|
|
729
|
+
const hasNestedItems = nested && nested.length > 0;
|
|
730
|
+
const hasActualNestedContent = nestedContent.filter(Boolean).length > 0;
|
|
731
|
+
if (levelContentItems.length === 1 && dataPaths.length === 1) {
|
|
732
|
+
if (hasNoReturnData ||
|
|
733
|
+
(hasNestedItems && !hasActualNestedContent)) {
|
|
734
|
+
// Function has no return data (only signatures) - return empty array
|
|
735
|
+
funcContents = 'return []';
|
|
736
|
+
}
|
|
737
|
+
else {
|
|
738
|
+
// Has return data - return data path
|
|
739
|
+
funcContents = `return ${dataPaths[0]}`;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
else {
|
|
743
|
+
funcContents = `return {\n${indent(levelContents)}\n}`;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
levelContents = `(${argsString}) => {\n${indent(funcContents)}\n}`;
|
|
747
|
+
if (!isArray) {
|
|
748
|
+
return levelContents;
|
|
469
749
|
}
|
|
470
750
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
751
|
+
// For generic arrays of functions WITH nested properties (e.g., functionCallReturnValue[] = "function"
|
|
752
|
+
// with nested .filter, .sort, etc.), the levelContents would be a bare arrow function "() => {...}"
|
|
753
|
+
// that wraps object content. Using this in a .map(({...})) creates invalid syntax like "({ () => {...} })".
|
|
754
|
+
// When isGenericArray is true AND there are nested properties, we're accessing data from the elements,
|
|
755
|
+
// not calling them - so skip the function wrapping.
|
|
756
|
+
// But if there are NO nested properties, keep the wrapper because callers may want to call the elements.
|
|
757
|
+
const hasNonStructuralNestedItems = nested &&
|
|
758
|
+
nested.length > 0 &&
|
|
759
|
+
nested.some((n) => !n.name.match(/^\[\d*\]$/));
|
|
760
|
+
if (isGenericArray && hasNonStructuralNestedItems) {
|
|
761
|
+
// Skip the arrow function wrapper - just use the nested content directly
|
|
762
|
+
levelContents = levelContentItems.filter(Boolean).join(',\n');
|
|
474
763
|
}
|
|
475
764
|
}
|
|
476
765
|
// Check if all nested items are array prototype methods
|
|
@@ -483,7 +772,102 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
483
772
|
return ARRAY_PROTOTYPE_METHODS.has(methodName);
|
|
484
773
|
});
|
|
485
774
|
let returnValueContents = '';
|
|
486
|
-
if (
|
|
775
|
+
// Check if this is a known tuple-returning hook (useAtom, useState, etc.)
|
|
776
|
+
// These should return [value, setter] tuples, not arrays or data paths
|
|
777
|
+
// Check isGenericArray from current context OR from schema for root level calls
|
|
778
|
+
// (at root level, isGenericArray might not be set yet but the schema contains [] pattern)
|
|
779
|
+
const hasGenericArrayInSchema = root &&
|
|
780
|
+
TUPLE_RETURNING_HOOKS.has(baseMockName) &&
|
|
781
|
+
Object.keys(relevantReturnValueSchema ?? {}).some((k) => k.includes('.functionCallReturnValue[]'));
|
|
782
|
+
// Check if there are array indices beyond what a standard 2-element tuple would have
|
|
783
|
+
// For tuple-returning hooks, [0] and [1] are expected (value and setter)
|
|
784
|
+
// Only consider it "differentiated" if there are indices >= 2 (e.g., [2], [3])
|
|
785
|
+
const tupleHasDifferentiatedIndices = nested?.some((n) => {
|
|
786
|
+
const indexMatch = n.name.match(/^\[(\d+)\]$/);
|
|
787
|
+
if (!indexMatch)
|
|
788
|
+
return false;
|
|
789
|
+
const index = parseInt(indexMatch[1], 10);
|
|
790
|
+
return index >= 2;
|
|
791
|
+
});
|
|
792
|
+
const isTupleReturningHook = TUPLE_RETURNING_HOOKS.has(baseMockName) &&
|
|
793
|
+
(isGenericArray || hasGenericArrayInSchema) &&
|
|
794
|
+
!tupleHasDifferentiatedIndices;
|
|
795
|
+
// Debug logging for tuple-returning hooks
|
|
796
|
+
if (TUPLE_RETURNING_HOOKS.has(baseMockName) && root) {
|
|
797
|
+
const schemaKeys = Object.keys(relevantReturnValueSchema ?? {});
|
|
798
|
+
const hasArrayPattern = schemaKeys.some((k) => k.includes('.functionCallReturnValue[]'));
|
|
799
|
+
console.log(`CodeYam: Tuple hook check for ${baseMockName} (root):`, `hasGenericArrayInSchema=${hasGenericArrayInSchema}`, `hasArrayPattern=${hasArrayPattern}`, `tupleHasDifferentiatedIndices=${tupleHasDifferentiatedIndices}`, `isTupleReturningHook=${isTupleReturningHook}`, `schemaKeysSample=${schemaKeys.slice(0, 5).join(', ')}`);
|
|
800
|
+
}
|
|
801
|
+
if (isTupleReturningHook) {
|
|
802
|
+
// Tuple-returning hooks should return [value, setter] tuple
|
|
803
|
+
// The value is the first element from scenarios data, setter is a no-op
|
|
804
|
+
// Default to [] when data is undefined to prevent errors like ".includes is not a function"
|
|
805
|
+
// Check if there are multiple call patterns for this hook in the schema
|
|
806
|
+
// (e.g., useAtom(quoteFilterAtom) and useAtom(supplierAtom))
|
|
807
|
+
const hookCallPatterns = Object.keys(relevantReturnValueSchema ?? {})
|
|
808
|
+
.filter((k) => {
|
|
809
|
+
// Match patterns like "useAtom(someArg)" but not nested paths like "useAtom(x).foo"
|
|
810
|
+
const regex = new RegExp(`^${baseMockName}\\([^)]+\\)$`);
|
|
811
|
+
return regex.test(k);
|
|
812
|
+
})
|
|
813
|
+
.map((k) => {
|
|
814
|
+
// Extract the argument from the key like "useAtom(quoteFilterAtom)" -> "quoteFilterAtom"
|
|
815
|
+
const match = k.match(/\(([^)]+)\)/);
|
|
816
|
+
return { key: k, arg: match?.[1] ?? '' };
|
|
817
|
+
});
|
|
818
|
+
if (hookCallPatterns.length > 1) {
|
|
819
|
+
// Multiple patterns - generate conditional dispatch based on first argument
|
|
820
|
+
// For Jotai atoms, we use debugLabel; for others, we try to match the argument string
|
|
821
|
+
const conditions = hookCallPatterns
|
|
822
|
+
.map(({ key, arg }) => `if (argLabel === '${arg}' || argStr.includes('${arg}')) {\n return [scenarios().data()?.["${key}"]?.[0] ?? [], () => {}];\n }`)
|
|
823
|
+
.join('\n ');
|
|
824
|
+
// Use the first pattern as fallback
|
|
825
|
+
const fallbackKey = hookCallPatterns[0]?.key ?? dataKey;
|
|
826
|
+
returnValueContents = `(() => {
|
|
827
|
+
// Dynamic dispatch for tuple-returning hook with multiple argument patterns
|
|
828
|
+
const argLabel = args[0]?.debugLabel ?? '';
|
|
829
|
+
const argStr = args[0]?.toString?.() ?? String(args[0] ?? '');
|
|
830
|
+
${conditions}
|
|
831
|
+
// Fallback to first pattern
|
|
832
|
+
return [scenarios().data()?.["${fallbackKey}"]?.[0] ?? [], () => {}];
|
|
833
|
+
})()`;
|
|
834
|
+
}
|
|
835
|
+
else {
|
|
836
|
+
// Single pattern or no patterns - use dynamic dispatch to handle case where
|
|
837
|
+
// the mock is used with different atoms than what was captured in the schema.
|
|
838
|
+
// Use the first argument to construct the data key dynamically.
|
|
839
|
+
const fallbackKey = hookCallPatterns[0]?.key ?? `${baseMockName}()`;
|
|
840
|
+
returnValueContents = `(() => {
|
|
841
|
+
// Dynamic dispatch for tuple-returning hook
|
|
842
|
+
// Try to construct key from argument's debugLabel (Jotai atoms) or toString
|
|
843
|
+
const argLabel = args[0]?.debugLabel ?? '';
|
|
844
|
+
const argStr = args[0]?.toString?.() ?? '';
|
|
845
|
+
const allData = scenarios().data() ?? {};
|
|
846
|
+
|
|
847
|
+
// Try to find a matching key using debugLabel first
|
|
848
|
+
if (argLabel) {
|
|
849
|
+
const labelKey = '${baseMockName}(' + argLabel + ')';
|
|
850
|
+
if (allData[labelKey]) {
|
|
851
|
+
return [allData[labelKey]?.[0] ?? [], () => {}];
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
// Try to find any matching key that contains part of the argument string
|
|
856
|
+
const keys = Object.keys(allData).filter(k => k.startsWith('${baseMockName}('));
|
|
857
|
+
for (const key of keys) {
|
|
858
|
+
const keyArg = key.slice(${baseMockName.length + 1}, -1);
|
|
859
|
+
if (argStr.includes(keyArg)) {
|
|
860
|
+
return [allData[key]?.[0] ?? [], () => {}];
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
// Fallback to first matching key or default
|
|
865
|
+
const fallback = keys[0] ?? '${fallbackKey}';
|
|
866
|
+
return [allData[fallback]?.[0] ?? [], () => {}];
|
|
867
|
+
})()`;
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
else if (!returnsFunctionArgs &&
|
|
487
871
|
nestedContent.length === 0 &&
|
|
488
872
|
dataPaths.length === 1) {
|
|
489
873
|
returnValueContents = dataPaths[0];
|
|
@@ -516,14 +900,354 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
516
900
|
// Get the array base path (without the [0])
|
|
517
901
|
const arrayBasePath = dataPaths[0].replace(/\?\.\[0\]$/, '');
|
|
518
902
|
// Replace [0] references with [__idx__] in level contents
|
|
519
|
-
|
|
903
|
+
let mappedContents = levelContents.replace(/\?\.\[0\]/g, '?.[__idx__]');
|
|
520
904
|
// levelContents may already be wrapped in {...} from structural [0] element,
|
|
521
905
|
// so check if we need to add the wrapper or not
|
|
522
906
|
const needsWrapper = !mappedContents.trim().startsWith('{');
|
|
907
|
+
// Helper to check if a position is inside a string literal
|
|
908
|
+
// Returns the end position of the string if inside one, -1 otherwise
|
|
909
|
+
// Defined here so it's accessible in both needsWrapper branches
|
|
910
|
+
const skipStringLiteral = (content, pos) => {
|
|
911
|
+
const char = content[pos];
|
|
912
|
+
if (char !== '"' && char !== "'" && char !== '`')
|
|
913
|
+
return -1;
|
|
914
|
+
// Find the matching closing quote
|
|
915
|
+
let j = pos + 1;
|
|
916
|
+
while (j < content.length) {
|
|
917
|
+
if (content[j] === '\\') {
|
|
918
|
+
j += 2; // Skip escaped character
|
|
919
|
+
continue;
|
|
920
|
+
}
|
|
921
|
+
if (content[j] === char) {
|
|
922
|
+
return j + 1; // Return position after closing quote
|
|
923
|
+
}
|
|
924
|
+
j++;
|
|
925
|
+
}
|
|
926
|
+
return content.length; // Unclosed string, skip to end
|
|
927
|
+
};
|
|
928
|
+
// Filter out bare arrow functions which are invalid as object properties.
|
|
929
|
+
// Arrow functions can be multi-line, so we need to match the entire function body, not just the first line.
|
|
930
|
+
// Pattern: starts with "(args) =>", followed by either:
|
|
931
|
+
// - A single-line body: "() => expression"
|
|
932
|
+
// - A multi-line body: "() => { ... }" (with matching braces)
|
|
933
|
+
// IMPORTANT: Only filter BARE arrow functions (without property names).
|
|
934
|
+
// "() => {...}" is invalid, but "get: (arg1) => {...}" is valid.
|
|
935
|
+
// We use a function to properly handle nested braces.
|
|
936
|
+
// Defined here so it's accessible in both needsWrapper branches
|
|
937
|
+
const filterOutArrowFunctions = (content) => {
|
|
938
|
+
const result = [];
|
|
939
|
+
let i = 0;
|
|
940
|
+
while (i < content.length) {
|
|
941
|
+
// Skip over string literals entirely
|
|
942
|
+
const stringEnd = skipStringLiteral(content, i);
|
|
943
|
+
if (stringEnd !== -1) {
|
|
944
|
+
result.push(content.slice(i, stringEnd));
|
|
945
|
+
i = stringEnd;
|
|
946
|
+
continue;
|
|
947
|
+
}
|
|
948
|
+
// Check if we're at the start of an arrow function (with optional leading whitespace)
|
|
949
|
+
const arrowMatch = content
|
|
950
|
+
.slice(i)
|
|
951
|
+
.match(/^(\s*)\([^)]*\)\s*=>\s*/);
|
|
952
|
+
if (arrowMatch) {
|
|
953
|
+
// Check if this is a bare arrow function or a named property with arrow function value
|
|
954
|
+
// Look back to see if there's a "key:" pattern before this position
|
|
955
|
+
const before = content.slice(0, i);
|
|
956
|
+
const beforeTrimmed = before.trim();
|
|
957
|
+
// Valid patterns where arrow function is NOT bare:
|
|
958
|
+
// 1. Property value: "key: (arg) => ..." - ends with ':'
|
|
959
|
+
// 2. Function argument: ".map((arg) => ..." - ends with '('
|
|
960
|
+
// 3. Method call: "?.map" followed directly by the arrow function
|
|
961
|
+
// In this case, the '(' is consumed by the arrow function regex match,
|
|
962
|
+
// so beforeTrimmed ends with the method name (e.g., 'map'), not '('.
|
|
963
|
+
// We detect this by checking if beforeTrimmed ends with an identifier
|
|
964
|
+
// that could be a method name (preceded by '.' or '?.').
|
|
965
|
+
// NOTE: We don't include ',' because "{ prop, () => {} }" is invalid
|
|
966
|
+
// (can't distinguish function argument from object property context)
|
|
967
|
+
const isPropertyValue = beforeTrimmed.endsWith(':');
|
|
968
|
+
const isFunctionArg = beforeTrimmed.endsWith('(');
|
|
969
|
+
// Check if before ends with a method call pattern like ".map" or "?.map"
|
|
970
|
+
// The '(' after the method name is consumed by the arrow function regex
|
|
971
|
+
const isMethodCallArg = /\??\.\w+$/.test(beforeTrimmed);
|
|
972
|
+
const hasPropertyName = isPropertyValue || isFunctionArg || isMethodCallArg;
|
|
973
|
+
if (!hasPropertyName) {
|
|
974
|
+
// This is a bare arrow function - filter it out
|
|
975
|
+
// Found arrow function start, need to find its end
|
|
976
|
+
const afterArrow = i + arrowMatch[0].length;
|
|
977
|
+
if (content[afterArrow] === '{') {
|
|
978
|
+
// Multi-line arrow function - find matching closing brace
|
|
979
|
+
// Must respect string literals when counting braces
|
|
980
|
+
let braceCount = 1;
|
|
981
|
+
let j = afterArrow + 1;
|
|
982
|
+
while (j < content.length && braceCount > 0) {
|
|
983
|
+
const strEnd = skipStringLiteral(content, j);
|
|
984
|
+
if (strEnd !== -1) {
|
|
985
|
+
j = strEnd;
|
|
986
|
+
continue;
|
|
987
|
+
}
|
|
988
|
+
if (content[j] === '{')
|
|
989
|
+
braceCount++;
|
|
990
|
+
if (content[j] === '}')
|
|
991
|
+
braceCount--;
|
|
992
|
+
j++;
|
|
993
|
+
}
|
|
994
|
+
// Skip past the arrow function
|
|
995
|
+
i = j;
|
|
996
|
+
// Only skip trailing comma, keep newlines
|
|
997
|
+
while (i < content.length && content[i] === ' ') {
|
|
998
|
+
i++;
|
|
999
|
+
}
|
|
1000
|
+
if (content[i] === ',') {
|
|
1001
|
+
i++; // Skip the comma after the arrow function
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
else {
|
|
1005
|
+
// Single expression arrow function - skip to next comma or newline
|
|
1006
|
+
let j = afterArrow;
|
|
1007
|
+
while (j < content.length &&
|
|
1008
|
+
content[j] !== ',' &&
|
|
1009
|
+
content[j] !== '\n') {
|
|
1010
|
+
j++;
|
|
1011
|
+
}
|
|
1012
|
+
i = j;
|
|
1013
|
+
if (content[i] === ',')
|
|
1014
|
+
i++; // Skip the comma
|
|
1015
|
+
}
|
|
1016
|
+
continue;
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
// Not a bare arrow function, keep this character
|
|
1020
|
+
result.push(content[i]);
|
|
1021
|
+
i++;
|
|
1022
|
+
}
|
|
1023
|
+
return result.join('');
|
|
1024
|
+
};
|
|
1025
|
+
// Filter out bare object blocks (e.g., "{ ...spread, props }," without a property name)
|
|
1026
|
+
// These are invalid in object literal context - you need "key: { ... }" not just "{ ... }"
|
|
1027
|
+
// Defined here so it's accessible in both needsWrapper branches
|
|
1028
|
+
// The skipFirstBrace parameter allows the else branch to preserve the outer object
|
|
1029
|
+
const filterOutBareObjects = (content, skipFirstBrace = false) => {
|
|
1030
|
+
const result = [];
|
|
1031
|
+
let i = 0;
|
|
1032
|
+
let firstBraceSkipped = false;
|
|
1033
|
+
while (i < content.length) {
|
|
1034
|
+
// Skip over string literals entirely - braces inside strings should not be processed
|
|
1035
|
+
const stringEnd = skipStringLiteral(content, i);
|
|
1036
|
+
if (stringEnd !== -1) {
|
|
1037
|
+
result.push(content.slice(i, stringEnd));
|
|
1038
|
+
i = stringEnd;
|
|
1039
|
+
continue;
|
|
1040
|
+
}
|
|
1041
|
+
// Check if we're at a bare object start (newline/comma followed by { without : before it)
|
|
1042
|
+
// Look back to see if there's a colon (property assignment) before this brace
|
|
1043
|
+
const isStartOfLine = i === 0 ||
|
|
1044
|
+
content[i - 1] === '\n' ||
|
|
1045
|
+
content.slice(0, i).trim().endsWith(',');
|
|
1046
|
+
if (content[i] === '{' && isStartOfLine) {
|
|
1047
|
+
// Check if this is actually a bare object (not "key: {")
|
|
1048
|
+
const beforeTrimmed = content.slice(0, i).trim();
|
|
1049
|
+
const isBareObject = beforeTrimmed.endsWith(',') ||
|
|
1050
|
+
beforeTrimmed === '' ||
|
|
1051
|
+
beforeTrimmed.endsWith('(');
|
|
1052
|
+
if (isBareObject) {
|
|
1053
|
+
// If skipFirstBrace is true and this is the first bare brace at position 0,
|
|
1054
|
+
// don't filter it - it's the intentional outer object wrapper
|
|
1055
|
+
if (skipFirstBrace && !firstBraceSkipped && i === 0) {
|
|
1056
|
+
firstBraceSkipped = true;
|
|
1057
|
+
result.push(content[i]);
|
|
1058
|
+
i++;
|
|
1059
|
+
continue;
|
|
1060
|
+
}
|
|
1061
|
+
// Find matching closing brace, respecting string literals
|
|
1062
|
+
let braceCount = 1;
|
|
1063
|
+
let j = i + 1;
|
|
1064
|
+
while (j < content.length && braceCount > 0) {
|
|
1065
|
+
const strEnd = skipStringLiteral(content, j);
|
|
1066
|
+
if (strEnd !== -1) {
|
|
1067
|
+
j = strEnd;
|
|
1068
|
+
continue;
|
|
1069
|
+
}
|
|
1070
|
+
if (content[j] === '{')
|
|
1071
|
+
braceCount++;
|
|
1072
|
+
if (content[j] === '}')
|
|
1073
|
+
braceCount--;
|
|
1074
|
+
j++;
|
|
1075
|
+
}
|
|
1076
|
+
// Skip past the object
|
|
1077
|
+
i = j;
|
|
1078
|
+
// Skip trailing comma
|
|
1079
|
+
while (i < content.length && content[i] === ' ') {
|
|
1080
|
+
i++;
|
|
1081
|
+
}
|
|
1082
|
+
if (content[i] === ',') {
|
|
1083
|
+
i++;
|
|
1084
|
+
}
|
|
1085
|
+
continue;
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
result.push(content[i]);
|
|
1089
|
+
i++;
|
|
1090
|
+
}
|
|
1091
|
+
return result.join('');
|
|
1092
|
+
};
|
|
1093
|
+
// Helper to clean up formatting issues after filtering
|
|
1094
|
+
const cleanupContent = (content) => {
|
|
1095
|
+
return (content
|
|
1096
|
+
.replace(/,\s*,/g, ',') // Double commas
|
|
1097
|
+
.replace(/,(\s*\n\s*\})/g, '$1') // Trailing comma before closing brace
|
|
1098
|
+
.replace(/\{\s*\n\s*,/g, '{\n') // Leading comma after opening brace
|
|
1099
|
+
// Remove incomplete .map calls where callback was filtered out
|
|
1100
|
+
// Pattern: ".map" followed by newline/whitespace without "(" for args
|
|
1101
|
+
.replace(/\?\.map(?=\s*[\n\r,}\]])/g, '')
|
|
1102
|
+
.replace(/\.map(?=\s*[\n\r,}\]])/g, '')
|
|
1103
|
+
// Clean up orphan })) sequences (from nested filtered map callbacks)
|
|
1104
|
+
.replace(/\s*\}\)\)\s*\n\s*\}/g, '\n}')
|
|
1105
|
+
.replace(/^\s*\n/gm, '') // Empty lines
|
|
1106
|
+
.trim());
|
|
1107
|
+
};
|
|
523
1108
|
if (needsWrapper) {
|
|
524
|
-
|
|
1109
|
+
// Apply filters to remove invalid content
|
|
1110
|
+
mappedContents = filterOutArrowFunctions(mappedContents);
|
|
1111
|
+
mappedContents = filterOutBareObjects(mappedContents);
|
|
1112
|
+
mappedContents = cleanupContent(mappedContents);
|
|
1113
|
+
// If mappedContents is empty after filtering, don't generate .map() at all
|
|
1114
|
+
// Just use the array path directly with spread or as-is
|
|
1115
|
+
// This prevents orphan )) from empty .map() callbacks
|
|
1116
|
+
const cleanedForEmptyCheck = mappedContents
|
|
1117
|
+
.replace(/\s+/g, '')
|
|
1118
|
+
.replace(/,+/g, '');
|
|
1119
|
+
if (cleanedForEmptyCheck.length === 0) {
|
|
1120
|
+
// Content is empty - just return the array directly
|
|
1121
|
+
returnValueContents = arrayBasePath;
|
|
1122
|
+
}
|
|
1123
|
+
else {
|
|
1124
|
+
// Check if mappedContents is just a bare expression (no property names)
|
|
1125
|
+
// A bare expression like "scenarios().data()?.["key"]?.[__idx__]," cannot be
|
|
1126
|
+
// wrapped in ({ }) because it's not a valid object property.
|
|
1127
|
+
// Pattern: content has no ":" that's not inside brackets/parens/strings
|
|
1128
|
+
const hasBareExpression = (() => {
|
|
1129
|
+
const trimmed = mappedContents.trim().replace(/,\s*$/, ''); // Remove trailing comma
|
|
1130
|
+
let depth = 0;
|
|
1131
|
+
let inString = false;
|
|
1132
|
+
let stringChar = '';
|
|
1133
|
+
for (let i = 0; i < trimmed.length; i++) {
|
|
1134
|
+
const char = trimmed[i];
|
|
1135
|
+
if (inString) {
|
|
1136
|
+
if (char === '\\') {
|
|
1137
|
+
i++; // Skip escaped char
|
|
1138
|
+
continue;
|
|
1139
|
+
}
|
|
1140
|
+
if (char === stringChar) {
|
|
1141
|
+
inString = false;
|
|
1142
|
+
}
|
|
1143
|
+
continue;
|
|
1144
|
+
}
|
|
1145
|
+
if (char === '"' || char === "'" || char === '`') {
|
|
1146
|
+
inString = true;
|
|
1147
|
+
stringChar = char;
|
|
1148
|
+
continue;
|
|
1149
|
+
}
|
|
1150
|
+
if (char === '(' || char === '[' || char === '{') {
|
|
1151
|
+
depth++;
|
|
1152
|
+
continue;
|
|
1153
|
+
}
|
|
1154
|
+
if (char === ')' || char === ']' || char === '}') {
|
|
1155
|
+
depth--;
|
|
1156
|
+
continue;
|
|
1157
|
+
}
|
|
1158
|
+
// Found a colon at depth 0 = has property name
|
|
1159
|
+
if (char === ':' && depth === 0) {
|
|
1160
|
+
return false;
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
return true;
|
|
1164
|
+
})();
|
|
1165
|
+
if (hasBareExpression) {
|
|
1166
|
+
// Content is just an expression - return it directly without object wrapper
|
|
1167
|
+
const trimmedContent = mappedContents
|
|
1168
|
+
.trim()
|
|
1169
|
+
.replace(/,\s*$/, '');
|
|
1170
|
+
returnValueContents = `${arrayBasePath}?.map((__item__, __idx__) => (\n${indent(trimmedContent)}\n))`;
|
|
1171
|
+
}
|
|
1172
|
+
else {
|
|
1173
|
+
// When generating object-wrapped .map(), ensure original item data is preserved.
|
|
1174
|
+
// If no data spread was included (e.g., because this is a plain array property,
|
|
1175
|
+
// not a function return), add ...__item__ to spread the original item properties.
|
|
1176
|
+
// Without this, the .map() would create new objects with only nested function
|
|
1177
|
+
// properties, losing data like filePath, frontmatter, body, etc.
|
|
1178
|
+
const hasDataSpread = mappedContents.includes('...scenarios()') ||
|
|
1179
|
+
mappedContents.includes('...__item__');
|
|
1180
|
+
if (!hasDataSpread) {
|
|
1181
|
+
mappedContents = `...__item__,\n${mappedContents}`;
|
|
1182
|
+
}
|
|
1183
|
+
returnValueContents = `${arrayBasePath}?.map((__item__, __idx__) => ({\n${indent(mappedContents)}\n}))`;
|
|
1184
|
+
}
|
|
1185
|
+
} // Close the empty content check else block
|
|
525
1186
|
}
|
|
526
1187
|
else {
|
|
1188
|
+
// Content already starts with '{'. Check if there are additional properties after the inner object.
|
|
1189
|
+
// If so, we need to merge them INTO the object, not leave them outside.
|
|
1190
|
+
// Pattern: "{ ...spread, props },\nfilter: ...,\nsort: ..."
|
|
1191
|
+
// Should become: "{ ...spread, props, filter: ..., sort: ... }"
|
|
1192
|
+
const trimmed = mappedContents.trim();
|
|
1193
|
+
// Find first }, at depth 0 that is NOT inside a string literal
|
|
1194
|
+
// This prevents splitting keys like ?.["useQuery({ id }, { enabled })"]
|
|
1195
|
+
// and also prevents finding }, inside nested arrow functions
|
|
1196
|
+
const findBraceCommaOutsideStrings = (content) => {
|
|
1197
|
+
let i = 0;
|
|
1198
|
+
let depth = 0; // Track brace depth to find the outer object's },
|
|
1199
|
+
while (i < content.length - 1) {
|
|
1200
|
+
// Skip over string literals
|
|
1201
|
+
const strEnd = skipStringLiteral(content, i);
|
|
1202
|
+
if (strEnd !== -1) {
|
|
1203
|
+
i = strEnd;
|
|
1204
|
+
continue;
|
|
1205
|
+
}
|
|
1206
|
+
// Track brace depth
|
|
1207
|
+
if (content[i] === '{') {
|
|
1208
|
+
depth++;
|
|
1209
|
+
i++;
|
|
1210
|
+
continue;
|
|
1211
|
+
}
|
|
1212
|
+
// Check for }, pattern at depth 1 (the outer object level)
|
|
1213
|
+
// We're looking for the outer object's closing brace, which is at depth 1
|
|
1214
|
+
// (we started at depth 0, opened { at depth 0 -> 1)
|
|
1215
|
+
if (content[i] === '}') {
|
|
1216
|
+
depth--;
|
|
1217
|
+
if (depth === 0 &&
|
|
1218
|
+
i + 1 < content.length &&
|
|
1219
|
+
content[i + 1] === ',') {
|
|
1220
|
+
return i;
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
i++;
|
|
1224
|
+
}
|
|
1225
|
+
return -1;
|
|
1226
|
+
};
|
|
1227
|
+
const firstBraceEnd = findBraceCommaOutsideStrings(trimmed);
|
|
1228
|
+
if (firstBraceEnd !== -1) {
|
|
1229
|
+
// Found pattern "{ ... }," followed by more content
|
|
1230
|
+
// Extract the inner object and the trailing properties
|
|
1231
|
+
const innerObject = trimmed.slice(0, firstBraceEnd);
|
|
1232
|
+
const trailingContent = trimmed.slice(firstBraceEnd + 2).trim();
|
|
1233
|
+
if (trailingContent) {
|
|
1234
|
+
// Merge trailing properties into the inner object
|
|
1235
|
+
mappedContents = `${innerObject},\n${trailingContent}\n}`;
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
// Even when content starts with {, we need to filter out invalid properties inside
|
|
1239
|
+
// (arrow functions and bare objects that were generated from the schema)
|
|
1240
|
+
// Pass skipFirstBrace=true because the content's outer { is the intentional wrapper
|
|
1241
|
+
mappedContents = filterOutArrowFunctions(mappedContents);
|
|
1242
|
+
mappedContents = filterOutBareObjects(mappedContents, true);
|
|
1243
|
+
mappedContents = cleanupContent(mappedContents);
|
|
1244
|
+
// Same as needsWrapper branch: ensure item data is preserved in .map()
|
|
1245
|
+
const hasDataSpreadInner = mappedContents.includes('...scenarios()') ||
|
|
1246
|
+
mappedContents.includes('...__item__');
|
|
1247
|
+
if (!hasDataSpreadInner && mappedContents.trim().length > 0) {
|
|
1248
|
+
// Insert ...__item__ after the opening brace
|
|
1249
|
+
mappedContents = mappedContents.replace(/^\s*\{/, '{\n...__item__,');
|
|
1250
|
+
}
|
|
527
1251
|
returnValueContents = `${arrayBasePath}?.map((__item__, __idx__) => (\n${indent(mappedContents)}\n))`;
|
|
528
1252
|
}
|
|
529
1253
|
}
|
|
@@ -532,7 +1256,36 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
532
1256
|
}
|
|
533
1257
|
}
|
|
534
1258
|
else {
|
|
535
|
-
|
|
1259
|
+
// When we have a single data path and nested content that creates an object structure,
|
|
1260
|
+
// and we're NOT at the root level, we need to handle the case where the parent data
|
|
1261
|
+
// value is null or undefined. Without this check, `{ ...null, prop: null?.["prop"] }`
|
|
1262
|
+
// creates `{ prop: undefined }` instead of `null`, causing errors like
|
|
1263
|
+
// "Cannot read properties of undefined (reading 'some')" when code does
|
|
1264
|
+
// data?.prop.some(...) because data is an object with prop: undefined, not null.
|
|
1265
|
+
// We only apply this to non-root cases because root-level mocks are expected to exist.
|
|
1266
|
+
// We also skip structural elements (like [0] inside arrays) because the null check
|
|
1267
|
+
// syntax doesn't work inside .map() callbacks where structural elements are used.
|
|
1268
|
+
// We also skip array index elements ([0], [1], etc.) because they represent tuple/array
|
|
1269
|
+
// elements, not properties that could be null.
|
|
1270
|
+
// We also only apply this when we're inside a function return value context - i.e.,
|
|
1271
|
+
// when the data path contains a function call pattern like ?.["someFunction(...)"].
|
|
1272
|
+
// This prevents adding null checks to intermediate objects in chains like supabase.auth.
|
|
1273
|
+
const hasNestedContent = nestedContent.filter(Boolean).length > 0;
|
|
1274
|
+
const isArrayIndexElement = name.match(/^\[\d*\]$/);
|
|
1275
|
+
// Check if data path contains a function call pattern, indicating we're inside a function return value
|
|
1276
|
+
const isInsideFunctionReturnValue = dataPaths.length === 1 &&
|
|
1277
|
+
dataPaths[0].match(/\?\.\["\w+\([^"]*\)"\]/);
|
|
1278
|
+
if (!root &&
|
|
1279
|
+
!returnValue.isStructural &&
|
|
1280
|
+
!isArrayIndexElement &&
|
|
1281
|
+
isInsideFunctionReturnValue &&
|
|
1282
|
+
hasNestedContent) {
|
|
1283
|
+
// Wrap with null check: if parent is null/undefined, return it directly; otherwise create object
|
|
1284
|
+
returnValueContents = `${dataPaths[0]} == null ? ${dataPaths[0]} : {\n${indent(levelContents)}\n}`;
|
|
1285
|
+
}
|
|
1286
|
+
else {
|
|
1287
|
+
returnValueContents = `{\n${indent(levelContents)}\n}`;
|
|
1288
|
+
}
|
|
536
1289
|
}
|
|
537
1290
|
}
|
|
538
1291
|
if (root) {
|
|
@@ -608,7 +1361,18 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
608
1361
|
}
|
|
609
1362
|
else {
|
|
610
1363
|
// No argument variants - use existing behavior
|
|
611
|
-
|
|
1364
|
+
// But if there's nested content, we need to include it in the return object
|
|
1365
|
+
// (similar to how argument variant branches handle this at line 1070-1072)
|
|
1366
|
+
const hasNestedContent = validNestedContent.length > 0;
|
|
1367
|
+
let funcReturnContents;
|
|
1368
|
+
if (hasNestedContent && levelContentItems.length > 1) {
|
|
1369
|
+
// Include both spread and nested content in the return
|
|
1370
|
+
funcReturnContents = `{\n${indent(levelContents)}\n}`;
|
|
1371
|
+
}
|
|
1372
|
+
else {
|
|
1373
|
+
funcReturnContents = returnValueContents;
|
|
1374
|
+
}
|
|
1375
|
+
const funcContents = `return ${funcReturnContents}`;
|
|
612
1376
|
content = `${cleanOutTypes(name)}: ${isAsyncFunction ? 'async ' : ''}(${argsString}) => {\n${indent(funcContents)}\n}`;
|
|
613
1377
|
}
|
|
614
1378
|
}
|
|
@@ -617,8 +1381,14 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
617
1381
|
return;
|
|
618
1382
|
}
|
|
619
1383
|
else if (name.match(/\[\d*\]/)) {
|
|
1384
|
+
// Numeric array index like [0], [1] - can be used as computed property
|
|
620
1385
|
content = returnValueContents;
|
|
621
1386
|
}
|
|
1387
|
+
else if (name.match(/^\[[a-zA-Z_]\w*\]$/)) {
|
|
1388
|
+
// Variable-based index like [currentItemIndex] - must be quoted string key
|
|
1389
|
+
// Otherwise JavaScript would try to evaluate the variable name
|
|
1390
|
+
content = `"${safeString(name)}": ${returnValueContents}`;
|
|
1391
|
+
}
|
|
622
1392
|
else {
|
|
623
1393
|
content = `${safeString(name)}: ${returnValueContents}`;
|
|
624
1394
|
}
|
|
@@ -630,7 +1400,31 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
630
1400
|
return content;
|
|
631
1401
|
};
|
|
632
1402
|
// Create the return value structure
|
|
633
|
-
|
|
1403
|
+
// OPTIMIZATION: Filter keys to only those starting with baseMockName before sorting.
|
|
1404
|
+
// This dramatically reduces processing time for large schemas (e.g., 9216 keys -> ~100 relevant keys).
|
|
1405
|
+
// Without this filter, the loop would call splitOutsideParenthesesAndArrays on every key
|
|
1406
|
+
// even though most are filtered out later by the baseMockName check.
|
|
1407
|
+
const allSchemaKeys = Object.keys(relevantReturnValueSchema ?? {});
|
|
1408
|
+
const relevantKeys = allSchemaKeys.filter((key) => {
|
|
1409
|
+
// Fast prefix check - key must start with baseMockName followed by ( or < or .
|
|
1410
|
+
// This matches: "useAtom()", "useAtom<T>()", "useAtom.something", but not "useAtomValue()"
|
|
1411
|
+
if (key === baseMockName)
|
|
1412
|
+
return true;
|
|
1413
|
+
if (key.startsWith(baseMockName + '('))
|
|
1414
|
+
return true;
|
|
1415
|
+
if (key.startsWith(baseMockName + '<'))
|
|
1416
|
+
return true;
|
|
1417
|
+
if (key.startsWith(baseMockName + '.'))
|
|
1418
|
+
return true;
|
|
1419
|
+
// Also include 'returnValue' paths which are normalized later
|
|
1420
|
+
if (key === 'returnValue' ||
|
|
1421
|
+
key.startsWith('returnValue.') ||
|
|
1422
|
+
key.startsWith('returnValue['))
|
|
1423
|
+
return true;
|
|
1424
|
+
return false;
|
|
1425
|
+
});
|
|
1426
|
+
const schemaKeyCount = relevantKeys.length;
|
|
1427
|
+
const sortedKeys = relevantKeys.sort((a, b) => {
|
|
634
1428
|
const aParts = splitOutsideParenthesesAndArrays(a);
|
|
635
1429
|
const bParts = splitOutsideParenthesesAndArrays(b);
|
|
636
1430
|
const maxLength = Math.max(aParts.length, bParts.length);
|
|
@@ -654,6 +1448,36 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
654
1448
|
}
|
|
655
1449
|
return 0;
|
|
656
1450
|
});
|
|
1451
|
+
// OPTIMIZATION: Pre-compute prefix indexes for O(1) lookups instead of O(n) scans.
|
|
1452
|
+
// This reduces complexity from O(n²) to O(n) for large schemas (9k+ keys).
|
|
1453
|
+
//
|
|
1454
|
+
// 1. extendedReturnValuePrefixes: Set of all path prefixes that have a .functionCallReturnValue extension
|
|
1455
|
+
// Used by hasExtendedFunctionCallReturnValue check at line ~1754
|
|
1456
|
+
// 2. functionCallsWithReturnValue: Set of function call paths where .functionCallReturnValue IMMEDIATELY follows
|
|
1457
|
+
// Used by hasProperFunctionCallPath check at line ~1787
|
|
1458
|
+
// IMPORTANT: Only includes paths where the function call is directly followed by .functionCallReturnValue
|
|
1459
|
+
// e.g., "a.b().functionCallReturnValue" -> adds "a.b()" but NOT "a" even if "a" ends with ")"
|
|
1460
|
+
const extendedReturnValuePrefixes = new Set();
|
|
1461
|
+
const functionCallsWithReturnValue = new Set();
|
|
1462
|
+
for (const k of relevantKeys) {
|
|
1463
|
+
const parts = splitOutsideParenthesesAndArrays(k);
|
|
1464
|
+
const returnValueIndex = parts.findIndex((part) => part.startsWith(RETURN_VALUE));
|
|
1465
|
+
if (returnValueIndex !== -1) {
|
|
1466
|
+
// Add all prefixes of k up to (but not including) functionCallReturnValue
|
|
1467
|
+
const prefix = joinParenthesesAndArrays(parts.slice(0, returnValueIndex));
|
|
1468
|
+
extendedReturnValuePrefixes.add(prefix);
|
|
1469
|
+
// ONLY add to functionCallsWithReturnValue if functionCallReturnValue IMMEDIATELY follows
|
|
1470
|
+
if (prefix.endsWith(')')) {
|
|
1471
|
+
functionCallsWithReturnValue.add(prefix);
|
|
1472
|
+
}
|
|
1473
|
+
// Also add intermediate prefixes for nested paths to extendedReturnValuePrefixes
|
|
1474
|
+
// This helps hasExtendedFunctionCallReturnValue which checks key + '.'
|
|
1475
|
+
for (let i = 1; i < returnValueIndex; i++) {
|
|
1476
|
+
const partialPrefix = joinParenthesesAndArrays(parts.slice(0, i));
|
|
1477
|
+
extendedReturnValuePrefixes.add(partialPrefix);
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
657
1481
|
for (const key of sortedKeys) {
|
|
658
1482
|
const value = relevantReturnValueSchema[key];
|
|
659
1483
|
const parts = splitOutsideParenthesesAndArrays(key);
|
|
@@ -681,8 +1505,8 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
681
1505
|
parts.splice(i, 1);
|
|
682
1506
|
}
|
|
683
1507
|
}
|
|
684
|
-
//
|
|
685
|
-
//
|
|
1508
|
+
// Compare against baseMockName (without generics/args), not the full mockName
|
|
1509
|
+
// e.g., for "useFetcher<User>()", baseMockName is "useFetcher"
|
|
686
1510
|
if (parts[0].split('(')[0] !== baseMockName)
|
|
687
1511
|
continue;
|
|
688
1512
|
// Include paths with functionCallReturnValue OR function-typed paths that need mocking
|
|
@@ -699,7 +1523,9 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
699
1523
|
// nested inside (e.g., methods on array elements passed as arguments).
|
|
700
1524
|
if (hasSignaturePath)
|
|
701
1525
|
continue;
|
|
702
|
-
|
|
1526
|
+
// OPTIMIZATION: Use pre-computed index instead of O(n) scan
|
|
1527
|
+
// Old code: Object.keys(relevantReturnValueSchema).some((k) => k.startsWith(key + '.') && k.includes('.functionCallReturnValue'))
|
|
1528
|
+
const hasExtendedFunctionCallReturnValue = extendedReturnValuePrefixes.has(key);
|
|
703
1529
|
// Skip JSX components - they look like function calls (e.g., Context.Provider())
|
|
704
1530
|
// but they're React components used in JSX, not functions that need mocking
|
|
705
1531
|
// Check both the value type and whether the functionCallReturnValue is jsx-component
|
|
@@ -724,7 +1550,9 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
724
1550
|
// This part is a function call, and the next part is NOT .functionCallReturnValue
|
|
725
1551
|
// Check if there's any path with .functionCallReturnValue for this function call
|
|
726
1552
|
const functionCallPath = joinParenthesesAndArrays(parts.slice(0, i + 1));
|
|
727
|
-
|
|
1553
|
+
// OPTIMIZATION: Use pre-computed index instead of O(n) scan
|
|
1554
|
+
// Old code: Object.keys(relevantReturnValueSchema).some((k) => k.startsWith(functionCallPath + '.functionCallReturnValue'))
|
|
1555
|
+
const hasProperFunctionCallPath = functionCallsWithReturnValue.has(functionCallPath);
|
|
728
1556
|
if (hasProperFunctionCallPath) {
|
|
729
1557
|
// Skip this path - the .functionCallReturnValue path will handle it correctly
|
|
730
1558
|
shouldSkipKey = true;
|
|
@@ -778,6 +1606,16 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
778
1606
|
const nextIsArray = !!nextPart?.match(/^\[\d*\]/);
|
|
779
1607
|
const isDifferentiatedArray = !!part?.match(/^\[\d+\]/);
|
|
780
1608
|
const nextIsDifferentiatedArray = !!nextPart?.match(/^\[\d+\]/);
|
|
1609
|
+
// Variable index patterns like [currentItemIndex] or [targetIndex] indicate array access
|
|
1610
|
+
// but don't represent actual data structure - they're markers from variable-based index tracking.
|
|
1611
|
+
// Skip them AND all remaining parts to avoid creating spurious nested structure that breaks array iteration.
|
|
1612
|
+
// The remaining parts (e.g., .missing_attributes) describe properties of array elements, which are
|
|
1613
|
+
// already handled by the generic [] accessor path.
|
|
1614
|
+
const isVariableIndex = !!part?.match(/^\[[a-zA-Z_]\w*\]$/);
|
|
1615
|
+
if (isVariableIndex) {
|
|
1616
|
+
// Break out of the loop entirely - don't process any remaining parts
|
|
1617
|
+
break;
|
|
1618
|
+
}
|
|
781
1619
|
// Find the correct value for the current part being processed
|
|
782
1620
|
let partValue = value; // default to the final value
|
|
783
1621
|
if (isFunctionCallReturnValue(part) && nextIsArray) {
|
|
@@ -869,7 +1707,35 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
869
1707
|
}
|
|
870
1708
|
}
|
|
871
1709
|
else {
|
|
872
|
-
|
|
1710
|
+
// Before setting returnsFunctionArgs on the parent (for generic [] = function),
|
|
1711
|
+
// check if there are specific array indices (like [0], [1]) that are NOT functions.
|
|
1712
|
+
// If so, don't set returnsFunctionArgs because those specific indices take precedence.
|
|
1713
|
+
// This prevents adding ["()"] to paths like [0] when [0] is 'unknown' but [] is 'function'.
|
|
1714
|
+
//
|
|
1715
|
+
// Use parts.slice(0, i + 1) to get the current path INCLUDING functionCallReturnValue.
|
|
1716
|
+
// For example, if parts = ['useAtom()','functionCallReturnValue','[]']
|
|
1717
|
+
// and i = 1, we want to check 'useAtom().functionCallReturnValue[0]' etc.
|
|
1718
|
+
const arrayContainerPath = joinParenthesesAndArrays(parts.slice(0, i + 1));
|
|
1719
|
+
const hasNonFunctionSpecificIndices = Object.entries(relevantReturnValueSchema).some(([k, v]) => {
|
|
1720
|
+
// Look for paths like "arrayContainerPath[0]", "arrayContainerPath[1]" etc.
|
|
1721
|
+
const indexMatch = k.match(new RegExp(`^${arrayContainerPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\[(\\d+)\\]$`));
|
|
1722
|
+
// If found and it's NOT a function type, we have a conflict
|
|
1723
|
+
return (indexMatch &&
|
|
1724
|
+
!['function', 'async-function'].includes(v));
|
|
1725
|
+
});
|
|
1726
|
+
// Also check if [] has nested object properties (like [].filter, [].name)
|
|
1727
|
+
// If so, [] items are objects with properties, not pure functions to be called
|
|
1728
|
+
// This handles cases where the schema shows [].filter = object but doesn't
|
|
1729
|
+
// have explicit [0] entries
|
|
1730
|
+
const genericArrayPath = `${arrayContainerPath}[]`;
|
|
1731
|
+
const hasNestedProperties = Object.keys(relevantReturnValueSchema).some((k) => {
|
|
1732
|
+
// Check for paths like "arrayContainerPath[].propertyName" (not [].())
|
|
1733
|
+
return (k.startsWith(genericArrayPath + '.') &&
|
|
1734
|
+
!k.startsWith(genericArrayPath + '.('));
|
|
1735
|
+
});
|
|
1736
|
+
if (!hasNonFunctionSpecificIndices && !hasNestedProperties) {
|
|
1737
|
+
returnValueSection.returnsFunctionArgs = [];
|
|
1738
|
+
}
|
|
873
1739
|
}
|
|
874
1740
|
}
|
|
875
1741
|
}
|
|
@@ -890,7 +1756,8 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
890
1756
|
}
|
|
891
1757
|
// If the next part is an object with nested content, continue processing
|
|
892
1758
|
// This handles paths like functionCallReturnValue.selectedOptions.elementOptions[]
|
|
893
|
-
|
|
1759
|
+
// Also handles union types like 'array | undefined' or 'object | undefined'
|
|
1760
|
+
if (nextValue?.includes('object') || nextValue?.includes('array')) {
|
|
894
1761
|
continue;
|
|
895
1762
|
}
|
|
896
1763
|
}
|
|
@@ -1020,7 +1887,12 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
1020
1887
|
relevantPart.isArray = true;
|
|
1021
1888
|
relevantPart.isGenericArray = true;
|
|
1022
1889
|
}
|
|
1023
|
-
if
|
|
1890
|
+
// Check if there are remaining parts after functionCallReturnValue that need processing
|
|
1891
|
+
// (e.g., data properties like useQuery().functionCallReturnValue.data)
|
|
1892
|
+
const hasRemainingPartsAfterReturnValue = nextPart &&
|
|
1893
|
+
(isFunctionCallReturnValue(nextPart) ||
|
|
1894
|
+
(isFunctionCallReturnValue(parts[i]) && i < parts.length - 1));
|
|
1895
|
+
if (!hasNestedFunction && !hasRemainingPartsAfterReturnValue) {
|
|
1024
1896
|
// Before breaking, check if this function returns an array
|
|
1025
1897
|
// by looking for a functionCallReturnValue: 'array' entry in the schema
|
|
1026
1898
|
if (relevantPart && part.endsWith(')')) {
|
|
@@ -1048,6 +1920,7 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
1048
1920
|
const contents = constructReturnValueString(returnValueParts);
|
|
1049
1921
|
if (mockNameParts.length > 1) {
|
|
1050
1922
|
const originalLib = `${mockNameParts[0]}__cyOriginal`;
|
|
1923
|
+
const skipOriginalSpread = options?.skipOriginalSpread;
|
|
1051
1924
|
const subPart = (parts, originalLib) => {
|
|
1052
1925
|
const part = parts.shift();
|
|
1053
1926
|
if (!isValidKey(part))
|
|
@@ -1055,7 +1928,9 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
1055
1928
|
const isLast = parts.length === 0;
|
|
1056
1929
|
const partContents = isLast
|
|
1057
1930
|
? contents
|
|
1058
|
-
:
|
|
1931
|
+
: skipOriginalSpread
|
|
1932
|
+
? subPart(parts, originalLib)
|
|
1933
|
+
: `...${originalLib}.${part},\n${subPart(parts, originalLib)}`;
|
|
1059
1934
|
let code = `${part}: {\n${indent(partContents)}\n}`;
|
|
1060
1935
|
if (part.includes('(') || (isFunction && isLast)) {
|
|
1061
1936
|
const args = funcArgs(part)
|
|
@@ -1065,28 +1940,30 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
1065
1940
|
}
|
|
1066
1941
|
return code;
|
|
1067
1942
|
};
|
|
1068
|
-
const returnParts =
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1943
|
+
const returnParts = skipOriginalSpread
|
|
1944
|
+
? [subPart(mockNameParts.slice(1), originalLib)]
|
|
1945
|
+
: [
|
|
1946
|
+
`...${mockNameParts[0]}__cyOriginal`,
|
|
1947
|
+
subPart(mockNameParts.slice(1), originalLib),
|
|
1948
|
+
];
|
|
1949
|
+
return `const ${mockNameParts[0]} = {\n${indent(returnParts.filter(Boolean).join(',\n'))}\n};`;
|
|
1073
1950
|
}
|
|
1074
1951
|
else if (isFunction) {
|
|
1075
1952
|
// For headers() and cookies() from next/headers, add common iterator methods
|
|
1076
1953
|
// These are needed when the mock is passed to functions that use .entries(), .keys(), etc.
|
|
1077
1954
|
// (e.g., Object.fromEntries(headers.entries()) in buildLegacyHeaders)
|
|
1078
|
-
const needsIteratorMethods =
|
|
1955
|
+
const needsIteratorMethods = baseMockName === 'headers' || baseMockName === 'cookies';
|
|
1079
1956
|
let enhancedContents = contents;
|
|
1080
1957
|
if (needsIteratorMethods && contents.trim().startsWith('{')) {
|
|
1081
1958
|
// Add iterator methods that operate on the scenario data
|
|
1082
|
-
// Use
|
|
1083
|
-
const
|
|
1959
|
+
// Use the dataKey (original call signature or canonical key)
|
|
1960
|
+
const quotedDataKey = quotePropertyKey(dataKey);
|
|
1084
1961
|
const iteratorMethods = `,
|
|
1085
|
-
entries: () => Object.entries(scenarios().data()
|
|
1086
|
-
keys: () => Object.keys(scenarios().data()
|
|
1087
|
-
values: () => Object.values(scenarios().data()
|
|
1088
|
-
forEach: (fn) => Object.entries(scenarios().data()
|
|
1089
|
-
has: (key) => Object.prototype.hasOwnProperty.call(scenarios().data()
|
|
1962
|
+
entries: () => Object.entries(scenarios().data()?.${quotedDataKey} || {}),
|
|
1963
|
+
keys: () => Object.keys(scenarios().data()?.${quotedDataKey} || {}),
|
|
1964
|
+
values: () => Object.values(scenarios().data()?.${quotedDataKey} || {}),
|
|
1965
|
+
forEach: (fn) => Object.entries(scenarios().data()?.${quotedDataKey} || {}).forEach(([k, v]) => fn(v, k)),
|
|
1966
|
+
has: (key) => Object.prototype.hasOwnProperty.call(scenarios().data()?.${quotedDataKey} || {}, key)`;
|
|
1090
1967
|
// Insert before the closing brace (handle trailing whitespace)
|
|
1091
1968
|
enhancedContents = contents.replace(/\}\s*$/, iteratorMethods + '\n}');
|
|
1092
1969
|
}
|
|
@@ -1096,29 +1973,43 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
1096
1973
|
// `new ClassName("arg")` wouldn't create the expected instance.
|
|
1097
1974
|
// For Error subclasses (detected by name ending in "Error"), extend Error for proper error handling.
|
|
1098
1975
|
if (entityType === 'class') {
|
|
1099
|
-
const isErrorSubclass =
|
|
1100
|
-
const baseClass = isErrorSubclass ? 'Error' : 'Object';
|
|
1976
|
+
const isErrorSubclass = baseMockName.endsWith('Error');
|
|
1101
1977
|
const superCall = isErrorSubclass ? 'super(message);' : '';
|
|
1102
1978
|
const nameAssignment = isErrorSubclass
|
|
1103
|
-
? `this.name = '${
|
|
1979
|
+
? `this.name = '${baseMockName}';`
|
|
1104
1980
|
: '';
|
|
1105
|
-
// Use
|
|
1106
|
-
const
|
|
1107
|
-
|
|
1981
|
+
// Use the safe function name for the class definition
|
|
1982
|
+
const className = mockNameIsCallSignature
|
|
1983
|
+
? derivedFunctionName
|
|
1984
|
+
: baseMockName;
|
|
1985
|
+
return `class ${className}${isErrorSubclass ? ' extends Error' : ''} {
|
|
1108
1986
|
constructor(message) {
|
|
1109
1987
|
${superCall}
|
|
1110
1988
|
${nameAssignment}
|
|
1111
|
-
Object.assign(this, scenarios().data()
|
|
1989
|
+
Object.assign(this, scenarios().data()?.${quotePropertyKey(dataKey)} || {});
|
|
1112
1990
|
}
|
|
1113
1991
|
}`;
|
|
1114
1992
|
}
|
|
1115
|
-
//
|
|
1116
|
-
//
|
|
1117
|
-
//
|
|
1118
|
-
//
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1993
|
+
// Generate safe function name:
|
|
1994
|
+
// 1. For call signatures: use derivedFunctionName
|
|
1995
|
+
// e.g., "useFetcher<User>()" becomes "useFetcher_User"
|
|
1996
|
+
// e.g., "db.select(usersQuery)" becomes "db_select_usersQuery"
|
|
1997
|
+
// 2. With uniqueFunctionSuffix option: append suffix for unique naming
|
|
1998
|
+
// e.g., baseMockName = "useFetcher", suffix = "entityDiffFetcher" -> "useFetcher_entityDiffFetcher"
|
|
1999
|
+
// 3. EXCEPTION: When keepOriginalFunctionName is true (for single-call cases), use the base name
|
|
2000
|
+
let safeFunctionName;
|
|
2001
|
+
if (options?.keepOriginalFunctionName) {
|
|
2002
|
+
safeFunctionName = baseMockName;
|
|
2003
|
+
}
|
|
2004
|
+
else if (options?.uniqueFunctionSuffix) {
|
|
2005
|
+
safeFunctionName = `${baseMockName}_${options.uniqueFunctionSuffix}`;
|
|
2006
|
+
}
|
|
2007
|
+
else if (mockNameIsCallSignature && derivedFunctionName) {
|
|
2008
|
+
safeFunctionName = derivedFunctionName;
|
|
2009
|
+
}
|
|
2010
|
+
else {
|
|
2011
|
+
safeFunctionName = baseMockName;
|
|
2012
|
+
}
|
|
1122
2013
|
// Check if this function returns a function (detected by double-call pattern: mockName(args)())
|
|
1123
2014
|
// This happens when the schema has keys like "wrapThrows(() => JSON.parse(savedFilters))()"
|
|
1124
2015
|
// where the function call is immediately followed by another call.
|
|
@@ -1154,20 +2045,57 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
1154
2045
|
return true;
|
|
1155
2046
|
return false;
|
|
1156
2047
|
});
|
|
2048
|
+
// Use ...args to accept any number of arguments - prevents TypeScript errors
|
|
2049
|
+
// like "Expected 0 arguments, but got X" when caller passes arguments
|
|
1157
2050
|
// For higher-order functions, wrap the return in an arrow function
|
|
1158
2051
|
// so that mockFunc(arg)() works correctly (outer call returns a function, inner call gets the data)
|
|
1159
2052
|
const returnValue = isHigherOrderFunction
|
|
1160
|
-
? `() => ${
|
|
1161
|
-
:
|
|
1162
|
-
|
|
2053
|
+
? `() => (${enhancedContents})`
|
|
2054
|
+
: enhancedContents;
|
|
2055
|
+
// Inline the return value directly in the function to avoid module-level const
|
|
2056
|
+
// that would be evaluated before scenario context is ready
|
|
2057
|
+
// Add fallback for simple data path returns to prevent undefined errors (e.g., createTheme)
|
|
2058
|
+
// Only add fallback if returnValue is a simple data accessor (starts with scenarios().data())
|
|
2059
|
+
// and doesn't already have nested structure (object literal, array, or method chains like .map())
|
|
2060
|
+
const isSimpleDataPath = returnValue.startsWith('scenarios().data()') &&
|
|
2061
|
+
!returnValue.trim().startsWith('{') &&
|
|
2062
|
+
!returnValue.trim().startsWith('[') &&
|
|
2063
|
+
!returnValue.includes('.map('); // Exclude method chains
|
|
2064
|
+
const safeReturnValue = isSimpleDataPath
|
|
2065
|
+
? `${returnValue} ?? {}`
|
|
2066
|
+
: returnValue;
|
|
2067
|
+
const refName = `_${safeFunctionName}Ref`;
|
|
2068
|
+
const assignment = `${refName}.current = ${safeReturnValue};`;
|
|
2069
|
+
const ifBlock = `if (!${refName}.current) {\n${indent(assignment)}\n}`;
|
|
2070
|
+
const body = `${ifBlock}\nreturn ${refName}.current;`;
|
|
2071
|
+
return [
|
|
2072
|
+
`// PATCHED: memoize to return stable reference (prevents infinite useEffect re-triggers)`,
|
|
2073
|
+
`const ${refName} = {`,
|
|
2074
|
+
` current: null,`,
|
|
2075
|
+
`};`,
|
|
2076
|
+
`${isRootAsyncFunction ? 'async ' : ''}function ${safeFunctionName}(...args) {`,
|
|
2077
|
+
indent(body),
|
|
2078
|
+
`}`,
|
|
2079
|
+
].join('\n');
|
|
1163
2080
|
}
|
|
1164
2081
|
else {
|
|
1165
|
-
//
|
|
1166
|
-
//
|
|
1167
|
-
//
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
2082
|
+
// Generate safe const name:
|
|
2083
|
+
// 1. For call signatures: use derivedFunctionName
|
|
2084
|
+
// 2. With uniqueFunctionSuffix option: append suffix for unique naming
|
|
2085
|
+
// 3. EXCEPTION: When keepOriginalFunctionName is true (for single-call cases), use the base name
|
|
2086
|
+
let safeName;
|
|
2087
|
+
if (options?.keepOriginalFunctionName) {
|
|
2088
|
+
safeName = baseMockName;
|
|
2089
|
+
}
|
|
2090
|
+
else if (options?.uniqueFunctionSuffix) {
|
|
2091
|
+
safeName = `${baseMockName}_${options.uniqueFunctionSuffix}`;
|
|
2092
|
+
}
|
|
2093
|
+
else if (mockNameIsCallSignature && derivedFunctionName) {
|
|
2094
|
+
safeName = derivedFunctionName;
|
|
2095
|
+
}
|
|
2096
|
+
else {
|
|
2097
|
+
safeName = baseMockName;
|
|
2098
|
+
}
|
|
1171
2099
|
// Get any jsx-component properties that need to be preserved from the original
|
|
1172
2100
|
const jsxProperties = getJsxComponentProperties(mockName, relevantReturnValueSchema);
|
|
1173
2101
|
// If there are jsx-component properties, add them as references to the original
|