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
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Better Auth Any Backend
|
|
3
|
+
dimension: things
|
|
4
|
+
category: plans
|
|
5
|
+
tags: architecture, auth, backend, connections, convex, events, frontend, groups, ontology, people
|
|
6
|
+
related_dimensions: connections, events, groups, people
|
|
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 things dimension in the plans category.
|
|
13
|
+
Location: one/things/plans/better-auth-any-backend.md
|
|
14
|
+
Purpose: Documents better auth + one ontology: universal authentication
|
|
15
|
+
Related dimensions: connections, events, groups, people
|
|
16
|
+
For AI agents: Read this to understand better auth any backend.
|
|
17
|
+
---
|
|
18
|
+
|
|
1
19
|
# Better Auth + ONE Ontology: Universal Authentication
|
|
2
20
|
|
|
3
21
|
**Integrating Better Auth with the ONE 6-dimension ontology using Effect.ts**
|
|
@@ -11,6 +29,7 @@ Better Auth is already integrated in our `/frontend` with 6 authentication metho
|
|
|
11
29
|
**Key Insight:** Auth maps perfectly to the 6 dimensions: groups partition auth data, people are the authorized users, sessions are connections, auth actions are events, and all operations use Effect.ts for type-safety.
|
|
12
30
|
|
|
13
31
|
**Architecture:**
|
|
32
|
+
|
|
14
33
|
```
|
|
15
34
|
┌─────────────────────────────────────────────────────────┐
|
|
16
35
|
│ Frontend (Astro + React) │
|
|
@@ -70,6 +89,7 @@ Better Auth is already integrated in our `/frontend` with 6 authentication metho
|
|
|
70
89
|
```
|
|
71
90
|
|
|
72
91
|
**What This Achieves:**
|
|
92
|
+
|
|
73
93
|
- ✅ Organizations → multi-tenant auth (perfect isolation)
|
|
74
94
|
- ✅ People → users with roles (authorization built-in)
|
|
75
95
|
- ✅ Things → optional device tracking
|
|
@@ -129,6 +149,7 @@ Better Auth is already integrated in our `/frontend` with 6 authentication metho
|
|
|
129
149
|
```
|
|
130
150
|
|
|
131
151
|
**Benefits:**
|
|
152
|
+
|
|
132
153
|
- ✅ Perfect multi-tenant isolation → users in Org A can't see Org B
|
|
133
154
|
- ✅ Per-org auth settings → different signup rules per org
|
|
134
155
|
- ✅ Per-org quotas → user limits, rate limits
|
|
@@ -192,6 +213,7 @@ Better Auth is already integrated in our `/frontend` with 6 authentication metho
|
|
|
192
213
|
- **Things** → Created/deleted within org context
|
|
193
214
|
|
|
194
215
|
**Benefits:**
|
|
216
|
+
|
|
195
217
|
- ✅ People are first-class dimension → clear authorization model
|
|
196
218
|
- ✅ Role-based access → platform_owner can access all orgs
|
|
197
219
|
- ✅ Multi-org membership → same person, multiple organizations
|
|
@@ -223,6 +245,7 @@ Better Auth is already integrated in our `/frontend` with 6 authentication metho
|
|
|
223
245
|
```
|
|
224
246
|
|
|
225
247
|
**Benefits:**
|
|
248
|
+
|
|
226
249
|
- ✅ Track which devices user is logged in from
|
|
227
250
|
- ✅ Security: Detect suspicious login locations
|
|
228
251
|
- ✅ UX: "Sign out from all devices except this one"
|
|
@@ -255,6 +278,7 @@ Better Auth is already integrated in our `/frontend` with 6 authentication metho
|
|
|
255
278
|
```
|
|
256
279
|
|
|
257
280
|
**Benefits:**
|
|
281
|
+
|
|
258
282
|
- ✅ Sessions connect people to devices → clear actor model
|
|
259
283
|
- ✅ Automatic cleanup → delete expired connections
|
|
260
284
|
- ✅ Real-time sync → revoke session = instant logout everywhere
|
|
@@ -288,6 +312,7 @@ Better Auth is already integrated in our `/frontend` with 6 authentication metho
|
|
|
288
312
|
```
|
|
289
313
|
|
|
290
314
|
**Benefits:**
|
|
315
|
+
|
|
291
316
|
- ✅ OAuth accounts connect people to OAuth providers
|
|
292
317
|
- ✅ Multiple providers → person can have Google + GitHub + Apple
|
|
293
318
|
- ✅ Token refresh → update connection metadata
|
|
@@ -295,6 +320,7 @@ Better Auth is already integrated in our `/frontend` with 6 authentication metho
|
|
|
295
320
|
|
|
296
321
|
**Note on Schema Design:**
|
|
297
322
|
The connection schema may need to support both:
|
|
323
|
+
|
|
298
324
|
- `fromPersonId: Id<'people'>` for people → thing connections
|
|
299
325
|
- `fromThingId: Id<'things'>` for thing → thing connections
|
|
300
326
|
|
|
@@ -359,6 +385,7 @@ Or use a union type with discriminator for flexibility.
|
|
|
359
385
|
```
|
|
360
386
|
|
|
361
387
|
**Benefits:**
|
|
388
|
+
|
|
362
389
|
- ✅ Complete audit trail → every auth action logged with actorId
|
|
363
390
|
- ✅ Security analytics → detect suspicious patterns (impossible travel, brute force)
|
|
364
391
|
- ✅ User timeline → see complete login history
|
|
@@ -405,6 +432,7 @@ Or use a union type with discriminator for flexibility.
|
|
|
405
432
|
```
|
|
406
433
|
|
|
407
434
|
**Benefits:**
|
|
435
|
+
|
|
408
436
|
- ✅ AI learns normal auth patterns per user/org
|
|
409
437
|
- ✅ Detect anomalies: "User always logs in from NYC, now trying from Russia"
|
|
410
438
|
- ✅ Behavioral analysis: "User logs in Mon-Fri 9am-5pm, now 3am Sunday is suspicious"
|
|
@@ -414,6 +442,7 @@ Or use a union type with discriminator for flexibility.
|
|
|
414
442
|
**Example Use Cases:**
|
|
415
443
|
|
|
416
444
|
1. **Security Anomaly Detection:**
|
|
445
|
+
|
|
417
446
|
```typescript
|
|
418
447
|
// Query knowledge for similar auth patterns
|
|
419
448
|
const similarPatterns = await queryKnowledge({
|
|
@@ -421,27 +450,28 @@ Or use a union type with discriminator for flexibility.
|
|
|
421
450
|
query: "user login from new location",
|
|
422
451
|
filters: {
|
|
423
452
|
behaviorType: "suspicious",
|
|
424
|
-
labels: ["security:anomaly"]
|
|
453
|
+
labels: ["security:anomaly"],
|
|
425
454
|
},
|
|
426
|
-
k: 5
|
|
427
|
-
})
|
|
455
|
+
k: 5,
|
|
456
|
+
});
|
|
428
457
|
|
|
429
458
|
// If similar patterns were flagged before → increase risk score
|
|
430
459
|
if (similarPatterns.length > 3) {
|
|
431
|
-
riskScore += 30
|
|
460
|
+
riskScore += 30;
|
|
432
461
|
}
|
|
433
462
|
```
|
|
434
463
|
|
|
435
464
|
2. **Person Preference Learning:**
|
|
465
|
+
|
|
436
466
|
```typescript
|
|
437
467
|
// AI learns: "This person prefers Google OAuth, dislikes email/password"
|
|
438
468
|
const personPreferences = await queryKnowledge({
|
|
439
469
|
sourcePersonId: personId,
|
|
440
|
-
labels: ["auth:preference"]
|
|
441
|
-
})
|
|
470
|
+
labels: ["auth:preference"],
|
|
471
|
+
});
|
|
442
472
|
|
|
443
473
|
// Suggest preferred auth method in UI
|
|
444
|
-
suggestedMethod = personPreferences[0]?.chunk.preferredMethod || "email"
|
|
474
|
+
suggestedMethod = personPreferences[0]?.chunk.preferredMethod || "email";
|
|
445
475
|
```
|
|
446
476
|
|
|
447
477
|
3. **Compliance & Audit:**
|
|
@@ -451,8 +481,8 @@ Or use a union type with discriminator for flexibility.
|
|
|
451
481
|
organizationId,
|
|
452
482
|
query: "admin login from outside US",
|
|
453
483
|
labels: ["compliance:geographic_restriction"],
|
|
454
|
-
timeRange: { start: lastQuarter, end: now }
|
|
455
|
-
})
|
|
484
|
+
timeRange: { start: lastQuarter, end: now },
|
|
485
|
+
});
|
|
456
486
|
```
|
|
457
487
|
|
|
458
488
|
---
|
|
@@ -509,6 +539,7 @@ Or use a union type with discriminator for flexibility.
|
|
|
509
539
|
- 2FA required ⚠️
|
|
510
540
|
|
|
511
541
|
**Benefits of 6 Dimensions:**
|
|
542
|
+
|
|
512
543
|
- ✅ Perfect multi-tenant isolation (organizations)
|
|
513
544
|
- ✅ Clear authorization model (people with roles, NOT things)
|
|
514
545
|
- ✅ Device tracking (things)
|
|
@@ -526,347 +557,344 @@ Or use a union type with discriminator for flexibility.
|
|
|
526
557
|
|
|
527
558
|
```typescript
|
|
528
559
|
// frontend/src/services/AuthService.ts
|
|
529
|
-
import { Effect, Context } from
|
|
530
|
-
import { DataProvider, ThingNotFoundError } from
|
|
560
|
+
import { Effect, Context } from "effect";
|
|
561
|
+
import { DataProvider, ThingNotFoundError } from "@/providers/DataProvider";
|
|
531
562
|
|
|
532
563
|
// Auth-specific errors
|
|
533
564
|
export class AuthenticationError {
|
|
534
|
-
readonly _tag =
|
|
565
|
+
readonly _tag = "AuthenticationError";
|
|
535
566
|
constructor(readonly reason: string) {}
|
|
536
567
|
}
|
|
537
568
|
|
|
538
569
|
export class InvalidCredentialsError {
|
|
539
|
-
readonly _tag =
|
|
570
|
+
readonly _tag = "InvalidCredentialsError";
|
|
540
571
|
}
|
|
541
572
|
|
|
542
573
|
export class EmailAlreadyExistsError {
|
|
543
|
-
readonly _tag =
|
|
574
|
+
readonly _tag = "EmailAlreadyExistsError";
|
|
544
575
|
constructor(readonly email: string) {}
|
|
545
576
|
}
|
|
546
577
|
|
|
547
578
|
// User type (thing with type: "person")
|
|
548
579
|
export interface User {
|
|
549
|
-
id: string
|
|
550
|
-
email: string
|
|
551
|
-
name: string
|
|
552
|
-
emailVerified: boolean
|
|
553
|
-
image?: string
|
|
580
|
+
id: string;
|
|
581
|
+
email: string;
|
|
582
|
+
name: string;
|
|
583
|
+
emailVerified: boolean;
|
|
584
|
+
image?: string;
|
|
554
585
|
}
|
|
555
586
|
|
|
556
587
|
// Session type (connection with type: "session")
|
|
557
588
|
export interface Session {
|
|
558
|
-
id: string
|
|
559
|
-
userId: string
|
|
560
|
-
token: string
|
|
561
|
-
expiresAt: number
|
|
562
|
-
method: "email" | "google" | "github"
|
|
589
|
+
id: string;
|
|
590
|
+
userId: string;
|
|
591
|
+
token: string;
|
|
592
|
+
expiresAt: number;
|
|
593
|
+
method: "email" | "google" | "github";
|
|
563
594
|
}
|
|
564
595
|
|
|
565
596
|
// AuthService interface
|
|
566
597
|
export interface AuthServiceInterface {
|
|
567
598
|
// Sign up → creates thing (type: person) + logs event
|
|
568
599
|
signUp: (params: {
|
|
569
|
-
email: string
|
|
570
|
-
password: string
|
|
571
|
-
name: string
|
|
572
|
-
organizationId?: string
|
|
573
|
-
}) => Effect.Effect<User, EmailAlreadyExistsError | Error
|
|
600
|
+
email: string;
|
|
601
|
+
password: string;
|
|
602
|
+
name: string;
|
|
603
|
+
organizationId?: string;
|
|
604
|
+
}) => Effect.Effect<User, EmailAlreadyExistsError | Error>;
|
|
574
605
|
|
|
575
606
|
// Sign in → creates connection (type: session) + logs event
|
|
576
607
|
signIn: (params: {
|
|
577
|
-
email: string
|
|
578
|
-
password: string
|
|
579
|
-
organizationId?: string
|
|
608
|
+
email: string;
|
|
609
|
+
password: string;
|
|
610
|
+
organizationId?: string;
|
|
580
611
|
}) => Effect.Effect<
|
|
581
612
|
{ user: User; session: Session },
|
|
582
613
|
InvalidCredentialsError | Error
|
|
583
|
-
|
|
614
|
+
>;
|
|
584
615
|
|
|
585
616
|
// OAuth sign in → creates thing + connection (oauth_account) + connection (session)
|
|
586
617
|
signInWithOAuth: (params: {
|
|
587
|
-
provider: "google" | "github" | "apple"
|
|
588
|
-
code: string
|
|
589
|
-
organizationId?: string
|
|
618
|
+
provider: "google" | "github" | "apple";
|
|
619
|
+
code: string;
|
|
620
|
+
organizationId?: string;
|
|
590
621
|
}) => Effect.Effect<
|
|
591
622
|
{ user: User; session: Session },
|
|
592
623
|
AuthenticationError | Error
|
|
593
|
-
|
|
624
|
+
>;
|
|
594
625
|
|
|
595
626
|
// Sign out → deletes connection (session) + logs event
|
|
596
|
-
signOut: (sessionToken: string) => Effect.Effect<void, Error
|
|
627
|
+
signOut: (sessionToken: string) => Effect.Effect<void, Error>;
|
|
597
628
|
|
|
598
629
|
// Get current session → queries connection (type: session)
|
|
599
|
-
getSession: (
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
>
|
|
630
|
+
getSession: (
|
|
631
|
+
sessionToken: string,
|
|
632
|
+
) => Effect.Effect<{ user: User; session: Session } | null, Error>;
|
|
603
633
|
|
|
604
634
|
// Verify email → updates thing properties.emailVerified + logs event
|
|
605
|
-
verifyEmail: (token: string) => Effect.Effect<void, Error
|
|
635
|
+
verifyEmail: (token: string) => Effect.Effect<void, Error>;
|
|
606
636
|
|
|
607
637
|
// Reset password → creates event (verification_token) → updates thing password
|
|
608
|
-
requestPasswordReset: (email: string) => Effect.Effect<void, Error
|
|
638
|
+
requestPasswordReset: (email: string) => Effect.Effect<void, Error>;
|
|
609
639
|
resetPassword: (params: {
|
|
610
|
-
token: string
|
|
611
|
-
newPassword: string
|
|
612
|
-
}) => Effect.Effect<void, Error
|
|
640
|
+
token: string;
|
|
641
|
+
newPassword: string;
|
|
642
|
+
}) => Effect.Effect<void, Error>;
|
|
613
643
|
}
|
|
614
644
|
|
|
615
645
|
// AuthService implementation (backend-agnostic via DataProvider)
|
|
616
|
-
export class AuthService extends Effect.Service<AuthService>()(
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
type: 'person',
|
|
629
|
-
organizationId: params.organizationId,
|
|
630
|
-
filters: { 'properties.email': params.email }
|
|
631
|
-
}).pipe(
|
|
632
|
-
Effect.catchAll(() => Effect.succeed([]))
|
|
633
|
-
)
|
|
634
|
-
|
|
635
|
-
if (existing.length > 0) {
|
|
636
|
-
return yield* Effect.fail(
|
|
637
|
-
new EmailAlreadyExistsError(params.email)
|
|
638
|
-
)
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
// 2. Hash password (use bcrypt in real app)
|
|
642
|
-
const hashedPassword = yield* hashPassword(params.password)
|
|
643
|
-
|
|
644
|
-
// 3. Create user thing
|
|
645
|
-
const userId = yield* provider.things.create({
|
|
646
|
-
type: 'person',
|
|
647
|
-
name: params.name,
|
|
646
|
+
export class AuthService extends Effect.Service<AuthService>()("AuthService", {
|
|
647
|
+
effect: Effect.gen(function* () {
|
|
648
|
+
const provider = yield* DataProvider;
|
|
649
|
+
|
|
650
|
+
return {
|
|
651
|
+
// Sign up: create user thing + log event
|
|
652
|
+
signUp: (params) =>
|
|
653
|
+
Effect.gen(function* () {
|
|
654
|
+
// 1. Check if email exists
|
|
655
|
+
const existing = yield* provider.things
|
|
656
|
+
.list({
|
|
657
|
+
type: "person",
|
|
648
658
|
organizationId: params.organizationId,
|
|
649
|
-
properties:
|
|
650
|
-
email: params.email,
|
|
651
|
-
emailVerified: false,
|
|
652
|
-
password: hashedPassword
|
|
653
|
-
}
|
|
654
|
-
})
|
|
655
|
-
|
|
656
|
-
// 4. Log sign_up event
|
|
657
|
-
yield* provider.events.log({
|
|
658
|
-
type: 'sign_up',
|
|
659
|
-
actorId: userId,
|
|
660
|
-
organizationId: params.organizationId,
|
|
661
|
-
metadata: {
|
|
662
|
-
method: 'email',
|
|
663
|
-
success: true
|
|
664
|
-
}
|
|
659
|
+
filters: { "properties.email": params.email },
|
|
665
660
|
})
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
661
|
+
.pipe(Effect.catchAll(() => Effect.succeed([])));
|
|
662
|
+
|
|
663
|
+
if (existing.length > 0) {
|
|
664
|
+
return yield* Effect.fail(
|
|
665
|
+
new EmailAlreadyExistsError(params.email),
|
|
666
|
+
);
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
// 2. Hash password (use bcrypt in real app)
|
|
670
|
+
const hashedPassword = yield* hashPassword(params.password);
|
|
671
|
+
|
|
672
|
+
// 3. Create user thing
|
|
673
|
+
const userId = yield* provider.things.create({
|
|
674
|
+
type: "person",
|
|
675
|
+
name: params.name,
|
|
676
|
+
organizationId: params.organizationId,
|
|
677
|
+
properties: {
|
|
670
678
|
email: params.email,
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
}
|
|
674
|
-
})
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
toThingId: null, // No device tracking yet
|
|
721
|
-
relationshipType: 'session',
|
|
722
|
-
organizationId: params.organizationId,
|
|
723
|
-
metadata: {
|
|
724
|
-
token,
|
|
725
|
-
expiresAt: Date.now() + (7 * 24 * 60 * 60 * 1000), // 7 days
|
|
726
|
-
method: 'email'
|
|
727
|
-
}
|
|
728
|
-
})
|
|
729
|
-
|
|
730
|
-
// 5. Log successful sign_in event
|
|
679
|
+
emailVerified: false,
|
|
680
|
+
password: hashedPassword,
|
|
681
|
+
},
|
|
682
|
+
});
|
|
683
|
+
|
|
684
|
+
// 4. Log sign_up event
|
|
685
|
+
yield* provider.events.log({
|
|
686
|
+
type: "sign_up",
|
|
687
|
+
actorId: userId,
|
|
688
|
+
organizationId: params.organizationId,
|
|
689
|
+
metadata: {
|
|
690
|
+
method: "email",
|
|
691
|
+
success: true,
|
|
692
|
+
},
|
|
693
|
+
});
|
|
694
|
+
|
|
695
|
+
// 5. Return user
|
|
696
|
+
return {
|
|
697
|
+
id: userId,
|
|
698
|
+
email: params.email,
|
|
699
|
+
name: params.name,
|
|
700
|
+
emailVerified: false,
|
|
701
|
+
};
|
|
702
|
+
}),
|
|
703
|
+
|
|
704
|
+
// Sign in: verify credentials + create session connection
|
|
705
|
+
signIn: (params) =>
|
|
706
|
+
Effect.gen(function* () {
|
|
707
|
+
// 1. Find user by email
|
|
708
|
+
const users = yield* provider.things.list({
|
|
709
|
+
type: "person",
|
|
710
|
+
organizationId: params.organizationId,
|
|
711
|
+
filters: { "properties.email": params.email },
|
|
712
|
+
});
|
|
713
|
+
|
|
714
|
+
if (users.length === 0) {
|
|
715
|
+
return yield* Effect.fail(new InvalidCredentialsError());
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
const user = users[0];
|
|
719
|
+
|
|
720
|
+
// 2. Verify password
|
|
721
|
+
const valid = yield* verifyPassword(
|
|
722
|
+
params.password,
|
|
723
|
+
user.properties.password,
|
|
724
|
+
);
|
|
725
|
+
|
|
726
|
+
if (!valid) {
|
|
727
|
+
// Log failed attempt
|
|
731
728
|
yield* provider.events.log({
|
|
732
|
-
type:
|
|
729
|
+
type: "sign_in",
|
|
733
730
|
actorId: user._id,
|
|
734
|
-
targetId: sessionId,
|
|
735
731
|
organizationId: params.organizationId,
|
|
736
732
|
metadata: {
|
|
737
|
-
method:
|
|
738
|
-
success:
|
|
739
|
-
|
|
740
|
-
})
|
|
741
|
-
|
|
742
|
-
return {
|
|
743
|
-
user: {
|
|
744
|
-
id: user._id,
|
|
745
|
-
email: user.properties.email,
|
|
746
|
-
name: user.name,
|
|
747
|
-
emailVerified: user.properties.emailVerified,
|
|
748
|
-
image: user.properties.image
|
|
733
|
+
method: "email",
|
|
734
|
+
success: false,
|
|
735
|
+
errorReason: "invalid_credentials",
|
|
749
736
|
},
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
737
|
+
});
|
|
738
|
+
|
|
739
|
+
return yield* Effect.fail(new InvalidCredentialsError());
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
// 3. Generate session token
|
|
743
|
+
const token = yield* generateSecureToken();
|
|
744
|
+
|
|
745
|
+
// 4. Create session connection
|
|
746
|
+
const sessionId = yield* provider.connections.create({
|
|
747
|
+
fromThingId: user._id,
|
|
748
|
+
toThingId: null, // No device tracking yet
|
|
749
|
+
relationshipType: "session",
|
|
750
|
+
organizationId: params.organizationId,
|
|
751
|
+
metadata: {
|
|
752
|
+
token,
|
|
753
|
+
expiresAt: Date.now() + 7 * 24 * 60 * 60 * 1000, // 7 days
|
|
754
|
+
method: "email",
|
|
755
|
+
},
|
|
756
|
+
});
|
|
757
|
+
|
|
758
|
+
// 5. Log successful sign_in event
|
|
759
|
+
yield* provider.events.log({
|
|
760
|
+
type: "sign_in",
|
|
761
|
+
actorId: user._id,
|
|
762
|
+
targetId: sessionId,
|
|
763
|
+
organizationId: params.organizationId,
|
|
764
|
+
metadata: {
|
|
765
|
+
method: "email",
|
|
766
|
+
success: true,
|
|
767
|
+
},
|
|
768
|
+
});
|
|
769
|
+
|
|
770
|
+
return {
|
|
771
|
+
user: {
|
|
772
|
+
id: user._id,
|
|
773
|
+
email: user.properties.email,
|
|
774
|
+
name: user.name,
|
|
775
|
+
emailVerified: user.properties.emailVerified,
|
|
776
|
+
image: user.properties.image,
|
|
777
|
+
},
|
|
778
|
+
session: {
|
|
779
|
+
id: sessionId,
|
|
780
|
+
userId: user._id,
|
|
781
|
+
token,
|
|
782
|
+
expiresAt: Date.now() + 7 * 24 * 60 * 60 * 1000,
|
|
783
|
+
method: "email",
|
|
784
|
+
},
|
|
785
|
+
};
|
|
786
|
+
}),
|
|
787
|
+
|
|
788
|
+
// Sign out: delete session connection + log event
|
|
789
|
+
signOut: (sessionToken) =>
|
|
790
|
+
Effect.gen(function* () {
|
|
791
|
+
// 1. Find session connection by token
|
|
792
|
+
const sessions = yield* provider.connections.list({
|
|
793
|
+
relationshipType: "session",
|
|
794
|
+
filters: { "metadata.token": sessionToken },
|
|
795
|
+
});
|
|
796
|
+
|
|
797
|
+
if (sessions.length === 0) {
|
|
798
|
+
return; // Session already gone
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
const session = sessions[0];
|
|
802
|
+
|
|
803
|
+
// 2. Delete session connection
|
|
804
|
+
yield* provider.connections.delete(session._id);
|
|
805
|
+
|
|
806
|
+
// 3. Log sign_out event
|
|
807
|
+
yield* provider.events.log({
|
|
808
|
+
type: "sign_out",
|
|
809
|
+
actorId: session.fromThingId,
|
|
810
|
+
targetId: session._id,
|
|
811
|
+
metadata: {
|
|
812
|
+
method: session.metadata.method,
|
|
813
|
+
success: true,
|
|
814
|
+
},
|
|
815
|
+
});
|
|
816
|
+
}),
|
|
817
|
+
|
|
818
|
+
// Get session: query active session connection
|
|
819
|
+
getSession: (sessionToken) =>
|
|
820
|
+
Effect.gen(function* () {
|
|
821
|
+
// 1. Find session connection by token
|
|
822
|
+
const sessions = yield* provider.connections
|
|
823
|
+
.list({
|
|
824
|
+
relationshipType: "session",
|
|
825
|
+
filters: { "metadata.token": sessionToken },
|
|
787
826
|
})
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
)
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
method: session.metadata.method
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
}),
|
|
834
|
-
|
|
835
|
-
// Additional methods: verifyEmail, requestPasswordReset, etc.
|
|
836
|
-
// ... (similar pattern using provider.things, provider.events)
|
|
837
|
-
}
|
|
838
|
-
}),
|
|
839
|
-
dependencies: [DataProvider]
|
|
840
|
-
}
|
|
841
|
-
) {}
|
|
827
|
+
.pipe(Effect.catchAll(() => Effect.succeed([])));
|
|
828
|
+
|
|
829
|
+
if (sessions.length === 0) {
|
|
830
|
+
return null;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
const session = sessions[0];
|
|
834
|
+
|
|
835
|
+
// 2. Check expiration
|
|
836
|
+
if (session.metadata.expiresAt < Date.now()) {
|
|
837
|
+
// Session expired - delete it
|
|
838
|
+
yield* provider.connections.delete(session._id);
|
|
839
|
+
return null;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
// 3. Get user thing
|
|
843
|
+
const user = yield* provider.things.get(session.fromThingId);
|
|
844
|
+
|
|
845
|
+
return {
|
|
846
|
+
user: {
|
|
847
|
+
id: user._id,
|
|
848
|
+
email: user.properties.email,
|
|
849
|
+
name: user.name,
|
|
850
|
+
emailVerified: user.properties.emailVerified,
|
|
851
|
+
image: user.properties.image,
|
|
852
|
+
},
|
|
853
|
+
session: {
|
|
854
|
+
id: session._id,
|
|
855
|
+
userId: user._id,
|
|
856
|
+
token: session.metadata.token,
|
|
857
|
+
expiresAt: session.metadata.expiresAt,
|
|
858
|
+
method: session.metadata.method,
|
|
859
|
+
},
|
|
860
|
+
};
|
|
861
|
+
}),
|
|
862
|
+
|
|
863
|
+
// Additional methods: verifyEmail, requestPasswordReset, etc.
|
|
864
|
+
// ... (similar pattern using provider.things, provider.events)
|
|
865
|
+
};
|
|
866
|
+
}),
|
|
867
|
+
dependencies: [DataProvider],
|
|
868
|
+
}) {}
|
|
842
869
|
|
|
843
870
|
// Helper functions (use crypto libraries in production)
|
|
844
871
|
const hashPassword = (password: string) =>
|
|
845
872
|
Effect.tryPromise({
|
|
846
873
|
try: async () => {
|
|
847
874
|
// Use bcrypt or argon2 in production
|
|
848
|
-
return `hashed_${password}
|
|
875
|
+
return `hashed_${password}`;
|
|
849
876
|
},
|
|
850
|
-
catch: (error) => new Error(String(error))
|
|
851
|
-
})
|
|
877
|
+
catch: (error) => new Error(String(error)),
|
|
878
|
+
});
|
|
852
879
|
|
|
853
880
|
const verifyPassword = (password: string, hash: string) =>
|
|
854
881
|
Effect.tryPromise({
|
|
855
882
|
try: async () => {
|
|
856
883
|
// Use bcrypt.compare or argon2.verify in production
|
|
857
|
-
return hash === `hashed_${password}
|
|
884
|
+
return hash === `hashed_${password}`;
|
|
858
885
|
},
|
|
859
|
-
catch: (error) => new Error(String(error))
|
|
860
|
-
})
|
|
886
|
+
catch: (error) => new Error(String(error)),
|
|
887
|
+
});
|
|
861
888
|
|
|
862
889
|
const generateSecureToken = () =>
|
|
863
890
|
Effect.sync(() => {
|
|
864
891
|
// Use crypto.randomBytes in production
|
|
865
|
-
return Math.random().toString(36).substring(2, 15)
|
|
866
|
-
})
|
|
892
|
+
return Math.random().toString(36).substring(2, 15);
|
|
893
|
+
});
|
|
867
894
|
```
|
|
868
895
|
|
|
869
896
|
**Key Points:**
|
|
897
|
+
|
|
870
898
|
- ✅ Uses `DataProvider` → backend-agnostic (works with Convex, Supabase, WordPress)
|
|
871
899
|
- ✅ All operations wrapped in `Effect.gen` → type-safe, composable
|
|
872
900
|
- ✅ Users stored as things (type: person)
|
|
@@ -884,35 +912,43 @@ const generateSecureToken = () =>
|
|
|
884
912
|
// frontend/src/providers/DataProvider.ts
|
|
885
913
|
export interface DataProvider {
|
|
886
914
|
things: {
|
|
887
|
-
get: (id: string) => Effect.Effect<Thing, ThingNotFoundError
|
|
888
|
-
list: (params: {
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
915
|
+
get: (id: string) => Effect.Effect<Thing, ThingNotFoundError>;
|
|
916
|
+
list: (params: {
|
|
917
|
+
type: ThingType;
|
|
918
|
+
organizationId?: string;
|
|
919
|
+
filters?: any;
|
|
920
|
+
}) => Effect.Effect<Thing[], Error>;
|
|
921
|
+
create: (input: {
|
|
922
|
+
type: ThingType;
|
|
923
|
+
name: string;
|
|
924
|
+
properties: any;
|
|
925
|
+
}) => Effect.Effect<string, Error>;
|
|
926
|
+
update: (id: string, updates: Partial<Thing>) => Effect.Effect<void, Error>;
|
|
927
|
+
delete: (id: string) => Effect.Effect<void, Error>;
|
|
928
|
+
};
|
|
895
929
|
|
|
896
930
|
connections: {
|
|
897
931
|
create: (input: {
|
|
898
|
-
fromThingId: string
|
|
899
|
-
toThingId: string | null
|
|
900
|
-
relationshipType: ConnectionType
|
|
901
|
-
metadata?: any
|
|
902
|
-
}) => Effect.Effect<string, Error
|
|
903
|
-
list: (params: {
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
932
|
+
fromThingId: string;
|
|
933
|
+
toThingId: string | null;
|
|
934
|
+
relationshipType: ConnectionType;
|
|
935
|
+
metadata?: any;
|
|
936
|
+
}) => Effect.Effect<string, Error>;
|
|
937
|
+
list: (params: {
|
|
938
|
+
relationshipType: ConnectionType;
|
|
939
|
+
filters?: any;
|
|
940
|
+
}) => Effect.Effect<Connection[], Error>;
|
|
941
|
+
delete: (id: string) => Effect.Effect<void, Error>;
|
|
942
|
+
};
|
|
907
943
|
|
|
908
944
|
events: {
|
|
909
945
|
log: (event: {
|
|
910
|
-
type: EventType
|
|
911
|
-
actorId: string
|
|
912
|
-
targetId?: string
|
|
913
|
-
metadata?: any
|
|
914
|
-
}) => Effect.Effect<void, Error
|
|
915
|
-
}
|
|
946
|
+
type: EventType;
|
|
947
|
+
actorId: string;
|
|
948
|
+
targetId?: string;
|
|
949
|
+
metadata?: any;
|
|
950
|
+
}) => Effect.Effect<void, Error>;
|
|
951
|
+
};
|
|
916
952
|
}
|
|
917
953
|
```
|
|
918
954
|
|
|
@@ -922,10 +958,10 @@ export interface DataProvider {
|
|
|
922
958
|
|
|
923
959
|
```typescript
|
|
924
960
|
// frontend/src/providers/convex/ConvexProvider.ts
|
|
925
|
-
import { Effect, Layer } from
|
|
926
|
-
import { ConvexHttpClient } from
|
|
927
|
-
import { DataProvider } from
|
|
928
|
-
import { api } from
|
|
961
|
+
import { Effect, Layer } from "effect";
|
|
962
|
+
import { ConvexHttpClient } from "convex/browser";
|
|
963
|
+
import { DataProvider } from "../DataProvider";
|
|
964
|
+
import { api } from "./api";
|
|
929
965
|
|
|
930
966
|
export class ConvexProvider implements DataProvider {
|
|
931
967
|
constructor(private client: ConvexHttpClient) {}
|
|
@@ -934,46 +970,47 @@ export class ConvexProvider implements DataProvider {
|
|
|
934
970
|
create: (input) =>
|
|
935
971
|
Effect.tryPromise({
|
|
936
972
|
try: () => this.client.mutation(api.things.create, input),
|
|
937
|
-
catch: (error) => new Error(String(error))
|
|
973
|
+
catch: (error) => new Error(String(error)),
|
|
938
974
|
}),
|
|
939
975
|
|
|
940
976
|
list: (params) =>
|
|
941
977
|
Effect.tryPromise({
|
|
942
978
|
try: () => this.client.query(api.things.list, params),
|
|
943
|
-
catch: (error) => new Error(String(error))
|
|
979
|
+
catch: (error) => new Error(String(error)),
|
|
944
980
|
}),
|
|
945
981
|
|
|
946
982
|
// ... other methods
|
|
947
|
-
}
|
|
983
|
+
};
|
|
948
984
|
|
|
949
985
|
connections = {
|
|
950
986
|
create: (input) =>
|
|
951
987
|
Effect.tryPromise({
|
|
952
988
|
try: () => this.client.mutation(api.connections.create, input),
|
|
953
|
-
catch: (error) => new Error(String(error))
|
|
989
|
+
catch: (error) => new Error(String(error)),
|
|
954
990
|
}),
|
|
955
991
|
|
|
956
992
|
// ... other methods
|
|
957
|
-
}
|
|
993
|
+
};
|
|
958
994
|
|
|
959
995
|
events = {
|
|
960
996
|
log: (event) =>
|
|
961
997
|
Effect.tryPromise({
|
|
962
998
|
try: () => this.client.mutation(api.events.log, event),
|
|
963
|
-
catch: (error) => new Error(String(error))
|
|
964
|
-
})
|
|
965
|
-
}
|
|
999
|
+
catch: (error) => new Error(String(error)),
|
|
1000
|
+
}),
|
|
1001
|
+
};
|
|
966
1002
|
}
|
|
967
1003
|
|
|
968
1004
|
// Factory function
|
|
969
1005
|
export const convexProvider = (config: { url: string }) =>
|
|
970
1006
|
Layer.succeed(
|
|
971
1007
|
DataProvider,
|
|
972
|
-
new ConvexProvider(new ConvexHttpClient(config.url))
|
|
973
|
-
)
|
|
1008
|
+
new ConvexProvider(new ConvexHttpClient(config.url)),
|
|
1009
|
+
);
|
|
974
1010
|
```
|
|
975
1011
|
|
|
976
1012
|
**Result:**
|
|
1013
|
+
|
|
977
1014
|
- AuthService calls `provider.things.create()` → works with Convex
|
|
978
1015
|
- Change to `supabaseProvider()` → works with Supabase
|
|
979
1016
|
- Change to `wordpressProvider()` → works with WordPress
|
|
@@ -989,48 +1026,48 @@ export const convexProvider = (config: { url: string }) =>
|
|
|
989
1026
|
|
|
990
1027
|
```tsx
|
|
991
1028
|
// frontend/src/components/auth/SignUpForm.tsx
|
|
992
|
-
import { useEffectRunner } from
|
|
993
|
-
import { AuthService } from
|
|
994
|
-
import { Effect } from
|
|
995
|
-
import { useState } from
|
|
1029
|
+
import { useEffectRunner } from "@/hooks/useEffectRunner";
|
|
1030
|
+
import { AuthService } from "@/services/AuthService";
|
|
1031
|
+
import { Effect } from "effect";
|
|
1032
|
+
import { useState } from "react";
|
|
996
1033
|
|
|
997
1034
|
export function SignUpForm({ organizationId }: { organizationId: string }) {
|
|
998
|
-
const { run, loading, error } = useEffectRunner()
|
|
1035
|
+
const { run, loading, error } = useEffectRunner();
|
|
999
1036
|
const [formData, setFormData] = useState({
|
|
1000
|
-
email:
|
|
1001
|
-
password:
|
|
1002
|
-
name:
|
|
1003
|
-
})
|
|
1037
|
+
email: "",
|
|
1038
|
+
password: "",
|
|
1039
|
+
name: "",
|
|
1040
|
+
});
|
|
1004
1041
|
|
|
1005
1042
|
const handleSubmit = async (e: React.FormEvent) => {
|
|
1006
|
-
e.preventDefault()
|
|
1043
|
+
e.preventDefault();
|
|
1007
1044
|
|
|
1008
1045
|
// Define Effect program using AuthService
|
|
1009
1046
|
const program = Effect.gen(function* () {
|
|
1010
|
-
const auth = yield* AuthService
|
|
1047
|
+
const auth = yield* AuthService;
|
|
1011
1048
|
|
|
1012
1049
|
// Sign up → creates thing (type: person) + logs event
|
|
1013
1050
|
const user = yield* auth.signUp({
|
|
1014
1051
|
...formData,
|
|
1015
|
-
organizationId
|
|
1016
|
-
})
|
|
1052
|
+
organizationId,
|
|
1053
|
+
});
|
|
1017
1054
|
|
|
1018
|
-
return user
|
|
1055
|
+
return user;
|
|
1019
1056
|
}).pipe(
|
|
1020
1057
|
// Handle specific errors
|
|
1021
|
-
Effect.catchTag(
|
|
1022
|
-
Effect.fail(new Error(`Email ${err.email} is already registered`))
|
|
1023
|
-
)
|
|
1024
|
-
)
|
|
1058
|
+
Effect.catchTag("EmailAlreadyExistsError", (err) =>
|
|
1059
|
+
Effect.fail(new Error(`Email ${err.email} is already registered`)),
|
|
1060
|
+
),
|
|
1061
|
+
);
|
|
1025
1062
|
|
|
1026
1063
|
// Run Effect program
|
|
1027
1064
|
const user = await run(program, {
|
|
1028
1065
|
onSuccess: (user) => {
|
|
1029
1066
|
// Redirect to verify email page
|
|
1030
|
-
window.location.href =
|
|
1031
|
-
}
|
|
1032
|
-
})
|
|
1033
|
-
}
|
|
1067
|
+
window.location.href = "/verify-email";
|
|
1068
|
+
},
|
|
1069
|
+
});
|
|
1070
|
+
};
|
|
1034
1071
|
|
|
1035
1072
|
return (
|
|
1036
1073
|
<form onSubmit={handleSubmit} className="space-y-4">
|
|
@@ -1058,15 +1095,13 @@ export function SignUpForm({ organizationId }: { organizationId: string }) {
|
|
|
1058
1095
|
required
|
|
1059
1096
|
/>
|
|
1060
1097
|
|
|
1061
|
-
{error &&
|
|
1062
|
-
<div className="text-red-600">{error}</div>
|
|
1063
|
-
)}
|
|
1098
|
+
{error && <div className="text-red-600">{error}</div>}
|
|
1064
1099
|
|
|
1065
1100
|
<button type="submit" disabled={loading}>
|
|
1066
|
-
{loading ?
|
|
1101
|
+
{loading ? "Creating account..." : "Sign Up"}
|
|
1067
1102
|
</button>
|
|
1068
1103
|
</form>
|
|
1069
|
-
)
|
|
1104
|
+
);
|
|
1070
1105
|
}
|
|
1071
1106
|
```
|
|
1072
1107
|
|
|
@@ -1074,50 +1109,50 @@ export function SignUpForm({ organizationId }: { organizationId: string }) {
|
|
|
1074
1109
|
|
|
1075
1110
|
```tsx
|
|
1076
1111
|
// frontend/src/components/auth/SignInForm.tsx
|
|
1077
|
-
import { useEffectRunner } from
|
|
1078
|
-
import { AuthService } from
|
|
1079
|
-
import { Effect } from
|
|
1080
|
-
import { useState } from
|
|
1112
|
+
import { useEffectRunner } from "@/hooks/useEffectRunner";
|
|
1113
|
+
import { AuthService } from "@/services/AuthService";
|
|
1114
|
+
import { Effect } from "effect";
|
|
1115
|
+
import { useState } from "react";
|
|
1081
1116
|
|
|
1082
1117
|
export function SignInForm({ organizationId }: { organizationId: string }) {
|
|
1083
|
-
const { run, loading, error } = useEffectRunner()
|
|
1118
|
+
const { run, loading, error } = useEffectRunner();
|
|
1084
1119
|
const [formData, setFormData] = useState({
|
|
1085
|
-
email:
|
|
1086
|
-
password:
|
|
1087
|
-
})
|
|
1120
|
+
email: "",
|
|
1121
|
+
password: "",
|
|
1122
|
+
});
|
|
1088
1123
|
|
|
1089
1124
|
const handleSubmit = async (e: React.FormEvent) => {
|
|
1090
|
-
e.preventDefault()
|
|
1125
|
+
e.preventDefault();
|
|
1091
1126
|
|
|
1092
1127
|
// Define Effect program
|
|
1093
1128
|
const program = Effect.gen(function* () {
|
|
1094
|
-
const auth = yield* AuthService
|
|
1129
|
+
const auth = yield* AuthService;
|
|
1095
1130
|
|
|
1096
1131
|
// Sign in → creates connection (type: session) + logs event
|
|
1097
1132
|
const result = yield* auth.signIn({
|
|
1098
1133
|
...formData,
|
|
1099
|
-
organizationId
|
|
1100
|
-
})
|
|
1134
|
+
organizationId,
|
|
1135
|
+
});
|
|
1101
1136
|
|
|
1102
|
-
return result
|
|
1137
|
+
return result;
|
|
1103
1138
|
}).pipe(
|
|
1104
1139
|
// Handle invalid credentials
|
|
1105
|
-
Effect.catchTag(
|
|
1106
|
-
Effect.fail(new Error(
|
|
1107
|
-
)
|
|
1108
|
-
)
|
|
1140
|
+
Effect.catchTag("InvalidCredentialsError", () =>
|
|
1141
|
+
Effect.fail(new Error("Invalid email or password")),
|
|
1142
|
+
),
|
|
1143
|
+
);
|
|
1109
1144
|
|
|
1110
1145
|
// Run Effect program
|
|
1111
1146
|
await run(program, {
|
|
1112
1147
|
onSuccess: ({ user, session }) => {
|
|
1113
1148
|
// Store session token in cookie/localStorage
|
|
1114
|
-
document.cookie = `session=${session.token}; path=/; max-age=${7 * 24 * 60 * 60}
|
|
1149
|
+
document.cookie = `session=${session.token}; path=/; max-age=${7 * 24 * 60 * 60}`;
|
|
1115
1150
|
|
|
1116
1151
|
// Redirect to dashboard
|
|
1117
|
-
window.location.href =
|
|
1118
|
-
}
|
|
1119
|
-
})
|
|
1120
|
-
}
|
|
1152
|
+
window.location.href = "/dashboard";
|
|
1153
|
+
},
|
|
1154
|
+
});
|
|
1155
|
+
};
|
|
1121
1156
|
|
|
1122
1157
|
return (
|
|
1123
1158
|
<form onSubmit={handleSubmit} className="space-y-4">
|
|
@@ -1137,19 +1172,17 @@ export function SignInForm({ organizationId }: { organizationId: string }) {
|
|
|
1137
1172
|
required
|
|
1138
1173
|
/>
|
|
1139
1174
|
|
|
1140
|
-
{error &&
|
|
1141
|
-
<div className="text-red-600">{error}</div>
|
|
1142
|
-
)}
|
|
1175
|
+
{error && <div className="text-red-600">{error}</div>}
|
|
1143
1176
|
|
|
1144
1177
|
<button type="submit" disabled={loading}>
|
|
1145
|
-
{loading ?
|
|
1178
|
+
{loading ? "Signing in..." : "Sign In"}
|
|
1146
1179
|
</button>
|
|
1147
1180
|
|
|
1148
1181
|
<a href="/forgot-password" className="text-sm text-blue-600">
|
|
1149
1182
|
Forgot password?
|
|
1150
1183
|
</a>
|
|
1151
1184
|
</form>
|
|
1152
|
-
)
|
|
1185
|
+
);
|
|
1153
1186
|
}
|
|
1154
1187
|
```
|
|
1155
1188
|
|
|
@@ -1230,6 +1263,7 @@ try {
|
|
|
1230
1263
|
```
|
|
1231
1264
|
|
|
1232
1265
|
**Key Points:**
|
|
1266
|
+
|
|
1233
1267
|
- ✅ Components use `useEffectRunner` hook
|
|
1234
1268
|
- ✅ All auth operations wrapped in `Effect.gen`
|
|
1235
1269
|
- ✅ Typed error handling with `catchTag`
|
|
@@ -1246,19 +1280,19 @@ try {
|
|
|
1246
1280
|
|
|
1247
1281
|
```typescript
|
|
1248
1282
|
// backend/convex/schema.ts
|
|
1249
|
-
import { defineSchema, defineTable } from "convex/server"
|
|
1250
|
-
import { v } from "convex/values"
|
|
1283
|
+
import { defineSchema, defineTable } from "convex/server";
|
|
1284
|
+
import { v } from "convex/values";
|
|
1251
1285
|
|
|
1252
1286
|
export default defineSchema({
|
|
1253
1287
|
// Users = things with type: "person"
|
|
1254
1288
|
things: defineTable({
|
|
1255
|
-
type: v.string(),
|
|
1289
|
+
type: v.string(), // "person", "course", "product", etc.
|
|
1256
1290
|
name: v.string(),
|
|
1257
1291
|
organizationId: v.string(),
|
|
1258
1292
|
status: v.string(),
|
|
1259
|
-
properties: v.any(),
|
|
1293
|
+
properties: v.any(), // { email, emailVerified, password, ... }
|
|
1260
1294
|
createdAt: v.number(),
|
|
1261
|
-
updatedAt: v.number()
|
|
1295
|
+
updatedAt: v.number(),
|
|
1262
1296
|
})
|
|
1263
1297
|
.index("by_type", ["type"])
|
|
1264
1298
|
.index("by_organization", ["organizationId"])
|
|
@@ -1266,14 +1300,14 @@ export default defineSchema({
|
|
|
1266
1300
|
|
|
1267
1301
|
// Sessions = connections with relationshipType: "session"
|
|
1268
1302
|
connections: defineTable({
|
|
1269
|
-
fromThingId: v.string(),
|
|
1270
|
-
toThingId: v.union(v.string(), v.null()),
|
|
1271
|
-
relationshipType: v.string(),
|
|
1303
|
+
fromThingId: v.string(), // User ID
|
|
1304
|
+
toThingId: v.union(v.string(), v.null()), // Device ID (optional)
|
|
1305
|
+
relationshipType: v.string(), // "session", "oauth_account", etc.
|
|
1272
1306
|
organizationId: v.string(),
|
|
1273
1307
|
status: v.string(),
|
|
1274
|
-
metadata: v.any(),
|
|
1308
|
+
metadata: v.any(), // { token, expiresAt, method, ... }
|
|
1275
1309
|
createdAt: v.number(),
|
|
1276
|
-
updatedAt: v.number()
|
|
1310
|
+
updatedAt: v.number(),
|
|
1277
1311
|
})
|
|
1278
1312
|
.index("by_type", ["relationshipType"])
|
|
1279
1313
|
.index("by_from", ["fromThingId"])
|
|
@@ -1281,18 +1315,18 @@ export default defineSchema({
|
|
|
1281
1315
|
|
|
1282
1316
|
// Auth events = events with type: "sign_up", "sign_in", etc.
|
|
1283
1317
|
events: defineTable({
|
|
1284
|
-
type: v.string(),
|
|
1318
|
+
type: v.string(), // "sign_up", "sign_in", "sign_out", etc.
|
|
1285
1319
|
actorId: v.string(),
|
|
1286
1320
|
targetId: v.optional(v.string()),
|
|
1287
1321
|
organizationId: v.string(),
|
|
1288
1322
|
metadata: v.any(),
|
|
1289
1323
|
timestamp: v.number(),
|
|
1290
|
-
createdAt: v.number()
|
|
1324
|
+
createdAt: v.number(),
|
|
1291
1325
|
})
|
|
1292
1326
|
.index("by_type", ["type"])
|
|
1293
1327
|
.index("by_actor", ["actorId"])
|
|
1294
|
-
.index("by_timestamp", ["timestamp"])
|
|
1295
|
-
})
|
|
1328
|
+
.index("by_timestamp", ["timestamp"]),
|
|
1329
|
+
});
|
|
1296
1330
|
```
|
|
1297
1331
|
|
|
1298
1332
|
**Result:** Users, sessions, OAuth accounts all stored in the ontology!
|
|
@@ -1359,43 +1393,43 @@ CREATE INDEX idx_events_actor ON events("actorId");
|
|
|
1359
1393
|
|
|
1360
1394
|
```typescript
|
|
1361
1395
|
// frontend/src/middleware.ts
|
|
1362
|
-
import { defineMiddleware } from
|
|
1363
|
-
import { AuthService } from
|
|
1364
|
-
import { Effect } from
|
|
1365
|
-
import { ClientLayer } from
|
|
1396
|
+
import { defineMiddleware } from "astro:middleware";
|
|
1397
|
+
import { AuthService } from "@/services/AuthService";
|
|
1398
|
+
import { Effect } from "effect";
|
|
1399
|
+
import { ClientLayer } from "@/services/ClientLayer";
|
|
1366
1400
|
|
|
1367
1401
|
export const onRequest = defineMiddleware(async (context, next) => {
|
|
1368
1402
|
// Get session token from cookie
|
|
1369
|
-
const sessionToken = context.cookies.get(
|
|
1403
|
+
const sessionToken = context.cookies.get("session")?.value;
|
|
1370
1404
|
|
|
1371
1405
|
if (!sessionToken) {
|
|
1372
|
-
context.locals.user = null
|
|
1373
|
-
context.locals.session = null
|
|
1374
|
-
return next()
|
|
1406
|
+
context.locals.user = null;
|
|
1407
|
+
context.locals.session = null;
|
|
1408
|
+
return next();
|
|
1375
1409
|
}
|
|
1376
1410
|
|
|
1377
1411
|
// Verify session using AuthService
|
|
1378
1412
|
const program = Effect.gen(function* () {
|
|
1379
|
-
const auth = yield* AuthService
|
|
1380
|
-
return yield* auth.getSession(sessionToken)
|
|
1381
|
-
})
|
|
1413
|
+
const auth = yield* AuthService;
|
|
1414
|
+
return yield* auth.getSession(sessionToken);
|
|
1415
|
+
});
|
|
1382
1416
|
|
|
1383
1417
|
try {
|
|
1384
1418
|
const result = await Effect.runPromise(
|
|
1385
|
-
program.pipe(Effect.provide(ClientLayer))
|
|
1386
|
-
)
|
|
1419
|
+
program.pipe(Effect.provide(ClientLayer)),
|
|
1420
|
+
);
|
|
1387
1421
|
|
|
1388
1422
|
if (result) {
|
|
1389
|
-
context.locals.user = result.user
|
|
1390
|
-
context.locals.session = result.session
|
|
1423
|
+
context.locals.user = result.user;
|
|
1424
|
+
context.locals.session = result.session;
|
|
1391
1425
|
}
|
|
1392
1426
|
} catch (error) {
|
|
1393
1427
|
// Session invalid - clear cookie
|
|
1394
|
-
context.cookies.delete(
|
|
1428
|
+
context.cookies.delete("session");
|
|
1395
1429
|
}
|
|
1396
1430
|
|
|
1397
|
-
return next()
|
|
1398
|
-
})
|
|
1431
|
+
return next();
|
|
1432
|
+
});
|
|
1399
1433
|
```
|
|
1400
1434
|
|
|
1401
1435
|
### Protected Routes
|
|
@@ -1417,6 +1451,7 @@ if (!user) {
|
|
|
1417
1451
|
```
|
|
1418
1452
|
|
|
1419
1453
|
**Session Benefits:**
|
|
1454
|
+
|
|
1420
1455
|
- ✅ Stored as connections → query active sessions
|
|
1421
1456
|
- ✅ Automatic expiration → status="expired" when expiresAt passed
|
|
1422
1457
|
- ✅ Real-time revocation → delete connection = logged out everywhere
|
|
@@ -1452,6 +1487,7 @@ if (!org) {
|
|
|
1452
1487
|
```
|
|
1453
1488
|
|
|
1454
1489
|
**How It Works:**
|
|
1490
|
+
|
|
1455
1491
|
1. User visits `fitnesspro.one.ie/signup`
|
|
1456
1492
|
2. Middleware extracts `fitnesspro` → queries organization thing
|
|
1457
1493
|
3. Sign up form passes `organizationId` to AuthService
|
|
@@ -1460,6 +1496,7 @@ if (!org) {
|
|
|
1460
1496
|
6. All queries automatically filtered by `organizationId`
|
|
1461
1497
|
|
|
1462
1498
|
**Benefits:**
|
|
1499
|
+
|
|
1463
1500
|
- ✅ Data isolation → users can't access other orgs
|
|
1464
1501
|
- ✅ Automatic scoping → all auth operations org-scoped
|
|
1465
1502
|
- ✅ Multi-org users → same email, different orgs
|
|
@@ -1475,77 +1512,81 @@ If you have existing Better Auth code and want to migrate gradually:
|
|
|
1475
1512
|
|
|
1476
1513
|
```typescript
|
|
1477
1514
|
// frontend/src/auth/better-auth-compat.ts
|
|
1478
|
-
import { AuthService } from
|
|
1479
|
-
import { Effect } from
|
|
1480
|
-
import { ClientLayer } from
|
|
1515
|
+
import { AuthService } from "@/services/AuthService";
|
|
1516
|
+
import { Effect } from "effect";
|
|
1517
|
+
import { ClientLayer } from "@/services/ClientLayer";
|
|
1481
1518
|
|
|
1482
1519
|
// Better Auth API compatibility layer
|
|
1483
1520
|
export const betterAuth = {
|
|
1484
1521
|
api: {
|
|
1485
1522
|
signUp: {
|
|
1486
|
-
email: async (params: {
|
|
1523
|
+
email: async (params: {
|
|
1524
|
+
email: string;
|
|
1525
|
+
password: string;
|
|
1526
|
+
name: string;
|
|
1527
|
+
}) => {
|
|
1487
1528
|
const program = Effect.gen(function* () {
|
|
1488
|
-
const auth = yield* AuthService
|
|
1529
|
+
const auth = yield* AuthService;
|
|
1489
1530
|
return yield* auth.signUp({
|
|
1490
1531
|
...params,
|
|
1491
|
-
organizationId: getCurrentOrgId()
|
|
1492
|
-
})
|
|
1493
|
-
})
|
|
1532
|
+
organizationId: getCurrentOrgId(),
|
|
1533
|
+
});
|
|
1534
|
+
});
|
|
1494
1535
|
|
|
1495
|
-
return Effect.runPromise(program.pipe(Effect.provide(ClientLayer)))
|
|
1496
|
-
}
|
|
1536
|
+
return Effect.runPromise(program.pipe(Effect.provide(ClientLayer)));
|
|
1537
|
+
},
|
|
1497
1538
|
},
|
|
1498
1539
|
|
|
1499
1540
|
signIn: {
|
|
1500
1541
|
email: async (params: { email: string; password: string }) => {
|
|
1501
1542
|
const program = Effect.gen(function* () {
|
|
1502
|
-
const auth = yield* AuthService
|
|
1543
|
+
const auth = yield* AuthService;
|
|
1503
1544
|
return yield* auth.signIn({
|
|
1504
1545
|
...params,
|
|
1505
|
-
organizationId: getCurrentOrgId()
|
|
1506
|
-
})
|
|
1507
|
-
})
|
|
1546
|
+
organizationId: getCurrentOrgId(),
|
|
1547
|
+
});
|
|
1548
|
+
});
|
|
1508
1549
|
|
|
1509
|
-
return Effect.runPromise(program.pipe(Effect.provide(ClientLayer)))
|
|
1510
|
-
}
|
|
1550
|
+
return Effect.runPromise(program.pipe(Effect.provide(ClientLayer)));
|
|
1551
|
+
},
|
|
1511
1552
|
},
|
|
1512
1553
|
|
|
1513
1554
|
signOut: async () => {
|
|
1514
|
-
const sessionToken = getSessionToken()
|
|
1515
|
-
if (!sessionToken) return
|
|
1555
|
+
const sessionToken = getSessionToken();
|
|
1556
|
+
if (!sessionToken) return;
|
|
1516
1557
|
|
|
1517
1558
|
const program = Effect.gen(function* () {
|
|
1518
|
-
const auth = yield* AuthService
|
|
1519
|
-
return yield* auth.signOut(sessionToken)
|
|
1520
|
-
})
|
|
1559
|
+
const auth = yield* AuthService;
|
|
1560
|
+
return yield* auth.signOut(sessionToken);
|
|
1561
|
+
});
|
|
1521
1562
|
|
|
1522
|
-
return Effect.runPromise(program.pipe(Effect.provide(ClientLayer)))
|
|
1563
|
+
return Effect.runPromise(program.pipe(Effect.provide(ClientLayer)));
|
|
1523
1564
|
},
|
|
1524
1565
|
|
|
1525
1566
|
getSession: async () => {
|
|
1526
|
-
const sessionToken = getSessionToken()
|
|
1527
|
-
if (!sessionToken) return null
|
|
1567
|
+
const sessionToken = getSessionToken();
|
|
1568
|
+
if (!sessionToken) return null;
|
|
1528
1569
|
|
|
1529
1570
|
const program = Effect.gen(function* () {
|
|
1530
|
-
const auth = yield* AuthService
|
|
1531
|
-
return yield* auth.getSession(sessionToken)
|
|
1532
|
-
})
|
|
1571
|
+
const auth = yield* AuthService;
|
|
1572
|
+
return yield* auth.getSession(sessionToken);
|
|
1573
|
+
});
|
|
1533
1574
|
|
|
1534
|
-
return Effect.runPromise(program.pipe(Effect.provide(ClientLayer)))
|
|
1535
|
-
}
|
|
1536
|
-
}
|
|
1537
|
-
}
|
|
1575
|
+
return Effect.runPromise(program.pipe(Effect.provide(ClientLayer)));
|
|
1576
|
+
},
|
|
1577
|
+
},
|
|
1578
|
+
};
|
|
1538
1579
|
|
|
1539
1580
|
// Helper functions
|
|
1540
1581
|
function getCurrentOrgId(): string {
|
|
1541
1582
|
// Extract from subdomain or context
|
|
1542
|
-
return globalThis.currentOrgId ||
|
|
1583
|
+
return globalThis.currentOrgId || "";
|
|
1543
1584
|
}
|
|
1544
1585
|
|
|
1545
1586
|
function getSessionToken(): string | null {
|
|
1546
1587
|
// Read from cookie
|
|
1547
|
-
const match = document.cookie.match(/session=([^;]+)/)
|
|
1548
|
-
return match ? match[1] : null
|
|
1588
|
+
const match = document.cookie.match(/session=([^;]+)/);
|
|
1589
|
+
return match ? match[1] : null;
|
|
1549
1590
|
}
|
|
1550
1591
|
```
|
|
1551
1592
|
|
|
@@ -1559,130 +1600,127 @@ function getSessionToken(): string | null {
|
|
|
1559
1600
|
|
|
1560
1601
|
```typescript
|
|
1561
1602
|
// frontend/src/services/__tests__/AuthService.test.ts
|
|
1562
|
-
import { describe, it, expect } from
|
|
1563
|
-
import { Effect, Layer } from
|
|
1564
|
-
import { AuthService } from
|
|
1565
|
-
import { DataProvider } from
|
|
1603
|
+
import { describe, it, expect } from "vitest";
|
|
1604
|
+
import { Effect, Layer } from "effect";
|
|
1605
|
+
import { AuthService } from "../AuthService";
|
|
1606
|
+
import { DataProvider } from "@/providers/DataProvider";
|
|
1566
1607
|
|
|
1567
1608
|
// Mock DataProvider
|
|
1568
|
-
const mockThings: any[] = []
|
|
1569
|
-
const mockConnections: any[] = []
|
|
1570
|
-
const mockEvents: any[] = []
|
|
1609
|
+
const mockThings: any[] = [];
|
|
1610
|
+
const mockConnections: any[] = [];
|
|
1611
|
+
const mockEvents: any[] = [];
|
|
1571
1612
|
|
|
1572
1613
|
const MockDataProvider = Layer.succeed(DataProvider, {
|
|
1573
1614
|
things: {
|
|
1574
1615
|
list: (params) =>
|
|
1575
|
-
Effect.succeed(
|
|
1576
|
-
mockThings.filter(t => t.type === params.type)
|
|
1577
|
-
),
|
|
1616
|
+
Effect.succeed(mockThings.filter((t) => t.type === params.type)),
|
|
1578
1617
|
|
|
1579
1618
|
create: (input) =>
|
|
1580
1619
|
Effect.sync(() => {
|
|
1581
|
-
const id = `thing_${Date.now()}
|
|
1582
|
-
mockThings.push({ _id: id, ...input })
|
|
1583
|
-
return id
|
|
1620
|
+
const id = `thing_${Date.now()}`;
|
|
1621
|
+
mockThings.push({ _id: id, ...input });
|
|
1622
|
+
return id;
|
|
1584
1623
|
}),
|
|
1585
1624
|
|
|
1586
|
-
get: (id) =>
|
|
1587
|
-
Effect.succeed(mockThings.find(t => t._id === id)!)
|
|
1625
|
+
get: (id) => Effect.succeed(mockThings.find((t) => t._id === id)!),
|
|
1588
1626
|
},
|
|
1589
1627
|
|
|
1590
1628
|
connections: {
|
|
1591
1629
|
create: (input) =>
|
|
1592
1630
|
Effect.sync(() => {
|
|
1593
|
-
const id = `conn_${Date.now()}
|
|
1594
|
-
mockConnections.push({ _id: id, ...input })
|
|
1595
|
-
return id
|
|
1631
|
+
const id = `conn_${Date.now()}`;
|
|
1632
|
+
mockConnections.push({ _id: id, ...input });
|
|
1633
|
+
return id;
|
|
1596
1634
|
}),
|
|
1597
1635
|
|
|
1598
1636
|
list: (params) =>
|
|
1599
1637
|
Effect.succeed(
|
|
1600
|
-
mockConnections.filter(
|
|
1601
|
-
c.relationshipType === params.relationshipType
|
|
1602
|
-
)
|
|
1638
|
+
mockConnections.filter(
|
|
1639
|
+
(c) => c.relationshipType === params.relationshipType,
|
|
1640
|
+
),
|
|
1603
1641
|
),
|
|
1604
1642
|
|
|
1605
1643
|
delete: (id) =>
|
|
1606
1644
|
Effect.sync(() => {
|
|
1607
|
-
const index = mockConnections.findIndex(c => c._id === id)
|
|
1608
|
-
mockConnections.splice(index, 1)
|
|
1609
|
-
})
|
|
1645
|
+
const index = mockConnections.findIndex((c) => c._id === id);
|
|
1646
|
+
mockConnections.splice(index, 1);
|
|
1647
|
+
}),
|
|
1610
1648
|
},
|
|
1611
1649
|
|
|
1612
1650
|
events: {
|
|
1613
1651
|
log: (event) =>
|
|
1614
1652
|
Effect.sync(() => {
|
|
1615
|
-
mockEvents.push(event)
|
|
1616
|
-
})
|
|
1617
|
-
}
|
|
1618
|
-
})
|
|
1653
|
+
mockEvents.push(event);
|
|
1654
|
+
}),
|
|
1655
|
+
},
|
|
1656
|
+
});
|
|
1619
1657
|
|
|
1620
|
-
describe(
|
|
1621
|
-
it(
|
|
1658
|
+
describe("AuthService", () => {
|
|
1659
|
+
it("signs up a new user", async () => {
|
|
1622
1660
|
const program = Effect.gen(function* () {
|
|
1623
|
-
const auth = yield* AuthService
|
|
1661
|
+
const auth = yield* AuthService;
|
|
1624
1662
|
|
|
1625
1663
|
const user = yield* auth.signUp({
|
|
1626
|
-
email:
|
|
1627
|
-
password:
|
|
1628
|
-
name:
|
|
1629
|
-
organizationId:
|
|
1630
|
-
})
|
|
1664
|
+
email: "test@example.com",
|
|
1665
|
+
password: "password123",
|
|
1666
|
+
name: "Test User",
|
|
1667
|
+
organizationId: "org_123",
|
|
1668
|
+
});
|
|
1631
1669
|
|
|
1632
|
-
return user
|
|
1633
|
-
})
|
|
1670
|
+
return user;
|
|
1671
|
+
});
|
|
1634
1672
|
|
|
1635
1673
|
const user = await Effect.runPromise(
|
|
1636
1674
|
program.pipe(
|
|
1637
1675
|
Effect.provide(AuthService.Default),
|
|
1638
|
-
Effect.provide(MockDataProvider)
|
|
1639
|
-
)
|
|
1640
|
-
)
|
|
1641
|
-
|
|
1642
|
-
expect(user.email).toBe('test@example.com')
|
|
1643
|
-
expect(user.name).toBe('Test User')
|
|
1644
|
-
expect(mockThings.length).toBe(1)
|
|
1645
|
-
expect(mockEvents.length).toBe(1) // sign_up event logged
|
|
1646
|
-
})
|
|
1676
|
+
Effect.provide(MockDataProvider),
|
|
1677
|
+
),
|
|
1678
|
+
);
|
|
1647
1679
|
|
|
1648
|
-
|
|
1680
|
+
expect(user.email).toBe("test@example.com");
|
|
1681
|
+
expect(user.name).toBe("Test User");
|
|
1682
|
+
expect(mockThings.length).toBe(1);
|
|
1683
|
+
expect(mockEvents.length).toBe(1); // sign_up event logged
|
|
1684
|
+
});
|
|
1685
|
+
|
|
1686
|
+
it("signs in existing user", async () => {
|
|
1649
1687
|
// Pre-populate mock user
|
|
1650
1688
|
mockThings.push({
|
|
1651
|
-
_id:
|
|
1652
|
-
type:
|
|
1653
|
-
name:
|
|
1689
|
+
_id: "user_1",
|
|
1690
|
+
type: "person",
|
|
1691
|
+
name: "Test User",
|
|
1654
1692
|
properties: {
|
|
1655
|
-
email:
|
|
1656
|
-
password:
|
|
1657
|
-
emailVerified: true
|
|
1658
|
-
}
|
|
1659
|
-
})
|
|
1693
|
+
email: "test@example.com",
|
|
1694
|
+
password: "hashed_password123",
|
|
1695
|
+
emailVerified: true,
|
|
1696
|
+
},
|
|
1697
|
+
});
|
|
1660
1698
|
|
|
1661
1699
|
const program = Effect.gen(function* () {
|
|
1662
|
-
const auth = yield* AuthService
|
|
1700
|
+
const auth = yield* AuthService;
|
|
1663
1701
|
|
|
1664
1702
|
const result = yield* auth.signIn({
|
|
1665
|
-
email:
|
|
1666
|
-
password:
|
|
1667
|
-
organizationId:
|
|
1668
|
-
})
|
|
1703
|
+
email: "test@example.com",
|
|
1704
|
+
password: "password123",
|
|
1705
|
+
organizationId: "org_123",
|
|
1706
|
+
});
|
|
1669
1707
|
|
|
1670
|
-
return result
|
|
1671
|
-
})
|
|
1708
|
+
return result;
|
|
1709
|
+
});
|
|
1672
1710
|
|
|
1673
1711
|
const result = await Effect.runPromise(
|
|
1674
1712
|
program.pipe(
|
|
1675
1713
|
Effect.provide(AuthService.Default),
|
|
1676
|
-
Effect.provide(MockDataProvider)
|
|
1677
|
-
)
|
|
1678
|
-
)
|
|
1679
|
-
|
|
1680
|
-
expect(result.user.email).toBe(
|
|
1681
|
-
expect(result.session.userId).toBe(
|
|
1682
|
-
expect(mockConnections.length).toBe(1) // session connection created
|
|
1683
|
-
expect(mockEvents.length).toBe(1) // sign_in event logged
|
|
1684
|
-
})
|
|
1685
|
-
})
|
|
1714
|
+
Effect.provide(MockDataProvider),
|
|
1715
|
+
),
|
|
1716
|
+
);
|
|
1717
|
+
|
|
1718
|
+
expect(result.user.email).toBe("test@example.com");
|
|
1719
|
+
expect(result.session.userId).toBe("user_1");
|
|
1720
|
+
expect(mockConnections.length).toBe(1); // session connection created
|
|
1721
|
+
expect(mockEvents.length).toBe(1); // sign_in event logged
|
|
1722
|
+
});
|
|
1723
|
+
});
|
|
1686
1724
|
```
|
|
1687
1725
|
|
|
1688
1726
|
**Key Point:** No mocking libraries needed! Effect.ts test layers provide real implementations.
|
|
@@ -1700,12 +1738,12 @@ Keep existing Better Auth, add AuthService:
|
|
|
1700
1738
|
|
|
1701
1739
|
// OLD: Better Auth (keep for now)
|
|
1702
1740
|
export const betterAuth = betterAuth({
|
|
1703
|
-
database: drizzleAdapter(db)
|
|
1704
|
-
})
|
|
1741
|
+
database: drizzleAdapter(db),
|
|
1742
|
+
});
|
|
1705
1743
|
|
|
1706
1744
|
// NEW: AuthService (add alongside)
|
|
1707
|
-
import { AuthService } from
|
|
1708
|
-
import { ClientLayer } from
|
|
1745
|
+
import { AuthService } from "@/services/AuthService";
|
|
1746
|
+
import { ClientLayer } from "@/services/ClientLayer";
|
|
1709
1747
|
|
|
1710
1748
|
// Use both in parallel during migration
|
|
1711
1749
|
```
|
|
@@ -1714,18 +1752,18 @@ import { ClientLayer } from '@/services/ClientLayer'
|
|
|
1714
1752
|
|
|
1715
1753
|
```tsx
|
|
1716
1754
|
// OLD: Better Auth
|
|
1717
|
-
import { useSession } from
|
|
1718
|
-
const session = useSession()
|
|
1755
|
+
import { useSession } from "@/auth/client";
|
|
1756
|
+
const session = useSession();
|
|
1719
1757
|
|
|
1720
1758
|
// NEW: AuthService + Effect.ts
|
|
1721
|
-
import { useEffectRunner } from
|
|
1722
|
-
import { AuthService } from
|
|
1723
|
-
const { run } = useEffectRunner()
|
|
1759
|
+
import { useEffectRunner } from "@/hooks/useEffectRunner";
|
|
1760
|
+
import { AuthService } from "@/services/AuthService";
|
|
1761
|
+
const { run } = useEffectRunner();
|
|
1724
1762
|
const program = Effect.gen(function* () {
|
|
1725
|
-
const auth = yield* AuthService
|
|
1726
|
-
return yield* auth.getSession(token)
|
|
1727
|
-
})
|
|
1728
|
-
const session = await run(program)
|
|
1763
|
+
const auth = yield* AuthService;
|
|
1764
|
+
return yield* auth.getSession(token);
|
|
1765
|
+
});
|
|
1766
|
+
const session = await run(program);
|
|
1729
1767
|
```
|
|
1730
1768
|
|
|
1731
1769
|
### Phase 3: Remove Better Auth
|
|
@@ -1739,34 +1777,40 @@ Once all components migrated, remove Better Auth dependencies.
|
|
|
1739
1777
|
### What We Achieve
|
|
1740
1778
|
|
|
1741
1779
|
✅ **Users = Things (type: person)**
|
|
1780
|
+
|
|
1742
1781
|
- Works with all thing operations
|
|
1743
1782
|
- Can have connections (relationships, org membership)
|
|
1744
1783
|
- Can be actors in events (audit trail)
|
|
1745
1784
|
- Can be embedded in knowledge (AI context)
|
|
1746
1785
|
|
|
1747
1786
|
✅ **Sessions = Connections (type: session)**
|
|
1787
|
+
|
|
1748
1788
|
- Real-time sync → revoke everywhere instantly
|
|
1749
1789
|
- Automatic expiration → query only active
|
|
1750
1790
|
- Analytics → count sessions, track patterns
|
|
1751
1791
|
|
|
1752
1792
|
✅ **Auth Events Logged**
|
|
1793
|
+
|
|
1753
1794
|
- Complete audit trail
|
|
1754
1795
|
- Security analytics
|
|
1755
1796
|
- User timeline
|
|
1756
1797
|
|
|
1757
1798
|
✅ **Effect.ts Integration**
|
|
1799
|
+
|
|
1758
1800
|
- Type-safe auth operations
|
|
1759
1801
|
- Composable workflows
|
|
1760
1802
|
- Consistent error handling
|
|
1761
1803
|
- Easy testing with test layers
|
|
1762
1804
|
|
|
1763
1805
|
✅ **Backend-Agnostic**
|
|
1806
|
+
|
|
1764
1807
|
- AuthService uses DataProvider
|
|
1765
1808
|
- Works with Convex, Supabase, WordPress, Notion
|
|
1766
1809
|
- Swap backends by changing ONE line
|
|
1767
1810
|
- Same auth code, different backend
|
|
1768
1811
|
|
|
1769
1812
|
✅ **Multi-Tenant by Default**
|
|
1813
|
+
|
|
1770
1814
|
- Users scoped to organizations
|
|
1771
1815
|
- Sessions scoped to organizations
|
|
1772
1816
|
- Data isolation automatic
|
|
@@ -1820,22 +1864,22 @@ frontend/src/
|
|
|
1820
1864
|
|
|
1821
1865
|
### Comparison
|
|
1822
1866
|
|
|
1823
|
-
| Aspect
|
|
1824
|
-
|
|
1825
|
-
| **Architecture**
|
|
1826
|
-
| **Multi-Tenancy**
|
|
1827
|
-
| **Authorization**
|
|
1828
|
-
| **Users**
|
|
1829
|
-
| **Devices**
|
|
1830
|
-
| **Sessions**
|
|
1831
|
-
| **OAuth**
|
|
1832
|
-
| **Audit Trail**
|
|
1833
|
-
| **Security AI**
|
|
1834
|
-
| **Backend**
|
|
1835
|
-
| **Error Handling** | Try/catch
|
|
1836
|
-
| **Testing**
|
|
1837
|
-
| **Data Isolation** | Manual queries
|
|
1838
|
-
| **Analytics**
|
|
1867
|
+
| Aspect | Better Auth (Traditional) | ONE 6-Dimension |
|
|
1868
|
+
| ------------------ | -------------------------- | ---------------------------------- |
|
|
1869
|
+
| **Architecture** | 4 separate tables | 6 dimensions |
|
|
1870
|
+
| **Multi-Tenancy** | Manual implementation | Organizations (dimension 1) |
|
|
1871
|
+
| **Authorization** | Basic roles | People with roles (dimension 2) |
|
|
1872
|
+
| **Users** | Separate `user` table | Things (type: creator) |
|
|
1873
|
+
| **Devices** | Not tracked | Things (type: device) - optional |
|
|
1874
|
+
| **Sessions** | Separate `session` table | Connections (type: session) |
|
|
1875
|
+
| **OAuth** | Separate `account` table | Connections (type: oauth_account) |
|
|
1876
|
+
| **Audit Trail** | Not logged | Events (dimension 5) - complete |
|
|
1877
|
+
| **Security AI** | None | Knowledge (dimension 6) - patterns |
|
|
1878
|
+
| **Backend** | Database-specific adapters | Universal DataProvider |
|
|
1879
|
+
| **Error Handling** | Try/catch | Typed Effect errors |
|
|
1880
|
+
| **Testing** | Mock database | Effect test layers |
|
|
1881
|
+
| **Data Isolation** | Manual queries | Automatic (groupId scoping) |
|
|
1882
|
+
| **Analytics** | External tool | Built-in (events + knowledge) |
|
|
1839
1883
|
|
|
1840
1884
|
### Next Steps
|
|
1841
1885
|
|