oneie 3.6.12 → 3.6.14
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/.claude/agents/AUDIT-agent-ops-alignment.md +379 -0
- package/.claude/agents/NEWS-QUICKSTART.md +321 -0
- package/.claude/agents/NEWS-README.md +353 -0
- package/.claude/agents/agent-backend.md +1 -1
- package/.claude/agents/agent-builder.md +220 -151
- package/.claude/agents/agent-clean.md +39 -31
- package/.claude/agents/agent-clone.md +107 -54
- package/.claude/agents/agent-designer.md +76 -71
- package/.claude/agents/agent-director.md +164 -1
- package/.claude/agents/agent-documenter.md +169 -132
- package/.claude/agents/agent-frontend.md +442 -446
- package/.claude/agents/agent-integrator.md +30 -23
- package/.claude/agents/agent-lawyer.md +145 -98
- package/.claude/agents/agent-news.md +363 -0
- package/.claude/agents/agent-onboard.md +99 -69
- package/.claude/agents/agent-ontology.md +585 -0
- package/.claude/agents/agent-ops.md +178 -171
- package/.claude/agents/agent-problem-solver.md +132 -115
- package/.claude/agents/agent-quality.md +94 -77
- package/.claude/agents/agent-sales.md +89 -67
- package/.claude/commands/release.md +3 -1
- package/.claude/commands/server.md +64 -5
- package/.claude/hooks/README-knowledge-hooks.md +266 -80
- package/.claude/hooks/README-root-cleanup.md +200 -0
- package/.claude/hooks/README.md +284 -0
- package/.claude/hooks/__pycache__/done.cpython-313.pyc +0 -0
- package/.claude/hooks/__pycache__/todo.cpython-313.pyc +0 -0
- package/.claude/hooks/check-filenames.py +169 -32
- package/.claude/hooks/clean-post.py +195 -28
- package/.claude/hooks/clean-pre.py +96 -11
- package/.claude/hooks/done.py +74 -13
- package/.claude/hooks/format-hook.sh +105 -17
- package/.claude/hooks/hook-logger.sh +121 -7
- package/.claude/hooks/knowledge-post.py +136 -32
- package/.claude/hooks/knowledge-pre.py +129 -34
- package/.claude/hooks/notification-hook.sh +184 -17
- package/.claude/hooks/root-cleanup.py +181 -39
- package/.claude/hooks/security-hook.sh +248 -8
- package/.claude/hooks/tag-all-docs.py +175 -49
- package/.claude/hooks/test-validate-ontology.sh +170 -0
- package/.claude/hooks/todo.py +92 -22
- package/.claude/hooks/validate-ontology-structure-summary.md +243 -0
- package/.claude/hooks/validate-ontology-structure.py +83 -20
- package/AGENTS.md +60 -245
- package/CLAUDE.md +70 -1
- package/README.md +25 -0
- package/folders.yaml +1 -1
- package/one/.claude/settings.local.json +11 -0
- package/one/.obsidian/community-plugins.json +3 -1
- package/one/.obsidian/plugins/editing-toolbar/data.json +328 -0
- package/one/.obsidian/plugins/editing-toolbar/main.js +12 -0
- package/one/.obsidian/plugins/editing-toolbar/manifest.json +10 -0
- package/one/.obsidian/plugins/editing-toolbar/styles.css +1338 -0
- package/one/.obsidian/plugins/terminal/data.json +154 -0
- package/one/.obsidian/plugins/terminal/main.js +197 -0
- package/one/.obsidian/plugins/terminal/manifest.json +14 -0
- package/one/.obsidian/plugins/terminal/styles.css +32 -0
- package/one/.obsidian/workspace.json +71 -45
- package/one/README.md +18 -0
- package/one/connections/a2a.md +49 -0
- package/one/connections/acp.md +47 -0
- package/one/connections/acps.md +18 -0
- package/one/connections/agentkit.md +18 -0
- package/one/connections/agui.md +18 -0
- package/one/connections/any-backend.md +39 -21
- package/one/connections/ap2.md +74 -0
- package/one/connections/api/queries-reference.md +18 -0
- package/one/connections/api-docs.md +18 -0
- package/one/connections/api-reference.md +18 -0
- package/one/connections/api.md +18 -0
- package/one/connections/architecture-diagram.md +18 -0
- package/one/connections/communications.md +18 -0
- package/one/connections/connections.md +18 -0
- package/one/connections/copilotkit.md +18 -0
- package/one/connections/cryptonetworks.md +18 -0
- package/one/connections/documentation.md +18 -0
- package/one/connections/effect.md +18 -0
- package/one/connections/elizaos.md +18 -0
- package/one/connections/groups.md +814 -0
- package/one/connections/inference.md +18 -0
- package/one/connections/integration-examples.md +18 -0
- package/one/connections/integration-guide.md +18 -0
- package/one/connections/integration-phase2.md +32 -14
- package/one/connections/kyc.md +18 -0
- package/one/connections/mcp.md +18 -0
- package/one/connections/membership.md +18 -0
- package/one/connections/middleware.md +18 -0
- package/one/connections/multitenant.md +18 -0
- package/one/connections/n8n.md +18 -0
- package/one/connections/patterns.md +18 -0
- package/one/connections/protocols.md +20 -2
- package/one/connections/relationships.md +18 -0
- package/one/connections/schema.md +18 -0
- package/one/connections/service-layer.md +18 -0
- package/one/connections/vectors.md +18 -0
- package/one/connections/wordpress.md +18 -0
- package/one/connections/workflow-copy.md +18 -0
- package/one/connections/workflow-examples.md +18 -0
- package/one/connections/workflow-onboarding.md +18 -0
- package/one/connections/workflow.md +18 -0
- package/one/connections/workflows/delegation.md +18 -0
- package/one/connections/workflows/frontend.md +18 -0
- package/one/connections/workflows/strategy.md +18 -0
- package/one/connections/workflows/tasks.md +18 -0
- package/one/connections/x402-baazar.md +131 -0
- package/one/connections/x402.md +268 -164
- package/one/events/2024-10-14-deployment-plan.md +15 -16
- package/one/events/2024-10-14-deployment-success.md +15 -16
- package/one/events/2024-10-14-final-sync-complete.md +15 -16
- package/one/events/2024-10-14-release-v2.0.6.md +15 -16
- package/one/events/2024-10-15-agent-clean-v2-summary.md +15 -16
- package/one/events/2024-10-15-handoff-to-clean.md +15 -16
- package/one/events/2024-10-15-package-manager-tests.md +15 -16
- package/one/events/2024-10-15-release-command-complete.md +15 -16
- package/one/events/2025-10-15-private-files-secured.md +18 -0
- package/one/events/2025-10-15-unignore-public-group-docs.md +18 -0
- package/one/events/ALIGNMENT_REPORT_PROBLEM_SOLVER.md +335 -0
- package/one/events/ALIGNMENT_SUMMARY.md +280 -0
- package/one/events/API_ROUTES_FIXES_SUMMARY.md +18 -0
- package/one/events/ASTRO-INTEGRATION-EXAMPLES.md +18 -0
- package/one/events/AUDIT-ONTOLOGY-ALIGNMENT.md +598 -0
- package/one/events/BEFORE_AFTER_COMPARISON.md +18 -0
- package/one/events/CART-DRAWER-INTEGRATION-GUIDE.md +18 -0
- package/one/events/CASCADE-2-BACKEND-AGNOSTIC.md +18 -0
- package/one/events/CLAUDE copy.md +897 -0
- package/one/events/CLEANUP-RELEASE-V2.0.8.md +18 -0
- package/one/events/CONNECTIONS_DEMO.md +18 -0
- package/one/events/CREATE-WEBSITE.md +18 -0
- package/one/events/CRITICAL-FIXES-COMPLETE.md +18 -0
- package/one/events/CUSTOM-DOMAIN.md +18 -0
- package/one/events/DELIVERABLES.md +18 -0
- package/one/events/DEMO-GROUPS-PAGE.md +18 -0
- package/one/events/DEMO-TESTING-SUMMARY.md +18 -0
- package/one/events/DEMO_COMPONENTS.md +18 -0
- package/one/events/DEMO_HOOKS_INDEX.md +18 -0
- package/one/events/DEMO_INFRASTRUCTURE.md +18 -0
- package/one/events/DEMO_INFRASTRUCTURE_SUMMARY.md +18 -0
- package/one/events/DEMO_INTEGRATION_CHECKLIST.md +18 -0
- package/one/events/DEMO_QUICK_REFERENCE.md +18 -0
- package/one/events/DEMO_SETUP.md +18 -0
- package/one/events/DEPLOYMENT copy.md +18 -0
- package/one/events/DEPLOYMENT.md +18 -0
- package/one/events/ECOMMERCE-BEFORE-AFTER.md +16 -0
- package/one/events/ECOMMERCE-DEMO-PLAN.md +18 -0
- package/one/events/ECOMMERCE-ENHANCEMENTS.md +18 -0
- package/one/events/ECOMMERCE-HIGH-CONVERTING-ELEMENTS.md +18 -0
- package/one/events/ECOMMERCE-LIVE-DEMO.md +18 -0
- package/one/events/ECOMMERCE-REFACTOR-SUMMARY.md +18 -0
- package/one/events/ECOMMERCE-SETUP-SUMMARY.md +18 -0
- package/one/events/ECOMMERCE-TEMPLATE-COMPLETE.md +18 -0
- package/one/events/ECOMMERCE-TEMPLATES-SUMMARY.md +18 -0
- package/one/events/EFFECT_TS_API_PATTERN.md +18 -0
- package/one/events/FEATURE-2-4-COMPLETE.md +18 -0
- package/one/events/FEATURE_2_3_COMPLETE.md +18 -0
- package/one/events/GRADIENT-TEXT-PERMANENT-FIX.md +18 -0
- package/one/events/GROUPS-MIGRATION.md +18 -0
- package/one/events/GROUPS_DEMO_IMPLEMENTATION.md +18 -0
- package/one/events/HANDOFF.md +18 -0
- package/one/events/HOOKS-DEMO.md +18 -0
- package/one/events/IMPLEMENTATION-SUMMARY-FINAL.md +18 -0
- package/one/events/IMPLEMENTATION_SUMMARY.md +18 -0
- package/one/events/INSTALL-TESTS.md +18 -0
- package/one/events/INSTALLATION_FOLDERS.md +18 -0
- package/one/events/INSTALLATION_FOLDERS_FILES.md +18 -0
- package/one/events/INSTALLATION_FOLDERS_SUMMARY.md +18 -0
- package/one/events/INTEGRATION-ARCHITECTURE.md +18 -0
- package/one/events/INTEGRATION-CHECKLIST.md +18 -0
- package/one/events/INTEGRATION-ORCHESTRATION.md +18 -0
- package/one/events/INTEGRATION-SUMMARY.md +18 -0
- package/one/events/LANDING-PAGE-EXAMPLE-OUTPUT.md +18 -0
- package/one/events/LANDING-PAGE-IMPLEMENTATION.md +18 -0
- package/one/events/LANDING-PAGE-QUICKSTART.md +18 -0
- package/one/events/LICENSE.md +18 -0
- package/one/events/MCP-CONFIGURATION.md +18 -0
- package/one/events/MCP-SETUP-COMPLETE.md +18 -0
- package/one/events/MIGRATION-REPORT.md +18 -0
- package/one/events/MIGRATION.md +18 -0
- package/one/events/MULTI-ONTOLOGY-COMPLETE-GUIDE.md +18 -0
- package/one/events/MULTI-ONTOLOGY-IMPLEMENTATION-COMPLETE.md +18 -0
- package/one/events/NODE-UPGRADE.md +18 -0
- package/one/events/ONBOARDING-IMPLEMENTATION-COMPLETE copy.md +18 -0
- package/one/events/ONTOLOGY-HOOKS-README.md +18 -0
- package/one/events/ONTOLOGY-INTEGRATION-MANIFEST.md +18 -0
- package/one/events/ONTOLOGY-TUTORIALS-SUMMARY.md +18 -0
- package/one/events/ONTOLOGY-TYPE-GENERATOR-SUMMARY.md +18 -0
- package/one/events/ONTOLOGY_DISCOVERY_IMPLEMENTATION.md +18 -0
- package/one/events/ONTOLOGY_DISCOVERY_QUICKSTART.md +18 -0
- package/one/events/PACKAGE-STRUCTURE.md +18 -0
- package/one/events/PLAYBOOK-SETUP-SUMMARY.md +18 -0
- package/one/events/PROMPT_FIX_FRONTEND_ONLY.md +18 -0
- package/one/events/QA-CHECKLIST.md +18 -0
- package/one/events/QUICK-START-ONTOLOGY.md +18 -0
- package/one/events/README-archived.md +18 -0
- package/one/events/SEARCH_DEMO_CODE_REFERENCE.md +18 -0
- package/one/events/SEARCH_DEMO_DELIVERY.md +18 -0
- package/one/events/SEARCH_DEMO_SUMMARY.md +18 -0
- package/one/events/SEARCH_DEMO_VISUAL_GUIDE.md +18 -0
- package/one/events/SECURITY-AUDIT-FIXES.md +18 -0
- package/one/events/SECURITY-SCAN-COMPLETE.md +18 -0
- package/one/events/SHOP-BUILD-STATUS.md +18 -0
- package/one/events/SHOP-PREMIUM-UPDATE.md +16 -0
- package/one/events/SIMPLE_FIX_FRONTEND_ONLY.md +18 -0
- package/one/events/SITE-WIDE-GRADIENT-FIX.md +18 -0
- package/one/events/STORE-PRODUCTION-READY-STATUS.md +18 -0
- package/one/events/STRIPE-INTEGRATION.md +18 -0
- package/one/events/STRIPE-PAYMENT-METHODS-GUIDE.md +18 -0
- package/one/events/STRIPE-SETUP-GUIDE.md +18 -0
- package/one/events/TEST-PLAN-INDEX.md +18 -0
- package/one/events/TEST-PLAN.md +18 -0
- package/one/events/TEST-SUMMARY.md +18 -0
- package/one/events/TESTS-QUICK-REF.md +18 -0
- package/one/events/TRANSITIONS-QUICK-START.md +18 -0
- package/one/events/TRANSPARENCY-FIXES.md +18 -0
- package/one/events/TYPESCRIPT_FIXES.md +18 -0
- package/one/events/TYPESCRIPT_FIXES_INDEX.md +18 -0
- package/one/events/VIEW-TRANSITIONS.md +18 -0
- package/one/events/agent-director-enhancement-summary.md +18 -0
- package/one/events/agent-onboard-implementation-summary.md +18 -0
- package/one/events/agent-ontology-alignment-completion.md +263 -0
- package/one/events/backend-integration-tests.md +18 -0
- package/one/events/clean-agent-ontology-cleanup-report.md +18 -0
- package/one/events/clean-agent-todo-analysis-summary.md +336 -0
- package/one/events/cloudflare-automation-complete.md +18 -0
- package/one/events/cloudflare-pages-infrastructure-setup.md +18 -0
- package/one/events/contact-page-complete.md +18 -0
- package/one/events/convex-analysis-index.md +18 -0
- package/one/events/convex-structure-analysis.md +18 -0
- package/one/events/deployment-installation-folders.md +18 -0
- package/one/events/deployment-ops-summary.md +18 -0
- package/one/events/deployment-verification.md +18 -0
- package/one/events/design-spec-complete.md +18 -0
- package/one/events/documentation-audit-index.md +473 -0
- package/one/events/documentation-audit-summary.md +417 -0
- package/one/events/documentation-improvement-roadmap.md +906 -0
- package/one/events/documentation-standards-compliance-report.md +538 -0
- package/one/events/events.md +18 -0
- package/one/events/frontend-effects-complete.md +584 -0
- package/one/events/frontend-effects-orchestration.md +1356 -0
- package/one/events/frontend-effects-risk-register.md +1055 -0
- package/one/events/frontend-effects-week1-assignments.md +1594 -0
- package/one/events/hook-ontology-alignment-summary.md +528 -0
- package/one/events/installation-folders-workflow-integration.md +18 -0
- package/one/events/landing-page-generator.md +18 -0
- package/one/events/legal-assessment-2025-10-16.md +18 -0
- package/one/events/onboarding-implementation-complete.md +18 -0
- package/one/events/ontology-test-examples.md +18 -0
- package/one/events/phase1-backend-implementation-complete.md +18 -0
- package/one/events/release.md +18 -0
- package/one/events/root-cleanup-alignment-report.md +265 -0
- package/one/events/separate-implementation-status.md +18 -0
- package/one/events/session-summary-2025-10-18.md +18 -0
- package/one/events/skills-complete.md +18 -0
- package/one/events/skills-infer-6-10-summary.md +18 -0
- package/one/events/skills-phase1-complete.md +18 -0
- package/one/events/structural-analysis-architecture-vs-plans.md +559 -0
- package/one/events/test-dashboard.md +18 -0
- package/one/events/test-index.md +18 -0
- package/one/events/test-report-ontology.md +18 -0
- package/one/events/testing-summary.md +18 -0
- package/one/events/todo-refactoring-complete.md +408 -0
- package/one/events/wave1-backend-implementation-complete.md +698 -0
- package/one/groups/features.md +26 -0
- package/one/groups/groups.md +83 -39
- package/one/groups/one.md +47 -27
- package/one/groups/{strategy copy.md → strategy-copy.md} +23 -5
- package/one/knowledge/.obsidian/ecommerce-ontology.md +18 -0
- package/one/knowledge/100-inference-quick-reference.md +18 -0
- package/one/knowledge/agent-onboard-usage.md +18 -0
- package/one/knowledge/agentic-commerce.md +146 -0
- package/one/knowledge/ai-agents-vs-memecoins-thesis.md +683 -0
- package/one/knowledge/ai-platform.md +18 -0
- package/one/knowledge/ai-token-crypto-analysis-framework.md +1191 -0
- package/one/knowledge/ai-token-paradigm-shift-2025.md +732 -0
- package/one/knowledge/altcoin-cycle-prediction-ontology.md +884 -0
- package/one/knowledge/altcoin-cycle-trading-strategy.md +642 -0
- package/one/knowledge/architecture-any-backend.md +265 -42
- package/one/knowledge/architecture-diagram.md +404 -94
- package/one/knowledge/architecture-frontend.md +130 -51
- package/one/knowledge/architecture.md +1496 -1831
- package/one/knowledge/{ontology.md.backup → archived/ontology.old.md} +18 -0
- package/one/knowledge/astro-effect-complete-vision.md +2148 -0
- package/one/knowledge/astro-effect-simple-architecture.md +717 -0
- package/one/knowledge/audit-agent-onboard-alignment.md +481 -0
- package/one/knowledge/audit-agent-sales-alignment.md +444 -0
- package/one/knowledge/backend-api-reference.md +18 -0
- package/one/knowledge/cli-claude-handoff.md +18 -0
- package/one/knowledge/context-engineering.md +610 -0
- package/one/knowledge/crypto-analysis-strategy.md +1276 -0
- package/one/knowledge/crypto-cycle-2024-2025-analysis.md +44 -0
- package/one/knowledge/crypto.md +18 -0
- package/one/knowledge/docs.md +627 -0
- package/one/knowledge/dsl.md +18 -0
- package/one/knowledge/files.md +18 -0
- package/one/knowledge/frontend.md +18 -0
- package/one/knowledge/hono.md +18 -0
- package/one/knowledge/implementation-examples.md +18 -0
- package/one/knowledge/installation-folders.md +18 -0
- package/one/knowledge/institutional-cycle-paradigm-2025.md +555 -0
- package/one/knowledge/knowledge.md +18 -0
- package/one/knowledge/language.md +18 -0
- package/one/knowledge/lessons-learned.md +18 -0
- package/one/knowledge/lessons-website-building-focus.md +18 -0
- package/one/knowledge/merge-report.md +254 -0
- package/one/knowledge/nine-padel-playbook.md +18 -0
- package/one/knowledge/ontology-blog.yaml +42 -26
- package/one/knowledge/ontology-cheatsheet.md +18 -0
- package/one/knowledge/ontology-community.yaml +60 -37
- package/one/knowledge/ontology-core-universal.md +19 -1
- package/one/knowledge/ontology-core.yaml +58 -45
- package/one/knowledge/ontology-courses.yaml +71 -48
- package/one/knowledge/ontology-creator.md +30 -4
- package/one/knowledge/ontology-crypto.md +1603 -0
- package/one/knowledge/ontology-developer-guide.md +18 -0
- package/one/knowledge/ontology-documentation.md +46 -25
- package/one/knowledge/ontology-ecommerce.md +24 -6
- package/one/knowledge/ontology-education.md +18 -0
- package/one/knowledge/ontology-engineering-specification.md +22 -4
- package/one/knowledge/ontology-engineering.md +67 -43
- package/one/knowledge/ontology-files.yaml +525 -0
- package/one/knowledge/ontology-frontend-master.md +2898 -0
- package/one/knowledge/ontology-frontend-specifications.md +57 -49
- package/one/knowledge/ontology-frontend.md +40 -22
- package/one/knowledge/ontology-index.md +18 -0
- package/one/knowledge/ontology-minimal.yaml +18 -16
- package/one/knowledge/ontology-portfolio.yaml +40 -26
- package/one/knowledge/ontology-quickstart.md +18 -0
- package/one/knowledge/ontology-release.md +317 -0
- package/one/knowledge/ontology-shop.yaml +146 -119
- package/one/knowledge/ontology-tokens.yaml +46 -27
- package/one/knowledge/ontology-tutorial.md +18 -0
- package/one/knowledge/ontology-video-script.md +18 -0
- package/one/knowledge/ontology-visual-guide.md +20 -2
- package/one/knowledge/ontology.md +1329 -304
- package/one/knowledge/ontology.yaml +763 -275
- package/one/knowledge/patterns/backend/convex-mutation-pattern.md +48 -18
- package/one/knowledge/patterns/backend/convex-query-pattern.md +78 -23
- package/one/knowledge/patterns/backend/mutation-template.md +28 -10
- package/one/knowledge/patterns/backend/query-template.md +44 -25
- package/one/knowledge/patterns/backend/service-template.md +35 -14
- package/one/knowledge/patterns/design/component-architecture.md +45 -9
- package/one/knowledge/patterns/design/test-driven-design-pattern.md +37 -3
- package/one/knowledge/patterns/design/wireframe-template.md +36 -2
- package/one/knowledge/patterns/frontend/component-template.md +91 -40
- package/one/knowledge/patterns/frontend/form-template.md +131 -59
- package/one/knowledge/patterns/frontend/page-template.md +59 -28
- package/one/knowledge/patterns/frontend/react-component-pattern.md +87 -27
- package/one/knowledge/patterns/test/acceptance-criteria-template.md +28 -10
- package/one/knowledge/patterns/test/technical-test-template.md +48 -26
- package/one/knowledge/patterns/test/test-driven-pattern.md +25 -5
- package/one/knowledge/patterns/test/user-flow-template.md +18 -0
- package/one/knowledge/provider-agnostic-content.md +995 -0
- package/one/knowledge/provider-creation-guide.md +18 -0
- package/one/knowledge/quality-loop.md +18 -0
- package/one/knowledge/readme-architecture.md +158 -0
- package/one/knowledge/readme.md +18 -0
- package/one/knowledge/rules.md +18 -0
- package/one/knowledge/score.md +18 -0
- package/one/knowledge/specifications.md +18 -0
- package/one/knowledge/tags.md +18 -0
- package/one/knowledge/todo-template.md +18 -0
- package/one/knowledge/todo.md +18 -0
- package/one/knowledge/typescript-patterns.md +18 -0
- package/one/knowledge/universal-generation-language.md +827 -0
- package/one/knowledge/x402-research.md +104 -0
- package/one/license.md +18 -0
- package/one/people/anthony-o-connell.md +48 -19
- package/one/people/people.md +54 -31
- package/one/things/ALIGNMENT_AUDIT_QUALITY_AGENT.md +401 -0
- package/one/things/AUDIT_AGENT_INTEGRATOR_ALIGNMENT.md +588 -0
- package/one/things/AUDIT_REPORT_AGENT_CLEAN.md +461 -0
- package/one/things/CHECKLIST.md +51 -0
- package/one/things/IMPLEMENTATION_STATUS.md +379 -0
- package/one/things/ONE.md +19 -1
- package/one/things/agents/agent-backend.md +198 -98
- package/one/things/agents/agent-builder.md +267 -158
- package/one/things/agents/agent-clean.md +40 -15
- package/one/things/agents/agent-clone.md +33 -50
- package/one/things/agents/agent-deploy.md +59 -11
- package/one/things/agents/agent-designer.md +274 -146
- package/one/things/agents/agent-director.md +20 -2
- package/one/things/agents/agent-documenter.md +126 -46
- package/one/things/agents/agent-frontend.md +104 -22
- package/one/things/agents/agent-integrator.md +153 -76
- package/one/things/agents/agent-lawyer.md +197 -92
- package/one/things/agents/agent-problem-solver.md +302 -224
- package/one/things/agents/agent-quality.md +149 -19
- package/one/things/agents/agent-sales.md +95 -7
- package/one/things/cascade/cascade.yaml +20 -3
- package/one/things/cascade/docs/examples/1-1-agent-prompts/design.md +53 -0
- package/one/things/cascade/docs/examples/1-1-agent-prompts/tests.md +50 -0
- package/one/things/cascade/docs/examples/1-1-agent-prompts.md +76 -0
- package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/design.md +49 -3
- package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/tests.md +45 -0
- package/one/things/cascade/docs/examples/1-2-yaml-orchestrator.md +32 -0
- package/one/things/cascade/docs/examples/1-3-event-coordination/design.md +45 -3
- package/one/things/cascade/docs/examples/1-3-event-coordination/tests.md +44 -0
- package/one/things/cascade/docs/examples/1-3-event-coordination.md +40 -1
- package/one/things/cascade/docs/examples/1-4-knowledge-management/design.md +81 -25
- package/one/things/cascade/docs/examples/1-4-knowledge-management/tests.md +41 -0
- package/one/things/cascade/docs/examples/1-4-knowledge-management.md +91 -16
- package/one/things/cascade/docs/examples/1-5-quality-loops/design.md +136 -73
- package/one/things/cascade/docs/examples/1-5-quality-loops/tests.md +43 -0
- package/one/things/cascade/docs/examples/1-5-quality-loops.md +88 -4
- package/one/things/cascade/docs/examples/1-6-numbering-structure/design.md +52 -3
- package/one/things/cascade/docs/examples/1-6-numbering-structure/tests.md +44 -1
- package/one/things/cascade/docs/examples/1-6-numbering-structure.md +78 -14
- package/one/things/cascade/docs/examples/readme.md +37 -0
- package/one/things/cascade/docs/getting-started.md +18 -0
- package/one/things/cascade/docs/workflow.md +18 -12
- package/one/things/cascade/readme.md +43 -0
- package/one/things/cascade/templates/feature-template.md +28 -6
- package/one/things/claude/agents/advocacy-activation-manager.md +64 -39
- package/one/things/claude/agents/advocacy-campaign-designer.md +64 -39
- package/one/things/claude/agents/analyst.md +64 -39
- package/one/things/claude/agents/architect.md +64 -39
- package/one/things/claude/agents/brand-identity-specialist.md +64 -39
- package/one/things/claude/agents/bstp-token-strategist.md +48 -25
- package/one/things/claude/agents/builder-repo.md +69 -26
- package/one/things/claude/agents/bullstamp-community-builder.md +48 -25
- package/one/things/claude/agents/bullstamp-marketing-orchestrator.md +48 -25
- package/one/things/claude/agents/bulltilt-platform-growth.md +48 -25
- package/one/things/claude/agents/company-bullstamp-character.md +45 -30
- package/one/things/claude/agents/company-bullstamp-community.md +45 -30
- package/one/things/claude/agents/company-bullstamp-marketing.md +45 -30
- package/one/things/claude/agents/company-bullstamp-token.md +45 -30
- package/one/things/claude/agents/company-bulltilt-growth.md +45 -30
- package/one/things/claude/agents/content-bibliography-formatter.md +48 -25
- package/one/things/claude/agents/content-calendar-planner.md +59 -34
- package/one/things/claude/agents/content-chapter-formatter.md +60 -35
- package/one/things/claude/agents/content-formatter.md +59 -34
- package/one/things/claude/agents/content-hook-specialist.md +54 -31
- package/one/things/claude/agents/content-image-formatter.md +59 -34
- package/one/things/claude/agents/content-introduction-formatter.md +59 -34
- package/one/things/claude/agents/content-multiplication-engine.md +54 -31
- package/one/things/claude/agents/content-playbook-writer.md +60 -35
- package/one/things/claude/agents/content-team-manager.md +59 -34
- package/one/things/claude/agents/content-toc-formatter.md +60 -35
- package/one/things/claude/agents/convex-backend-specialist.md +380 -216
- package/one/things/claude/agents/core-manager.md +59 -34
- package/one/things/claude/agents/core-master.md +55 -32
- package/one/things/claude/agents/cross-functional-manager.md +46 -41
- package/one/things/claude/agents/crypto-airdrop-strategist.md +74 -54
- package/one/things/claude/agents/crypto-analytics-educator.md +73 -30
- package/one/things/claude/agents/crypto-architecture-specialist.md +70 -39
- package/one/things/claude/agents/crypto-community-analyst.md +47 -31
- package/one/things/claude/agents/crypto-community-psychologist.md +68 -31
- package/one/things/claude/agents/crypto-dex-optimization-expert.md +72 -31
- package/one/things/claude/agents/crypto-dex-optimizer.md +45 -30
- package/one/things/claude/agents/crypto-diamond-formation-specialist.md +69 -30
- package/one/things/claude/agents/crypto-diamond-hands.md +45 -30
- package/one/things/claude/agents/crypto-ecosystem-expansion-manager.md +73 -30
- package/one/things/claude/agents/crypto-engagement-specialist.md +71 -30
- package/one/things/claude/agents/crypto-market-researcher.md +45 -30
- package/one/things/claude/agents/crypto-marketing-orchestrator.md +74 -34
- package/one/things/claude/agents/crypto-network-effect-amplifier.md +75 -30
- package/one/things/claude/agents/crypto-optimization-analyst.md +73 -30
- package/one/things/claude/agents/crypto-strategic-synthesizer.md +69 -30
- package/one/things/claude/agents/crypto-team-manager.md +45 -40
- package/one/things/claude/agents/crypto-token-analyst.md +66 -25
- package/one/things/claude/agents/crypto-viral-content-creator.md +64 -61
- package/one/things/claude/agents/crypto-wallet-identification-expert.md +61 -51
- package/one/things/claude/agents/crypto-wallet-identifier.md +45 -30
- package/one/things/claude/agents/customer-journey-designer.md +51 -58
- package/one/things/claude/agents/customer-success-manager.md +51 -58
- package/one/things/claude/agents/dev.md +51 -58
- package/one/things/claude/agents/documenter.md +71 -69
- package/one/things/claude/agents/elevate-marketing-orchestrator.md +45 -52
- package/one/things/claude/agents/engagement-specialist.md +45 -52
- package/one/things/claude/agents/engineering-architect.md +54 -54
- package/one/things/claude/agents/engineering-business-analyst.md +46 -56
- package/one/things/claude/agents/engineering-developer.md +51 -52
- package/one/things/claude/agents/engineering-director.md +65 -25
- package/one/things/claude/agents/engineering-ingestor.md +110 -100
- package/one/things/claude/agents/engineering-product-manager.md +43 -55
- package/one/things/claude/agents/engineering-product-owner.md +46 -56
- package/one/things/claude/agents/engineering-project-coordinator.md +44 -56
- package/one/things/claude/agents/engineering-quality-assurance.md +53 -54
- package/one/things/claude/agents/engineering-team-manager.md +46 -43
- package/one/things/claude/agents/engineering-user-experience.md +51 -52
- package/one/things/claude/agents/framework-elevate-manager.md +45 -30
- package/one/things/claude/agents/improver.md +120 -78
- package/one/things/claude/agents/intelligence-team-manager.md +45 -40
- package/one/things/claude/agents/lead-capture-expert.md +45 -52
- package/one/things/claude/agents/lead-magnet-creator.md +45 -52
- package/one/things/claude/agents/market-research-analyst.md +48 -25
- package/one/things/claude/agents/marketing-brand-identity.md +57 -27
- package/one/things/claude/agents/marketing-content-hooks.md +45 -40
- package/one/things/claude/agents/marketing-content-multiplier.md +45 -40
- package/one/things/claude/agents/marketing-content-poster.md +71 -60
- package/one/things/claude/agents/marketing-customer-journey.md +45 -40
- package/one/things/claude/agents/marketing-director.md +46 -41
- package/one/things/claude/agents/marketing-engagement.md +45 -40
- package/one/things/claude/agents/marketing-lead-capture.md +45 -40
- package/one/things/claude/agents/marketing-lead-magnet.md +45 -40
- package/one/things/claude/agents/marketing-network-effects.md +45 -40
- package/one/things/claude/agents/marketing-nurture-campaigns.md +45 -40
- package/one/things/claude/agents/marketing-share-optimizer.md +45 -40
- package/one/things/claude/agents/marketing-team-manager.md +45 -40
- package/one/things/claude/agents/marketing-viral-growth.md +49 -18
- package/one/things/claude/agents/mission-commander.md +45 -40
- package/one/things/claude/agents/network-effect-analyst.md +48 -31
- package/one/things/claude/agents/nextjs-15-specialist.md +209 -122
- package/one/things/claude/agents/npx.md +126 -70
- package/one/things/claude/agents/nurture-campaign-manager.md +48 -25
- package/one/things/claude/agents/one-master.md +48 -25
- package/one/things/claude/agents/one-orchestrator.md +57 -27
- package/one/things/claude/agents/one.md +88 -31
- package/one/things/claude/agents/playbook-generator.md +48 -25
- package/one/things/claude/agents/pm.md +48 -25
- package/one/things/claude/agents/po.md +51 -26
- package/one/things/claude/agents/qa.md +50 -25
- package/one/things/claude/agents/research-foundation-analyst.md +48 -31
- package/one/things/claude/agents/research-intelligence-gatherer.md +59 -32
- package/one/things/claude/agents/research-market-analyst.md +47 -30
- package/one/things/claude/agents/research-team-manager.md +47 -40
- package/one/things/claude/agents/sales-environment-optimizer.md +50 -25
- package/one/things/claude/agents/sales-team-manager.md +47 -40
- package/one/things/claude/agents/sales-upsell-strategist.md +47 -30
- package/one/things/claude/agents/service-advocacy-campaigns.md +47 -30
- package/one/things/claude/agents/service-advocacy-manager.md +47 -30
- package/one/things/claude/agents/service-success-manager.md +47 -30
- package/one/things/claude/agents/service-team-manager.md +45 -40
- package/one/things/claude/agents/shadcn-ui-design-system-specialist.md +85 -30
- package/one/things/claude/agents/share-optimization-specialist.md +50 -25
- package/one/things/claude/agents/sm.md +50 -25
- package/one/things/claude/agents/story-teller.md +51 -26
- package/one/things/claude/agents/task-master.md +52 -27
- package/one/things/claude/agents/tauri-cross-platform-specialist.md +201 -116
- package/one/things/claude/agents/tester.md +85 -46
- package/one/things/claude/agents/the-bull-character-manager.md +48 -25
- package/one/things/claude/agents/tools-playbook-generator.md +43 -40
- package/one/things/claude/agents/turbo-repo-builder.md +57 -27
- package/one/things/claude/agents/upsell-strategist.md +48 -25
- package/one/things/claude/agents/ux-expert.md +50 -25
- package/one/things/claude/agents/viral-growth-orchestrator.md +50 -27
- package/one/things/claude/commands/agent.md +25 -5
- package/one/things/claude/commands/cascade-status.md +33 -8
- package/one/things/claude/commands/ingest.md +64 -11
- package/one/things/claude/commands/ingestor.md +29 -7
- package/one/things/claude/commands/mission.md +24 -4
- package/one/things/claude/commands/npx.md +30 -7
- package/one/things/claude/commands/one.md +114 -68
- package/one/things/claude/commands/quality-check.md +72 -24
- package/one/things/claude/commands/smart-route.md +45 -4
- package/one/things/claude/commands/start.md +22 -4
- package/one/things/claude/commands/story.md +25 -5
- package/one/things/claude/commands/task.md +21 -1
- package/one/things/cli/cli-code.md +244 -219
- package/one/things/cli/cli-compiler-code.md +244 -219
- package/one/things/cli/cli.md +30 -6
- package/one/things/components/card-shadcn.md +252 -228
- package/one/things/components/card.md +315 -324
- package/one/things/components.md +667 -593
- package/one/things/componets.md +16 -1
- package/one/things/creator-diagram.md +23 -5
- package/one/things/demo-accessibility-animations.md +73 -47
- package/one/things/demo-components.md +225 -219
- package/one/things/demo-design-summary.md +89 -26
- package/one/things/demo-design-system.md +184 -130
- package/one/things/demo-page-layouts.md +52 -25
- package/one/things/designs/accessibility-audit.md +153 -66
- package/one/things/designs/component-specifications.md +163 -65
- package/one/things/designs/design-overview.md +81 -22
- package/one/things/designs/design-tokens.md +127 -93
- package/one/things/designs/wireframes-dashboard.md +64 -7
- package/one/things/docs/api-requests.md +75 -11
- package/one/things/docs/ecommerce/ARCHITECTURE-DIAGRAM.md +18 -0
- package/one/things/docs/ecommerce/CONVERSION-ELEMENTS-IMPLEMENTATION.md +57 -0
- package/one/things/docs/ecommerce/CONVERSION-ELEMENTS-SUMMARY.md +62 -6
- package/one/things/docs/ecommerce/CONVERSION-UX-IMPLEMENTATION-SUMMARY.md +60 -5
- package/one/things/docs/ecommerce/FEATURE-SUMMARY.md +95 -27
- package/one/things/docs/ecommerce/IMPLEMENTATION-NOTES.md +130 -62
- package/one/things/docs/ecommerce/INTEGRATION-EXAMPLE.md +43 -19
- package/one/things/docs/ecommerce/QUICK-START.md +41 -4
- package/one/things/docs/ecommerce/URGENCY-IMPLEMENTATION-SUMMARY.md +75 -6
- package/one/things/docs/ecommerce/URGENCY-QUICK-REFERENCE.md +58 -24
- package/one/things/examples/children/lemonade-stand.md +52 -14
- package/one/things/examples/enterprise/crm-saas.md +43 -28
- package/one/things/features/1-1-agent-prompts.md +76 -0
- package/one/things/features/1-2-yaml-orchestrator.md +32 -0
- package/one/things/features/1-3-event-coordination.md +40 -1
- package/one/things/features/1-4-knowledge-management.md +91 -16
- package/one/things/features/1-5-quality-loops.md +88 -4
- package/one/things/features/1-6-numbering-structure.md +78 -14
- package/one/things/features/2-1-dataprovider-interface.md +311 -86
- package/one/things/features/2-2-config-system.md +307 -140
- package/one/things/features/2-3-effectts-services.md +263 -116
- package/one/things/features/2-4-react-hooks.md +217 -201
- package/one/things/features/2-5-auth-migration.md +406 -308
- package/one/things/features/2-6-dashboard-migration.md +112 -13
- package/one/things/features/2-7-alternative-providers.md +138 -65
- package/one/things/features/2-7-implementation-report.md +68 -24
- package/one/things/features/2-cli.md +88 -76
- package/one/things/features/2-design.md +112 -80
- package/one/things/features/2-tests.md +56 -0
- package/one/things/features/AUTH_HOOKS_IMPLEMENTATION.md +91 -36
- package/one/things/features/DECOUPLING.md +36 -18
- package/one/things/features/DEPLOYMENT.md +22 -4
- package/one/things/features/IMPLEMENTATION_SUMMARY.md +48 -2
- package/one/things/features/improve.md +47 -29
- package/one/things/features/remove-convex-deps.md +18 -0
- package/one/things/features/top-features.md +28 -20
- package/one/things/features/use-one-backend.md +210 -173
- package/one/things/features-in-english.md +19 -6
- package/one/things/files.yaml +721 -0
- package/one/things/ideas/1-create-workflow.md +18 -0
- package/one/things/ideas/2-backend-agnostic-frontend.md +57 -2
- package/one/things/implementation/backend-guide.md +64 -19
- package/one/things/interface.md +43 -0
- package/one/things/landing-page-implementation.md +455 -0
- package/one/things/legal/README.md +44 -0
- package/one/things/legal/privacy-policy.md +186 -23
- package/one/things/legal/terms-of-service.md +164 -3
- package/one/things/master-workflow-plan.md +806 -0
- package/one/things/plans/0-timeline.md +36 -0
- package/one/things/plans/1-create-workflow.md +19 -0
- package/one/things/plans/QUICK-START-SIMPLIFICATION.md +333 -0
- package/one/things/plans/README-SIMPLIFICATION.md +349 -0
- package/one/things/plans/SIMPLIFICATION-EXAMPLES.md +16 -0
- package/one/things/plans/SIMPLIFICATION-SUMMARY.md +455 -0
- package/one/things/plans/ai-elements.md +21 -2
- package/one/things/plans/ai-integration.md +108 -59
- package/one/things/plans/ai-sdk.md +85 -48
- package/one/things/plans/ai-tools.md +621 -0
- package/one/things/plans/app.md +142 -71
- package/one/things/plans/architecture-summary.md +34 -5
- package/one/things/plans/async-ai-agents.md +19 -1
- package/one/things/plans/backend-agnostic-frontend.md +70 -8
- package/one/things/plans/backend-cleanup-quickstart.md +52 -18
- package/one/things/plans/backend-ontology-conformance.md +110 -51
- package/one/things/plans/backend-status.md +58 -0
- package/one/things/plans/backend-structure.md +103 -55
- package/one/things/plans/backend-target-structure.md +61 -17
- package/one/things/plans/backend.md +60 -18
- package/one/things/plans/better-auth-any-backend-revised.md +325 -287
- package/one/things/plans/better-auth-any-backend.md +575 -531
- package/one/things/plans/better-auth-available-features.md +43 -5
- package/one/things/plans/big-plan.md +20 -6
- package/one/things/plans/cli-updates-required.md +44 -4
- package/one/things/plans/complete-step-by-step.md +223 -116
- package/one/things/plans/components.md +709 -0
- package/one/things/plans/convex-agents.md +79 -50
- package/one/things/plans/convex-better-auth.md +186 -154
- package/one/things/plans/convex-on-off.md +47 -29
- package/one/things/plans/crypto-token-researcher.md +629 -0
- package/one/things/plans/data-quality-metrics.md +745 -0
- package/one/things/plans/deep-researcher-agent.md +466 -0
- package/one/things/plans/deploy-to-cloudflare.md +55 -13
- package/one/things/plans/deployment-architecture.md +54 -11
- package/one/things/plans/desktop.md +21 -3
- package/one/things/plans/development-plan.md +184 -121
- package/one/things/plans/development-workflow-tldr.md +207 -0
- package/one/things/plans/development-workflow.md +959 -0
- package/one/things/plans/effect-components.md +667 -593
- package/one/things/plans/effect-patterns-reference.md +2235 -0
- package/one/things/plans/effect.md +204 -131
- package/one/things/plans/email.md +21 -8
- package/one/things/plans/enhance-auth.md +64 -41
- package/one/things/plans/execution-strategy.md +1291 -0
- package/one/things/plans/existing-infrastructure.md +712 -0
- package/one/things/plans/feature-based-sites.md +124 -51
- package/one/things/plans/frontend-effects.md +1276 -0
- package/one/things/plans/group-folder-multi-tenancy.md +92 -29
- package/one/things/plans/improve-codebase.md +498 -421
- package/one/things/plans/install-components.md +18 -1
- package/one/things/plans/integrate-frontend-and-backend.md +68 -44
- package/one/things/plans/landing.md +92 -0
- package/one/things/plans/layout.md +45 -1
- package/one/things/plans/mail-backend.md +546 -493
- package/one/things/plans/mail.md +379 -326
- package/one/things/plans/mcp-clear-context-prompt.md +21 -0
- package/one/things/plans/mcp-simple.md +20 -0
- package/one/things/plans/multi-ontology-architecture.md +115 -66
- package/one/things/plans/next-features.md +31 -0
- package/one/things/plans/onboarding.md +20 -1
- package/one/things/plans/one.md +18 -0
- package/one/things/plans/ontology-6-dimensions.md +24 -45
- package/one/things/plans/ontology-compliance-audit.md +315 -0
- package/one/things/plans/ontology-driven-strategy.md +19 -3
- package/one/things/plans/ontology-refine.md +586 -0
- package/one/things/plans/ontology-ui-approach.md +18 -0
- package/one/things/plans/open-agent.md +152 -97
- package/one/things/plans/performace.md +32 -0
- package/one/things/plans/phase-1-foundation.md +620 -0
- package/one/things/plans/phase-3-implementation.md +1037 -0
- package/one/things/plans/quick-wins.md +342 -187
- package/one/things/plans/readme-backend-cleanup.md +54 -13
- package/one/things/plans/release.md +55 -2
- package/one/things/plans/repos.md +22 -0
- package/one/things/plans/separate-copy-2.md +127 -71
- package/one/things/plans/separate-copy-3.md +35 -14
- package/one/things/plans/separate-copy.md +127 -71
- package/one/things/plans/separate-demo.md +37 -3
- package/one/things/plans/separate.md +24 -6
- package/one/things/plans/sequence.md +155 -12
- package/one/things/plans/shadcn-integration-summary.md +104 -44
- package/one/things/plans/sidebar.md +44 -10
- package/one/things/plans/skills.md +103 -0
- package/one/things/plans/small-fixes.md +19 -1
- package/one/things/plans/start-new.md +34 -8
- package/one/things/plans/switch-off-auth.md +22 -0
- package/one/things/plans/sync-checklist.md +30 -0
- package/one/things/plans/test-backend-connection.md +38 -0
- package/one/things/plans/unified-implementation-plan.md +144 -62
- package/one/things/plans/update-demos.md +103 -35
- package/one/things/plans/use-our-backend.md +572 -0
- package/one/things/plans/wave1-onboarding-100-inferences.md +1686 -0
- package/one/things/plans/wave1-onboarding-vision.md +744 -0
- package/one/things/plans/wave1-orchestration-summary.md +604 -0
- package/one/things/plans/wave1-specialist-assignments.md +1413 -0
- package/one/things/plans/workflow-files.md +28 -14
- package/one/things/plans/workflow.md +18 -12
- package/one/things/products/cascade-landing-page.md +150 -46
- package/one/things/products/cascade.md +185 -135
- package/one/things/products/context-engineering.md +411 -350
- package/one/things/products/onthology.md +15 -0
- package/one/things/products/ontology-ui-shadcn.md +375 -353
- package/one/things/products/ontology-ui.md +101 -59
- package/one/things/products/ontology.md +90 -18
- package/one/things/products/sdk.md +181 -165
- package/one/things/promptkit.md +70 -43
- package/one/things/repos/all-repos.md +0 -0
- package/one/things/service-providers-new.md +95 -25
- package/one/things/service-providers.md +231 -202
- package/one/things/structure.md +532 -0
- package/one/things/system.md +18 -0
- package/one/things/templates.md +40 -0
- package/one/things/tests/2-1-dataprovider-interface.md +103 -31
- package/one/things/tests/2-1-test-analysis.md +65 -17
- package/one/things/things.md +48 -13
- package/one/things/todo-acp-integration.md +744 -0
- package/one/things/todo-ai.md +933 -0
- package/one/things/todo-api.md +1078 -0
- package/one/things/todo-assignment.md +580 -0
- package/one/things/todo-buy-chatgpt.md +1450 -0
- package/one/things/todo-components.md +1683 -0
- package/one/things/todo-connections.md +278 -0
- package/one/things/todo-ecommerce-frontend.md +1313 -0
- package/one/things/todo-ecommerce.md +569 -0
- package/one/things/todo-effects.md +1075 -0
- package/one/things/todo-frontend-effects.md +977 -0
- package/one/things/todo-landing-page.md +1091 -0
- package/one/things/todo-mail.md +1160 -0
- package/one/things/todo-master-plan.md +490 -0
- package/one/things/todo-onboard.md +666 -0
- package/one/things/todo-one-ie.md +538 -0
- package/one/things/todo-page.md +606 -0
- package/one/things/todo-plans.md +282 -0
- package/one/things/todo-projects.md +241 -0
- package/one/things/todo-refactoring-plan.md +366 -0
- package/one/things/todo-sequence.md +1621 -0
- package/one/things/todo-use-our-backend.md +1908 -0
- package/one/things/todo-workflow.md +626 -0
- package/one/things/todo-x402.md +2047 -0
- package/one/things/todo.md +459 -1075
- package/one/things/video/scripts-crypto.md +835 -0
- package/one/things/video-script-ontology.md +334 -0
- package/package.json +1 -1
- package/one/knowledge/CLOUDFLARE_ENV_SETUP.md +0 -49
- package/one/knowledge/docs/flow.md +0 -0
- package/one/knowledge/documentation-summary.md +0 -285
- package/one/knowledge/inference-score.md +0 -159
- package/one/knowledge/ontology-frontend-copy-2.md +0 -1492
- package/one/knowledge/ontology-frontend-copy.md +0 -753
- package/one/knowledge/ontology-migration-guide.md +0 -811
- package/one/things/features/0 All Features.md +0 -2
- package/one/things/plans/1-create-workflow-status.md +0 -555
- package/one/things/plans/2-backend-agnostic-frontend.md +0 -546
- package/one/things/plans/2-sites.md +0 -895
- package/one/things/plans/3-groups.md +0 -735
- package/one/things/plans/5-build-frontend.md +0 -0
- package/one/things/plans/5-complete.md +0 -17
- package/one/things/plans/agent-director-100-inference-plans.md +0 -410
- package/one/things/plans/dual-website-strategy.md +0 -612
- package/one/things/plans/releases.md +0 -809
|
@@ -0,0 +1,2148 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Astro Effect Complete Vision
|
|
3
|
+
dimension: knowledge
|
|
4
|
+
category: astro-effect-complete-vision.md
|
|
5
|
+
tags: architecture
|
|
6
|
+
related_dimensions: events, things
|
|
7
|
+
scope: global
|
|
8
|
+
created: 2025-11-03
|
|
9
|
+
updated: 2025-11-03
|
|
10
|
+
version: 1.0.0
|
|
11
|
+
ai_context: |
|
|
12
|
+
This document is part of the knowledge dimension in the astro-effect-complete-vision.md category.
|
|
13
|
+
Location: one/knowledge/astro-effect-complete-vision.md
|
|
14
|
+
Purpose: Documents complete vision: astro + effect.ts in 5 layers
|
|
15
|
+
Related dimensions: events, things
|
|
16
|
+
For AI agents: Read this to understand astro effect complete vision.
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# Complete Vision: Astro + Effect.ts in 5 Layers
|
|
20
|
+
|
|
21
|
+
## Overview: Progressive Enhancement Architecture
|
|
22
|
+
|
|
23
|
+
This document shows **real-world examples** of building with Astro + Effect.ts, progressing through 5 layers of complexity. Each layer builds on the previous, showing when and why to add each piece.
|
|
24
|
+
|
|
25
|
+
**Foundation:** Read `astro-effect-simple-architecture.md` first for the core philosophy.
|
|
26
|
+
|
|
27
|
+
## The 5 Layers
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
Layer 1: Static Content (Astro + Content Collections)
|
|
31
|
+
↓
|
|
32
|
+
Layer 2: Validation (+ Zod schemas + Effect.ts)
|
|
33
|
+
↓
|
|
34
|
+
Layer 3: Client State (+ React islands)
|
|
35
|
+
↓
|
|
36
|
+
Layer 4: Data Persistence (+ REST API)
|
|
37
|
+
↓
|
|
38
|
+
Layer 5: Full-Stack App (+ Database + Auth)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Golden Rule:** Start at Layer 1. Only move to the next layer when you need it.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Layer 1: Static Content (Blog Example)
|
|
46
|
+
|
|
47
|
+
**Use Case:** Marketing site, blog, documentation - anything that's mostly read-only.
|
|
48
|
+
|
|
49
|
+
**What You Need:**
|
|
50
|
+
- Astro pages (routing)
|
|
51
|
+
- Content collections (markdown/YAML)
|
|
52
|
+
- shadcn components (UI)
|
|
53
|
+
|
|
54
|
+
**What You DON'T Need:**
|
|
55
|
+
- ❌ State management
|
|
56
|
+
- ❌ Database
|
|
57
|
+
- ❌ API
|
|
58
|
+
- ❌ Authentication
|
|
59
|
+
|
|
60
|
+
### Complete File Structure
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
src/
|
|
64
|
+
├── pages/
|
|
65
|
+
│ ├── index.astro # Homepage
|
|
66
|
+
│ ├── blog/
|
|
67
|
+
│ │ ├── index.astro # Blog list
|
|
68
|
+
│ │ └── [...slug].astro # Blog post detail
|
|
69
|
+
│ └── about.astro # About page
|
|
70
|
+
│
|
|
71
|
+
├── content/
|
|
72
|
+
│ ├── config.ts # Content schemas
|
|
73
|
+
│ └── blog/
|
|
74
|
+
│ ├── first-post.md
|
|
75
|
+
│ ├── second-post.md
|
|
76
|
+
│ └── third-post.md
|
|
77
|
+
│
|
|
78
|
+
├── components/
|
|
79
|
+
│ ├── BlogCard.tsx # Post preview card
|
|
80
|
+
│ ├── BlogPost.tsx # Full post display
|
|
81
|
+
│ └── ui/ # shadcn components
|
|
82
|
+
│ ├── card.tsx
|
|
83
|
+
│ ├── button.tsx
|
|
84
|
+
│ └── badge.tsx
|
|
85
|
+
│
|
|
86
|
+
└── layouts/
|
|
87
|
+
└── Layout.astro # Base layout
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Schema Definition
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
// src/content/config.ts
|
|
94
|
+
import { defineCollection, z } from "astro:content";
|
|
95
|
+
|
|
96
|
+
const blogCollection = defineCollection({
|
|
97
|
+
type: "content",
|
|
98
|
+
schema: z.object({
|
|
99
|
+
title: z.string(),
|
|
100
|
+
description: z.string(),
|
|
101
|
+
author: z.string(),
|
|
102
|
+
date: z.date(),
|
|
103
|
+
tags: z.array(z.string()).default([]),
|
|
104
|
+
featured: z.boolean().default(false),
|
|
105
|
+
}),
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
export const collections = { blog: blogCollection };
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Content Files
|
|
112
|
+
|
|
113
|
+
```markdown
|
|
114
|
+
---
|
|
115
|
+
# src/content/blog/first-post.md
|
|
116
|
+
title: "Getting Started with Astro"
|
|
117
|
+
description: "Learn how to build lightning-fast websites"
|
|
118
|
+
author: "Alice Developer"
|
|
119
|
+
date: 2025-01-15
|
|
120
|
+
tags: ["astro", "web-dev"]
|
|
121
|
+
featured: true
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
# Getting Started with Astro
|
|
125
|
+
|
|
126
|
+
Astro is a modern static site generator that lets you build faster websites...
|
|
127
|
+
|
|
128
|
+
## Key Features
|
|
129
|
+
|
|
130
|
+
- **Islands Architecture**: Ship less JavaScript
|
|
131
|
+
- **Content Collections**: Type-safe content
|
|
132
|
+
- **Framework Agnostic**: Use React, Vue, Svelte, or none
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### List Page
|
|
136
|
+
|
|
137
|
+
```astro
|
|
138
|
+
---
|
|
139
|
+
// src/pages/blog/index.astro
|
|
140
|
+
import Layout from "@/layouts/Layout.astro";
|
|
141
|
+
import { getCollection } from "astro:content";
|
|
142
|
+
import BlogCard from "@/components/BlogCard.tsx";
|
|
143
|
+
|
|
144
|
+
// Get all blog posts, sorted by date
|
|
145
|
+
const posts = (await getCollection("blog"))
|
|
146
|
+
.sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf());
|
|
147
|
+
|
|
148
|
+
const featuredPosts = posts.filter(p => p.data.featured);
|
|
149
|
+
const regularPosts = posts.filter(p => !p.data.featured);
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
<Layout title="Blog">
|
|
153
|
+
<div class="container py-12">
|
|
154
|
+
<h1 class="text-5xl font-bold mb-4">Blog</h1>
|
|
155
|
+
<p class="text-xl text-gray-600 mb-12">
|
|
156
|
+
Thoughts on web development, design, and technology
|
|
157
|
+
</p>
|
|
158
|
+
|
|
159
|
+
{featuredPosts.length > 0 && (
|
|
160
|
+
<section class="mb-12">
|
|
161
|
+
<h2 class="text-3xl font-bold mb-6">Featured Posts</h2>
|
|
162
|
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
|
163
|
+
{featuredPosts.map(post => (
|
|
164
|
+
<BlogCard post={post} featured={true} />
|
|
165
|
+
))}
|
|
166
|
+
</div>
|
|
167
|
+
</section>
|
|
168
|
+
)}
|
|
169
|
+
|
|
170
|
+
<section>
|
|
171
|
+
<h2 class="text-3xl font-bold mb-6">All Posts</h2>
|
|
172
|
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
|
|
173
|
+
{regularPosts.map(post => (
|
|
174
|
+
<BlogCard post={post} />
|
|
175
|
+
))}
|
|
176
|
+
</div>
|
|
177
|
+
</section>
|
|
178
|
+
</div>
|
|
179
|
+
</Layout>
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Detail Page
|
|
183
|
+
|
|
184
|
+
```astro
|
|
185
|
+
---
|
|
186
|
+
// src/pages/blog/[...slug].astro
|
|
187
|
+
import Layout from "@/layouts/Layout.astro";
|
|
188
|
+
import { getCollection, type CollectionEntry } from "astro:content";
|
|
189
|
+
import { Badge } from "@/components/ui/badge";
|
|
190
|
+
|
|
191
|
+
export async function getStaticPaths() {
|
|
192
|
+
const posts = await getCollection("blog");
|
|
193
|
+
return posts.map(post => ({
|
|
194
|
+
params: { slug: post.slug },
|
|
195
|
+
props: { post },
|
|
196
|
+
}));
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
type Props = { post: CollectionEntry<"blog"> };
|
|
200
|
+
const { post } = Astro.props;
|
|
201
|
+
const { Content } = await post.render();
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
<Layout title={post.data.title}>
|
|
205
|
+
<article class="container max-w-4xl py-12">
|
|
206
|
+
<header class="mb-8">
|
|
207
|
+
<h1 class="text-5xl font-bold mb-4">{post.data.title}</h1>
|
|
208
|
+
<p class="text-xl text-gray-600 mb-4">{post.data.description}</p>
|
|
209
|
+
|
|
210
|
+
<div class="flex items-center gap-4 text-sm text-gray-500 mb-4">
|
|
211
|
+
<span>By {post.data.author}</span>
|
|
212
|
+
<span>•</span>
|
|
213
|
+
<time datetime={post.data.date.toISOString()}>
|
|
214
|
+
{post.data.date.toLocaleDateString()}
|
|
215
|
+
</time>
|
|
216
|
+
</div>
|
|
217
|
+
|
|
218
|
+
<div class="flex gap-2">
|
|
219
|
+
{post.data.tags.map(tag => (
|
|
220
|
+
<Badge variant="secondary">{tag}</Badge>
|
|
221
|
+
))}
|
|
222
|
+
</div>
|
|
223
|
+
</header>
|
|
224
|
+
|
|
225
|
+
<div class="prose prose-lg max-w-none">
|
|
226
|
+
<Content />
|
|
227
|
+
</div>
|
|
228
|
+
</article>
|
|
229
|
+
</Layout>
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Component
|
|
233
|
+
|
|
234
|
+
```tsx
|
|
235
|
+
// src/components/BlogCard.tsx
|
|
236
|
+
import { Card, CardHeader, CardTitle, CardDescription, CardContent } from "@/components/ui/card";
|
|
237
|
+
import { Badge } from "@/components/ui/badge";
|
|
238
|
+
import type { CollectionEntry } from "astro:content";
|
|
239
|
+
|
|
240
|
+
type Props = {
|
|
241
|
+
post: CollectionEntry<"blog">;
|
|
242
|
+
featured?: boolean;
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
export function BlogCard({ post, featured = false }: Props) {
|
|
246
|
+
return (
|
|
247
|
+
<a href={`/blog/${post.slug}`} class="block transition hover:scale-105">
|
|
248
|
+
<Card className={featured ? "border-2 border-blue-500" : ""}>
|
|
249
|
+
<CardHeader>
|
|
250
|
+
<CardTitle>{post.data.title}</CardTitle>
|
|
251
|
+
<CardDescription>{post.data.description}</CardDescription>
|
|
252
|
+
</CardHeader>
|
|
253
|
+
<CardContent>
|
|
254
|
+
<div class="flex items-center justify-between text-sm text-gray-500">
|
|
255
|
+
<span>{post.data.author}</span>
|
|
256
|
+
<time datetime={post.data.date.toISOString()}>
|
|
257
|
+
{post.data.date.toLocaleDateString()}
|
|
258
|
+
</time>
|
|
259
|
+
</div>
|
|
260
|
+
<div class="flex gap-2 mt-3">
|
|
261
|
+
{post.data.tags.slice(0, 3).map(tag => (
|
|
262
|
+
<Badge key={tag} variant="outline">{tag}</Badge>
|
|
263
|
+
))}
|
|
264
|
+
</div>
|
|
265
|
+
</CardContent>
|
|
266
|
+
</Card>
|
|
267
|
+
</a>
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
**Layer 1 Result:** Static blog with type-safe content, beautiful UI, and zero JavaScript overhead.
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## Layer 2: Validation (Product Catalog Example)
|
|
277
|
+
|
|
278
|
+
**Use Case:** E-commerce product catalog, pricing calculator - anything needing input validation.
|
|
279
|
+
|
|
280
|
+
**Added to Layer 1:**
|
|
281
|
+
- ✅ Effect.ts services (validation logic)
|
|
282
|
+
- ✅ Zod refinements (advanced validation)
|
|
283
|
+
|
|
284
|
+
**Still Don't Need:**
|
|
285
|
+
- ❌ Client state
|
|
286
|
+
- ❌ Database
|
|
287
|
+
- ❌ API
|
|
288
|
+
|
|
289
|
+
### Complete File Structure
|
|
290
|
+
|
|
291
|
+
```
|
|
292
|
+
src/
|
|
293
|
+
├── pages/
|
|
294
|
+
│ ├── products/
|
|
295
|
+
│ │ ├── index.astro # Product list
|
|
296
|
+
│ │ └── [slug].astro # Product detail
|
|
297
|
+
│ └── calculator.astro # Price calculator
|
|
298
|
+
│
|
|
299
|
+
├── content/
|
|
300
|
+
│ ├── config.ts
|
|
301
|
+
│ └── products/
|
|
302
|
+
│ ├── product-1.yaml
|
|
303
|
+
│ └── product-2.yaml
|
|
304
|
+
│
|
|
305
|
+
├── components/
|
|
306
|
+
│ ├── ProductCard.tsx
|
|
307
|
+
│ ├── PriceCalculator.tsx # Uses Effect.ts validation
|
|
308
|
+
│ └── ui/
|
|
309
|
+
│
|
|
310
|
+
└── lib/
|
|
311
|
+
└── services/
|
|
312
|
+
└── productService.ts # Effect.ts validation logic
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Enhanced Schema with Validation
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
// src/content/config.ts
|
|
319
|
+
import { defineCollection, z } from "astro:content";
|
|
320
|
+
|
|
321
|
+
const productCollection = defineCollection({
|
|
322
|
+
type: "data",
|
|
323
|
+
schema: z.object({
|
|
324
|
+
name: z.string().min(1, "Product name required"),
|
|
325
|
+
slug: z.string().regex(/^[a-z0-9-]+$/, "Invalid slug format"),
|
|
326
|
+
description: z.string(),
|
|
327
|
+
price: z.number().positive("Price must be positive"),
|
|
328
|
+
currency: z.enum(["USD", "EUR", "GBP"]).default("USD"),
|
|
329
|
+
category: z.enum(["software", "hardware", "service"]),
|
|
330
|
+
inStock: z.boolean().default(true),
|
|
331
|
+
features: z.array(z.string()).min(1, "At least one feature required"),
|
|
332
|
+
specifications: z.record(z.string(), z.any()).optional(),
|
|
333
|
+
}).refine(
|
|
334
|
+
data => data.price > 0 || !data.inStock,
|
|
335
|
+
{ message: "In-stock products must have a positive price" }
|
|
336
|
+
),
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
export const collections = { products: productCollection };
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### Product Content
|
|
343
|
+
|
|
344
|
+
```yaml
|
|
345
|
+
# src/content/products/pro-plan.yaml
|
|
346
|
+
name: "Pro Plan"
|
|
347
|
+
slug: "pro-plan"
|
|
348
|
+
description: "Professional features for growing teams"
|
|
349
|
+
price: 49.99
|
|
350
|
+
currency: "USD"
|
|
351
|
+
category: "software"
|
|
352
|
+
inStock: true
|
|
353
|
+
features:
|
|
354
|
+
- "Unlimited projects"
|
|
355
|
+
- "Advanced analytics"
|
|
356
|
+
- "Priority support"
|
|
357
|
+
- "Custom integrations"
|
|
358
|
+
specifications:
|
|
359
|
+
users: "Up to 50"
|
|
360
|
+
storage: "1TB"
|
|
361
|
+
apiCalls: "100,000/month"
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### Effect.ts Service
|
|
365
|
+
|
|
366
|
+
```typescript
|
|
367
|
+
// src/lib/services/productService.ts
|
|
368
|
+
import { Effect, Data } from "effect";
|
|
369
|
+
|
|
370
|
+
// Tagged errors
|
|
371
|
+
export class ValidationError extends Data.TaggedError("ValidationError")<{
|
|
372
|
+
field: string;
|
|
373
|
+
message: string;
|
|
374
|
+
}> {}
|
|
375
|
+
|
|
376
|
+
export class PriceError extends Data.TaggedError("PriceError")<{
|
|
377
|
+
reason: string;
|
|
378
|
+
}> {}
|
|
379
|
+
|
|
380
|
+
// Validation functions
|
|
381
|
+
export const validateQuantity = (
|
|
382
|
+
quantity: number
|
|
383
|
+
): Effect.Effect<number, ValidationError> =>
|
|
384
|
+
Effect.gen(function* () {
|
|
385
|
+
if (!Number.isInteger(quantity)) {
|
|
386
|
+
return yield* new ValidationError({
|
|
387
|
+
field: "quantity",
|
|
388
|
+
message: "Quantity must be an integer",
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
if (quantity < 1) {
|
|
392
|
+
return yield* new ValidationError({
|
|
393
|
+
field: "quantity",
|
|
394
|
+
message: "Quantity must be at least 1",
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
if (quantity > 1000) {
|
|
398
|
+
return yield* new ValidationError({
|
|
399
|
+
field: "quantity",
|
|
400
|
+
message: "Quantity cannot exceed 1000",
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
return quantity;
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
export const calculatePrice = (
|
|
407
|
+
basePrice: number,
|
|
408
|
+
quantity: number,
|
|
409
|
+
discountCode?: string
|
|
410
|
+
): Effect.Effect<{ total: number; discount: number }, PriceError | ValidationError> =>
|
|
411
|
+
Effect.gen(function* () {
|
|
412
|
+
// Validate quantity first
|
|
413
|
+
const validQuantity = yield* validateQuantity(quantity);
|
|
414
|
+
|
|
415
|
+
if (basePrice <= 0) {
|
|
416
|
+
return yield* new PriceError({ reason: "Invalid base price" });
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
let discount = 0;
|
|
420
|
+
|
|
421
|
+
// Apply volume discount
|
|
422
|
+
if (validQuantity >= 10) discount += 0.1; // 10% off
|
|
423
|
+
if (validQuantity >= 50) discount += 0.05; // Additional 5% off
|
|
424
|
+
|
|
425
|
+
// Apply promo code
|
|
426
|
+
if (discountCode === "SAVE20") discount += 0.2;
|
|
427
|
+
if (discountCode === "SAVE10") discount += 0.1;
|
|
428
|
+
|
|
429
|
+
const subtotal = basePrice * validQuantity;
|
|
430
|
+
const discountAmount = subtotal * discount;
|
|
431
|
+
const total = subtotal - discountAmount;
|
|
432
|
+
|
|
433
|
+
return { total, discount: discountAmount };
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
// Composable validation pipeline
|
|
437
|
+
export const validateAndPrice = (
|
|
438
|
+
product: { price: number; inStock: boolean },
|
|
439
|
+
quantity: number,
|
|
440
|
+
discountCode?: string
|
|
441
|
+
): Effect.Effect<{ total: number; discount: number }, ValidationError | PriceError> =>
|
|
442
|
+
Effect.gen(function* () {
|
|
443
|
+
if (!product.inStock) {
|
|
444
|
+
return yield* new PriceError({ reason: "Product out of stock" });
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
return yield* calculatePrice(product.price, quantity, discountCode);
|
|
448
|
+
});
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
### Calculator Component (Client Island)
|
|
452
|
+
|
|
453
|
+
```tsx
|
|
454
|
+
// src/components/PriceCalculator.tsx
|
|
455
|
+
import { useState } from "react";
|
|
456
|
+
import { Button } from "@/components/ui/button";
|
|
457
|
+
import { Input } from "@/components/ui/input";
|
|
458
|
+
import { Label } from "@/components/ui/label";
|
|
459
|
+
import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card";
|
|
460
|
+
import { Alert, AlertDescription } from "@/components/ui/alert";
|
|
461
|
+
import { Effect } from "effect";
|
|
462
|
+
import { calculatePrice, type ValidationError, type PriceError } from "@/lib/services/productService";
|
|
463
|
+
|
|
464
|
+
type Props = {
|
|
465
|
+
basePrice: number;
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
export function PriceCalculator({ basePrice }: Props) {
|
|
469
|
+
const [quantity, setQuantity] = useState(1);
|
|
470
|
+
const [discountCode, setDiscountCode] = useState("");
|
|
471
|
+
const [result, setResult] = useState<{ total: number; discount: number } | null>(null);
|
|
472
|
+
const [error, setError] = useState<string | null>(null);
|
|
473
|
+
|
|
474
|
+
const handleCalculate = async () => {
|
|
475
|
+
setError(null);
|
|
476
|
+
|
|
477
|
+
const effect = calculatePrice(basePrice, quantity, discountCode || undefined);
|
|
478
|
+
|
|
479
|
+
const result = await Effect.runPromise(
|
|
480
|
+
Effect.either(effect)
|
|
481
|
+
);
|
|
482
|
+
|
|
483
|
+
if (result._tag === "Left") {
|
|
484
|
+
const err = result.left;
|
|
485
|
+
if (err._tag === "ValidationError") {
|
|
486
|
+
setError(`${err.field}: ${err.message}`);
|
|
487
|
+
} else if (err._tag === "PriceError") {
|
|
488
|
+
setError(err.reason);
|
|
489
|
+
}
|
|
490
|
+
setResult(null);
|
|
491
|
+
} else {
|
|
492
|
+
setResult(result.right);
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
return (
|
|
497
|
+
<Card>
|
|
498
|
+
<CardHeader>
|
|
499
|
+
<CardTitle>Price Calculator</CardTitle>
|
|
500
|
+
</CardHeader>
|
|
501
|
+
<CardContent className="space-y-4">
|
|
502
|
+
<div>
|
|
503
|
+
<Label htmlFor="quantity">Quantity</Label>
|
|
504
|
+
<Input
|
|
505
|
+
id="quantity"
|
|
506
|
+
type="number"
|
|
507
|
+
min="1"
|
|
508
|
+
value={quantity}
|
|
509
|
+
onChange={(e) => setQuantity(Number(e.target.value))}
|
|
510
|
+
/>
|
|
511
|
+
</div>
|
|
512
|
+
|
|
513
|
+
<div>
|
|
514
|
+
<Label htmlFor="discount">Discount Code (optional)</Label>
|
|
515
|
+
<Input
|
|
516
|
+
id="discount"
|
|
517
|
+
type="text"
|
|
518
|
+
placeholder="SAVE20"
|
|
519
|
+
value={discountCode}
|
|
520
|
+
onChange={(e) => setDiscountCode(e.target.value.toUpperCase())}
|
|
521
|
+
/>
|
|
522
|
+
</div>
|
|
523
|
+
|
|
524
|
+
<Button onClick={handleCalculate} className="w-full">
|
|
525
|
+
Calculate Price
|
|
526
|
+
</Button>
|
|
527
|
+
|
|
528
|
+
{error && (
|
|
529
|
+
<Alert variant="destructive">
|
|
530
|
+
<AlertDescription>{error}</AlertDescription>
|
|
531
|
+
</Alert>
|
|
532
|
+
)}
|
|
533
|
+
|
|
534
|
+
{result && (
|
|
535
|
+
<div className="p-4 bg-green-50 rounded-lg">
|
|
536
|
+
<p className="text-sm text-gray-600">Discount: ${result.discount.toFixed(2)}</p>
|
|
537
|
+
<p className="text-2xl font-bold text-green-600">
|
|
538
|
+
Total: ${result.total.toFixed(2)}
|
|
539
|
+
</p>
|
|
540
|
+
</div>
|
|
541
|
+
)}
|
|
542
|
+
</CardContent>
|
|
543
|
+
</Card>
|
|
544
|
+
);
|
|
545
|
+
}
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
### Product Page with Calculator
|
|
549
|
+
|
|
550
|
+
```astro
|
|
551
|
+
---
|
|
552
|
+
// src/pages/products/[slug].astro
|
|
553
|
+
import Layout from "@/layouts/Layout.astro";
|
|
554
|
+
import { getCollection } from "astro:content";
|
|
555
|
+
import PriceCalculator from "@/components/PriceCalculator.tsx";
|
|
556
|
+
import { Badge } from "@/components/ui/badge";
|
|
557
|
+
|
|
558
|
+
export async function getStaticPaths() {
|
|
559
|
+
const products = await getCollection("products");
|
|
560
|
+
return products.map(product => ({
|
|
561
|
+
params: { slug: product.data.slug },
|
|
562
|
+
props: { product },
|
|
563
|
+
}));
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
const { product } = Astro.props;
|
|
567
|
+
---
|
|
568
|
+
|
|
569
|
+
<Layout title={product.data.name}>
|
|
570
|
+
<div class="container max-w-6xl py-12">
|
|
571
|
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-12">
|
|
572
|
+
<!-- Product Info -->
|
|
573
|
+
<div>
|
|
574
|
+
<h1 class="text-4xl font-bold mb-4">{product.data.name}</h1>
|
|
575
|
+
<p class="text-xl text-gray-600 mb-6">{product.data.description}</p>
|
|
576
|
+
|
|
577
|
+
<div class="mb-6">
|
|
578
|
+
<Badge variant={product.data.inStock ? "default" : "destructive"}>
|
|
579
|
+
{product.data.inStock ? "In Stock" : "Out of Stock"}
|
|
580
|
+
</Badge>
|
|
581
|
+
<Badge variant="outline" class="ml-2">{product.data.category}</Badge>
|
|
582
|
+
</div>
|
|
583
|
+
|
|
584
|
+
<div class="mb-6">
|
|
585
|
+
<h2 class="text-2xl font-bold mb-3">Features</h2>
|
|
586
|
+
<ul class="list-disc list-inside space-y-2">
|
|
587
|
+
{product.data.features.map(feature => (
|
|
588
|
+
<li>{feature}</li>
|
|
589
|
+
))}
|
|
590
|
+
</ul>
|
|
591
|
+
</div>
|
|
592
|
+
|
|
593
|
+
{product.data.specifications && (
|
|
594
|
+
<div>
|
|
595
|
+
<h2 class="text-2xl font-bold mb-3">Specifications</h2>
|
|
596
|
+
<dl class="space-y-2">
|
|
597
|
+
{Object.entries(product.data.specifications).map(([key, value]) => (
|
|
598
|
+
<div class="flex justify-between">
|
|
599
|
+
<dt class="font-medium">{key}:</dt>
|
|
600
|
+
<dd class="text-gray-600">{value}</dd>
|
|
601
|
+
</div>
|
|
602
|
+
))}
|
|
603
|
+
</dl>
|
|
604
|
+
</div>
|
|
605
|
+
)}
|
|
606
|
+
</div>
|
|
607
|
+
|
|
608
|
+
<!-- Price Calculator -->
|
|
609
|
+
<div>
|
|
610
|
+
<PriceCalculator basePrice={product.data.price} client:load />
|
|
611
|
+
</div>
|
|
612
|
+
</div>
|
|
613
|
+
</div>
|
|
614
|
+
</Layout>
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
**Layer 2 Result:** Product catalog with sophisticated validation, pricing logic, and error handling - all type-safe.
|
|
618
|
+
|
|
619
|
+
---
|
|
620
|
+
|
|
621
|
+
## Layer 3: Client State (Shopping Cart Example)
|
|
622
|
+
|
|
623
|
+
**Use Case:** Shopping cart, interactive forms, multi-step wizards - anything needing client-side state.
|
|
624
|
+
|
|
625
|
+
**Added to Layer 2:**
|
|
626
|
+
- ✅ React state hooks (useState, useReducer)
|
|
627
|
+
- ✅ Client-side interactivity
|
|
628
|
+
- ✅ nanostores (for global client state)
|
|
629
|
+
|
|
630
|
+
**Still Don't Need:**
|
|
631
|
+
- ❌ Database
|
|
632
|
+
- ❌ API (state is ephemeral)
|
|
633
|
+
|
|
634
|
+
### Complete File Structure
|
|
635
|
+
|
|
636
|
+
```
|
|
637
|
+
src/
|
|
638
|
+
├── pages/
|
|
639
|
+
│ ├── shop/
|
|
640
|
+
│ │ ├── index.astro # Product listing
|
|
641
|
+
│ │ ├── [slug].astro # Product detail
|
|
642
|
+
│ │ └── cart.astro # Shopping cart page
|
|
643
|
+
│ └── checkout.astro # Checkout flow
|
|
644
|
+
│
|
|
645
|
+
├── content/
|
|
646
|
+
│ └── products/
|
|
647
|
+
│
|
|
648
|
+
├── components/
|
|
649
|
+
│ ├── ProductCard.tsx
|
|
650
|
+
│ ├── AddToCartButton.tsx # Client island
|
|
651
|
+
│ ├── ShoppingCart.tsx # Client island
|
|
652
|
+
│ └── CartSummary.tsx # Client island
|
|
653
|
+
│
|
|
654
|
+
├── lib/
|
|
655
|
+
│ ├── services/
|
|
656
|
+
│ │ ├── productService.ts
|
|
657
|
+
│ │ └── cartService.ts # Effect.ts cart logic
|
|
658
|
+
│ └── stores/
|
|
659
|
+
│ └── cart.ts # nanostores global state
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
### Cart Store (nanostores)
|
|
663
|
+
|
|
664
|
+
```typescript
|
|
665
|
+
// src/lib/stores/cart.ts
|
|
666
|
+
import { atom, map } from "nanostores";
|
|
667
|
+
|
|
668
|
+
export type CartItem = {
|
|
669
|
+
productId: string;
|
|
670
|
+
name: string;
|
|
671
|
+
price: number;
|
|
672
|
+
quantity: number;
|
|
673
|
+
};
|
|
674
|
+
|
|
675
|
+
export const cartItems = map<Record<string, CartItem>>({});
|
|
676
|
+
|
|
677
|
+
export const cartCount = atom(0);
|
|
678
|
+
|
|
679
|
+
// Actions
|
|
680
|
+
export function addToCart(item: Omit<CartItem, "quantity">) {
|
|
681
|
+
const current = cartItems.get();
|
|
682
|
+
const existing = current[item.productId];
|
|
683
|
+
|
|
684
|
+
if (existing) {
|
|
685
|
+
cartItems.setKey(item.productId, {
|
|
686
|
+
...existing,
|
|
687
|
+
quantity: existing.quantity + 1,
|
|
688
|
+
});
|
|
689
|
+
} else {
|
|
690
|
+
cartItems.setKey(item.productId, { ...item, quantity: 1 });
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
updateCartCount();
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
export function removeFromCart(productId: string) {
|
|
697
|
+
const current = cartItems.get();
|
|
698
|
+
const { [productId]: removed, ...rest } = current;
|
|
699
|
+
cartItems.set(rest);
|
|
700
|
+
updateCartCount();
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
export function updateQuantity(productId: string, quantity: number) {
|
|
704
|
+
if (quantity <= 0) {
|
|
705
|
+
removeFromCart(productId);
|
|
706
|
+
} else {
|
|
707
|
+
const current = cartItems.get();
|
|
708
|
+
const item = current[productId];
|
|
709
|
+
if (item) {
|
|
710
|
+
cartItems.setKey(productId, { ...item, quantity });
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
updateCartCount();
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
export function clearCart() {
|
|
717
|
+
cartItems.set({});
|
|
718
|
+
cartCount.set(0);
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
function updateCartCount() {
|
|
722
|
+
const items = Object.values(cartItems.get());
|
|
723
|
+
const total = items.reduce((sum, item) => sum + item.quantity, 0);
|
|
724
|
+
cartCount.set(total);
|
|
725
|
+
}
|
|
726
|
+
```
|
|
727
|
+
|
|
728
|
+
### Cart Service (Effect.ts)
|
|
729
|
+
|
|
730
|
+
```typescript
|
|
731
|
+
// src/lib/services/cartService.ts
|
|
732
|
+
import { Effect, Data } from "effect";
|
|
733
|
+
import type { CartItem } from "@/lib/stores/cart";
|
|
734
|
+
|
|
735
|
+
export class CartError extends Data.TaggedError("CartError")<{
|
|
736
|
+
reason: string;
|
|
737
|
+
}> {}
|
|
738
|
+
|
|
739
|
+
export const validateCartItem = (
|
|
740
|
+
item: CartItem
|
|
741
|
+
): Effect.Effect<CartItem, CartError> =>
|
|
742
|
+
Effect.gen(function* () {
|
|
743
|
+
if (item.quantity < 1) {
|
|
744
|
+
return yield* new CartError({ reason: "Quantity must be at least 1" });
|
|
745
|
+
}
|
|
746
|
+
if (item.quantity > 99) {
|
|
747
|
+
return yield* new CartError({ reason: "Quantity cannot exceed 99" });
|
|
748
|
+
}
|
|
749
|
+
if (item.price <= 0) {
|
|
750
|
+
return yield* new CartError({ reason: "Invalid price" });
|
|
751
|
+
}
|
|
752
|
+
return item;
|
|
753
|
+
});
|
|
754
|
+
|
|
755
|
+
export const calculateCartTotal = (
|
|
756
|
+
items: CartItem[]
|
|
757
|
+
): Effect.Effect<{ subtotal: number; tax: number; total: number }, CartError> =>
|
|
758
|
+
Effect.gen(function* () {
|
|
759
|
+
// Validate all items
|
|
760
|
+
const validatedItems = yield* Effect.all(
|
|
761
|
+
items.map(validateCartItem),
|
|
762
|
+
{ concurrency: "unbounded" }
|
|
763
|
+
);
|
|
764
|
+
|
|
765
|
+
const subtotal = validatedItems.reduce(
|
|
766
|
+
(sum, item) => sum + item.price * item.quantity,
|
|
767
|
+
0
|
|
768
|
+
);
|
|
769
|
+
|
|
770
|
+
const tax = subtotal * 0.08; // 8% tax
|
|
771
|
+
const total = subtotal + tax;
|
|
772
|
+
|
|
773
|
+
return { subtotal, tax, total };
|
|
774
|
+
});
|
|
775
|
+
|
|
776
|
+
export const applyDiscount = (
|
|
777
|
+
total: number,
|
|
778
|
+
code: string
|
|
779
|
+
): Effect.Effect<{ discount: number; finalTotal: number }, CartError> =>
|
|
780
|
+
Effect.gen(function* () {
|
|
781
|
+
let discount = 0;
|
|
782
|
+
|
|
783
|
+
switch (code.toUpperCase()) {
|
|
784
|
+
case "SAVE10":
|
|
785
|
+
discount = total * 0.1;
|
|
786
|
+
break;
|
|
787
|
+
case "SAVE20":
|
|
788
|
+
discount = total * 0.2;
|
|
789
|
+
break;
|
|
790
|
+
case "FREESHIP":
|
|
791
|
+
discount = 10; // Free shipping
|
|
792
|
+
break;
|
|
793
|
+
default:
|
|
794
|
+
return yield* new CartError({ reason: "Invalid discount code" });
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
return {
|
|
798
|
+
discount,
|
|
799
|
+
finalTotal: total - discount,
|
|
800
|
+
};
|
|
801
|
+
});
|
|
802
|
+
```
|
|
803
|
+
|
|
804
|
+
### Add to Cart Button
|
|
805
|
+
|
|
806
|
+
```tsx
|
|
807
|
+
// src/components/AddToCartButton.tsx
|
|
808
|
+
import { useState } from "react";
|
|
809
|
+
import { Button } from "@/components/ui/button";
|
|
810
|
+
import { addToCart } from "@/lib/stores/cart";
|
|
811
|
+
import { ShoppingCart, Check } from "lucide-react";
|
|
812
|
+
|
|
813
|
+
type Props = {
|
|
814
|
+
productId: string;
|
|
815
|
+
name: string;
|
|
816
|
+
price: number;
|
|
817
|
+
};
|
|
818
|
+
|
|
819
|
+
export function AddToCartButton({ productId, name, price }: Props) {
|
|
820
|
+
const [added, setAdded] = useState(false);
|
|
821
|
+
|
|
822
|
+
const handleAdd = () => {
|
|
823
|
+
addToCart({ productId, name, price });
|
|
824
|
+
setAdded(true);
|
|
825
|
+
setTimeout(() => setAdded(false), 2000);
|
|
826
|
+
};
|
|
827
|
+
|
|
828
|
+
return (
|
|
829
|
+
<Button onClick={handleAdd} className="w-full" disabled={added}>
|
|
830
|
+
{added ? (
|
|
831
|
+
<>
|
|
832
|
+
<Check className="mr-2 h-4 w-4" />
|
|
833
|
+
Added!
|
|
834
|
+
</>
|
|
835
|
+
) : (
|
|
836
|
+
<>
|
|
837
|
+
<ShoppingCart className="mr-2 h-4 w-4" />
|
|
838
|
+
Add to Cart
|
|
839
|
+
</>
|
|
840
|
+
)}
|
|
841
|
+
</Button>
|
|
842
|
+
);
|
|
843
|
+
}
|
|
844
|
+
```
|
|
845
|
+
|
|
846
|
+
### Shopping Cart Component
|
|
847
|
+
|
|
848
|
+
```tsx
|
|
849
|
+
// src/components/ShoppingCart.tsx
|
|
850
|
+
import { useStore } from "@nanostores/react";
|
|
851
|
+
import { cartItems, removeFromCart, updateQuantity } from "@/lib/stores/cart";
|
|
852
|
+
import { calculateCartTotal } from "@/lib/services/cartService";
|
|
853
|
+
import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card";
|
|
854
|
+
import { Button } from "@/components/ui/button";
|
|
855
|
+
import { Input } from "@/components/ui/input";
|
|
856
|
+
import { Trash2 } from "lucide-react";
|
|
857
|
+
import { useEffect, useState } from "react";
|
|
858
|
+
import { Effect } from "effect";
|
|
859
|
+
|
|
860
|
+
export function ShoppingCart() {
|
|
861
|
+
const $cartItems = useStore(cartItems);
|
|
862
|
+
const items = Object.values($cartItems);
|
|
863
|
+
|
|
864
|
+
const [totals, setTotals] = useState<{
|
|
865
|
+
subtotal: number;
|
|
866
|
+
tax: number;
|
|
867
|
+
total: number;
|
|
868
|
+
} | null>(null);
|
|
869
|
+
|
|
870
|
+
useEffect(() => {
|
|
871
|
+
const calculateTotals = async () => {
|
|
872
|
+
if (items.length === 0) {
|
|
873
|
+
setTotals(null);
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
const result = await Effect.runPromise(
|
|
878
|
+
Effect.either(calculateCartTotal(items))
|
|
879
|
+
);
|
|
880
|
+
|
|
881
|
+
if (result._tag === "Right") {
|
|
882
|
+
setTotals(result.right);
|
|
883
|
+
}
|
|
884
|
+
};
|
|
885
|
+
|
|
886
|
+
calculateTotals();
|
|
887
|
+
}, [$cartItems]);
|
|
888
|
+
|
|
889
|
+
if (items.length === 0) {
|
|
890
|
+
return (
|
|
891
|
+
<Card>
|
|
892
|
+
<CardContent className="p-12 text-center">
|
|
893
|
+
<p className="text-gray-500">Your cart is empty</p>
|
|
894
|
+
</CardContent>
|
|
895
|
+
</Card>
|
|
896
|
+
);
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
return (
|
|
900
|
+
<Card>
|
|
901
|
+
<CardHeader>
|
|
902
|
+
<CardTitle>Shopping Cart ({items.length} items)</CardTitle>
|
|
903
|
+
</CardHeader>
|
|
904
|
+
<CardContent className="space-y-4">
|
|
905
|
+
{items.map(item => (
|
|
906
|
+
<div key={item.productId} className="flex items-center gap-4 p-4 border rounded">
|
|
907
|
+
<div className="flex-1">
|
|
908
|
+
<h3 className="font-semibold">{item.name}</h3>
|
|
909
|
+
<p className="text-sm text-gray-600">${item.price.toFixed(2)} each</p>
|
|
910
|
+
</div>
|
|
911
|
+
|
|
912
|
+
<div className="flex items-center gap-2">
|
|
913
|
+
<Input
|
|
914
|
+
type="number"
|
|
915
|
+
min="1"
|
|
916
|
+
max="99"
|
|
917
|
+
value={item.quantity}
|
|
918
|
+
onChange={(e) => updateQuantity(item.productId, Number(e.target.value))}
|
|
919
|
+
className="w-20"
|
|
920
|
+
/>
|
|
921
|
+
</div>
|
|
922
|
+
|
|
923
|
+
<div className="font-bold">
|
|
924
|
+
${(item.price * item.quantity).toFixed(2)}
|
|
925
|
+
</div>
|
|
926
|
+
|
|
927
|
+
<Button
|
|
928
|
+
variant="ghost"
|
|
929
|
+
size="icon"
|
|
930
|
+
onClick={() => removeFromCart(item.productId)}
|
|
931
|
+
>
|
|
932
|
+
<Trash2 className="h-4 w-4" />
|
|
933
|
+
</Button>
|
|
934
|
+
</div>
|
|
935
|
+
))}
|
|
936
|
+
|
|
937
|
+
{totals && (
|
|
938
|
+
<div className="border-t pt-4 space-y-2">
|
|
939
|
+
<div className="flex justify-between text-sm">
|
|
940
|
+
<span>Subtotal:</span>
|
|
941
|
+
<span>${totals.subtotal.toFixed(2)}</span>
|
|
942
|
+
</div>
|
|
943
|
+
<div className="flex justify-between text-sm">
|
|
944
|
+
<span>Tax (8%):</span>
|
|
945
|
+
<span>${totals.tax.toFixed(2)}</span>
|
|
946
|
+
</div>
|
|
947
|
+
<div className="flex justify-between text-lg font-bold">
|
|
948
|
+
<span>Total:</span>
|
|
949
|
+
<span>${totals.total.toFixed(2)}</span>
|
|
950
|
+
</div>
|
|
951
|
+
</div>
|
|
952
|
+
)}
|
|
953
|
+
|
|
954
|
+
<Button className="w-full" size="lg">
|
|
955
|
+
Proceed to Checkout
|
|
956
|
+
</Button>
|
|
957
|
+
</CardContent>
|
|
958
|
+
</Card>
|
|
959
|
+
);
|
|
960
|
+
}
|
|
961
|
+
```
|
|
962
|
+
|
|
963
|
+
### Cart Page
|
|
964
|
+
|
|
965
|
+
```astro
|
|
966
|
+
---
|
|
967
|
+
// src/pages/shop/cart.astro
|
|
968
|
+
import Layout from "@/layouts/Layout.astro";
|
|
969
|
+
import ShoppingCart from "@/components/ShoppingCart.tsx";
|
|
970
|
+
---
|
|
971
|
+
|
|
972
|
+
<Layout title="Shopping Cart">
|
|
973
|
+
<div class="container max-w-4xl py-12">
|
|
974
|
+
<h1 class="text-4xl font-bold mb-8">Shopping Cart</h1>
|
|
975
|
+
<ShoppingCart client:load />
|
|
976
|
+
</div>
|
|
977
|
+
</Layout>
|
|
978
|
+
```
|
|
979
|
+
|
|
980
|
+
### Product Page with Cart Button
|
|
981
|
+
|
|
982
|
+
```astro
|
|
983
|
+
---
|
|
984
|
+
// src/pages/shop/[slug].astro
|
|
985
|
+
import Layout from "@/layouts/Layout.astro";
|
|
986
|
+
import { getCollection } from "astro:content";
|
|
987
|
+
import AddToCartButton from "@/components/AddToCartButton.tsx";
|
|
988
|
+
|
|
989
|
+
export async function getStaticPaths() {
|
|
990
|
+
const products = await getCollection("products");
|
|
991
|
+
return products.map(product => ({
|
|
992
|
+
params: { slug: product.data.slug },
|
|
993
|
+
props: { product },
|
|
994
|
+
}));
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
const { product } = Astro.props;
|
|
998
|
+
---
|
|
999
|
+
|
|
1000
|
+
<Layout title={product.data.name}>
|
|
1001
|
+
<div class="container max-w-4xl py-12">
|
|
1002
|
+
<h1 class="text-4xl font-bold mb-4">{product.data.name}</h1>
|
|
1003
|
+
<p class="text-xl text-gray-600 mb-6">{product.data.description}</p>
|
|
1004
|
+
|
|
1005
|
+
<div class="text-3xl font-bold text-green-600 mb-6">
|
|
1006
|
+
${product.data.price.toFixed(2)}
|
|
1007
|
+
</div>
|
|
1008
|
+
|
|
1009
|
+
<div class="max-w-sm">
|
|
1010
|
+
<AddToCartButton
|
|
1011
|
+
productId={product.id}
|
|
1012
|
+
name={product.data.name}
|
|
1013
|
+
price={product.data.price}
|
|
1014
|
+
client:load
|
|
1015
|
+
/>
|
|
1016
|
+
</div>
|
|
1017
|
+
</div>
|
|
1018
|
+
</Layout>
|
|
1019
|
+
```
|
|
1020
|
+
|
|
1021
|
+
**Layer 3 Result:** Interactive shopping cart with client-side state management, all validated with Effect.ts.
|
|
1022
|
+
|
|
1023
|
+
---
|
|
1024
|
+
|
|
1025
|
+
## Layer 4: Data Persistence (Multi-Source Migration Example)
|
|
1026
|
+
|
|
1027
|
+
**Use Case:** Data migrations, external API integration, CMS syncing - anything that fetches/transforms data from external sources.
|
|
1028
|
+
|
|
1029
|
+
**Added to Layer 3:**
|
|
1030
|
+
- ✅ REST API integration
|
|
1031
|
+
- ✅ External data fetching
|
|
1032
|
+
- ✅ Data transformation pipelines
|
|
1033
|
+
|
|
1034
|
+
**Still Don't Need:**
|
|
1035
|
+
- ❌ Your own database (reading from external sources)
|
|
1036
|
+
|
|
1037
|
+
### Complete File Structure
|
|
1038
|
+
|
|
1039
|
+
```
|
|
1040
|
+
src/
|
|
1041
|
+
├── pages/
|
|
1042
|
+
│ ├── migrate/
|
|
1043
|
+
│ │ ├── index.astro # Migration dashboard
|
|
1044
|
+
│ │ └── [source].astro # Source-specific migration
|
|
1045
|
+
│ └── api/
|
|
1046
|
+
│ └── migrate.ts # API endpoint for migrations
|
|
1047
|
+
│
|
|
1048
|
+
├── lib/
|
|
1049
|
+
│ └── services/
|
|
1050
|
+
│ ├── migrationService.ts # Effect.ts migration logic
|
|
1051
|
+
│ ├── githubAdapter.ts # GitHub API adapter
|
|
1052
|
+
│ ├── notionAdapter.ts # Notion API adapter
|
|
1053
|
+
│ └── stripeAdapter.ts # Stripe API adapter
|
|
1054
|
+
│
|
|
1055
|
+
└── components/
|
|
1056
|
+
└── MigrationStatus.tsx # Real-time status display
|
|
1057
|
+
```
|
|
1058
|
+
|
|
1059
|
+
### Migration Service (Effect.ts)
|
|
1060
|
+
|
|
1061
|
+
```typescript
|
|
1062
|
+
// src/lib/services/migrationService.ts
|
|
1063
|
+
import { Effect, Data, Context } from "effect";
|
|
1064
|
+
|
|
1065
|
+
// Tagged errors
|
|
1066
|
+
export class FetchError extends Data.TaggedError("FetchError")<{
|
|
1067
|
+
source: string;
|
|
1068
|
+
reason: string;
|
|
1069
|
+
}> {}
|
|
1070
|
+
|
|
1071
|
+
export class TransformError extends Data.TaggedError("TransformError")<{
|
|
1072
|
+
item: string;
|
|
1073
|
+
reason: string;
|
|
1074
|
+
}> {}
|
|
1075
|
+
|
|
1076
|
+
export class ValidationError extends Data.TaggedError("ValidationError")<{
|
|
1077
|
+
field: string;
|
|
1078
|
+
message: string;
|
|
1079
|
+
}> {}
|
|
1080
|
+
|
|
1081
|
+
// Data source interface
|
|
1082
|
+
export interface DataSource {
|
|
1083
|
+
readonly name: string;
|
|
1084
|
+
readonly fetch: () => Effect.Effect<unknown[], FetchError>;
|
|
1085
|
+
readonly transform: (data: unknown) => Effect.Effect<MigratedItem, TransformError>;
|
|
1086
|
+
readonly validate: (item: MigratedItem) => Effect.Effect<MigratedItem, ValidationError>;
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
export const DataSource = Context.GenericTag<DataSource>("DataSource");
|
|
1090
|
+
|
|
1091
|
+
// Migrated item schema
|
|
1092
|
+
export type MigratedItem = {
|
|
1093
|
+
id: string;
|
|
1094
|
+
title: string;
|
|
1095
|
+
content: string;
|
|
1096
|
+
author: string;
|
|
1097
|
+
createdAt: Date;
|
|
1098
|
+
tags: string[];
|
|
1099
|
+
metadata: Record<string, any>;
|
|
1100
|
+
};
|
|
1101
|
+
|
|
1102
|
+
// Migration pipeline
|
|
1103
|
+
export const migrateFromSource = (
|
|
1104
|
+
source: DataSource
|
|
1105
|
+
): Effect.Effect<MigratedItem[], FetchError | TransformError | ValidationError> =>
|
|
1106
|
+
Effect.gen(function* () {
|
|
1107
|
+
console.log(`Starting migration from ${source.name}...`);
|
|
1108
|
+
|
|
1109
|
+
// Step 1: Fetch raw data
|
|
1110
|
+
const rawData = yield* source.fetch();
|
|
1111
|
+
console.log(`Fetched ${rawData.length} items from ${source.name}`);
|
|
1112
|
+
|
|
1113
|
+
// Step 2: Transform each item
|
|
1114
|
+
const transformed = yield* Effect.all(
|
|
1115
|
+
rawData.map(item => source.transform(item)),
|
|
1116
|
+
{ concurrency: 5 } // Process 5 items at a time
|
|
1117
|
+
);
|
|
1118
|
+
console.log(`Transformed ${transformed.length} items`);
|
|
1119
|
+
|
|
1120
|
+
// Step 3: Validate each item
|
|
1121
|
+
const validated = yield* Effect.all(
|
|
1122
|
+
transformed.map(item => source.validate(item)),
|
|
1123
|
+
{ concurrency: "unbounded" }
|
|
1124
|
+
);
|
|
1125
|
+
console.log(`Validated ${validated.length} items`);
|
|
1126
|
+
|
|
1127
|
+
return validated;
|
|
1128
|
+
});
|
|
1129
|
+
|
|
1130
|
+
// Batch migration from multiple sources
|
|
1131
|
+
export const migrateFromMultipleSources = (
|
|
1132
|
+
sources: DataSource[]
|
|
1133
|
+
): Effect.Effect<
|
|
1134
|
+
Map<string, MigratedItem[]>,
|
|
1135
|
+
FetchError | TransformError | ValidationError
|
|
1136
|
+
> =>
|
|
1137
|
+
Effect.gen(function* () {
|
|
1138
|
+
const results = yield* Effect.all(
|
|
1139
|
+
sources.map(source =>
|
|
1140
|
+
migrateFromSource(source).pipe(
|
|
1141
|
+
Effect.map(items => [source.name, items] as const)
|
|
1142
|
+
)
|
|
1143
|
+
),
|
|
1144
|
+
{ concurrency: 3 } // Process 3 sources at a time
|
|
1145
|
+
);
|
|
1146
|
+
|
|
1147
|
+
return new Map(results);
|
|
1148
|
+
});
|
|
1149
|
+
|
|
1150
|
+
// Validation helper
|
|
1151
|
+
export const validateMigratedItem = (
|
|
1152
|
+
item: MigratedItem
|
|
1153
|
+
): Effect.Effect<MigratedItem, ValidationError> =>
|
|
1154
|
+
Effect.gen(function* () {
|
|
1155
|
+
if (!item.id?.trim()) {
|
|
1156
|
+
return yield* new ValidationError({
|
|
1157
|
+
field: "id",
|
|
1158
|
+
message: "ID is required",
|
|
1159
|
+
});
|
|
1160
|
+
}
|
|
1161
|
+
if (!item.title?.trim()) {
|
|
1162
|
+
return yield* new ValidationError({
|
|
1163
|
+
field: "title",
|
|
1164
|
+
message: "Title is required",
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1167
|
+
if (item.tags.length === 0) {
|
|
1168
|
+
return yield* new ValidationError({
|
|
1169
|
+
field: "tags",
|
|
1170
|
+
message: "At least one tag required",
|
|
1171
|
+
});
|
|
1172
|
+
}
|
|
1173
|
+
return item;
|
|
1174
|
+
});
|
|
1175
|
+
```
|
|
1176
|
+
|
|
1177
|
+
### GitHub Adapter
|
|
1178
|
+
|
|
1179
|
+
```typescript
|
|
1180
|
+
// src/lib/services/githubAdapter.ts
|
|
1181
|
+
import { Effect } from "effect";
|
|
1182
|
+
import { FetchError, TransformError, validateMigratedItem, type MigratedItem, type DataSource } from "./migrationService";
|
|
1183
|
+
|
|
1184
|
+
type GitHubIssue = {
|
|
1185
|
+
id: number;
|
|
1186
|
+
number: number;
|
|
1187
|
+
title: string;
|
|
1188
|
+
body: string;
|
|
1189
|
+
user: { login: string };
|
|
1190
|
+
created_at: string;
|
|
1191
|
+
labels: Array<{ name: string }>;
|
|
1192
|
+
};
|
|
1193
|
+
|
|
1194
|
+
export const GitHubDataSource: DataSource = {
|
|
1195
|
+
name: "GitHub",
|
|
1196
|
+
|
|
1197
|
+
fetch: (): Effect.Effect<GitHubIssue[], FetchError> =>
|
|
1198
|
+
Effect.tryPromise({
|
|
1199
|
+
try: async () => {
|
|
1200
|
+
const response = await fetch(
|
|
1201
|
+
"https://api.github.com/repos/owner/repo/issues",
|
|
1202
|
+
{
|
|
1203
|
+
headers: {
|
|
1204
|
+
Authorization: `token ${import.meta.env.GITHUB_TOKEN}`,
|
|
1205
|
+
Accept: "application/vnd.github.v3+json",
|
|
1206
|
+
},
|
|
1207
|
+
}
|
|
1208
|
+
);
|
|
1209
|
+
|
|
1210
|
+
if (!response.ok) {
|
|
1211
|
+
throw new Error(`GitHub API error: ${response.statusText}`);
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
return response.json();
|
|
1215
|
+
},
|
|
1216
|
+
catch: (error) =>
|
|
1217
|
+
new FetchError({
|
|
1218
|
+
source: "GitHub",
|
|
1219
|
+
reason: error instanceof Error ? error.message : "Unknown error",
|
|
1220
|
+
}),
|
|
1221
|
+
}),
|
|
1222
|
+
|
|
1223
|
+
transform: (data: unknown): Effect.Effect<MigratedItem, TransformError> =>
|
|
1224
|
+
Effect.try({
|
|
1225
|
+
try: () => {
|
|
1226
|
+
const issue = data as GitHubIssue;
|
|
1227
|
+
|
|
1228
|
+
return {
|
|
1229
|
+
id: `github-${issue.number}`,
|
|
1230
|
+
title: issue.title,
|
|
1231
|
+
content: issue.body || "",
|
|
1232
|
+
author: issue.user.login,
|
|
1233
|
+
createdAt: new Date(issue.created_at),
|
|
1234
|
+
tags: issue.labels.map(l => l.name),
|
|
1235
|
+
metadata: {
|
|
1236
|
+
source: "github",
|
|
1237
|
+
issueNumber: issue.number,
|
|
1238
|
+
url: `https://github.com/owner/repo/issues/${issue.number}`,
|
|
1239
|
+
},
|
|
1240
|
+
};
|
|
1241
|
+
},
|
|
1242
|
+
catch: (error) =>
|
|
1243
|
+
new TransformError({
|
|
1244
|
+
item: JSON.stringify(data),
|
|
1245
|
+
reason: error instanceof Error ? error.message : "Transform failed",
|
|
1246
|
+
}),
|
|
1247
|
+
}),
|
|
1248
|
+
|
|
1249
|
+
validate: validateMigratedItem,
|
|
1250
|
+
};
|
|
1251
|
+
```
|
|
1252
|
+
|
|
1253
|
+
### Notion Adapter
|
|
1254
|
+
|
|
1255
|
+
```typescript
|
|
1256
|
+
// src/lib/services/notionAdapter.ts
|
|
1257
|
+
import { Effect } from "effect";
|
|
1258
|
+
import { FetchError, TransformError, validateMigratedItem, type MigratedItem, type DataSource } from "./migrationService";
|
|
1259
|
+
|
|
1260
|
+
type NotionPage = {
|
|
1261
|
+
id: string;
|
|
1262
|
+
properties: {
|
|
1263
|
+
Title: { title: Array<{ plain_text: string }> };
|
|
1264
|
+
Tags: { multi_select: Array<{ name: string }> };
|
|
1265
|
+
Created: { created_time: string };
|
|
1266
|
+
};
|
|
1267
|
+
url: string;
|
|
1268
|
+
};
|
|
1269
|
+
|
|
1270
|
+
export const NotionDataSource: DataSource = {
|
|
1271
|
+
name: "Notion",
|
|
1272
|
+
|
|
1273
|
+
fetch: (): Effect.Effect<NotionPage[], FetchError> =>
|
|
1274
|
+
Effect.tryPromise({
|
|
1275
|
+
try: async () => {
|
|
1276
|
+
const response = await fetch(
|
|
1277
|
+
"https://api.notion.com/v1/databases/DATABASE_ID/query",
|
|
1278
|
+
{
|
|
1279
|
+
method: "POST",
|
|
1280
|
+
headers: {
|
|
1281
|
+
Authorization: `Bearer ${import.meta.env.NOTION_TOKEN}`,
|
|
1282
|
+
"Notion-Version": "2022-06-28",
|
|
1283
|
+
"Content-Type": "application/json",
|
|
1284
|
+
},
|
|
1285
|
+
}
|
|
1286
|
+
);
|
|
1287
|
+
|
|
1288
|
+
if (!response.ok) {
|
|
1289
|
+
throw new Error(`Notion API error: ${response.statusText}`);
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
const json = await response.json();
|
|
1293
|
+
return json.results;
|
|
1294
|
+
},
|
|
1295
|
+
catch: (error) =>
|
|
1296
|
+
new FetchError({
|
|
1297
|
+
source: "Notion",
|
|
1298
|
+
reason: error instanceof Error ? error.message : "Unknown error",
|
|
1299
|
+
}),
|
|
1300
|
+
}),
|
|
1301
|
+
|
|
1302
|
+
transform: (data: unknown): Effect.Effect<MigratedItem, TransformError> =>
|
|
1303
|
+
Effect.try({
|
|
1304
|
+
try: () => {
|
|
1305
|
+
const page = data as NotionPage;
|
|
1306
|
+
|
|
1307
|
+
return {
|
|
1308
|
+
id: `notion-${page.id}`,
|
|
1309
|
+
title: page.properties.Title.title[0]?.plain_text || "Untitled",
|
|
1310
|
+
content: "", // Would need to fetch page content separately
|
|
1311
|
+
author: "notion-import",
|
|
1312
|
+
createdAt: new Date(page.properties.Created.created_time),
|
|
1313
|
+
tags: page.properties.Tags.multi_select.map(t => t.name),
|
|
1314
|
+
metadata: {
|
|
1315
|
+
source: "notion",
|
|
1316
|
+
pageId: page.id,
|
|
1317
|
+
url: page.url,
|
|
1318
|
+
},
|
|
1319
|
+
};
|
|
1320
|
+
},
|
|
1321
|
+
catch: (error) =>
|
|
1322
|
+
new TransformError({
|
|
1323
|
+
item: JSON.stringify(data),
|
|
1324
|
+
reason: error instanceof Error ? error.message : "Transform failed",
|
|
1325
|
+
}),
|
|
1326
|
+
}),
|
|
1327
|
+
|
|
1328
|
+
validate: validateMigratedItem,
|
|
1329
|
+
};
|
|
1330
|
+
```
|
|
1331
|
+
|
|
1332
|
+
### Migration Page
|
|
1333
|
+
|
|
1334
|
+
```astro
|
|
1335
|
+
---
|
|
1336
|
+
// src/pages/migrate/index.astro
|
|
1337
|
+
import Layout from "@/layouts/Layout.astro";
|
|
1338
|
+
import { Button } from "@/components/ui/button";
|
|
1339
|
+
import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card";
|
|
1340
|
+
import MigrationStatus from "@/components/MigrationStatus.tsx";
|
|
1341
|
+
|
|
1342
|
+
const sources = [
|
|
1343
|
+
{ name: "GitHub", description: "Import issues as blog posts", icon: "📦" },
|
|
1344
|
+
{ name: "Notion", description: "Import database pages", icon: "📝" },
|
|
1345
|
+
{ name: "Stripe", description: "Import customer data", icon: "💳" },
|
|
1346
|
+
];
|
|
1347
|
+
---
|
|
1348
|
+
|
|
1349
|
+
<Layout title="Data Migration">
|
|
1350
|
+
<div class="container max-w-6xl py-12">
|
|
1351
|
+
<h1 class="text-4xl font-bold mb-4">Data Migration</h1>
|
|
1352
|
+
<p class="text-xl text-gray-600 mb-12">
|
|
1353
|
+
Import content from external sources
|
|
1354
|
+
</p>
|
|
1355
|
+
|
|
1356
|
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-12">
|
|
1357
|
+
{sources.map(source => (
|
|
1358
|
+
<Card>
|
|
1359
|
+
<CardHeader>
|
|
1360
|
+
<CardTitle class="flex items-center gap-2">
|
|
1361
|
+
<span class="text-3xl">{source.icon}</span>
|
|
1362
|
+
{source.name}
|
|
1363
|
+
</CardTitle>
|
|
1364
|
+
</CardHeader>
|
|
1365
|
+
<CardContent>
|
|
1366
|
+
<p class="text-sm text-gray-600 mb-4">{source.description}</p>
|
|
1367
|
+
<Button asChild class="w-full">
|
|
1368
|
+
<a href={`/migrate/${source.name.toLowerCase()}`}>
|
|
1369
|
+
Start Migration
|
|
1370
|
+
</a>
|
|
1371
|
+
</Button>
|
|
1372
|
+
</CardContent>
|
|
1373
|
+
</Card>
|
|
1374
|
+
))}
|
|
1375
|
+
</div>
|
|
1376
|
+
|
|
1377
|
+
<MigrationStatus client:load />
|
|
1378
|
+
</div>
|
|
1379
|
+
</Layout>
|
|
1380
|
+
```
|
|
1381
|
+
|
|
1382
|
+
### Migration Status Component
|
|
1383
|
+
|
|
1384
|
+
```tsx
|
|
1385
|
+
// src/components/MigrationStatus.tsx
|
|
1386
|
+
import { useState } from "react";
|
|
1387
|
+
import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card";
|
|
1388
|
+
import { Button } from "@/components/ui/button";
|
|
1389
|
+
import { Alert, AlertDescription } from "@/components/ui/alert";
|
|
1390
|
+
import { Effect } from "effect";
|
|
1391
|
+
import { migrateFromMultipleSources } from "@/lib/services/migrationService";
|
|
1392
|
+
import { GitHubDataSource } from "@/lib/services/githubAdapter";
|
|
1393
|
+
import { NotionDataSource } from "@/lib/services/notionAdapter";
|
|
1394
|
+
|
|
1395
|
+
type MigrationState = "idle" | "running" | "success" | "error";
|
|
1396
|
+
|
|
1397
|
+
export function MigrationStatus() {
|
|
1398
|
+
const [state, setState] = useState<MigrationState>("idle");
|
|
1399
|
+
const [results, setResults] = useState<Map<string, any[]> | null>(null);
|
|
1400
|
+
const [error, setError] = useState<string | null>(null);
|
|
1401
|
+
|
|
1402
|
+
const runMigration = async () => {
|
|
1403
|
+
setState("running");
|
|
1404
|
+
setError(null);
|
|
1405
|
+
|
|
1406
|
+
const sources = [GitHubDataSource, NotionDataSource];
|
|
1407
|
+
|
|
1408
|
+
const result = await Effect.runPromise(
|
|
1409
|
+
Effect.either(migrateFromMultipleSources(sources))
|
|
1410
|
+
);
|
|
1411
|
+
|
|
1412
|
+
if (result._tag === "Left") {
|
|
1413
|
+
const err = result.left;
|
|
1414
|
+
setError(`Migration failed: ${err._tag} - ${JSON.stringify(err)}`);
|
|
1415
|
+
setState("error");
|
|
1416
|
+
} else {
|
|
1417
|
+
setResults(result.right);
|
|
1418
|
+
setState("success");
|
|
1419
|
+
}
|
|
1420
|
+
};
|
|
1421
|
+
|
|
1422
|
+
return (
|
|
1423
|
+
<Card>
|
|
1424
|
+
<CardHeader>
|
|
1425
|
+
<CardTitle>Migration Status</CardTitle>
|
|
1426
|
+
</CardHeader>
|
|
1427
|
+
<CardContent className="space-y-4">
|
|
1428
|
+
<Button
|
|
1429
|
+
onClick={runMigration}
|
|
1430
|
+
disabled={state === "running"}
|
|
1431
|
+
className="w-full"
|
|
1432
|
+
>
|
|
1433
|
+
{state === "running" ? "Migrating..." : "Run Migration"}
|
|
1434
|
+
</Button>
|
|
1435
|
+
|
|
1436
|
+
{error && (
|
|
1437
|
+
<Alert variant="destructive">
|
|
1438
|
+
<AlertDescription>{error}</AlertDescription>
|
|
1439
|
+
</Alert>
|
|
1440
|
+
)}
|
|
1441
|
+
|
|
1442
|
+
{results && (
|
|
1443
|
+
<div className="space-y-4">
|
|
1444
|
+
<Alert>
|
|
1445
|
+
<AlertDescription>
|
|
1446
|
+
Migration completed successfully!
|
|
1447
|
+
</AlertDescription>
|
|
1448
|
+
</Alert>
|
|
1449
|
+
|
|
1450
|
+
{Array.from(results.entries()).map(([source, items]) => (
|
|
1451
|
+
<div key={source} className="p-4 border rounded">
|
|
1452
|
+
<h3 className="font-semibold mb-2">{source}</h3>
|
|
1453
|
+
<p className="text-sm text-gray-600">
|
|
1454
|
+
Migrated {items.length} items
|
|
1455
|
+
</p>
|
|
1456
|
+
<ul className="mt-2 space-y-1">
|
|
1457
|
+
{items.slice(0, 5).map(item => (
|
|
1458
|
+
<li key={item.id} className="text-sm">
|
|
1459
|
+
• {item.title}
|
|
1460
|
+
</li>
|
|
1461
|
+
))}
|
|
1462
|
+
{items.length > 5 && (
|
|
1463
|
+
<li className="text-sm text-gray-500">
|
|
1464
|
+
... and {items.length - 5} more
|
|
1465
|
+
</li>
|
|
1466
|
+
)}
|
|
1467
|
+
</ul>
|
|
1468
|
+
</div>
|
|
1469
|
+
))}
|
|
1470
|
+
</div>
|
|
1471
|
+
)}
|
|
1472
|
+
</CardContent>
|
|
1473
|
+
</Card>
|
|
1474
|
+
);
|
|
1475
|
+
}
|
|
1476
|
+
```
|
|
1477
|
+
|
|
1478
|
+
**Layer 4 Result:** Multi-source data migration with Effect.ts pipelines, error handling, and concurrent processing.
|
|
1479
|
+
|
|
1480
|
+
---
|
|
1481
|
+
|
|
1482
|
+
## Layer 5: Full-Stack App (Team Management Example)
|
|
1483
|
+
|
|
1484
|
+
**Use Case:** Full CRUD application with authentication, database persistence, and real-time updates.
|
|
1485
|
+
|
|
1486
|
+
**Added to Layer 4:**
|
|
1487
|
+
- ✅ Database (PostgreSQL via Drizzle ORM)
|
|
1488
|
+
- ✅ Authentication (Better Auth)
|
|
1489
|
+
- ✅ REST API (Hono)
|
|
1490
|
+
- ✅ WebSockets (real-time updates)
|
|
1491
|
+
|
|
1492
|
+
**Complete File Structure**
|
|
1493
|
+
|
|
1494
|
+
```
|
|
1495
|
+
src/
|
|
1496
|
+
├── pages/
|
|
1497
|
+
│ ├── teams/
|
|
1498
|
+
│ │ ├── index.astro # Team list
|
|
1499
|
+
│ │ ├── [id].astro # Team detail
|
|
1500
|
+
│ │ ├── new.astro # Create team
|
|
1501
|
+
│ │ └── [id]/
|
|
1502
|
+
│ │ ├── edit.astro # Edit team
|
|
1503
|
+
│ │ └── members.astro # Manage members
|
|
1504
|
+
│ ├── auth/
|
|
1505
|
+
│ │ ├── login.astro
|
|
1506
|
+
│ │ ├── register.astro
|
|
1507
|
+
│ │ └── logout.astro
|
|
1508
|
+
│ └── api/
|
|
1509
|
+
│ └── teams/
|
|
1510
|
+
│ ├── index.ts # List/create teams
|
|
1511
|
+
│ ├── [id].ts # Get/update/delete team
|
|
1512
|
+
│ └── [id]/
|
|
1513
|
+
│ └── members.ts # Manage members
|
|
1514
|
+
│
|
|
1515
|
+
├── components/
|
|
1516
|
+
│ ├── TeamList.tsx # Real-time team list
|
|
1517
|
+
│ ├── TeamForm.tsx # Create/edit form
|
|
1518
|
+
│ ├── MemberManager.tsx # Add/remove members
|
|
1519
|
+
│ └── AuthGuard.tsx # Protected routes
|
|
1520
|
+
│
|
|
1521
|
+
├── lib/
|
|
1522
|
+
│ ├── db/
|
|
1523
|
+
│ │ ├── schema.ts # Drizzle schema
|
|
1524
|
+
│ │ └── client.ts # Database client
|
|
1525
|
+
│ ├── auth/
|
|
1526
|
+
│ │ └── config.ts # Better Auth config
|
|
1527
|
+
│ └── services/
|
|
1528
|
+
│ ├── teamService.ts # Effect.ts team logic
|
|
1529
|
+
│ └── memberService.ts # Effect.ts member logic
|
|
1530
|
+
│
|
|
1531
|
+
└── backend/
|
|
1532
|
+
└── src/
|
|
1533
|
+
├── routes/
|
|
1534
|
+
│ └── teams.ts # Hono routes
|
|
1535
|
+
└── server.ts # Main server
|
|
1536
|
+
```
|
|
1537
|
+
|
|
1538
|
+
### Database Schema (Drizzle)
|
|
1539
|
+
|
|
1540
|
+
```typescript
|
|
1541
|
+
// src/lib/db/schema.ts
|
|
1542
|
+
import { pgTable, uuid, varchar, timestamp, boolean, json } from "drizzle-orm/pg-core";
|
|
1543
|
+
|
|
1544
|
+
export const users = pgTable("users", {
|
|
1545
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
1546
|
+
email: varchar("email", { length: 255 }).notNull().unique(),
|
|
1547
|
+
name: varchar("name", { length: 255 }).notNull(),
|
|
1548
|
+
passwordHash: varchar("password_hash", { length: 255 }).notNull(),
|
|
1549
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
1550
|
+
});
|
|
1551
|
+
|
|
1552
|
+
export const teams = pgTable("teams", {
|
|
1553
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
1554
|
+
name: varchar("name", { length: 255 }).notNull(),
|
|
1555
|
+
description: varchar("description", { length: 1000 }),
|
|
1556
|
+
ownerId: uuid("owner_id").references(() => users.id).notNull(),
|
|
1557
|
+
status: varchar("status", { length: 50 }).notNull().default("active"),
|
|
1558
|
+
settings: json("settings").$type<Record<string, any>>(),
|
|
1559
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
1560
|
+
updatedAt: timestamp("updated_at").defaultNow().notNull(),
|
|
1561
|
+
});
|
|
1562
|
+
|
|
1563
|
+
export const teamMembers = pgTable("team_members", {
|
|
1564
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
1565
|
+
teamId: uuid("team_id").references(() => teams.id).notNull(),
|
|
1566
|
+
userId: uuid("user_id").references(() => users.id).notNull(),
|
|
1567
|
+
role: varchar("role", { length: 50 }).notNull().default("member"),
|
|
1568
|
+
joinedAt: timestamp("joined_at").defaultNow().notNull(),
|
|
1569
|
+
});
|
|
1570
|
+
```
|
|
1571
|
+
|
|
1572
|
+
### Team Service (Effect.ts)
|
|
1573
|
+
|
|
1574
|
+
```typescript
|
|
1575
|
+
// src/lib/services/teamService.ts
|
|
1576
|
+
import { Effect, Data, Context } from "effect";
|
|
1577
|
+
import { db } from "@/lib/db/client";
|
|
1578
|
+
import { teams, teamMembers, users } from "@/lib/db/schema";
|
|
1579
|
+
import { eq, and } from "drizzle-orm";
|
|
1580
|
+
|
|
1581
|
+
// Tagged errors
|
|
1582
|
+
export class TeamNotFoundError extends Data.TaggedError("TeamNotFoundError")<{
|
|
1583
|
+
teamId: string;
|
|
1584
|
+
}> {}
|
|
1585
|
+
|
|
1586
|
+
export class UnauthorizedError extends Data.TaggedError("UnauthorizedError")<{
|
|
1587
|
+
reason: string;
|
|
1588
|
+
}> {}
|
|
1589
|
+
|
|
1590
|
+
export class ValidationError extends Data.TaggedError("ValidationError")<{
|
|
1591
|
+
field: string;
|
|
1592
|
+
message: string;
|
|
1593
|
+
}> {}
|
|
1594
|
+
|
|
1595
|
+
export class DatabaseError extends Data.TaggedError("DatabaseError")<{
|
|
1596
|
+
operation: string;
|
|
1597
|
+
reason: string;
|
|
1598
|
+
}> {}
|
|
1599
|
+
|
|
1600
|
+
// Types
|
|
1601
|
+
export type Team = typeof teams.$inferSelect;
|
|
1602
|
+
export type CreateTeamInput = {
|
|
1603
|
+
name: string;
|
|
1604
|
+
description?: string;
|
|
1605
|
+
ownerId: string;
|
|
1606
|
+
};
|
|
1607
|
+
export type UpdateTeamInput = Partial<CreateTeamInput>;
|
|
1608
|
+
|
|
1609
|
+
// Database context
|
|
1610
|
+
export interface Database {
|
|
1611
|
+
readonly db: typeof db;
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
export const Database = Context.GenericTag<Database>("Database");
|
|
1615
|
+
|
|
1616
|
+
// Validation
|
|
1617
|
+
export const validateTeamName = (
|
|
1618
|
+
name: string
|
|
1619
|
+
): Effect.Effect<string, ValidationError> =>
|
|
1620
|
+
Effect.gen(function* () {
|
|
1621
|
+
if (!name?.trim()) {
|
|
1622
|
+
return yield* new ValidationError({
|
|
1623
|
+
field: "name",
|
|
1624
|
+
message: "Team name is required",
|
|
1625
|
+
});
|
|
1626
|
+
}
|
|
1627
|
+
if (name.length < 2) {
|
|
1628
|
+
return yield* new ValidationError({
|
|
1629
|
+
field: "name",
|
|
1630
|
+
message: "Team name must be at least 2 characters",
|
|
1631
|
+
});
|
|
1632
|
+
}
|
|
1633
|
+
if (name.length > 100) {
|
|
1634
|
+
return yield* new ValidationError({
|
|
1635
|
+
field: "name",
|
|
1636
|
+
message: "Team name cannot exceed 100 characters",
|
|
1637
|
+
});
|
|
1638
|
+
}
|
|
1639
|
+
return name.trim();
|
|
1640
|
+
});
|
|
1641
|
+
|
|
1642
|
+
// Create team
|
|
1643
|
+
export const createTeam = (
|
|
1644
|
+
input: CreateTeamInput
|
|
1645
|
+
): Effect.Effect<Team, ValidationError | DatabaseError, Database> =>
|
|
1646
|
+
Effect.gen(function* () {
|
|
1647
|
+
const database = yield* Database;
|
|
1648
|
+
|
|
1649
|
+
// Validate input
|
|
1650
|
+
const validName = yield* validateTeamName(input.name);
|
|
1651
|
+
|
|
1652
|
+
// Insert into database
|
|
1653
|
+
const result = yield* Effect.tryPromise({
|
|
1654
|
+
try: async () => {
|
|
1655
|
+
const [team] = await database.db
|
|
1656
|
+
.insert(teams)
|
|
1657
|
+
.values({
|
|
1658
|
+
name: validName,
|
|
1659
|
+
description: input.description,
|
|
1660
|
+
ownerId: input.ownerId,
|
|
1661
|
+
status: "active",
|
|
1662
|
+
settings: {},
|
|
1663
|
+
})
|
|
1664
|
+
.returning();
|
|
1665
|
+
return team;
|
|
1666
|
+
},
|
|
1667
|
+
catch: (error) =>
|
|
1668
|
+
new DatabaseError({
|
|
1669
|
+
operation: "createTeam",
|
|
1670
|
+
reason: error instanceof Error ? error.message : "Unknown error",
|
|
1671
|
+
}),
|
|
1672
|
+
});
|
|
1673
|
+
|
|
1674
|
+
return result;
|
|
1675
|
+
});
|
|
1676
|
+
|
|
1677
|
+
// Get team by ID
|
|
1678
|
+
export const getTeamById = (
|
|
1679
|
+
teamId: string
|
|
1680
|
+
): Effect.Effect<Team, TeamNotFoundError | DatabaseError, Database> =>
|
|
1681
|
+
Effect.gen(function* () {
|
|
1682
|
+
const database = yield* Database;
|
|
1683
|
+
|
|
1684
|
+
const result = yield* Effect.tryPromise({
|
|
1685
|
+
try: async () => {
|
|
1686
|
+
const [team] = await database.db
|
|
1687
|
+
.select()
|
|
1688
|
+
.from(teams)
|
|
1689
|
+
.where(eq(teams.id, teamId))
|
|
1690
|
+
.limit(1);
|
|
1691
|
+
return team;
|
|
1692
|
+
},
|
|
1693
|
+
catch: (error) =>
|
|
1694
|
+
new DatabaseError({
|
|
1695
|
+
operation: "getTeamById",
|
|
1696
|
+
reason: error instanceof Error ? error.message : "Unknown error",
|
|
1697
|
+
}),
|
|
1698
|
+
});
|
|
1699
|
+
|
|
1700
|
+
if (!result) {
|
|
1701
|
+
return yield* new TeamNotFoundError({ teamId });
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
return result;
|
|
1705
|
+
});
|
|
1706
|
+
|
|
1707
|
+
// Update team
|
|
1708
|
+
export const updateTeam = (
|
|
1709
|
+
teamId: string,
|
|
1710
|
+
userId: string,
|
|
1711
|
+
input: UpdateTeamInput
|
|
1712
|
+
): Effect.Effect<Team, TeamNotFoundError | UnauthorizedError | ValidationError | DatabaseError, Database> =>
|
|
1713
|
+
Effect.gen(function* () {
|
|
1714
|
+
const database = yield* Database;
|
|
1715
|
+
|
|
1716
|
+
// Get existing team
|
|
1717
|
+
const team = yield* getTeamById(teamId);
|
|
1718
|
+
|
|
1719
|
+
// Check authorization
|
|
1720
|
+
if (team.ownerId !== userId) {
|
|
1721
|
+
return yield* new UnauthorizedError({
|
|
1722
|
+
reason: "Only team owner can update team",
|
|
1723
|
+
});
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
// Validate input
|
|
1727
|
+
const validName = input.name
|
|
1728
|
+
? yield* validateTeamName(input.name)
|
|
1729
|
+
: team.name;
|
|
1730
|
+
|
|
1731
|
+
// Update database
|
|
1732
|
+
const result = yield* Effect.tryPromise({
|
|
1733
|
+
try: async () => {
|
|
1734
|
+
const [updated] = await database.db
|
|
1735
|
+
.update(teams)
|
|
1736
|
+
.set({
|
|
1737
|
+
name: validName,
|
|
1738
|
+
description: input.description ?? team.description,
|
|
1739
|
+
updatedAt: new Date(),
|
|
1740
|
+
})
|
|
1741
|
+
.where(eq(teams.id, teamId))
|
|
1742
|
+
.returning();
|
|
1743
|
+
return updated;
|
|
1744
|
+
},
|
|
1745
|
+
catch: (error) =>
|
|
1746
|
+
new DatabaseError({
|
|
1747
|
+
operation: "updateTeam",
|
|
1748
|
+
reason: error instanceof Error ? error.message : "Unknown error",
|
|
1749
|
+
}),
|
|
1750
|
+
});
|
|
1751
|
+
|
|
1752
|
+
return result;
|
|
1753
|
+
});
|
|
1754
|
+
|
|
1755
|
+
// Delete team
|
|
1756
|
+
export const deleteTeam = (
|
|
1757
|
+
teamId: string,
|
|
1758
|
+
userId: string
|
|
1759
|
+
): Effect.Effect<void, TeamNotFoundError | UnauthorizedError | DatabaseError, Database> =>
|
|
1760
|
+
Effect.gen(function* () {
|
|
1761
|
+
const database = yield* Database;
|
|
1762
|
+
|
|
1763
|
+
// Get existing team
|
|
1764
|
+
const team = yield* getTeamById(teamId);
|
|
1765
|
+
|
|
1766
|
+
// Check authorization
|
|
1767
|
+
if (team.ownerId !== userId) {
|
|
1768
|
+
return yield* new UnauthorizedError({
|
|
1769
|
+
reason: "Only team owner can delete team",
|
|
1770
|
+
});
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
// Delete from database
|
|
1774
|
+
yield* Effect.tryPromise({
|
|
1775
|
+
try: async () => {
|
|
1776
|
+
await database.db.delete(teams).where(eq(teams.id, teamId));
|
|
1777
|
+
},
|
|
1778
|
+
catch: (error) =>
|
|
1779
|
+
new DatabaseError({
|
|
1780
|
+
operation: "deleteTeam",
|
|
1781
|
+
reason: error instanceof Error ? error.message : "Unknown error",
|
|
1782
|
+
}),
|
|
1783
|
+
});
|
|
1784
|
+
});
|
|
1785
|
+
|
|
1786
|
+
// List user's teams
|
|
1787
|
+
export const listUserTeams = (
|
|
1788
|
+
userId: string
|
|
1789
|
+
): Effect.Effect<Team[], DatabaseError, Database> =>
|
|
1790
|
+
Effect.gen(function* () {
|
|
1791
|
+
const database = yield* Database;
|
|
1792
|
+
|
|
1793
|
+
const result = yield* Effect.tryPromise({
|
|
1794
|
+
try: async () => {
|
|
1795
|
+
// Teams where user is owner OR member
|
|
1796
|
+
const ownedTeams = await database.db
|
|
1797
|
+
.select()
|
|
1798
|
+
.from(teams)
|
|
1799
|
+
.where(eq(teams.ownerId, userId));
|
|
1800
|
+
|
|
1801
|
+
const memberTeamIds = await database.db
|
|
1802
|
+
.select({ teamId: teamMembers.teamId })
|
|
1803
|
+
.from(teamMembers)
|
|
1804
|
+
.where(eq(teamMembers.userId, userId));
|
|
1805
|
+
|
|
1806
|
+
const memberTeams = await database.db
|
|
1807
|
+
.select()
|
|
1808
|
+
.from(teams)
|
|
1809
|
+
.where(
|
|
1810
|
+
eq(
|
|
1811
|
+
teams.id,
|
|
1812
|
+
memberTeamIds.map(m => m.teamId)[0] // Simplified - should use IN clause
|
|
1813
|
+
)
|
|
1814
|
+
);
|
|
1815
|
+
|
|
1816
|
+
// Combine and deduplicate
|
|
1817
|
+
const allTeams = [...ownedTeams, ...memberTeams];
|
|
1818
|
+
const uniqueTeams = Array.from(
|
|
1819
|
+
new Map(allTeams.map(t => [t.id, t])).values()
|
|
1820
|
+
);
|
|
1821
|
+
|
|
1822
|
+
return uniqueTeams;
|
|
1823
|
+
},
|
|
1824
|
+
catch: (error) =>
|
|
1825
|
+
new DatabaseError({
|
|
1826
|
+
operation: "listUserTeams",
|
|
1827
|
+
reason: error instanceof Error ? error.message : "Unknown error",
|
|
1828
|
+
}),
|
|
1829
|
+
});
|
|
1830
|
+
|
|
1831
|
+
return result;
|
|
1832
|
+
});
|
|
1833
|
+
```
|
|
1834
|
+
|
|
1835
|
+
### API Routes (Hono)
|
|
1836
|
+
|
|
1837
|
+
```typescript
|
|
1838
|
+
// backend/src/routes/teams.ts
|
|
1839
|
+
import { Hono } from "hono";
|
|
1840
|
+
import { Effect, Context } from "effect";
|
|
1841
|
+
import {
|
|
1842
|
+
createTeam,
|
|
1843
|
+
getTeamById,
|
|
1844
|
+
updateTeam,
|
|
1845
|
+
deleteTeam,
|
|
1846
|
+
listUserTeams,
|
|
1847
|
+
Database,
|
|
1848
|
+
} from "@/lib/services/teamService";
|
|
1849
|
+
import { db } from "@/lib/db/client";
|
|
1850
|
+
|
|
1851
|
+
const app = new Hono();
|
|
1852
|
+
|
|
1853
|
+
// Middleware: Provide database context
|
|
1854
|
+
const withDatabase = <R, E, A>(
|
|
1855
|
+
effect: Effect.Effect<A, E, Database | R>
|
|
1856
|
+
): Effect.Effect<A, E, R> =>
|
|
1857
|
+
effect.pipe(
|
|
1858
|
+
Effect.provideService(Database, { db })
|
|
1859
|
+
);
|
|
1860
|
+
|
|
1861
|
+
// GET /api/teams - List user's teams
|
|
1862
|
+
app.get("/", async (c) => {
|
|
1863
|
+
const userId = c.get("userId"); // From auth middleware
|
|
1864
|
+
|
|
1865
|
+
const result = await Effect.runPromise(
|
|
1866
|
+
Effect.either(withDatabase(listUserTeams(userId)))
|
|
1867
|
+
);
|
|
1868
|
+
|
|
1869
|
+
if (result._tag === "Left") {
|
|
1870
|
+
const error = result.left;
|
|
1871
|
+
return c.json({ error: error._tag, details: error }, 500);
|
|
1872
|
+
}
|
|
1873
|
+
|
|
1874
|
+
return c.json({ data: result.right });
|
|
1875
|
+
});
|
|
1876
|
+
|
|
1877
|
+
// POST /api/teams - Create team
|
|
1878
|
+
app.post("/", async (c) => {
|
|
1879
|
+
const userId = c.get("userId");
|
|
1880
|
+
const body = await c.req.json();
|
|
1881
|
+
|
|
1882
|
+
const result = await Effect.runPromise(
|
|
1883
|
+
Effect.either(
|
|
1884
|
+
withDatabase(
|
|
1885
|
+
createTeam({
|
|
1886
|
+
name: body.name,
|
|
1887
|
+
description: body.description,
|
|
1888
|
+
ownerId: userId,
|
|
1889
|
+
})
|
|
1890
|
+
)
|
|
1891
|
+
)
|
|
1892
|
+
);
|
|
1893
|
+
|
|
1894
|
+
if (result._tag === "Left") {
|
|
1895
|
+
const error = result.left;
|
|
1896
|
+
const status = error._tag === "ValidationError" ? 400 : 500;
|
|
1897
|
+
return c.json({ error: error._tag, details: error }, status);
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
return c.json({ data: result.right }, 201);
|
|
1901
|
+
});
|
|
1902
|
+
|
|
1903
|
+
// GET /api/teams/:id - Get team
|
|
1904
|
+
app.get("/:id", async (c) => {
|
|
1905
|
+
const teamId = c.req.param("id");
|
|
1906
|
+
|
|
1907
|
+
const result = await Effect.runPromise(
|
|
1908
|
+
Effect.either(withDatabase(getTeamById(teamId)))
|
|
1909
|
+
);
|
|
1910
|
+
|
|
1911
|
+
if (result._tag === "Left") {
|
|
1912
|
+
const error = result.left;
|
|
1913
|
+
const status = error._tag === "TeamNotFoundError" ? 404 : 500;
|
|
1914
|
+
return c.json({ error: error._tag, details: error }, status);
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1917
|
+
return c.json({ data: result.right });
|
|
1918
|
+
});
|
|
1919
|
+
|
|
1920
|
+
// PATCH /api/teams/:id - Update team
|
|
1921
|
+
app.patch("/:id", async (c) => {
|
|
1922
|
+
const teamId = c.req.param("id");
|
|
1923
|
+
const userId = c.get("userId");
|
|
1924
|
+
const body = await c.req.json();
|
|
1925
|
+
|
|
1926
|
+
const result = await Effect.runPromise(
|
|
1927
|
+
Effect.either(
|
|
1928
|
+
withDatabase(
|
|
1929
|
+
updateTeam(teamId, userId, {
|
|
1930
|
+
name: body.name,
|
|
1931
|
+
description: body.description,
|
|
1932
|
+
})
|
|
1933
|
+
)
|
|
1934
|
+
)
|
|
1935
|
+
);
|
|
1936
|
+
|
|
1937
|
+
if (result._tag === "Left") {
|
|
1938
|
+
const error = result.left;
|
|
1939
|
+
const status =
|
|
1940
|
+
error._tag === "TeamNotFoundError"
|
|
1941
|
+
? 404
|
|
1942
|
+
: error._tag === "UnauthorizedError"
|
|
1943
|
+
? 403
|
|
1944
|
+
: error._tag === "ValidationError"
|
|
1945
|
+
? 400
|
|
1946
|
+
: 500;
|
|
1947
|
+
return c.json({ error: error._tag, details: error }, status);
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
return c.json({ data: result.right });
|
|
1951
|
+
});
|
|
1952
|
+
|
|
1953
|
+
// DELETE /api/teams/:id - Delete team
|
|
1954
|
+
app.delete("/:id", async (c) => {
|
|
1955
|
+
const teamId = c.req.param("id");
|
|
1956
|
+
const userId = c.get("userId");
|
|
1957
|
+
|
|
1958
|
+
const result = await Effect.runPromise(
|
|
1959
|
+
Effect.either(withDatabase(deleteTeam(teamId, userId)))
|
|
1960
|
+
);
|
|
1961
|
+
|
|
1962
|
+
if (result._tag === "Left") {
|
|
1963
|
+
const error = result.left;
|
|
1964
|
+
const status =
|
|
1965
|
+
error._tag === "TeamNotFoundError"
|
|
1966
|
+
? 404
|
|
1967
|
+
: error._tag === "UnauthorizedError"
|
|
1968
|
+
? 403
|
|
1969
|
+
: 500;
|
|
1970
|
+
return c.json({ error: error._tag, details: error }, status);
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
return c.json({ success: true }, 204);
|
|
1974
|
+
});
|
|
1975
|
+
|
|
1976
|
+
export default app;
|
|
1977
|
+
```
|
|
1978
|
+
|
|
1979
|
+
### Team List Component
|
|
1980
|
+
|
|
1981
|
+
```tsx
|
|
1982
|
+
// src/components/TeamList.tsx
|
|
1983
|
+
import { useEffect, useState } from "react";
|
|
1984
|
+
import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card";
|
|
1985
|
+
import { Button } from "@/components/ui/button";
|
|
1986
|
+
import { Alert, AlertDescription } from "@/components/ui/alert";
|
|
1987
|
+
import { Plus, Users } from "lucide-react";
|
|
1988
|
+
|
|
1989
|
+
type Team = {
|
|
1990
|
+
id: string;
|
|
1991
|
+
name: string;
|
|
1992
|
+
description: string | null;
|
|
1993
|
+
status: string;
|
|
1994
|
+
createdAt: string;
|
|
1995
|
+
};
|
|
1996
|
+
|
|
1997
|
+
export function TeamList() {
|
|
1998
|
+
const [teams, setTeams] = useState<Team[]>([]);
|
|
1999
|
+
const [loading, setLoading] = useState(true);
|
|
2000
|
+
const [error, setError] = useState<string | null>(null);
|
|
2001
|
+
|
|
2002
|
+
useEffect(() => {
|
|
2003
|
+
fetchTeams();
|
|
2004
|
+
}, []);
|
|
2005
|
+
|
|
2006
|
+
const fetchTeams = async () => {
|
|
2007
|
+
try {
|
|
2008
|
+
const response = await fetch("/api/teams");
|
|
2009
|
+
const json = await response.json();
|
|
2010
|
+
|
|
2011
|
+
if (response.ok) {
|
|
2012
|
+
setTeams(json.data);
|
|
2013
|
+
} else {
|
|
2014
|
+
setError(json.error);
|
|
2015
|
+
}
|
|
2016
|
+
} catch (err) {
|
|
2017
|
+
setError("Failed to fetch teams");
|
|
2018
|
+
} finally {
|
|
2019
|
+
setLoading(false);
|
|
2020
|
+
}
|
|
2021
|
+
};
|
|
2022
|
+
|
|
2023
|
+
if (loading) {
|
|
2024
|
+
return <div>Loading teams...</div>;
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
if (error) {
|
|
2028
|
+
return (
|
|
2029
|
+
<Alert variant="destructive">
|
|
2030
|
+
<AlertDescription>{error}</AlertDescription>
|
|
2031
|
+
</Alert>
|
|
2032
|
+
);
|
|
2033
|
+
}
|
|
2034
|
+
|
|
2035
|
+
return (
|
|
2036
|
+
<div className="space-y-6">
|
|
2037
|
+
<div className="flex justify-between items-center">
|
|
2038
|
+
<h2 className="text-2xl font-bold">Your Teams</h2>
|
|
2039
|
+
<Button asChild>
|
|
2040
|
+
<a href="/teams/new">
|
|
2041
|
+
<Plus className="mr-2 h-4 w-4" />
|
|
2042
|
+
Create Team
|
|
2043
|
+
</a>
|
|
2044
|
+
</Button>
|
|
2045
|
+
</div>
|
|
2046
|
+
|
|
2047
|
+
{teams.length === 0 ? (
|
|
2048
|
+
<Card>
|
|
2049
|
+
<CardContent className="p-12 text-center">
|
|
2050
|
+
<Users className="h-12 w-12 mx-auto text-gray-400 mb-4" />
|
|
2051
|
+
<p className="text-gray-500">No teams yet. Create your first team!</p>
|
|
2052
|
+
</CardContent>
|
|
2053
|
+
</Card>
|
|
2054
|
+
) : (
|
|
2055
|
+
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
|
|
2056
|
+
{teams.map(team => (
|
|
2057
|
+
<a key={team.id} href={`/teams/${team.id}`}>
|
|
2058
|
+
<Card className="hover:shadow-lg transition">
|
|
2059
|
+
<CardHeader>
|
|
2060
|
+
<CardTitle>{team.name}</CardTitle>
|
|
2061
|
+
</CardHeader>
|
|
2062
|
+
<CardContent>
|
|
2063
|
+
<p className="text-sm text-gray-600">
|
|
2064
|
+
{team.description || "No description"}
|
|
2065
|
+
</p>
|
|
2066
|
+
</CardContent>
|
|
2067
|
+
</Card>
|
|
2068
|
+
</a>
|
|
2069
|
+
))}
|
|
2070
|
+
</div>
|
|
2071
|
+
)}
|
|
2072
|
+
</div>
|
|
2073
|
+
);
|
|
2074
|
+
}
|
|
2075
|
+
```
|
|
2076
|
+
|
|
2077
|
+
### Team List Page
|
|
2078
|
+
|
|
2079
|
+
```astro
|
|
2080
|
+
---
|
|
2081
|
+
// src/pages/teams/index.astro
|
|
2082
|
+
import Layout from "@/layouts/Layout.astro";
|
|
2083
|
+
import TeamList from "@/components/TeamList.tsx";
|
|
2084
|
+
|
|
2085
|
+
// Server-side auth check
|
|
2086
|
+
const session = Astro.locals.session;
|
|
2087
|
+
if (!session) {
|
|
2088
|
+
return Astro.redirect("/auth/login");
|
|
2089
|
+
}
|
|
2090
|
+
---
|
|
2091
|
+
|
|
2092
|
+
<Layout title="Teams">
|
|
2093
|
+
<div class="container max-w-6xl py-12">
|
|
2094
|
+
<TeamList client:load />
|
|
2095
|
+
</div>
|
|
2096
|
+
</Layout>
|
|
2097
|
+
```
|
|
2098
|
+
|
|
2099
|
+
**Layer 5 Result:** Full-stack team management app with database, authentication, type-safe API, and Effect.ts business logic.
|
|
2100
|
+
|
|
2101
|
+
---
|
|
2102
|
+
|
|
2103
|
+
## Summary: When to Use Each Layer
|
|
2104
|
+
|
|
2105
|
+
| Layer | Use Case | Example |
|
|
2106
|
+
|-------|----------|---------|
|
|
2107
|
+
| **Layer 1** | Static content, marketing sites, docs | Blog, portfolio, documentation |
|
|
2108
|
+
| **Layer 2** | Add validation/transformation | Product catalog, pricing calculator |
|
|
2109
|
+
| **Layer 3** | Add client interactivity | Shopping cart, multi-step forms |
|
|
2110
|
+
| **Layer 4** | Fetch/transform external data | Data migrations, API integrations |
|
|
2111
|
+
| **Layer 5** | Full CRUD with auth/database | Team management, SaaS apps |
|
|
2112
|
+
|
|
2113
|
+
## Development Workflow
|
|
2114
|
+
|
|
2115
|
+
```bash
|
|
2116
|
+
# Start with Layer 1
|
|
2117
|
+
npm run dev
|
|
2118
|
+
|
|
2119
|
+
# Add content
|
|
2120
|
+
echo "name: My Team" > src/content/teams/myteam.yaml
|
|
2121
|
+
|
|
2122
|
+
# Generate types
|
|
2123
|
+
bunx astro sync
|
|
2124
|
+
|
|
2125
|
+
# Add Layer 2 validation
|
|
2126
|
+
# Create Effect.ts service in src/lib/services/
|
|
2127
|
+
|
|
2128
|
+
# Add Layer 3 interactivity
|
|
2129
|
+
# Create React component with client:load
|
|
2130
|
+
|
|
2131
|
+
# Add Layer 4 persistence
|
|
2132
|
+
# Set up backend API
|
|
2133
|
+
|
|
2134
|
+
# Add Layer 5 full-stack
|
|
2135
|
+
# Add database + auth
|
|
2136
|
+
```
|
|
2137
|
+
|
|
2138
|
+
## Key Principles
|
|
2139
|
+
|
|
2140
|
+
1. **Start simple** - Begin at Layer 1, only add complexity when needed
|
|
2141
|
+
2. **Type-safe everywhere** - Zod schemas → TypeScript types → Effect.ts services
|
|
2142
|
+
3. **Progressive enhancement** - Each layer builds on the previous
|
|
2143
|
+
4. **Effect.ts for logic** - All business logic uses Effect.ts for error handling
|
|
2144
|
+
5. **Content collections first** - Use content collections before reaching for a database
|
|
2145
|
+
|
|
2146
|
+
---
|
|
2147
|
+
|
|
2148
|
+
**Built for clarity. Designed for scale. Perfect for AI agents.**
|