@useatlas/create 0.0.1
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/README.md +231 -0
- package/index.ts +829 -0
- package/package.json +38 -0
- package/templates/docker/.env.example +67 -0
- package/templates/docker/Dockerfile +52 -0
- package/templates/docker/bin/__tests__/benchmark.test.ts +598 -0
- package/templates/docker/bin/__tests__/duckdb-ingest.test.ts +171 -0
- package/templates/docker/bin/__tests__/eval.test.ts +434 -0
- package/templates/docker/bin/__tests__/matview-partition.test.ts +615 -0
- package/templates/docker/bin/__tests__/multi-source.test.ts +113 -0
- package/templates/docker/bin/__tests__/plugin-cli.test.ts +322 -0
- package/templates/docker/bin/__tests__/profiler-heuristics.test.ts +608 -0
- package/templates/docker/bin/__tests__/query.test.ts +240 -0
- package/templates/docker/bin/__tests__/schema-drift.test.ts +542 -0
- package/templates/docker/bin/__tests__/view-yaml-generation.test.ts +146 -0
- package/templates/docker/bin/atlas.ts +5044 -0
- package/templates/docker/bin/benchmark.ts +695 -0
- package/templates/docker/bin/enrich.ts +559 -0
- package/templates/docker/bin/eval.ts +770 -0
- package/templates/docker/bin/smoke.ts +438 -0
- package/templates/docker/data/.gitkeep +0 -0
- package/templates/docker/data/cybersec.sql +1961 -0
- package/templates/docker/data/demo-semantic/catalog.yml +40 -0
- package/templates/docker/data/demo-semantic/entities/accounts.yml +170 -0
- package/templates/docker/data/demo-semantic/entities/companies.yml +207 -0
- package/templates/docker/data/demo-semantic/entities/people.yml +145 -0
- package/templates/docker/data/demo-semantic/glossary.yml +22 -0
- package/templates/docker/data/demo-semantic/metrics/accounts.yml +38 -0
- package/templates/docker/data/demo-semantic/metrics/companies.yml +89 -0
- package/templates/docker/data/demo.sql +373 -0
- package/templates/docker/data/ecommerce.sql +1690 -0
- package/templates/docker/data/init-demo-db.sql +8 -0
- package/templates/docker/docker-compose.yml +34 -0
- package/templates/docker/docs/deploy.md +390 -0
- package/templates/docker/eslint.config.mjs +18 -0
- package/templates/docker/gitignore +5 -0
- package/templates/docker/next.config.ts +9 -0
- package/templates/docker/package.json +59 -0
- package/templates/docker/postcss.config.mjs +8 -0
- package/templates/docker/public/.gitkeep +0 -0
- package/templates/docker/public/favicon.svg +4 -0
- package/templates/docker/railway.json +13 -0
- package/templates/docker/render.yaml +34 -0
- package/templates/docker/semantic/catalog.yml +5 -0
- package/templates/docker/semantic/entities/.gitkeep +0 -0
- package/templates/docker/semantic/glossary.yml +6 -0
- package/templates/docker/semantic/metrics/.gitkeep +0 -0
- package/templates/docker/sidecar/Dockerfile +28 -0
- package/templates/docker/sidecar/railway.json +14 -0
- package/templates/docker/sidecar/server.ts +188 -0
- package/templates/docker/src/api/__tests__/actions.test.ts +683 -0
- package/templates/docker/src/api/__tests__/admin.test.ts +820 -0
- package/templates/docker/src/api/__tests__/auth.test.ts +165 -0
- package/templates/docker/src/api/__tests__/chat.test.ts +376 -0
- package/templates/docker/src/api/__tests__/conversations.test.ts +555 -0
- package/templates/docker/src/api/__tests__/cors.test.ts +135 -0
- package/templates/docker/src/api/__tests__/health-plugin.test.ts +169 -0
- package/templates/docker/src/api/__tests__/health.test.ts +261 -0
- package/templates/docker/src/api/__tests__/query.test.ts +891 -0
- package/templates/docker/src/api/__tests__/scheduled-tasks.test.ts +601 -0
- package/templates/docker/src/api/__tests__/slack.test.ts +847 -0
- package/templates/docker/src/api/index.ts +117 -0
- package/templates/docker/src/api/routes/actions.ts +274 -0
- package/templates/docker/src/api/routes/admin.ts +757 -0
- package/templates/docker/src/api/routes/auth.ts +48 -0
- package/templates/docker/src/api/routes/chat.ts +465 -0
- package/templates/docker/src/api/routes/conversations.ts +266 -0
- package/templates/docker/src/api/routes/health.ts +287 -0
- package/templates/docker/src/api/routes/openapi.ts +390 -0
- package/templates/docker/src/api/routes/query.ts +318 -0
- package/templates/docker/src/api/routes/scheduled-tasks.ts +467 -0
- package/templates/docker/src/api/routes/slack.ts +611 -0
- package/templates/docker/src/api/server.ts +226 -0
- package/templates/docker/src/app/api/[...route]/route.ts +33 -0
- package/templates/docker/src/app/error.tsx +24 -0
- package/templates/docker/src/app/globals.css +126 -0
- package/templates/docker/src/app/layout.tsx +19 -0
- package/templates/docker/src/app/page.tsx +14 -0
- package/templates/docker/src/global.d.ts +1 -0
- package/templates/docker/src/lib/__tests__/agent-cache.test.ts +437 -0
- package/templates/docker/src/lib/__tests__/agent-dialect.test.ts +114 -0
- package/templates/docker/src/lib/__tests__/agent-health-annotations.test.ts +164 -0
- package/templates/docker/src/lib/__tests__/agent-integration.test.ts +514 -0
- package/templates/docker/src/lib/__tests__/config-actions.test.ts +166 -0
- package/templates/docker/src/lib/__tests__/config.test.ts +1063 -0
- package/templates/docker/src/lib/__tests__/conversations.test.ts +589 -0
- package/templates/docker/src/lib/__tests__/errors.test.ts +256 -0
- package/templates/docker/src/lib/__tests__/logger.test.ts +200 -0
- package/templates/docker/src/lib/__tests__/providers.test.ts +99 -0
- package/templates/docker/src/lib/__tests__/rls.test.ts +435 -0
- package/templates/docker/src/lib/__tests__/scheduled-task-types.test.ts +124 -0
- package/templates/docker/src/lib/__tests__/scheduled-tasks.test.ts +550 -0
- package/templates/docker/src/lib/__tests__/semantic-index.test.ts +547 -0
- package/templates/docker/src/lib/__tests__/semantic-multisource.test.ts +544 -0
- package/templates/docker/src/lib/__tests__/semantic.test.ts +363 -0
- package/templates/docker/src/lib/__tests__/startup-actions.test.ts +452 -0
- package/templates/docker/src/lib/__tests__/startup.test.ts +465 -0
- package/templates/docker/src/lib/__tests__/tracing.test.ts +28 -0
- package/templates/docker/src/lib/action-types.ts +95 -0
- package/templates/docker/src/lib/agent-query.ts +178 -0
- package/templates/docker/src/lib/agent.ts +505 -0
- package/templates/docker/src/lib/api-url.ts +2 -0
- package/templates/docker/src/lib/auth/__tests__/audit.test.ts +418 -0
- package/templates/docker/src/lib/auth/__tests__/byot-integration.test.ts +222 -0
- package/templates/docker/src/lib/auth/__tests__/byot.test.ts +366 -0
- package/templates/docker/src/lib/auth/__tests__/detect.test.ts +190 -0
- package/templates/docker/src/lib/auth/__tests__/managed.test.ts +173 -0
- package/templates/docker/src/lib/auth/__tests__/middleware.test.ts +456 -0
- package/templates/docker/src/lib/auth/__tests__/migrate.test.ts +201 -0
- package/templates/docker/src/lib/auth/__tests__/permissions.test.ts +225 -0
- package/templates/docker/src/lib/auth/__tests__/server.test.ts +34 -0
- package/templates/docker/src/lib/auth/__tests__/simple-key.test.ts +176 -0
- package/templates/docker/src/lib/auth/__tests__/types.test.ts +44 -0
- package/templates/docker/src/lib/auth/audit.ts +89 -0
- package/templates/docker/src/lib/auth/byot.ts +158 -0
- package/templates/docker/src/lib/auth/client.ts +35 -0
- package/templates/docker/src/lib/auth/detect.ts +83 -0
- package/templates/docker/src/lib/auth/managed.ts +73 -0
- package/templates/docker/src/lib/auth/middleware.ts +208 -0
- package/templates/docker/src/lib/auth/migrate.ts +111 -0
- package/templates/docker/src/lib/auth/permissions.ts +156 -0
- package/templates/docker/src/lib/auth/server.ts +142 -0
- package/templates/docker/src/lib/auth/simple-key.ts +92 -0
- package/templates/docker/src/lib/auth/types.ts +49 -0
- package/templates/docker/src/lib/config.ts +704 -0
- package/templates/docker/src/lib/conversation-types.ts +29 -0
- package/templates/docker/src/lib/conversations.ts +270 -0
- package/templates/docker/src/lib/db/__tests__/connection.test.ts +69 -0
- package/templates/docker/src/lib/db/__tests__/duckdb.test.ts +141 -0
- package/templates/docker/src/lib/db/__tests__/internal.test.ts +387 -0
- package/templates/docker/src/lib/db/__tests__/registry-health.test.ts +207 -0
- package/templates/docker/src/lib/db/__tests__/registry-pool-limits.test.ts +156 -0
- package/templates/docker/src/lib/db/__tests__/registry.test.ts +595 -0
- package/templates/docker/src/lib/db/__tests__/salesforce.test.ts +339 -0
- package/templates/docker/src/lib/db/__tests__/snowflake.test.ts +217 -0
- package/templates/docker/src/lib/db/__tests__/source-rate-limit.test.ts +130 -0
- package/templates/docker/src/lib/db/connection.ts +753 -0
- package/templates/docker/src/lib/db/duckdb.ts +122 -0
- package/templates/docker/src/lib/db/internal.ts +273 -0
- package/templates/docker/src/lib/db/salesforce.ts +342 -0
- package/templates/docker/src/lib/db/source-rate-limit.ts +191 -0
- package/templates/docker/src/lib/errors.ts +154 -0
- package/templates/docker/src/lib/logger.ts +98 -0
- package/templates/docker/src/lib/plugins/__tests__/hooks-integration.test.ts +202 -0
- package/templates/docker/src/lib/plugins/__tests__/hooks.test.ts +529 -0
- package/templates/docker/src/lib/plugins/__tests__/migrate.test.ts +521 -0
- package/templates/docker/src/lib/plugins/__tests__/registry.test.ts +346 -0
- package/templates/docker/src/lib/plugins/__tests__/tools.test.ts +49 -0
- package/templates/docker/src/lib/plugins/__tests__/wiring.test.ts +585 -0
- package/templates/docker/src/lib/plugins/hooks.ts +162 -0
- package/templates/docker/src/lib/plugins/index.ts +9 -0
- package/templates/docker/src/lib/plugins/migrate.ts +309 -0
- package/templates/docker/src/lib/plugins/registry.ts +231 -0
- package/templates/docker/src/lib/plugins/tools.ts +39 -0
- package/templates/docker/src/lib/plugins/wiring.ts +291 -0
- package/templates/docker/src/lib/providers.ts +102 -0
- package/templates/docker/src/lib/rls.ts +321 -0
- package/templates/docker/src/lib/scheduled-task-types.ts +132 -0
- package/templates/docker/src/lib/scheduled-tasks.ts +475 -0
- package/templates/docker/src/lib/scheduler/__tests__/delivery.test.ts +192 -0
- package/templates/docker/src/lib/scheduler/__tests__/engine.test.ts +248 -0
- package/templates/docker/src/lib/scheduler/__tests__/format-email.test.ts +96 -0
- package/templates/docker/src/lib/scheduler/__tests__/format-slack.test.ts +78 -0
- package/templates/docker/src/lib/scheduler/__tests__/format-webhook.test.ts +78 -0
- package/templates/docker/src/lib/scheduler/delivery.ts +248 -0
- package/templates/docker/src/lib/scheduler/engine.ts +317 -0
- package/templates/docker/src/lib/scheduler/executor.ts +73 -0
- package/templates/docker/src/lib/scheduler/format-email.ts +109 -0
- package/templates/docker/src/lib/scheduler/format-slack.ts +35 -0
- package/templates/docker/src/lib/scheduler/format-webhook.ts +37 -0
- package/templates/docker/src/lib/scheduler/index.ts +7 -0
- package/templates/docker/src/lib/security.ts +11 -0
- package/templates/docker/src/lib/semantic-index.ts +503 -0
- package/templates/docker/src/lib/semantic.ts +387 -0
- package/templates/docker/src/lib/sidecar-types.ts +16 -0
- package/templates/docker/src/lib/slack/__tests__/api.test.ts +160 -0
- package/templates/docker/src/lib/slack/__tests__/format.test.ts +237 -0
- package/templates/docker/src/lib/slack/__tests__/store.test.ts +188 -0
- package/templates/docker/src/lib/slack/__tests__/threads.test.ts +112 -0
- package/templates/docker/src/lib/slack/__tests__/verify.test.ts +111 -0
- package/templates/docker/src/lib/slack/api.ts +102 -0
- package/templates/docker/src/lib/slack/format.ts +209 -0
- package/templates/docker/src/lib/slack/store.ts +107 -0
- package/templates/docker/src/lib/slack/threads.ts +64 -0
- package/templates/docker/src/lib/slack/verify.ts +71 -0
- package/templates/docker/src/lib/startup.ts +730 -0
- package/templates/docker/src/lib/tools/__tests__/action-permissions.test.ts +594 -0
- package/templates/docker/src/lib/tools/__tests__/custom-validation.test.ts +238 -0
- package/templates/docker/src/lib/tools/__tests__/explore-backend.test.ts +267 -0
- package/templates/docker/src/lib/tools/__tests__/explore-nsjail.test.ts +492 -0
- package/templates/docker/src/lib/tools/__tests__/explore-plugin.test.ts +374 -0
- package/templates/docker/src/lib/tools/__tests__/explore-sdk-compat.test.ts +82 -0
- package/templates/docker/src/lib/tools/__tests__/explore-sidecar.test.ts +208 -0
- package/templates/docker/src/lib/tools/__tests__/registry-actions.test.ts +144 -0
- package/templates/docker/src/lib/tools/__tests__/registry.test.ts +235 -0
- package/templates/docker/src/lib/tools/__tests__/salesforce-tool.test.ts +154 -0
- package/templates/docker/src/lib/tools/__tests__/soql-validation.test.ts +303 -0
- package/templates/docker/src/lib/tools/__tests__/sql-audit.test.ts +225 -0
- package/templates/docker/src/lib/tools/__tests__/sql-connection-whitelist.test.ts +98 -0
- package/templates/docker/src/lib/tools/__tests__/sql-duckdb.test.ts +233 -0
- package/templates/docker/src/lib/tools/__tests__/sql-ratelimit.test.ts +225 -0
- package/templates/docker/src/lib/tools/__tests__/sql.test.ts +1012 -0
- package/templates/docker/src/lib/tools/actions/__tests__/audit.test.ts +211 -0
- package/templates/docker/src/lib/tools/actions/__tests__/email.test.ts +378 -0
- package/templates/docker/src/lib/tools/actions/__tests__/handler.test.ts +681 -0
- package/templates/docker/src/lib/tools/actions/__tests__/jira.test.ts +427 -0
- package/templates/docker/src/lib/tools/actions/audit.ts +47 -0
- package/templates/docker/src/lib/tools/actions/email.ts +191 -0
- package/templates/docker/src/lib/tools/actions/handler.ts +591 -0
- package/templates/docker/src/lib/tools/actions/index.ts +23 -0
- package/templates/docker/src/lib/tools/actions/jira.ts +220 -0
- package/templates/docker/src/lib/tools/explore-nsjail.ts +343 -0
- package/templates/docker/src/lib/tools/explore-sandbox.ts +264 -0
- package/templates/docker/src/lib/tools/explore-sidecar.ts +163 -0
- package/templates/docker/src/lib/tools/explore.ts +379 -0
- package/templates/docker/src/lib/tools/registry.ts +221 -0
- package/templates/docker/src/lib/tools/salesforce.ts +138 -0
- package/templates/docker/src/lib/tools/soql-validation.ts +172 -0
- package/templates/docker/src/lib/tools/sql.ts +680 -0
- package/templates/docker/src/lib/tracing.ts +40 -0
- package/templates/docker/src/lib/utils.ts +6 -0
- package/templates/docker/src/test-setup.ts +38 -0
- package/templates/docker/src/types/vercel-sandbox.d.ts +54 -0
- package/templates/docker/src/ui/components/actions/action-approval-card.tsx +295 -0
- package/templates/docker/src/ui/components/actions/action-status-badge.tsx +50 -0
- package/templates/docker/src/ui/components/admin/admin-layout.tsx +26 -0
- package/templates/docker/src/ui/components/admin/admin-sidebar.tsx +96 -0
- package/templates/docker/src/ui/components/admin/empty-state.tsx +24 -0
- package/templates/docker/src/ui/components/admin/entity-detail.tsx +233 -0
- package/templates/docker/src/ui/components/admin/entity-list.tsx +96 -0
- package/templates/docker/src/ui/components/admin/error-banner.tsx +22 -0
- package/templates/docker/src/ui/components/admin/feature-disabled.tsx +44 -0
- package/templates/docker/src/ui/components/admin/health-badge.tsx +30 -0
- package/templates/docker/src/ui/components/admin/loading-state.tsx +14 -0
- package/templates/docker/src/ui/components/admin/stat-card.tsx +32 -0
- package/templates/docker/src/ui/components/atlas-chat.tsx +370 -0
- package/templates/docker/src/ui/components/chart/chart-detection.ts +261 -0
- package/templates/docker/src/ui/components/chart/result-chart.tsx +375 -0
- package/templates/docker/src/ui/components/chat/api-key-bar.tsx +66 -0
- package/templates/docker/src/ui/components/chat/copy-button.tsx +25 -0
- package/templates/docker/src/ui/components/chat/data-table.tsx +102 -0
- package/templates/docker/src/ui/components/chat/error-banner.tsx +32 -0
- package/templates/docker/src/ui/components/chat/explore-card.tsx +41 -0
- package/templates/docker/src/ui/components/chat/loading-card.tsx +10 -0
- package/templates/docker/src/ui/components/chat/managed-auth-card.tsx +116 -0
- package/templates/docker/src/ui/components/chat/markdown.tsx +72 -0
- package/templates/docker/src/ui/components/chat/sql-block.tsx +30 -0
- package/templates/docker/src/ui/components/chat/sql-result-card.tsx +144 -0
- package/templates/docker/src/ui/components/chat/starter-prompts.ts +6 -0
- package/templates/docker/src/ui/components/chat/tool-part.tsx +40 -0
- package/templates/docker/src/ui/components/chat/typing-indicator.tsx +19 -0
- package/templates/docker/src/ui/components/conversations/conversation-item.tsx +120 -0
- package/templates/docker/src/ui/components/conversations/conversation-list.tsx +66 -0
- package/templates/docker/src/ui/components/conversations/conversation-sidebar.tsx +78 -0
- package/templates/docker/src/ui/components/conversations/delete-confirmation.tsx +27 -0
- package/templates/docker/src/ui/context.tsx +78 -0
- package/templates/docker/src/ui/hooks/use-admin-fetch.ts +104 -0
- package/templates/docker/src/ui/hooks/use-conversations.ts +184 -0
- package/templates/docker/src/ui/hooks/use-dark-mode.ts +17 -0
- package/templates/docker/src/ui/lib/action-types.ts +63 -0
- package/templates/docker/src/ui/lib/helpers.ts +104 -0
- package/templates/docker/src/ui/lib/types.ts +145 -0
- package/templates/docker/tsconfig.json +41 -0
- package/templates/docker/vercel.json +3 -0
- package/templates/nextjs-standalone/.env.example +68 -0
- package/templates/nextjs-standalone/bin/__tests__/benchmark.test.ts +598 -0
- package/templates/nextjs-standalone/bin/__tests__/duckdb-ingest.test.ts +171 -0
- package/templates/nextjs-standalone/bin/__tests__/eval.test.ts +434 -0
- package/templates/nextjs-standalone/bin/__tests__/matview-partition.test.ts +615 -0
- package/templates/nextjs-standalone/bin/__tests__/multi-source.test.ts +113 -0
- package/templates/nextjs-standalone/bin/__tests__/plugin-cli.test.ts +322 -0
- package/templates/nextjs-standalone/bin/__tests__/profiler-heuristics.test.ts +608 -0
- package/templates/nextjs-standalone/bin/__tests__/query.test.ts +240 -0
- package/templates/nextjs-standalone/bin/__tests__/schema-drift.test.ts +542 -0
- package/templates/nextjs-standalone/bin/__tests__/view-yaml-generation.test.ts +146 -0
- package/templates/nextjs-standalone/bin/atlas.ts +5044 -0
- package/templates/nextjs-standalone/bin/benchmark.ts +695 -0
- package/templates/nextjs-standalone/bin/enrich.ts +559 -0
- package/templates/nextjs-standalone/bin/eval.ts +770 -0
- package/templates/nextjs-standalone/bin/smoke.ts +438 -0
- package/templates/nextjs-standalone/data/.gitkeep +0 -0
- package/templates/nextjs-standalone/data/cybersec.sql +1961 -0
- package/templates/nextjs-standalone/data/demo-semantic/catalog.yml +40 -0
- package/templates/nextjs-standalone/data/demo-semantic/entities/accounts.yml +170 -0
- package/templates/nextjs-standalone/data/demo-semantic/entities/companies.yml +207 -0
- package/templates/nextjs-standalone/data/demo-semantic/entities/people.yml +145 -0
- package/templates/nextjs-standalone/data/demo-semantic/glossary.yml +22 -0
- package/templates/nextjs-standalone/data/demo-semantic/metrics/accounts.yml +38 -0
- package/templates/nextjs-standalone/data/demo-semantic/metrics/companies.yml +89 -0
- package/templates/nextjs-standalone/data/demo.sql +373 -0
- package/templates/nextjs-standalone/data/ecommerce.sql +1690 -0
- package/templates/nextjs-standalone/data/init-demo-db.sql +8 -0
- package/templates/nextjs-standalone/docs/deploy.md +390 -0
- package/templates/nextjs-standalone/eslint.config.mjs +18 -0
- package/templates/nextjs-standalone/gitignore +5 -0
- package/templates/nextjs-standalone/next.config.ts +10 -0
- package/templates/nextjs-standalone/package.json +63 -0
- package/templates/nextjs-standalone/postcss.config.mjs +8 -0
- package/templates/nextjs-standalone/semantic/catalog.yml +5 -0
- package/templates/nextjs-standalone/semantic/entities/.gitkeep +0 -0
- package/templates/nextjs-standalone/semantic/glossary.yml +6 -0
- package/templates/nextjs-standalone/semantic/metrics/.gitkeep +0 -0
- package/templates/nextjs-standalone/src/api/__tests__/actions.test.ts +683 -0
- package/templates/nextjs-standalone/src/api/__tests__/admin.test.ts +820 -0
- package/templates/nextjs-standalone/src/api/__tests__/auth.test.ts +165 -0
- package/templates/nextjs-standalone/src/api/__tests__/chat.test.ts +376 -0
- package/templates/nextjs-standalone/src/api/__tests__/conversations.test.ts +555 -0
- package/templates/nextjs-standalone/src/api/__tests__/cors.test.ts +135 -0
- package/templates/nextjs-standalone/src/api/__tests__/health-plugin.test.ts +169 -0
- package/templates/nextjs-standalone/src/api/__tests__/health.test.ts +261 -0
- package/templates/nextjs-standalone/src/api/__tests__/query.test.ts +891 -0
- package/templates/nextjs-standalone/src/api/__tests__/scheduled-tasks.test.ts +601 -0
- package/templates/nextjs-standalone/src/api/__tests__/slack.test.ts +847 -0
- package/templates/nextjs-standalone/src/api/index.ts +117 -0
- package/templates/nextjs-standalone/src/api/routes/actions.ts +274 -0
- package/templates/nextjs-standalone/src/api/routes/admin.ts +757 -0
- package/templates/nextjs-standalone/src/api/routes/auth.ts +48 -0
- package/templates/nextjs-standalone/src/api/routes/chat.ts +465 -0
- package/templates/nextjs-standalone/src/api/routes/conversations.ts +266 -0
- package/templates/nextjs-standalone/src/api/routes/health.ts +287 -0
- package/templates/nextjs-standalone/src/api/routes/openapi.ts +390 -0
- package/templates/nextjs-standalone/src/api/routes/query.ts +318 -0
- package/templates/nextjs-standalone/src/api/routes/scheduled-tasks.ts +467 -0
- package/templates/nextjs-standalone/src/api/routes/slack.ts +611 -0
- package/templates/nextjs-standalone/src/api/server.ts +226 -0
- package/templates/nextjs-standalone/src/app/api/[...route]/route.ts +33 -0
- package/templates/nextjs-standalone/src/app/error.tsx +24 -0
- package/templates/nextjs-standalone/src/app/global-error.tsx +68 -0
- package/templates/nextjs-standalone/src/app/globals.css +126 -0
- package/templates/nextjs-standalone/src/app/layout.tsx +19 -0
- package/templates/nextjs-standalone/src/app/page.tsx +14 -0
- package/templates/nextjs-standalone/src/lib/__tests__/agent-cache.test.ts +437 -0
- package/templates/nextjs-standalone/src/lib/__tests__/agent-dialect.test.ts +114 -0
- package/templates/nextjs-standalone/src/lib/__tests__/agent-health-annotations.test.ts +164 -0
- package/templates/nextjs-standalone/src/lib/__tests__/agent-integration.test.ts +514 -0
- package/templates/nextjs-standalone/src/lib/__tests__/config-actions.test.ts +166 -0
- package/templates/nextjs-standalone/src/lib/__tests__/config.test.ts +1063 -0
- package/templates/nextjs-standalone/src/lib/__tests__/conversations.test.ts +589 -0
- package/templates/nextjs-standalone/src/lib/__tests__/errors.test.ts +256 -0
- package/templates/nextjs-standalone/src/lib/__tests__/logger.test.ts +200 -0
- package/templates/nextjs-standalone/src/lib/__tests__/providers.test.ts +99 -0
- package/templates/nextjs-standalone/src/lib/__tests__/rls.test.ts +435 -0
- package/templates/nextjs-standalone/src/lib/__tests__/scheduled-task-types.test.ts +124 -0
- package/templates/nextjs-standalone/src/lib/__tests__/scheduled-tasks.test.ts +550 -0
- package/templates/nextjs-standalone/src/lib/__tests__/semantic-index.test.ts +547 -0
- package/templates/nextjs-standalone/src/lib/__tests__/semantic-multisource.test.ts +544 -0
- package/templates/nextjs-standalone/src/lib/__tests__/semantic.test.ts +363 -0
- package/templates/nextjs-standalone/src/lib/__tests__/startup-actions.test.ts +452 -0
- package/templates/nextjs-standalone/src/lib/__tests__/startup.test.ts +465 -0
- package/templates/nextjs-standalone/src/lib/__tests__/tracing.test.ts +28 -0
- package/templates/nextjs-standalone/src/lib/action-types.ts +95 -0
- package/templates/nextjs-standalone/src/lib/agent-query.ts +178 -0
- package/templates/nextjs-standalone/src/lib/agent.ts +505 -0
- package/templates/nextjs-standalone/src/lib/api-url.ts +3 -0
- package/templates/nextjs-standalone/src/lib/auth/__tests__/audit.test.ts +418 -0
- package/templates/nextjs-standalone/src/lib/auth/__tests__/byot-integration.test.ts +222 -0
- package/templates/nextjs-standalone/src/lib/auth/__tests__/byot.test.ts +366 -0
- package/templates/nextjs-standalone/src/lib/auth/__tests__/detect.test.ts +190 -0
- package/templates/nextjs-standalone/src/lib/auth/__tests__/managed.test.ts +173 -0
- package/templates/nextjs-standalone/src/lib/auth/__tests__/middleware.test.ts +456 -0
- package/templates/nextjs-standalone/src/lib/auth/__tests__/migrate.test.ts +201 -0
- package/templates/nextjs-standalone/src/lib/auth/__tests__/permissions.test.ts +225 -0
- package/templates/nextjs-standalone/src/lib/auth/__tests__/server.test.ts +34 -0
- package/templates/nextjs-standalone/src/lib/auth/__tests__/simple-key.test.ts +176 -0
- package/templates/nextjs-standalone/src/lib/auth/__tests__/types.test.ts +44 -0
- package/templates/nextjs-standalone/src/lib/auth/audit.ts +89 -0
- package/templates/nextjs-standalone/src/lib/auth/byot.ts +158 -0
- package/templates/nextjs-standalone/src/lib/auth/client.ts +23 -0
- package/templates/nextjs-standalone/src/lib/auth/detect.ts +83 -0
- package/templates/nextjs-standalone/src/lib/auth/managed.ts +73 -0
- package/templates/nextjs-standalone/src/lib/auth/middleware.ts +208 -0
- package/templates/nextjs-standalone/src/lib/auth/migrate.ts +111 -0
- package/templates/nextjs-standalone/src/lib/auth/permissions.ts +156 -0
- package/templates/nextjs-standalone/src/lib/auth/server.ts +142 -0
- package/templates/nextjs-standalone/src/lib/auth/simple-key.ts +92 -0
- package/templates/nextjs-standalone/src/lib/auth/types.ts +49 -0
- package/templates/nextjs-standalone/src/lib/config.ts +704 -0
- package/templates/nextjs-standalone/src/lib/conversation-types.ts +29 -0
- package/templates/nextjs-standalone/src/lib/conversations.ts +270 -0
- package/templates/nextjs-standalone/src/lib/db/__tests__/connection.test.ts +69 -0
- package/templates/nextjs-standalone/src/lib/db/__tests__/duckdb.test.ts +141 -0
- package/templates/nextjs-standalone/src/lib/db/__tests__/internal.test.ts +387 -0
- package/templates/nextjs-standalone/src/lib/db/__tests__/registry-health.test.ts +207 -0
- package/templates/nextjs-standalone/src/lib/db/__tests__/registry-pool-limits.test.ts +156 -0
- package/templates/nextjs-standalone/src/lib/db/__tests__/registry.test.ts +595 -0
- package/templates/nextjs-standalone/src/lib/db/__tests__/salesforce.test.ts +339 -0
- package/templates/nextjs-standalone/src/lib/db/__tests__/snowflake.test.ts +217 -0
- package/templates/nextjs-standalone/src/lib/db/__tests__/source-rate-limit.test.ts +130 -0
- package/templates/nextjs-standalone/src/lib/db/connection.ts +753 -0
- package/templates/nextjs-standalone/src/lib/db/duckdb.ts +122 -0
- package/templates/nextjs-standalone/src/lib/db/internal.ts +273 -0
- package/templates/nextjs-standalone/src/lib/db/salesforce.ts +342 -0
- package/templates/nextjs-standalone/src/lib/db/source-rate-limit.ts +191 -0
- package/templates/nextjs-standalone/src/lib/errors.ts +154 -0
- package/templates/nextjs-standalone/src/lib/logger.ts +98 -0
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/hooks-integration.test.ts +202 -0
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/hooks.test.ts +529 -0
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/migrate.test.ts +521 -0
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/registry.test.ts +346 -0
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/tools.test.ts +49 -0
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/wiring.test.ts +585 -0
- package/templates/nextjs-standalone/src/lib/plugins/hooks.ts +162 -0
- package/templates/nextjs-standalone/src/lib/plugins/index.ts +9 -0
- package/templates/nextjs-standalone/src/lib/plugins/migrate.ts +309 -0
- package/templates/nextjs-standalone/src/lib/plugins/registry.ts +231 -0
- package/templates/nextjs-standalone/src/lib/plugins/tools.ts +39 -0
- package/templates/nextjs-standalone/src/lib/plugins/wiring.ts +291 -0
- package/templates/nextjs-standalone/src/lib/providers.ts +102 -0
- package/templates/nextjs-standalone/src/lib/rls.ts +321 -0
- package/templates/nextjs-standalone/src/lib/scheduled-task-types.ts +132 -0
- package/templates/nextjs-standalone/src/lib/scheduled-tasks.ts +475 -0
- package/templates/nextjs-standalone/src/lib/scheduler/__tests__/delivery.test.ts +192 -0
- package/templates/nextjs-standalone/src/lib/scheduler/__tests__/engine.test.ts +248 -0
- package/templates/nextjs-standalone/src/lib/scheduler/__tests__/format-email.test.ts +96 -0
- package/templates/nextjs-standalone/src/lib/scheduler/__tests__/format-slack.test.ts +78 -0
- package/templates/nextjs-standalone/src/lib/scheduler/__tests__/format-webhook.test.ts +78 -0
- package/templates/nextjs-standalone/src/lib/scheduler/delivery.ts +248 -0
- package/templates/nextjs-standalone/src/lib/scheduler/engine.ts +317 -0
- package/templates/nextjs-standalone/src/lib/scheduler/executor.ts +73 -0
- package/templates/nextjs-standalone/src/lib/scheduler/format-email.ts +109 -0
- package/templates/nextjs-standalone/src/lib/scheduler/format-slack.ts +35 -0
- package/templates/nextjs-standalone/src/lib/scheduler/format-webhook.ts +37 -0
- package/templates/nextjs-standalone/src/lib/scheduler/index.ts +7 -0
- package/templates/nextjs-standalone/src/lib/security.ts +11 -0
- package/templates/nextjs-standalone/src/lib/semantic-index.ts +503 -0
- package/templates/nextjs-standalone/src/lib/semantic.ts +387 -0
- package/templates/nextjs-standalone/src/lib/sidecar-types.ts +16 -0
- package/templates/nextjs-standalone/src/lib/slack/__tests__/api.test.ts +160 -0
- package/templates/nextjs-standalone/src/lib/slack/__tests__/format.test.ts +237 -0
- package/templates/nextjs-standalone/src/lib/slack/__tests__/store.test.ts +188 -0
- package/templates/nextjs-standalone/src/lib/slack/__tests__/threads.test.ts +112 -0
- package/templates/nextjs-standalone/src/lib/slack/__tests__/verify.test.ts +111 -0
- package/templates/nextjs-standalone/src/lib/slack/api.ts +102 -0
- package/templates/nextjs-standalone/src/lib/slack/format.ts +209 -0
- package/templates/nextjs-standalone/src/lib/slack/store.ts +107 -0
- package/templates/nextjs-standalone/src/lib/slack/threads.ts +64 -0
- package/templates/nextjs-standalone/src/lib/slack/verify.ts +71 -0
- package/templates/nextjs-standalone/src/lib/startup.ts +730 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/action-permissions.test.ts +594 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/custom-validation.test.ts +238 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-backend.test.ts +267 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-nsjail.test.ts +492 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-plugin.test.ts +374 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-sdk-compat.test.ts +82 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-sidecar.test.ts +208 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/registry-actions.test.ts +144 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/registry.test.ts +235 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/salesforce-tool.test.ts +154 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/soql-validation.test.ts +303 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/sql-audit.test.ts +225 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/sql-connection-whitelist.test.ts +98 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/sql-duckdb.test.ts +233 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/sql-ratelimit.test.ts +225 -0
- package/templates/nextjs-standalone/src/lib/tools/__tests__/sql.test.ts +1012 -0
- package/templates/nextjs-standalone/src/lib/tools/actions/__tests__/audit.test.ts +211 -0
- package/templates/nextjs-standalone/src/lib/tools/actions/__tests__/email.test.ts +378 -0
- package/templates/nextjs-standalone/src/lib/tools/actions/__tests__/handler.test.ts +681 -0
- package/templates/nextjs-standalone/src/lib/tools/actions/__tests__/jira.test.ts +427 -0
- package/templates/nextjs-standalone/src/lib/tools/actions/audit.ts +47 -0
- package/templates/nextjs-standalone/src/lib/tools/actions/email.ts +191 -0
- package/templates/nextjs-standalone/src/lib/tools/actions/handler.ts +591 -0
- package/templates/nextjs-standalone/src/lib/tools/actions/index.ts +23 -0
- package/templates/nextjs-standalone/src/lib/tools/actions/jira.ts +220 -0
- package/templates/nextjs-standalone/src/lib/tools/explore-nsjail.ts +343 -0
- package/templates/nextjs-standalone/src/lib/tools/explore-sandbox.ts +264 -0
- package/templates/nextjs-standalone/src/lib/tools/explore-sidecar.ts +163 -0
- package/templates/nextjs-standalone/src/lib/tools/explore.ts +379 -0
- package/templates/nextjs-standalone/src/lib/tools/registry.ts +221 -0
- package/templates/nextjs-standalone/src/lib/tools/salesforce.ts +138 -0
- package/templates/nextjs-standalone/src/lib/tools/soql-validation.ts +172 -0
- package/templates/nextjs-standalone/src/lib/tools/sql.ts +680 -0
- package/templates/nextjs-standalone/src/lib/tracing.ts +40 -0
- package/templates/nextjs-standalone/src/lib/utils.ts +6 -0
- package/templates/nextjs-standalone/src/test-setup.ts +38 -0
- package/templates/nextjs-standalone/src/ui/components/actions/action-approval-card.tsx +295 -0
- package/templates/nextjs-standalone/src/ui/components/actions/action-status-badge.tsx +50 -0
- package/templates/nextjs-standalone/src/ui/components/admin/admin-layout.tsx +26 -0
- package/templates/nextjs-standalone/src/ui/components/admin/admin-sidebar.tsx +96 -0
- package/templates/nextjs-standalone/src/ui/components/admin/empty-state.tsx +24 -0
- package/templates/nextjs-standalone/src/ui/components/admin/entity-detail.tsx +233 -0
- package/templates/nextjs-standalone/src/ui/components/admin/entity-list.tsx +96 -0
- package/templates/nextjs-standalone/src/ui/components/admin/error-banner.tsx +22 -0
- package/templates/nextjs-standalone/src/ui/components/admin/feature-disabled.tsx +44 -0
- package/templates/nextjs-standalone/src/ui/components/admin/health-badge.tsx +30 -0
- package/templates/nextjs-standalone/src/ui/components/admin/loading-state.tsx +14 -0
- package/templates/nextjs-standalone/src/ui/components/admin/stat-card.tsx +32 -0
- package/templates/nextjs-standalone/src/ui/components/atlas-chat.tsx +370 -0
- package/templates/nextjs-standalone/src/ui/components/chart/chart-detection.ts +261 -0
- package/templates/nextjs-standalone/src/ui/components/chart/result-chart.tsx +375 -0
- package/templates/nextjs-standalone/src/ui/components/chat/api-key-bar.tsx +66 -0
- package/templates/nextjs-standalone/src/ui/components/chat/copy-button.tsx +25 -0
- package/templates/nextjs-standalone/src/ui/components/chat/data-table.tsx +102 -0
- package/templates/nextjs-standalone/src/ui/components/chat/error-banner.tsx +32 -0
- package/templates/nextjs-standalone/src/ui/components/chat/explore-card.tsx +41 -0
- package/templates/nextjs-standalone/src/ui/components/chat/loading-card.tsx +10 -0
- package/templates/nextjs-standalone/src/ui/components/chat/managed-auth-card.tsx +116 -0
- package/templates/nextjs-standalone/src/ui/components/chat/markdown.tsx +72 -0
- package/templates/nextjs-standalone/src/ui/components/chat/sql-block.tsx +30 -0
- package/templates/nextjs-standalone/src/ui/components/chat/sql-result-card.tsx +144 -0
- package/templates/nextjs-standalone/src/ui/components/chat/starter-prompts.ts +6 -0
- package/templates/nextjs-standalone/src/ui/components/chat/tool-part.tsx +40 -0
- package/templates/nextjs-standalone/src/ui/components/chat/typing-indicator.tsx +19 -0
- package/templates/nextjs-standalone/src/ui/components/conversations/conversation-item.tsx +120 -0
- package/templates/nextjs-standalone/src/ui/components/conversations/conversation-list.tsx +66 -0
- package/templates/nextjs-standalone/src/ui/components/conversations/conversation-sidebar.tsx +78 -0
- package/templates/nextjs-standalone/src/ui/components/conversations/delete-confirmation.tsx +27 -0
- package/templates/nextjs-standalone/src/ui/context.tsx +78 -0
- package/templates/nextjs-standalone/src/ui/hooks/use-admin-fetch.ts +104 -0
- package/templates/nextjs-standalone/src/ui/hooks/use-conversations.ts +184 -0
- package/templates/nextjs-standalone/src/ui/hooks/use-dark-mode.ts +17 -0
- package/templates/nextjs-standalone/src/ui/lib/action-types.ts +63 -0
- package/templates/nextjs-standalone/src/ui/lib/helpers.ts +104 -0
- package/templates/nextjs-standalone/src/ui/lib/types.ts +145 -0
- package/templates/nextjs-standalone/tsconfig.json +32 -0
- package/templates/nextjs-standalone/vercel.json +4 -0
|
@@ -0,0 +1,615 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import * as yaml from "js-yaml";
|
|
3
|
+
import type { TableProfile, ColumnProfile, EntitySnapshot } from "../atlas";
|
|
4
|
+
import {
|
|
5
|
+
generateEntityYAML,
|
|
6
|
+
generateMetricYAML,
|
|
7
|
+
generateCatalogYAML,
|
|
8
|
+
isMatView,
|
|
9
|
+
isViewLike,
|
|
10
|
+
isView,
|
|
11
|
+
parseEntityYAML,
|
|
12
|
+
profileToSnapshot,
|
|
13
|
+
computeDiff,
|
|
14
|
+
formatDiff,
|
|
15
|
+
inferForeignKeys,
|
|
16
|
+
detectAbandonedTables,
|
|
17
|
+
detectDenormalizedTables,
|
|
18
|
+
} from "../atlas";
|
|
19
|
+
|
|
20
|
+
// --- Helpers ---
|
|
21
|
+
|
|
22
|
+
function makeColumn(overrides: Partial<ColumnProfile> = {}): ColumnProfile {
|
|
23
|
+
return {
|
|
24
|
+
name: "col",
|
|
25
|
+
type: "text",
|
|
26
|
+
nullable: false,
|
|
27
|
+
unique_count: null,
|
|
28
|
+
null_count: null,
|
|
29
|
+
sample_values: [],
|
|
30
|
+
is_primary_key: false,
|
|
31
|
+
is_foreign_key: false,
|
|
32
|
+
fk_target_table: null,
|
|
33
|
+
fk_target_column: null,
|
|
34
|
+
is_enum_like: false,
|
|
35
|
+
profiler_notes: [],
|
|
36
|
+
...overrides,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function makeProfile(overrides: Partial<TableProfile> = {}): TableProfile {
|
|
41
|
+
return {
|
|
42
|
+
table_name: "test_table",
|
|
43
|
+
object_type: "table" as const,
|
|
44
|
+
row_count: 100,
|
|
45
|
+
columns: [makeColumn({ name: "id", is_primary_key: true })],
|
|
46
|
+
primary_key_columns: ["id"],
|
|
47
|
+
foreign_keys: [],
|
|
48
|
+
inferred_foreign_keys: [],
|
|
49
|
+
profiler_notes: [],
|
|
50
|
+
table_flags: { possibly_abandoned: false, possibly_denormalized: false },
|
|
51
|
+
...overrides,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function makeMatViewProfile(overrides: Partial<TableProfile> = {}): TableProfile {
|
|
56
|
+
return makeProfile({
|
|
57
|
+
table_name: "daily_summary",
|
|
58
|
+
object_type: "materialized_view" as const,
|
|
59
|
+
row_count: 500,
|
|
60
|
+
columns: [
|
|
61
|
+
makeColumn({ name: "date", type: "date", sample_values: ["2024-01-01", "2024-01-02"] }),
|
|
62
|
+
makeColumn({ name: "total_orders", type: "integer" }),
|
|
63
|
+
makeColumn({ name: "total_revenue", type: "numeric", sample_values: ["12345.67", "98765.43"] }),
|
|
64
|
+
],
|
|
65
|
+
primary_key_columns: [],
|
|
66
|
+
foreign_keys: [],
|
|
67
|
+
inferred_foreign_keys: [],
|
|
68
|
+
matview_populated: true,
|
|
69
|
+
...overrides,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function makePartitionedProfile(overrides: Partial<TableProfile> = {}): TableProfile {
|
|
74
|
+
return makeProfile({
|
|
75
|
+
table_name: "events",
|
|
76
|
+
object_type: "table" as const,
|
|
77
|
+
row_count: 100000,
|
|
78
|
+
columns: [
|
|
79
|
+
makeColumn({ name: "id", type: "integer", is_primary_key: true }),
|
|
80
|
+
makeColumn({ name: "created_at", type: "timestamp" }),
|
|
81
|
+
makeColumn({ name: "event_type", type: "text", sample_values: ["click", "view", "purchase"], is_enum_like: true }),
|
|
82
|
+
],
|
|
83
|
+
primary_key_columns: ["id"],
|
|
84
|
+
partition_info: { strategy: "range", key: "created_at", children: ["events_2024q1", "events_2024q2"] },
|
|
85
|
+
...overrides,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function makeSnapshot(
|
|
90
|
+
table: string,
|
|
91
|
+
columns: Record<string, string>,
|
|
92
|
+
fks: string[] = [],
|
|
93
|
+
meta: { objectType?: string; partitionStrategy?: string; partitionKey?: string } = {},
|
|
94
|
+
): EntitySnapshot {
|
|
95
|
+
return {
|
|
96
|
+
table,
|
|
97
|
+
columns: new Map(Object.entries(columns)),
|
|
98
|
+
foreignKeys: new Set(fks),
|
|
99
|
+
...meta,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// --- isMatView / isViewLike / isView helpers ---
|
|
104
|
+
|
|
105
|
+
describe("isMatView", () => {
|
|
106
|
+
test("returns true for materialized_view", () => {
|
|
107
|
+
expect(isMatView(makeMatViewProfile())).toBe(true);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test("returns false for view", () => {
|
|
111
|
+
expect(isMatView(makeProfile({ object_type: "view" }))).toBe(false);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test("returns false for table", () => {
|
|
115
|
+
expect(isMatView(makeProfile({ object_type: "table" }))).toBe(false);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
describe("isViewLike", () => {
|
|
120
|
+
test("returns true for view", () => {
|
|
121
|
+
expect(isViewLike(makeProfile({ object_type: "view" }))).toBe(true);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test("returns true for materialized_view", () => {
|
|
125
|
+
expect(isViewLike(makeMatViewProfile())).toBe(true);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test("returns false for table", () => {
|
|
129
|
+
expect(isViewLike(makeProfile({ object_type: "table" }))).toBe(false);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
describe("isView with materialized_view", () => {
|
|
134
|
+
test("returns false for materialized_view", () => {
|
|
135
|
+
expect(isView(makeMatViewProfile())).toBe(false);
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// --- generateEntityYAML for matviews ---
|
|
140
|
+
|
|
141
|
+
describe("generateEntityYAML (materialized views)", () => {
|
|
142
|
+
test("produces type 'materialized_view'", () => {
|
|
143
|
+
const profile = makeMatViewProfile();
|
|
144
|
+
const result = generateEntityYAML(profile, [profile], "postgres");
|
|
145
|
+
const doc = yaml.load(result) as Record<string, unknown>;
|
|
146
|
+
|
|
147
|
+
expect(doc.type).toBe("materialized_view");
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
test("does not include measures", () => {
|
|
151
|
+
const profile = makeMatViewProfile();
|
|
152
|
+
const result = generateEntityYAML(profile, [profile], "postgres");
|
|
153
|
+
const doc = yaml.load(result) as Record<string, unknown>;
|
|
154
|
+
|
|
155
|
+
expect(doc.measures).toBeUndefined();
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
test("does not include query_patterns", () => {
|
|
159
|
+
const profile = makeMatViewProfile();
|
|
160
|
+
const result = generateEntityYAML(profile, [profile], "postgres");
|
|
161
|
+
const doc = yaml.load(result) as Record<string, unknown>;
|
|
162
|
+
|
|
163
|
+
expect(doc.query_patterns).toBeUndefined();
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
test("description starts with 'Materialized view:'", () => {
|
|
167
|
+
const profile = makeMatViewProfile();
|
|
168
|
+
const result = generateEntityYAML(profile, [profile], "postgres");
|
|
169
|
+
const doc = yaml.load(result) as Record<string, unknown>;
|
|
170
|
+
|
|
171
|
+
expect(typeof doc.description).toBe("string");
|
|
172
|
+
expect((doc.description as string).startsWith("Materialized view:")).toBe(true);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
test("grain mentions 'materialized view'", () => {
|
|
176
|
+
const profile = makeMatViewProfile();
|
|
177
|
+
const result = generateEntityYAML(profile, [profile], "postgres");
|
|
178
|
+
const doc = yaml.load(result) as Record<string, unknown>;
|
|
179
|
+
|
|
180
|
+
expect(typeof doc.grain).toBe("string");
|
|
181
|
+
expect((doc.grain as string).toLowerCase()).toContain("materialized view");
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test("use_cases includes staleness warning", () => {
|
|
185
|
+
const profile = makeMatViewProfile();
|
|
186
|
+
const result = generateEntityYAML(profile, [profile], "postgres");
|
|
187
|
+
const doc = yaml.load(result) as Record<string, unknown>;
|
|
188
|
+
|
|
189
|
+
const useCases = doc.use_cases as string[];
|
|
190
|
+
expect(Array.isArray(useCases)).toBe(true);
|
|
191
|
+
expect(useCases.some((uc) => uc.includes("materialized view") && uc.includes("stale"))).toBe(true);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
test("unpopulated matview includes no-data warning", () => {
|
|
195
|
+
const profile = makeMatViewProfile({ matview_populated: false });
|
|
196
|
+
const result = generateEntityYAML(profile, [profile], "postgres");
|
|
197
|
+
const doc = yaml.load(result) as Record<string, unknown>;
|
|
198
|
+
|
|
199
|
+
const useCases = doc.use_cases as string[];
|
|
200
|
+
expect(useCases.some((uc) => uc.includes("never been refreshed"))).toBe(true);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
test("populated matview does not include no-data warning", () => {
|
|
204
|
+
const profile = makeMatViewProfile({ matview_populated: true });
|
|
205
|
+
const result = generateEntityYAML(profile, [profile], "postgres");
|
|
206
|
+
const doc = yaml.load(result) as Record<string, unknown>;
|
|
207
|
+
|
|
208
|
+
const useCases = doc.use_cases as string[];
|
|
209
|
+
expect(useCases.some((uc) => uc.includes("never been refreshed"))).toBe(false);
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
// --- generateEntityYAML for partitioned tables ---
|
|
214
|
+
|
|
215
|
+
describe("generateEntityYAML (partitioned tables)", () => {
|
|
216
|
+
test("includes partitioned, partition_strategy, partition_key fields", () => {
|
|
217
|
+
const profile = makePartitionedProfile();
|
|
218
|
+
const result = generateEntityYAML(profile, [profile], "postgres");
|
|
219
|
+
const doc = yaml.load(result) as Record<string, unknown>;
|
|
220
|
+
|
|
221
|
+
expect(doc.partitioned).toBe(true);
|
|
222
|
+
expect(doc.partition_strategy).toBe("range");
|
|
223
|
+
expect(doc.partition_key).toBe("created_at");
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
test("use_cases includes partition hint", () => {
|
|
227
|
+
const profile = makePartitionedProfile();
|
|
228
|
+
const result = generateEntityYAML(profile, [profile], "postgres");
|
|
229
|
+
const doc = yaml.load(result) as Record<string, unknown>;
|
|
230
|
+
|
|
231
|
+
const useCases = doc.use_cases as string[];
|
|
232
|
+
expect(useCases.some((uc) => uc.includes("partitioned by range") && uc.includes("created_at"))).toBe(true);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
test("non-partitioned table has no partition fields", () => {
|
|
236
|
+
const profile = makeProfile();
|
|
237
|
+
const result = generateEntityYAML(profile, [profile], "postgres");
|
|
238
|
+
const doc = yaml.load(result) as Record<string, unknown>;
|
|
239
|
+
|
|
240
|
+
expect(doc.partitioned).toBeUndefined();
|
|
241
|
+
expect(doc.partition_strategy).toBeUndefined();
|
|
242
|
+
expect(doc.partition_key).toBeUndefined();
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
// --- generateMetricYAML for matviews ---
|
|
247
|
+
|
|
248
|
+
describe("generateMetricYAML (materialized views)", () => {
|
|
249
|
+
test("returns null for matview profiles", () => {
|
|
250
|
+
const profile = makeMatViewProfile();
|
|
251
|
+
const result = generateMetricYAML(profile);
|
|
252
|
+
|
|
253
|
+
expect(result).toBeNull();
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
// --- generateCatalogYAML ---
|
|
258
|
+
|
|
259
|
+
describe("generateCatalogYAML (matview and partition)", () => {
|
|
260
|
+
test("matview entry shows [materialized view]", () => {
|
|
261
|
+
const profile = makeMatViewProfile();
|
|
262
|
+
const result = generateCatalogYAML([profile]);
|
|
263
|
+
const doc = yaml.load(result) as Record<string, unknown>;
|
|
264
|
+
const entities = doc.entities as { description: string }[];
|
|
265
|
+
|
|
266
|
+
expect(entities[0].description).toContain("[materialized view]");
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
test("partitioned table entry shows [partitioned by strategy]", () => {
|
|
270
|
+
const profile = makePartitionedProfile();
|
|
271
|
+
const result = generateCatalogYAML([profile]);
|
|
272
|
+
const doc = yaml.load(result) as Record<string, unknown>;
|
|
273
|
+
const entities = doc.entities as { description: string }[];
|
|
274
|
+
|
|
275
|
+
expect(entities[0].description).toContain("[partitioned by range]");
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
test("matview entry grain mentions materialized view", () => {
|
|
279
|
+
const profile = makeMatViewProfile();
|
|
280
|
+
const result = generateCatalogYAML([profile]);
|
|
281
|
+
const doc = yaml.load(result) as Record<string, unknown>;
|
|
282
|
+
const entities = doc.entities as { grain: string }[];
|
|
283
|
+
|
|
284
|
+
expect(entities[0].grain).toContain("materialized view");
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
test("metrics section excludes matviews", () => {
|
|
288
|
+
const matview = makeMatViewProfile();
|
|
289
|
+
const table = makeProfile({
|
|
290
|
+
table_name: "orders",
|
|
291
|
+
columns: [
|
|
292
|
+
makeColumn({ name: "id", type: "integer", is_primary_key: true }),
|
|
293
|
+
makeColumn({ name: "amount", type: "numeric" }),
|
|
294
|
+
],
|
|
295
|
+
});
|
|
296
|
+
const result = generateCatalogYAML([matview, table]);
|
|
297
|
+
const doc = yaml.load(result) as Record<string, unknown>;
|
|
298
|
+
const metrics = doc.metrics as { file: string }[] | undefined;
|
|
299
|
+
|
|
300
|
+
// Only orders should have metrics, not the matview
|
|
301
|
+
if (metrics) {
|
|
302
|
+
expect(metrics.every((m) => !m.file.includes("daily_summary"))).toBe(true);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
// --- Diff with matviews ---
|
|
308
|
+
|
|
309
|
+
describe("computeDiff (metadata changes)", () => {
|
|
310
|
+
test("detects object type change", () => {
|
|
311
|
+
const db = new Map([
|
|
312
|
+
["summary", makeSnapshot("summary", { id: "number" }, [], { objectType: "materialized_view" })],
|
|
313
|
+
]);
|
|
314
|
+
const yml = new Map([
|
|
315
|
+
["summary", makeSnapshot("summary", { id: "number" }, [], { objectType: "view" })],
|
|
316
|
+
]);
|
|
317
|
+
const diff = computeDiff(db, yml);
|
|
318
|
+
expect(diff.tableDiffs).toHaveLength(1);
|
|
319
|
+
expect(diff.tableDiffs[0].metadataChanges).toContain("type changed: view → materialized_view");
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
test("detects partition strategy change", () => {
|
|
323
|
+
const db = new Map([
|
|
324
|
+
["events", makeSnapshot("events", { id: "number" }, [], { partitionStrategy: "list" })],
|
|
325
|
+
]);
|
|
326
|
+
const yml = new Map([
|
|
327
|
+
["events", makeSnapshot("events", { id: "number" }, [], { partitionStrategy: "range" })],
|
|
328
|
+
]);
|
|
329
|
+
const diff = computeDiff(db, yml);
|
|
330
|
+
expect(diff.tableDiffs).toHaveLength(1);
|
|
331
|
+
expect(diff.tableDiffs[0].metadataChanges).toContain("partition strategy changed: range → list");
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
test("detects partition key added", () => {
|
|
335
|
+
const db = new Map([
|
|
336
|
+
["events", makeSnapshot("events", { id: "number" }, [], { partitionStrategy: "range", partitionKey: "created_at" })],
|
|
337
|
+
]);
|
|
338
|
+
const yml = new Map([
|
|
339
|
+
["events", makeSnapshot("events", { id: "number" }, [])],
|
|
340
|
+
]);
|
|
341
|
+
const diff = computeDiff(db, yml);
|
|
342
|
+
expect(diff.tableDiffs).toHaveLength(1);
|
|
343
|
+
expect(diff.tableDiffs[0].metadataChanges.some((mc) => mc.includes("partition strategy added"))).toBe(true);
|
|
344
|
+
expect(diff.tableDiffs[0].metadataChanges.some((mc) => mc.includes("partition key added"))).toBe(true);
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
test("new matview shows as new table", () => {
|
|
348
|
+
const db = new Map([
|
|
349
|
+
["daily_summary", makeSnapshot("daily_summary", { date: "date", total: "number" }, [], { objectType: "materialized_view" })],
|
|
350
|
+
]);
|
|
351
|
+
const yml = new Map<string, EntitySnapshot>();
|
|
352
|
+
const diff = computeDiff(db, yml);
|
|
353
|
+
expect(diff.newTables).toEqual(["daily_summary"]);
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
test("no metadata drift for identical snapshots", () => {
|
|
357
|
+
const db = new Map([
|
|
358
|
+
["events", makeSnapshot("events", { id: "number" }, [], { objectType: "fact_table", partitionStrategy: "range", partitionKey: "created_at" })],
|
|
359
|
+
]);
|
|
360
|
+
const yml = new Map([
|
|
361
|
+
["events", makeSnapshot("events", { id: "number" }, [], { objectType: "fact_table", partitionStrategy: "range", partitionKey: "created_at" })],
|
|
362
|
+
]);
|
|
363
|
+
const diff = computeDiff(db, yml);
|
|
364
|
+
expect(diff.tableDiffs).toEqual([]);
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
describe("formatDiff (metadata changes)", () => {
|
|
369
|
+
test("displays metadata changes", () => {
|
|
370
|
+
const diff = {
|
|
371
|
+
newTables: [],
|
|
372
|
+
removedTables: [],
|
|
373
|
+
tableDiffs: [
|
|
374
|
+
{
|
|
375
|
+
table: "summary",
|
|
376
|
+
addedColumns: [],
|
|
377
|
+
removedColumns: [],
|
|
378
|
+
typeChanges: [],
|
|
379
|
+
addedFKs: [],
|
|
380
|
+
removedFKs: [],
|
|
381
|
+
metadataChanges: ["type changed: view → materialized_view"],
|
|
382
|
+
},
|
|
383
|
+
],
|
|
384
|
+
};
|
|
385
|
+
const output = formatDiff(diff);
|
|
386
|
+
expect(output).toContain("~ type changed: view → materialized_view");
|
|
387
|
+
expect(output).toContain("1 metadata change");
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
// --- parseEntityYAML with metadata ---
|
|
392
|
+
|
|
393
|
+
describe("parseEntityYAML (metadata fields)", () => {
|
|
394
|
+
test("extracts objectType from type field", () => {
|
|
395
|
+
const doc = {
|
|
396
|
+
table: "summary",
|
|
397
|
+
type: "materialized_view",
|
|
398
|
+
dimensions: [{ name: "id", sql: "id", type: "number" }],
|
|
399
|
+
};
|
|
400
|
+
const snap = parseEntityYAML(doc);
|
|
401
|
+
expect(snap.objectType).toBe("materialized_view");
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
test("extracts partition fields", () => {
|
|
405
|
+
const doc = {
|
|
406
|
+
table: "events",
|
|
407
|
+
type: "fact_table",
|
|
408
|
+
partitioned: true,
|
|
409
|
+
partition_strategy: "range",
|
|
410
|
+
partition_key: "created_at",
|
|
411
|
+
dimensions: [{ name: "id", sql: "id", type: "number" }],
|
|
412
|
+
};
|
|
413
|
+
const snap = parseEntityYAML(doc);
|
|
414
|
+
expect(snap.partitionStrategy).toBe("range");
|
|
415
|
+
expect(snap.partitionKey).toBe("created_at");
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
test("missing metadata fields are undefined", () => {
|
|
419
|
+
const doc = {
|
|
420
|
+
table: "simple",
|
|
421
|
+
dimensions: [{ name: "id", sql: "id", type: "number" }],
|
|
422
|
+
};
|
|
423
|
+
const snap = parseEntityYAML(doc);
|
|
424
|
+
expect(snap.objectType).toBeUndefined();
|
|
425
|
+
expect(snap.partitionStrategy).toBeUndefined();
|
|
426
|
+
expect(snap.partitionKey).toBeUndefined();
|
|
427
|
+
});
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
// --- profileToSnapshot with metadata ---
|
|
431
|
+
|
|
432
|
+
describe("profileToSnapshot (metadata)", () => {
|
|
433
|
+
test("matview profile produces correct objectType", () => {
|
|
434
|
+
const profile = makeMatViewProfile();
|
|
435
|
+
const snap = profileToSnapshot(profile);
|
|
436
|
+
expect(snap.objectType).toBe("materialized_view");
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
test("partitioned profile produces partition metadata", () => {
|
|
440
|
+
const profile = makePartitionedProfile();
|
|
441
|
+
const snap = profileToSnapshot(profile);
|
|
442
|
+
expect(snap.objectType).toBe("fact_table");
|
|
443
|
+
expect(snap.partitionStrategy).toBe("range");
|
|
444
|
+
expect(snap.partitionKey).toBe("created_at");
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
test("regular table has no partition metadata", () => {
|
|
448
|
+
const profile = makeProfile();
|
|
449
|
+
const snap = profileToSnapshot(profile);
|
|
450
|
+
expect(snap.objectType).toBe("fact_table");
|
|
451
|
+
expect(snap.partitionStrategy).toBeUndefined();
|
|
452
|
+
expect(snap.partitionKey).toBeUndefined();
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
test("view profile produces correct objectType", () => {
|
|
456
|
+
const profile = makeProfile({ object_type: "view" as const, table_name: "active_users" });
|
|
457
|
+
const snap = profileToSnapshot(profile);
|
|
458
|
+
expect(snap.objectType).toBe("view");
|
|
459
|
+
});
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
// --- Heuristic matview exclusion ---
|
|
463
|
+
|
|
464
|
+
describe("inferForeignKeys (matview exclusion)", () => {
|
|
465
|
+
test("does not use materialized views as FK targets", () => {
|
|
466
|
+
const matview = makeMatViewProfile({
|
|
467
|
+
table_name: "users",
|
|
468
|
+
columns: [makeColumn({ name: "id", type: "integer", is_primary_key: true })],
|
|
469
|
+
primary_key_columns: ["id"],
|
|
470
|
+
});
|
|
471
|
+
const table = makeProfile({
|
|
472
|
+
table_name: "orders",
|
|
473
|
+
columns: [
|
|
474
|
+
makeColumn({ name: "id", type: "integer", is_primary_key: true }),
|
|
475
|
+
makeColumn({ name: "user_id", type: "integer" }),
|
|
476
|
+
],
|
|
477
|
+
primary_key_columns: ["id"],
|
|
478
|
+
});
|
|
479
|
+
inferForeignKeys([matview, table]);
|
|
480
|
+
expect(table.inferred_foreign_keys).toHaveLength(0);
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
test("does not infer FKs on materialized view columns", () => {
|
|
484
|
+
const table = makeProfile({
|
|
485
|
+
table_name: "users",
|
|
486
|
+
columns: [makeColumn({ name: "id", type: "integer", is_primary_key: true })],
|
|
487
|
+
primary_key_columns: ["id"],
|
|
488
|
+
});
|
|
489
|
+
const matview = makeMatViewProfile({
|
|
490
|
+
table_name: "user_summary",
|
|
491
|
+
columns: [
|
|
492
|
+
makeColumn({ name: "date", type: "date" }),
|
|
493
|
+
makeColumn({ name: "user_id", type: "integer" }),
|
|
494
|
+
],
|
|
495
|
+
primary_key_columns: [],
|
|
496
|
+
});
|
|
497
|
+
inferForeignKeys([table, matview]);
|
|
498
|
+
expect(matview.inferred_foreign_keys).toHaveLength(0);
|
|
499
|
+
});
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
describe("detectAbandonedTables (matview exclusion)", () => {
|
|
503
|
+
test("skips materialized views even with abandoned-looking names", () => {
|
|
504
|
+
const profile = makeMatViewProfile({ table_name: "legacy_risk_scores" });
|
|
505
|
+
detectAbandonedTables([profile]);
|
|
506
|
+
expect(profile.table_flags.possibly_abandoned).toBe(false);
|
|
507
|
+
});
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
describe("detectDenormalizedTables (matview exclusion)", () => {
|
|
511
|
+
test("skips materialized views even with denormalized-looking names", () => {
|
|
512
|
+
const profile = makeMatViewProfile({ table_name: "daily_scan_stats" });
|
|
513
|
+
detectDenormalizedTables([profile]);
|
|
514
|
+
expect(profile.table_flags.possibly_denormalized).toBe(false);
|
|
515
|
+
});
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
// --- computeDiff undefined objectType edge cases ---
|
|
519
|
+
|
|
520
|
+
describe("computeDiff (undefined objectType edge cases)", () => {
|
|
521
|
+
test("does NOT report type change when yml objectType is undefined", () => {
|
|
522
|
+
const db = new Map([
|
|
523
|
+
["summary", makeSnapshot("summary", { id: "number" }, [], { objectType: "materialized_view" })],
|
|
524
|
+
]);
|
|
525
|
+
const yml = new Map([
|
|
526
|
+
["summary", makeSnapshot("summary", { id: "number" }, [])],
|
|
527
|
+
]);
|
|
528
|
+
const diff = computeDiff(db, yml);
|
|
529
|
+
expect(diff.tableDiffs).toHaveLength(0);
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
test("does NOT report type change when db objectType is undefined", () => {
|
|
533
|
+
const db = new Map([
|
|
534
|
+
["summary", makeSnapshot("summary", { id: "number" }, [])],
|
|
535
|
+
]);
|
|
536
|
+
const yml = new Map([
|
|
537
|
+
["summary", makeSnapshot("summary", { id: "number" }, [], { objectType: "view" })],
|
|
538
|
+
]);
|
|
539
|
+
const diff = computeDiff(db, yml);
|
|
540
|
+
expect(diff.tableDiffs).toHaveLength(0);
|
|
541
|
+
});
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
// --- Additional diff edge cases ---
|
|
545
|
+
|
|
546
|
+
describe("computeDiff (partition removal and change)", () => {
|
|
547
|
+
test("detects partition strategy and key removed", () => {
|
|
548
|
+
const db = new Map([
|
|
549
|
+
["events", makeSnapshot("events", { id: "number" }, [])],
|
|
550
|
+
]);
|
|
551
|
+
const yml = new Map([
|
|
552
|
+
["events", makeSnapshot("events", { id: "number" }, [], { partitionStrategy: "range", partitionKey: "created_at" })],
|
|
553
|
+
]);
|
|
554
|
+
const diff = computeDiff(db, yml);
|
|
555
|
+
expect(diff.tableDiffs).toHaveLength(1);
|
|
556
|
+
expect(diff.tableDiffs[0].metadataChanges.some((mc) => mc.includes("partition strategy removed"))).toBe(true);
|
|
557
|
+
expect(diff.tableDiffs[0].metadataChanges.some((mc) => mc.includes("partition key removed"))).toBe(true);
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
test("detects partition key changed", () => {
|
|
561
|
+
const db = new Map([
|
|
562
|
+
["events", makeSnapshot("events", { id: "number" }, [], { partitionStrategy: "range", partitionKey: "updated_at" })],
|
|
563
|
+
]);
|
|
564
|
+
const yml = new Map([
|
|
565
|
+
["events", makeSnapshot("events", { id: "number" }, [], { partitionStrategy: "range", partitionKey: "created_at" })],
|
|
566
|
+
]);
|
|
567
|
+
const diff = computeDiff(db, yml);
|
|
568
|
+
expect(diff.tableDiffs).toHaveLength(1);
|
|
569
|
+
expect(diff.tableDiffs[0].metadataChanges).toContain("partition key changed: created_at → updated_at");
|
|
570
|
+
});
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
// --- matview with undefined populated status ---
|
|
574
|
+
|
|
575
|
+
describe("generateEntityYAML (matview populated edge case)", () => {
|
|
576
|
+
test("matview with undefined populated status does not include no-data warning", () => {
|
|
577
|
+
const profile = makeMatViewProfile();
|
|
578
|
+
delete (profile as unknown as Record<string, unknown>).matview_populated;
|
|
579
|
+
const result = generateEntityYAML(profile, [profile], "postgres");
|
|
580
|
+
const doc = yaml.load(result) as Record<string, unknown>;
|
|
581
|
+
|
|
582
|
+
const useCases = doc.use_cases as string[];
|
|
583
|
+
// Staleness warning should still be present
|
|
584
|
+
expect(useCases.some((uc) => uc.includes("materialized view") && uc.includes("stale"))).toBe(true);
|
|
585
|
+
// But "never been refreshed" should be absent when populated is undefined (not explicitly false)
|
|
586
|
+
expect(useCases.some((uc) => uc.includes("never been refreshed"))).toBe(false);
|
|
587
|
+
});
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
// --- formatDiff pluralization ---
|
|
591
|
+
|
|
592
|
+
describe("formatDiff (metadata pluralization)", () => {
|
|
593
|
+
test("pluralizes metadata changes in summary", () => {
|
|
594
|
+
const diff = {
|
|
595
|
+
newTables: [],
|
|
596
|
+
removedTables: [],
|
|
597
|
+
tableDiffs: [
|
|
598
|
+
{
|
|
599
|
+
table: "events",
|
|
600
|
+
addedColumns: [],
|
|
601
|
+
removedColumns: [],
|
|
602
|
+
typeChanges: [],
|
|
603
|
+
addedFKs: [],
|
|
604
|
+
removedFKs: [],
|
|
605
|
+
metadataChanges: [
|
|
606
|
+
"partition strategy changed: range → list",
|
|
607
|
+
"partition key changed: created_at → updated_at",
|
|
608
|
+
],
|
|
609
|
+
},
|
|
610
|
+
],
|
|
611
|
+
};
|
|
612
|
+
const output = formatDiff(diff);
|
|
613
|
+
expect(output).toContain("2 metadata changes");
|
|
614
|
+
});
|
|
615
|
+
});
|