@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,544 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for per-source semantic layer loading in semantic.ts.
|
|
3
|
+
*
|
|
4
|
+
* Verifies the multi-source directory layout where per-source subdirectories
|
|
5
|
+
* (e.g. `semantic/warehouse/entities/`) auto-derive the connection ID from
|
|
6
|
+
* the directory name.
|
|
7
|
+
*/
|
|
8
|
+
import { describe, it, expect, beforeEach, afterEach } from "bun:test";
|
|
9
|
+
import { resolve, join } from "path";
|
|
10
|
+
import { mkdirSync, writeFileSync, rmSync, existsSync } from "fs";
|
|
11
|
+
|
|
12
|
+
// Cache-busting import for fresh module instance
|
|
13
|
+
const semModPath = resolve(__dirname, "../semantic.ts");
|
|
14
|
+
const semMod = await import(`${semModPath}?t=multisource-${Date.now()}`);
|
|
15
|
+
const getWhitelistedTables = semMod.getWhitelistedTables as typeof import("../semantic").getWhitelistedTables;
|
|
16
|
+
const _resetWhitelists = semMod._resetWhitelists as typeof import("../semantic")._resetWhitelists;
|
|
17
|
+
const getCrossSourceJoins = semMod.getCrossSourceJoins as typeof import("../semantic").getCrossSourceJoins;
|
|
18
|
+
|
|
19
|
+
const tmpBase = resolve(__dirname, ".tmp-semantic-multisource-test");
|
|
20
|
+
let testCounter = 0;
|
|
21
|
+
|
|
22
|
+
function ensureDir(subdir: string): string {
|
|
23
|
+
const dir = resolve(tmpBase, subdir);
|
|
24
|
+
mkdirSync(dir, { recursive: true });
|
|
25
|
+
return dir;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function cleanTmpBase() {
|
|
29
|
+
if (existsSync(tmpBase)) {
|
|
30
|
+
rmSync(tmpBase, { recursive: true, force: true });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function writeEntity(dir: string, filename: string, content: string) {
|
|
35
|
+
writeFileSync(join(dir, filename), content);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
describe("per-source semantic layer loading", () => {
|
|
39
|
+
beforeEach(() => {
|
|
40
|
+
_resetWhitelists();
|
|
41
|
+
testCounter++;
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
afterEach(() => {
|
|
45
|
+
_resetWhitelists();
|
|
46
|
+
cleanTmpBase();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("loads default entities from root/entities/ and per-source from subdirectories", () => {
|
|
50
|
+
const root = ensureDir(`multisource-${testCounter}`);
|
|
51
|
+
const defaultEntities = ensureDir(`multisource-${testCounter}/entities`);
|
|
52
|
+
const warehouseEntities = ensureDir(`multisource-${testCounter}/warehouse/entities`);
|
|
53
|
+
|
|
54
|
+
writeEntity(defaultEntities, "users.yml", `table: users\ncolumns:\n id:\n type: integer\n`);
|
|
55
|
+
writeEntity(warehouseEntities, "events.yml", `table: events\ncolumns:\n id:\n type: integer\n`);
|
|
56
|
+
|
|
57
|
+
const defaultTables = getWhitelistedTables("default", undefined, root);
|
|
58
|
+
const warehouseTables = getWhitelistedTables("warehouse", undefined, root);
|
|
59
|
+
|
|
60
|
+
expect(defaultTables.has("users")).toBe(true);
|
|
61
|
+
expect(defaultTables.has("events")).toBe(false);
|
|
62
|
+
expect(warehouseTables.has("events")).toBe(true);
|
|
63
|
+
expect(warehouseTables.has("users")).toBe(false);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("directory name becomes connection ID for entities without explicit connection field", () => {
|
|
67
|
+
const root = ensureDir(`dirname-${testCounter}`);
|
|
68
|
+
ensureDir(`dirname-${testCounter}/entities`);
|
|
69
|
+
const salesforceEntities = ensureDir(`dirname-${testCounter}/salesforce/entities`);
|
|
70
|
+
|
|
71
|
+
// No explicit connection field — should be inferred as "salesforce"
|
|
72
|
+
writeEntity(salesforceEntities, "accounts.yml", `table: accounts\ncolumns:\n id:\n type: integer\n`);
|
|
73
|
+
|
|
74
|
+
const sfTables = getWhitelistedTables("salesforce", undefined, root);
|
|
75
|
+
expect(sfTables.has("accounts")).toBe(true);
|
|
76
|
+
|
|
77
|
+
const defaultTables = getWhitelistedTables("default", undefined, root);
|
|
78
|
+
expect(defaultTables.has("accounts")).toBe(false);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("explicit connection field in YAML overrides directory-based inference", () => {
|
|
82
|
+
const root = ensureDir(`override-${testCounter}`);
|
|
83
|
+
ensureDir(`override-${testCounter}/entities`);
|
|
84
|
+
const warehouseEntities = ensureDir(`override-${testCounter}/warehouse/entities`);
|
|
85
|
+
|
|
86
|
+
// Entity is in warehouse/ dir but explicitly targets "analytics" connection
|
|
87
|
+
writeEntity(
|
|
88
|
+
warehouseEntities,
|
|
89
|
+
"events.yml",
|
|
90
|
+
`table: events\nconnection: analytics\ncolumns:\n id:\n type: integer\n`,
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const warehouseTables = getWhitelistedTables("warehouse", undefined, root);
|
|
94
|
+
expect(warehouseTables.has("events")).toBe(false);
|
|
95
|
+
|
|
96
|
+
const analyticsTables = getWhitelistedTables("analytics", undefined, root);
|
|
97
|
+
expect(analyticsTables.has("events")).toBe(true);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("backward compat: no subdirectories → shared whitelist mode", () => {
|
|
101
|
+
const root = ensureDir(`compat-${testCounter}`);
|
|
102
|
+
const defaultEntities = ensureDir(`compat-${testCounter}/entities`);
|
|
103
|
+
|
|
104
|
+
// No connection fields, no subdirectories — all connections share the same whitelist
|
|
105
|
+
writeEntity(defaultEntities, "orders.yml", `table: orders\ncolumns:\n id:\n type: integer\n`);
|
|
106
|
+
writeEntity(defaultEntities, "users.yml", `table: users\ncolumns:\n id:\n type: integer\n`);
|
|
107
|
+
|
|
108
|
+
const defaultTables = getWhitelistedTables("default", undefined, root);
|
|
109
|
+
const anyTables = getWhitelistedTables("anything", undefined, root);
|
|
110
|
+
|
|
111
|
+
expect(defaultTables.has("orders")).toBe(true);
|
|
112
|
+
expect(defaultTables.has("users")).toBe(true);
|
|
113
|
+
// Backward compat: non-default connections get the same tables
|
|
114
|
+
expect(anyTables.has("orders")).toBe(true);
|
|
115
|
+
expect(anyTables.has("users")).toBe(true);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("unknown connection IDs get empty whitelists in partitioned mode", () => {
|
|
119
|
+
const root = ensureDir(`unknown-${testCounter}`);
|
|
120
|
+
const defaultEntities = ensureDir(`unknown-${testCounter}/entities`);
|
|
121
|
+
const warehouseEntities = ensureDir(`unknown-${testCounter}/warehouse/entities`);
|
|
122
|
+
|
|
123
|
+
writeEntity(defaultEntities, "users.yml", `table: users\ncolumns:\n id:\n type: integer\n`);
|
|
124
|
+
writeEntity(warehouseEntities, "events.yml", `table: events\ncolumns:\n id:\n type: integer\n`);
|
|
125
|
+
|
|
126
|
+
const unknownTables = getWhitelistedTables("nonexistent", undefined, root);
|
|
127
|
+
expect(unknownTables.size).toBe(0);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("reserved directories (entities, metrics) are not treated as source names", () => {
|
|
131
|
+
const root = ensureDir(`reserved-${testCounter}`);
|
|
132
|
+
const defaultEntities = ensureDir(`reserved-${testCounter}/entities`);
|
|
133
|
+
ensureDir(`reserved-${testCounter}/metrics`);
|
|
134
|
+
|
|
135
|
+
writeEntity(defaultEntities, "orders.yml", `table: orders\ncolumns:\n id:\n type: integer\n`);
|
|
136
|
+
|
|
137
|
+
// "entities" and "metrics" should not be treated as connection IDs
|
|
138
|
+
const entitiesTables = getWhitelistedTables("entities", undefined, root);
|
|
139
|
+
const metricsTables = getWhitelistedTables("metrics", undefined, root);
|
|
140
|
+
|
|
141
|
+
// In shared mode (no partitioning), these would still get the default tables
|
|
142
|
+
// but they should NOT have any tables from a dir called "entities" or "metrics"
|
|
143
|
+
const defaultTables = getWhitelistedTables("default", undefined, root);
|
|
144
|
+
expect(defaultTables.has("orders")).toBe(true);
|
|
145
|
+
// No partitioning triggered so backward compat shares
|
|
146
|
+
expect(entitiesTables.has("orders")).toBe(true);
|
|
147
|
+
expect(metricsTables.has("orders")).toBe(true);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it("multiple per-source subdirectories coexist", () => {
|
|
151
|
+
const root = ensureDir(`multi-${testCounter}`);
|
|
152
|
+
const defaultEntities = ensureDir(`multi-${testCounter}/entities`);
|
|
153
|
+
const warehouseEntities = ensureDir(`multi-${testCounter}/warehouse/entities`);
|
|
154
|
+
const salesforceEntities = ensureDir(`multi-${testCounter}/salesforce/entities`);
|
|
155
|
+
|
|
156
|
+
writeEntity(defaultEntities, "users.yml", `table: users\ncolumns:\n id:\n type: integer\n`);
|
|
157
|
+
writeEntity(warehouseEntities, "events.yml", `table: events\ncolumns:\n id:\n type: integer\n`);
|
|
158
|
+
writeEntity(salesforceEntities, "accounts.yml", `table: accounts\ncolumns:\n id:\n type: integer\n`);
|
|
159
|
+
|
|
160
|
+
const defaultTables = getWhitelistedTables("default", undefined, root);
|
|
161
|
+
const warehouseTables = getWhitelistedTables("warehouse", undefined, root);
|
|
162
|
+
const salesforceTables = getWhitelistedTables("salesforce", undefined, root);
|
|
163
|
+
|
|
164
|
+
expect(defaultTables.has("users")).toBe(true);
|
|
165
|
+
expect(defaultTables.has("events")).toBe(false);
|
|
166
|
+
expect(defaultTables.has("accounts")).toBe(false);
|
|
167
|
+
|
|
168
|
+
expect(warehouseTables.has("events")).toBe(true);
|
|
169
|
+
expect(warehouseTables.has("users")).toBe(false);
|
|
170
|
+
expect(warehouseTables.has("accounts")).toBe(false);
|
|
171
|
+
|
|
172
|
+
expect(salesforceTables.has("accounts")).toBe(true);
|
|
173
|
+
expect(salesforceTables.has("users")).toBe(false);
|
|
174
|
+
expect(salesforceTables.has("events")).toBe(false);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it("schema-qualified tables work with per-source loading", () => {
|
|
178
|
+
const root = ensureDir(`schema-${testCounter}`);
|
|
179
|
+
ensureDir(`schema-${testCounter}/entities`);
|
|
180
|
+
const warehouseEntities = ensureDir(`schema-${testCounter}/warehouse/entities`);
|
|
181
|
+
|
|
182
|
+
writeEntity(
|
|
183
|
+
warehouseEntities,
|
|
184
|
+
"analytics_orders.yml",
|
|
185
|
+
`table: analytics.orders\ncolumns:\n id:\n type: integer\n`,
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
const warehouseTables = getWhitelistedTables("warehouse", undefined, root);
|
|
189
|
+
expect(warehouseTables.has("analytics.orders")).toBe(true);
|
|
190
|
+
expect(warehouseTables.has("orders")).toBe(true);
|
|
191
|
+
|
|
192
|
+
const defaultTables = getWhitelistedTables("default", undefined, root);
|
|
193
|
+
expect(defaultTables.has("analytics.orders")).toBe(false);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it("empty semantic root → empty set", () => {
|
|
197
|
+
const root = ensureDir(`empty-${testCounter}`);
|
|
198
|
+
const tables = getWhitelistedTables("default", undefined, root);
|
|
199
|
+
expect(tables.size).toBe(0);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it("non-existent semantic root → empty set", () => {
|
|
203
|
+
const tables = getWhitelistedTables("default", undefined, "/tmp/nonexistent-atlas-multisource-test");
|
|
204
|
+
expect(tables.size).toBe(0);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it("legacy entitiesDir param still works (backward compat)", () => {
|
|
208
|
+
// This verifies that existing tests using entitiesDir continue to work
|
|
209
|
+
const dir = ensureDir(`legacy-${testCounter}`);
|
|
210
|
+
writeEntity(dir, "orders.yml", `table: orders\ncolumns:\n id:\n type: integer\n`);
|
|
211
|
+
|
|
212
|
+
const tables = getWhitelistedTables("default", dir);
|
|
213
|
+
expect(tables.has("orders")).toBe(true);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
it("subdirectory without entities/ subfolder is ignored", () => {
|
|
217
|
+
const root = ensureDir(`noentities-${testCounter}`);
|
|
218
|
+
const defaultEntities = ensureDir(`noentities-${testCounter}/entities`);
|
|
219
|
+
// Create a subdirectory without an entities/ subfolder
|
|
220
|
+
ensureDir(`noentities-${testCounter}/warehouse`);
|
|
221
|
+
|
|
222
|
+
writeEntity(defaultEntities, "users.yml", `table: users\ncolumns:\n id:\n type: integer\n`);
|
|
223
|
+
|
|
224
|
+
// Should not crash, warehouse just has no tables
|
|
225
|
+
const defaultTables = getWhitelistedTables("default", undefined, root);
|
|
226
|
+
expect(defaultTables.has("users")).toBe(true);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it("same table name in default and source → correctly isolated", () => {
|
|
230
|
+
const root = ensureDir(`samename-${testCounter}`);
|
|
231
|
+
const defaultEntities = ensureDir(`samename-${testCounter}/entities`);
|
|
232
|
+
const warehouseEntities = ensureDir(`samename-${testCounter}/warehouse/entities`);
|
|
233
|
+
|
|
234
|
+
writeEntity(defaultEntities, "orders.yml", `table: orders\ncolumns:\n id:\n type: integer\n`);
|
|
235
|
+
writeEntity(warehouseEntities, "orders.yml", `table: orders\ncolumns:\n id:\n type: integer\n`);
|
|
236
|
+
|
|
237
|
+
const defaultTables = getWhitelistedTables("default", undefined, root);
|
|
238
|
+
const warehouseTables = getWhitelistedTables("warehouse", undefined, root);
|
|
239
|
+
|
|
240
|
+
expect(defaultTables.has("orders")).toBe(true);
|
|
241
|
+
expect(warehouseTables.has("orders")).toBe(true);
|
|
242
|
+
expect(defaultTables).not.toBe(warehouseTables);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it("reserved directories with entities/ subfolder are still excluded", () => {
|
|
246
|
+
const root = ensureDir(`reserved-strict-${testCounter}`);
|
|
247
|
+
const defaultEntities = ensureDir(`reserved-strict-${testCounter}/entities`);
|
|
248
|
+
// Create metrics/entities/ — should be blocked by RESERVED_DIRS, not by missing dir
|
|
249
|
+
const metricsEntities = ensureDir(`reserved-strict-${testCounter}/metrics/entities`);
|
|
250
|
+
|
|
251
|
+
writeEntity(defaultEntities, "orders.yml", `table: orders\ncolumns:\n id:\n type: integer\n`);
|
|
252
|
+
writeEntity(metricsEntities, "shadow.yml", `table: shadow\ncolumns:\n id:\n type: integer\n`);
|
|
253
|
+
|
|
254
|
+
const defaultTables = getWhitelistedTables("default", undefined, root);
|
|
255
|
+
expect(defaultTables.has("orders")).toBe(true);
|
|
256
|
+
|
|
257
|
+
// "metrics" is reserved — should NOT be treated as a source
|
|
258
|
+
const metricsTables = getWhitelistedTables("metrics", undefined, root);
|
|
259
|
+
expect(metricsTables.has("shadow")).toBe(false);
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
describe("cross-source join hints", () => {
|
|
264
|
+
beforeEach(() => {
|
|
265
|
+
_resetWhitelists();
|
|
266
|
+
testCounter++;
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
afterEach(() => {
|
|
270
|
+
_resetWhitelists();
|
|
271
|
+
cleanTmpBase();
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
it("entity with cross_source_joins is parsed", () => {
|
|
275
|
+
const root = ensureDir(`csj-basic-${testCounter}`);
|
|
276
|
+
const defaultEntities = ensureDir(`csj-basic-${testCounter}/entities`);
|
|
277
|
+
|
|
278
|
+
writeEntity(
|
|
279
|
+
defaultEntities,
|
|
280
|
+
"users.yml",
|
|
281
|
+
[
|
|
282
|
+
"table: users",
|
|
283
|
+
"columns:",
|
|
284
|
+
" id:",
|
|
285
|
+
" type: integer",
|
|
286
|
+
"cross_source_joins:",
|
|
287
|
+
" - source: warehouse",
|
|
288
|
+
" target_table: events",
|
|
289
|
+
" on: users.id = events.user_id",
|
|
290
|
+
" relationship: one_to_many",
|
|
291
|
+
' description: User activity events',
|
|
292
|
+
].join("\n"),
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
const joins = getCrossSourceJoins(root);
|
|
296
|
+
expect(joins).toHaveLength(1);
|
|
297
|
+
expect(joins[0].fromSource).toBe("default");
|
|
298
|
+
expect(joins[0].fromTable).toBe("users");
|
|
299
|
+
expect(joins[0].toSource).toBe("warehouse");
|
|
300
|
+
expect(joins[0].toTable).toBe("events");
|
|
301
|
+
expect(joins[0].on).toBe("users.id = events.user_id");
|
|
302
|
+
expect(joins[0].relationship).toBe("one_to_many");
|
|
303
|
+
expect(joins[0].description).toBe("User activity events");
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
it("entity without cross_source_joins returns empty array (backward compat)", () => {
|
|
307
|
+
const root = ensureDir(`csj-compat-${testCounter}`);
|
|
308
|
+
const defaultEntities = ensureDir(`csj-compat-${testCounter}/entities`);
|
|
309
|
+
|
|
310
|
+
writeEntity(defaultEntities, "orders.yml", "table: orders\ncolumns:\n id:\n type: integer\n");
|
|
311
|
+
|
|
312
|
+
const joins = getCrossSourceJoins(root);
|
|
313
|
+
expect(joins).toHaveLength(0);
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
it("multiple cross-source joins on one entity", () => {
|
|
317
|
+
const root = ensureDir(`csj-multi-${testCounter}`);
|
|
318
|
+
const defaultEntities = ensureDir(`csj-multi-${testCounter}/entities`);
|
|
319
|
+
|
|
320
|
+
writeEntity(
|
|
321
|
+
defaultEntities,
|
|
322
|
+
"users.yml",
|
|
323
|
+
[
|
|
324
|
+
"table: users",
|
|
325
|
+
"columns:",
|
|
326
|
+
" id:",
|
|
327
|
+
" type: integer",
|
|
328
|
+
"cross_source_joins:",
|
|
329
|
+
" - source: warehouse",
|
|
330
|
+
" target_table: events",
|
|
331
|
+
" on: users.id = events.user_id",
|
|
332
|
+
" relationship: one_to_many",
|
|
333
|
+
" - source: salesforce",
|
|
334
|
+
" target_table: contacts",
|
|
335
|
+
" on: users.email = contacts.email",
|
|
336
|
+
" relationship: one_to_one",
|
|
337
|
+
].join("\n"),
|
|
338
|
+
);
|
|
339
|
+
|
|
340
|
+
const joins = getCrossSourceJoins(root);
|
|
341
|
+
expect(joins).toHaveLength(2);
|
|
342
|
+
expect(joins[0].toSource).toBe("warehouse");
|
|
343
|
+
expect(joins[1].toSource).toBe("salesforce");
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
it("cross-source joins from multiple entities across sources", () => {
|
|
347
|
+
const root = ensureDir(`csj-across-${testCounter}`);
|
|
348
|
+
const defaultEntities = ensureDir(`csj-across-${testCounter}/entities`);
|
|
349
|
+
const warehouseEntities = ensureDir(`csj-across-${testCounter}/warehouse/entities`);
|
|
350
|
+
|
|
351
|
+
writeEntity(
|
|
352
|
+
defaultEntities,
|
|
353
|
+
"users.yml",
|
|
354
|
+
[
|
|
355
|
+
"table: users",
|
|
356
|
+
"columns:",
|
|
357
|
+
" id:",
|
|
358
|
+
" type: integer",
|
|
359
|
+
"cross_source_joins:",
|
|
360
|
+
" - source: warehouse",
|
|
361
|
+
" target_table: events",
|
|
362
|
+
" on: users.id = events.user_id",
|
|
363
|
+
" relationship: one_to_many",
|
|
364
|
+
].join("\n"),
|
|
365
|
+
);
|
|
366
|
+
|
|
367
|
+
writeEntity(
|
|
368
|
+
warehouseEntities,
|
|
369
|
+
"events.yml",
|
|
370
|
+
[
|
|
371
|
+
"table: events",
|
|
372
|
+
"columns:",
|
|
373
|
+
" id:",
|
|
374
|
+
" type: integer",
|
|
375
|
+
"cross_source_joins:",
|
|
376
|
+
" - source: default",
|
|
377
|
+
" target_table: users",
|
|
378
|
+
" on: events.user_id = users.id",
|
|
379
|
+
" relationship: many_to_one",
|
|
380
|
+
].join("\n"),
|
|
381
|
+
);
|
|
382
|
+
|
|
383
|
+
const joins = getCrossSourceJoins(root);
|
|
384
|
+
expect(joins).toHaveLength(2);
|
|
385
|
+
|
|
386
|
+
const fromDefault = joins.find((j) => j.fromSource === "default");
|
|
387
|
+
const fromWarehouse = joins.find((j) => j.fromSource === "warehouse");
|
|
388
|
+
|
|
389
|
+
expect(fromDefault).toBeDefined();
|
|
390
|
+
expect(fromDefault!.fromTable).toBe("users");
|
|
391
|
+
expect(fromDefault!.toSource).toBe("warehouse");
|
|
392
|
+
|
|
393
|
+
expect(fromWarehouse).toBeDefined();
|
|
394
|
+
expect(fromWarehouse!.fromTable).toBe("events");
|
|
395
|
+
expect(fromWarehouse!.toSource).toBe("default");
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
it("explicit connection field used as fromSource (not directory name)", () => {
|
|
399
|
+
const root = ensureDir(`csj-explicit-${testCounter}`);
|
|
400
|
+
ensureDir(`csj-explicit-${testCounter}/entities`);
|
|
401
|
+
const warehouseEntities = ensureDir(`csj-explicit-${testCounter}/warehouse/entities`);
|
|
402
|
+
|
|
403
|
+
// Entity lives in warehouse/ dir but declares connection: analytics
|
|
404
|
+
writeEntity(
|
|
405
|
+
warehouseEntities,
|
|
406
|
+
"events.yml",
|
|
407
|
+
[
|
|
408
|
+
"table: events",
|
|
409
|
+
"connection: analytics",
|
|
410
|
+
"columns:",
|
|
411
|
+
" id:",
|
|
412
|
+
" type: integer",
|
|
413
|
+
"cross_source_joins:",
|
|
414
|
+
" - source: default",
|
|
415
|
+
" target_table: users",
|
|
416
|
+
" on: events.user_id = users.id",
|
|
417
|
+
" relationship: many_to_one",
|
|
418
|
+
].join("\n"),
|
|
419
|
+
);
|
|
420
|
+
|
|
421
|
+
const joins = getCrossSourceJoins(root);
|
|
422
|
+
expect(joins).toHaveLength(1);
|
|
423
|
+
// fromSource should be "analytics" (from connection field), not "warehouse" (from directory)
|
|
424
|
+
expect(joins[0].fromSource).toBe("analytics");
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
it("invalid cross_source_joins entry skipped gracefully — entity stays whitelisted", () => {
|
|
428
|
+
const root = ensureDir(`csj-invalid-${testCounter}`);
|
|
429
|
+
const defaultEntities = ensureDir(`csj-invalid-${testCounter}/entities`);
|
|
430
|
+
|
|
431
|
+
// Missing required fields (target_table, on, relationship) — the malformed
|
|
432
|
+
// join entry is skipped, but the entity itself remains in the whitelist
|
|
433
|
+
// because cross_source_joins validation is separate from core entity parsing.
|
|
434
|
+
writeEntity(
|
|
435
|
+
defaultEntities,
|
|
436
|
+
"users.yml",
|
|
437
|
+
[
|
|
438
|
+
"table: users",
|
|
439
|
+
"columns:",
|
|
440
|
+
" id:",
|
|
441
|
+
" type: integer",
|
|
442
|
+
"cross_source_joins:",
|
|
443
|
+
" - source: warehouse",
|
|
444
|
+
// missing target_table, on, relationship
|
|
445
|
+
].join("\n"),
|
|
446
|
+
);
|
|
447
|
+
|
|
448
|
+
// A valid entity in the same directory should still load fine
|
|
449
|
+
writeEntity(
|
|
450
|
+
defaultEntities,
|
|
451
|
+
"orders.yml",
|
|
452
|
+
"table: orders\ncolumns:\n id:\n type: integer\n",
|
|
453
|
+
);
|
|
454
|
+
|
|
455
|
+
const tables = getWhitelistedTables("default", undefined, root);
|
|
456
|
+
// The entity stays in the whitelist — only the bad join entry is skipped
|
|
457
|
+
expect(tables.has("users")).toBe(true);
|
|
458
|
+
expect(tables.has("orders")).toBe(true);
|
|
459
|
+
|
|
460
|
+
const joins = getCrossSourceJoins(root);
|
|
461
|
+
// No valid joins from the users entity (all were invalid)
|
|
462
|
+
expect(joins.filter((j) => j.fromTable === "users")).toHaveLength(0);
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
it("partial invalid joins — valid entries collected, invalid entries skipped, entity stays whitelisted", () => {
|
|
466
|
+
const root = ensureDir(`csj-partial-${testCounter}`);
|
|
467
|
+
const defaultEntities = ensureDir(`csj-partial-${testCounter}/entities`);
|
|
468
|
+
|
|
469
|
+
// Two cross_source_joins: one valid, one missing required fields.
|
|
470
|
+
// The valid one should be collected, the invalid one skipped, and the
|
|
471
|
+
// entity should remain in the whitelist.
|
|
472
|
+
writeEntity(
|
|
473
|
+
defaultEntities,
|
|
474
|
+
"users.yml",
|
|
475
|
+
[
|
|
476
|
+
"table: users",
|
|
477
|
+
"columns:",
|
|
478
|
+
" id:",
|
|
479
|
+
" type: integer",
|
|
480
|
+
"cross_source_joins:",
|
|
481
|
+
" - source: warehouse",
|
|
482
|
+
" target_table: events",
|
|
483
|
+
" on: users.id = events.user_id",
|
|
484
|
+
" relationship: one_to_many",
|
|
485
|
+
" - source: salesforce",
|
|
486
|
+
// missing target_table, on, relationship
|
|
487
|
+
].join("\n"),
|
|
488
|
+
);
|
|
489
|
+
|
|
490
|
+
const tables = getWhitelistedTables("default", undefined, root);
|
|
491
|
+
expect(tables.has("users")).toBe(true);
|
|
492
|
+
|
|
493
|
+
const joins = getCrossSourceJoins(root);
|
|
494
|
+
const userJoins = joins.filter((j) => j.fromTable === "users");
|
|
495
|
+
expect(userJoins).toHaveLength(1);
|
|
496
|
+
expect(userJoins[0].toSource).toBe("warehouse");
|
|
497
|
+
expect(userJoins[0].toTable).toBe("events");
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
it("getCrossSourceJoins() without args uses global cache populated by getWhitelistedTables()", () => {
|
|
501
|
+
// Set up a temp directory that looks like a semantic root at process.cwd()/semantic
|
|
502
|
+
const tmpRoot = ensureDir(`csj-cache-${testCounter}`);
|
|
503
|
+
const entitiesDir = ensureDir(`csj-cache-${testCounter}/semantic/entities`);
|
|
504
|
+
|
|
505
|
+
writeEntity(
|
|
506
|
+
entitiesDir,
|
|
507
|
+
"users.yml",
|
|
508
|
+
[
|
|
509
|
+
"table: users",
|
|
510
|
+
"columns:",
|
|
511
|
+
" id:",
|
|
512
|
+
" type: integer",
|
|
513
|
+
"cross_source_joins:",
|
|
514
|
+
" - source: warehouse",
|
|
515
|
+
" target_table: events",
|
|
516
|
+
" on: users.id = events.user_id",
|
|
517
|
+
" relationship: one_to_many",
|
|
518
|
+
" description: User activity events",
|
|
519
|
+
].join("\n"),
|
|
520
|
+
);
|
|
521
|
+
|
|
522
|
+
// Temporarily change CWD so getWhitelistedTables() without args finds semantic/
|
|
523
|
+
const originalCwd = process.cwd();
|
|
524
|
+
process.chdir(tmpRoot);
|
|
525
|
+
try {
|
|
526
|
+
// Call without custom paths — populates global cache (_tablesByConnection + _crossSourceJoins)
|
|
527
|
+
const tables = getWhitelistedTables();
|
|
528
|
+
expect(tables.has("users")).toBe(true);
|
|
529
|
+
|
|
530
|
+
// Call getCrossSourceJoins() without args — reads from global cache
|
|
531
|
+
const joins = getCrossSourceJoins();
|
|
532
|
+
expect(joins).toHaveLength(1);
|
|
533
|
+
expect(joins[0].fromSource).toBe("default");
|
|
534
|
+
expect(joins[0].fromTable).toBe("users");
|
|
535
|
+
expect(joins[0].toSource).toBe("warehouse");
|
|
536
|
+
expect(joins[0].toTable).toBe("events");
|
|
537
|
+
expect(joins[0].on).toBe("users.id = events.user_id");
|
|
538
|
+
expect(joins[0].relationship).toBe("one_to_many");
|
|
539
|
+
expect(joins[0].description).toBe("User activity events");
|
|
540
|
+
} finally {
|
|
541
|
+
process.chdir(originalCwd);
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
});
|