@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,108 @@
|
|
|
1
|
+
# Reference: multi-stage Dockerfile, env template, proxy, commands (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/docker-compose-dev`. Read when writing the app image, the env template, or the reverse proxy.
|
|
4
|
+
|
|
5
|
+
## Multi-stage Dockerfile (dev and prod from one file)
|
|
6
|
+
|
|
7
|
+
```dockerfile
|
|
8
|
+
# Dockerfile — pin the base image major in your repo
|
|
9
|
+
FROM node:lts-alpine AS base
|
|
10
|
+
WORKDIR /app
|
|
11
|
+
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
|
12
|
+
|
|
13
|
+
# --- Dependencies stage ---
|
|
14
|
+
FROM base AS deps
|
|
15
|
+
COPY package*.json ./
|
|
16
|
+
RUN npm ci
|
|
17
|
+
|
|
18
|
+
# --- Development stage (dev dependencies included) ---
|
|
19
|
+
FROM deps AS dev
|
|
20
|
+
ENV NODE_ENV=development
|
|
21
|
+
COPY . .
|
|
22
|
+
USER appuser
|
|
23
|
+
CMD ["npm", "run", "dev"]
|
|
24
|
+
|
|
25
|
+
# --- Build stage ---
|
|
26
|
+
FROM deps AS builder
|
|
27
|
+
COPY . .
|
|
28
|
+
RUN npm run build
|
|
29
|
+
|
|
30
|
+
# --- Production stage (runtime deps only, non-root, healthcheck) ---
|
|
31
|
+
FROM base AS prod
|
|
32
|
+
ENV NODE_ENV=production
|
|
33
|
+
COPY --from=builder /app/dist ./dist
|
|
34
|
+
COPY --from=builder /app/package*.json ./
|
|
35
|
+
RUN npm ci --omit=dev && npm cache clean --force
|
|
36
|
+
USER appuser
|
|
37
|
+
EXPOSE 3000
|
|
38
|
+
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
|
39
|
+
CMD wget -qO- http://localhost:3000/healthz || exit 1
|
|
40
|
+
CMD ["node", "dist/server.js"]
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## `.env.example` (committed; `.env` is gitignored)
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# .env.example — every key present, values redacted or dev-safe
|
|
47
|
+
NODE_ENV=development
|
|
48
|
+
APP_PORT=3000
|
|
49
|
+
|
|
50
|
+
POSTGRES_USER=appuser
|
|
51
|
+
POSTGRES_PASSWORD=changeme_dev
|
|
52
|
+
POSTGRES_DB=appdb
|
|
53
|
+
|
|
54
|
+
REDIS_PASSWORD=changeme_dev
|
|
55
|
+
|
|
56
|
+
LOG_LEVEL=debug
|
|
57
|
+
|
|
58
|
+
# JWT_SECRET= <- fill in .env only
|
|
59
|
+
# THIRD_PARTY_API_KEY= <- fill in .env only
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Reverse proxy (nginx) in front of the app
|
|
63
|
+
|
|
64
|
+
```nginx
|
|
65
|
+
# nginx/conf.d/default.conf
|
|
66
|
+
upstream app_backend {
|
|
67
|
+
server app:3000; # service name, not localhost
|
|
68
|
+
keepalive 32;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
server {
|
|
72
|
+
listen 80;
|
|
73
|
+
server_name _;
|
|
74
|
+
|
|
75
|
+
location /healthz {
|
|
76
|
+
proxy_pass http://app_backend;
|
|
77
|
+
access_log off;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
location / {
|
|
81
|
+
proxy_pass http://app_backend;
|
|
82
|
+
proxy_http_version 1.1;
|
|
83
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
84
|
+
proxy_set_header Connection 'upgrade';
|
|
85
|
+
proxy_set_header Host $host;
|
|
86
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
87
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
88
|
+
proxy_cache_bypass $http_upgrade;
|
|
89
|
+
client_max_body_size 10M;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Mount it read-only and healthcheck the config: `test: ["CMD", "nginx", "-t"]`.
|
|
95
|
+
|
|
96
|
+
## Everyday commands
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
docker compose up -d # start (base + auto-loaded dev override)
|
|
100
|
+
docker compose logs -f app # tail one service
|
|
101
|
+
docker compose exec app sh # shell into a running container
|
|
102
|
+
docker compose run --rm app npm run db:migrate # one-off task
|
|
103
|
+
docker compose up -d --build # rebuild after Dockerfile changes
|
|
104
|
+
docker compose config # validate + render the effective file
|
|
105
|
+
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d --build # prod
|
|
106
|
+
docker compose down # teardown, volumes preserved
|
|
107
|
+
docker compose down -v # DANGER: also destroys data volumes
|
|
108
|
+
```
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Reference: ASP.NET Core composition root, options, data access (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/dotnet-aspnet` — composition root, typed options, repository with async EF Core queries, migration commands. Read when wiring services, config, or persistence.
|
|
4
|
+
|
|
5
|
+
## Composition root (one place, deliberate order)
|
|
6
|
+
|
|
7
|
+
```csharp
|
|
8
|
+
// Program.cs
|
|
9
|
+
var builder = WebApplication.CreateBuilder(args);
|
|
10
|
+
|
|
11
|
+
builder.Services.AddControllers();
|
|
12
|
+
builder.Services.AddProblemDetails();
|
|
13
|
+
|
|
14
|
+
// Typed options — never bare Configuration[""] reads in services.
|
|
15
|
+
builder.Services.AddOptions<PaymentOptions>()
|
|
16
|
+
.BindConfiguration(PaymentOptions.SectionName)
|
|
17
|
+
.ValidateDataAnnotations()
|
|
18
|
+
.ValidateOnStart();
|
|
19
|
+
|
|
20
|
+
builder.Services.AddDbContext<AppDbContext>(o =>
|
|
21
|
+
o.UseNpgsql(builder.Configuration.GetConnectionString("Default")));
|
|
22
|
+
|
|
23
|
+
// Registration order matters in layered setups: overrides last, where
|
|
24
|
+
// the repo's conventions say they belong.
|
|
25
|
+
builder.Services.AddScoped<IOrderRepository, OrderRepository>();
|
|
26
|
+
builder.Services.AddScoped<IOrderService, OrderService>();
|
|
27
|
+
builder.Services.AddScoped<ExceptionHandlingMiddleware>();
|
|
28
|
+
|
|
29
|
+
builder.Services.AddAuthorization(options =>
|
|
30
|
+
options.AddPolicy("CanCreateOrders", p => p.RequireClaim("scope", "orders:write")));
|
|
31
|
+
|
|
32
|
+
var app = builder.Build();
|
|
33
|
+
app.UseMiddleware<ExceptionHandlingMiddleware>();
|
|
34
|
+
app.UseAuthentication();
|
|
35
|
+
app.UseAuthorization();
|
|
36
|
+
app.MapControllers();
|
|
37
|
+
app.Run();
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Typed options
|
|
41
|
+
|
|
42
|
+
```csharp
|
|
43
|
+
// Api/Infrastructure/PaymentOptions.cs
|
|
44
|
+
public class PaymentOptions
|
|
45
|
+
{
|
|
46
|
+
public const string SectionName = "Payment";
|
|
47
|
+
|
|
48
|
+
[Required, Url] public string BaseUrl { get; init; } = string.Empty;
|
|
49
|
+
public TimeSpan Timeout { get; init; } = TimeSpan.FromSeconds(5);
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
```jsonc
|
|
54
|
+
// appsettings.json (tracked) — placeholders only, real values from env/secret store
|
|
55
|
+
{ "Payment": { "BaseUrl": "" }, "ConnectionStrings": { "Default": "" } }
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Repository — async, parameterized, projected
|
|
59
|
+
|
|
60
|
+
```csharp
|
|
61
|
+
// Data/OrderRepository.cs
|
|
62
|
+
public class OrderRepository : IOrderRepository
|
|
63
|
+
{
|
|
64
|
+
private readonly AppDbContext _db;
|
|
65
|
+
public OrderRepository(AppDbContext db) => _db = db;
|
|
66
|
+
|
|
67
|
+
public Task<Order?> GetWithItemsAsync(Guid id, Guid ownerId, CancellationToken ct) =>
|
|
68
|
+
_db.Orders
|
|
69
|
+
.Include(o => o.Items)
|
|
70
|
+
.SingleOrDefaultAsync(o => o.Id == id && o.Customer.OwnerId == ownerId, ct);
|
|
71
|
+
|
|
72
|
+
public Task<List<OrderSummary>> SummariesAsync(Guid ownerId, CancellationToken ct) =>
|
|
73
|
+
_db.Orders
|
|
74
|
+
.Where(o => o.Customer.OwnerId == ownerId)
|
|
75
|
+
.Select(o => new OrderSummary(o.Id, o.Status, o.Total)) // projection, no entity leak
|
|
76
|
+
.ToListAsync(ct);
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
LINQ-to-entities is parameterized by construction. If raw SQL is unavoidable, use the interpolated APIs (`FromSqlInterpolated` / `ExecuteSqlInterpolated`) — never string concatenation.
|
|
81
|
+
|
|
82
|
+
## Migrations (generated, reviewed, both ways)
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
dotnet ef migrations add AddConfirmationSentAtToOrders
|
|
86
|
+
dotnet ef database update # up on a scratch database
|
|
87
|
+
dotnet ef database update <PreviousMigration> # verify the down path
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Never hand-edit the model snapshot; regenerate instead. Migration and entity change ship in the same commit.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Reference: ASP.NET Core web layer (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/dotnet-aspnet` — thin controller, DTO records, explicit authorization, error contract. Read when adding or changing an endpoint.
|
|
4
|
+
|
|
5
|
+
## DTOs (records) at the boundary
|
|
6
|
+
|
|
7
|
+
```csharp
|
|
8
|
+
// Api/Orders/OrderDtos.cs
|
|
9
|
+
public record CreateOrderRequest(
|
|
10
|
+
[property: Required] Guid CustomerId,
|
|
11
|
+
[property: MinLength(1)] IReadOnlyList<OrderItemRequest> Items);
|
|
12
|
+
|
|
13
|
+
public record OrderResponse(Guid Id, string Status, decimal Total, DateTimeOffset CreatedAt);
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Thin controller — authorization declared on every action
|
|
17
|
+
|
|
18
|
+
```csharp
|
|
19
|
+
// Api/Orders/OrdersController.cs
|
|
20
|
+
[ApiController]
|
|
21
|
+
[Route("api/orders")]
|
|
22
|
+
public class OrdersController : ControllerBase
|
|
23
|
+
{
|
|
24
|
+
private readonly IOrderService _orders;
|
|
25
|
+
|
|
26
|
+
public OrdersController(IOrderService orders) => _orders = orders;
|
|
27
|
+
|
|
28
|
+
[HttpPost]
|
|
29
|
+
[Authorize(Policy = "CanCreateOrders")] // explicit — never implied
|
|
30
|
+
[ProducesResponseType<OrderResponse>(StatusCodes.Status201Created)]
|
|
31
|
+
public async Task<ActionResult<OrderResponse>> Create(
|
|
32
|
+
CreateOrderRequest request, CancellationToken ct)
|
|
33
|
+
{
|
|
34
|
+
var result = await _orders.PlaceAsync(User.GetUserId(), request, ct);
|
|
35
|
+
|
|
36
|
+
// Repo result contract shown as a result object — follow the neighbor.
|
|
37
|
+
if (!result.IsSuccess)
|
|
38
|
+
return Problem(statusCode: StatusCodes.Status422UnprocessableEntity,
|
|
39
|
+
detail: result.Error);
|
|
40
|
+
|
|
41
|
+
return CreatedAtAction(nameof(Get), new { id = result.Value.Id },
|
|
42
|
+
OrderMapper.ToResponse(result.Value));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
[HttpGet("{id:guid}")]
|
|
46
|
+
[Authorize]
|
|
47
|
+
public async Task<ActionResult<OrderResponse>> Get(Guid id, CancellationToken ct)
|
|
48
|
+
{
|
|
49
|
+
var order = await _orders.GetForUserAsync(User.GetUserId(), id, ct);
|
|
50
|
+
return order is null ? NotFound() : OrderMapper.ToResponse(order);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Error contract middleware (opaque 500s, typed 4xx)
|
|
56
|
+
|
|
57
|
+
```csharp
|
|
58
|
+
// Api/Infrastructure/ExceptionHandlingMiddleware.cs
|
|
59
|
+
public class ExceptionHandlingMiddleware : IMiddleware
|
|
60
|
+
{
|
|
61
|
+
private readonly ILogger<ExceptionHandlingMiddleware> _logger;
|
|
62
|
+
|
|
63
|
+
public ExceptionHandlingMiddleware(ILogger<ExceptionHandlingMiddleware> logger)
|
|
64
|
+
=> _logger = logger;
|
|
65
|
+
|
|
66
|
+
public async Task InvokeAsync(HttpContext context, RequestDelegate next)
|
|
67
|
+
{
|
|
68
|
+
try
|
|
69
|
+
{
|
|
70
|
+
await next(context);
|
|
71
|
+
}
|
|
72
|
+
catch (DomainNotFoundException ex)
|
|
73
|
+
{
|
|
74
|
+
await Results.Problem(statusCode: StatusCodes.Status404NotFound,
|
|
75
|
+
detail: ex.Message).ExecuteAsync(context);
|
|
76
|
+
}
|
|
77
|
+
catch (Exception ex)
|
|
78
|
+
{
|
|
79
|
+
_logger.LogError(ex, "unhandled exception on {Path}", context.Request.Path);
|
|
80
|
+
// Never the exception text to the client.
|
|
81
|
+
await Results.Problem(statusCode: StatusCodes.Status500InternalServerError,
|
|
82
|
+
detail: "unexpected error").ExecuteAsync(context);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Whether the repo throws typed exceptions or returns result objects: pick up the neighboring module's style and keep the module consistent.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Reference: e-commerce patterns (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `domain/ecommerce-completo` — locked stock decrement, server-side price revalidation, and order state-transition validation. Evicted from the standing fragment; read when implementing one of these mechanisms.
|
|
4
|
+
|
|
5
|
+
## Stock decrement without a race (wrong vs right)
|
|
6
|
+
|
|
7
|
+
```sql
|
|
8
|
+
-- ❌ WRONG: two buyers can both read quantity = 1 and both purchase the last unit
|
|
9
|
+
SELECT quantity FROM product_variants WHERE id = $1;
|
|
10
|
+
-- (another session reads quantity = 1 here too)
|
|
11
|
+
UPDATE product_variants SET quantity = quantity - 1 WHERE id = $1;
|
|
12
|
+
|
|
13
|
+
-- ✅ RIGHT: pessimistic lock inside one transaction
|
|
14
|
+
BEGIN;
|
|
15
|
+
SELECT quantity FROM product_variants WHERE id = $1 FOR UPDATE;
|
|
16
|
+
-- only this transaction can read/modify the row now
|
|
17
|
+
UPDATE product_variants SET quantity = quantity - 1
|
|
18
|
+
WHERE id = $1 AND quantity > 0;
|
|
19
|
+
COMMIT;
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Pair the lock with a `CHECK (quantity >= 0)` constraint — the application validates, the database enforces.
|
|
23
|
+
|
|
24
|
+
## Reservation vs real decrement
|
|
25
|
+
|
|
26
|
+
```sql
|
|
27
|
+
-- Add to cart: reserve, never decrement the real stock
|
|
28
|
+
UPDATE product_variants
|
|
29
|
+
SET reserved_quantity = reserved_quantity + $qty
|
|
30
|
+
WHERE id = $1 AND quantity - reserved_quantity >= $qty;
|
|
31
|
+
|
|
32
|
+
-- Payment confirmed: commit the decrement and release the hold
|
|
33
|
+
UPDATE product_variants
|
|
34
|
+
SET quantity = quantity - $qty,
|
|
35
|
+
reserved_quantity = reserved_quantity - $qty
|
|
36
|
+
WHERE id = $1;
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
A scheduled job releases `reserved_quantity` for checkout sessions that expired without payment.
|
|
40
|
+
|
|
41
|
+
## Server-side price revalidation (wrong vs right)
|
|
42
|
+
|
|
43
|
+
```javascript
|
|
44
|
+
// ❌ WRONG: charging the price stored in the cart / sent by the frontend
|
|
45
|
+
const total = cartItems.reduce((sum, item) => sum + item.price * item.qty, 0);
|
|
46
|
+
|
|
47
|
+
// ✅ RIGHT: re-read current prices from the database at checkout
|
|
48
|
+
const variants = await db.productVariants.findMany({
|
|
49
|
+
where: { id: { in: cartItems.map((i) => i.variantId) } },
|
|
50
|
+
});
|
|
51
|
+
const total = cartItems.reduce((sum, item) => {
|
|
52
|
+
const variant = variants.find((v) => v.id === item.variantId);
|
|
53
|
+
return sum + variant.price * item.qty; // price from the DB, never the client
|
|
54
|
+
}, 0);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The immutable `CheckoutSession` snapshots these DB prices; the charge always uses the snapshot, never the live cart.
|
|
58
|
+
|
|
59
|
+
## State-transition validation (wrong vs right)
|
|
60
|
+
|
|
61
|
+
```javascript
|
|
62
|
+
// ❌ WRONG: any order can be canceled from any state
|
|
63
|
+
await order.update({ status: 'canceled' });
|
|
64
|
+
|
|
65
|
+
// ✅ RIGHT: validate the transition before executing it
|
|
66
|
+
const CANCELABLE = ['pending', 'payment_failed', 'confirmed'];
|
|
67
|
+
if (!CANCELABLE.includes(order.status)) {
|
|
68
|
+
throw new BusinessError(
|
|
69
|
+
'ORDER_NOT_CANCELABLE',
|
|
70
|
+
`Cannot cancel order in state: ${order.status}`,
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
await order.transition('canceled'); // emits events: notify, release stock, refund
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Centralize legal transitions in one map (`state → allowed next states`) so every mutation path validates against the same source of truth, and each transition emits its side effects (notification, inventory update, ERP webhook) as events.
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Reference: typed IPC bridge (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/electron-app` — the preload bridge, main-process handler registration, and renderer access. Read when adding a native capability.
|
|
4
|
+
|
|
5
|
+
## 1. Define the API in preload (the only bridge)
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// src/preload/index.ts
|
|
9
|
+
import { contextBridge, ipcRenderer } from 'electron';
|
|
10
|
+
|
|
11
|
+
export type ElectronAPI = {
|
|
12
|
+
fs: {
|
|
13
|
+
readFile: (path: string) => Promise<string>;
|
|
14
|
+
writeFile: (path: string, content: string) => Promise<void>;
|
|
15
|
+
openDialog: (options: Electron.OpenDialogOptions) => Promise<string[]>;
|
|
16
|
+
};
|
|
17
|
+
app: {
|
|
18
|
+
getVersion: () => Promise<string>;
|
|
19
|
+
quit: () => void;
|
|
20
|
+
};
|
|
21
|
+
updater: {
|
|
22
|
+
checkForUpdates: () => Promise<void>;
|
|
23
|
+
onUpdateAvailable: (cb: (info: UpdateInfo) => void) => () => void;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
contextBridge.exposeInMainWorld('api', {
|
|
28
|
+
fs: {
|
|
29
|
+
readFile: (path: string) => ipcRenderer.invoke('fs:readFile', path),
|
|
30
|
+
writeFile: (path: string, content: string) =>
|
|
31
|
+
ipcRenderer.invoke('fs:writeFile', path, content),
|
|
32
|
+
openDialog: (options: Electron.OpenDialogOptions) =>
|
|
33
|
+
ipcRenderer.invoke('fs:openDialog', options),
|
|
34
|
+
},
|
|
35
|
+
app: {
|
|
36
|
+
getVersion: () => ipcRenderer.invoke('app:getVersion'),
|
|
37
|
+
quit: () => ipcRenderer.send('app:quit'),
|
|
38
|
+
},
|
|
39
|
+
updater: {
|
|
40
|
+
checkForUpdates: () => ipcRenderer.invoke('updater:checkForUpdates'),
|
|
41
|
+
onUpdateAvailable: (cb) => {
|
|
42
|
+
const listener = (_: unknown, info: UpdateInfo) => cb(info);
|
|
43
|
+
ipcRenderer.on('updater:updateAvailable', listener);
|
|
44
|
+
// Subscribe functions ALWAYS return their own cleanup
|
|
45
|
+
return () => ipcRenderer.removeListener('updater:updateAvailable', listener);
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
} satisfies ElectronAPI);
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Only narrow functions cross the bridge — never `require`, `process`, `fs`, or `ipcRenderer` itself.
|
|
52
|
+
|
|
53
|
+
## 2. Register handlers in main (validate everything)
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
// src/main/ipc/fs-handlers.ts
|
|
57
|
+
import { ipcMain, dialog } from 'electron';
|
|
58
|
+
import { readFile, writeFile } from 'fs/promises';
|
|
59
|
+
|
|
60
|
+
export function registerFsHandlers() {
|
|
61
|
+
ipcMain.handle('fs:readFile', async (_event, path: string) => {
|
|
62
|
+
// Validate the path — never trust renderer input blindly
|
|
63
|
+
if (!path || typeof path !== 'string') {
|
|
64
|
+
throw new Error('Invalid path');
|
|
65
|
+
}
|
|
66
|
+
return readFile(path, 'utf-8');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
ipcMain.handle('fs:writeFile', async (_event, path: string, content: string) => {
|
|
70
|
+
if (!path || typeof path !== 'string' || typeof content !== 'string') {
|
|
71
|
+
throw new Error('Invalid arguments');
|
|
72
|
+
}
|
|
73
|
+
await writeFile(path, content, 'utf-8');
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
ipcMain.handle('fs:openDialog', async (_event, options: Electron.OpenDialogOptions) => {
|
|
77
|
+
const result = await dialog.showOpenDialog(options);
|
|
78
|
+
return result.filePaths;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// src/main/ipc/index.ts — one registration entry point
|
|
83
|
+
export function registerAllHandlers() {
|
|
84
|
+
registerFsHandlers();
|
|
85
|
+
registerAppHandlers();
|
|
86
|
+
registerUpdaterHandlers();
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## 3. Access from the renderer
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
// src/renderer/src/hooks/useElectronApi.ts
|
|
94
|
+
// Safe wrapper — fails loudly outside an Electron environment
|
|
95
|
+
export function useElectronApi() {
|
|
96
|
+
const api = (window as Window & { api?: ElectronAPI }).api;
|
|
97
|
+
if (!api) throw new Error('Electron API unavailable — not running inside Electron');
|
|
98
|
+
return api;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// In a React component:
|
|
102
|
+
export function FileEditor() {
|
|
103
|
+
const api = useElectronApi();
|
|
104
|
+
const [content, setContent] = useState('');
|
|
105
|
+
|
|
106
|
+
async function handleOpen() {
|
|
107
|
+
const [path] = await api.fs.openDialog({
|
|
108
|
+
properties: ['openFile'],
|
|
109
|
+
filters: [{ name: 'Text', extensions: ['txt', 'md'] }],
|
|
110
|
+
});
|
|
111
|
+
if (path) setContent(await api.fs.readFile(path));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<div>
|
|
116
|
+
<button onClick={handleOpen}>Open file</button>
|
|
117
|
+
<textarea value={content} onChange={(e) => setContent(e.target.value)} />
|
|
118
|
+
</div>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Unit tests stub the bridge: `vi.stubGlobal('api', { fs: { readFile: vi.fn().mockResolvedValue('…') } })`.
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# Reference: window security, packaging, updater, persistence (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/electron-app`. Read when creating windows, configuring packaging, or wiring updates/persistence.
|
|
4
|
+
|
|
5
|
+
## Window security flags (mandatory on every window)
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// src/main/windows/main-window.ts
|
|
9
|
+
export function createMainWindow(): BrowserWindow {
|
|
10
|
+
return new BrowserWindow({
|
|
11
|
+
width: 1200,
|
|
12
|
+
height: 800,
|
|
13
|
+
webPreferences: {
|
|
14
|
+
preload: path.join(__dirname, '../preload/index.js'),
|
|
15
|
+
contextIsolation: true, // MANDATORY — isolates contexts
|
|
16
|
+
nodeIntegration: false, // MANDATORY — renderer gets no Node.js
|
|
17
|
+
sandbox: true, // blocks unexposed Chromium-native APIs
|
|
18
|
+
webSecurity: true, // never disable in production
|
|
19
|
+
allowRunningInsecureContent: false, // never true
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Why these are critical: without `contextIsolation`, a renderer XSS can run Node code; without `nodeIntegration: false`, `require('fs')` works in the renderer.
|
|
26
|
+
|
|
27
|
+
## Navigation and window-open guards
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
// src/main/index.ts — block navigation to non-allowlisted origins
|
|
31
|
+
app.on('web-contents-created', (_event, contents) => {
|
|
32
|
+
contents.on('will-navigate', (event, url) => {
|
|
33
|
+
const allowedOrigins = ['http://localhost:5173', 'app://'];
|
|
34
|
+
if (!allowedOrigins.some((origin) => url.startsWith(origin))) {
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
contents.setWindowOpenHandler(({ url }) => {
|
|
40
|
+
// External links open in the OS browser, never inside Electron
|
|
41
|
+
if (url.startsWith('https://')) shell.openExternal(url);
|
|
42
|
+
return { action: 'deny' };
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Packaging (electron-builder)
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
// electron-builder.config.ts
|
|
51
|
+
import { Configuration } from 'electron-builder';
|
|
52
|
+
|
|
53
|
+
const config: Configuration = {
|
|
54
|
+
appId: 'com.company.app',
|
|
55
|
+
productName: 'My App',
|
|
56
|
+
directories: { output: 'release', buildResources: 'resources' },
|
|
57
|
+
files: ['dist/**/*', 'dist-main/**/*', 'resources/**/*'],
|
|
58
|
+
win: { target: ['nsis', 'portable'], icon: 'resources/icon.ico', signingHashAlgorithms: ['sha256'] },
|
|
59
|
+
mac: {
|
|
60
|
+
target: ['dmg', 'zip'],
|
|
61
|
+
icon: 'resources/icon.icns',
|
|
62
|
+
hardenedRuntime: true,
|
|
63
|
+
entitlements: 'resources/entitlements.mac.plist',
|
|
64
|
+
entitlementsInherit: 'resources/entitlements.mac.plist',
|
|
65
|
+
},
|
|
66
|
+
linux: { target: ['AppImage', 'deb'], icon: 'resources/icon.png' },
|
|
67
|
+
publish: { provider: 'github', owner: 'my-org', repo: 'my-app' },
|
|
68
|
+
nsis: { oneClick: false, allowToChangeInstallationDirectory: true },
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export default config;
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Never commit signing certificates or keys; they come from CI secrets.
|
|
75
|
+
|
|
76
|
+
## Auto-updater (electron-updater)
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
// src/main/services/auto-updater.ts
|
|
80
|
+
import { autoUpdater } from 'electron-updater';
|
|
81
|
+
import log from 'electron-log';
|
|
82
|
+
|
|
83
|
+
export function setupAutoUpdater(mainWindow: BrowserWindow) {
|
|
84
|
+
autoUpdater.logger = log;
|
|
85
|
+
autoUpdater.autoDownload = false; // ask before downloading
|
|
86
|
+
|
|
87
|
+
autoUpdater.on('update-available', (info) =>
|
|
88
|
+
mainWindow.webContents.send('updater:updateAvailable', info));
|
|
89
|
+
autoUpdater.on('update-downloaded', () =>
|
|
90
|
+
mainWindow.webContents.send('updater:updateReady'));
|
|
91
|
+
autoUpdater.on('error', (err) => log.error('Auto-updater error:', err));
|
|
92
|
+
|
|
93
|
+
setTimeout(() => autoUpdater.checkForUpdates(), 3000);
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Persistence in main (typed store)
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
// src/main/services/store.ts (electron-store)
|
|
101
|
+
import Store from 'electron-store';
|
|
102
|
+
|
|
103
|
+
interface AppStore {
|
|
104
|
+
windowBounds: { width: number; height: number; x: number; y: number };
|
|
105
|
+
recentFiles: string[];
|
|
106
|
+
theme: 'light' | 'dark' | 'system';
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export const store = new Store<AppStore>({
|
|
110
|
+
defaults: {
|
|
111
|
+
windowBounds: { width: 1200, height: 800, x: 0, y: 0 },
|
|
112
|
+
recentFiles: [],
|
|
113
|
+
theme: 'system',
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
export function persistWindowBounds(window: BrowserWindow) {
|
|
118
|
+
window.on('close', () => store.set('windowBounds', window.getBounds()));
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## E2E against the packaged entry point (Playwright)
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
// tests/e2e/app.spec.ts
|
|
126
|
+
import { test, expect, _electron as electron } from '@playwright/test';
|
|
127
|
+
|
|
128
|
+
test('app opens the main window', async () => {
|
|
129
|
+
const app = await electron.launch({ args: ['dist-main/main/index.js'] });
|
|
130
|
+
const window = await app.firstWindow();
|
|
131
|
+
await expect(window).toHaveTitle('My App');
|
|
132
|
+
await app.close();
|
|
133
|
+
});
|
|
134
|
+
```
|