@codeyam/codeyam-cli 0.1.0-staging.8e7b1bd → 0.1.0-staging.a77070e
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 +37 -33
- package/analyzer-template/packages/ai/index.ts +21 -5
- package/analyzer-template/packages/ai/package.json +5 -5
- package/analyzer-template/packages/ai/src/lib/__mocks__/completionCall.ts +122 -0
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +228 -24
- package/analyzer-template/packages/ai/src/lib/astScopes/arrayDerivationDetector.ts +199 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +239 -13
- package/analyzer-template/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.ts +644 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +181 -23
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.ts +10 -17
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.ts +18 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.ts +38 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.ts +181 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +1619 -125
- package/analyzer-template/packages/ai/src/lib/astScopes/sharedPatterns.ts +28 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +324 -5
- package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +29 -10
- package/analyzer-template/packages/ai/src/lib/completionCall.ts +247 -66
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +2788 -390
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +21 -4
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +976 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +243 -77
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.ts +16 -3
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.ts +6 -4
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +71 -2
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +161 -19
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.ts +70 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coercePrimitivesToArraysBySchema.ts +62 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +163 -14
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.ts +98 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.ts +179 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.ts +40 -30
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +422 -86
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.ts +129 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/stripNullableMarkers.ts +35 -0
- package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +183 -0
- package/analyzer-template/packages/ai/src/lib/deepEqual.ts +30 -0
- package/analyzer-template/packages/ai/src/lib/e2eDataTracking.ts +334 -0
- package/analyzer-template/packages/ai/src/lib/extractCriticalDataKeys.ts +120 -0
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarioData.ts +74 -7
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +89 -112
- package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +63 -2
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +1497 -92
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +216 -109
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +677 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +528 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +2484 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +239 -0
- package/analyzer-template/packages/ai/src/lib/getConditionalUsagesFromCode.ts +143 -31
- package/analyzer-template/packages/ai/src/lib/guessScenarioDataFromDescription.ts +8 -2
- package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +328 -7
- package/analyzer-template/packages/ai/src/lib/mergeJsonTypeDefinitions.ts +5 -0
- package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +111 -87
- package/analyzer-template/packages/ai/src/lib/promptGenerators/collapseNullableObjects.ts +118 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +17 -7
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.ts +1 -1
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +32 -102
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChunkPrompt.ts +82 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateCriticalKeysPrompt.ts +103 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +110 -6
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.ts +14 -53
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.ts +58 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.ts +28 -2
- package/analyzer-template/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.ts +391 -0
- package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +824 -0
- package/analyzer-template/packages/ai/src/lib/splitOutsideParentheses.ts +5 -1
- package/analyzer-template/packages/ai/src/lib/validateExecutionFlowPaths.ts +531 -0
- package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +127 -3
- package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +121 -2
- package/analyzer-template/packages/analyze/index.ts +2 -0
- package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +79 -59
- package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +132 -33
- package/analyzer-template/packages/analyze/src/lib/analysisContext.ts +44 -4
- package/analyzer-template/packages/analyze/src/lib/asts/index.ts +7 -2
- package/analyzer-template/packages/analyze/src/lib/asts/nodes/getNodeType.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/asts/nodes/index.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/asts/nodes/isAsyncFunction.ts +67 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.ts +19 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.ts +19 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllExports.ts +11 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.ts +8 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.ts +49 -1
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.ts +2 -1
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +570 -180
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +62 -1
- package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +15 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/gatherEntityMap.ts +4 -2
- package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +33 -10
- package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +31 -15
- package/analyzer-template/packages/analyze/src/lib/files/analyzeEntity.ts +11 -7
- package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +11 -12
- package/analyzer-template/packages/analyze/src/lib/files/analyzeRemixRoute.ts +4 -5
- package/analyzer-template/packages/analyze/src/lib/files/enums/steps.ts +1 -1
- package/analyzer-template/packages/analyze/src/lib/files/getImportedExports.ts +22 -13
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/TransformationTracer.ts +1352 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +313 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.ts +102 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +675 -77
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.ts +1 -1
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.ts +28 -62
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +633 -137
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +166 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +78 -83
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +4 -8
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +1087 -168
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.ts +56 -11
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/propagateArrayItemSchemas.ts +474 -0
- package/analyzer-template/packages/analyze/src/lib/files/setImportedExports.ts +2 -1
- package/analyzer-template/packages/analyze/src/lib/index.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/utils/getFileByPath.ts +19 -0
- package/analyzer-template/packages/aws/codebuild/index.ts +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts +11 -1
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js +29 -18
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts +2 -2
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js +2 -2
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts +8 -18
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js +17 -61
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts +15 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts.map +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js +31 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js.map +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js +8 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js.map +1 -1
- package/analyzer-template/packages/aws/package.json +10 -10
- package/analyzer-template/packages/aws/s3/index.ts +1 -0
- package/analyzer-template/packages/aws/src/lib/codebuild/waitForBuild.ts +43 -19
- package/analyzer-template/packages/aws/src/lib/ecs/ecsDefineContainer.ts +3 -3
- package/analyzer-template/packages/aws/src/lib/ecs/ecsTaskFactory.ts +17 -69
- package/analyzer-template/packages/aws/src/lib/s3/checkS3ObjectExists.ts +47 -0
- package/analyzer-template/packages/aws/src/lib/s3/uploadFileToS3.ts +8 -1
- package/analyzer-template/packages/database/index.ts +1 -0
- package/analyzer-template/packages/database/package.json +4 -4
- 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 +26 -5
- package/analyzer-template/packages/database/src/lib/kysely/tableRelations.ts +2 -2
- package/analyzer-template/packages/database/src/lib/kysely/tables/commitsTable.ts +6 -0
- package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +36 -9
- package/analyzer-template/packages/database/src/lib/kysely/tables/editorScenariosTable.ts +164 -0
- 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 +58 -19
- package/analyzer-template/packages/database/src/lib/loadEntities.ts +26 -9
- package/analyzer-template/packages/database/src/lib/loadEntityBranches.ts +12 -0
- package/analyzer-template/packages/database/src/lib/loadReadyToBeCapturedAnalyses.ts +5 -5
- package/analyzer-template/packages/database/src/lib/projectToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/saveFiles.ts +1 -1
- package/analyzer-template/packages/database/src/lib/scenarioToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +96 -152
- package/analyzer-template/packages/database/src/lib/updateFreshAnalysisStatus.ts +58 -42
- package/analyzer-template/packages/database/src/lib/updateFreshAnalysisStatusWithScenarios.ts +81 -65
- 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 +221 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.ts +73 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.ts +42 -9
- package/analyzer-template/packages/generate/src/lib/deepMerge.ts +26 -1
- package/analyzer-template/packages/generate/src/lib/getComponentScenarioPath.ts +8 -3
- package/analyzer-template/packages/generate/src/lib/scenarioComponentForServer.ts +114 -0
- package/analyzer-template/packages/github/dist/database/index.d.ts +1 -0
- package/analyzer-template/packages/github/dist/database/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/index.js +1 -0
- package/analyzer-template/packages/github/dist/database/index.js.map +1 -1
- 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 +6 -2
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +18 -3
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tableRelations.d.ts +2 -2
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts +1 -11
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js +3 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +30 -7
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts +29 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js +149 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -0
- 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 +7 -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 +45 -14
- 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 -10
- 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.js +5 -3
- 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 +76 -89
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatus.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatus.js +41 -30
- package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatus.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatusWithScenarios.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatusWithScenarios.js +68 -57
- package/analyzer-template/packages/github/dist/database/src/lib/updateFreshAnalysisStatusWithScenarios.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 +217 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts +20 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +41 -9
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js +27 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/getComponentScenarioPath.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/getComponentScenarioPath.js +7 -3
- package/analyzer-template/packages/github/dist/generate/src/lib/getComponentScenarioPath.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts +8 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js +89 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js.map +1 -0
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js +10 -0
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js +3 -0
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.d.ts +2 -2
- package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.js +2 -0
- package/analyzer-template/packages/github/dist/types/src/enums/ProjectFramework.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +87 -13
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts +8 -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 +21 -6
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +199 -3
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/applyUniversalMocks.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/applyUniversalMocks.js +26 -2
- package/analyzer-template/packages/github/dist/utils/src/lib/applyUniversalMocks.js.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
- package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts +9 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js +29 -3
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js.map +1 -1
- package/analyzer-template/packages/github/package.json +2 -2
- package/analyzer-template/packages/github/src/lib/loadOrCreateCommit.ts +14 -0
- package/analyzer-template/packages/github/src/lib/syncPrimaryBranch.ts +2 -0
- package/analyzer-template/packages/process/index.ts +2 -0
- package/analyzer-template/packages/process/package.json +12 -0
- package/analyzer-template/packages/process/tsconfig.json +8 -0
- package/analyzer-template/packages/types/index.ts +5 -0
- package/analyzer-template/packages/types/src/enums/ProjectFramework.ts +2 -0
- package/analyzer-template/packages/types/src/types/Analysis.ts +104 -13
- package/analyzer-template/packages/types/src/types/Commit.ts +2 -0
- package/analyzer-template/packages/types/src/types/Entity.ts +2 -0
- package/analyzer-template/packages/types/src/types/ProjectMetadata.ts +8 -0
- package/analyzer-template/packages/types/src/types/Scenario.ts +21 -10
- package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +228 -3
- package/analyzer-template/packages/types/src/types/ScopeAnalysis.ts +6 -1
- package/analyzer-template/packages/types/src/types/StatementInfo.ts +2 -0
- package/analyzer-template/packages/ui-components/package.json +5 -5
- package/analyzer-template/packages/ui-components/src/components/ScenarioDetailInteractiveView.tsx +23 -7
- package/analyzer-template/packages/utils/dist/types/index.d.ts +2 -2
- package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.js +2 -0
- package/analyzer-template/packages/utils/dist/types/src/enums/ProjectFramework.js.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +87 -13
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts +8 -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 +21 -6
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +199 -3
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/applyUniversalMocks.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/applyUniversalMocks.js +26 -2
- package/analyzer-template/packages/utils/dist/utils/src/lib/applyUniversalMocks.js.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js +98 -3
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
- package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts +9 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js +29 -3
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js.map +1 -1
- package/analyzer-template/packages/utils/src/lib/applyUniversalMocks.ts +28 -2
- package/analyzer-template/packages/utils/src/lib/fs/rsyncCopy.ts +121 -3
- package/analyzer-template/packages/utils/src/lib/lightweightEntityExtractor.ts +27 -0
- package/analyzer-template/packages/utils/src/lib/safeFileName.ts +48 -3
- package/analyzer-template/playwright/capture.ts +57 -26
- package/analyzer-template/playwright/captureFromUrl.ts +89 -82
- package/analyzer-template/playwright/captureStatic.ts +1 -1
- package/analyzer-template/playwright/getCodeYamInfo.ts +12 -7
- package/analyzer-template/playwright/takeElementScreenshot.ts +26 -11
- package/analyzer-template/playwright/takeScreenshot.ts +9 -7
- package/analyzer-template/playwright/waitForServer.ts +21 -6
- package/analyzer-template/project/TESTING.md +83 -0
- package/analyzer-template/project/analyzeBaselineCommit.ts +9 -0
- package/analyzer-template/project/analyzeBranchCommit.ts +4 -0
- package/analyzer-template/project/analyzeFileEntities.ts +4 -0
- package/analyzer-template/project/analyzeRegularCommit.ts +9 -0
- package/analyzer-template/project/captureLibraryFunctionDirect.ts +29 -26
- package/analyzer-template/project/constructMockCode.ts +1453 -189
- package/analyzer-template/project/controller/startController.ts +16 -1
- package/analyzer-template/project/createEntitiesAndSortFiles.ts +83 -0
- package/analyzer-template/project/executeLibraryFunctionDirect.ts +7 -3
- package/analyzer-template/project/loadReadyToBeCaptured.ts +82 -42
- package/analyzer-template/project/mocks/analyzeFileMock.ts +8 -7
- package/analyzer-template/project/orchestrateCapture/AwsCaptureTaskRunner.ts +12 -4
- package/analyzer-template/project/orchestrateCapture/KyselyAnalysisLoader.ts +13 -9
- package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +93 -42
- package/analyzer-template/project/orchestrateCapture/taskRunner.ts +4 -2
- package/analyzer-template/project/orchestrateCapture.ts +85 -10
- package/analyzer-template/project/reconcileMockDataKeys.ts +251 -3
- package/analyzer-template/project/runAnalysis.ts +11 -0
- package/analyzer-template/project/runMultiScenarioServer.ts +11 -10
- package/analyzer-template/project/serverOnlyModules.ts +413 -0
- package/analyzer-template/project/start.ts +64 -15
- package/analyzer-template/project/startScenarioCapture.ts +88 -41
- package/analyzer-template/project/writeClientLogRoute.ts +125 -0
- package/analyzer-template/project/writeMockDataTsx.ts +458 -65
- package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
- package/analyzer-template/project/writeScenarioComponents.ts +1529 -237
- package/analyzer-template/project/writeScenarioFiles.ts +26 -0
- package/analyzer-template/project/writeSimpleRoot.ts +31 -23
- package/analyzer-template/project/writeUniversalMocks.ts +32 -11
- package/analyzer-template/scripts/comboWorkerLoop.cjs +99 -50
- package/analyzer-template/scripts/defaultCmd.sh +9 -0
- package/analyzer-template/tsconfig.json +14 -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 +1283 -144
- package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
- package/background/src/lib/virtualized/project/controller/startController.js +11 -1
- package/background/src/lib/virtualized/project/controller/startController.js.map +1 -1
- package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js +73 -1
- package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js.map +1 -1
- package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js +6 -3
- package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js.map +1 -1
- package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js +34 -9
- package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js.map +1 -1
- package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js +7 -7
- package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js +2 -2
- package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js +12 -6
- package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +73 -36
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture.js +69 -11
- package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +211 -3
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
- package/background/src/lib/virtualized/project/runAnalysis.js +9 -0
- package/background/src/lib/virtualized/project/runAnalysis.js.map +1 -1
- package/background/src/lib/virtualized/project/runMultiScenarioServer.js +11 -9
- package/background/src/lib/virtualized/project/runMultiScenarioServer.js.map +1 -1
- package/background/src/lib/virtualized/project/serverOnlyModules.js +338 -0
- package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -0
- package/background/src/lib/virtualized/project/start.js +55 -15
- package/background/src/lib/virtualized/project/start.js.map +1 -1
- package/background/src/lib/virtualized/project/startScenarioCapture.js +66 -31
- package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/writeClientLogRoute.js +110 -0
- package/background/src/lib/virtualized/project/writeClientLogRoute.js.map +1 -0
- package/background/src/lib/virtualized/project/writeMockDataTsx.js +393 -54
- 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 +1129 -161
- package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioFiles.js +19 -0
- package/background/src/lib/virtualized/project/writeScenarioFiles.js.map +1 -1
- package/background/src/lib/virtualized/project/writeSimpleRoot.js +31 -21
- package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
- package/background/src/lib/virtualized/project/writeUniversalMocks.js +27 -12
- package/background/src/lib/virtualized/project/writeUniversalMocks.js.map +1 -1
- package/codeyam-cli/scripts/apply-setup.js +386 -9
- package/codeyam-cli/scripts/apply-setup.js.map +1 -1
- package/codeyam-cli/src/__tests__/memory-scripts/filter-session.test.js +196 -0
- package/codeyam-cli/src/__tests__/memory-scripts/filter-session.test.js.map +1 -0
- package/codeyam-cli/src/__tests__/memory-scripts/read-json-field.test.js +114 -0
- package/codeyam-cli/src/__tests__/memory-scripts/read-json-field.test.js.map +1 -0
- package/codeyam-cli/src/__tests__/memory-scripts/ripgrep-fallback.test.js +149 -0
- package/codeyam-cli/src/__tests__/memory-scripts/ripgrep-fallback.test.js.map +1 -0
- package/codeyam-cli/src/cli.js +48 -22
- package/codeyam-cli/src/cli.js.map +1 -1
- package/codeyam-cli/src/codeyam-cli.js +18 -2
- package/codeyam-cli/src/codeyam-cli.js.map +1 -1
- package/codeyam-cli/src/commands/__tests__/editor.isolateArgs.test.js +51 -0
- package/codeyam-cli/src/commands/__tests__/editor.isolateArgs.test.js.map +1 -0
- package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js +56 -0
- package/codeyam-cli/src/commands/__tests__/editor.stepDispatch.test.js.map +1 -0
- package/codeyam-cli/src/commands/__tests__/init.gitignore.test.js +101 -47
- package/codeyam-cli/src/commands/__tests__/init.gitignore.test.js.map +1 -1
- package/codeyam-cli/src/commands/analyze.js +22 -10
- package/codeyam-cli/src/commands/analyze.js.map +1 -1
- package/codeyam-cli/src/commands/baseline.js +176 -0
- package/codeyam-cli/src/commands/baseline.js.map +1 -0
- package/codeyam-cli/src/commands/debug.js +44 -18
- package/codeyam-cli/src/commands/debug.js.map +1 -1
- package/codeyam-cli/src/commands/default.js +43 -35
- package/codeyam-cli/src/commands/default.js.map +1 -1
- package/codeyam-cli/src/commands/editor.js +4692 -0
- package/codeyam-cli/src/commands/editor.js.map +1 -0
- package/codeyam-cli/src/commands/editorIsolateArgs.js +25 -0
- package/codeyam-cli/src/commands/editorIsolateArgs.js.map +1 -0
- package/codeyam-cli/src/commands/init.js +148 -292
- package/codeyam-cli/src/commands/init.js.map +1 -1
- package/codeyam-cli/src/commands/memory.js +278 -0
- package/codeyam-cli/src/commands/memory.js.map +1 -0
- package/codeyam-cli/src/commands/recapture.js +228 -0
- package/codeyam-cli/src/commands/recapture.js.map +1 -0
- package/codeyam-cli/src/commands/report.js +72 -24
- package/codeyam-cli/src/commands/report.js.map +1 -1
- package/codeyam-cli/src/commands/setup-sandbox.js +2 -0
- package/codeyam-cli/src/commands/setup-sandbox.js.map +1 -1
- package/codeyam-cli/src/commands/setup-simulations.js +284 -0
- package/codeyam-cli/src/commands/setup-simulations.js.map +1 -0
- package/codeyam-cli/src/commands/start.js +8 -12
- package/codeyam-cli/src/commands/start.js.map +1 -1
- package/codeyam-cli/src/commands/status.js +23 -1
- package/codeyam-cli/src/commands/status.js.map +1 -1
- package/codeyam-cli/src/commands/telemetry.js +37 -0
- package/codeyam-cli/src/commands/telemetry.js.map +1 -0
- 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/data/techStacks.js +77 -0
- package/codeyam-cli/src/data/techStacks.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js +173 -0
- package/codeyam-cli/src/utils/__tests__/analyzerFinalization.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/backgroundServer.test.js +46 -0
- package/codeyam-cli/src/utils/__tests__/backgroundServer.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/devServerState.test.js +134 -0
- package/codeyam-cli/src/utils/__tests__/devServerState.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorApi.test.js +137 -0
- package/codeyam-cli/src/utils/__tests__/editorApi.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +2520 -0
- package/codeyam-cli/src/utils/__tests__/editorAudit.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorBroadcastViewport.test.js +76 -0
- package/codeyam-cli/src/utils/__tests__/editorBroadcastViewport.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorCapture.test.js +93 -0
- package/codeyam-cli/src/utils/__tests__/editorCapture.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorCaptureScenarioSeeding.test.js +137 -0
- package/codeyam-cli/src/utils/__tests__/editorCaptureScenarioSeeding.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorDeleteScenario.test.js +100 -0
- package/codeyam-cli/src/utils/__tests__/editorDeleteScenario.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorDevServer.test.js +304 -0
- package/codeyam-cli/src/utils/__tests__/editorDevServer.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js +194 -0
- package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorEntityHelpers.test.js +315 -0
- package/codeyam-cli/src/utils/__tests__/editorEntityHelpers.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorImageVerifier.test.js +294 -0
- package/codeyam-cli/src/utils/__tests__/editorImageVerifier.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorJournal.test.js +542 -0
- package/codeyam-cli/src/utils/__tests__/editorJournal.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js +594 -0
- package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorMigration.test.js +435 -0
- package/codeyam-cli/src/utils/__tests__/editorMigration.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorMockState.test.js +270 -0
- package/codeyam-cli/src/utils/__tests__/editorMockState.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorPreloadHelpers.test.js +217 -0
- package/codeyam-cli/src/utils/__tests__/editorPreloadHelpers.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorPreview.test.js +353 -0
- package/codeyam-cli/src/utils/__tests__/editorPreview.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorProxySession.test.js +153 -0
- package/codeyam-cli/src/utils/__tests__/editorProxySession.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarioLookup.test.js +139 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarioLookup.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarioSwitch.test.js +291 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarioSwitch.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js +1609 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js +280 -0
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapterPrismaValidation.test.js +143 -0
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapterPrismaValidation.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorSessionFilter.test.js +66 -0
- package/codeyam-cli/src/utils/__tests__/editorSessionFilter.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorShouldRevalidate.test.js +53 -0
- package/codeyam-cli/src/utils/__tests__/editorShouldRevalidate.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js +1876 -0
- package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/git.editor.test.js +134 -0
- package/codeyam-cli/src/utils/__tests__/git.editor.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/glossaryAdd.test.js +177 -0
- package/codeyam-cli/src/utils/__tests__/glossaryAdd.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/journalCaptureStabilization.test.js +107 -0
- package/codeyam-cli/src/utils/__tests__/journalCaptureStabilization.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/npmVersionCheck.test.js +185 -0
- package/codeyam-cli/src/utils/__tests__/npmVersionCheck.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js +129 -0
- package/codeyam-cli/src/utils/__tests__/parseRegisterArg.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/pathIgnoring.test.js +9 -0
- package/codeyam-cli/src/utils/__tests__/pathIgnoring.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/project.test.js +65 -0
- package/codeyam-cli/src/utils/__tests__/project.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/routePatternMatching.test.js +118 -0
- package/codeyam-cli/src/utils/__tests__/routePatternMatching.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/scenarioCoverage.test.js +284 -0
- package/codeyam-cli/src/utils/__tests__/scenarioCoverage.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/scenarioMarkers.test.js +121 -0
- package/codeyam-cli/src/utils/__tests__/scenarioMarkers.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/scenariosManifest.test.js +672 -0
- package/codeyam-cli/src/utils/__tests__/scenariosManifest.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 +175 -82
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/telemetry.test.js +159 -0
- package/codeyam-cli/src/utils/__tests__/telemetry.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/templateConsistency.test.js +51 -0
- package/codeyam-cli/src/utils/__tests__/templateConsistency.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/webappDetection.test.js +142 -0
- package/codeyam-cli/src/utils/__tests__/webappDetection.test.js.map +1 -0
- package/codeyam-cli/src/utils/analysisRunner.js +32 -16
- package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
- package/codeyam-cli/src/utils/analyzer.js +16 -0
- package/codeyam-cli/src/utils/analyzer.js.map +1 -1
- package/codeyam-cli/src/utils/analyzerFinalization.js +100 -0
- package/codeyam-cli/src/utils/analyzerFinalization.js.map +1 -0
- package/codeyam-cli/src/utils/backgroundServer.js +205 -32
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/buildFlags.js +4 -0
- package/codeyam-cli/src/utils/buildFlags.js.map +1 -0
- package/codeyam-cli/src/utils/database.js +128 -7
- package/codeyam-cli/src/utils/database.js.map +1 -1
- package/codeyam-cli/src/utils/devModeEvents.js +40 -0
- package/codeyam-cli/src/utils/devModeEvents.js.map +1 -0
- package/codeyam-cli/src/utils/devServerState.js +71 -0
- package/codeyam-cli/src/utils/devServerState.js.map +1 -0
- package/codeyam-cli/src/utils/editorApi.js +79 -0
- package/codeyam-cli/src/utils/editorApi.js.map +1 -0
- package/codeyam-cli/src/utils/editorAudit.js +496 -0
- package/codeyam-cli/src/utils/editorAudit.js.map +1 -0
- package/codeyam-cli/src/utils/editorBroadcastViewport.js +26 -0
- package/codeyam-cli/src/utils/editorBroadcastViewport.js.map +1 -0
- package/codeyam-cli/src/utils/editorCapture.js +102 -0
- package/codeyam-cli/src/utils/editorCapture.js.map +1 -0
- package/codeyam-cli/src/utils/editorDeleteScenario.js +67 -0
- package/codeyam-cli/src/utils/editorDeleteScenario.js.map +1 -0
- package/codeyam-cli/src/utils/editorDevServer.js +197 -0
- package/codeyam-cli/src/utils/editorDevServer.js.map +1 -0
- package/codeyam-cli/src/utils/editorEntityChangeStatus.js +50 -0
- package/codeyam-cli/src/utils/editorEntityChangeStatus.js.map +1 -0
- package/codeyam-cli/src/utils/editorEntityHelpers.js +144 -0
- package/codeyam-cli/src/utils/editorEntityHelpers.js.map +1 -0
- package/codeyam-cli/src/utils/editorImageVerifier.js +155 -0
- package/codeyam-cli/src/utils/editorImageVerifier.js.map +1 -0
- package/codeyam-cli/src/utils/editorJournal.js +225 -0
- package/codeyam-cli/src/utils/editorJournal.js.map +1 -0
- package/codeyam-cli/src/utils/editorLoaderHelpers.js +152 -0
- package/codeyam-cli/src/utils/editorLoaderHelpers.js.map +1 -0
- package/codeyam-cli/src/utils/editorMigration.js +224 -0
- package/codeyam-cli/src/utils/editorMigration.js.map +1 -0
- package/codeyam-cli/src/utils/editorMockState.js +248 -0
- package/codeyam-cli/src/utils/editorMockState.js.map +1 -0
- package/codeyam-cli/src/utils/editorPreloadHelpers.js +135 -0
- package/codeyam-cli/src/utils/editorPreloadHelpers.js.map +1 -0
- package/codeyam-cli/src/utils/editorPreview.js +137 -0
- package/codeyam-cli/src/utils/editorPreview.js.map +1 -0
- package/codeyam-cli/src/utils/editorScenarioSwitch.js +134 -0
- package/codeyam-cli/src/utils/editorScenarioSwitch.js.map +1 -0
- package/codeyam-cli/src/utils/editorScenarios.js +584 -0
- package/codeyam-cli/src/utils/editorScenarios.js.map +1 -0
- package/codeyam-cli/src/utils/editorSeedAdapter.js +422 -0
- package/codeyam-cli/src/utils/editorSeedAdapter.js.map +1 -0
- package/codeyam-cli/src/utils/editorShouldRevalidate.js +21 -0
- package/codeyam-cli/src/utils/editorShouldRevalidate.js.map +1 -0
- package/codeyam-cli/src/utils/entityChangeStatus.js +366 -0
- package/codeyam-cli/src/utils/entityChangeStatus.js.map +1 -0
- package/codeyam-cli/src/utils/entityChangeStatus.server.js +196 -0
- package/codeyam-cli/src/utils/entityChangeStatus.server.js.map +1 -0
- package/codeyam-cli/src/utils/fileMetadata.js +5 -0
- package/codeyam-cli/src/utils/fileMetadata.js.map +1 -1
- package/codeyam-cli/src/utils/fileWatcher.js +63 -9
- package/codeyam-cli/src/utils/fileWatcher.js.map +1 -1
- package/codeyam-cli/src/utils/generateReport.js +253 -106
- package/codeyam-cli/src/utils/generateReport.js.map +1 -1
- package/codeyam-cli/src/utils/git.js +182 -0
- package/codeyam-cli/src/utils/git.js.map +1 -0
- package/codeyam-cli/src/utils/glossaryAdd.js +74 -0
- package/codeyam-cli/src/utils/glossaryAdd.js.map +1 -0
- package/codeyam-cli/src/utils/install-skills.js +134 -44
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/interactiveSyncWatcher.js +126 -0
- package/codeyam-cli/src/utils/interactiveSyncWatcher.js.map +1 -0
- 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/parseRegisterArg.js +31 -0
- package/codeyam-cli/src/utils/parseRegisterArg.js.map +1 -0
- package/codeyam-cli/src/utils/pathIgnoring.js +19 -7
- package/codeyam-cli/src/utils/pathIgnoring.js.map +1 -1
- package/codeyam-cli/src/utils/progress.js +8 -1
- package/codeyam-cli/src/utils/progress.js.map +1 -1
- package/codeyam-cli/src/utils/project.js +15 -5
- package/codeyam-cli/src/utils/project.js.map +1 -1
- package/codeyam-cli/src/utils/queue/__tests__/heartbeat.test.js +11 -11
- package/codeyam-cli/src/utils/queue/__tests__/heartbeat.test.js.map +1 -1
- package/codeyam-cli/src/utils/queue/__tests__/manager.test.js +60 -0
- package/codeyam-cli/src/utils/queue/__tests__/manager.test.js.map +1 -1
- package/codeyam-cli/src/utils/queue/heartbeat.js +13 -5
- package/codeyam-cli/src/utils/queue/heartbeat.js.map +1 -1
- package/codeyam-cli/src/utils/queue/job.js +319 -17
- package/codeyam-cli/src/utils/queue/job.js.map +1 -1
- package/codeyam-cli/src/utils/queue/manager.js +26 -7
- package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
- package/codeyam-cli/src/utils/queue/persistence.js.map +1 -1
- package/codeyam-cli/src/utils/requireSimulations.js +10 -0
- package/codeyam-cli/src/utils/requireSimulations.js.map +1 -0
- package/codeyam-cli/src/utils/routePatternMatching.js +129 -0
- package/codeyam-cli/src/utils/routePatternMatching.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js +82 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js +229 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js +67 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js +105 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js +34 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js +162 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js +74 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js +376 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js +113 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js +127 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js +50 -0
- package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js +116 -0
- package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/index.js +5 -0
- package/codeyam-cli/src/utils/ruleReflection/index.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js +44 -0
- package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js +85 -0
- package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/types.js +5 -0
- package/codeyam-cli/src/utils/ruleReflection/types.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/parser.test.js +83 -0
- package/codeyam-cli/src/utils/rules/__tests__/parser.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/pathMatcher.test.js +118 -0
- package/codeyam-cli/src/utils/rules/__tests__/pathMatcher.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/rulePlacement.test.js +72 -0
- package/codeyam-cli/src/utils/rules/__tests__/rulePlacement.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js +293 -0
- package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/sourceFiles.test.js +76 -0
- package/codeyam-cli/src/utils/rules/__tests__/sourceFiles.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/index.js +7 -0
- package/codeyam-cli/src/utils/rules/index.js.map +1 -0
- package/codeyam-cli/src/utils/rules/parser.js +93 -0
- package/codeyam-cli/src/utils/rules/parser.js.map +1 -0
- package/codeyam-cli/src/utils/rules/pathMatcher.js +49 -0
- package/codeyam-cli/src/utils/rules/pathMatcher.js.map +1 -0
- package/codeyam-cli/src/utils/rules/rulePlacement.js +65 -0
- package/codeyam-cli/src/utils/rules/rulePlacement.js.map +1 -0
- package/codeyam-cli/src/utils/rules/ruleState.js +150 -0
- package/codeyam-cli/src/utils/rules/ruleState.js.map +1 -0
- package/codeyam-cli/src/utils/rules/sourceFiles.js +43 -0
- package/codeyam-cli/src/utils/rules/sourceFiles.js.map +1 -0
- package/codeyam-cli/src/utils/rules/staleness.js +137 -0
- package/codeyam-cli/src/utils/rules/staleness.js.map +1 -0
- package/codeyam-cli/src/utils/scenarioCoverage.js +77 -0
- package/codeyam-cli/src/utils/scenarioCoverage.js.map +1 -0
- package/codeyam-cli/src/utils/scenarioMarkers.js +134 -0
- package/codeyam-cli/src/utils/scenarioMarkers.js.map +1 -0
- package/codeyam-cli/src/utils/scenariosManifest.js +285 -0
- package/codeyam-cli/src/utils/scenariosManifest.js.map +1 -0
- package/codeyam-cli/src/utils/serverState.js +94 -12
- package/codeyam-cli/src/utils/serverState.js.map +1 -1
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +96 -45
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
- package/codeyam-cli/src/utils/simulationGateMiddleware.js +166 -0
- package/codeyam-cli/src/utils/simulationGateMiddleware.js.map +1 -0
- package/codeyam-cli/src/utils/slugUtils.js +25 -0
- package/codeyam-cli/src/utils/slugUtils.js.map +1 -0
- package/codeyam-cli/src/utils/syncMocksMiddleware.js +7 -26
- package/codeyam-cli/src/utils/syncMocksMiddleware.js.map +1 -1
- package/codeyam-cli/src/utils/telemetry.js +106 -0
- package/codeyam-cli/src/utils/telemetry.js.map +1 -0
- package/codeyam-cli/src/utils/telemetryMiddleware.js +22 -0
- package/codeyam-cli/src/utils/telemetryMiddleware.js.map +1 -0
- package/codeyam-cli/src/utils/testRunner.js +158 -0
- package/codeyam-cli/src/utils/testRunner.js.map +1 -0
- package/codeyam-cli/src/utils/transcriptPruning.js +67 -0
- package/codeyam-cli/src/utils/transcriptPruning.js.map +1 -0
- package/codeyam-cli/src/utils/versionInfo.js +67 -15
- package/codeyam-cli/src/utils/versionInfo.js.map +1 -1
- package/codeyam-cli/src/utils/webappDetection.js +35 -2
- package/codeyam-cli/src/utils/webappDetection.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__/buildPtyEnv.test.js +35 -0
- package/codeyam-cli/src/webserver/__tests__/buildPtyEnv.test.js.map +1 -0
- package/codeyam-cli/src/webserver/__tests__/clientErrors.test.js +80 -0
- package/codeyam-cli/src/webserver/__tests__/clientErrors.test.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/__tests__/editorProxy.test.js +628 -0
- package/codeyam-cli/src/webserver/__tests__/editorProxy.test.js.map +1 -0
- package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js +217 -0
- package/codeyam-cli/src/webserver/__tests__/idleDetector.test.js.map +1 -0
- package/codeyam-cli/src/webserver/app/lib/clientErrors.js +71 -0
- package/codeyam-cli/src/webserver/app/lib/clientErrors.js.map +1 -0
- package/codeyam-cli/src/webserver/app/lib/database.js +159 -33
- package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
- package/codeyam-cli/src/webserver/app/lib/dbNotifier.js.map +1 -1
- package/codeyam-cli/src/webserver/app/lib/git.js +397 -0
- package/codeyam-cli/src/webserver/app/lib/git.js.map +1 -0
- package/codeyam-cli/src/webserver/app/types/editor.js +8 -0
- package/codeyam-cli/src/webserver/app/types/editor.js.map +1 -0
- package/codeyam-cli/src/webserver/backgroundServer.js +191 -47
- package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/webserver/bootstrap.js +60 -0
- package/codeyam-cli/src/webserver/bootstrap.js.map +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/CopyButton-CLe80MMu.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-Crt_KN_U.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeBadge-CQgyEGV-.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-CD7lGABo.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-CgTNOhnu.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-CKeQT5Ty.js +25 -0
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-D3s1MFkb.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/LoadingDots-By5zI316.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/LogViewer-CM5zg40N.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-C2PLkej3.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-DanvyBPb.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-DUMfcNVK.js +10 -0
- package/codeyam-cli/src/webserver/build/client/assets/Spinner-D0LgAaSa.js +34 -0
- package/codeyam-cli/src/webserver/build/client/assets/TruncatedFilePath-CK7-NaPZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/ViewportInspectBar-BA_Ry-rs.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/_index-BAWd-Xjf.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-BOARiB-g.js +27 -0
- package/codeyam-cli/src/webserver/build/client/assets/addon-canvas-DpzMmAy5.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/addon-fit-YJmn1quW.js +12 -0
- package/codeyam-cli/src/webserver/build/client/assets/addon-web-links-CHx25PAe.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/addon-webgl-DI8QOUvO.js +58 -0
- package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-Bg3e7q4S.js +22 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.agent-transcripts-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.dev-mode-events-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-audit-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-capture-scenario-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-client-errors-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-commit-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-dev-server-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-entity-status-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-file-diff-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-file-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-entry-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-image._-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-screenshot-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-journal-update-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-load-commit-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-project-info-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-refresh-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-register-scenario-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-rename-scenario-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-save-seed-state-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-coverage-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-data-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-image._-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenario-prompt-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-scenarios-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-session-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-switch-scenario-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.editor-test-results-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.health-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.labs-unlock-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.memory-profile-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.restart-server-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.rule-path-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.save-fixture-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/book-open-CL-lMgHh.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/chevron-down-GmAjGS9-.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/chunk-JZWAC4HX-BAdwhyCx.js +43 -0
- package/codeyam-cli/src/webserver/build/client/assets/circle-check-DFcQkN5j.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/copy-C6iF61Xs.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-4ImjHTVC.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-C1gnJVOL.svg → cy-logo-cli-CCKUIm0S.svg} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DcX-ZS3p.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{dev.empty-CwLmCS0J.js → dev.empty-C8y4mmyv.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/editor._tab-Gbk_i5Js.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/editor.entity.(_sha)-Bnx7yUP0.js +58 -0
- package/codeyam-cli/src/webserver/build/client/assets/editorPreview-oepecPae.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-FHOVOgFN.js → entity._sha._-Blfy9UlN.js} +22 -15
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.dev-KTQuL0aj.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-C6eeL24i.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-DQM8E7L4.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-CAoXLsQr.js +5 -0
- package/codeyam-cli/src/webserver/build/client/assets/entry.client-SuW9syRS.js +29 -0
- package/codeyam-cli/src/webserver/build/client/assets/executionFlowCoverage-BWhdfn70.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-Daa96Fr1.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/files-D-xGrg29.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/git-Bq_fbXP5.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/globals-fAqOD9ex.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-fmIEn3Bc.js +9 -0
- package/codeyam-cli/src/webserver/build/client/assets/index-Bp1l4hSv.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/index-CWV9XZiG.js +9 -0
- package/codeyam-cli/src/webserver/build/client/assets/index-DE3jI_dv.js +15 -0
- package/codeyam-cli/src/webserver/build/client/assets/jsx-runtime-D_zvdyIk.js +9 -0
- package/codeyam-cli/src/webserver/build/client/assets/labs-B_IX45ih.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/loader-circle-De-7qQ2u.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/manifest-3157d6b8.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-Cx2xEx7s.js +101 -0
- package/codeyam-cli/src/webserver/build/client/assets/pause-CFxEKL1u.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/preload-helper-ckwbz45p.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/root-DB3O9_9j.js +67 -0
- package/codeyam-cli/src/webserver/build/client/assets/scenarioStatus-B_8jpV3e.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/search-BdBb5aqc.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/settings-DdE-Untf.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/simulations-DSCdE99u.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/terminal-CrplD4b1.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-DqJ0j69l.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-DhXHbEjP.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/useLastLogLine-BNd5hYuW.js +2 -0
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-Cy5Qg_UR.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/useToast-5HR2j9ZE.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/xterm-BqvuqXEL.js +27 -0
- package/codeyam-cli/src/webserver/build/client/sound-test.html +98 -0
- package/codeyam-cli/src/webserver/build/server/assets/analysisRunner-BMmkgAkg.js +13 -0
- package/codeyam-cli/src/webserver/build/server/assets/index-DxB0pOSt.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/init-DLYLaqqP.js +10 -0
- package/codeyam-cli/src/webserver/build/server/assets/progress-CHTtrxFG.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-CcyitQLQ.js +551 -0
- package/codeyam-cli/src/webserver/build/server/index.js +1 -1
- package/codeyam-cli/src/webserver/build-info.json +5 -5
- package/codeyam-cli/src/webserver/devServer.js +40 -8
- package/codeyam-cli/src/webserver/devServer.js.map +1 -1
- package/codeyam-cli/src/webserver/editorProxy.js +976 -0
- package/codeyam-cli/src/webserver/editorProxy.js.map +1 -0
- package/codeyam-cli/src/webserver/idleDetector.js +106 -0
- package/codeyam-cli/src/webserver/idleDetector.js.map +1 -0
- package/codeyam-cli/src/webserver/mockStateEvents.js +28 -0
- package/codeyam-cli/src/webserver/mockStateEvents.js.map +1 -0
- package/codeyam-cli/src/webserver/public/sound-test.html +98 -0
- package/codeyam-cli/src/webserver/scripts/codeyam-preload.mjs +414 -0
- package/codeyam-cli/src/webserver/scripts/journalCapture.ts +266 -0
- package/codeyam-cli/src/webserver/server.js +376 -26
- package/codeyam-cli/src/webserver/server.js.map +1 -1
- package/codeyam-cli/src/webserver/terminalServer.js +831 -0
- package/codeyam-cli/src/webserver/terminalServer.js.map +1 -0
- package/codeyam-cli/templates/chrome-extension-react/EXTENSION_SETUP.md +75 -0
- package/codeyam-cli/templates/chrome-extension-react/README.md +46 -0
- package/codeyam-cli/templates/chrome-extension-react/gitignore +15 -0
- package/codeyam-cli/templates/chrome-extension-react/index.html +12 -0
- package/codeyam-cli/templates/chrome-extension-react/package.json +27 -0
- package/codeyam-cli/templates/chrome-extension-react/popup.html +12 -0
- package/codeyam-cli/templates/chrome-extension-react/public/manifest.json +15 -0
- package/codeyam-cli/templates/chrome-extension-react/src/background/service-worker.ts +7 -0
- package/codeyam-cli/templates/chrome-extension-react/src/globals.css +6 -0
- package/codeyam-cli/templates/chrome-extension-react/src/lib/storage.ts +37 -0
- package/codeyam-cli/templates/chrome-extension-react/src/popup/App.tsx +12 -0
- package/codeyam-cli/templates/chrome-extension-react/src/popup/main.tsx +10 -0
- package/codeyam-cli/templates/chrome-extension-react/tsconfig.json +24 -0
- package/codeyam-cli/templates/chrome-extension-react/vite.config.ts +41 -0
- package/codeyam-cli/templates/codeyam-editor-claude.md +147 -0
- package/codeyam-cli/templates/codeyam-editor-reference.md +214 -0
- package/codeyam-cli/templates/codeyam-memory-hook.sh +199 -0
- package/codeyam-cli/templates/commands/codeyam-diagnose.md +481 -0
- package/codeyam-cli/templates/editor-step-hook.py +321 -0
- package/codeyam-cli/templates/expo-react-native/MOBILE_SETUP.md +89 -0
- package/codeyam-cli/templates/expo-react-native/README.md +41 -0
- package/codeyam-cli/templates/expo-react-native/app/(tabs)/_layout.tsx +33 -0
- package/codeyam-cli/templates/expo-react-native/app/(tabs)/index.tsx +12 -0
- package/codeyam-cli/templates/expo-react-native/app/(tabs)/settings.tsx +12 -0
- package/codeyam-cli/templates/expo-react-native/app/_layout.tsx +12 -0
- package/codeyam-cli/templates/expo-react-native/app.json +18 -0
- package/codeyam-cli/templates/expo-react-native/babel.config.js +9 -0
- package/codeyam-cli/templates/expo-react-native/gitignore +12 -0
- package/codeyam-cli/templates/expo-react-native/global.css +3 -0
- package/codeyam-cli/templates/expo-react-native/lib/storage.ts +32 -0
- package/codeyam-cli/templates/expo-react-native/metro.config.js +6 -0
- package/codeyam-cli/templates/expo-react-native/nativewind-env.d.ts +1 -0
- package/codeyam-cli/templates/expo-react-native/package.json +38 -0
- package/codeyam-cli/templates/expo-react-native/tailwind.config.js +10 -0
- package/codeyam-cli/templates/expo-react-native/tsconfig.json +10 -0
- package/codeyam-cli/templates/hooks/staleness-check.sh +43 -0
- package/codeyam-cli/templates/isolation-route/next-app.tsx.template +80 -0
- package/codeyam-cli/templates/isolation-route/next-pages.tsx.template +79 -0
- package/codeyam-cli/templates/isolation-route/vite-react.tsx.template +78 -0
- package/codeyam-cli/templates/msw/browser-setup.ts.template +47 -0
- package/codeyam-cli/templates/msw/handler-router.ts.template +47 -0
- package/codeyam-cli/templates/msw/server-setup.ts.template +52 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/AUTH_PATTERNS.md +308 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/AUTH_UPGRADE.md +304 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/DATABASE.md +126 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/FEATURE_PATTERNS.md +37 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/README.md +53 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/app/api/todos/route.ts +17 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/app/codeyam-isolate/layout.tsx +12 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/app/globals.css +26 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/app/layout.tsx +34 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/app/lib/prisma.ts +24 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/app/page.tsx +10 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/env +4 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/eslint.config.mjs +11 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/gitignore +64 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/next.config.ts +14 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/package.json +39 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/postcss.config.mjs +7 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/prisma/schema.prisma +27 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/prisma/seed.ts +40 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/prisma.config.ts +12 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/seed-adapter.ts +127 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/tsconfig.json +34 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/vitest.config.ts +13 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/README.md +52 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/SUPABASE_SETUP.md +104 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/app/api/todos/route.ts +17 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/app/globals.css +26 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/app/layout.tsx +34 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/app/lib/prisma.ts +20 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/app/lib/supabase.ts +12 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/app/page.tsx +10 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/env +9 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/eslint.config.mjs +11 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/gitignore +40 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/next.config.ts +11 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/package.json +37 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/postcss.config.mjs +7 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/prisma/schema.prisma +27 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/prisma/seed.ts +39 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/prisma.config.ts +12 -0
- package/codeyam-cli/templates/nextjs-prisma-supabase/tsconfig.json +34 -0
- package/codeyam-cli/templates/prompts/conversation-guidance.txt +44 -0
- package/codeyam-cli/templates/prompts/conversation-prompt.txt +28 -0
- package/codeyam-cli/templates/prompts/interruption-prompt.txt +31 -0
- package/codeyam-cli/templates/prompts/stale-rules-prompt.txt +24 -0
- package/codeyam-cli/templates/rule-notification-hook.py +83 -0
- package/codeyam-cli/templates/rule-reflection-hook.py +647 -0
- package/codeyam-cli/templates/rules-instructions.md +78 -0
- package/codeyam-cli/templates/seed-adapters/supabase.ts +282 -0
- package/codeyam-cli/templates/{codeyam-debug-skill.md → skills/codeyam-debug/SKILL.md} +48 -4
- package/codeyam-cli/templates/skills/codeyam-dev-mode/SKILL.md +237 -0
- package/codeyam-cli/templates/skills/codeyam-editor/SKILL.md +211 -0
- package/codeyam-cli/templates/skills/codeyam-memory/SKILL.md +611 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/deprecated-prompt.md +100 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/detect-deprecated-patterns.mjs +139 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/find-exports.mjs +52 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/holistic-analysis/misleading-api-prompt.md +117 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/lib/read-json-field.mjs +61 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/lib/ripgrep-fallback.mjs +155 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/analyze-prompt.md +46 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/cleanup.mjs +13 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/filter-session.mjs +95 -0
- package/codeyam-cli/templates/skills/codeyam-memory/scripts/session-mining/preprocess.mjs +160 -0
- package/codeyam-cli/templates/skills/codeyam-new-rule/SKILL.md +11 -0
- package/codeyam-cli/templates/{codeyam-setup-skill.md → skills/codeyam-setup/SKILL.md} +151 -4
- package/codeyam-cli/templates/{codeyam-sim-skill.md → skills/codeyam-sim/SKILL.md} +1 -1
- package/codeyam-cli/templates/{codeyam-test-skill.md → skills/codeyam-test/SKILL.md} +1 -1
- package/codeyam-cli/templates/{codeyam-verify-skill.md → skills/codeyam-verify/SKILL.md} +1 -1
- package/package.json +40 -29
- package/packages/ai/index.js +8 -6
- package/packages/ai/index.js.map +1 -1
- package/packages/ai/src/lib/analyzeScope.js +181 -13
- package/packages/ai/src/lib/analyzeScope.js.map +1 -1
- package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js +150 -0
- package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js.map +1 -0
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +176 -13
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
- package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js +435 -0
- package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js.map +1 -0
- package/packages/ai/src/lib/astScopes/methodSemantics.js +138 -23
- package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js +10 -14
- package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js +8 -0
- package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js +23 -0
- package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js +138 -1
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/processExpression.js +1235 -104
- package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
- package/packages/ai/src/lib/astScopes/sharedPatterns.js +25 -0
- package/packages/ai/src/lib/astScopes/sharedPatterns.js.map +1 -1
- package/packages/ai/src/lib/checkAllAttributes.js +24 -9
- package/packages/ai/src/lib/checkAllAttributes.js.map +1 -1
- package/packages/ai/src/lib/completionCall.js +188 -38
- package/packages/ai/src/lib/completionCall.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +2192 -224
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +19 -4
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +661 -0
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +180 -56
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js +13 -3
- package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js +6 -4
- package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +66 -2
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +139 -13
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js +63 -0
- package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/coercePrimitivesToArraysBySchema.js +54 -0
- package/packages/ai/src/lib/dataStructure/helpers/coercePrimitivesToArraysBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +142 -12
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js +86 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js +173 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js +37 -20
- package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +355 -77
- 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/dataStructure/helpers/stripNullableMarkers.js +34 -0
- package/packages/ai/src/lib/dataStructure/helpers/stripNullableMarkers.js.map +1 -0
- package/packages/ai/src/lib/dataStructureChunking.js +130 -0
- package/packages/ai/src/lib/dataStructureChunking.js.map +1 -0
- package/packages/ai/src/lib/deepEqual.js +32 -0
- package/packages/ai/src/lib/deepEqual.js.map +1 -0
- package/packages/ai/src/lib/e2eDataTracking.js +241 -0
- package/packages/ai/src/lib/e2eDataTracking.js.map +1 -0
- package/packages/ai/src/lib/extractCriticalDataKeys.js +96 -0
- package/packages/ai/src/lib/extractCriticalDataKeys.js.map +1 -0
- package/packages/ai/src/lib/generateChangesEntityScenarioData.js +62 -5
- package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateChangesEntityScenarios.js +81 -90
- package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateEntityDataStructure.js +50 -1
- package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarioData.js +1183 -85
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarios.js +193 -83
- package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +484 -0
- package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js +380 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +1807 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js +194 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js.map +1 -0
- package/packages/ai/src/lib/getConditionalUsagesFromCode.js +84 -14
- package/packages/ai/src/lib/getConditionalUsagesFromCode.js.map +1 -1
- package/packages/ai/src/lib/guessScenarioDataFromDescription.js +2 -1
- package/packages/ai/src/lib/guessScenarioDataFromDescription.js.map +1 -1
- package/packages/ai/src/lib/isolateScopes.js +270 -7
- package/packages/ai/src/lib/isolateScopes.js.map +1 -1
- package/packages/ai/src/lib/mergeJsonTypeDefinitions.js +5 -0
- package/packages/ai/src/lib/mergeJsonTypeDefinitions.js.map +1 -1
- package/packages/ai/src/lib/mergeStatements.js +88 -46
- package/packages/ai/src/lib/mergeStatements.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js +97 -0
- package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +16 -4
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +21 -64
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js +54 -0
- package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +83 -6
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js +10 -34
- package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js +45 -0
- package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js +16 -3
- package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js +335 -0
- package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js.map +1 -0
- package/packages/ai/src/lib/resolvePathToControllable.js +677 -0
- package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -0
- package/packages/ai/src/lib/splitOutsideParentheses.js +3 -1
- package/packages/ai/src/lib/splitOutsideParentheses.js.map +1 -1
- package/packages/ai/src/lib/worker/SerializableDataStructure.js +29 -0
- package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js +98 -1
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js.map +1 -1
- package/packages/analyze/index.js +1 -0
- package/packages/analyze/index.js.map +1 -1
- package/packages/analyze/src/lib/FileAnalyzer.js +75 -36
- package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/ProjectAnalyzer.js +109 -30
- 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/index.js +4 -2
- package/packages/analyze/src/lib/asts/index.js.map +1 -1
- package/packages/analyze/src/lib/asts/nodes/getNodeType.js +1 -0
- package/packages/analyze/src/lib/asts/nodes/getNodeType.js.map +1 -1
- package/packages/analyze/src/lib/asts/nodes/index.js +1 -0
- package/packages/analyze/src/lib/asts/nodes/index.js.map +1 -1
- package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js +52 -0
- package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js.map +1 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js +14 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js +14 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js +6 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js +6 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js +39 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js +2 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +428 -123
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +49 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +11 -0
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js +2 -1
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +31 -10
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeChange.js +21 -11
- package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeEntity.js +9 -8
- package/packages/analyze/src/lib/files/analyzeEntity.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeInitial.js +9 -10
- package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeRemixRoute.js +3 -2
- package/packages/analyze/src/lib/files/analyzeRemixRoute.js.map +1 -1
- package/packages/analyze/src/lib/files/enums/steps.js +1 -1
- package/packages/analyze/src/lib/files/enums/steps.js.map +1 -1
- package/packages/analyze/src/lib/files/getImportedExports.js +17 -8
- package/packages/analyze/src/lib/files/getImportedExports.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js +907 -0
- package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +255 -0
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js +85 -0
- package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +525 -61
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js +29 -34
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +469 -85
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +104 -0
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +56 -69
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +4 -8
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +891 -143
- 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/index.js +1 -0
- package/packages/database/index.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 +18 -3
- package/packages/database/src/lib/kysely/db.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/commitsTable.js +3 -0
- package/packages/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
- package/packages/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/editorScenariosTable.js +149 -0
- package/packages/database/src/lib/kysely/tables/editorScenariosTable.js.map +1 -0
- 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 +45 -14
- package/packages/database/src/lib/loadCommits.js.map +1 -1
- package/packages/database/src/lib/loadEntities.js +23 -10
- 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 +5 -3
- 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 +76 -89
- package/packages/database/src/lib/updateCommitMetadata.js.map +1 -1
- package/packages/database/src/lib/updateFreshAnalysisStatus.js +41 -30
- package/packages/database/src/lib/updateFreshAnalysisStatus.js.map +1 -1
- package/packages/database/src/lib/updateFreshAnalysisStatusWithScenarios.js +68 -57
- package/packages/database/src/lib/updateFreshAnalysisStatusWithScenarios.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 +217 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
- package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +41 -9
- package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
- package/packages/generate/src/lib/deepMerge.js +27 -1
- package/packages/generate/src/lib/deepMerge.js.map +1 -1
- package/packages/generate/src/lib/getComponentScenarioPath.js +7 -3
- package/packages/generate/src/lib/getComponentScenarioPath.js.map +1 -1
- package/packages/generate/src/lib/scenarioComponentForServer.js +89 -0
- package/packages/generate/src/lib/scenarioComponentForServer.js.map +1 -0
- package/packages/github/src/lib/loadOrCreateCommit.js +10 -0
- package/packages/github/src/lib/loadOrCreateCommit.js.map +1 -1
- package/packages/github/src/lib/syncPrimaryBranch.js +3 -0
- package/packages/github/src/lib/syncPrimaryBranch.js.map +1 -1
- package/packages/process/index.js +3 -0
- package/packages/process/index.js.map +1 -0
- package/packages/process/src/GlobalProcessManager.js.map +1 -0
- package/{background/src/lib/process → packages/process/src}/ProcessManager.js +1 -1
- package/packages/process/src/ProcessManager.js.map +1 -0
- package/packages/process/src/index.js.map +1 -0
- package/packages/process/src/managedExecAsync.js.map +1 -0
- package/packages/types/index.js.map +1 -1
- package/packages/types/src/enums/ProjectFramework.js +2 -0
- package/packages/types/src/enums/ProjectFramework.js.map +1 -1
- package/packages/utils/src/lib/applyUniversalMocks.js +26 -2
- package/packages/utils/src/lib/applyUniversalMocks.js.map +1 -1
- package/packages/utils/src/lib/fs/rsyncCopy.js +98 -3
- package/packages/utils/src/lib/fs/rsyncCopy.js.map +1 -1
- package/packages/utils/src/lib/lightweightEntityExtractor.js +25 -0
- package/packages/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
- package/packages/utils/src/lib/safeFileName.js +29 -3
- package/packages/utils/src/lib/safeFileName.js.map +1 -1
- package/scripts/npm-post-install.cjs +34 -0
- package/analyzer-template/packages/ai/src/lib/findMatchingAttribute.ts +0 -102
- package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +0 -197
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +0 -271
- package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +0 -294
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.ts +0 -67
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +0 -115
- package/analyzer-template/process/INTEGRATION_COMPLETE.md +0 -333
- package/analyzer-template/process/INTEGRATION_EXAMPLE.md +0 -525
- package/analyzer-template/process/README.md +0 -507
- package/background/src/lib/process/GlobalProcessManager.js.map +0 -1
- package/background/src/lib/process/ProcessManager.js.map +0 -1
- package/background/src/lib/process/index.js.map +0 -1
- package/background/src/lib/process/managedExecAsync.js.map +0 -1
- package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js +0 -238
- package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js.map +0 -1
- package/codeyam-cli/src/commands/detect-universal-mocks.js +0 -118
- package/codeyam-cli/src/commands/detect-universal-mocks.js.map +0 -1
- package/codeyam-cli/src/commands/list.js +0 -31
- package/codeyam-cli/src/commands/list.js.map +0 -1
- package/codeyam-cli/src/commands/webapp-info.js +0 -146
- package/codeyam-cli/src/commands/webapp-info.js.map +0 -1
- package/codeyam-cli/src/utils/universal-mocks.js +0 -152
- package/codeyam-cli/src/utils/universal-mocks.js.map +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-CWKV2GEz.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeBadge-DQeyk25_.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-D2hFeDeg.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-C8K-4kKP.js +0 -26
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-DgXLv61M.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/LogViewer-DFdLQbPS.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-DlRDjT4h.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-7UkVL-UI.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-XjtsGuPo.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/TruncatedFilePath-ayCJdUAc.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/_index-D2eJjWLf.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-w6sbwlOd.js +0 -7
- package/codeyam-cli/src/webserver/build/client/assets/chevron-down-BBNQ8hup.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/chunk-WWGJGFF6-Bex4RrGs.js +0 -26
- package/codeyam-cli/src/webserver/build/client/assets/circle-check-cdhjVtom.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-DkgmwwRC.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-YZ-kM3ZG.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-BeQlz94_.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/entry.client-DN2XXM7Z.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-CUeAIQNI.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-ccMQfhGf.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/git-JmESAHx5.js +0 -12
- package/codeyam-cli/src/webserver/build/client/assets/globals-CO-U8Bpo.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-XQCGvadH.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/index-DsL9BiOc.js +0 -8
- package/codeyam-cli/src/webserver/build/client/assets/loader-circle-COYCR2oZ.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-90adba57.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/root-DfbVEEjF.js +0 -16
- package/codeyam-cli/src/webserver/build/client/assets/search-DvK9iMBu.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/server-build-CMKNK2uU.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/settings-9LTbit4Z.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/simulations-BrxN5ZtV.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-Iv0p8T-1.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useLastLogLine-DOGXmJcI.js +0 -2
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-BWmSRPH6.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useToast-C07gRg7Z.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-CE_1qXCG.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-BY_VDhiD.js +0 -166
- package/codeyam-cli/templates/codeyam-stop-hook.sh +0 -284
- package/codeyam-cli/templates/debug-command.md +0 -141
- package/packages/ai/src/lib/findMatchingAttribute.js +0 -77
- package/packages/ai/src/lib/findMatchingAttribute.js.map +0 -1
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +0 -136
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +0 -220
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateEntityKeyAttributes.js +0 -241
- package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/isFrontend.js +0 -5
- package/packages/ai/src/lib/isFrontend.js.map +0 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js +0 -40
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js.map +0 -1
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +0 -72
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +0 -1
- package/scripts/finalize-analyzer.cjs +0 -79
- /package/analyzer-template/{process → packages/process/src}/GlobalProcessManager.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/ProcessManager.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/index.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/managedExecAsync.ts +0 -0
- /package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-CMKNK2uU.css → styles-CMKNK2uU.css} +0 -0
- /package/{background/src/lib/process → packages/process/src}/GlobalProcessManager.js +0 -0
- /package/{background/src/lib/process → packages/process/src}/index.js +0 -0
- /package/{background/src/lib/process → packages/process/src}/managedExecAsync.js +0 -0
|
@@ -25,13 +25,102 @@ interface ReturnValuePart {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* Converts a
|
|
29
|
-
*
|
|
28
|
+
* Converts a call signature to a valid JavaScript identifier (function name).
|
|
29
|
+
* The original signature is preserved for data access - this only creates the function name.
|
|
30
|
+
*
|
|
31
|
+
* Examples:
|
|
32
|
+
* - "useAuth()" → "useAuth"
|
|
33
|
+
* - "db.select(usersQuery)" → "db_select_usersQuery"
|
|
34
|
+
* - "db.select(postsQuery)" → "db_select_postsQuery"
|
|
35
|
+
* - "useFetcher<User>()" → "useFetcher_User"
|
|
36
|
+
* - "useFetcher<{ data: UserData | null }>()" → "useFetcher_data_UserData_null"
|
|
37
|
+
* - "eq('user_id', value)" → "eq_user_id_value"
|
|
38
|
+
* - "from('workouts')" → "from_workouts"
|
|
30
39
|
*/
|
|
31
|
-
function
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
function callSignatureToFunctionName(signature: string): string {
|
|
41
|
+
// Extract components from the signature
|
|
42
|
+
const components: string[] = [];
|
|
43
|
+
|
|
44
|
+
// 1. Extract function path (parts separated by dots outside parens/brackets)
|
|
45
|
+
const pathMatch = signature.match(/^([^<(]+)/);
|
|
46
|
+
if (pathMatch) {
|
|
47
|
+
const path = pathMatch[1];
|
|
48
|
+
// Split on dots but preserve the parts
|
|
49
|
+
components.push(...path.split('.').filter(Boolean));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 2. Extract generic type parameters (content between < and >)
|
|
53
|
+
const genericMatch = signature.match(/<([^>]+)>/);
|
|
54
|
+
if (genericMatch) {
|
|
55
|
+
const genericContent = genericMatch[1];
|
|
56
|
+
// Extract meaningful identifiers from generic type
|
|
57
|
+
// Handle complex types like "{ data: UserData | null }"
|
|
58
|
+
const typeIdentifiers = genericContent
|
|
59
|
+
.replace(/[{}:;,]/g, ' ') // Remove structural chars
|
|
60
|
+
.replace(/\|/g, ' ') // Handle union types
|
|
61
|
+
.split(/\s+/)
|
|
62
|
+
.filter(Boolean)
|
|
63
|
+
.filter((s) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(s)) // Only valid identifiers
|
|
64
|
+
.filter(
|
|
65
|
+
(s) =>
|
|
66
|
+
![
|
|
67
|
+
'null',
|
|
68
|
+
'undefined',
|
|
69
|
+
'void',
|
|
70
|
+
'never',
|
|
71
|
+
'any',
|
|
72
|
+
'unknown',
|
|
73
|
+
'data',
|
|
74
|
+
'typeof',
|
|
75
|
+
].includes(s),
|
|
76
|
+
); // Skip common non-meaningful keywords
|
|
77
|
+
|
|
78
|
+
if (typeIdentifiers.length > 0) {
|
|
79
|
+
components.push(...typeIdentifiers.slice(0, 2)); // Limit to first 2 for reasonable length
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 3. Extract function arguments (first 2 for disambiguation)
|
|
84
|
+
const argsMatch = signature.match(/\(([^)]*)\)/);
|
|
85
|
+
if (argsMatch && argsMatch[1]) {
|
|
86
|
+
const argsContent = argsMatch[1].trim();
|
|
87
|
+
if (argsContent) {
|
|
88
|
+
const args = argsContent.split(',').map((arg) => arg.trim());
|
|
89
|
+
for (const arg of args.slice(0, 2)) {
|
|
90
|
+
// For quoted strings, extract the content
|
|
91
|
+
const stringMatch = arg.match(/^['"`](.+)['"`]$/);
|
|
92
|
+
if (stringMatch) {
|
|
93
|
+
// Split on dots for string paths like 'users.id'
|
|
94
|
+
const parts = stringMatch[1].split('.').filter(Boolean);
|
|
95
|
+
components.push(...parts);
|
|
96
|
+
} else if (/^[A-Za-z_][A-Za-z0-9_]*$/.test(arg)) {
|
|
97
|
+
// Valid identifier - use as-is
|
|
98
|
+
components.push(arg);
|
|
99
|
+
} else if (/^\d+$/.test(arg)) {
|
|
100
|
+
// Number - use as-is
|
|
101
|
+
components.push(arg);
|
|
102
|
+
}
|
|
103
|
+
// Skip complex expressions
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Build the function name from components
|
|
109
|
+
const functionName = components
|
|
110
|
+
.join('_')
|
|
111
|
+
.replace(/[^a-zA-Z0-9_]/g, '_') // Sanitize special chars
|
|
112
|
+
.replace(/_+/g, '_') // Collapse multiple underscores
|
|
113
|
+
.replace(/^_|_$/g, ''); // Trim underscores
|
|
114
|
+
|
|
115
|
+
return functionName || 'mock';
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Check if a mock name is a call signature (e.g., "useFetcher<User>()", "db.select(query)")
|
|
120
|
+
*/
|
|
121
|
+
function isCallSignature(mockName: string): boolean {
|
|
122
|
+
// Call signatures contain parentheses (function calls)
|
|
123
|
+
return mockName.includes('(');
|
|
35
124
|
}
|
|
36
125
|
|
|
37
126
|
/**
|
|
@@ -196,29 +285,54 @@ function funcArgs(functionSignature: string): string[] {
|
|
|
196
285
|
|
|
197
286
|
// isValidKey ensures that the key does not contain any characters that would make it invalid in a JavaScript object.
|
|
198
287
|
// For example, it should not contain spaces, special characters, or start with a number.
|
|
288
|
+
// Also rejects keys that are pure function calls like "()" or "(args)" - these aren't property names.
|
|
199
289
|
function isValidKey(key: string) {
|
|
200
290
|
if (!key || key.length === 0) return false;
|
|
201
291
|
const keyWithOutArguments = key.split('(')[0];
|
|
292
|
+
// Reject empty keys (happens when key is "()" or "(args)") - these are function calls, not property names
|
|
293
|
+
if (!keyWithOutArguments || keyWithOutArguments.length === 0) return false;
|
|
202
294
|
return !/\s/.test(keyWithOutArguments);
|
|
203
295
|
}
|
|
204
296
|
|
|
297
|
+
/**
|
|
298
|
+
* Known hooks that return tuples [value, setter] instead of arrays.
|
|
299
|
+
* These should NOT use the .map() pattern even when the schema has generic array access ([]).
|
|
300
|
+
* Instead, they should return [data, () => {}] where data is from scenarios().
|
|
301
|
+
*/
|
|
302
|
+
const TUPLE_RETURNING_HOOKS = new Set([
|
|
303
|
+
'useAtom', // Jotai
|
|
304
|
+
'useState', // React
|
|
305
|
+
'useReducer', // React
|
|
306
|
+
'useRecoilState', // Recoil
|
|
307
|
+
'useImmerAtom', // Jotai with Immer
|
|
308
|
+
]);
|
|
309
|
+
|
|
205
310
|
export default function constructMockCode(
|
|
206
311
|
mockName: string,
|
|
207
312
|
dependencySchemas: DeepReadonly<DataStructure['dependencySchemas']>,
|
|
208
313
|
entityType?: EntityType,
|
|
314
|
+
_canonicalKey?: string, // DEPRECATED: No longer used, kept for API compatibility
|
|
315
|
+
options?: {
|
|
316
|
+
keepOriginalFunctionName?: boolean;
|
|
317
|
+
uniqueFunctionSuffix?: string;
|
|
318
|
+
skipOriginalSpread?: boolean; // Skip spreading from __cyOriginal when it won't be defined
|
|
319
|
+
},
|
|
209
320
|
) {
|
|
210
|
-
// Check
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
? variableQualifierMatch[1]
|
|
321
|
+
// Check if mockName is a call signature (e.g., "useFetcher<User>()", "db.select(query)")
|
|
322
|
+
const mockNameIsCallSignature = isCallSignature(mockName);
|
|
323
|
+
|
|
324
|
+
// For call signatures, use the original signature for data access but generate
|
|
325
|
+
// a valid JS function name from it
|
|
326
|
+
const derivedFunctionName = mockNameIsCallSignature
|
|
327
|
+
? callSignatureToFunctionName(mockName)
|
|
218
328
|
: null;
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
329
|
+
|
|
330
|
+
// The baseMockName is the function name without type params and args
|
|
331
|
+
// e.g., "useFetcher<User>()" -> "useFetcher", "db.select(query)" -> "db"
|
|
332
|
+
const baseMockName = mockName.split(/[<(]/)[0];
|
|
333
|
+
|
|
334
|
+
// The data key is the mockName (call signature) for data access
|
|
335
|
+
let dataKey: string;
|
|
222
336
|
|
|
223
337
|
const mockNameParts = splitOutsideParenthesesAndArrays(baseMockName);
|
|
224
338
|
|
|
@@ -227,34 +341,14 @@ export default function constructMockCode(
|
|
|
227
341
|
let dataStructureValue: string | undefined;
|
|
228
342
|
let foundEntityWithSignature = false;
|
|
229
343
|
let signatureSchema: DataStructure['signatureSchema'] | undefined;
|
|
344
|
+
let baseSchemaHasMethodCalls = false;
|
|
230
345
|
|
|
231
|
-
for (const filePath in dependencySchemas) {
|
|
346
|
+
entitySearch: for (const filePath in dependencySchemas) {
|
|
232
347
|
for (const entityName in dependencySchemas[filePath]) {
|
|
233
|
-
//
|
|
234
|
-
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
: mockNameParts[0];
|
|
238
|
-
|
|
239
|
-
// Check for direct match
|
|
240
|
-
let matches =
|
|
241
|
-
entityName === targetEntityName || entityName === mockNameParts[0];
|
|
242
|
-
|
|
243
|
-
// If no direct match and no qualifier was provided, check if the entity
|
|
244
|
-
// is stored under a variable-qualified key (e.g., "stateBadge <- getStateBadge")
|
|
245
|
-
// This handles the case where gatherDataForMocks stored the entity with a variable
|
|
246
|
-
// qualifier but writeScenarioComponents called constructMockCode without one.
|
|
247
|
-
if (!matches && !variableQualifier) {
|
|
248
|
-
const qualifiedKeyMatch = entityName.match(
|
|
249
|
-
new RegExp(`^([a-zA-Z_][a-zA-Z0-9_]*)\\s*<-\\s*${mockNameParts[0]}$`),
|
|
250
|
-
);
|
|
251
|
-
if (qualifiedKeyMatch) {
|
|
252
|
-
matches = true;
|
|
253
|
-
// Extract the variable qualifier from the entity name so we can use
|
|
254
|
-
// it for the data lookup key later
|
|
255
|
-
variableQualifier = qualifiedKeyMatch[1];
|
|
256
|
-
}
|
|
257
|
-
}
|
|
348
|
+
// Match entity by base name (without generics/args)
|
|
349
|
+
const entityBaseName = entityName.split(/[<(]/)[0];
|
|
350
|
+
const matches =
|
|
351
|
+
entityBaseName === baseMockName || entityName === mockNameParts[0];
|
|
258
352
|
|
|
259
353
|
if (!matches) continue;
|
|
260
354
|
|
|
@@ -285,19 +379,102 @@ export default function constructMockCode(
|
|
|
285
379
|
});
|
|
286
380
|
|
|
287
381
|
if (dataStructurePath) {
|
|
382
|
+
// Start with the base entity's return value schema
|
|
383
|
+
const baseReturnValueSchema =
|
|
384
|
+
dependencySchemas[filePath][entityName]?.returnValueSchema;
|
|
385
|
+
const mergedSchema = {
|
|
386
|
+
...baseReturnValueSchema,
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
// Check if the base schema has method-call entries (e.g., .map().functionCallReturnValue)
|
|
390
|
+
// When it does, the scenario data is stored as an object with method keys, and
|
|
391
|
+
// array prototype methods need mock implementations. When it doesn't, the data
|
|
392
|
+
// is a raw array and native methods like .includes() work directly.
|
|
393
|
+
if (baseReturnValueSchema) {
|
|
394
|
+
baseSchemaHasMethodCalls = Object.keys(baseReturnValueSchema).some(
|
|
395
|
+
(k) =>
|
|
396
|
+
k.startsWith(baseMockName + '.') &&
|
|
397
|
+
k.includes('(') &&
|
|
398
|
+
k.includes('.functionCallReturnValue'),
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// Merge in method-call dependencies that are separate entries.
|
|
403
|
+
// e.g., "activityTypes.find((a) => a.value === type)" is a separate dependency
|
|
404
|
+
// for a .find() call on activityTypes. We need to include these with a
|
|
405
|
+
// .functionCallReturnValue path so constructMockCode generates callable mock methods.
|
|
406
|
+
for (const otherEntityName in dependencySchemas[filePath]) {
|
|
407
|
+
if (otherEntityName === entityName) continue;
|
|
408
|
+
if (
|
|
409
|
+
otherEntityName.startsWith(baseMockName + '.') &&
|
|
410
|
+
otherEntityName.includes('(')
|
|
411
|
+
) {
|
|
412
|
+
// Add a functionCallReturnValue entry for this method call.
|
|
413
|
+
// This ensures constructMockCode treats it as a function that returns data,
|
|
414
|
+
// generating a proper mock method with data lookup.
|
|
415
|
+
const fcrvPath = `${otherEntityName}.functionCallReturnValue`;
|
|
416
|
+
if (!mergedSchema[fcrvPath]) {
|
|
417
|
+
// Infer the return type from the method-call dependency's schema
|
|
418
|
+
const otherSchema =
|
|
419
|
+
dependencySchemas[filePath][otherEntityName]?.returnValueSchema;
|
|
420
|
+
// Look for element type (baseMockName[]) or fall back to 'unknown'
|
|
421
|
+
const elementType = otherSchema?.[`${baseMockName}[]`];
|
|
422
|
+
mergedSchema[fcrvPath] = elementType || 'unknown';
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
288
427
|
relevantReturnValueSchema = fillInDirectSchemaGapsAndUnknowns({
|
|
289
|
-
schema:
|
|
428
|
+
schema: mergedSchema,
|
|
290
429
|
});
|
|
291
430
|
// NOTE: clearAttributesFromMapping is disabled because it deletes
|
|
292
431
|
// method calls on arrays (like .eq() after functionCallReturnValue: 'array')
|
|
293
432
|
// However, we still need to remove duplicate function calls that create invalid syntax
|
|
294
433
|
removeDuplicateFunctionCalls(relevantReturnValueSchema);
|
|
295
434
|
dataStructureValue = relevantReturnValueSchema?.[dataStructurePath];
|
|
296
|
-
break;
|
|
435
|
+
break entitySearch;
|
|
297
436
|
}
|
|
298
437
|
}
|
|
299
438
|
}
|
|
300
439
|
|
|
440
|
+
// Check if the entity is used as a function (called with ()) vs an object/namespace.
|
|
441
|
+
// Look for paths in the schema that start with "baseMockName(" or "baseMockName<" indicating function calls.
|
|
442
|
+
// The "<" handles generic type parameters like useLoaderData<T>().
|
|
443
|
+
// Also check dataStructurePath === 'returnValue' which indicates a function return value.
|
|
444
|
+
const entityIsFunction =
|
|
445
|
+
foundEntityWithSignature ||
|
|
446
|
+
dataStructurePath === 'returnValue' ||
|
|
447
|
+
Object.keys(relevantReturnValueSchema ?? {}).some(
|
|
448
|
+
(key) =>
|
|
449
|
+
key.startsWith(`${baseMockName}(`) ||
|
|
450
|
+
key.startsWith(`${baseMockName}<`),
|
|
451
|
+
);
|
|
452
|
+
|
|
453
|
+
// Calculate the data key - use the call signature (mockName) for data access
|
|
454
|
+
// For simple names without parentheses:
|
|
455
|
+
// - Append () ONLY if the entity is a function/hook (detected above)
|
|
456
|
+
// - Don't append () for object/namespace mocks like "supabase"
|
|
457
|
+
if (mockNameIsCallSignature || mockName.includes('(')) {
|
|
458
|
+
dataKey = mockName;
|
|
459
|
+
} else if (entityIsFunction) {
|
|
460
|
+
// Entity is a function/hook - append () to match call signature format
|
|
461
|
+
dataKey = `${mockName}()`;
|
|
462
|
+
} else {
|
|
463
|
+
// Entity is an object/namespace - use bare name as key
|
|
464
|
+
dataKey = mockName;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// Helper to wrap key in appropriate quotes for computed property access
|
|
468
|
+
// Use single quotes when key contains double quotes to avoid syntax errors
|
|
469
|
+
const quotePropertyKey = (key: string): string => {
|
|
470
|
+
const escaped = key.replace(/\n/g, '\\n');
|
|
471
|
+
if (escaped.includes('"')) {
|
|
472
|
+
// Use single quotes, escaping any single quotes in the key
|
|
473
|
+
return `['${escaped.replace(/'/g, "\\'")}']`;
|
|
474
|
+
}
|
|
475
|
+
return `["${escaped}"]`;
|
|
476
|
+
};
|
|
477
|
+
|
|
301
478
|
// Check if the return value schema only contains function type markers
|
|
302
479
|
// (e.g., "validateInputs()": "function") without actual return data
|
|
303
480
|
// (no functionCallReturnValue entries)
|
|
@@ -326,10 +503,15 @@ export default function constructMockCode(
|
|
|
326
503
|
key.startsWith('signature['),
|
|
327
504
|
).length;
|
|
328
505
|
const args = Array.from({ length: argCount }, (_, i) => `arg${i + 1}`);
|
|
506
|
+
// Always add ...rest to accept extra arguments beyond the signature
|
|
507
|
+
args.push('...rest');
|
|
329
508
|
const argsString = args.join(', ');
|
|
330
509
|
|
|
331
510
|
// Generate empty mock function
|
|
332
|
-
|
|
511
|
+
// Use baseMockName (not mockName) because mockName may contain a full call
|
|
512
|
+
// signature with argument expressions (e.g., "logSignOutAction(sessionUser.id, ...)")
|
|
513
|
+
// which would produce invalid syntax as function parameter names.
|
|
514
|
+
return `function ${baseMockName}(${argsString}) {
|
|
333
515
|
// Empty mock - original function mocked out
|
|
334
516
|
}`;
|
|
335
517
|
}
|
|
@@ -350,10 +532,40 @@ export default function constructMockCode(
|
|
|
350
532
|
key.startsWith('signature['),
|
|
351
533
|
).length;
|
|
352
534
|
const args = Array.from({ length: argCount }, (_, i) => `arg${i + 1}`);
|
|
535
|
+
// Always add ...rest to accept extra arguments beyond the signature
|
|
536
|
+
args.push('...rest');
|
|
353
537
|
const argsString = args.join(', ');
|
|
354
538
|
|
|
539
|
+
// Check for Higher-Order Component (HOC) pattern:
|
|
540
|
+
// - First argument is a function (component) or unknown (couldn't trace type)
|
|
541
|
+
// - Returns a function
|
|
542
|
+
// HOCs like memo, forwardRef, createContext should return their first argument
|
|
543
|
+
//
|
|
544
|
+
// The return value key can be either:
|
|
545
|
+
// - 'memo()' (clean format)
|
|
546
|
+
// - 'memo(({ value, width }: Props) => { ... })' (full component code format)
|
|
547
|
+
const firstArgIsFunctionOrUnknown =
|
|
548
|
+
signatureSchema['signature[0]'] === 'function' ||
|
|
549
|
+
signatureSchema['signature[0]'] === 'unknown';
|
|
550
|
+
const returnsFunction = relevantReturnValueSchema
|
|
551
|
+
? Object.entries(relevantReturnValueSchema).some(([key, value]) => {
|
|
552
|
+
// Check if key represents a function call that returns a function
|
|
553
|
+
// Key should start with the mock name, contain '(', end with ')', and have value 'function'
|
|
554
|
+
const isFunctionCall =
|
|
555
|
+
key.startsWith(mockName + '(') && key.endsWith(')');
|
|
556
|
+
return isFunctionCall && value === 'function';
|
|
557
|
+
})
|
|
558
|
+
: false;
|
|
559
|
+
|
|
560
|
+
if (firstArgIsFunctionOrUnknown && returnsFunction) {
|
|
561
|
+
// HOC pattern detected - return the first argument
|
|
562
|
+
return `function ${baseMockName}(${argsString}) {
|
|
563
|
+
return arg1;
|
|
564
|
+
}`;
|
|
565
|
+
}
|
|
566
|
+
|
|
355
567
|
// Generate empty mock function
|
|
356
|
-
return `function ${
|
|
568
|
+
return `function ${baseMockName}(${argsString}) {
|
|
357
569
|
// Empty mock - original function mocked out
|
|
358
570
|
}`;
|
|
359
571
|
}
|
|
@@ -380,6 +592,99 @@ export default function constructMockCode(
|
|
|
380
592
|
dataStructureValue === 'array' &&
|
|
381
593
|
(dataStructurePath === 'returnValue' || pathDepth <= mockNameParts.length);
|
|
382
594
|
|
|
595
|
+
// OPTIMIZATION: Early return for tuple-returning hooks (useAtom, useState, etc.)
|
|
596
|
+
// These hooks have simple [value, setter] return patterns that don't need the full
|
|
597
|
+
// 9216-key schema processing. Check if this is a tuple-returning hook and generate
|
|
598
|
+
// the mock code directly without iterating over all schema keys.
|
|
599
|
+
if (TUPLE_RETURNING_HOOKS.has(baseMockName) && isFunction) {
|
|
600
|
+
// Check if schema has generic array pattern (indicates tuple return like [value, setter])
|
|
601
|
+
const schemaKeys = Object.keys(relevantReturnValueSchema ?? {});
|
|
602
|
+
const hasGenericArrayInSchema = schemaKeys.some(
|
|
603
|
+
(k) =>
|
|
604
|
+
k.includes('.functionCallReturnValue[]') ||
|
|
605
|
+
k === `${dataKey}.functionCallReturnValue[]` ||
|
|
606
|
+
k === 'returnValue[]',
|
|
607
|
+
);
|
|
608
|
+
|
|
609
|
+
// Check for differentiated tuple indices (e.g., functionCallReturnValue[2], [3]) which would NOT be a standard tuple
|
|
610
|
+
// We only check indices immediately after functionCallReturnValue, not nested indices like signature[2]
|
|
611
|
+
const tupleHasDifferentiatedIndices = schemaKeys.some((k) => {
|
|
612
|
+
// Look for .functionCallReturnValue[N] where N >= 2
|
|
613
|
+
const match = k.match(/\.functionCallReturnValue\[(\d+)\]/);
|
|
614
|
+
if (!match) return false;
|
|
615
|
+
const idx = parseInt(match[1], 10);
|
|
616
|
+
return idx >= 2;
|
|
617
|
+
});
|
|
618
|
+
|
|
619
|
+
const isTupleReturningHook =
|
|
620
|
+
hasGenericArrayInSchema && !tupleHasDifferentiatedIndices;
|
|
621
|
+
|
|
622
|
+
if (isTupleReturningHook) {
|
|
623
|
+
// Find all call patterns for this hook (e.g., useAtom(quoteFilterAtom), useAtom(supplierAtom))
|
|
624
|
+
const hookCallPatterns = Object.keys(relevantReturnValueSchema ?? {})
|
|
625
|
+
.filter((k) => {
|
|
626
|
+
const regex = new RegExp(`^${baseMockName}\\([^)]+\\)$`);
|
|
627
|
+
return regex.test(k);
|
|
628
|
+
})
|
|
629
|
+
.map((k) => {
|
|
630
|
+
const match = k.match(/\(([^)]+)\)/);
|
|
631
|
+
return { key: k, arg: match?.[1] ?? '' };
|
|
632
|
+
});
|
|
633
|
+
|
|
634
|
+
let tupleReturnCode: string;
|
|
635
|
+
if (hookCallPatterns.length > 1) {
|
|
636
|
+
// Multiple patterns - generate conditional dispatch
|
|
637
|
+
const conditions = hookCallPatterns
|
|
638
|
+
.map(
|
|
639
|
+
({ key, arg }) =>
|
|
640
|
+
`if (argLabel === '${arg}' || argStr.includes('${arg}')) {\n return [scenarios().data()?.["${key}"]?.[0] ?? [], () => {}];\n }`,
|
|
641
|
+
)
|
|
642
|
+
.join('\n ');
|
|
643
|
+
const fallbackKey = hookCallPatterns[0]?.key ?? dataKey;
|
|
644
|
+
tupleReturnCode = `(() => {
|
|
645
|
+
// Dynamic dispatch for tuple-returning hook with multiple argument patterns
|
|
646
|
+
const argLabel = args[0]?.debugLabel ?? '';
|
|
647
|
+
const argStr = args[0]?.toString?.() ?? String(args[0] ?? '');
|
|
648
|
+
${conditions}
|
|
649
|
+
return [scenarios().data()?.["${fallbackKey}"]?.[0] ?? [], () => {}];
|
|
650
|
+
})()`;
|
|
651
|
+
} else {
|
|
652
|
+
// Single or no patterns - use dynamic dispatch
|
|
653
|
+
const fallbackKey = hookCallPatterns[0]?.key ?? `${baseMockName}()`;
|
|
654
|
+
tupleReturnCode = `(() => {
|
|
655
|
+
// Dynamic dispatch for tuple-returning hook
|
|
656
|
+
const argLabel = args[0]?.debugLabel ?? '';
|
|
657
|
+
const argStr = args[0]?.toString?.() ?? '';
|
|
658
|
+
const allData = scenarios().data() ?? {};
|
|
659
|
+
if (argLabel) {
|
|
660
|
+
const labelKey = '${baseMockName}(' + argLabel + ')';
|
|
661
|
+
if (allData[labelKey]) {
|
|
662
|
+
return [allData[labelKey]?.[0] ?? [], () => {}];
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
const keys = Object.keys(allData).filter(k => k.startsWith('${baseMockName}('));
|
|
666
|
+
for (const key of keys) {
|
|
667
|
+
const keyArg = key.slice(${baseMockName.length + 1}, -1);
|
|
668
|
+
if (argStr.includes(keyArg)) {
|
|
669
|
+
return [allData[key]?.[0] ?? [], () => {}];
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
return [allData[keys[0] ?? '${fallbackKey}']?.[0] ?? [], () => {}];
|
|
673
|
+
})()`;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
const safeFunctionName = options?.uniqueFunctionSuffix
|
|
677
|
+
? `${baseMockName}_${options.uniqueFunctionSuffix}`
|
|
678
|
+
: options?.keepOriginalFunctionName
|
|
679
|
+
? baseMockName
|
|
680
|
+
: mockNameIsCallSignature && derivedFunctionName
|
|
681
|
+
? derivedFunctionName
|
|
682
|
+
: baseMockName;
|
|
683
|
+
|
|
684
|
+
return `function ${safeFunctionName}(...args) {\n return ${tupleReturnCode};\n}`;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
|
|
383
688
|
const returnValueParts: ReturnValuePart = {
|
|
384
689
|
name: dataStructureName,
|
|
385
690
|
isArray: isRootArray,
|
|
@@ -412,22 +717,21 @@ export default function constructMockCode(
|
|
|
412
717
|
// so "useLoaderData<typeof loader>()" becomes "useLoaderData()"
|
|
413
718
|
name = cleanOutTypes(name);
|
|
414
719
|
|
|
415
|
-
// For
|
|
416
|
-
// This
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
//
|
|
420
|
-
|
|
421
|
-
|
|
720
|
+
// For root data access, use the dataKey (original call signature or canonical key)
|
|
721
|
+
// This preserves the original call signature for LLM clarity
|
|
722
|
+
if (isRootAccess) {
|
|
723
|
+
// For call signature format, use the original mockName as the data key
|
|
724
|
+
// e.g., scenarios().data()?.["useFetcher<User>()"]
|
|
725
|
+
// e.g., scenarios().data()?.["db.select(usersQuery)"]
|
|
726
|
+
return `?.${quotePropertyKey(dataKey)}`;
|
|
422
727
|
}
|
|
423
728
|
|
|
424
729
|
// Only use unquoted array access syntax for pure array indices like [0], [1]
|
|
425
|
-
|
|
426
|
-
if (name.match(/^\[\d+\]$/) && !name.includes(' <- ')) {
|
|
730
|
+
if (name.match(/^\[\d+\]$/)) {
|
|
427
731
|
return `?.${name}`;
|
|
428
732
|
}
|
|
429
733
|
|
|
430
|
-
return
|
|
734
|
+
return `?.${quotePropertyKey(name)}`;
|
|
431
735
|
};
|
|
432
736
|
|
|
433
737
|
const constructDataPaths = () => {
|
|
@@ -442,10 +746,6 @@ export default function constructMockCode(
|
|
|
442
746
|
}
|
|
443
747
|
|
|
444
748
|
const addReturnValueFunctionAccessor = (dataPath: string) => {
|
|
445
|
-
// Add function call accessor if:
|
|
446
|
-
// - There are actual arguments, OR
|
|
447
|
-
// - This is a callable (not a method that returns an array directly)
|
|
448
|
-
// For methods like getAll() that return arrays, the data is at ["getAll()"] not ["getAll()"]["()"]
|
|
449
749
|
if (
|
|
450
750
|
returnValue.returnsFunctionArgs &&
|
|
451
751
|
(returnValue.returnsFunctionArgs.length > 0 ||
|
|
@@ -454,7 +754,17 @@ export default function constructMockCode(
|
|
|
454
754
|
if (returnValue.isArray) {
|
|
455
755
|
dataPath = `${dataPath}${optionalAccess('[0]')}`;
|
|
456
756
|
}
|
|
457
|
-
|
|
757
|
+
// Only add the function call accessor ?.["(args)"] when there are actual
|
|
758
|
+
// arguments. When returnsFunctionArgs is empty [] (function-returns-function
|
|
759
|
+
// with no specific arg patterns), skip the ?.["()"] because:
|
|
760
|
+
// 1. preprocessSchemaForMocks collapses nested functionCallReturnValue chains
|
|
761
|
+
// into flat entries (e.g., getTranslate() = string, not {(): string})
|
|
762
|
+
// 2. The mock data is a flat value, so ?.["()"] on a string returns undefined
|
|
763
|
+
// 3. constructContent still wraps the return in a function (via returnsFunctionArgs)
|
|
764
|
+
// so the function-returns-function behavior is preserved without data nesting
|
|
765
|
+
if (returnValue.returnsFunctionArgs.length > 0) {
|
|
766
|
+
dataPath = `${dataPath}${optionalAccess(`(${safeString(returnValue.returnsFunctionArgs.join(', '))})`)}`;
|
|
767
|
+
}
|
|
458
768
|
}
|
|
459
769
|
return dataPath;
|
|
460
770
|
};
|
|
@@ -495,16 +805,6 @@ export default function constructMockCode(
|
|
|
495
805
|
hasNoReturnData,
|
|
496
806
|
} = returnValue;
|
|
497
807
|
|
|
498
|
-
const nestedContent: (string | undefined)[] = (nested ?? []).map(
|
|
499
|
-
(nestedItem) => {
|
|
500
|
-
const nestedContent = constructReturnValueString(
|
|
501
|
-
nestedItem,
|
|
502
|
-
dataPaths,
|
|
503
|
-
);
|
|
504
|
-
return nestedContent;
|
|
505
|
-
},
|
|
506
|
-
);
|
|
507
|
-
|
|
508
808
|
// Array prototype methods that should be ignored when building mocks
|
|
509
809
|
// (these work on any array - we don't need to mock them)
|
|
510
810
|
const ARRAY_PROTOTYPE_METHODS = new Set([
|
|
@@ -549,6 +849,48 @@ export default function constructMockCode(
|
|
|
549
849
|
'length',
|
|
550
850
|
]);
|
|
551
851
|
|
|
852
|
+
// When an array has differentiated indices ([0], [1], etc.), filter out any
|
|
853
|
+
// non-index items from nested. These non-index items come from generic [] paths
|
|
854
|
+
// like [].filter or [].sort, which describe element properties, not array elements.
|
|
855
|
+
// Including them would generate invalid syntax like "sort: ..." inside an array literal.
|
|
856
|
+
const hasDifferentiatedIndices =
|
|
857
|
+
isArray &&
|
|
858
|
+
nested &&
|
|
859
|
+
nested.some((n) => n.name.match(/^\[\d+\]$/) && n.name !== '[0]');
|
|
860
|
+
let filteredNested =
|
|
861
|
+
hasDifferentiatedIndices && nested
|
|
862
|
+
? nested.filter((n) => n.name.match(/^\[\d+\]$/))
|
|
863
|
+
: nested;
|
|
864
|
+
|
|
865
|
+
// When a variable IS an array (not a function returning an array),
|
|
866
|
+
// filter out array prototype methods like .includes(), .filter(), etc.
|
|
867
|
+
// ONLY when the base schema has no method-call entries. When the base
|
|
868
|
+
// schema has methods (e.g., .map().functionCallReturnValue), the scenario
|
|
869
|
+
// data is stored as an object with method-call keys, and ALL methods
|
|
870
|
+
// need mock implementations. When the base schema has no methods, the
|
|
871
|
+
// data is a raw array and native methods like .includes() work directly.
|
|
872
|
+
if (
|
|
873
|
+
isArray &&
|
|
874
|
+
!returnsFunctionArray &&
|
|
875
|
+
!baseSchemaHasMethodCalls &&
|
|
876
|
+
filteredNested
|
|
877
|
+
) {
|
|
878
|
+
filteredNested = filteredNested.filter((n) => {
|
|
879
|
+
const methodName = n.name.replace(/[<(].*$/, '');
|
|
880
|
+
return !ARRAY_PROTOTYPE_METHODS.has(methodName);
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
const nestedContent: (string | undefined)[] = (filteredNested ?? []).map(
|
|
885
|
+
(nestedItem) => {
|
|
886
|
+
const nestedContent = constructReturnValueString(
|
|
887
|
+
nestedItem,
|
|
888
|
+
dataPaths,
|
|
889
|
+
);
|
|
890
|
+
return nestedContent;
|
|
891
|
+
},
|
|
892
|
+
);
|
|
893
|
+
|
|
552
894
|
const levelContentItems = [];
|
|
553
895
|
// Add spread for data paths when:
|
|
554
896
|
// - Not a function returning an array, OR function returns array with custom methods
|
|
@@ -579,53 +921,114 @@ export default function constructMockCode(
|
|
|
579
921
|
) {
|
|
580
922
|
levelContentItems.push(...dataPaths.map((path) => `...${path}`));
|
|
581
923
|
}
|
|
582
|
-
|
|
924
|
+
// Filter out nested content that would be invalid as object properties
|
|
925
|
+
// (e.g., bare arrow functions like "() => {...}" without a property name)
|
|
926
|
+
// Only apply this filter when building object content, not array content.
|
|
927
|
+
// Bare arrow functions ARE valid as array elements (like [0] = {...}, [1] = () => {...})
|
|
928
|
+
// Check both isArray (item IS an array) and returnsFunctionArray (item returns an array)
|
|
929
|
+
const inArrayContext = isArray || returnsFunctionArray;
|
|
930
|
+
const validNestedContent = nestedContent.filter((content) => {
|
|
931
|
+
if (!content) return false;
|
|
932
|
+
// Only filter bare arrow functions when NOT in array context
|
|
933
|
+
// In arrays, bare arrow functions are valid elements
|
|
934
|
+
if (!inArrayContext && content.match(/^\s*\([^)]*\)\s*=>/)) {
|
|
935
|
+
return false;
|
|
936
|
+
}
|
|
937
|
+
return true;
|
|
938
|
+
});
|
|
939
|
+
levelContentItems.push(...validNestedContent);
|
|
583
940
|
|
|
584
941
|
let levelContents: string = levelContentItems.filter(Boolean).join(',\n');
|
|
585
942
|
if (returnsFunctionArgs) {
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
943
|
+
// When returnsFunctionArgs is empty [] OR has a single literal string argument,
|
|
944
|
+
// the function returns a callable function (e.g., getTranslate() returns t,
|
|
945
|
+
// where t('key') looks up translations)
|
|
946
|
+
// Generate a dispatch function that looks up keys based on the argument
|
|
947
|
+
//
|
|
948
|
+
// Detect translation-like pattern:
|
|
949
|
+
// - Data path ends with ["('some.literal')"] - a literal string key
|
|
950
|
+
// - This means the mock data has keys like "('common.surveys')": "Surveys"
|
|
951
|
+
// - Exclude ["()"] which is an empty function call (not a translation pattern)
|
|
952
|
+
const dataPath = dataPaths[0];
|
|
953
|
+
// Pattern matches ?.["('...')"] at end of path, but NOT ?.["()"] (empty args)
|
|
954
|
+
const literalKeyPattern = dataPath?.match(/\?\.\["\('.+'\)"\]$/);
|
|
955
|
+
|
|
956
|
+
if (
|
|
957
|
+
!returnsFunctionArray &&
|
|
958
|
+
dataPaths.length === 1 &&
|
|
959
|
+
literalKeyPattern // Only dispatch when there's a literal key pattern
|
|
960
|
+
) {
|
|
961
|
+
// Function returns a function - generate dispatch function
|
|
962
|
+
// Strip the literal key from the path and use dynamic lookup
|
|
963
|
+
const dataPathBase = literalKeyPattern
|
|
964
|
+
? dataPath.replace(/\?\.\["\('.+'\)"\]$/, '')
|
|
965
|
+
: dataPath;
|
|
966
|
+
const funcContents = `return ${dataPathBase}?.[\`('\${arg1}')\`]`;
|
|
967
|
+
levelContents = `(arg1) => {\n${indent(funcContents)}\n}`;
|
|
968
|
+
|
|
969
|
+
if (!isArray) {
|
|
970
|
+
return levelContents;
|
|
602
971
|
}
|
|
603
972
|
} else {
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
if (
|
|
611
|
-
hasNoReturnData ||
|
|
612
|
-
(hasNestedItems && !hasActualNestedContent)
|
|
613
|
-
) {
|
|
973
|
+
const argsString = returnsFunctionArgs
|
|
974
|
+
.map((_, index) => `arg${index + 1}`)
|
|
975
|
+
.join(', ');
|
|
976
|
+
let funcContents = '';
|
|
977
|
+
if (returnsFunctionArray) {
|
|
978
|
+
if (hasNoReturnData) {
|
|
614
979
|
// Function has no return data (only signatures) - return empty array
|
|
615
980
|
funcContents = 'return []';
|
|
616
|
-
} else {
|
|
617
|
-
//
|
|
981
|
+
} else if (levelContents.length === 0 && dataPaths.length === 1) {
|
|
982
|
+
// When returning an array with no nested content, return the data path directly
|
|
983
|
+
// (the data path points to the array in scenario data)
|
|
618
984
|
funcContents = `return ${dataPaths[0]}`;
|
|
985
|
+
} else if (levelContents.length === 0) {
|
|
986
|
+
funcContents = 'return []';
|
|
987
|
+
} else {
|
|
988
|
+
funcContents = `return [\n${indent(levelContents)}\n]`;
|
|
619
989
|
}
|
|
620
990
|
} else {
|
|
621
|
-
|
|
991
|
+
// Check if function has no actual return data (only signatures)
|
|
992
|
+
const hasNestedItems = nested && nested.length > 0;
|
|
993
|
+
const hasActualNestedContent =
|
|
994
|
+
nestedContent.filter(Boolean).length > 0;
|
|
995
|
+
|
|
996
|
+
if (levelContentItems.length === 1 && dataPaths.length === 1) {
|
|
997
|
+
if (
|
|
998
|
+
hasNoReturnData ||
|
|
999
|
+
(hasNestedItems && !hasActualNestedContent)
|
|
1000
|
+
) {
|
|
1001
|
+
// Function has no return data (only signatures) - return empty array
|
|
1002
|
+
funcContents = 'return []';
|
|
1003
|
+
} else {
|
|
1004
|
+
// Has return data - return data path
|
|
1005
|
+
funcContents = `return ${dataPaths[0]}`;
|
|
1006
|
+
}
|
|
1007
|
+
} else {
|
|
1008
|
+
funcContents = `return {\n${indent(levelContents)}\n}`;
|
|
1009
|
+
}
|
|
622
1010
|
}
|
|
623
|
-
}
|
|
624
1011
|
|
|
625
|
-
|
|
1012
|
+
levelContents = `(${argsString}) => {\n${indent(funcContents)}\n}`;
|
|
626
1013
|
|
|
627
|
-
|
|
628
|
-
|
|
1014
|
+
if (!isArray) {
|
|
1015
|
+
return levelContents;
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
// For generic arrays of functions WITH nested properties (e.g., functionCallReturnValue[] = "function"
|
|
1020
|
+
// with nested .filter, .sort, etc.), the levelContents would be a bare arrow function "() => {...}"
|
|
1021
|
+
// that wraps object content. Using this in a .map(({...})) creates invalid syntax like "({ () => {...} })".
|
|
1022
|
+
// When isGenericArray is true AND there are nested properties, we're accessing data from the elements,
|
|
1023
|
+
// not calling them - so skip the function wrapping.
|
|
1024
|
+
// But if there are NO nested properties, keep the wrapper because callers may want to call the elements.
|
|
1025
|
+
const hasNonStructuralNestedItems =
|
|
1026
|
+
nested &&
|
|
1027
|
+
nested.length > 0 &&
|
|
1028
|
+
nested.some((n) => !n.name.match(/^\[\d*\]$/));
|
|
1029
|
+
if (isGenericArray && hasNonStructuralNestedItems) {
|
|
1030
|
+
// Skip the arrow function wrapper - just use the nested content directly
|
|
1031
|
+
levelContents = levelContentItems.filter(Boolean).join(',\n');
|
|
629
1032
|
}
|
|
630
1033
|
}
|
|
631
1034
|
|
|
@@ -641,7 +1044,123 @@ export default function constructMockCode(
|
|
|
641
1044
|
});
|
|
642
1045
|
|
|
643
1046
|
let returnValueContents = '';
|
|
644
|
-
|
|
1047
|
+
|
|
1048
|
+
// Check if this is a known tuple-returning hook (useAtom, useState, etc.)
|
|
1049
|
+
// These should return [value, setter] tuples, not arrays or data paths
|
|
1050
|
+
// Check isGenericArray from current context OR from schema for root level calls
|
|
1051
|
+
// (at root level, isGenericArray might not be set yet but the schema contains [] pattern)
|
|
1052
|
+
const hasGenericArrayInSchema =
|
|
1053
|
+
root &&
|
|
1054
|
+
TUPLE_RETURNING_HOOKS.has(baseMockName) &&
|
|
1055
|
+
Object.keys(relevantReturnValueSchema ?? {}).some((k) =>
|
|
1056
|
+
k.includes('.functionCallReturnValue[]'),
|
|
1057
|
+
);
|
|
1058
|
+
// Check if there are array indices beyond what a standard 2-element tuple would have
|
|
1059
|
+
// For tuple-returning hooks, [0] and [1] are expected (value and setter)
|
|
1060
|
+
// Only consider it "differentiated" if there are indices >= 2 (e.g., [2], [3])
|
|
1061
|
+
const tupleHasDifferentiatedIndices = nested?.some((n) => {
|
|
1062
|
+
const indexMatch = n.name.match(/^\[(\d+)\]$/);
|
|
1063
|
+
if (!indexMatch) return false;
|
|
1064
|
+
const index = parseInt(indexMatch[1], 10);
|
|
1065
|
+
return index >= 2;
|
|
1066
|
+
});
|
|
1067
|
+
const isTupleReturningHook =
|
|
1068
|
+
TUPLE_RETURNING_HOOKS.has(baseMockName) &&
|
|
1069
|
+
(isGenericArray || hasGenericArrayInSchema) &&
|
|
1070
|
+
!tupleHasDifferentiatedIndices;
|
|
1071
|
+
|
|
1072
|
+
// Debug logging for tuple-returning hooks
|
|
1073
|
+
if (TUPLE_RETURNING_HOOKS.has(baseMockName) && root) {
|
|
1074
|
+
const schemaKeys = Object.keys(relevantReturnValueSchema ?? {});
|
|
1075
|
+
const hasArrayPattern = schemaKeys.some((k) =>
|
|
1076
|
+
k.includes('.functionCallReturnValue[]'),
|
|
1077
|
+
);
|
|
1078
|
+
console.log(
|
|
1079
|
+
`CodeYam: Tuple hook check for ${baseMockName} (root):`,
|
|
1080
|
+
`hasGenericArrayInSchema=${hasGenericArrayInSchema}`,
|
|
1081
|
+
`hasArrayPattern=${hasArrayPattern}`,
|
|
1082
|
+
`tupleHasDifferentiatedIndices=${tupleHasDifferentiatedIndices}`,
|
|
1083
|
+
`isTupleReturningHook=${isTupleReturningHook}`,
|
|
1084
|
+
`schemaKeysSample=${schemaKeys.slice(0, 5).join(', ')}`,
|
|
1085
|
+
);
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
if (isTupleReturningHook) {
|
|
1089
|
+
// Tuple-returning hooks should return [value, setter] tuple
|
|
1090
|
+
// The value is the first element from scenarios data, setter is a no-op
|
|
1091
|
+
// Default to [] when data is undefined to prevent errors like ".includes is not a function"
|
|
1092
|
+
|
|
1093
|
+
// Check if there are multiple call patterns for this hook in the schema
|
|
1094
|
+
// (e.g., useAtom(quoteFilterAtom) and useAtom(supplierAtom))
|
|
1095
|
+
const hookCallPatterns = Object.keys(relevantReturnValueSchema ?? {})
|
|
1096
|
+
.filter((k) => {
|
|
1097
|
+
// Match patterns like "useAtom(someArg)" but not nested paths like "useAtom(x).foo"
|
|
1098
|
+
const regex = new RegExp(`^${baseMockName}\\([^)]+\\)$`);
|
|
1099
|
+
return regex.test(k);
|
|
1100
|
+
})
|
|
1101
|
+
.map((k) => {
|
|
1102
|
+
// Extract the argument from the key like "useAtom(quoteFilterAtom)" -> "quoteFilterAtom"
|
|
1103
|
+
const match = k.match(/\(([^)]+)\)/);
|
|
1104
|
+
return { key: k, arg: match?.[1] ?? '' };
|
|
1105
|
+
});
|
|
1106
|
+
|
|
1107
|
+
if (hookCallPatterns.length > 1) {
|
|
1108
|
+
// Multiple patterns - generate conditional dispatch based on first argument
|
|
1109
|
+
// For Jotai atoms, we use debugLabel; for others, we try to match the argument string
|
|
1110
|
+
const conditions = hookCallPatterns
|
|
1111
|
+
.map(
|
|
1112
|
+
({ key, arg }) =>
|
|
1113
|
+
`if (argLabel === '${arg}' || argStr.includes('${arg}')) {\n return [scenarios().data()?.["${key}"]?.[0] ?? [], () => {}];\n }`,
|
|
1114
|
+
)
|
|
1115
|
+
.join('\n ');
|
|
1116
|
+
|
|
1117
|
+
// Use the first pattern as fallback
|
|
1118
|
+
const fallbackKey = hookCallPatterns[0]?.key ?? dataKey;
|
|
1119
|
+
|
|
1120
|
+
returnValueContents = `(() => {
|
|
1121
|
+
// Dynamic dispatch for tuple-returning hook with multiple argument patterns
|
|
1122
|
+
const argLabel = args[0]?.debugLabel ?? '';
|
|
1123
|
+
const argStr = args[0]?.toString?.() ?? String(args[0] ?? '');
|
|
1124
|
+
${conditions}
|
|
1125
|
+
// Fallback to first pattern
|
|
1126
|
+
return [scenarios().data()?.["${fallbackKey}"]?.[0] ?? [], () => {}];
|
|
1127
|
+
})()`;
|
|
1128
|
+
} else {
|
|
1129
|
+
// Single pattern or no patterns - use dynamic dispatch to handle case where
|
|
1130
|
+
// the mock is used with different atoms than what was captured in the schema.
|
|
1131
|
+
// Use the first argument to construct the data key dynamically.
|
|
1132
|
+
const fallbackKey = hookCallPatterns[0]?.key ?? `${baseMockName}()`;
|
|
1133
|
+
|
|
1134
|
+
returnValueContents = `(() => {
|
|
1135
|
+
// Dynamic dispatch for tuple-returning hook
|
|
1136
|
+
// Try to construct key from argument's debugLabel (Jotai atoms) or toString
|
|
1137
|
+
const argLabel = args[0]?.debugLabel ?? '';
|
|
1138
|
+
const argStr = args[0]?.toString?.() ?? '';
|
|
1139
|
+
const allData = scenarios().data() ?? {};
|
|
1140
|
+
|
|
1141
|
+
// Try to find a matching key using debugLabel first
|
|
1142
|
+
if (argLabel) {
|
|
1143
|
+
const labelKey = '${baseMockName}(' + argLabel + ')';
|
|
1144
|
+
if (allData[labelKey]) {
|
|
1145
|
+
return [allData[labelKey]?.[0] ?? [], () => {}];
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
// Try to find any matching key that contains part of the argument string
|
|
1150
|
+
const keys = Object.keys(allData).filter(k => k.startsWith('${baseMockName}('));
|
|
1151
|
+
for (const key of keys) {
|
|
1152
|
+
const keyArg = key.slice(${baseMockName.length + 1}, -1);
|
|
1153
|
+
if (argStr.includes(keyArg)) {
|
|
1154
|
+
return [allData[key]?.[0] ?? [], () => {}];
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
// Fallback to first matching key or default
|
|
1159
|
+
const fallback = keys[0] ?? '${fallbackKey}';
|
|
1160
|
+
return [allData[fallback]?.[0] ?? [], () => {}];
|
|
1161
|
+
})()`;
|
|
1162
|
+
}
|
|
1163
|
+
} else if (
|
|
645
1164
|
!returnsFunctionArgs &&
|
|
646
1165
|
nestedContent.length === 0 &&
|
|
647
1166
|
dataPaths.length === 1
|
|
@@ -662,31 +1181,438 @@ export default function constructMockCode(
|
|
|
662
1181
|
// When GENERIC array (using []) has nested content (like functions that need wrapping),
|
|
663
1182
|
// use .map() to transform ALL elements instead of just creating [0]
|
|
664
1183
|
// For DIFFERENTIATED arrays (using [0], [1], etc.), keep the static array structure
|
|
1184
|
+
//
|
|
1185
|
+
// IMPORTANT: If the nested content contains differentiated indices like [0], [1],
|
|
1186
|
+
// we MUST use static array pattern, not .map(). The presence of differentiated
|
|
1187
|
+
// indices means the array elements have different types/structures, so .map()
|
|
1188
|
+
// would generate invalid code trying to treat them uniformly.
|
|
1189
|
+
const hasDifferentiatedIndices =
|
|
1190
|
+
nested &&
|
|
1191
|
+
nested.some((n) => n.name.match(/^\[\d+\]$/) && n.name !== '[0]');
|
|
665
1192
|
if (
|
|
666
1193
|
isGenericArray &&
|
|
667
1194
|
nestedContent.length > 0 &&
|
|
668
|
-
dataPaths.length > 0
|
|
1195
|
+
dataPaths.length > 0 &&
|
|
1196
|
+
!hasDifferentiatedIndices
|
|
669
1197
|
) {
|
|
670
1198
|
// Get the array base path (without the [0])
|
|
671
1199
|
const arrayBasePath = dataPaths[0].replace(/\?\.\[0\]$/, '');
|
|
672
1200
|
// Replace [0] references with [__idx__] in level contents
|
|
673
|
-
|
|
1201
|
+
let mappedContents = levelContents.replace(
|
|
674
1202
|
/\?\.\[0\]/g,
|
|
675
1203
|
'?.[__idx__]',
|
|
676
1204
|
);
|
|
677
1205
|
// levelContents may already be wrapped in {...} from structural [0] element,
|
|
678
1206
|
// so check if we need to add the wrapper or not
|
|
679
1207
|
const needsWrapper = !mappedContents.trim().startsWith('{');
|
|
1208
|
+
|
|
1209
|
+
// Helper to check if a position is inside a string literal
|
|
1210
|
+
// Returns the end position of the string if inside one, -1 otherwise
|
|
1211
|
+
// Defined here so it's accessible in both needsWrapper branches
|
|
1212
|
+
const skipStringLiteral = (
|
|
1213
|
+
content: string,
|
|
1214
|
+
pos: number,
|
|
1215
|
+
): number => {
|
|
1216
|
+
const char = content[pos];
|
|
1217
|
+
if (char !== '"' && char !== "'" && char !== '`') return -1;
|
|
1218
|
+
// Find the matching closing quote
|
|
1219
|
+
let j = pos + 1;
|
|
1220
|
+
while (j < content.length) {
|
|
1221
|
+
if (content[j] === '\\') {
|
|
1222
|
+
j += 2; // Skip escaped character
|
|
1223
|
+
continue;
|
|
1224
|
+
}
|
|
1225
|
+
if (content[j] === char) {
|
|
1226
|
+
return j + 1; // Return position after closing quote
|
|
1227
|
+
}
|
|
1228
|
+
j++;
|
|
1229
|
+
}
|
|
1230
|
+
return content.length; // Unclosed string, skip to end
|
|
1231
|
+
};
|
|
1232
|
+
|
|
1233
|
+
// Filter out bare arrow functions which are invalid as object properties.
|
|
1234
|
+
// Arrow functions can be multi-line, so we need to match the entire function body, not just the first line.
|
|
1235
|
+
// Pattern: starts with "(args) =>", followed by either:
|
|
1236
|
+
// - A single-line body: "() => expression"
|
|
1237
|
+
// - A multi-line body: "() => { ... }" (with matching braces)
|
|
1238
|
+
// IMPORTANT: Only filter BARE arrow functions (without property names).
|
|
1239
|
+
// "() => {...}" is invalid, but "get: (arg1) => {...}" is valid.
|
|
1240
|
+
// We use a function to properly handle nested braces.
|
|
1241
|
+
// Defined here so it's accessible in both needsWrapper branches
|
|
1242
|
+
const filterOutArrowFunctions = (content: string): string => {
|
|
1243
|
+
const result: string[] = [];
|
|
1244
|
+
let i = 0;
|
|
1245
|
+
while (i < content.length) {
|
|
1246
|
+
// Skip over string literals entirely
|
|
1247
|
+
const stringEnd = skipStringLiteral(content, i);
|
|
1248
|
+
if (stringEnd !== -1) {
|
|
1249
|
+
result.push(content.slice(i, stringEnd));
|
|
1250
|
+
i = stringEnd;
|
|
1251
|
+
continue;
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
// Check if we're at the start of an arrow function (with optional leading whitespace)
|
|
1255
|
+
const arrowMatch = content
|
|
1256
|
+
.slice(i)
|
|
1257
|
+
.match(/^(\s*)\([^)]*\)\s*=>\s*/);
|
|
1258
|
+
if (arrowMatch) {
|
|
1259
|
+
// Check if this is a bare arrow function or a named property with arrow function value
|
|
1260
|
+
// Look back to see if there's a "key:" pattern before this position
|
|
1261
|
+
const before = content.slice(0, i);
|
|
1262
|
+
const beforeTrimmed = before.trim();
|
|
1263
|
+
// Valid patterns where arrow function is NOT bare:
|
|
1264
|
+
// 1. Property value: "key: (arg) => ..." - ends with ':'
|
|
1265
|
+
// 2. Function argument: ".map((arg) => ..." - ends with '('
|
|
1266
|
+
// 3. Method call: "?.map" followed directly by the arrow function
|
|
1267
|
+
// In this case, the '(' is consumed by the arrow function regex match,
|
|
1268
|
+
// so beforeTrimmed ends with the method name (e.g., 'map'), not '('.
|
|
1269
|
+
// We detect this by checking if beforeTrimmed ends with an identifier
|
|
1270
|
+
// that could be a method name (preceded by '.' or '?.').
|
|
1271
|
+
// NOTE: We don't include ',' because "{ prop, () => {} }" is invalid
|
|
1272
|
+
// (can't distinguish function argument from object property context)
|
|
1273
|
+
const isPropertyValue = beforeTrimmed.endsWith(':');
|
|
1274
|
+
const isFunctionArg = beforeTrimmed.endsWith('(');
|
|
1275
|
+
// Check if before ends with a method call pattern like ".map" or "?.map"
|
|
1276
|
+
// The '(' after the method name is consumed by the arrow function regex
|
|
1277
|
+
const isMethodCallArg = /\??\.\w+$/.test(beforeTrimmed);
|
|
1278
|
+
const hasPropertyName =
|
|
1279
|
+
isPropertyValue || isFunctionArg || isMethodCallArg;
|
|
1280
|
+
|
|
1281
|
+
if (!hasPropertyName) {
|
|
1282
|
+
// This is a bare arrow function - filter it out
|
|
1283
|
+
// Found arrow function start, need to find its end
|
|
1284
|
+
const afterArrow = i + arrowMatch[0].length;
|
|
1285
|
+
if (content[afterArrow] === '{') {
|
|
1286
|
+
// Multi-line arrow function - find matching closing brace
|
|
1287
|
+
// Must respect string literals when counting braces
|
|
1288
|
+
let braceCount = 1;
|
|
1289
|
+
let j = afterArrow + 1;
|
|
1290
|
+
while (j < content.length && braceCount > 0) {
|
|
1291
|
+
const strEnd = skipStringLiteral(content, j);
|
|
1292
|
+
if (strEnd !== -1) {
|
|
1293
|
+
j = strEnd;
|
|
1294
|
+
continue;
|
|
1295
|
+
}
|
|
1296
|
+
if (content[j] === '{') braceCount++;
|
|
1297
|
+
if (content[j] === '}') braceCount--;
|
|
1298
|
+
j++;
|
|
1299
|
+
}
|
|
1300
|
+
// Skip past the arrow function
|
|
1301
|
+
i = j;
|
|
1302
|
+
// Only skip trailing comma, keep newlines
|
|
1303
|
+
while (i < content.length && content[i] === ' ') {
|
|
1304
|
+
i++;
|
|
1305
|
+
}
|
|
1306
|
+
if (content[i] === ',') {
|
|
1307
|
+
i++; // Skip the comma after the arrow function
|
|
1308
|
+
}
|
|
1309
|
+
} else {
|
|
1310
|
+
// Single expression arrow function - skip to next comma or newline
|
|
1311
|
+
let j = afterArrow;
|
|
1312
|
+
while (
|
|
1313
|
+
j < content.length &&
|
|
1314
|
+
content[j] !== ',' &&
|
|
1315
|
+
content[j] !== '\n'
|
|
1316
|
+
) {
|
|
1317
|
+
j++;
|
|
1318
|
+
}
|
|
1319
|
+
i = j;
|
|
1320
|
+
if (content[i] === ',') i++; // Skip the comma
|
|
1321
|
+
}
|
|
1322
|
+
continue;
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
// Not a bare arrow function, keep this character
|
|
1326
|
+
result.push(content[i]);
|
|
1327
|
+
i++;
|
|
1328
|
+
}
|
|
1329
|
+
return result.join('');
|
|
1330
|
+
};
|
|
1331
|
+
|
|
1332
|
+
// Filter out bare object blocks (e.g., "{ ...spread, props }," without a property name)
|
|
1333
|
+
// These are invalid in object literal context - you need "key: { ... }" not just "{ ... }"
|
|
1334
|
+
// Defined here so it's accessible in both needsWrapper branches
|
|
1335
|
+
// The skipFirstBrace parameter allows the else branch to preserve the outer object
|
|
1336
|
+
const filterOutBareObjects = (
|
|
1337
|
+
content: string,
|
|
1338
|
+
skipFirstBrace = false,
|
|
1339
|
+
): string => {
|
|
1340
|
+
const result: string[] = [];
|
|
1341
|
+
let i = 0;
|
|
1342
|
+
let firstBraceSkipped = false;
|
|
1343
|
+
while (i < content.length) {
|
|
1344
|
+
// Skip over string literals entirely - braces inside strings should not be processed
|
|
1345
|
+
const stringEnd = skipStringLiteral(content, i);
|
|
1346
|
+
if (stringEnd !== -1) {
|
|
1347
|
+
result.push(content.slice(i, stringEnd));
|
|
1348
|
+
i = stringEnd;
|
|
1349
|
+
continue;
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
// Check if we're at a bare object start (newline/comma followed by { without : before it)
|
|
1353
|
+
// Look back to see if there's a colon (property assignment) before this brace
|
|
1354
|
+
const isStartOfLine =
|
|
1355
|
+
i === 0 ||
|
|
1356
|
+
content[i - 1] === '\n' ||
|
|
1357
|
+
content.slice(0, i).trim().endsWith(',');
|
|
1358
|
+
if (content[i] === '{' && isStartOfLine) {
|
|
1359
|
+
// Check if this is actually a bare object (not "key: {")
|
|
1360
|
+
const beforeTrimmed = content.slice(0, i).trim();
|
|
1361
|
+
const isBareObject =
|
|
1362
|
+
beforeTrimmed.endsWith(',') ||
|
|
1363
|
+
beforeTrimmed === '' ||
|
|
1364
|
+
beforeTrimmed.endsWith('(');
|
|
1365
|
+
|
|
1366
|
+
if (isBareObject) {
|
|
1367
|
+
// If skipFirstBrace is true and this is the first bare brace at position 0,
|
|
1368
|
+
// don't filter it - it's the intentional outer object wrapper
|
|
1369
|
+
if (skipFirstBrace && !firstBraceSkipped && i === 0) {
|
|
1370
|
+
firstBraceSkipped = true;
|
|
1371
|
+
result.push(content[i]);
|
|
1372
|
+
i++;
|
|
1373
|
+
continue;
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
// Find matching closing brace, respecting string literals
|
|
1377
|
+
let braceCount = 1;
|
|
1378
|
+
let j = i + 1;
|
|
1379
|
+
while (j < content.length && braceCount > 0) {
|
|
1380
|
+
const strEnd = skipStringLiteral(content, j);
|
|
1381
|
+
if (strEnd !== -1) {
|
|
1382
|
+
j = strEnd;
|
|
1383
|
+
continue;
|
|
1384
|
+
}
|
|
1385
|
+
if (content[j] === '{') braceCount++;
|
|
1386
|
+
if (content[j] === '}') braceCount--;
|
|
1387
|
+
j++;
|
|
1388
|
+
}
|
|
1389
|
+
// Skip past the object
|
|
1390
|
+
i = j;
|
|
1391
|
+
// Skip trailing comma
|
|
1392
|
+
while (i < content.length && content[i] === ' ') {
|
|
1393
|
+
i++;
|
|
1394
|
+
}
|
|
1395
|
+
if (content[i] === ',') {
|
|
1396
|
+
i++;
|
|
1397
|
+
}
|
|
1398
|
+
continue;
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
result.push(content[i]);
|
|
1402
|
+
i++;
|
|
1403
|
+
}
|
|
1404
|
+
return result.join('');
|
|
1405
|
+
};
|
|
1406
|
+
|
|
1407
|
+
// Helper to clean up formatting issues after filtering
|
|
1408
|
+
const cleanupContent = (content: string): string => {
|
|
1409
|
+
return (
|
|
1410
|
+
content
|
|
1411
|
+
.replace(/,\s*,/g, ',') // Double commas
|
|
1412
|
+
.replace(/,(\s*\n\s*\})/g, '$1') // Trailing comma before closing brace
|
|
1413
|
+
.replace(/\{\s*\n\s*,/g, '{\n') // Leading comma after opening brace
|
|
1414
|
+
// Remove incomplete .map calls where callback was filtered out
|
|
1415
|
+
// Pattern: ".map" followed by newline/whitespace without "(" for args
|
|
1416
|
+
.replace(/\?\.map(?=\s*[\n\r,}\]])/g, '')
|
|
1417
|
+
.replace(/\.map(?=\s*[\n\r,}\]])/g, '')
|
|
1418
|
+
// Clean up orphan })) sequences (from nested filtered map callbacks)
|
|
1419
|
+
.replace(/\s*\}\)\)\s*\n\s*\}/g, '\n}')
|
|
1420
|
+
.replace(/^\s*\n/gm, '') // Empty lines
|
|
1421
|
+
.trim()
|
|
1422
|
+
);
|
|
1423
|
+
};
|
|
1424
|
+
|
|
680
1425
|
if (needsWrapper) {
|
|
681
|
-
|
|
1426
|
+
// Apply filters to remove invalid content
|
|
1427
|
+
mappedContents = filterOutArrowFunctions(mappedContents);
|
|
1428
|
+
mappedContents = filterOutBareObjects(mappedContents);
|
|
1429
|
+
mappedContents = cleanupContent(mappedContents);
|
|
1430
|
+
|
|
1431
|
+
// If mappedContents is empty after filtering, don't generate .map() at all
|
|
1432
|
+
// Just use the array path directly with spread or as-is
|
|
1433
|
+
// This prevents orphan )) from empty .map() callbacks
|
|
1434
|
+
const cleanedForEmptyCheck = mappedContents
|
|
1435
|
+
.replace(/\s+/g, '')
|
|
1436
|
+
.replace(/,+/g, '');
|
|
1437
|
+
if (cleanedForEmptyCheck.length === 0) {
|
|
1438
|
+
// Content is empty - just return the array directly
|
|
1439
|
+
returnValueContents = arrayBasePath;
|
|
1440
|
+
} else {
|
|
1441
|
+
// Check if mappedContents is just a bare expression (no property names)
|
|
1442
|
+
// A bare expression like "scenarios().data()?.["key"]?.[__idx__]," cannot be
|
|
1443
|
+
// wrapped in ({ }) because it's not a valid object property.
|
|
1444
|
+
// Pattern: content has no ":" that's not inside brackets/parens/strings
|
|
1445
|
+
const hasBareExpression = (() => {
|
|
1446
|
+
const trimmed = mappedContents.trim().replace(/,\s*$/, ''); // Remove trailing comma
|
|
1447
|
+
let depth = 0;
|
|
1448
|
+
let inString = false;
|
|
1449
|
+
let stringChar = '';
|
|
1450
|
+
for (let i = 0; i < trimmed.length; i++) {
|
|
1451
|
+
const char = trimmed[i];
|
|
1452
|
+
if (inString) {
|
|
1453
|
+
if (char === '\\') {
|
|
1454
|
+
i++; // Skip escaped char
|
|
1455
|
+
continue;
|
|
1456
|
+
}
|
|
1457
|
+
if (char === stringChar) {
|
|
1458
|
+
inString = false;
|
|
1459
|
+
}
|
|
1460
|
+
continue;
|
|
1461
|
+
}
|
|
1462
|
+
if (char === '"' || char === "'" || char === '`') {
|
|
1463
|
+
inString = true;
|
|
1464
|
+
stringChar = char;
|
|
1465
|
+
continue;
|
|
1466
|
+
}
|
|
1467
|
+
if (char === '(' || char === '[' || char === '{') {
|
|
1468
|
+
depth++;
|
|
1469
|
+
continue;
|
|
1470
|
+
}
|
|
1471
|
+
if (char === ')' || char === ']' || char === '}') {
|
|
1472
|
+
depth--;
|
|
1473
|
+
continue;
|
|
1474
|
+
}
|
|
1475
|
+
// Found a colon at depth 0 = has property name
|
|
1476
|
+
if (char === ':' && depth === 0) {
|
|
1477
|
+
return false;
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
return true;
|
|
1481
|
+
})();
|
|
1482
|
+
|
|
1483
|
+
if (hasBareExpression) {
|
|
1484
|
+
// Content is just an expression - return it directly without object wrapper
|
|
1485
|
+
const trimmedContent = mappedContents
|
|
1486
|
+
.trim()
|
|
1487
|
+
.replace(/,\s*$/, '');
|
|
1488
|
+
returnValueContents = `${arrayBasePath}?.map((__item__, __idx__) => (\n${indent(trimmedContent)}\n))`;
|
|
1489
|
+
} else {
|
|
1490
|
+
// When generating object-wrapped .map(), ensure original item data is preserved.
|
|
1491
|
+
// If no data spread was included (e.g., because this is a plain array property,
|
|
1492
|
+
// not a function return), add ...__item__ to spread the original item properties.
|
|
1493
|
+
// Without this, the .map() would create new objects with only nested function
|
|
1494
|
+
// properties, losing data like filePath, frontmatter, body, etc.
|
|
1495
|
+
const hasDataSpread =
|
|
1496
|
+
mappedContents.includes('...scenarios()') ||
|
|
1497
|
+
mappedContents.includes('...__item__');
|
|
1498
|
+
if (!hasDataSpread) {
|
|
1499
|
+
mappedContents = `...__item__,\n${mappedContents}`;
|
|
1500
|
+
}
|
|
1501
|
+
returnValueContents = `${arrayBasePath}?.map((__item__, __idx__) => ({\n${indent(mappedContents)}\n}))`;
|
|
1502
|
+
}
|
|
1503
|
+
} // Close the empty content check else block
|
|
682
1504
|
} else {
|
|
1505
|
+
// Content already starts with '{'. Check if there are additional properties after the inner object.
|
|
1506
|
+
// If so, we need to merge them INTO the object, not leave them outside.
|
|
1507
|
+
// Pattern: "{ ...spread, props },\nfilter: ...,\nsort: ..."
|
|
1508
|
+
// Should become: "{ ...spread, props, filter: ..., sort: ... }"
|
|
1509
|
+
const trimmed = mappedContents.trim();
|
|
1510
|
+
|
|
1511
|
+
// Find first }, at depth 0 that is NOT inside a string literal
|
|
1512
|
+
// This prevents splitting keys like ?.["useQuery({ id }, { enabled })"]
|
|
1513
|
+
// and also prevents finding }, inside nested arrow functions
|
|
1514
|
+
const findBraceCommaOutsideStrings = (
|
|
1515
|
+
content: string,
|
|
1516
|
+
): number => {
|
|
1517
|
+
let i = 0;
|
|
1518
|
+
let depth = 0; // Track brace depth to find the outer object's },
|
|
1519
|
+
while (i < content.length - 1) {
|
|
1520
|
+
// Skip over string literals
|
|
1521
|
+
const strEnd = skipStringLiteral(content, i);
|
|
1522
|
+
if (strEnd !== -1) {
|
|
1523
|
+
i = strEnd;
|
|
1524
|
+
continue;
|
|
1525
|
+
}
|
|
1526
|
+
// Track brace depth
|
|
1527
|
+
if (content[i] === '{') {
|
|
1528
|
+
depth++;
|
|
1529
|
+
i++;
|
|
1530
|
+
continue;
|
|
1531
|
+
}
|
|
1532
|
+
// Check for }, pattern at depth 1 (the outer object level)
|
|
1533
|
+
// We're looking for the outer object's closing brace, which is at depth 1
|
|
1534
|
+
// (we started at depth 0, opened { at depth 0 -> 1)
|
|
1535
|
+
if (content[i] === '}') {
|
|
1536
|
+
depth--;
|
|
1537
|
+
if (
|
|
1538
|
+
depth === 0 &&
|
|
1539
|
+
i + 1 < content.length &&
|
|
1540
|
+
content[i + 1] === ','
|
|
1541
|
+
) {
|
|
1542
|
+
return i;
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
i++;
|
|
1546
|
+
}
|
|
1547
|
+
return -1;
|
|
1548
|
+
};
|
|
1549
|
+
|
|
1550
|
+
const firstBraceEnd = findBraceCommaOutsideStrings(trimmed);
|
|
1551
|
+
if (firstBraceEnd !== -1) {
|
|
1552
|
+
// Found pattern "{ ... }," followed by more content
|
|
1553
|
+
// Extract the inner object and the trailing properties
|
|
1554
|
+
const innerObject = trimmed.slice(0, firstBraceEnd);
|
|
1555
|
+
const trailingContent = trimmed.slice(firstBraceEnd + 2).trim();
|
|
1556
|
+
if (trailingContent) {
|
|
1557
|
+
// Merge trailing properties into the inner object
|
|
1558
|
+
mappedContents = `${innerObject},\n${trailingContent}\n}`;
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
// Even when content starts with {, we need to filter out invalid properties inside
|
|
1562
|
+
// (arrow functions and bare objects that were generated from the schema)
|
|
1563
|
+
// Pass skipFirstBrace=true because the content's outer { is the intentional wrapper
|
|
1564
|
+
mappedContents = filterOutArrowFunctions(mappedContents);
|
|
1565
|
+
mappedContents = filterOutBareObjects(mappedContents, true);
|
|
1566
|
+
mappedContents = cleanupContent(mappedContents);
|
|
1567
|
+
// Same as needsWrapper branch: ensure item data is preserved in .map()
|
|
1568
|
+
const hasDataSpreadInner =
|
|
1569
|
+
mappedContents.includes('...scenarios()') ||
|
|
1570
|
+
mappedContents.includes('...__item__');
|
|
1571
|
+
if (!hasDataSpreadInner && mappedContents.trim().length > 0) {
|
|
1572
|
+
// Insert ...__item__ after the opening brace
|
|
1573
|
+
mappedContents = mappedContents.replace(
|
|
1574
|
+
/^\s*\{/,
|
|
1575
|
+
'{\n...__item__,',
|
|
1576
|
+
);
|
|
1577
|
+
}
|
|
683
1578
|
returnValueContents = `${arrayBasePath}?.map((__item__, __idx__) => (\n${indent(mappedContents)}\n))`;
|
|
684
1579
|
}
|
|
685
1580
|
} else {
|
|
686
1581
|
returnValueContents = `[\n${indent(levelContents)}\n]`;
|
|
687
1582
|
}
|
|
688
1583
|
} else {
|
|
689
|
-
|
|
1584
|
+
// When we have a single data path and nested content that creates an object structure,
|
|
1585
|
+
// and we're NOT at the root level, we need to handle the case where the parent data
|
|
1586
|
+
// value is null or undefined. Without this check, `{ ...null, prop: null?.["prop"] }`
|
|
1587
|
+
// creates `{ prop: undefined }` instead of `null`, causing errors like
|
|
1588
|
+
// "Cannot read properties of undefined (reading 'some')" when code does
|
|
1589
|
+
// data?.prop.some(...) because data is an object with prop: undefined, not null.
|
|
1590
|
+
// We only apply this to non-root cases because root-level mocks are expected to exist.
|
|
1591
|
+
// We also skip structural elements (like [0] inside arrays) because the null check
|
|
1592
|
+
// syntax doesn't work inside .map() callbacks where structural elements are used.
|
|
1593
|
+
// We also skip array index elements ([0], [1], etc.) because they represent tuple/array
|
|
1594
|
+
// elements, not properties that could be null.
|
|
1595
|
+
// We also only apply this when we're inside a function return value context - i.e.,
|
|
1596
|
+
// when the data path contains a function call pattern like ?.["someFunction(...)"].
|
|
1597
|
+
// This prevents adding null checks to intermediate objects in chains like supabase.auth.
|
|
1598
|
+
const hasNestedContent = nestedContent.filter(Boolean).length > 0;
|
|
1599
|
+
const isArrayIndexElement = name.match(/^\[\d*\]$/);
|
|
1600
|
+
// Check if data path contains a function call pattern, indicating we're inside a function return value
|
|
1601
|
+
const isInsideFunctionReturnValue =
|
|
1602
|
+
dataPaths.length === 1 &&
|
|
1603
|
+
dataPaths[0].match(/\?\.\["\w+\([^"]*\)"\]/);
|
|
1604
|
+
if (
|
|
1605
|
+
!root &&
|
|
1606
|
+
!returnValue.isStructural &&
|
|
1607
|
+
!isArrayIndexElement &&
|
|
1608
|
+
isInsideFunctionReturnValue &&
|
|
1609
|
+
hasNestedContent
|
|
1610
|
+
) {
|
|
1611
|
+
// Wrap with null check: if parent is null/undefined, return it directly; otherwise create object
|
|
1612
|
+
returnValueContents = `${dataPaths[0]} == null ? ${dataPaths[0]} : {\n${indent(levelContents)}\n}`;
|
|
1613
|
+
} else {
|
|
1614
|
+
returnValueContents = `{\n${indent(levelContents)}\n}`;
|
|
1615
|
+
}
|
|
690
1616
|
}
|
|
691
1617
|
}
|
|
692
1618
|
|
|
@@ -698,6 +1624,13 @@ export default function constructMockCode(
|
|
|
698
1624
|
if (args && args.length > 0) {
|
|
699
1625
|
if (!isValidKey(name)) return;
|
|
700
1626
|
|
|
1627
|
+
// Skip array index patterns like [], [0], [1] when they have args
|
|
1628
|
+
// These represent function calls on array elements, not property keys
|
|
1629
|
+
// e.g., customSizes[].(args) means each array element is callable, not a property named "[]"
|
|
1630
|
+
if (name.match(/^\[\d*\]$/)) {
|
|
1631
|
+
return;
|
|
1632
|
+
}
|
|
1633
|
+
|
|
701
1634
|
const mostArgs = args.sort(
|
|
702
1635
|
(a: string[], b: string[]) => b.length - a.length,
|
|
703
1636
|
)[0];
|
|
@@ -757,8 +1690,18 @@ export default function constructMockCode(
|
|
|
757
1690
|
// Use all paths for fallback (existing behavior)
|
|
758
1691
|
fallbackContent = `return ${returnValueContents}`;
|
|
759
1692
|
} else {
|
|
760
|
-
//
|
|
761
|
-
|
|
1693
|
+
// No explicit fallback paths - return the first literal's value as default
|
|
1694
|
+
// Returning spread of all values is dangerous because if values are primitives (strings),
|
|
1695
|
+
// spreading them creates objects with numeric keys like {0:'a', 1:'b', ...}
|
|
1696
|
+
// which causes "Objects are not valid as React child" errors
|
|
1697
|
+
const firstLiteralValue = literalKeys[0];
|
|
1698
|
+
const firstGroupPaths = argGroups.get(firstLiteralValue);
|
|
1699
|
+
if (firstGroupPaths && firstGroupPaths.length === 1) {
|
|
1700
|
+
fallbackContent = `return ${firstGroupPaths[0]}`;
|
|
1701
|
+
} else {
|
|
1702
|
+
// Multiple paths for first literal - return undefined as safe fallback
|
|
1703
|
+
fallbackContent = `return undefined`;
|
|
1704
|
+
}
|
|
762
1705
|
}
|
|
763
1706
|
|
|
764
1707
|
const funcContents =
|
|
@@ -767,15 +1710,49 @@ export default function constructMockCode(
|
|
|
767
1710
|
fallbackContent;
|
|
768
1711
|
content = `${cleanOutTypes(name)}: ${isAsyncFunction ? 'async ' : ''}(${argsString}) => {\n${indent(funcContents)}\n}`;
|
|
769
1712
|
} else {
|
|
770
|
-
// No argument variants
|
|
771
|
-
|
|
772
|
-
|
|
1713
|
+
// No argument variants
|
|
1714
|
+
// Check if this is an array method callback containing JSX.
|
|
1715
|
+
// JSX can't be serialized to JSON, so the LLM generates [{}] as data.
|
|
1716
|
+
// Instead of returning that unusable data, generate a passthrough that
|
|
1717
|
+
// calls the real callback on the best available array data from siblings.
|
|
1718
|
+
const containsJsx = dataPaths.some((p) => /<[A-Z]/.test(p));
|
|
1719
|
+
const isArrayMethod = ARRAY_PROTOTYPE_METHODS.has(name);
|
|
1720
|
+
|
|
1721
|
+
if (containsJsx && isArrayMethod && dataPaths.length > 0) {
|
|
1722
|
+
// Extract parent data path by removing the last ?.["..."] segment
|
|
1723
|
+
const parentPath = dataPaths[0].replace(/\?\.\["[^"]*"\]$/, '');
|
|
1724
|
+
const funcLines = [
|
|
1725
|
+
`const _d = ${parentPath};`,
|
|
1726
|
+
`const _a = Object.values(_d || {}).filter(v => Array.isArray(v) && v.length > 0 && v.some(i => i && typeof i === "object" && Object.keys(i).length > 0)).sort((a, b) => b.length - a.length);`,
|
|
1727
|
+
`return _a[0] ? _a[0].${name}(${argsString}) : []`,
|
|
1728
|
+
];
|
|
1729
|
+
const funcContents = funcLines.join('\n');
|
|
1730
|
+
content = `${cleanOutTypes(name)}: ${isAsyncFunction ? 'async ' : ''}(${argsString}) => {\n${indent(funcContents)}\n}`;
|
|
1731
|
+
} else {
|
|
1732
|
+
// But if there's nested content, we need to include it in the return object
|
|
1733
|
+
// (similar to how argument variant branches handle this at line 1070-1072)
|
|
1734
|
+
const hasNestedContent = validNestedContent.length > 0;
|
|
1735
|
+
let funcReturnContents: string;
|
|
1736
|
+
if (hasNestedContent && levelContentItems.length > 1) {
|
|
1737
|
+
// Include both spread and nested content in the return
|
|
1738
|
+
funcReturnContents = `{\n${indent(levelContents)}\n}`;
|
|
1739
|
+
} else {
|
|
1740
|
+
funcReturnContents = returnValueContents;
|
|
1741
|
+
}
|
|
1742
|
+
const funcContents = `return ${funcReturnContents}`;
|
|
1743
|
+
content = `${cleanOutTypes(name)}: ${isAsyncFunction ? 'async ' : ''}(${argsString}) => {\n${indent(funcContents)}\n}`;
|
|
1744
|
+
}
|
|
773
1745
|
}
|
|
774
1746
|
} else {
|
|
775
1747
|
if (!isValidKey(name)) {
|
|
776
1748
|
return;
|
|
777
1749
|
} else if (name.match(/\[\d*\]/)) {
|
|
1750
|
+
// Numeric array index like [0], [1] - can be used as computed property
|
|
778
1751
|
content = returnValueContents;
|
|
1752
|
+
} else if (name.match(/^\[[a-zA-Z_]\w*\]$/)) {
|
|
1753
|
+
// Variable-based index like [currentItemIndex] - must be quoted string key
|
|
1754
|
+
// Otherwise JavaScript would try to evaluate the variable name
|
|
1755
|
+
content = `"${safeString(name)}": ${returnValueContents}`;
|
|
779
1756
|
} else {
|
|
780
1757
|
content = `${safeString(name)}: ${returnValueContents}`;
|
|
781
1758
|
}
|
|
@@ -790,34 +1767,91 @@ export default function constructMockCode(
|
|
|
790
1767
|
};
|
|
791
1768
|
|
|
792
1769
|
// Create the return value structure
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
1770
|
+
// OPTIMIZATION: Filter keys to only those starting with baseMockName before sorting.
|
|
1771
|
+
// This dramatically reduces processing time for large schemas (e.g., 9216 keys -> ~100 relevant keys).
|
|
1772
|
+
// Without this filter, the loop would call splitOutsideParenthesesAndArrays on every key
|
|
1773
|
+
// even though most are filtered out later by the baseMockName check.
|
|
1774
|
+
const allSchemaKeys = Object.keys(relevantReturnValueSchema ?? {});
|
|
1775
|
+
const relevantKeys = allSchemaKeys.filter((key) => {
|
|
1776
|
+
// Fast prefix check - key must start with baseMockName followed by ( or < or .
|
|
1777
|
+
// This matches: "useAtom()", "useAtom<T>()", "useAtom.something", but not "useAtomValue()"
|
|
1778
|
+
if (key === baseMockName) return true;
|
|
1779
|
+
if (key.startsWith(baseMockName + '(')) return true;
|
|
1780
|
+
if (key.startsWith(baseMockName + '<')) return true;
|
|
1781
|
+
if (key.startsWith(baseMockName + '.')) return true;
|
|
1782
|
+
// Also include 'returnValue' paths which are normalized later
|
|
1783
|
+
if (
|
|
1784
|
+
key === 'returnValue' ||
|
|
1785
|
+
key.startsWith('returnValue.') ||
|
|
1786
|
+
key.startsWith('returnValue[')
|
|
1787
|
+
)
|
|
1788
|
+
return true;
|
|
1789
|
+
return false;
|
|
1790
|
+
});
|
|
1791
|
+
|
|
1792
|
+
const schemaKeyCount = relevantKeys.length;
|
|
1793
|
+
const sortedKeys = relevantKeys.sort((a: string, b: string) => {
|
|
1794
|
+
const aParts = splitOutsideParenthesesAndArrays(a);
|
|
1795
|
+
const bParts = splitOutsideParenthesesAndArrays(b);
|
|
1796
|
+
|
|
1797
|
+
const maxLength = Math.max(aParts.length, bParts.length);
|
|
1798
|
+
for (let i = 0; i < maxLength; ++i) {
|
|
1799
|
+
const aPart = aParts[i];
|
|
1800
|
+
const bPart = bParts[i];
|
|
1801
|
+
|
|
1802
|
+
if (!aPart) return -1;
|
|
1803
|
+
if (!bPart) return 1;
|
|
1804
|
+
|
|
1805
|
+
if (aPart === bPart) continue;
|
|
1806
|
+
|
|
1807
|
+
const aName = aPart.split('(')[0];
|
|
1808
|
+
const bName = bPart.split('(')[0];
|
|
1809
|
+
|
|
1810
|
+
if (aName !== bName) {
|
|
1811
|
+
return aName.localeCompare(bName);
|
|
1812
|
+
} else {
|
|
1813
|
+
return aPart.localeCompare(bPart);
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
810
1816
|
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
1817
|
+
return 0;
|
|
1818
|
+
});
|
|
1819
|
+
|
|
1820
|
+
// OPTIMIZATION: Pre-compute prefix indexes for O(1) lookups instead of O(n) scans.
|
|
1821
|
+
// This reduces complexity from O(n²) to O(n) for large schemas (9k+ keys).
|
|
1822
|
+
//
|
|
1823
|
+
// 1. extendedReturnValuePrefixes: Set of all path prefixes that have a .functionCallReturnValue extension
|
|
1824
|
+
// Used by hasExtendedFunctionCallReturnValue check at line ~1754
|
|
1825
|
+
// 2. functionCallsWithReturnValue: Set of function call paths where .functionCallReturnValue IMMEDIATELY follows
|
|
1826
|
+
// Used by hasProperFunctionCallPath check at line ~1787
|
|
1827
|
+
// IMPORTANT: Only includes paths where the function call is directly followed by .functionCallReturnValue
|
|
1828
|
+
// e.g., "a.b().functionCallReturnValue" -> adds "a.b()" but NOT "a" even if "a" ends with ")"
|
|
1829
|
+
const extendedReturnValuePrefixes = new Set<string>();
|
|
1830
|
+
const functionCallsWithReturnValue = new Set<string>();
|
|
1831
|
+
|
|
1832
|
+
for (const k of relevantKeys) {
|
|
1833
|
+
const parts = splitOutsideParenthesesAndArrays(k);
|
|
1834
|
+
const returnValueIndex = parts.findIndex((part) =>
|
|
1835
|
+
part.startsWith(RETURN_VALUE),
|
|
1836
|
+
);
|
|
1837
|
+
if (returnValueIndex !== -1) {
|
|
1838
|
+
// Add all prefixes of k up to (but not including) functionCallReturnValue
|
|
1839
|
+
const prefix = joinParenthesesAndArrays(parts.slice(0, returnValueIndex));
|
|
1840
|
+
extendedReturnValuePrefixes.add(prefix);
|
|
1841
|
+
|
|
1842
|
+
// ONLY add to functionCallsWithReturnValue if functionCallReturnValue IMMEDIATELY follows
|
|
1843
|
+
if (prefix.endsWith(')')) {
|
|
1844
|
+
functionCallsWithReturnValue.add(prefix);
|
|
816
1845
|
}
|
|
817
1846
|
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
1847
|
+
// Also add intermediate prefixes for nested paths to extendedReturnValuePrefixes
|
|
1848
|
+
// This helps hasExtendedFunctionCallReturnValue which checks key + '.'
|
|
1849
|
+
for (let i = 1; i < returnValueIndex; i++) {
|
|
1850
|
+
const partialPrefix = joinParenthesesAndArrays(parts.slice(0, i));
|
|
1851
|
+
extendedReturnValuePrefixes.add(partialPrefix);
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
821
1855
|
|
|
822
1856
|
for (const key of sortedKeys) {
|
|
823
1857
|
const value = relevantReturnValueSchema[key];
|
|
@@ -852,8 +1886,8 @@ export default function constructMockCode(
|
|
|
852
1886
|
}
|
|
853
1887
|
}
|
|
854
1888
|
|
|
855
|
-
//
|
|
856
|
-
//
|
|
1889
|
+
// Compare against baseMockName (without generics/args), not the full mockName
|
|
1890
|
+
// e.g., for "useFetcher<User>()", baseMockName is "useFetcher"
|
|
857
1891
|
if (parts[0].split('(')[0] !== baseMockName) continue;
|
|
858
1892
|
|
|
859
1893
|
// Include paths with functionCallReturnValue OR function-typed paths that need mocking
|
|
@@ -875,9 +1909,10 @@ export default function constructMockCode(
|
|
|
875
1909
|
// nested inside (e.g., methods on array elements passed as arguments).
|
|
876
1910
|
if (hasSignaturePath) continue;
|
|
877
1911
|
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
1912
|
+
// OPTIMIZATION: Use pre-computed index instead of O(n) scan
|
|
1913
|
+
// Old code: Object.keys(relevantReturnValueSchema).some((k) => k.startsWith(key + '.') && k.includes('.functionCallReturnValue'))
|
|
1914
|
+
const hasExtendedFunctionCallReturnValue =
|
|
1915
|
+
extendedReturnValuePrefixes.has(key);
|
|
881
1916
|
|
|
882
1917
|
// Skip JSX components - they look like function calls (e.g., Context.Provider())
|
|
883
1918
|
// but they're React components used in JSX, not functions that need mocking
|
|
@@ -888,6 +1923,38 @@ export default function constructMockCode(
|
|
|
888
1923
|
'jsx-component';
|
|
889
1924
|
if (isJsxComponent) continue;
|
|
890
1925
|
|
|
1926
|
+
// Skip paths that bypass .functionCallReturnValue when there's a corresponding path with it.
|
|
1927
|
+
// Example: If we have both:
|
|
1928
|
+
// - trpc.customer.useQuery(...).data (incorrect - no .functionCallReturnValue)
|
|
1929
|
+
// - trpc.customer.useQuery(...).functionCallReturnValue.data (correct)
|
|
1930
|
+
// We should skip the first path because the second one properly captures the return value.
|
|
1931
|
+
// This can happen when the analyzer sees both the raw property access and the return value structure.
|
|
1932
|
+
if (!hasFunctionCallReturnValue) {
|
|
1933
|
+
// This path has no .functionCallReturnValue. Check if any function call in this path
|
|
1934
|
+
// has a corresponding .functionCallReturnValue path in the schema.
|
|
1935
|
+
let shouldSkipKey = false;
|
|
1936
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
1937
|
+
const part = parts[i];
|
|
1938
|
+
if (part.endsWith(')') && !isFunctionCallReturnValue(parts[i + 1])) {
|
|
1939
|
+
// This part is a function call, and the next part is NOT .functionCallReturnValue
|
|
1940
|
+
// Check if there's any path with .functionCallReturnValue for this function call
|
|
1941
|
+
const functionCallPath = joinParenthesesAndArrays(
|
|
1942
|
+
parts.slice(0, i + 1),
|
|
1943
|
+
);
|
|
1944
|
+
// OPTIMIZATION: Use pre-computed index instead of O(n) scan
|
|
1945
|
+
// Old code: Object.keys(relevantReturnValueSchema).some((k) => k.startsWith(functionCallPath + '.functionCallReturnValue'))
|
|
1946
|
+
const hasProperFunctionCallPath =
|
|
1947
|
+
functionCallsWithReturnValue.has(functionCallPath);
|
|
1948
|
+
if (hasProperFunctionCallPath) {
|
|
1949
|
+
// Skip this path - the .functionCallReturnValue path will handle it correctly
|
|
1950
|
+
shouldSkipKey = true;
|
|
1951
|
+
break;
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
if (shouldSkipKey) continue;
|
|
1956
|
+
}
|
|
1957
|
+
|
|
891
1958
|
const isFunctionPath =
|
|
892
1959
|
['function', 'async-function'].includes(value) &&
|
|
893
1960
|
parts[parts.length - 1].endsWith(')') &&
|
|
@@ -936,6 +2003,17 @@ export default function constructMockCode(
|
|
|
936
2003
|
const nextIsArray = !!nextPart?.match(/^\[\d*\]/);
|
|
937
2004
|
const isDifferentiatedArray = !!part?.match(/^\[\d+\]/);
|
|
938
2005
|
const nextIsDifferentiatedArray = !!nextPart?.match(/^\[\d+\]/);
|
|
2006
|
+
|
|
2007
|
+
// Variable index patterns like [currentItemIndex] or [targetIndex] indicate array access
|
|
2008
|
+
// but don't represent actual data structure - they're markers from variable-based index tracking.
|
|
2009
|
+
// Skip them AND all remaining parts to avoid creating spurious nested structure that breaks array iteration.
|
|
2010
|
+
// The remaining parts (e.g., .missing_attributes) describe properties of array elements, which are
|
|
2011
|
+
// already handled by the generic [] accessor path.
|
|
2012
|
+
const isVariableIndex = !!part?.match(/^\[[a-zA-Z_]\w*\]$/);
|
|
2013
|
+
if (isVariableIndex) {
|
|
2014
|
+
// Break out of the loop entirely - don't process any remaining parts
|
|
2015
|
+
break;
|
|
2016
|
+
}
|
|
939
2017
|
// Find the correct value for the current part being processed
|
|
940
2018
|
let partValue = value; // default to the final value
|
|
941
2019
|
if (isFunctionCallReturnValue(part) && nextIsArray) {
|
|
@@ -1043,7 +2121,52 @@ export default function constructMockCode(
|
|
|
1043
2121
|
}
|
|
1044
2122
|
}
|
|
1045
2123
|
} else {
|
|
1046
|
-
|
|
2124
|
+
// Before setting returnsFunctionArgs on the parent (for generic [] = function),
|
|
2125
|
+
// check if there are specific array indices (like [0], [1]) that are NOT functions.
|
|
2126
|
+
// If so, don't set returnsFunctionArgs because those specific indices take precedence.
|
|
2127
|
+
// This prevents adding ["()"] to paths like [0] when [0] is 'unknown' but [] is 'function'.
|
|
2128
|
+
//
|
|
2129
|
+
// Use parts.slice(0, i + 1) to get the current path INCLUDING functionCallReturnValue.
|
|
2130
|
+
// For example, if parts = ['useAtom()','functionCallReturnValue','[]']
|
|
2131
|
+
// and i = 1, we want to check 'useAtom().functionCallReturnValue[0]' etc.
|
|
2132
|
+
const arrayContainerPath = joinParenthesesAndArrays(
|
|
2133
|
+
parts.slice(0, i + 1),
|
|
2134
|
+
);
|
|
2135
|
+
|
|
2136
|
+
const hasNonFunctionSpecificIndices = Object.entries(
|
|
2137
|
+
relevantReturnValueSchema,
|
|
2138
|
+
).some(([k, v]) => {
|
|
2139
|
+
// Look for paths like "arrayContainerPath[0]", "arrayContainerPath[1]" etc.
|
|
2140
|
+
const indexMatch = k.match(
|
|
2141
|
+
new RegExp(
|
|
2142
|
+
`^${arrayContainerPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\[(\\d+)\\]$`,
|
|
2143
|
+
),
|
|
2144
|
+
);
|
|
2145
|
+
// If found and it's NOT a function type, we have a conflict
|
|
2146
|
+
return (
|
|
2147
|
+
indexMatch &&
|
|
2148
|
+
!['function', 'async-function'].includes(v as string)
|
|
2149
|
+
);
|
|
2150
|
+
});
|
|
2151
|
+
|
|
2152
|
+
// Also check if [] has nested object properties (like [].filter, [].name)
|
|
2153
|
+
// If so, [] items are objects with properties, not pure functions to be called
|
|
2154
|
+
// This handles cases where the schema shows [].filter = object but doesn't
|
|
2155
|
+
// have explicit [0] entries
|
|
2156
|
+
const genericArrayPath = `${arrayContainerPath}[]`;
|
|
2157
|
+
const hasNestedProperties = Object.keys(
|
|
2158
|
+
relevantReturnValueSchema,
|
|
2159
|
+
).some((k) => {
|
|
2160
|
+
// Check for paths like "arrayContainerPath[].propertyName" (not [].())
|
|
2161
|
+
return (
|
|
2162
|
+
k.startsWith(genericArrayPath + '.') &&
|
|
2163
|
+
!k.startsWith(genericArrayPath + '.(')
|
|
2164
|
+
);
|
|
2165
|
+
});
|
|
2166
|
+
|
|
2167
|
+
if (!hasNonFunctionSpecificIndices && !hasNestedProperties) {
|
|
2168
|
+
returnValueSection.returnsFunctionArgs = [];
|
|
2169
|
+
}
|
|
1047
2170
|
}
|
|
1048
2171
|
}
|
|
1049
2172
|
}
|
|
@@ -1068,7 +2191,8 @@ export default function constructMockCode(
|
|
|
1068
2191
|
}
|
|
1069
2192
|
// If the next part is an object with nested content, continue processing
|
|
1070
2193
|
// This handles paths like functionCallReturnValue.selectedOptions.elementOptions[]
|
|
1071
|
-
|
|
2194
|
+
// Also handles union types like 'array | undefined' or 'object | undefined'
|
|
2195
|
+
if (nextValue?.includes('object') || nextValue?.includes('array')) {
|
|
1072
2196
|
continue;
|
|
1073
2197
|
}
|
|
1074
2198
|
}
|
|
@@ -1197,17 +2321,22 @@ export default function constructMockCode(
|
|
|
1197
2321
|
) {
|
|
1198
2322
|
returnValueSection.nested.push(relevantPart);
|
|
1199
2323
|
}
|
|
1200
|
-
} else
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
const
|
|
1205
|
-
|
|
1206
|
-
|
|
2324
|
+
} else {
|
|
2325
|
+
// Add args to existing entry if current part has function arguments
|
|
2326
|
+
// This handles the case where bare `t` is processed first (creating {name: 't', args: undefined})
|
|
2327
|
+
// and then `t("common.close")` is processed - we need to add its args to the existing entry
|
|
2328
|
+
const currentArgs = funcArgs(part);
|
|
2329
|
+
const hasNewArgs = currentArgs.length > 0 || part.includes('(');
|
|
2330
|
+
|
|
2331
|
+
if (hasNewArgs) {
|
|
2332
|
+
const existingArgs = relevantPart.args?.find(
|
|
2333
|
+
(args) => args.join(',') === currentArgs.join(','),
|
|
2334
|
+
);
|
|
1207
2335
|
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
2336
|
+
if (!existingArgs) {
|
|
2337
|
+
relevantPart.args ||= [];
|
|
2338
|
+
relevantPart.args.push(currentArgs);
|
|
2339
|
+
}
|
|
1211
2340
|
}
|
|
1212
2341
|
}
|
|
1213
2342
|
|
|
@@ -1217,7 +2346,14 @@ export default function constructMockCode(
|
|
|
1217
2346
|
relevantPart.isGenericArray = true;
|
|
1218
2347
|
}
|
|
1219
2348
|
|
|
1220
|
-
if
|
|
2349
|
+
// Check if there are remaining parts after functionCallReturnValue that need processing
|
|
2350
|
+
// (e.g., data properties like useQuery().functionCallReturnValue.data)
|
|
2351
|
+
const hasRemainingPartsAfterReturnValue =
|
|
2352
|
+
nextPart &&
|
|
2353
|
+
(isFunctionCallReturnValue(nextPart) ||
|
|
2354
|
+
(isFunctionCallReturnValue(parts[i]) && i < parts.length - 1));
|
|
2355
|
+
|
|
2356
|
+
if (!hasNestedFunction && !hasRemainingPartsAfterReturnValue) {
|
|
1221
2357
|
// Before breaking, check if this function returns an array
|
|
1222
2358
|
// by looking for a functionCallReturnValue: 'array' entry in the schema
|
|
1223
2359
|
if (relevantPart && part.endsWith(')')) {
|
|
@@ -1245,10 +2381,28 @@ export default function constructMockCode(
|
|
|
1245
2381
|
}
|
|
1246
2382
|
}
|
|
1247
2383
|
|
|
2384
|
+
// Post-processing: When the root functionCallReturnValue is typed as "function" but the
|
|
2385
|
+
// return value also has nested properties (methods like .from(), .auth, etc.), it's actually
|
|
2386
|
+
// an object, not a function to be called. Clear returnsFunctionArgs to prevent double-wrapping
|
|
2387
|
+
// (adding an extra () => { return { ... } } wrapper and ["()"] data paths).
|
|
2388
|
+
// This handles cases like Supabase's createClient() which returns an object with methods.
|
|
2389
|
+
// Only applied to the root level - nested parts that are functions with methods (like
|
|
2390
|
+
// useSearchParams()[1] which is a setter function with .set() and .delete()) should keep
|
|
2391
|
+
// their returnsFunctionArgs since they genuinely ARE functions.
|
|
2392
|
+
if (
|
|
2393
|
+
returnValueParts.returnsFunctionArgs &&
|
|
2394
|
+
returnValueParts.returnsFunctionArgs.length === 0 &&
|
|
2395
|
+
returnValueParts.nested &&
|
|
2396
|
+
returnValueParts.nested.length > 0
|
|
2397
|
+
) {
|
|
2398
|
+
returnValueParts.returnsFunctionArgs = undefined;
|
|
2399
|
+
}
|
|
2400
|
+
|
|
1248
2401
|
const contents = constructReturnValueString(returnValueParts);
|
|
1249
2402
|
|
|
1250
2403
|
if (mockNameParts.length > 1) {
|
|
1251
2404
|
const originalLib = `${mockNameParts[0]}__cyOriginal`;
|
|
2405
|
+
const skipOriginalSpread = options?.skipOriginalSpread;
|
|
1252
2406
|
|
|
1253
2407
|
const subPart = (
|
|
1254
2408
|
parts: string[],
|
|
@@ -1260,7 +2414,9 @@ export default function constructMockCode(
|
|
|
1260
2414
|
|
|
1261
2415
|
const partContents = isLast
|
|
1262
2416
|
? contents
|
|
1263
|
-
:
|
|
2417
|
+
: skipOriginalSpread
|
|
2418
|
+
? subPart(parts, originalLib)
|
|
2419
|
+
: `...${originalLib}.${part},\n${subPart(parts, originalLib)}`;
|
|
1264
2420
|
|
|
1265
2421
|
let code = `${part}: {\n${indent(partContents)}\n}`;
|
|
1266
2422
|
|
|
@@ -1274,27 +2430,31 @@ export default function constructMockCode(
|
|
|
1274
2430
|
return code;
|
|
1275
2431
|
};
|
|
1276
2432
|
|
|
1277
|
-
const returnParts =
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
2433
|
+
const returnParts = skipOriginalSpread
|
|
2434
|
+
? [subPart(mockNameParts.slice(1), originalLib)]
|
|
2435
|
+
: [
|
|
2436
|
+
`...${mockNameParts[0]}__cyOriginal`,
|
|
2437
|
+
subPart(mockNameParts.slice(1), originalLib),
|
|
2438
|
+
];
|
|
1281
2439
|
|
|
1282
|
-
return `const ${mockNameParts[0]} = {\n${indent(returnParts.join(',\n'))}\n};`;
|
|
2440
|
+
return `const ${mockNameParts[0]} = {\n${indent(returnParts.filter(Boolean).join(',\n'))}\n};`;
|
|
1283
2441
|
} else if (isFunction) {
|
|
1284
2442
|
// For headers() and cookies() from next/headers, add common iterator methods
|
|
1285
2443
|
// These are needed when the mock is passed to functions that use .entries(), .keys(), etc.
|
|
1286
2444
|
// (e.g., Object.fromEntries(headers.entries()) in buildLegacyHeaders)
|
|
1287
2445
|
const needsIteratorMethods =
|
|
1288
|
-
|
|
2446
|
+
baseMockName === 'headers' || baseMockName === 'cookies';
|
|
1289
2447
|
let enhancedContents = contents;
|
|
1290
2448
|
if (needsIteratorMethods && contents.trim().startsWith('{')) {
|
|
1291
2449
|
// Add iterator methods that operate on the scenario data
|
|
2450
|
+
// Use the dataKey (original call signature or canonical key)
|
|
2451
|
+
const quotedDataKey = quotePropertyKey(dataKey);
|
|
1292
2452
|
const iteratorMethods = `,
|
|
1293
|
-
entries: () => Object.entries(scenarios().data()
|
|
1294
|
-
keys: () => Object.keys(scenarios().data()
|
|
1295
|
-
values: () => Object.values(scenarios().data()
|
|
1296
|
-
forEach: (fn) => Object.entries(scenarios().data()
|
|
1297
|
-
has: (key) => Object.prototype.hasOwnProperty.call(scenarios().data()
|
|
2453
|
+
entries: () => Object.entries(scenarios().data()?.${quotedDataKey} || {}),
|
|
2454
|
+
keys: () => Object.keys(scenarios().data()?.${quotedDataKey} || {}),
|
|
2455
|
+
values: () => Object.values(scenarios().data()?.${quotedDataKey} || {}),
|
|
2456
|
+
forEach: (fn) => Object.entries(scenarios().data()?.${quotedDataKey} || {}).forEach(([k, v]) => fn(v, k)),
|
|
2457
|
+
has: (key) => Object.prototype.hasOwnProperty.call(scenarios().data()?.${quotedDataKey} || {}, key)`;
|
|
1298
2458
|
// Insert before the closing brace (handle trailing whitespace)
|
|
1299
2459
|
enhancedContents = contents.replace(/\}\s*$/, iteratorMethods + '\n}');
|
|
1300
2460
|
}
|
|
@@ -1305,36 +2465,140 @@ export default function constructMockCode(
|
|
|
1305
2465
|
// `new ClassName("arg")` wouldn't create the expected instance.
|
|
1306
2466
|
// For Error subclasses (detected by name ending in "Error"), extend Error for proper error handling.
|
|
1307
2467
|
if (entityType === 'class') {
|
|
1308
|
-
const isErrorSubclass =
|
|
1309
|
-
const baseClass = isErrorSubclass ? 'Error' : 'Object';
|
|
2468
|
+
const isErrorSubclass = baseMockName.endsWith('Error');
|
|
1310
2469
|
const superCall = isErrorSubclass ? 'super(message);' : '';
|
|
1311
2470
|
const nameAssignment = isErrorSubclass
|
|
1312
|
-
? `this.name = '${
|
|
2471
|
+
? `this.name = '${baseMockName}';`
|
|
1313
2472
|
: '';
|
|
1314
|
-
|
|
1315
|
-
|
|
2473
|
+
// Use the base class name for the class definition, not the call-signature-derived name.
|
|
2474
|
+
// When mockName is "StatsCalculator(supabase)", baseMockName is "StatsCalculator"
|
|
2475
|
+
// and derivedFunctionName would be "StatsCalculator_supabase" which is wrong.
|
|
2476
|
+
// Classes are instantiated with `new ClassName(args)` so the name must match the original.
|
|
2477
|
+
const className = baseMockName;
|
|
2478
|
+
|
|
2479
|
+
// Use the already-generated contents (which has proper function wrappers for methods)
|
|
2480
|
+
// instead of raw scenarios().data() which would create non-callable string-keyed properties.
|
|
2481
|
+
// For classes with methods like calculateStats(), the contents will have:
|
|
2482
|
+
// { calculateStats: (...args) => scenarios().data()?.["key"]?.["calculateStats(...)"], ... }
|
|
2483
|
+
// which makes methods callable on the instance.
|
|
2484
|
+
const classContents = enhancedContents.trim().startsWith('{')
|
|
2485
|
+
? enhancedContents
|
|
2486
|
+
: `scenarios().data()?.${quotePropertyKey(dataKey)} || {}`;
|
|
2487
|
+
|
|
2488
|
+
return `class ${className}${isErrorSubclass ? ' extends Error' : ''} {
|
|
1316
2489
|
constructor(message) {
|
|
1317
2490
|
${superCall}
|
|
1318
2491
|
${nameAssignment}
|
|
1319
|
-
Object.assign(this,
|
|
2492
|
+
Object.assign(this, ${classContents});
|
|
1320
2493
|
}
|
|
1321
2494
|
}`;
|
|
1322
2495
|
}
|
|
1323
2496
|
|
|
1324
|
-
//
|
|
1325
|
-
//
|
|
1326
|
-
//
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
2497
|
+
// Generate safe function name:
|
|
2498
|
+
// 1. For call signatures: use derivedFunctionName
|
|
2499
|
+
// e.g., "useFetcher<User>()" becomes "useFetcher_User"
|
|
2500
|
+
// e.g., "db.select(usersQuery)" becomes "db_select_usersQuery"
|
|
2501
|
+
// 2. With uniqueFunctionSuffix option: append suffix for unique naming
|
|
2502
|
+
// e.g., baseMockName = "useFetcher", suffix = "entityDiffFetcher" -> "useFetcher_entityDiffFetcher"
|
|
2503
|
+
// 3. EXCEPTION: When keepOriginalFunctionName is true (for single-call cases), use the base name
|
|
2504
|
+
let safeFunctionName: string;
|
|
2505
|
+
if (options?.keepOriginalFunctionName) {
|
|
2506
|
+
safeFunctionName = baseMockName;
|
|
2507
|
+
} else if (options?.uniqueFunctionSuffix) {
|
|
2508
|
+
safeFunctionName = `${baseMockName}_${options.uniqueFunctionSuffix}`;
|
|
2509
|
+
} else if (mockNameIsCallSignature && derivedFunctionName) {
|
|
2510
|
+
safeFunctionName = derivedFunctionName;
|
|
2511
|
+
} else {
|
|
2512
|
+
safeFunctionName = baseMockName;
|
|
2513
|
+
}
|
|
1330
2514
|
|
|
1331
|
-
|
|
2515
|
+
// Check if this function returns a function (detected by double-call pattern: mockName(args)())
|
|
2516
|
+
// This happens when the schema has keys like "wrapThrows(() => JSON.parse(savedFilters))()"
|
|
2517
|
+
// where the function call is immediately followed by another call.
|
|
2518
|
+
// Example usage: const result = wrapThrows(() => JSON.parse(x))(); // double call
|
|
2519
|
+
const isHigherOrderFunction = Object.keys(
|
|
2520
|
+
relevantReturnValueSchema ?? {},
|
|
2521
|
+
).some((key) => {
|
|
2522
|
+
if (!key.startsWith(baseMockName)) return false;
|
|
2523
|
+
|
|
2524
|
+
// Find the first ( after baseMockName (the start of the function call)
|
|
2525
|
+
const firstOpenParen = key.indexOf('(', baseMockName.length);
|
|
2526
|
+
if (firstOpenParen === -1) return false;
|
|
2527
|
+
|
|
2528
|
+
// Skip if the ( is not immediately after the mock name
|
|
2529
|
+
// (there might be type params like func<T>() - handle by checking for < or ()
|
|
2530
|
+
const between = key.slice(baseMockName.length, firstOpenParen);
|
|
2531
|
+
if (between.length > 0 && !between.startsWith('<')) return false;
|
|
2532
|
+
|
|
2533
|
+
// Find the matching ) for the first ( using depth counting
|
|
2534
|
+
let depth = 1;
|
|
2535
|
+
let i = firstOpenParen + 1;
|
|
2536
|
+
while (i < key.length && depth > 0) {
|
|
2537
|
+
if (key[i] === '(') depth++;
|
|
2538
|
+
if (key[i] === ')') depth--;
|
|
2539
|
+
i++;
|
|
2540
|
+
}
|
|
2541
|
+
|
|
2542
|
+
if (depth !== 0) return false; // Unbalanced parentheses
|
|
2543
|
+
|
|
2544
|
+
// Now i points just after the matching )
|
|
2545
|
+
// Check if there's another ( immediately (indicating double call)
|
|
2546
|
+
const remaining = key.slice(i);
|
|
2547
|
+
if (remaining.startsWith('(')) return true;
|
|
2548
|
+
|
|
2549
|
+
return false;
|
|
2550
|
+
});
|
|
2551
|
+
|
|
2552
|
+
// Use ...args to accept any number of arguments - prevents TypeScript errors
|
|
2553
|
+
// like "Expected 0 arguments, but got X" when caller passes arguments
|
|
2554
|
+
// For higher-order functions, wrap the return in an arrow function
|
|
2555
|
+
// so that mockFunc(arg)() works correctly (outer call returns a function, inner call gets the data)
|
|
2556
|
+
const returnValue = isHigherOrderFunction
|
|
2557
|
+
? `() => (${enhancedContents})`
|
|
2558
|
+
: enhancedContents;
|
|
2559
|
+
|
|
2560
|
+
// Inline the return value directly in the function to avoid module-level const
|
|
2561
|
+
// that would be evaluated before scenario context is ready
|
|
2562
|
+
// Add fallback for simple data path returns to prevent undefined errors (e.g., createTheme)
|
|
2563
|
+
// Only add fallback if returnValue is a simple data accessor (starts with scenarios().data())
|
|
2564
|
+
// and doesn't already have nested structure (object literal, array, or method chains like .map())
|
|
2565
|
+
const isSimpleDataPath =
|
|
2566
|
+
returnValue.startsWith('scenarios().data()') &&
|
|
2567
|
+
!returnValue.trim().startsWith('{') &&
|
|
2568
|
+
!returnValue.trim().startsWith('[') &&
|
|
2569
|
+
!returnValue.includes('.map('); // Exclude method chains
|
|
2570
|
+
const safeReturnValue = isSimpleDataPath
|
|
2571
|
+
? `${returnValue} ?? {}`
|
|
2572
|
+
: returnValue;
|
|
2573
|
+
const refName = `_${safeFunctionName}Ref`;
|
|
2574
|
+
const assignment = `${refName}.current = ${safeReturnValue};`;
|
|
2575
|
+
const ifBlock = `if (!${refName}.current) {\n${indent(assignment)}\n}`;
|
|
2576
|
+
const body = `${ifBlock}\nreturn ${refName}.current;`;
|
|
2577
|
+
|
|
2578
|
+
return [
|
|
2579
|
+
`// PATCHED: memoize to return stable reference (prevents infinite useEffect re-triggers)`,
|
|
2580
|
+
`const ${refName} = {`,
|
|
2581
|
+
` current: null,`,
|
|
2582
|
+
`};`,
|
|
2583
|
+
`${isRootAsyncFunction ? 'async ' : ''}function ${safeFunctionName}(...args) {`,
|
|
2584
|
+
indent(body),
|
|
2585
|
+
`}`,
|
|
2586
|
+
].join('\n');
|
|
1332
2587
|
} else {
|
|
1333
|
-
//
|
|
1334
|
-
//
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
2588
|
+
// Generate safe const name:
|
|
2589
|
+
// 1. For call signatures: use derivedFunctionName
|
|
2590
|
+
// 2. With uniqueFunctionSuffix option: append suffix for unique naming
|
|
2591
|
+
// 3. EXCEPTION: When keepOriginalFunctionName is true (for single-call cases), use the base name
|
|
2592
|
+
let safeName: string;
|
|
2593
|
+
if (options?.keepOriginalFunctionName) {
|
|
2594
|
+
safeName = baseMockName;
|
|
2595
|
+
} else if (options?.uniqueFunctionSuffix) {
|
|
2596
|
+
safeName = `${baseMockName}_${options.uniqueFunctionSuffix}`;
|
|
2597
|
+
} else if (mockNameIsCallSignature && derivedFunctionName) {
|
|
2598
|
+
safeName = derivedFunctionName;
|
|
2599
|
+
} else {
|
|
2600
|
+
safeName = baseMockName;
|
|
2601
|
+
}
|
|
1338
2602
|
|
|
1339
2603
|
// Get any jsx-component properties that need to be preserved from the original
|
|
1340
2604
|
const jsxProperties = getJsxComponentProperties(
|