@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,149 @@
|
|
|
1
|
+
# Reference: Airflow DAG patterns (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/data-pipeline-airflow`. Read when writing a new pipeline or adding fan-out.
|
|
4
|
+
|
|
5
|
+
## TaskFlow ETL DAG (paths through XCom, data through S3)
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
# dags/etl_customers.py
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
from datetime import timedelta
|
|
11
|
+
import logging
|
|
12
|
+
|
|
13
|
+
import pendulum
|
|
14
|
+
from airflow.decorators import dag, task
|
|
15
|
+
|
|
16
|
+
logger = logging.getLogger(__name__)
|
|
17
|
+
|
|
18
|
+
default_args = {
|
|
19
|
+
"owner": "data-team",
|
|
20
|
+
"retries": 2,
|
|
21
|
+
"retry_delay": timedelta(minutes=5),
|
|
22
|
+
"retry_exponential_backoff": True,
|
|
23
|
+
"max_retry_delay": timedelta(minutes=30),
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@dag(
|
|
27
|
+
dag_id="etl_customers",
|
|
28
|
+
description="Extract customers from Postgres, transform, load to S3 data lake",
|
|
29
|
+
schedule="0 2 * * *", # 2 AM UTC daily
|
|
30
|
+
start_date=pendulum.datetime(2024, 1, 1, tz="UTC"),
|
|
31
|
+
catchup=False, # no accidental backfill
|
|
32
|
+
max_active_runs=1, # runs must not overlap
|
|
33
|
+
default_args=default_args,
|
|
34
|
+
tags=["etl", "customers", "daily"],
|
|
35
|
+
doc_md="Customer ETL. Deadline: complete by 4 AM UTC. Owner: #data-team.",
|
|
36
|
+
)
|
|
37
|
+
def etl_customers():
|
|
38
|
+
|
|
39
|
+
@task
|
|
40
|
+
def extract(ds: str | None = None) -> str:
|
|
41
|
+
"""Extract from Postgres, upload Parquet to S3. Returns the S3 key."""
|
|
42
|
+
# Heavy imports INSIDE the task — DAG files are parsed continuously
|
|
43
|
+
from airflow.providers.postgres.hooks.postgres import PostgresHook
|
|
44
|
+
from utils.s3 import upload_to_s3
|
|
45
|
+
|
|
46
|
+
hook = PostgresHook(postgres_conn_id="postgres_prod") # Airflow Connection
|
|
47
|
+
df = hook.get_pandas_df("""
|
|
48
|
+
SELECT customer_id, email, created_at, plan, mrr
|
|
49
|
+
FROM customers
|
|
50
|
+
WHERE updated_at >= CURRENT_DATE - 1
|
|
51
|
+
""")
|
|
52
|
+
logger.info("Extracted %d customer records", len(df))
|
|
53
|
+
|
|
54
|
+
s3_path = f"raw/customers/{ds}/customers.parquet" # logical date, not wall clock
|
|
55
|
+
upload_to_s3(df, bucket="my-data-lake", key=s3_path)
|
|
56
|
+
return s3_path # XCom: just the path string
|
|
57
|
+
|
|
58
|
+
@task
|
|
59
|
+
def quality_check(s3_path: str) -> str:
|
|
60
|
+
"""Fail the task (and stop the load) on critical quality failures."""
|
|
61
|
+
from utils.s3 import read_from_s3
|
|
62
|
+
from utils.quality import run_quality_suite
|
|
63
|
+
|
|
64
|
+
df = read_from_s3(bucket="my-data-lake", key=s3_path)
|
|
65
|
+
report = run_quality_suite(df, suite_name="customers")
|
|
66
|
+
critical = [c for c in report.results if c.severity == "critical" and not c.passed]
|
|
67
|
+
if critical:
|
|
68
|
+
raise ValueError(f"Critical quality checks failed: {[c.name for c in critical]}")
|
|
69
|
+
return s3_path
|
|
70
|
+
|
|
71
|
+
@task
|
|
72
|
+
def transform(s3_path: str) -> str:
|
|
73
|
+
import polars as pl
|
|
74
|
+
from utils.s3 import read_from_s3_polars, upload_polars_to_s3
|
|
75
|
+
|
|
76
|
+
df = read_from_s3_polars(bucket="my-data-lake", key=s3_path)
|
|
77
|
+
transformed = (
|
|
78
|
+
df.with_columns([
|
|
79
|
+
pl.col("email").str.to_lowercase().alias("email_normalized"),
|
|
80
|
+
pl.col("mrr").cast(pl.Float64),
|
|
81
|
+
(pl.col("mrr") * 12).alias("arr"),
|
|
82
|
+
])
|
|
83
|
+
.filter(pl.col("customer_id").is_not_null())
|
|
84
|
+
)
|
|
85
|
+
curated = s3_path.replace("raw/", "curated/")
|
|
86
|
+
upload_polars_to_s3(transformed, bucket="my-data-lake", key=curated)
|
|
87
|
+
return curated
|
|
88
|
+
|
|
89
|
+
@task
|
|
90
|
+
def load(curated_path: str) -> None:
|
|
91
|
+
"""Idempotent warehouse load: staging table + transactional swap."""
|
|
92
|
+
from airflow.providers.amazon.aws.hooks.redshift_sql import RedshiftSQLHook
|
|
93
|
+
from utils.s3 import get_s3_url
|
|
94
|
+
|
|
95
|
+
hook = RedshiftSQLHook(redshift_conn_id="redshift_prod")
|
|
96
|
+
s3_url = get_s3_url(bucket="my-data-lake", key=curated_path)
|
|
97
|
+
hook.run(f"""
|
|
98
|
+
COPY customers_staging FROM '{s3_url}'
|
|
99
|
+
IAM_ROLE 'arn:aws:iam::<account>:role/RedshiftS3Role'
|
|
100
|
+
FORMAT PARQUET;
|
|
101
|
+
|
|
102
|
+
BEGIN;
|
|
103
|
+
DELETE FROM customers WHERE customer_id IN (SELECT customer_id FROM customers_staging);
|
|
104
|
+
INSERT INTO customers SELECT * FROM customers_staging;
|
|
105
|
+
TRUNCATE TABLE customers_staging;
|
|
106
|
+
COMMIT;
|
|
107
|
+
""")
|
|
108
|
+
|
|
109
|
+
load(transform(quality_check(extract())))
|
|
110
|
+
|
|
111
|
+
etl_customers()
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Dynamic task mapping (fan-out)
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
# dags/ml_feature_refresh.py
|
|
118
|
+
from __future__ import annotations
|
|
119
|
+
from airflow.decorators import dag, task
|
|
120
|
+
|
|
121
|
+
@dag(schedule="@hourly", catchup=False, tags=["ml", "features"])
|
|
122
|
+
def ml_feature_refresh():
|
|
123
|
+
|
|
124
|
+
@task
|
|
125
|
+
def get_tables_to_process() -> list[str]:
|
|
126
|
+
# Could query a config table; keep it cheap
|
|
127
|
+
return ["orders", "sessions", "events", "products"]
|
|
128
|
+
|
|
129
|
+
@task
|
|
130
|
+
def compute_features(table_name: str) -> dict:
|
|
131
|
+
# ... feature computation ...
|
|
132
|
+
return {"table": table_name, "rows_processed": 1000}
|
|
133
|
+
|
|
134
|
+
@task
|
|
135
|
+
def summarize_runs(results: list[dict]) -> None:
|
|
136
|
+
total = sum(r["rows_processed"] for r in results)
|
|
137
|
+
print(f"Feature refresh complete. Total rows: {total}")
|
|
138
|
+
|
|
139
|
+
results = compute_features.expand(table_name=get_tables_to_process()) # fan-out
|
|
140
|
+
summarize_runs(results)
|
|
141
|
+
|
|
142
|
+
ml_feature_refresh()
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## XCom discipline
|
|
146
|
+
|
|
147
|
+
Pass via XCom: file paths/keys, ids (`job-123`), small stats (`{"rows": 1000}`).
|
|
148
|
+
Never pass: dataframes, file contents, large JSON, connections. Tasks write to
|
|
149
|
+
S3/DB and hand the next task only the path or key.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Reference: Airflow connections, alerts, and tests (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/data-pipeline-airflow`. Read when wiring credentials, alerting, or DAG tests.
|
|
4
|
+
|
|
5
|
+
## Connections without UI clicks (CI/CD-friendly)
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Format: AIRFLOW_CONN_{UPPER_CONN_ID}=<connection-uri>
|
|
9
|
+
export AIRFLOW_CONN_POSTGRES_PROD="postgresql://user:pass@rds-host:5432/mydb"
|
|
10
|
+
export AIRFLOW_CONN_REDSHIFT_PROD="redshift+psycopg2://user:pass@endpoint:5439/mydb"
|
|
11
|
+
export AIRFLOW_CONN_AWS_DEFAULT="aws://:@?region_name=us-east-1" # IAM role
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Or a secrets backend (e.g. AWS Secrets Manager) in `airflow.cfg`:
|
|
15
|
+
|
|
16
|
+
```ini
|
|
17
|
+
[secrets]
|
|
18
|
+
backend = airflow.providers.amazon.aws.secrets.secrets_manager.SecretsManagerBackend
|
|
19
|
+
backend_kwargs = {"connections_prefix": "airflow/connections"}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Real secrets belong in the secrets backend or the deployment environment — the URIs above are wired by CI, never committed.
|
|
23
|
+
|
|
24
|
+
## Alert callback (notify, don't fail)
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
# dags/utils/notifications.py
|
|
28
|
+
import requests
|
|
29
|
+
|
|
30
|
+
def notify_slack_failure(context) -> None:
|
|
31
|
+
"""on_failure_callback — alerts the team channel; never raises."""
|
|
32
|
+
from airflow.models import Variable
|
|
33
|
+
|
|
34
|
+
# Variable.get INSIDE the function: module-level reads hit the metadata DB
|
|
35
|
+
# on every scheduler parse loop.
|
|
36
|
+
webhook = Variable.get("SLACK_WEBHOOK_URL", default_var=None)
|
|
37
|
+
if not webhook:
|
|
38
|
+
return
|
|
39
|
+
ti = context["task_instance"]
|
|
40
|
+
msg = f":warning: Task failed: `{ti.dag_id}.{ti.task_id}` run {context['run_id']}"
|
|
41
|
+
try:
|
|
42
|
+
requests.post(webhook, json={"text": msg}, timeout=5)
|
|
43
|
+
except requests.RequestException:
|
|
44
|
+
pass # alerting must never take the pipeline down
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Wire it via `default_args={"on_failure_callback": notify_slack_failure}`. For
|
|
48
|
+
lateness (rather than failure) alerting, use the deadline/SLA mechanism of your
|
|
49
|
+
Airflow generation — classic SLA callbacks were replaced by Deadline Alerts in
|
|
50
|
+
newer major versions; both notify and must not fail the DAG.
|
|
51
|
+
|
|
52
|
+
## DAG tests (no scheduler needed)
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
# tests/test_etl_customers.py
|
|
56
|
+
import pytest
|
|
57
|
+
from airflow.models import DagBag
|
|
58
|
+
|
|
59
|
+
@pytest.fixture(scope="module")
|
|
60
|
+
def dagbag():
|
|
61
|
+
return DagBag(dag_folder="dags/", include_examples=False)
|
|
62
|
+
|
|
63
|
+
def test_dag_loads_without_errors(dagbag):
|
|
64
|
+
assert dagbag.import_errors == {}
|
|
65
|
+
assert dagbag.get_dag("etl_customers") is not None
|
|
66
|
+
|
|
67
|
+
def test_dag_shape(dagbag):
|
|
68
|
+
dag = dagbag.get_dag("etl_customers")
|
|
69
|
+
assert len(dag.tasks) == 4 # extract, quality_check, transform, load
|
|
70
|
+
assert dag.catchup is False
|
|
71
|
+
assert dag.timetable.summary == "0 2 * * *" # portable across major versions
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Task logic itself is tested as plain Python (import the function, call it with fakes) — the DagBag test only proves the DAG parses and is shaped as expected. Use `dag.test()` for a local integration run.
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# Reference: extracting rules out of a legacy form (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/delphi-object-pascal` — characterization test first, one rule extracted into a UI-free unit, parameterized data access with an explicit transaction, and threaded work that updates the UI safely.
|
|
4
|
+
|
|
5
|
+
## 1. The starting point (what legacy usually looks like)
|
|
6
|
+
|
|
7
|
+
```pascal
|
|
8
|
+
// uMainForm.pas — rule, SQL and formatting all inside the click handler
|
|
9
|
+
procedure TMainForm.btnCalcularClick(Sender: TObject);
|
|
10
|
+
var
|
|
11
|
+
Total: Currency;
|
|
12
|
+
begin
|
|
13
|
+
Query1.SQL.Text := 'SELECT valor FROM itens WHERE pedido = ' + edtPedido.Text; // injection
|
|
14
|
+
Query1.Open;
|
|
15
|
+
Total := 0;
|
|
16
|
+
while not Query1.Eof do
|
|
17
|
+
begin
|
|
18
|
+
Total := Total + Query1.FieldByName('valor').AsCurrency;
|
|
19
|
+
if Query1.FieldByName('valor').AsCurrency > 1000 then
|
|
20
|
+
Total := Total - (Query1.FieldByName('valor').AsCurrency * 0.05); // discount rule
|
|
21
|
+
Query1.Next;
|
|
22
|
+
end;
|
|
23
|
+
lblTotal.Caption := FormatCurr('R$ #,##0.00', Total);
|
|
24
|
+
end;
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 2. Characterization test BEFORE touching it
|
|
28
|
+
|
|
29
|
+
Pin the current behavior — including what looks wrong. If the discount is a bug, that is a separate, deliberate commit.
|
|
30
|
+
|
|
31
|
+
```pascal
|
|
32
|
+
unit uOrderTotalsTests;
|
|
33
|
+
|
|
34
|
+
interface
|
|
35
|
+
|
|
36
|
+
uses DUnitX.TestFramework, uOrderTotals;
|
|
37
|
+
|
|
38
|
+
type
|
|
39
|
+
[TestFixture]
|
|
40
|
+
TOrderTotalsTests = class
|
|
41
|
+
public
|
|
42
|
+
[Test]
|
|
43
|
+
[TestCase('no discount under the threshold', '100,200,300')]
|
|
44
|
+
[TestCase('five percent off items over 1000', '2000,0,1900')]
|
|
45
|
+
procedure TotalMatchesLegacyBehavior(const A, B, Expected: Currency);
|
|
46
|
+
end;
|
|
47
|
+
|
|
48
|
+
implementation
|
|
49
|
+
|
|
50
|
+
procedure TOrderTotalsTests.TotalMatchesLegacyBehavior(const A, B, Expected: Currency);
|
|
51
|
+
var
|
|
52
|
+
Items: TArray<Currency>;
|
|
53
|
+
begin
|
|
54
|
+
Items := [A, B];
|
|
55
|
+
Assert.AreEqual(Expected, TOrderTotals.Sum(Items), 0.001);
|
|
56
|
+
end;
|
|
57
|
+
|
|
58
|
+
initialization
|
|
59
|
+
TDUnitX.RegisterTestFixture(TOrderTotalsTests);
|
|
60
|
+
|
|
61
|
+
end.
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## 3. The extracted rule — a unit that knows nothing about the UI
|
|
65
|
+
|
|
66
|
+
```pascal
|
|
67
|
+
unit uOrderTotals; // uses NO Vcl.* / FMX.* unit: compiles in a console test runner
|
|
68
|
+
|
|
69
|
+
interface
|
|
70
|
+
|
|
71
|
+
type
|
|
72
|
+
TOrderTotals = class
|
|
73
|
+
public
|
|
74
|
+
const DiscountThreshold = 1000;
|
|
75
|
+
const DiscountRate = 0.05;
|
|
76
|
+
/// Sum of the items, 5% off each item above the threshold (legacy behavior, pinned by tests).
|
|
77
|
+
class function Sum(const Values: TArray<Currency>): Currency; static;
|
|
78
|
+
end;
|
|
79
|
+
|
|
80
|
+
implementation
|
|
81
|
+
|
|
82
|
+
class function TOrderTotals.Sum(const Values: TArray<Currency>): Currency;
|
|
83
|
+
var
|
|
84
|
+
Value: Currency;
|
|
85
|
+
begin
|
|
86
|
+
Result := 0;
|
|
87
|
+
for Value in Values do
|
|
88
|
+
begin
|
|
89
|
+
Result := Result + Value;
|
|
90
|
+
if Value > DiscountThreshold then
|
|
91
|
+
Result := Result - (Value * DiscountRate);
|
|
92
|
+
end;
|
|
93
|
+
end;
|
|
94
|
+
|
|
95
|
+
end.
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The form now only orchestrates:
|
|
99
|
+
|
|
100
|
+
```pascal
|
|
101
|
+
procedure TMainForm.btnCalcularClick(Sender: TObject);
|
|
102
|
+
begin
|
|
103
|
+
lblTotal.Caption := FormatCurr('R$ #,##0.00',
|
|
104
|
+
TOrderTotals.Sum(FOrderRepository.ItemValues(StrToInt(edtPedido.Text))));
|
|
105
|
+
end;
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## 4. Parameterized data access with an explicit transaction
|
|
109
|
+
|
|
110
|
+
```pascal
|
|
111
|
+
function TOrderRepository.ItemValues(const OrderId: Integer): TArray<Currency>;
|
|
112
|
+
var
|
|
113
|
+
Query: TFDQuery;
|
|
114
|
+
Values: TList<Currency>;
|
|
115
|
+
begin
|
|
116
|
+
Values := TList<Currency>.Create;
|
|
117
|
+
try
|
|
118
|
+
Query := TFDQuery.Create(nil);
|
|
119
|
+
try
|
|
120
|
+
Query.Connection := FConnection; // injected, owned by the data layer
|
|
121
|
+
Query.SQL.Text := 'SELECT valor FROM itens WHERE pedido = :pedido';
|
|
122
|
+
Query.ParamByName('pedido').AsInteger := OrderId; // never string concatenation
|
|
123
|
+
Query.Open;
|
|
124
|
+
while not Query.Eof do
|
|
125
|
+
begin
|
|
126
|
+
Values.Add(Query.FieldByName('valor').AsCurrency);
|
|
127
|
+
Query.Next;
|
|
128
|
+
end;
|
|
129
|
+
finally
|
|
130
|
+
Query.Free; // created by hand → freed by hand
|
|
131
|
+
end;
|
|
132
|
+
Result := Values.ToArray;
|
|
133
|
+
finally
|
|
134
|
+
Values.Free;
|
|
135
|
+
end;
|
|
136
|
+
end;
|
|
137
|
+
|
|
138
|
+
procedure TOrderRepository.Approve(const OrderId: Integer);
|
|
139
|
+
begin
|
|
140
|
+
FConnection.StartTransaction;
|
|
141
|
+
try
|
|
142
|
+
FConnection.ExecSQL('UPDATE pedidos SET status = :s WHERE id = :id', ['aprovado', OrderId]);
|
|
143
|
+
FConnection.Commit;
|
|
144
|
+
except
|
|
145
|
+
FConnection.Rollback; // never leave a transaction open
|
|
146
|
+
raise; // never swallow the exception
|
|
147
|
+
end;
|
|
148
|
+
end;
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## 5. Threaded work that updates the UI
|
|
152
|
+
|
|
153
|
+
```pascal
|
|
154
|
+
procedure TMainForm.btnImportarClick(Sender: TObject);
|
|
155
|
+
begin
|
|
156
|
+
btnImportar.Enabled := False;
|
|
157
|
+
TThread.CreateAnonymousThread(
|
|
158
|
+
procedure
|
|
159
|
+
var
|
|
160
|
+
Imported: Integer;
|
|
161
|
+
begin
|
|
162
|
+
Imported := FImportService.Run; // no control is read or written here
|
|
163
|
+
TThread.Queue(nil,
|
|
164
|
+
procedure
|
|
165
|
+
begin
|
|
166
|
+
lblStatus.Caption := Format('%d registros importados', [Imported]);
|
|
167
|
+
btnImportar.Enabled := True; // UI only on the main thread
|
|
168
|
+
end);
|
|
169
|
+
end).Start;
|
|
170
|
+
end;
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Lazarus / Free Pascal differences
|
|
174
|
+
|
|
175
|
+
Same rules; the test framework is FPCUnit (`TTestCase` + `AssertEquals`), forms are `.lfm`, the build command is `lazbuild <project>.lpi`, and the data components are usually SQLdb (`TSQLQuery.Params.ParamByName`) instead of FireDAC.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Reference: Celery task pattern (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/django-drf-celery`. Read when writing or reviewing a Celery task.
|
|
4
|
+
|
|
5
|
+
## Idempotent task with bounded retries
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
# apps/users/tasks.py
|
|
9
|
+
from celery import shared_task
|
|
10
|
+
from celery.utils.log import get_task_logger
|
|
11
|
+
from .services import UserService
|
|
12
|
+
|
|
13
|
+
logger = get_task_logger(__name__)
|
|
14
|
+
|
|
15
|
+
@shared_task(
|
|
16
|
+
bind=True, # access to self: retry + task id
|
|
17
|
+
max_retries=3,
|
|
18
|
+
default_retry_delay=60, # seconds
|
|
19
|
+
serializer='json', # NEVER pickle
|
|
20
|
+
acks_late=True, # ack only after the task completes
|
|
21
|
+
reject_on_worker_lost=True, # re-queue if the worker dies mid-task
|
|
22
|
+
name='users.send_welcome_email',
|
|
23
|
+
)
|
|
24
|
+
def send_welcome_email(self, user_id: int) -> str:
|
|
25
|
+
"""Send welcome email to a new user. Idempotent: safe to retry."""
|
|
26
|
+
try:
|
|
27
|
+
result = UserService.send_welcome_email(user_id=user_id)
|
|
28
|
+
logger.info("Welcome email sent", extra={"user_id": user_id})
|
|
29
|
+
return result
|
|
30
|
+
except UserService.EmailAlreadySentError:
|
|
31
|
+
# Idempotency check hit — work already done, do not retry
|
|
32
|
+
logger.warning("Email already sent", extra={"user_id": user_id})
|
|
33
|
+
return "already_sent"
|
|
34
|
+
except Exception as exc:
|
|
35
|
+
logger.error("Failed to send email", exc_info=True, extra={"user_id": user_id})
|
|
36
|
+
# Exponential backoff for external services
|
|
37
|
+
raise self.retry(exc=exc, countdown=2 ** self.request.retries * 60)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Pattern summary:
|
|
41
|
+
|
|
42
|
+
- Tasks receive **IDs**, never model instances; they call a service, they hold no business logic.
|
|
43
|
+
- `serializer='json'` always — pickle deserialization is remote code execution.
|
|
44
|
+
- `acks_late=True` + `reject_on_worker_lost=True` on anything touching external services.
|
|
45
|
+
- Idempotency first: check whether the work is already done before doing it.
|
|
46
|
+
- Structured logging via `extra={}`; never f-string sensitive data into messages.
|
|
47
|
+
- In prod, route tasks to dedicated queues via `CELERY_TASK_ROUTES`; test with `CELERY_TASK_ALWAYS_EAGER = True` in the test settings only.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Reference: DRF ViewSets, serializers, and permissions (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/django-drf-celery`. Read when adding endpoints or validation.
|
|
4
|
+
|
|
5
|
+
## ViewSet delegating to a service
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
# apps/users/views.py
|
|
9
|
+
from rest_framework import viewsets, status
|
|
10
|
+
from rest_framework.decorators import action
|
|
11
|
+
from rest_framework.response import Response
|
|
12
|
+
from rest_framework.permissions import IsAuthenticated, IsAdminUser
|
|
13
|
+
from .serializers import UserSerializer, UserCreateSerializer, PasswordChangeSerializer
|
|
14
|
+
from .services import UserService
|
|
15
|
+
|
|
16
|
+
class UserViewSet(viewsets.ModelViewSet):
|
|
17
|
+
serializer_class = UserSerializer
|
|
18
|
+
permission_classes = [IsAuthenticated]
|
|
19
|
+
|
|
20
|
+
def get_queryset(self):
|
|
21
|
+
# Querysets come from the service layer, never built inline
|
|
22
|
+
if self.request.user.is_staff:
|
|
23
|
+
return UserService.list_all()
|
|
24
|
+
return UserService.list_active()
|
|
25
|
+
|
|
26
|
+
def get_permissions(self):
|
|
27
|
+
if self.action in ['destroy', 'list']:
|
|
28
|
+
return [IsAdminUser()]
|
|
29
|
+
return super().get_permissions()
|
|
30
|
+
|
|
31
|
+
def get_serializer_class(self):
|
|
32
|
+
if self.action == 'create':
|
|
33
|
+
return UserCreateSerializer
|
|
34
|
+
return self.serializer_class
|
|
35
|
+
|
|
36
|
+
def perform_create(self, serializer):
|
|
37
|
+
user = UserService.create_user(**serializer.validated_data)
|
|
38
|
+
serializer.instance = user # reflect the saved instance back
|
|
39
|
+
|
|
40
|
+
@action(detail=False, methods=['get', 'patch'], url_path='me')
|
|
41
|
+
def me(self, request):
|
|
42
|
+
if request.method == 'GET':
|
|
43
|
+
return Response(UserSerializer(request.user).data)
|
|
44
|
+
serializer = UserSerializer(request.user, data=request.data, partial=True)
|
|
45
|
+
serializer.is_valid(raise_exception=True)
|
|
46
|
+
UserService.update_user(request.user, **serializer.validated_data)
|
|
47
|
+
return Response(serializer.data)
|
|
48
|
+
|
|
49
|
+
@action(detail=False, methods=['post'], url_path='change-password')
|
|
50
|
+
def change_password(self, request):
|
|
51
|
+
serializer = PasswordChangeSerializer(data=request.data)
|
|
52
|
+
serializer.is_valid(raise_exception=True)
|
|
53
|
+
UserService.change_password(request.user, **serializer.validated_data)
|
|
54
|
+
return Response(status=status.HTTP_204_NO_CONTENT)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Serializer validation (format only, no DB queries)
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
# apps/users/serializers.py
|
|
61
|
+
from rest_framework import serializers
|
|
62
|
+
from django.contrib.auth.password_validation import validate_password
|
|
63
|
+
from .models import User
|
|
64
|
+
|
|
65
|
+
class UserCreateSerializer(serializers.ModelSerializer):
|
|
66
|
+
password = serializers.CharField(write_only=True, validators=[validate_password])
|
|
67
|
+
password_confirm = serializers.CharField(write_only=True)
|
|
68
|
+
|
|
69
|
+
class Meta:
|
|
70
|
+
model = User
|
|
71
|
+
fields = ['email', 'name', 'password', 'password_confirm']
|
|
72
|
+
|
|
73
|
+
def validate(self, data):
|
|
74
|
+
if data['password'] != data.pop('password_confirm'):
|
|
75
|
+
raise serializers.ValidationError(
|
|
76
|
+
{'password_confirm': 'Passwords do not match.'}
|
|
77
|
+
)
|
|
78
|
+
return data
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Sensitive fields are always `write_only=True`; uniqueness/existence checks belong to the service, not `validate`.
|
|
82
|
+
|
|
83
|
+
## Custom object-level permission
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
# apps/users/permissions.py
|
|
87
|
+
from rest_framework.permissions import BasePermission
|
|
88
|
+
|
|
89
|
+
class IsOwnerOrAdmin(BasePermission):
|
|
90
|
+
def has_object_permission(self, request, view, obj):
|
|
91
|
+
return obj == request.user or request.user.is_staff
|
|
92
|
+
```
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Reference: Compose file layering (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/docker-compose-dev` — base file, dev override, prod override. Note there is no top-level `version:` key: it is obsolete in the Compose Specification and current `docker compose` warns on it. Image tags below use floating tags for brevity — pin majors (or digests) in your repo.
|
|
4
|
+
|
|
5
|
+
## Base file (shared by all environments)
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
# docker-compose.yml
|
|
9
|
+
x-common-env: &common-env
|
|
10
|
+
NODE_ENV: ${NODE_ENV:-development}
|
|
11
|
+
LOG_LEVEL: ${LOG_LEVEL:-debug}
|
|
12
|
+
|
|
13
|
+
services:
|
|
14
|
+
app:
|
|
15
|
+
build:
|
|
16
|
+
context: .
|
|
17
|
+
dockerfile: Dockerfile
|
|
18
|
+
target: ${BUILD_TARGET:-dev} # dev | prod
|
|
19
|
+
ports:
|
|
20
|
+
- "${APP_PORT:-3000}:3000"
|
|
21
|
+
environment:
|
|
22
|
+
<<: *common-env
|
|
23
|
+
DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
|
|
24
|
+
REDIS_URL: redis://redis:6379
|
|
25
|
+
PORT: 3000
|
|
26
|
+
depends_on:
|
|
27
|
+
postgres:
|
|
28
|
+
condition: service_healthy
|
|
29
|
+
redis:
|
|
30
|
+
condition: service_healthy
|
|
31
|
+
networks: [app-network]
|
|
32
|
+
restart: unless-stopped
|
|
33
|
+
|
|
34
|
+
postgres:
|
|
35
|
+
image: postgres:alpine # pin a major in your repo
|
|
36
|
+
environment:
|
|
37
|
+
POSTGRES_USER: ${POSTGRES_USER:-appuser}
|
|
38
|
+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
|
|
39
|
+
POSTGRES_DB: ${POSTGRES_DB:-appdb}
|
|
40
|
+
volumes:
|
|
41
|
+
- postgres-data:/var/lib/postgresql/data
|
|
42
|
+
- ./db/init:/docker-entrypoint-initdb.d:ro # init SQL scripts
|
|
43
|
+
healthcheck:
|
|
44
|
+
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-appuser} -d ${POSTGRES_DB:-appdb}"]
|
|
45
|
+
interval: 5s
|
|
46
|
+
timeout: 5s
|
|
47
|
+
retries: 10
|
|
48
|
+
start_period: 10s
|
|
49
|
+
networks: [app-network]
|
|
50
|
+
restart: unless-stopped
|
|
51
|
+
|
|
52
|
+
redis:
|
|
53
|
+
image: redis:alpine
|
|
54
|
+
command: >
|
|
55
|
+
redis-server
|
|
56
|
+
--requirepass ${REDIS_PASSWORD:-changeme}
|
|
57
|
+
--maxmemory 256mb
|
|
58
|
+
--maxmemory-policy allkeys-lru
|
|
59
|
+
volumes:
|
|
60
|
+
- redis-data:/data
|
|
61
|
+
healthcheck:
|
|
62
|
+
test: ["CMD-SHELL", "redis-cli -a $$REDIS_PASSWORD ping | grep PONG"]
|
|
63
|
+
interval: 5s
|
|
64
|
+
timeout: 3s
|
|
65
|
+
retries: 5
|
|
66
|
+
networks: [app-network]
|
|
67
|
+
restart: unless-stopped
|
|
68
|
+
|
|
69
|
+
networks:
|
|
70
|
+
app-network:
|
|
71
|
+
driver: bridge
|
|
72
|
+
|
|
73
|
+
volumes:
|
|
74
|
+
postgres-data:
|
|
75
|
+
redis-data:
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Dev override (auto-loaded by `docker compose up`)
|
|
79
|
+
|
|
80
|
+
```yaml
|
|
81
|
+
# docker-compose.override.yml
|
|
82
|
+
services:
|
|
83
|
+
app:
|
|
84
|
+
build:
|
|
85
|
+
target: dev
|
|
86
|
+
volumes:
|
|
87
|
+
# Hot reload: bind-mount source into the container
|
|
88
|
+
- ./src:/app/src:delegated
|
|
89
|
+
- ./package.json:/app/package.json:ro
|
|
90
|
+
- ./tsconfig.json:/app/tsconfig.json:ro
|
|
91
|
+
# Preserve the container's node_modules (never bind-mounted)
|
|
92
|
+
- app-node-modules:/app/node_modules
|
|
93
|
+
command: npm run dev
|
|
94
|
+
environment:
|
|
95
|
+
CHOKIDAR_USEPOLLING: "true" # file watching on Windows/WSL2
|
|
96
|
+
WATCHPACK_POLLING: "true"
|
|
97
|
+
|
|
98
|
+
postgres:
|
|
99
|
+
ports:
|
|
100
|
+
- "5432:5432" # exposed in dev only, for local DB clients
|
|
101
|
+
|
|
102
|
+
redis:
|
|
103
|
+
ports:
|
|
104
|
+
- "6379:6379"
|
|
105
|
+
|
|
106
|
+
volumes:
|
|
107
|
+
app-node-modules:
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Prod override (explicit `-f` chain only)
|
|
111
|
+
|
|
112
|
+
```yaml
|
|
113
|
+
# docker-compose.prod.yml
|
|
114
|
+
# Usage: docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d --build
|
|
115
|
+
services:
|
|
116
|
+
app:
|
|
117
|
+
build:
|
|
118
|
+
target: prod
|
|
119
|
+
restart: always
|
|
120
|
+
deploy:
|
|
121
|
+
resources:
|
|
122
|
+
limits:
|
|
123
|
+
cpus: '0.5'
|
|
124
|
+
memory: 512M
|
|
125
|
+
reservations:
|
|
126
|
+
cpus: '0.25'
|
|
127
|
+
memory: 256M
|
|
128
|
+
logging:
|
|
129
|
+
driver: "json-file"
|
|
130
|
+
options:
|
|
131
|
+
max-size: "10m"
|
|
132
|
+
max-file: "3"
|
|
133
|
+
|
|
134
|
+
postgres:
|
|
135
|
+
# No host ports in production
|
|
136
|
+
deploy:
|
|
137
|
+
resources:
|
|
138
|
+
limits:
|
|
139
|
+
memory: 1G
|
|
140
|
+
|
|
141
|
+
redis:
|
|
142
|
+
deploy:
|
|
143
|
+
resources:
|
|
144
|
+
limits:
|
|
145
|
+
memory: 512M
|
|
146
|
+
```
|