@codeyam/codeyam-cli 0.1.0-staging.e38f7bd → 0.1.0-staging.f777668
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 +36 -32
- 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 +441 -82
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.ts +129 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/stripNullableMarkers.ts +35 -0
- package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +183 -0
- package/analyzer-template/packages/ai/src/lib/deepEqual.ts +30 -0
- package/analyzer-template/packages/ai/src/lib/e2eDataTracking.ts +334 -0
- package/analyzer-template/packages/ai/src/lib/extractCriticalDataKeys.ts +120 -0
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarioData.ts +74 -7
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +89 -112
- package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +63 -2
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +1495 -101
- 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 +711 -78
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.ts +1 -1
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.ts +28 -62
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +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 +68 -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 -3
- package/analyzer-template/packages/database/src/lib/loadEntityBranches.ts +12 -0
- package/analyzer-template/packages/database/src/lib/loadReadyToBeCapturedAnalyses.ts +25 -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 +153 -144
- 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/directExecutionScript.ts +17 -2
- package/analyzer-template/packages/generate/src/lib/getComponentScenarioPath.ts +8 -3
- package/analyzer-template/packages/generate/src/lib/scenarioComponentForServer.ts +114 -0
- package/analyzer-template/packages/github/dist/database/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 +22 -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 +51 -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 -4
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js +9 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js +20 -5
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts +2 -2
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js +100 -88
- 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/directExecutionScript.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/directExecutionScript.js +10 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/directExecutionScript.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/getComponentScenarioPath.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/getComponentScenarioPath.js +7 -3
- package/analyzer-template/packages/github/dist/generate/src/lib/getComponentScenarioPath.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts +8 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js +89 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js.map +1 -0
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js +10 -0
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js +3 -0
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.d.ts +2 -2
- package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +87 -13
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts +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/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 +4 -4
- package/analyzer-template/packages/ui-components/src/components/ScenarioDetailInteractiveView.tsx +23 -7
- package/analyzer-template/packages/utils/dist/types/index.d.ts +2 -2
- package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +87 -13
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts +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 +15 -9
- package/analyzer-template/playwright/waitForServer.ts +21 -6
- package/analyzer-template/project/TESTING.md +83 -0
- package/analyzer-template/project/analyzeBaselineCommit.ts +9 -0
- package/analyzer-template/project/analyzeBranchCommit.ts +4 -0
- package/analyzer-template/project/analyzeFileEntities.ts +4 -0
- package/analyzer-template/project/analyzeRegularCommit.ts +9 -0
- package/analyzer-template/project/captureLibraryFunctionDirect.ts +29 -26
- package/analyzer-template/project/constructMockCode.ts +1459 -178
- package/analyzer-template/project/controller/startController.ts +16 -1
- package/analyzer-template/project/createEntitiesAndSortFiles.ts +83 -0
- package/analyzer-template/project/executeLibraryFunctionDirect.ts +7 -3
- package/analyzer-template/project/loadReadyToBeCaptured.ts +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 +92 -13
- 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 +75 -19
- package/analyzer-template/project/startScenarioCapture.ts +88 -41
- package/analyzer-template/project/writeClientLogRoute.ts +125 -0
- package/analyzer-template/project/writeMockDataTsx.ts +483 -73
- package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
- package/analyzer-template/project/writeScenarioComponents.ts +1538 -226
- package/analyzer-template/project/writeScenarioFiles.ts +26 -0
- package/analyzer-template/project/writeSimpleRoot.ts +56 -22
- package/analyzer-template/project/writeUniversalMocks.ts +32 -11
- package/analyzer-template/scripts/comboWorkerLoop.cjs +99 -50
- package/analyzer-template/scripts/defaultCmd.sh +9 -0
- package/analyzer-template/tsconfig.json +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 +1288 -133
- 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 +76 -14
- 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 +64 -19
- 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 +416 -62
- package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js +15 -0
- package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js.map +1 -0
- package/background/src/lib/virtualized/project/writeScenarioComponents.js +1134 -153
- package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioFiles.js +19 -0
- package/background/src/lib/virtualized/project/writeScenarioFiles.js.map +1 -1
- package/background/src/lib/virtualized/project/writeSimpleRoot.js +57 -20
- package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
- package/background/src/lib/virtualized/project/writeUniversalMocks.js +27 -12
- package/background/src/lib/virtualized/project/writeUniversalMocks.js.map +1 -1
- package/codeyam-cli/scripts/apply-setup.js +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 +39 -22
- package/codeyam-cli/src/cli.js.map +1 -1
- package/codeyam-cli/src/codeyam-cli.js +18 -2
- package/codeyam-cli/src/codeyam-cli.js.map +1 -1
- package/codeyam-cli/src/commands/analyze.js +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 +2607 -0
- package/codeyam-cli/src/commands/editor.js.map +1 -0
- package/codeyam-cli/src/commands/init.js +81 -260
- 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/test-startup.js +3 -1
- package/codeyam-cli/src/commands/test-startup.js.map +1 -1
- package/codeyam-cli/src/commands/verify.js +14 -2
- package/codeyam-cli/src/commands/verify.js.map +1 -1
- package/codeyam-cli/src/commands/wipe.js +108 -0
- package/codeyam-cli/src/commands/wipe.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/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 +127 -0
- package/codeyam-cli/src/utils/__tests__/editorApi.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorAudit.test.js +635 -0
- package/codeyam-cli/src/utils/__tests__/editorAudit.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__/editorDevServer.test.js +155 -0
- package/codeyam-cli/src/utils/__tests__/editorDevServer.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.test.js +121 -0
- package/codeyam-cli/src/utils/__tests__/editorEntityChangeStatus.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 +393 -0
- package/codeyam-cli/src/utils/__tests__/editorLoaderHelpers.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 +266 -0
- package/codeyam-cli/src/utils/__tests__/editorPreview.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 +221 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarioSwitch.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js +221 -0
- package/codeyam-cli/src/utils/__tests__/editorScenarios.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js +213 -0
- package/codeyam-cli/src/utils/__tests__/editorSeedAdapter.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/entityChangeStatus.test.js +1686 -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__/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 +101 -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__/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 +246 -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 +174 -82
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
- package/codeyam-cli/src/utils/__tests__/templateConsistency.test.js +50 -0
- package/codeyam-cli/src/utils/__tests__/templateConsistency.test.js.map +1 -0
- package/codeyam-cli/src/utils/analysisRunner.js +29 -15
- package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
- package/codeyam-cli/src/utils/analyzer.js +7 -0
- package/codeyam-cli/src/utils/analyzer.js.map +1 -1
- package/codeyam-cli/src/utils/backgroundServer.js +122 -25
- 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 +91 -5
- 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 +73 -0
- package/codeyam-cli/src/utils/editorApi.js.map +1 -0
- package/codeyam-cli/src/utils/editorAudit.js +159 -0
- package/codeyam-cli/src/utils/editorAudit.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/editorDevServer.js +109 -0
- package/codeyam-cli/src/utils/editorDevServer.js.map +1 -0
- package/codeyam-cli/src/utils/editorEntityChangeStatus.js +44 -0
- package/codeyam-cli/src/utils/editorEntityChangeStatus.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 +81 -0
- package/codeyam-cli/src/utils/editorLoaderHelpers.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 +106 -0
- package/codeyam-cli/src/utils/editorPreview.js.map +1 -0
- package/codeyam-cli/src/utils/editorScenarioSwitch.js +112 -0
- package/codeyam-cli/src/utils/editorScenarioSwitch.js.map +1 -0
- package/codeyam-cli/src/utils/editorScenarios.js +96 -0
- package/codeyam-cli/src/utils/editorScenarios.js.map +1 -0
- package/codeyam-cli/src/utils/editorSeedAdapter.js +173 -0
- package/codeyam-cli/src/utils/editorSeedAdapter.js.map +1 -0
- package/codeyam-cli/src/utils/entityChangeStatus.js +337 -0
- package/codeyam-cli/src/utils/entityChangeStatus.js.map +1 -0
- package/codeyam-cli/src/utils/entityChangeStatus.server.js +107 -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 +25 -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/install-skills.js +120 -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 +7 -0
- 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 +104 -7
- package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
- package/codeyam-cli/src/utils/queue/persistence.js.map +1 -1
- package/codeyam-cli/src/utils/requireSimulations.js +10 -0
- package/codeyam-cli/src/utils/requireSimulations.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js +82 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js +229 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js +67 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js +105 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js +34 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js +162 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js +74 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js +376 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js +113 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js +127 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js +50 -0
- package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js +116 -0
- package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/index.js +5 -0
- package/codeyam-cli/src/utils/ruleReflection/index.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js +44 -0
- package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js +85 -0
- package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/types.js +5 -0
- package/codeyam-cli/src/utils/ruleReflection/types.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/parser.test.js +83 -0
- package/codeyam-cli/src/utils/rules/__tests__/parser.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/pathMatcher.test.js +118 -0
- package/codeyam-cli/src/utils/rules/__tests__/pathMatcher.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/rulePlacement.test.js +72 -0
- package/codeyam-cli/src/utils/rules/__tests__/rulePlacement.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js +293 -0
- package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/sourceFiles.test.js +76 -0
- package/codeyam-cli/src/utils/rules/__tests__/sourceFiles.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/index.js +7 -0
- package/codeyam-cli/src/utils/rules/index.js.map +1 -0
- package/codeyam-cli/src/utils/rules/parser.js +93 -0
- package/codeyam-cli/src/utils/rules/parser.js.map +1 -0
- package/codeyam-cli/src/utils/rules/pathMatcher.js +49 -0
- package/codeyam-cli/src/utils/rules/pathMatcher.js.map +1 -0
- package/codeyam-cli/src/utils/rules/rulePlacement.js +65 -0
- package/codeyam-cli/src/utils/rules/rulePlacement.js.map +1 -0
- package/codeyam-cli/src/utils/rules/ruleState.js +150 -0
- package/codeyam-cli/src/utils/rules/ruleState.js.map +1 -0
- package/codeyam-cli/src/utils/rules/sourceFiles.js +43 -0
- package/codeyam-cli/src/utils/rules/sourceFiles.js.map +1 -0
- package/codeyam-cli/src/utils/rules/staleness.js +137 -0
- package/codeyam-cli/src/utils/rules/staleness.js.map +1 -0
- package/codeyam-cli/src/utils/scenarioMarkers.js +134 -0
- package/codeyam-cli/src/utils/scenarioMarkers.js.map +1 -0
- package/codeyam-cli/src/utils/scenariosManifest.js +112 -0
- package/codeyam-cli/src/utils/scenariosManifest.js.map +1 -0
- package/codeyam-cli/src/utils/serverState.js +64 -12
- package/codeyam-cli/src/utils/serverState.js.map +1 -1
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +95 -45
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
- package/codeyam-cli/src/utils/simulationGateMiddleware.js +159 -0
- package/codeyam-cli/src/utils/simulationGateMiddleware.js.map +1 -0
- package/codeyam-cli/src/utils/syncMocksMiddleware.js +5 -24
- package/codeyam-cli/src/utils/syncMocksMiddleware.js.map +1 -1
- package/codeyam-cli/src/utils/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 +14 -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__/dependency-smoke.test.js +66 -0
- package/codeyam-cli/src/webserver/__tests__/dependency-smoke.test.js.map +1 -0
- package/codeyam-cli/src/webserver/app/lib/database.js +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 +396 -0
- package/codeyam-cli/src/webserver/app/lib/git.js.map +1 -0
- package/codeyam-cli/src/webserver/backgroundServer.js +171 -26
- 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-DmJveP3T.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-C76mRRiF.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-kykTbcnD.js → EntityTypeBadge-g3saevPb.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-CobE682z.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-Bu6c6aDe.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-DYFW3lDD.js +25 -0
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-DLeucoVX.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/LoadingDots-BU_OAEMP.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/LogViewer-ceAyBX-H.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-djPLI-WV.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-BED4B6sP.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-ZlRKbhrq.js +10 -0
- package/codeyam-cli/src/webserver/build/client/assets/Spinner-Bb5uFQ5V.js +34 -0
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-C06nsHKY.js → TruncatedFilePath-C8OKAR5x.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/ViewportInspectBar-oAf2Kqsf.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/_index-C96V0n15.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-BpKzcsJz.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-Duc5hnl7.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-D9hemwl6.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-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-scenarios-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-D_nMCFmP.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/chevron-down-BH2h1Ea2.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/chunk-JZWAC4HX-C4pqxYJB.js +51 -0
- package/codeyam-cli/src/webserver/build/client/assets/circle-check-DyIKORY6.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/copy-NDbZjXao.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-CMT1jU2q.js +21 -0
- package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-C1gnJVOL.svg → cy-logo-cli-CCKUIm0S.svg} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DcX-ZS3p.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-CltMNppm.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/editor-DTEBHY7Z.js +10 -0
- package/codeyam-cli/src/webserver/build/client/assets/editorPreview-B7ztwLut.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-CYqBrC9s.js → entity._sha._-DItJnD8s.js} +22 -15
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.dev-D5rYBT5x.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-CF164ouH.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-p9hhkjJM.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-BMvVHNXU.js +5 -0
- package/codeyam-cli/src/webserver/build/client/assets/entry.client-DTvKq3TY.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-cPo8LiG3.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/files-DO4CZ16O.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/git-CdN8sCqs.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/globals-JMY99HpD.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-10oVnAAH.js +9 -0
- package/codeyam-cli/src/webserver/build/client/assets/index-BcvgDzbZ.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/index-yHOVb4rc.js +15 -0
- package/codeyam-cli/src/webserver/build/client/assets/labs-Zk7ryIM1.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/loader-circle-BAXYRVEO.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/manifest-7aab51c4.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-Dg0mvYrI.js +96 -0
- package/codeyam-cli/src/webserver/build/client/assets/pause-DTAcYxBt.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-FRztnN-P.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-fKo7v0Zo.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/settings-DfuTtcJP.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/simulations-B3aOzpCZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/terminal-BG4heKCG.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-DtSmdtM4.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-CrAK28Bc.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/useLastLogLine-C14nCb1q.js +2 -0
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-O-jkvSPx.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useToast-Bbf4Hokd.js → useToast-9FIWuYfK.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/xterm-BqvuqXEL.js +27 -0
- package/codeyam-cli/src/webserver/build/server/assets/index-Cz751Dm2.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-DSylnYVM.js +367 -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 +431 -0
- package/codeyam-cli/src/webserver/editorProxy.js.map +1 -0
- package/codeyam-cli/src/webserver/scripts/codeyam-preload.mjs +414 -0
- package/codeyam-cli/src/webserver/scripts/journalCapture.ts +230 -0
- package/codeyam-cli/src/webserver/server.js +293 -26
- package/codeyam-cli/src/webserver/server.js.map +1 -1
- package/codeyam-cli/src/webserver/terminalServer.js +706 -0
- package/codeyam-cli/src/webserver/terminalServer.js.map +1 -0
- package/codeyam-cli/templates/codeyam-editor-claude.md +68 -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 +208 -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/PRISMA_SETUP.md +84 -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 +19 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/app/page.tsx +10 -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 +38 -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 +37 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/prisma.config.ts +12 -0
- package/codeyam-cli/templates/nextjs-prisma-sqlite/seed-adapter.ts +89 -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/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/{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 +136 -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 +39 -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 +371 -73
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js +107 -0
- package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js.map +1 -0
- package/packages/ai/src/lib/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 +1182 -91
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarios.js +193 -83
- package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +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 +550 -62
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js +29 -34
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +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 +51 -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 -4
- package/packages/database/src/lib/loadEntities.js.map +1 -1
- package/packages/database/src/lib/loadEntityBranches.js +9 -0
- package/packages/database/src/lib/loadEntityBranches.js.map +1 -1
- package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js +20 -5
- package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
- package/packages/database/src/lib/projectToDb.js +1 -1
- package/packages/database/src/lib/projectToDb.js.map +1 -1
- package/packages/database/src/lib/saveFiles.js +1 -1
- package/packages/database/src/lib/saveFiles.js.map +1 -1
- package/packages/database/src/lib/scenarioToDb.js +1 -1
- package/packages/database/src/lib/scenarioToDb.js.map +1 -1
- package/packages/database/src/lib/updateCommitMetadata.js +100 -88
- 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/directExecutionScript.js +10 -1
- package/packages/generate/src/lib/directExecutionScript.js.map +1 -1
- package/packages/generate/src/lib/getComponentScenarioPath.js +7 -3
- package/packages/generate/src/lib/getComponentScenarioPath.js.map +1 -1
- package/packages/generate/src/lib/scenarioComponentForServer.js +89 -0
- package/packages/generate/src/lib/scenarioComponentForServer.js.map +1 -0
- package/packages/github/src/lib/loadOrCreateCommit.js +10 -0
- package/packages/github/src/lib/loadOrCreateCommit.js.map +1 -1
- package/packages/github/src/lib/syncPrimaryBranch.js +3 -0
- package/packages/github/src/lib/syncPrimaryBranch.js.map +1 -1
- package/packages/process/index.js +3 -0
- package/packages/process/index.js.map +1 -0
- package/packages/process/src/GlobalProcessManager.js.map +1 -0
- package/{background/src/lib/process → packages/process/src}/ProcessManager.js +1 -1
- package/packages/process/src/ProcessManager.js.map +1 -0
- package/packages/process/src/index.js.map +1 -0
- package/packages/process/src/managedExecAsync.js.map +1 -0
- package/packages/types/index.js.map +1 -1
- package/packages/utils/src/lib/applyUniversalMocks.js +26 -2
- package/packages/utils/src/lib/applyUniversalMocks.js.map +1 -1
- package/packages/utils/src/lib/fs/rsyncCopy.js +98 -3
- package/packages/utils/src/lib/fs/rsyncCopy.js.map +1 -1
- package/packages/utils/src/lib/lightweightEntityExtractor.js +25 -0
- package/packages/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
- package/packages/utils/src/lib/safeFileName.js +29 -3
- package/packages/utils/src/lib/safeFileName.js.map +1 -1
- package/scripts/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/ai/src/lib/transformMockDataToMatchSchema.ts +0 -156
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +0 -115
- package/analyzer-template/process/INTEGRATION_COMPLETE.md +0 -333
- package/analyzer-template/process/INTEGRATION_EXAMPLE.md +0 -525
- package/analyzer-template/process/README.md +0 -507
- package/background/src/lib/process/GlobalProcessManager.js.map +0 -1
- package/background/src/lib/process/ProcessManager.js.map +0 -1
- package/background/src/lib/process/index.js.map +0 -1
- package/background/src/lib/process/managedExecAsync.js.map +0 -1
- package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js +0 -238
- package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js.map +0 -1
- package/codeyam-cli/src/commands/detect-universal-mocks.js +0 -118
- package/codeyam-cli/src/commands/detect-universal-mocks.js.map +0 -1
- package/codeyam-cli/src/commands/list.js +0 -31
- package/codeyam-cli/src/commands/list.js.map +0 -1
- package/codeyam-cli/src/commands/webapp-info.js +0 -146
- package/codeyam-cli/src/commands/webapp-info.js.map +0 -1
- package/codeyam-cli/src/utils/universal-mocks.js +0 -152
- package/codeyam-cli/src/utils/universal-mocks.js.map +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-D4htqD-x.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-Catz6XEN.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-TlHocYno.js +0 -26
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-CVMmGuIc.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/LogViewer-JkfQ-VaI.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-CVZ0H4BL.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-BrMAP1nP.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-CJhE4cCv.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/_index-faVIcr_i.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-CLMa2sgx.js +0 -7
- package/codeyam-cli/src/webserver/build/client/assets/chevron-down-DwYjrK_h.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/chunk-WWGJGFF6-CgXbbZRx.js +0 -26
- package/codeyam-cli/src/webserver/build/client/assets/circle-check-B2oHQ-zo.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-BBYuR56H.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-CT0Q5lVu.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-Bj5GHkhb.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-eW5z9AyZ.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/entry.client-B9tSboXM.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-CmO-EZAB.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-DLinnTOx.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/git-CIxwBQvb.js +0 -12
- package/codeyam-cli/src/webserver/build/client/assets/globals-xPz593l2.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-XQCGvadH.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/index-_LjBsTxX.js +0 -8
- package/codeyam-cli/src/webserver/build/client/assets/loader-circle-D_EGChhq.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-ca438c41.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/root-CHHYHuzL.js +0 -16
- package/codeyam-cli/src/webserver/build/client/assets/search-DY8yoDpH.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/server-build-CMKNK2uU.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/settings-BT6wVHd5.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/simulations-gv3H7JV7.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-BthANBVv.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useLastLogLine-Blr5oZDE.js +0 -2
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-CANr3QJ5.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-BtBPtyHx.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-N2cTnejq.js +0 -166
- package/codeyam-cli/templates/codeyam-stop-hook.sh +0 -284
- package/codeyam-cli/templates/debug-command.md +0 -141
- package/packages/ai/src/lib/findMatchingAttribute.js +0 -77
- package/packages/ai/src/lib/findMatchingAttribute.js.map +0 -1
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +0 -136
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +0 -220
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateEntityKeyAttributes.js +0 -241
- package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/isFrontend.js +0 -5
- package/packages/ai/src/lib/isFrontend.js.map +0 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js +0 -40
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js.map +0 -1
- package/packages/ai/src/lib/transformMockDataToMatchSchema.js +0 -124
- package/packages/ai/src/lib/transformMockDataToMatchSchema.js.map +0 -1
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +0 -72
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +0 -1
- package/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
|
@@ -1,4 +1,94 @@
|
|
|
1
1
|
import { joinParenthesesAndArrays, splitOutsideParenthesesAndArrays, functionArguments, cleanOutBoundary, fillInDirectSchemaGapsAndUnknowns, removeDuplicateFunctionCalls, } from "../../../../../packages/ai/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Converts a call signature to a valid JavaScript identifier (function name).
|
|
4
|
+
* The original signature is preserved for data access - this only creates the function name.
|
|
5
|
+
*
|
|
6
|
+
* Examples:
|
|
7
|
+
* - "useAuth()" → "useAuth"
|
|
8
|
+
* - "db.select(usersQuery)" → "db_select_usersQuery"
|
|
9
|
+
* - "db.select(postsQuery)" → "db_select_postsQuery"
|
|
10
|
+
* - "useFetcher<User>()" → "useFetcher_User"
|
|
11
|
+
* - "useFetcher<{ data: UserData | null }>()" → "useFetcher_data_UserData_null"
|
|
12
|
+
* - "eq('user_id', value)" → "eq_user_id_value"
|
|
13
|
+
* - "from('workouts')" → "from_workouts"
|
|
14
|
+
*/
|
|
15
|
+
function callSignatureToFunctionName(signature) {
|
|
16
|
+
// Extract components from the signature
|
|
17
|
+
const components = [];
|
|
18
|
+
// 1. Extract function path (parts separated by dots outside parens/brackets)
|
|
19
|
+
const pathMatch = signature.match(/^([^<(]+)/);
|
|
20
|
+
if (pathMatch) {
|
|
21
|
+
const path = pathMatch[1];
|
|
22
|
+
// Split on dots but preserve the parts
|
|
23
|
+
components.push(...path.split('.').filter(Boolean));
|
|
24
|
+
}
|
|
25
|
+
// 2. Extract generic type parameters (content between < and >)
|
|
26
|
+
const genericMatch = signature.match(/<([^>]+)>/);
|
|
27
|
+
if (genericMatch) {
|
|
28
|
+
const genericContent = genericMatch[1];
|
|
29
|
+
// Extract meaningful identifiers from generic type
|
|
30
|
+
// Handle complex types like "{ data: UserData | null }"
|
|
31
|
+
const typeIdentifiers = genericContent
|
|
32
|
+
.replace(/[{}:;,]/g, ' ') // Remove structural chars
|
|
33
|
+
.replace(/\|/g, ' ') // Handle union types
|
|
34
|
+
.split(/\s+/)
|
|
35
|
+
.filter(Boolean)
|
|
36
|
+
.filter((s) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(s)) // Only valid identifiers
|
|
37
|
+
.filter((s) => ![
|
|
38
|
+
'null',
|
|
39
|
+
'undefined',
|
|
40
|
+
'void',
|
|
41
|
+
'never',
|
|
42
|
+
'any',
|
|
43
|
+
'unknown',
|
|
44
|
+
'data',
|
|
45
|
+
'typeof',
|
|
46
|
+
].includes(s)); // Skip common non-meaningful keywords
|
|
47
|
+
if (typeIdentifiers.length > 0) {
|
|
48
|
+
components.push(...typeIdentifiers.slice(0, 2)); // Limit to first 2 for reasonable length
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// 3. Extract function arguments (first 2 for disambiguation)
|
|
52
|
+
const argsMatch = signature.match(/\(([^)]*)\)/);
|
|
53
|
+
if (argsMatch && argsMatch[1]) {
|
|
54
|
+
const argsContent = argsMatch[1].trim();
|
|
55
|
+
if (argsContent) {
|
|
56
|
+
const args = argsContent.split(',').map((arg) => arg.trim());
|
|
57
|
+
for (const arg of args.slice(0, 2)) {
|
|
58
|
+
// For quoted strings, extract the content
|
|
59
|
+
const stringMatch = arg.match(/^['"`](.+)['"`]$/);
|
|
60
|
+
if (stringMatch) {
|
|
61
|
+
// Split on dots for string paths like 'users.id'
|
|
62
|
+
const parts = stringMatch[1].split('.').filter(Boolean);
|
|
63
|
+
components.push(...parts);
|
|
64
|
+
}
|
|
65
|
+
else if (/^[A-Za-z_][A-Za-z0-9_]*$/.test(arg)) {
|
|
66
|
+
// Valid identifier - use as-is
|
|
67
|
+
components.push(arg);
|
|
68
|
+
}
|
|
69
|
+
else if (/^\d+$/.test(arg)) {
|
|
70
|
+
// Number - use as-is
|
|
71
|
+
components.push(arg);
|
|
72
|
+
}
|
|
73
|
+
// Skip complex expressions
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// Build the function name from components
|
|
78
|
+
const functionName = components
|
|
79
|
+
.join('_')
|
|
80
|
+
.replace(/[^a-zA-Z0-9_]/g, '_') // Sanitize special chars
|
|
81
|
+
.replace(/_+/g, '_') // Collapse multiple underscores
|
|
82
|
+
.replace(/^_|_$/g, ''); // Trim underscores
|
|
83
|
+
return functionName || 'mock';
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Check if a mock name is a call signature (e.g., "useFetcher<User>()", "db.select(query)")
|
|
87
|
+
*/
|
|
88
|
+
function isCallSignature(mockName) {
|
|
89
|
+
// Call signatures contain parentheses (function calls)
|
|
90
|
+
return mockName.includes('(');
|
|
91
|
+
}
|
|
2
92
|
/**
|
|
3
93
|
* Extract property names that are jsx-components and should be preserved from original.
|
|
4
94
|
* These are paths like "MockName.Provider()" where the value or functionCallReturnValue is 'jsx-component'.
|
|
@@ -125,50 +215,54 @@ function funcArgs(functionSignature) {
|
|
|
125
215
|
}
|
|
126
216
|
// isValidKey ensures that the key does not contain any characters that would make it invalid in a JavaScript object.
|
|
127
217
|
// For example, it should not contain spaces, special characters, or start with a number.
|
|
218
|
+
// Also rejects keys that are pure function calls like "()" or "(args)" - these aren't property names.
|
|
128
219
|
function isValidKey(key) {
|
|
129
220
|
if (!key || key.length === 0)
|
|
130
221
|
return false;
|
|
131
222
|
const keyWithOutArguments = key.split('(')[0];
|
|
223
|
+
// Reject empty keys (happens when key is "()" or "(args)") - these are function calls, not property names
|
|
224
|
+
if (!keyWithOutArguments || keyWithOutArguments.length === 0)
|
|
225
|
+
return false;
|
|
132
226
|
return !/\s/.test(keyWithOutArguments);
|
|
133
227
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
228
|
+
/**
|
|
229
|
+
* Known hooks that return tuples [value, setter] instead of arrays.
|
|
230
|
+
* These should NOT use the .map() pattern even when the schema has generic array access ([]).
|
|
231
|
+
* Instead, they should return [data, () => {}] where data is from scenarios().
|
|
232
|
+
*/
|
|
233
|
+
const TUPLE_RETURNING_HOOKS = new Set([
|
|
234
|
+
'useAtom', // Jotai
|
|
235
|
+
'useState', // React
|
|
236
|
+
'useReducer', // React
|
|
237
|
+
'useRecoilState', // Recoil
|
|
238
|
+
'useImmerAtom', // Jotai with Immer
|
|
239
|
+
]);
|
|
240
|
+
export default function constructMockCode(mockName, dependencySchemas, entityType, _canonicalKey, // DEPRECATED: No longer used, kept for API compatibility
|
|
241
|
+
options) {
|
|
242
|
+
// Check if mockName is a call signature (e.g., "useFetcher<User>()", "db.select(query)")
|
|
243
|
+
const mockNameIsCallSignature = isCallSignature(mockName);
|
|
244
|
+
// For call signatures, use the original signature for data access but generate
|
|
245
|
+
// a valid JS function name from it
|
|
246
|
+
const derivedFunctionName = mockNameIsCallSignature
|
|
247
|
+
? callSignatureToFunctionName(mockName)
|
|
140
248
|
: null;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
249
|
+
// The baseMockName is the function name without type params and args
|
|
250
|
+
// e.g., "useFetcher<User>()" -> "useFetcher", "db.select(query)" -> "db"
|
|
251
|
+
const baseMockName = mockName.split(/[<(]/)[0];
|
|
252
|
+
// The data key is the mockName (call signature) for data access
|
|
253
|
+
let dataKey;
|
|
144
254
|
const mockNameParts = splitOutsideParenthesesAndArrays(baseMockName);
|
|
145
255
|
let relevantReturnValueSchema;
|
|
146
256
|
let dataStructurePath;
|
|
147
257
|
let dataStructureValue;
|
|
148
258
|
let foundEntityWithSignature = false;
|
|
149
259
|
let signatureSchema;
|
|
150
|
-
|
|
260
|
+
let baseSchemaHasMethodCalls = false;
|
|
261
|
+
entitySearch: for (const filePath in dependencySchemas) {
|
|
151
262
|
for (const entityName in dependencySchemas[filePath]) {
|
|
152
|
-
//
|
|
153
|
-
|
|
154
|
-
const
|
|
155
|
-
? `${variableQualifier} <- ${baseMockName}`
|
|
156
|
-
: mockNameParts[0];
|
|
157
|
-
// Check for direct match
|
|
158
|
-
let matches = entityName === targetEntityName || entityName === mockNameParts[0];
|
|
159
|
-
// If no direct match and no qualifier was provided, check if the entity
|
|
160
|
-
// is stored under a variable-qualified key (e.g., "stateBadge <- getStateBadge")
|
|
161
|
-
// This handles the case where gatherDataForMocks stored the entity with a variable
|
|
162
|
-
// qualifier but writeScenarioComponents called constructMockCode without one.
|
|
163
|
-
if (!matches && !variableQualifier) {
|
|
164
|
-
const qualifiedKeyMatch = entityName.match(new RegExp(`^([a-zA-Z_][a-zA-Z0-9_]*)\\s*<-\\s*${mockNameParts[0]}$`));
|
|
165
|
-
if (qualifiedKeyMatch) {
|
|
166
|
-
matches = true;
|
|
167
|
-
// Extract the variable qualifier from the entity name so we can use
|
|
168
|
-
// it for the data lookup key later
|
|
169
|
-
variableQualifier = qualifiedKeyMatch[1];
|
|
170
|
-
}
|
|
171
|
-
}
|
|
263
|
+
// Match entity by base name (without generics/args)
|
|
264
|
+
const entityBaseName = entityName.split(/[<(]/)[0];
|
|
265
|
+
const matches = entityBaseName === baseMockName || entityName === mockNameParts[0];
|
|
172
266
|
if (!matches)
|
|
173
267
|
continue;
|
|
174
268
|
// Track if we found the entity and it has a signature (is a function)
|
|
@@ -188,18 +282,87 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
188
282
|
pathParts[mockNameParts.length - 1].startsWith(mockNameParts[mockNameParts.length - 1]));
|
|
189
283
|
});
|
|
190
284
|
if (dataStructurePath) {
|
|
285
|
+
// Start with the base entity's return value schema
|
|
286
|
+
const baseReturnValueSchema = dependencySchemas[filePath][entityName]?.returnValueSchema;
|
|
287
|
+
const mergedSchema = {
|
|
288
|
+
...baseReturnValueSchema,
|
|
289
|
+
};
|
|
290
|
+
// Check if the base schema has method-call entries (e.g., .map().functionCallReturnValue)
|
|
291
|
+
// When it does, the scenario data is stored as an object with method keys, and
|
|
292
|
+
// array prototype methods need mock implementations. When it doesn't, the data
|
|
293
|
+
// is a raw array and native methods like .includes() work directly.
|
|
294
|
+
if (baseReturnValueSchema) {
|
|
295
|
+
baseSchemaHasMethodCalls = Object.keys(baseReturnValueSchema).some((k) => k.startsWith(baseMockName + '.') &&
|
|
296
|
+
k.includes('(') &&
|
|
297
|
+
k.includes('.functionCallReturnValue'));
|
|
298
|
+
}
|
|
299
|
+
// Merge in method-call dependencies that are separate entries.
|
|
300
|
+
// e.g., "activityTypes.find((a) => a.value === type)" is a separate dependency
|
|
301
|
+
// for a .find() call on activityTypes. We need to include these with a
|
|
302
|
+
// .functionCallReturnValue path so constructMockCode generates callable mock methods.
|
|
303
|
+
for (const otherEntityName in dependencySchemas[filePath]) {
|
|
304
|
+
if (otherEntityName === entityName)
|
|
305
|
+
continue;
|
|
306
|
+
if (otherEntityName.startsWith(baseMockName + '.') &&
|
|
307
|
+
otherEntityName.includes('(')) {
|
|
308
|
+
// Add a functionCallReturnValue entry for this method call.
|
|
309
|
+
// This ensures constructMockCode treats it as a function that returns data,
|
|
310
|
+
// generating a proper mock method with data lookup.
|
|
311
|
+
const fcrvPath = `${otherEntityName}.functionCallReturnValue`;
|
|
312
|
+
if (!mergedSchema[fcrvPath]) {
|
|
313
|
+
// Infer the return type from the method-call dependency's schema
|
|
314
|
+
const otherSchema = dependencySchemas[filePath][otherEntityName]?.returnValueSchema;
|
|
315
|
+
// Look for element type (baseMockName[]) or fall back to 'unknown'
|
|
316
|
+
const elementType = otherSchema?.[`${baseMockName}[]`];
|
|
317
|
+
mergedSchema[fcrvPath] = elementType || 'unknown';
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
191
321
|
relevantReturnValueSchema = fillInDirectSchemaGapsAndUnknowns({
|
|
192
|
-
schema:
|
|
322
|
+
schema: mergedSchema,
|
|
193
323
|
});
|
|
194
324
|
// NOTE: clearAttributesFromMapping is disabled because it deletes
|
|
195
325
|
// method calls on arrays (like .eq() after functionCallReturnValue: 'array')
|
|
196
326
|
// However, we still need to remove duplicate function calls that create invalid syntax
|
|
197
327
|
removeDuplicateFunctionCalls(relevantReturnValueSchema);
|
|
198
328
|
dataStructureValue = relevantReturnValueSchema?.[dataStructurePath];
|
|
199
|
-
break;
|
|
329
|
+
break entitySearch;
|
|
200
330
|
}
|
|
201
331
|
}
|
|
202
332
|
}
|
|
333
|
+
// Check if the entity is used as a function (called with ()) vs an object/namespace.
|
|
334
|
+
// Look for paths in the schema that start with "baseMockName(" or "baseMockName<" indicating function calls.
|
|
335
|
+
// The "<" handles generic type parameters like useLoaderData<T>().
|
|
336
|
+
// Also check dataStructurePath === 'returnValue' which indicates a function return value.
|
|
337
|
+
const entityIsFunction = foundEntityWithSignature ||
|
|
338
|
+
dataStructurePath === 'returnValue' ||
|
|
339
|
+
Object.keys(relevantReturnValueSchema ?? {}).some((key) => key.startsWith(`${baseMockName}(`) ||
|
|
340
|
+
key.startsWith(`${baseMockName}<`));
|
|
341
|
+
// Calculate the data key - use the call signature (mockName) for data access
|
|
342
|
+
// For simple names without parentheses:
|
|
343
|
+
// - Append () ONLY if the entity is a function/hook (detected above)
|
|
344
|
+
// - Don't append () for object/namespace mocks like "supabase"
|
|
345
|
+
if (mockNameIsCallSignature || mockName.includes('(')) {
|
|
346
|
+
dataKey = mockName;
|
|
347
|
+
}
|
|
348
|
+
else if (entityIsFunction) {
|
|
349
|
+
// Entity is a function/hook - append () to match call signature format
|
|
350
|
+
dataKey = `${mockName}()`;
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
// Entity is an object/namespace - use bare name as key
|
|
354
|
+
dataKey = mockName;
|
|
355
|
+
}
|
|
356
|
+
// Helper to wrap key in appropriate quotes for computed property access
|
|
357
|
+
// Use single quotes when key contains double quotes to avoid syntax errors
|
|
358
|
+
const quotePropertyKey = (key) => {
|
|
359
|
+
const escaped = key.replace(/\n/g, '\\n');
|
|
360
|
+
if (escaped.includes('"')) {
|
|
361
|
+
// Use single quotes, escaping any single quotes in the key
|
|
362
|
+
return `['${escaped.replace(/'/g, "\\'")}']`;
|
|
363
|
+
}
|
|
364
|
+
return `["${escaped}"]`;
|
|
365
|
+
};
|
|
203
366
|
// Check if the return value schema only contains function type markers
|
|
204
367
|
// (e.g., "validateInputs()": "function") without actual return data
|
|
205
368
|
// (no functionCallReturnValue entries)
|
|
@@ -222,9 +385,14 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
222
385
|
// Count the number of arguments from signature schema
|
|
223
386
|
const argCount = Object.keys(signatureSchema).filter((key) => key.startsWith('signature[')).length;
|
|
224
387
|
const args = Array.from({ length: argCount }, (_, i) => `arg${i + 1}`);
|
|
388
|
+
// Always add ...rest to accept extra arguments beyond the signature
|
|
389
|
+
args.push('...rest');
|
|
225
390
|
const argsString = args.join(', ');
|
|
226
391
|
// Generate empty mock function
|
|
227
|
-
|
|
392
|
+
// Use baseMockName (not mockName) because mockName may contain a full call
|
|
393
|
+
// signature with argument expressions (e.g., "logSignOutAction(sessionUser.id, ...)")
|
|
394
|
+
// which would produce invalid syntax as function parameter names.
|
|
395
|
+
return `function ${baseMockName}(${argsString}) {
|
|
228
396
|
// Empty mock - original function mocked out
|
|
229
397
|
}`;
|
|
230
398
|
}
|
|
@@ -240,9 +408,35 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
240
408
|
!hasMeaningfulReturnData(relevantReturnValueSchema)) {
|
|
241
409
|
const argCount = Object.keys(signatureSchema).filter((key) => key.startsWith('signature[')).length;
|
|
242
410
|
const args = Array.from({ length: argCount }, (_, i) => `arg${i + 1}`);
|
|
411
|
+
// Always add ...rest to accept extra arguments beyond the signature
|
|
412
|
+
args.push('...rest');
|
|
243
413
|
const argsString = args.join(', ');
|
|
414
|
+
// Check for Higher-Order Component (HOC) pattern:
|
|
415
|
+
// - First argument is a function (component) or unknown (couldn't trace type)
|
|
416
|
+
// - Returns a function
|
|
417
|
+
// HOCs like memo, forwardRef, createContext should return their first argument
|
|
418
|
+
//
|
|
419
|
+
// The return value key can be either:
|
|
420
|
+
// - 'memo()' (clean format)
|
|
421
|
+
// - 'memo(({ value, width }: Props) => { ... })' (full component code format)
|
|
422
|
+
const firstArgIsFunctionOrUnknown = signatureSchema['signature[0]'] === 'function' ||
|
|
423
|
+
signatureSchema['signature[0]'] === 'unknown';
|
|
424
|
+
const returnsFunction = relevantReturnValueSchema
|
|
425
|
+
? Object.entries(relevantReturnValueSchema).some(([key, value]) => {
|
|
426
|
+
// Check if key represents a function call that returns a function
|
|
427
|
+
// Key should start with the mock name, contain '(', end with ')', and have value 'function'
|
|
428
|
+
const isFunctionCall = key.startsWith(mockName + '(') && key.endsWith(')');
|
|
429
|
+
return isFunctionCall && value === 'function';
|
|
430
|
+
})
|
|
431
|
+
: false;
|
|
432
|
+
if (firstArgIsFunctionOrUnknown && returnsFunction) {
|
|
433
|
+
// HOC pattern detected - return the first argument
|
|
434
|
+
return `function ${baseMockName}(${argsString}) {
|
|
435
|
+
return arg1;
|
|
436
|
+
}`;
|
|
437
|
+
}
|
|
244
438
|
// Generate empty mock function
|
|
245
|
-
return `function ${
|
|
439
|
+
return `function ${baseMockName}(${argsString}) {
|
|
246
440
|
// Empty mock - original function mocked out
|
|
247
441
|
}`;
|
|
248
442
|
}
|
|
@@ -257,6 +451,87 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
257
451
|
const pathDepth = splitOutsideParenthesesAndArrays(dataStructurePath).length;
|
|
258
452
|
const isRootArray = dataStructureValue === 'array' &&
|
|
259
453
|
(dataStructurePath === 'returnValue' || pathDepth <= mockNameParts.length);
|
|
454
|
+
// OPTIMIZATION: Early return for tuple-returning hooks (useAtom, useState, etc.)
|
|
455
|
+
// These hooks have simple [value, setter] return patterns that don't need the full
|
|
456
|
+
// 9216-key schema processing. Check if this is a tuple-returning hook and generate
|
|
457
|
+
// the mock code directly without iterating over all schema keys.
|
|
458
|
+
if (TUPLE_RETURNING_HOOKS.has(baseMockName) && isFunction) {
|
|
459
|
+
// Check if schema has generic array pattern (indicates tuple return like [value, setter])
|
|
460
|
+
const schemaKeys = Object.keys(relevantReturnValueSchema ?? {});
|
|
461
|
+
const hasGenericArrayInSchema = schemaKeys.some((k) => k.includes('.functionCallReturnValue[]') ||
|
|
462
|
+
k === `${dataKey}.functionCallReturnValue[]` ||
|
|
463
|
+
k === 'returnValue[]');
|
|
464
|
+
// Check for differentiated tuple indices (e.g., functionCallReturnValue[2], [3]) which would NOT be a standard tuple
|
|
465
|
+
// We only check indices immediately after functionCallReturnValue, not nested indices like signature[2]
|
|
466
|
+
const tupleHasDifferentiatedIndices = schemaKeys.some((k) => {
|
|
467
|
+
// Look for .functionCallReturnValue[N] where N >= 2
|
|
468
|
+
const match = k.match(/\.functionCallReturnValue\[(\d+)\]/);
|
|
469
|
+
if (!match)
|
|
470
|
+
return false;
|
|
471
|
+
const idx = parseInt(match[1], 10);
|
|
472
|
+
return idx >= 2;
|
|
473
|
+
});
|
|
474
|
+
const isTupleReturningHook = hasGenericArrayInSchema && !tupleHasDifferentiatedIndices;
|
|
475
|
+
if (isTupleReturningHook) {
|
|
476
|
+
// Find all call patterns for this hook (e.g., useAtom(quoteFilterAtom), useAtom(supplierAtom))
|
|
477
|
+
const hookCallPatterns = Object.keys(relevantReturnValueSchema ?? {})
|
|
478
|
+
.filter((k) => {
|
|
479
|
+
const regex = new RegExp(`^${baseMockName}\\([^)]+\\)$`);
|
|
480
|
+
return regex.test(k);
|
|
481
|
+
})
|
|
482
|
+
.map((k) => {
|
|
483
|
+
const match = k.match(/\(([^)]+)\)/);
|
|
484
|
+
return { key: k, arg: match?.[1] ?? '' };
|
|
485
|
+
});
|
|
486
|
+
let tupleReturnCode;
|
|
487
|
+
if (hookCallPatterns.length > 1) {
|
|
488
|
+
// Multiple patterns - generate conditional dispatch
|
|
489
|
+
const conditions = hookCallPatterns
|
|
490
|
+
.map(({ key, arg }) => `if (argLabel === '${arg}' || argStr.includes('${arg}')) {\n return [scenarios().data()?.["${key}"]?.[0] ?? [], () => {}];\n }`)
|
|
491
|
+
.join('\n ');
|
|
492
|
+
const fallbackKey = hookCallPatterns[0]?.key ?? dataKey;
|
|
493
|
+
tupleReturnCode = `(() => {
|
|
494
|
+
// Dynamic dispatch for tuple-returning hook with multiple argument patterns
|
|
495
|
+
const argLabel = args[0]?.debugLabel ?? '';
|
|
496
|
+
const argStr = args[0]?.toString?.() ?? String(args[0] ?? '');
|
|
497
|
+
${conditions}
|
|
498
|
+
return [scenarios().data()?.["${fallbackKey}"]?.[0] ?? [], () => {}];
|
|
499
|
+
})()`;
|
|
500
|
+
}
|
|
501
|
+
else {
|
|
502
|
+
// Single or no patterns - use dynamic dispatch
|
|
503
|
+
const fallbackKey = hookCallPatterns[0]?.key ?? `${baseMockName}()`;
|
|
504
|
+
tupleReturnCode = `(() => {
|
|
505
|
+
// Dynamic dispatch for tuple-returning hook
|
|
506
|
+
const argLabel = args[0]?.debugLabel ?? '';
|
|
507
|
+
const argStr = args[0]?.toString?.() ?? '';
|
|
508
|
+
const allData = scenarios().data() ?? {};
|
|
509
|
+
if (argLabel) {
|
|
510
|
+
const labelKey = '${baseMockName}(' + argLabel + ')';
|
|
511
|
+
if (allData[labelKey]) {
|
|
512
|
+
return [allData[labelKey]?.[0] ?? [], () => {}];
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
const keys = Object.keys(allData).filter(k => k.startsWith('${baseMockName}('));
|
|
516
|
+
for (const key of keys) {
|
|
517
|
+
const keyArg = key.slice(${baseMockName.length + 1}, -1);
|
|
518
|
+
if (argStr.includes(keyArg)) {
|
|
519
|
+
return [allData[key]?.[0] ?? [], () => {}];
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
return [allData[keys[0] ?? '${fallbackKey}']?.[0] ?? [], () => {}];
|
|
523
|
+
})()`;
|
|
524
|
+
}
|
|
525
|
+
const safeFunctionName = options?.uniqueFunctionSuffix
|
|
526
|
+
? `${baseMockName}_${options.uniqueFunctionSuffix}`
|
|
527
|
+
: options?.keepOriginalFunctionName
|
|
528
|
+
? baseMockName
|
|
529
|
+
: mockNameIsCallSignature && derivedFunctionName
|
|
530
|
+
? derivedFunctionName
|
|
531
|
+
: baseMockName;
|
|
532
|
+
return `function ${safeFunctionName}(...args) {\n return ${tupleReturnCode};\n}`;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
260
535
|
const returnValueParts = {
|
|
261
536
|
name: dataStructureName,
|
|
262
537
|
isArray: isRootArray,
|
|
@@ -277,18 +552,19 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
277
552
|
// Strip type parameters like <typeof loader> from function names
|
|
278
553
|
// so "useLoaderData<typeof loader>()" becomes "useLoaderData()"
|
|
279
554
|
name = cleanOutTypes(name);
|
|
280
|
-
// For
|
|
281
|
-
// This
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
//
|
|
285
|
-
|
|
286
|
-
|
|
555
|
+
// For root data access, use the dataKey (original call signature or canonical key)
|
|
556
|
+
// This preserves the original call signature for LLM clarity
|
|
557
|
+
if (isRootAccess) {
|
|
558
|
+
// For call signature format, use the original mockName as the data key
|
|
559
|
+
// e.g., scenarios().data()?.["useFetcher<User>()"]
|
|
560
|
+
// e.g., scenarios().data()?.["db.select(usersQuery)"]
|
|
561
|
+
return `?.${quotePropertyKey(dataKey)}`;
|
|
287
562
|
}
|
|
288
|
-
|
|
563
|
+
// Only use unquoted array access syntax for pure array indices like [0], [1]
|
|
564
|
+
if (name.match(/^\[\d+\]$/)) {
|
|
289
565
|
return `?.${name}`;
|
|
290
566
|
}
|
|
291
|
-
return
|
|
567
|
+
return `?.${quotePropertyKey(name)}`;
|
|
292
568
|
};
|
|
293
569
|
const constructDataPaths = () => {
|
|
294
570
|
// For structural elements, return modified base paths for children
|
|
@@ -300,17 +576,23 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
300
576
|
return [];
|
|
301
577
|
}
|
|
302
578
|
const addReturnValueFunctionAccessor = (dataPath) => {
|
|
303
|
-
// Add function call accessor if:
|
|
304
|
-
// - There are actual arguments, OR
|
|
305
|
-
// - This is a callable (not a method that returns an array directly)
|
|
306
|
-
// For methods like getAll() that return arrays, the data is at ["getAll()"] not ["getAll()"]["()"]
|
|
307
579
|
if (returnValue.returnsFunctionArgs &&
|
|
308
580
|
(returnValue.returnsFunctionArgs.length > 0 ||
|
|
309
581
|
!returnValue.returnsFunctionArray)) {
|
|
310
582
|
if (returnValue.isArray) {
|
|
311
583
|
dataPath = `${dataPath}${optionalAccess('[0]')}`;
|
|
312
584
|
}
|
|
313
|
-
|
|
585
|
+
// Only add the function call accessor ?.["(args)"] when there are actual
|
|
586
|
+
// arguments. When returnsFunctionArgs is empty [] (function-returns-function
|
|
587
|
+
// with no specific arg patterns), skip the ?.["()"] because:
|
|
588
|
+
// 1. preprocessSchemaForMocks collapses nested functionCallReturnValue chains
|
|
589
|
+
// into flat entries (e.g., getTranslate() = string, not {(): string})
|
|
590
|
+
// 2. The mock data is a flat value, so ?.["()"] on a string returns undefined
|
|
591
|
+
// 3. constructContent still wraps the return in a function (via returnsFunctionArgs)
|
|
592
|
+
// so the function-returns-function behavior is preserved without data nesting
|
|
593
|
+
if (returnValue.returnsFunctionArgs.length > 0) {
|
|
594
|
+
dataPath = `${dataPath}${optionalAccess(`(${safeString(returnValue.returnsFunctionArgs.join(', '))})`)}`;
|
|
595
|
+
}
|
|
314
596
|
}
|
|
315
597
|
return dataPath;
|
|
316
598
|
};
|
|
@@ -336,10 +618,6 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
336
618
|
};
|
|
337
619
|
const constructContent = (dataPaths) => {
|
|
338
620
|
const { name, args, nested, isArray, isGenericArray, returnsFunctionArgs, returnsFunctionArray, isAsyncFunction, hasNoReturnData, } = returnValue;
|
|
339
|
-
const nestedContent = (nested ?? []).map((nestedItem) => {
|
|
340
|
-
const nestedContent = constructReturnValueString(nestedItem, dataPaths);
|
|
341
|
-
return nestedContent;
|
|
342
|
-
});
|
|
343
621
|
// Array prototype methods that should be ignored when building mocks
|
|
344
622
|
// (these work on any array - we don't need to mock them)
|
|
345
623
|
const ARRAY_PROTOTYPE_METHODS = new Set([
|
|
@@ -383,6 +661,36 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
383
661
|
'with',
|
|
384
662
|
'length',
|
|
385
663
|
]);
|
|
664
|
+
// When an array has differentiated indices ([0], [1], etc.), filter out any
|
|
665
|
+
// non-index items from nested. These non-index items come from generic [] paths
|
|
666
|
+
// like [].filter or [].sort, which describe element properties, not array elements.
|
|
667
|
+
// Including them would generate invalid syntax like "sort: ..." inside an array literal.
|
|
668
|
+
const hasDifferentiatedIndices = isArray &&
|
|
669
|
+
nested &&
|
|
670
|
+
nested.some((n) => n.name.match(/^\[\d+\]$/) && n.name !== '[0]');
|
|
671
|
+
let filteredNested = hasDifferentiatedIndices && nested
|
|
672
|
+
? nested.filter((n) => n.name.match(/^\[\d+\]$/))
|
|
673
|
+
: nested;
|
|
674
|
+
// When a variable IS an array (not a function returning an array),
|
|
675
|
+
// filter out array prototype methods like .includes(), .filter(), etc.
|
|
676
|
+
// ONLY when the base schema has no method-call entries. When the base
|
|
677
|
+
// schema has methods (e.g., .map().functionCallReturnValue), the scenario
|
|
678
|
+
// data is stored as an object with method-call keys, and ALL methods
|
|
679
|
+
// need mock implementations. When the base schema has no methods, the
|
|
680
|
+
// data is a raw array and native methods like .includes() work directly.
|
|
681
|
+
if (isArray &&
|
|
682
|
+
!returnsFunctionArray &&
|
|
683
|
+
!baseSchemaHasMethodCalls &&
|
|
684
|
+
filteredNested) {
|
|
685
|
+
filteredNested = filteredNested.filter((n) => {
|
|
686
|
+
const methodName = n.name.replace(/[<(].*$/, '');
|
|
687
|
+
return !ARRAY_PROTOTYPE_METHODS.has(methodName);
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
const nestedContent = (filteredNested ?? []).map((nestedItem) => {
|
|
691
|
+
const nestedContent = constructReturnValueString(nestedItem, dataPaths);
|
|
692
|
+
return nestedContent;
|
|
693
|
+
});
|
|
386
694
|
const levelContentItems = [];
|
|
387
695
|
// Add spread for data paths when:
|
|
388
696
|
// - Not a function returning an array, OR function returns array with custom methods
|
|
@@ -410,52 +718,110 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
410
718
|
(!returnValue.isStructural || isStructuralArrayElementWithNested)) {
|
|
411
719
|
levelContentItems.push(...dataPaths.map((path) => `...${path}`));
|
|
412
720
|
}
|
|
413
|
-
|
|
721
|
+
// Filter out nested content that would be invalid as object properties
|
|
722
|
+
// (e.g., bare arrow functions like "() => {...}" without a property name)
|
|
723
|
+
// Only apply this filter when building object content, not array content.
|
|
724
|
+
// Bare arrow functions ARE valid as array elements (like [0] = {...}, [1] = () => {...})
|
|
725
|
+
// Check both isArray (item IS an array) and returnsFunctionArray (item returns an array)
|
|
726
|
+
const inArrayContext = isArray || returnsFunctionArray;
|
|
727
|
+
const validNestedContent = nestedContent.filter((content) => {
|
|
728
|
+
if (!content)
|
|
729
|
+
return false;
|
|
730
|
+
// Only filter bare arrow functions when NOT in array context
|
|
731
|
+
// In arrays, bare arrow functions are valid elements
|
|
732
|
+
if (!inArrayContext && content.match(/^\s*\([^)]*\)\s*=>/)) {
|
|
733
|
+
return false;
|
|
734
|
+
}
|
|
735
|
+
return true;
|
|
736
|
+
});
|
|
737
|
+
levelContentItems.push(...validNestedContent);
|
|
414
738
|
let levelContents = levelContentItems.filter(Boolean).join(',\n');
|
|
415
739
|
if (returnsFunctionArgs) {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
740
|
+
// When returnsFunctionArgs is empty [] OR has a single literal string argument,
|
|
741
|
+
// the function returns a callable function (e.g., getTranslate() returns t,
|
|
742
|
+
// where t('key') looks up translations)
|
|
743
|
+
// Generate a dispatch function that looks up keys based on the argument
|
|
744
|
+
//
|
|
745
|
+
// Detect translation-like pattern:
|
|
746
|
+
// - Data path ends with ["('some.literal')"] - a literal string key
|
|
747
|
+
// - This means the mock data has keys like "('common.surveys')": "Surveys"
|
|
748
|
+
// - Exclude ["()"] which is an empty function call (not a translation pattern)
|
|
749
|
+
const dataPath = dataPaths[0];
|
|
750
|
+
// Pattern matches ?.["('...')"] at end of path, but NOT ?.["()"] (empty args)
|
|
751
|
+
const literalKeyPattern = dataPath?.match(/\?\.\["\('.+'\)"\]$/);
|
|
752
|
+
if (!returnsFunctionArray &&
|
|
753
|
+
dataPaths.length === 1 &&
|
|
754
|
+
literalKeyPattern // Only dispatch when there's a literal key pattern
|
|
755
|
+
) {
|
|
756
|
+
// Function returns a function - generate dispatch function
|
|
757
|
+
// Strip the literal key from the path and use dynamic lookup
|
|
758
|
+
const dataPathBase = literalKeyPattern
|
|
759
|
+
? dataPath.replace(/\?\.\["\('.+'\)"\]$/, '')
|
|
760
|
+
: dataPath;
|
|
761
|
+
const funcContents = `return ${dataPathBase}?.[\`('\${arg1}')\`]`;
|
|
762
|
+
levelContents = `(arg1) => {\n${indent(funcContents)}\n}`;
|
|
763
|
+
if (!isArray) {
|
|
764
|
+
return levelContents;
|
|
435
765
|
}
|
|
436
766
|
}
|
|
437
767
|
else {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
768
|
+
const argsString = returnsFunctionArgs
|
|
769
|
+
.map((_, index) => `arg${index + 1}`)
|
|
770
|
+
.join(', ');
|
|
771
|
+
let funcContents = '';
|
|
772
|
+
if (returnsFunctionArray) {
|
|
773
|
+
if (hasNoReturnData) {
|
|
444
774
|
// Function has no return data (only signatures) - return empty array
|
|
445
775
|
funcContents = 'return []';
|
|
446
776
|
}
|
|
447
|
-
else {
|
|
448
|
-
//
|
|
777
|
+
else if (levelContents.length === 0 && dataPaths.length === 1) {
|
|
778
|
+
// When returning an array with no nested content, return the data path directly
|
|
779
|
+
// (the data path points to the array in scenario data)
|
|
449
780
|
funcContents = `return ${dataPaths[0]}`;
|
|
450
781
|
}
|
|
782
|
+
else if (levelContents.length === 0) {
|
|
783
|
+
funcContents = 'return []';
|
|
784
|
+
}
|
|
785
|
+
else {
|
|
786
|
+
funcContents = `return [\n${indent(levelContents)}\n]`;
|
|
787
|
+
}
|
|
451
788
|
}
|
|
452
789
|
else {
|
|
453
|
-
|
|
790
|
+
// Check if function has no actual return data (only signatures)
|
|
791
|
+
const hasNestedItems = nested && nested.length > 0;
|
|
792
|
+
const hasActualNestedContent = nestedContent.filter(Boolean).length > 0;
|
|
793
|
+
if (levelContentItems.length === 1 && dataPaths.length === 1) {
|
|
794
|
+
if (hasNoReturnData ||
|
|
795
|
+
(hasNestedItems && !hasActualNestedContent)) {
|
|
796
|
+
// Function has no return data (only signatures) - return empty array
|
|
797
|
+
funcContents = 'return []';
|
|
798
|
+
}
|
|
799
|
+
else {
|
|
800
|
+
// Has return data - return data path
|
|
801
|
+
funcContents = `return ${dataPaths[0]}`;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
else {
|
|
805
|
+
funcContents = `return {\n${indent(levelContents)}\n}`;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
levelContents = `(${argsString}) => {\n${indent(funcContents)}\n}`;
|
|
809
|
+
if (!isArray) {
|
|
810
|
+
return levelContents;
|
|
454
811
|
}
|
|
455
812
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
813
|
+
// For generic arrays of functions WITH nested properties (e.g., functionCallReturnValue[] = "function"
|
|
814
|
+
// with nested .filter, .sort, etc.), the levelContents would be a bare arrow function "() => {...}"
|
|
815
|
+
// that wraps object content. Using this in a .map(({...})) creates invalid syntax like "({ () => {...} })".
|
|
816
|
+
// When isGenericArray is true AND there are nested properties, we're accessing data from the elements,
|
|
817
|
+
// not calling them - so skip the function wrapping.
|
|
818
|
+
// But if there are NO nested properties, keep the wrapper because callers may want to call the elements.
|
|
819
|
+
const hasNonStructuralNestedItems = nested &&
|
|
820
|
+
nested.length > 0 &&
|
|
821
|
+
nested.some((n) => !n.name.match(/^\[\d*\]$/));
|
|
822
|
+
if (isGenericArray && hasNonStructuralNestedItems) {
|
|
823
|
+
// Skip the arrow function wrapper - just use the nested content directly
|
|
824
|
+
levelContents = levelContentItems.filter(Boolean).join(',\n');
|
|
459
825
|
}
|
|
460
826
|
}
|
|
461
827
|
// Check if all nested items are array prototype methods
|
|
@@ -468,7 +834,102 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
468
834
|
return ARRAY_PROTOTYPE_METHODS.has(methodName);
|
|
469
835
|
});
|
|
470
836
|
let returnValueContents = '';
|
|
471
|
-
if (
|
|
837
|
+
// Check if this is a known tuple-returning hook (useAtom, useState, etc.)
|
|
838
|
+
// These should return [value, setter] tuples, not arrays or data paths
|
|
839
|
+
// Check isGenericArray from current context OR from schema for root level calls
|
|
840
|
+
// (at root level, isGenericArray might not be set yet but the schema contains [] pattern)
|
|
841
|
+
const hasGenericArrayInSchema = root &&
|
|
842
|
+
TUPLE_RETURNING_HOOKS.has(baseMockName) &&
|
|
843
|
+
Object.keys(relevantReturnValueSchema ?? {}).some((k) => k.includes('.functionCallReturnValue[]'));
|
|
844
|
+
// Check if there are array indices beyond what a standard 2-element tuple would have
|
|
845
|
+
// For tuple-returning hooks, [0] and [1] are expected (value and setter)
|
|
846
|
+
// Only consider it "differentiated" if there are indices >= 2 (e.g., [2], [3])
|
|
847
|
+
const tupleHasDifferentiatedIndices = nested?.some((n) => {
|
|
848
|
+
const indexMatch = n.name.match(/^\[(\d+)\]$/);
|
|
849
|
+
if (!indexMatch)
|
|
850
|
+
return false;
|
|
851
|
+
const index = parseInt(indexMatch[1], 10);
|
|
852
|
+
return index >= 2;
|
|
853
|
+
});
|
|
854
|
+
const isTupleReturningHook = TUPLE_RETURNING_HOOKS.has(baseMockName) &&
|
|
855
|
+
(isGenericArray || hasGenericArrayInSchema) &&
|
|
856
|
+
!tupleHasDifferentiatedIndices;
|
|
857
|
+
// Debug logging for tuple-returning hooks
|
|
858
|
+
if (TUPLE_RETURNING_HOOKS.has(baseMockName) && root) {
|
|
859
|
+
const schemaKeys = Object.keys(relevantReturnValueSchema ?? {});
|
|
860
|
+
const hasArrayPattern = schemaKeys.some((k) => k.includes('.functionCallReturnValue[]'));
|
|
861
|
+
console.log(`CodeYam: Tuple hook check for ${baseMockName} (root):`, `hasGenericArrayInSchema=${hasGenericArrayInSchema}`, `hasArrayPattern=${hasArrayPattern}`, `tupleHasDifferentiatedIndices=${tupleHasDifferentiatedIndices}`, `isTupleReturningHook=${isTupleReturningHook}`, `schemaKeysSample=${schemaKeys.slice(0, 5).join(', ')}`);
|
|
862
|
+
}
|
|
863
|
+
if (isTupleReturningHook) {
|
|
864
|
+
// Tuple-returning hooks should return [value, setter] tuple
|
|
865
|
+
// The value is the first element from scenarios data, setter is a no-op
|
|
866
|
+
// Default to [] when data is undefined to prevent errors like ".includes is not a function"
|
|
867
|
+
// Check if there are multiple call patterns for this hook in the schema
|
|
868
|
+
// (e.g., useAtom(quoteFilterAtom) and useAtom(supplierAtom))
|
|
869
|
+
const hookCallPatterns = Object.keys(relevantReturnValueSchema ?? {})
|
|
870
|
+
.filter((k) => {
|
|
871
|
+
// Match patterns like "useAtom(someArg)" but not nested paths like "useAtom(x).foo"
|
|
872
|
+
const regex = new RegExp(`^${baseMockName}\\([^)]+\\)$`);
|
|
873
|
+
return regex.test(k);
|
|
874
|
+
})
|
|
875
|
+
.map((k) => {
|
|
876
|
+
// Extract the argument from the key like "useAtom(quoteFilterAtom)" -> "quoteFilterAtom"
|
|
877
|
+
const match = k.match(/\(([^)]+)\)/);
|
|
878
|
+
return { key: k, arg: match?.[1] ?? '' };
|
|
879
|
+
});
|
|
880
|
+
if (hookCallPatterns.length > 1) {
|
|
881
|
+
// Multiple patterns - generate conditional dispatch based on first argument
|
|
882
|
+
// For Jotai atoms, we use debugLabel; for others, we try to match the argument string
|
|
883
|
+
const conditions = hookCallPatterns
|
|
884
|
+
.map(({ key, arg }) => `if (argLabel === '${arg}' || argStr.includes('${arg}')) {\n return [scenarios().data()?.["${key}"]?.[0] ?? [], () => {}];\n }`)
|
|
885
|
+
.join('\n ');
|
|
886
|
+
// Use the first pattern as fallback
|
|
887
|
+
const fallbackKey = hookCallPatterns[0]?.key ?? dataKey;
|
|
888
|
+
returnValueContents = `(() => {
|
|
889
|
+
// Dynamic dispatch for tuple-returning hook with multiple argument patterns
|
|
890
|
+
const argLabel = args[0]?.debugLabel ?? '';
|
|
891
|
+
const argStr = args[0]?.toString?.() ?? String(args[0] ?? '');
|
|
892
|
+
${conditions}
|
|
893
|
+
// Fallback to first pattern
|
|
894
|
+
return [scenarios().data()?.["${fallbackKey}"]?.[0] ?? [], () => {}];
|
|
895
|
+
})()`;
|
|
896
|
+
}
|
|
897
|
+
else {
|
|
898
|
+
// Single pattern or no patterns - use dynamic dispatch to handle case where
|
|
899
|
+
// the mock is used with different atoms than what was captured in the schema.
|
|
900
|
+
// Use the first argument to construct the data key dynamically.
|
|
901
|
+
const fallbackKey = hookCallPatterns[0]?.key ?? `${baseMockName}()`;
|
|
902
|
+
returnValueContents = `(() => {
|
|
903
|
+
// Dynamic dispatch for tuple-returning hook
|
|
904
|
+
// Try to construct key from argument's debugLabel (Jotai atoms) or toString
|
|
905
|
+
const argLabel = args[0]?.debugLabel ?? '';
|
|
906
|
+
const argStr = args[0]?.toString?.() ?? '';
|
|
907
|
+
const allData = scenarios().data() ?? {};
|
|
908
|
+
|
|
909
|
+
// Try to find a matching key using debugLabel first
|
|
910
|
+
if (argLabel) {
|
|
911
|
+
const labelKey = '${baseMockName}(' + argLabel + ')';
|
|
912
|
+
if (allData[labelKey]) {
|
|
913
|
+
return [allData[labelKey]?.[0] ?? [], () => {}];
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
// Try to find any matching key that contains part of the argument string
|
|
918
|
+
const keys = Object.keys(allData).filter(k => k.startsWith('${baseMockName}('));
|
|
919
|
+
for (const key of keys) {
|
|
920
|
+
const keyArg = key.slice(${baseMockName.length + 1}, -1);
|
|
921
|
+
if (argStr.includes(keyArg)) {
|
|
922
|
+
return [allData[key]?.[0] ?? [], () => {}];
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
// Fallback to first matching key or default
|
|
927
|
+
const fallback = keys[0] ?? '${fallbackKey}';
|
|
928
|
+
return [allData[fallback]?.[0] ?? [], () => {}];
|
|
929
|
+
})()`;
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
else if (!returnsFunctionArgs &&
|
|
472
933
|
nestedContent.length === 0 &&
|
|
473
934
|
dataPaths.length === 1) {
|
|
474
935
|
returnValueContents = dataPaths[0];
|
|
@@ -487,20 +948,368 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
487
948
|
// When GENERIC array (using []) has nested content (like functions that need wrapping),
|
|
488
949
|
// use .map() to transform ALL elements instead of just creating [0]
|
|
489
950
|
// For DIFFERENTIATED arrays (using [0], [1], etc.), keep the static array structure
|
|
951
|
+
//
|
|
952
|
+
// IMPORTANT: If the nested content contains differentiated indices like [0], [1],
|
|
953
|
+
// we MUST use static array pattern, not .map(). The presence of differentiated
|
|
954
|
+
// indices means the array elements have different types/structures, so .map()
|
|
955
|
+
// would generate invalid code trying to treat them uniformly.
|
|
956
|
+
const hasDifferentiatedIndices = nested &&
|
|
957
|
+
nested.some((n) => n.name.match(/^\[\d+\]$/) && n.name !== '[0]');
|
|
490
958
|
if (isGenericArray &&
|
|
491
959
|
nestedContent.length > 0 &&
|
|
492
|
-
dataPaths.length > 0
|
|
960
|
+
dataPaths.length > 0 &&
|
|
961
|
+
!hasDifferentiatedIndices) {
|
|
493
962
|
// Get the array base path (without the [0])
|
|
494
963
|
const arrayBasePath = dataPaths[0].replace(/\?\.\[0\]$/, '');
|
|
495
964
|
// Replace [0] references with [__idx__] in level contents
|
|
496
|
-
|
|
965
|
+
let mappedContents = levelContents.replace(/\?\.\[0\]/g, '?.[__idx__]');
|
|
497
966
|
// levelContents may already be wrapped in {...} from structural [0] element,
|
|
498
967
|
// so check if we need to add the wrapper or not
|
|
499
968
|
const needsWrapper = !mappedContents.trim().startsWith('{');
|
|
969
|
+
// Helper to check if a position is inside a string literal
|
|
970
|
+
// Returns the end position of the string if inside one, -1 otherwise
|
|
971
|
+
// Defined here so it's accessible in both needsWrapper branches
|
|
972
|
+
const skipStringLiteral = (content, pos) => {
|
|
973
|
+
const char = content[pos];
|
|
974
|
+
if (char !== '"' && char !== "'" && char !== '`')
|
|
975
|
+
return -1;
|
|
976
|
+
// Find the matching closing quote
|
|
977
|
+
let j = pos + 1;
|
|
978
|
+
while (j < content.length) {
|
|
979
|
+
if (content[j] === '\\') {
|
|
980
|
+
j += 2; // Skip escaped character
|
|
981
|
+
continue;
|
|
982
|
+
}
|
|
983
|
+
if (content[j] === char) {
|
|
984
|
+
return j + 1; // Return position after closing quote
|
|
985
|
+
}
|
|
986
|
+
j++;
|
|
987
|
+
}
|
|
988
|
+
return content.length; // Unclosed string, skip to end
|
|
989
|
+
};
|
|
990
|
+
// Filter out bare arrow functions which are invalid as object properties.
|
|
991
|
+
// Arrow functions can be multi-line, so we need to match the entire function body, not just the first line.
|
|
992
|
+
// Pattern: starts with "(args) =>", followed by either:
|
|
993
|
+
// - A single-line body: "() => expression"
|
|
994
|
+
// - A multi-line body: "() => { ... }" (with matching braces)
|
|
995
|
+
// IMPORTANT: Only filter BARE arrow functions (without property names).
|
|
996
|
+
// "() => {...}" is invalid, but "get: (arg1) => {...}" is valid.
|
|
997
|
+
// We use a function to properly handle nested braces.
|
|
998
|
+
// Defined here so it's accessible in both needsWrapper branches
|
|
999
|
+
const filterOutArrowFunctions = (content) => {
|
|
1000
|
+
const result = [];
|
|
1001
|
+
let i = 0;
|
|
1002
|
+
while (i < content.length) {
|
|
1003
|
+
// Skip over string literals entirely
|
|
1004
|
+
const stringEnd = skipStringLiteral(content, i);
|
|
1005
|
+
if (stringEnd !== -1) {
|
|
1006
|
+
result.push(content.slice(i, stringEnd));
|
|
1007
|
+
i = stringEnd;
|
|
1008
|
+
continue;
|
|
1009
|
+
}
|
|
1010
|
+
// Check if we're at the start of an arrow function (with optional leading whitespace)
|
|
1011
|
+
const arrowMatch = content
|
|
1012
|
+
.slice(i)
|
|
1013
|
+
.match(/^(\s*)\([^)]*\)\s*=>\s*/);
|
|
1014
|
+
if (arrowMatch) {
|
|
1015
|
+
// Check if this is a bare arrow function or a named property with arrow function value
|
|
1016
|
+
// Look back to see if there's a "key:" pattern before this position
|
|
1017
|
+
const before = content.slice(0, i);
|
|
1018
|
+
const beforeTrimmed = before.trim();
|
|
1019
|
+
// Valid patterns where arrow function is NOT bare:
|
|
1020
|
+
// 1. Property value: "key: (arg) => ..." - ends with ':'
|
|
1021
|
+
// 2. Function argument: ".map((arg) => ..." - ends with '('
|
|
1022
|
+
// 3. Method call: "?.map" followed directly by the arrow function
|
|
1023
|
+
// In this case, the '(' is consumed by the arrow function regex match,
|
|
1024
|
+
// so beforeTrimmed ends with the method name (e.g., 'map'), not '('.
|
|
1025
|
+
// We detect this by checking if beforeTrimmed ends with an identifier
|
|
1026
|
+
// that could be a method name (preceded by '.' or '?.').
|
|
1027
|
+
// NOTE: We don't include ',' because "{ prop, () => {} }" is invalid
|
|
1028
|
+
// (can't distinguish function argument from object property context)
|
|
1029
|
+
const isPropertyValue = beforeTrimmed.endsWith(':');
|
|
1030
|
+
const isFunctionArg = beforeTrimmed.endsWith('(');
|
|
1031
|
+
// Check if before ends with a method call pattern like ".map" or "?.map"
|
|
1032
|
+
// The '(' after the method name is consumed by the arrow function regex
|
|
1033
|
+
const isMethodCallArg = /\??\.\w+$/.test(beforeTrimmed);
|
|
1034
|
+
const hasPropertyName = isPropertyValue || isFunctionArg || isMethodCallArg;
|
|
1035
|
+
if (!hasPropertyName) {
|
|
1036
|
+
// This is a bare arrow function - filter it out
|
|
1037
|
+
// Found arrow function start, need to find its end
|
|
1038
|
+
const afterArrow = i + arrowMatch[0].length;
|
|
1039
|
+
if (content[afterArrow] === '{') {
|
|
1040
|
+
// Multi-line arrow function - find matching closing brace
|
|
1041
|
+
// Must respect string literals when counting braces
|
|
1042
|
+
let braceCount = 1;
|
|
1043
|
+
let j = afterArrow + 1;
|
|
1044
|
+
while (j < content.length && braceCount > 0) {
|
|
1045
|
+
const strEnd = skipStringLiteral(content, j);
|
|
1046
|
+
if (strEnd !== -1) {
|
|
1047
|
+
j = strEnd;
|
|
1048
|
+
continue;
|
|
1049
|
+
}
|
|
1050
|
+
if (content[j] === '{')
|
|
1051
|
+
braceCount++;
|
|
1052
|
+
if (content[j] === '}')
|
|
1053
|
+
braceCount--;
|
|
1054
|
+
j++;
|
|
1055
|
+
}
|
|
1056
|
+
// Skip past the arrow function
|
|
1057
|
+
i = j;
|
|
1058
|
+
// Only skip trailing comma, keep newlines
|
|
1059
|
+
while (i < content.length && content[i] === ' ') {
|
|
1060
|
+
i++;
|
|
1061
|
+
}
|
|
1062
|
+
if (content[i] === ',') {
|
|
1063
|
+
i++; // Skip the comma after the arrow function
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
else {
|
|
1067
|
+
// Single expression arrow function - skip to next comma or newline
|
|
1068
|
+
let j = afterArrow;
|
|
1069
|
+
while (j < content.length &&
|
|
1070
|
+
content[j] !== ',' &&
|
|
1071
|
+
content[j] !== '\n') {
|
|
1072
|
+
j++;
|
|
1073
|
+
}
|
|
1074
|
+
i = j;
|
|
1075
|
+
if (content[i] === ',')
|
|
1076
|
+
i++; // Skip the comma
|
|
1077
|
+
}
|
|
1078
|
+
continue;
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
// Not a bare arrow function, keep this character
|
|
1082
|
+
result.push(content[i]);
|
|
1083
|
+
i++;
|
|
1084
|
+
}
|
|
1085
|
+
return result.join('');
|
|
1086
|
+
};
|
|
1087
|
+
// Filter out bare object blocks (e.g., "{ ...spread, props }," without a property name)
|
|
1088
|
+
// These are invalid in object literal context - you need "key: { ... }" not just "{ ... }"
|
|
1089
|
+
// Defined here so it's accessible in both needsWrapper branches
|
|
1090
|
+
// The skipFirstBrace parameter allows the else branch to preserve the outer object
|
|
1091
|
+
const filterOutBareObjects = (content, skipFirstBrace = false) => {
|
|
1092
|
+
const result = [];
|
|
1093
|
+
let i = 0;
|
|
1094
|
+
let firstBraceSkipped = false;
|
|
1095
|
+
while (i < content.length) {
|
|
1096
|
+
// Skip over string literals entirely - braces inside strings should not be processed
|
|
1097
|
+
const stringEnd = skipStringLiteral(content, i);
|
|
1098
|
+
if (stringEnd !== -1) {
|
|
1099
|
+
result.push(content.slice(i, stringEnd));
|
|
1100
|
+
i = stringEnd;
|
|
1101
|
+
continue;
|
|
1102
|
+
}
|
|
1103
|
+
// Check if we're at a bare object start (newline/comma followed by { without : before it)
|
|
1104
|
+
// Look back to see if there's a colon (property assignment) before this brace
|
|
1105
|
+
const isStartOfLine = i === 0 ||
|
|
1106
|
+
content[i - 1] === '\n' ||
|
|
1107
|
+
content.slice(0, i).trim().endsWith(',');
|
|
1108
|
+
if (content[i] === '{' && isStartOfLine) {
|
|
1109
|
+
// Check if this is actually a bare object (not "key: {")
|
|
1110
|
+
const beforeTrimmed = content.slice(0, i).trim();
|
|
1111
|
+
const isBareObject = beforeTrimmed.endsWith(',') ||
|
|
1112
|
+
beforeTrimmed === '' ||
|
|
1113
|
+
beforeTrimmed.endsWith('(');
|
|
1114
|
+
if (isBareObject) {
|
|
1115
|
+
// If skipFirstBrace is true and this is the first bare brace at position 0,
|
|
1116
|
+
// don't filter it - it's the intentional outer object wrapper
|
|
1117
|
+
if (skipFirstBrace && !firstBraceSkipped && i === 0) {
|
|
1118
|
+
firstBraceSkipped = true;
|
|
1119
|
+
result.push(content[i]);
|
|
1120
|
+
i++;
|
|
1121
|
+
continue;
|
|
1122
|
+
}
|
|
1123
|
+
// Find matching closing brace, respecting string literals
|
|
1124
|
+
let braceCount = 1;
|
|
1125
|
+
let j = i + 1;
|
|
1126
|
+
while (j < content.length && braceCount > 0) {
|
|
1127
|
+
const strEnd = skipStringLiteral(content, j);
|
|
1128
|
+
if (strEnd !== -1) {
|
|
1129
|
+
j = strEnd;
|
|
1130
|
+
continue;
|
|
1131
|
+
}
|
|
1132
|
+
if (content[j] === '{')
|
|
1133
|
+
braceCount++;
|
|
1134
|
+
if (content[j] === '}')
|
|
1135
|
+
braceCount--;
|
|
1136
|
+
j++;
|
|
1137
|
+
}
|
|
1138
|
+
// Skip past the object
|
|
1139
|
+
i = j;
|
|
1140
|
+
// Skip trailing comma
|
|
1141
|
+
while (i < content.length && content[i] === ' ') {
|
|
1142
|
+
i++;
|
|
1143
|
+
}
|
|
1144
|
+
if (content[i] === ',') {
|
|
1145
|
+
i++;
|
|
1146
|
+
}
|
|
1147
|
+
continue;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
result.push(content[i]);
|
|
1151
|
+
i++;
|
|
1152
|
+
}
|
|
1153
|
+
return result.join('');
|
|
1154
|
+
};
|
|
1155
|
+
// Helper to clean up formatting issues after filtering
|
|
1156
|
+
const cleanupContent = (content) => {
|
|
1157
|
+
return (content
|
|
1158
|
+
.replace(/,\s*,/g, ',') // Double commas
|
|
1159
|
+
.replace(/,(\s*\n\s*\})/g, '$1') // Trailing comma before closing brace
|
|
1160
|
+
.replace(/\{\s*\n\s*,/g, '{\n') // Leading comma after opening brace
|
|
1161
|
+
// Remove incomplete .map calls where callback was filtered out
|
|
1162
|
+
// Pattern: ".map" followed by newline/whitespace without "(" for args
|
|
1163
|
+
.replace(/\?\.map(?=\s*[\n\r,}\]])/g, '')
|
|
1164
|
+
.replace(/\.map(?=\s*[\n\r,}\]])/g, '')
|
|
1165
|
+
// Clean up orphan })) sequences (from nested filtered map callbacks)
|
|
1166
|
+
.replace(/\s*\}\)\)\s*\n\s*\}/g, '\n}')
|
|
1167
|
+
.replace(/^\s*\n/gm, '') // Empty lines
|
|
1168
|
+
.trim());
|
|
1169
|
+
};
|
|
500
1170
|
if (needsWrapper) {
|
|
501
|
-
|
|
1171
|
+
// Apply filters to remove invalid content
|
|
1172
|
+
mappedContents = filterOutArrowFunctions(mappedContents);
|
|
1173
|
+
mappedContents = filterOutBareObjects(mappedContents);
|
|
1174
|
+
mappedContents = cleanupContent(mappedContents);
|
|
1175
|
+
// If mappedContents is empty after filtering, don't generate .map() at all
|
|
1176
|
+
// Just use the array path directly with spread or as-is
|
|
1177
|
+
// This prevents orphan )) from empty .map() callbacks
|
|
1178
|
+
const cleanedForEmptyCheck = mappedContents
|
|
1179
|
+
.replace(/\s+/g, '')
|
|
1180
|
+
.replace(/,+/g, '');
|
|
1181
|
+
if (cleanedForEmptyCheck.length === 0) {
|
|
1182
|
+
// Content is empty - just return the array directly
|
|
1183
|
+
returnValueContents = arrayBasePath;
|
|
1184
|
+
}
|
|
1185
|
+
else {
|
|
1186
|
+
// Check if mappedContents is just a bare expression (no property names)
|
|
1187
|
+
// A bare expression like "scenarios().data()?.["key"]?.[__idx__]," cannot be
|
|
1188
|
+
// wrapped in ({ }) because it's not a valid object property.
|
|
1189
|
+
// Pattern: content has no ":" that's not inside brackets/parens/strings
|
|
1190
|
+
const hasBareExpression = (() => {
|
|
1191
|
+
const trimmed = mappedContents.trim().replace(/,\s*$/, ''); // Remove trailing comma
|
|
1192
|
+
let depth = 0;
|
|
1193
|
+
let inString = false;
|
|
1194
|
+
let stringChar = '';
|
|
1195
|
+
for (let i = 0; i < trimmed.length; i++) {
|
|
1196
|
+
const char = trimmed[i];
|
|
1197
|
+
if (inString) {
|
|
1198
|
+
if (char === '\\') {
|
|
1199
|
+
i++; // Skip escaped char
|
|
1200
|
+
continue;
|
|
1201
|
+
}
|
|
1202
|
+
if (char === stringChar) {
|
|
1203
|
+
inString = false;
|
|
1204
|
+
}
|
|
1205
|
+
continue;
|
|
1206
|
+
}
|
|
1207
|
+
if (char === '"' || char === "'" || char === '`') {
|
|
1208
|
+
inString = true;
|
|
1209
|
+
stringChar = char;
|
|
1210
|
+
continue;
|
|
1211
|
+
}
|
|
1212
|
+
if (char === '(' || char === '[' || char === '{') {
|
|
1213
|
+
depth++;
|
|
1214
|
+
continue;
|
|
1215
|
+
}
|
|
1216
|
+
if (char === ')' || char === ']' || char === '}') {
|
|
1217
|
+
depth--;
|
|
1218
|
+
continue;
|
|
1219
|
+
}
|
|
1220
|
+
// Found a colon at depth 0 = has property name
|
|
1221
|
+
if (char === ':' && depth === 0) {
|
|
1222
|
+
return false;
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
return true;
|
|
1226
|
+
})();
|
|
1227
|
+
if (hasBareExpression) {
|
|
1228
|
+
// Content is just an expression - return it directly without object wrapper
|
|
1229
|
+
const trimmedContent = mappedContents
|
|
1230
|
+
.trim()
|
|
1231
|
+
.replace(/,\s*$/, '');
|
|
1232
|
+
returnValueContents = `${arrayBasePath}?.map((__item__, __idx__) => (\n${indent(trimmedContent)}\n))`;
|
|
1233
|
+
}
|
|
1234
|
+
else {
|
|
1235
|
+
// When generating object-wrapped .map(), ensure original item data is preserved.
|
|
1236
|
+
// If no data spread was included (e.g., because this is a plain array property,
|
|
1237
|
+
// not a function return), add ...__item__ to spread the original item properties.
|
|
1238
|
+
// Without this, the .map() would create new objects with only nested function
|
|
1239
|
+
// properties, losing data like filePath, frontmatter, body, etc.
|
|
1240
|
+
const hasDataSpread = mappedContents.includes('...scenarios()') ||
|
|
1241
|
+
mappedContents.includes('...__item__');
|
|
1242
|
+
if (!hasDataSpread) {
|
|
1243
|
+
mappedContents = `...__item__,\n${mappedContents}`;
|
|
1244
|
+
}
|
|
1245
|
+
returnValueContents = `${arrayBasePath}?.map((__item__, __idx__) => ({\n${indent(mappedContents)}\n}))`;
|
|
1246
|
+
}
|
|
1247
|
+
} // Close the empty content check else block
|
|
502
1248
|
}
|
|
503
1249
|
else {
|
|
1250
|
+
// Content already starts with '{'. Check if there are additional properties after the inner object.
|
|
1251
|
+
// If so, we need to merge them INTO the object, not leave them outside.
|
|
1252
|
+
// Pattern: "{ ...spread, props },\nfilter: ...,\nsort: ..."
|
|
1253
|
+
// Should become: "{ ...spread, props, filter: ..., sort: ... }"
|
|
1254
|
+
const trimmed = mappedContents.trim();
|
|
1255
|
+
// Find first }, at depth 0 that is NOT inside a string literal
|
|
1256
|
+
// This prevents splitting keys like ?.["useQuery({ id }, { enabled })"]
|
|
1257
|
+
// and also prevents finding }, inside nested arrow functions
|
|
1258
|
+
const findBraceCommaOutsideStrings = (content) => {
|
|
1259
|
+
let i = 0;
|
|
1260
|
+
let depth = 0; // Track brace depth to find the outer object's },
|
|
1261
|
+
while (i < content.length - 1) {
|
|
1262
|
+
// Skip over string literals
|
|
1263
|
+
const strEnd = skipStringLiteral(content, i);
|
|
1264
|
+
if (strEnd !== -1) {
|
|
1265
|
+
i = strEnd;
|
|
1266
|
+
continue;
|
|
1267
|
+
}
|
|
1268
|
+
// Track brace depth
|
|
1269
|
+
if (content[i] === '{') {
|
|
1270
|
+
depth++;
|
|
1271
|
+
i++;
|
|
1272
|
+
continue;
|
|
1273
|
+
}
|
|
1274
|
+
// Check for }, pattern at depth 1 (the outer object level)
|
|
1275
|
+
// We're looking for the outer object's closing brace, which is at depth 1
|
|
1276
|
+
// (we started at depth 0, opened { at depth 0 -> 1)
|
|
1277
|
+
if (content[i] === '}') {
|
|
1278
|
+
depth--;
|
|
1279
|
+
if (depth === 0 &&
|
|
1280
|
+
i + 1 < content.length &&
|
|
1281
|
+
content[i + 1] === ',') {
|
|
1282
|
+
return i;
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
i++;
|
|
1286
|
+
}
|
|
1287
|
+
return -1;
|
|
1288
|
+
};
|
|
1289
|
+
const firstBraceEnd = findBraceCommaOutsideStrings(trimmed);
|
|
1290
|
+
if (firstBraceEnd !== -1) {
|
|
1291
|
+
// Found pattern "{ ... }," followed by more content
|
|
1292
|
+
// Extract the inner object and the trailing properties
|
|
1293
|
+
const innerObject = trimmed.slice(0, firstBraceEnd);
|
|
1294
|
+
const trailingContent = trimmed.slice(firstBraceEnd + 2).trim();
|
|
1295
|
+
if (trailingContent) {
|
|
1296
|
+
// Merge trailing properties into the inner object
|
|
1297
|
+
mappedContents = `${innerObject},\n${trailingContent}\n}`;
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
// Even when content starts with {, we need to filter out invalid properties inside
|
|
1301
|
+
// (arrow functions and bare objects that were generated from the schema)
|
|
1302
|
+
// Pass skipFirstBrace=true because the content's outer { is the intentional wrapper
|
|
1303
|
+
mappedContents = filterOutArrowFunctions(mappedContents);
|
|
1304
|
+
mappedContents = filterOutBareObjects(mappedContents, true);
|
|
1305
|
+
mappedContents = cleanupContent(mappedContents);
|
|
1306
|
+
// Same as needsWrapper branch: ensure item data is preserved in .map()
|
|
1307
|
+
const hasDataSpreadInner = mappedContents.includes('...scenarios()') ||
|
|
1308
|
+
mappedContents.includes('...__item__');
|
|
1309
|
+
if (!hasDataSpreadInner && mappedContents.trim().length > 0) {
|
|
1310
|
+
// Insert ...__item__ after the opening brace
|
|
1311
|
+
mappedContents = mappedContents.replace(/^\s*\{/, '{\n...__item__,');
|
|
1312
|
+
}
|
|
504
1313
|
returnValueContents = `${arrayBasePath}?.map((__item__, __idx__) => (\n${indent(mappedContents)}\n))`;
|
|
505
1314
|
}
|
|
506
1315
|
}
|
|
@@ -509,7 +1318,36 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
509
1318
|
}
|
|
510
1319
|
}
|
|
511
1320
|
else {
|
|
512
|
-
|
|
1321
|
+
// When we have a single data path and nested content that creates an object structure,
|
|
1322
|
+
// and we're NOT at the root level, we need to handle the case where the parent data
|
|
1323
|
+
// value is null or undefined. Without this check, `{ ...null, prop: null?.["prop"] }`
|
|
1324
|
+
// creates `{ prop: undefined }` instead of `null`, causing errors like
|
|
1325
|
+
// "Cannot read properties of undefined (reading 'some')" when code does
|
|
1326
|
+
// data?.prop.some(...) because data is an object with prop: undefined, not null.
|
|
1327
|
+
// We only apply this to non-root cases because root-level mocks are expected to exist.
|
|
1328
|
+
// We also skip structural elements (like [0] inside arrays) because the null check
|
|
1329
|
+
// syntax doesn't work inside .map() callbacks where structural elements are used.
|
|
1330
|
+
// We also skip array index elements ([0], [1], etc.) because they represent tuple/array
|
|
1331
|
+
// elements, not properties that could be null.
|
|
1332
|
+
// We also only apply this when we're inside a function return value context - i.e.,
|
|
1333
|
+
// when the data path contains a function call pattern like ?.["someFunction(...)"].
|
|
1334
|
+
// This prevents adding null checks to intermediate objects in chains like supabase.auth.
|
|
1335
|
+
const hasNestedContent = nestedContent.filter(Boolean).length > 0;
|
|
1336
|
+
const isArrayIndexElement = name.match(/^\[\d*\]$/);
|
|
1337
|
+
// Check if data path contains a function call pattern, indicating we're inside a function return value
|
|
1338
|
+
const isInsideFunctionReturnValue = dataPaths.length === 1 &&
|
|
1339
|
+
dataPaths[0].match(/\?\.\["\w+\([^"]*\)"\]/);
|
|
1340
|
+
if (!root &&
|
|
1341
|
+
!returnValue.isStructural &&
|
|
1342
|
+
!isArrayIndexElement &&
|
|
1343
|
+
isInsideFunctionReturnValue &&
|
|
1344
|
+
hasNestedContent) {
|
|
1345
|
+
// Wrap with null check: if parent is null/undefined, return it directly; otherwise create object
|
|
1346
|
+
returnValueContents = `${dataPaths[0]} == null ? ${dataPaths[0]} : {\n${indent(levelContents)}\n}`;
|
|
1347
|
+
}
|
|
1348
|
+
else {
|
|
1349
|
+
returnValueContents = `{\n${indent(levelContents)}\n}`;
|
|
1350
|
+
}
|
|
513
1351
|
}
|
|
514
1352
|
}
|
|
515
1353
|
if (root) {
|
|
@@ -519,6 +1357,12 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
519
1357
|
if (args && args.length > 0) {
|
|
520
1358
|
if (!isValidKey(name))
|
|
521
1359
|
return;
|
|
1360
|
+
// Skip array index patterns like [], [0], [1] when they have args
|
|
1361
|
+
// These represent function calls on array elements, not property keys
|
|
1362
|
+
// e.g., customSizes[].(args) means each array element is callable, not a property named "[]"
|
|
1363
|
+
if (name.match(/^\[\d*\]$/)) {
|
|
1364
|
+
return;
|
|
1365
|
+
}
|
|
522
1366
|
const mostArgs = args.sort((a, b) => b.length - a.length)[0];
|
|
523
1367
|
const argsString = mostArgs
|
|
524
1368
|
.map((_, index) => `arg${index + 1}`)
|
|
@@ -558,8 +1402,19 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
558
1402
|
fallbackContent = `return ${returnValueContents}`;
|
|
559
1403
|
}
|
|
560
1404
|
else {
|
|
561
|
-
//
|
|
562
|
-
|
|
1405
|
+
// No explicit fallback paths - return the first literal's value as default
|
|
1406
|
+
// Returning spread of all values is dangerous because if values are primitives (strings),
|
|
1407
|
+
// spreading them creates objects with numeric keys like {0:'a', 1:'b', ...}
|
|
1408
|
+
// which causes "Objects are not valid as React child" errors
|
|
1409
|
+
const firstLiteralValue = literalKeys[0];
|
|
1410
|
+
const firstGroupPaths = argGroups.get(firstLiteralValue);
|
|
1411
|
+
if (firstGroupPaths && firstGroupPaths.length === 1) {
|
|
1412
|
+
fallbackContent = `return ${firstGroupPaths[0]}`;
|
|
1413
|
+
}
|
|
1414
|
+
else {
|
|
1415
|
+
// Multiple paths for first literal - return undefined as safe fallback
|
|
1416
|
+
fallbackContent = `return undefined`;
|
|
1417
|
+
}
|
|
563
1418
|
}
|
|
564
1419
|
const funcContents = conditionalBranches.join('\n') +
|
|
565
1420
|
'\n// Fallback for unmatched arguments\n' +
|
|
@@ -567,9 +1422,39 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
567
1422
|
content = `${cleanOutTypes(name)}: ${isAsyncFunction ? 'async ' : ''}(${argsString}) => {\n${indent(funcContents)}\n}`;
|
|
568
1423
|
}
|
|
569
1424
|
else {
|
|
570
|
-
// No argument variants
|
|
571
|
-
|
|
572
|
-
|
|
1425
|
+
// No argument variants
|
|
1426
|
+
// Check if this is an array method callback containing JSX.
|
|
1427
|
+
// JSX can't be serialized to JSON, so the LLM generates [{}] as data.
|
|
1428
|
+
// Instead of returning that unusable data, generate a passthrough that
|
|
1429
|
+
// calls the real callback on the best available array data from siblings.
|
|
1430
|
+
const containsJsx = dataPaths.some((p) => /<[A-Z]/.test(p));
|
|
1431
|
+
const isArrayMethod = ARRAY_PROTOTYPE_METHODS.has(name);
|
|
1432
|
+
if (containsJsx && isArrayMethod && dataPaths.length > 0) {
|
|
1433
|
+
// Extract parent data path by removing the last ?.["..."] segment
|
|
1434
|
+
const parentPath = dataPaths[0].replace(/\?\.\["[^"]*"\]$/, '');
|
|
1435
|
+
const funcLines = [
|
|
1436
|
+
`const _d = ${parentPath};`,
|
|
1437
|
+
`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);`,
|
|
1438
|
+
`return _a[0] ? _a[0].${name}(${argsString}) : []`,
|
|
1439
|
+
];
|
|
1440
|
+
const funcContents = funcLines.join('\n');
|
|
1441
|
+
content = `${cleanOutTypes(name)}: ${isAsyncFunction ? 'async ' : ''}(${argsString}) => {\n${indent(funcContents)}\n}`;
|
|
1442
|
+
}
|
|
1443
|
+
else {
|
|
1444
|
+
// But if there's nested content, we need to include it in the return object
|
|
1445
|
+
// (similar to how argument variant branches handle this at line 1070-1072)
|
|
1446
|
+
const hasNestedContent = validNestedContent.length > 0;
|
|
1447
|
+
let funcReturnContents;
|
|
1448
|
+
if (hasNestedContent && levelContentItems.length > 1) {
|
|
1449
|
+
// Include both spread and nested content in the return
|
|
1450
|
+
funcReturnContents = `{\n${indent(levelContents)}\n}`;
|
|
1451
|
+
}
|
|
1452
|
+
else {
|
|
1453
|
+
funcReturnContents = returnValueContents;
|
|
1454
|
+
}
|
|
1455
|
+
const funcContents = `return ${funcReturnContents}`;
|
|
1456
|
+
content = `${cleanOutTypes(name)}: ${isAsyncFunction ? 'async ' : ''}(${argsString}) => {\n${indent(funcContents)}\n}`;
|
|
1457
|
+
}
|
|
573
1458
|
}
|
|
574
1459
|
}
|
|
575
1460
|
else {
|
|
@@ -577,8 +1462,14 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
577
1462
|
return;
|
|
578
1463
|
}
|
|
579
1464
|
else if (name.match(/\[\d*\]/)) {
|
|
1465
|
+
// Numeric array index like [0], [1] - can be used as computed property
|
|
580
1466
|
content = returnValueContents;
|
|
581
1467
|
}
|
|
1468
|
+
else if (name.match(/^\[[a-zA-Z_]\w*\]$/)) {
|
|
1469
|
+
// Variable-based index like [currentItemIndex] - must be quoted string key
|
|
1470
|
+
// Otherwise JavaScript would try to evaluate the variable name
|
|
1471
|
+
content = `"${safeString(name)}": ${returnValueContents}`;
|
|
1472
|
+
}
|
|
582
1473
|
else {
|
|
583
1474
|
content = `${safeString(name)}: ${returnValueContents}`;
|
|
584
1475
|
}
|
|
@@ -590,7 +1481,31 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
590
1481
|
return content;
|
|
591
1482
|
};
|
|
592
1483
|
// Create the return value structure
|
|
593
|
-
|
|
1484
|
+
// OPTIMIZATION: Filter keys to only those starting with baseMockName before sorting.
|
|
1485
|
+
// This dramatically reduces processing time for large schemas (e.g., 9216 keys -> ~100 relevant keys).
|
|
1486
|
+
// Without this filter, the loop would call splitOutsideParenthesesAndArrays on every key
|
|
1487
|
+
// even though most are filtered out later by the baseMockName check.
|
|
1488
|
+
const allSchemaKeys = Object.keys(relevantReturnValueSchema ?? {});
|
|
1489
|
+
const relevantKeys = allSchemaKeys.filter((key) => {
|
|
1490
|
+
// Fast prefix check - key must start with baseMockName followed by ( or < or .
|
|
1491
|
+
// This matches: "useAtom()", "useAtom<T>()", "useAtom.something", but not "useAtomValue()"
|
|
1492
|
+
if (key === baseMockName)
|
|
1493
|
+
return true;
|
|
1494
|
+
if (key.startsWith(baseMockName + '('))
|
|
1495
|
+
return true;
|
|
1496
|
+
if (key.startsWith(baseMockName + '<'))
|
|
1497
|
+
return true;
|
|
1498
|
+
if (key.startsWith(baseMockName + '.'))
|
|
1499
|
+
return true;
|
|
1500
|
+
// Also include 'returnValue' paths which are normalized later
|
|
1501
|
+
if (key === 'returnValue' ||
|
|
1502
|
+
key.startsWith('returnValue.') ||
|
|
1503
|
+
key.startsWith('returnValue['))
|
|
1504
|
+
return true;
|
|
1505
|
+
return false;
|
|
1506
|
+
});
|
|
1507
|
+
const schemaKeyCount = relevantKeys.length;
|
|
1508
|
+
const sortedKeys = relevantKeys.sort((a, b) => {
|
|
594
1509
|
const aParts = splitOutsideParenthesesAndArrays(a);
|
|
595
1510
|
const bParts = splitOutsideParenthesesAndArrays(b);
|
|
596
1511
|
const maxLength = Math.max(aParts.length, bParts.length);
|
|
@@ -614,6 +1529,36 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
614
1529
|
}
|
|
615
1530
|
return 0;
|
|
616
1531
|
});
|
|
1532
|
+
// OPTIMIZATION: Pre-compute prefix indexes for O(1) lookups instead of O(n) scans.
|
|
1533
|
+
// This reduces complexity from O(n²) to O(n) for large schemas (9k+ keys).
|
|
1534
|
+
//
|
|
1535
|
+
// 1. extendedReturnValuePrefixes: Set of all path prefixes that have a .functionCallReturnValue extension
|
|
1536
|
+
// Used by hasExtendedFunctionCallReturnValue check at line ~1754
|
|
1537
|
+
// 2. functionCallsWithReturnValue: Set of function call paths where .functionCallReturnValue IMMEDIATELY follows
|
|
1538
|
+
// Used by hasProperFunctionCallPath check at line ~1787
|
|
1539
|
+
// IMPORTANT: Only includes paths where the function call is directly followed by .functionCallReturnValue
|
|
1540
|
+
// e.g., "a.b().functionCallReturnValue" -> adds "a.b()" but NOT "a" even if "a" ends with ")"
|
|
1541
|
+
const extendedReturnValuePrefixes = new Set();
|
|
1542
|
+
const functionCallsWithReturnValue = new Set();
|
|
1543
|
+
for (const k of relevantKeys) {
|
|
1544
|
+
const parts = splitOutsideParenthesesAndArrays(k);
|
|
1545
|
+
const returnValueIndex = parts.findIndex((part) => part.startsWith(RETURN_VALUE));
|
|
1546
|
+
if (returnValueIndex !== -1) {
|
|
1547
|
+
// Add all prefixes of k up to (but not including) functionCallReturnValue
|
|
1548
|
+
const prefix = joinParenthesesAndArrays(parts.slice(0, returnValueIndex));
|
|
1549
|
+
extendedReturnValuePrefixes.add(prefix);
|
|
1550
|
+
// ONLY add to functionCallsWithReturnValue if functionCallReturnValue IMMEDIATELY follows
|
|
1551
|
+
if (prefix.endsWith(')')) {
|
|
1552
|
+
functionCallsWithReturnValue.add(prefix);
|
|
1553
|
+
}
|
|
1554
|
+
// Also add intermediate prefixes for nested paths to extendedReturnValuePrefixes
|
|
1555
|
+
// This helps hasExtendedFunctionCallReturnValue which checks key + '.'
|
|
1556
|
+
for (let i = 1; i < returnValueIndex; i++) {
|
|
1557
|
+
const partialPrefix = joinParenthesesAndArrays(parts.slice(0, i));
|
|
1558
|
+
extendedReturnValuePrefixes.add(partialPrefix);
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
617
1562
|
for (const key of sortedKeys) {
|
|
618
1563
|
const value = relevantReturnValueSchema[key];
|
|
619
1564
|
const parts = splitOutsideParenthesesAndArrays(key);
|
|
@@ -641,7 +1586,9 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
641
1586
|
parts.splice(i, 1);
|
|
642
1587
|
}
|
|
643
1588
|
}
|
|
644
|
-
|
|
1589
|
+
// Compare against baseMockName (without generics/args), not the full mockName
|
|
1590
|
+
// e.g., for "useFetcher<User>()", baseMockName is "useFetcher"
|
|
1591
|
+
if (parts[0].split('(')[0] !== baseMockName)
|
|
645
1592
|
continue;
|
|
646
1593
|
// Include paths with functionCallReturnValue OR function-typed paths that need mocking
|
|
647
1594
|
const hasFunctionCallReturnValue = parts.some((p) => isFunctionCallReturnValue(p));
|
|
@@ -657,7 +1604,9 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
657
1604
|
// nested inside (e.g., methods on array elements passed as arguments).
|
|
658
1605
|
if (hasSignaturePath)
|
|
659
1606
|
continue;
|
|
660
|
-
|
|
1607
|
+
// OPTIMIZATION: Use pre-computed index instead of O(n) scan
|
|
1608
|
+
// Old code: Object.keys(relevantReturnValueSchema).some((k) => k.startsWith(key + '.') && k.includes('.functionCallReturnValue'))
|
|
1609
|
+
const hasExtendedFunctionCallReturnValue = extendedReturnValuePrefixes.has(key);
|
|
661
1610
|
// Skip JSX components - they look like function calls (e.g., Context.Provider())
|
|
662
1611
|
// but they're React components used in JSX, not functions that need mocking
|
|
663
1612
|
// Check both the value type and whether the functionCallReturnValue is jsx-component
|
|
@@ -666,6 +1615,35 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
666
1615
|
'jsx-component';
|
|
667
1616
|
if (isJsxComponent)
|
|
668
1617
|
continue;
|
|
1618
|
+
// Skip paths that bypass .functionCallReturnValue when there's a corresponding path with it.
|
|
1619
|
+
// Example: If we have both:
|
|
1620
|
+
// - trpc.customer.useQuery(...).data (incorrect - no .functionCallReturnValue)
|
|
1621
|
+
// - trpc.customer.useQuery(...).functionCallReturnValue.data (correct)
|
|
1622
|
+
// We should skip the first path because the second one properly captures the return value.
|
|
1623
|
+
// This can happen when the analyzer sees both the raw property access and the return value structure.
|
|
1624
|
+
if (!hasFunctionCallReturnValue) {
|
|
1625
|
+
// This path has no .functionCallReturnValue. Check if any function call in this path
|
|
1626
|
+
// has a corresponding .functionCallReturnValue path in the schema.
|
|
1627
|
+
let shouldSkipKey = false;
|
|
1628
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
1629
|
+
const part = parts[i];
|
|
1630
|
+
if (part.endsWith(')') && !isFunctionCallReturnValue(parts[i + 1])) {
|
|
1631
|
+
// This part is a function call, and the next part is NOT .functionCallReturnValue
|
|
1632
|
+
// Check if there's any path with .functionCallReturnValue for this function call
|
|
1633
|
+
const functionCallPath = joinParenthesesAndArrays(parts.slice(0, i + 1));
|
|
1634
|
+
// OPTIMIZATION: Use pre-computed index instead of O(n) scan
|
|
1635
|
+
// Old code: Object.keys(relevantReturnValueSchema).some((k) => k.startsWith(functionCallPath + '.functionCallReturnValue'))
|
|
1636
|
+
const hasProperFunctionCallPath = functionCallsWithReturnValue.has(functionCallPath);
|
|
1637
|
+
if (hasProperFunctionCallPath) {
|
|
1638
|
+
// Skip this path - the .functionCallReturnValue path will handle it correctly
|
|
1639
|
+
shouldSkipKey = true;
|
|
1640
|
+
break;
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
if (shouldSkipKey)
|
|
1645
|
+
continue;
|
|
1646
|
+
}
|
|
669
1647
|
const isFunctionPath = ['function', 'async-function'].includes(value) &&
|
|
670
1648
|
parts[parts.length - 1].endsWith(')') &&
|
|
671
1649
|
!hasAnyFunctionCallReturnValue &&
|
|
@@ -709,6 +1687,16 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
709
1687
|
const nextIsArray = !!nextPart?.match(/^\[\d*\]/);
|
|
710
1688
|
const isDifferentiatedArray = !!part?.match(/^\[\d+\]/);
|
|
711
1689
|
const nextIsDifferentiatedArray = !!nextPart?.match(/^\[\d+\]/);
|
|
1690
|
+
// Variable index patterns like [currentItemIndex] or [targetIndex] indicate array access
|
|
1691
|
+
// but don't represent actual data structure - they're markers from variable-based index tracking.
|
|
1692
|
+
// Skip them AND all remaining parts to avoid creating spurious nested structure that breaks array iteration.
|
|
1693
|
+
// The remaining parts (e.g., .missing_attributes) describe properties of array elements, which are
|
|
1694
|
+
// already handled by the generic [] accessor path.
|
|
1695
|
+
const isVariableIndex = !!part?.match(/^\[[a-zA-Z_]\w*\]$/);
|
|
1696
|
+
if (isVariableIndex) {
|
|
1697
|
+
// Break out of the loop entirely - don't process any remaining parts
|
|
1698
|
+
break;
|
|
1699
|
+
}
|
|
712
1700
|
// Find the correct value for the current part being processed
|
|
713
1701
|
let partValue = value; // default to the final value
|
|
714
1702
|
if (isFunctionCallReturnValue(part) && nextIsArray) {
|
|
@@ -800,7 +1788,35 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
800
1788
|
}
|
|
801
1789
|
}
|
|
802
1790
|
else {
|
|
803
|
-
|
|
1791
|
+
// Before setting returnsFunctionArgs on the parent (for generic [] = function),
|
|
1792
|
+
// check if there are specific array indices (like [0], [1]) that are NOT functions.
|
|
1793
|
+
// If so, don't set returnsFunctionArgs because those specific indices take precedence.
|
|
1794
|
+
// This prevents adding ["()"] to paths like [0] when [0] is 'unknown' but [] is 'function'.
|
|
1795
|
+
//
|
|
1796
|
+
// Use parts.slice(0, i + 1) to get the current path INCLUDING functionCallReturnValue.
|
|
1797
|
+
// For example, if parts = ['useAtom()','functionCallReturnValue','[]']
|
|
1798
|
+
// and i = 1, we want to check 'useAtom().functionCallReturnValue[0]' etc.
|
|
1799
|
+
const arrayContainerPath = joinParenthesesAndArrays(parts.slice(0, i + 1));
|
|
1800
|
+
const hasNonFunctionSpecificIndices = Object.entries(relevantReturnValueSchema).some(([k, v]) => {
|
|
1801
|
+
// Look for paths like "arrayContainerPath[0]", "arrayContainerPath[1]" etc.
|
|
1802
|
+
const indexMatch = k.match(new RegExp(`^${arrayContainerPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\[(\\d+)\\]$`));
|
|
1803
|
+
// If found and it's NOT a function type, we have a conflict
|
|
1804
|
+
return (indexMatch &&
|
|
1805
|
+
!['function', 'async-function'].includes(v));
|
|
1806
|
+
});
|
|
1807
|
+
// Also check if [] has nested object properties (like [].filter, [].name)
|
|
1808
|
+
// If so, [] items are objects with properties, not pure functions to be called
|
|
1809
|
+
// This handles cases where the schema shows [].filter = object but doesn't
|
|
1810
|
+
// have explicit [0] entries
|
|
1811
|
+
const genericArrayPath = `${arrayContainerPath}[]`;
|
|
1812
|
+
const hasNestedProperties = Object.keys(relevantReturnValueSchema).some((k) => {
|
|
1813
|
+
// Check for paths like "arrayContainerPath[].propertyName" (not [].())
|
|
1814
|
+
return (k.startsWith(genericArrayPath + '.') &&
|
|
1815
|
+
!k.startsWith(genericArrayPath + '.('));
|
|
1816
|
+
});
|
|
1817
|
+
if (!hasNonFunctionSpecificIndices && !hasNestedProperties) {
|
|
1818
|
+
returnValueSection.returnsFunctionArgs = [];
|
|
1819
|
+
}
|
|
804
1820
|
}
|
|
805
1821
|
}
|
|
806
1822
|
}
|
|
@@ -821,7 +1837,8 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
821
1837
|
}
|
|
822
1838
|
// If the next part is an object with nested content, continue processing
|
|
823
1839
|
// This handles paths like functionCallReturnValue.selectedOptions.elementOptions[]
|
|
824
|
-
|
|
1840
|
+
// Also handles union types like 'array | undefined' or 'object | undefined'
|
|
1841
|
+
if (nextValue?.includes('object') || nextValue?.includes('array')) {
|
|
825
1842
|
continue;
|
|
826
1843
|
}
|
|
827
1844
|
}
|
|
@@ -932,12 +1949,18 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
932
1949
|
returnValueSection.nested.push(relevantPart);
|
|
933
1950
|
}
|
|
934
1951
|
}
|
|
935
|
-
else
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
1952
|
+
else {
|
|
1953
|
+
// Add args to existing entry if current part has function arguments
|
|
1954
|
+
// This handles the case where bare `t` is processed first (creating {name: 't', args: undefined})
|
|
1955
|
+
// and then `t("common.close")` is processed - we need to add its args to the existing entry
|
|
1956
|
+
const currentArgs = funcArgs(part);
|
|
1957
|
+
const hasNewArgs = currentArgs.length > 0 || part.includes('(');
|
|
1958
|
+
if (hasNewArgs) {
|
|
1959
|
+
const existingArgs = relevantPart.args?.find((args) => args.join(',') === currentArgs.join(','));
|
|
1960
|
+
if (!existingArgs) {
|
|
1961
|
+
relevantPart.args || (relevantPart.args = []);
|
|
1962
|
+
relevantPart.args.push(currentArgs);
|
|
1963
|
+
}
|
|
941
1964
|
}
|
|
942
1965
|
}
|
|
943
1966
|
// If nextPart is [], update existing part to be a generic array
|
|
@@ -945,7 +1968,12 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
945
1968
|
relevantPart.isArray = true;
|
|
946
1969
|
relevantPart.isGenericArray = true;
|
|
947
1970
|
}
|
|
948
|
-
if
|
|
1971
|
+
// Check if there are remaining parts after functionCallReturnValue that need processing
|
|
1972
|
+
// (e.g., data properties like useQuery().functionCallReturnValue.data)
|
|
1973
|
+
const hasRemainingPartsAfterReturnValue = nextPart &&
|
|
1974
|
+
(isFunctionCallReturnValue(nextPart) ||
|
|
1975
|
+
(isFunctionCallReturnValue(parts[i]) && i < parts.length - 1));
|
|
1976
|
+
if (!hasNestedFunction && !hasRemainingPartsAfterReturnValue) {
|
|
949
1977
|
// Before breaking, check if this function returns an array
|
|
950
1978
|
// by looking for a functionCallReturnValue: 'array' entry in the schema
|
|
951
1979
|
if (relevantPart && part.endsWith(')')) {
|
|
@@ -970,9 +1998,24 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
970
1998
|
returnValueSection = relevantPart;
|
|
971
1999
|
}
|
|
972
2000
|
}
|
|
2001
|
+
// Post-processing: When the root functionCallReturnValue is typed as "function" but the
|
|
2002
|
+
// return value also has nested properties (methods like .from(), .auth, etc.), it's actually
|
|
2003
|
+
// an object, not a function to be called. Clear returnsFunctionArgs to prevent double-wrapping
|
|
2004
|
+
// (adding an extra () => { return { ... } } wrapper and ["()"] data paths).
|
|
2005
|
+
// This handles cases like Supabase's createClient() which returns an object with methods.
|
|
2006
|
+
// Only applied to the root level - nested parts that are functions with methods (like
|
|
2007
|
+
// useSearchParams()[1] which is a setter function with .set() and .delete()) should keep
|
|
2008
|
+
// their returnsFunctionArgs since they genuinely ARE functions.
|
|
2009
|
+
if (returnValueParts.returnsFunctionArgs &&
|
|
2010
|
+
returnValueParts.returnsFunctionArgs.length === 0 &&
|
|
2011
|
+
returnValueParts.nested &&
|
|
2012
|
+
returnValueParts.nested.length > 0) {
|
|
2013
|
+
returnValueParts.returnsFunctionArgs = undefined;
|
|
2014
|
+
}
|
|
973
2015
|
const contents = constructReturnValueString(returnValueParts);
|
|
974
2016
|
if (mockNameParts.length > 1) {
|
|
975
2017
|
const originalLib = `${mockNameParts[0]}__cyOriginal`;
|
|
2018
|
+
const skipOriginalSpread = options?.skipOriginalSpread;
|
|
976
2019
|
const subPart = (parts, originalLib) => {
|
|
977
2020
|
const part = parts.shift();
|
|
978
2021
|
if (!isValidKey(part))
|
|
@@ -980,7 +2023,9 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
980
2023
|
const isLast = parts.length === 0;
|
|
981
2024
|
const partContents = isLast
|
|
982
2025
|
? contents
|
|
983
|
-
:
|
|
2026
|
+
: skipOriginalSpread
|
|
2027
|
+
? subPart(parts, originalLib)
|
|
2028
|
+
: `...${originalLib}.${part},\n${subPart(parts, originalLib)}`;
|
|
984
2029
|
let code = `${part}: {\n${indent(partContents)}\n}`;
|
|
985
2030
|
if (part.includes('(') || (isFunction && isLast)) {
|
|
986
2031
|
const args = funcArgs(part)
|
|
@@ -990,26 +2035,30 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
990
2035
|
}
|
|
991
2036
|
return code;
|
|
992
2037
|
};
|
|
993
|
-
const returnParts =
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
2038
|
+
const returnParts = skipOriginalSpread
|
|
2039
|
+
? [subPart(mockNameParts.slice(1), originalLib)]
|
|
2040
|
+
: [
|
|
2041
|
+
`...${mockNameParts[0]}__cyOriginal`,
|
|
2042
|
+
subPart(mockNameParts.slice(1), originalLib),
|
|
2043
|
+
];
|
|
2044
|
+
return `const ${mockNameParts[0]} = {\n${indent(returnParts.filter(Boolean).join(',\n'))}\n};`;
|
|
998
2045
|
}
|
|
999
2046
|
else if (isFunction) {
|
|
1000
2047
|
// For headers() and cookies() from next/headers, add common iterator methods
|
|
1001
2048
|
// These are needed when the mock is passed to functions that use .entries(), .keys(), etc.
|
|
1002
2049
|
// (e.g., Object.fromEntries(headers.entries()) in buildLegacyHeaders)
|
|
1003
|
-
const needsIteratorMethods =
|
|
2050
|
+
const needsIteratorMethods = baseMockName === 'headers' || baseMockName === 'cookies';
|
|
1004
2051
|
let enhancedContents = contents;
|
|
1005
2052
|
if (needsIteratorMethods && contents.trim().startsWith('{')) {
|
|
1006
2053
|
// Add iterator methods that operate on the scenario data
|
|
2054
|
+
// Use the dataKey (original call signature or canonical key)
|
|
2055
|
+
const quotedDataKey = quotePropertyKey(dataKey);
|
|
1007
2056
|
const iteratorMethods = `,
|
|
1008
|
-
entries: () => Object.entries(scenarios().data()
|
|
1009
|
-
keys: () => Object.keys(scenarios().data()
|
|
1010
|
-
values: () => Object.values(scenarios().data()
|
|
1011
|
-
forEach: (fn) => Object.entries(scenarios().data()
|
|
1012
|
-
has: (key) => Object.prototype.hasOwnProperty.call(scenarios().data()
|
|
2057
|
+
entries: () => Object.entries(scenarios().data()?.${quotedDataKey} || {}),
|
|
2058
|
+
keys: () => Object.keys(scenarios().data()?.${quotedDataKey} || {}),
|
|
2059
|
+
values: () => Object.values(scenarios().data()?.${quotedDataKey} || {}),
|
|
2060
|
+
forEach: (fn) => Object.entries(scenarios().data()?.${quotedDataKey} || {}).forEach(([k, v]) => fn(v, k)),
|
|
2061
|
+
has: (key) => Object.prototype.hasOwnProperty.call(scenarios().data()?.${quotedDataKey} || {}, key)`;
|
|
1013
2062
|
// Insert before the closing brace (handle trailing whitespace)
|
|
1014
2063
|
enhancedContents = contents.replace(/\}\s*$/, iteratorMethods + '\n}');
|
|
1015
2064
|
}
|
|
@@ -1019,32 +2068,138 @@ export default function constructMockCode(mockName, dependencySchemas, entityTyp
|
|
|
1019
2068
|
// `new ClassName("arg")` wouldn't create the expected instance.
|
|
1020
2069
|
// For Error subclasses (detected by name ending in "Error"), extend Error for proper error handling.
|
|
1021
2070
|
if (entityType === 'class') {
|
|
1022
|
-
const isErrorSubclass =
|
|
1023
|
-
const baseClass = isErrorSubclass ? 'Error' : 'Object';
|
|
2071
|
+
const isErrorSubclass = baseMockName.endsWith('Error');
|
|
1024
2072
|
const superCall = isErrorSubclass ? 'super(message);' : '';
|
|
1025
2073
|
const nameAssignment = isErrorSubclass
|
|
1026
|
-
? `this.name = '${
|
|
2074
|
+
? `this.name = '${baseMockName}';`
|
|
1027
2075
|
: '';
|
|
1028
|
-
|
|
2076
|
+
// Use the base class name for the class definition, not the call-signature-derived name.
|
|
2077
|
+
// When mockName is "StatsCalculator(supabase)", baseMockName is "StatsCalculator"
|
|
2078
|
+
// and derivedFunctionName would be "StatsCalculator_supabase" which is wrong.
|
|
2079
|
+
// Classes are instantiated with `new ClassName(args)` so the name must match the original.
|
|
2080
|
+
const className = baseMockName;
|
|
2081
|
+
// Use the already-generated contents (which has proper function wrappers for methods)
|
|
2082
|
+
// instead of raw scenarios().data() which would create non-callable string-keyed properties.
|
|
2083
|
+
// For classes with methods like calculateStats(), the contents will have:
|
|
2084
|
+
// { calculateStats: (...args) => scenarios().data()?.["key"]?.["calculateStats(...)"], ... }
|
|
2085
|
+
// which makes methods callable on the instance.
|
|
2086
|
+
const classContents = enhancedContents.trim().startsWith('{')
|
|
2087
|
+
? enhancedContents
|
|
2088
|
+
: `scenarios().data()?.${quotePropertyKey(dataKey)} || {}`;
|
|
2089
|
+
return `class ${className}${isErrorSubclass ? ' extends Error' : ''} {
|
|
1029
2090
|
constructor(message) {
|
|
1030
2091
|
${superCall}
|
|
1031
2092
|
${nameAssignment}
|
|
1032
|
-
Object.assign(this,
|
|
2093
|
+
Object.assign(this, ${classContents});
|
|
1033
2094
|
}
|
|
1034
2095
|
}`;
|
|
1035
2096
|
}
|
|
1036
|
-
//
|
|
1037
|
-
//
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
2097
|
+
// Generate safe function name:
|
|
2098
|
+
// 1. For call signatures: use derivedFunctionName
|
|
2099
|
+
// e.g., "useFetcher<User>()" becomes "useFetcher_User"
|
|
2100
|
+
// e.g., "db.select(usersQuery)" becomes "db_select_usersQuery"
|
|
2101
|
+
// 2. With uniqueFunctionSuffix option: append suffix for unique naming
|
|
2102
|
+
// e.g., baseMockName = "useFetcher", suffix = "entityDiffFetcher" -> "useFetcher_entityDiffFetcher"
|
|
2103
|
+
// 3. EXCEPTION: When keepOriginalFunctionName is true (for single-call cases), use the base name
|
|
2104
|
+
let safeFunctionName;
|
|
2105
|
+
if (options?.keepOriginalFunctionName) {
|
|
2106
|
+
safeFunctionName = baseMockName;
|
|
2107
|
+
}
|
|
2108
|
+
else if (options?.uniqueFunctionSuffix) {
|
|
2109
|
+
safeFunctionName = `${baseMockName}_${options.uniqueFunctionSuffix}`;
|
|
2110
|
+
}
|
|
2111
|
+
else if (mockNameIsCallSignature && derivedFunctionName) {
|
|
2112
|
+
safeFunctionName = derivedFunctionName;
|
|
2113
|
+
}
|
|
2114
|
+
else {
|
|
2115
|
+
safeFunctionName = baseMockName;
|
|
2116
|
+
}
|
|
2117
|
+
// Check if this function returns a function (detected by double-call pattern: mockName(args)())
|
|
2118
|
+
// This happens when the schema has keys like "wrapThrows(() => JSON.parse(savedFilters))()"
|
|
2119
|
+
// where the function call is immediately followed by another call.
|
|
2120
|
+
// Example usage: const result = wrapThrows(() => JSON.parse(x))(); // double call
|
|
2121
|
+
const isHigherOrderFunction = Object.keys(relevantReturnValueSchema ?? {}).some((key) => {
|
|
2122
|
+
if (!key.startsWith(baseMockName))
|
|
2123
|
+
return false;
|
|
2124
|
+
// Find the first ( after baseMockName (the start of the function call)
|
|
2125
|
+
const firstOpenParen = key.indexOf('(', baseMockName.length);
|
|
2126
|
+
if (firstOpenParen === -1)
|
|
2127
|
+
return false;
|
|
2128
|
+
// Skip if the ( is not immediately after the mock name
|
|
2129
|
+
// (there might be type params like func<T>() - handle by checking for < or ()
|
|
2130
|
+
const between = key.slice(baseMockName.length, firstOpenParen);
|
|
2131
|
+
if (between.length > 0 && !between.startsWith('<'))
|
|
2132
|
+
return false;
|
|
2133
|
+
// Find the matching ) for the first ( using depth counting
|
|
2134
|
+
let depth = 1;
|
|
2135
|
+
let i = firstOpenParen + 1;
|
|
2136
|
+
while (i < key.length && depth > 0) {
|
|
2137
|
+
if (key[i] === '(')
|
|
2138
|
+
depth++;
|
|
2139
|
+
if (key[i] === ')')
|
|
2140
|
+
depth--;
|
|
2141
|
+
i++;
|
|
2142
|
+
}
|
|
2143
|
+
if (depth !== 0)
|
|
2144
|
+
return false; // Unbalanced parentheses
|
|
2145
|
+
// Now i points just after the matching )
|
|
2146
|
+
// Check if there's another ( immediately (indicating double call)
|
|
2147
|
+
const remaining = key.slice(i);
|
|
2148
|
+
if (remaining.startsWith('('))
|
|
2149
|
+
return true;
|
|
2150
|
+
return false;
|
|
2151
|
+
});
|
|
2152
|
+
// Use ...args to accept any number of arguments - prevents TypeScript errors
|
|
2153
|
+
// like "Expected 0 arguments, but got X" when caller passes arguments
|
|
2154
|
+
// For higher-order functions, wrap the return in an arrow function
|
|
2155
|
+
// so that mockFunc(arg)() works correctly (outer call returns a function, inner call gets the data)
|
|
2156
|
+
const returnValue = isHigherOrderFunction
|
|
2157
|
+
? `() => (${enhancedContents})`
|
|
2158
|
+
: enhancedContents;
|
|
2159
|
+
// Inline the return value directly in the function to avoid module-level const
|
|
2160
|
+
// that would be evaluated before scenario context is ready
|
|
2161
|
+
// Add fallback for simple data path returns to prevent undefined errors (e.g., createTheme)
|
|
2162
|
+
// Only add fallback if returnValue is a simple data accessor (starts with scenarios().data())
|
|
2163
|
+
// and doesn't already have nested structure (object literal, array, or method chains like .map())
|
|
2164
|
+
const isSimpleDataPath = returnValue.startsWith('scenarios().data()') &&
|
|
2165
|
+
!returnValue.trim().startsWith('{') &&
|
|
2166
|
+
!returnValue.trim().startsWith('[') &&
|
|
2167
|
+
!returnValue.includes('.map('); // Exclude method chains
|
|
2168
|
+
const safeReturnValue = isSimpleDataPath
|
|
2169
|
+
? `${returnValue} ?? {}`
|
|
2170
|
+
: returnValue;
|
|
2171
|
+
const refName = `_${safeFunctionName}Ref`;
|
|
2172
|
+
const assignment = `${refName}.current = ${safeReturnValue};`;
|
|
2173
|
+
const ifBlock = `if (!${refName}.current) {\n${indent(assignment)}\n}`;
|
|
2174
|
+
const body = `${ifBlock}\nreturn ${refName}.current;`;
|
|
2175
|
+
return [
|
|
2176
|
+
`// PATCHED: memoize to return stable reference (prevents infinite useEffect re-triggers)`,
|
|
2177
|
+
`const ${refName} = {`,
|
|
2178
|
+
` current: null,`,
|
|
2179
|
+
`};`,
|
|
2180
|
+
`${isRootAsyncFunction ? 'async ' : ''}function ${safeFunctionName}(...args) {`,
|
|
2181
|
+
indent(body),
|
|
2182
|
+
`}`,
|
|
2183
|
+
].join('\n');
|
|
1042
2184
|
}
|
|
1043
2185
|
else {
|
|
1044
|
-
//
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
2186
|
+
// Generate safe const name:
|
|
2187
|
+
// 1. For call signatures: use derivedFunctionName
|
|
2188
|
+
// 2. With uniqueFunctionSuffix option: append suffix for unique naming
|
|
2189
|
+
// 3. EXCEPTION: When keepOriginalFunctionName is true (for single-call cases), use the base name
|
|
2190
|
+
let safeName;
|
|
2191
|
+
if (options?.keepOriginalFunctionName) {
|
|
2192
|
+
safeName = baseMockName;
|
|
2193
|
+
}
|
|
2194
|
+
else if (options?.uniqueFunctionSuffix) {
|
|
2195
|
+
safeName = `${baseMockName}_${options.uniqueFunctionSuffix}`;
|
|
2196
|
+
}
|
|
2197
|
+
else if (mockNameIsCallSignature && derivedFunctionName) {
|
|
2198
|
+
safeName = derivedFunctionName;
|
|
2199
|
+
}
|
|
2200
|
+
else {
|
|
2201
|
+
safeName = baseMockName;
|
|
2202
|
+
}
|
|
1048
2203
|
// Get any jsx-component properties that need to be preserved from the original
|
|
1049
2204
|
const jsxProperties = getJsxComponentProperties(mockName, relevantReturnValueSchema);
|
|
1050
2205
|
// If there are jsx-component properties, add them as references to the original
|