@codeyam/codeyam-cli 0.1.0-staging.e38f7bd → 0.1.0-staging.eb21b2f
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 +21 -17
- package/analyzer-template/packages/ai/index.ts +21 -5
- package/analyzer-template/packages/ai/package.json +4 -4
- package/analyzer-template/packages/ai/src/lib/__mocks__/completionCall.ts +122 -0
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +228 -24
- package/analyzer-template/packages/ai/src/lib/astScopes/arrayDerivationDetector.ts +199 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +205 -10
- package/analyzer-template/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.ts +644 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +181 -23
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.ts +10 -17
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.ts +18 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.ts +38 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.ts +181 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +1619 -125
- package/analyzer-template/packages/ai/src/lib/astScopes/sharedPatterns.ts +28 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +324 -5
- package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +29 -10
- package/analyzer-template/packages/ai/src/lib/completionCall.ts +216 -36
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +2543 -399
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +21 -4
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +976 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +243 -77
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.ts +16 -3
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.ts +6 -4
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +71 -2
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +161 -19
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.ts +70 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +163 -14
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.ts +98 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.ts +179 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.ts +40 -30
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +441 -82
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.ts +129 -0
- package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +183 -0
- package/analyzer-template/packages/ai/src/lib/deepEqual.ts +30 -0
- package/analyzer-template/packages/ai/src/lib/e2eDataTracking.ts +334 -0
- package/analyzer-template/packages/ai/src/lib/extractCriticalDataKeys.ts +120 -0
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarioData.ts +74 -7
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +89 -112
- package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +63 -2
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +1419 -101
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +216 -109
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +710 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +528 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +2484 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +239 -0
- package/analyzer-template/packages/ai/src/lib/getConditionalUsagesFromCode.ts +143 -31
- package/analyzer-template/packages/ai/src/lib/guessScenarioDataFromDescription.ts +8 -2
- package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +328 -7
- package/analyzer-template/packages/ai/src/lib/mergeJsonTypeDefinitions.ts +5 -0
- package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +111 -87
- package/analyzer-template/packages/ai/src/lib/promptGenerators/collapseNullableObjects.ts +118 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +17 -7
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.ts +1 -1
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +32 -102
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChunkPrompt.ts +82 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateCriticalKeysPrompt.ts +103 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +110 -6
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.ts +14 -53
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.ts +58 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.ts +28 -2
- package/analyzer-template/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.ts +391 -0
- package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +824 -0
- package/analyzer-template/packages/ai/src/lib/splitOutsideParentheses.ts +5 -1
- package/analyzer-template/packages/ai/src/lib/validateExecutionFlowPaths.ts +531 -0
- package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +127 -3
- package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +121 -2
- package/analyzer-template/packages/analyze/index.ts +2 -0
- package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +79 -59
- package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +113 -26
- package/analyzer-template/packages/analyze/src/lib/analysisContext.ts +44 -4
- package/analyzer-template/packages/analyze/src/lib/asts/nodes/index.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/asts/nodes/isAsyncFunction.ts +67 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.ts +19 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.ts +19 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllExports.ts +11 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.ts +8 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.ts +49 -1
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.ts +2 -1
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +570 -180
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +54 -1
- package/analyzer-template/packages/analyze/src/lib/files/analyze/dependencyResolver.ts +6 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +3 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/gatherEntityMap.ts +4 -2
- package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +33 -10
- package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +31 -15
- package/analyzer-template/packages/analyze/src/lib/files/analyzeEntity.ts +11 -7
- package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +11 -12
- package/analyzer-template/packages/analyze/src/lib/files/analyzeRemixRoute.ts +4 -5
- package/analyzer-template/packages/analyze/src/lib/files/enums/steps.ts +1 -1
- package/analyzer-template/packages/analyze/src/lib/files/getImportedExports.ts +22 -13
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/TransformationTracer.ts +1315 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +313 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.ts +102 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +711 -78
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.ts +1 -1
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.ts +28 -62
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +550 -137
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +264 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +78 -83
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +4 -8
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +1067 -167
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.ts +56 -11
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/propagateArrayItemSchemas.ts +474 -0
- package/analyzer-template/packages/analyze/src/lib/files/setImportedExports.ts +2 -1
- package/analyzer-template/packages/analyze/src/lib/index.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/utils/getFileByPath.ts +19 -0
- package/analyzer-template/packages/aws/codebuild/index.ts +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts +11 -1
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js +29 -18
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts +2 -2
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js +2 -2
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts +8 -18
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js +17 -61
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts +15 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts.map +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js +31 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js.map +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js +8 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js.map +1 -1
- package/analyzer-template/packages/aws/package.json +3 -3
- package/analyzer-template/packages/aws/s3/index.ts +1 -0
- package/analyzer-template/packages/aws/src/lib/codebuild/waitForBuild.ts +43 -19
- package/analyzer-template/packages/aws/src/lib/ecs/ecsDefineContainer.ts +3 -3
- package/analyzer-template/packages/aws/src/lib/ecs/ecsTaskFactory.ts +17 -69
- package/analyzer-template/packages/aws/src/lib/s3/checkS3ObjectExists.ts +47 -0
- package/analyzer-template/packages/aws/src/lib/s3/uploadFileToS3.ts +8 -1
- package/analyzer-template/packages/database/package.json +1 -1
- package/analyzer-template/packages/database/src/lib/analysisBranchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/analysisToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/branchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/commitBranchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/commitToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/fileToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/kysely/db.ts +18 -5
- package/analyzer-template/packages/database/src/lib/kysely/tableRelations.ts +2 -2
- package/analyzer-template/packages/database/src/lib/kysely/tables/commitsTable.ts +6 -0
- package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +36 -9
- package/analyzer-template/packages/database/src/lib/kysely/tables/labsRequestsTable.ts +52 -0
- package/analyzer-template/packages/database/src/lib/loadAnalyses.ts +58 -1
- package/analyzer-template/packages/database/src/lib/loadAnalysis.ts +13 -0
- package/analyzer-template/packages/database/src/lib/loadBranch.ts +16 -1
- package/analyzer-template/packages/database/src/lib/loadCommit.ts +11 -0
- package/analyzer-template/packages/database/src/lib/loadCommits.ts +28 -0
- package/analyzer-template/packages/database/src/lib/loadEntities.ts +26 -3
- package/analyzer-template/packages/database/src/lib/loadEntityBranches.ts +12 -0
- package/analyzer-template/packages/database/src/lib/loadReadyToBeCapturedAnalyses.ts +30 -5
- package/analyzer-template/packages/database/src/lib/projectToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/saveFiles.ts +1 -1
- package/analyzer-template/packages/database/src/lib/scenarioToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +7 -14
- package/analyzer-template/packages/database/src/lib/userScenarioToDb.ts +1 -1
- package/analyzer-template/packages/generate/index.ts +3 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.ts +17 -1
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.ts +193 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.ts +73 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.ts +9 -4
- package/analyzer-template/packages/generate/src/lib/deepMerge.ts +26 -1
- package/analyzer-template/packages/generate/src/lib/directExecutionScript.ts +17 -2
- package/analyzer-template/packages/generate/src/lib/getComponentScenarioPath.ts +8 -3
- package/analyzer-template/packages/generate/src/lib/scenarioComponentForServer.ts +114 -0
- package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts +4 -2
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +13 -3
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tableRelations.d.ts +2 -2
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts +1 -11
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js +3 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +30 -7
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.d.ts +23 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js +35 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts +2 -6
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts +2 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js +45 -2
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js +8 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js +11 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js +7 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts +3 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js +22 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts +3 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js +23 -4
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js +9 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js +23 -5
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts +2 -2
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js +5 -4
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/index.d.ts +3 -0
- package/analyzer-template/packages/github/dist/generate/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/index.js +3 -0
- package/analyzer-template/packages/github/dist/generate/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts +9 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts +20 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js +27 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/directExecutionScript.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/directExecutionScript.js +10 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/directExecutionScript.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/getComponentScenarioPath.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/getComponentScenarioPath.js +7 -3
- package/analyzer-template/packages/github/dist/generate/src/lib/getComponentScenarioPath.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts +8 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js +89 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js.map +1 -0
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js +10 -0
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js +3 -0
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.d.ts +2 -2
- package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +87 -13
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts +7 -0
- package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts +11 -6
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +199 -3
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/applyUniversalMocks.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/applyUniversalMocks.js +26 -2
- package/analyzer-template/packages/github/dist/utils/src/lib/applyUniversalMocks.js.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
- package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts +9 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js +29 -3
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js.map +1 -1
- package/analyzer-template/packages/github/package.json +1 -1
- package/analyzer-template/packages/github/src/lib/loadOrCreateCommit.ts +14 -0
- package/analyzer-template/packages/github/src/lib/syncPrimaryBranch.ts +2 -0
- package/analyzer-template/packages/process/index.ts +2 -0
- package/analyzer-template/packages/process/package.json +12 -0
- package/analyzer-template/packages/process/tsconfig.json +8 -0
- package/analyzer-template/packages/types/index.ts +5 -0
- package/analyzer-template/packages/types/src/types/Analysis.ts +104 -13
- package/analyzer-template/packages/types/src/types/Commit.ts +2 -0
- package/analyzer-template/packages/types/src/types/Entity.ts +2 -0
- package/analyzer-template/packages/types/src/types/ProjectMetadata.ts +7 -0
- package/analyzer-template/packages/types/src/types/Scenario.ts +11 -10
- package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +228 -3
- package/analyzer-template/packages/types/src/types/ScopeAnalysis.ts +6 -1
- package/analyzer-template/packages/types/src/types/StatementInfo.ts +2 -0
- package/analyzer-template/packages/ui-components/package.json +4 -4
- package/analyzer-template/packages/ui-components/src/components/ScenarioDetailInteractiveView.tsx +23 -7
- package/analyzer-template/packages/utils/dist/types/index.d.ts +2 -2
- package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +87 -13
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts +7 -0
- package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts +11 -6
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +199 -3
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/applyUniversalMocks.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/applyUniversalMocks.js +26 -2
- package/analyzer-template/packages/utils/dist/utils/src/lib/applyUniversalMocks.js.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js +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/lightweightEntityExtractor.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
- package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts +9 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js +29 -3
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js.map +1 -1
- package/analyzer-template/packages/utils/src/lib/applyUniversalMocks.ts +28 -2
- package/analyzer-template/packages/utils/src/lib/fs/rsyncCopy.ts +108 -2
- package/analyzer-template/packages/utils/src/lib/lightweightEntityExtractor.ts +27 -0
- package/analyzer-template/packages/utils/src/lib/safeFileName.ts +48 -3
- package/analyzer-template/playwright/capture.ts +57 -26
- package/analyzer-template/playwright/captureStatic.ts +1 -1
- package/analyzer-template/playwright/getCodeYamInfo.ts +12 -7
- package/analyzer-template/playwright/takeElementScreenshot.ts +26 -11
- package/analyzer-template/playwright/takeScreenshot.ts +15 -9
- package/analyzer-template/playwright/waitForServer.ts +21 -6
- package/analyzer-template/project/TESTING.md +83 -0
- package/analyzer-template/project/analyzeBaselineCommit.ts +9 -0
- package/analyzer-template/project/analyzeBranchCommit.ts +4 -0
- package/analyzer-template/project/analyzeFileEntities.ts +4 -0
- package/analyzer-template/project/analyzeRegularCommit.ts +9 -0
- package/analyzer-template/project/captureLibraryFunctionDirect.ts +29 -26
- package/analyzer-template/project/constructMockCode.ts +1319 -158
- package/analyzer-template/project/controller/startController.ts +16 -1
- package/analyzer-template/project/createEntitiesAndSortFiles.ts +83 -0
- package/analyzer-template/project/executeLibraryFunctionDirect.ts +7 -3
- package/analyzer-template/project/loadReadyToBeCaptured.ts +82 -42
- package/analyzer-template/project/mocks/analyzeFileMock.ts +8 -7
- package/analyzer-template/project/orchestrateCapture/AwsCaptureTaskRunner.ts +12 -4
- package/analyzer-template/project/orchestrateCapture/KyselyAnalysisLoader.ts +13 -9
- package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +93 -42
- package/analyzer-template/project/orchestrateCapture/taskRunner.ts +4 -2
- package/analyzer-template/project/orchestrateCapture.ts +88 -12
- package/analyzer-template/project/reconcileMockDataKeys.ts +245 -2
- package/analyzer-template/project/runAnalysis.ts +11 -0
- package/analyzer-template/project/runMultiScenarioServer.ts +11 -10
- package/analyzer-template/project/serverOnlyModules.ts +413 -0
- package/analyzer-template/project/start.ts +72 -19
- package/analyzer-template/project/startScenarioCapture.ts +79 -41
- package/analyzer-template/project/writeMockDataTsx.ts +466 -73
- package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
- package/analyzer-template/project/writeScenarioComponents.ts +1447 -214
- package/analyzer-template/project/writeScenarioFiles.ts +26 -0
- package/analyzer-template/project/writeSimpleRoot.ts +56 -22
- package/analyzer-template/project/writeUniversalMocks.ts +32 -11
- package/analyzer-template/scripts/comboWorkerLoop.cjs +99 -50
- package/analyzer-template/scripts/defaultCmd.sh +9 -0
- package/analyzer-template/tsconfig.json +2 -1
- package/background/src/lib/local/createLocalAnalyzer.js +2 -30
- package/background/src/lib/local/createLocalAnalyzer.js.map +1 -1
- package/background/src/lib/local/execAsync.js +1 -1
- package/background/src/lib/local/execAsync.js.map +1 -1
- package/background/src/lib/virtualized/common/execAsync.js +1 -1
- package/background/src/lib/virtualized/common/execAsync.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeBaselineCommit.js +7 -1
- package/background/src/lib/virtualized/project/analyzeBaselineCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeBranchCommit.js +2 -1
- package/background/src/lib/virtualized/project/analyzeBranchCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeFileEntities.js +2 -1
- package/background/src/lib/virtualized/project/analyzeFileEntities.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeRegularCommit.js +7 -1
- package/background/src/lib/virtualized/project/analyzeRegularCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js +3 -3
- package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js.map +1 -1
- package/background/src/lib/virtualized/project/constructMockCode.js +1171 -120
- package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
- package/background/src/lib/virtualized/project/controller/startController.js +11 -1
- package/background/src/lib/virtualized/project/controller/startController.js.map +1 -1
- package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js +73 -1
- package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js.map +1 -1
- package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js +6 -3
- package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js.map +1 -1
- package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js +34 -9
- package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js.map +1 -1
- package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js +7 -7
- package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js +2 -2
- package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js +12 -6
- package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +73 -36
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture.js +72 -13
- package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +204 -2
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
- package/background/src/lib/virtualized/project/runAnalysis.js +9 -0
- package/background/src/lib/virtualized/project/runAnalysis.js.map +1 -1
- package/background/src/lib/virtualized/project/runMultiScenarioServer.js +11 -9
- package/background/src/lib/virtualized/project/runMultiScenarioServer.js.map +1 -1
- package/background/src/lib/virtualized/project/serverOnlyModules.js +338 -0
- package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -0
- package/background/src/lib/virtualized/project/start.js +62 -19
- package/background/src/lib/virtualized/project/start.js.map +1 -1
- package/background/src/lib/virtualized/project/startScenarioCapture.js +61 -31
- package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/writeMockDataTsx.js +404 -62
- 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 +1066 -146
- package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioFiles.js +19 -0
- package/background/src/lib/virtualized/project/writeScenarioFiles.js.map +1 -1
- package/background/src/lib/virtualized/project/writeSimpleRoot.js +57 -20
- package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
- package/background/src/lib/virtualized/project/writeUniversalMocks.js +27 -12
- package/background/src/lib/virtualized/project/writeUniversalMocks.js.map +1 -1
- package/codeyam-cli/scripts/apply-setup.js +180 -0
- package/codeyam-cli/scripts/apply-setup.js.map +1 -1
- package/codeyam-cli/src/cli.js +11 -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 +44 -18
- package/codeyam-cli/src/commands/debug.js.map +1 -1
- package/codeyam-cli/src/commands/default.js +30 -34
- package/codeyam-cli/src/commands/default.js.map +1 -1
- package/codeyam-cli/src/commands/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 +307 -0
- package/codeyam-cli/src/commands/memory.js.map +1 -0
- package/codeyam-cli/src/commands/recapture.js +228 -0
- package/codeyam-cli/src/commands/recapture.js.map +1 -0
- package/codeyam-cli/src/commands/report.js +72 -24
- package/codeyam-cli/src/commands/report.js.map +1 -1
- package/codeyam-cli/src/commands/setup-sandbox.js +2 -0
- package/codeyam-cli/src/commands/setup-sandbox.js.map +1 -1
- package/codeyam-cli/src/commands/setup-simulations.js +284 -0
- package/codeyam-cli/src/commands/setup-simulations.js.map +1 -0
- package/codeyam-cli/src/commands/start.js +8 -12
- package/codeyam-cli/src/commands/start.js.map +1 -1
- package/codeyam-cli/src/commands/status.js +23 -1
- package/codeyam-cli/src/commands/status.js.map +1 -1
- package/codeyam-cli/src/commands/test-startup.js +3 -1
- package/codeyam-cli/src/commands/test-startup.js.map +1 -1
- package/codeyam-cli/src/commands/verify.js +14 -2
- package/codeyam-cli/src/commands/verify.js.map +1 -1
- package/codeyam-cli/src/commands/wipe.js +108 -0
- package/codeyam-cli/src/commands/wipe.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/npmVersionCheck.test.js +179 -0
- package/codeyam-cli/src/utils/__tests__/npmVersionCheck.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js +81 -0
- package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +128 -82
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
- package/codeyam-cli/src/utils/analysisRunner.js +29 -15
- package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
- package/codeyam-cli/src/utils/analyzer.js +7 -0
- package/codeyam-cli/src/utils/analyzer.js.map +1 -1
- package/codeyam-cli/src/utils/backgroundServer.js +104 -23
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/database.js +91 -5
- package/codeyam-cli/src/utils/database.js.map +1 -1
- package/codeyam-cli/src/utils/generateReport.js +253 -106
- package/codeyam-cli/src/utils/generateReport.js.map +1 -1
- package/codeyam-cli/src/utils/git.js +79 -0
- package/codeyam-cli/src/utils/git.js.map +1 -0
- package/codeyam-cli/src/utils/install-skills.js +76 -42
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/labsAutoCheck.js +19 -0
- package/codeyam-cli/src/utils/labsAutoCheck.js.map +1 -0
- package/codeyam-cli/src/utils/npmVersionCheck.js +76 -0
- package/codeyam-cli/src/utils/npmVersionCheck.js.map +1 -0
- package/codeyam-cli/src/utils/progress.js +7 -0
- package/codeyam-cli/src/utils/progress.js.map +1 -1
- package/codeyam-cli/src/utils/queue/__tests__/manager.test.js +38 -0
- package/codeyam-cli/src/utils/queue/__tests__/manager.test.js.map +1 -1
- package/codeyam-cli/src/utils/queue/job.js +249 -16
- package/codeyam-cli/src/utils/queue/job.js.map +1 -1
- package/codeyam-cli/src/utils/queue/manager.js +103 -7
- package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
- package/codeyam-cli/src/utils/queue/persistence.js.map +1 -1
- package/codeyam-cli/src/utils/requireSimulations.js +10 -0
- package/codeyam-cli/src/utils/requireSimulations.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js +82 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js +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 +116 -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 +46 -15
- package/codeyam-cli/src/utils/versionInfo.js.map +1 -1
- package/codeyam-cli/src/utils/wipe.js +128 -0
- package/codeyam-cli/src/utils/wipe.js.map +1 -0
- package/codeyam-cli/src/webserver/__tests__/dependency-smoke.test.js +66 -0
- package/codeyam-cli/src/webserver/__tests__/dependency-smoke.test.js.map +1 -0
- package/codeyam-cli/src/webserver/app/lib/database.js +118 -6
- package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
- package/codeyam-cli/src/webserver/app/lib/dbNotifier.js.map +1 -1
- package/codeyam-cli/src/webserver/backgroundServer.js +55 -10
- package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/webserver/bootstrap.js +60 -0
- package/codeyam-cli/src/webserver/bootstrap.js.map +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/CopyButton-jNYXRRNI.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-bwuHPyTa.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-kykTbcnD.js → EntityTypeBadge-CvzqMxcu.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-BH0XDim7.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-EhOseatT.js +34 -0
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-yjIHlOGa.js +25 -0
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-Cq5o8jL4.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/LoadingDots-BvMu2i-g.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/LogViewer-kgBTLoJD.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-BzPgx-xO.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-CwZrv-Ok.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-BX2Ny2Qj.js +10 -0
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-C06nsHKY.js → TruncatedFilePath-CDpEprKa.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/_index-BRx8ZGZo.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-4S4yPfFw.js +27 -0
- package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-DHKuQSmR.js +17 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.agent-transcripts-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.health-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.labs-unlock-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.memory-profile-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.restart-server-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.save-fixture-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/book-open-D4IPYH_y.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/chevron-down-CG65viiV.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/chunk-JZWAC4HX-DB3aFuEO.js +51 -0
- package/codeyam-cli/src/webserver/build/client/assets/circle-check-igfMr5DY.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/copy-Coc4o_8c.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-D1zB-pYc.js +21 -0
- package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-C1gnJVOL.svg → cy-logo-cli-CCKUIm0S.svg} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DcX-ZS3p.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-JTAjQ54M.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-CYqBrC9s.js → entity._sha._-B0h9AqE6.js} +22 -15
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-DjLxr2JB.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-CtYowLOt.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-PePWg17F.js +5 -0
- package/codeyam-cli/src/webserver/build/client/assets/entry.client-I-Wo99C_.js +29 -0
- package/codeyam-cli/src/webserver/build/client/assets/executionFlowCoverage-BWhdfn70.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-9sMMAiWJ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/files-Co65J0s3.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/git-BdHOxVfg.js +15 -0
- package/codeyam-cli/src/webserver/build/client/assets/globals-CCgBKWy4.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-fmIEn3Bc.js +9 -0
- package/codeyam-cli/src/webserver/build/client/assets/index-CUM5iXwc.js +9 -0
- package/codeyam-cli/src/webserver/build/client/assets/index-_417gcQW.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/labs-BK0C1H1T.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/loader-circle-TzRHMVog.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/manifest-390cb8fa.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-CzZySbBE.js +78 -0
- package/codeyam-cli/src/webserver/build/client/assets/pause-hjzB7t2z.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/preload-helper-ckwbz45p.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/root-DnbDhvTU.js +62 -0
- package/codeyam-cli/src/webserver/build/client/assets/scenarioStatus-B_8jpV3e.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/search-DcAwD_Ln.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/settings-CclxrcPK.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/simulations-DVNJVQgD.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/terminal-DbEAHMbA.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-CAD5b1o_.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-BqgrAzs3.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-Blr5oZDE.js → useLastLogLine-DAFqfEDH.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-DZlYx2c4.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useToast-Bbf4Hokd.js → useToast-ihdMtlf6.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-CXfuiwt3.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-BSvme_Ao.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/devServer.js +1 -3
- package/codeyam-cli/src/webserver/devServer.js.map +1 -1
- package/codeyam-cli/src/webserver/server.js +35 -25
- package/codeyam-cli/src/webserver/server.js.map +1 -1
- package/codeyam-cli/templates/{codeyam-debug-skill.md → codeyam-debug.md} +48 -4
- package/codeyam-cli/templates/codeyam-diagnose.md +481 -0
- package/codeyam-cli/templates/codeyam-memory-hook.sh +199 -0
- package/codeyam-cli/templates/codeyam-memory.md +396 -0
- package/codeyam-cli/templates/codeyam-new-rule.md +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 +25 -22
- package/packages/ai/index.js +8 -6
- package/packages/ai/index.js.map +1 -1
- package/packages/ai/src/lib/analyzeScope.js +181 -13
- package/packages/ai/src/lib/analyzeScope.js.map +1 -1
- package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js +150 -0
- package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js.map +1 -0
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +154 -9
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
- package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js +435 -0
- package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js.map +1 -0
- package/packages/ai/src/lib/astScopes/methodSemantics.js +138 -23
- package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js +10 -14
- package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js +8 -0
- package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js +23 -0
- package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js +138 -1
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/processExpression.js +1235 -104
- package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
- package/packages/ai/src/lib/astScopes/sharedPatterns.js +25 -0
- package/packages/ai/src/lib/astScopes/sharedPatterns.js.map +1 -1
- package/packages/ai/src/lib/checkAllAttributes.js +24 -9
- package/packages/ai/src/lib/checkAllAttributes.js.map +1 -1
- package/packages/ai/src/lib/completionCall.js +178 -31
- package/packages/ai/src/lib/completionCall.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +1961 -224
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +19 -4
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +661 -0
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +180 -56
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js +13 -3
- package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js +6 -4
- package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +66 -2
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +139 -13
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js +63 -0
- package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +142 -12
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js +86 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js +173 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js +37 -20
- package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +371 -73
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js +107 -0
- package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructureChunking.js +130 -0
- package/packages/ai/src/lib/dataStructureChunking.js.map +1 -0
- package/packages/ai/src/lib/deepEqual.js +32 -0
- package/packages/ai/src/lib/deepEqual.js.map +1 -0
- package/packages/ai/src/lib/e2eDataTracking.js +241 -0
- package/packages/ai/src/lib/e2eDataTracking.js.map +1 -0
- package/packages/ai/src/lib/extractCriticalDataKeys.js +96 -0
- package/packages/ai/src/lib/extractCriticalDataKeys.js.map +1 -0
- package/packages/ai/src/lib/generateChangesEntityScenarioData.js +62 -5
- package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateChangesEntityScenarios.js +81 -90
- package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateEntityDataStructure.js +50 -1
- package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarioData.js +1127 -91
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarios.js +193 -83
- package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +495 -0
- package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js +380 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +1807 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js +194 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js.map +1 -0
- package/packages/ai/src/lib/getConditionalUsagesFromCode.js +84 -14
- package/packages/ai/src/lib/getConditionalUsagesFromCode.js.map +1 -1
- package/packages/ai/src/lib/guessScenarioDataFromDescription.js +2 -1
- package/packages/ai/src/lib/guessScenarioDataFromDescription.js.map +1 -1
- package/packages/ai/src/lib/isolateScopes.js +270 -7
- package/packages/ai/src/lib/isolateScopes.js.map +1 -1
- package/packages/ai/src/lib/mergeJsonTypeDefinitions.js +5 -0
- package/packages/ai/src/lib/mergeJsonTypeDefinitions.js.map +1 -1
- package/packages/ai/src/lib/mergeStatements.js +88 -46
- package/packages/ai/src/lib/mergeStatements.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js +97 -0
- package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +16 -4
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +21 -64
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js +54 -0
- package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +83 -6
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js +10 -34
- package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js +45 -0
- package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js +16 -3
- package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js +335 -0
- package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js.map +1 -0
- package/packages/ai/src/lib/resolvePathToControllable.js +677 -0
- package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -0
- package/packages/ai/src/lib/splitOutsideParentheses.js +3 -1
- package/packages/ai/src/lib/splitOutsideParentheses.js.map +1 -1
- package/packages/ai/src/lib/worker/SerializableDataStructure.js +29 -0
- package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js +98 -1
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js.map +1 -1
- package/packages/analyze/index.js +1 -0
- package/packages/analyze/index.js.map +1 -1
- package/packages/analyze/src/lib/FileAnalyzer.js +75 -36
- package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/ProjectAnalyzer.js +96 -26
- package/packages/analyze/src/lib/ProjectAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/analysisContext.js +30 -5
- package/packages/analyze/src/lib/analysisContext.js.map +1 -1
- package/packages/analyze/src/lib/asts/nodes/index.js +1 -0
- package/packages/analyze/src/lib/asts/nodes/index.js.map +1 -1
- package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js +52 -0
- package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js.map +1 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js +14 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js +14 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js +6 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js +6 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js +39 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js +2 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +428 -123
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +42 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/dependencyResolver.js +5 -0
- package/packages/analyze/src/lib/files/analyze/dependencyResolver.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +2 -0
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js +2 -1
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +31 -10
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeChange.js +21 -11
- package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeEntity.js +9 -8
- package/packages/analyze/src/lib/files/analyzeEntity.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeInitial.js +9 -10
- package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeRemixRoute.js +3 -2
- package/packages/analyze/src/lib/files/analyzeRemixRoute.js.map +1 -1
- package/packages/analyze/src/lib/files/enums/steps.js +1 -1
- package/packages/analyze/src/lib/files/enums/steps.js.map +1 -1
- package/packages/analyze/src/lib/files/getImportedExports.js +17 -8
- package/packages/analyze/src/lib/files/getImportedExports.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js +880 -0
- package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +255 -0
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js +85 -0
- package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +550 -62
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js +29 -34
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +404 -85
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +144 -0
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +56 -69
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +4 -8
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +875 -141
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js +46 -9
- package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/setImportedExports.js +2 -1
- package/packages/analyze/src/lib/files/setImportedExports.js.map +1 -1
- package/packages/analyze/src/lib/index.js +1 -0
- package/packages/analyze/src/lib/index.js.map +1 -1
- package/packages/analyze/src/lib/utils/getFileByPath.js +12 -0
- package/packages/analyze/src/lib/utils/getFileByPath.js.map +1 -0
- package/packages/aws/src/lib/ecs/ecsDefineContainer.js +2 -2
- package/packages/aws/src/lib/ecs/ecsDefineContainer.js.map +1 -1
- package/packages/aws/src/lib/ecs/ecsTaskFactory.js +17 -61
- package/packages/aws/src/lib/ecs/ecsTaskFactory.js.map +1 -1
- package/packages/database/src/lib/analysisBranchToDb.js +1 -1
- package/packages/database/src/lib/analysisBranchToDb.js.map +1 -1
- package/packages/database/src/lib/analysisToDb.js +1 -1
- package/packages/database/src/lib/analysisToDb.js.map +1 -1
- package/packages/database/src/lib/branchToDb.js +1 -1
- package/packages/database/src/lib/branchToDb.js.map +1 -1
- package/packages/database/src/lib/commitBranchToDb.js +1 -1
- package/packages/database/src/lib/commitBranchToDb.js.map +1 -1
- package/packages/database/src/lib/commitToDb.js +1 -1
- package/packages/database/src/lib/commitToDb.js.map +1 -1
- package/packages/database/src/lib/fileToDb.js +1 -1
- package/packages/database/src/lib/fileToDb.js.map +1 -1
- package/packages/database/src/lib/kysely/db.js +13 -3
- package/packages/database/src/lib/kysely/db.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/commitsTable.js +3 -0
- package/packages/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
- package/packages/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/labsRequestsTable.js +35 -0
- package/packages/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
- package/packages/database/src/lib/loadAnalyses.js +45 -2
- package/packages/database/src/lib/loadAnalyses.js.map +1 -1
- package/packages/database/src/lib/loadAnalysis.js +8 -0
- package/packages/database/src/lib/loadAnalysis.js.map +1 -1
- package/packages/database/src/lib/loadBranch.js +11 -1
- package/packages/database/src/lib/loadBranch.js.map +1 -1
- package/packages/database/src/lib/loadCommit.js +7 -0
- package/packages/database/src/lib/loadCommit.js.map +1 -1
- package/packages/database/src/lib/loadCommits.js +22 -1
- package/packages/database/src/lib/loadCommits.js.map +1 -1
- package/packages/database/src/lib/loadEntities.js +23 -4
- package/packages/database/src/lib/loadEntities.js.map +1 -1
- package/packages/database/src/lib/loadEntityBranches.js +9 -0
- package/packages/database/src/lib/loadEntityBranches.js.map +1 -1
- package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js +23 -5
- package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
- package/packages/database/src/lib/projectToDb.js +1 -1
- package/packages/database/src/lib/projectToDb.js.map +1 -1
- package/packages/database/src/lib/saveFiles.js +1 -1
- package/packages/database/src/lib/saveFiles.js.map +1 -1
- package/packages/database/src/lib/scenarioToDb.js +1 -1
- package/packages/database/src/lib/scenarioToDb.js.map +1 -1
- package/packages/database/src/lib/updateCommitMetadata.js +5 -4
- package/packages/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/packages/generate/index.js +3 -0
- package/packages/generate/index.js.map +1 -1
- package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
- package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
- package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
- package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
- package/packages/generate/src/lib/deepMerge.js +27 -1
- package/packages/generate/src/lib/deepMerge.js.map +1 -1
- package/packages/generate/src/lib/directExecutionScript.js +10 -1
- package/packages/generate/src/lib/directExecutionScript.js.map +1 -1
- package/packages/generate/src/lib/getComponentScenarioPath.js +7 -3
- package/packages/generate/src/lib/getComponentScenarioPath.js.map +1 -1
- package/packages/generate/src/lib/scenarioComponentForServer.js +89 -0
- package/packages/generate/src/lib/scenarioComponentForServer.js.map +1 -0
- package/packages/github/src/lib/loadOrCreateCommit.js +10 -0
- package/packages/github/src/lib/loadOrCreateCommit.js.map +1 -1
- package/packages/github/src/lib/syncPrimaryBranch.js +3 -0
- package/packages/github/src/lib/syncPrimaryBranch.js.map +1 -1
- package/packages/process/index.js +3 -0
- package/packages/process/index.js.map +1 -0
- package/packages/process/src/GlobalProcessManager.js.map +1 -0
- package/{background/src/lib/process → packages/process/src}/ProcessManager.js +1 -1
- package/packages/process/src/ProcessManager.js.map +1 -0
- package/packages/process/src/index.js.map +1 -0
- package/packages/process/src/managedExecAsync.js.map +1 -0
- package/packages/types/index.js.map +1 -1
- package/packages/utils/src/lib/applyUniversalMocks.js +26 -2
- package/packages/utils/src/lib/applyUniversalMocks.js.map +1 -1
- package/packages/utils/src/lib/fs/rsyncCopy.js +93 -2
- package/packages/utils/src/lib/fs/rsyncCopy.js.map +1 -1
- package/packages/utils/src/lib/lightweightEntityExtractor.js +25 -0
- package/packages/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
- package/packages/utils/src/lib/safeFileName.js +29 -3
- package/packages/utils/src/lib/safeFileName.js.map +1 -1
- package/scripts/finalize-analyzer.cjs +8 -74
- package/analyzer-template/packages/ai/src/lib/findMatchingAttribute.ts +0 -102
- package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +0 -197
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +0 -271
- package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +0 -294
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.ts +0 -67
- package/analyzer-template/packages/ai/src/lib/transformMockDataToMatchSchema.ts +0 -156
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +0 -115
- package/analyzer-template/process/INTEGRATION_COMPLETE.md +0 -333
- package/analyzer-template/process/INTEGRATION_EXAMPLE.md +0 -525
- package/analyzer-template/process/README.md +0 -507
- package/background/src/lib/process/GlobalProcessManager.js.map +0 -1
- package/background/src/lib/process/ProcessManager.js.map +0 -1
- package/background/src/lib/process/index.js.map +0 -1
- package/background/src/lib/process/managedExecAsync.js.map +0 -1
- package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js +0 -238
- package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js.map +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-D4htqD-x.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-Catz6XEN.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-TlHocYno.js +0 -26
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-CVMmGuIc.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/LogViewer-JkfQ-VaI.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-CVZ0H4BL.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-BrMAP1nP.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-CJhE4cCv.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/_index-faVIcr_i.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-CLMa2sgx.js +0 -7
- package/codeyam-cli/src/webserver/build/client/assets/chevron-down-DwYjrK_h.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/chunk-WWGJGFF6-CgXbbZRx.js +0 -26
- package/codeyam-cli/src/webserver/build/client/assets/circle-check-B2oHQ-zo.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-BBYuR56H.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-CT0Q5lVu.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-Bj5GHkhb.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-eW5z9AyZ.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/entry.client-B9tSboXM.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-CmO-EZAB.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-DLinnTOx.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/git-CIxwBQvb.js +0 -12
- package/codeyam-cli/src/webserver/build/client/assets/globals-xPz593l2.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-XQCGvadH.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/index-_LjBsTxX.js +0 -8
- package/codeyam-cli/src/webserver/build/client/assets/loader-circle-D_EGChhq.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-ca438c41.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/root-CHHYHuzL.js +0 -16
- package/codeyam-cli/src/webserver/build/client/assets/search-DY8yoDpH.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/server-build-CMKNK2uU.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/settings-BT6wVHd5.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/simulations-gv3H7JV7.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-BthANBVv.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-CANr3QJ5.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-BtBPtyHx.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-N2cTnejq.js +0 -166
- package/codeyam-cli/templates/debug-command.md +0 -141
- package/packages/ai/src/lib/findMatchingAttribute.js +0 -77
- package/packages/ai/src/lib/findMatchingAttribute.js.map +0 -1
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +0 -136
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +0 -220
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateEntityKeyAttributes.js +0 -241
- package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/isFrontend.js +0 -5
- package/packages/ai/src/lib/isFrontend.js.map +0 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js +0 -40
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js.map +0 -1
- package/packages/ai/src/lib/transformMockDataToMatchSchema.js +0 -124
- package/packages/ai/src/lib/transformMockDataToMatchSchema.js.map +0 -1
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +0 -72
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +0 -1
- /package/analyzer-template/{process → packages/process/src}/GlobalProcessManager.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/ProcessManager.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/index.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/managedExecAsync.ts +0 -0
- /package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-CMKNK2uU.css → styles-CMKNK2uU.css} +0 -0
- /package/{background/src/lib/process → packages/process/src}/GlobalProcessManager.js +0 -0
- /package/{background/src/lib/process → packages/process/src}/index.js +0 -0
- /package/{background/src/lib/process → packages/process/src}/managedExecAsync.js +0 -0
|
@@ -1,4 +1,94 @@
|
|
|
1
1
|
import { joinParenthesesAndArrays, splitOutsideParenthesesAndArrays, functionArguments, cleanOutBoundary, fillInDirectSchemaGapsAndUnknowns, removeDuplicateFunctionCalls, } from "../../../../../packages/ai/index.js";
|
|
2
|
+
/**
|
|
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"
|
|
14
|
+
*/
|
|
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('(');
|
|
91
|
+
}
|
|
2
92
|
/**
|
|
3
93
|
* Extract property names that are jsx-components and should be preserved from original.
|
|
4
94
|
* These are paths like "MockName.Provider()" where the value or functionCallReturnValue is 'jsx-component'.
|
|
@@ -125,50 +215,53 @@ function funcArgs(functionSignature) {
|
|
|
125
215
|
}
|
|
126
216
|
// isValidKey ensures that the key does not contain any characters that would make it invalid in a JavaScript object.
|
|
127
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.
|
|
128
219
|
function isValidKey(key) {
|
|
129
220
|
if (!key || key.length === 0)
|
|
130
221
|
return false;
|
|
131
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;
|
|
132
226
|
return !/\s/.test(keyWithOutArguments);
|
|
133
227
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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)
|
|
140
248
|
: null;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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;
|
|
144
254
|
const mockNameParts = splitOutsideParenthesesAndArrays(baseMockName);
|
|
145
255
|
let relevantReturnValueSchema;
|
|
146
256
|
let dataStructurePath;
|
|
147
257
|
let dataStructureValue;
|
|
148
258
|
let foundEntityWithSignature = false;
|
|
149
259
|
let signatureSchema;
|
|
150
|
-
for (const filePath in dependencySchemas) {
|
|
260
|
+
entitySearch: for (const filePath in dependencySchemas) {
|
|
151
261
|
for (const entityName in dependencySchemas[filePath]) {
|
|
152
|
-
//
|
|
153
|
-
|
|
154
|
-
const
|
|
155
|
-
? `${variableQualifier} <- ${baseMockName}`
|
|
156
|
-
: mockNameParts[0];
|
|
157
|
-
// Check for direct match
|
|
158
|
-
let matches = entityName === targetEntityName || entityName === mockNameParts[0];
|
|
159
|
-
// If no direct match and no qualifier was provided, check if the entity
|
|
160
|
-
// is stored under a variable-qualified key (e.g., "stateBadge <- getStateBadge")
|
|
161
|
-
// This handles the case where gatherDataForMocks stored the entity with a variable
|
|
162
|
-
// qualifier but writeScenarioComponents called constructMockCode without one.
|
|
163
|
-
if (!matches && !variableQualifier) {
|
|
164
|
-
const qualifiedKeyMatch = entityName.match(new RegExp(`^([a-zA-Z_][a-zA-Z0-9_]*)\\s*<-\\s*${mockNameParts[0]}$`));
|
|
165
|
-
if (qualifiedKeyMatch) {
|
|
166
|
-
matches = true;
|
|
167
|
-
// Extract the variable qualifier from the entity name so we can use
|
|
168
|
-
// it for the data lookup key later
|
|
169
|
-
variableQualifier = qualifiedKeyMatch[1];
|
|
170
|
-
}
|
|
171
|
-
}
|
|
262
|
+
// Match entity by base name (without generics/args)
|
|
263
|
+
const entityBaseName = entityName.split(/[<(]/)[0];
|
|
264
|
+
const matches = entityBaseName === baseMockName || entityName === mockNameParts[0];
|
|
172
265
|
if (!matches)
|
|
173
266
|
continue;
|
|
174
267
|
// Track if we found the entity and it has a signature (is a function)
|
|
@@ -196,10 +289,43 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
196
289
|
// However, we still need to remove duplicate function calls that create invalid syntax
|
|
197
290
|
removeDuplicateFunctionCalls(relevantReturnValueSchema);
|
|
198
291
|
dataStructureValue = relevantReturnValueSchema?.[dataStructurePath];
|
|
199
|
-
break;
|
|
292
|
+
break entitySearch;
|
|
200
293
|
}
|
|
201
294
|
}
|
|
202
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
|
+
};
|
|
203
329
|
// Check if the return value schema only contains function type markers
|
|
204
330
|
// (e.g., "validateInputs()": "function") without actual return data
|
|
205
331
|
// (no functionCallReturnValue entries)
|
|
@@ -222,6 +348,8 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
222
348
|
// Count the number of arguments from signature schema
|
|
223
349
|
const argCount = Object.keys(signatureSchema).filter((key) => key.startsWith('signature[')).length;
|
|
224
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');
|
|
225
353
|
const argsString = args.join(', ');
|
|
226
354
|
// Generate empty mock function
|
|
227
355
|
return `function ${mockName}(${argsString}) {
|
|
@@ -240,7 +368,33 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
240
368
|
!hasMeaningfulReturnData(relevantReturnValueSchema)) {
|
|
241
369
|
const argCount = Object.keys(signatureSchema).filter((key) => key.startsWith('signature[')).length;
|
|
242
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');
|
|
243
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
|
+
}
|
|
244
398
|
// Generate empty mock function
|
|
245
399
|
return `function ${mockName}(${argsString}) {
|
|
246
400
|
// Empty mock - original function mocked out
|
|
@@ -257,6 +411,87 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
257
411
|
const pathDepth = splitOutsideParenthesesAndArrays(dataStructurePath).length;
|
|
258
412
|
const isRootArray = dataStructureValue === 'array' &&
|
|
259
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
|
+
}
|
|
260
495
|
const returnValueParts = {
|
|
261
496
|
name: dataStructureName,
|
|
262
497
|
isArray: isRootArray,
|
|
@@ -277,18 +512,19 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
277
512
|
// Strip type parameters like <typeof loader> from function names
|
|
278
513
|
// so "useLoaderData<typeof loader>()" becomes "useLoaderData()"
|
|
279
514
|
name = cleanOutTypes(name);
|
|
280
|
-
// For
|
|
281
|
-
// This
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
//
|
|
285
|
-
|
|
286
|
-
|
|
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)}`;
|
|
287
522
|
}
|
|
288
|
-
|
|
523
|
+
// Only use unquoted array access syntax for pure array indices like [0], [1]
|
|
524
|
+
if (name.match(/^\[\d+\]$/)) {
|
|
289
525
|
return `?.${name}`;
|
|
290
526
|
}
|
|
291
|
-
return
|
|
527
|
+
return `?.${quotePropertyKey(name)}`;
|
|
292
528
|
};
|
|
293
529
|
const constructDataPaths = () => {
|
|
294
530
|
// For structural elements, return modified base paths for children
|
|
@@ -336,7 +572,17 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
336
572
|
};
|
|
337
573
|
const constructContent = (dataPaths) => {
|
|
338
574
|
const { name, args, nested, isArray, isGenericArray, returnsFunctionArgs, returnsFunctionArray, isAsyncFunction, hasNoReturnData, } = returnValue;
|
|
339
|
-
|
|
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) => {
|
|
340
586
|
const nestedContent = constructReturnValueString(nestedItem, dataPaths);
|
|
341
587
|
return nestedContent;
|
|
342
588
|
});
|
|
@@ -410,52 +656,110 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
410
656
|
(!returnValue.isStructural || isStructuralArrayElementWithNested)) {
|
|
411
657
|
levelContentItems.push(...dataPaths.map((path) => `...${path}`));
|
|
412
658
|
}
|
|
413
|
-
|
|
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);
|
|
414
676
|
let levelContents = levelContentItems.filter(Boolean).join(',\n');
|
|
415
677
|
if (returnsFunctionArgs) {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
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;
|
|
435
703
|
}
|
|
436
704
|
}
|
|
437
705
|
else {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
706
|
+
const argsString = returnsFunctionArgs
|
|
707
|
+
.map((_, index) => `arg${index + 1}`)
|
|
708
|
+
.join(', ');
|
|
709
|
+
let funcContents = '';
|
|
710
|
+
if (returnsFunctionArray) {
|
|
711
|
+
if (hasNoReturnData) {
|
|
444
712
|
// Function has no return data (only signatures) - return empty array
|
|
445
713
|
funcContents = 'return []';
|
|
446
714
|
}
|
|
447
|
-
else {
|
|
448
|
-
//
|
|
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)
|
|
449
718
|
funcContents = `return ${dataPaths[0]}`;
|
|
450
719
|
}
|
|
720
|
+
else if (levelContents.length === 0) {
|
|
721
|
+
funcContents = 'return []';
|
|
722
|
+
}
|
|
723
|
+
else {
|
|
724
|
+
funcContents = `return [\n${indent(levelContents)}\n]`;
|
|
725
|
+
}
|
|
451
726
|
}
|
|
452
727
|
else {
|
|
453
|
-
|
|
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;
|
|
454
749
|
}
|
|
455
750
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
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');
|
|
459
763
|
}
|
|
460
764
|
}
|
|
461
765
|
// Check if all nested items are array prototype methods
|
|
@@ -468,7 +772,102 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
468
772
|
return ARRAY_PROTOTYPE_METHODS.has(methodName);
|
|
469
773
|
});
|
|
470
774
|
let returnValueContents = '';
|
|
471
|
-
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 &&
|
|
472
871
|
nestedContent.length === 0 &&
|
|
473
872
|
dataPaths.length === 1) {
|
|
474
873
|
returnValueContents = dataPaths[0];
|
|
@@ -487,20 +886,368 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
487
886
|
// When GENERIC array (using []) has nested content (like functions that need wrapping),
|
|
488
887
|
// use .map() to transform ALL elements instead of just creating [0]
|
|
489
888
|
// For DIFFERENTIATED arrays (using [0], [1], etc.), keep the static array structure
|
|
889
|
+
//
|
|
890
|
+
// IMPORTANT: If the nested content contains differentiated indices like [0], [1],
|
|
891
|
+
// we MUST use static array pattern, not .map(). The presence of differentiated
|
|
892
|
+
// indices means the array elements have different types/structures, so .map()
|
|
893
|
+
// would generate invalid code trying to treat them uniformly.
|
|
894
|
+
const hasDifferentiatedIndices = nested &&
|
|
895
|
+
nested.some((n) => n.name.match(/^\[\d+\]$/) && n.name !== '[0]');
|
|
490
896
|
if (isGenericArray &&
|
|
491
897
|
nestedContent.length > 0 &&
|
|
492
|
-
dataPaths.length > 0
|
|
898
|
+
dataPaths.length > 0 &&
|
|
899
|
+
!hasDifferentiatedIndices) {
|
|
493
900
|
// Get the array base path (without the [0])
|
|
494
901
|
const arrayBasePath = dataPaths[0].replace(/\?\.\[0\]$/, '');
|
|
495
902
|
// Replace [0] references with [__idx__] in level contents
|
|
496
|
-
|
|
903
|
+
let mappedContents = levelContents.replace(/\?\.\[0\]/g, '?.[__idx__]');
|
|
497
904
|
// levelContents may already be wrapped in {...} from structural [0] element,
|
|
498
905
|
// so check if we need to add the wrapper or not
|
|
499
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
|
+
};
|
|
500
1108
|
if (needsWrapper) {
|
|
501
|
-
|
|
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
|
|
502
1186
|
}
|
|
503
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
|
+
}
|
|
504
1251
|
returnValueContents = `${arrayBasePath}?.map((__item__, __idx__) => (\n${indent(mappedContents)}\n))`;
|
|
505
1252
|
}
|
|
506
1253
|
}
|
|
@@ -509,7 +1256,36 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
509
1256
|
}
|
|
510
1257
|
}
|
|
511
1258
|
else {
|
|
512
|
-
|
|
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
|
+
}
|
|
513
1289
|
}
|
|
514
1290
|
}
|
|
515
1291
|
if (root) {
|
|
@@ -519,6 +1295,12 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
519
1295
|
if (args && args.length > 0) {
|
|
520
1296
|
if (!isValidKey(name))
|
|
521
1297
|
return;
|
|
1298
|
+
// Skip array index patterns like [], [0], [1] when they have args
|
|
1299
|
+
// These represent function calls on array elements, not property keys
|
|
1300
|
+
// e.g., customSizes[].(args) means each array element is callable, not a property named "[]"
|
|
1301
|
+
if (name.match(/^\[\d*\]$/)) {
|
|
1302
|
+
return;
|
|
1303
|
+
}
|
|
522
1304
|
const mostArgs = args.sort((a, b) => b.length - a.length)[0];
|
|
523
1305
|
const argsString = mostArgs
|
|
524
1306
|
.map((_, index) => `arg${index + 1}`)
|
|
@@ -558,8 +1340,19 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
558
1340
|
fallbackContent = `return ${returnValueContents}`;
|
|
559
1341
|
}
|
|
560
1342
|
else {
|
|
561
|
-
//
|
|
562
|
-
|
|
1343
|
+
// No explicit fallback paths - return the first literal's value as default
|
|
1344
|
+
// Returning spread of all values is dangerous because if values are primitives (strings),
|
|
1345
|
+
// spreading them creates objects with numeric keys like {0:'a', 1:'b', ...}
|
|
1346
|
+
// which causes "Objects are not valid as React child" errors
|
|
1347
|
+
const firstLiteralValue = literalKeys[0];
|
|
1348
|
+
const firstGroupPaths = argGroups.get(firstLiteralValue);
|
|
1349
|
+
if (firstGroupPaths && firstGroupPaths.length === 1) {
|
|
1350
|
+
fallbackContent = `return ${firstGroupPaths[0]}`;
|
|
1351
|
+
}
|
|
1352
|
+
else {
|
|
1353
|
+
// Multiple paths for first literal - return undefined as safe fallback
|
|
1354
|
+
fallbackContent = `return undefined`;
|
|
1355
|
+
}
|
|
563
1356
|
}
|
|
564
1357
|
const funcContents = conditionalBranches.join('\n') +
|
|
565
1358
|
'\n// Fallback for unmatched arguments\n' +
|
|
@@ -568,7 +1361,18 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
568
1361
|
}
|
|
569
1362
|
else {
|
|
570
1363
|
// No argument variants - use existing behavior
|
|
571
|
-
|
|
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}`;
|
|
572
1376
|
content = `${cleanOutTypes(name)}: ${isAsyncFunction ? 'async ' : ''}(${argsString}) => {\n${indent(funcContents)}\n}`;
|
|
573
1377
|
}
|
|
574
1378
|
}
|
|
@@ -577,8 +1381,14 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
577
1381
|
return;
|
|
578
1382
|
}
|
|
579
1383
|
else if (name.match(/\[\d*\]/)) {
|
|
1384
|
+
// Numeric array index like [0], [1] - can be used as computed property
|
|
580
1385
|
content = returnValueContents;
|
|
581
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
|
+
}
|
|
582
1392
|
else {
|
|
583
1393
|
content = `${safeString(name)}: ${returnValueContents}`;
|
|
584
1394
|
}
|
|
@@ -590,7 +1400,31 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
590
1400
|
return content;
|
|
591
1401
|
};
|
|
592
1402
|
// Create the return value structure
|
|
593
|
-
|
|
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) => {
|
|
594
1428
|
const aParts = splitOutsideParenthesesAndArrays(a);
|
|
595
1429
|
const bParts = splitOutsideParenthesesAndArrays(b);
|
|
596
1430
|
const maxLength = Math.max(aParts.length, bParts.length);
|
|
@@ -614,6 +1448,36 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
614
1448
|
}
|
|
615
1449
|
return 0;
|
|
616
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
|
+
}
|
|
617
1481
|
for (const key of sortedKeys) {
|
|
618
1482
|
const value = relevantReturnValueSchema[key];
|
|
619
1483
|
const parts = splitOutsideParenthesesAndArrays(key);
|
|
@@ -641,7 +1505,9 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
641
1505
|
parts.splice(i, 1);
|
|
642
1506
|
}
|
|
643
1507
|
}
|
|
644
|
-
|
|
1508
|
+
// Compare against baseMockName (without generics/args), not the full mockName
|
|
1509
|
+
// e.g., for "useFetcher<User>()", baseMockName is "useFetcher"
|
|
1510
|
+
if (parts[0].split('(')[0] !== baseMockName)
|
|
645
1511
|
continue;
|
|
646
1512
|
// Include paths with functionCallReturnValue OR function-typed paths that need mocking
|
|
647
1513
|
const hasFunctionCallReturnValue = parts.some((p) => isFunctionCallReturnValue(p));
|
|
@@ -657,7 +1523,9 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
657
1523
|
// nested inside (e.g., methods on array elements passed as arguments).
|
|
658
1524
|
if (hasSignaturePath)
|
|
659
1525
|
continue;
|
|
660
|
-
|
|
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);
|
|
661
1529
|
// Skip JSX components - they look like function calls (e.g., Context.Provider())
|
|
662
1530
|
// but they're React components used in JSX, not functions that need mocking
|
|
663
1531
|
// Check both the value type and whether the functionCallReturnValue is jsx-component
|
|
@@ -666,6 +1534,35 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
666
1534
|
'jsx-component';
|
|
667
1535
|
if (isJsxComponent)
|
|
668
1536
|
continue;
|
|
1537
|
+
// Skip paths that bypass .functionCallReturnValue when there's a corresponding path with it.
|
|
1538
|
+
// Example: If we have both:
|
|
1539
|
+
// - trpc.customer.useQuery(...).data (incorrect - no .functionCallReturnValue)
|
|
1540
|
+
// - trpc.customer.useQuery(...).functionCallReturnValue.data (correct)
|
|
1541
|
+
// We should skip the first path because the second one properly captures the return value.
|
|
1542
|
+
// This can happen when the analyzer sees both the raw property access and the return value structure.
|
|
1543
|
+
if (!hasFunctionCallReturnValue) {
|
|
1544
|
+
// This path has no .functionCallReturnValue. Check if any function call in this path
|
|
1545
|
+
// has a corresponding .functionCallReturnValue path in the schema.
|
|
1546
|
+
let shouldSkipKey = false;
|
|
1547
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
1548
|
+
const part = parts[i];
|
|
1549
|
+
if (part.endsWith(')') && !isFunctionCallReturnValue(parts[i + 1])) {
|
|
1550
|
+
// This part is a function call, and the next part is NOT .functionCallReturnValue
|
|
1551
|
+
// Check if there's any path with .functionCallReturnValue for this function call
|
|
1552
|
+
const functionCallPath = joinParenthesesAndArrays(parts.slice(0, i + 1));
|
|
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);
|
|
1556
|
+
if (hasProperFunctionCallPath) {
|
|
1557
|
+
// Skip this path - the .functionCallReturnValue path will handle it correctly
|
|
1558
|
+
shouldSkipKey = true;
|
|
1559
|
+
break;
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
if (shouldSkipKey)
|
|
1564
|
+
continue;
|
|
1565
|
+
}
|
|
669
1566
|
const isFunctionPath = ['function', 'async-function'].includes(value) &&
|
|
670
1567
|
parts[parts.length - 1].endsWith(')') &&
|
|
671
1568
|
!hasAnyFunctionCallReturnValue &&
|
|
@@ -709,6 +1606,16 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
709
1606
|
const nextIsArray = !!nextPart?.match(/^\[\d*\]/);
|
|
710
1607
|
const isDifferentiatedArray = !!part?.match(/^\[\d+\]/);
|
|
711
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
|
+
}
|
|
712
1619
|
// Find the correct value for the current part being processed
|
|
713
1620
|
let partValue = value; // default to the final value
|
|
714
1621
|
if (isFunctionCallReturnValue(part) && nextIsArray) {
|
|
@@ -800,7 +1707,35 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
800
1707
|
}
|
|
801
1708
|
}
|
|
802
1709
|
else {
|
|
803
|
-
|
|
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
|
+
}
|
|
804
1739
|
}
|
|
805
1740
|
}
|
|
806
1741
|
}
|
|
@@ -821,7 +1756,8 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
821
1756
|
}
|
|
822
1757
|
// If the next part is an object with nested content, continue processing
|
|
823
1758
|
// This handles paths like functionCallReturnValue.selectedOptions.elementOptions[]
|
|
824
|
-
|
|
1759
|
+
// Also handles union types like 'array | undefined' or 'object | undefined'
|
|
1760
|
+
if (nextValue?.includes('object') || nextValue?.includes('array')) {
|
|
825
1761
|
continue;
|
|
826
1762
|
}
|
|
827
1763
|
}
|
|
@@ -932,12 +1868,18 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
932
1868
|
returnValueSection.nested.push(relevantPart);
|
|
933
1869
|
}
|
|
934
1870
|
}
|
|
935
|
-
else
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
1871
|
+
else {
|
|
1872
|
+
// Add args to existing entry if current part has function arguments
|
|
1873
|
+
// This handles the case where bare `t` is processed first (creating {name: 't', args: undefined})
|
|
1874
|
+
// and then `t("common.close")` is processed - we need to add its args to the existing entry
|
|
1875
|
+
const currentArgs = funcArgs(part);
|
|
1876
|
+
const hasNewArgs = currentArgs.length > 0 || part.includes('(');
|
|
1877
|
+
if (hasNewArgs) {
|
|
1878
|
+
const existingArgs = relevantPart.args?.find((args) => args.join(',') === currentArgs.join(','));
|
|
1879
|
+
if (!existingArgs) {
|
|
1880
|
+
relevantPart.args || (relevantPart.args = []);
|
|
1881
|
+
relevantPart.args.push(currentArgs);
|
|
1882
|
+
}
|
|
941
1883
|
}
|
|
942
1884
|
}
|
|
943
1885
|
// If nextPart is [], update existing part to be a generic array
|
|
@@ -945,7 +1887,12 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
945
1887
|
relevantPart.isArray = true;
|
|
946
1888
|
relevantPart.isGenericArray = true;
|
|
947
1889
|
}
|
|
948
|
-
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) {
|
|
949
1896
|
// Before breaking, check if this function returns an array
|
|
950
1897
|
// by looking for a functionCallReturnValue: 'array' entry in the schema
|
|
951
1898
|
if (relevantPart && part.endsWith(')')) {
|
|
@@ -973,6 +1920,7 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
973
1920
|
const contents = constructReturnValueString(returnValueParts);
|
|
974
1921
|
if (mockNameParts.length > 1) {
|
|
975
1922
|
const originalLib = `${mockNameParts[0]}__cyOriginal`;
|
|
1923
|
+
const skipOriginalSpread = options?.skipOriginalSpread;
|
|
976
1924
|
const subPart = (parts, originalLib) => {
|
|
977
1925
|
const part = parts.shift();
|
|
978
1926
|
if (!isValidKey(part))
|
|
@@ -980,7 +1928,9 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
980
1928
|
const isLast = parts.length === 0;
|
|
981
1929
|
const partContents = isLast
|
|
982
1930
|
? contents
|
|
983
|
-
:
|
|
1931
|
+
: skipOriginalSpread
|
|
1932
|
+
? subPart(parts, originalLib)
|
|
1933
|
+
: `...${originalLib}.${part},\n${subPart(parts, originalLib)}`;
|
|
984
1934
|
let code = `${part}: {\n${indent(partContents)}\n}`;
|
|
985
1935
|
if (part.includes('(') || (isFunction && isLast)) {
|
|
986
1936
|
const args = funcArgs(part)
|
|
@@ -990,26 +1940,30 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
990
1940
|
}
|
|
991
1941
|
return code;
|
|
992
1942
|
};
|
|
993
|
-
const returnParts =
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
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};`;
|
|
998
1950
|
}
|
|
999
1951
|
else if (isFunction) {
|
|
1000
1952
|
// For headers() and cookies() from next/headers, add common iterator methods
|
|
1001
1953
|
// These are needed when the mock is passed to functions that use .entries(), .keys(), etc.
|
|
1002
1954
|
// (e.g., Object.fromEntries(headers.entries()) in buildLegacyHeaders)
|
|
1003
|
-
const needsIteratorMethods =
|
|
1955
|
+
const needsIteratorMethods = baseMockName === 'headers' || baseMockName === 'cookies';
|
|
1004
1956
|
let enhancedContents = contents;
|
|
1005
1957
|
if (needsIteratorMethods && contents.trim().startsWith('{')) {
|
|
1006
1958
|
// Add iterator methods that operate on the scenario data
|
|
1959
|
+
// Use the dataKey (original call signature or canonical key)
|
|
1960
|
+
const quotedDataKey = quotePropertyKey(dataKey);
|
|
1007
1961
|
const iteratorMethods = `,
|
|
1008
|
-
entries: () => Object.entries(scenarios().data()
|
|
1009
|
-
keys: () => Object.keys(scenarios().data()
|
|
1010
|
-
values: () => Object.values(scenarios().data()
|
|
1011
|
-
forEach: (fn) => Object.entries(scenarios().data()
|
|
1012
|
-
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)`;
|
|
1013
1967
|
// Insert before the closing brace (handle trailing whitespace)
|
|
1014
1968
|
enhancedContents = contents.replace(/\}\s*$/, iteratorMethods + '\n}');
|
|
1015
1969
|
}
|
|
@@ -1019,32 +1973,129 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
1019
1973
|
// `new ClassName("arg")` wouldn't create the expected instance.
|
|
1020
1974
|
// For Error subclasses (detected by name ending in "Error"), extend Error for proper error handling.
|
|
1021
1975
|
if (entityType === 'class') {
|
|
1022
|
-
const isErrorSubclass =
|
|
1023
|
-
const baseClass = isErrorSubclass ? 'Error' : 'Object';
|
|
1976
|
+
const isErrorSubclass = baseMockName.endsWith('Error');
|
|
1024
1977
|
const superCall = isErrorSubclass ? 'super(message);' : '';
|
|
1025
1978
|
const nameAssignment = isErrorSubclass
|
|
1026
|
-
? `this.name = '${
|
|
1979
|
+
? `this.name = '${baseMockName}';`
|
|
1027
1980
|
: '';
|
|
1028
|
-
|
|
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' : ''} {
|
|
1029
1986
|
constructor(message) {
|
|
1030
1987
|
${superCall}
|
|
1031
1988
|
${nameAssignment}
|
|
1032
|
-
Object.assign(this, scenarios().data()
|
|
1989
|
+
Object.assign(this, scenarios().data()?.${quotePropertyKey(dataKey)} || {});
|
|
1033
1990
|
}
|
|
1034
1991
|
}`;
|
|
1035
1992
|
}
|
|
1036
|
-
//
|
|
1037
|
-
//
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
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
|
+
}
|
|
2013
|
+
// Check if this function returns a function (detected by double-call pattern: mockName(args)())
|
|
2014
|
+
// This happens when the schema has keys like "wrapThrows(() => JSON.parse(savedFilters))()"
|
|
2015
|
+
// where the function call is immediately followed by another call.
|
|
2016
|
+
// Example usage: const result = wrapThrows(() => JSON.parse(x))(); // double call
|
|
2017
|
+
const isHigherOrderFunction = Object.keys(relevantReturnValueSchema ?? {}).some((key) => {
|
|
2018
|
+
if (!key.startsWith(baseMockName))
|
|
2019
|
+
return false;
|
|
2020
|
+
// Find the first ( after baseMockName (the start of the function call)
|
|
2021
|
+
const firstOpenParen = key.indexOf('(', baseMockName.length);
|
|
2022
|
+
if (firstOpenParen === -1)
|
|
2023
|
+
return false;
|
|
2024
|
+
// Skip if the ( is not immediately after the mock name
|
|
2025
|
+
// (there might be type params like func<T>() - handle by checking for < or ()
|
|
2026
|
+
const between = key.slice(baseMockName.length, firstOpenParen);
|
|
2027
|
+
if (between.length > 0 && !between.startsWith('<'))
|
|
2028
|
+
return false;
|
|
2029
|
+
// Find the matching ) for the first ( using depth counting
|
|
2030
|
+
let depth = 1;
|
|
2031
|
+
let i = firstOpenParen + 1;
|
|
2032
|
+
while (i < key.length && depth > 0) {
|
|
2033
|
+
if (key[i] === '(')
|
|
2034
|
+
depth++;
|
|
2035
|
+
if (key[i] === ')')
|
|
2036
|
+
depth--;
|
|
2037
|
+
i++;
|
|
2038
|
+
}
|
|
2039
|
+
if (depth !== 0)
|
|
2040
|
+
return false; // Unbalanced parentheses
|
|
2041
|
+
// Now i points just after the matching )
|
|
2042
|
+
// Check if there's another ( immediately (indicating double call)
|
|
2043
|
+
const remaining = key.slice(i);
|
|
2044
|
+
if (remaining.startsWith('('))
|
|
2045
|
+
return true;
|
|
2046
|
+
return false;
|
|
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
|
|
2050
|
+
// For higher-order functions, wrap the return in an arrow function
|
|
2051
|
+
// so that mockFunc(arg)() works correctly (outer call returns a function, inner call gets the data)
|
|
2052
|
+
const returnValue = isHigherOrderFunction
|
|
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');
|
|
1042
2080
|
}
|
|
1043
2081
|
else {
|
|
1044
|
-
//
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
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
|
+
}
|
|
1048
2099
|
// Get any jsx-component properties that need to be preserved from the original
|
|
1049
2100
|
const jsxProperties = getJsxComponentProperties(mockName, relevantReturnValueSchema);
|
|
1050
2101
|
// If there are jsx-component properties, add them as references to the original
|