ai-first-cli 1.3.1 → 1.3.5
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/.ai-dev/index.db +0 -0
- package/BETA_EVALUATION_REPORT.md +151 -0
- package/CHANGELOG.md +178 -0
- package/PHASE1_USER_SIMULATION.md +56 -0
- package/PHASE2_USER_SIMULATION.md +81 -0
- package/PHASE3_USER_SIMULATION.md +176 -0
- package/README.es.md +18 -0
- package/README.md +80 -1
- package/ai/graph/knowledge-graph.json +10 -0
- package/ai-context/ai_context.md +130 -0
- package/{test-projects/react-app/.ai-dev → ai-context}/ai_rules.md +10 -5
- package/ai-context/architecture.md +136 -0
- package/ai-context/context/features/src.json +69 -0
- package/ai-context/context/features/test-projects.json +69 -0
- package/ai-context/context/flows/App.json +17 -0
- package/ai-context/context/flows/DashboardPage.json +14 -0
- package/ai-context/context/flows/LoginPage.json +14 -0
- package/ai-context/context/flows/admin.json +10 -0
- package/ai-context/context/flows/ai-first.json +9 -0
- package/ai-context/context/flows/androidresources.json +11 -0
- package/ai-context/context/flows/auth.json +13 -0
- package/ai-context/context/flows/authController.json +14 -0
- package/ai-context/context/flows/doctor.json +9 -0
- package/ai-context/context/flows/entrypoints.json +9 -0
- package/ai-context/context/flows/explore.json +9 -0
- package/ai-context/context/flows/fastapiAdapter.json +14 -0
- package/ai-context/context/flows/fastapiadapter.json +11 -0
- package/ai-context/context/flows/index.json +19 -0
- package/ai-context/context/flows/indexer.json +9 -0
- package/ai-context/context/flows/indexstate.json +9 -0
- package/ai-context/context/flows/init.json +22 -0
- package/ai-context/context/flows/main.json +18 -0
- package/ai-context/context/flows/mainactivity.json +9 -0
- package/ai-context/context/flows/models.json +15 -0
- package/ai-context/context/flows/posts.json +15 -0
- package/ai-context/context/flows/repoMapper.json +20 -0
- package/ai-context/context/flows/repomapper.json +11 -0
- package/ai-context/context/flows/routes.json +15 -0
- package/ai-context/context/flows/serializers.json +10 -0
- package/ai-context/context/flows/user.json +23 -0
- package/ai-context/context/flows/views.json +12 -0
- package/{test-projects/react-app/.ai-dev → ai-context}/conventions.md +3 -2
- package/ai-context/dependencies.json +3360 -0
- package/ai-context/entrypoints.md +45 -0
- package/ai-context/index-state.json +196 -0
- package/ai-context/modules.json +901 -0
- package/ai-context/project.json +33 -0
- package/ai-context/repo_map.json +8857 -0
- package/ai-context/repo_map.md +2002 -0
- package/{test-projects/flask-app/.ai-dev → ai-context}/schema.json +1 -1
- package/ai-context/summary.md +46 -0
- package/ai-context/symbols.json +82467 -0
- package/{test-projects/react-app/.ai-dev → ai-context}/tech_stack.md +15 -7
- package/ai-context-evaluation-report-1774223059505.md +206 -0
- package/dist/analyzers/architecture.d.ts.map +1 -1
- package/dist/analyzers/architecture.js +6 -0
- package/dist/analyzers/architecture.js.map +1 -1
- package/dist/analyzers/entrypoints.d.ts.map +1 -1
- package/dist/analyzers/entrypoints.js +105 -0
- package/dist/analyzers/entrypoints.js.map +1 -1
- package/dist/analyzers/symbols.d.ts.map +1 -1
- package/dist/analyzers/symbols.js +72 -1
- package/dist/analyzers/symbols.js.map +1 -1
- package/dist/analyzers/techStack.d.ts +8 -0
- package/dist/analyzers/techStack.d.ts.map +1 -1
- package/dist/analyzers/techStack.js +75 -0
- package/dist/analyzers/techStack.js.map +1 -1
- package/dist/scripts/ai-context-evaluator.js +367 -0
- package/package.json +1 -1
- package/quick-evaluation-report-1774396002305.md +64 -0
- package/quick-evaluator.ts +200 -0
- package/scripts/ai-context-evaluator.ts +440 -0
- package/src/analyzers/architecture.ts +8 -0
- package/src/analyzers/entrypoints.ts +115 -0
- package/src/analyzers/symbols.ts +77 -1
- package/src/analyzers/techStack.ts +93 -0
- package/tests/apex-parser.test.ts +193 -0
- package/tests/cli-commands-batch1.test.ts +808 -0
- package/tests/cli-commands-batch2.test.ts +1113 -0
- package/tests/cli-commands-batch3.test.ts +1128 -0
- package/tests/cli-index.test.ts +1007 -0
- package/tests/cli-init.test.ts +761 -0
- package/tests/salesforce-apex-classes.test.ts +713 -0
- package/tests/salesforce-apex-triggers.test.ts +871 -0
- package/tests/salesforce-custom-objects.test.ts +918 -0
- package/tests/salesforce-flows.test.ts +710 -0
- package/tests/salesforce-lwc.test.ts +963 -0
- package/tests/salesforce-sfdx-integration.test.ts +1125 -0
- package/ANALISIS_COMPLETO.md +0 -424
- package/ANALISIS_MEJORAS.md +0 -327
- package/CONTRIBUTING.md +0 -89
- package/FLOW.md +0 -129
- package/TEST_RESULTS.md +0 -198
- package/TEST_RESULTS_COMPARATIVE.md +0 -159
- package/TEST_RESULTS_COMPLETE.md +0 -127
- package/TEST_RESULTS_COMPREHENSIVE.md +0 -208
- package/install.sh +0 -188
- package/run-all-tests.sh +0 -184
- package/test-ai-context-understanding.sh +0 -21
- package/test-projects/django-app/.ai-dev/ai_context.md +0 -92
- package/test-projects/django-app/.ai-dev/ai_rules.md +0 -47
- package/test-projects/django-app/.ai-dev/architecture.md +0 -57
- package/test-projects/django-app/.ai-dev/cache.json +0 -169
- package/test-projects/django-app/.ai-dev/context/flows/views.json +0 -10
- package/test-projects/django-app/.ai-dev/conventions.md +0 -51
- package/test-projects/django-app/.ai-dev/dependencies.json +0 -312
- package/test-projects/django-app/.ai-dev/entrypoints.md +0 -4
- package/test-projects/django-app/.ai-dev/files.json +0 -209
- package/test-projects/django-app/.ai-dev/graph/knowledge-graph.json +0 -36
- package/test-projects/django-app/.ai-dev/graph/module-graph.json +0 -145
- package/test-projects/django-app/.ai-dev/graph/symbol-graph.json +0 -1488
- package/test-projects/django-app/.ai-dev/graph/symbol-references.json +0 -1
- package/test-projects/django-app/.ai-dev/index-state.json +0 -294
- package/test-projects/django-app/.ai-dev/modules.json +0 -35
- package/test-projects/django-app/.ai-dev/project.json +0 -11
- package/test-projects/django-app/.ai-dev/repo_map.json +0 -412
- package/test-projects/django-app/.ai-dev/repo_map.md +0 -105
- package/test-projects/django-app/.ai-dev/schema.json +0 -5
- package/test-projects/django-app/.ai-dev/summary.md +0 -15
- package/test-projects/django-app/.ai-dev/symbols.json +0 -1
- package/test-projects/django-app/.ai-dev/tech_stack.md +0 -32
- package/test-projects/django-app/README.md +0 -91
- package/test-projects/django-app/blog/__init__.py +0 -0
- package/test-projects/django-app/blog/admin.py +0 -31
- package/test-projects/django-app/blog/models.py +0 -55
- package/test-projects/django-app/blog/serializers.py +0 -69
- package/test-projects/django-app/blog/urls.py +0 -14
- package/test-projects/django-app/blog/views.py +0 -96
- package/test-projects/django-app/django_app/__init__.py +0 -0
- package/test-projects/django-app/django_app/settings.py +0 -90
- package/test-projects/django-app/django_app/urls.py +0 -11
- package/test-projects/django-app/django_app/wsgi.py +0 -9
- package/test-projects/django-app/manage.py +0 -23
- package/test-projects/django-app/requirements.txt +0 -3
- package/test-projects/django-app/users/__init__.py +0 -0
- package/test-projects/django-app/users/admin.py +0 -42
- package/test-projects/django-app/users/models.py +0 -54
- package/test-projects/django-app/users/serializers.py +0 -113
- package/test-projects/django-app/users/urls.py +0 -13
- package/test-projects/django-app/users/views.py +0 -135
- package/test-projects/express-api/.ai-dev/ai_context.md +0 -112
- package/test-projects/express-api/.ai-dev/ai_rules.md +0 -50
- package/test-projects/express-api/.ai-dev/architecture.md +0 -62
- package/test-projects/express-api/.ai-dev/context/features/controllers.json +0 -13
- package/test-projects/express-api/.ai-dev/context/features/services.json +0 -13
- package/test-projects/express-api/.ai-dev/context/flows/auth.json +0 -12
- package/test-projects/express-api/.ai-dev/context/flows/user.json +0 -13
- package/test-projects/express-api/.ai-dev/conventions.md +0 -51
- package/test-projects/express-api/.ai-dev/dependencies.json +0 -54
- package/test-projects/express-api/.ai-dev/entrypoints.md +0 -17
- package/test-projects/express-api/.ai-dev/modules.json +0 -30
- package/test-projects/express-api/.ai-dev/project.json +0 -15
- package/test-projects/express-api/.ai-dev/repo_map.json +0 -100
- package/test-projects/express-api/.ai-dev/repo_map.md +0 -36
- package/test-projects/express-api/.ai-dev/schema.json +0 -5
- package/test-projects/express-api/.ai-dev/summary.md +0 -14
- package/test-projects/express-api/.ai-dev/symbols.json +0 -7
- package/test-projects/express-api/.ai-dev/tech_stack.md +0 -38
- package/test-projects/express-api/.ai-dev/tools.json +0 -10
- package/test-projects/express-api/controllers/authController.js +0 -32
- package/test-projects/express-api/controllers/userController.js +0 -51
- package/test-projects/express-api/index.js +0 -30
- package/test-projects/express-api/middleware/authMiddleware.js +0 -30
- package/test-projects/express-api/models/userRepository.js +0 -25
- package/test-projects/express-api/package.json +0 -18
- package/test-projects/express-api/services/authService.js +0 -17
- package/test-projects/express-api/services/userService.js +0 -28
- package/test-projects/fastapi-app/.ai-dev/ai_context.md +0 -89
- package/test-projects/fastapi-app/.ai-dev/ai_rules.md +0 -47
- package/test-projects/fastapi-app/.ai-dev/architecture.md +0 -39
- package/test-projects/fastapi-app/.ai-dev/cache.json +0 -125
- package/test-projects/fastapi-app/.ai-dev/conventions.md +0 -51
- package/test-projects/fastapi-app/.ai-dev/dependencies.json +0 -244
- package/test-projects/fastapi-app/.ai-dev/entrypoints.md +0 -4
- package/test-projects/fastapi-app/.ai-dev/files.json +0 -154
- package/test-projects/fastapi-app/.ai-dev/graph/knowledge-graph.json +0 -15
- package/test-projects/fastapi-app/.ai-dev/graph/module-graph.json +0 -78
- package/test-projects/fastapi-app/.ai-dev/graph/symbol-graph.json +0 -1724
- package/test-projects/fastapi-app/.ai-dev/graph/symbol-references.json +0 -51
- package/test-projects/fastapi-app/.ai-dev/index-state.json +0 -217
- package/test-projects/fastapi-app/.ai-dev/modules.json +0 -16
- package/test-projects/fastapi-app/.ai-dev/project.json +0 -9
- package/test-projects/fastapi-app/.ai-dev/repo_map.json +0 -298
- package/test-projects/fastapi-app/.ai-dev/repo_map.md +0 -74
- package/test-projects/fastapi-app/.ai-dev/schema.json +0 -5
- package/test-projects/fastapi-app/.ai-dev/summary.md +0 -12
- package/test-projects/fastapi-app/.ai-dev/symbols.json +0 -1
- package/test-projects/fastapi-app/.ai-dev/tech_stack.md +0 -32
- package/test-projects/fastapi-app/.ai-dev/tools.json +0 -10
- package/test-projects/fastapi-app/README.md +0 -118
- package/test-projects/fastapi-app/app/database.py +0 -21
- package/test-projects/fastapi-app/app/dependencies.py +0 -107
- package/test-projects/fastapi-app/app/main.py +0 -47
- package/test-projects/fastapi-app/app/models.py +0 -149
- package/test-projects/fastapi-app/app/routers/auth.py +0 -117
- package/test-projects/fastapi-app/app/routers/posts.py +0 -272
- package/test-projects/fastapi-app/app/schemas.py +0 -191
- package/test-projects/fastapi-app/requirements.txt +0 -10
- package/test-projects/flask-app/.ai-dev/ai_context.md +0 -94
- package/test-projects/flask-app/.ai-dev/ai_rules.md +0 -47
- package/test-projects/flask-app/.ai-dev/architecture.md +0 -49
- package/test-projects/flask-app/.ai-dev/cache.json +0 -157
- package/test-projects/flask-app/.ai-dev/context/features/app.json +0 -25
- package/test-projects/flask-app/.ai-dev/context/flows/routes.json +0 -14
- package/test-projects/flask-app/.ai-dev/conventions.md +0 -51
- package/test-projects/flask-app/.ai-dev/dependencies.json +0 -298
- package/test-projects/flask-app/.ai-dev/entrypoints.md +0 -4
- package/test-projects/flask-app/.ai-dev/files.json +0 -194
- package/test-projects/flask-app/.ai-dev/graph/knowledge-graph.json +0 -60
- package/test-projects/flask-app/.ai-dev/graph/module-graph.json +0 -95
- package/test-projects/flask-app/.ai-dev/graph/symbol-graph.json +0 -1448
- package/test-projects/flask-app/.ai-dev/graph/symbol-references.json +0 -45
- package/test-projects/flask-app/.ai-dev/index-state.json +0 -273
- package/test-projects/flask-app/.ai-dev/modules.json +0 -21
- package/test-projects/flask-app/.ai-dev/project.json +0 -13
- package/test-projects/flask-app/.ai-dev/repo_map.json +0 -400
- package/test-projects/flask-app/.ai-dev/repo_map.md +0 -98
- package/test-projects/flask-app/.ai-dev/summary.md +0 -13
- package/test-projects/flask-app/.ai-dev/symbols.json +0 -1
- package/test-projects/flask-app/.ai-dev/tech_stack.md +0 -32
- package/test-projects/flask-app/.ai-dev/tools.json +0 -10
- package/test-projects/flask-app/README.md +0 -129
- package/test-projects/flask-app/app/__init__.py +0 -46
- package/test-projects/flask-app/app/api/__init__.py +0 -7
- package/test-projects/flask-app/app/api/routes.py +0 -122
- package/test-projects/flask-app/app/auth/__init__.py +0 -7
- package/test-projects/flask-app/app/auth/forms.py +0 -52
- package/test-projects/flask-app/app/auth/routes.py +0 -68
- package/test-projects/flask-app/app/blog/__init__.py +0 -7
- package/test-projects/flask-app/app/blog/forms.py +0 -35
- package/test-projects/flask-app/app/blog/routes.py +0 -140
- package/test-projects/flask-app/app/main/__init__.py +0 -7
- package/test-projects/flask-app/app/main/routes.py +0 -88
- package/test-projects/flask-app/app/models.py +0 -177
- package/test-projects/flask-app/config.py +0 -64
- package/test-projects/flask-app/requirements.txt +0 -10
- package/test-projects/laravel-app/.ai-dev/ai_context.md +0 -97
- package/test-projects/laravel-app/.ai-dev/ai_rules.md +0 -47
- package/test-projects/laravel-app/.ai-dev/architecture.md +0 -60
- package/test-projects/laravel-app/.ai-dev/cache.json +0 -161
- package/test-projects/laravel-app/.ai-dev/context/features/app.json +0 -21
- package/test-projects/laravel-app/.ai-dev/context/flows/.json +0 -9
- package/test-projects/laravel-app/.ai-dev/context/flows/category.json +0 -12
- package/test-projects/laravel-app/.ai-dev/context/flows/comment.json +0 -12
- package/test-projects/laravel-app/.ai-dev/context/flows/post.json +0 -12
- package/test-projects/laravel-app/.ai-dev/context/flows/unnamed.json +0 -9
- package/test-projects/laravel-app/.ai-dev/conventions.md +0 -51
- package/test-projects/laravel-app/.ai-dev/dependencies.json +0 -6
- package/test-projects/laravel-app/.ai-dev/entrypoints.md +0 -4
- package/test-projects/laravel-app/.ai-dev/files.json +0 -199
- package/test-projects/laravel-app/.ai-dev/graph/knowledge-graph.json +0 -98
- package/test-projects/laravel-app/.ai-dev/graph/module-graph.json +0 -30
- package/test-projects/laravel-app/.ai-dev/graph/symbol-graph.json +0 -5
- package/test-projects/laravel-app/.ai-dev/graph/symbol-references.json +0 -1
- package/test-projects/laravel-app/.ai-dev/index-state.json +0 -280
- package/test-projects/laravel-app/.ai-dev/modules.json +0 -29
- package/test-projects/laravel-app/.ai-dev/project.json +0 -17
- package/test-projects/laravel-app/.ai-dev/repo_map.json +0 -419
- package/test-projects/laravel-app/.ai-dev/repo_map.md +0 -106
- package/test-projects/laravel-app/.ai-dev/schema.json +0 -5
- package/test-projects/laravel-app/.ai-dev/summary.md +0 -15
- package/test-projects/laravel-app/.ai-dev/symbols.json +0 -1
- package/test-projects/laravel-app/.ai-dev/tech_stack.md +0 -34
- package/test-projects/laravel-app/.ai-dev/tools.json +0 -10
- package/test-projects/laravel-app/README.md +0 -107
- package/test-projects/laravel-app/app/Http/Controllers/Api/CategoryController.php +0 -88
- package/test-projects/laravel-app/app/Http/Controllers/Api/CommentController.php +0 -56
- package/test-projects/laravel-app/app/Http/Controllers/Api/PostController.php +0 -174
- package/test-projects/laravel-app/app/Http/Controllers/Controller.php +0 -12
- package/test-projects/laravel-app/app/Models/Category.php +0 -34
- package/test-projects/laravel-app/app/Models/Comment.php +0 -51
- package/test-projects/laravel-app/app/Models/Post.php +0 -108
- package/test-projects/laravel-app/app/Models/User.php +0 -85
- package/test-projects/laravel-app/bootstrap/app.php +0 -25
- package/test-projects/laravel-app/composer.json +0 -35
- package/test-projects/laravel-app/routes/api.php +0 -40
- package/test-projects/nestjs-backend/.ai-dev/ai_context.md +0 -111
- package/test-projects/nestjs-backend/.ai-dev/ai_rules.md +0 -52
- package/test-projects/nestjs-backend/.ai-dev/architecture.md +0 -49
- package/test-projects/nestjs-backend/.ai-dev/cache.json +0 -169
- package/test-projects/nestjs-backend/.ai-dev/context/features/src.json +0 -23
- package/test-projects/nestjs-backend/.ai-dev/context/flows/auth.controller.json +0 -14
- package/test-projects/nestjs-backend/.ai-dev/context/flows/auth.json +0 -10
- package/test-projects/nestjs-backend/.ai-dev/context/flows/users..json +0 -10
- package/test-projects/nestjs-backend/.ai-dev/context/flows/users.controller.json +0 -14
- package/test-projects/nestjs-backend/.ai-dev/context/flows/users.json +0 -10
- package/test-projects/nestjs-backend/.ai-dev/conventions.md +0 -52
- package/test-projects/nestjs-backend/.ai-dev/dependencies.json +0 -152
- package/test-projects/nestjs-backend/.ai-dev/entrypoints.md +0 -18
- package/test-projects/nestjs-backend/.ai-dev/files.json +0 -209
- package/test-projects/nestjs-backend/.ai-dev/graph/knowledge-graph.json +0 -132
- package/test-projects/nestjs-backend/.ai-dev/graph/module-graph.json +0 -29
- package/test-projects/nestjs-backend/.ai-dev/graph/symbol-graph.json +0 -304
- package/test-projects/nestjs-backend/.ai-dev/graph/symbol-references.json +0 -5
- package/test-projects/nestjs-backend/.ai-dev/index-state.json +0 -294
- package/test-projects/nestjs-backend/.ai-dev/modules.json +0 -19
- package/test-projects/nestjs-backend/.ai-dev/project.json +0 -18
- package/test-projects/nestjs-backend/.ai-dev/repo_map.json +0 -427
- package/test-projects/nestjs-backend/.ai-dev/repo_map.md +0 -104
- package/test-projects/nestjs-backend/.ai-dev/schema.json +0 -5
- package/test-projects/nestjs-backend/.ai-dev/summary.md +0 -13
- package/test-projects/nestjs-backend/.ai-dev/symbols.json +0 -1
- package/test-projects/nestjs-backend/.ai-dev/tech_stack.md +0 -38
- package/test-projects/nestjs-backend/.ai-dev/tools.json +0 -10
- package/test-projects/nestjs-backend/package.json +0 -22
- package/test-projects/nestjs-backend/src/app.module.ts +0 -8
- package/test-projects/nestjs-backend/src/auth/auth.controller.ts +0 -22
- package/test-projects/nestjs-backend/src/auth/auth.module.ts +0 -11
- package/test-projects/nestjs-backend/src/auth/auth.service.ts +0 -28
- package/test-projects/nestjs-backend/src/auth/dto/login.dto.ts +0 -4
- package/test-projects/nestjs-backend/src/auth/strategies/jwt.strategy.ts +0 -18
- package/test-projects/nestjs-backend/src/main.ts +0 -9
- package/test-projects/nestjs-backend/src/users/users.controller.ts +0 -32
- package/test-projects/nestjs-backend/src/users/users.module.ts +0 -10
- package/test-projects/nestjs-backend/src/users/users.service.ts +0 -42
- package/test-projects/nestjs-backend/tsconfig.json +0 -21
- package/test-projects/python-cli/.ai-dev/ai_context.md +0 -95
- package/test-projects/python-cli/.ai-dev/ai_rules.md +0 -47
- package/test-projects/python-cli/.ai-dev/architecture.md +0 -55
- package/test-projects/python-cli/.ai-dev/cache.json +0 -149
- package/test-projects/python-cli/.ai-dev/context/features/cli.json +0 -16
- package/test-projects/python-cli/.ai-dev/context/flows/list_.json +0 -9
- package/test-projects/python-cli/.ai-dev/context/flows/remove_.json +0 -9
- package/test-projects/python-cli/.ai-dev/conventions.md +0 -51
- package/test-projects/python-cli/.ai-dev/dependencies.json +0 -66
- package/test-projects/python-cli/.ai-dev/entrypoints.md +0 -4
- package/test-projects/python-cli/.ai-dev/files.json +0 -184
- package/test-projects/python-cli/.ai-dev/graph/knowledge-graph.json +0 -83
- package/test-projects/python-cli/.ai-dev/graph/module-graph.json +0 -31
- package/test-projects/python-cli/.ai-dev/graph/symbol-graph.json +0 -358
- package/test-projects/python-cli/.ai-dev/graph/symbol-references.json +0 -11
- package/test-projects/python-cli/.ai-dev/index-state.json +0 -259
- package/test-projects/python-cli/.ai-dev/modules.json +0 -21
- package/test-projects/python-cli/.ai-dev/project.json +0 -15
- package/test-projects/python-cli/.ai-dev/repo_map.json +0 -367
- package/test-projects/python-cli/.ai-dev/repo_map.md +0 -93
- package/test-projects/python-cli/.ai-dev/schema.json +0 -5
- package/test-projects/python-cli/.ai-dev/summary.md +0 -14
- package/test-projects/python-cli/.ai-dev/symbols.json +0 -1
- package/test-projects/python-cli/.ai-dev/tech_stack.md +0 -32
- package/test-projects/python-cli/.ai-dev/tools.json +0 -10
- package/test-projects/python-cli/__init__.py +0 -1
- package/test-projects/python-cli/cli/__init__.py +0 -1
- package/test-projects/python-cli/cli/add_command.py +0 -6
- package/test-projects/python-cli/cli/list_command.py +0 -7
- package/test-projects/python-cli/cli/remove_command.py +0 -6
- package/test-projects/python-cli/main.py +0 -34
- package/test-projects/python-cli/models/__init__.py +0 -2
- package/test-projects/python-cli/models/task.py +0 -19
- package/test-projects/python-cli/models/task_repository.py +0 -44
- package/test-projects/rails-app/.ai-dev/ai_context.md +0 -94
- package/test-projects/rails-app/.ai-dev/ai_rules.md +0 -47
- package/test-projects/rails-app/.ai-dev/architecture.md +0 -49
- package/test-projects/rails-app/.ai-dev/cache.json +0 -193
- package/test-projects/rails-app/.ai-dev/context/features/app.json +0 -24
- package/test-projects/rails-app/.ai-dev/context/features/config.json +0 -13
- package/test-projects/rails-app/.ai-dev/context/flows/application.json +0 -9
- package/test-projects/rails-app/.ai-dev/context/flows/application_.json +0 -9
- package/test-projects/rails-app/.ai-dev/context/flows/comments.json +0 -11
- package/test-projects/rails-app/.ai-dev/context/flows/comments_.json +0 -11
- package/test-projects/rails-app/.ai-dev/context/flows/posts.json +0 -11
- package/test-projects/rails-app/.ai-dev/context/flows/posts_.json +0 -11
- package/test-projects/rails-app/.ai-dev/context/flows/routes.json +0 -9
- package/test-projects/rails-app/.ai-dev/context/flows/users.json +0 -11
- package/test-projects/rails-app/.ai-dev/context/flows/users_.json +0 -11
- package/test-projects/rails-app/.ai-dev/conventions.md +0 -51
- package/test-projects/rails-app/.ai-dev/dependencies.json +0 -6
- package/test-projects/rails-app/.ai-dev/entrypoints.md +0 -4
- package/test-projects/rails-app/.ai-dev/files.json +0 -239
- package/test-projects/rails-app/.ai-dev/graph/knowledge-graph.json +0 -130
- package/test-projects/rails-app/.ai-dev/graph/module-graph.json +0 -27
- package/test-projects/rails-app/.ai-dev/graph/symbol-graph.json +0 -5
- package/test-projects/rails-app/.ai-dev/graph/symbol-references.json +0 -1
- package/test-projects/rails-app/.ai-dev/index-state.json +0 -336
- package/test-projects/rails-app/.ai-dev/modules.json +0 -26
- package/test-projects/rails-app/.ai-dev/project.json +0 -22
- package/test-projects/rails-app/.ai-dev/repo_map.json +0 -486
- package/test-projects/rails-app/.ai-dev/repo_map.md +0 -117
- package/test-projects/rails-app/.ai-dev/schema.json +0 -5
- package/test-projects/rails-app/.ai-dev/summary.md +0 -13
- package/test-projects/rails-app/.ai-dev/symbols.json +0 -1
- package/test-projects/rails-app/.ai-dev/tech_stack.md +0 -32
- package/test-projects/rails-app/.ai-dev/tools.json +0 -10
- package/test-projects/rails-app/Gemfile +0 -38
- package/test-projects/rails-app/README.md +0 -140
- package/test-projects/rails-app/Rakefile +0 -8
- package/test-projects/rails-app/app/controllers/api/comments_controller.rb +0 -75
- package/test-projects/rails-app/app/controllers/api/posts_controller.rb +0 -68
- package/test-projects/rails-app/app/controllers/api/users_controller.rb +0 -54
- package/test-projects/rails-app/app/controllers/application_controller.rb +0 -31
- package/test-projects/rails-app/app/models/comment.rb +0 -34
- package/test-projects/rails-app/app/models/post.rb +0 -36
- package/test-projects/rails-app/app/models/user.rb +0 -28
- package/test-projects/rails-app/app/services/post_service.rb +0 -92
- package/test-projects/rails-app/app/services/user_service.rb +0 -76
- package/test-projects/rails-app/config/application.rb +0 -27
- package/test-projects/rails-app/config/environment.rb +0 -7
- package/test-projects/rails-app/config/routes.rb +0 -15
- package/test-projects/react-app/.ai-dev/ai_context.md +0 -96
- package/test-projects/react-app/.ai-dev/architecture.md +0 -39
- package/test-projects/react-app/.ai-dev/cache.json +0 -153
- package/test-projects/react-app/.ai-dev/context/features/src.json +0 -18
- package/test-projects/react-app/.ai-dev/context/flows/UsersPage.json +0 -14
- package/test-projects/react-app/.ai-dev/context/flows/dashboard.json +0 -9
- package/test-projects/react-app/.ai-dev/context/flows/login.json +0 -9
- package/test-projects/react-app/.ai-dev/context/flows/users.json +0 -9
- package/test-projects/react-app/.ai-dev/dependencies.json +0 -128
- package/test-projects/react-app/.ai-dev/entrypoints.md +0 -4
- package/test-projects/react-app/.ai-dev/files.json +0 -189
- package/test-projects/react-app/.ai-dev/graph/knowledge-graph.json +0 -112
- package/test-projects/react-app/.ai-dev/graph/module-graph.json +0 -31
- package/test-projects/react-app/.ai-dev/graph/symbol-graph.json +0 -868
- package/test-projects/react-app/.ai-dev/graph/symbol-references.json +0 -31
- package/test-projects/react-app/.ai-dev/index-state.json +0 -266
- package/test-projects/react-app/.ai-dev/modules.json +0 -17
- package/test-projects/react-app/.ai-dev/project.json +0 -16
- package/test-projects/react-app/.ai-dev/repo_map.json +0 -391
- package/test-projects/react-app/.ai-dev/repo_map.md +0 -94
- package/test-projects/react-app/.ai-dev/schema.json +0 -5
- package/test-projects/react-app/.ai-dev/summary.md +0 -13
- package/test-projects/react-app/.ai-dev/symbols.json +0 -1
- package/test-projects/react-app/.ai-dev/tools.json +0 -10
- package/test-projects/react-app/package.json +0 -16
- package/test-projects/react-app/src/App.tsx +0 -21
- package/test-projects/react-app/src/context/AuthContext.tsx +0 -41
- package/test-projects/react-app/src/hooks/useAuth.ts +0 -10
- package/test-projects/react-app/src/main.tsx +0 -10
- package/test-projects/react-app/src/pages/DashboardPage.tsx +0 -17
- package/test-projects/react-app/src/pages/LoginPage.tsx +0 -41
- package/test-projects/react-app/src/pages/UsersPage.tsx +0 -36
- package/test-projects/react-app/src/services/userService.ts +0 -37
- package/test-projects/salesforce-cli/.ai-dev/ai_context.md +0 -89
- package/test-projects/salesforce-cli/.ai-dev/ai_rules.md +0 -47
- package/test-projects/salesforce-cli/.ai-dev/architecture.md +0 -39
- package/test-projects/salesforce-cli/.ai-dev/cache.json +0 -125
- package/test-projects/salesforce-cli/.ai-dev/context/features/force-app.json +0 -14
- package/test-projects/salesforce-cli/.ai-dev/context/flows/account.json +0 -9
- package/test-projects/salesforce-cli/.ai-dev/context/flows/opportunity.json +0 -9
- package/test-projects/salesforce-cli/.ai-dev/conventions.md +0 -51
- package/test-projects/salesforce-cli/.ai-dev/dependencies.json +0 -6
- package/test-projects/salesforce-cli/.ai-dev/entrypoints.md +0 -4
- package/test-projects/salesforce-cli/.ai-dev/files.json +0 -154
- package/test-projects/salesforce-cli/.ai-dev/graph/knowledge-graph.json +0 -64
- package/test-projects/salesforce-cli/.ai-dev/graph/module-graph.json +0 -13
- package/test-projects/salesforce-cli/.ai-dev/graph/symbol-graph.json +0 -148
- package/test-projects/salesforce-cli/.ai-dev/graph/symbol-references.json +0 -1
- package/test-projects/salesforce-cli/.ai-dev/index-state.json +0 -217
- package/test-projects/salesforce-cli/.ai-dev/modules.json +0 -12
- package/test-projects/salesforce-cli/.ai-dev/project.json +0 -14
- package/test-projects/salesforce-cli/.ai-dev/repo_map.json +0 -328
- package/test-projects/salesforce-cli/.ai-dev/repo_map.md +0 -80
- package/test-projects/salesforce-cli/.ai-dev/schema.json +0 -5
- package/test-projects/salesforce-cli/.ai-dev/summary.md +0 -13
- package/test-projects/salesforce-cli/.ai-dev/symbols.json +0 -1
- package/test-projects/salesforce-cli/.ai-dev/tech_stack.md +0 -31
- package/test-projects/salesforce-cli/.ai-dev/tools.json +0 -10
- package/test-projects/salesforce-cli/.forceignore +0 -27
- package/test-projects/salesforce-cli/force-app/main/default/classes/AccountController.cls +0 -24
- package/test-projects/salesforce-cli/force-app/main/default/classes/OpportunityController.cls +0 -25
- package/test-projects/salesforce-cli/force-app/main/default/objects/Project__c.object.xml +0 -45
- package/test-projects/salesforce-cli/force-app/main/default/triggers/AccountTrigger.trigger +0 -33
- package/test-projects/salesforce-cli/sfdx-project.json +0 -11
- package/test-projects/spring-boot-app/.ai-dev/ai_context.md +0 -91
- package/test-projects/spring-boot-app/.ai-dev/ai_rules.md +0 -48
- package/test-projects/spring-boot-app/.ai-dev/architecture.md +0 -39
- package/test-projects/spring-boot-app/.ai-dev/cache.json +0 -173
- package/test-projects/spring-boot-app/.ai-dev/context/features/src.json +0 -26
- package/test-projects/spring-boot-app/.ai-dev/context/flows/PostController.json +0 -19
- package/test-projects/spring-boot-app/.ai-dev/context/flows/UserController.json +0 -19
- package/test-projects/spring-boot-app/.ai-dev/context/flows/comment.json +0 -11
- package/test-projects/spring-boot-app/.ai-dev/context/flows/post.json +0 -14
- package/test-projects/spring-boot-app/.ai-dev/context/flows/user.json +0 -14
- package/test-projects/spring-boot-app/.ai-dev/conventions.md +0 -52
- package/test-projects/spring-boot-app/.ai-dev/dependencies.json +0 -326
- package/test-projects/spring-boot-app/.ai-dev/entrypoints.md +0 -4
- package/test-projects/spring-boot-app/.ai-dev/files.json +0 -214
- package/test-projects/spring-boot-app/.ai-dev/graph/knowledge-graph.json +0 -231
- package/test-projects/spring-boot-app/.ai-dev/graph/module-graph.json +0 -22
- package/test-projects/spring-boot-app/.ai-dev/graph/symbol-graph.json +0 -794
- package/test-projects/spring-boot-app/.ai-dev/graph/symbol-references.json +0 -70
- package/test-projects/spring-boot-app/.ai-dev/index-state.json +0 -301
- package/test-projects/spring-boot-app/.ai-dev/modules.json +0 -21
- package/test-projects/spring-boot-app/.ai-dev/project.json +0 -17
- package/test-projects/spring-boot-app/.ai-dev/repo_map.json +0 -461
- package/test-projects/spring-boot-app/.ai-dev/repo_map.md +0 -109
- package/test-projects/spring-boot-app/.ai-dev/schema.json +0 -5
- package/test-projects/spring-boot-app/.ai-dev/summary.md +0 -12
- package/test-projects/spring-boot-app/.ai-dev/symbols.json +0 -1
- package/test-projects/spring-boot-app/.ai-dev/tech_stack.md +0 -32
- package/test-projects/spring-boot-app/.ai-dev/tools.json +0 -10
- package/test-projects/spring-boot-app/.classpath +0 -57
- package/test-projects/spring-boot-app/.factorypath +0 -69
- package/test-projects/spring-boot-app/.project +0 -34
- package/test-projects/spring-boot-app/.settings/org.eclipse.core.resources.prefs +0 -4
- package/test-projects/spring-boot-app/.settings/org.eclipse.jdt.apt.core.prefs +0 -4
- package/test-projects/spring-boot-app/.settings/org.eclipse.jdt.core.prefs +0 -10
- package/test-projects/spring-boot-app/.settings/org.eclipse.m2e.core.prefs +0 -4
- package/test-projects/spring-boot-app/README.md +0 -122
- package/test-projects/spring-boot-app/pom.xml +0 -79
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/DemoApplication.java +0 -12
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/controllers/CommentController.java +0 -89
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/controllers/PostController.java +0 -92
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/controllers/UserController.java +0 -84
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/models/Comment.java +0 -38
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/models/Post.java +0 -56
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/models/User.java +0 -44
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/repositories/CommentRepository.java +0 -21
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/repositories/PostRepository.java +0 -18
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/repositories/UserRepository.java +0 -15
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/services/PostService.java +0 -83
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/services/UserService.java +0 -62
- package/test-projects/spring-boot-app/src/main/resources/application.properties +0 -22
- package/test-projects/spring-boot-app/target/classes/com/example/demo/DemoApplication.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/controllers/CommentController$CommentCreateRequest.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/controllers/CommentController$CommentUpdateRequest.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/controllers/CommentController.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/controllers/PostController$PostCreateRequest.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/controllers/PostController$PostUpdateRequest.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/controllers/PostController.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/controllers/UserController$UserCreateRequest.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/controllers/UserController$UserUpdateRequest.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/controllers/UserController.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/models/Comment.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/models/Post.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/models/User.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/repositories/CommentRepository.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/repositories/PostRepository.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/repositories/UserRepository.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/services/PostService.class +0 -0
- package/test-projects/spring-boot-app/target/classes/com/example/demo/services/UserService.class +0 -0
- package/tests/e2e/run-e2e.sh +0 -88
- /package/{test-projects/django-app/.ai-dev → ai-context}/tools.json +0 -0
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
# Laravel Blog API
|
|
2
|
-
|
|
3
|
-
A Laravel REST API for a blog application with user authentication, posts, comments, and categories.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- **User Management**: Authentication with Laravel Sanctum, user profiles
|
|
8
|
-
- **Blog Posts**: CRUD operations with publishing workflow
|
|
9
|
-
- **Comments**: Nested comments on posts
|
|
10
|
-
- **Categories**: Organize posts by categories
|
|
11
|
-
- **REST API**: Full REST API with Laravel
|
|
12
|
-
- **Authentication**: Token-based authentication
|
|
13
|
-
|
|
14
|
-
## Project Structure
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
laravel-app/
|
|
18
|
-
├── app/
|
|
19
|
-
│ ├── Http/
|
|
20
|
-
│ │ └── Controllers/
|
|
21
|
-
│ │ └── Api/ # API Controllers
|
|
22
|
-
│ └── Models/ # Eloquent Models
|
|
23
|
-
│ ├── Post.php
|
|
24
|
-
│ ├── Comment.php
|
|
25
|
-
│ ├── Category.php
|
|
26
|
-
│ └── User.php
|
|
27
|
-
├── routes/
|
|
28
|
-
│ └── api.php # API Routes
|
|
29
|
-
├── config/ # Configuration
|
|
30
|
-
└── composer.json
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## Models
|
|
34
|
-
|
|
35
|
-
### Post
|
|
36
|
-
- title, content, slug, published status
|
|
37
|
-
- Relationships: user, comments, categories
|
|
38
|
-
- Scopes: published(), drafts()
|
|
39
|
-
- Methods: publish(), unpublish()
|
|
40
|
-
|
|
41
|
-
### Comment
|
|
42
|
-
- content, post_id, user_id, parent_id (for nested)
|
|
43
|
-
- Relationships: post, user, parent
|
|
44
|
-
|
|
45
|
-
### Category
|
|
46
|
-
- name, slug, description
|
|
47
|
-
- Relationships: posts
|
|
48
|
-
|
|
49
|
-
### User
|
|
50
|
-
- name, email, bio, avatar, social links
|
|
51
|
-
- Relationships: posts, comments
|
|
52
|
-
- Methods: isAdmin(), publishedPostsCount()
|
|
53
|
-
|
|
54
|
-
## API Endpoints
|
|
55
|
-
|
|
56
|
-
### Posts
|
|
57
|
-
- `GET /api/posts` - List posts (filter by published, category, search)
|
|
58
|
-
- `POST /api/posts` - Create post
|
|
59
|
-
- `GET /api/posts/{post}` - Get single post
|
|
60
|
-
- `PUT /api/posts/{post}` - Update post
|
|
61
|
-
- `DELETE /api/posts/{post}` - Delete post
|
|
62
|
-
- `POST /api/posts/{post}/publish` - Publish post
|
|
63
|
-
- `POST /api/posts/{post}/unpublish` - Unpublish post
|
|
64
|
-
- `GET /api/my-posts` - Get current user's posts
|
|
65
|
-
|
|
66
|
-
### Categories
|
|
67
|
-
- `GET /api/categories` - List categories
|
|
68
|
-
- `POST /api/categories` - Create category
|
|
69
|
-
- `GET /api/categories/{category}` - Get category
|
|
70
|
-
- `GET /api/categories/{category}/posts` - Get posts in category
|
|
71
|
-
|
|
72
|
-
### Comments
|
|
73
|
-
- `GET /api/posts/{post}/comments` - Get post comments
|
|
74
|
-
- `POST /api/comments` - Create comment
|
|
75
|
-
- `DELETE /api/comments/{comment}` - Delete comment
|
|
76
|
-
|
|
77
|
-
## Setup
|
|
78
|
-
|
|
79
|
-
```bash
|
|
80
|
-
# Install dependencies
|
|
81
|
-
composer install
|
|
82
|
-
|
|
83
|
-
# Copy environment file
|
|
84
|
-
cp .env.example .env
|
|
85
|
-
|
|
86
|
-
# Generate application key
|
|
87
|
-
php artisan key:generate
|
|
88
|
-
|
|
89
|
-
# Run migrations
|
|
90
|
-
php artisan migrate
|
|
91
|
-
|
|
92
|
-
# Run server
|
|
93
|
-
php artisan serve
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## Testing with ai-first
|
|
97
|
-
|
|
98
|
-
```bash
|
|
99
|
-
# Generate AI context
|
|
100
|
-
ai-first init --root laravel-app
|
|
101
|
-
|
|
102
|
-
# Generate repository map
|
|
103
|
-
ai-first map --root laravel-app
|
|
104
|
-
|
|
105
|
-
# Generate SQLite index
|
|
106
|
-
ai-first index --root laravel-app
|
|
107
|
-
```
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
namespace App\Http\Controllers\Api;
|
|
4
|
-
|
|
5
|
-
use App\Http\Controllers\Controller;
|
|
6
|
-
use App\Models\Category;
|
|
7
|
-
use Illuminate\Http\Request;
|
|
8
|
-
use Illuminate\Http\JsonResponse;
|
|
9
|
-
use Illuminate\Support\Str;
|
|
10
|
-
|
|
11
|
-
class CategoryController extends Controller
|
|
12
|
-
{
|
|
13
|
-
/**
|
|
14
|
-
* Display a listing of the resource.
|
|
15
|
-
*/
|
|
16
|
-
public function index(): JsonResponse
|
|
17
|
-
{
|
|
18
|
-
$categories = Category::withCount('posts')->get();
|
|
19
|
-
return response()->json($categories);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Store a newly created resource in storage.
|
|
24
|
-
*/
|
|
25
|
-
public function store(Request $request): JsonResponse
|
|
26
|
-
{
|
|
27
|
-
$validated = $request->validate([
|
|
28
|
-
'name' => 'required|string|max:255|unique:categories',
|
|
29
|
-
'description' => 'nullable|string',
|
|
30
|
-
]);
|
|
31
|
-
|
|
32
|
-
$validated['slug'] = Str::slug($validated['name']);
|
|
33
|
-
|
|
34
|
-
$category = Category::create($validated);
|
|
35
|
-
|
|
36
|
-
return response()->json($category, 201);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Display the specified resource.
|
|
41
|
-
*/
|
|
42
|
-
public function show(Category $category): JsonResponse
|
|
43
|
-
{
|
|
44
|
-
return response()->json($category->loadCount('posts'));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Update the specified resource in storage.
|
|
49
|
-
*/
|
|
50
|
-
public function update(Request $request, Category $category): JsonResponse
|
|
51
|
-
{
|
|
52
|
-
$validated = $request->validate([
|
|
53
|
-
'name' => 'string|max:255|unique:categories,name,' . $category->id,
|
|
54
|
-
'description' => 'nullable|string',
|
|
55
|
-
]);
|
|
56
|
-
|
|
57
|
-
if (isset($validated['name'])) {
|
|
58
|
-
$validated['slug'] = Str::slug($validated['name']);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
$category->update($validated);
|
|
62
|
-
|
|
63
|
-
return response()->json($category);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Remove the specified resource from storage.
|
|
68
|
-
*/
|
|
69
|
-
public function destroy(Category $category): JsonResponse
|
|
70
|
-
{
|
|
71
|
-
$category->delete();
|
|
72
|
-
return response()->json(['message' => 'Category deleted successfully']);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Get posts in this category.
|
|
77
|
-
*/
|
|
78
|
-
public function posts(Category $category): JsonResponse
|
|
79
|
-
{
|
|
80
|
-
$posts = $category->posts()
|
|
81
|
-
->with(['user'])
|
|
82
|
-
->published()
|
|
83
|
-
->latest()
|
|
84
|
-
->paginate(10);
|
|
85
|
-
|
|
86
|
-
return response()->json($posts);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
namespace App\Http\Controllers\Api;
|
|
4
|
-
|
|
5
|
-
use App\Http\Controllers\Controller;
|
|
6
|
-
use App\Models\Comment;
|
|
7
|
-
use App\Models\Post;
|
|
8
|
-
use Illuminate\Http\Request;
|
|
9
|
-
use Illuminate\Http\JsonResponse;
|
|
10
|
-
|
|
11
|
-
class CommentController extends Controller
|
|
12
|
-
{
|
|
13
|
-
/**
|
|
14
|
-
* Display a listing of comments for a post.
|
|
15
|
-
*/
|
|
16
|
-
public function index(Post $post): JsonResponse
|
|
17
|
-
{
|
|
18
|
-
$comments = $post->comments()
|
|
19
|
-
->with(['user', 'replies'])
|
|
20
|
-
->topLevel()
|
|
21
|
-
->latest()
|
|
22
|
-
->paginate(20);
|
|
23
|
-
|
|
24
|
-
return response()->json($comments);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Store a newly created resource in storage.
|
|
29
|
-
*/
|
|
30
|
-
public function store(Request $request): JsonResponse
|
|
31
|
-
{
|
|
32
|
-
$validated = $request->validate([
|
|
33
|
-
'content' => 'required|string',
|
|
34
|
-
'post_id' => 'required|exists:posts,id',
|
|
35
|
-
'parent_id' => 'nullable|exists:comments,id',
|
|
36
|
-
]);
|
|
37
|
-
|
|
38
|
-
$validated['user_id'] = auth()->id();
|
|
39
|
-
|
|
40
|
-
$comment = Comment::create($validated);
|
|
41
|
-
|
|
42
|
-
return response()->json($comment->load('user'), 201);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Remove the specified resource from storage.
|
|
47
|
-
*/
|
|
48
|
-
public function destroy(Comment $comment): JsonResponse
|
|
49
|
-
{
|
|
50
|
-
$this->authorize('delete', $comment);
|
|
51
|
-
|
|
52
|
-
$comment->delete();
|
|
53
|
-
|
|
54
|
-
return response()->json(['message' => 'Comment deleted successfully']);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
namespace App\Http\Controllers\Api;
|
|
4
|
-
|
|
5
|
-
use App\Http\Controllers\Controller;
|
|
6
|
-
use App\Models\Post;
|
|
7
|
-
use App\Models\Category;
|
|
8
|
-
use Illuminate\Http\Request;
|
|
9
|
-
use Illuminate\Http\JsonResponse;
|
|
10
|
-
use Illuminate\Support\Str;
|
|
11
|
-
|
|
12
|
-
class PostController extends Controller
|
|
13
|
-
{
|
|
14
|
-
/**
|
|
15
|
-
* Display a listing of the resource.
|
|
16
|
-
*/
|
|
17
|
-
public function index(Request $request): JsonResponse
|
|
18
|
-
{
|
|
19
|
-
$query = Post::with(['user', 'categories']);
|
|
20
|
-
|
|
21
|
-
// Filter by published status
|
|
22
|
-
if ($request->has('published')) {
|
|
23
|
-
$request->boolean('published')
|
|
24
|
-
? $query->published()
|
|
25
|
-
: $query->drafts();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Filter by category
|
|
29
|
-
if ($request->has('category')) {
|
|
30
|
-
$query->whereHas('categories', function ($q) use ($request) {
|
|
31
|
-
$q->where('slug', $request->category);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Search
|
|
36
|
-
if ($request->has('search')) {
|
|
37
|
-
$search = $request->search;
|
|
38
|
-
$query->where(function ($q) use ($search) {
|
|
39
|
-
$q->where('title', 'like', "%{$search}%")
|
|
40
|
-
->orWhere('content', 'like', "%{$search}%");
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
$posts = $query->latest()->paginate(10);
|
|
45
|
-
|
|
46
|
-
return response()->json($posts);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Store a newly created resource in storage.
|
|
51
|
-
*/
|
|
52
|
-
public function store(Request $request): JsonResponse
|
|
53
|
-
{
|
|
54
|
-
$validated = $request->validate([
|
|
55
|
-
'title' => 'required|string|max:255',
|
|
56
|
-
'content' => 'required|string',
|
|
57
|
-
'published' => 'boolean',
|
|
58
|
-
'category_ids' => 'array',
|
|
59
|
-
'category_ids.*' => 'exists:categories,id',
|
|
60
|
-
]);
|
|
61
|
-
|
|
62
|
-
$validated['slug'] = Str::slug($validated['title']);
|
|
63
|
-
$validated['user_id'] = auth()->id();
|
|
64
|
-
|
|
65
|
-
$post = Post::create($validated);
|
|
66
|
-
|
|
67
|
-
if (isset($validated['category_ids'])) {
|
|
68
|
-
$post->categories()->attach($validated['category_ids']);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if ($validated['published'] ?? false) {
|
|
72
|
-
$post->publish();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return response()->json($post->load(['user', 'categories']), 201);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Display the specified resource.
|
|
80
|
-
*/
|
|
81
|
-
public function show(Post $post): JsonResponse
|
|
82
|
-
{
|
|
83
|
-
return response()->json($post->load(['user', 'categories', 'comments.user']));
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Update the specified resource in storage.
|
|
88
|
-
*/
|
|
89
|
-
public function update(Request $request, Post $post): JsonResponse
|
|
90
|
-
{
|
|
91
|
-
$this->authorize('update', $post);
|
|
92
|
-
|
|
93
|
-
$validated = $request->validate([
|
|
94
|
-
'title' => 'string|max:255',
|
|
95
|
-
'content' => 'string',
|
|
96
|
-
'published' => 'boolean',
|
|
97
|
-
'category_ids' => 'array',
|
|
98
|
-
'category_ids.*' => 'exists:categories,id',
|
|
99
|
-
]);
|
|
100
|
-
|
|
101
|
-
if (isset($validated['title'])) {
|
|
102
|
-
$validated['slug'] = Str::slug($validated['title']);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
$post->update($validated);
|
|
106
|
-
|
|
107
|
-
if (isset($validated['category_ids'])) {
|
|
108
|
-
$post->categories()->sync($validated['category_ids']);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Handle publish/unpublish
|
|
112
|
-
if (isset($validated['published'])) {
|
|
113
|
-
$validated['published'] ? $post->publish() : $post->unpublish();
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return response()->json($post->load(['user', 'categories']));
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Remove the specified resource from storage.
|
|
121
|
-
*/
|
|
122
|
-
public function destroy(Post $post): JsonResponse
|
|
123
|
-
{
|
|
124
|
-
$this->authorize('delete', $post);
|
|
125
|
-
|
|
126
|
-
$post->delete();
|
|
127
|
-
|
|
128
|
-
return response()->json(['message' => 'Post deleted successfully']);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Publish a post.
|
|
133
|
-
*/
|
|
134
|
-
public function publish(Post $post): JsonResponse
|
|
135
|
-
{
|
|
136
|
-
$this->authorize('update', $post);
|
|
137
|
-
|
|
138
|
-
$post->publish();
|
|
139
|
-
|
|
140
|
-
return response()->json([
|
|
141
|
-
'message' => 'Post published successfully',
|
|
142
|
-
'post' => $post
|
|
143
|
-
]);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Unpublish a post.
|
|
148
|
-
*/
|
|
149
|
-
public function unpublish(Post $post): JsonResponse
|
|
150
|
-
{
|
|
151
|
-
$this->authorize('update', $post);
|
|
152
|
-
|
|
153
|
-
$post->unpublish();
|
|
154
|
-
|
|
155
|
-
return response()->json([
|
|
156
|
-
'message' => 'Post unpublished successfully',
|
|
157
|
-
'post' => $post
|
|
158
|
-
]);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Get posts by current user.
|
|
163
|
-
*/
|
|
164
|
-
public function myPosts(Request $request): JsonResponse
|
|
165
|
-
{
|
|
166
|
-
$posts = auth()->user()
|
|
167
|
-
->posts()
|
|
168
|
-
->with(['categories'])
|
|
169
|
-
->latest()
|
|
170
|
-
->paginate(10);
|
|
171
|
-
|
|
172
|
-
return response()->json($posts);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
namespace App\Http\Controllers;
|
|
4
|
-
|
|
5
|
-
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
|
6
|
-
use Illuminate\Foundation\Validation\ValidatesRequests;
|
|
7
|
-
use Illuminate\Routing\Controller as BaseController;
|
|
8
|
-
|
|
9
|
-
class Controller extends BaseController
|
|
10
|
-
{
|
|
11
|
-
use AuthorizesRequests, ValidatesRequests;
|
|
12
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
namespace App\Models;
|
|
4
|
-
|
|
5
|
-
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
6
|
-
use Illuminate\Database\Eloquent\Model;
|
|
7
|
-
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
8
|
-
|
|
9
|
-
class Category extends Model
|
|
10
|
-
{
|
|
11
|
-
use HasFactory;
|
|
12
|
-
|
|
13
|
-
protected $fillable = [
|
|
14
|
-
'name',
|
|
15
|
-
'slug',
|
|
16
|
-
'description',
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Get the posts for the category.
|
|
21
|
-
*/
|
|
22
|
-
public function posts(): BelongsToMany
|
|
23
|
-
{
|
|
24
|
-
return $this->belongsToMany(Post::class);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Get route key name.
|
|
29
|
-
*/
|
|
30
|
-
public function getRouteKeyName(): string
|
|
31
|
-
{
|
|
32
|
-
return 'slug';
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
namespace App\Models;
|
|
4
|
-
|
|
5
|
-
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
6
|
-
use Illuminate\Database\Eloquent\Model;
|
|
7
|
-
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
8
|
-
|
|
9
|
-
class Comment extends Model
|
|
10
|
-
{
|
|
11
|
-
use HasFactory;
|
|
12
|
-
|
|
13
|
-
protected $fillable = [
|
|
14
|
-
'content',
|
|
15
|
-
'post_id',
|
|
16
|
-
'user_id',
|
|
17
|
-
'parent_id',
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Get the post that owns the comment.
|
|
22
|
-
*/
|
|
23
|
-
public function post(): BelongsTo
|
|
24
|
-
{
|
|
25
|
-
return $this->belongsTo(Post::class);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Get the user that owns the comment.
|
|
30
|
-
*/
|
|
31
|
-
public function user(): BelongsTo
|
|
32
|
-
{
|
|
33
|
-
return $this->belongsTo(User::class);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Get the parent comment (for replies).
|
|
38
|
-
*/
|
|
39
|
-
public function parent(): BelongsTo
|
|
40
|
-
{
|
|
41
|
-
return $this->belongsTo(Comment::class, 'parent_id');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Scope a query to only include top-level comments.
|
|
46
|
-
*/
|
|
47
|
-
public function scopeTopLevel($query)
|
|
48
|
-
{
|
|
49
|
-
return $query->whereNull('parent_id');
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
namespace App\Models;
|
|
4
|
-
|
|
5
|
-
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
6
|
-
use Illuminate\Database\Eloquent\Model;
|
|
7
|
-
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
8
|
-
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
9
|
-
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
10
|
-
|
|
11
|
-
class Post extends Model
|
|
12
|
-
{
|
|
13
|
-
use HasFactory;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The attributes that are mass assignable.
|
|
17
|
-
*
|
|
18
|
-
* @var array<int, string>
|
|
19
|
-
*/
|
|
20
|
-
protected $fillable = [
|
|
21
|
-
'title',
|
|
22
|
-
'content',
|
|
23
|
-
'slug',
|
|
24
|
-
'published',
|
|
25
|
-
'published_at',
|
|
26
|
-
'user_id',
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* The attributes that should be cast.
|
|
31
|
-
*
|
|
32
|
-
* @var array<string, string>
|
|
33
|
-
*/
|
|
34
|
-
protected $casts = [
|
|
35
|
-
'published' => 'boolean',
|
|
36
|
-
'published_at' => 'datetime',
|
|
37
|
-
];
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Get the user that owns the post.
|
|
41
|
-
*/
|
|
42
|
-
public function user(): BelongsTo
|
|
43
|
-
{
|
|
44
|
-
return $this->belongsTo(User::class);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Get the comments for the post.
|
|
49
|
-
*/
|
|
50
|
-
public function comments(): HasMany
|
|
51
|
-
{
|
|
52
|
-
return $this->hasMany(Comment::class);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Get the categories for the post.
|
|
57
|
-
*/
|
|
58
|
-
public function categories(): BelongsToMany
|
|
59
|
-
{
|
|
60
|
-
return $this->belongsToMany(Category::class);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Get the tags for the post.
|
|
65
|
-
*/
|
|
66
|
-
public function tags(): BelongsToMany
|
|
67
|
-
{
|
|
68
|
-
return $this->belongsToMany(Tag::class);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Scope a query to only include published posts.
|
|
73
|
-
*/
|
|
74
|
-
public function scopePublished($query)
|
|
75
|
-
{
|
|
76
|
-
return $query->where('published', true);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Scope a query to only include draft posts.
|
|
81
|
-
*/
|
|
82
|
-
public function scopeDrafts($query)
|
|
83
|
-
{
|
|
84
|
-
return $query->where('published', false);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Publish the post.
|
|
89
|
-
*/
|
|
90
|
-
public function publish(): void
|
|
91
|
-
{
|
|
92
|
-
$this->update([
|
|
93
|
-
'published' => true,
|
|
94
|
-
'published_at' => now(),
|
|
95
|
-
]);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Unpublish the post.
|
|
100
|
-
*/
|
|
101
|
-
public function unpublish(): void
|
|
102
|
-
{
|
|
103
|
-
$this->update([
|
|
104
|
-
'published' => false,
|
|
105
|
-
'published_at' => null,
|
|
106
|
-
]);
|
|
107
|
-
}
|
|
108
|
-
}
|