@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,55 @@
|
|
|
1
|
+
# Reference: Expo Router navigation and auth redirect (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/react-native-expo`. Read when wiring the root layout, providers, or the auth flow.
|
|
4
|
+
|
|
5
|
+
## Root layout: providers + segment-based auth redirect
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// app/_layout.tsx — root layout (providers + auth redirect)
|
|
9
|
+
import { Stack, useRouter, useSegments } from 'expo-router';
|
|
10
|
+
import { useEffect } from 'react';
|
|
11
|
+
import { QueryClientProvider } from '@tanstack/react-query';
|
|
12
|
+
import { useAuthStore } from '@/stores/auth.store';
|
|
13
|
+
import { queryClient } from '@/lib/query-client';
|
|
14
|
+
|
|
15
|
+
export default function RootLayout() {
|
|
16
|
+
const { isAuthenticated } = useAuthStore();
|
|
17
|
+
const segments = useSegments();
|
|
18
|
+
const router = useRouter();
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
const inAuthGroup = segments[0] === '(auth)';
|
|
22
|
+
|
|
23
|
+
if (!isAuthenticated && !inAuthGroup) {
|
|
24
|
+
router.replace('/(auth)/login');
|
|
25
|
+
} else if (isAuthenticated && inAuthGroup) {
|
|
26
|
+
router.replace('/(tabs)');
|
|
27
|
+
}
|
|
28
|
+
}, [isAuthenticated, segments]);
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<QueryClientProvider client={queryClient}>
|
|
32
|
+
<Stack screenOptions={{ headerShown: false }} />
|
|
33
|
+
</QueryClientProvider>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Route anatomy
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
app/ # Expo Router file-based routing
|
|
42
|
+
├── (auth)/ # Auth route group (login, register)
|
|
43
|
+
│ ├── _layout.tsx # Stack navigator for auth screens
|
|
44
|
+
│ ├── login.tsx
|
|
45
|
+
│ └── register.tsx
|
|
46
|
+
├── (tabs)/ # Main app with bottom tabs
|
|
47
|
+
│ ├── _layout.tsx # Tab navigator config
|
|
48
|
+
│ ├── index.tsx # Home tab
|
|
49
|
+
│ └── profile.tsx
|
|
50
|
+
├── [id].tsx # Dynamic route: /123
|
|
51
|
+
├── _layout.tsx # Root layout (providers, auth redirect)
|
|
52
|
+
└── +not-found.tsx # 404 screen
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Deep links: configure `scheme` in `app.json` and resolve with `expo-linking`. Push notifications: `expo-notifications` — register the device token and send it to the API.
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Reference: Zustand store and TanStack Query patterns (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/react-ts-zustand-query`.
|
|
4
|
+
|
|
5
|
+
## Zustand store with immer + persist, consumed via selectors
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// stores/ui.store.ts
|
|
9
|
+
import { create } from 'zustand';
|
|
10
|
+
import { devtools, persist } from 'zustand/middleware';
|
|
11
|
+
import { immer } from 'zustand/middleware/immer';
|
|
12
|
+
|
|
13
|
+
interface UIState {
|
|
14
|
+
sidebarOpen: boolean;
|
|
15
|
+
notifications: Notification[];
|
|
16
|
+
toggleSidebar: () => void;
|
|
17
|
+
addNotification: (n: Notification) => void;
|
|
18
|
+
dismissNotification: (id: string) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const useUIStore = create<UIState>()(
|
|
22
|
+
devtools(
|
|
23
|
+
persist(
|
|
24
|
+
immer((set) => ({
|
|
25
|
+
sidebarOpen: true,
|
|
26
|
+
notifications: [],
|
|
27
|
+
toggleSidebar: () => set((s) => { s.sidebarOpen = !s.sidebarOpen; }),
|
|
28
|
+
addNotification: (n) => set((s) => { s.notifications.push(n); }),
|
|
29
|
+
dismissNotification: (id) => set((s) => {
|
|
30
|
+
s.notifications = s.notifications.filter((n) => n.id !== id);
|
|
31
|
+
}),
|
|
32
|
+
})),
|
|
33
|
+
{ name: 'ui-store' }
|
|
34
|
+
),
|
|
35
|
+
{ name: 'UIStore' }
|
|
36
|
+
)
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
// CORRECT — specific selector (minimal re-renders)
|
|
40
|
+
const sidebarOpen = useUIStore((s) => s.sidebarOpen);
|
|
41
|
+
|
|
42
|
+
// WRONG — no selector (re-renders on ANY store change)
|
|
43
|
+
const store = useUIStore();
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Query-key factory and hooks
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
// features/users/api.ts
|
|
50
|
+
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
|
51
|
+
import { api } from '@/lib/axios';
|
|
52
|
+
|
|
53
|
+
export const userKeys = {
|
|
54
|
+
all: ['users'] as const,
|
|
55
|
+
lists: () => [...userKeys.all, 'list'] as const,
|
|
56
|
+
list: (filters: Record<string, unknown>) => [...userKeys.lists(), filters] as const,
|
|
57
|
+
details: () => [...userKeys.all, 'detail'] as const,
|
|
58
|
+
detail: (id: string) => [...userKeys.details(), id] as const,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export function useUsers(filters = {}) {
|
|
62
|
+
return useQuery({
|
|
63
|
+
queryKey: userKeys.list(filters),
|
|
64
|
+
queryFn: () => api.get('/users', { params: filters }).then((r) => r.data),
|
|
65
|
+
staleTime: 5 * 60 * 1000, // explicit — never rely on the default
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function useUser(id: string) {
|
|
70
|
+
return useQuery({
|
|
71
|
+
queryKey: userKeys.detail(id),
|
|
72
|
+
queryFn: () => api.get(`/users/${id}`).then((r) => r.data),
|
|
73
|
+
enabled: !!id, // conditional query
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function useDeleteUser() {
|
|
78
|
+
const queryClient = useQueryClient();
|
|
79
|
+
return useMutation({
|
|
80
|
+
mutationFn: (id: string) => api.delete(`/users/${id}`),
|
|
81
|
+
onSuccess: () => {
|
|
82
|
+
queryClient.invalidateQueries({ queryKey: userKeys.lists() });
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## HTTP client with auth interceptors
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
// lib/axios.ts
|
|
92
|
+
import axios from 'axios';
|
|
93
|
+
import { useAuthStore } from '@/stores/auth.store';
|
|
94
|
+
|
|
95
|
+
export const api = axios.create({
|
|
96
|
+
baseURL: import.meta.env.VITE_API_URL,
|
|
97
|
+
timeout: 10000,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
api.interceptors.request.use((config) => {
|
|
101
|
+
const token = useAuthStore.getState().token;
|
|
102
|
+
if (token) config.headers.Authorization = `Bearer ${token}`;
|
|
103
|
+
return config;
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
api.interceptors.response.use(
|
|
107
|
+
(res) => res,
|
|
108
|
+
async (error) => {
|
|
109
|
+
if (error.response?.status === 401 && !error.config._retry) {
|
|
110
|
+
error.config._retry = true;
|
|
111
|
+
try {
|
|
112
|
+
await useAuthStore.getState().refreshToken();
|
|
113
|
+
return api(error.config);
|
|
114
|
+
} catch {
|
|
115
|
+
useAuthStore.getState().logout();
|
|
116
|
+
window.location.href = '/login';
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return Promise.reject(error);
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Testing a query hook with MSW
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
// features/users/__tests__/useUsers.test.tsx
|
|
128
|
+
import { renderHook, waitFor } from '@testing-library/react';
|
|
129
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
130
|
+
import { http, HttpResponse } from 'msw';
|
|
131
|
+
import { setupServer } from 'msw/node';
|
|
132
|
+
import { useUsers } from '../api';
|
|
133
|
+
|
|
134
|
+
const server = setupServer(
|
|
135
|
+
http.get('/api/users', () => HttpResponse.json([{ id: '1', name: 'Test' }])),
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
beforeAll(() => server.listen());
|
|
139
|
+
afterEach(() => server.resetHandlers());
|
|
140
|
+
afterAll(() => server.close());
|
|
141
|
+
|
|
142
|
+
function wrapper({ children }: { children: React.ReactNode }) {
|
|
143
|
+
const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
|
144
|
+
return <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
test('fetches users', async () => {
|
|
148
|
+
const { result } = renderHook(() => useUsers(), { wrapper });
|
|
149
|
+
await waitFor(() => expect(result.current.isSuccess).toBe(true));
|
|
150
|
+
expect(result.current.data).toHaveLength(1);
|
|
151
|
+
});
|
|
152
|
+
```
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Reference: React feature module (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/react-typescript` — feature folder anatomy, query-key factory, and mutation invalidation. Evicted from the standing fragment; read only when creating or restructuring a feature.
|
|
4
|
+
|
|
5
|
+
## Feature types + API hooks
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// src/features/projects/types.ts
|
|
9
|
+
export interface Project {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
status: 'active' | 'archived';
|
|
13
|
+
createdAt: string;
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
// src/features/projects/api.ts
|
|
19
|
+
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
|
20
|
+
import { apiClient } from '@/lib/api-client';
|
|
21
|
+
import type { Project } from './types';
|
|
22
|
+
|
|
23
|
+
// Query-key factory: the single place keys are defined for this feature.
|
|
24
|
+
export const projectKeys = {
|
|
25
|
+
all: ['projects'] as const,
|
|
26
|
+
list: (filters: Record<string, unknown>) => [...projectKeys.all, 'list', filters] as const,
|
|
27
|
+
detail: (id: string) => [...projectKeys.all, 'detail', id] as const,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export function useProjects(filters = {}) {
|
|
31
|
+
return useQuery({
|
|
32
|
+
queryKey: projectKeys.list(filters),
|
|
33
|
+
queryFn: () => apiClient.get<Project[]>('/projects', { params: filters }),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function useCreateProject() {
|
|
38
|
+
const queryClient = useQueryClient();
|
|
39
|
+
return useMutation({
|
|
40
|
+
mutationFn: (data: Omit<Project, 'id' | 'createdAt'>) =>
|
|
41
|
+
apiClient.post<Project>('/projects', data),
|
|
42
|
+
onSuccess: () => {
|
|
43
|
+
// Invalidate through the factory — never inline string arrays.
|
|
44
|
+
queryClient.invalidateQueries({ queryKey: projectKeys.all });
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Component typing convention
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
// ✅ explicit props interface, named after the component
|
|
54
|
+
interface UserCardProps {
|
|
55
|
+
user: User;
|
|
56
|
+
onEdit?: (id: string) => void;
|
|
57
|
+
}
|
|
58
|
+
export function UserCard({ user, onEdit }: UserCardProps) { /* ... */ }
|
|
59
|
+
|
|
60
|
+
// ❌ untyped inline props
|
|
61
|
+
export function UserCard(props: any) { /* ... */ }
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Use `React.ComponentPropsWithoutRef<'element'>` when wrapping native HTML elements.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Reference: schema-first forms and Zustand stores (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/react-typescript`. Read when building a form or a client-state store.
|
|
4
|
+
|
|
5
|
+
## Form: Zod schema first, then React Hook Form
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// src/features/projects/components/CreateProjectForm.tsx
|
|
9
|
+
import { useForm } from 'react-hook-form';
|
|
10
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
import { useCreateProject } from '../api';
|
|
13
|
+
|
|
14
|
+
const createProjectSchema = z.object({
|
|
15
|
+
name: z.string().min(3, 'Name must have at least 3 characters'),
|
|
16
|
+
status: z.enum(['active', 'archived']),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
type FormData = z.infer<typeof createProjectSchema>;
|
|
20
|
+
|
|
21
|
+
export function CreateProjectForm() {
|
|
22
|
+
const { register, handleSubmit, formState: { errors } } = useForm<FormData>({
|
|
23
|
+
resolver: zodResolver(createProjectSchema),
|
|
24
|
+
});
|
|
25
|
+
const createProject = useCreateProject();
|
|
26
|
+
|
|
27
|
+
const onSubmit = (data: FormData) => createProject.mutate(data);
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
31
|
+
<input {...register('name')} placeholder="Project name" />
|
|
32
|
+
{errors.name && <p className="text-red-500 text-sm">{errors.name.message}</p>}
|
|
33
|
+
<button type="submit" disabled={createProject.isPending}>
|
|
34
|
+
{createProject.isPending ? 'Creating…' : 'Create project'}
|
|
35
|
+
</button>
|
|
36
|
+
</form>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Zustand store consumed via selectors
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
// src/stores/ui.store.ts
|
|
45
|
+
import { create } from 'zustand';
|
|
46
|
+
import { devtools } from 'zustand/middleware';
|
|
47
|
+
|
|
48
|
+
interface UIState {
|
|
49
|
+
sidebarOpen: boolean;
|
|
50
|
+
theme: 'light' | 'dark';
|
|
51
|
+
toggleSidebar: () => void;
|
|
52
|
+
setTheme: (theme: 'light' | 'dark') => void;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const useUIStore = create<UIState>()(
|
|
56
|
+
devtools(
|
|
57
|
+
(set) => ({
|
|
58
|
+
sidebarOpen: true,
|
|
59
|
+
theme: 'light',
|
|
60
|
+
toggleSidebar: () => set((s) => ({ sidebarOpen: !s.sidebarOpen })),
|
|
61
|
+
setTheme: (theme) => set({ theme }),
|
|
62
|
+
}),
|
|
63
|
+
{ name: 'ui-store' }
|
|
64
|
+
)
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
// Usage: const sidebarOpen = useUIStore((s) => s.sidebarOpen);
|
|
68
|
+
// ALWAYS select — a bare useUIStore() re-renders on every state change.
|
|
69
|
+
```
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Reference: React recipes (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/react-typescript` — protected route and optimistic update. Read when the task needs one of these patterns.
|
|
4
|
+
|
|
5
|
+
## Protected route
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
function ProtectedRoute({ children }: { children: React.ReactNode }) {
|
|
9
|
+
const { data: user, isLoading } = useCurrentUser();
|
|
10
|
+
if (isLoading) return <Spinner />;
|
|
11
|
+
if (!user) return <Navigate to="/login" replace />;
|
|
12
|
+
return <>{children}</>;
|
|
13
|
+
}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Auth flow: token in an httpOnly cookie, an api-client interceptor attaches it, and a 401 response redirects to login.
|
|
17
|
+
|
|
18
|
+
## Optimistic update
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
useMutation({
|
|
22
|
+
mutationFn: updateProject,
|
|
23
|
+
onMutate: async (newData) => {
|
|
24
|
+
await queryClient.cancelQueries({ queryKey: projectKeys.detail(id) });
|
|
25
|
+
const previous = queryClient.getQueryData(projectKeys.detail(id));
|
|
26
|
+
queryClient.setQueryData(projectKeys.detail(id), newData);
|
|
27
|
+
return { previous };
|
|
28
|
+
},
|
|
29
|
+
onError: (_err, _new, context) => {
|
|
30
|
+
// roll back to the snapshot on failure
|
|
31
|
+
queryClient.setQueryData(projectKeys.detail(id), context?.previous);
|
|
32
|
+
},
|
|
33
|
+
onSettled: () => {
|
|
34
|
+
queryClient.invalidateQueries({ queryKey: projectKeys.detail(id) });
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
```
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Reference: React testing harness (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/react-typescript` — MSW + QueryClient test setup. Read when writing the first test for a feature that fetches data.
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
// src/features/projects/__tests__/ProjectList.test.tsx
|
|
7
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
8
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
9
|
+
import { http, HttpResponse } from 'msw';
|
|
10
|
+
import { setupServer } from 'msw/node';
|
|
11
|
+
import { ProjectList } from '../components/ProjectList';
|
|
12
|
+
|
|
13
|
+
const server = setupServer(
|
|
14
|
+
http.get('/api/projects', () =>
|
|
15
|
+
HttpResponse.json([{ id: '1', name: 'Test', status: 'active' }])
|
|
16
|
+
),
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
beforeAll(() => server.listen());
|
|
20
|
+
afterEach(() => server.resetHandlers());
|
|
21
|
+
afterAll(() => server.close());
|
|
22
|
+
|
|
23
|
+
function renderWithProviders(ui: React.ReactElement) {
|
|
24
|
+
const queryClient = new QueryClient({
|
|
25
|
+
defaultOptions: { queries: { retry: false } }, // retries hide failures in tests
|
|
26
|
+
});
|
|
27
|
+
return render(
|
|
28
|
+
<QueryClientProvider client={queryClient}>{ui}</QueryClientProvider>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
test('renders project list from API', async () => {
|
|
33
|
+
renderWithProviders(<ProjectList />);
|
|
34
|
+
await waitFor(() => {
|
|
35
|
+
expect(screen.getByText('Test')).toBeInTheDocument();
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Rules embedded here: mock at the network boundary (MSW), never mock the query hooks themselves; a fresh `QueryClient` per test so caches never leak between tests.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Reference: realtime patterns (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `domain/realtime-websockets` — handshake authentication, pub/sub adapter wiring, TTL presence, event-handler offloading, and SSE cursor resume. Evicted from the standing fragment; read when implementing one of these mechanisms.
|
|
4
|
+
|
|
5
|
+
## Handshake authentication (Socket.io middleware)
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
// Authenticate ONCE at the handshake — never per event
|
|
9
|
+
io.use(async (socket, next) => {
|
|
10
|
+
const token = socket.handshake.auth.token;
|
|
11
|
+
try {
|
|
12
|
+
socket.user = await verifyJWT(token); // available in every handler
|
|
13
|
+
next();
|
|
14
|
+
} catch {
|
|
15
|
+
next(new Error('Authentication error'));
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Room joins still authorize against the resource every time:
|
|
21
|
+
|
|
22
|
+
```javascript
|
|
23
|
+
socket.on('join_room', async (room) => {
|
|
24
|
+
if (!(await canAccess(socket.user, room))) return socket.emit('error', 'forbidden');
|
|
25
|
+
await socket.join(room); // rooms named <resource_type>:<resource_id>, e.g. post:123
|
|
26
|
+
await updatePresence(room, socket.user.id);
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Scaling across instances (pub/sub adapter)
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
// ❌ WRONG: with N instances, a socket on instance 1 never sees an event emitted on instance 2
|
|
34
|
+
io.to(roomId).emit('message', data); // reaches only same-instance connections
|
|
35
|
+
|
|
36
|
+
// ✅ RIGHT: a Redis-backed adapter syncs rooms/events across all instances
|
|
37
|
+
import { createAdapter } from '@socket.io/redis-adapter';
|
|
38
|
+
import { createClient } from 'redis';
|
|
39
|
+
|
|
40
|
+
const pubClient = createClient({ url: process.env.REDIS_URL });
|
|
41
|
+
const subClient = pubClient.duplicate();
|
|
42
|
+
await Promise.all([pubClient.connect(), subClient.connect()]);
|
|
43
|
+
io.adapter(createAdapter(pubClient, subClient));
|
|
44
|
+
io.to(roomId).emit('message', data); // now reaches every client in the room, on any instance
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Presence with TTL + heartbeat (wrong vs right)
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
// ❌ WRONG: a server restart with no disconnect event strands the user "online" forever
|
|
51
|
+
await redis.hset(`presence:room:${roomId}`, userId, JSON.stringify({ online: true }));
|
|
52
|
+
|
|
53
|
+
// ✅ RIGHT: TTL as the safety net, heartbeat renews it
|
|
54
|
+
await redis.hset(`presence:${roomId}`, userId, Date.now());
|
|
55
|
+
await redis.expire(`presence:${roomId}`, 60); // 60s TTL
|
|
56
|
+
// client sends a heartbeat every ~30s → handler re-sets the key and TTL
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
On disconnect, remove the user from presence only if this was their last connection (a user can hold multiple tabs/devices).
|
|
60
|
+
|
|
61
|
+
## Keep event handlers light
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
// ❌ WRONG: expensive uncached query on the hot handler path
|
|
65
|
+
socket.on('get_history', async () => {
|
|
66
|
+
const messages = await db.messages.findMany({ /* slow query */ });
|
|
67
|
+
socket.emit('history', messages);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// ✅ RIGHT: serve from cache; fall back to the DB without blocking the loop
|
|
71
|
+
socket.on('get_history', async () => {
|
|
72
|
+
const messages =
|
|
73
|
+
(await cache.get(`history:${roomId}`)) ??
|
|
74
|
+
(await db.messages.findMany({ /* bounded query */ }));
|
|
75
|
+
socket.emit('history', messages);
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
For genuinely heavy work (aggregation, fan-out), enqueue it to a worker and emit the result when ready. Reconnection recovers missed messages via a REST history endpoint (or `lastEventId` cursor) — never by rebuilding full state over the socket.
|
|
80
|
+
|
|
81
|
+
## SSE with a resumable cursor
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
event: job_progress
|
|
85
|
+
id: 1042
|
|
86
|
+
retry: 5000
|
|
87
|
+
data: {"jobId":"j_9","pct":62}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
- `id:` on every event lets the browser send `Last-Event-ID` on automatic reconnect — the server resumes from the cursor instead of replaying or dropping.
|
|
91
|
+
- `retry:` tunes the browser's reconnect backoff.
|
|
92
|
+
- Authenticate the stream on open, subscribe it to the pub/sub channel, and close it when the job/feed completes.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Reference: reporting and analytics patterns (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `domain/relatorios-analytics` — materialized views with concurrent refresh, timezone-correct date ranges, streaming exports, and the async report-job pipeline. Evicted from the standing fragment; read when implementing one of these mechanisms.
|
|
4
|
+
|
|
5
|
+
## Materialized view with concurrent refresh (PostgreSQL)
|
|
6
|
+
|
|
7
|
+
```sql
|
|
8
|
+
-- Aggregate once, serve many times
|
|
9
|
+
CREATE MATERIALIZED VIEW sales_by_day AS
|
|
10
|
+
SELECT
|
|
11
|
+
DATE(created_at AT TIME ZONE 'America/Sao_Paulo') AS day,
|
|
12
|
+
SUM(amount_cents) / 100.0 AS total,
|
|
13
|
+
COUNT(*) AS order_count
|
|
14
|
+
FROM orders
|
|
15
|
+
WHERE status = 'completed'
|
|
16
|
+
GROUP BY 1;
|
|
17
|
+
|
|
18
|
+
-- Index the view so dashboard queries are instant
|
|
19
|
+
CREATE UNIQUE INDEX ON sales_by_day (day);
|
|
20
|
+
|
|
21
|
+
-- Production refresh: CONCURRENTLY avoids locking readers
|
|
22
|
+
-- (requires a unique index on the view)
|
|
23
|
+
REFRESH MATERIALIZED VIEW CONCURRENTLY sales_by_day;
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Timezone-correct date ranges
|
|
27
|
+
|
|
28
|
+
```sql
|
|
29
|
+
-- ❌ WRONG: groups by UTC day → a 9pm São Paulo sale lands on "tomorrow"
|
|
30
|
+
SELECT DATE(created_at) AS day, SUM(amount) FROM orders GROUP BY 1;
|
|
31
|
+
|
|
32
|
+
-- ✅ RIGHT: convert to the user's/tenant's zone BEFORE grouping
|
|
33
|
+
SELECT DATE(created_at AT TIME ZONE 'America/Sao_Paulo') AS day, SUM(amount)
|
|
34
|
+
FROM orders GROUP BY 1;
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```javascript
|
|
38
|
+
// ❌ WRONG: "today" in server time
|
|
39
|
+
const today = { gte: new Date().setHours(0, 0, 0, 0) };
|
|
40
|
+
|
|
41
|
+
// ✅ RIGHT: the tenant's timezone, converted to UTC bounds (any tz-aware date library)
|
|
42
|
+
const tz = tenant.timezone; // e.g. 'America/Sao_Paulo'
|
|
43
|
+
const today = {
|
|
44
|
+
gte: DateTime.now().setZone(tz).startOf('day').toUTC().toJSDate(),
|
|
45
|
+
lt: DateTime.now().setZone(tz).endOf('day').toUTC().toJSDate(),
|
|
46
|
+
};
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Streaming export (wrong vs right)
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
// ❌ WRONG: buffers the whole result — hundreds of MB in RAM, then a crash
|
|
53
|
+
const rows = await db.orders.findMany({ where: filters });
|
|
54
|
+
res.send(rows.map(toCSV).join('\n'));
|
|
55
|
+
|
|
56
|
+
// ✅ RIGHT: cursor → transform → sink, constant memory
|
|
57
|
+
const cursor = db.orders.stream({ where: filters });
|
|
58
|
+
cursor
|
|
59
|
+
.pipe(new Transform({
|
|
60
|
+
objectMode: true,
|
|
61
|
+
transform(row, _, cb) { cb(null, formatCSV(row) + '\n'); },
|
|
62
|
+
}))
|
|
63
|
+
.pipe(res); // or pipe into a streaming object-storage upload
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
For object storage, pipe the CSV stream into a streaming multipart upload (the maintained AWS SDK ships an `Upload` helper in `@aws-sdk/lib-storage`; the old `.upload().promise()` API belongs to the deprecated v2 SDK). Never accumulate the file in memory or on the web server's disk.
|
|
67
|
+
|
|
68
|
+
## Async report-job pipeline
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
1. POST /reports/export → create job row (status=queued) → return { jobId }
|
|
72
|
+
2. worker picks the job → streams the query to CSV/Excel → uploads to object storage
|
|
73
|
+
3. worker finalizes → status=ready, downloadUrl = signed link with expiry (e.g. 24h)
|
|
74
|
+
4. notify → email the user the expiring link
|
|
75
|
+
5. GET /reports/jobs/:id → queued | processing | ready | failed (+ progress when known)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
- Cap concurrent exports per user (e.g. 3); the excess waits in the queue.
|
|
79
|
+
- Scheduled reports run through the same pipeline and alert after consecutive failures.
|
|
80
|
+
- Read from the replica; monitor replication lag and surface staleness in the UI when relevant.
|
|
81
|
+
- Never interpolate user input into report SQL — resolve filters/fields through a whitelist.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Reference: auth helpers, protected loaders, and S3 uploads (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/remix-express-full`.
|
|
4
|
+
|
|
5
|
+
## Auth helpers and a protected route
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// app/lib/auth.server.ts
|
|
9
|
+
import { redirect } from '@remix-run/node'
|
|
10
|
+
import { db } from './db.server'
|
|
11
|
+
import { users } from '~/db/schema'
|
|
12
|
+
import { eq } from 'drizzle-orm'
|
|
13
|
+
|
|
14
|
+
export async function getUser(request: Request) {
|
|
15
|
+
const userId = (request as Request & { session?: { userId?: string } }).session?.userId
|
|
16
|
+
if (!userId) return null
|
|
17
|
+
return db.query.users.findFirst({ where: eq(users.id, userId) }) ?? null
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export async function requireUser(request: Request) {
|
|
21
|
+
const user = await getUser(request)
|
|
22
|
+
if (!user) throw redirect('/login')
|
|
23
|
+
return user
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// app/routes/dashboard._index.tsx
|
|
27
|
+
import { json, type LoaderFunctionArgs } from '@remix-run/node'
|
|
28
|
+
import { useLoaderData } from '@remix-run/react'
|
|
29
|
+
import { requireUser } from '~/lib/auth.server'
|
|
30
|
+
import { db } from '~/lib/db.server'
|
|
31
|
+
|
|
32
|
+
export async function loader({ request }: LoaderFunctionArgs) {
|
|
33
|
+
const user = await requireUser(request)
|
|
34
|
+
const posts = await db.query.posts.findMany({
|
|
35
|
+
where: (p, { eq }) => eq(p.authorId, user.id),
|
|
36
|
+
orderBy: (p, { desc }) => [desc(p.createdAt)],
|
|
37
|
+
limit: 20,
|
|
38
|
+
})
|
|
39
|
+
return json({ user, posts })
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function ErrorBoundary() {
|
|
43
|
+
return <div className="p-4 text-red-500">Something went wrong loading your dashboard.</div>
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Server-side S3 upload with validation
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
// app/lib/s3.server.ts
|
|
51
|
+
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3'
|
|
52
|
+
import { randomUUID } from 'node:crypto'
|
|
53
|
+
import path from 'node:path'
|
|
54
|
+
|
|
55
|
+
const s3 = new S3Client({ region: process.env.AWS_REGION! })
|
|
56
|
+
|
|
57
|
+
export async function uploadToS3(file: File, prefix = 'uploads/') {
|
|
58
|
+
const ext = path.extname(file.name).toLowerCase()
|
|
59
|
+
const key = `${prefix}${randomUUID()}${ext}`
|
|
60
|
+
|
|
61
|
+
await s3.send(new PutObjectCommand({
|
|
62
|
+
Bucket: process.env.S3_BUCKET!,
|
|
63
|
+
Key: key,
|
|
64
|
+
Body: Buffer.from(await file.arrayBuffer()),
|
|
65
|
+
ContentType: file.type,
|
|
66
|
+
}))
|
|
67
|
+
|
|
68
|
+
return { key, url: `https://${process.env.S3_BUCKET}.s3.${process.env.AWS_REGION}.amazonaws.com/${key}` }
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// app/routes/api.upload.tsx — validate auth + size BEFORE the S3 put
|
|
72
|
+
import { json, type ActionFunctionArgs } from '@remix-run/node'
|
|
73
|
+
import { requireUser } from '~/lib/auth.server'
|
|
74
|
+
import { uploadToS3 } from '~/lib/s3.server'
|
|
75
|
+
|
|
76
|
+
export async function action({ request }: ActionFunctionArgs) {
|
|
77
|
+
const user = await requireUser(request)
|
|
78
|
+
const formData = await request.formData()
|
|
79
|
+
const file = formData.get('file')
|
|
80
|
+
if (!(file instanceof File) || file.size > 5 * 1024 * 1024) {
|
|
81
|
+
return json({ error: 'Invalid file' }, 400)
|
|
82
|
+
}
|
|
83
|
+
const { url } = await uploadToS3(file, `users/${user.id}/`)
|
|
84
|
+
return json({ url })
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Never hand presigned upload URLs to untrusted clients — validate and proxy through the server instead.
|