@codeyam/codeyam-cli 0.1.0-staging.76566f9 → 0.1.0-staging.7baa6db
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/analyzer-template/.build-info.json +8 -8
- package/analyzer-template/common/execAsync.ts +1 -1
- package/analyzer-template/log.txt +3 -3
- package/analyzer-template/package.json +15 -12
- package/analyzer-template/packages/ai/index.ts +21 -5
- package/analyzer-template/packages/ai/package.json +3 -3
- package/analyzer-template/packages/ai/src/lib/__mocks__/completionCall.ts +122 -0
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +226 -24
- package/analyzer-template/packages/ai/src/lib/astScopes/arrayDerivationDetector.ts +199 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +183 -10
- package/analyzer-template/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.ts +644 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +181 -23
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.ts +10 -17
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.ts +18 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.ts +15 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.ts +181 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +1229 -30
- package/analyzer-template/packages/ai/src/lib/astScopes/sharedPatterns.ts +28 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +265 -6
- package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +29 -10
- package/analyzer-template/packages/ai/src/lib/completionCall.ts +216 -36
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +1750 -318
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +5 -1
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +296 -35
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +10 -2
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.ts +16 -3
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.ts +6 -4
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +54 -3
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +129 -20
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.ts +70 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +140 -14
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.ts +179 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.ts +40 -30
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +393 -90
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.ts +129 -0
- package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +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 +33 -7
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +86 -142
- package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +59 -3
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +1385 -67
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +200 -196
- 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/guessScenarioDataFromDescription.ts +5 -5
- package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +328 -7
- package/analyzer-template/packages/ai/src/lib/mergeJsonTypeDefinitions.ts +5 -0
- package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +111 -87
- package/analyzer-template/packages/ai/src/lib/promptGenerators/collapseNullableObjects.ts +118 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +10 -7
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.ts +1 -1
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +32 -142
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChunkPrompt.ts +82 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateCriticalKeysPrompt.ts +103 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +110 -6
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.ts +14 -89
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.ts +58 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.ts +11 -11
- package/analyzer-template/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.ts +391 -0
- package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +824 -0
- package/analyzer-template/packages/ai/src/lib/splitOutsideParentheses.ts +5 -1
- package/analyzer-template/packages/ai/src/lib/validateExecutionFlowPaths.ts +531 -0
- package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +122 -3
- package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +114 -2
- package/analyzer-template/packages/analyze/index.ts +2 -0
- package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +79 -59
- package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +113 -26
- package/analyzer-template/packages/analyze/src/lib/analysisContext.ts +44 -4
- package/analyzer-template/packages/analyze/src/lib/asts/nodes/index.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/asts/nodes/isAsyncFunction.ts +67 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.ts +19 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.ts +19 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllExports.ts +11 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.ts +8 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.ts +49 -1
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.ts +2 -1
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +467 -283
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +34 -1
- package/analyzer-template/packages/analyze/src/lib/files/analyze/dependencyResolver.ts +6 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +3 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/gatherEntityMap.ts +4 -2
- package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +33 -10
- package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +31 -15
- package/analyzer-template/packages/analyze/src/lib/files/analyzeEntity.ts +11 -7
- package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +11 -12
- package/analyzer-template/packages/analyze/src/lib/files/analyzeRemixRoute.ts +4 -5
- package/analyzer-template/packages/analyze/src/lib/files/enums/steps.ts +1 -1
- package/analyzer-template/packages/analyze/src/lib/files/getImportedExports.ts +14 -12
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/TransformationTracer.ts +1315 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +201 -46
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.ts +102 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +304 -66
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.ts +28 -62
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +306 -20
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +264 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +2 -3
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +825 -71
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.ts +56 -11
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/propagateArrayItemSchemas.ts +474 -0
- package/analyzer-template/packages/analyze/src/lib/files/setImportedExports.ts +2 -1
- package/analyzer-template/packages/analyze/src/lib/index.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/utils/getFileByPath.ts +19 -0
- package/analyzer-template/packages/aws/codebuild/index.ts +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts +11 -1
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js +29 -18
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts +2 -2
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js +2 -2
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts +8 -18
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js +17 -61
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js +8 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js.map +1 -1
- package/analyzer-template/packages/aws/package.json +3 -3
- package/analyzer-template/packages/aws/src/lib/codebuild/waitForBuild.ts +43 -19
- package/analyzer-template/packages/aws/src/lib/ecs/ecsDefineContainer.ts +3 -3
- package/analyzer-template/packages/aws/src/lib/ecs/ecsTaskFactory.ts +17 -69
- package/analyzer-template/packages/aws/src/lib/s3/uploadFileToS3.ts +8 -1
- package/analyzer-template/packages/database/package.json +1 -1
- package/analyzer-template/packages/database/src/lib/analysisBranchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/analysisToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/branchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/commitBranchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/commitToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/fileToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/kysely/db.ts +14 -1
- package/analyzer-template/packages/database/src/lib/kysely/tables/commitsTable.ts +6 -0
- package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +17 -1
- package/analyzer-template/packages/database/src/lib/kysely/tables/labsRequestsTable.ts +52 -0
- package/analyzer-template/packages/database/src/lib/loadAnalyses.ts +58 -1
- package/analyzer-template/packages/database/src/lib/loadAnalysis.ts +13 -0
- package/analyzer-template/packages/database/src/lib/loadBranch.ts +16 -1
- package/analyzer-template/packages/database/src/lib/loadCommit.ts +11 -0
- package/analyzer-template/packages/database/src/lib/loadCommits.ts +28 -0
- package/analyzer-template/packages/database/src/lib/loadEntities.ts +26 -3
- package/analyzer-template/packages/database/src/lib/loadEntityBranches.ts +12 -0
- package/analyzer-template/packages/database/src/lib/loadReadyToBeCapturedAnalyses.ts +7 -3
- package/analyzer-template/packages/database/src/lib/projectToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/saveFiles.ts +1 -1
- package/analyzer-template/packages/database/src/lib/scenarioToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +7 -14
- package/analyzer-template/packages/database/src/lib/userScenarioToDb.ts +1 -1
- package/analyzer-template/packages/generate/index.ts +3 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.ts +17 -1
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.ts +193 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.ts +73 -0
- package/analyzer-template/packages/generate/src/lib/scenarioComponentForServer.ts +114 -0
- package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts +2 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +11 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts +1 -18
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js +3 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +17 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.d.ts +23 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js +35 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts +2 -6
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts +2 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js +45 -2
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js +8 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js +11 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js +7 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts +3 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js +22 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts +3 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js +23 -4
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js +9 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js +7 -4
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts +2 -2
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js +5 -4
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/index.d.ts +3 -0
- package/analyzer-template/packages/github/dist/generate/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/index.js +3 -0
- package/analyzer-template/packages/github/dist/generate/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts +9 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts +20 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts +8 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js +89 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js.map +1 -0
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js +10 -0
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js +3 -0
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.d.ts +3 -4
- package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.js +0 -1
- package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +71 -27
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts +7 -0
- package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts +9 -54
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.js +1 -21
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +153 -5
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts +9 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js +29 -3
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js.map +1 -1
- package/analyzer-template/packages/github/package.json +1 -1
- package/analyzer-template/packages/github/src/lib/loadOrCreateCommit.ts +14 -0
- package/analyzer-template/packages/github/src/lib/syncPrimaryBranch.ts +2 -0
- package/analyzer-template/packages/process/index.ts +2 -0
- package/analyzer-template/packages/process/package.json +12 -0
- package/analyzer-template/packages/process/tsconfig.json +8 -0
- package/analyzer-template/packages/types/index.ts +3 -6
- package/analyzer-template/packages/types/src/types/Analysis.ts +87 -27
- package/analyzer-template/packages/types/src/types/Commit.ts +2 -0
- package/analyzer-template/packages/types/src/types/Entity.ts +2 -0
- package/analyzer-template/packages/types/src/types/ProjectMetadata.ts +7 -0
- package/analyzer-template/packages/types/src/types/Scenario.ts +9 -77
- package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +181 -5
- package/analyzer-template/packages/types/src/types/ScopeAnalysis.ts +6 -1
- package/analyzer-template/packages/types/src/types/StatementInfo.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/index.d.ts +3 -4
- package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/index.js +0 -1
- package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +71 -27
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts +7 -0
- package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts +9 -54
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.js +1 -21
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.js.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +153 -5
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js +93 -2
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts +9 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js +29 -3
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js.map +1 -1
- package/analyzer-template/packages/utils/src/lib/fs/rsyncCopy.ts +108 -2
- package/analyzer-template/packages/utils/src/lib/safeFileName.ts +48 -3
- package/analyzer-template/playwright/capture.ts +57 -26
- package/analyzer-template/playwright/captureStatic.ts +1 -1
- package/analyzer-template/playwright/getCodeYamInfo.ts +12 -7
- package/analyzer-template/playwright/waitForServer.ts +21 -6
- package/analyzer-template/project/analyzeBaselineCommit.ts +9 -0
- package/analyzer-template/project/analyzeBranchCommit.ts +4 -0
- package/analyzer-template/project/analyzeFileEntities.ts +4 -0
- package/analyzer-template/project/analyzeRegularCommit.ts +9 -0
- package/analyzer-template/project/captureLibraryFunctionDirect.ts +29 -26
- package/analyzer-template/project/constructMockCode.ts +1006 -107
- package/analyzer-template/project/controller/startController.ts +16 -1
- package/analyzer-template/project/createEntitiesAndSortFiles.ts +83 -0
- package/analyzer-template/project/executeLibraryFunctionDirect.ts +7 -3
- package/analyzer-template/project/loadReadyToBeCaptured.ts +65 -41
- package/analyzer-template/project/mocks/analyzeFileMock.ts +8 -7
- package/analyzer-template/project/orchestrateCapture/AwsCaptureTaskRunner.ts +12 -4
- package/analyzer-template/project/orchestrateCapture/KyselyAnalysisLoader.ts +3 -6
- package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +18 -7
- package/analyzer-template/project/orchestrateCapture/taskRunner.ts +4 -2
- package/analyzer-template/project/orchestrateCapture.ts +81 -9
- package/analyzer-template/project/reconcileMockDataKeys.ts +240 -0
- package/analyzer-template/project/runAnalysis.ts +11 -0
- package/analyzer-template/project/serverOnlyModules.ts +127 -2
- package/analyzer-template/project/start.ts +51 -15
- package/analyzer-template/project/startScenarioCapture.ts +6 -0
- package/analyzer-template/project/writeMockDataTsx.ts +298 -11
- package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
- package/analyzer-template/project/writeScenarioComponents.ts +326 -42
- package/analyzer-template/project/writeScenarioFiles.ts +26 -0
- package/analyzer-template/project/writeSimpleRoot.ts +23 -13
- 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 +881 -71
- package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
- package/background/src/lib/virtualized/project/controller/startController.js +11 -1
- package/background/src/lib/virtualized/project/controller/startController.js.map +1 -1
- package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js +73 -1
- package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js.map +1 -1
- package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js +6 -3
- package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js.map +1 -1
- package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js +19 -8
- package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js.map +1 -1
- package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js +7 -7
- package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js +2 -2
- package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js +3 -2
- package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +7 -5
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture.js +65 -10
- package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +199 -0
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
- package/background/src/lib/virtualized/project/runAnalysis.js +9 -0
- package/background/src/lib/virtualized/project/runAnalysis.js.map +1 -1
- package/background/src/lib/virtualized/project/serverOnlyModules.js +106 -3
- package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -1
- package/background/src/lib/virtualized/project/start.js +47 -15
- package/background/src/lib/virtualized/project/start.js.map +1 -1
- package/background/src/lib/virtualized/project/startScenarioCapture.js +7 -0
- package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/writeMockDataTsx.js +255 -8
- 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 +255 -41
- 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 +23 -13
- package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
- package/codeyam-cli/scripts/apply-setup.js +180 -0
- package/codeyam-cli/scripts/apply-setup.js.map +1 -1
- package/codeyam-cli/src/cli.js +9 -1
- package/codeyam-cli/src/cli.js.map +1 -1
- package/codeyam-cli/src/codeyam-cli.js +18 -2
- package/codeyam-cli/src/codeyam-cli.js.map +1 -1
- package/codeyam-cli/src/commands/analyze.js +5 -3
- package/codeyam-cli/src/commands/analyze.js.map +1 -1
- package/codeyam-cli/src/commands/baseline.js +176 -0
- package/codeyam-cli/src/commands/baseline.js.map +1 -0
- package/codeyam-cli/src/commands/debug.js +37 -23
- package/codeyam-cli/src/commands/debug.js.map +1 -1
- package/codeyam-cli/src/commands/default.js +30 -34
- package/codeyam-cli/src/commands/default.js.map +1 -1
- package/codeyam-cli/src/commands/detect-universal-mocks.js +2 -0
- package/codeyam-cli/src/commands/detect-universal-mocks.js.map +1 -1
- package/codeyam-cli/src/commands/init.js +49 -257
- package/codeyam-cli/src/commands/init.js.map +1 -1
- package/codeyam-cli/src/commands/memory.js +307 -0
- package/codeyam-cli/src/commands/memory.js.map +1 -0
- package/codeyam-cli/src/commands/recapture.js +31 -18
- package/codeyam-cli/src/commands/recapture.js.map +1 -1
- package/codeyam-cli/src/commands/report.js +46 -1
- package/codeyam-cli/src/commands/report.js.map +1 -1
- package/codeyam-cli/src/commands/setup-sandbox.js +2 -0
- package/codeyam-cli/src/commands/setup-sandbox.js.map +1 -1
- package/codeyam-cli/src/commands/setup-simulations.js +284 -0
- package/codeyam-cli/src/commands/setup-simulations.js.map +1 -0
- package/codeyam-cli/src/commands/start.js +8 -12
- package/codeyam-cli/src/commands/start.js.map +1 -1
- package/codeyam-cli/src/commands/status.js +23 -1
- package/codeyam-cli/src/commands/status.js.map +1 -1
- package/codeyam-cli/src/commands/test-startup.js +3 -1
- package/codeyam-cli/src/commands/test-startup.js.map +1 -1
- package/codeyam-cli/src/commands/verify.js +14 -2
- package/codeyam-cli/src/commands/verify.js.map +1 -1
- package/codeyam-cli/src/commands/wipe.js +108 -0
- package/codeyam-cli/src/commands/wipe.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/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 +102 -21
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/database.js +91 -5
- package/codeyam-cli/src/utils/database.js.map +1 -1
- package/codeyam-cli/src/utils/generateReport.js +4 -3
- package/codeyam-cli/src/utils/generateReport.js.map +1 -1
- package/codeyam-cli/src/utils/git.js +79 -0
- package/codeyam-cli/src/utils/git.js.map +1 -0
- package/codeyam-cli/src/utils/install-skills.js +76 -37
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/labsAutoCheck.js +19 -0
- package/codeyam-cli/src/utils/labsAutoCheck.js.map +1 -0
- package/codeyam-cli/src/utils/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/job.js +109 -0
- package/codeyam-cli/src/utils/queue/job.js.map +1 -1
- package/codeyam-cli/src/utils/queue/manager.js +6 -0
- package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
- package/codeyam-cli/src/utils/queue/persistence.js.map +1 -1
- package/codeyam-cli/src/utils/requireSimulations.js +10 -0
- package/codeyam-cli/src/utils/requireSimulations.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js +82 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js +230 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js +67 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js +105 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js +34 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js +162 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js +74 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js +376 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js +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 +88 -23
- package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
- package/codeyam-cli/src/webserver/app/lib/dbNotifier.js.map +1 -1
- package/codeyam-cli/src/webserver/backgroundServer.js +50 -0
- package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/webserver/bootstrap.js +51 -0
- package/codeyam-cli/src/webserver/bootstrap.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/CopyButton-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-CzGX-miz.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-CBQPrpT0.js → LibraryFunctionPreview-Cq5o8jL4.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-D1CdlbrV.js → LoadingDots-BvMu2i-g.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-wDPcZNKx.js → LogViewer-kgBTLoJD.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-BzPgx-xO.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-BfmDgXxG.js → SafeScreenshot-CwZrv-Ok.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-BX2Ny2Qj.js +10 -0
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-6J7zDUD5.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.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-BYimnrHg.js → chevron-down-CG65viiV.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/chunk-JZWAC4HX-DB3aFuEO.js +51 -0
- package/codeyam-cli/src/webserver/build/client/assets/{circle-check-CaVsIRxt.js → circle-check-igfMr5DY.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/copy-Coc4o_8c.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-CgUsG7ib.js → createLucideIcon-D1zB-pYc.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-C1gnJVOL.svg → cy-logo-cli-CCKUIm0S.svg} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DcX-ZS3p.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-JTAjQ54M.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-Dt-SjPsw.js → entity._sha._-B0h9AqE6.js} +12 -12
- 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-CfLCUi9S.js → entity._sha_.edit._scenarioId-PePWg17F.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entry.client-DKJyZfAY.js → entry.client-I-Wo99C_.js} +6 -6
- package/codeyam-cli/src/webserver/build/client/assets/executionFlowCoverage-BWhdfn70.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{fileTableUtils-DAtOlaWE.js → fileTableUtils-9sMMAiWJ.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-Co65J0s3.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{git-D62Lxxmv.js → git-BdHOxVfg.js} +8 -8
- package/codeyam-cli/src/webserver/build/client/assets/globals-OvbPxnso.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{index-CzNNiTkw.js → index-CUM5iXwc.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{index-BosqDOlH.js → index-_417gcQW.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/labs-BK0C1H1T.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-CNp9QFCX.js → loader-circle-TzRHMVog.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-1dde4642.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-CSehFhoZ.js +92 -0
- package/codeyam-cli/src/webserver/build/client/assets/pause-hjzB7t2z.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/root-WysVEEJs.js +62 -0
- package/codeyam-cli/src/webserver/build/client/assets/{search-DDGjYAMJ.js → search-DcAwD_Ln.js} +1 -1
- 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-CBc5dE1s.js → triangle-alert-CAD5b1o_.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-BqgrAzs3.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-BqPPNjAl.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-DWHcCcl1.js → useToast-ihdMtlf6.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-Bs3qItZt.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-CqaV_Zaw.js +273 -0
- package/codeyam-cli/src/webserver/build/server/index.js +1 -1
- package/codeyam-cli/src/webserver/build-info.json +5 -5
- package/codeyam-cli/src/webserver/server.js +35 -25
- package/codeyam-cli/src/webserver/server.js.map +1 -1
- package/codeyam-cli/templates/{codeyam-debug-skill.md → codeyam-debug.md} +48 -4
- package/codeyam-cli/templates/codeyam-diagnose.md +481 -0
- package/codeyam-cli/templates/codeyam-memory-hook.sh +199 -0
- package/codeyam-cli/templates/codeyam-memory.md +396 -0
- package/codeyam-cli/templates/codeyam-new-rule.md +13 -0
- package/codeyam-cli/templates/{codeyam-setup-skill.md → codeyam-setup.md} +13 -1
- package/codeyam-cli/templates/{codeyam-sim-skill.md → codeyam-sim.md} +1 -1
- package/codeyam-cli/templates/{codeyam-test-skill.md → codeyam-test.md} +1 -1
- package/codeyam-cli/templates/{codeyam-verify-skill.md → codeyam-verify.md} +1 -1
- package/codeyam-cli/templates/rule-notification-hook.py +56 -0
- package/codeyam-cli/templates/rule-reflection-hook.py +627 -0
- package/codeyam-cli/templates/rules-instructions.md +132 -0
- package/package.json +17 -14
- package/packages/ai/index.js +8 -6
- package/packages/ai/index.js.map +1 -1
- package/packages/ai/src/lib/analyzeScope.js +179 -13
- package/packages/ai/src/lib/analyzeScope.js.map +1 -1
- package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js +150 -0
- package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js.map +1 -0
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +138 -9
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
- package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js +435 -0
- package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js.map +1 -0
- package/packages/ai/src/lib/astScopes/methodSemantics.js +138 -23
- package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js +10 -14
- package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js +8 -0
- package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js +7 -0
- package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js +138 -1
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/processExpression.js +944 -30
- package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
- package/packages/ai/src/lib/astScopes/sharedPatterns.js +25 -0
- package/packages/ai/src/lib/astScopes/sharedPatterns.js.map +1 -1
- package/packages/ai/src/lib/checkAllAttributes.js +24 -9
- package/packages/ai/src/lib/checkAllAttributes.js.map +1 -1
- package/packages/ai/src/lib/completionCall.js +178 -31
- package/packages/ai/src/lib/completionCall.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +1367 -187
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +5 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +230 -23
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +7 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js +13 -3
- package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js +6 -4
- package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +52 -3
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +111 -14
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js +63 -0
- package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +122 -12
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js +173 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js +37 -20
- package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +333 -81
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js +107 -0
- package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructureChunking.js +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 +21 -5
- package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateChangesEntityScenarios.js +78 -120
- package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateEntityDataStructure.js +47 -2
- package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarioData.js +1101 -62
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarios.js +177 -163
- package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +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/guessScenarioDataFromDescription.js +2 -2
- package/packages/ai/src/lib/guessScenarioDataFromDescription.js.map +1 -1
- package/packages/ai/src/lib/isolateScopes.js +270 -7
- package/packages/ai/src/lib/isolateScopes.js.map +1 -1
- package/packages/ai/src/lib/mergeJsonTypeDefinitions.js +5 -0
- package/packages/ai/src/lib/mergeJsonTypeDefinitions.js.map +1 -1
- package/packages/ai/src/lib/mergeStatements.js +88 -46
- package/packages/ai/src/lib/mergeStatements.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js +97 -0
- package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +10 -4
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +21 -100
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js +54 -0
- package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +83 -6
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js +10 -70
- package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js +45 -0
- package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js +9 -9
- package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js +335 -0
- package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js.map +1 -0
- package/packages/ai/src/lib/resolvePathToControllable.js +677 -0
- package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -0
- package/packages/ai/src/lib/splitOutsideParentheses.js +3 -1
- package/packages/ai/src/lib/splitOutsideParentheses.js.map +1 -1
- package/packages/ai/src/lib/worker/SerializableDataStructure.js +29 -0
- package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js +94 -1
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js.map +1 -1
- package/packages/analyze/index.js +1 -0
- package/packages/analyze/index.js.map +1 -1
- package/packages/analyze/src/lib/FileAnalyzer.js +75 -36
- package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/ProjectAnalyzer.js +96 -26
- package/packages/analyze/src/lib/ProjectAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/analysisContext.js +30 -5
- package/packages/analyze/src/lib/analysisContext.js.map +1 -1
- package/packages/analyze/src/lib/asts/nodes/index.js +1 -0
- package/packages/analyze/src/lib/asts/nodes/index.js.map +1 -1
- package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js +52 -0
- package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js.map +1 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js +14 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js +14 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js +6 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js +6 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js +39 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js +2 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +206 -57
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +24 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/dependencyResolver.js +5 -0
- package/packages/analyze/src/lib/files/analyze/dependencyResolver.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +2 -0
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js +2 -1
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +31 -10
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeChange.js +21 -11
- package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeEntity.js +9 -8
- package/packages/analyze/src/lib/files/analyzeEntity.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeInitial.js +9 -10
- package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeRemixRoute.js +3 -2
- package/packages/analyze/src/lib/files/analyzeRemixRoute.js.map +1 -1
- package/packages/analyze/src/lib/files/enums/steps.js +1 -1
- package/packages/analyze/src/lib/files/enums/steps.js.map +1 -1
- package/packages/analyze/src/lib/files/getImportedExports.js +11 -7
- package/packages/analyze/src/lib/files/getImportedExports.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js +880 -0
- package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +170 -40
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js +85 -0
- package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +253 -42
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js +29 -34
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +218 -20
- 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 +1 -0
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +2 -3
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +670 -53
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js +46 -9
- package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/setImportedExports.js +2 -1
- package/packages/analyze/src/lib/files/setImportedExports.js.map +1 -1
- package/packages/analyze/src/lib/index.js +1 -0
- package/packages/analyze/src/lib/index.js.map +1 -1
- package/packages/analyze/src/lib/utils/getFileByPath.js +12 -0
- package/packages/analyze/src/lib/utils/getFileByPath.js.map +1 -0
- package/packages/aws/src/lib/ecs/ecsDefineContainer.js +2 -2
- package/packages/aws/src/lib/ecs/ecsDefineContainer.js.map +1 -1
- package/packages/aws/src/lib/ecs/ecsTaskFactory.js +17 -61
- package/packages/aws/src/lib/ecs/ecsTaskFactory.js.map +1 -1
- package/packages/database/src/lib/analysisBranchToDb.js +1 -1
- package/packages/database/src/lib/analysisBranchToDb.js.map +1 -1
- package/packages/database/src/lib/analysisToDb.js +1 -1
- package/packages/database/src/lib/analysisToDb.js.map +1 -1
- package/packages/database/src/lib/branchToDb.js +1 -1
- package/packages/database/src/lib/branchToDb.js.map +1 -1
- package/packages/database/src/lib/commitBranchToDb.js +1 -1
- package/packages/database/src/lib/commitBranchToDb.js.map +1 -1
- package/packages/database/src/lib/commitToDb.js +1 -1
- package/packages/database/src/lib/commitToDb.js.map +1 -1
- package/packages/database/src/lib/fileToDb.js +1 -1
- package/packages/database/src/lib/fileToDb.js.map +1 -1
- package/packages/database/src/lib/kysely/db.js +11 -1
- package/packages/database/src/lib/kysely/db.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/commitsTable.js +3 -0
- package/packages/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/labsRequestsTable.js +35 -0
- package/packages/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
- package/packages/database/src/lib/loadAnalyses.js +45 -2
- package/packages/database/src/lib/loadAnalyses.js.map +1 -1
- package/packages/database/src/lib/loadAnalysis.js +8 -0
- package/packages/database/src/lib/loadAnalysis.js.map +1 -1
- package/packages/database/src/lib/loadBranch.js +11 -1
- package/packages/database/src/lib/loadBranch.js.map +1 -1
- package/packages/database/src/lib/loadCommit.js +7 -0
- package/packages/database/src/lib/loadCommit.js.map +1 -1
- package/packages/database/src/lib/loadCommits.js +22 -1
- package/packages/database/src/lib/loadCommits.js.map +1 -1
- package/packages/database/src/lib/loadEntities.js +23 -4
- package/packages/database/src/lib/loadEntities.js.map +1 -1
- package/packages/database/src/lib/loadEntityBranches.js +9 -0
- package/packages/database/src/lib/loadEntityBranches.js.map +1 -1
- package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js +7 -4
- package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
- package/packages/database/src/lib/projectToDb.js +1 -1
- package/packages/database/src/lib/projectToDb.js.map +1 -1
- package/packages/database/src/lib/saveFiles.js +1 -1
- package/packages/database/src/lib/saveFiles.js.map +1 -1
- package/packages/database/src/lib/scenarioToDb.js +1 -1
- package/packages/database/src/lib/scenarioToDb.js.map +1 -1
- package/packages/database/src/lib/updateCommitMetadata.js +5 -4
- package/packages/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/packages/generate/index.js +3 -0
- package/packages/generate/index.js.map +1 -1
- package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
- package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
- package/packages/generate/src/lib/scenarioComponentForServer.js +89 -0
- package/packages/generate/src/lib/scenarioComponentForServer.js.map +1 -0
- package/packages/github/src/lib/loadOrCreateCommit.js +10 -0
- package/packages/github/src/lib/loadOrCreateCommit.js.map +1 -1
- package/packages/github/src/lib/syncPrimaryBranch.js +3 -0
- package/packages/github/src/lib/syncPrimaryBranch.js.map +1 -1
- package/packages/process/index.js +3 -0
- package/packages/process/index.js.map +1 -0
- package/packages/process/src/GlobalProcessManager.js.map +1 -0
- package/{background/src/lib/process → packages/process/src}/ProcessManager.js +1 -1
- package/packages/process/src/ProcessManager.js.map +1 -0
- package/packages/process/src/index.js.map +1 -0
- package/packages/process/src/managedExecAsync.js.map +1 -0
- package/packages/types/index.js +0 -1
- package/packages/types/index.js.map +1 -1
- package/packages/types/src/types/Scenario.js +1 -21
- package/packages/types/src/types/Scenario.js.map +1 -1
- package/packages/utils/src/lib/fs/rsyncCopy.js +93 -2
- package/packages/utils/src/lib/fs/rsyncCopy.js.map +1 -1
- package/packages/utils/src/lib/safeFileName.js +29 -3
- package/packages/utils/src/lib/safeFileName.js.map +1 -1
- package/scripts/finalize-analyzer.cjs +8 -76
- package/analyzer-template/packages/ai/src/lib/findMatchingAttribute.ts +0 -102
- package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +0 -409
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +0 -288
- package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +0 -495
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.ts +0 -67
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +0 -120
- package/analyzer-template/process/INTEGRATION_COMPLETE.md +0 -333
- package/analyzer-template/process/INTEGRATION_EXAMPLE.md +0 -525
- package/analyzer-template/process/README.md +0 -507
- package/background/src/lib/process/GlobalProcessManager.js.map +0 -1
- package/background/src/lib/process/ProcessManager.js.map +0 -1
- package/background/src/lib/process/index.js.map +0 -1
- package/background/src/lib/process/managedExecAsync.js.map +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-wXL1Z2Aq.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-CXFKsCOD.js +0 -41
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-D-9pXIaY.js +0 -25
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-4lcOlid-.js +0 -11
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-CUxUNEEC.js +0 -15
- package/codeyam-cli/src/webserver/build/client/assets/_index-DHImXdXq.js +0 -11
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-CVP_WGQ3.js +0 -32
- package/codeyam-cli/src/webserver/build/client/assets/chunk-JMJ3UQ3L-BambyYE_.js +0 -51
- package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-CKnwPCDr.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-DW_hdGUc.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-DyB90fWk.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-D_3ero5o.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-ClR0d32A.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/globals-C9s7Lhdl.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/keyAttributeCoverage-CTlFMihX.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-0d27da29.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/root-B_wIKCIf.js +0 -56
- package/codeyam-cli/src/webserver/build/client/assets/settings-DgTyB-Wg.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/simulations-CoNWGt0K.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-BMIGFP-m.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useInteractiveMode-Dk_FQqWJ.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-DsJbgMY9.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-CU58-Ttc.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-D35o2uae.js +0 -175
- package/codeyam-cli/templates/debug-codeyam.md +0 -625
- package/packages/ai/src/lib/findMatchingAttribute.js +0 -77
- package/packages/ai/src/lib/findMatchingAttribute.js.map +0 -1
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +0 -298
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +0 -226
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateEntityKeyAttributes.js +0 -408
- package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/isFrontend.js +0 -5
- package/packages/ai/src/lib/isFrontend.js.map +0 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js +0 -40
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js.map +0 -1
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +0 -77
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +0 -1
- /package/analyzer-template/{process → packages/process/src}/GlobalProcessManager.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/ProcessManager.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/index.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/managedExecAsync.ts +0 -0
- /package/codeyam-cli/src/webserver/build/client/assets/{api.link-scenario-value-l0sNRNKZ.js → api.agent-transcripts-l0sNRNKZ.js} +0 -0
- /package/codeyam-cli/src/webserver/build/client/assets/{api.update-key-attributes-l0sNRNKZ.js → api.health-l0sNRNKZ.js} +0 -0
- /package/codeyam-cli/src/webserver/build/client/assets/{api.update-valid-values-l0sNRNKZ.js → api.labs-unlock-l0sNRNKZ.js} +0 -0
- /package/{background/src/lib/process → packages/process/src}/GlobalProcessManager.js +0 -0
- /package/{background/src/lib/process → packages/process/src}/index.js +0 -0
- /package/{background/src/lib/process → packages/process/src}/managedExecAsync.js +0 -0
|
@@ -285,12 +285,28 @@ function funcArgs(functionSignature: string): string[] {
|
|
|
285
285
|
|
|
286
286
|
// isValidKey ensures that the key does not contain any characters that would make it invalid in a JavaScript object.
|
|
287
287
|
// For example, it should not contain spaces, special characters, or start with a number.
|
|
288
|
+
// Also rejects keys that are pure function calls like "()" or "(args)" - these aren't property names.
|
|
288
289
|
function isValidKey(key: string) {
|
|
289
290
|
if (!key || key.length === 0) return false;
|
|
290
291
|
const keyWithOutArguments = key.split('(')[0];
|
|
292
|
+
// Reject empty keys (happens when key is "()" or "(args)") - these are function calls, not property names
|
|
293
|
+
if (!keyWithOutArguments || keyWithOutArguments.length === 0) return false;
|
|
291
294
|
return !/\s/.test(keyWithOutArguments);
|
|
292
295
|
}
|
|
293
296
|
|
|
297
|
+
/**
|
|
298
|
+
* Known hooks that return tuples [value, setter] instead of arrays.
|
|
299
|
+
* These should NOT use the .map() pattern even when the schema has generic array access ([]).
|
|
300
|
+
* Instead, they should return [data, () => {}] where data is from scenarios().
|
|
301
|
+
*/
|
|
302
|
+
const TUPLE_RETURNING_HOOKS = new Set([
|
|
303
|
+
'useAtom', // Jotai
|
|
304
|
+
'useState', // React
|
|
305
|
+
'useReducer', // React
|
|
306
|
+
'useRecoilState', // Recoil
|
|
307
|
+
'useImmerAtom', // Jotai with Immer
|
|
308
|
+
]);
|
|
309
|
+
|
|
294
310
|
export default function constructMockCode(
|
|
295
311
|
mockName: string,
|
|
296
312
|
dependencySchemas: DeepReadonly<DataStructure['dependencySchemas']>,
|
|
@@ -299,6 +315,7 @@ export default function constructMockCode(
|
|
|
299
315
|
options?: {
|
|
300
316
|
keepOriginalFunctionName?: boolean;
|
|
301
317
|
uniqueFunctionSuffix?: string;
|
|
318
|
+
skipOriginalSpread?: boolean; // Skip spreading from __cyOriginal when it won't be defined
|
|
302
319
|
},
|
|
303
320
|
) {
|
|
304
321
|
// Check if mockName is a call signature (e.g., "useFetcher<User>()", "db.select(query)")
|
|
@@ -325,7 +342,7 @@ export default function constructMockCode(
|
|
|
325
342
|
let foundEntityWithSignature = false;
|
|
326
343
|
let signatureSchema: DataStructure['signatureSchema'] | undefined;
|
|
327
344
|
|
|
328
|
-
for (const filePath in dependencySchemas) {
|
|
345
|
+
entitySearch: for (const filePath in dependencySchemas) {
|
|
329
346
|
for (const entityName in dependencySchemas[filePath]) {
|
|
330
347
|
// Match entity by base name (without generics/args)
|
|
331
348
|
const entityBaseName = entityName.split(/[<(]/)[0];
|
|
@@ -369,7 +386,7 @@ export default function constructMockCode(
|
|
|
369
386
|
// However, we still need to remove duplicate function calls that create invalid syntax
|
|
370
387
|
removeDuplicateFunctionCalls(relevantReturnValueSchema);
|
|
371
388
|
dataStructureValue = relevantReturnValueSchema?.[dataStructurePath];
|
|
372
|
-
break;
|
|
389
|
+
break entitySearch;
|
|
373
390
|
}
|
|
374
391
|
}
|
|
375
392
|
}
|
|
@@ -401,17 +418,16 @@ export default function constructMockCode(
|
|
|
401
418
|
dataKey = mockName;
|
|
402
419
|
}
|
|
403
420
|
|
|
404
|
-
//
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
);
|
|
421
|
+
// Helper to wrap key in appropriate quotes for computed property access
|
|
422
|
+
// Use single quotes when key contains double quotes to avoid syntax errors
|
|
423
|
+
const quotePropertyKey = (key: string): string => {
|
|
424
|
+
const escaped = key.replace(/\n/g, '\\n');
|
|
425
|
+
if (escaped.includes('"')) {
|
|
426
|
+
// Use single quotes, escaping any single quotes in the key
|
|
427
|
+
return `['${escaped.replace(/'/g, "\\'")}']`;
|
|
428
|
+
}
|
|
429
|
+
return `["${escaped}"]`;
|
|
430
|
+
};
|
|
415
431
|
|
|
416
432
|
// Check if the return value schema only contains function type markers
|
|
417
433
|
// (e.g., "validateInputs()": "function") without actual return data
|
|
@@ -441,6 +457,8 @@ export default function constructMockCode(
|
|
|
441
457
|
key.startsWith('signature['),
|
|
442
458
|
).length;
|
|
443
459
|
const args = Array.from({ length: argCount }, (_, i) => `arg${i + 1}`);
|
|
460
|
+
// Always add ...rest to accept extra arguments beyond the signature
|
|
461
|
+
args.push('...rest');
|
|
444
462
|
const argsString = args.join(', ');
|
|
445
463
|
|
|
446
464
|
// Generate empty mock function
|
|
@@ -465,8 +483,38 @@ export default function constructMockCode(
|
|
|
465
483
|
key.startsWith('signature['),
|
|
466
484
|
).length;
|
|
467
485
|
const args = Array.from({ length: argCount }, (_, i) => `arg${i + 1}`);
|
|
486
|
+
// Always add ...rest to accept extra arguments beyond the signature
|
|
487
|
+
args.push('...rest');
|
|
468
488
|
const argsString = args.join(', ');
|
|
469
489
|
|
|
490
|
+
// Check for Higher-Order Component (HOC) pattern:
|
|
491
|
+
// - First argument is a function (component) or unknown (couldn't trace type)
|
|
492
|
+
// - Returns a function
|
|
493
|
+
// HOCs like memo, forwardRef, createContext should return their first argument
|
|
494
|
+
//
|
|
495
|
+
// The return value key can be either:
|
|
496
|
+
// - 'memo()' (clean format)
|
|
497
|
+
// - 'memo(({ value, width }: Props) => { ... })' (full component code format)
|
|
498
|
+
const firstArgIsFunctionOrUnknown =
|
|
499
|
+
signatureSchema['signature[0]'] === 'function' ||
|
|
500
|
+
signatureSchema['signature[0]'] === 'unknown';
|
|
501
|
+
const returnsFunction = relevantReturnValueSchema
|
|
502
|
+
? Object.entries(relevantReturnValueSchema).some(([key, value]) => {
|
|
503
|
+
// Check if key represents a function call that returns a function
|
|
504
|
+
// Key should start with the mock name, contain '(', end with ')', and have value 'function'
|
|
505
|
+
const isFunctionCall =
|
|
506
|
+
key.startsWith(mockName + '(') && key.endsWith(')');
|
|
507
|
+
return isFunctionCall && value === 'function';
|
|
508
|
+
})
|
|
509
|
+
: false;
|
|
510
|
+
|
|
511
|
+
if (firstArgIsFunctionOrUnknown && returnsFunction) {
|
|
512
|
+
// HOC pattern detected - return the first argument
|
|
513
|
+
return `function ${mockName}(${argsString}) {
|
|
514
|
+
return arg1;
|
|
515
|
+
}`;
|
|
516
|
+
}
|
|
517
|
+
|
|
470
518
|
// Generate empty mock function
|
|
471
519
|
return `function ${mockName}(${argsString}) {
|
|
472
520
|
// Empty mock - original function mocked out
|
|
@@ -495,6 +543,99 @@ export default function constructMockCode(
|
|
|
495
543
|
dataStructureValue === 'array' &&
|
|
496
544
|
(dataStructurePath === 'returnValue' || pathDepth <= mockNameParts.length);
|
|
497
545
|
|
|
546
|
+
// OPTIMIZATION: Early return for tuple-returning hooks (useAtom, useState, etc.)
|
|
547
|
+
// These hooks have simple [value, setter] return patterns that don't need the full
|
|
548
|
+
// 9216-key schema processing. Check if this is a tuple-returning hook and generate
|
|
549
|
+
// the mock code directly without iterating over all schema keys.
|
|
550
|
+
if (TUPLE_RETURNING_HOOKS.has(baseMockName) && isFunction) {
|
|
551
|
+
// Check if schema has generic array pattern (indicates tuple return like [value, setter])
|
|
552
|
+
const schemaKeys = Object.keys(relevantReturnValueSchema ?? {});
|
|
553
|
+
const hasGenericArrayInSchema = schemaKeys.some(
|
|
554
|
+
(k) =>
|
|
555
|
+
k.includes('.functionCallReturnValue[]') ||
|
|
556
|
+
k === `${dataKey}.functionCallReturnValue[]` ||
|
|
557
|
+
k === 'returnValue[]',
|
|
558
|
+
);
|
|
559
|
+
|
|
560
|
+
// Check for differentiated tuple indices (e.g., functionCallReturnValue[2], [3]) which would NOT be a standard tuple
|
|
561
|
+
// We only check indices immediately after functionCallReturnValue, not nested indices like signature[2]
|
|
562
|
+
const tupleHasDifferentiatedIndices = schemaKeys.some((k) => {
|
|
563
|
+
// Look for .functionCallReturnValue[N] where N >= 2
|
|
564
|
+
const match = k.match(/\.functionCallReturnValue\[(\d+)\]/);
|
|
565
|
+
if (!match) return false;
|
|
566
|
+
const idx = parseInt(match[1], 10);
|
|
567
|
+
return idx >= 2;
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
const isTupleReturningHook =
|
|
571
|
+
hasGenericArrayInSchema && !tupleHasDifferentiatedIndices;
|
|
572
|
+
|
|
573
|
+
if (isTupleReturningHook) {
|
|
574
|
+
// Find all call patterns for this hook (e.g., useAtom(quoteFilterAtom), useAtom(supplierAtom))
|
|
575
|
+
const hookCallPatterns = Object.keys(relevantReturnValueSchema ?? {})
|
|
576
|
+
.filter((k) => {
|
|
577
|
+
const regex = new RegExp(`^${baseMockName}\\([^)]+\\)$`);
|
|
578
|
+
return regex.test(k);
|
|
579
|
+
})
|
|
580
|
+
.map((k) => {
|
|
581
|
+
const match = k.match(/\(([^)]+)\)/);
|
|
582
|
+
return { key: k, arg: match?.[1] ?? '' };
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
let tupleReturnCode: string;
|
|
586
|
+
if (hookCallPatterns.length > 1) {
|
|
587
|
+
// Multiple patterns - generate conditional dispatch
|
|
588
|
+
const conditions = hookCallPatterns
|
|
589
|
+
.map(
|
|
590
|
+
({ key, arg }) =>
|
|
591
|
+
`if (argLabel === '${arg}' || argStr.includes('${arg}')) {\n return [scenarios().data()?.["${key}"]?.[0] ?? [], () => {}];\n }`,
|
|
592
|
+
)
|
|
593
|
+
.join('\n ');
|
|
594
|
+
const fallbackKey = hookCallPatterns[0]?.key ?? dataKey;
|
|
595
|
+
tupleReturnCode = `(() => {
|
|
596
|
+
// Dynamic dispatch for tuple-returning hook with multiple argument patterns
|
|
597
|
+
const argLabel = args[0]?.debugLabel ?? '';
|
|
598
|
+
const argStr = args[0]?.toString?.() ?? String(args[0] ?? '');
|
|
599
|
+
${conditions}
|
|
600
|
+
return [scenarios().data()?.["${fallbackKey}"]?.[0] ?? [], () => {}];
|
|
601
|
+
})()`;
|
|
602
|
+
} else {
|
|
603
|
+
// Single or no patterns - use dynamic dispatch
|
|
604
|
+
const fallbackKey = hookCallPatterns[0]?.key ?? `${baseMockName}()`;
|
|
605
|
+
tupleReturnCode = `(() => {
|
|
606
|
+
// Dynamic dispatch for tuple-returning hook
|
|
607
|
+
const argLabel = args[0]?.debugLabel ?? '';
|
|
608
|
+
const argStr = args[0]?.toString?.() ?? '';
|
|
609
|
+
const allData = scenarios().data() ?? {};
|
|
610
|
+
if (argLabel) {
|
|
611
|
+
const labelKey = '${baseMockName}(' + argLabel + ')';
|
|
612
|
+
if (allData[labelKey]) {
|
|
613
|
+
return [allData[labelKey]?.[0] ?? [], () => {}];
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
const keys = Object.keys(allData).filter(k => k.startsWith('${baseMockName}('));
|
|
617
|
+
for (const key of keys) {
|
|
618
|
+
const keyArg = key.slice(${baseMockName.length + 1}, -1);
|
|
619
|
+
if (argStr.includes(keyArg)) {
|
|
620
|
+
return [allData[key]?.[0] ?? [], () => {}];
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
return [allData[keys[0] ?? '${fallbackKey}']?.[0] ?? [], () => {}];
|
|
624
|
+
})()`;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
const safeFunctionName = options?.uniqueFunctionSuffix
|
|
628
|
+
? `${baseMockName}_${options.uniqueFunctionSuffix}`
|
|
629
|
+
: options?.keepOriginalFunctionName
|
|
630
|
+
? baseMockName
|
|
631
|
+
: mockNameIsCallSignature && derivedFunctionName
|
|
632
|
+
? derivedFunctionName
|
|
633
|
+
: baseMockName;
|
|
634
|
+
|
|
635
|
+
return `function ${safeFunctionName}(...args) {\n return ${tupleReturnCode};\n}`;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
|
|
498
639
|
const returnValueParts: ReturnValuePart = {
|
|
499
640
|
name: dataStructureName,
|
|
500
641
|
isArray: isRootArray,
|
|
@@ -533,7 +674,7 @@ export default function constructMockCode(
|
|
|
533
674
|
// For call signature format, use the original mockName as the data key
|
|
534
675
|
// e.g., scenarios().data()?.["useFetcher<User>()"]
|
|
535
676
|
// e.g., scenarios().data()?.["db.select(usersQuery)"]
|
|
536
|
-
return
|
|
677
|
+
return `?.${quotePropertyKey(dataKey)}`;
|
|
537
678
|
}
|
|
538
679
|
|
|
539
680
|
// Only use unquoted array access syntax for pure array indices like [0], [1]
|
|
@@ -541,7 +682,7 @@ export default function constructMockCode(
|
|
|
541
682
|
return `?.${name}`;
|
|
542
683
|
}
|
|
543
684
|
|
|
544
|
-
return
|
|
685
|
+
return `?.${quotePropertyKey(name)}`;
|
|
545
686
|
};
|
|
546
687
|
|
|
547
688
|
const constructDataPaths = () => {
|
|
@@ -609,7 +750,20 @@ export default function constructMockCode(
|
|
|
609
750
|
hasNoReturnData,
|
|
610
751
|
} = returnValue;
|
|
611
752
|
|
|
612
|
-
|
|
753
|
+
// When an array has differentiated indices ([0], [1], etc.), filter out any
|
|
754
|
+
// non-index items from nested. These non-index items come from generic [] paths
|
|
755
|
+
// like [].filter or [].sort, which describe element properties, not array elements.
|
|
756
|
+
// Including them would generate invalid syntax like "sort: ..." inside an array literal.
|
|
757
|
+
const hasDifferentiatedIndices =
|
|
758
|
+
isArray &&
|
|
759
|
+
nested &&
|
|
760
|
+
nested.some((n) => n.name.match(/^\[\d+\]$/) && n.name !== '[0]');
|
|
761
|
+
const filteredNested =
|
|
762
|
+
hasDifferentiatedIndices && nested
|
|
763
|
+
? nested.filter((n) => n.name.match(/^\[\d+\]$/))
|
|
764
|
+
: nested;
|
|
765
|
+
|
|
766
|
+
const nestedContent: (string | undefined)[] = (filteredNested ?? []).map(
|
|
613
767
|
(nestedItem) => {
|
|
614
768
|
const nestedContent = constructReturnValueString(
|
|
615
769
|
nestedItem,
|
|
@@ -693,53 +847,114 @@ export default function constructMockCode(
|
|
|
693
847
|
) {
|
|
694
848
|
levelContentItems.push(...dataPaths.map((path) => `...${path}`));
|
|
695
849
|
}
|
|
696
|
-
|
|
850
|
+
// Filter out nested content that would be invalid as object properties
|
|
851
|
+
// (e.g., bare arrow functions like "() => {...}" without a property name)
|
|
852
|
+
// Only apply this filter when building object content, not array content.
|
|
853
|
+
// Bare arrow functions ARE valid as array elements (like [0] = {...}, [1] = () => {...})
|
|
854
|
+
// Check both isArray (item IS an array) and returnsFunctionArray (item returns an array)
|
|
855
|
+
const inArrayContext = isArray || returnsFunctionArray;
|
|
856
|
+
const validNestedContent = nestedContent.filter((content) => {
|
|
857
|
+
if (!content) return false;
|
|
858
|
+
// Only filter bare arrow functions when NOT in array context
|
|
859
|
+
// In arrays, bare arrow functions are valid elements
|
|
860
|
+
if (!inArrayContext && content.match(/^\s*\([^)]*\)\s*=>/)) {
|
|
861
|
+
return false;
|
|
862
|
+
}
|
|
863
|
+
return true;
|
|
864
|
+
});
|
|
865
|
+
levelContentItems.push(...validNestedContent);
|
|
697
866
|
|
|
698
867
|
let levelContents: string = levelContentItems.filter(Boolean).join(',\n');
|
|
699
868
|
if (returnsFunctionArgs) {
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
869
|
+
// When returnsFunctionArgs is empty [] OR has a single literal string argument,
|
|
870
|
+
// the function returns a callable function (e.g., getTranslate() returns t,
|
|
871
|
+
// where t('key') looks up translations)
|
|
872
|
+
// Generate a dispatch function that looks up keys based on the argument
|
|
873
|
+
//
|
|
874
|
+
// Detect translation-like pattern:
|
|
875
|
+
// - Data path ends with ["('some.literal')"] - a literal string key
|
|
876
|
+
// - This means the mock data has keys like "('common.surveys')": "Surveys"
|
|
877
|
+
// - Exclude ["()"] which is an empty function call (not a translation pattern)
|
|
878
|
+
const dataPath = dataPaths[0];
|
|
879
|
+
// Pattern matches ?.["('...')"] at end of path, but NOT ?.["()"] (empty args)
|
|
880
|
+
const literalKeyPattern = dataPath?.match(/\?\.\["\('.+'\)"\]$/);
|
|
881
|
+
|
|
882
|
+
if (
|
|
883
|
+
!returnsFunctionArray &&
|
|
884
|
+
dataPaths.length === 1 &&
|
|
885
|
+
literalKeyPattern // Only dispatch when there's a literal key pattern
|
|
886
|
+
) {
|
|
887
|
+
// Function returns a function - generate dispatch function
|
|
888
|
+
// Strip the literal key from the path and use dynamic lookup
|
|
889
|
+
const dataPathBase = literalKeyPattern
|
|
890
|
+
? dataPath.replace(/\?\.\["\('.+'\)"\]$/, '')
|
|
891
|
+
: dataPath;
|
|
892
|
+
const funcContents = `return ${dataPathBase}?.[\`('\${arg1}')\`]`;
|
|
893
|
+
levelContents = `(arg1) => {\n${indent(funcContents)}\n}`;
|
|
894
|
+
|
|
895
|
+
if (!isArray) {
|
|
896
|
+
return levelContents;
|
|
716
897
|
}
|
|
717
898
|
} else {
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
if (
|
|
725
|
-
hasNoReturnData ||
|
|
726
|
-
(hasNestedItems && !hasActualNestedContent)
|
|
727
|
-
) {
|
|
899
|
+
const argsString = returnsFunctionArgs
|
|
900
|
+
.map((_, index) => `arg${index + 1}`)
|
|
901
|
+
.join(', ');
|
|
902
|
+
let funcContents = '';
|
|
903
|
+
if (returnsFunctionArray) {
|
|
904
|
+
if (hasNoReturnData) {
|
|
728
905
|
// Function has no return data (only signatures) - return empty array
|
|
729
906
|
funcContents = 'return []';
|
|
730
|
-
} else {
|
|
731
|
-
//
|
|
907
|
+
} else if (levelContents.length === 0 && dataPaths.length === 1) {
|
|
908
|
+
// When returning an array with no nested content, return the data path directly
|
|
909
|
+
// (the data path points to the array in scenario data)
|
|
732
910
|
funcContents = `return ${dataPaths[0]}`;
|
|
911
|
+
} else if (levelContents.length === 0) {
|
|
912
|
+
funcContents = 'return []';
|
|
913
|
+
} else {
|
|
914
|
+
funcContents = `return [\n${indent(levelContents)}\n]`;
|
|
733
915
|
}
|
|
734
916
|
} else {
|
|
735
|
-
|
|
917
|
+
// Check if function has no actual return data (only signatures)
|
|
918
|
+
const hasNestedItems = nested && nested.length > 0;
|
|
919
|
+
const hasActualNestedContent =
|
|
920
|
+
nestedContent.filter(Boolean).length > 0;
|
|
921
|
+
|
|
922
|
+
if (levelContentItems.length === 1 && dataPaths.length === 1) {
|
|
923
|
+
if (
|
|
924
|
+
hasNoReturnData ||
|
|
925
|
+
(hasNestedItems && !hasActualNestedContent)
|
|
926
|
+
) {
|
|
927
|
+
// Function has no return data (only signatures) - return empty array
|
|
928
|
+
funcContents = 'return []';
|
|
929
|
+
} else {
|
|
930
|
+
// Has return data - return data path
|
|
931
|
+
funcContents = `return ${dataPaths[0]}`;
|
|
932
|
+
}
|
|
933
|
+
} else {
|
|
934
|
+
funcContents = `return {\n${indent(levelContents)}\n}`;
|
|
935
|
+
}
|
|
736
936
|
}
|
|
737
|
-
}
|
|
738
937
|
|
|
739
|
-
|
|
938
|
+
levelContents = `(${argsString}) => {\n${indent(funcContents)}\n}`;
|
|
740
939
|
|
|
741
|
-
|
|
742
|
-
|
|
940
|
+
if (!isArray) {
|
|
941
|
+
return levelContents;
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
// For generic arrays of functions WITH nested properties (e.g., functionCallReturnValue[] = "function"
|
|
946
|
+
// with nested .filter, .sort, etc.), the levelContents would be a bare arrow function "() => {...}"
|
|
947
|
+
// that wraps object content. Using this in a .map(({...})) creates invalid syntax like "({ () => {...} })".
|
|
948
|
+
// When isGenericArray is true AND there are nested properties, we're accessing data from the elements,
|
|
949
|
+
// not calling them - so skip the function wrapping.
|
|
950
|
+
// But if there are NO nested properties, keep the wrapper because callers may want to call the elements.
|
|
951
|
+
const hasNonStructuralNestedItems =
|
|
952
|
+
nested &&
|
|
953
|
+
nested.length > 0 &&
|
|
954
|
+
nested.some((n) => !n.name.match(/^\[\d*\]$/));
|
|
955
|
+
if (isGenericArray && hasNonStructuralNestedItems) {
|
|
956
|
+
// Skip the arrow function wrapper - just use the nested content directly
|
|
957
|
+
levelContents = levelContentItems.filter(Boolean).join(',\n');
|
|
743
958
|
}
|
|
744
959
|
}
|
|
745
960
|
|
|
@@ -755,7 +970,123 @@ export default function constructMockCode(
|
|
|
755
970
|
});
|
|
756
971
|
|
|
757
972
|
let returnValueContents = '';
|
|
758
|
-
|
|
973
|
+
|
|
974
|
+
// Check if this is a known tuple-returning hook (useAtom, useState, etc.)
|
|
975
|
+
// These should return [value, setter] tuples, not arrays or data paths
|
|
976
|
+
// Check isGenericArray from current context OR from schema for root level calls
|
|
977
|
+
// (at root level, isGenericArray might not be set yet but the schema contains [] pattern)
|
|
978
|
+
const hasGenericArrayInSchema =
|
|
979
|
+
root &&
|
|
980
|
+
TUPLE_RETURNING_HOOKS.has(baseMockName) &&
|
|
981
|
+
Object.keys(relevantReturnValueSchema ?? {}).some((k) =>
|
|
982
|
+
k.includes('.functionCallReturnValue[]'),
|
|
983
|
+
);
|
|
984
|
+
// Check if there are array indices beyond what a standard 2-element tuple would have
|
|
985
|
+
// For tuple-returning hooks, [0] and [1] are expected (value and setter)
|
|
986
|
+
// Only consider it "differentiated" if there are indices >= 2 (e.g., [2], [3])
|
|
987
|
+
const tupleHasDifferentiatedIndices = nested?.some((n) => {
|
|
988
|
+
const indexMatch = n.name.match(/^\[(\d+)\]$/);
|
|
989
|
+
if (!indexMatch) return false;
|
|
990
|
+
const index = parseInt(indexMatch[1], 10);
|
|
991
|
+
return index >= 2;
|
|
992
|
+
});
|
|
993
|
+
const isTupleReturningHook =
|
|
994
|
+
TUPLE_RETURNING_HOOKS.has(baseMockName) &&
|
|
995
|
+
(isGenericArray || hasGenericArrayInSchema) &&
|
|
996
|
+
!tupleHasDifferentiatedIndices;
|
|
997
|
+
|
|
998
|
+
// Debug logging for tuple-returning hooks
|
|
999
|
+
if (TUPLE_RETURNING_HOOKS.has(baseMockName) && root) {
|
|
1000
|
+
const schemaKeys = Object.keys(relevantReturnValueSchema ?? {});
|
|
1001
|
+
const hasArrayPattern = schemaKeys.some((k) =>
|
|
1002
|
+
k.includes('.functionCallReturnValue[]'),
|
|
1003
|
+
);
|
|
1004
|
+
console.log(
|
|
1005
|
+
`CodeYam: Tuple hook check for ${baseMockName} (root):`,
|
|
1006
|
+
`hasGenericArrayInSchema=${hasGenericArrayInSchema}`,
|
|
1007
|
+
`hasArrayPattern=${hasArrayPattern}`,
|
|
1008
|
+
`tupleHasDifferentiatedIndices=${tupleHasDifferentiatedIndices}`,
|
|
1009
|
+
`isTupleReturningHook=${isTupleReturningHook}`,
|
|
1010
|
+
`schemaKeysSample=${schemaKeys.slice(0, 5).join(', ')}`,
|
|
1011
|
+
);
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
if (isTupleReturningHook) {
|
|
1015
|
+
// Tuple-returning hooks should return [value, setter] tuple
|
|
1016
|
+
// The value is the first element from scenarios data, setter is a no-op
|
|
1017
|
+
// Default to [] when data is undefined to prevent errors like ".includes is not a function"
|
|
1018
|
+
|
|
1019
|
+
// Check if there are multiple call patterns for this hook in the schema
|
|
1020
|
+
// (e.g., useAtom(quoteFilterAtom) and useAtom(supplierAtom))
|
|
1021
|
+
const hookCallPatterns = Object.keys(relevantReturnValueSchema ?? {})
|
|
1022
|
+
.filter((k) => {
|
|
1023
|
+
// Match patterns like "useAtom(someArg)" but not nested paths like "useAtom(x).foo"
|
|
1024
|
+
const regex = new RegExp(`^${baseMockName}\\([^)]+\\)$`);
|
|
1025
|
+
return regex.test(k);
|
|
1026
|
+
})
|
|
1027
|
+
.map((k) => {
|
|
1028
|
+
// Extract the argument from the key like "useAtom(quoteFilterAtom)" -> "quoteFilterAtom"
|
|
1029
|
+
const match = k.match(/\(([^)]+)\)/);
|
|
1030
|
+
return { key: k, arg: match?.[1] ?? '' };
|
|
1031
|
+
});
|
|
1032
|
+
|
|
1033
|
+
if (hookCallPatterns.length > 1) {
|
|
1034
|
+
// Multiple patterns - generate conditional dispatch based on first argument
|
|
1035
|
+
// For Jotai atoms, we use debugLabel; for others, we try to match the argument string
|
|
1036
|
+
const conditions = hookCallPatterns
|
|
1037
|
+
.map(
|
|
1038
|
+
({ key, arg }) =>
|
|
1039
|
+
`if (argLabel === '${arg}' || argStr.includes('${arg}')) {\n return [scenarios().data()?.["${key}"]?.[0] ?? [], () => {}];\n }`,
|
|
1040
|
+
)
|
|
1041
|
+
.join('\n ');
|
|
1042
|
+
|
|
1043
|
+
// Use the first pattern as fallback
|
|
1044
|
+
const fallbackKey = hookCallPatterns[0]?.key ?? dataKey;
|
|
1045
|
+
|
|
1046
|
+
returnValueContents = `(() => {
|
|
1047
|
+
// Dynamic dispatch for tuple-returning hook with multiple argument patterns
|
|
1048
|
+
const argLabel = args[0]?.debugLabel ?? '';
|
|
1049
|
+
const argStr = args[0]?.toString?.() ?? String(args[0] ?? '');
|
|
1050
|
+
${conditions}
|
|
1051
|
+
// Fallback to first pattern
|
|
1052
|
+
return [scenarios().data()?.["${fallbackKey}"]?.[0] ?? [], () => {}];
|
|
1053
|
+
})()`;
|
|
1054
|
+
} else {
|
|
1055
|
+
// Single pattern or no patterns - use dynamic dispatch to handle case where
|
|
1056
|
+
// the mock is used with different atoms than what was captured in the schema.
|
|
1057
|
+
// Use the first argument to construct the data key dynamically.
|
|
1058
|
+
const fallbackKey = hookCallPatterns[0]?.key ?? `${baseMockName}()`;
|
|
1059
|
+
|
|
1060
|
+
returnValueContents = `(() => {
|
|
1061
|
+
// Dynamic dispatch for tuple-returning hook
|
|
1062
|
+
// Try to construct key from argument's debugLabel (Jotai atoms) or toString
|
|
1063
|
+
const argLabel = args[0]?.debugLabel ?? '';
|
|
1064
|
+
const argStr = args[0]?.toString?.() ?? '';
|
|
1065
|
+
const allData = scenarios().data() ?? {};
|
|
1066
|
+
|
|
1067
|
+
// Try to find a matching key using debugLabel first
|
|
1068
|
+
if (argLabel) {
|
|
1069
|
+
const labelKey = '${baseMockName}(' + argLabel + ')';
|
|
1070
|
+
if (allData[labelKey]) {
|
|
1071
|
+
return [allData[labelKey]?.[0] ?? [], () => {}];
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
// Try to find any matching key that contains part of the argument string
|
|
1076
|
+
const keys = Object.keys(allData).filter(k => k.startsWith('${baseMockName}('));
|
|
1077
|
+
for (const key of keys) {
|
|
1078
|
+
const keyArg = key.slice(${baseMockName.length + 1}, -1);
|
|
1079
|
+
if (argStr.includes(keyArg)) {
|
|
1080
|
+
return [allData[key]?.[0] ?? [], () => {}];
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
// Fallback to first matching key or default
|
|
1085
|
+
const fallback = keys[0] ?? '${fallbackKey}';
|
|
1086
|
+
return [allData[fallback]?.[0] ?? [], () => {}];
|
|
1087
|
+
})()`;
|
|
1088
|
+
}
|
|
1089
|
+
} else if (
|
|
759
1090
|
!returnsFunctionArgs &&
|
|
760
1091
|
nestedContent.length === 0 &&
|
|
761
1092
|
dataPaths.length === 1
|
|
@@ -793,23 +1124,421 @@ export default function constructMockCode(
|
|
|
793
1124
|
// Get the array base path (without the [0])
|
|
794
1125
|
const arrayBasePath = dataPaths[0].replace(/\?\.\[0\]$/, '');
|
|
795
1126
|
// Replace [0] references with [__idx__] in level contents
|
|
796
|
-
|
|
1127
|
+
let mappedContents = levelContents.replace(
|
|
797
1128
|
/\?\.\[0\]/g,
|
|
798
1129
|
'?.[__idx__]',
|
|
799
1130
|
);
|
|
800
1131
|
// levelContents may already be wrapped in {...} from structural [0] element,
|
|
801
1132
|
// so check if we need to add the wrapper or not
|
|
802
1133
|
const needsWrapper = !mappedContents.trim().startsWith('{');
|
|
1134
|
+
|
|
1135
|
+
// Helper to check if a position is inside a string literal
|
|
1136
|
+
// Returns the end position of the string if inside one, -1 otherwise
|
|
1137
|
+
// Defined here so it's accessible in both needsWrapper branches
|
|
1138
|
+
const skipStringLiteral = (
|
|
1139
|
+
content: string,
|
|
1140
|
+
pos: number,
|
|
1141
|
+
): number => {
|
|
1142
|
+
const char = content[pos];
|
|
1143
|
+
if (char !== '"' && char !== "'" && char !== '`') return -1;
|
|
1144
|
+
// Find the matching closing quote
|
|
1145
|
+
let j = pos + 1;
|
|
1146
|
+
while (j < content.length) {
|
|
1147
|
+
if (content[j] === '\\') {
|
|
1148
|
+
j += 2; // Skip escaped character
|
|
1149
|
+
continue;
|
|
1150
|
+
}
|
|
1151
|
+
if (content[j] === char) {
|
|
1152
|
+
return j + 1; // Return position after closing quote
|
|
1153
|
+
}
|
|
1154
|
+
j++;
|
|
1155
|
+
}
|
|
1156
|
+
return content.length; // Unclosed string, skip to end
|
|
1157
|
+
};
|
|
1158
|
+
|
|
1159
|
+
// Filter out bare arrow functions which are invalid as object properties.
|
|
1160
|
+
// Arrow functions can be multi-line, so we need to match the entire function body, not just the first line.
|
|
1161
|
+
// Pattern: starts with "(args) =>", followed by either:
|
|
1162
|
+
// - A single-line body: "() => expression"
|
|
1163
|
+
// - A multi-line body: "() => { ... }" (with matching braces)
|
|
1164
|
+
// IMPORTANT: Only filter BARE arrow functions (without property names).
|
|
1165
|
+
// "() => {...}" is invalid, but "get: (arg1) => {...}" is valid.
|
|
1166
|
+
// We use a function to properly handle nested braces.
|
|
1167
|
+
// Defined here so it's accessible in both needsWrapper branches
|
|
1168
|
+
const filterOutArrowFunctions = (content: string): string => {
|
|
1169
|
+
const result: string[] = [];
|
|
1170
|
+
let i = 0;
|
|
1171
|
+
while (i < content.length) {
|
|
1172
|
+
// Skip over string literals entirely
|
|
1173
|
+
const stringEnd = skipStringLiteral(content, i);
|
|
1174
|
+
if (stringEnd !== -1) {
|
|
1175
|
+
result.push(content.slice(i, stringEnd));
|
|
1176
|
+
i = stringEnd;
|
|
1177
|
+
continue;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
// Check if we're at the start of an arrow function (with optional leading whitespace)
|
|
1181
|
+
const arrowMatch = content
|
|
1182
|
+
.slice(i)
|
|
1183
|
+
.match(/^(\s*)\([^)]*\)\s*=>\s*/);
|
|
1184
|
+
if (arrowMatch) {
|
|
1185
|
+
// Check if this is a bare arrow function or a named property with arrow function value
|
|
1186
|
+
// Look back to see if there's a "key:" pattern before this position
|
|
1187
|
+
const before = content.slice(0, i);
|
|
1188
|
+
const beforeTrimmed = before.trim();
|
|
1189
|
+
// Valid patterns where arrow function is NOT bare:
|
|
1190
|
+
// 1. Property value: "key: (arg) => ..." - ends with ':'
|
|
1191
|
+
// 2. Function argument: ".map((arg) => ..." - ends with '('
|
|
1192
|
+
// 3. Method call: "?.map" followed directly by the arrow function
|
|
1193
|
+
// In this case, the '(' is consumed by the arrow function regex match,
|
|
1194
|
+
// so beforeTrimmed ends with the method name (e.g., 'map'), not '('.
|
|
1195
|
+
// We detect this by checking if beforeTrimmed ends with an identifier
|
|
1196
|
+
// that could be a method name (preceded by '.' or '?.').
|
|
1197
|
+
// NOTE: We don't include ',' because "{ prop, () => {} }" is invalid
|
|
1198
|
+
// (can't distinguish function argument from object property context)
|
|
1199
|
+
const isPropertyValue = beforeTrimmed.endsWith(':');
|
|
1200
|
+
const isFunctionArg = beforeTrimmed.endsWith('(');
|
|
1201
|
+
// Check if before ends with a method call pattern like ".map" or "?.map"
|
|
1202
|
+
// The '(' after the method name is consumed by the arrow function regex
|
|
1203
|
+
const isMethodCallArg = /\??\.\w+$/.test(beforeTrimmed);
|
|
1204
|
+
const hasPropertyName =
|
|
1205
|
+
isPropertyValue || isFunctionArg || isMethodCallArg;
|
|
1206
|
+
|
|
1207
|
+
if (!hasPropertyName) {
|
|
1208
|
+
// This is a bare arrow function - filter it out
|
|
1209
|
+
// Found arrow function start, need to find its end
|
|
1210
|
+
const afterArrow = i + arrowMatch[0].length;
|
|
1211
|
+
if (content[afterArrow] === '{') {
|
|
1212
|
+
// Multi-line arrow function - find matching closing brace
|
|
1213
|
+
// Must respect string literals when counting braces
|
|
1214
|
+
let braceCount = 1;
|
|
1215
|
+
let j = afterArrow + 1;
|
|
1216
|
+
while (j < content.length && braceCount > 0) {
|
|
1217
|
+
const strEnd = skipStringLiteral(content, j);
|
|
1218
|
+
if (strEnd !== -1) {
|
|
1219
|
+
j = strEnd;
|
|
1220
|
+
continue;
|
|
1221
|
+
}
|
|
1222
|
+
if (content[j] === '{') braceCount++;
|
|
1223
|
+
if (content[j] === '}') braceCount--;
|
|
1224
|
+
j++;
|
|
1225
|
+
}
|
|
1226
|
+
// Skip past the arrow function
|
|
1227
|
+
i = j;
|
|
1228
|
+
// Only skip trailing comma, keep newlines
|
|
1229
|
+
while (i < content.length && content[i] === ' ') {
|
|
1230
|
+
i++;
|
|
1231
|
+
}
|
|
1232
|
+
if (content[i] === ',') {
|
|
1233
|
+
i++; // Skip the comma after the arrow function
|
|
1234
|
+
}
|
|
1235
|
+
} else {
|
|
1236
|
+
// Single expression arrow function - skip to next comma or newline
|
|
1237
|
+
let j = afterArrow;
|
|
1238
|
+
while (
|
|
1239
|
+
j < content.length &&
|
|
1240
|
+
content[j] !== ',' &&
|
|
1241
|
+
content[j] !== '\n'
|
|
1242
|
+
) {
|
|
1243
|
+
j++;
|
|
1244
|
+
}
|
|
1245
|
+
i = j;
|
|
1246
|
+
if (content[i] === ',') i++; // Skip the comma
|
|
1247
|
+
}
|
|
1248
|
+
continue;
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
// Not a bare arrow function, keep this character
|
|
1252
|
+
result.push(content[i]);
|
|
1253
|
+
i++;
|
|
1254
|
+
}
|
|
1255
|
+
return result.join('');
|
|
1256
|
+
};
|
|
1257
|
+
|
|
1258
|
+
// Filter out bare object blocks (e.g., "{ ...spread, props }," without a property name)
|
|
1259
|
+
// These are invalid in object literal context - you need "key: { ... }" not just "{ ... }"
|
|
1260
|
+
// Defined here so it's accessible in both needsWrapper branches
|
|
1261
|
+
// The skipFirstBrace parameter allows the else branch to preserve the outer object
|
|
1262
|
+
const filterOutBareObjects = (
|
|
1263
|
+
content: string,
|
|
1264
|
+
skipFirstBrace = false,
|
|
1265
|
+
): string => {
|
|
1266
|
+
const result: string[] = [];
|
|
1267
|
+
let i = 0;
|
|
1268
|
+
let firstBraceSkipped = false;
|
|
1269
|
+
while (i < content.length) {
|
|
1270
|
+
// Skip over string literals entirely - braces inside strings should not be processed
|
|
1271
|
+
const stringEnd = skipStringLiteral(content, i);
|
|
1272
|
+
if (stringEnd !== -1) {
|
|
1273
|
+
result.push(content.slice(i, stringEnd));
|
|
1274
|
+
i = stringEnd;
|
|
1275
|
+
continue;
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
// Check if we're at a bare object start (newline/comma followed by { without : before it)
|
|
1279
|
+
// Look back to see if there's a colon (property assignment) before this brace
|
|
1280
|
+
const isStartOfLine =
|
|
1281
|
+
i === 0 ||
|
|
1282
|
+
content[i - 1] === '\n' ||
|
|
1283
|
+
content.slice(0, i).trim().endsWith(',');
|
|
1284
|
+
if (content[i] === '{' && isStartOfLine) {
|
|
1285
|
+
// Check if this is actually a bare object (not "key: {")
|
|
1286
|
+
const beforeTrimmed = content.slice(0, i).trim();
|
|
1287
|
+
const isBareObject =
|
|
1288
|
+
beforeTrimmed.endsWith(',') ||
|
|
1289
|
+
beforeTrimmed === '' ||
|
|
1290
|
+
beforeTrimmed.endsWith('(');
|
|
1291
|
+
|
|
1292
|
+
if (isBareObject) {
|
|
1293
|
+
// If skipFirstBrace is true and this is the first bare brace at position 0,
|
|
1294
|
+
// don't filter it - it's the intentional outer object wrapper
|
|
1295
|
+
if (skipFirstBrace && !firstBraceSkipped && i === 0) {
|
|
1296
|
+
firstBraceSkipped = true;
|
|
1297
|
+
result.push(content[i]);
|
|
1298
|
+
i++;
|
|
1299
|
+
continue;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
// Find matching closing brace, respecting string literals
|
|
1303
|
+
let braceCount = 1;
|
|
1304
|
+
let j = i + 1;
|
|
1305
|
+
while (j < content.length && braceCount > 0) {
|
|
1306
|
+
const strEnd = skipStringLiteral(content, j);
|
|
1307
|
+
if (strEnd !== -1) {
|
|
1308
|
+
j = strEnd;
|
|
1309
|
+
continue;
|
|
1310
|
+
}
|
|
1311
|
+
if (content[j] === '{') braceCount++;
|
|
1312
|
+
if (content[j] === '}') braceCount--;
|
|
1313
|
+
j++;
|
|
1314
|
+
}
|
|
1315
|
+
// Skip past the object
|
|
1316
|
+
i = j;
|
|
1317
|
+
// Skip trailing comma
|
|
1318
|
+
while (i < content.length && content[i] === ' ') {
|
|
1319
|
+
i++;
|
|
1320
|
+
}
|
|
1321
|
+
if (content[i] === ',') {
|
|
1322
|
+
i++;
|
|
1323
|
+
}
|
|
1324
|
+
continue;
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
result.push(content[i]);
|
|
1328
|
+
i++;
|
|
1329
|
+
}
|
|
1330
|
+
return result.join('');
|
|
1331
|
+
};
|
|
1332
|
+
|
|
1333
|
+
// Helper to clean up formatting issues after filtering
|
|
1334
|
+
const cleanupContent = (content: string): string => {
|
|
1335
|
+
return (
|
|
1336
|
+
content
|
|
1337
|
+
.replace(/,\s*,/g, ',') // Double commas
|
|
1338
|
+
.replace(/,(\s*\n\s*\})/g, '$1') // Trailing comma before closing brace
|
|
1339
|
+
.replace(/\{\s*\n\s*,/g, '{\n') // Leading comma after opening brace
|
|
1340
|
+
// Remove incomplete .map calls where callback was filtered out
|
|
1341
|
+
// Pattern: ".map" followed by newline/whitespace without "(" for args
|
|
1342
|
+
.replace(/\?\.map(?=\s*[\n\r,}\]])/g, '')
|
|
1343
|
+
.replace(/\.map(?=\s*[\n\r,}\]])/g, '')
|
|
1344
|
+
// Clean up orphan })) sequences (from nested filtered map callbacks)
|
|
1345
|
+
.replace(/\s*\}\)\)\s*\n\s*\}/g, '\n}')
|
|
1346
|
+
.replace(/^\s*\n/gm, '') // Empty lines
|
|
1347
|
+
.trim()
|
|
1348
|
+
);
|
|
1349
|
+
};
|
|
1350
|
+
|
|
803
1351
|
if (needsWrapper) {
|
|
804
|
-
|
|
1352
|
+
// Apply filters to remove invalid content
|
|
1353
|
+
mappedContents = filterOutArrowFunctions(mappedContents);
|
|
1354
|
+
mappedContents = filterOutBareObjects(mappedContents);
|
|
1355
|
+
mappedContents = cleanupContent(mappedContents);
|
|
1356
|
+
|
|
1357
|
+
// If mappedContents is empty after filtering, don't generate .map() at all
|
|
1358
|
+
// Just use the array path directly with spread or as-is
|
|
1359
|
+
// This prevents orphan )) from empty .map() callbacks
|
|
1360
|
+
const cleanedForEmptyCheck = mappedContents
|
|
1361
|
+
.replace(/\s+/g, '')
|
|
1362
|
+
.replace(/,+/g, '');
|
|
1363
|
+
if (cleanedForEmptyCheck.length === 0) {
|
|
1364
|
+
// Content is empty - just return the array directly
|
|
1365
|
+
returnValueContents = arrayBasePath;
|
|
1366
|
+
} else {
|
|
1367
|
+
// Check if mappedContents is just a bare expression (no property names)
|
|
1368
|
+
// A bare expression like "scenarios().data()?.["key"]?.[__idx__]," cannot be
|
|
1369
|
+
// wrapped in ({ }) because it's not a valid object property.
|
|
1370
|
+
// Pattern: content has no ":" that's not inside brackets/parens/strings
|
|
1371
|
+
const hasBareExpression = (() => {
|
|
1372
|
+
const trimmed = mappedContents.trim().replace(/,\s*$/, ''); // Remove trailing comma
|
|
1373
|
+
let depth = 0;
|
|
1374
|
+
let inString = false;
|
|
1375
|
+
let stringChar = '';
|
|
1376
|
+
for (let i = 0; i < trimmed.length; i++) {
|
|
1377
|
+
const char = trimmed[i];
|
|
1378
|
+
if (inString) {
|
|
1379
|
+
if (char === '\\') {
|
|
1380
|
+
i++; // Skip escaped char
|
|
1381
|
+
continue;
|
|
1382
|
+
}
|
|
1383
|
+
if (char === stringChar) {
|
|
1384
|
+
inString = false;
|
|
1385
|
+
}
|
|
1386
|
+
continue;
|
|
1387
|
+
}
|
|
1388
|
+
if (char === '"' || char === "'" || char === '`') {
|
|
1389
|
+
inString = true;
|
|
1390
|
+
stringChar = char;
|
|
1391
|
+
continue;
|
|
1392
|
+
}
|
|
1393
|
+
if (char === '(' || char === '[' || char === '{') {
|
|
1394
|
+
depth++;
|
|
1395
|
+
continue;
|
|
1396
|
+
}
|
|
1397
|
+
if (char === ')' || char === ']' || char === '}') {
|
|
1398
|
+
depth--;
|
|
1399
|
+
continue;
|
|
1400
|
+
}
|
|
1401
|
+
// Found a colon at depth 0 = has property name
|
|
1402
|
+
if (char === ':' && depth === 0) {
|
|
1403
|
+
return false;
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
return true;
|
|
1407
|
+
})();
|
|
1408
|
+
|
|
1409
|
+
if (hasBareExpression) {
|
|
1410
|
+
// Content is just an expression - return it directly without object wrapper
|
|
1411
|
+
const trimmedContent = mappedContents
|
|
1412
|
+
.trim()
|
|
1413
|
+
.replace(/,\s*$/, '');
|
|
1414
|
+
returnValueContents = `${arrayBasePath}?.map((__item__, __idx__) => (\n${indent(trimmedContent)}\n))`;
|
|
1415
|
+
} else {
|
|
1416
|
+
// When generating object-wrapped .map(), ensure original item data is preserved.
|
|
1417
|
+
// If no data spread was included (e.g., because this is a plain array property,
|
|
1418
|
+
// not a function return), add ...__item__ to spread the original item properties.
|
|
1419
|
+
// Without this, the .map() would create new objects with only nested function
|
|
1420
|
+
// properties, losing data like filePath, frontmatter, body, etc.
|
|
1421
|
+
const hasDataSpread =
|
|
1422
|
+
mappedContents.includes('...scenarios()') ||
|
|
1423
|
+
mappedContents.includes('...__item__');
|
|
1424
|
+
if (!hasDataSpread) {
|
|
1425
|
+
mappedContents = `...__item__,\n${mappedContents}`;
|
|
1426
|
+
}
|
|
1427
|
+
returnValueContents = `${arrayBasePath}?.map((__item__, __idx__) => ({\n${indent(mappedContents)}\n}))`;
|
|
1428
|
+
}
|
|
1429
|
+
} // Close the empty content check else block
|
|
805
1430
|
} else {
|
|
1431
|
+
// Content already starts with '{'. Check if there are additional properties after the inner object.
|
|
1432
|
+
// If so, we need to merge them INTO the object, not leave them outside.
|
|
1433
|
+
// Pattern: "{ ...spread, props },\nfilter: ...,\nsort: ..."
|
|
1434
|
+
// Should become: "{ ...spread, props, filter: ..., sort: ... }"
|
|
1435
|
+
const trimmed = mappedContents.trim();
|
|
1436
|
+
|
|
1437
|
+
// Find first }, at depth 0 that is NOT inside a string literal
|
|
1438
|
+
// This prevents splitting keys like ?.["useQuery({ id }, { enabled })"]
|
|
1439
|
+
// and also prevents finding }, inside nested arrow functions
|
|
1440
|
+
const findBraceCommaOutsideStrings = (
|
|
1441
|
+
content: string,
|
|
1442
|
+
): number => {
|
|
1443
|
+
let i = 0;
|
|
1444
|
+
let depth = 0; // Track brace depth to find the outer object's },
|
|
1445
|
+
while (i < content.length - 1) {
|
|
1446
|
+
// Skip over string literals
|
|
1447
|
+
const strEnd = skipStringLiteral(content, i);
|
|
1448
|
+
if (strEnd !== -1) {
|
|
1449
|
+
i = strEnd;
|
|
1450
|
+
continue;
|
|
1451
|
+
}
|
|
1452
|
+
// Track brace depth
|
|
1453
|
+
if (content[i] === '{') {
|
|
1454
|
+
depth++;
|
|
1455
|
+
i++;
|
|
1456
|
+
continue;
|
|
1457
|
+
}
|
|
1458
|
+
// Check for }, pattern at depth 1 (the outer object level)
|
|
1459
|
+
// We're looking for the outer object's closing brace, which is at depth 1
|
|
1460
|
+
// (we started at depth 0, opened { at depth 0 -> 1)
|
|
1461
|
+
if (content[i] === '}') {
|
|
1462
|
+
depth--;
|
|
1463
|
+
if (
|
|
1464
|
+
depth === 0 &&
|
|
1465
|
+
i + 1 < content.length &&
|
|
1466
|
+
content[i + 1] === ','
|
|
1467
|
+
) {
|
|
1468
|
+
return i;
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
i++;
|
|
1472
|
+
}
|
|
1473
|
+
return -1;
|
|
1474
|
+
};
|
|
1475
|
+
|
|
1476
|
+
const firstBraceEnd = findBraceCommaOutsideStrings(trimmed);
|
|
1477
|
+
if (firstBraceEnd !== -1) {
|
|
1478
|
+
// Found pattern "{ ... }," followed by more content
|
|
1479
|
+
// Extract the inner object and the trailing properties
|
|
1480
|
+
const innerObject = trimmed.slice(0, firstBraceEnd);
|
|
1481
|
+
const trailingContent = trimmed.slice(firstBraceEnd + 2).trim();
|
|
1482
|
+
if (trailingContent) {
|
|
1483
|
+
// Merge trailing properties into the inner object
|
|
1484
|
+
mappedContents = `${innerObject},\n${trailingContent}\n}`;
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
// Even when content starts with {, we need to filter out invalid properties inside
|
|
1488
|
+
// (arrow functions and bare objects that were generated from the schema)
|
|
1489
|
+
// Pass skipFirstBrace=true because the content's outer { is the intentional wrapper
|
|
1490
|
+
mappedContents = filterOutArrowFunctions(mappedContents);
|
|
1491
|
+
mappedContents = filterOutBareObjects(mappedContents, true);
|
|
1492
|
+
mappedContents = cleanupContent(mappedContents);
|
|
1493
|
+
// Same as needsWrapper branch: ensure item data is preserved in .map()
|
|
1494
|
+
const hasDataSpreadInner =
|
|
1495
|
+
mappedContents.includes('...scenarios()') ||
|
|
1496
|
+
mappedContents.includes('...__item__');
|
|
1497
|
+
if (!hasDataSpreadInner && mappedContents.trim().length > 0) {
|
|
1498
|
+
// Insert ...__item__ after the opening brace
|
|
1499
|
+
mappedContents = mappedContents.replace(
|
|
1500
|
+
/^\s*\{/,
|
|
1501
|
+
'{\n...__item__,',
|
|
1502
|
+
);
|
|
1503
|
+
}
|
|
806
1504
|
returnValueContents = `${arrayBasePath}?.map((__item__, __idx__) => (\n${indent(mappedContents)}\n))`;
|
|
807
1505
|
}
|
|
808
1506
|
} else {
|
|
809
1507
|
returnValueContents = `[\n${indent(levelContents)}\n]`;
|
|
810
1508
|
}
|
|
811
1509
|
} else {
|
|
812
|
-
|
|
1510
|
+
// When we have a single data path and nested content that creates an object structure,
|
|
1511
|
+
// and we're NOT at the root level, we need to handle the case where the parent data
|
|
1512
|
+
// value is null or undefined. Without this check, `{ ...null, prop: null?.["prop"] }`
|
|
1513
|
+
// creates `{ prop: undefined }` instead of `null`, causing errors like
|
|
1514
|
+
// "Cannot read properties of undefined (reading 'some')" when code does
|
|
1515
|
+
// data?.prop.some(...) because data is an object with prop: undefined, not null.
|
|
1516
|
+
// We only apply this to non-root cases because root-level mocks are expected to exist.
|
|
1517
|
+
// We also skip structural elements (like [0] inside arrays) because the null check
|
|
1518
|
+
// syntax doesn't work inside .map() callbacks where structural elements are used.
|
|
1519
|
+
// We also skip array index elements ([0], [1], etc.) because they represent tuple/array
|
|
1520
|
+
// elements, not properties that could be null.
|
|
1521
|
+
// We also only apply this when we're inside a function return value context - i.e.,
|
|
1522
|
+
// when the data path contains a function call pattern like ?.["someFunction(...)"].
|
|
1523
|
+
// This prevents adding null checks to intermediate objects in chains like supabase.auth.
|
|
1524
|
+
const hasNestedContent = nestedContent.filter(Boolean).length > 0;
|
|
1525
|
+
const isArrayIndexElement = name.match(/^\[\d*\]$/);
|
|
1526
|
+
// Check if data path contains a function call pattern, indicating we're inside a function return value
|
|
1527
|
+
const isInsideFunctionReturnValue =
|
|
1528
|
+
dataPaths.length === 1 &&
|
|
1529
|
+
dataPaths[0].match(/\?\.\["\w+\([^"]*\)"\]/);
|
|
1530
|
+
if (
|
|
1531
|
+
!root &&
|
|
1532
|
+
!returnValue.isStructural &&
|
|
1533
|
+
!isArrayIndexElement &&
|
|
1534
|
+
isInsideFunctionReturnValue &&
|
|
1535
|
+
hasNestedContent
|
|
1536
|
+
) {
|
|
1537
|
+
// Wrap with null check: if parent is null/undefined, return it directly; otherwise create object
|
|
1538
|
+
returnValueContents = `${dataPaths[0]} == null ? ${dataPaths[0]} : {\n${indent(levelContents)}\n}`;
|
|
1539
|
+
} else {
|
|
1540
|
+
returnValueContents = `{\n${indent(levelContents)}\n}`;
|
|
1541
|
+
}
|
|
813
1542
|
}
|
|
814
1543
|
}
|
|
815
1544
|
|
|
@@ -908,14 +1637,29 @@ export default function constructMockCode(
|
|
|
908
1637
|
content = `${cleanOutTypes(name)}: ${isAsyncFunction ? 'async ' : ''}(${argsString}) => {\n${indent(funcContents)}\n}`;
|
|
909
1638
|
} else {
|
|
910
1639
|
// No argument variants - use existing behavior
|
|
911
|
-
|
|
1640
|
+
// But if there's nested content, we need to include it in the return object
|
|
1641
|
+
// (similar to how argument variant branches handle this at line 1070-1072)
|
|
1642
|
+
const hasNestedContent = validNestedContent.length > 0;
|
|
1643
|
+
let funcReturnContents: string;
|
|
1644
|
+
if (hasNestedContent && levelContentItems.length > 1) {
|
|
1645
|
+
// Include both spread and nested content in the return
|
|
1646
|
+
funcReturnContents = `{\n${indent(levelContents)}\n}`;
|
|
1647
|
+
} else {
|
|
1648
|
+
funcReturnContents = returnValueContents;
|
|
1649
|
+
}
|
|
1650
|
+
const funcContents = `return ${funcReturnContents}`;
|
|
912
1651
|
content = `${cleanOutTypes(name)}: ${isAsyncFunction ? 'async ' : ''}(${argsString}) => {\n${indent(funcContents)}\n}`;
|
|
913
1652
|
}
|
|
914
1653
|
} else {
|
|
915
1654
|
if (!isValidKey(name)) {
|
|
916
1655
|
return;
|
|
917
1656
|
} else if (name.match(/\[\d*\]/)) {
|
|
1657
|
+
// Numeric array index like [0], [1] - can be used as computed property
|
|
918
1658
|
content = returnValueContents;
|
|
1659
|
+
} else if (name.match(/^\[[a-zA-Z_]\w*\]$/)) {
|
|
1660
|
+
// Variable-based index like [currentItemIndex] - must be quoted string key
|
|
1661
|
+
// Otherwise JavaScript would try to evaluate the variable name
|
|
1662
|
+
content = `"${safeString(name)}": ${returnValueContents}`;
|
|
919
1663
|
} else {
|
|
920
1664
|
content = `${safeString(name)}: ${returnValueContents}`;
|
|
921
1665
|
}
|
|
@@ -930,34 +1674,91 @@ export default function constructMockCode(
|
|
|
930
1674
|
};
|
|
931
1675
|
|
|
932
1676
|
// Create the return value structure
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
1677
|
+
// OPTIMIZATION: Filter keys to only those starting with baseMockName before sorting.
|
|
1678
|
+
// This dramatically reduces processing time for large schemas (e.g., 9216 keys -> ~100 relevant keys).
|
|
1679
|
+
// Without this filter, the loop would call splitOutsideParenthesesAndArrays on every key
|
|
1680
|
+
// even though most are filtered out later by the baseMockName check.
|
|
1681
|
+
const allSchemaKeys = Object.keys(relevantReturnValueSchema ?? {});
|
|
1682
|
+
const relevantKeys = allSchemaKeys.filter((key) => {
|
|
1683
|
+
// Fast prefix check - key must start with baseMockName followed by ( or < or .
|
|
1684
|
+
// This matches: "useAtom()", "useAtom<T>()", "useAtom.something", but not "useAtomValue()"
|
|
1685
|
+
if (key === baseMockName) return true;
|
|
1686
|
+
if (key.startsWith(baseMockName + '(')) return true;
|
|
1687
|
+
if (key.startsWith(baseMockName + '<')) return true;
|
|
1688
|
+
if (key.startsWith(baseMockName + '.')) return true;
|
|
1689
|
+
// Also include 'returnValue' paths which are normalized later
|
|
1690
|
+
if (
|
|
1691
|
+
key === 'returnValue' ||
|
|
1692
|
+
key.startsWith('returnValue.') ||
|
|
1693
|
+
key.startsWith('returnValue[')
|
|
1694
|
+
)
|
|
1695
|
+
return true;
|
|
1696
|
+
return false;
|
|
1697
|
+
});
|
|
1698
|
+
|
|
1699
|
+
const schemaKeyCount = relevantKeys.length;
|
|
1700
|
+
const sortedKeys = relevantKeys.sort((a: string, b: string) => {
|
|
1701
|
+
const aParts = splitOutsideParenthesesAndArrays(a);
|
|
1702
|
+
const bParts = splitOutsideParenthesesAndArrays(b);
|
|
1703
|
+
|
|
1704
|
+
const maxLength = Math.max(aParts.length, bParts.length);
|
|
1705
|
+
for (let i = 0; i < maxLength; ++i) {
|
|
1706
|
+
const aPart = aParts[i];
|
|
1707
|
+
const bPart = bParts[i];
|
|
1708
|
+
|
|
1709
|
+
if (!aPart) return -1;
|
|
1710
|
+
if (!bPart) return 1;
|
|
1711
|
+
|
|
1712
|
+
if (aPart === bPart) continue;
|
|
1713
|
+
|
|
1714
|
+
const aName = aPart.split('(')[0];
|
|
1715
|
+
const bName = bPart.split('(')[0];
|
|
1716
|
+
|
|
1717
|
+
if (aName !== bName) {
|
|
1718
|
+
return aName.localeCompare(bName);
|
|
1719
|
+
} else {
|
|
1720
|
+
return aPart.localeCompare(bPart);
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
950
1723
|
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
1724
|
+
return 0;
|
|
1725
|
+
});
|
|
1726
|
+
|
|
1727
|
+
// OPTIMIZATION: Pre-compute prefix indexes for O(1) lookups instead of O(n) scans.
|
|
1728
|
+
// This reduces complexity from O(n²) to O(n) for large schemas (9k+ keys).
|
|
1729
|
+
//
|
|
1730
|
+
// 1. extendedReturnValuePrefixes: Set of all path prefixes that have a .functionCallReturnValue extension
|
|
1731
|
+
// Used by hasExtendedFunctionCallReturnValue check at line ~1754
|
|
1732
|
+
// 2. functionCallsWithReturnValue: Set of function call paths where .functionCallReturnValue IMMEDIATELY follows
|
|
1733
|
+
// Used by hasProperFunctionCallPath check at line ~1787
|
|
1734
|
+
// IMPORTANT: Only includes paths where the function call is directly followed by .functionCallReturnValue
|
|
1735
|
+
// e.g., "a.b().functionCallReturnValue" -> adds "a.b()" but NOT "a" even if "a" ends with ")"
|
|
1736
|
+
const extendedReturnValuePrefixes = new Set<string>();
|
|
1737
|
+
const functionCallsWithReturnValue = new Set<string>();
|
|
1738
|
+
|
|
1739
|
+
for (const k of relevantKeys) {
|
|
1740
|
+
const parts = splitOutsideParenthesesAndArrays(k);
|
|
1741
|
+
const returnValueIndex = parts.findIndex((part) =>
|
|
1742
|
+
part.startsWith(RETURN_VALUE),
|
|
1743
|
+
);
|
|
1744
|
+
if (returnValueIndex !== -1) {
|
|
1745
|
+
// Add all prefixes of k up to (but not including) functionCallReturnValue
|
|
1746
|
+
const prefix = joinParenthesesAndArrays(parts.slice(0, returnValueIndex));
|
|
1747
|
+
extendedReturnValuePrefixes.add(prefix);
|
|
1748
|
+
|
|
1749
|
+
// ONLY add to functionCallsWithReturnValue if functionCallReturnValue IMMEDIATELY follows
|
|
1750
|
+
if (prefix.endsWith(')')) {
|
|
1751
|
+
functionCallsWithReturnValue.add(prefix);
|
|
956
1752
|
}
|
|
957
1753
|
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
1754
|
+
// Also add intermediate prefixes for nested paths to extendedReturnValuePrefixes
|
|
1755
|
+
// This helps hasExtendedFunctionCallReturnValue which checks key + '.'
|
|
1756
|
+
for (let i = 1; i < returnValueIndex; i++) {
|
|
1757
|
+
const partialPrefix = joinParenthesesAndArrays(parts.slice(0, i));
|
|
1758
|
+
extendedReturnValuePrefixes.add(partialPrefix);
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
961
1762
|
|
|
962
1763
|
for (const key of sortedKeys) {
|
|
963
1764
|
const value = relevantReturnValueSchema[key];
|
|
@@ -1015,9 +1816,10 @@ export default function constructMockCode(
|
|
|
1015
1816
|
// nested inside (e.g., methods on array elements passed as arguments).
|
|
1016
1817
|
if (hasSignaturePath) continue;
|
|
1017
1818
|
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1819
|
+
// OPTIMIZATION: Use pre-computed index instead of O(n) scan
|
|
1820
|
+
// Old code: Object.keys(relevantReturnValueSchema).some((k) => k.startsWith(key + '.') && k.includes('.functionCallReturnValue'))
|
|
1821
|
+
const hasExtendedFunctionCallReturnValue =
|
|
1822
|
+
extendedReturnValuePrefixes.has(key);
|
|
1021
1823
|
|
|
1022
1824
|
// Skip JSX components - they look like function calls (e.g., Context.Provider())
|
|
1023
1825
|
// but they're React components used in JSX, not functions that need mocking
|
|
@@ -1046,11 +1848,10 @@ export default function constructMockCode(
|
|
|
1046
1848
|
const functionCallPath = joinParenthesesAndArrays(
|
|
1047
1849
|
parts.slice(0, i + 1),
|
|
1048
1850
|
);
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
);
|
|
1851
|
+
// OPTIMIZATION: Use pre-computed index instead of O(n) scan
|
|
1852
|
+
// Old code: Object.keys(relevantReturnValueSchema).some((k) => k.startsWith(functionCallPath + '.functionCallReturnValue'))
|
|
1853
|
+
const hasProperFunctionCallPath =
|
|
1854
|
+
functionCallsWithReturnValue.has(functionCallPath);
|
|
1054
1855
|
if (hasProperFunctionCallPath) {
|
|
1055
1856
|
// Skip this path - the .functionCallReturnValue path will handle it correctly
|
|
1056
1857
|
shouldSkipKey = true;
|
|
@@ -1109,6 +1910,17 @@ export default function constructMockCode(
|
|
|
1109
1910
|
const nextIsArray = !!nextPart?.match(/^\[\d*\]/);
|
|
1110
1911
|
const isDifferentiatedArray = !!part?.match(/^\[\d+\]/);
|
|
1111
1912
|
const nextIsDifferentiatedArray = !!nextPart?.match(/^\[\d+\]/);
|
|
1913
|
+
|
|
1914
|
+
// Variable index patterns like [currentItemIndex] or [targetIndex] indicate array access
|
|
1915
|
+
// but don't represent actual data structure - they're markers from variable-based index tracking.
|
|
1916
|
+
// Skip them AND all remaining parts to avoid creating spurious nested structure that breaks array iteration.
|
|
1917
|
+
// The remaining parts (e.g., .missing_attributes) describe properties of array elements, which are
|
|
1918
|
+
// already handled by the generic [] accessor path.
|
|
1919
|
+
const isVariableIndex = !!part?.match(/^\[[a-zA-Z_]\w*\]$/);
|
|
1920
|
+
if (isVariableIndex) {
|
|
1921
|
+
// Break out of the loop entirely - don't process any remaining parts
|
|
1922
|
+
break;
|
|
1923
|
+
}
|
|
1112
1924
|
// Find the correct value for the current part being processed
|
|
1113
1925
|
let partValue = value; // default to the final value
|
|
1114
1926
|
if (isFunctionCallReturnValue(part) && nextIsArray) {
|
|
@@ -1216,7 +2028,52 @@ export default function constructMockCode(
|
|
|
1216
2028
|
}
|
|
1217
2029
|
}
|
|
1218
2030
|
} else {
|
|
1219
|
-
|
|
2031
|
+
// Before setting returnsFunctionArgs on the parent (for generic [] = function),
|
|
2032
|
+
// check if there are specific array indices (like [0], [1]) that are NOT functions.
|
|
2033
|
+
// If so, don't set returnsFunctionArgs because those specific indices take precedence.
|
|
2034
|
+
// This prevents adding ["()"] to paths like [0] when [0] is 'unknown' but [] is 'function'.
|
|
2035
|
+
//
|
|
2036
|
+
// Use parts.slice(0, i + 1) to get the current path INCLUDING functionCallReturnValue.
|
|
2037
|
+
// For example, if parts = ['useAtom()','functionCallReturnValue','[]']
|
|
2038
|
+
// and i = 1, we want to check 'useAtom().functionCallReturnValue[0]' etc.
|
|
2039
|
+
const arrayContainerPath = joinParenthesesAndArrays(
|
|
2040
|
+
parts.slice(0, i + 1),
|
|
2041
|
+
);
|
|
2042
|
+
|
|
2043
|
+
const hasNonFunctionSpecificIndices = Object.entries(
|
|
2044
|
+
relevantReturnValueSchema,
|
|
2045
|
+
).some(([k, v]) => {
|
|
2046
|
+
// Look for paths like "arrayContainerPath[0]", "arrayContainerPath[1]" etc.
|
|
2047
|
+
const indexMatch = k.match(
|
|
2048
|
+
new RegExp(
|
|
2049
|
+
`^${arrayContainerPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\[(\\d+)\\]$`,
|
|
2050
|
+
),
|
|
2051
|
+
);
|
|
2052
|
+
// If found and it's NOT a function type, we have a conflict
|
|
2053
|
+
return (
|
|
2054
|
+
indexMatch &&
|
|
2055
|
+
!['function', 'async-function'].includes(v as string)
|
|
2056
|
+
);
|
|
2057
|
+
});
|
|
2058
|
+
|
|
2059
|
+
// Also check if [] has nested object properties (like [].filter, [].name)
|
|
2060
|
+
// If so, [] items are objects with properties, not pure functions to be called
|
|
2061
|
+
// This handles cases where the schema shows [].filter = object but doesn't
|
|
2062
|
+
// have explicit [0] entries
|
|
2063
|
+
const genericArrayPath = `${arrayContainerPath}[]`;
|
|
2064
|
+
const hasNestedProperties = Object.keys(
|
|
2065
|
+
relevantReturnValueSchema,
|
|
2066
|
+
).some((k) => {
|
|
2067
|
+
// Check for paths like "arrayContainerPath[].propertyName" (not [].())
|
|
2068
|
+
return (
|
|
2069
|
+
k.startsWith(genericArrayPath + '.') &&
|
|
2070
|
+
!k.startsWith(genericArrayPath + '.(')
|
|
2071
|
+
);
|
|
2072
|
+
});
|
|
2073
|
+
|
|
2074
|
+
if (!hasNonFunctionSpecificIndices && !hasNestedProperties) {
|
|
2075
|
+
returnValueSection.returnsFunctionArgs = [];
|
|
2076
|
+
}
|
|
1220
2077
|
}
|
|
1221
2078
|
}
|
|
1222
2079
|
}
|
|
@@ -1241,7 +2098,8 @@ export default function constructMockCode(
|
|
|
1241
2098
|
}
|
|
1242
2099
|
// If the next part is an object with nested content, continue processing
|
|
1243
2100
|
// This handles paths like functionCallReturnValue.selectedOptions.elementOptions[]
|
|
1244
|
-
|
|
2101
|
+
// Also handles union types like 'array | undefined' or 'object | undefined'
|
|
2102
|
+
if (nextValue?.includes('object') || nextValue?.includes('array')) {
|
|
1245
2103
|
continue;
|
|
1246
2104
|
}
|
|
1247
2105
|
}
|
|
@@ -1395,7 +2253,14 @@ export default function constructMockCode(
|
|
|
1395
2253
|
relevantPart.isGenericArray = true;
|
|
1396
2254
|
}
|
|
1397
2255
|
|
|
1398
|
-
if
|
|
2256
|
+
// Check if there are remaining parts after functionCallReturnValue that need processing
|
|
2257
|
+
// (e.g., data properties like useQuery().functionCallReturnValue.data)
|
|
2258
|
+
const hasRemainingPartsAfterReturnValue =
|
|
2259
|
+
nextPart &&
|
|
2260
|
+
(isFunctionCallReturnValue(nextPart) ||
|
|
2261
|
+
(isFunctionCallReturnValue(parts[i]) && i < parts.length - 1));
|
|
2262
|
+
|
|
2263
|
+
if (!hasNestedFunction && !hasRemainingPartsAfterReturnValue) {
|
|
1399
2264
|
// Before breaking, check if this function returns an array
|
|
1400
2265
|
// by looking for a functionCallReturnValue: 'array' entry in the schema
|
|
1401
2266
|
if (relevantPart && part.endsWith(')')) {
|
|
@@ -1427,6 +2292,7 @@ export default function constructMockCode(
|
|
|
1427
2292
|
|
|
1428
2293
|
if (mockNameParts.length > 1) {
|
|
1429
2294
|
const originalLib = `${mockNameParts[0]}__cyOriginal`;
|
|
2295
|
+
const skipOriginalSpread = options?.skipOriginalSpread;
|
|
1430
2296
|
|
|
1431
2297
|
const subPart = (
|
|
1432
2298
|
parts: string[],
|
|
@@ -1438,7 +2304,9 @@ export default function constructMockCode(
|
|
|
1438
2304
|
|
|
1439
2305
|
const partContents = isLast
|
|
1440
2306
|
? contents
|
|
1441
|
-
:
|
|
2307
|
+
: skipOriginalSpread
|
|
2308
|
+
? subPart(parts, originalLib)
|
|
2309
|
+
: `...${originalLib}.${part},\n${subPart(parts, originalLib)}`;
|
|
1442
2310
|
|
|
1443
2311
|
let code = `${part}: {\n${indent(partContents)}\n}`;
|
|
1444
2312
|
|
|
@@ -1452,12 +2320,14 @@ export default function constructMockCode(
|
|
|
1452
2320
|
return code;
|
|
1453
2321
|
};
|
|
1454
2322
|
|
|
1455
|
-
const returnParts =
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
2323
|
+
const returnParts = skipOriginalSpread
|
|
2324
|
+
? [subPart(mockNameParts.slice(1), originalLib)]
|
|
2325
|
+
: [
|
|
2326
|
+
`...${mockNameParts[0]}__cyOriginal`,
|
|
2327
|
+
subPart(mockNameParts.slice(1), originalLib),
|
|
2328
|
+
];
|
|
1459
2329
|
|
|
1460
|
-
return `const ${mockNameParts[0]} = {\n${indent(returnParts.join(',\n'))}\n};`;
|
|
2330
|
+
return `const ${mockNameParts[0]} = {\n${indent(returnParts.filter(Boolean).join(',\n'))}\n};`;
|
|
1461
2331
|
} else if (isFunction) {
|
|
1462
2332
|
// For headers() and cookies() from next/headers, add common iterator methods
|
|
1463
2333
|
// These are needed when the mock is passed to functions that use .entries(), .keys(), etc.
|
|
@@ -1468,12 +2338,13 @@ export default function constructMockCode(
|
|
|
1468
2338
|
if (needsIteratorMethods && contents.trim().startsWith('{')) {
|
|
1469
2339
|
// Add iterator methods that operate on the scenario data
|
|
1470
2340
|
// Use the dataKey (original call signature or canonical key)
|
|
2341
|
+
const quotedDataKey = quotePropertyKey(dataKey);
|
|
1471
2342
|
const iteratorMethods = `,
|
|
1472
|
-
entries: () => Object.entries(scenarios().data()
|
|
1473
|
-
keys: () => Object.keys(scenarios().data()
|
|
1474
|
-
values: () => Object.values(scenarios().data()
|
|
1475
|
-
forEach: (fn) => Object.entries(scenarios().data()
|
|
1476
|
-
has: (key) => Object.prototype.hasOwnProperty.call(scenarios().data()
|
|
2343
|
+
entries: () => Object.entries(scenarios().data()?.${quotedDataKey} || {}),
|
|
2344
|
+
keys: () => Object.keys(scenarios().data()?.${quotedDataKey} || {}),
|
|
2345
|
+
values: () => Object.values(scenarios().data()?.${quotedDataKey} || {}),
|
|
2346
|
+
forEach: (fn) => Object.entries(scenarios().data()?.${quotedDataKey} || {}).forEach(([k, v]) => fn(v, k)),
|
|
2347
|
+
has: (key) => Object.prototype.hasOwnProperty.call(scenarios().data()?.${quotedDataKey} || {}, key)`;
|
|
1477
2348
|
// Insert before the closing brace (handle trailing whitespace)
|
|
1478
2349
|
enhancedContents = contents.replace(/\}\s*$/, iteratorMethods + '\n}');
|
|
1479
2350
|
}
|
|
@@ -1498,7 +2369,7 @@ export default function constructMockCode(
|
|
|
1498
2369
|
constructor(message) {
|
|
1499
2370
|
${superCall}
|
|
1500
2371
|
${nameAssignment}
|
|
1501
|
-
Object.assign(this, scenarios().data()
|
|
2372
|
+
Object.assign(this, scenarios().data()?.${quotePropertyKey(dataKey)} || {});
|
|
1502
2373
|
}
|
|
1503
2374
|
}`;
|
|
1504
2375
|
}
|
|
@@ -1558,13 +2429,41 @@ export default function constructMockCode(
|
|
|
1558
2429
|
return false;
|
|
1559
2430
|
});
|
|
1560
2431
|
|
|
2432
|
+
// Use ...args to accept any number of arguments - prevents TypeScript errors
|
|
2433
|
+
// like "Expected 0 arguments, but got X" when caller passes arguments
|
|
1561
2434
|
// For higher-order functions, wrap the return in an arrow function
|
|
1562
2435
|
// so that mockFunc(arg)() works correctly (outer call returns a function, inner call gets the data)
|
|
1563
2436
|
const returnValue = isHigherOrderFunction
|
|
1564
|
-
? `() => ${
|
|
1565
|
-
:
|
|
1566
|
-
|
|
1567
|
-
|
|
2437
|
+
? `() => (${enhancedContents})`
|
|
2438
|
+
: enhancedContents;
|
|
2439
|
+
|
|
2440
|
+
// Inline the return value directly in the function to avoid module-level const
|
|
2441
|
+
// that would be evaluated before scenario context is ready
|
|
2442
|
+
// Add fallback for simple data path returns to prevent undefined errors (e.g., createTheme)
|
|
2443
|
+
// Only add fallback if returnValue is a simple data accessor (starts with scenarios().data())
|
|
2444
|
+
// and doesn't already have nested structure (object literal, array, or method chains like .map())
|
|
2445
|
+
const isSimpleDataPath =
|
|
2446
|
+
returnValue.startsWith('scenarios().data()') &&
|
|
2447
|
+
!returnValue.trim().startsWith('{') &&
|
|
2448
|
+
!returnValue.trim().startsWith('[') &&
|
|
2449
|
+
!returnValue.includes('.map('); // Exclude method chains
|
|
2450
|
+
const safeReturnValue = isSimpleDataPath
|
|
2451
|
+
? `${returnValue} ?? {}`
|
|
2452
|
+
: returnValue;
|
|
2453
|
+
const refName = `_${safeFunctionName}Ref`;
|
|
2454
|
+
const assignment = `${refName}.current = ${safeReturnValue};`;
|
|
2455
|
+
const ifBlock = `if (!${refName}.current) {\n${indent(assignment)}\n}`;
|
|
2456
|
+
const body = `${ifBlock}\nreturn ${refName}.current;`;
|
|
2457
|
+
|
|
2458
|
+
return [
|
|
2459
|
+
`// PATCHED: memoize to return stable reference (prevents infinite useEffect re-triggers)`,
|
|
2460
|
+
`const ${refName} = {`,
|
|
2461
|
+
` current: null,`,
|
|
2462
|
+
`};`,
|
|
2463
|
+
`${isRootAsyncFunction ? 'async ' : ''}function ${safeFunctionName}(...args) {`,
|
|
2464
|
+
indent(body),
|
|
2465
|
+
`}`,
|
|
2466
|
+
].join('\n');
|
|
1568
2467
|
} else {
|
|
1569
2468
|
// Generate safe const name:
|
|
1570
2469
|
// 1. For call signatures: use derivedFunctionName
|