agentic-dev 0.1.0 → 0.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/.agent/prd.json +29 -0
- package/.agent/progress.txt +1 -0
- package/.agent/prompt.md +21 -0
- package/.agent/ralph-loop-state.json +13 -0
- package/.agent/ralph-supervisor-state.json +12 -0
- package/.agent/ralph-supervisor.sh +238 -0
- package/.agent/ralph.sh +305 -0
- package/.agent/runs/README.md +7 -0
- package/.agent/sdd-build-ast-audit.json +13 -0
- package/.claude/CLAUDE.md +44 -0
- package/.claude/agentic-dev.json +3 -0
- package/.claude/agents/ai-dev.md +27 -0
- package/.claude/agents/backend-dev.md +26 -0
- package/.claude/agents/db-dev.md +26 -0
- package/.claude/agents/devops.md +27 -0
- package/.claude/agents/frontend-dev.md +25 -0
- package/.claude/agents/github-ops.md +25 -0
- package/.claude/agents/test-dev.md +26 -0
- package/.claude/agents/uiux-designer.md +25 -0
- package/.claude/settings.json +49 -0
- package/.claude/settings.local.json +8 -0
- package/.claude/skills/commit/SKILL.md +37 -0
- package/.claude/skills/dev-browser/SKILL.md +30 -0
- package/.claude/skills/otro/SKILL.md +43 -0
- package/.claude/skills/planning-with-files/SKILL.md +37 -0
- package/.claude/skills/prd/SKILL.md +27 -0
- package/.claude/skills/ralph-loop/SKILL.md +42 -0
- package/.claude/skills/sdd/SKILL.md +13 -0
- package/.claude/skills/sdd-dev/SKILL.md +71 -0
- package/.claude/skills/sdd-development/SKILL.md +13 -0
- package/.claude/workspace-config.json +3 -0
- package/.codex/agentic-dev.json +3 -0
- package/.codex/agents/README.md +22 -0
- package/.codex/agents/api.toml +11 -0
- package/.codex/agents/architecture.toml +11 -0
- package/.codex/agents/ci.toml +11 -0
- package/.codex/agents/gitops.toml +11 -0
- package/.codex/agents/orchestrator.toml +11 -0
- package/.codex/agents/quality.toml +11 -0
- package/.codex/agents/runtime.toml +11 -0
- package/.codex/agents/security.toml +11 -0
- package/.codex/agents/specs.toml +11 -0
- package/.codex/agents/ui.toml +11 -0
- package/.codex/config.toml +46 -0
- package/.codex/skills/SKILL.md +13 -0
- package/.codex/skills/agents/openai.yaml +4 -0
- package/.codex/skills/commit/SKILL.md +219 -0
- package/.codex/skills/commit/references/commit_examples.md +292 -0
- package/.codex/skills/dev-browser/SKILL.md +211 -0
- package/.codex/skills/dev-browser/bun.lock +443 -0
- package/.codex/skills/dev-browser/package-lock.json +2988 -0
- package/.codex/skills/dev-browser/package.json +31 -0
- package/.codex/skills/dev-browser/references/scraping.md +155 -0
- package/.codex/skills/dev-browser/scripts/start-relay.ts +32 -0
- package/.codex/skills/dev-browser/scripts/start-server.ts +117 -0
- package/.codex/skills/dev-browser/server.sh +24 -0
- package/.codex/skills/dev-browser/src/client.ts +474 -0
- package/.codex/skills/dev-browser/src/index.ts +287 -0
- package/.codex/skills/dev-browser/src/relay.ts +731 -0
- package/.codex/skills/dev-browser/src/snapshot/__tests__/snapshot.test.ts +223 -0
- package/.codex/skills/dev-browser/src/snapshot/browser-script.ts +877 -0
- package/.codex/skills/dev-browser/src/snapshot/index.ts +14 -0
- package/.codex/skills/dev-browser/src/snapshot/inject.ts +13 -0
- package/.codex/skills/dev-browser/src/types.ts +34 -0
- package/.codex/skills/dev-browser/tsconfig.json +36 -0
- package/.codex/skills/dev-browser/vitest.config.ts +12 -0
- package/.codex/skills/otro/SKILL.md +74 -0
- package/.codex/skills/otro/agents/openai.yaml +4 -0
- package/.codex/skills/otro/references/agent-prompts.md +61 -0
- package/.codex/skills/otro/references/contracts.md +146 -0
- package/.codex/skills/otro/references/orchestration-loop.md +51 -0
- package/.codex/skills/otro/references/runtime.md +79 -0
- package/.codex/skills/otro/runs/README.md +11 -0
- package/.codex/skills/otro/schemas/step_plan.schema.json +289 -0
- package/.codex/skills/otro/schemas/task_result.schema.json +142 -0
- package/.codex/skills/otro/schemas/wave_plan.schema.json +4 -0
- package/.codex/skills/otro/scripts/README.md +38 -0
- package/.codex/skills/otro/scripts/bump_validation_header.py +179 -0
- package/.codex/skills/otro/scripts/check_validation_header.py +84 -0
- package/.codex/skills/otro/scripts/common.py +303 -0
- package/.codex/skills/otro/scripts/init_run.sh +68 -0
- package/.codex/skills/otro/scripts/plan_loop.py +8 -0
- package/.codex/skills/otro/scripts/plan_step.py +367 -0
- package/.codex/skills/otro/scripts/plan_wave.py +8 -0
- package/.codex/skills/otro/scripts/reconcile_loop.py +8 -0
- package/.codex/skills/otro/scripts/reconcile_step.py +37 -0
- package/.codex/skills/otro/scripts/reconcile_wave.py +8 -0
- package/.codex/skills/otro/scripts/run_loop.py +300 -0
- package/.codex/skills/otro/scripts/run_loop_step.py +8 -0
- package/.codex/skills/otro/scripts/run_step.py +246 -0
- package/.codex/skills/otro/scripts/run_wave.py +8 -0
- package/.codex/skills/otro/validation/validation.md +15 -0
- package/.codex/skills/planning-with-files/SKILL.md +42 -0
- package/.codex/skills/planning-with-files/agents/openai.yaml +4 -0
- package/.codex/skills/planning-with-files/assets/plan-template.md +37 -0
- package/.codex/skills/planning-with-files/references/plan-rules.md +35 -0
- package/.codex/skills/planning-with-files/scripts/new_plan.sh +65 -0
- package/.codex/skills/prd/SKILL.md +235 -0
- package/.codex/skills/ralph-loop/SKILL.md +46 -0
- package/.codex/skills/ralph-loop/agents/openai.yaml +4 -0
- package/.codex/skills/ralph-loop/references/failure-triage.md +32 -0
- package/.codex/skills/ralph-loop/scripts/loop_until_success.sh +97 -0
- package/.codex/skills/sdd/SKILL.md +184 -0
- package/.codex/skills/sdd/agents/openai.yaml +4 -0
- package/.codex/skills/sdd/references/section-map.md +67 -0
- package/.dockerignore +8 -0
- package/.env.example +50 -0
- package/.gitignore +16 -0
- package/AGENTS.md +78 -0
- package/README.md +83 -47
- package/SDD_SKILL.md +589 -0
- package/bin/agentic-dev.mjs +97 -0
- package/client/admin/.dockerignore +3 -0
- package/client/admin/.env.example +1 -0
- package/client/admin/Dockerfile +16 -0
- package/client/admin/Dockerfile.dev +18 -0
- package/client/admin/README.md +20 -0
- package/client/admin/index.html +12 -0
- package/client/admin/package.json +41 -0
- package/client/admin/postcss.config.js +6 -0
- package/client/admin/scripts/ui-parity-admin-adapter.mjs +65 -0
- package/client/admin/src/api/alerts.ts +33 -0
- package/client/admin/src/api/client.ts +71 -0
- package/client/admin/src/api/orders.ts +33 -0
- package/client/admin/src/api/support.ts +11 -0
- package/client/admin/src/app/App.tsx +23 -0
- package/client/admin/src/auth/AuthProvider.tsx +122 -0
- package/client/admin/src/auth/ProtectedRoute.tsx +22 -0
- package/client/admin/src/auth/auth-client.ts +38 -0
- package/client/admin/src/auth/types.ts +18 -0
- package/client/admin/src/components/AdminNotificationsDrawer.tsx +162 -0
- package/client/admin/src/components/AdminShell.tsx +76 -0
- package/client/admin/src/components/ui/button.tsx +34 -0
- package/client/admin/src/components/ui/input.tsx +21 -0
- package/client/admin/src/lib/cn.ts +6 -0
- package/client/admin/src/lib/specRouteCatalog.json +30 -0
- package/client/admin/src/lib/specScreens.json +22 -0
- package/client/admin/src/main.tsx +17 -0
- package/client/admin/src/pages/AdminDashboardPage.tsx +171 -0
- package/client/admin/src/pages/AdminLoginPage.tsx +75 -0
- package/client/admin/src/pages/AdminQueuePage.tsx +107 -0
- package/client/admin/src/pages/AdminSupportPage.tsx +61 -0
- package/client/admin/src/styles/globals.css +17 -0
- package/client/admin/src/theme-vars.ts +18 -0
- package/client/admin/src/theme.ts +25 -0
- package/client/admin/src/vite-env.d.ts +1 -0
- package/client/admin/tailwind.config.js +8 -0
- package/client/admin/tsconfig.json +25 -0
- package/client/admin/vite.config.ts +12 -0
- package/client/landing/.dockerignore +3 -0
- package/client/landing/.env.example +1 -0
- package/client/landing/Dockerfile +16 -0
- package/client/landing/Dockerfile.dev +18 -0
- package/client/landing/README.md +18 -0
- package/client/landing/index.html +12 -0
- package/client/landing/package.json +41 -0
- package/client/landing/postcss.config.js +6 -0
- package/client/landing/scripts/ui-parity-landing-adapter.mjs +65 -0
- package/client/landing/src/App.tsx +21 -0
- package/client/landing/src/api/catalog.ts +30 -0
- package/client/landing/src/api/client.ts +30 -0
- package/client/landing/src/auth/AuthProvider.tsx +122 -0
- package/client/landing/src/auth/ProtectedRoute.tsx +22 -0
- package/client/landing/src/auth/auth-client.ts +38 -0
- package/client/landing/src/auth/types.ts +18 -0
- package/client/landing/src/components/LandingShell.tsx +34 -0
- package/client/landing/src/lib/specRouteCatalog.json +23 -0
- package/client/landing/src/lib/specScreens.json +17 -0
- package/client/landing/src/main.tsx +17 -0
- package/client/landing/src/pages/LandingHomePage.tsx +215 -0
- package/client/landing/src/pages/LandingLoginPage.tsx +90 -0
- package/client/landing/src/pages/LandingWorkspacePage.tsx +126 -0
- package/client/landing/src/styles/globals.css +17 -0
- package/client/landing/src/theme-vars.ts +16 -0
- package/client/landing/src/theme.ts +21 -0
- package/client/landing/src/vite-env.d.ts +1 -0
- package/client/landing/tailwind.config.js +8 -0
- package/client/landing/tsconfig.json +25 -0
- package/client/landing/vite.config.ts +12 -0
- package/client/mobile/.dockerignore +2 -0
- package/client/mobile/.env.example +1 -0
- package/client/mobile/Dockerfile +16 -0
- package/client/mobile/Dockerfile.dev +18 -0
- package/client/mobile/README.md +19 -0
- package/client/mobile/index.html +12 -0
- package/client/mobile/package.json +42 -0
- package/client/mobile/postcss.config.js +6 -0
- package/client/mobile/scripts/ui-parity-mobile-adapter.mjs +67 -0
- package/client/mobile/src/App.tsx +1 -0
- package/client/mobile/src/api/client.ts +62 -0
- package/client/mobile/src/api/fulfillment.ts +55 -0
- package/client/mobile/src/api/shipping.ts +56 -0
- package/client/mobile/src/app/App.tsx +23 -0
- package/client/mobile/src/auth/AuthProvider.tsx +122 -0
- package/client/mobile/src/auth/ProtectedRoute.tsx +27 -0
- package/client/mobile/src/auth/auth-client.ts +38 -0
- package/client/mobile/src/auth/types.ts +18 -0
- package/client/mobile/src/components/InShell.tsx +74 -0
- package/client/mobile/src/components/ui/button.tsx +35 -0
- package/client/mobile/src/components/ui/card.tsx +15 -0
- package/client/mobile/src/components/ui/input.tsx +21 -0
- package/client/mobile/src/lib/cn.ts +6 -0
- package/client/mobile/src/lib/specRouteCatalog.json +26 -0
- package/client/mobile/src/lib/specScreens.json +22 -0
- package/client/mobile/src/lib/useSpeechRecognitionInput.ts +271 -0
- package/client/mobile/src/main.tsx +17 -0
- package/client/mobile/src/pages/DashboardPage.tsx +172 -0
- package/client/mobile/src/pages/FulfillmentPage.tsx +138 -0
- package/client/mobile/src/pages/LoginPage.tsx +74 -0
- package/client/mobile/src/pages/ShippingPage.tsx +338 -0
- package/client/mobile/src/styles/globals.css +23 -0
- package/client/mobile/src/theme-vars.ts +16 -0
- package/client/mobile/src/theme.ts +21 -0
- package/client/mobile/src/vite-env.d.ts +1 -0
- package/client/mobile/tailwind.config.js +8 -0
- package/client/mobile/tsconfig.json +25 -0
- package/client/mobile/vite.config.ts +12 -0
- package/client/platform/.dockerignore +3 -0
- package/client/platform/.env.example +1 -0
- package/client/platform/Dockerfile +16 -0
- package/client/platform/Dockerfile.dev +18 -0
- package/client/platform/README.md +47 -0
- package/client/platform/index.html +12 -0
- package/client/platform/package.json +42 -0
- package/client/platform/postcss.config.js +6 -0
- package/client/platform/scripts/ui-parity-platform-adapter.mjs +66 -0
- package/client/platform/src/api/client.ts +30 -0
- package/client/platform/src/api/orders.ts +42 -0
- package/client/platform/src/app/App.tsx +21 -0
- package/client/platform/src/auth/AuthProvider.tsx +122 -0
- package/client/platform/src/auth/ProtectedRoute.tsx +22 -0
- package/client/platform/src/auth/auth-client.ts +38 -0
- package/client/platform/src/auth/types.ts +18 -0
- package/client/platform/src/components/AppShell.tsx +59 -0
- package/client/platform/src/components/ui/button.tsx +35 -0
- package/client/platform/src/components/ui/card.tsx +7 -0
- package/client/platform/src/components/ui/input.tsx +21 -0
- package/client/platform/src/lib/cn.ts +6 -0
- package/client/platform/src/lib/specRouteCatalog.json +23 -0
- package/client/platform/src/lib/specScreens.json +17 -0
- package/client/platform/src/main.tsx +17 -0
- package/client/platform/src/pages/DashboardPage.tsx +158 -0
- package/client/platform/src/pages/LoginPage.tsx +72 -0
- package/client/platform/src/pages/OrdersPage.tsx +123 -0
- package/client/platform/src/styles/globals.css +17 -0
- package/client/platform/src/theme-vars.ts +18 -0
- package/client/platform/src/theme.ts +25 -0
- package/client/platform/src/vite-env.d.ts +1 -0
- package/client/platform/tailwind.config.js +8 -0
- package/client/platform/tsconfig.json +25 -0
- package/client/platform/vite.config.ts +12 -0
- package/compose.yml +206 -0
- package/infra/compose/.env.dev.example +28 -0
- package/infra/compose/.env.prod.example +29 -0
- package/infra/compose/README.md +35 -0
- package/infra/compose/dev.yml +125 -0
- package/infra/compose/prod.yml +126 -0
- package/infra/terraform/README.md +34 -0
- package/infra/terraform/aws/data/.terraform.lock.hcl +25 -0
- package/infra/terraform/aws/data/README.md +18 -0
- package/infra/terraform/aws/data/main.tf +147 -0
- package/infra/terraform/aws/data/outputs.tf +14 -0
- package/infra/terraform/aws/data/variables.tf +57 -0
- package/infra/terraform/aws/data/versions.tf +10 -0
- package/infra/terraform/aws/domain/.terraform.lock.hcl +25 -0
- package/infra/terraform/aws/domain/README.md +20 -0
- package/infra/terraform/aws/domain/env/dev.tfvars.example +6 -0
- package/infra/terraform/aws/domain/env/prod.tfvars.example +7 -0
- package/infra/terraform/aws/domain/main.tf +149 -0
- package/infra/terraform/aws/domain/outputs.tf +29 -0
- package/infra/terraform/aws/domain/variables.tf +58 -0
- package/infra/terraform/aws/domain/versions.tf +10 -0
- package/infra/terraform/openstack/README.md +38 -0
- package/infra/terraform/openstack/dev/.terraform.lock.hcl +24 -0
- package/infra/terraform/openstack/dev/README.md +18 -0
- package/infra/terraform/openstack/dev/main.tf +49 -0
- package/infra/terraform/openstack/dev/providers.tf +15 -0
- package/infra/terraform/openstack/dev/terraform.tfvars.example +54 -0
- package/infra/terraform/openstack/dev/variables.tf +210 -0
- package/infra/terraform/openstack/dev/versions.tf +10 -0
- package/infra/terraform/openstack/modules/environment_host/main.tf +143 -0
- package/infra/terraform/openstack/modules/environment_host/outputs.tf +25 -0
- package/infra/terraform/openstack/modules/environment_host/templates/docker-host-user-data.sh.tftpl +40 -0
- package/infra/terraform/openstack/modules/environment_host/variables.tf +145 -0
- package/infra/terraform/openstack/modules/environment_host/versions.tf +7 -0
- package/infra/terraform/openstack/prod/.terraform.lock.hcl +24 -0
- package/infra/terraform/openstack/prod/README.md +18 -0
- package/infra/terraform/openstack/prod/main.tf +49 -0
- package/infra/terraform/openstack/prod/providers.tf +15 -0
- package/infra/terraform/openstack/prod/terraform.tfvars.example +55 -0
- package/infra/terraform/openstack/prod/variables.tf +210 -0
- package/infra/terraform/openstack/prod/versions.tf +10 -0
- package/infra/terraform/openstack/server/.terraform.lock.hcl +45 -0
- package/infra/terraform/openstack/server/README.md +47 -0
- package/infra/terraform/openstack/server/main.tf +161 -0
- package/infra/terraform/openstack/server/outputs.tf +30 -0
- package/infra/terraform/openstack/server/providers.tf +30 -0
- package/infra/terraform/openstack/server/templates/server-user-data.sh.tftpl +50 -0
- package/infra/terraform/openstack/server/variables.tf +233 -0
- package/infra/terraform/openstack/server/zz_aspace.auto.tfvars.example.json +29 -0
- package/lib/scaffold.mjs +373 -0
- package/package.json +33 -12
- package/pnpm-workspace.yaml +2 -0
- package/scripts/dev/audit_sdd_build_ast.py +277 -0
- package/sdd/01_planning/01_feature/INDEX.md +16 -0
- package/sdd/01_planning/01_feature/README.md +76 -0
- package/sdd/01_planning/01_feature/alerts_feature_spec.md +55 -0
- package/sdd/01_planning/01_feature/auth_feature_spec.md +57 -0
- package/sdd/01_planning/01_feature/catalog_feature_spec.md +61 -0
- package/sdd/01_planning/01_feature/fulfillment_feature_spec.md +58 -0
- package/sdd/01_planning/01_feature/health_feature_spec.md +52 -0
- package/sdd/01_planning/01_feature/inventory_feature_spec.md +60 -0
- package/sdd/01_planning/01_feature/order_feature_spec.md +63 -0
- package/sdd/01_planning/01_feature/shipping_feature_spec.md +55 -0
- package/sdd/01_planning/01_feature/support_feature_spec.md +53 -0
- package/sdd/01_planning/01_feature/user_feature_spec.md +54 -0
- package/sdd/01_planning/02_screen/INDEX.md +13 -0
- package/sdd/01_planning/02_screen/README.md +41 -0
- package/sdd/01_planning/02_screen/admin_screen_spec.pdf +0 -0
- package/sdd/01_planning/02_screen/assets/README.md +16 -0
- package/sdd/01_planning/02_screen/assets/example/README.md +13 -0
- package/sdd/01_planning/02_screen/landing_screen_spec.pdf +0 -0
- package/sdd/01_planning/02_screen/mobile_screen_spec.pdf +0 -0
- package/sdd/01_planning/02_screen/platform_screen_spec.pdf +0 -0
- package/sdd/01_planning/03_architecture/INDEX.md +9 -0
- package/sdd/01_planning/03_architecture/README.md +25 -0
- package/sdd/01_planning/03_architecture/architecture_document_structure.md +77 -0
- package/sdd/01_planning/03_architecture/backend/README.md +10 -0
- package/sdd/01_planning/03_architecture/frontend/README.md +12 -0
- package/sdd/01_planning/03_architecture/infra/README.md +10 -0
- package/sdd/01_planning/03_architecture/tech-research/README.md +4 -0
- package/sdd/01_planning/03_architecture/templates_system_architecture.md +84 -0
- package/sdd/01_planning/04_data/INDEX.md +4 -0
- package/sdd/01_planning/04_data/README.md +10 -0
- package/sdd/01_planning/04_data/templates_data_modeling.md +119 -0
- package/sdd/01_planning/05_api/README.md +12 -0
- package/sdd/01_planning/05_api/templates_api_contract.md +90 -0
- package/sdd/01_planning/06_iac/README.md +11 -0
- package/sdd/01_planning/06_iac/templates_runtime_and_cicd_baseline.md +46 -0
- package/sdd/01_planning/07_integration/README.md +11 -0
- package/sdd/01_planning/07_integration/templates_frontend_api_integration.md +46 -0
- package/sdd/01_planning/08_nonfunctional/README.md +7 -0
- package/sdd/01_planning/09_security/README.md +7 -0
- package/sdd/01_planning/10_test/README.md +12 -0
- package/sdd/01_planning/10_test/templates_test_strategy.md +60 -0
- package/sdd/01_planning/INDEX.md +19 -0
- package/sdd/01_planning/README.md +17 -0
- package/sdd/02_plan/01_feature/README.md +34 -0
- package/sdd/02_plan/01_feature/_feature_todo_template.md +29 -0
- package/sdd/02_plan/02_screen/INDEX.md +19 -0
- package/sdd/02_plan/02_screen/README.md +39 -0
- package/sdd/02_plan/02_screen/_screen_todo_template.md +60 -0
- package/sdd/02_plan/03_architecture/README.md +23 -0
- package/sdd/02_plan/03_architecture/architecture_document_governance.md +40 -0
- package/sdd/02_plan/03_architecture/build_ast_runtime_tree_governance.md +53 -0
- package/sdd/02_plan/03_architecture/repository_governance.md +39 -0
- package/sdd/02_plan/03_architecture/runtime_and_structure_governance.md +38 -0
- package/sdd/02_plan/03_architecture/templates-hexagonal-template-architecture.md +9 -0
- package/sdd/02_plan/03_architecture/toolchain_governance.md +98 -0
- package/sdd/02_plan/04_data/README.md +5 -0
- package/sdd/02_plan/05_api/README.md +5 -0
- package/sdd/02_plan/06_iac/README.md +11 -0
- package/sdd/02_plan/06_iac/dev_runtime_delivery.md +36 -0
- package/sdd/02_plan/06_iac/template_runtime_delivery.md +50 -0
- package/sdd/02_plan/07_integration/README.md +5 -0
- package/sdd/02_plan/07_integration/frontend_live_integration.md +31 -0
- package/sdd/02_plan/08_nonfunctional/README.md +5 -0
- package/sdd/02_plan/08_nonfunctional/repository_hygiene.md +26 -0
- package/sdd/02_plan/09_security/README.md +5 -0
- package/sdd/02_plan/10_test/README.md +11 -0
- package/sdd/02_plan/10_test/regression_verification.md +39 -0
- package/sdd/02_plan/10_test/templates/README.md +8 -0
- package/sdd/02_plan/10_test/templates/ui_parity_platform_contract.template.yaml +23 -0
- package/sdd/02_plan/10_test/verification_strategy.md +43 -0
- package/sdd/02_plan/99_generated/from_planning/ui_parity/.gitkeep +1 -0
- package/sdd/02_plan/README.md +40 -0
- package/sdd/03_build/01_feature/README.md +20 -0
- package/sdd/03_build/01_feature/domain/README.md +3 -0
- package/sdd/03_build/01_feature/domain/account_and_access.md +20 -0
- package/sdd/03_build/01_feature/domain/catalog_and_inventory.md +20 -0
- package/sdd/03_build/01_feature/domain/ordering_and_fulfillment.md +21 -0
- package/sdd/03_build/01_feature/domain/support_and_observability.md +21 -0
- package/sdd/03_build/01_feature/domain_surfaces.md +28 -0
- package/sdd/03_build/01_feature/service/README.md +3 -0
- package/sdd/03_build/01_feature/service/admin_surface.md +15 -0
- package/sdd/03_build/01_feature/service/landing_surface.md +13 -0
- package/sdd/03_build/01_feature/service/mobile_surface.md +14 -0
- package/sdd/03_build/01_feature/service/platform_surface.md +14 -0
- package/sdd/03_build/02_screen/README.md +25 -0
- package/sdd/03_build/02_screen/_screen_build_template.md +26 -0
- package/sdd/03_build/02_screen/admin/README.md +5 -0
- package/sdd/03_build/02_screen/landing/README.md +5 -0
- package/sdd/03_build/02_screen/mobile/README.md +5 -0
- package/sdd/03_build/02_screen/platform/README.md +5 -0
- package/sdd/03_build/03_architecture/README.md +10 -0
- package/sdd/03_build/03_architecture/architecture_document_governance.md +30 -0
- package/sdd/03_build/03_architecture/build_ast_runtime_tree_governance.md +24 -0
- package/sdd/03_build/03_architecture/repository_governance.md +18 -0
- package/sdd/03_build/03_architecture/toolchain_governance.md +36 -0
- package/sdd/03_build/06_iac/README.md +3 -0
- package/sdd/03_build/06_iac/dev_runtime_delivery.md +10 -0
- package/sdd/03_build/06_iac/template_runtime_delivery.md +49 -0
- package/sdd/03_build/07_integration/README.md +3 -0
- package/sdd/03_build/07_integration/frontend_live_integration.md +11 -0
- package/sdd/03_build/08_nonfunctional/README.md +3 -0
- package/sdd/03_build/08_nonfunctional/repository_hygiene.md +10 -0
- package/sdd/03_build/10_test/README.md +9 -0
- package/sdd/03_build/10_test/regression_verification.md +16 -0
- package/sdd/03_build/10_test/verification_harness.md +11 -0
- package/sdd/03_build/README.md +35 -0
- package/sdd/04_verify/01_feature/README.md +5 -0
- package/sdd/04_verify/01_feature/domain_verification.md +14 -0
- package/sdd/04_verify/01_feature/service_verification.md +22 -0
- package/sdd/04_verify/02_screen/README.md +6 -0
- package/sdd/04_verify/02_screen/_screen_verify_template.md +20 -0
- package/sdd/04_verify/02_screen/admin/README.md +4 -0
- package/sdd/04_verify/02_screen/landing/README.md +4 -0
- package/sdd/04_verify/02_screen/mobile/README.md +4 -0
- package/sdd/04_verify/02_screen/platform/README.md +4 -0
- package/sdd/04_verify/03_architecture/README.md +10 -0
- package/sdd/04_verify/03_architecture/architecture_document_governance.md +15 -0
- package/sdd/04_verify/03_architecture/build_ast_runtime_tree_governance.md +28 -0
- package/sdd/04_verify/03_architecture/repository_governance.md +16 -0
- package/sdd/04_verify/03_architecture/toolchain_governance.md +58 -0
- package/sdd/04_verify/06_iac/README.md +3 -0
- package/sdd/04_verify/06_iac/dev_runtime_delivery.md +10 -0
- package/sdd/04_verify/06_iac/template_runtime_delivery.md +42 -0
- package/sdd/04_verify/07_integration/README.md +3 -0
- package/sdd/04_verify/07_integration/frontend_live_integration.md +16 -0
- package/sdd/04_verify/08_nonfunctional/README.md +3 -0
- package/sdd/04_verify/08_nonfunctional/repository_hygiene.md +14 -0
- package/sdd/04_verify/10_test/README.md +9 -0
- package/sdd/04_verify/10_test/regression_verification.md +16 -0
- package/sdd/04_verify/10_test/ui_parity/README.md +4 -0
- package/sdd/04_verify/10_test/ui_parity/loop_runs/.gitkeep +0 -0
- package/sdd/04_verify/10_test/ui_parity/reference/.gitkeep +0 -0
- package/sdd/04_verify/10_test/ui_parity/staged_runs/.gitkeep +0 -0
- package/sdd/04_verify/10_test/verification_harness.md +17 -0
- package/sdd/04_verify/README.md +22 -0
- package/sdd/05_operate/01_runbooks/.gitkeep +1 -0
- package/sdd/05_operate/01_runbooks/README.md +4 -0
- package/sdd/05_operate/02_delivery_status/README.md +4 -0
- package/sdd/05_operate/02_delivery_status/service_status.md +16 -0
- package/sdd/05_operate/README.md +12 -0
- package/sdd/99_toolchain/01_automation/.gitkeep +1 -0
- package/sdd/99_toolchain/01_automation/README.md +76 -0
- package/sdd/99_toolchain/01_automation/agentic-dev/analyze_proof_results.py +132 -0
- package/sdd/99_toolchain/01_automation/agentic-dev/analyze_route_gap.py +85 -0
- package/sdd/99_toolchain/01_automation/agentic-dev/assets/repo-contract.template.json +75 -0
- package/sdd/99_toolchain/01_automation/agentic-dev/bootstrap_frontend_parity.sh +84 -0
- package/sdd/99_toolchain/01_automation/agentic-dev/init_frontend_parity.sh +33 -0
- package/sdd/99_toolchain/01_automation/agentic-dev/init_repo_contract.sh +51 -0
- package/sdd/99_toolchain/01_automation/agentic-dev/repo-contract.json +76 -0
- package/sdd/99_toolchain/01_automation/agentic-dev/resolve_frontend_target.py +52 -0
- package/sdd/99_toolchain/01_automation/agentic-dev/resolve_repo_contract.py +56 -0
- package/sdd/99_toolchain/01_automation/agentic-dev/run_frontend_target.sh +100 -0
- package/sdd/99_toolchain/01_automation/agentic-dev/run_repo_phase.sh +140 -0
- package/sdd/99_toolchain/01_automation/agentic-dev/validate_json_schema.py +39 -0
- package/sdd/99_toolchain/01_automation/agentic-parity-harness-design.md +291 -0
- package/sdd/99_toolchain/01_automation/assets/admin_screen_capture/dashboard.png +0 -0
- package/sdd/99_toolchain/01_automation/assets/admin_screen_capture/login.png +0 -0
- package/sdd/99_toolchain/01_automation/assets/admin_screen_capture/queue.png +0 -0
- package/sdd/99_toolchain/01_automation/assets/admin_screen_capture/support.png +0 -0
- package/sdd/99_toolchain/01_automation/assets/landing_screen_capture/home.png +0 -0
- package/sdd/99_toolchain/01_automation/assets/landing_screen_capture/login.png +0 -0
- package/sdd/99_toolchain/01_automation/assets/landing_screen_capture/workspace.png +0 -0
- package/sdd/99_toolchain/01_automation/assets/mobile_screen_capture/dashboard.png +0 -0
- package/sdd/99_toolchain/01_automation/assets/mobile_screen_capture/fulfillment.png +0 -0
- package/sdd/99_toolchain/01_automation/assets/mobile_screen_capture/login.png +0 -0
- package/sdd/99_toolchain/01_automation/assets/platform_screen_capture/dashboard.png +0 -0
- package/sdd/99_toolchain/01_automation/assets/platform_screen_capture/login.png +0 -0
- package/sdd/99_toolchain/01_automation/assets/platform_screen_capture/orders.png +0 -0
- package/sdd/99_toolchain/01_automation/build_asset_recipes.py +10 -0
- package/sdd/99_toolchain/01_automation/build_screen_spec_pdf.py +427 -0
- package/sdd/99_toolchain/01_automation/capture_screen_assets.mjs +148 -0
- package/sdd/99_toolchain/01_automation/harness-layout.md +34 -0
- package/sdd/99_toolchain/01_automation/parity-execution-tooling-design.md +319 -0
- package/sdd/99_toolchain/01_automation/playwright_exactness_manifest.py +21 -0
- package/sdd/99_toolchain/01_automation/run_playwright_exactness.py +87 -0
- package/sdd/99_toolchain/01_automation/screen_spec_manifest.py +321 -0
- package/sdd/99_toolchain/01_automation/spec_asset_builder.py +274 -0
- package/sdd/99_toolchain/01_automation/ui-contract-projection.md +79 -0
- package/sdd/99_toolchain/01_automation/ui-parity/README.md +60 -0
- package/sdd/99_toolchain/01_automation/ui-parity/cli/extract-reference-pages.mjs +2 -0
- package/sdd/99_toolchain/01_automation/ui-parity/cli/materialize-reference-assets.mjs +58 -0
- package/sdd/99_toolchain/01_automation/ui-parity/cli/normalize-reference-assets.mjs +2 -0
- package/sdd/99_toolchain/01_automation/ui-parity/cli/route-gap-report.mjs +187 -0
- package/sdd/99_toolchain/01_automation/ui-parity/cli/run-proof.mjs +50 -0
- package/sdd/99_toolchain/01_automation/ui-parity/cli/scaffold-contract.mjs +62 -0
- package/sdd/99_toolchain/01_automation/ui-parity/cli/upload-parity1.mjs +2 -0
- package/sdd/99_toolchain/01_automation/ui-parity/contracts/collector-metadata.schema.json +33 -0
- package/sdd/99_toolchain/01_automation/ui-parity/contracts/proof-result.schema.json +76 -0
- package/sdd/99_toolchain/01_automation/ui-parity/contracts/route-gap-report.schema.json +95 -0
- package/sdd/99_toolchain/01_automation/ui-parity/core/capture-runner.mjs +55 -0
- package/sdd/99_toolchain/01_automation/ui-parity/core/load-adapter.mjs +25 -0
- package/sdd/99_toolchain/01_automation/ui-parity/core/load-contract.mjs +81 -0
- package/sdd/99_toolchain/01_automation/ui-parity/core/paths.mjs +23 -0
- package/sdd/99_toolchain/01_automation/ui-parity/core/proof-runner.mjs +255 -0
- package/sdd/99_toolchain/01_automation/ui-parity/interfaces/ui-parity-artifact-layout.md +23 -0
- package/sdd/99_toolchain/01_automation/ui-parity/interfaces/ui-parity-proof-interface.md +60 -0
- package/sdd/99_toolchain/01_automation/ui-parity/interfaces/ui-parity-route-gap-interface.md +82 -0
- package/sdd/99_toolchain/01_automation/ui-parity/runtime/playwright-runtime.mjs +16 -0
- package/sdd/99_toolchain/01_automation/ui-parity/runtime/static-runtime.mjs +6 -0
- package/sdd/99_toolchain/02_policies/.gitkeep +1 -0
- package/sdd/99_toolchain/02_policies/build-ast-governance-policy.md +22 -0
- package/sdd/99_toolchain/02_policies/compose-runtime-baseline-policy.md +24 -0
- package/sdd/99_toolchain/02_policies/convention-storage-policy.md +26 -0
- package/sdd/99_toolchain/02_policies/main-push-before-dev-deploy-policy.md +27 -0
- package/sdd/99_toolchain/02_policies/otro-orchestration-policy.md +30 -0
- package/sdd/99_toolchain/02_policies/regression-verification-policy.md +22 -0
- package/sdd/99_toolchain/03_templates/.gitkeep +1 -0
- package/sdd/99_toolchain/03_templates/asset_recipe_manifest.example.py +38 -0
- package/sdd/99_toolchain/03_templates/generated_assets/README.md +11 -0
- package/sdd/99_toolchain/03_templates/generated_assets/example-brand-lockup.svg +3 -0
- package/sdd/99_toolchain/03_templates/generated_assets/example-brand-mark.svg +3 -0
- package/sdd/99_toolchain/03_templates/generated_assets/example-brand-wordmark.svg +3 -0
- package/sdd/99_toolchain/03_templates/playwright_exactness_manifest.example.py +21 -0
- package/sdd/99_toolchain/README.md +23 -0
- package/sdd/README.md +21 -0
- package/server/.dockerignore +4 -0
- package/server/.env.example +19 -0
- package/server/Dockerfile +22 -0
- package/server/Dockerfile.dev +19 -0
- package/server/README.md +33 -0
- package/server/__init__.py +0 -0
- package/server/api/__init__.py +1 -0
- package/server/api/http/__init__.py +4 -0
- package/server/api/http/app.py +53 -0
- package/server/api/http/router.py +24 -0
- package/server/config.py +52 -0
- package/server/contexts/__init__.py +12 -0
- package/server/contexts/alerts/__init__.py +1 -0
- package/server/contexts/alerts/application/__init__.py +13 -0
- package/server/contexts/alerts/application/services.py +41 -0
- package/server/contexts/alerts/contracts/__init__.py +3 -0
- package/server/contexts/alerts/contracts/http/__init__.py +3 -0
- package/server/contexts/alerts/contracts/http/router.py +37 -0
- package/server/contexts/alerts/domain/__init__.py +15 -0
- package/server/contexts/alerts/domain/models.py +29 -0
- package/server/contexts/alerts/infrastructure/__init__.py +11 -0
- package/server/contexts/alerts/infrastructure/repository.py +41 -0
- package/server/contexts/auth/__init__.py +1 -0
- package/server/contexts/auth/application/__init__.py +3 -0
- package/server/contexts/auth/application/ports.py +10 -0
- package/server/contexts/auth/application/services.py +64 -0
- package/server/contexts/auth/contracts/__init__.py +4 -0
- package/server/contexts/auth/contracts/http/__init__.py +4 -0
- package/server/contexts/auth/contracts/http/dependencies.py +37 -0
- package/server/contexts/auth/contracts/http/router.py +19 -0
- package/server/contexts/auth/domain/__init__.py +3 -0
- package/server/contexts/auth/domain/models.py +24 -0
- package/server/contexts/auth/infrastructure/__init__.py +4 -0
- package/server/contexts/auth/infrastructure/adapters/memory.py +19 -0
- package/server/contexts/auth/infrastructure/adapters/mongodb.py +24 -0
- package/server/contexts/auth/infrastructure/adapters/sqlalchemy.py +74 -0
- package/server/contexts/auth/infrastructure/repository.py +28 -0
- package/server/contexts/catalog/__init__.py +1 -0
- package/server/contexts/catalog/application/__init__.py +28 -0
- package/server/contexts/catalog/application/ports.py +15 -0
- package/server/contexts/catalog/application/services.py +154 -0
- package/server/contexts/catalog/contracts/__init__.py +3 -0
- package/server/contexts/catalog/contracts/http/__init__.py +3 -0
- package/server/contexts/catalog/contracts/http/router.py +60 -0
- package/server/contexts/catalog/domain/__init__.py +45 -0
- package/server/contexts/catalog/domain/models.py +113 -0
- package/server/contexts/catalog/infrastructure/__init__.py +4 -0
- package/server/contexts/catalog/infrastructure/adapters/memory.py +62 -0
- package/server/contexts/catalog/infrastructure/repository.py +8 -0
- package/server/contexts/fulfillment/__init__.py +1 -0
- package/server/contexts/fulfillment/application/__init__.py +13 -0
- package/server/contexts/fulfillment/application/ports.py +20 -0
- package/server/contexts/fulfillment/application/services.py +85 -0
- package/server/contexts/fulfillment/contracts/__init__.py +3 -0
- package/server/contexts/fulfillment/contracts/http/__init__.py +3 -0
- package/server/contexts/fulfillment/contracts/http/router.py +40 -0
- package/server/contexts/fulfillment/domain/__init__.py +25 -0
- package/server/contexts/fulfillment/domain/models.py +73 -0
- package/server/contexts/fulfillment/infrastructure/__init__.py +13 -0
- package/server/contexts/fulfillment/infrastructure/adapters/memory.py +43 -0
- package/server/contexts/fulfillment/infrastructure/repository.py +97 -0
- package/server/contexts/health/__init__.py +1 -0
- package/server/contexts/health/application/__init__.py +3 -0
- package/server/contexts/health/application/services.py +2 -0
- package/server/contexts/health/contracts/__init__.py +3 -0
- package/server/contexts/health/contracts/http/__init__.py +3 -0
- package/server/contexts/health/contracts/http/router.py +10 -0
- package/server/contexts/inventory/__init__.py +1 -0
- package/server/contexts/inventory/application/__init__.py +28 -0
- package/server/contexts/inventory/application/ports.py +11 -0
- package/server/contexts/inventory/application/services.py +214 -0
- package/server/contexts/inventory/contracts/__init__.py +3 -0
- package/server/contexts/inventory/contracts/http/__init__.py +3 -0
- package/server/contexts/inventory/contracts/http/router.py +82 -0
- package/server/contexts/inventory/domain/__init__.py +33 -0
- package/server/contexts/inventory/domain/models.py +93 -0
- package/server/contexts/inventory/infrastructure/__init__.py +4 -0
- package/server/contexts/inventory/infrastructure/adapters/memory.py +24 -0
- package/server/contexts/inventory/infrastructure/repository.py +8 -0
- package/server/contexts/orders/__init__.py +1 -0
- package/server/contexts/orders/application/__init__.py +19 -0
- package/server/contexts/orders/application/services.py +127 -0
- package/server/contexts/orders/contracts/__init__.py +3 -0
- package/server/contexts/orders/contracts/http/__init__.py +3 -0
- package/server/contexts/orders/contracts/http/router.py +82 -0
- package/server/contexts/orders/domain/__init__.py +29 -0
- package/server/contexts/orders/domain/models.py +95 -0
- package/server/contexts/orders/infrastructure/__init__.py +7 -0
- package/server/contexts/orders/infrastructure/repository.py +104 -0
- package/server/contexts/shipping/__init__.py +1 -0
- package/server/contexts/shipping/application/__init__.py +13 -0
- package/server/contexts/shipping/application/services.py +92 -0
- package/server/contexts/shipping/contracts/__init__.py +3 -0
- package/server/contexts/shipping/contracts/http/__init__.py +3 -0
- package/server/contexts/shipping/contracts/http/router.py +40 -0
- package/server/contexts/shipping/domain/__init__.py +19 -0
- package/server/contexts/shipping/domain/models.py +48 -0
- package/server/contexts/shipping/infrastructure/__init__.py +9 -0
- package/server/contexts/shipping/infrastructure/repository.py +50 -0
- package/server/contexts/support/__init__.py +1 -0
- package/server/contexts/support/application/__init__.py +13 -0
- package/server/contexts/support/application/services.py +29 -0
- package/server/contexts/support/contracts/__init__.py +3 -0
- package/server/contexts/support/contracts/http/__init__.py +3 -0
- package/server/contexts/support/contracts/http/router.py +40 -0
- package/server/contexts/support/domain/__init__.py +13 -0
- package/server/contexts/support/domain/models.py +27 -0
- package/server/contexts/support/infrastructure/__init__.py +11 -0
- package/server/contexts/support/infrastructure/repository.py +70 -0
- package/server/contexts/user/__init__.py +1 -0
- package/server/contexts/user/application/__init__.py +3 -0
- package/server/contexts/user/application/ports.py +11 -0
- package/server/contexts/user/application/services.py +44 -0
- package/server/contexts/user/contracts/__init__.py +3 -0
- package/server/contexts/user/contracts/http/__init__.py +3 -0
- package/server/contexts/user/contracts/http/router.py +26 -0
- package/server/contexts/user/domain/__init__.py +3 -0
- package/server/contexts/user/domain/models.py +22 -0
- package/server/contexts/user/infrastructure/__init__.py +3 -0
- package/server/contexts/user/infrastructure/adapters/memory.py +27 -0
- package/server/contexts/user/infrastructure/adapters/mongodb.py +41 -0
- package/server/contexts/user/infrastructure/adapters/sqlalchemy.py +94 -0
- package/server/contexts/user/infrastructure/factory.py +28 -0
- package/server/data/README.md +24 -0
- package/server/data/bootstrap/alerts.json +38 -0
- package/server/data/bootstrap/auth_accounts.json +18 -0
- package/server/data/bootstrap/catalog_products.json +179 -0
- package/server/data/bootstrap/fulfillment_events.json +5 -0
- package/server/data/bootstrap/fulfillment_notes.json +5 -0
- package/server/data/bootstrap/fulfillment_tasks.json +50 -0
- package/server/data/bootstrap/inventory_levels.json +80 -0
- package/server/data/bootstrap/orders.json +62 -0
- package/server/data/bootstrap/shipping_shipments.json +50 -0
- package/server/data/bootstrap/support_faqs.json +26 -0
- package/server/data/bootstrap/users.json +20 -0
- package/server/data/bootstrap_loader.py +15 -0
- package/server/docker-entrypoint.sh +56 -0
- package/server/main.py +3 -0
- package/server/pyproject.toml +36 -0
- package/server/shared/__init__.py +1 -0
- package/server/shared/application/__init__.py +3 -0
- package/server/shared/application/health.py +2 -0
- package/server/shared/infrastructure/__init__.py +10 -0
- package/server/shared/infrastructure/runtime.py +6 -0
- package/server/shared/infrastructure/security.py +33 -0
- package/server/tests/e2e/test_domain_feature_flows.py +483 -0
- package/server/tests/test_health.py +49 -0
- package/server/uv.lock +1169 -0
- package/bin/agentic-dev.js +0 -9
- package/src/cli.js +0 -37
- package/src/init-command.js +0 -230
- package/src/lib/command.js +0 -14
- package/src/lib/fs.js +0 -92
- package/src/lib/git.js +0 -57
- package/src/lib/github.js +0 -77
- package/src/lib/prompt.js +0 -52
- package/src/lib/system.js +0 -15
- package/src/lib/template.js +0 -143
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from pydantic import BaseModel
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class AlertItem(BaseModel):
|
|
5
|
+
id: str
|
|
6
|
+
source: str
|
|
7
|
+
title: str
|
|
8
|
+
message: str
|
|
9
|
+
tone: str
|
|
10
|
+
created_at: str
|
|
11
|
+
read: bool
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class AlertRecord(AlertItem):
|
|
15
|
+
pass
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class AlertReadResult(AlertItem):
|
|
19
|
+
pass
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class AlertsPayload(BaseModel):
|
|
23
|
+
unread_count: int
|
|
24
|
+
items: list[AlertItem]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class AlertsReadAllResult(BaseModel):
|
|
28
|
+
updated_count: int
|
|
29
|
+
unread_count: int
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from contexts.alerts.domain import AlertRecord
|
|
2
|
+
from data.bootstrap_loader import load_bootstrap_json
|
|
3
|
+
|
|
4
|
+
_alert_store: list[AlertRecord] | None = None
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def _get_alert_store() -> list[AlertRecord]:
|
|
8
|
+
global _alert_store
|
|
9
|
+
if _alert_store is None:
|
|
10
|
+
_alert_store = [
|
|
11
|
+
AlertRecord(**entry) for entry in load_bootstrap_json("alerts.json")
|
|
12
|
+
]
|
|
13
|
+
return _alert_store
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def list_seed_alerts() -> list[AlertRecord]:
|
|
17
|
+
return [record.model_copy(deep=True) for record in _get_alert_store()]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def mark_seed_alert_read(alert_id: str) -> AlertRecord:
|
|
21
|
+
records = _get_alert_store()
|
|
22
|
+
for index, record in enumerate(records):
|
|
23
|
+
if record.id != alert_id:
|
|
24
|
+
continue
|
|
25
|
+
|
|
26
|
+
updated_record = record.model_copy(update={"read": True})
|
|
27
|
+
records[index] = updated_record
|
|
28
|
+
return updated_record.model_copy(deep=True)
|
|
29
|
+
|
|
30
|
+
raise LookupError(f"Alert {alert_id} not found")
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def mark_all_seed_alerts_read() -> int:
|
|
34
|
+
records = _get_alert_store()
|
|
35
|
+
updated_count = 0
|
|
36
|
+
for index, record in enumerate(records):
|
|
37
|
+
if record.read:
|
|
38
|
+
continue
|
|
39
|
+
records[index] = record.model_copy(update={"read": True})
|
|
40
|
+
updated_count += 1
|
|
41
|
+
return updated_count
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__all__ = ["contracts", "application", "domain", "infrastructure"]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from typing import Protocol
|
|
2
|
+
|
|
3
|
+
from contexts.auth.domain import AuthAccountRecord
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class AuthAccountRepository(Protocol):
|
|
7
|
+
def initialize(self) -> None: ...
|
|
8
|
+
def seed_accounts(self, accounts: list[AuthAccountRecord]) -> None: ...
|
|
9
|
+
def get_by_email(self, email: str) -> AuthAccountRecord | None: ...
|
|
10
|
+
def get_by_id(self, user_id: str) -> AuthAccountRecord | None: ...
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
from functools import lru_cache
|
|
2
|
+
|
|
3
|
+
from fastapi import HTTPException, status
|
|
4
|
+
|
|
5
|
+
from config import get_settings
|
|
6
|
+
from contexts.auth.domain import AuthAccountRecord, AuthenticatedUser, AuthToken, LoginCommand
|
|
7
|
+
from contexts.auth.infrastructure import (
|
|
8
|
+
decode_access_token,
|
|
9
|
+
get_auth_repository,
|
|
10
|
+
issue_access_token,
|
|
11
|
+
verify_password,
|
|
12
|
+
)
|
|
13
|
+
from data.bootstrap_loader import load_bootstrap_json
|
|
14
|
+
from shared.infrastructure import hash_password
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def authenticate_user(command: LoginCommand) -> AuthToken:
|
|
18
|
+
prepare_auth_store()
|
|
19
|
+
repository = get_auth_repository()
|
|
20
|
+
account = repository.get_by_email(str(command.email))
|
|
21
|
+
if account is None or not verify_password(command.password, account.password_hash):
|
|
22
|
+
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid credentials")
|
|
23
|
+
|
|
24
|
+
return AuthToken(access_token=issue_access_token(account.id), user_id=account.id)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def resolve_current_user(bearer_token: str) -> AuthenticatedUser:
|
|
28
|
+
prepare_auth_store()
|
|
29
|
+
subject = decode_access_token(bearer_token)
|
|
30
|
+
if subject is None:
|
|
31
|
+
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid token")
|
|
32
|
+
|
|
33
|
+
repository = get_auth_repository()
|
|
34
|
+
account = repository.get_by_id(subject)
|
|
35
|
+
if account is None:
|
|
36
|
+
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid token")
|
|
37
|
+
return AuthenticatedUser(**account.model_dump(exclude={"password_hash"}))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def prepare_auth_store() -> None:
|
|
41
|
+
_seed_auth_store()
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@lru_cache
|
|
45
|
+
def _seed_auth_store() -> None:
|
|
46
|
+
settings = get_settings()
|
|
47
|
+
repository = get_auth_repository()
|
|
48
|
+
repository.initialize()
|
|
49
|
+
password_lookup = {
|
|
50
|
+
"bootstrap_admin_password": settings.bootstrap_admin_password,
|
|
51
|
+
"bootstrap_operator_password": settings.bootstrap_operator_password,
|
|
52
|
+
}
|
|
53
|
+
accounts = [
|
|
54
|
+
AuthAccountRecord(
|
|
55
|
+
id=entry["id"],
|
|
56
|
+
name=entry["name"],
|
|
57
|
+
email=entry["email"],
|
|
58
|
+
role=entry["role"],
|
|
59
|
+
status=entry["status"],
|
|
60
|
+
password_hash=hash_password(password_lookup[entry["password_source"]]),
|
|
61
|
+
)
|
|
62
|
+
for entry in load_bootstrap_json("auth_accounts.json")
|
|
63
|
+
]
|
|
64
|
+
repository.seed_accounts(accounts)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from fastapi import Depends, Header, HTTPException, status
|
|
2
|
+
|
|
3
|
+
from contexts.auth.application import resolve_current_user
|
|
4
|
+
from contexts.auth.domain import AuthenticatedUser
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def _extract_bearer_token(authorization: str | None) -> str:
|
|
8
|
+
if authorization is None:
|
|
9
|
+
raise HTTPException(
|
|
10
|
+
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
11
|
+
detail="Missing authorization header",
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
scheme, _, token = authorization.partition(" ")
|
|
15
|
+
if scheme.casefold() != "bearer" or not token.strip():
|
|
16
|
+
raise HTTPException(
|
|
17
|
+
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
18
|
+
detail="Invalid authorization header",
|
|
19
|
+
)
|
|
20
|
+
return token.strip()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def require_authenticated_user(
|
|
24
|
+
authorization: str | None = Header(default=None),
|
|
25
|
+
) -> AuthenticatedUser:
|
|
26
|
+
return resolve_current_user(_extract_bearer_token(authorization))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def require_admin_user(
|
|
30
|
+
current_user: AuthenticatedUser = Depends(require_authenticated_user),
|
|
31
|
+
) -> AuthenticatedUser:
|
|
32
|
+
if current_user.role != "admin":
|
|
33
|
+
raise HTTPException(
|
|
34
|
+
status_code=status.HTTP_403_FORBIDDEN,
|
|
35
|
+
detail="Admin access required",
|
|
36
|
+
)
|
|
37
|
+
return current_user
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from fastapi import APIRouter, Depends
|
|
2
|
+
|
|
3
|
+
from contexts.auth.application import authenticate_user
|
|
4
|
+
from contexts.auth.contracts.http.dependencies import require_authenticated_user
|
|
5
|
+
from contexts.auth.domain import AuthToken, AuthenticatedUser, LoginCommand
|
|
6
|
+
|
|
7
|
+
router = APIRouter(prefix="/auth", tags=["auth"])
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@router.post("/login", response_model=AuthToken)
|
|
11
|
+
def login(command: LoginCommand) -> AuthToken:
|
|
12
|
+
return authenticate_user(command)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@router.get("/me", response_model=AuthenticatedUser)
|
|
16
|
+
def me(
|
|
17
|
+
current_user: AuthenticatedUser = Depends(require_authenticated_user),
|
|
18
|
+
) -> AuthenticatedUser:
|
|
19
|
+
return current_user
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from pydantic import BaseModel, EmailStr
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class LoginCommand(BaseModel):
|
|
5
|
+
email: EmailStr
|
|
6
|
+
password: str
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AuthToken(BaseModel):
|
|
10
|
+
access_token: str
|
|
11
|
+
token_type: str = "bearer"
|
|
12
|
+
user_id: str
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class AuthenticatedUser(BaseModel):
|
|
16
|
+
id: str
|
|
17
|
+
name: str
|
|
18
|
+
email: EmailStr
|
|
19
|
+
role: str
|
|
20
|
+
status: str
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class AuthAccountRecord(AuthenticatedUser):
|
|
24
|
+
password_hash: str
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from contexts.auth.domain import AuthAccountRecord
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class MemoryAuthAccountRepository:
|
|
5
|
+
def __init__(self) -> None:
|
|
6
|
+
self._accounts: dict[str, AuthAccountRecord] = {}
|
|
7
|
+
|
|
8
|
+
def initialize(self) -> None:
|
|
9
|
+
return None
|
|
10
|
+
|
|
11
|
+
def seed_accounts(self, accounts: list[AuthAccountRecord]) -> None:
|
|
12
|
+
for account in accounts:
|
|
13
|
+
self._accounts[account.id] = account
|
|
14
|
+
|
|
15
|
+
def get_by_email(self, email: str) -> AuthAccountRecord | None:
|
|
16
|
+
return next((account for account in self._accounts.values() if account.email == email), None)
|
|
17
|
+
|
|
18
|
+
def get_by_id(self, user_id: str) -> AuthAccountRecord | None:
|
|
19
|
+
return self._accounts.get(user_id)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from pymongo import ASCENDING, MongoClient
|
|
2
|
+
|
|
3
|
+
from contexts.auth.domain import AuthAccountRecord
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class MongoAuthAccountRepository:
|
|
7
|
+
def __init__(self, mongodb_url: str, database_name: str) -> None:
|
|
8
|
+
self.client = MongoClient(mongodb_url)
|
|
9
|
+
self.collection = self.client[database_name]["auth_accounts"]
|
|
10
|
+
|
|
11
|
+
def initialize(self) -> None:
|
|
12
|
+
self.collection.create_index([("email", ASCENDING)], unique=True)
|
|
13
|
+
|
|
14
|
+
def seed_accounts(self, accounts: list[AuthAccountRecord]) -> None:
|
|
15
|
+
for account in accounts:
|
|
16
|
+
self.collection.update_one({"id": account.id}, {"$set": account.model_dump()}, upsert=True)
|
|
17
|
+
|
|
18
|
+
def get_by_email(self, email: str) -> AuthAccountRecord | None:
|
|
19
|
+
record = self.collection.find_one({"email": email}, {"_id": 0})
|
|
20
|
+
return AuthAccountRecord(**record) if record else None
|
|
21
|
+
|
|
22
|
+
def get_by_id(self, user_id: str) -> AuthAccountRecord | None:
|
|
23
|
+
record = self.collection.find_one({"id": user_id}, {"_id": 0})
|
|
24
|
+
return AuthAccountRecord(**record) if record else None
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
from sqlalchemy import String, create_engine, select
|
|
2
|
+
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, sessionmaker
|
|
3
|
+
|
|
4
|
+
from contexts.auth.domain import AuthAccountRecord
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Base(DeclarativeBase):
|
|
8
|
+
pass
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class AuthAccountTable(Base):
|
|
12
|
+
__tablename__ = "auth_accounts"
|
|
13
|
+
|
|
14
|
+
id: Mapped[str] = mapped_column(String(64), primary_key=True)
|
|
15
|
+
name: Mapped[str] = mapped_column(String(128))
|
|
16
|
+
email: Mapped[str] = mapped_column(String(255), unique=True, index=True)
|
|
17
|
+
role: Mapped[str] = mapped_column(String(64))
|
|
18
|
+
status: Mapped[str] = mapped_column(String(32))
|
|
19
|
+
password_hash: Mapped[str] = mapped_column(String(255))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class SqlAlchemyAuthAccountRepository:
|
|
23
|
+
def __init__(self, database_url: str) -> None:
|
|
24
|
+
self.engine = create_engine(database_url, future=True)
|
|
25
|
+
self.session_factory = sessionmaker(bind=self.engine, expire_on_commit=False)
|
|
26
|
+
|
|
27
|
+
def initialize(self) -> None:
|
|
28
|
+
Base.metadata.create_all(self.engine)
|
|
29
|
+
|
|
30
|
+
def seed_accounts(self, accounts: list[AuthAccountRecord]) -> None:
|
|
31
|
+
with self.session_factory() as session:
|
|
32
|
+
for account in accounts:
|
|
33
|
+
existing = session.get(AuthAccountTable, account.id)
|
|
34
|
+
if existing is None:
|
|
35
|
+
session.add(AuthAccountTable(**account.model_dump()))
|
|
36
|
+
continue
|
|
37
|
+
for field, value in account.model_dump().items():
|
|
38
|
+
setattr(existing, field, value)
|
|
39
|
+
session.commit()
|
|
40
|
+
|
|
41
|
+
def get_by_email(self, email: str) -> AuthAccountRecord | None:
|
|
42
|
+
with self.session_factory() as session:
|
|
43
|
+
record = session.scalar(select(AuthAccountTable).where(AuthAccountTable.email == email))
|
|
44
|
+
return self._to_record(record)
|
|
45
|
+
|
|
46
|
+
def get_by_id(self, user_id: str) -> AuthAccountRecord | None:
|
|
47
|
+
with self.session_factory() as session:
|
|
48
|
+
record = session.get(AuthAccountTable, user_id)
|
|
49
|
+
return self._to_record(record)
|
|
50
|
+
|
|
51
|
+
@staticmethod
|
|
52
|
+
def _to_record(record: AuthAccountTable | None) -> AuthAccountRecord | None:
|
|
53
|
+
if record is None:
|
|
54
|
+
return None
|
|
55
|
+
return AuthAccountRecord(
|
|
56
|
+
id=record.id,
|
|
57
|
+
name=record.name,
|
|
58
|
+
email=record.email,
|
|
59
|
+
role=record.role,
|
|
60
|
+
status=record.status,
|
|
61
|
+
password_hash=record.password_hash,
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class PostgresAuthAccountRepository(SqlAlchemyAuthAccountRepository):
|
|
66
|
+
pass
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class MySqlAuthAccountRepository(SqlAlchemyAuthAccountRepository):
|
|
70
|
+
pass
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class MariaDbAuthAccountRepository(SqlAlchemyAuthAccountRepository):
|
|
74
|
+
pass
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from functools import lru_cache
|
|
2
|
+
from typing import TYPE_CHECKING
|
|
3
|
+
|
|
4
|
+
from config import get_settings
|
|
5
|
+
from contexts.auth.infrastructure.adapters.memory import MemoryAuthAccountRepository
|
|
6
|
+
from contexts.auth.infrastructure.adapters.mongodb import MongoAuthAccountRepository
|
|
7
|
+
from contexts.auth.infrastructure.adapters.sqlalchemy import (
|
|
8
|
+
MariaDbAuthAccountRepository,
|
|
9
|
+
MySqlAuthAccountRepository,
|
|
10
|
+
PostgresAuthAccountRepository,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
if TYPE_CHECKING:
|
|
14
|
+
from contexts.auth.application.ports import AuthAccountRepository
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@lru_cache
|
|
18
|
+
def get_auth_repository() -> "AuthAccountRepository":
|
|
19
|
+
settings = get_settings()
|
|
20
|
+
if settings.database_backend == "postgres":
|
|
21
|
+
return PostgresAuthAccountRepository(settings.postgres_url)
|
|
22
|
+
if settings.database_backend == "mysql":
|
|
23
|
+
return MySqlAuthAccountRepository(settings.mysql_url)
|
|
24
|
+
if settings.database_backend == "mariadb":
|
|
25
|
+
return MariaDbAuthAccountRepository(settings.mariadb_url)
|
|
26
|
+
if settings.database_backend == "mongodb":
|
|
27
|
+
return MongoAuthAccountRepository(settings.mongodb_url, settings.mongodb_database)
|
|
28
|
+
return MemoryAuthAccountRepository()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__all__ = ["application", "contracts", "domain", "infrastructure"]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from .services import (
|
|
2
|
+
create_product,
|
|
3
|
+
get_product_or_404,
|
|
4
|
+
list_product_summaries,
|
|
5
|
+
prepare_catalog_store,
|
|
6
|
+
update_product_or_404,
|
|
7
|
+
update_product_status_or_404,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
create_catalog_product = create_product
|
|
11
|
+
get_catalog_product_or_404 = get_product_or_404
|
|
12
|
+
list_catalog_products = list_product_summaries
|
|
13
|
+
update_catalog_product = update_product_or_404
|
|
14
|
+
update_catalog_product_status = update_product_status_or_404
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
"create_catalog_product",
|
|
18
|
+
"create_product",
|
|
19
|
+
"get_catalog_product_or_404",
|
|
20
|
+
"get_product_or_404",
|
|
21
|
+
"list_catalog_products",
|
|
22
|
+
"list_product_summaries",
|
|
23
|
+
"prepare_catalog_store",
|
|
24
|
+
"update_catalog_product",
|
|
25
|
+
"update_catalog_product_status",
|
|
26
|
+
"update_product_or_404",
|
|
27
|
+
"update_product_status_or_404",
|
|
28
|
+
]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from typing import Protocol
|
|
2
|
+
|
|
3
|
+
from contexts.catalog.domain import ProductRecord, ProductStatus, ProductSummary
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class CatalogRepository(Protocol):
|
|
7
|
+
def initialize(self) -> None: ...
|
|
8
|
+
def seed_products(self, products: list[ProductRecord]) -> None: ...
|
|
9
|
+
def list_products(self) -> list[ProductRecord]: ...
|
|
10
|
+
def list_summaries(self) -> list[ProductSummary]: ...
|
|
11
|
+
def get_by_id(self, product_id: str) -> ProductRecord | None: ...
|
|
12
|
+
def get_by_slug(self, slug: str) -> ProductRecord | None: ...
|
|
13
|
+
def create_product(self, product: ProductRecord) -> ProductRecord: ...
|
|
14
|
+
def update_product(self, product: ProductRecord) -> ProductRecord: ...
|
|
15
|
+
def update_status(self, product_id: str, status: ProductStatus) -> ProductRecord | None: ...
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
from datetime import datetime, timezone
|
|
2
|
+
from functools import lru_cache
|
|
3
|
+
|
|
4
|
+
from fastapi import HTTPException, status as http_status
|
|
5
|
+
|
|
6
|
+
from contexts.catalog.domain import (
|
|
7
|
+
CreateProductCommand,
|
|
8
|
+
ProductDetail,
|
|
9
|
+
ProductRecord,
|
|
10
|
+
ProductStatus,
|
|
11
|
+
ProductSummary,
|
|
12
|
+
UpdateProductCommand,
|
|
13
|
+
UpdateProductStatusCommand,
|
|
14
|
+
)
|
|
15
|
+
from contexts.catalog.infrastructure import get_catalog_repository
|
|
16
|
+
from data.bootstrap_loader import load_bootstrap_json
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def list_product_summaries(
|
|
20
|
+
product_status: ProductStatus | None = None,
|
|
21
|
+
category: str | None = None,
|
|
22
|
+
search: str | None = None,
|
|
23
|
+
) -> list[ProductSummary]:
|
|
24
|
+
prepare_catalog_store()
|
|
25
|
+
repository = get_catalog_repository()
|
|
26
|
+
products = repository.list_products()
|
|
27
|
+
|
|
28
|
+
if product_status is not None:
|
|
29
|
+
products = [product for product in products if product.status == product_status]
|
|
30
|
+
if category is not None:
|
|
31
|
+
normalized_category = category.strip().casefold()
|
|
32
|
+
products = [product for product in products if product.category.casefold() == normalized_category]
|
|
33
|
+
if search is not None:
|
|
34
|
+
normalized_search = search.strip().casefold()
|
|
35
|
+
products = [
|
|
36
|
+
product
|
|
37
|
+
for product in products
|
|
38
|
+
if normalized_search
|
|
39
|
+
in " ".join([product.name, product.brand, product.category, product.slug, *product.tags]).casefold()
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
return [_to_summary(product) for product in products]
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def get_product_or_404(product_id: str) -> ProductDetail:
|
|
46
|
+
prepare_catalog_store()
|
|
47
|
+
repository = get_catalog_repository()
|
|
48
|
+
product = repository.get_by_id(product_id)
|
|
49
|
+
if product is None:
|
|
50
|
+
raise HTTPException(status_code=http_status.HTTP_404_NOT_FOUND, detail="Catalog product not found")
|
|
51
|
+
return ProductDetail(**product.model_dump())
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def create_product(command: CreateProductCommand) -> ProductDetail:
|
|
55
|
+
prepare_catalog_store()
|
|
56
|
+
repository = get_catalog_repository()
|
|
57
|
+
if repository.get_by_slug(command.slug) is not None:
|
|
58
|
+
raise HTTPException(status_code=http_status.HTTP_409_CONFLICT, detail="Catalog product slug already exists")
|
|
59
|
+
|
|
60
|
+
next_id = _next_product_id(repository.list_products())
|
|
61
|
+
timestamp = _now_iso()
|
|
62
|
+
product = ProductRecord(
|
|
63
|
+
id=next_id,
|
|
64
|
+
slug=command.slug,
|
|
65
|
+
name=command.name,
|
|
66
|
+
brand=command.brand,
|
|
67
|
+
category=command.category,
|
|
68
|
+
status=command.status,
|
|
69
|
+
short_description=command.short_description,
|
|
70
|
+
description=command.description,
|
|
71
|
+
hero_image=command.hero_image,
|
|
72
|
+
gallery=command.gallery,
|
|
73
|
+
price=command.price,
|
|
74
|
+
compare_at_price=command.compare_at_price,
|
|
75
|
+
tags=command.tags,
|
|
76
|
+
attributes=command.attributes,
|
|
77
|
+
variants=command.variants,
|
|
78
|
+
created_at=timestamp,
|
|
79
|
+
updated_at=timestamp,
|
|
80
|
+
)
|
|
81
|
+
return ProductDetail(**repository.create_product(product).model_dump())
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def update_product_or_404(product_id: str, command: UpdateProductCommand) -> ProductDetail:
|
|
85
|
+
prepare_catalog_store()
|
|
86
|
+
repository = get_catalog_repository()
|
|
87
|
+
current = repository.get_by_id(product_id)
|
|
88
|
+
if current is None:
|
|
89
|
+
raise HTTPException(status_code=http_status.HTTP_404_NOT_FOUND, detail="Catalog product not found")
|
|
90
|
+
|
|
91
|
+
updates = command.model_dump(exclude_none=True, exclude_unset=True)
|
|
92
|
+
if not updates:
|
|
93
|
+
raise HTTPException(status_code=http_status.HTTP_400_BAD_REQUEST, detail="No catalog product fields provided")
|
|
94
|
+
|
|
95
|
+
if "slug" in updates:
|
|
96
|
+
existing = repository.get_by_slug(updates["slug"])
|
|
97
|
+
if existing is not None and existing.id != product_id:
|
|
98
|
+
raise HTTPException(status_code=http_status.HTTP_409_CONFLICT, detail="Catalog product slug already exists")
|
|
99
|
+
|
|
100
|
+
updated = current.model_copy(update={**updates, "updated_at": _now_iso()})
|
|
101
|
+
return ProductDetail(**repository.update_product(updated).model_dump())
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def update_product_status_or_404(product_id: str, command: UpdateProductStatusCommand) -> ProductDetail:
|
|
105
|
+
prepare_catalog_store()
|
|
106
|
+
repository = get_catalog_repository()
|
|
107
|
+
current = repository.get_by_id(product_id)
|
|
108
|
+
if current is None:
|
|
109
|
+
raise HTTPException(status_code=http_status.HTTP_404_NOT_FOUND, detail="Catalog product not found")
|
|
110
|
+
updated = current.model_copy(update={"status": command.status, "updated_at": _now_iso()})
|
|
111
|
+
return ProductDetail(**repository.update_product(updated).model_dump())
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def prepare_catalog_store() -> None:
|
|
115
|
+
_seed_catalog_store()
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
@lru_cache
|
|
119
|
+
def _seed_catalog_store() -> None:
|
|
120
|
+
repository = get_catalog_repository()
|
|
121
|
+
repository.initialize()
|
|
122
|
+
records = [ProductRecord(**entry) for entry in load_bootstrap_json("catalog_products.json")]
|
|
123
|
+
repository.seed_products(records)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def _to_summary(product: ProductRecord) -> ProductSummary:
|
|
127
|
+
return ProductSummary(
|
|
128
|
+
id=product.id,
|
|
129
|
+
slug=product.slug,
|
|
130
|
+
name=product.name,
|
|
131
|
+
brand=product.brand,
|
|
132
|
+
category=product.category,
|
|
133
|
+
status=product.status,
|
|
134
|
+
short_description=product.short_description,
|
|
135
|
+
hero_image=product.hero_image,
|
|
136
|
+
price=product.price,
|
|
137
|
+
compare_at_price=product.compare_at_price,
|
|
138
|
+
tags=product.tags,
|
|
139
|
+
variant_count=len(product.variants),
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def _next_product_id(products: list[ProductRecord]) -> str:
|
|
144
|
+
max_sequence = 1000
|
|
145
|
+
for product in products:
|
|
146
|
+
try:
|
|
147
|
+
max_sequence = max(max_sequence, int(product.id.split("-")[-1]))
|
|
148
|
+
except ValueError:
|
|
149
|
+
continue
|
|
150
|
+
return f"prd-{max_sequence + 1}"
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def _now_iso() -> str:
|
|
154
|
+
return datetime.now(timezone.utc).replace(microsecond=0).isoformat()
|