@invictus-group-ai/orchestra 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/LICENSING.md +49 -0
- package/README.md +507 -0
- package/assets/settings-template.json +99 -0
- package/bin/invi.js +6 -0
- package/content-dist/LICENSE +95 -0
- package/content-dist/PIPELINE.md +823 -0
- package/content-dist/README.md +128 -0
- package/content-dist/agents/README.md +135 -0
- package/content-dist/agents/mapping.json +476 -0
- package/content-dist/agents/stacks/backend-django.md +66 -0
- package/content-dist/agents/stacks/backend-dotnet.md +72 -0
- package/content-dist/agents/stacks/backend-fastapi.md +66 -0
- package/content-dist/agents/stacks/backend-laravel.md +66 -0
- package/content-dist/agents/stacks/backend-node.md +66 -0
- package/content-dist/agents/stacks/backend-spring.md +66 -0
- package/content-dist/agents/stacks/desktop-delphi.md +73 -0
- package/content-dist/agents/stacks/frontend-angular.md +65 -0
- package/content-dist/agents/stacks/frontend-react.md +67 -0
- package/content-dist/agents/stacks/frontend-svelte.md +67 -0
- package/content-dist/agents/stacks/frontend-vue.md +66 -0
- package/content-dist/agents/stacks/mobile-flutter.md +68 -0
- package/content-dist/agents/stacks/wordpress.md +66 -0
- package/content-dist/agents/universal/invi-qa.md +57 -0
- package/content-dist/agents/universal/invi-reviewer.md +61 -0
- package/content-dist/agents/universal/invi-security.md +55 -0
- package/content-dist/agents/universal/invi-tester.md +55 -0
- package/content-dist/agents/universal/invi-ui.md +85 -0
- package/content-dist/fragments/base.md +37 -0
- package/content-dist/fragments/domain/api-publica-rate-limiting.md +83 -0
- package/content-dist/fragments/domain/autenticacao-enterprise.md +86 -0
- package/content-dist/fragments/domain/busca-elasticsearch.md +86 -0
- package/content-dist/fragments/domain/dashboard-admin-rbac.md +80 -0
- package/content-dist/fragments/domain/design-system.md +71 -0
- package/content-dist/fragments/domain/ecommerce-completo.md +86 -0
- package/content-dist/fragments/domain/filas-jobs.md +80 -0
- package/content-dist/fragments/domain/integracao-crm-erp.md +82 -0
- package/content-dist/fragments/domain/lgpd.md +84 -0
- package/content-dist/fragments/domain/multi-tenancy.md +79 -0
- package/content-dist/fragments/domain/notificacoes-multicanal.md +81 -0
- package/content-dist/fragments/domain/pagamentos-brasil.md +85 -0
- package/content-dist/fragments/domain/plataforma-conteudo.md +77 -0
- package/content-dist/fragments/domain/realtime-websockets.md +92 -0
- package/content-dist/fragments/domain/relatorios-analytics.md +80 -0
- package/content-dist/fragments/domain/saas-stripe-billing.md +79 -0
- package/content-dist/fragments/domain/sistema-pagamentos.md +81 -0
- package/content-dist/fragments/domain/upload-midia.md +81 -0
- package/content-dist/fragments/domain/whatsapp-business.md +82 -0
- package/content-dist/fragments/index.json +1670 -0
- package/content-dist/fragments/references/angular-ngrx/app-config-and-testing.md +81 -0
- package/content-dist/fragments/references/angular-ngrx/store-pattern.md +155 -0
- package/content-dist/fragments/references/ansible-server-setup/layout-and-config.md +143 -0
- package/content-dist/fragments/references/ansible-server-setup/roles.md +238 -0
- package/content-dist/fragments/references/api-publica-rate-limiting/patterns.md +68 -0
- package/content-dist/fragments/references/astro-static/content-and-islands.md +117 -0
- package/content-dist/fragments/references/autenticacao-enterprise/pitfalls.md +70 -0
- package/content-dist/fragments/references/busca-elasticsearch/patterns.md +100 -0
- package/content-dist/fragments/references/chrome-extension-mv3/messaging-and-storage.md +109 -0
- package/content-dist/fragments/references/cli-typescript-commander/commands-and-config.md +136 -0
- package/content-dist/fragments/references/cloud-run-gcp/build-and-deploy.md +127 -0
- package/content-dist/fragments/references/cloud-run-gcp/iam-secrets-networking.md +65 -0
- package/content-dist/fragments/references/computer-vision-yolo/serving-and-export.md +182 -0
- package/content-dist/fragments/references/computer-vision-yolo/training-and-validation.md +131 -0
- package/content-dist/fragments/references/convex-react/functions.md +117 -0
- package/content-dist/fragments/references/convex-react/react-and-storage.md +109 -0
- package/content-dist/fragments/references/dashboard-admin-rbac/patterns.md +73 -0
- package/content-dist/fragments/references/data-pipeline-airflow/dag-patterns.md +149 -0
- package/content-dist/fragments/references/data-pipeline-airflow/operations.md +74 -0
- package/content-dist/fragments/references/delphi-object-pascal/legacy-extraction.md +175 -0
- package/content-dist/fragments/references/django-drf-celery/celery-tasks.md +47 -0
- package/content-dist/fragments/references/django-drf-celery/viewsets-and-serializers.md +92 -0
- package/content-dist/fragments/references/docker-compose-dev/compose-files.md +146 -0
- package/content-dist/fragments/references/docker-compose-dev/dockerfile-and-proxy.md +108 -0
- package/content-dist/fragments/references/dotnet-aspnet/data-and-di.md +90 -0
- package/content-dist/fragments/references/dotnet-aspnet/web-layer.md +88 -0
- package/content-dist/fragments/references/ecommerce-completo/patterns.md +76 -0
- package/content-dist/fragments/references/electron-app/ipc-bridge.md +123 -0
- package/content-dist/fragments/references/electron-app/security-and-packaging.md +134 -0
- package/content-dist/fragments/references/elixir-phoenix/context-and-web.md +112 -0
- package/content-dist/fragments/references/elixir-phoenix/processes.md +65 -0
- package/content-dist/fragments/references/filas-jobs/patterns.md +116 -0
- package/content-dist/fragments/references/fine-tuning-huggingface/data-and-export.md +114 -0
- package/content-dist/fragments/references/fine-tuning-huggingface/training-and-lora.md +123 -0
- package/content-dist/fragments/references/flutter/platform-channels-and-goldens.md +68 -0
- package/content-dist/fragments/references/flutter/state-and-widgets.md +95 -0
- package/content-dist/fragments/references/github-actions-cicd/workflows.md +235 -0
- package/content-dist/fragments/references/go-chi-gorm/http-layer.md +87 -0
- package/content-dist/fragments/references/go-chi-gorm/service-layer.md +58 -0
- package/content-dist/fragments/references/graphql-apollo/resolvers-and-loaders.md +128 -0
- package/content-dist/fragments/references/hono-bun/patterns.md +144 -0
- package/content-dist/fragments/references/integracao-crm-erp/patterns.md +100 -0
- package/content-dist/fragments/references/kubernetes-helm/chart-templates.md +162 -0
- package/content-dist/fragments/references/kubernetes-helm/secrets-storage-deploy.md +78 -0
- package/content-dist/fragments/references/langchain-python-agent/agent-and-cost.md +120 -0
- package/content-dist/fragments/references/langchain-python-agent/memory-and-resilience.md +76 -0
- package/content-dist/fragments/references/laravel/eloquent-and-queues.md +126 -0
- package/content-dist/fragments/references/laravel/http-layer.md +110 -0
- package/content-dist/fragments/references/lgpd/patterns.md +110 -0
- package/content-dist/fragments/references/llm-ops-production/routing-and-budget.md +118 -0
- package/content-dist/fragments/references/llm-ops-production/tracing-eval-ab.md +102 -0
- package/content-dist/fragments/references/microservices-docker/compose-and-gateway.md +93 -0
- package/content-dist/fragments/references/microservices-docker/events-and-correlation.md +88 -0
- package/content-dist/fragments/references/ml-fastapi-serving/metrics-drift-docker.md +97 -0
- package/content-dist/fragments/references/ml-fastapi-serving/serving-core.md +155 -0
- package/content-dist/fragments/references/ml-training-pipeline/dvc-pipeline.md +102 -0
- package/content-dist/fragments/references/ml-training-pipeline/mlflow-registry-ci.md +139 -0
- package/content-dist/fragments/references/monitoring-observability/alerts-and-config.md +169 -0
- package/content-dist/fragments/references/monitoring-observability/instrumentation-node.md +139 -0
- package/content-dist/fragments/references/multi-tenancy/patterns.md +85 -0
- package/content-dist/fragments/references/nestjs-typescript/guards-and-decorators.md +103 -0
- package/content-dist/fragments/references/nestjs-typescript/modules-dtos-setup.md +106 -0
- package/content-dist/fragments/references/nextjs-app-router/patterns.md +177 -0
- package/content-dist/fragments/references/nextjs-prisma-postgres/billing.md +167 -0
- package/content-dist/fragments/references/nextjs-trpc-drizzle/data-and-auth.md +121 -0
- package/content-dist/fragments/references/nextjs-trpc-drizzle/trpc-setup.md +62 -0
- package/content-dist/fragments/references/nodejs-express-typescript/config-and-tokens.md +48 -0
- package/content-dist/fragments/references/nodejs-express-typescript/middleware.md +108 -0
- package/content-dist/fragments/references/notificacoes-multicanal/patterns.md +78 -0
- package/content-dist/fragments/references/nuxt3-tailwind/server-routes.md +79 -0
- package/content-dist/fragments/references/nuxt3-tailwind/state-and-fetching.md +129 -0
- package/content-dist/fragments/references/openai-api-integration/calls.md +210 -0
- package/content-dist/fragments/references/openai-api-integration/client-and-cost.md +71 -0
- package/content-dist/fragments/references/pagamentos-brasil/gateways-reconciliation.md +92 -0
- package/content-dist/fragments/references/pagamentos-brasil/pix-boleto.md +115 -0
- package/content-dist/fragments/references/plataforma-conteudo/patterns.md +74 -0
- package/content-dist/fragments/references/python-fastapi/dependency-injection.md +99 -0
- package/content-dist/fragments/references/python-fastapi/settings-and-tasks.md +47 -0
- package/content-dist/fragments/references/rag-pipeline/ingestion.md +92 -0
- package/content-dist/fragments/references/rag-pipeline/retrieval-and-eval.md +148 -0
- package/content-dist/fragments/references/react-express-monolith/auth-and-client.md +110 -0
- package/content-dist/fragments/references/react-express-monolith/monorepo.md +71 -0
- package/content-dist/fragments/references/react-native-expo/native-patterns.md +103 -0
- package/content-dist/fragments/references/react-native-expo/navigation-and-auth.md +55 -0
- package/content-dist/fragments/references/react-ts-zustand-query/store-and-query.md +152 -0
- package/content-dist/fragments/references/react-typescript/feature-module.md +64 -0
- package/content-dist/fragments/references/react-typescript/forms-and-state.md +69 -0
- package/content-dist/fragments/references/react-typescript/recipes.md +37 -0
- package/content-dist/fragments/references/react-typescript/testing.md +40 -0
- package/content-dist/fragments/references/realtime-websockets/patterns.md +92 -0
- package/content-dist/fragments/references/relatorios-analytics/patterns.md +81 -0
- package/content-dist/fragments/references/remix-express-full/auth-and-uploads.md +88 -0
- package/content-dist/fragments/references/remix-express-full/express-server.md +54 -0
- package/content-dist/fragments/references/remix-typescript/auth-and-db.md +68 -0
- package/content-dist/fragments/references/remix-typescript/loaders-and-actions.md +98 -0
- package/content-dist/fragments/references/rust-axum/error-and-state.md +99 -0
- package/content-dist/fragments/references/rust-axum/handlers.md +87 -0
- package/content-dist/fragments/references/saas-stripe-billing/patterns.md +86 -0
- package/content-dist/fragments/references/serverless-lambda/handler-patterns.md +107 -0
- package/content-dist/fragments/references/sistema-pagamentos/pitfalls.md +54 -0
- package/content-dist/fragments/references/spring-boot/service-and-data.md +96 -0
- package/content-dist/fragments/references/spring-boot/web-layer.md +100 -0
- package/content-dist/fragments/references/supabase-nextjs/clients-and-middleware.md +102 -0
- package/content-dist/fragments/references/supabase-nextjs/rls-and-storage.md +86 -0
- package/content-dist/fragments/references/svelte-sveltekit/hooks-and-state.md +67 -0
- package/content-dist/fragments/references/svelte-sveltekit/load-and-actions.md +80 -0
- package/content-dist/fragments/references/t3-stack/routers-and-callers.md +75 -0
- package/content-dist/fragments/references/t3-stack/trpc-setup.md +60 -0
- package/content-dist/fragments/references/terraform-aws/modules-and-ci.md +114 -0
- package/content-dist/fragments/references/terraform-aws/state-and-workspaces.md +66 -0
- package/content-dist/fragments/references/turborepo-monorepo/pipeline-and-packages.md +84 -0
- package/content-dist/fragments/references/upload-midia/patterns.md +80 -0
- package/content-dist/fragments/references/vector-search-pinecone/client-and-upsert.md +98 -0
- package/content-dist/fragments/references/vector-search-pinecone/query-and-hybrid.md +81 -0
- package/content-dist/fragments/references/vps-deploy-producao/compose-prod.md +97 -0
- package/content-dist/fragments/references/vps-deploy-producao/proxy-and-operations.md +118 -0
- package/content-dist/fragments/references/vscode-extension/activation-and-tree.md +98 -0
- package/content-dist/fragments/references/vscode-extension/webview-csp.md +57 -0
- package/content-dist/fragments/references/vue3-pinia-vite/components-and-stores.md +73 -0
- package/content-dist/fragments/references/vue3-pinia-vite/queries-forms-testing.md +100 -0
- package/content-dist/fragments/references/whatsapp-business/patterns.md +107 -0
- package/content-dist/fragments/references/wordpress/hooks-and-security.md +92 -0
- package/content-dist/fragments/references/wordpress/wp-cli-gates.md +64 -0
- package/content-dist/fragments/stack/angular-ngrx.md +75 -0
- package/content-dist/fragments/stack/ansible-server-setup.md +69 -0
- package/content-dist/fragments/stack/astro-static.md +72 -0
- package/content-dist/fragments/stack/chrome-extension-mv3.md +66 -0
- package/content-dist/fragments/stack/cli-typescript-commander.md +66 -0
- package/content-dist/fragments/stack/cloud-run-gcp.md +63 -0
- package/content-dist/fragments/stack/computer-vision-yolo.md +62 -0
- package/content-dist/fragments/stack/convex-react.md +65 -0
- package/content-dist/fragments/stack/data-pipeline-airflow.md +64 -0
- package/content-dist/fragments/stack/delphi-object-pascal.md +63 -0
- package/content-dist/fragments/stack/django-drf-celery.md +63 -0
- package/content-dist/fragments/stack/docker-compose-dev.md +69 -0
- package/content-dist/fragments/stack/dotnet-aspnet.md +62 -0
- package/content-dist/fragments/stack/electron-app.md +70 -0
- package/content-dist/fragments/stack/elixir-phoenix.md +65 -0
- package/content-dist/fragments/stack/fine-tuning-huggingface.md +69 -0
- package/content-dist/fragments/stack/flutter.md +61 -0
- package/content-dist/fragments/stack/github-actions-cicd.md +73 -0
- package/content-dist/fragments/stack/go-chi-gorm.md +73 -0
- package/content-dist/fragments/stack/graphql-apollo.md +70 -0
- package/content-dist/fragments/stack/hono-bun.md +62 -0
- package/content-dist/fragments/stack/kubernetes-helm.md +67 -0
- package/content-dist/fragments/stack/langchain-python-agent.md +64 -0
- package/content-dist/fragments/stack/laravel.md +64 -0
- package/content-dist/fragments/stack/llm-ops-production.md +63 -0
- package/content-dist/fragments/stack/microservices-docker.md +70 -0
- package/content-dist/fragments/stack/ml-fastapi-serving.md +64 -0
- package/content-dist/fragments/stack/ml-training-pipeline.md +67 -0
- package/content-dist/fragments/stack/monitoring-observability.md +68 -0
- package/content-dist/fragments/stack/nestjs-typescript.md +68 -0
- package/content-dist/fragments/stack/nextjs-app-router.md +65 -0
- package/content-dist/fragments/stack/nextjs-prisma-postgres.md +61 -0
- package/content-dist/fragments/stack/nextjs-trpc-drizzle.md +63 -0
- package/content-dist/fragments/stack/nodejs-express-typescript.md +60 -0
- package/content-dist/fragments/stack/nuxt3-tailwind.md +62 -0
- package/content-dist/fragments/stack/openai-api-integration.md +58 -0
- package/content-dist/fragments/stack/python-fastapi.md +64 -0
- package/content-dist/fragments/stack/rag-pipeline.md +62 -0
- package/content-dist/fragments/stack/react-express-monolith.md +61 -0
- package/content-dist/fragments/stack/react-native-expo.md +68 -0
- package/content-dist/fragments/stack/react-ts-zustand-query.md +64 -0
- package/content-dist/fragments/stack/react-typescript.md +73 -0
- package/content-dist/fragments/stack/remix-express-full.md +63 -0
- package/content-dist/fragments/stack/remix-typescript.md +66 -0
- package/content-dist/fragments/stack/rust-axum.md +63 -0
- package/content-dist/fragments/stack/serverless-lambda.md +65 -0
- package/content-dist/fragments/stack/spring-boot.md +63 -0
- package/content-dist/fragments/stack/supabase-nextjs.md +64 -0
- package/content-dist/fragments/stack/svelte-sveltekit.md +67 -0
- package/content-dist/fragments/stack/t3-stack.md +63 -0
- package/content-dist/fragments/stack/terraform-aws.md +65 -0
- package/content-dist/fragments/stack/turborepo-monorepo.md +61 -0
- package/content-dist/fragments/stack/vector-search-pinecone.md +63 -0
- package/content-dist/fragments/stack/vps-deploy-producao.md +64 -0
- package/content-dist/fragments/stack/vscode-extension.md +64 -0
- package/content-dist/fragments/stack/vue3-pinia-vite.md +65 -0
- package/content-dist/fragments/stack/wordpress.md +63 -0
- package/content-dist/skills/invi-commit/SKILL.md +85 -0
- package/content-dist/skills/invi-journal/SKILL.md +67 -0
- package/content-dist/skills/invi-map/SKILL.md +118 -0
- package/content-dist/skills/invi-mode/SKILL.md +176 -0
- package/content-dist/skills/invi-pr/SKILL.md +142 -0
- package/content-dist/skills/invi-qa/SKILL.md +75 -0
- package/content-dist/skills/invi-refactor-legacy/SKILL.md +90 -0
- package/content-dist/skills/invi-review/SKILL.md +83 -0
- package/content-dist/skills/invi-security/SKILL.md +89 -0
- package/content-dist/skills/invi-status/SKILL.md +72 -0
- package/content-dist/skills/invi-task/SKILL.md +143 -0
- package/content-dist/skills/invi-test/SKILL.md +97 -0
- package/content-dist/skills/po-handoff/SKILL.md +130 -0
- package/content-dist/skills/po-intake/SKILL.md +115 -0
- package/content-dist/skills/po-lint/SKILL.md +82 -0
- package/content-dist/skills/po-spec/SKILL.md +138 -0
- package/content-dist/skills/po-status/SKILL.md +130 -0
- package/content-dist/skills/po-verify/SKILL.md +124 -0
- package/content-dist/templates/requirements/REQ-TEMPLATE.md +110 -0
- package/content-dist/templates/requirements/constitution-TEMPLATE.md +77 -0
- package/dist/baseline.d.ts +21 -0
- package/dist/baseline.d.ts.map +1 -0
- package/dist/baseline.js +43 -0
- package/dist/baseline.js.map +1 -0
- package/dist/cli.d.ts +15 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +345 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/doctor.d.ts +31 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +173 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/export.d.ts +49 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +95 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/gate.d.ts +42 -0
- package/dist/commands/gate.d.ts.map +1 -0
- package/dist/commands/gate.js +97 -0
- package/dist/commands/gate.js.map +1 -0
- package/dist/commands/init.d.ts +88 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +540 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/journalCmd.d.ts +47 -0
- package/dist/commands/journalCmd.d.ts.map +1 -0
- package/dist/commands/journalCmd.js +89 -0
- package/dist/commands/journalCmd.js.map +1 -0
- package/dist/commands/keys.d.ts +68 -0
- package/dist/commands/keys.d.ts.map +1 -0
- package/dist/commands/keys.js +240 -0
- package/dist/commands/keys.js.map +1 -0
- package/dist/commands/map.d.ts +123 -0
- package/dist/commands/map.d.ts.map +1 -0
- package/dist/commands/map.js +383 -0
- package/dist/commands/map.js.map +1 -0
- package/dist/commands/plan.d.ts +28 -0
- package/dist/commands/plan.d.ts.map +1 -0
- package/dist/commands/plan.js +64 -0
- package/dist/commands/plan.js.map +1 -0
- package/dist/commands/req.d.ts +92 -0
- package/dist/commands/req.d.ts.map +1 -0
- package/dist/commands/req.js +270 -0
- package/dist/commands/req.js.map +1 -0
- package/dist/commands/review.d.ts +40 -0
- package/dist/commands/review.d.ts.map +1 -0
- package/dist/commands/review.js +101 -0
- package/dist/commands/review.js.map +1 -0
- package/dist/commands/run.d.ts +33 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +151 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/ship.d.ts +45 -0
- package/dist/commands/ship.d.ts.map +1 -0
- package/dist/commands/ship.js +252 -0
- package/dist/commands/ship.js.map +1 -0
- package/dist/commands/status.d.ts +36 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +152 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/sync.d.ts +91 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +331 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/commands/syncCommits.d.ts +56 -0
- package/dist/commands/syncCommits.d.ts.map +1 -0
- package/dist/commands/syncCommits.js +97 -0
- package/dist/commands/syncCommits.js.map +1 -0
- package/dist/commands/task.d.ts +108 -0
- package/dist/commands/task.d.ts.map +1 -0
- package/dist/commands/task.js +217 -0
- package/dist/commands/task.js.map +1 -0
- package/dist/commands/update.d.ts +92 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +541 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/verifyTask.d.ts +50 -0
- package/dist/commands/verifyTask.d.ts.map +1 -0
- package/dist/commands/verifyTask.js +172 -0
- package/dist/commands/verifyTask.js.map +1 -0
- package/dist/content.d.ts +128 -0
- package/dist/content.d.ts.map +1 -0
- package/dist/content.js +177 -0
- package/dist/content.js.map +1 -0
- package/dist/detect.d.ts +122 -0
- package/dist/detect.d.ts.map +1 -0
- package/dist/detect.js +594 -0
- package/dist/detect.js.map +1 -0
- package/dist/events.d.ts +36 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +76 -0
- package/dist/events.js.map +1 -0
- package/dist/frontmatter.d.ts +15 -0
- package/dist/frontmatter.d.ts.map +1 -0
- package/dist/frontmatter.js +74 -0
- package/dist/frontmatter.js.map +1 -0
- package/dist/i18n/en.d.ts +421 -0
- package/dist/i18n/en.d.ts.map +1 -0
- package/dist/i18n/en.js +443 -0
- package/dist/i18n/en.js.map +1 -0
- package/dist/i18n/index.d.ts +40 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +66 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/pt-BR.d.ts +11 -0
- package/dist/i18n/pt-BR.d.ts.map +1 -0
- package/dist/i18n/pt-BR.js +435 -0
- package/dist/i18n/pt-BR.js.map +1 -0
- package/dist/identity.d.ts +78 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +152 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +79 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/insights.d.ts +86 -0
- package/dist/insights.d.ts.map +1 -0
- package/dist/insights.js +199 -0
- package/dist/insights.js.map +1 -0
- package/dist/interview.d.ts +81 -0
- package/dist/interview.d.ts.map +1 -0
- package/dist/interview.js +283 -0
- package/dist/interview.js.map +1 -0
- package/dist/inventory.d.ts +79 -0
- package/dist/inventory.d.ts.map +1 -0
- package/dist/inventory.js +86 -0
- package/dist/inventory.js.map +1 -0
- package/dist/journal.d.ts +22 -0
- package/dist/journal.d.ts.map +1 -0
- package/dist/journal.js +88 -0
- package/dist/journal.js.map +1 -0
- package/dist/migrations/legacyNames.d.ts +45 -0
- package/dist/migrations/legacyNames.d.ts.map +1 -0
- package/dist/migrations/legacyNames.js +118 -0
- package/dist/migrations/legacyNames.js.map +1 -0
- package/dist/plan.d.ts +42 -0
- package/dist/plan.d.ts.map +1 -0
- package/dist/plan.js +126 -0
- package/dist/plan.js.map +1 -0
- package/dist/render/agents.d.ts +327 -0
- package/dist/render/agents.d.ts.map +1 -0
- package/dist/render/agents.js +356 -0
- package/dist/render/agents.js.map +1 -0
- package/dist/render/claudeMd.d.ts +29 -0
- package/dist/render/claudeMd.d.ts.map +1 -0
- package/dist/render/claudeMd.js +110 -0
- package/dist/render/claudeMd.js.map +1 -0
- package/dist/render/githooks.d.ts +41 -0
- package/dist/render/githooks.d.ts.map +1 -0
- package/dist/render/githooks.js +168 -0
- package/dist/render/githooks.js.map +1 -0
- package/dist/render/markers.d.ts +13 -0
- package/dist/render/markers.d.ts.map +1 -0
- package/dist/render/markers.js +35 -0
- package/dist/render/markers.js.map +1 -0
- package/dist/render/requirements.d.ts +56 -0
- package/dist/render/requirements.d.ts.map +1 -0
- package/dist/render/requirements.js +86 -0
- package/dist/render/requirements.js.map +1 -0
- package/dist/render/settings.d.ts +43 -0
- package/dist/render/settings.d.ts.map +1 -0
- package/dist/render/settings.js +94 -0
- package/dist/render/settings.js.map +1 -0
- package/dist/render/transparency.d.ts +7 -0
- package/dist/render/transparency.d.ts.map +1 -0
- package/dist/render/transparency.js +164 -0
- package/dist/render/transparency.js.map +1 -0
- package/dist/requirements.d.ts +84 -0
- package/dist/requirements.d.ts.map +1 -0
- package/dist/requirements.js +229 -0
- package/dist/requirements.js.map +1 -0
- package/dist/sizing.d.ts +63 -0
- package/dist/sizing.d.ts.map +1 -0
- package/dist/sizing.js +104 -0
- package/dist/sizing.js.map +1 -0
- package/dist/tasks.d.ts +199 -0
- package/dist/tasks.d.ts.map +1 -0
- package/dist/tasks.js +320 -0
- package/dist/tasks.js.map +1 -0
- package/dist/util/diff3.d.ts +26 -0
- package/dist/util/diff3.d.ts.map +1 -0
- package/dist/util/diff3.js +112 -0
- package/dist/util/diff3.js.map +1 -0
- package/dist/util/fsx.d.ts +33 -0
- package/dist/util/fsx.d.ts.map +1 -0
- package/dist/util/fsx.js +153 -0
- package/dist/util/fsx.js.map +1 -0
- package/dist/util/git.d.ts +58 -0
- package/dist/util/git.d.ts.map +1 -0
- package/dist/util/git.js +171 -0
- package/dist/util/git.js.map +1 -0
- package/dist/util/merge.d.ts +27 -0
- package/dist/util/merge.d.ts.map +1 -0
- package/dist/util/merge.js +78 -0
- package/dist/util/merge.js.map +1 -0
- package/dist/util/out.d.ts +18 -0
- package/dist/util/out.d.ts.map +1 -0
- package/dist/util/out.js +23 -0
- package/dist/util/out.js.map +1 -0
- package/dist/util/proc.d.ts +12 -0
- package/dist/util/proc.d.ts.map +1 -0
- package/dist/util/proc.js +45 -0
- package/dist/util/proc.js.map +1 -0
- package/dist/util/registry.d.ts +58 -0
- package/dist/util/registry.d.ts.map +1 -0
- package/dist/util/registry.js +240 -0
- package/dist/util/registry.js.map +1 -0
- package/dist/verify.d.ts +52 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +205 -0
- package/dist/verify.js.map +1 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +18 -0
- package/dist/version.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Reference: Spring Boot service and data layer (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/spring-boot` — transactional service, repository with fetch join, typed configuration, migration discipline. Read when touching business rules, queries, or config.
|
|
4
|
+
|
|
5
|
+
## Transactional service (business rules live here)
|
|
6
|
+
|
|
7
|
+
```java
|
|
8
|
+
// domain/order/OrderService.java
|
|
9
|
+
@Service
|
|
10
|
+
public class OrderService {
|
|
11
|
+
|
|
12
|
+
private final OrderRepository orders;
|
|
13
|
+
private final CustomerRepository customers;
|
|
14
|
+
|
|
15
|
+
public OrderService(OrderRepository orders, CustomerRepository customers) {
|
|
16
|
+
this.orders = orders;
|
|
17
|
+
this.customers = customers;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@Transactional
|
|
21
|
+
public Order place(UUID userId, CreateOrderRequest request) {
|
|
22
|
+
Customer customer = customers.findByIdAndOwner(request.customerId(), userId)
|
|
23
|
+
.orElseThrow(() -> new CustomerNotFoundException(request.customerId()));
|
|
24
|
+
Order order = Order.create(customer, request.items()); // invariant checks inside
|
|
25
|
+
return orders.save(order);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@Transactional(readOnly = true)
|
|
29
|
+
public Order getForUser(UUID userId, UUID orderId) {
|
|
30
|
+
return orders.findWithItemsByIdAndOwner(orderId, userId)
|
|
31
|
+
.orElseThrow(() -> new OrderNotFoundException(orderId));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Self-invocation warning: calling `this.place(...)` from another method of `OrderService` bypasses the transaction proxy. If two entry points need different transaction semantics, split the class.
|
|
37
|
+
|
|
38
|
+
## Repository: fetch join kills the N+1
|
|
39
|
+
|
|
40
|
+
```java
|
|
41
|
+
// domain/order/OrderRepository.java
|
|
42
|
+
public interface OrderRepository extends JpaRepository<Order, UUID> {
|
|
43
|
+
|
|
44
|
+
@Query("""
|
|
45
|
+
select o from Order o
|
|
46
|
+
join fetch o.items
|
|
47
|
+
where o.id = :id and o.customer.owner.id = :ownerId
|
|
48
|
+
""")
|
|
49
|
+
Optional<Order> findWithItemsByIdAndOwner(UUID id, UUID ownerId);
|
|
50
|
+
|
|
51
|
+
// List endpoints: projection instead of entity graph when read-only.
|
|
52
|
+
@Query("""
|
|
53
|
+
select new com.acme.api.order.OrderSummary(o.id, o.status, o.total)
|
|
54
|
+
from Order o where o.customer.owner.id = :ownerId
|
|
55
|
+
""")
|
|
56
|
+
Page<OrderSummary> summariesForOwner(UUID ownerId, Pageable pageable);
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Typed configuration + profiles
|
|
61
|
+
|
|
62
|
+
```java
|
|
63
|
+
// config/PaymentProperties.java
|
|
64
|
+
@ConfigurationProperties(prefix = "app.payment")
|
|
65
|
+
@Validated
|
|
66
|
+
public record PaymentProperties(@NotBlank String baseUrl, Duration timeout) {
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
```yaml
|
|
71
|
+
# src/main/resources/application.yml — defaults, no secrets
|
|
72
|
+
app:
|
|
73
|
+
payment:
|
|
74
|
+
base-url: ${PAYMENT_BASE_URL:http://localhost:8081}
|
|
75
|
+
timeout: 5s
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
```yaml
|
|
79
|
+
# src/main/resources/application-prod.yml — prod profile overrides only
|
|
80
|
+
app:
|
|
81
|
+
payment:
|
|
82
|
+
base-url: ${PAYMENT_BASE_URL} # value injected from the environment
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Enable with `@ConfigurationPropertiesScan`; inject `PaymentProperties` — never `@Value` scattered through services.
|
|
86
|
+
|
|
87
|
+
## Migration discipline
|
|
88
|
+
|
|
89
|
+
```sql
|
|
90
|
+
-- src/main/resources/db/migration/V7__add_confirmation_sent_at_to_orders.sql
|
|
91
|
+
alter table orders add column confirmation_sent_at timestamptz;
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
- One migration file per schema change, applied by the repo's tool (Flyway shown; Liquibase equivalent).
|
|
95
|
+
- CI migrates a clean database; `ddl-auto` stays `validate` (or `none`) outside local scratch.
|
|
96
|
+
- Entity change and migration ship in the same commit.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Reference: Spring Boot web layer (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/spring-boot` — thin controller, DTO records, mapper, controller advice. Read when adding or changing an endpoint.
|
|
4
|
+
|
|
5
|
+
## Request/response DTOs (records) + controller
|
|
6
|
+
|
|
7
|
+
```java
|
|
8
|
+
// api/order/OrderDtos.java
|
|
9
|
+
public record CreateOrderRequest(
|
|
10
|
+
@NotNull UUID customerId,
|
|
11
|
+
@NotEmpty List<@Valid OrderItemRequest> items) {
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public record OrderResponse(UUID id, String status, BigDecimal total, Instant createdAt) {
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```java
|
|
19
|
+
// api/order/OrderController.java
|
|
20
|
+
@RestController
|
|
21
|
+
@RequestMapping("/api/orders")
|
|
22
|
+
class OrderController {
|
|
23
|
+
|
|
24
|
+
private final OrderService orderService; // constructor injection, final
|
|
25
|
+
|
|
26
|
+
OrderController(OrderService orderService) {
|
|
27
|
+
this.orderService = orderService;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@PostMapping
|
|
31
|
+
@ResponseStatus(HttpStatus.CREATED)
|
|
32
|
+
OrderResponse create(@Valid @RequestBody CreateOrderRequest request,
|
|
33
|
+
@AuthenticationPrincipal AppPrincipal principal) {
|
|
34
|
+
Order order = orderService.place(principal.userId(), request);
|
|
35
|
+
return OrderMapper.toResponse(order); // entity never leaves the layer
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@GetMapping("/{id}")
|
|
39
|
+
OrderResponse get(@PathVariable UUID id, @AuthenticationPrincipal AppPrincipal principal) {
|
|
40
|
+
return OrderMapper.toResponse(orderService.getForUser(principal.userId(), id));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Mapper (explicit, boring, testable)
|
|
46
|
+
|
|
47
|
+
```java
|
|
48
|
+
// api/order/OrderMapper.java
|
|
49
|
+
final class OrderMapper {
|
|
50
|
+
private OrderMapper() {}
|
|
51
|
+
|
|
52
|
+
static OrderResponse toResponse(Order order) {
|
|
53
|
+
return new OrderResponse(
|
|
54
|
+
order.getId(),
|
|
55
|
+
order.getStatus().name(),
|
|
56
|
+
order.getTotal(),
|
|
57
|
+
order.getCreatedAt());
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Typed exceptions → one error envelope
|
|
63
|
+
|
|
64
|
+
```java
|
|
65
|
+
// domain/DomainExceptions.java
|
|
66
|
+
public class OrderNotFoundException extends RuntimeException {
|
|
67
|
+
public OrderNotFoundException(UUID id) {
|
|
68
|
+
super("order %s not found".formatted(id));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
```java
|
|
74
|
+
// api/ApiExceptionHandler.java
|
|
75
|
+
@RestControllerAdvice
|
|
76
|
+
class ApiExceptionHandler {
|
|
77
|
+
|
|
78
|
+
@ExceptionHandler(OrderNotFoundException.class)
|
|
79
|
+
ProblemDetail notFound(OrderNotFoundException ex) {
|
|
80
|
+
return ProblemDetail.forStatusAndDetail(HttpStatus.NOT_FOUND, ex.getMessage());
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@ExceptionHandler(MethodArgumentNotValidException.class)
|
|
84
|
+
ProblemDetail invalid(MethodArgumentNotValidException ex) {
|
|
85
|
+
ProblemDetail pd = ProblemDetail.forStatus(HttpStatus.UNPROCESSABLE_ENTITY);
|
|
86
|
+
pd.setProperty("errors", ex.getBindingResult().getFieldErrors().stream()
|
|
87
|
+
.map(f -> Map.of("field", f.getField(), "message", f.getDefaultMessage()))
|
|
88
|
+
.toList());
|
|
89
|
+
return pd;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Fallback: log with correlation id, return an opaque 500 — never the stack trace.
|
|
93
|
+
@ExceptionHandler(Exception.class)
|
|
94
|
+
ProblemDetail unexpected(Exception ex) {
|
|
95
|
+
return ProblemDetail.forStatusAndDetail(HttpStatus.INTERNAL_SERVER_ERROR, "unexpected error");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Follow whichever error envelope the repo already uses (ProblemDetail here) — one advice class, one shape, everywhere.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Reference: Supabase clients and session-refresh middleware (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/supabase-nextjs`.
|
|
4
|
+
|
|
5
|
+
## Browser and server clients (never mixed)
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// src/lib/supabase/client.ts (browser client)
|
|
9
|
+
import { createBrowserClient } from '@supabase/ssr'
|
|
10
|
+
import type { Database } from '~/types/database.types'
|
|
11
|
+
|
|
12
|
+
export function createClient() {
|
|
13
|
+
return createBrowserClient<Database>(
|
|
14
|
+
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
|
15
|
+
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// src/lib/supabase/server.ts (server-side, reads/writes cookies)
|
|
20
|
+
import { createServerClient } from '@supabase/ssr'
|
|
21
|
+
import { cookies } from 'next/headers'
|
|
22
|
+
import type { Database } from '~/types/database.types'
|
|
23
|
+
|
|
24
|
+
export async function createClient() {
|
|
25
|
+
const cookieStore = await cookies()
|
|
26
|
+
return createServerClient<Database>(
|
|
27
|
+
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
|
28
|
+
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
|
29
|
+
{
|
|
30
|
+
cookies: {
|
|
31
|
+
getAll: () => cookieStore.getAll(),
|
|
32
|
+
setAll: (cookiesToSet) => {
|
|
33
|
+
cookiesToSet.forEach(({ name, value, options }) =>
|
|
34
|
+
cookieStore.set(name, value, options)
|
|
35
|
+
)
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Session-refresh middleware
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
// middleware.ts
|
|
47
|
+
import { createServerClient } from '@supabase/ssr'
|
|
48
|
+
import { NextResponse, type NextRequest } from 'next/server'
|
|
49
|
+
|
|
50
|
+
export async function middleware(request: NextRequest) {
|
|
51
|
+
let supabaseResponse = NextResponse.next({ request })
|
|
52
|
+
const supabase = createServerClient(
|
|
53
|
+
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
|
54
|
+
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
|
55
|
+
{
|
|
56
|
+
cookies: {
|
|
57
|
+
getAll: () => request.cookies.getAll(),
|
|
58
|
+
setAll: (c) => c.forEach(({ name, value, options }) =>
|
|
59
|
+
supabaseResponse.cookies.set(name, value, options)),
|
|
60
|
+
},
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
await supabase.auth.getUser() // refreshes the token automatically
|
|
64
|
+
return supabaseResponse
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export const config = { matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'] }
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Realtime subscription (Client Component, cleaned up on unmount)
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
'use client'
|
|
74
|
+
import { useEffect, useState } from 'react'
|
|
75
|
+
import { createClient } from '~/lib/supabase/client'
|
|
76
|
+
import type { Database } from '~/types/database.types'
|
|
77
|
+
|
|
78
|
+
type Post = Database['public']['Tables']['posts']['Row']
|
|
79
|
+
|
|
80
|
+
export function RealtimePosts({ initialPosts }: { initialPosts: Post[] }) {
|
|
81
|
+
const [posts, setPosts] = useState(initialPosts)
|
|
82
|
+
const supabase = createClient()
|
|
83
|
+
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
const channel = supabase
|
|
86
|
+
.channel('posts-realtime')
|
|
87
|
+
.on('postgres_changes',
|
|
88
|
+
{ event: 'INSERT', schema: 'public', table: 'posts', filter: 'published=eq.true' },
|
|
89
|
+
(payload) => setPosts(prev => [payload.new as Post, ...prev])
|
|
90
|
+
)
|
|
91
|
+
.on('postgres_changes',
|
|
92
|
+
{ event: 'DELETE', schema: 'public', table: 'posts' },
|
|
93
|
+
(payload) => setPosts(prev => prev.filter(p => p.id !== payload.old.id))
|
|
94
|
+
)
|
|
95
|
+
.subscribe()
|
|
96
|
+
|
|
97
|
+
return () => { void supabase.removeChannel(channel) }
|
|
98
|
+
}, [supabase])
|
|
99
|
+
|
|
100
|
+
return <ul>{posts.map(p => <li key={p.id}>{p.title}</li>)}</ul>
|
|
101
|
+
}
|
|
102
|
+
```
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Reference: Supabase RLS policies and storage buckets (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/supabase-nextjs`.
|
|
4
|
+
|
|
5
|
+
## Row Level Security policies (deny-by-default)
|
|
6
|
+
|
|
7
|
+
```sql
|
|
8
|
+
-- supabase/migrations/001_init.sql
|
|
9
|
+
|
|
10
|
+
CREATE TABLE profiles (
|
|
11
|
+
id UUID REFERENCES auth.users PRIMARY KEY,
|
|
12
|
+
username TEXT UNIQUE NOT NULL,
|
|
13
|
+
avatar_url TEXT,
|
|
14
|
+
updated_at TIMESTAMPTZ DEFAULT NOW()
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
ALTER TABLE profiles ENABLE ROW LEVEL SECURITY;
|
|
18
|
+
|
|
19
|
+
CREATE POLICY "Public profiles are viewable by everyone"
|
|
20
|
+
ON profiles FOR SELECT USING (true);
|
|
21
|
+
|
|
22
|
+
CREATE POLICY "Users can insert their own profile"
|
|
23
|
+
ON profiles FOR INSERT WITH CHECK (auth.uid() = id);
|
|
24
|
+
|
|
25
|
+
CREATE POLICY "Users can update their own profile"
|
|
26
|
+
ON profiles FOR UPDATE USING (auth.uid() = id);
|
|
27
|
+
|
|
28
|
+
CREATE TABLE posts (
|
|
29
|
+
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
|
|
30
|
+
title TEXT NOT NULL,
|
|
31
|
+
body TEXT NOT NULL,
|
|
32
|
+
author_id UUID REFERENCES profiles(id) ON DELETE CASCADE NOT NULL,
|
|
33
|
+
published BOOLEAN DEFAULT false,
|
|
34
|
+
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
ALTER TABLE posts ENABLE ROW LEVEL SECURITY;
|
|
38
|
+
|
|
39
|
+
CREATE POLICY "Published posts viewable by all"
|
|
40
|
+
ON posts FOR SELECT USING (published = true OR author_id = auth.uid());
|
|
41
|
+
|
|
42
|
+
CREATE POLICY "Authors can insert posts"
|
|
43
|
+
ON posts FOR INSERT WITH CHECK (auth.uid() = author_id);
|
|
44
|
+
|
|
45
|
+
CREATE POLICY "Authors can update their posts"
|
|
46
|
+
ON posts FOR UPDATE USING (auth.uid() = author_id);
|
|
47
|
+
|
|
48
|
+
CREATE POLICY "Authors can delete their posts"
|
|
49
|
+
ON posts FOR DELETE USING (auth.uid() = author_id);
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Private storage bucket with owner-only policies
|
|
53
|
+
|
|
54
|
+
```sql
|
|
55
|
+
INSERT INTO storage.buckets (id, name, public) VALUES ('avatars', 'avatars', false);
|
|
56
|
+
|
|
57
|
+
CREATE POLICY "Avatar images are accessible by owner"
|
|
58
|
+
ON storage.objects FOR SELECT
|
|
59
|
+
USING (bucket_id = 'avatars' AND auth.uid() = owner);
|
|
60
|
+
|
|
61
|
+
CREATE POLICY "Users can upload their own avatar"
|
|
62
|
+
ON storage.objects FOR INSERT
|
|
63
|
+
WITH CHECK (
|
|
64
|
+
bucket_id = 'avatars'
|
|
65
|
+
AND auth.uid() = owner
|
|
66
|
+
AND (storage.foldername(name))[1] = auth.uid()::text
|
|
67
|
+
);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Upload from a Server Action
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
async function uploadAvatar(file: File) {
|
|
74
|
+
const supabase = await createClient() // server client
|
|
75
|
+
const { data: { user } } = await supabase.auth.getUser()
|
|
76
|
+
if (!user) throw new Error('Not authenticated')
|
|
77
|
+
|
|
78
|
+
const ext = file.name.split('.').pop()
|
|
79
|
+
const path = `${user.id}/avatar.${ext}`
|
|
80
|
+
const { error } = await supabase.storage.from('avatars').upload(path, file, { upsert: true })
|
|
81
|
+
if (error) throw error
|
|
82
|
+
|
|
83
|
+
const { data } = supabase.storage.from('avatars').getPublicUrl(path)
|
|
84
|
+
return data.publicUrl
|
|
85
|
+
}
|
|
86
|
+
```
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Reference: SvelteKit hooks middleware and shared client state (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/svelte-sveltekit`.
|
|
4
|
+
|
|
5
|
+
## Global middleware — attach the user to locals
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// src/hooks.server.ts
|
|
9
|
+
import type { Handle } from '@sveltejs/kit';
|
|
10
|
+
import { validateSession } from '$lib/server/auth';
|
|
11
|
+
|
|
12
|
+
export const handle: Handle = async ({ event, resolve }) => {
|
|
13
|
+
const sessionId = event.cookies.get('session');
|
|
14
|
+
if (sessionId) {
|
|
15
|
+
event.locals.user = await validateSession(sessionId);
|
|
16
|
+
}
|
|
17
|
+
return resolve(event);
|
|
18
|
+
};
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Shared client state — custom store with persistence
|
|
22
|
+
|
|
23
|
+
Prefer runes (`$state`/`$derived` in `.svelte.ts` modules) for new shared reactive state where the project's Svelte version supports them; the store contract below remains valid and interoperable.
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
// lib/stores/theme.ts
|
|
27
|
+
import { writable, derived } from 'svelte/store';
|
|
28
|
+
import { browser } from '$app/environment';
|
|
29
|
+
|
|
30
|
+
function createThemeStore() {
|
|
31
|
+
const { subscribe, set, update } = writable<'light' | 'dark'>(
|
|
32
|
+
browser ? (localStorage.getItem('theme') as 'light' | 'dark') ?? 'light' : 'light'
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
subscribe,
|
|
37
|
+
toggle: () => update((t) => {
|
|
38
|
+
const next = t === 'light' ? 'dark' : 'light';
|
|
39
|
+
if (browser) localStorage.setItem('theme', next);
|
|
40
|
+
return next;
|
|
41
|
+
}),
|
|
42
|
+
set,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const theme = createThemeStore();
|
|
47
|
+
export const isDark = derived(theme, ($t) => $t === 'dark');
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## File anatomy
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
src/
|
|
54
|
+
├── lib/
|
|
55
|
+
│ ├── server/ # NEVER exposed to the client ($lib/server/*)
|
|
56
|
+
│ │ ├── db/ # ORM config + queries
|
|
57
|
+
│ │ └── auth.ts # Session validation
|
|
58
|
+
│ ├── components/ # Reusable .svelte components (ui/, layout/)
|
|
59
|
+
│ ├── stores/ # Shared client state
|
|
60
|
+
│ └── utils.ts # Pure helpers
|
|
61
|
+
├── routes/
|
|
62
|
+
│ ├── +layout.svelte / +layout.server.ts # Root layout + session load
|
|
63
|
+
│ ├── (public)/ # Route group without auth
|
|
64
|
+
│ ├── (app)/ # Route group with auth guard in +layout.server.ts
|
|
65
|
+
│ └── api/ # API routes (+server.ts)
|
|
66
|
+
└── hooks.server.ts # Global middleware (auth, logging)
|
|
67
|
+
```
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Reference: SvelteKit load functions and form actions (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/svelte-sveltekit`.
|
|
4
|
+
|
|
5
|
+
## Server load with auth check
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// routes/(app)/users/+page.server.ts
|
|
9
|
+
import { db } from '$lib/server/db';
|
|
10
|
+
import { users } from '$lib/server/db/schema';
|
|
11
|
+
import { error } from '@sveltejs/kit';
|
|
12
|
+
import type { PageServerLoad } from './$types';
|
|
13
|
+
|
|
14
|
+
export const load: PageServerLoad = async ({ locals }) => {
|
|
15
|
+
if (!locals.user) throw error(401, 'Unauthorized');
|
|
16
|
+
|
|
17
|
+
const allUsers = await db.select().from(users).orderBy(users.createdAt);
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
users: allUsers,
|
|
21
|
+
meta: { title: 'Users', count: allUsers.length },
|
|
22
|
+
};
|
|
23
|
+
// In +page.svelte the `data` prop is typed automatically from this return.
|
|
24
|
+
};
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Form action with Superforms + Zod
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
// routes/(app)/users/new/schema.ts
|
|
31
|
+
import { z } from 'zod';
|
|
32
|
+
|
|
33
|
+
export const createUserSchema = z.object({
|
|
34
|
+
name: z.string().min(2, 'Name must have at least 2 characters'),
|
|
35
|
+
email: z.string().email('Invalid email'),
|
|
36
|
+
role: z.enum(['admin', 'member']),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// routes/(app)/users/new/+page.server.ts
|
|
40
|
+
import { superValidate, fail } from 'sveltekit-superforms';
|
|
41
|
+
import { zod } from 'sveltekit-superforms/adapters';
|
|
42
|
+
import { createUserSchema } from './schema';
|
|
43
|
+
|
|
44
|
+
export const load = async () => {
|
|
45
|
+
const form = await superValidate(zod(createUserSchema));
|
|
46
|
+
return { form };
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const actions = {
|
|
50
|
+
default: async ({ request }) => {
|
|
51
|
+
const form = await superValidate(request, zod(createUserSchema));
|
|
52
|
+
if (!form.valid) return fail(400, { form });
|
|
53
|
+
|
|
54
|
+
await db.insert(users).values(form.data);
|
|
55
|
+
return { form };
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```svelte
|
|
61
|
+
<!-- routes/(app)/users/new/+page.svelte -->
|
|
62
|
+
<script lang="ts">
|
|
63
|
+
import { superForm } from 'sveltekit-superforms';
|
|
64
|
+
export let data;
|
|
65
|
+
|
|
66
|
+
const { form, errors, enhance, delayed } = superForm(data.form);
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<form method="POST" use:enhance>
|
|
70
|
+
<input name="name" bind:value={$form.name} />
|
|
71
|
+
{#if $errors.name}<span class="text-red-500">{$errors.name}</span>{/if}
|
|
72
|
+
|
|
73
|
+
<input name="email" bind:value={$form.email} />
|
|
74
|
+
{#if $errors.email}<span class="text-red-500">{$errors.email}</span>{/if}
|
|
75
|
+
|
|
76
|
+
<button disabled={$delayed}>
|
|
77
|
+
{$delayed ? 'Saving…' : 'Create user'}
|
|
78
|
+
</button>
|
|
79
|
+
</form>
|
|
80
|
+
```
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Reference: tRPC routers, client hooks, and server callers (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/t3-stack`. Read when adding a router, consuming procedures from client components, or calling tRPC from Server Components.
|
|
4
|
+
|
|
5
|
+
## Router with input validation and ownership checks
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// src/server/api/routers/post.ts
|
|
9
|
+
import { z } from 'zod'
|
|
10
|
+
import { TRPCError } from '@trpc/server'
|
|
11
|
+
import { createTRPCRouter, protectedProcedure, publicProcedure } from '../trpc'
|
|
12
|
+
|
|
13
|
+
export const postRouter = createTRPCRouter({
|
|
14
|
+
list: publicProcedure
|
|
15
|
+
.input(z.object({ limit: z.number().min(1).max(100).default(20), cursor: z.string().optional() }))
|
|
16
|
+
.query(async ({ ctx, input }) => {
|
|
17
|
+
const posts = await ctx.db.post.findMany({
|
|
18
|
+
take: input.limit + 1,
|
|
19
|
+
cursor: input.cursor ? { id: input.cursor } : undefined,
|
|
20
|
+
orderBy: { createdAt: 'desc' },
|
|
21
|
+
include: { author: { select: { id: true, name: true, image: true } } },
|
|
22
|
+
})
|
|
23
|
+
const nextCursor = posts.length > input.limit ? posts.pop()!.id : undefined
|
|
24
|
+
return { posts, nextCursor }
|
|
25
|
+
}),
|
|
26
|
+
|
|
27
|
+
create: protectedProcedure
|
|
28
|
+
.input(z.object({ title: z.string().min(1).max(200), body: z.string().min(1) }))
|
|
29
|
+
.mutation(async ({ ctx, input }) => {
|
|
30
|
+
return ctx.db.post.create({ data: { ...input, authorId: ctx.session.user.id } })
|
|
31
|
+
}),
|
|
32
|
+
|
|
33
|
+
delete: protectedProcedure
|
|
34
|
+
.input(z.object({ id: z.string().cuid() }))
|
|
35
|
+
.mutation(async ({ ctx, input }) => {
|
|
36
|
+
const post = await ctx.db.post.findUnique({ where: { id: input.id } })
|
|
37
|
+
if (!post) throw new TRPCError({ code: 'NOT_FOUND' })
|
|
38
|
+
if (post.authorId !== ctx.session.user.id) throw new TRPCError({ code: 'FORBIDDEN' })
|
|
39
|
+
return ctx.db.post.delete({ where: { id: input.id } })
|
|
40
|
+
}),
|
|
41
|
+
})
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Client component (React hooks)
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
'use client'
|
|
48
|
+
import { trpc } from '~/trpc/client'
|
|
49
|
+
|
|
50
|
+
function PostList() {
|
|
51
|
+
const utils = trpc.useUtils()
|
|
52
|
+
const { data, isLoading } = trpc.post.list.useQuery({ limit: 10 })
|
|
53
|
+
const createPost = trpc.post.create.useMutation({
|
|
54
|
+
onSuccess: () => utils.post.list.invalidate(),
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
if (isLoading) return <p>Loading...</p>
|
|
58
|
+
return <ul>{data?.posts.map(p => <li key={p.id}>{p.title}</li>)}</ul>
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Server Component — direct caller, no HTTP
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
// src/app/dashboard/page.tsx
|
|
66
|
+
import { createCaller } from '~/server/api/root'
|
|
67
|
+
import { createTRPCContext } from '~/server/api/trpc'
|
|
68
|
+
|
|
69
|
+
export default async function DashboardPage() {
|
|
70
|
+
const ctx = await createTRPCContext()
|
|
71
|
+
const caller = createCaller(ctx)
|
|
72
|
+
const { posts } = await caller.post.list({ limit: 5 })
|
|
73
|
+
return <ul>{posts.map(p => <li key={p.id}>{p.title}</li>)}</ul>
|
|
74
|
+
}
|
|
75
|
+
```
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Reference: tRPC context and procedure builders (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/t3-stack`. Read when wiring the tRPC context, adding a procedure kind, or shaping error formatting.
|
|
4
|
+
|
|
5
|
+
## Context + protected procedure
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// src/server/api/trpc.ts
|
|
9
|
+
import { initTRPC, TRPCError } from '@trpc/server'
|
|
10
|
+
import { ZodError } from 'zod'
|
|
11
|
+
import superjson from 'superjson'
|
|
12
|
+
import type { Session } from 'next-auth'
|
|
13
|
+
import { auth } from '../auth'
|
|
14
|
+
import { db } from '../db'
|
|
15
|
+
|
|
16
|
+
interface CreateContextOptions { session: Session | null }
|
|
17
|
+
|
|
18
|
+
export const createTRPCContext = async (): Promise<CreateContextOptions & { db: typeof db }> => {
|
|
19
|
+
const session = await auth()
|
|
20
|
+
return { session, db }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const t = initTRPC.context<typeof createTRPCContext>().create({
|
|
24
|
+
transformer: superjson,
|
|
25
|
+
errorFormatter({ shape, error }) {
|
|
26
|
+
return {
|
|
27
|
+
...shape,
|
|
28
|
+
data: {
|
|
29
|
+
...shape.data,
|
|
30
|
+
zodError: error.cause instanceof ZodError ? error.cause.flatten() : null,
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
export const createCallerFactory = t.createCallerFactory
|
|
37
|
+
export const createTRPCRouter = t.router
|
|
38
|
+
export const publicProcedure = t.procedure
|
|
39
|
+
|
|
40
|
+
export const protectedProcedure = t.procedure.use(({ ctx, next }) => {
|
|
41
|
+
if (!ctx.session?.user) {
|
|
42
|
+
throw new TRPCError({ code: 'UNAUTHORIZED' })
|
|
43
|
+
}
|
|
44
|
+
return next({ ctx: { ...ctx, session: ctx.session } })
|
|
45
|
+
})
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Prisma client singleton
|
|
49
|
+
|
|
50
|
+
Avoid hot-reload connection exhaustion in dev by stashing the client on `globalThis`:
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
// src/server/db.ts
|
|
54
|
+
import { PrismaClient } from '@prisma/client'
|
|
55
|
+
|
|
56
|
+
const globalForPrisma = globalThis as unknown as { prisma?: PrismaClient }
|
|
57
|
+
|
|
58
|
+
export const db = globalForPrisma.prisma ?? new PrismaClient()
|
|
59
|
+
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = db
|
|
60
|
+
```
|