ai-first-cli 1.3.0 → 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/.github/workflows/publish.yml +4 -1
- 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/test_adapters.mjs +11 -11
- 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/CONTRIBUTING.md +0 -89
- package/FLOW.md +0 -129
- package/install.sh +0 -188
- package/run-all-tests.sh +0 -184
- 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,140 +0,0 @@
|
|
|
1
|
-
# Rails Blog API
|
|
2
|
-
|
|
3
|
-
A RESTful Rails API for a blog application with users, posts, and comments.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
This is a Rails 7.1 API-only application that provides endpoints for managing:
|
|
8
|
-
- **Users** - Blog authors and commenters
|
|
9
|
-
- **Posts** - Blog articles with title, content, and body
|
|
10
|
-
- **Comments** - User comments on posts
|
|
11
|
-
|
|
12
|
-
## Project Structure
|
|
13
|
-
|
|
14
|
-
```
|
|
15
|
-
rails-app/
|
|
16
|
-
├── app/
|
|
17
|
-
│ ├── controllers/
|
|
18
|
-
│ │ ├── application_controller.rb
|
|
19
|
-
│ │ └── api/
|
|
20
|
-
│ │ ├── users_controller.rb
|
|
21
|
-
│ │ ├── posts_controller.rb
|
|
22
|
-
│ │ └── comments_controller.rb
|
|
23
|
-
│ ├── models/
|
|
24
|
-
│ │ ├── user.rb
|
|
25
|
-
│ │ ├── post.rb
|
|
26
|
-
│ │ └── comment.rb
|
|
27
|
-
│ └── services/
|
|
28
|
-
│ ├── user_service.rb
|
|
29
|
-
│ └── post_service.rb
|
|
30
|
-
├── config/
|
|
31
|
-
│ ├── application.rb
|
|
32
|
-
│ ├── environment.rb
|
|
33
|
-
│ └── routes.rb
|
|
34
|
-
├── Gemfile
|
|
35
|
-
├── Rakefile
|
|
36
|
-
└── README.md
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Models
|
|
40
|
-
|
|
41
|
-
### User
|
|
42
|
-
- `name` - User's name
|
|
43
|
-
- `email` - Unique email address
|
|
44
|
-
- `active` - Active status flag
|
|
45
|
-
- Has many `posts` and `comments`
|
|
46
|
-
|
|
47
|
-
### Post
|
|
48
|
-
- `title` - Post title
|
|
49
|
-
- `content` - Short content/summary
|
|
50
|
-
- `body` - Full post body
|
|
51
|
-
- `published` - Publication status
|
|
52
|
-
- `published_at` - Publication timestamp
|
|
53
|
-
- Belongs to `user`, has many `comments`
|
|
54
|
-
|
|
55
|
-
### Comment
|
|
56
|
-
- `content` - Comment text
|
|
57
|
-
- `approved` - Moderation status
|
|
58
|
-
- `approved_at` - Approval timestamp
|
|
59
|
-
- Belongs to `post` and `user`
|
|
60
|
-
|
|
61
|
-
## API Endpoints
|
|
62
|
-
|
|
63
|
-
### Users
|
|
64
|
-
| Method | Endpoint | Description |
|
|
65
|
-
|--------|----------|-------------|
|
|
66
|
-
| GET | `/api/users` | List all active users |
|
|
67
|
-
| GET | `/api/users/:id` | Get a specific user |
|
|
68
|
-
| POST | `/api/users` | Create a new user |
|
|
69
|
-
| PUT | `/api/users/:id` | Update a user |
|
|
70
|
-
| DELETE | `/api/users/:id` | Delete a user |
|
|
71
|
-
|
|
72
|
-
### Posts
|
|
73
|
-
| Method | Endpoint | Description |
|
|
74
|
-
|--------|----------|-------------|
|
|
75
|
-
| GET | `/api/posts` | List all posts |
|
|
76
|
-
| GET | `/api/posts/:id` | Get a specific post |
|
|
77
|
-
| POST | `/api/posts` | Create a new post |
|
|
78
|
-
| PUT | `/api/posts/:id` | Update a post |
|
|
79
|
-
| DELETE | `/api/posts/:id` | Delete a post |
|
|
80
|
-
| POST | `/api/posts/:id/publish` | Publish a post |
|
|
81
|
-
| POST | `/api/posts/:id/unpublish` | Unpublish a post |
|
|
82
|
-
|
|
83
|
-
### Comments
|
|
84
|
-
| Method | Endpoint | Description |
|
|
85
|
-
|--------|----------|-------------|
|
|
86
|
-
| GET | `/api/posts/:post_id/comments` | List comments for a post |
|
|
87
|
-
| GET | `/api/posts/:post_id/comments/:id` | Get a specific comment |
|
|
88
|
-
| POST | `/api/posts/:post_id/comments` | Create a comment |
|
|
89
|
-
| PUT | `/api/posts/:post_id/comments/:id` | Update a comment |
|
|
90
|
-
| DELETE | `/api/posts/:post_id/comments/:id` | Delete a comment |
|
|
91
|
-
| POST | `/api/posts/:post_id/comments/:id/approve` | Approve a comment |
|
|
92
|
-
| POST | `/api/posts/:post_id/comments/:id/reject` | Reject a comment |
|
|
93
|
-
|
|
94
|
-
## Services
|
|
95
|
-
|
|
96
|
-
### UserService
|
|
97
|
-
- `create_user(attributes)` - Create a new user
|
|
98
|
-
- `find_by_email(email)` - Find user by email
|
|
99
|
-
- `find_user(id)` - Find user by ID
|
|
100
|
-
- `update_user(id, attributes)` - Update user
|
|
101
|
-
- `delete_user(id)` - Delete user
|
|
102
|
-
- `active_users` - Get all active users
|
|
103
|
-
- `deactivate_user(id)` - Deactivate a user
|
|
104
|
-
- `activate_user(id)` - Activate a user
|
|
105
|
-
|
|
106
|
-
### PostService
|
|
107
|
-
- `create_post(attributes)` - Create a new post
|
|
108
|
-
- `find_post(id)` - Find post by ID
|
|
109
|
-
- `update_post(id, attributes)` - Update post
|
|
110
|
-
- `delete_post(id)` - Delete post
|
|
111
|
-
- `publish(id)` - Publish a post
|
|
112
|
-
- `unpublish(id)` - Unpublish a post
|
|
113
|
-
- `published_posts` - Get all published posts
|
|
114
|
-
- `draft_posts` - Get all draft posts
|
|
115
|
-
- `posts_by_user(user_id)` - Get posts by user
|
|
116
|
-
- `search(query)` - Search posts by title/content
|
|
117
|
-
|
|
118
|
-
## Setup
|
|
119
|
-
|
|
120
|
-
```bash
|
|
121
|
-
# Install dependencies
|
|
122
|
-
bundle install
|
|
123
|
-
|
|
124
|
-
# Setup database
|
|
125
|
-
rails db:create db:migrate
|
|
126
|
-
|
|
127
|
-
# Start server
|
|
128
|
-
rails server
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
## Testing
|
|
132
|
-
|
|
133
|
-
```bash
|
|
134
|
-
# Run tests
|
|
135
|
-
bundle exec rspec
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
## License
|
|
139
|
-
|
|
140
|
-
MIT License
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
|
4
|
-
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
|
5
|
-
|
|
6
|
-
require_relative "config/application"
|
|
7
|
-
|
|
8
|
-
Rails.application.load_tasks
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Api
|
|
4
|
-
class CommentsController < ApplicationController
|
|
5
|
-
before_action :set_post
|
|
6
|
-
before_action :set_comment, only: %i[show update destroy]
|
|
7
|
-
|
|
8
|
-
# GET /api/posts/:post_id/comments
|
|
9
|
-
def index
|
|
10
|
-
@comments = @post.comments.includes(:user).recent
|
|
11
|
-
@comments = @comments.approved if params[:approved] == "true"
|
|
12
|
-
@comments = @comments.pending if params[:approved] == "false"
|
|
13
|
-
render_success @comments
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
# GET /api/posts/:post_id/comments/:id
|
|
17
|
-
def show
|
|
18
|
-
render_success @comment.as_json(include: :user)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# POST /api/posts/:post_id/comments
|
|
22
|
-
def create
|
|
23
|
-
@comment = @post.comments.build(comment_params)
|
|
24
|
-
|
|
25
|
-
if @comment.save
|
|
26
|
-
render_success @comment, status: :created
|
|
27
|
-
else
|
|
28
|
-
render_error @comment.errors.full_messages.join(", "), status: :unprocessable_entity
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# PATCH/PUT /api/posts/:post_id/comments/:id
|
|
33
|
-
def update
|
|
34
|
-
if @comment.update(comment_params)
|
|
35
|
-
render_success @comment
|
|
36
|
-
else
|
|
37
|
-
render_error @comment.errors.full_messages.join(", "), status: :unprocessable_entity
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# DELETE /api/posts/:post_id/comments/:id
|
|
42
|
-
def destroy
|
|
43
|
-
@comment.destroy
|
|
44
|
-
head :no_content
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
# POST /api/posts/:post_id/comments/:id/approve
|
|
48
|
-
def approve
|
|
49
|
-
@comment = @post.comments.find(params[:id])
|
|
50
|
-
@comment.approve!
|
|
51
|
-
render_success @comment
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# POST /api/posts/:post_id/comments/:id/reject
|
|
55
|
-
def reject
|
|
56
|
-
@comment = @post.comments.find(params[:id])
|
|
57
|
-
@comment.reject!
|
|
58
|
-
render_success @comment
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
private
|
|
62
|
-
|
|
63
|
-
def set_post
|
|
64
|
-
@post = Post.find(params[:post_id])
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def set_comment
|
|
68
|
-
@comment = @post.comments.find(params[:id])
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def comment_params
|
|
72
|
-
params.require(:comment).permit(:content, :user_id, :approved)
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
end
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Api
|
|
4
|
-
class PostsController < ApplicationController
|
|
5
|
-
before_action :set_post, only: %i[show update destroy]
|
|
6
|
-
|
|
7
|
-
# GET /api/posts
|
|
8
|
-
def index
|
|
9
|
-
@posts = Post.includes(:user, :comments).recent
|
|
10
|
-
@posts = @posts.published if params[:published] == "true"
|
|
11
|
-
@posts = @posts.draft if params[:published] == "false"
|
|
12
|
-
render_success @posts
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# GET /api/posts/:id
|
|
16
|
-
def show
|
|
17
|
-
render_success @post.as_json(include: %i[user comments])
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# POST /api/posts
|
|
21
|
-
def create
|
|
22
|
-
@post = PostService.create_post(post_params)
|
|
23
|
-
|
|
24
|
-
if @post.persisted?
|
|
25
|
-
render_success @post, status: :created
|
|
26
|
-
else
|
|
27
|
-
render_error @post.errors.full_messages.join(", "), status: :unprocessable_entity
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
# PATCH/PUT /api/posts/:id
|
|
32
|
-
def update
|
|
33
|
-
if @post.update(post_params)
|
|
34
|
-
render_success @post
|
|
35
|
-
else
|
|
36
|
-
render_error @post.errors.full_messages.join(", "), status: :unprocessable_entity
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
# DELETE /api/posts/:id
|
|
41
|
-
def destroy
|
|
42
|
-
@post.destroy
|
|
43
|
-
head :no_content
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
# POST /api/posts/:id/publish
|
|
47
|
-
def publish
|
|
48
|
-
@post = PostService.publish(params[:id])
|
|
49
|
-
render_success @post
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
# POST /api/posts/:id/unpublish
|
|
53
|
-
def unpublish
|
|
54
|
-
@post = PostService.unpublish(params[:id])
|
|
55
|
-
render_success @post
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
private
|
|
59
|
-
|
|
60
|
-
def set_post
|
|
61
|
-
@post = Post.find(params[:id])
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def post_params
|
|
65
|
-
params.require(:post).permit(:title, :content, :body, :user_id, :published)
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
end
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Api
|
|
4
|
-
class UsersController < ApplicationController
|
|
5
|
-
before_action :set_user, only: %i[show update destroy]
|
|
6
|
-
|
|
7
|
-
# GET /api/users
|
|
8
|
-
def index
|
|
9
|
-
@users = User.active.recent
|
|
10
|
-
render_success @users
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
# GET /api/users/:id
|
|
14
|
-
def show
|
|
15
|
-
render_success @user
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
# POST /api/users
|
|
19
|
-
def create
|
|
20
|
-
@user = UserService.create_user(user_params)
|
|
21
|
-
|
|
22
|
-
if @user.persisted?
|
|
23
|
-
render_success @user, status: :created
|
|
24
|
-
else
|
|
25
|
-
render_error @user.errors.full_messages.join(", "), status: :unprocessable_entity
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# PATCH/PUT /api/users/:id
|
|
30
|
-
def update
|
|
31
|
-
if @user.update(user_params)
|
|
32
|
-
render_success @user
|
|
33
|
-
else
|
|
34
|
-
render_error @user.errors.full_messages.join(", "), status: :unprocessable_entity
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
# DELETE /api/users/:id
|
|
39
|
-
def destroy
|
|
40
|
-
@user.destroy
|
|
41
|
-
head :no_content
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
private
|
|
45
|
-
|
|
46
|
-
def set_user
|
|
47
|
-
@user = User.find(params[:id])
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def user_params
|
|
51
|
-
params.require(:user).permit(:name, :email)
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class ApplicationController < ActionController::API
|
|
4
|
-
# Common error handling
|
|
5
|
-
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
|
|
6
|
-
rescue_from ActiveRecord::RecordInvalid, with: :record_invalid
|
|
7
|
-
rescue_from StandardError, with: :internal_error
|
|
8
|
-
|
|
9
|
-
private
|
|
10
|
-
|
|
11
|
-
def record_not_found(exception)
|
|
12
|
-
render json: { error: "Record not found", message: exception.message }, status: :not_found
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def record_invalid(exception)
|
|
16
|
-
render json: { error: "Validation failed", errors: exception.record.errors.full_messages }, status: :unprocessable_entity
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def internal_error(exception)
|
|
20
|
-
Rails.logger.error "Internal error: #{exception.message}"
|
|
21
|
-
render json: { error: "Internal server error" }, status: :internal_server_error
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def render_success(data, status: :ok)
|
|
25
|
-
render json: { data: data }, status: status
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def render_error(message, status: :bad_request)
|
|
29
|
-
render json: { error: message }, status: status
|
|
30
|
-
end
|
|
31
|
-
end
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Comment < ApplicationRecord
|
|
4
|
-
# Validations
|
|
5
|
-
validates :content, presence: true, length: { minimum: 1, maximum: 2000 }
|
|
6
|
-
validates :post_id, presence: true
|
|
7
|
-
validates :user_id, presence: true
|
|
8
|
-
|
|
9
|
-
# Associations
|
|
10
|
-
belongs_to :post
|
|
11
|
-
belongs_to :user
|
|
12
|
-
|
|
13
|
-
# Scopes
|
|
14
|
-
scope :approved, -> { where(approved: true) }
|
|
15
|
-
scope :pending, -> { where(approved: false) }
|
|
16
|
-
scope :recent, -> { order(created_at: :desc) }
|
|
17
|
-
|
|
18
|
-
# Instance methods
|
|
19
|
-
def approve!
|
|
20
|
-
update!(approved: true, approved_at: Time.current)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def reject!
|
|
24
|
-
update!(approved: false, approved_at: nil)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def approved?
|
|
28
|
-
approved == true
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def pending?
|
|
32
|
-
!approved?
|
|
33
|
-
end
|
|
34
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Post < ApplicationRecord
|
|
4
|
-
# Validations
|
|
5
|
-
validates :title, presence: true, length: { minimum: 5, maximum: 200 }
|
|
6
|
-
validates :content, presence: true
|
|
7
|
-
validates :body, presence: true
|
|
8
|
-
validates :user_id, presence: true
|
|
9
|
-
|
|
10
|
-
# Associations
|
|
11
|
-
belongs_to :user
|
|
12
|
-
has_many :comments, dependent: :destroy
|
|
13
|
-
|
|
14
|
-
# Scopes
|
|
15
|
-
scope :published, -> { where(published: true) }
|
|
16
|
-
scope :draft, -> { where(published: false) }
|
|
17
|
-
scope :recent, -> { order(created_at: :desc) }
|
|
18
|
-
scope :by_user, ->(user_id) { where(user_id: user_id) }
|
|
19
|
-
|
|
20
|
-
# Instance methods
|
|
21
|
-
def publish!
|
|
22
|
-
update!(published: true, published_at: Time.current)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def unpublish!
|
|
26
|
-
update!(published: false, published_at: nil)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def published?
|
|
30
|
-
published == true
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def draft?
|
|
34
|
-
!published?
|
|
35
|
-
end
|
|
36
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class User < ApplicationRecord
|
|
4
|
-
# Validations
|
|
5
|
-
validates :name, presence: true, length: { minimum: 2, maximum: 100 }
|
|
6
|
-
validates :email, presence: true, uniqueness: true, format: { with: URI::MailTo::EMAIL_REGEXP }
|
|
7
|
-
|
|
8
|
-
# Associations
|
|
9
|
-
has_many :posts, dependent: :destroy
|
|
10
|
-
has_many :comments, dependent: :destroy
|
|
11
|
-
|
|
12
|
-
# Scopes
|
|
13
|
-
scope :active, -> { where(active: true) }
|
|
14
|
-
scope :recent, -> { order(created_at: :desc) }
|
|
15
|
-
|
|
16
|
-
# Instance methods
|
|
17
|
-
def full_name
|
|
18
|
-
name
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def deactivate!
|
|
22
|
-
update!(active: false)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def activate!
|
|
26
|
-
update!(active: true)
|
|
27
|
-
end
|
|
28
|
-
end
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class PostService
|
|
4
|
-
# Create a new post with the given attributes
|
|
5
|
-
#
|
|
6
|
-
# @param attributes [Hash] Post attributes (title, content, body, user_id)
|
|
7
|
-
# @return [Post] The created post
|
|
8
|
-
def self.create_post(attributes)
|
|
9
|
-
Post.create!(attributes)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
# Find a post by ID
|
|
13
|
-
#
|
|
14
|
-
# @param id [Integer] The post ID
|
|
15
|
-
# @return [Post] The found post
|
|
16
|
-
# @raise [ActiveRecord::RecordNotFound] If post not found
|
|
17
|
-
def self.find_post(id)
|
|
18
|
-
Post.includes(:user, :comments).find(id)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# Update a post with the given attributes
|
|
22
|
-
#
|
|
23
|
-
# @param id [Integer] The post ID
|
|
24
|
-
# @param attributes [Hash] Attributes to update
|
|
25
|
-
# @return [Post] The updated post
|
|
26
|
-
def self.update_post(id, attributes)
|
|
27
|
-
post = Post.find(id)
|
|
28
|
-
post.update!(attributes)
|
|
29
|
-
post
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# Delete a post by ID
|
|
33
|
-
#
|
|
34
|
-
# @param id [Integer] The post ID
|
|
35
|
-
# @return [Boolean] True if deleted
|
|
36
|
-
def self.delete_post(id)
|
|
37
|
-
post = Post.find(id)
|
|
38
|
-
post.destroy!
|
|
39
|
-
true
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# Publish a post
|
|
43
|
-
#
|
|
44
|
-
# @param id [Integer] The post ID
|
|
45
|
-
# @return [Post] The published post
|
|
46
|
-
def self.publish(id)
|
|
47
|
-
post = Post.find(id)
|
|
48
|
-
post.publish!
|
|
49
|
-
post
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
# Unpublish a post
|
|
53
|
-
#
|
|
54
|
-
# @param id [Integer] The post ID
|
|
55
|
-
# @return [Post] The unpublished post
|
|
56
|
-
def self.unpublish(id)
|
|
57
|
-
post = Post.find(id)
|
|
58
|
-
post.unpublish!
|
|
59
|
-
post
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
# Get all published posts
|
|
63
|
-
#
|
|
64
|
-
# @return [Array<Post>] List of published posts
|
|
65
|
-
def self.published_posts
|
|
66
|
-
Post.published.recent.includes(:user)
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
# Get all draft posts
|
|
70
|
-
#
|
|
71
|
-
# @return [Array<Post>] List of draft posts
|
|
72
|
-
def self.draft_posts
|
|
73
|
-
Post.draft.recent.includes(:user)
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
# Get posts by user
|
|
77
|
-
#
|
|
78
|
-
# @param user_id [Integer] The user ID
|
|
79
|
-
# @return [Array<Post>] List of posts by the user
|
|
80
|
-
def self.posts_by_user(user_id)
|
|
81
|
-
Post.by_user(user_id).recent.includes(:comments)
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
# Search posts by title or content
|
|
85
|
-
#
|
|
86
|
-
# @param query [String] The search query
|
|
87
|
-
# @return [Array<Post>] Matching posts
|
|
88
|
-
def self.search(query)
|
|
89
|
-
Post.where("title LIKE ? OR content LIKE ? OR body LIKE ?", "%#{query}%", "%#{query}%", "%#{query}%")
|
|
90
|
-
.recent
|
|
91
|
-
end
|
|
92
|
-
end
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class UserService
|
|
4
|
-
# Create a new user with the given attributes
|
|
5
|
-
#
|
|
6
|
-
# @param attributes [Hash] User attributes (name, email)
|
|
7
|
-
# @return [User] The created user
|
|
8
|
-
def self.create_user(attributes)
|
|
9
|
-
User.create!(attributes)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
# Find a user by email
|
|
13
|
-
#
|
|
14
|
-
# @param email [String] The email to search for
|
|
15
|
-
# @return [User, nil] The found user or nil
|
|
16
|
-
def self.find_by_email(email)
|
|
17
|
-
User.find_by(email: email)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# Find a user by ID
|
|
21
|
-
#
|
|
22
|
-
# @param id [Integer] The user ID
|
|
23
|
-
# @return [User] The found user
|
|
24
|
-
# @raise [ActiveRecord::RecordNotFound] If user not found
|
|
25
|
-
def self.find_user(id)
|
|
26
|
-
User.find(id)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# Update a user with the given attributes
|
|
30
|
-
#
|
|
31
|
-
# @param id [Integer] The user ID
|
|
32
|
-
# @param attributes [Hash] Attributes to update
|
|
33
|
-
# @return [User] The updated user
|
|
34
|
-
def self.update_user(id, attributes)
|
|
35
|
-
user = User.find(id)
|
|
36
|
-
user.update!(attributes)
|
|
37
|
-
user
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
# Delete a user by ID
|
|
41
|
-
#
|
|
42
|
-
# @param id [Integer] The user ID
|
|
43
|
-
# @return [Boolean] True if deleted
|
|
44
|
-
def self.delete_user(id)
|
|
45
|
-
user = User.find(id)
|
|
46
|
-
user.destroy!
|
|
47
|
-
true
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
# Get all active users
|
|
51
|
-
#
|
|
52
|
-
# @return [Array<User>] List of active users
|
|
53
|
-
def self.active_users
|
|
54
|
-
User.active.recent
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
# Deactivate a user
|
|
58
|
-
#
|
|
59
|
-
# @param id [Integer] The user ID
|
|
60
|
-
# @return [User] The deactivated user
|
|
61
|
-
def self.deactivate_user(id)
|
|
62
|
-
user = User.find(id)
|
|
63
|
-
user.deactivate!
|
|
64
|
-
user
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
# Activate a user
|
|
68
|
-
#
|
|
69
|
-
# @param id [Integer] The user ID
|
|
70
|
-
# @return [User] The activated user
|
|
71
|
-
def self.activate_user(id)
|
|
72
|
-
user = User.find(id)
|
|
73
|
-
user.activate!
|
|
74
|
-
user
|
|
75
|
-
end
|
|
76
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "environment"
|
|
4
|
-
|
|
5
|
-
module RailsApp
|
|
6
|
-
class Application < Rails::Application
|
|
7
|
-
# Initialize configuration defaults for originally generated Rails version
|
|
8
|
-
config.load_defaults 7.1
|
|
9
|
-
|
|
10
|
-
# Configuration for the application, engines, and railties goes here.
|
|
11
|
-
#
|
|
12
|
-
# These settings can be overridden in specific environments using the files
|
|
13
|
-
# in config/environments, which are processed later.
|
|
14
|
-
#
|
|
15
|
-
# config.time_zone = "Central Time (US & Canada)"
|
|
16
|
-
# config.eager_load_paths << Rails.root.join("extras")
|
|
17
|
-
|
|
18
|
-
# Only loads a smaller set of middleware suitable for API only apps
|
|
19
|
-
config.api_only = true
|
|
20
|
-
|
|
21
|
-
# Enable service objects directory
|
|
22
|
-
config.autoload_paths << Rails.root.join("app/services")
|
|
23
|
-
|
|
24
|
-
# Enable Zeitwerk autoloading
|
|
25
|
-
config.autoloader = :zeitwerk
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
Rails.application.routes.draw do
|
|
4
|
-
# API namespace for versioned endpoints
|
|
5
|
-
namespace :api do
|
|
6
|
-
resources :users, only: %i[index show create update destroy]
|
|
7
|
-
|
|
8
|
-
resources :posts, only: %i[index show create update destroy] do
|
|
9
|
-
resources :comments, only: %i[index show create update destroy]
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
# Health check endpoint
|
|
14
|
-
get "/health", to: "health#show"
|
|
15
|
-
end
|