ai-first-cli 1.1.5 → 1.2.0
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 → .ai-dev}/ai_context.md +8 -8
- package/{ai → .ai-dev}/ai_rules.md +2 -2
- package/{ai → .ai-dev}/architecture.md +38 -23
- package/.ai-dev/cache.json +2349 -0
- package/.ai-dev/context/features/test-projects.json +69 -0
- package/.ai-dev/context/flows/api.json +9 -0
- package/{ai → .ai-dev}/context/flows/auth.json +2 -1
- package/.ai-dev/context/flows/category.json +12 -0
- package/.ai-dev/context/flows/comment.json +16 -0
- package/.ai-dev/context/flows/post.json +18 -0
- package/.ai-dev/context/flows/routes.json +19 -0
- package/.ai-dev/context/flows/user.json +20 -0
- package/.ai-dev/context/flows/views.json +14 -0
- package/.ai-dev/dependencies.json +2946 -0
- package/.ai-dev/files.json +2944 -0
- package/{ai → .ai-dev}/git/commit-activity.json +39 -126
- package/{ai → .ai-dev}/git/recent-files.json +6 -6
- package/.ai-dev/git/recent-flows.json +1 -0
- package/.ai-dev/graph/knowledge-graph.json +44314 -0
- package/.ai-dev/graph/module-graph.json +866 -0
- package/.ai-dev/graph/symbol-graph.json +200622 -0
- package/.ai-dev/graph/symbol-references.json +6778 -0
- package/.ai-dev/hierarchy.json +20 -0
- package/.ai-dev/index-state.json +4123 -0
- package/.ai-dev/index.db +0 -0
- package/.ai-dev/modules.json +532 -0
- package/{ai → .ai-dev}/project.json +8 -7
- package/{ai → .ai-dev}/repo_map.json +3403 -918
- package/{ai → .ai-dev}/repo_map.md +604 -45
- package/{test-projects/nestjs-backend/ai → .ai-dev}/schema.json +1 -1
- package/{ai → .ai-dev}/summary.md +15 -5
- package/.ai-dev/symbols.json +7 -0
- package/{ai → .ai-dev}/tech_stack.md +7 -3
- package/.github/workflows/publish.yml +55 -0
- package/CHANGELOG.md +125 -0
- package/PLAN_MEJORAS.md +216 -0
- package/README.es.md +82 -99
- package/README.md +70 -89
- package/STATUS_ADAPTADORES +126 -0
- package/TEST_RESULTS_PHASE1.md +420 -0
- package/ai/graph/knowledge-graph.json +6 -44411
- package/ai-context/ai_context.md +130 -0
- package/ai-context/ai_rules.md +54 -0
- package/ai-context/architecture.md +136 -0
- package/ai-context/cache.json +2349 -0
- package/ai-context/ccp/jira-123/context.json +7 -0
- package/ai-context/context/features/commands.json +18 -0
- package/ai-context/context/features/src.json +61 -0
- package/ai-context/context/features/test-projects.json +69 -0
- package/ai-context/context/flows/account.json +9 -0
- package/ai-context/context/flows/ai-first.json +9 -0
- package/ai-context/context/flows/api.json +9 -0
- package/ai-context/context/flows/auth.json +13 -0
- package/ai-context/context/flows/category.json +12 -0
- package/ai-context/context/flows/comment.json +16 -0
- package/ai-context/context/flows/dashboard.json +9 -0
- package/ai-context/context/flows/doctor.json +9 -0
- package/ai-context/context/flows/explore.json +9 -0
- package/ai-context/context/flows/login.json +9 -0
- package/ai-context/context/flows/opportunity.json +9 -0
- package/ai-context/context/flows/post.json +18 -0
- package/ai-context/context/flows/routes.json +19 -0
- package/ai-context/context/flows/user.json +20 -0
- package/ai-context/context/flows/users.json +9 -0
- package/ai-context/context/flows/views.json +14 -0
- package/ai-context/context/repo.json +56 -0
- package/ai-context/context/utils.json +7 -0
- package/ai-context/conventions.md +53 -0
- package/ai-context/dependencies.json +2946 -0
- package/ai-context/embeddings.json +23828 -0
- package/ai-context/entrypoints.md +42 -0
- package/ai-context/files.json +2944 -0
- package/ai-context/git/commit-activity.json +8646 -0
- package/ai-context/git/recent-features.json +1 -0
- package/ai-context/git/recent-files.json +52 -0
- package/ai-context/git/recent-flows.json +1 -0
- package/ai-context/graph/knowledge-graph.json +44314 -0
- package/ai-context/graph/module-graph.json +866 -0
- package/ai-context/graph/symbol-graph.json +200622 -0
- package/ai-context/graph/symbol-references.json +6778 -0
- package/ai-context/hierarchy.json +20 -0
- package/ai-context/index-state.json +4123 -0
- package/ai-context/index.db +0 -0
- package/ai-context/modules.json +532 -0
- package/ai-context/project.json +30 -0
- package/ai-context/repo_map.json +5818 -0
- package/ai-context/repo_map.md +1327 -0
- package/{test-projects/python-cli/ai → ai-context}/schema.json +1 -1
- package/ai-context/summary.md +42 -0
- package/ai-context/symbols.json +7 -0
- package/ai-context/tech_stack.md +46 -0
- package/dist/analyzers/symbols.d.ts.map +1 -1
- package/dist/analyzers/symbols.js +135 -7
- package/dist/analyzers/symbols.js.map +1 -1
- package/dist/commands/ai-first.d.ts.map +1 -1
- package/dist/commands/ai-first.js +35 -15
- package/dist/commands/ai-first.js.map +1 -1
- package/dist/commands/doctor.js +1 -1
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/explore.js +1 -1
- package/dist/commands/explore.js.map +1 -1
- package/dist/core/ccp.js +1 -1
- package/dist/core/ccp.js.map +1 -1
- package/dist/core/embeddings.d.ts +11 -6
- package/dist/core/embeddings.d.ts.map +1 -1
- package/dist/core/embeddings.js +88 -38
- package/dist/core/embeddings.js.map +1 -1
- package/dist/core/gitAnalyzer.js +3 -3
- package/dist/core/gitAnalyzer.js.map +1 -1
- package/dist/core/incrementalAnalyzer.d.ts.map +1 -1
- package/dist/core/incrementalAnalyzer.js +76 -14
- package/dist/core/incrementalAnalyzer.js.map +1 -1
- package/dist/core/knowledgeGraphBuilder.js +1 -1
- package/dist/core/knowledgeGraphBuilder.js.map +1 -1
- package/dist/core/semanticContexts.d.ts.map +1 -1
- package/dist/core/semanticContexts.js +13 -4
- package/dist/core/semanticContexts.js.map +1 -1
- package/docs/guide/getting-started.md +8 -8
- package/docs/guide/quick-start.md +8 -8
- package/examples/01-express-api.md +3 -3
- package/examples/02-react-app.md +3 -3
- package/examples/03-python-django.md +3 -3
- package/examples/README.md +3 -3
- package/package.json +1 -1
- package/src/analyzers/symbols.ts +144 -7
- package/src/commands/ai-first.ts +37 -15
- package/src/commands/doctor.ts +1 -1
- package/src/commands/explore.ts +1 -1
- package/src/core/ccp.ts +1 -1
- package/src/core/embeddings.ts +106 -40
- package/src/core/gitAnalyzer.ts +3 -3
- package/src/core/incrementalAnalyzer.ts +101 -11
- package/src/core/knowledgeGraphBuilder.ts +1 -1
- package/src/core/semanticContexts.ts +14 -4
- package/test-projects/django-app/.ai-dev/ai_context.md +92 -0
- package/test-projects/django-app/.ai-dev/ai_rules.md +47 -0
- package/test-projects/django-app/.ai-dev/architecture.md +57 -0
- package/test-projects/django-app/.ai-dev/cache.json +169 -0
- package/test-projects/django-app/.ai-dev/context/flows/views.json +10 -0
- package/test-projects/django-app/.ai-dev/dependencies.json +312 -0
- package/test-projects/django-app/.ai-dev/files.json +209 -0
- package/test-projects/django-app/.ai-dev/graph/knowledge-graph.json +36 -0
- package/test-projects/django-app/.ai-dev/graph/module-graph.json +145 -0
- package/test-projects/django-app/.ai-dev/graph/symbol-graph.json +1488 -0
- package/test-projects/django-app/.ai-dev/index-state.json +294 -0
- package/test-projects/django-app/.ai-dev/index.db +0 -0
- package/test-projects/django-app/.ai-dev/modules.json +35 -0
- package/test-projects/django-app/.ai-dev/project.json +11 -0
- package/test-projects/django-app/.ai-dev/repo_map.json +412 -0
- package/test-projects/django-app/.ai-dev/repo_map.md +105 -0
- package/test-projects/{express-api/ai → django-app/.ai-dev}/schema.json +1 -1
- package/test-projects/django-app/.ai-dev/summary.md +15 -0
- package/test-projects/django-app/.ai-dev/symbols.json +1 -0
- package/test-projects/django-app/.ai-dev/tech_stack.md +32 -0
- package/test-projects/django-app/README.md +91 -0
- package/test-projects/django-app/ai-context/ai_context.md +92 -0
- package/test-projects/django-app/ai-context/ai_rules.md +47 -0
- package/test-projects/django-app/ai-context/architecture.md +57 -0
- package/test-projects/django-app/ai-context/cache.json +169 -0
- package/test-projects/django-app/ai-context/context/flows/views.json +10 -0
- package/test-projects/django-app/ai-context/conventions.md +51 -0
- package/test-projects/django-app/ai-context/dependencies.json +312 -0
- package/test-projects/django-app/ai-context/files.json +209 -0
- package/test-projects/django-app/ai-context/graph/knowledge-graph.json +36 -0
- package/test-projects/django-app/ai-context/graph/module-graph.json +145 -0
- package/test-projects/django-app/ai-context/graph/symbol-graph.json +1488 -0
- package/test-projects/django-app/ai-context/graph/symbol-references.json +1 -0
- package/test-projects/django-app/ai-context/index-state.json +294 -0
- package/test-projects/django-app/ai-context/index.db +0 -0
- package/test-projects/django-app/ai-context/modules.json +35 -0
- package/test-projects/django-app/ai-context/project.json +11 -0
- package/test-projects/django-app/ai-context/repo_map.json +412 -0
- package/test-projects/django-app/ai-context/repo_map.md +105 -0
- package/{ai → test-projects/django-app/ai-context}/schema.json +1 -1
- package/test-projects/django-app/ai-context/summary.md +15 -0
- package/test-projects/django-app/ai-context/symbols.json +1 -0
- package/test-projects/django-app/ai-context/tech_stack.md +32 -0
- package/test-projects/django-app/blog/__init__.py +0 -0
- package/test-projects/django-app/blog/admin.py +31 -0
- package/test-projects/django-app/blog/models.py +55 -0
- package/test-projects/django-app/blog/serializers.py +69 -0
- package/test-projects/django-app/blog/urls.py +14 -0
- package/test-projects/django-app/blog/views.py +96 -0
- package/test-projects/django-app/django_app/__init__.py +0 -0
- package/test-projects/django-app/django_app/settings.py +90 -0
- package/test-projects/django-app/django_app/urls.py +11 -0
- package/test-projects/django-app/django_app/wsgi.py +9 -0
- package/test-projects/django-app/manage.py +23 -0
- package/test-projects/django-app/requirements.txt +3 -0
- package/test-projects/django-app/users/__init__.py +0 -0
- package/test-projects/django-app/users/admin.py +42 -0
- package/test-projects/django-app/users/models.py +54 -0
- package/test-projects/django-app/users/serializers.py +113 -0
- package/test-projects/django-app/users/urls.py +13 -0
- package/test-projects/django-app/users/views.py +135 -0
- package/test-projects/express-api/{ai → .ai-dev}/project.json +2 -2
- package/test-projects/express-api/{ai → .ai-dev}/repo_map.json +1 -1
- package/test-projects/express-api/.ai-dev/schema.json +5 -0
- package/test-projects/express-api/.ai-dev/symbols.json +7 -0
- package/test-projects/express-api/ai-context/ai_context.md +112 -0
- package/test-projects/express-api/ai-context/ai_rules.md +50 -0
- package/test-projects/express-api/ai-context/architecture.md +62 -0
- package/test-projects/express-api/ai-context/context/features/controllers.json +13 -0
- package/test-projects/express-api/ai-context/context/features/services.json +13 -0
- package/test-projects/express-api/ai-context/context/flows/auth.json +12 -0
- package/test-projects/express-api/ai-context/context/flows/user.json +13 -0
- package/test-projects/express-api/ai-context/conventions.md +51 -0
- package/test-projects/express-api/ai-context/dependencies.json +54 -0
- package/test-projects/express-api/ai-context/entrypoints.md +17 -0
- package/test-projects/express-api/ai-context/modules.json +30 -0
- package/test-projects/express-api/ai-context/project.json +15 -0
- package/test-projects/express-api/ai-context/repo_map.json +100 -0
- package/test-projects/express-api/ai-context/repo_map.md +36 -0
- package/test-projects/express-api/ai-context/schema.json +5 -0
- package/test-projects/express-api/ai-context/summary.md +14 -0
- package/test-projects/express-api/ai-context/symbols.json +7 -0
- package/test-projects/express-api/ai-context/tech_stack.md +38 -0
- package/test-projects/express-api/index.js +9 -0
- package/test-projects/fastapi-app/.ai-dev/ai_context.md +89 -0
- package/test-projects/fastapi-app/.ai-dev/ai_rules.md +47 -0
- package/test-projects/fastapi-app/.ai-dev/architecture.md +39 -0
- package/test-projects/fastapi-app/.ai-dev/cache.json +125 -0
- package/test-projects/fastapi-app/.ai-dev/conventions.md +51 -0
- package/test-projects/fastapi-app/.ai-dev/dependencies.json +244 -0
- package/test-projects/fastapi-app/.ai-dev/files.json +154 -0
- package/test-projects/fastapi-app/.ai-dev/graph/knowledge-graph.json +15 -0
- package/test-projects/fastapi-app/.ai-dev/graph/module-graph.json +78 -0
- package/test-projects/fastapi-app/.ai-dev/graph/symbol-graph.json +1724 -0
- package/test-projects/fastapi-app/.ai-dev/graph/symbol-references.json +51 -0
- package/test-projects/fastapi-app/.ai-dev/index-state.json +217 -0
- package/test-projects/fastapi-app/.ai-dev/index.db +0 -0
- package/test-projects/fastapi-app/.ai-dev/modules.json +16 -0
- package/test-projects/fastapi-app/.ai-dev/project.json +9 -0
- package/test-projects/{express-api/ai/repo-map.json → fastapi-app/.ai-dev/repo_map.json} +121 -114
- package/test-projects/fastapi-app/.ai-dev/repo_map.md +74 -0
- package/test-projects/fastapi-app/.ai-dev/schema.json +5 -0
- package/test-projects/fastapi-app/.ai-dev/summary.md +12 -0
- package/test-projects/fastapi-app/.ai-dev/symbols.json +1 -0
- package/test-projects/fastapi-app/.ai-dev/tech_stack.md +32 -0
- package/test-projects/fastapi-app/.ai-dev/tools.json +10 -0
- package/test-projects/fastapi-app/README.md +118 -0
- package/test-projects/fastapi-app/ai-context/ai_context.md +89 -0
- package/test-projects/fastapi-app/ai-context/ai_rules.md +47 -0
- package/test-projects/fastapi-app/ai-context/architecture.md +39 -0
- package/test-projects/fastapi-app/ai-context/cache.json +125 -0
- package/test-projects/fastapi-app/ai-context/conventions.md +51 -0
- package/test-projects/fastapi-app/ai-context/dependencies.json +244 -0
- package/test-projects/fastapi-app/ai-context/entrypoints.md +4 -0
- package/test-projects/fastapi-app/ai-context/files.json +154 -0
- package/test-projects/fastapi-app/ai-context/graph/knowledge-graph.json +15 -0
- package/test-projects/fastapi-app/ai-context/graph/module-graph.json +78 -0
- package/test-projects/fastapi-app/ai-context/graph/symbol-graph.json +1724 -0
- package/test-projects/fastapi-app/ai-context/graph/symbol-references.json +51 -0
- package/test-projects/fastapi-app/ai-context/index-state.json +217 -0
- package/test-projects/fastapi-app/ai-context/index.db +0 -0
- package/test-projects/fastapi-app/ai-context/modules.json +16 -0
- package/test-projects/fastapi-app/ai-context/project.json +9 -0
- package/test-projects/fastapi-app/ai-context/repo_map.json +298 -0
- package/test-projects/fastapi-app/ai-context/repo_map.md +74 -0
- package/test-projects/fastapi-app/ai-context/schema.json +5 -0
- package/test-projects/fastapi-app/ai-context/summary.md +12 -0
- package/test-projects/fastapi-app/ai-context/symbols.json +1 -0
- package/test-projects/fastapi-app/ai-context/tech_stack.md +32 -0
- package/test-projects/fastapi-app/ai-context/tools.json +10 -0
- package/test-projects/fastapi-app/app/database.py +21 -0
- package/test-projects/fastapi-app/app/dependencies.py +107 -0
- package/test-projects/fastapi-app/app/main.py +47 -0
- package/test-projects/fastapi-app/app/models.py +149 -0
- package/test-projects/fastapi-app/app/routers/auth.py +117 -0
- package/test-projects/fastapi-app/app/routers/posts.py +272 -0
- package/test-projects/fastapi-app/app/schemas.py +191 -0
- package/test-projects/fastapi-app/requirements.txt +10 -0
- package/test-projects/flask-app/.ai-dev/ai_context.md +94 -0
- package/test-projects/flask-app/.ai-dev/ai_rules.md +47 -0
- package/test-projects/flask-app/.ai-dev/architecture.md +49 -0
- package/test-projects/flask-app/.ai-dev/cache.json +157 -0
- package/test-projects/flask-app/.ai-dev/context/features/app.json +25 -0
- package/test-projects/flask-app/.ai-dev/context/flows/routes.json +14 -0
- package/test-projects/flask-app/.ai-dev/conventions.md +51 -0
- package/test-projects/flask-app/.ai-dev/dependencies.json +298 -0
- package/test-projects/flask-app/.ai-dev/entrypoints.md +4 -0
- package/test-projects/flask-app/.ai-dev/files.json +194 -0
- package/test-projects/flask-app/.ai-dev/graph/knowledge-graph.json +60 -0
- package/test-projects/flask-app/.ai-dev/graph/module-graph.json +95 -0
- package/test-projects/flask-app/.ai-dev/graph/symbol-graph.json +1448 -0
- package/test-projects/flask-app/.ai-dev/graph/symbol-references.json +45 -0
- package/test-projects/flask-app/.ai-dev/index-state.json +273 -0
- package/test-projects/flask-app/.ai-dev/index.db +0 -0
- package/test-projects/flask-app/.ai-dev/modules.json +21 -0
- package/test-projects/flask-app/.ai-dev/project.json +13 -0
- package/test-projects/flask-app/.ai-dev/repo_map.json +400 -0
- package/test-projects/flask-app/.ai-dev/repo_map.md +98 -0
- package/test-projects/flask-app/.ai-dev/schema.json +5 -0
- package/test-projects/flask-app/.ai-dev/summary.md +13 -0
- package/test-projects/flask-app/.ai-dev/symbols.json +1 -0
- package/test-projects/flask-app/.ai-dev/tech_stack.md +32 -0
- package/test-projects/flask-app/.ai-dev/tools.json +10 -0
- package/test-projects/flask-app/README.md +129 -0
- package/test-projects/flask-app/ai-context/ai_context.md +94 -0
- package/test-projects/flask-app/ai-context/ai_rules.md +47 -0
- package/test-projects/flask-app/ai-context/architecture.md +49 -0
- package/test-projects/flask-app/ai-context/cache.json +157 -0
- package/test-projects/flask-app/ai-context/context/features/app.json +25 -0
- package/test-projects/flask-app/ai-context/context/flows/routes.json +14 -0
- package/test-projects/flask-app/ai-context/conventions.md +51 -0
- package/test-projects/flask-app/ai-context/dependencies.json +298 -0
- package/test-projects/flask-app/ai-context/entrypoints.md +4 -0
- package/test-projects/flask-app/ai-context/files.json +194 -0
- package/test-projects/flask-app/ai-context/graph/knowledge-graph.json +60 -0
- package/test-projects/flask-app/ai-context/graph/module-graph.json +95 -0
- package/test-projects/flask-app/ai-context/graph/symbol-graph.json +1448 -0
- package/test-projects/flask-app/ai-context/graph/symbol-references.json +45 -0
- package/test-projects/flask-app/ai-context/index-state.json +273 -0
- package/test-projects/flask-app/ai-context/index.db +0 -0
- package/test-projects/flask-app/ai-context/modules.json +21 -0
- package/test-projects/flask-app/ai-context/project.json +13 -0
- package/test-projects/flask-app/ai-context/repo_map.json +400 -0
- package/test-projects/flask-app/ai-context/repo_map.md +98 -0
- package/test-projects/flask-app/ai-context/schema.json +5 -0
- package/test-projects/flask-app/ai-context/summary.md +13 -0
- package/test-projects/flask-app/ai-context/symbols.json +1 -0
- package/test-projects/flask-app/ai-context/tech_stack.md +32 -0
- package/test-projects/flask-app/ai-context/tools.json +10 -0
- package/test-projects/flask-app/app/__init__.py +46 -0
- package/test-projects/flask-app/app/api/__init__.py +7 -0
- package/test-projects/flask-app/app/api/routes.py +122 -0
- package/test-projects/flask-app/app/auth/__init__.py +7 -0
- package/test-projects/flask-app/app/auth/forms.py +52 -0
- package/test-projects/flask-app/app/auth/routes.py +68 -0
- package/test-projects/flask-app/app/blog/__init__.py +7 -0
- package/test-projects/flask-app/app/blog/forms.py +35 -0
- package/test-projects/flask-app/app/blog/routes.py +140 -0
- package/test-projects/flask-app/app/main/__init__.py +7 -0
- package/test-projects/flask-app/app/main/routes.py +88 -0
- package/test-projects/flask-app/app/models.py +177 -0
- package/test-projects/flask-app/config.py +64 -0
- package/test-projects/flask-app/requirements.txt +10 -0
- package/test-projects/laravel-app/.ai-dev/ai_context.md +97 -0
- package/test-projects/laravel-app/.ai-dev/ai_rules.md +47 -0
- package/test-projects/laravel-app/.ai-dev/architecture.md +60 -0
- package/test-projects/laravel-app/.ai-dev/cache.json +161 -0
- package/test-projects/laravel-app/.ai-dev/context/features/app.json +21 -0
- package/test-projects/laravel-app/.ai-dev/context/flows/.json +9 -0
- package/test-projects/laravel-app/.ai-dev/context/flows/category.json +12 -0
- package/test-projects/laravel-app/.ai-dev/context/flows/comment.json +12 -0
- package/test-projects/laravel-app/.ai-dev/context/flows/post.json +12 -0
- package/test-projects/laravel-app/.ai-dev/context/flows/unnamed.json +9 -0
- package/test-projects/laravel-app/.ai-dev/conventions.md +51 -0
- package/test-projects/laravel-app/.ai-dev/entrypoints.md +4 -0
- package/test-projects/laravel-app/.ai-dev/files.json +199 -0
- package/test-projects/laravel-app/.ai-dev/graph/knowledge-graph.json +98 -0
- package/test-projects/laravel-app/.ai-dev/graph/module-graph.json +30 -0
- package/test-projects/laravel-app/.ai-dev/graph/symbol-graph.json +5 -0
- package/test-projects/laravel-app/.ai-dev/graph/symbol-references.json +1 -0
- package/test-projects/laravel-app/.ai-dev/index-state.json +280 -0
- package/test-projects/laravel-app/.ai-dev/index.db +0 -0
- package/test-projects/laravel-app/.ai-dev/modules.json +29 -0
- package/test-projects/laravel-app/.ai-dev/project.json +17 -0
- package/test-projects/laravel-app/.ai-dev/repo_map.json +419 -0
- package/test-projects/laravel-app/.ai-dev/repo_map.md +106 -0
- package/test-projects/laravel-app/.ai-dev/schema.json +5 -0
- package/test-projects/laravel-app/.ai-dev/summary.md +15 -0
- package/test-projects/laravel-app/.ai-dev/symbols.json +1 -0
- package/test-projects/laravel-app/.ai-dev/tech_stack.md +34 -0
- package/test-projects/laravel-app/.ai-dev/tools.json +10 -0
- package/test-projects/laravel-app/README.md +107 -0
- package/test-projects/laravel-app/ai-context/ai_context.md +97 -0
- package/test-projects/laravel-app/ai-context/ai_rules.md +47 -0
- package/test-projects/laravel-app/ai-context/architecture.md +60 -0
- package/test-projects/laravel-app/ai-context/cache.json +161 -0
- package/test-projects/laravel-app/ai-context/context/features/app.json +21 -0
- package/test-projects/laravel-app/ai-context/context/flows/.json +9 -0
- package/test-projects/laravel-app/ai-context/context/flows/category.json +12 -0
- package/test-projects/laravel-app/ai-context/context/flows/comment.json +12 -0
- package/test-projects/laravel-app/ai-context/context/flows/post.json +12 -0
- package/test-projects/laravel-app/ai-context/context/flows/unnamed.json +9 -0
- package/test-projects/laravel-app/ai-context/conventions.md +51 -0
- package/test-projects/laravel-app/ai-context/dependencies.json +6 -0
- package/test-projects/laravel-app/ai-context/entrypoints.md +4 -0
- package/test-projects/laravel-app/ai-context/files.json +199 -0
- package/test-projects/laravel-app/ai-context/graph/knowledge-graph.json +98 -0
- package/test-projects/laravel-app/ai-context/graph/module-graph.json +30 -0
- package/test-projects/laravel-app/ai-context/graph/symbol-graph.json +5 -0
- package/test-projects/laravel-app/ai-context/graph/symbol-references.json +1 -0
- package/test-projects/laravel-app/ai-context/index-state.json +280 -0
- package/test-projects/laravel-app/ai-context/index.db +0 -0
- package/test-projects/laravel-app/ai-context/modules.json +29 -0
- package/test-projects/laravel-app/ai-context/project.json +17 -0
- package/test-projects/laravel-app/ai-context/repo_map.json +419 -0
- package/test-projects/laravel-app/ai-context/repo_map.md +106 -0
- package/test-projects/laravel-app/ai-context/schema.json +5 -0
- package/test-projects/laravel-app/ai-context/summary.md +15 -0
- package/test-projects/laravel-app/ai-context/symbols.json +1 -0
- package/test-projects/laravel-app/ai-context/tech_stack.md +34 -0
- package/test-projects/laravel-app/ai-context/tools.json +10 -0
- package/test-projects/laravel-app/app/Http/Controllers/Api/CategoryController.php +88 -0
- package/test-projects/laravel-app/app/Http/Controllers/Api/CommentController.php +56 -0
- package/test-projects/laravel-app/app/Http/Controllers/Api/PostController.php +174 -0
- package/test-projects/laravel-app/app/Http/Controllers/Controller.php +12 -0
- package/test-projects/laravel-app/app/Models/Category.php +34 -0
- package/test-projects/laravel-app/app/Models/Comment.php +51 -0
- package/test-projects/laravel-app/app/Models/Post.php +108 -0
- package/test-projects/laravel-app/app/Models/User.php +85 -0
- package/test-projects/laravel-app/bootstrap/app.php +25 -0
- package/test-projects/laravel-app/composer.json +35 -0
- package/test-projects/laravel-app/routes/api.php +40 -0
- package/test-projects/nestjs-backend/{ai → .ai-dev}/ai_context.md +7 -6
- package/test-projects/nestjs-backend/{ai → .ai-dev}/ai_rules.md +4 -4
- package/test-projects/nestjs-backend/{ai → .ai-dev}/architecture.md +6 -0
- package/test-projects/nestjs-backend/{ai → .ai-dev}/cache.json +65 -33
- package/test-projects/nestjs-backend/.ai-dev/context/flows/auth.controller.json +14 -0
- package/test-projects/nestjs-backend/.ai-dev/context/flows/users.controller.json +14 -0
- package/test-projects/nestjs-backend/.ai-dev/context/flows/users.json +10 -0
- package/test-projects/nestjs-backend/.ai-dev/conventions.md +52 -0
- package/test-projects/nestjs-backend/{ai → .ai-dev}/files.json +25 -0
- package/test-projects/nestjs-backend/.ai-dev/graph/knowledge-graph.json +132 -0
- package/test-projects/nestjs-backend/{ai → .ai-dev}/index-state.json +122 -87
- package/{ai → test-projects/nestjs-backend/.ai-dev}/index.db +0 -0
- package/test-projects/nestjs-backend/{ai → .ai-dev}/project.json +6 -2
- package/test-projects/nestjs-backend/{ai/repo-map.json → .ai-dev/repo_map.json} +106 -2
- package/test-projects/nestjs-backend/.ai-dev/repo_map.md +104 -0
- package/test-projects/nestjs-backend/.ai-dev/schema.json +5 -0
- package/test-projects/nestjs-backend/{ai → .ai-dev}/summary.md +4 -2
- package/test-projects/nestjs-backend/.ai-dev/symbols.json +1 -0
- package/test-projects/nestjs-backend/{ai → .ai-dev}/tech_stack.md +2 -1
- package/test-projects/nestjs-backend/.ai-dev/tools.json +10 -0
- package/test-projects/nestjs-backend/ai-context/ai_context.md +111 -0
- package/test-projects/nestjs-backend/ai-context/ai_rules.md +52 -0
- package/test-projects/nestjs-backend/ai-context/architecture.md +49 -0
- package/test-projects/nestjs-backend/ai-context/cache.json +169 -0
- package/test-projects/nestjs-backend/ai-context/context/features/src.json +23 -0
- package/test-projects/nestjs-backend/ai-context/context/flows/auth.controller.json +14 -0
- package/test-projects/nestjs-backend/ai-context/context/flows/auth.json +10 -0
- package/test-projects/nestjs-backend/ai-context/context/flows/users..json +10 -0
- package/test-projects/nestjs-backend/ai-context/context/flows/users.controller.json +14 -0
- package/test-projects/nestjs-backend/ai-context/context/flows/users.json +10 -0
- package/test-projects/nestjs-backend/ai-context/conventions.md +52 -0
- package/test-projects/nestjs-backend/ai-context/dependencies.json +152 -0
- package/test-projects/nestjs-backend/ai-context/entrypoints.md +18 -0
- package/test-projects/nestjs-backend/ai-context/files.json +209 -0
- package/test-projects/nestjs-backend/ai-context/graph/knowledge-graph.json +132 -0
- package/test-projects/nestjs-backend/ai-context/graph/module-graph.json +29 -0
- package/test-projects/nestjs-backend/ai-context/graph/symbol-graph.json +304 -0
- package/test-projects/nestjs-backend/ai-context/graph/symbol-references.json +5 -0
- package/test-projects/nestjs-backend/ai-context/index-state.json +294 -0
- package/test-projects/nestjs-backend/ai-context/index.db +0 -0
- package/test-projects/nestjs-backend/ai-context/modules.json +19 -0
- package/test-projects/nestjs-backend/ai-context/project.json +18 -0
- package/test-projects/nestjs-backend/ai-context/repo_map.json +427 -0
- package/test-projects/nestjs-backend/ai-context/repo_map.md +104 -0
- package/test-projects/nestjs-backend/ai-context/schema.json +5 -0
- package/test-projects/nestjs-backend/ai-context/summary.md +13 -0
- package/test-projects/nestjs-backend/ai-context/symbols.json +1 -0
- package/test-projects/nestjs-backend/ai-context/tech_stack.md +38 -0
- package/test-projects/nestjs-backend/ai-context/tools.json +10 -0
- package/test-projects/python-cli/{ai → .ai-dev}/ai_context.md +5 -4
- package/test-projects/python-cli/{ai → .ai-dev}/ai_rules.md +2 -2
- package/test-projects/python-cli/{ai → .ai-dev}/architecture.md +6 -0
- package/test-projects/python-cli/{ai → .ai-dev}/cache.json +53 -33
- package/test-projects/python-cli/.ai-dev/entrypoints.md +4 -0
- package/test-projects/python-cli/{ai → .ai-dev}/files.json +10 -0
- package/test-projects/python-cli/{ai → .ai-dev}/graph/knowledge-graph.json +1 -1
- package/test-projects/python-cli/{ai → .ai-dev}/index-state.json +97 -83
- package/test-projects/python-cli/{ai → .ai-dev}/index.db +0 -0
- package/test-projects/python-cli/{ai → .ai-dev}/project.json +1 -1
- package/test-projects/python-cli/{ai/repo-map.json → .ai-dev/repo_map.json} +79 -2
- package/test-projects/python-cli/.ai-dev/repo_map.md +93 -0
- package/test-projects/python-cli/.ai-dev/schema.json +5 -0
- package/test-projects/python-cli/{ai → .ai-dev}/summary.md +4 -1
- package/test-projects/python-cli/.ai-dev/symbols.json +1 -0
- package/test-projects/python-cli/.ai-dev/tech_stack.md +32 -0
- package/test-projects/python-cli/.ai-dev/tools.json +10 -0
- package/test-projects/python-cli/ai-context/ai_context.md +95 -0
- package/test-projects/python-cli/ai-context/ai_rules.md +47 -0
- package/test-projects/python-cli/ai-context/architecture.md +55 -0
- package/test-projects/python-cli/ai-context/cache.json +149 -0
- package/test-projects/python-cli/ai-context/context/features/cli.json +16 -0
- package/test-projects/python-cli/ai-context/context/flows/list_.json +9 -0
- package/test-projects/python-cli/ai-context/context/flows/remove_.json +9 -0
- package/test-projects/python-cli/ai-context/conventions.md +51 -0
- package/test-projects/python-cli/ai-context/dependencies.json +66 -0
- package/test-projects/python-cli/ai-context/entrypoints.md +4 -0
- package/test-projects/python-cli/ai-context/files.json +184 -0
- package/test-projects/python-cli/ai-context/graph/knowledge-graph.json +83 -0
- package/test-projects/python-cli/ai-context/graph/module-graph.json +31 -0
- package/test-projects/python-cli/ai-context/graph/symbol-graph.json +358 -0
- package/test-projects/python-cli/ai-context/graph/symbol-references.json +11 -0
- package/test-projects/python-cli/ai-context/index-state.json +259 -0
- package/test-projects/{nestjs-backend/ai → python-cli/ai-context}/index.db +0 -0
- package/test-projects/python-cli/ai-context/modules.json +21 -0
- package/test-projects/python-cli/ai-context/project.json +15 -0
- package/test-projects/python-cli/ai-context/repo_map.json +367 -0
- package/test-projects/python-cli/ai-context/repo_map.md +93 -0
- package/test-projects/python-cli/ai-context/schema.json +5 -0
- package/test-projects/python-cli/ai-context/summary.md +14 -0
- package/test-projects/python-cli/ai-context/symbols.json +1 -0
- package/test-projects/python-cli/ai-context/tech_stack.md +32 -0
- package/test-projects/python-cli/ai-context/tools.json +10 -0
- package/test-projects/rails-app/.ai-dev/ai_context.md +94 -0
- package/test-projects/rails-app/.ai-dev/ai_rules.md +47 -0
- package/test-projects/rails-app/.ai-dev/architecture.md +49 -0
- package/test-projects/rails-app/.ai-dev/cache.json +193 -0
- package/test-projects/rails-app/.ai-dev/context/features/app.json +24 -0
- package/test-projects/rails-app/.ai-dev/context/features/config.json +13 -0
- package/test-projects/rails-app/.ai-dev/context/flows/application.json +9 -0
- package/test-projects/rails-app/.ai-dev/context/flows/application_.json +9 -0
- package/test-projects/rails-app/.ai-dev/context/flows/comments.json +11 -0
- package/test-projects/rails-app/.ai-dev/context/flows/comments_.json +11 -0
- package/test-projects/rails-app/.ai-dev/context/flows/posts.json +11 -0
- package/test-projects/rails-app/.ai-dev/context/flows/posts_.json +11 -0
- package/test-projects/rails-app/.ai-dev/context/flows/routes.json +9 -0
- package/test-projects/rails-app/.ai-dev/context/flows/users.json +11 -0
- package/test-projects/rails-app/.ai-dev/context/flows/users_.json +11 -0
- package/test-projects/rails-app/.ai-dev/conventions.md +51 -0
- package/test-projects/rails-app/.ai-dev/dependencies.json +6 -0
- package/test-projects/rails-app/.ai-dev/entrypoints.md +4 -0
- package/test-projects/rails-app/.ai-dev/files.json +239 -0
- package/test-projects/rails-app/.ai-dev/graph/knowledge-graph.json +130 -0
- package/test-projects/rails-app/.ai-dev/graph/module-graph.json +27 -0
- package/test-projects/rails-app/.ai-dev/graph/symbol-graph.json +5 -0
- package/test-projects/rails-app/.ai-dev/graph/symbol-references.json +1 -0
- package/test-projects/rails-app/.ai-dev/index-state.json +336 -0
- package/test-projects/rails-app/.ai-dev/index.db +0 -0
- package/test-projects/rails-app/.ai-dev/modules.json +26 -0
- package/test-projects/rails-app/.ai-dev/project.json +22 -0
- package/test-projects/rails-app/.ai-dev/repo_map.json +486 -0
- package/test-projects/rails-app/.ai-dev/repo_map.md +117 -0
- package/test-projects/rails-app/.ai-dev/schema.json +5 -0
- package/test-projects/rails-app/.ai-dev/summary.md +13 -0
- package/test-projects/rails-app/.ai-dev/symbols.json +1 -0
- package/test-projects/rails-app/.ai-dev/tech_stack.md +32 -0
- package/test-projects/rails-app/.ai-dev/tools.json +10 -0
- package/test-projects/rails-app/Gemfile +38 -0
- package/test-projects/rails-app/README.md +140 -0
- package/test-projects/rails-app/Rakefile +8 -0
- package/test-projects/rails-app/ai-context/ai_context.md +94 -0
- package/test-projects/rails-app/ai-context/ai_rules.md +47 -0
- package/test-projects/rails-app/ai-context/architecture.md +49 -0
- package/test-projects/rails-app/ai-context/cache.json +193 -0
- package/test-projects/rails-app/ai-context/context/features/app.json +24 -0
- package/test-projects/rails-app/ai-context/context/features/config.json +13 -0
- package/test-projects/rails-app/ai-context/context/flows/application.json +9 -0
- package/test-projects/rails-app/ai-context/context/flows/application_.json +9 -0
- package/test-projects/rails-app/ai-context/context/flows/comments.json +11 -0
- package/test-projects/rails-app/ai-context/context/flows/comments_.json +11 -0
- package/test-projects/rails-app/ai-context/context/flows/posts.json +11 -0
- package/test-projects/rails-app/ai-context/context/flows/posts_.json +11 -0
- package/test-projects/rails-app/ai-context/context/flows/routes.json +9 -0
- package/test-projects/rails-app/ai-context/context/flows/users.json +11 -0
- package/test-projects/rails-app/ai-context/context/flows/users_.json +11 -0
- package/test-projects/rails-app/ai-context/conventions.md +51 -0
- package/test-projects/rails-app/ai-context/dependencies.json +6 -0
- package/test-projects/rails-app/ai-context/entrypoints.md +4 -0
- package/test-projects/rails-app/ai-context/files.json +239 -0
- package/test-projects/rails-app/ai-context/graph/knowledge-graph.json +130 -0
- package/test-projects/rails-app/ai-context/graph/module-graph.json +27 -0
- package/test-projects/rails-app/ai-context/graph/symbol-graph.json +5 -0
- package/test-projects/rails-app/ai-context/graph/symbol-references.json +1 -0
- package/test-projects/rails-app/ai-context/index-state.json +336 -0
- package/test-projects/rails-app/ai-context/index.db +0 -0
- package/test-projects/rails-app/ai-context/modules.json +26 -0
- package/test-projects/rails-app/ai-context/project.json +22 -0
- package/test-projects/rails-app/ai-context/repo_map.json +486 -0
- package/test-projects/rails-app/ai-context/repo_map.md +117 -0
- package/test-projects/rails-app/ai-context/schema.json +5 -0
- package/test-projects/rails-app/ai-context/summary.md +13 -0
- package/test-projects/rails-app/ai-context/symbols.json +1 -0
- package/test-projects/rails-app/ai-context/tech_stack.md +32 -0
- package/test-projects/rails-app/ai-context/tools.json +10 -0
- package/test-projects/rails-app/app/controllers/api/comments_controller.rb +75 -0
- package/test-projects/rails-app/app/controllers/api/posts_controller.rb +68 -0
- package/test-projects/rails-app/app/controllers/api/users_controller.rb +54 -0
- package/test-projects/rails-app/app/controllers/application_controller.rb +31 -0
- package/test-projects/rails-app/app/models/comment.rb +34 -0
- package/test-projects/rails-app/app/models/post.rb +36 -0
- package/test-projects/rails-app/app/models/user.rb +28 -0
- package/test-projects/rails-app/app/services/post_service.rb +92 -0
- package/test-projects/rails-app/app/services/user_service.rb +76 -0
- package/test-projects/rails-app/config/application.rb +27 -0
- package/test-projects/rails-app/config/environment.rb +7 -0
- package/test-projects/rails-app/config/routes.rb +15 -0
- package/test-projects/react-app/{ai → .ai-dev}/ai_context.md +5 -4
- package/test-projects/react-app/{ai → .ai-dev}/ai_rules.md +2 -2
- package/test-projects/react-app/{ai → .ai-dev}/architecture.md +6 -0
- package/test-projects/react-app/{ai → .ai-dev}/cache.json +57 -33
- package/test-projects/react-app/.ai-dev/context/flows/UsersPage.json +14 -0
- package/test-projects/react-app/.ai-dev/entrypoints.md +4 -0
- package/test-projects/react-app/{ai → .ai-dev}/files.json +15 -0
- package/test-projects/react-app/{ai → .ai-dev}/graph/knowledge-graph.json +32 -3
- package/test-projects/react-app/{ai → .ai-dev}/index-state.json +105 -84
- package/test-projects/react-app/{ai → .ai-dev}/index.db +0 -0
- package/test-projects/react-app/{ai → .ai-dev}/project.json +2 -1
- package/test-projects/react-app/{ai/repo-map.json → .ai-dev/repo_map.json} +88 -2
- package/test-projects/react-app/.ai-dev/repo_map.md +94 -0
- package/test-projects/react-app/.ai-dev/schema.json +5 -0
- package/test-projects/react-app/{ai → .ai-dev}/summary.md +4 -2
- package/test-projects/react-app/.ai-dev/symbols.json +1 -0
- package/test-projects/react-app/{ai → .ai-dev}/tech_stack.md +2 -1
- package/test-projects/react-app/.ai-dev/tools.json +10 -0
- package/test-projects/react-app/ai-context/ai_context.md +96 -0
- package/test-projects/react-app/ai-context/ai_rules.md +49 -0
- package/test-projects/react-app/ai-context/architecture.md +39 -0
- package/test-projects/react-app/ai-context/cache.json +153 -0
- package/test-projects/react-app/ai-context/context/features/src.json +18 -0
- package/test-projects/react-app/ai-context/context/flows/UsersPage.json +14 -0
- package/test-projects/react-app/ai-context/context/flows/dashboard.json +9 -0
- package/test-projects/react-app/ai-context/context/flows/login.json +9 -0
- package/test-projects/react-app/ai-context/context/flows/users.json +9 -0
- package/test-projects/{nestjs-backend/ai → react-app/ai-context}/conventions.md +2 -2
- package/test-projects/react-app/ai-context/dependencies.json +128 -0
- package/test-projects/react-app/ai-context/entrypoints.md +4 -0
- package/test-projects/react-app/ai-context/files.json +189 -0
- package/test-projects/react-app/ai-context/graph/knowledge-graph.json +112 -0
- package/test-projects/react-app/ai-context/graph/module-graph.json +31 -0
- package/test-projects/react-app/ai-context/graph/symbol-graph.json +868 -0
- package/test-projects/react-app/ai-context/graph/symbol-references.json +31 -0
- package/test-projects/react-app/ai-context/index-state.json +266 -0
- package/test-projects/react-app/ai-context/index.db +0 -0
- package/test-projects/react-app/ai-context/modules.json +17 -0
- package/test-projects/react-app/ai-context/project.json +16 -0
- package/test-projects/react-app/ai-context/repo_map.json +391 -0
- package/test-projects/react-app/ai-context/repo_map.md +94 -0
- package/test-projects/react-app/ai-context/schema.json +5 -0
- package/test-projects/react-app/ai-context/summary.md +13 -0
- package/test-projects/react-app/ai-context/symbols.json +1 -0
- package/test-projects/react-app/ai-context/tech_stack.md +39 -0
- package/test-projects/react-app/ai-context/tools.json +10 -0
- package/test-projects/salesforce-cli/{ai → .ai-dev}/ai_context.md +5 -4
- package/test-projects/salesforce-cli/{ai → .ai-dev}/ai_rules.md +2 -2
- package/test-projects/salesforce-cli/{ai → .ai-dev}/architecture.md +6 -0
- package/test-projects/salesforce-cli/{ai → .ai-dev}/cache.json +52 -32
- package/test-projects/salesforce-cli/.ai-dev/conventions.md +51 -0
- package/test-projects/salesforce-cli/.ai-dev/dependencies.json +6 -0
- package/test-projects/salesforce-cli/.ai-dev/entrypoints.md +4 -0
- package/test-projects/salesforce-cli/{ai → .ai-dev}/files.json +10 -0
- package/test-projects/salesforce-cli/{ai → .ai-dev}/graph/knowledge-graph.json +1 -1
- package/test-projects/salesforce-cli/.ai-dev/graph/symbol-references.json +1 -0
- package/test-projects/salesforce-cli/{ai → .ai-dev}/index-state.json +90 -76
- package/test-projects/salesforce-cli/{ai → .ai-dev}/index.db +0 -0
- package/test-projects/salesforce-cli/{ai → .ai-dev}/project.json +1 -1
- package/test-projects/salesforce-cli/{ai/repo-map.json → .ai-dev/repo_map.json} +79 -2
- package/test-projects/salesforce-cli/.ai-dev/repo_map.md +80 -0
- package/test-projects/salesforce-cli/.ai-dev/schema.json +5 -0
- package/test-projects/salesforce-cli/{ai → .ai-dev}/summary.md +4 -2
- package/test-projects/salesforce-cli/.ai-dev/symbols.json +1 -0
- package/test-projects/salesforce-cli/{ai → .ai-dev}/tech_stack.md +2 -1
- package/test-projects/salesforce-cli/.ai-dev/tools.json +10 -0
- package/test-projects/salesforce-cli/ai-context/ai_context.md +89 -0
- package/test-projects/salesforce-cli/ai-context/ai_rules.md +47 -0
- package/test-projects/salesforce-cli/ai-context/architecture.md +39 -0
- package/test-projects/salesforce-cli/ai-context/cache.json +125 -0
- package/test-projects/salesforce-cli/ai-context/context/features/force-app.json +14 -0
- package/test-projects/salesforce-cli/ai-context/context/flows/account.json +9 -0
- package/test-projects/salesforce-cli/ai-context/context/flows/opportunity.json +9 -0
- package/test-projects/salesforce-cli/ai-context/conventions.md +51 -0
- package/test-projects/salesforce-cli/ai-context/dependencies.json +6 -0
- package/test-projects/salesforce-cli/ai-context/entrypoints.md +4 -0
- package/test-projects/{express-api/ai → salesforce-cli/ai-context}/files.json +27 -42
- package/test-projects/salesforce-cli/ai-context/graph/knowledge-graph.json +64 -0
- package/test-projects/salesforce-cli/ai-context/graph/module-graph.json +13 -0
- package/test-projects/salesforce-cli/ai-context/graph/symbol-graph.json +148 -0
- package/test-projects/salesforce-cli/ai-context/graph/symbol-references.json +1 -0
- package/test-projects/salesforce-cli/ai-context/index-state.json +217 -0
- package/test-projects/{express-api/ai → salesforce-cli/ai-context}/index.db +0 -0
- package/test-projects/salesforce-cli/ai-context/modules.json +12 -0
- package/test-projects/salesforce-cli/ai-context/project.json +14 -0
- package/test-projects/salesforce-cli/ai-context/repo_map.json +328 -0
- package/test-projects/salesforce-cli/ai-context/repo_map.md +80 -0
- package/test-projects/salesforce-cli/ai-context/schema.json +5 -0
- package/test-projects/salesforce-cli/ai-context/summary.md +13 -0
- package/test-projects/salesforce-cli/ai-context/symbols.json +1 -0
- package/test-projects/{python-cli/ai → salesforce-cli/ai-context}/tech_stack.md +3 -2
- package/test-projects/salesforce-cli/ai-context/tools.json +10 -0
- package/test-projects/spring-boot-app/.ai-dev/ai_context.md +91 -0
- package/test-projects/spring-boot-app/.ai-dev/ai_rules.md +48 -0
- package/test-projects/spring-boot-app/.ai-dev/architecture.md +39 -0
- package/test-projects/spring-boot-app/.ai-dev/cache.json +173 -0
- package/test-projects/spring-boot-app/.ai-dev/context/features/src.json +26 -0
- package/test-projects/spring-boot-app/.ai-dev/context/flows/PostController.json +19 -0
- package/test-projects/spring-boot-app/.ai-dev/context/flows/UserController.json +19 -0
- package/test-projects/spring-boot-app/.ai-dev/context/flows/comment.json +11 -0
- package/test-projects/spring-boot-app/.ai-dev/context/flows/post.json +14 -0
- package/test-projects/spring-boot-app/.ai-dev/context/flows/user.json +14 -0
- package/test-projects/spring-boot-app/.ai-dev/conventions.md +52 -0
- package/test-projects/spring-boot-app/.ai-dev/dependencies.json +326 -0
- package/test-projects/spring-boot-app/.ai-dev/entrypoints.md +4 -0
- package/test-projects/spring-boot-app/.ai-dev/files.json +214 -0
- package/test-projects/spring-boot-app/.ai-dev/graph/knowledge-graph.json +231 -0
- package/test-projects/spring-boot-app/.ai-dev/graph/module-graph.json +22 -0
- package/test-projects/spring-boot-app/.ai-dev/graph/symbol-graph.json +794 -0
- package/test-projects/spring-boot-app/.ai-dev/graph/symbol-references.json +70 -0
- package/test-projects/spring-boot-app/.ai-dev/index-state.json +301 -0
- package/test-projects/spring-boot-app/.ai-dev/index.db +0 -0
- package/test-projects/spring-boot-app/.ai-dev/modules.json +21 -0
- package/test-projects/spring-boot-app/.ai-dev/project.json +17 -0
- package/test-projects/spring-boot-app/.ai-dev/repo_map.json +461 -0
- package/test-projects/spring-boot-app/.ai-dev/repo_map.md +109 -0
- package/test-projects/spring-boot-app/.ai-dev/schema.json +5 -0
- package/test-projects/spring-boot-app/.ai-dev/summary.md +12 -0
- package/test-projects/spring-boot-app/.ai-dev/symbols.json +1 -0
- package/test-projects/spring-boot-app/.ai-dev/tech_stack.md +32 -0
- package/test-projects/spring-boot-app/.ai-dev/tools.json +10 -0
- package/test-projects/spring-boot-app/.classpath +57 -0
- package/test-projects/spring-boot-app/.factorypath +69 -0
- package/test-projects/spring-boot-app/.project +34 -0
- package/test-projects/spring-boot-app/.settings/org.eclipse.core.resources.prefs +4 -0
- package/test-projects/spring-boot-app/.settings/org.eclipse.jdt.apt.core.prefs +4 -0
- package/test-projects/spring-boot-app/.settings/org.eclipse.jdt.core.prefs +10 -0
- package/test-projects/spring-boot-app/.settings/org.eclipse.m2e.core.prefs +4 -0
- package/test-projects/spring-boot-app/README.md +122 -0
- package/test-projects/spring-boot-app/ai-context/ai_context.md +91 -0
- package/test-projects/spring-boot-app/ai-context/ai_rules.md +48 -0
- package/test-projects/spring-boot-app/ai-context/architecture.md +39 -0
- package/test-projects/spring-boot-app/ai-context/cache.json +173 -0
- package/test-projects/spring-boot-app/ai-context/context/features/src.json +26 -0
- package/test-projects/spring-boot-app/ai-context/context/flows/PostController.json +19 -0
- package/test-projects/spring-boot-app/ai-context/context/flows/UserController.json +19 -0
- package/test-projects/spring-boot-app/ai-context/context/flows/comment.json +11 -0
- package/test-projects/spring-boot-app/ai-context/context/flows/post.json +14 -0
- package/test-projects/spring-boot-app/ai-context/context/flows/user.json +14 -0
- package/test-projects/spring-boot-app/ai-context/conventions.md +52 -0
- package/test-projects/spring-boot-app/ai-context/dependencies.json +326 -0
- package/test-projects/spring-boot-app/ai-context/entrypoints.md +4 -0
- package/test-projects/spring-boot-app/ai-context/files.json +214 -0
- package/test-projects/spring-boot-app/ai-context/graph/knowledge-graph.json +231 -0
- package/test-projects/spring-boot-app/ai-context/graph/module-graph.json +22 -0
- package/test-projects/spring-boot-app/ai-context/graph/symbol-graph.json +794 -0
- package/test-projects/spring-boot-app/ai-context/graph/symbol-references.json +70 -0
- package/test-projects/spring-boot-app/ai-context/index-state.json +301 -0
- package/test-projects/spring-boot-app/ai-context/index.db +0 -0
- package/test-projects/spring-boot-app/ai-context/modules.json +21 -0
- package/test-projects/spring-boot-app/ai-context/project.json +17 -0
- package/test-projects/spring-boot-app/ai-context/repo_map.json +461 -0
- package/test-projects/spring-boot-app/ai-context/repo_map.md +109 -0
- package/test-projects/spring-boot-app/ai-context/schema.json +5 -0
- package/test-projects/spring-boot-app/ai-context/summary.md +12 -0
- package/test-projects/spring-boot-app/ai-context/symbols.json +1 -0
- package/test-projects/spring-boot-app/ai-context/tech_stack.md +32 -0
- package/test-projects/spring-boot-app/ai-context/tools.json +10 -0
- package/test-projects/spring-boot-app/pom.xml +79 -0
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/DemoApplication.java +12 -0
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/controllers/CommentController.java +89 -0
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/controllers/PostController.java +92 -0
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/controllers/UserController.java +84 -0
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/models/Comment.java +38 -0
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/models/Post.java +56 -0
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/models/User.java +44 -0
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/repositories/CommentRepository.java +21 -0
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/repositories/PostRepository.java +18 -0
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/repositories/UserRepository.java +15 -0
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/services/PostService.java +83 -0
- package/test-projects/spring-boot-app/src/main/java/com/example/demo/services/UserService.java +62 -0
- package/test-projects/spring-boot-app/src/main/resources/application.properties +22 -0
- 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/test_adapters.mjs +87 -0
- package/tests/e2e/README.md +20 -20
- package/tests/phase2-fixes.test.ts +200 -0
- package/ANALISIS_MEJORAS.md +0 -327
- 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/ai/cache.json +0 -1109
- package/ai/context/features/test-projects.json +0 -56
- package/ai/context/flows/add_.json +0 -9
- package/ai/context/flows/auth..json +0 -10
- package/ai/context/flows/list_.json +0 -9
- package/ai/context/flows/remove_.json +0 -9
- package/ai/context/flows/user.json +0 -14
- package/ai/context/flows/users..json +0 -10
- package/ai/dependencies.json +0 -485
- package/ai/files.json +0 -2029
- package/ai/git/recent-features.json +0 -3
- package/ai/git/recent-flows.json +0 -3
- package/ai/graph/module-graph.json +0 -389
- package/ai/graph/symbol-graph.json +0 -85206
- package/ai/graph/symbol-references.json +0 -2707
- package/ai/hierarchy.json +0 -7
- package/ai/index-state.json +0 -1939
- package/ai/modules.json +0 -299
- package/ai/repo-map.json +0 -2867
- package/test-projects/express-api/ai/cache.json +0 -125
- package/test-projects/express-api/ai/graph/knowledge-graph.json +0 -98
- package/test-projects/express-api/ai/graph/module-graph.json +0 -44
- package/test-projects/express-api/ai/graph/symbol-graph.json +0 -882
- package/test-projects/express-api/ai/graph/symbol-references.json +0 -51
- package/test-projects/express-api/ai/index-state.json +0 -238
- package/test-projects/express-api/ai/symbols.json +0 -1174
- package/test-projects/nestjs-backend/ai/graph/knowledge-graph.json +0 -74
- package/test-projects/nestjs-backend/ai/repo_map.json +0 -141
- package/test-projects/nestjs-backend/ai/repo_map.md +0 -39
- package/test-projects/nestjs-backend/ai/symbols.json +0 -527
- package/test-projects/python-cli/ai/context/flows/add_.json +0 -9
- package/test-projects/python-cli/ai/repo_map.json +0 -99
- package/test-projects/python-cli/ai/repo_map.md +0 -32
- package/test-projects/python-cli/ai/symbols.json +0 -475
- package/test-projects/react-app/ai/repo_map.json +0 -114
- package/test-projects/react-app/ai/repo_map.md +0 -31
- package/test-projects/react-app/ai/schema.json +0 -5
- package/test-projects/react-app/ai/symbols.json +0 -985
- package/test-projects/salesforce-cli/ai/repo_map.json +0 -69
- package/test-projects/salesforce-cli/ai/repo_map.md +0 -21
- package/test-projects/salesforce-cli/ai/schema.json +0 -5
- package/test-projects/salesforce-cli/ai/symbols.json +0 -245
- /package/{ai → .ai-dev}/ccp/jira-123/context.json +0 -0
- /package/{ai → .ai-dev}/context/features/commands.json +0 -0
- /package/{ai → .ai-dev}/context/features/src.json +0 -0
- /package/{ai → .ai-dev}/context/flows/account.json +0 -0
- /package/{ai → .ai-dev}/context/flows/ai-first.json +0 -0
- /package/{ai → .ai-dev}/context/flows/dashboard.json +0 -0
- /package/{ai → .ai-dev}/context/flows/doctor.json +0 -0
- /package/{ai → .ai-dev}/context/flows/explore.json +0 -0
- /package/{ai → .ai-dev}/context/flows/login.json +0 -0
- /package/{ai → .ai-dev}/context/flows/opportunity.json +0 -0
- /package/{ai → .ai-dev}/context/flows/users.json +0 -0
- /package/{ai → .ai-dev}/context/repo.json +0 -0
- /package/{ai → .ai-dev}/context/utils.json +0 -0
- /package/{ai → .ai-dev}/conventions.md +0 -0
- /package/{ai → .ai-dev}/embeddings.json +0 -0
- /package/{ai → .ai-dev}/entrypoints.md +0 -0
- /package/{ai/symbols.json → .ai-dev/git/recent-features.json} +0 -0
- /package/{ai → .ai-dev}/tools.json +0 -0
- /package/{test-projects/express-api/ai → ai-context}/tools.json +0 -0
- /package/test-projects/{salesforce-cli/ai → django-app/.ai-dev}/conventions.md +0 -0
- /package/test-projects/{python-cli/ai → django-app/.ai-dev}/entrypoints.md +0 -0
- /package/test-projects/{salesforce-cli/ai → django-app/.ai-dev}/graph/symbol-references.json +0 -0
- /package/test-projects/{nestjs-backend/ai → django-app/.ai-dev}/tools.json +0 -0
- /package/test-projects/{react-app/ai → django-app/ai-context}/entrypoints.md +0 -0
- /package/test-projects/{python-cli/ai → django-app/ai-context}/tools.json +0 -0
- /package/test-projects/express-api/{ai → .ai-dev}/ai_context.md +0 -0
- /package/test-projects/express-api/{ai → .ai-dev}/ai_rules.md +0 -0
- /package/test-projects/express-api/{ai → .ai-dev}/architecture.md +0 -0
- /package/test-projects/express-api/{ai → .ai-dev}/context/features/controllers.json +0 -0
- /package/test-projects/express-api/{ai → .ai-dev}/context/features/services.json +0 -0
- /package/test-projects/express-api/{ai → .ai-dev}/context/flows/auth.json +0 -0
- /package/test-projects/express-api/{ai → .ai-dev}/context/flows/user.json +0 -0
- /package/test-projects/express-api/{ai → .ai-dev}/conventions.md +0 -0
- /package/test-projects/express-api/{ai → .ai-dev}/dependencies.json +0 -0
- /package/test-projects/express-api/{ai → .ai-dev}/entrypoints.md +0 -0
- /package/test-projects/express-api/{ai → .ai-dev}/modules.json +0 -0
- /package/test-projects/express-api/{ai → .ai-dev}/repo_map.md +0 -0
- /package/test-projects/express-api/{ai → .ai-dev}/summary.md +0 -0
- /package/test-projects/express-api/{ai → .ai-dev}/tech_stack.md +0 -0
- /package/test-projects/{react-app/ai → express-api/.ai-dev}/tools.json +0 -0
- /package/test-projects/{salesforce-cli/ai → express-api/ai-context}/tools.json +0 -0
- /package/test-projects/{salesforce-cli/ai → fastapi-app/.ai-dev}/entrypoints.md +0 -0
- /package/test-projects/{salesforce-cli/ai → laravel-app/.ai-dev}/dependencies.json +0 -0
- /package/test-projects/nestjs-backend/{ai → .ai-dev}/context/features/src.json +0 -0
- /package/test-projects/nestjs-backend/{ai/context/flows/auth..json → .ai-dev/context/flows/auth.json} +0 -0
- /package/test-projects/nestjs-backend/{ai → .ai-dev}/context/flows/users..json +0 -0
- /package/test-projects/nestjs-backend/{ai → .ai-dev}/dependencies.json +0 -0
- /package/test-projects/nestjs-backend/{ai → .ai-dev}/entrypoints.md +0 -0
- /package/test-projects/nestjs-backend/{ai → .ai-dev}/graph/module-graph.json +0 -0
- /package/test-projects/nestjs-backend/{ai → .ai-dev}/graph/symbol-graph.json +0 -0
- /package/test-projects/nestjs-backend/{ai → .ai-dev}/graph/symbol-references.json +0 -0
- /package/test-projects/nestjs-backend/{ai → .ai-dev}/modules.json +0 -0
- /package/test-projects/python-cli/{ai → .ai-dev}/context/features/cli.json +0 -0
- /package/test-projects/python-cli/{ai → .ai-dev}/context/flows/list_.json +0 -0
- /package/test-projects/python-cli/{ai → .ai-dev}/context/flows/remove_.json +0 -0
- /package/test-projects/python-cli/{ai → .ai-dev}/conventions.md +0 -0
- /package/test-projects/python-cli/{ai → .ai-dev}/dependencies.json +0 -0
- /package/test-projects/python-cli/{ai → .ai-dev}/graph/module-graph.json +0 -0
- /package/test-projects/python-cli/{ai → .ai-dev}/graph/symbol-graph.json +0 -0
- /package/test-projects/python-cli/{ai → .ai-dev}/graph/symbol-references.json +0 -0
- /package/test-projects/python-cli/{ai → .ai-dev}/modules.json +0 -0
- /package/test-projects/react-app/{ai → .ai-dev}/context/features/src.json +0 -0
- /package/test-projects/react-app/{ai → .ai-dev}/context/flows/dashboard.json +0 -0
- /package/test-projects/react-app/{ai → .ai-dev}/context/flows/login.json +0 -0
- /package/test-projects/react-app/{ai → .ai-dev}/context/flows/users.json +0 -0
- /package/test-projects/react-app/{ai → .ai-dev}/conventions.md +0 -0
- /package/test-projects/react-app/{ai → .ai-dev}/dependencies.json +0 -0
- /package/test-projects/react-app/{ai → .ai-dev}/graph/module-graph.json +0 -0
- /package/test-projects/react-app/{ai → .ai-dev}/graph/symbol-graph.json +0 -0
- /package/test-projects/react-app/{ai → .ai-dev}/graph/symbol-references.json +0 -0
- /package/test-projects/react-app/{ai → .ai-dev}/modules.json +0 -0
- /package/test-projects/salesforce-cli/{ai → .ai-dev}/context/features/force-app.json +0 -0
- /package/test-projects/salesforce-cli/{ai → .ai-dev}/context/flows/account.json +0 -0
- /package/test-projects/salesforce-cli/{ai → .ai-dev}/context/flows/opportunity.json +0 -0
- /package/test-projects/salesforce-cli/{ai → .ai-dev}/graph/module-graph.json +0 -0
- /package/test-projects/salesforce-cli/{ai → .ai-dev}/graph/symbol-graph.json +0 -0
- /package/test-projects/salesforce-cli/{ai → .ai-dev}/modules.json +0 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""Blog application serializers."""
|
|
2
|
+
|
|
3
|
+
from rest_framework import serializers
|
|
4
|
+
from django.contrib.auth.models import User
|
|
5
|
+
from .models import Post, Comment, Category
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class CategorySerializer(serializers.ModelSerializer):
|
|
9
|
+
"""Serializer for Category model."""
|
|
10
|
+
|
|
11
|
+
class Meta:
|
|
12
|
+
model = Category
|
|
13
|
+
fields = ["id", "name", "description"]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class CommentSerializer(serializers.ModelSerializer):
|
|
17
|
+
"""Serializer for Comment model."""
|
|
18
|
+
|
|
19
|
+
author_username = serializers.CharField(source="author.username", read_only=True)
|
|
20
|
+
|
|
21
|
+
class Meta:
|
|
22
|
+
model = Comment
|
|
23
|
+
fields = ["id", "post", "author", "author_username", "content", "created_at"]
|
|
24
|
+
read_only_fields = ["author"]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class PostSerializer(serializers.ModelSerializer):
|
|
28
|
+
"""Serializer for Post model."""
|
|
29
|
+
|
|
30
|
+
author_username = serializers.CharField(source="author.username", read_only=True)
|
|
31
|
+
comments_count = serializers.IntegerField(source="comments.count", read_only=True)
|
|
32
|
+
categories = CategorySerializer(many=True, read_only=True)
|
|
33
|
+
|
|
34
|
+
class Meta:
|
|
35
|
+
model = Post
|
|
36
|
+
fields = [
|
|
37
|
+
"id",
|
|
38
|
+
"title",
|
|
39
|
+
"content",
|
|
40
|
+
"author",
|
|
41
|
+
"author_username",
|
|
42
|
+
"created_at",
|
|
43
|
+
"updated_at",
|
|
44
|
+
"published",
|
|
45
|
+
"comments_count",
|
|
46
|
+
"categories",
|
|
47
|
+
]
|
|
48
|
+
read_only_fields = ["author"]
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class PostCreateUpdateSerializer(serializers.ModelSerializer):
|
|
52
|
+
"""Serializer for creating and updating posts."""
|
|
53
|
+
|
|
54
|
+
category_ids = serializers.ListField(
|
|
55
|
+
child=serializers.IntegerField(), write_only=True, required=False
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
class Meta:
|
|
59
|
+
model = Post
|
|
60
|
+
fields = ["id", "title", "content", "published", "category_ids"]
|
|
61
|
+
|
|
62
|
+
def create(self, validated_data):
|
|
63
|
+
"""Create a new post with categories."""
|
|
64
|
+
category_ids = validated_data.pop("category_ids", [])
|
|
65
|
+
post = Post.objects.create(**validated_data)
|
|
66
|
+
if category_ids:
|
|
67
|
+
categories = Category.objects.filter(id__in=category_ids)
|
|
68
|
+
post.categories.set(categories)
|
|
69
|
+
return post
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""Blog application URL configuration."""
|
|
2
|
+
|
|
3
|
+
from django.urls import path, include
|
|
4
|
+
from rest_framework.routers import DefaultRouter
|
|
5
|
+
from .views import PostViewSet, CommentViewSet, CategoryViewSet
|
|
6
|
+
|
|
7
|
+
router = DefaultRouter()
|
|
8
|
+
router.register(r"posts", PostViewSet)
|
|
9
|
+
router.register(r"comments", CommentViewSet)
|
|
10
|
+
router.register(r"categories", CategoryViewSet)
|
|
11
|
+
|
|
12
|
+
urlpatterns = [
|
|
13
|
+
path("", include(router.urls)),
|
|
14
|
+
]
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"""Blog application views."""
|
|
2
|
+
|
|
3
|
+
from rest_framework import viewsets, status
|
|
4
|
+
from rest_framework.decorators import action
|
|
5
|
+
from rest_framework.response import Response
|
|
6
|
+
from rest_framework.permissions import IsAuthenticated, AllowAny
|
|
7
|
+
from django.contrib.auth.models import User
|
|
8
|
+
from .models import Post, Comment, Category
|
|
9
|
+
from .serializers import (
|
|
10
|
+
PostSerializer,
|
|
11
|
+
PostCreateUpdateSerializer,
|
|
12
|
+
CommentSerializer,
|
|
13
|
+
CategorySerializer,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class PostViewSet(viewsets.ModelViewSet):
|
|
18
|
+
"""ViewSet for blog posts."""
|
|
19
|
+
|
|
20
|
+
queryset = Post.objects.all()
|
|
21
|
+
permission_classes = [IsAuthenticated]
|
|
22
|
+
|
|
23
|
+
def get_serializer_class(self):
|
|
24
|
+
"""Return appropriate serializer class."""
|
|
25
|
+
if self.action in ["create", "update", "partial_update"]:
|
|
26
|
+
return PostCreateUpdateSerializer
|
|
27
|
+
return PostSerializer
|
|
28
|
+
|
|
29
|
+
def get_permissions(self):
|
|
30
|
+
"""Allow anyone to view published posts."""
|
|
31
|
+
if self.action in ["list", "retrieve"]:
|
|
32
|
+
return [AllowAny()]
|
|
33
|
+
return [IsAuthenticated()]
|
|
34
|
+
|
|
35
|
+
def perform_create(self, serializer):
|
|
36
|
+
"""Set the author to the current user."""
|
|
37
|
+
serializer.save(author=self.request.user)
|
|
38
|
+
|
|
39
|
+
@action(detail=True, methods=["post"])
|
|
40
|
+
def publish(self, request, pk=None):
|
|
41
|
+
"""Publish a blog post."""
|
|
42
|
+
post = self.get_object()
|
|
43
|
+
post.publish()
|
|
44
|
+
return Response({"status": "post published"})
|
|
45
|
+
|
|
46
|
+
@action(detail=False, methods=["get"])
|
|
47
|
+
def my_posts(self, request):
|
|
48
|
+
"""Get posts by current user."""
|
|
49
|
+
posts = Post.objects.filter(author=request.user)
|
|
50
|
+
serializer = PostSerializer(posts, many=True)
|
|
51
|
+
return Response(serializer.data)
|
|
52
|
+
|
|
53
|
+
@action(detail=False, methods=["get"])
|
|
54
|
+
def published(self, request):
|
|
55
|
+
"""Get all published posts."""
|
|
56
|
+
posts = Post.objects.filter(published=True)
|
|
57
|
+
serializer = PostSerializer(posts, many=True)
|
|
58
|
+
return Response(serializer.data)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class CommentViewSet(viewsets.ModelViewSet):
|
|
62
|
+
"""ViewSet for comments."""
|
|
63
|
+
|
|
64
|
+
queryset = Comment.objects.all()
|
|
65
|
+
serializer_class = CommentSerializer
|
|
66
|
+
permission_classes = [IsAuthenticated]
|
|
67
|
+
|
|
68
|
+
def perform_create(self, serializer):
|
|
69
|
+
"""Set the author to the current user."""
|
|
70
|
+
serializer.save(author=self.request.user)
|
|
71
|
+
|
|
72
|
+
def get_queryset(self):
|
|
73
|
+
"""Filter comments by post if provided."""
|
|
74
|
+
queryset = Comment.objects.all()
|
|
75
|
+
post_id = self.request.query_params.get("post", None)
|
|
76
|
+
if post_id:
|
|
77
|
+
queryset = queryset.filter(post_id=post_id)
|
|
78
|
+
return queryset
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class CategoryViewSet(viewsets.ModelViewSet):
|
|
82
|
+
"""ViewSet for categories."""
|
|
83
|
+
|
|
84
|
+
queryset = Category.objects.all()
|
|
85
|
+
serializer_class = CategorySerializer
|
|
86
|
+
permission_classes = [AllowAny]
|
|
87
|
+
|
|
88
|
+
@action(detail=True, methods=["get"])
|
|
89
|
+
def posts(self, request, pk=None):
|
|
90
|
+
"""Get posts in this category."""
|
|
91
|
+
category = self.get_object()
|
|
92
|
+
posts = category.posts.filter(published=True)
|
|
93
|
+
from .serializers import PostSerializer
|
|
94
|
+
|
|
95
|
+
serializer = PostSerializer(posts, many=True)
|
|
96
|
+
return Response(serializer.data)
|
|
File without changes
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Django settings for django_app project.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
BASE_DIR = Path(__file__).resolve().parent.parent
|
|
8
|
+
|
|
9
|
+
SECRET_KEY = "django-insecure-test-key-not-for-production"
|
|
10
|
+
|
|
11
|
+
DEBUG = True
|
|
12
|
+
|
|
13
|
+
ALLOWED_HOSTS = ["localhost", "127.0.0.1"]
|
|
14
|
+
|
|
15
|
+
INSTALLED_APPS = [
|
|
16
|
+
"django.contrib.admin",
|
|
17
|
+
"django.contrib.auth",
|
|
18
|
+
"django.contrib.contenttypes",
|
|
19
|
+
"django.contrib.sessions",
|
|
20
|
+
"django.contrib.messages",
|
|
21
|
+
"django.contrib.staticfiles",
|
|
22
|
+
"rest_framework",
|
|
23
|
+
"blog",
|
|
24
|
+
"users",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
MIDDLEWARE = [
|
|
28
|
+
"django.middleware.security.SecurityMiddleware",
|
|
29
|
+
"django.contrib.sessions.middleware.SessionMiddleware",
|
|
30
|
+
"django.middleware.common.CommonMiddleware",
|
|
31
|
+
"django.middleware.csrf.CsrfViewMiddleware",
|
|
32
|
+
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
|
33
|
+
"django.contrib.messages.middleware.MessageMiddleware",
|
|
34
|
+
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
ROOT_URLCONF = "django_app.urls"
|
|
38
|
+
|
|
39
|
+
TEMPLATES = [
|
|
40
|
+
{
|
|
41
|
+
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
42
|
+
"DIRS": [],
|
|
43
|
+
"APP_DIRS": True,
|
|
44
|
+
"OPTIONS": {
|
|
45
|
+
"context_processors": [
|
|
46
|
+
"django.template.context_processors.debug",
|
|
47
|
+
"django.template.context_processors.request",
|
|
48
|
+
"django.contrib.auth.context_processors.auth",
|
|
49
|
+
"django.contrib.messages.context_processors.messages",
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
WSGI_APPLICATION = "django_app.wsgi.application"
|
|
56
|
+
|
|
57
|
+
DATABASES = {
|
|
58
|
+
"default": {
|
|
59
|
+
"ENGINE": "django.db.backends.sqlite3",
|
|
60
|
+
"NAME": BASE_DIR / "db.sqlite3",
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
AUTH_PASSWORD_VALIDATORS = [
|
|
65
|
+
{
|
|
66
|
+
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
|
|
70
|
+
},
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
LANGUAGE_CODE = "en-us"
|
|
74
|
+
TIME_ZONE = "UTC"
|
|
75
|
+
USE_I18N = True
|
|
76
|
+
USE_TZ = True
|
|
77
|
+
|
|
78
|
+
STATIC_URL = "static/"
|
|
79
|
+
|
|
80
|
+
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
|
81
|
+
|
|
82
|
+
REST_FRAMEWORK = {
|
|
83
|
+
"DEFAULT_AUTHENTICATION_CLASSES": [
|
|
84
|
+
"rest_framework.authentication.SessionAuthentication",
|
|
85
|
+
"rest_framework.authentication.TokenAuthentication",
|
|
86
|
+
],
|
|
87
|
+
"DEFAULT_PERMISSION_CLASSES": [
|
|
88
|
+
"rest_framework.permissions.IsAuthenticated",
|
|
89
|
+
],
|
|
90
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""django_app URL configuration."""
|
|
2
|
+
|
|
3
|
+
from django.contrib import admin
|
|
4
|
+
from django.urls import path, include
|
|
5
|
+
|
|
6
|
+
urlpatterns = [
|
|
7
|
+
path("admin/", admin.site.urls),
|
|
8
|
+
path("api/blog/", include("blog.urls")),
|
|
9
|
+
path("api/users/", include("users.urls")),
|
|
10
|
+
path("api-auth/", include("rest_framework.urls")),
|
|
11
|
+
]
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
"""Django's command-line utility for administrative tasks."""
|
|
3
|
+
|
|
4
|
+
import os
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def main():
|
|
9
|
+
"""Run administrative tasks."""
|
|
10
|
+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_app.settings")
|
|
11
|
+
try:
|
|
12
|
+
from django.core.management import execute_from_command_line
|
|
13
|
+
except ImportError as exc:
|
|
14
|
+
raise ImportError(
|
|
15
|
+
"Couldn't import Django. Are you sure it's installed and "
|
|
16
|
+
"available on your PYTHONPATH environment variable? Did you "
|
|
17
|
+
"forget to activate a virtual environment?"
|
|
18
|
+
) from exc
|
|
19
|
+
execute_from_command_line(sys.argv)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
if __name__ == "__main__":
|
|
23
|
+
main()
|
|
File without changes
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""Users application admin configuration."""
|
|
2
|
+
|
|
3
|
+
from django.contrib import admin
|
|
4
|
+
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
|
5
|
+
from django.contrib.auth.models import User
|
|
6
|
+
from .models import UserProfile, Follow
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class UserProfileInline(admin.StackedInline):
|
|
10
|
+
"""Inline admin for UserProfile."""
|
|
11
|
+
|
|
12
|
+
model = UserProfile
|
|
13
|
+
can_delete = False
|
|
14
|
+
verbose_name_plural = "Profile"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class UserAdmin(BaseUserAdmin):
|
|
18
|
+
"""Extended User admin with profile."""
|
|
19
|
+
|
|
20
|
+
inlines = [UserProfileInline]
|
|
21
|
+
list_display = [
|
|
22
|
+
"username",
|
|
23
|
+
"email",
|
|
24
|
+
"first_name",
|
|
25
|
+
"last_name",
|
|
26
|
+
"is_staff",
|
|
27
|
+
"date_joined",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# Re-register UserAdmin
|
|
32
|
+
admin.site.unregister(User)
|
|
33
|
+
admin.site.register(User, UserAdmin)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@admin.register(Follow)
|
|
37
|
+
class FollowAdmin(admin.ModelAdmin):
|
|
38
|
+
"""Admin configuration for Follow model."""
|
|
39
|
+
|
|
40
|
+
list_display = ["follower", "following", "created_at"]
|
|
41
|
+
list_filter = ["created_at"]
|
|
42
|
+
search_fields = ["follower__username", "following__username"]
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""Users application models."""
|
|
2
|
+
|
|
3
|
+
from django.db import models
|
|
4
|
+
from django.contrib.auth.models import User
|
|
5
|
+
from django.db.models.signals import post_save
|
|
6
|
+
from django.dispatch import receiver
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class UserProfile(models.Model):
|
|
10
|
+
"""Extended user profile model."""
|
|
11
|
+
|
|
12
|
+
user = models.OneToOneField(User, on_delete=models.CASCADE, related_name="profile")
|
|
13
|
+
bio = models.TextField(max_length=500, blank=True)
|
|
14
|
+
location = models.CharField(max_length=100, blank=True)
|
|
15
|
+
birth_date = models.DateField(null=True, blank=True)
|
|
16
|
+
avatar = models.ImageField(upload_to="avatars/", blank=True)
|
|
17
|
+
website = models.URLField(blank=True)
|
|
18
|
+
twitter = models.CharField(max_length=100, blank=True)
|
|
19
|
+
github = models.CharField(max_length=100, blank=True)
|
|
20
|
+
|
|
21
|
+
def __str__(self):
|
|
22
|
+
return f"{self.user.username} Profile"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@receiver(post_save, sender=User)
|
|
26
|
+
def create_user_profile(sender, instance, created, **kwargs):
|
|
27
|
+
"""Create a user profile when a new user is created."""
|
|
28
|
+
if created:
|
|
29
|
+
UserProfile.objects.create(user=instance)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@receiver(post_save, sender=User)
|
|
33
|
+
def save_user_profile(sender, instance, **kwargs):
|
|
34
|
+
"""Save user profile when user is saved."""
|
|
35
|
+
instance.profile.save()
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class Follow(models.Model):
|
|
39
|
+
"""Follow relationship model."""
|
|
40
|
+
|
|
41
|
+
follower = models.ForeignKey(
|
|
42
|
+
User, on_delete=models.CASCADE, related_name="following"
|
|
43
|
+
)
|
|
44
|
+
following = models.ForeignKey(
|
|
45
|
+
User, on_delete=models.CASCADE, related_name="followers"
|
|
46
|
+
)
|
|
47
|
+
created_at = models.DateTimeField(auto_now_add=True)
|
|
48
|
+
|
|
49
|
+
class Meta:
|
|
50
|
+
unique_together = ["follower", "following"]
|
|
51
|
+
ordering = ["-created_at"]
|
|
52
|
+
|
|
53
|
+
def __str__(self):
|
|
54
|
+
return f"{self.follower.username} follows {self.following.username}"
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"""Users application serializers."""
|
|
2
|
+
|
|
3
|
+
from rest_framework import serializers
|
|
4
|
+
from django.contrib.auth.models import User
|
|
5
|
+
from .models import UserProfile, Follow
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class UserProfileSerializer(serializers.ModelSerializer):
|
|
9
|
+
"""Serializer for UserProfile model."""
|
|
10
|
+
|
|
11
|
+
class Meta:
|
|
12
|
+
model = UserProfile
|
|
13
|
+
fields = [
|
|
14
|
+
"bio",
|
|
15
|
+
"location",
|
|
16
|
+
"birth_date",
|
|
17
|
+
"avatar",
|
|
18
|
+
"website",
|
|
19
|
+
"twitter",
|
|
20
|
+
"github",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class UserSerializer(serializers.ModelSerializer):
|
|
25
|
+
"""Serializer for User model."""
|
|
26
|
+
|
|
27
|
+
profile = UserProfileSerializer()
|
|
28
|
+
posts_count = serializers.IntegerField(source="posts.count", read_only=True)
|
|
29
|
+
followers_count = serializers.IntegerField(source="followers.count", read_only=True)
|
|
30
|
+
following_count = serializers.IntegerField(source="following.count", read_only=True)
|
|
31
|
+
|
|
32
|
+
class Meta:
|
|
33
|
+
model = User
|
|
34
|
+
fields = [
|
|
35
|
+
"id",
|
|
36
|
+
"username",
|
|
37
|
+
"email",
|
|
38
|
+
"first_name",
|
|
39
|
+
"last_name",
|
|
40
|
+
"profile",
|
|
41
|
+
"posts_count",
|
|
42
|
+
"followers_count",
|
|
43
|
+
"following_count",
|
|
44
|
+
"date_joined",
|
|
45
|
+
]
|
|
46
|
+
read_only_fields = ["date_joined"]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class UserCreateSerializer(serializers.ModelSerializer):
|
|
50
|
+
"""Serializer for creating new users."""
|
|
51
|
+
|
|
52
|
+
password = serializers.CharField(write_only=True)
|
|
53
|
+
password_confirm = serializers.CharField(write_only=True)
|
|
54
|
+
|
|
55
|
+
class Meta:
|
|
56
|
+
model = User
|
|
57
|
+
fields = [
|
|
58
|
+
"username",
|
|
59
|
+
"email",
|
|
60
|
+
"password",
|
|
61
|
+
"password_confirm",
|
|
62
|
+
"first_name",
|
|
63
|
+
"last_name",
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
def validate(self, data):
|
|
67
|
+
"""Validate that passwords match."""
|
|
68
|
+
if data["password"] != data["password_confirm"]:
|
|
69
|
+
raise serializers.ValidationError("Passwords don't match")
|
|
70
|
+
return data
|
|
71
|
+
|
|
72
|
+
def create(self, validated_data):
|
|
73
|
+
"""Create a new user."""
|
|
74
|
+
validated_data.pop("password_confirm")
|
|
75
|
+
user = User.objects.create_user(**validated_data)
|
|
76
|
+
return user
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class FollowSerializer(serializers.ModelSerializer):
|
|
80
|
+
"""Serializer for Follow model."""
|
|
81
|
+
|
|
82
|
+
follower_username = serializers.CharField(
|
|
83
|
+
source="follower.username", read_only=True
|
|
84
|
+
)
|
|
85
|
+
following_username = serializers.CharField(
|
|
86
|
+
source="following.username", read_only=True
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
class Meta:
|
|
90
|
+
model = Follow
|
|
91
|
+
fields = [
|
|
92
|
+
"id",
|
|
93
|
+
"follower",
|
|
94
|
+
"follower_username",
|
|
95
|
+
"following",
|
|
96
|
+
"following_username",
|
|
97
|
+
"created_at",
|
|
98
|
+
]
|
|
99
|
+
read_only_fields = ["follower"]
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class ChangePasswordSerializer(serializers.Serializer):
|
|
103
|
+
"""Serializer for password change."""
|
|
104
|
+
|
|
105
|
+
old_password = serializers.CharField(required=True)
|
|
106
|
+
new_password = serializers.CharField(required=True)
|
|
107
|
+
new_password_confirm = serializers.CharField(required=True)
|
|
108
|
+
|
|
109
|
+
def validate(self, data):
|
|
110
|
+
"""Validate new passwords match."""
|
|
111
|
+
if data["new_password"] != data["new_password_confirm"]:
|
|
112
|
+
raise serializers.ValidationError("New passwords don't match")
|
|
113
|
+
return data
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Users application URL configuration."""
|
|
2
|
+
|
|
3
|
+
from django.urls import path, include
|
|
4
|
+
from rest_framework.routers import DefaultRouter
|
|
5
|
+
from .views import UserViewSet, UserProfileViewSet
|
|
6
|
+
|
|
7
|
+
router = DefaultRouter()
|
|
8
|
+
router.register(r"users", UserViewSet)
|
|
9
|
+
router.register(r"profiles", UserProfileViewSet)
|
|
10
|
+
|
|
11
|
+
urlpatterns = [
|
|
12
|
+
path("", include(router.urls)),
|
|
13
|
+
]
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"""Users application views."""
|
|
2
|
+
|
|
3
|
+
from rest_framework import viewsets, status, generics
|
|
4
|
+
from rest_framework.decorators import action
|
|
5
|
+
from rest_framework.response import Response
|
|
6
|
+
from rest_framework.permissions import IsAuthenticated, AllowAny
|
|
7
|
+
from django.contrib.auth.models import User
|
|
8
|
+
from django.contrib.auth import authenticate
|
|
9
|
+
from .models import UserProfile, Follow
|
|
10
|
+
from .serializers import (
|
|
11
|
+
UserSerializer,
|
|
12
|
+
UserCreateSerializer,
|
|
13
|
+
UserProfileSerializer,
|
|
14
|
+
FollowSerializer,
|
|
15
|
+
ChangePasswordSerializer,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class UserViewSet(viewsets.ModelViewSet):
|
|
20
|
+
"""ViewSet for users."""
|
|
21
|
+
|
|
22
|
+
queryset = User.objects.all()
|
|
23
|
+
serializer_class = UserSerializer
|
|
24
|
+
|
|
25
|
+
def get_permissions(self):
|
|
26
|
+
"""Allow anyone to register, but only authenticated users for other actions."""
|
|
27
|
+
if self.action == "create":
|
|
28
|
+
return [AllowAny()]
|
|
29
|
+
return [IsAuthenticated()]
|
|
30
|
+
|
|
31
|
+
def get_serializer_class(self):
|
|
32
|
+
"""Return appropriate serializer class."""
|
|
33
|
+
if self.action == "create":
|
|
34
|
+
return UserCreateSerializer
|
|
35
|
+
return UserSerializer
|
|
36
|
+
|
|
37
|
+
@action(detail=False, methods=["get"])
|
|
38
|
+
def me(self, request):
|
|
39
|
+
"""Get current user profile."""
|
|
40
|
+
serializer = UserSerializer(request.user)
|
|
41
|
+
return Response(serializer.data)
|
|
42
|
+
|
|
43
|
+
@action(detail=False, methods=["put", "patch"])
|
|
44
|
+
def update_profile(self, request):
|
|
45
|
+
"""Update current user profile."""
|
|
46
|
+
user = request.user
|
|
47
|
+
profile = user.profile
|
|
48
|
+
|
|
49
|
+
# Update user data
|
|
50
|
+
user_serializer = UserSerializer(user, data=request.data, partial=True)
|
|
51
|
+
if user_serializer.is_valid():
|
|
52
|
+
user_serializer.save()
|
|
53
|
+
|
|
54
|
+
# Update profile data
|
|
55
|
+
if "profile" in request.data:
|
|
56
|
+
profile_serializer = UserProfileSerializer(
|
|
57
|
+
profile, data=request.data["profile"], partial=True
|
|
58
|
+
)
|
|
59
|
+
if profile_serializer.is_valid():
|
|
60
|
+
profile_serializer.save()
|
|
61
|
+
|
|
62
|
+
return Response(UserSerializer(user).data)
|
|
63
|
+
|
|
64
|
+
@action(detail=False, methods=["post"])
|
|
65
|
+
def change_password(self, request):
|
|
66
|
+
"""Change user password."""
|
|
67
|
+
serializer = ChangePasswordSerializer(data=request.data)
|
|
68
|
+
if serializer.is_valid():
|
|
69
|
+
user = request.user
|
|
70
|
+
if user.check_password(serializer.validated_data["old_password"]):
|
|
71
|
+
user.set_password(serializer.validated_data["new_password"])
|
|
72
|
+
user.save()
|
|
73
|
+
return Response({"status": "password changed"})
|
|
74
|
+
return Response(
|
|
75
|
+
{"error": "Wrong old password"}, status=status.HTTP_400_BAD_REQUEST
|
|
76
|
+
)
|
|
77
|
+
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|
|
78
|
+
|
|
79
|
+
@action(detail=True, methods=["post"])
|
|
80
|
+
def follow(self, request, pk=None):
|
|
81
|
+
"""Follow a user."""
|
|
82
|
+
user_to_follow = self.get_object()
|
|
83
|
+
if user_to_follow == request.user:
|
|
84
|
+
return Response(
|
|
85
|
+
{"error": "Cannot follow yourself"}, status=status.HTTP_400_BAD_REQUEST
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
follow, created = Follow.objects.get_or_create(
|
|
89
|
+
follower=request.user, following=user_to_follow
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
if created:
|
|
93
|
+
return Response({"status": "following"})
|
|
94
|
+
return Response({"status": "already following"})
|
|
95
|
+
|
|
96
|
+
@action(detail=True, methods=["post"])
|
|
97
|
+
def unfollow(self, request, pk=None):
|
|
98
|
+
"""Unfollow a user."""
|
|
99
|
+
user_to_unfollow = self.get_object()
|
|
100
|
+
Follow.objects.filter(
|
|
101
|
+
follower=request.user, following=user_to_unfollow
|
|
102
|
+
).delete()
|
|
103
|
+
return Response({"status": "unfollowed"})
|
|
104
|
+
|
|
105
|
+
@action(detail=True, methods=["get"])
|
|
106
|
+
def followers(self, request, pk=None):
|
|
107
|
+
"""Get user followers."""
|
|
108
|
+
user = self.get_object()
|
|
109
|
+
followers = Follow.objects.filter(following=user)
|
|
110
|
+
serializer = FollowSerializer(followers, many=True)
|
|
111
|
+
return Response(serializer.data)
|
|
112
|
+
|
|
113
|
+
@action(detail=True, methods=["get"])
|
|
114
|
+
def following(self, request, pk=None):
|
|
115
|
+
"""Get who user is following."""
|
|
116
|
+
user = self.get_object()
|
|
117
|
+
following = Follow.objects.filter(follower=user)
|
|
118
|
+
serializer = FollowSerializer(following, many=True)
|
|
119
|
+
return Response(serializer.data)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
class UserProfileViewSet(viewsets.ModelViewSet):
|
|
123
|
+
"""ViewSet for user profiles."""
|
|
124
|
+
|
|
125
|
+
queryset = UserProfile.objects.all()
|
|
126
|
+
serializer_class = UserProfileSerializer
|
|
127
|
+
permission_classes = [IsAuthenticated]
|
|
128
|
+
|
|
129
|
+
def get_queryset(self):
|
|
130
|
+
"""Filter by user if provided."""
|
|
131
|
+
queryset = UserProfile.objects.all()
|
|
132
|
+
user_id = self.request.query_params.get("user", None)
|
|
133
|
+
if user_id:
|
|
134
|
+
queryset = queryset.filter(user_id=user_id)
|
|
135
|
+
return queryset
|