@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,547 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for the pre-indexed semantic layer summary (semantic-index.ts).
|
|
3
|
+
*
|
|
4
|
+
* Uses temp directories with entity/metric/glossary YAMLs to verify
|
|
5
|
+
* index building, small vs large mode, cache invalidation, and system
|
|
6
|
+
* prompt injection.
|
|
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 modPath = resolve(__dirname, "../semantic-index.ts");
|
|
14
|
+
const mod = await import(`${modPath}?t=${Date.now()}`);
|
|
15
|
+
const buildSemanticIndex = mod.buildSemanticIndex as typeof import("../semantic-index").buildSemanticIndex;
|
|
16
|
+
const getSemanticIndex = mod.getSemanticIndex as typeof import("../semantic-index").getSemanticIndex;
|
|
17
|
+
const invalidateSemanticIndex = mod.invalidateSemanticIndex as typeof import("../semantic-index").invalidateSemanticIndex;
|
|
18
|
+
const getIndexedEntityCount = mod.getIndexedEntityCount as typeof import("../semantic-index").getIndexedEntityCount;
|
|
19
|
+
|
|
20
|
+
const tmpBase = resolve(__dirname, ".tmp-semantic-index-test");
|
|
21
|
+
let testCounter = 0;
|
|
22
|
+
|
|
23
|
+
function ensureDir(subdir: string): string {
|
|
24
|
+
const dir = resolve(tmpBase, subdir);
|
|
25
|
+
mkdirSync(dir, { recursive: true });
|
|
26
|
+
return dir;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function cleanTmpBase() {
|
|
30
|
+
if (existsSync(tmpBase)) {
|
|
31
|
+
rmSync(tmpBase, { recursive: true, force: true });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function makeEntity(table: string, opts?: {
|
|
36
|
+
description?: string;
|
|
37
|
+
connection?: string;
|
|
38
|
+
type?: string;
|
|
39
|
+
grain?: string;
|
|
40
|
+
dimensions?: Array<{ name: string; type: string; description?: string; primary_key?: boolean }>;
|
|
41
|
+
measures?: Array<{ name: string; type: string; description?: string }>;
|
|
42
|
+
joins?: Array<{ target_entity: string; relationship: string }>;
|
|
43
|
+
query_patterns?: Array<{ name: string; description: string }>;
|
|
44
|
+
}) {
|
|
45
|
+
const lines: string[] = [];
|
|
46
|
+
lines.push(`name: ${table}`);
|
|
47
|
+
lines.push(`table: ${table}`);
|
|
48
|
+
if (opts?.type) lines.push(`type: ${opts.type}`);
|
|
49
|
+
if (opts?.connection) lines.push(`connection: ${opts.connection}`);
|
|
50
|
+
if (opts?.grain) lines.push(`grain: ${opts.grain}`);
|
|
51
|
+
if (opts?.description) lines.push(`description: "${opts.description}"`);
|
|
52
|
+
|
|
53
|
+
if (opts?.dimensions) {
|
|
54
|
+
lines.push("dimensions:");
|
|
55
|
+
for (const d of opts.dimensions) {
|
|
56
|
+
lines.push(` - name: ${d.name}`);
|
|
57
|
+
lines.push(` type: ${d.type}`);
|
|
58
|
+
if (d.description) lines.push(` description: "${d.description}"`);
|
|
59
|
+
if (d.primary_key) lines.push(` primary_key: true`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (opts?.measures) {
|
|
64
|
+
lines.push("measures:");
|
|
65
|
+
for (const m of opts.measures) {
|
|
66
|
+
lines.push(` - name: ${m.name}`);
|
|
67
|
+
lines.push(` type: ${m.type}`);
|
|
68
|
+
if (m.description) lines.push(` description: "${m.description}"`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (opts?.joins) {
|
|
73
|
+
lines.push("joins:");
|
|
74
|
+
for (const j of opts.joins) {
|
|
75
|
+
lines.push(` - target_entity: ${j.target_entity}`);
|
|
76
|
+
lines.push(` relationship: ${j.relationship}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (opts?.query_patterns) {
|
|
81
|
+
lines.push("query_patterns:");
|
|
82
|
+
for (const p of opts.query_patterns) {
|
|
83
|
+
lines.push(` - name: ${p.name}`);
|
|
84
|
+
lines.push(` description: "${p.description}"`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return lines.join("\n") + "\n";
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
describe("buildSemanticIndex", () => {
|
|
92
|
+
beforeEach(() => {
|
|
93
|
+
invalidateSemanticIndex();
|
|
94
|
+
testCounter++;
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
afterEach(() => {
|
|
98
|
+
invalidateSemanticIndex();
|
|
99
|
+
cleanTmpBase();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("returns empty string for missing semantic directory", () => {
|
|
103
|
+
const index = buildSemanticIndex("/tmp/nonexistent-semantic-index-test");
|
|
104
|
+
expect(index).toBe("");
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("returns empty string for empty entities directory", () => {
|
|
108
|
+
const root = ensureDir(`empty-${testCounter}`);
|
|
109
|
+
mkdirSync(join(root, "entities"), { recursive: true });
|
|
110
|
+
const index = buildSemanticIndex(root);
|
|
111
|
+
expect(index).toBe("");
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("builds full index for small semantic layer (< 20 entities)", () => {
|
|
115
|
+
const root = ensureDir(`small-${testCounter}`);
|
|
116
|
+
mkdirSync(join(root, "entities"), { recursive: true });
|
|
117
|
+
|
|
118
|
+
writeFileSync(
|
|
119
|
+
join(root, "entities", "users.yml"),
|
|
120
|
+
makeEntity("users", {
|
|
121
|
+
description: "User accounts table",
|
|
122
|
+
type: "fact_table",
|
|
123
|
+
grain: "one row per user",
|
|
124
|
+
dimensions: [
|
|
125
|
+
{ name: "id", type: "integer", primary_key: true },
|
|
126
|
+
{ name: "name", type: "text", description: "User full name" },
|
|
127
|
+
{ name: "email", type: "text", description: "User email address" },
|
|
128
|
+
],
|
|
129
|
+
measures: [
|
|
130
|
+
{ name: "user_count", type: "count_distinct", description: "Number of unique users" },
|
|
131
|
+
],
|
|
132
|
+
joins: [
|
|
133
|
+
{ target_entity: "orders", relationship: "one_to_many" },
|
|
134
|
+
],
|
|
135
|
+
query_patterns: [
|
|
136
|
+
{ name: "users_by_status", description: "Count users by status" },
|
|
137
|
+
],
|
|
138
|
+
}),
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
writeFileSync(
|
|
142
|
+
join(root, "entities", "orders.yml"),
|
|
143
|
+
makeEntity("orders", {
|
|
144
|
+
description: "Customer orders",
|
|
145
|
+
dimensions: [
|
|
146
|
+
{ name: "id", type: "integer", primary_key: true },
|
|
147
|
+
{ name: "user_id", type: "integer" },
|
|
148
|
+
{ name: "total", type: "numeric", description: "Order total amount" },
|
|
149
|
+
],
|
|
150
|
+
}),
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
const index = buildSemanticIndex(root);
|
|
154
|
+
|
|
155
|
+
// Should be in full mode
|
|
156
|
+
expect(index).toContain("mode: full");
|
|
157
|
+
expect(index).toContain("2 entities");
|
|
158
|
+
|
|
159
|
+
// Full mode shows columns
|
|
160
|
+
expect(index).toContain("**users**");
|
|
161
|
+
expect(index).toContain("id (integer PK)");
|
|
162
|
+
expect(index).toContain("name (text)");
|
|
163
|
+
expect(index).toContain("email (text)");
|
|
164
|
+
expect(index).toContain("User full name");
|
|
165
|
+
|
|
166
|
+
// Shows measures
|
|
167
|
+
expect(index).toContain("user_count");
|
|
168
|
+
|
|
169
|
+
// Shows joins
|
|
170
|
+
expect(index).toContain("→ orders");
|
|
171
|
+
|
|
172
|
+
// Shows query patterns
|
|
173
|
+
expect(index).toContain("users_by_status");
|
|
174
|
+
|
|
175
|
+
// Shows orders entity
|
|
176
|
+
expect(index).toContain("**orders**");
|
|
177
|
+
expect(index).toContain("total (numeric)");
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it("builds summary index for large semantic layer (20+ entities)", () => {
|
|
181
|
+
const root = ensureDir(`large-${testCounter}`);
|
|
182
|
+
mkdirSync(join(root, "entities"), { recursive: true });
|
|
183
|
+
|
|
184
|
+
// Create 22 entities to exceed threshold
|
|
185
|
+
for (let i = 0; i < 22; i++) {
|
|
186
|
+
writeFileSync(
|
|
187
|
+
join(root, "entities", `table_${i}.yml`),
|
|
188
|
+
makeEntity(`table_${i}`, {
|
|
189
|
+
description: `Table number ${i}`,
|
|
190
|
+
dimensions: [
|
|
191
|
+
{ name: "id", type: "integer", primary_key: true },
|
|
192
|
+
{ name: `col_${i}`, type: "text" },
|
|
193
|
+
{ name: `value_${i}`, type: "numeric" },
|
|
194
|
+
],
|
|
195
|
+
measures: [
|
|
196
|
+
{ name: `count_${i}`, type: "count" },
|
|
197
|
+
],
|
|
198
|
+
joins: i > 0
|
|
199
|
+
? [{ target_entity: `table_${i - 1}`, relationship: "many_to_one" }]
|
|
200
|
+
: undefined,
|
|
201
|
+
}),
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const index = buildSemanticIndex(root);
|
|
206
|
+
|
|
207
|
+
// Should be in summary mode
|
|
208
|
+
expect(index).toContain("mode: summary");
|
|
209
|
+
expect(index).toContain("22 entities");
|
|
210
|
+
|
|
211
|
+
// Summary mode shows column count but not individual columns
|
|
212
|
+
expect(index).toContain("3 columns");
|
|
213
|
+
expect(index).toContain("PK: id");
|
|
214
|
+
|
|
215
|
+
// Summary mode shows measures count and join targets
|
|
216
|
+
expect(index).toContain("1 measures");
|
|
217
|
+
expect(index).toContain("joins: table_0");
|
|
218
|
+
|
|
219
|
+
// Should NOT show individual column details like "(text)" descriptions
|
|
220
|
+
expect(index).not.toContain("id (integer PK)");
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
it("includes metrics in the index", () => {
|
|
224
|
+
const root = ensureDir(`metrics-${testCounter}`);
|
|
225
|
+
mkdirSync(join(root, "entities"), { recursive: true });
|
|
226
|
+
mkdirSync(join(root, "metrics"), { recursive: true });
|
|
227
|
+
|
|
228
|
+
writeFileSync(
|
|
229
|
+
join(root, "entities", "orders.yml"),
|
|
230
|
+
makeEntity("orders", {
|
|
231
|
+
dimensions: [{ name: "id", type: "integer" }],
|
|
232
|
+
}),
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
writeFileSync(
|
|
236
|
+
join(root, "metrics", "orders_metrics.yml"),
|
|
237
|
+
[
|
|
238
|
+
"metrics:",
|
|
239
|
+
" - name: total_revenue",
|
|
240
|
+
' description: "Sum of all order totals"',
|
|
241
|
+
" entity: orders",
|
|
242
|
+
" aggregation: sum",
|
|
243
|
+
" - name: avg_order_value",
|
|
244
|
+
' description: "Average order value"',
|
|
245
|
+
" entity: orders",
|
|
246
|
+
" aggregation: avg",
|
|
247
|
+
].join("\n") + "\n",
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
const index = buildSemanticIndex(root);
|
|
251
|
+
|
|
252
|
+
expect(index).toContain("### Metrics");
|
|
253
|
+
expect(index).toContain("total_revenue");
|
|
254
|
+
expect(index).toContain("Sum of all order totals");
|
|
255
|
+
expect(index).toContain("avg_order_value");
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
it("includes glossary terms in the index", () => {
|
|
259
|
+
const root = ensureDir(`glossary-${testCounter}`);
|
|
260
|
+
mkdirSync(join(root, "entities"), { recursive: true });
|
|
261
|
+
|
|
262
|
+
writeFileSync(
|
|
263
|
+
join(root, "entities", "orders.yml"),
|
|
264
|
+
makeEntity("orders", {
|
|
265
|
+
dimensions: [{ name: "id", type: "integer" }],
|
|
266
|
+
}),
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
writeFileSync(
|
|
270
|
+
join(root, "glossary.yml"),
|
|
271
|
+
[
|
|
272
|
+
"terms:",
|
|
273
|
+
" - term: revenue",
|
|
274
|
+
' definition: "Total income from sales"',
|
|
275
|
+
" status: defined",
|
|
276
|
+
" - term: size",
|
|
277
|
+
' definition: "Could refer to company size or deal size"',
|
|
278
|
+
" status: ambiguous",
|
|
279
|
+
' disambiguation: "Ask the user which size they mean"',
|
|
280
|
+
].join("\n") + "\n",
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
const index = buildSemanticIndex(root);
|
|
284
|
+
|
|
285
|
+
expect(index).toContain("### Glossary");
|
|
286
|
+
expect(index).toContain("**revenue**");
|
|
287
|
+
expect(index).toContain("Total income from sales");
|
|
288
|
+
expect(index).toContain("**size**");
|
|
289
|
+
expect(index).toContain("[AMBIGUOUS]");
|
|
290
|
+
expect(index).toContain("Ask the user which size they mean");
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
it("handles per-source subdirectories", () => {
|
|
294
|
+
const root = ensureDir(`multisource-${testCounter}`);
|
|
295
|
+
mkdirSync(join(root, "entities"), { recursive: true });
|
|
296
|
+
mkdirSync(join(root, "warehouse", "entities"), { recursive: true });
|
|
297
|
+
|
|
298
|
+
writeFileSync(
|
|
299
|
+
join(root, "entities", "users.yml"),
|
|
300
|
+
makeEntity("users", {
|
|
301
|
+
dimensions: [{ name: "id", type: "integer" }],
|
|
302
|
+
}),
|
|
303
|
+
);
|
|
304
|
+
|
|
305
|
+
writeFileSync(
|
|
306
|
+
join(root, "warehouse", "entities", "events.yml"),
|
|
307
|
+
makeEntity("events", {
|
|
308
|
+
dimensions: [{ name: "id", type: "integer" }],
|
|
309
|
+
}),
|
|
310
|
+
);
|
|
311
|
+
|
|
312
|
+
const index = buildSemanticIndex(root);
|
|
313
|
+
|
|
314
|
+
expect(index).toContain("2 entities");
|
|
315
|
+
expect(index).toContain("**users**");
|
|
316
|
+
expect(index).toContain("**events**");
|
|
317
|
+
// Per-source entities show connection ID
|
|
318
|
+
expect(index).toContain("[warehouse]");
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
it("skips malformed YAML files gracefully", () => {
|
|
322
|
+
const root = ensureDir(`malformed-${testCounter}`);
|
|
323
|
+
mkdirSync(join(root, "entities"), { recursive: true });
|
|
324
|
+
|
|
325
|
+
writeFileSync(join(root, "entities", "bad.yml"), "{{{not valid yaml");
|
|
326
|
+
writeFileSync(
|
|
327
|
+
join(root, "entities", "good.yml"),
|
|
328
|
+
makeEntity("good_table", {
|
|
329
|
+
dimensions: [{ name: "id", type: "integer" }],
|
|
330
|
+
}),
|
|
331
|
+
);
|
|
332
|
+
|
|
333
|
+
const index = buildSemanticIndex(root);
|
|
334
|
+
|
|
335
|
+
expect(index).toContain("1 entities");
|
|
336
|
+
expect(index).toContain("**good_table**");
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
it("includes catalog use_for hints in the index", () => {
|
|
340
|
+
const root = ensureDir(`catalog-${testCounter}`);
|
|
341
|
+
mkdirSync(join(root, "entities"), { recursive: true });
|
|
342
|
+
|
|
343
|
+
writeFileSync(
|
|
344
|
+
join(root, "entities", "orders.yml"),
|
|
345
|
+
makeEntity("orders", {
|
|
346
|
+
description: "Customer orders",
|
|
347
|
+
dimensions: [{ name: "id", type: "integer" }],
|
|
348
|
+
}),
|
|
349
|
+
);
|
|
350
|
+
|
|
351
|
+
writeFileSync(
|
|
352
|
+
join(root, "catalog.yml"),
|
|
353
|
+
[
|
|
354
|
+
"version: '1'",
|
|
355
|
+
"entities:",
|
|
356
|
+
" - name: orders",
|
|
357
|
+
' description: "Customer orders"',
|
|
358
|
+
" use_for:",
|
|
359
|
+
' - "Revenue analysis"',
|
|
360
|
+
' - "Order volume tracking"',
|
|
361
|
+
].join("\n") + "\n",
|
|
362
|
+
);
|
|
363
|
+
|
|
364
|
+
const index = buildSemanticIndex(root);
|
|
365
|
+
|
|
366
|
+
expect(index).toContain("Use for: Revenue analysis; Order volume tracking");
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
it("truncates long entity descriptions at 200 characters", () => {
|
|
370
|
+
const root = ensureDir(`truncate-${testCounter}`);
|
|
371
|
+
mkdirSync(join(root, "entities"), { recursive: true });
|
|
372
|
+
|
|
373
|
+
const longDesc = "A".repeat(250);
|
|
374
|
+
writeFileSync(
|
|
375
|
+
join(root, "entities", "wide.yml"),
|
|
376
|
+
makeEntity("wide", {
|
|
377
|
+
description: longDesc,
|
|
378
|
+
dimensions: [{ name: "id", type: "integer" }],
|
|
379
|
+
}),
|
|
380
|
+
);
|
|
381
|
+
|
|
382
|
+
const index = buildSemanticIndex(root);
|
|
383
|
+
|
|
384
|
+
// Should truncate to 197 chars + "..."
|
|
385
|
+
expect(index).toContain("A".repeat(197) + "...");
|
|
386
|
+
expect(index).not.toContain("A".repeat(200));
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
it("skips entities without a table field", () => {
|
|
390
|
+
const root = ensureDir(`notable-${testCounter}`);
|
|
391
|
+
mkdirSync(join(root, "entities"), { recursive: true });
|
|
392
|
+
|
|
393
|
+
// Valid YAML but missing the required `table` field
|
|
394
|
+
writeFileSync(join(root, "entities", "no_table.yml"), "name: orphan\ndescription: No table field\n");
|
|
395
|
+
writeFileSync(
|
|
396
|
+
join(root, "entities", "good.yml"),
|
|
397
|
+
makeEntity("good_table", {
|
|
398
|
+
dimensions: [{ name: "id", type: "integer" }],
|
|
399
|
+
}),
|
|
400
|
+
);
|
|
401
|
+
|
|
402
|
+
const index = buildSemanticIndex(root);
|
|
403
|
+
|
|
404
|
+
expect(index).toContain("1 entities");
|
|
405
|
+
expect(index).toContain("**good_table**");
|
|
406
|
+
expect(index).not.toContain("orphan");
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
it("handles entity with connection field", () => {
|
|
410
|
+
const root = ensureDir(`connection-${testCounter}`);
|
|
411
|
+
mkdirSync(join(root, "entities"), { recursive: true });
|
|
412
|
+
|
|
413
|
+
writeFileSync(
|
|
414
|
+
join(root, "entities", "events.yml"),
|
|
415
|
+
makeEntity("events", {
|
|
416
|
+
connection: "analytics",
|
|
417
|
+
dimensions: [{ name: "id", type: "integer" }],
|
|
418
|
+
}),
|
|
419
|
+
);
|
|
420
|
+
|
|
421
|
+
const index = buildSemanticIndex(root);
|
|
422
|
+
|
|
423
|
+
expect(index).toContain("[analytics]");
|
|
424
|
+
});
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
describe("getSemanticIndex caching", () => {
|
|
428
|
+
beforeEach(() => {
|
|
429
|
+
invalidateSemanticIndex();
|
|
430
|
+
testCounter++;
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
afterEach(() => {
|
|
434
|
+
invalidateSemanticIndex();
|
|
435
|
+
cleanTmpBase();
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
it("caches index across calls with same root", () => {
|
|
439
|
+
const root = ensureDir(`cache-${testCounter}`);
|
|
440
|
+
mkdirSync(join(root, "entities"), { recursive: true });
|
|
441
|
+
|
|
442
|
+
writeFileSync(
|
|
443
|
+
join(root, "entities", "users.yml"),
|
|
444
|
+
makeEntity("users", {
|
|
445
|
+
dimensions: [{ name: "id", type: "integer" }],
|
|
446
|
+
}),
|
|
447
|
+
);
|
|
448
|
+
|
|
449
|
+
const first = getSemanticIndex(root);
|
|
450
|
+
const second = getSemanticIndex(root);
|
|
451
|
+
|
|
452
|
+
// Same reference (cached)
|
|
453
|
+
expect(first).toBe(second);
|
|
454
|
+
expect(getIndexedEntityCount()).toBe(1);
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
it("invalidateSemanticIndex clears the cache", () => {
|
|
458
|
+
const root = ensureDir(`invalidate-${testCounter}`);
|
|
459
|
+
mkdirSync(join(root, "entities"), { recursive: true });
|
|
460
|
+
|
|
461
|
+
writeFileSync(
|
|
462
|
+
join(root, "entities", "users.yml"),
|
|
463
|
+
makeEntity("users", {
|
|
464
|
+
dimensions: [{ name: "id", type: "integer" }],
|
|
465
|
+
}),
|
|
466
|
+
);
|
|
467
|
+
|
|
468
|
+
const first = getSemanticIndex(root);
|
|
469
|
+
expect(first).toContain("**users**");
|
|
470
|
+
expect(getIndexedEntityCount()).toBe(1);
|
|
471
|
+
|
|
472
|
+
invalidateSemanticIndex();
|
|
473
|
+
expect(getIndexedEntityCount()).toBe(0);
|
|
474
|
+
|
|
475
|
+
// Add a new entity and rebuild
|
|
476
|
+
writeFileSync(
|
|
477
|
+
join(root, "entities", "orders.yml"),
|
|
478
|
+
makeEntity("orders", {
|
|
479
|
+
dimensions: [{ name: "id", type: "integer" }],
|
|
480
|
+
}),
|
|
481
|
+
);
|
|
482
|
+
|
|
483
|
+
const second = getSemanticIndex(root);
|
|
484
|
+
expect(second).toContain("**users**");
|
|
485
|
+
expect(second).toContain("**orders**");
|
|
486
|
+
expect(getIndexedEntityCount()).toBe(2);
|
|
487
|
+
});
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
describe("small vs large mode boundary", () => {
|
|
491
|
+
beforeEach(() => {
|
|
492
|
+
invalidateSemanticIndex();
|
|
493
|
+
testCounter++;
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
afterEach(() => {
|
|
497
|
+
invalidateSemanticIndex();
|
|
498
|
+
cleanTmpBase();
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
it("19 entities → full mode", () => {
|
|
502
|
+
const root = ensureDir(`boundary-19-${testCounter}`);
|
|
503
|
+
mkdirSync(join(root, "entities"), { recursive: true });
|
|
504
|
+
|
|
505
|
+
for (let i = 0; i < 19; i++) {
|
|
506
|
+
writeFileSync(
|
|
507
|
+
join(root, "entities", `t${i}.yml`),
|
|
508
|
+
makeEntity(`t${i}`, {
|
|
509
|
+
dimensions: [
|
|
510
|
+
{ name: "id", type: "integer", primary_key: true },
|
|
511
|
+
{ name: "val", type: "text" },
|
|
512
|
+
],
|
|
513
|
+
}),
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
const index = buildSemanticIndex(root);
|
|
518
|
+
expect(index).toContain("mode: full");
|
|
519
|
+
expect(index).toContain("19 entities");
|
|
520
|
+
// Full mode shows column types
|
|
521
|
+
expect(index).toContain("id (integer PK)");
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
it("20 entities → summary mode", () => {
|
|
525
|
+
const root = ensureDir(`boundary-20-${testCounter}`);
|
|
526
|
+
mkdirSync(join(root, "entities"), { recursive: true });
|
|
527
|
+
|
|
528
|
+
for (let i = 0; i < 20; i++) {
|
|
529
|
+
writeFileSync(
|
|
530
|
+
join(root, "entities", `t${i}.yml`),
|
|
531
|
+
makeEntity(`t${i}`, {
|
|
532
|
+
dimensions: [
|
|
533
|
+
{ name: "id", type: "integer", primary_key: true },
|
|
534
|
+
{ name: "val", type: "text" },
|
|
535
|
+
],
|
|
536
|
+
}),
|
|
537
|
+
);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
const index = buildSemanticIndex(root);
|
|
541
|
+
expect(index).toContain("mode: summary");
|
|
542
|
+
expect(index).toContain("20 entities");
|
|
543
|
+
// Summary mode shows count, not types
|
|
544
|
+
expect(index).toContain("2 columns");
|
|
545
|
+
expect(index).not.toContain("id (integer PK)");
|
|
546
|
+
});
|
|
547
|
+
});
|