@useatlas/create 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1 -1
- package/index.ts +253 -36
- package/package.json +4 -4
- package/templates/docker/Dockerfile +1 -1
- package/templates/docker/Dockerfile.sidecar +1 -1
- package/templates/docker/bin/__tests__/duckdb-ingest.test.ts +17 -14
- package/templates/docker/bin/__tests__/failure-threshold.test.ts +148 -0
- package/templates/docker/bin/__tests__/fatal-error-propagation.test.ts +267 -0
- package/templates/docker/bin/__tests__/profiler-heuristics.test.ts +5 -5
- package/templates/docker/bin/__tests__/schema-drift.test.ts +39 -0
- package/templates/docker/bin/atlas.ts +981 -1819
- package/templates/docker/bin/benchmark.ts +14 -16
- package/templates/docker/bin/enrich.ts +7 -2
- package/templates/docker/brand.css +13 -0
- package/templates/docker/data/cybersec-semantic/catalog.yml +222 -0
- package/templates/docker/data/cybersec-semantic/entities/alerts.yml +195 -0
- package/templates/docker/data/cybersec-semantic/entities/assets.yml +191 -0
- package/templates/docker/data/cybersec-semantic/entities/compliance_assessments.yml +170 -0
- package/templates/docker/data/cybersec-semantic/entities/incidents.yml +219 -0
- package/templates/docker/data/cybersec-semantic/entities/organizations.yml +136 -0
- package/templates/docker/data/cybersec-semantic/entities/plans.yml +114 -0
- package/templates/docker/data/cybersec-semantic/entities/remediation_actions.yml +212 -0
- package/templates/docker/data/cybersec-semantic/entities/scan_results.yml +215 -0
- package/templates/docker/data/cybersec-semantic/entities/scans.yml +180 -0
- package/templates/docker/data/cybersec-semantic/entities/subscriptions.yml +184 -0
- package/templates/docker/data/cybersec-semantic/entities/users.yml +140 -0
- package/templates/docker/data/cybersec-semantic/entities/vulnerabilities.yml +154 -0
- package/templates/docker/data/cybersec-semantic/glossary.yml +207 -0
- package/templates/docker/data/cybersec-semantic/metrics/business.yml +148 -0
- package/templates/docker/data/cybersec-semantic/metrics/compliance.yml +138 -0
- package/templates/docker/data/cybersec-semantic/metrics/security.yml +181 -0
- package/templates/docker/data/cybersec.sql +8 -8
- package/templates/docker/data/demo.sql +3 -0
- package/templates/docker/data/ecommerce-semantic/catalog.yml +221 -0
- package/templates/docker/data/ecommerce-semantic/entities/categories.yml +91 -0
- package/templates/docker/data/ecommerce-semantic/entities/customers.yml +133 -0
- package/templates/docker/data/ecommerce-semantic/entities/email_campaigns.yml +119 -0
- package/templates/docker/data/ecommerce-semantic/entities/inventory_levels.yml +153 -0
- package/templates/docker/data/ecommerce-semantic/entities/order_items.yml +159 -0
- package/templates/docker/data/ecommerce-semantic/entities/orders.yml +199 -0
- package/templates/docker/data/ecommerce-semantic/entities/payments.yml +140 -0
- package/templates/docker/data/ecommerce-semantic/entities/product_reviews.yml +155 -0
- package/templates/docker/data/ecommerce-semantic/entities/products.yml +178 -0
- package/templates/docker/data/ecommerce-semantic/entities/promotions.yml +171 -0
- package/templates/docker/data/ecommerce-semantic/entities/returns.yml +144 -0
- package/templates/docker/data/ecommerce-semantic/entities/sellers.yml +124 -0
- package/templates/docker/data/ecommerce-semantic/entities/shipments.yml +159 -0
- package/templates/docker/data/ecommerce-semantic/glossary.yml +193 -0
- package/templates/docker/data/ecommerce-semantic/metrics/customers.yml +116 -0
- package/templates/docker/data/ecommerce-semantic/metrics/operations.yml +131 -0
- package/templates/docker/data/ecommerce-semantic/metrics/revenue.yml +120 -0
- package/templates/docker/docs/deploy.md +2 -1
- package/templates/docker/ee/src/__mocks__/internal.ts +170 -0
- package/templates/docker/ee/src/audit/purge-scheduler.ts +113 -0
- package/templates/docker/ee/src/audit/retention.ts +467 -0
- package/templates/docker/ee/src/auth/ip-allowlist.ts +367 -0
- package/templates/docker/ee/src/auth/roles.ts +562 -0
- package/templates/docker/ee/src/auth/scim.ts +343 -0
- package/templates/docker/ee/src/auth/sso.ts +538 -0
- package/templates/docker/ee/src/backups/engine.ts +355 -0
- package/templates/docker/ee/src/backups/index.ts +26 -0
- package/templates/docker/ee/src/backups/restore.ts +169 -0
- package/templates/docker/ee/src/backups/scheduler.ts +153 -0
- package/templates/docker/ee/src/backups/verify.ts +124 -0
- package/templates/docker/ee/src/branding/white-label.ts +228 -0
- package/templates/docker/ee/src/compliance/masking.ts +477 -0
- package/templates/docker/ee/src/compliance/patterns.ts +16 -0
- package/templates/docker/ee/src/compliance/pii-detection.ts +217 -0
- package/templates/docker/ee/src/compliance/reports.ts +402 -0
- package/templates/docker/ee/src/deploy-mode.ts +37 -0
- package/templates/docker/ee/src/governance/approval.ts +699 -0
- package/templates/docker/ee/src/index.ts +74 -0
- package/templates/docker/ee/src/platform/domains.ts +562 -0
- package/templates/docker/ee/src/platform/model-routing.ts +382 -0
- package/templates/docker/ee/src/platform/residency.ts +265 -0
- package/templates/docker/ee/src/sla/alerting.ts +382 -0
- package/templates/docker/ee/src/sla/index.ts +12 -0
- package/templates/docker/ee/src/sla/metrics.ts +275 -0
- package/templates/docker/ee/src/test-setup.ts +1 -0
- package/templates/docker/next.config.ts +4 -1
- package/templates/docker/package.json +49 -29
- package/templates/docker/sidecar/Dockerfile +1 -1
- package/templates/docker/src/api/index.ts +336 -24
- package/templates/docker/src/api/routes/actions.ts +443 -176
- package/templates/docker/src/api/routes/admin-abuse.ts +219 -0
- package/templates/docker/src/api/routes/admin-approval.ts +418 -0
- package/templates/docker/src/api/routes/admin-audit-retention.ts +405 -0
- package/templates/docker/src/api/routes/admin-auth.ts +122 -0
- package/templates/docker/src/api/routes/admin-branding.ts +252 -0
- package/templates/docker/src/api/routes/admin-compliance.ts +352 -0
- package/templates/docker/src/api/routes/admin-domains.ts +334 -0
- package/templates/docker/src/api/routes/admin-integrations.ts +2667 -0
- package/templates/docker/src/api/routes/admin-ip-allowlist.ts +261 -0
- package/templates/docker/src/api/routes/admin-learned-patterns.ts +525 -0
- package/templates/docker/src/api/routes/admin-model-config.ts +252 -0
- package/templates/docker/src/api/routes/admin-onboarding-emails.ts +145 -0
- package/templates/docker/src/api/routes/admin-orgs.ts +710 -0
- package/templates/docker/src/api/routes/admin-prompts.ts +694 -0
- package/templates/docker/src/api/routes/admin-residency.ts +570 -0
- package/templates/docker/src/api/routes/admin-roles.ts +296 -0
- package/templates/docker/src/api/routes/admin-router.ts +120 -0
- package/templates/docker/src/api/routes/admin-sandbox.ts +417 -0
- package/templates/docker/src/api/routes/admin-scim.ts +262 -0
- package/templates/docker/src/api/routes/admin-sso.ts +545 -0
- package/templates/docker/src/api/routes/admin-suggestions.ts +176 -0
- package/templates/docker/src/api/routes/admin-usage.ts +310 -0
- package/templates/docker/src/api/routes/admin.ts +4156 -898
- package/templates/docker/src/api/routes/auth-preamble.ts +105 -0
- package/templates/docker/src/api/routes/billing.ts +397 -0
- package/templates/docker/src/api/routes/chat.ts +597 -334
- package/templates/docker/src/api/routes/conversations.ts +987 -132
- package/templates/docker/src/api/routes/demo.ts +673 -0
- package/templates/docker/src/api/routes/discord.ts +274 -0
- package/templates/docker/src/api/routes/ee-error-handler.ts +32 -0
- package/templates/docker/src/api/routes/health.ts +129 -14
- package/templates/docker/src/api/routes/middleware.ts +244 -0
- package/templates/docker/src/api/routes/onboarding-emails.ts +134 -0
- package/templates/docker/src/api/routes/onboarding.ts +1109 -0
- package/templates/docker/src/api/routes/openapi.ts +184 -1597
- package/templates/docker/src/api/routes/platform-admin.ts +760 -0
- package/templates/docker/src/api/routes/platform-backups.ts +436 -0
- package/templates/docker/src/api/routes/platform-domains.ts +235 -0
- package/templates/docker/src/api/routes/platform-residency.ts +257 -0
- package/templates/docker/src/api/routes/platform-sla.ts +379 -0
- package/templates/docker/src/api/routes/prompts.ts +221 -0
- package/templates/docker/src/api/routes/public-branding.ts +106 -0
- package/templates/docker/src/api/routes/query.ts +330 -219
- package/templates/docker/src/api/routes/scheduled-tasks.ts +393 -297
- package/templates/docker/src/api/routes/semantic.ts +179 -0
- package/templates/docker/src/api/routes/sessions.ts +210 -0
- package/templates/docker/src/api/routes/shared-domains.ts +98 -0
- package/templates/docker/src/api/routes/shared-schemas.ts +139 -0
- package/templates/docker/src/api/routes/slack.ts +209 -52
- package/templates/docker/src/api/routes/suggestions.ts +233 -0
- package/templates/docker/src/api/routes/tables.ts +67 -0
- package/templates/docker/src/api/routes/teams.ts +222 -0
- package/templates/docker/src/api/routes/validate-sql.ts +188 -0
- package/templates/docker/src/api/routes/validation-hook.ts +62 -0
- package/templates/docker/src/api/routes/widget-loader.ts +356 -0
- package/templates/docker/src/api/routes/widget.ts +428 -0
- package/templates/docker/src/api/routes/wizard.ts +852 -0
- package/templates/docker/src/api/server.ts +187 -69
- package/templates/docker/src/app/error.tsx +5 -2
- package/templates/docker/src/app/globals.css +1 -1
- package/templates/docker/src/app/layout.tsx +7 -2
- package/templates/docker/src/app/page.tsx +39 -5
- package/templates/docker/src/components/data-table/data-table-column-header.tsx +99 -0
- package/templates/docker/src/components/data-table/data-table-date-filter.tsx +225 -0
- package/templates/docker/src/components/data-table/data-table-expandable.tsx +125 -0
- package/templates/docker/src/components/data-table/data-table-faceted-filter.tsx +189 -0
- package/templates/docker/src/components/data-table/data-table-pagination.tsx +112 -0
- package/templates/docker/src/components/data-table/data-table-range-filter.tsx +122 -0
- package/templates/docker/src/components/data-table/data-table-slider-filter.tsx +256 -0
- package/templates/docker/src/components/data-table/data-table-sort-list.tsx +407 -0
- package/templates/docker/src/components/data-table/data-table-toolbar.tsx +149 -0
- package/templates/docker/src/components/data-table/data-table-view-options.tsx +89 -0
- package/templates/docker/src/components/data-table/data-table.tsx +105 -0
- package/templates/docker/src/components/form-dialog.tsx +135 -0
- package/templates/docker/src/components/ui/accordion.tsx +66 -0
- package/templates/docker/src/components/ui/calendar.tsx +220 -0
- package/templates/docker/src/components/ui/checkbox.tsx +32 -0
- package/templates/docker/src/components/ui/faceted.tsx +283 -0
- package/templates/docker/src/components/ui/form.tsx +167 -0
- package/templates/docker/src/components/ui/label.tsx +24 -0
- package/templates/docker/src/components/ui/popover.tsx +89 -0
- package/templates/docker/src/components/ui/progress.tsx +31 -0
- package/templates/docker/src/components/ui/scroll-area.tsx +6 -2
- package/templates/docker/src/components/ui/slider.tsx +63 -0
- package/templates/docker/src/components/ui/sortable.tsx +581 -0
- package/templates/docker/src/components/ui/switch.tsx +35 -0
- package/templates/docker/src/components/ui/textarea.tsx +18 -0
- package/templates/docker/src/config/data-table.ts +82 -0
- package/templates/docker/src/env-check.ts +74 -0
- package/templates/docker/src/hooks/use-callback-ref.ts +27 -0
- package/templates/docker/src/hooks/use-data-table.ts +316 -0
- package/templates/docker/src/hooks/use-debounced-callback.ts +28 -0
- package/templates/docker/src/lib/action-types.ts +7 -41
- package/templates/docker/src/lib/agent-query.ts +4 -2
- package/templates/docker/src/lib/agent.ts +363 -31
- package/templates/docker/src/lib/auth/admin-permissions.ts +38 -0
- package/templates/docker/src/lib/auth/audit.ts +19 -4
- package/templates/docker/src/lib/auth/byot.ts +3 -3
- package/templates/docker/src/lib/auth/client.ts +33 -3
- package/templates/docker/src/lib/auth/detect.ts +29 -8
- package/templates/docker/src/lib/auth/managed.ts +104 -14
- package/templates/docker/src/lib/auth/middleware.ts +53 -6
- package/templates/docker/src/lib/auth/migrate.ts +140 -15
- package/templates/docker/src/lib/auth/oauth-state.ts +123 -0
- package/templates/docker/src/lib/auth/org-permissions.ts +55 -0
- package/templates/docker/src/lib/auth/permissions.ts +26 -19
- package/templates/docker/src/lib/auth/server.ts +355 -9
- package/templates/docker/src/lib/auth/simple-key.ts +3 -3
- package/templates/docker/src/lib/auth/types.ts +15 -21
- package/templates/docker/src/lib/billing/enforcement.ts +368 -0
- package/templates/docker/src/lib/billing/plans.ts +155 -0
- package/templates/docker/src/lib/cache/index.ts +92 -0
- package/templates/docker/src/lib/cache/keys.ts +30 -0
- package/templates/docker/src/lib/cache/lru.ts +79 -0
- package/templates/docker/src/lib/cache/types.ts +31 -0
- package/templates/docker/src/lib/compose-refs.ts +62 -0
- package/templates/docker/src/lib/config.ts +563 -11
- package/templates/docker/src/lib/connection-types.ts +9 -0
- package/templates/docker/src/lib/conversation-types.ts +1 -25
- package/templates/docker/src/lib/conversations.ts +345 -14
- package/templates/docker/src/lib/data-table.ts +61 -0
- package/templates/docker/src/lib/db/connection.ts +793 -39
- package/templates/docker/src/lib/db/internal.ts +985 -139
- package/templates/docker/src/lib/db/migrate.ts +295 -0
- package/templates/docker/src/lib/db/migrations/0000_baseline.sql +703 -0
- package/templates/docker/src/lib/db/migrations/0001_teams_installations.sql +14 -0
- package/templates/docker/src/lib/db/migrations/0002_discord_installations.sql +14 -0
- package/templates/docker/src/lib/db/migrations/0003_telegram_installations.sql +15 -0
- package/templates/docker/src/lib/db/migrations/0004_sandbox_credentials.sql +18 -0
- package/templates/docker/src/lib/db/migrations/0005_oauth_state.sql +16 -0
- package/templates/docker/src/lib/db/migrations/0006_byot_credentials.sql +14 -0
- package/templates/docker/src/lib/db/migrations/0007_gchat_installations.sql +15 -0
- package/templates/docker/src/lib/db/migrations/0008_github_installations.sql +14 -0
- package/templates/docker/src/lib/db/migrations/0009_linear_installations.sql +15 -0
- package/templates/docker/src/lib/db/migrations/0010_whatsapp_installations.sql +14 -0
- package/templates/docker/src/lib/db/migrations/0011_email_installations.sql +16 -0
- package/templates/docker/src/lib/db/migrations/0012_region_migrations.sql +25 -0
- package/templates/docker/src/lib/db/schema.ts +1120 -0
- package/templates/docker/src/lib/db/source-rate-limit.ts +89 -139
- package/templates/docker/src/lib/demo.ts +308 -0
- package/templates/docker/src/lib/discord/store.ts +225 -0
- package/templates/docker/src/lib/effect/ai.ts +243 -0
- package/templates/docker/src/lib/effect/errors.ts +234 -0
- package/templates/docker/src/lib/effect/hono.ts +454 -0
- package/templates/docker/src/lib/effect/index.ts +137 -0
- package/templates/docker/src/lib/effect/layers.ts +496 -0
- package/templates/docker/src/lib/effect/services.ts +776 -0
- package/templates/docker/src/lib/effect/sql.ts +178 -0
- package/templates/docker/src/lib/effect/toolkit.ts +123 -0
- package/templates/docker/src/lib/email/delivery.ts +232 -0
- package/templates/docker/src/lib/email/engine.ts +349 -0
- package/templates/docker/src/lib/email/hooks.ts +107 -0
- package/templates/docker/src/lib/email/index.ts +16 -0
- package/templates/docker/src/lib/email/scheduler.ts +72 -0
- package/templates/docker/src/lib/email/sequence.ts +73 -0
- package/templates/docker/src/lib/email/store.ts +163 -0
- package/templates/docker/src/lib/email/templates.ts +215 -0
- package/templates/docker/src/lib/format.ts +67 -0
- package/templates/docker/src/lib/gchat/store.ts +202 -0
- package/templates/docker/src/lib/github/store.ts +197 -0
- package/templates/docker/src/lib/id.ts +29 -0
- package/templates/docker/src/lib/integrations/types.ts +166 -0
- package/templates/docker/src/lib/learn/pattern-analyzer.ts +224 -0
- package/templates/docker/src/lib/learn/pattern-cache.ts +229 -0
- package/templates/docker/src/lib/learn/pattern-proposer.ts +87 -0
- package/templates/docker/src/lib/learn/suggestion-helpers.ts +34 -0
- package/templates/docker/src/lib/learn/suggestions.ts +139 -0
- package/templates/docker/src/lib/linear/store.ts +200 -0
- package/templates/docker/src/lib/logger.ts +35 -3
- package/templates/docker/src/lib/metering.ts +272 -0
- package/templates/docker/src/lib/parsers.ts +99 -0
- package/templates/docker/src/lib/plugins/hooks.ts +13 -11
- package/templates/docker/src/lib/plugins/index.ts +3 -1
- package/templates/docker/src/lib/plugins/registry.ts +58 -6
- package/templates/docker/src/lib/plugins/settings.ts +147 -0
- package/templates/docker/src/lib/plugins/wiring.ts +6 -9
- package/templates/docker/src/lib/profiler.ts +1665 -0
- package/templates/docker/src/lib/providers.ts +188 -13
- package/templates/docker/src/lib/rls.ts +172 -60
- package/templates/docker/src/lib/sandbox/credentials.ts +206 -0
- package/templates/docker/src/lib/sandbox/validate.ts +179 -0
- package/templates/docker/src/lib/scheduled-task-types.ts +26 -94
- package/templates/docker/src/lib/scheduled-tasks.ts +174 -34
- package/templates/docker/src/lib/scheduler/delivery.ts +248 -150
- package/templates/docker/src/lib/scheduler/engine.ts +190 -154
- package/templates/docker/src/lib/scheduler/executor.ts +74 -23
- package/templates/docker/src/lib/scheduler/preview.ts +72 -0
- package/templates/docker/src/lib/security/abuse.ts +463 -0
- package/templates/docker/src/lib/semantic/diff.ts +267 -0
- package/templates/docker/src/lib/semantic/entities.ts +167 -0
- package/templates/docker/src/lib/semantic/files.ts +283 -0
- package/templates/docker/src/lib/semantic/index.ts +27 -0
- package/templates/docker/src/lib/{semantic-index.ts → semantic/search.ts} +80 -9
- package/templates/docker/src/lib/semantic/sync.ts +581 -0
- package/templates/docker/src/lib/{semantic.ts → semantic/whitelist.ts} +189 -3
- package/templates/docker/src/lib/settings.ts +817 -0
- package/templates/docker/src/lib/sidecar-types.ts +13 -0
- package/templates/docker/src/lib/slack/store.ts +134 -25
- package/templates/docker/src/lib/startup.ts +528 -362
- package/templates/docker/src/lib/teams/store.ts +216 -0
- package/templates/docker/src/lib/telegram/store.ts +202 -0
- package/templates/docker/src/lib/telemetry.ts +40 -0
- package/templates/docker/src/lib/tools/actions/audit.ts +8 -5
- package/templates/docker/src/lib/tools/actions/email.ts +3 -1
- package/templates/docker/src/lib/tools/actions/handler.ts +276 -93
- package/templates/docker/src/lib/tools/actions/jira.ts +2 -2
- package/templates/docker/src/lib/tools/backends/detect.ts +16 -0
- package/templates/docker/src/lib/tools/backends/index.ts +11 -0
- package/templates/docker/src/lib/tools/backends/nsjail.ts +213 -0
- package/templates/docker/src/lib/tools/backends/shared.ts +103 -0
- package/templates/docker/src/lib/tools/backends/types.ts +26 -0
- package/templates/docker/src/lib/tools/explore-nsjail.ts +7 -228
- package/templates/docker/src/lib/tools/explore-sandbox.ts +4 -29
- package/templates/docker/src/lib/tools/explore-sidecar.ts +18 -2
- package/templates/docker/src/lib/tools/explore.ts +246 -54
- package/templates/docker/src/lib/tools/index.ts +17 -0
- package/templates/docker/src/lib/tools/python-nsjail.ts +11 -139
- package/templates/docker/src/lib/tools/python-sandbox.ts +9 -132
- package/templates/docker/src/lib/tools/python-sidecar.ts +184 -3
- package/templates/docker/src/lib/tools/python-stream.ts +33 -0
- package/templates/docker/src/lib/tools/python-wrapper.ts +129 -0
- package/templates/docker/src/lib/tools/python.ts +115 -15
- package/templates/docker/src/lib/tools/registry.ts +14 -2
- package/templates/docker/src/lib/tools/sql.ts +778 -362
- package/templates/docker/src/lib/tracing.ts +16 -0
- package/templates/docker/src/lib/whatsapp/store.ts +198 -0
- package/templates/docker/src/lib/workspace.ts +89 -0
- package/templates/docker/src/progress.ts +121 -0
- package/templates/docker/src/types/data-table.ts +48 -0
- package/templates/docker/src/ui/atlas-chat-reexport.ts +3 -0
- package/templates/docker/src/ui/components/actions/action-approval-card.tsx +26 -19
- package/templates/docker/src/ui/components/actions/action-status-badge.tsx +3 -3
- package/templates/docker/src/ui/components/admin/admin-layout.tsx +57 -39
- package/templates/docker/src/ui/components/admin/admin-sidebar.tsx +213 -35
- package/templates/docker/src/ui/components/admin/delivery-status-badge.tsx +53 -0
- package/templates/docker/src/ui/components/admin/empty-state.tsx +27 -6
- package/templates/docker/src/ui/components/admin/entity-detail.tsx +3 -52
- package/templates/docker/src/ui/components/admin/error-banner.tsx +2 -2
- package/templates/docker/src/ui/components/admin/feature-disabled.tsx +28 -5
- package/templates/docker/src/ui/components/admin-content-wrapper.tsx +87 -0
- package/templates/docker/src/ui/components/atlas-chat.tsx +449 -166
- package/templates/docker/src/ui/components/branding-head.tsx +41 -0
- package/templates/docker/src/ui/components/chart/chart-detection.ts +62 -5
- package/templates/docker/src/ui/components/chart/result-chart.tsx +316 -125
- package/templates/docker/src/ui/components/chat/api-key-bar.tsx +4 -4
- package/templates/docker/src/ui/components/chat/data-table.tsx +45 -4
- package/templates/docker/src/ui/components/chat/error-banner.tsx +86 -5
- package/templates/docker/src/ui/components/chat/follow-up-chips.tsx +29 -0
- package/templates/docker/src/ui/components/chat/markdown.tsx +24 -0
- package/templates/docker/src/ui/components/chat/prompt-library.tsx +206 -0
- package/templates/docker/src/ui/components/chat/python-result-card.tsx +106 -78
- package/templates/docker/src/ui/components/chat/result-card-base.tsx +101 -0
- package/templates/docker/src/ui/components/chat/share-dialog.tsx +377 -0
- package/templates/docker/src/ui/components/chat/sql-result-card.tsx +94 -73
- package/templates/docker/src/ui/components/chat/suggestion-chips.tsx +46 -0
- package/templates/docker/src/ui/components/chat/tool-part.tsx +16 -4
- package/templates/docker/src/ui/components/conversations/conversation-item.tsx +48 -17
- package/templates/docker/src/ui/components/conversations/conversation-list.tsx +38 -24
- package/templates/docker/src/ui/components/conversations/conversation-sidebar.tsx +66 -7
- package/templates/docker/src/ui/components/conversations/delete-confirmation.tsx +9 -2
- package/templates/docker/src/ui/components/error-boundary.tsx +66 -0
- package/templates/docker/src/ui/components/notebook/delete-cell-dialog.tsx +48 -0
- package/templates/docker/src/ui/components/notebook/fork-branch-selector.tsx +68 -0
- package/templates/docker/src/ui/components/notebook/notebook-cell-input.tsx +76 -0
- package/templates/docker/src/ui/components/notebook/notebook-cell-output.tsx +58 -0
- package/templates/docker/src/ui/components/notebook/notebook-cell-toolbar.tsx +91 -0
- package/templates/docker/src/ui/components/notebook/notebook-cell.tsx +119 -0
- package/templates/docker/src/ui/components/notebook/notebook-empty-state.tsx +19 -0
- package/templates/docker/src/ui/components/notebook/notebook-export.ts +287 -0
- package/templates/docker/src/ui/components/notebook/notebook-input-bar.tsx +49 -0
- package/templates/docker/src/ui/components/notebook/notebook-shell.tsx +266 -0
- package/templates/docker/src/ui/components/notebook/notebook-text-cell.tsx +152 -0
- package/templates/docker/src/ui/components/notebook/types.ts +39 -0
- package/templates/docker/src/ui/components/notebook/use-keyboard-nav.ts +109 -0
- package/templates/docker/src/ui/components/notebook/use-notebook.ts +684 -0
- package/templates/docker/src/ui/components/org-switcher.tsx +111 -0
- package/templates/docker/src/ui/components/region-picker.tsx +103 -0
- package/templates/docker/src/ui/components/schema-explorer/schema-explorer.tsx +522 -0
- package/templates/docker/src/ui/components/social-icons.tsx +26 -0
- package/templates/docker/src/ui/components/tour/guided-tour.tsx +81 -0
- package/templates/docker/src/ui/components/tour/index.ts +5 -0
- package/templates/docker/src/ui/components/tour/nav-bar.tsx +100 -0
- package/templates/docker/src/ui/components/tour/tour-overlay.tsx +298 -0
- package/templates/docker/src/ui/components/tour/tour-steps.ts +43 -0
- package/templates/docker/src/ui/components/tour/types.ts +21 -0
- package/templates/docker/src/ui/components/tour/use-tour.ts +193 -0
- package/templates/docker/src/ui/context-reexport.ts +3 -0
- package/templates/docker/src/ui/hooks/theme-init-script.ts +17 -0
- package/templates/docker/src/ui/hooks/use-admin-fetch.ts +38 -30
- package/templates/docker/src/ui/hooks/use-admin-mutation.ts +188 -0
- package/templates/docker/src/ui/hooks/use-atlas-transport.ts +225 -0
- package/templates/docker/src/ui/hooks/use-branding.ts +68 -0
- package/templates/docker/src/ui/hooks/use-conversations.ts +106 -83
- package/templates/docker/src/ui/hooks/use-dark-mode.ts +134 -10
- package/templates/docker/src/ui/hooks/use-deploy-mode.ts +36 -0
- package/templates/docker/src/ui/hooks/use-platform-admin-guard.ts +49 -0
- package/templates/docker/src/ui/lib/action-types.ts +11 -63
- package/templates/docker/src/ui/lib/admin-schemas.ts +744 -0
- package/templates/docker/src/ui/lib/fetch-client.ts +84 -0
- package/templates/docker/src/ui/lib/fetch-error.ts +54 -0
- package/templates/docker/src/ui/lib/helpers.ts +94 -1
- package/templates/docker/src/ui/lib/types.ts +149 -140
- package/templates/docker/tsconfig.json +4 -2
- package/templates/nextjs-standalone/bin/__tests__/duckdb-ingest.test.ts +17 -14
- package/templates/nextjs-standalone/bin/__tests__/failure-threshold.test.ts +148 -0
- package/templates/nextjs-standalone/bin/__tests__/fatal-error-propagation.test.ts +267 -0
- package/templates/nextjs-standalone/bin/__tests__/profiler-heuristics.test.ts +5 -5
- package/templates/nextjs-standalone/bin/__tests__/schema-drift.test.ts +39 -0
- package/templates/nextjs-standalone/bin/atlas.ts +981 -1819
- package/templates/nextjs-standalone/bin/benchmark.ts +14 -16
- package/templates/nextjs-standalone/bin/enrich.ts +7 -2
- package/templates/nextjs-standalone/brand.css +13 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/catalog.yml +222 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/entities/alerts.yml +195 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/entities/assets.yml +191 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/entities/compliance_assessments.yml +170 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/entities/incidents.yml +219 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/entities/organizations.yml +136 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/entities/plans.yml +114 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/entities/remediation_actions.yml +212 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/entities/scan_results.yml +215 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/entities/scans.yml +180 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/entities/subscriptions.yml +184 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/entities/users.yml +140 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/entities/vulnerabilities.yml +154 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/glossary.yml +207 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/metrics/business.yml +148 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/metrics/compliance.yml +138 -0
- package/templates/nextjs-standalone/data/cybersec-semantic/metrics/security.yml +181 -0
- package/templates/nextjs-standalone/data/cybersec.sql +8 -8
- package/templates/nextjs-standalone/data/demo.sql +3 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/catalog.yml +221 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/categories.yml +91 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/customers.yml +133 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/email_campaigns.yml +119 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/inventory_levels.yml +153 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/order_items.yml +159 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/orders.yml +199 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/payments.yml +140 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/product_reviews.yml +155 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/products.yml +178 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/promotions.yml +171 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/returns.yml +144 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/sellers.yml +124 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/entities/shipments.yml +159 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/glossary.yml +193 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/metrics/customers.yml +116 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/metrics/operations.yml +131 -0
- package/templates/nextjs-standalone/data/ecommerce-semantic/metrics/revenue.yml +120 -0
- package/templates/nextjs-standalone/docs/deploy.md +2 -1
- package/templates/nextjs-standalone/ee/src/__mocks__/internal.ts +170 -0
- package/templates/nextjs-standalone/ee/src/audit/purge-scheduler.ts +113 -0
- package/templates/nextjs-standalone/ee/src/audit/retention.ts +467 -0
- package/templates/nextjs-standalone/ee/src/auth/ip-allowlist.ts +367 -0
- package/templates/nextjs-standalone/ee/src/auth/roles.ts +562 -0
- package/templates/nextjs-standalone/ee/src/auth/scim.ts +343 -0
- package/templates/nextjs-standalone/ee/src/auth/sso.ts +538 -0
- package/templates/nextjs-standalone/ee/src/backups/engine.ts +355 -0
- package/templates/nextjs-standalone/ee/src/backups/index.ts +26 -0
- package/templates/nextjs-standalone/ee/src/backups/restore.ts +169 -0
- package/templates/nextjs-standalone/ee/src/backups/scheduler.ts +153 -0
- package/templates/nextjs-standalone/ee/src/backups/verify.ts +124 -0
- package/templates/nextjs-standalone/ee/src/branding/white-label.ts +228 -0
- package/templates/nextjs-standalone/ee/src/compliance/masking.ts +477 -0
- package/templates/nextjs-standalone/ee/src/compliance/patterns.ts +16 -0
- package/templates/nextjs-standalone/ee/src/compliance/pii-detection.ts +217 -0
- package/templates/nextjs-standalone/ee/src/compliance/reports.ts +402 -0
- package/templates/nextjs-standalone/ee/src/deploy-mode.ts +37 -0
- package/templates/nextjs-standalone/ee/src/governance/approval.ts +699 -0
- package/templates/nextjs-standalone/ee/src/index.ts +74 -0
- package/templates/nextjs-standalone/ee/src/platform/domains.ts +562 -0
- package/templates/nextjs-standalone/ee/src/platform/model-routing.ts +382 -0
- package/templates/nextjs-standalone/ee/src/platform/residency.ts +265 -0
- package/templates/nextjs-standalone/ee/src/sla/alerting.ts +382 -0
- package/templates/nextjs-standalone/ee/src/sla/index.ts +12 -0
- package/templates/nextjs-standalone/ee/src/sla/metrics.ts +275 -0
- package/templates/nextjs-standalone/ee/src/test-setup.ts +1 -0
- package/templates/nextjs-standalone/next.config.ts +1 -1
- package/templates/nextjs-standalone/package.json +50 -30
- package/templates/nextjs-standalone/src/api/index.ts +336 -24
- package/templates/nextjs-standalone/src/api/routes/actions.ts +443 -176
- package/templates/nextjs-standalone/src/api/routes/admin-abuse.ts +219 -0
- package/templates/nextjs-standalone/src/api/routes/admin-approval.ts +418 -0
- package/templates/nextjs-standalone/src/api/routes/admin-audit-retention.ts +405 -0
- package/templates/nextjs-standalone/src/api/routes/admin-auth.ts +122 -0
- package/templates/nextjs-standalone/src/api/routes/admin-branding.ts +252 -0
- package/templates/nextjs-standalone/src/api/routes/admin-compliance.ts +352 -0
- package/templates/nextjs-standalone/src/api/routes/admin-domains.ts +334 -0
- package/templates/nextjs-standalone/src/api/routes/admin-integrations.ts +2667 -0
- package/templates/nextjs-standalone/src/api/routes/admin-ip-allowlist.ts +261 -0
- package/templates/nextjs-standalone/src/api/routes/admin-learned-patterns.ts +525 -0
- package/templates/nextjs-standalone/src/api/routes/admin-model-config.ts +252 -0
- package/templates/nextjs-standalone/src/api/routes/admin-onboarding-emails.ts +145 -0
- package/templates/nextjs-standalone/src/api/routes/admin-orgs.ts +710 -0
- package/templates/nextjs-standalone/src/api/routes/admin-prompts.ts +694 -0
- package/templates/nextjs-standalone/src/api/routes/admin-residency.ts +570 -0
- package/templates/nextjs-standalone/src/api/routes/admin-roles.ts +296 -0
- package/templates/nextjs-standalone/src/api/routes/admin-router.ts +120 -0
- package/templates/nextjs-standalone/src/api/routes/admin-sandbox.ts +417 -0
- package/templates/nextjs-standalone/src/api/routes/admin-scim.ts +262 -0
- package/templates/nextjs-standalone/src/api/routes/admin-sso.ts +545 -0
- package/templates/nextjs-standalone/src/api/routes/admin-suggestions.ts +176 -0
- package/templates/nextjs-standalone/src/api/routes/admin-usage.ts +310 -0
- package/templates/nextjs-standalone/src/api/routes/admin.ts +4156 -898
- package/templates/nextjs-standalone/src/api/routes/auth-preamble.ts +105 -0
- package/templates/nextjs-standalone/src/api/routes/billing.ts +397 -0
- package/templates/nextjs-standalone/src/api/routes/chat.ts +597 -334
- package/templates/nextjs-standalone/src/api/routes/conversations.ts +987 -132
- package/templates/nextjs-standalone/src/api/routes/demo.ts +673 -0
- package/templates/nextjs-standalone/src/api/routes/discord.ts +274 -0
- package/templates/nextjs-standalone/src/api/routes/ee-error-handler.ts +32 -0
- package/templates/nextjs-standalone/src/api/routes/health.ts +129 -14
- package/templates/nextjs-standalone/src/api/routes/middleware.ts +244 -0
- package/templates/nextjs-standalone/src/api/routes/onboarding-emails.ts +134 -0
- package/templates/nextjs-standalone/src/api/routes/onboarding.ts +1109 -0
- package/templates/nextjs-standalone/src/api/routes/openapi.ts +184 -1597
- package/templates/nextjs-standalone/src/api/routes/platform-admin.ts +760 -0
- package/templates/nextjs-standalone/src/api/routes/platform-backups.ts +436 -0
- package/templates/nextjs-standalone/src/api/routes/platform-domains.ts +235 -0
- package/templates/nextjs-standalone/src/api/routes/platform-residency.ts +257 -0
- package/templates/nextjs-standalone/src/api/routes/platform-sla.ts +379 -0
- package/templates/nextjs-standalone/src/api/routes/prompts.ts +221 -0
- package/templates/nextjs-standalone/src/api/routes/public-branding.ts +106 -0
- package/templates/nextjs-standalone/src/api/routes/query.ts +330 -219
- package/templates/nextjs-standalone/src/api/routes/scheduled-tasks.ts +393 -297
- package/templates/nextjs-standalone/src/api/routes/semantic.ts +179 -0
- package/templates/nextjs-standalone/src/api/routes/sessions.ts +210 -0
- package/templates/nextjs-standalone/src/api/routes/shared-domains.ts +98 -0
- package/templates/nextjs-standalone/src/api/routes/shared-schemas.ts +139 -0
- package/templates/nextjs-standalone/src/api/routes/slack.ts +209 -52
- package/templates/nextjs-standalone/src/api/routes/suggestions.ts +233 -0
- package/templates/nextjs-standalone/src/api/routes/tables.ts +67 -0
- package/templates/nextjs-standalone/src/api/routes/teams.ts +222 -0
- package/templates/nextjs-standalone/src/api/routes/validate-sql.ts +188 -0
- package/templates/nextjs-standalone/src/api/routes/validation-hook.ts +62 -0
- package/templates/nextjs-standalone/src/api/routes/widget-loader.ts +356 -0
- package/templates/nextjs-standalone/src/api/routes/widget.ts +428 -0
- package/templates/nextjs-standalone/src/api/routes/wizard.ts +852 -0
- package/templates/nextjs-standalone/src/api/server.ts +187 -69
- package/templates/nextjs-standalone/src/app/error.tsx +5 -2
- package/templates/nextjs-standalone/src/app/globals.css +1 -1
- package/templates/nextjs-standalone/src/app/layout.tsx +7 -2
- package/templates/nextjs-standalone/src/app/page.tsx +39 -5
- package/templates/nextjs-standalone/src/components/data-table/data-table-column-header.tsx +99 -0
- package/templates/nextjs-standalone/src/components/data-table/data-table-date-filter.tsx +225 -0
- package/templates/nextjs-standalone/src/components/data-table/data-table-expandable.tsx +125 -0
- package/templates/nextjs-standalone/src/components/data-table/data-table-faceted-filter.tsx +189 -0
- package/templates/nextjs-standalone/src/components/data-table/data-table-pagination.tsx +112 -0
- package/templates/nextjs-standalone/src/components/data-table/data-table-range-filter.tsx +122 -0
- package/templates/nextjs-standalone/src/components/data-table/data-table-slider-filter.tsx +256 -0
- package/templates/nextjs-standalone/src/components/data-table/data-table-sort-list.tsx +407 -0
- package/templates/nextjs-standalone/src/components/data-table/data-table-toolbar.tsx +149 -0
- package/templates/nextjs-standalone/src/components/data-table/data-table-view-options.tsx +89 -0
- package/templates/nextjs-standalone/src/components/data-table/data-table.tsx +105 -0
- package/templates/nextjs-standalone/src/components/form-dialog.tsx +135 -0
- package/templates/nextjs-standalone/src/components/ui/accordion.tsx +66 -0
- package/templates/nextjs-standalone/src/components/ui/calendar.tsx +220 -0
- package/templates/nextjs-standalone/src/components/ui/checkbox.tsx +32 -0
- package/templates/nextjs-standalone/src/components/ui/faceted.tsx +283 -0
- package/templates/nextjs-standalone/src/components/ui/form.tsx +167 -0
- package/templates/nextjs-standalone/src/components/ui/label.tsx +24 -0
- package/templates/nextjs-standalone/src/components/ui/popover.tsx +89 -0
- package/templates/nextjs-standalone/src/components/ui/progress.tsx +31 -0
- package/templates/nextjs-standalone/src/components/ui/scroll-area.tsx +6 -2
- package/templates/nextjs-standalone/src/components/ui/slider.tsx +63 -0
- package/templates/nextjs-standalone/src/components/ui/sortable.tsx +581 -0
- package/templates/nextjs-standalone/src/components/ui/switch.tsx +35 -0
- package/templates/nextjs-standalone/src/components/ui/textarea.tsx +18 -0
- package/templates/nextjs-standalone/src/config/data-table.ts +82 -0
- package/templates/nextjs-standalone/src/env-check.ts +74 -0
- package/templates/nextjs-standalone/src/hooks/use-callback-ref.ts +27 -0
- package/templates/nextjs-standalone/src/hooks/use-data-table.ts +316 -0
- package/templates/nextjs-standalone/src/hooks/use-debounced-callback.ts +28 -0
- package/templates/nextjs-standalone/src/lib/action-types.ts +7 -41
- package/templates/nextjs-standalone/src/lib/agent-query.ts +4 -2
- package/templates/nextjs-standalone/src/lib/agent.ts +363 -31
- package/templates/nextjs-standalone/src/lib/api-url.ts +2 -3
- package/templates/nextjs-standalone/src/lib/auth/admin-permissions.ts +38 -0
- package/templates/nextjs-standalone/src/lib/auth/audit.ts +19 -4
- package/templates/nextjs-standalone/src/lib/auth/byot.ts +3 -3
- package/templates/nextjs-standalone/src/lib/auth/detect.ts +29 -8
- package/templates/nextjs-standalone/src/lib/auth/managed.ts +104 -14
- package/templates/nextjs-standalone/src/lib/auth/middleware.ts +53 -6
- package/templates/nextjs-standalone/src/lib/auth/migrate.ts +140 -15
- package/templates/nextjs-standalone/src/lib/auth/oauth-state.ts +123 -0
- package/templates/nextjs-standalone/src/lib/auth/org-permissions.ts +55 -0
- package/templates/nextjs-standalone/src/lib/auth/permissions.ts +26 -19
- package/templates/nextjs-standalone/src/lib/auth/server.ts +355 -9
- package/templates/nextjs-standalone/src/lib/auth/simple-key.ts +3 -3
- package/templates/nextjs-standalone/src/lib/auth/types.ts +15 -21
- package/templates/nextjs-standalone/src/lib/billing/enforcement.ts +368 -0
- package/templates/nextjs-standalone/src/lib/billing/plans.ts +155 -0
- package/templates/nextjs-standalone/src/lib/cache/index.ts +92 -0
- package/templates/nextjs-standalone/src/lib/cache/keys.ts +30 -0
- package/templates/nextjs-standalone/src/lib/cache/lru.ts +79 -0
- package/templates/nextjs-standalone/src/lib/cache/types.ts +31 -0
- package/templates/nextjs-standalone/src/lib/compose-refs.ts +62 -0
- package/templates/nextjs-standalone/src/lib/config.ts +563 -11
- package/templates/nextjs-standalone/src/lib/connection-types.ts +9 -0
- package/templates/nextjs-standalone/src/lib/conversation-types.ts +1 -25
- package/templates/nextjs-standalone/src/lib/conversations.ts +345 -14
- package/templates/nextjs-standalone/src/lib/data-table.ts +61 -0
- package/templates/nextjs-standalone/src/lib/db/connection.ts +793 -39
- package/templates/nextjs-standalone/src/lib/db/internal.ts +985 -139
- package/templates/nextjs-standalone/src/lib/db/migrate.ts +295 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0000_baseline.sql +703 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0001_teams_installations.sql +14 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0002_discord_installations.sql +14 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0003_telegram_installations.sql +15 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0004_sandbox_credentials.sql +18 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0005_oauth_state.sql +16 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0006_byot_credentials.sql +14 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0007_gchat_installations.sql +15 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0008_github_installations.sql +14 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0009_linear_installations.sql +15 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0010_whatsapp_installations.sql +14 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0011_email_installations.sql +16 -0
- package/templates/nextjs-standalone/src/lib/db/migrations/0012_region_migrations.sql +25 -0
- package/templates/nextjs-standalone/src/lib/db/schema.ts +1120 -0
- package/templates/nextjs-standalone/src/lib/db/source-rate-limit.ts +89 -139
- package/templates/nextjs-standalone/src/lib/demo.ts +308 -0
- package/templates/nextjs-standalone/src/lib/discord/store.ts +225 -0
- package/templates/nextjs-standalone/src/lib/effect/ai.ts +243 -0
- package/templates/nextjs-standalone/src/lib/effect/errors.ts +234 -0
- package/templates/nextjs-standalone/src/lib/effect/hono.ts +454 -0
- package/templates/nextjs-standalone/src/lib/effect/index.ts +137 -0
- package/templates/nextjs-standalone/src/lib/effect/layers.ts +496 -0
- package/templates/nextjs-standalone/src/lib/effect/services.ts +776 -0
- package/templates/nextjs-standalone/src/lib/effect/sql.ts +178 -0
- package/templates/nextjs-standalone/src/lib/effect/toolkit.ts +123 -0
- package/templates/nextjs-standalone/src/lib/email/delivery.ts +232 -0
- package/templates/nextjs-standalone/src/lib/email/engine.ts +349 -0
- package/templates/nextjs-standalone/src/lib/email/hooks.ts +107 -0
- package/templates/nextjs-standalone/src/lib/email/index.ts +16 -0
- package/templates/nextjs-standalone/src/lib/email/scheduler.ts +72 -0
- package/templates/nextjs-standalone/src/lib/email/sequence.ts +73 -0
- package/templates/nextjs-standalone/src/lib/email/store.ts +163 -0
- package/templates/nextjs-standalone/src/lib/email/templates.ts +215 -0
- package/templates/nextjs-standalone/src/lib/format.test.ts +117 -0
- package/templates/nextjs-standalone/src/lib/format.ts +67 -0
- package/templates/nextjs-standalone/src/lib/gchat/store.ts +202 -0
- package/templates/nextjs-standalone/src/lib/github/store.ts +197 -0
- package/templates/nextjs-standalone/src/lib/id.ts +29 -0
- package/templates/nextjs-standalone/src/lib/integrations/types.ts +166 -0
- package/templates/nextjs-standalone/src/lib/learn/pattern-analyzer.ts +224 -0
- package/templates/nextjs-standalone/src/lib/learn/pattern-cache.ts +229 -0
- package/templates/nextjs-standalone/src/lib/learn/pattern-proposer.ts +87 -0
- package/templates/nextjs-standalone/src/lib/learn/suggestion-helpers.ts +34 -0
- package/templates/nextjs-standalone/src/lib/learn/suggestions.ts +139 -0
- package/templates/nextjs-standalone/src/lib/linear/store.ts +200 -0
- package/templates/nextjs-standalone/src/lib/logger.ts +35 -3
- package/templates/nextjs-standalone/src/lib/metering.ts +272 -0
- package/templates/nextjs-standalone/src/lib/parsers.ts +99 -0
- package/templates/nextjs-standalone/src/lib/plugins/hooks.ts +13 -11
- package/templates/nextjs-standalone/src/lib/plugins/index.ts +3 -1
- package/templates/nextjs-standalone/src/lib/plugins/registry.ts +58 -6
- package/templates/nextjs-standalone/src/lib/plugins/settings.ts +147 -0
- package/templates/nextjs-standalone/src/lib/plugins/wiring.ts +6 -9
- package/templates/nextjs-standalone/src/lib/profiler.ts +1665 -0
- package/templates/nextjs-standalone/src/lib/providers.ts +188 -13
- package/templates/nextjs-standalone/src/lib/rls.ts +172 -60
- package/templates/nextjs-standalone/src/lib/sandbox/credentials.ts +206 -0
- package/templates/nextjs-standalone/src/lib/sandbox/validate.ts +179 -0
- package/templates/nextjs-standalone/src/lib/scheduled-task-types.ts +26 -94
- package/templates/nextjs-standalone/src/lib/scheduled-tasks.ts +174 -34
- package/templates/nextjs-standalone/src/lib/scheduler/delivery.ts +248 -150
- package/templates/nextjs-standalone/src/lib/scheduler/engine.ts +190 -154
- package/templates/nextjs-standalone/src/lib/scheduler/executor.ts +74 -23
- package/templates/nextjs-standalone/src/lib/scheduler/preview.ts +72 -0
- package/templates/nextjs-standalone/src/lib/security/abuse.ts +463 -0
- package/templates/nextjs-standalone/src/lib/semantic/diff.ts +267 -0
- package/templates/nextjs-standalone/src/lib/semantic/entities.ts +167 -0
- package/templates/nextjs-standalone/src/lib/semantic/files.ts +283 -0
- package/templates/nextjs-standalone/src/lib/semantic/index.ts +27 -0
- package/templates/nextjs-standalone/src/lib/{semantic-index.ts → semantic/search.ts} +80 -9
- package/templates/nextjs-standalone/src/lib/semantic/sync.ts +581 -0
- package/templates/nextjs-standalone/src/lib/{semantic.ts → semantic/whitelist.ts} +189 -3
- package/templates/nextjs-standalone/src/lib/settings.ts +817 -0
- package/templates/nextjs-standalone/src/lib/sidecar-types.ts +13 -0
- package/templates/nextjs-standalone/src/lib/slack/store.ts +134 -25
- package/templates/nextjs-standalone/src/lib/startup.ts +528 -362
- package/templates/nextjs-standalone/src/lib/teams/store.ts +216 -0
- package/templates/nextjs-standalone/src/lib/telegram/store.ts +202 -0
- package/templates/nextjs-standalone/src/lib/telemetry.ts +40 -0
- package/templates/nextjs-standalone/src/lib/tools/actions/audit.ts +8 -5
- package/templates/nextjs-standalone/src/lib/tools/actions/email.ts +3 -1
- package/templates/nextjs-standalone/src/lib/tools/actions/handler.ts +276 -93
- package/templates/nextjs-standalone/src/lib/tools/actions/jira.ts +2 -2
- package/templates/nextjs-standalone/src/lib/tools/backends/detect.ts +16 -0
- package/templates/nextjs-standalone/src/lib/tools/backends/index.ts +11 -0
- package/templates/nextjs-standalone/src/lib/tools/backends/nsjail.ts +213 -0
- package/templates/nextjs-standalone/src/lib/tools/backends/shared.ts +103 -0
- package/templates/nextjs-standalone/src/lib/tools/backends/types.ts +26 -0
- package/templates/nextjs-standalone/src/lib/tools/explore-nsjail.ts +7 -228
- package/templates/nextjs-standalone/src/lib/tools/explore-sandbox.ts +4 -29
- package/templates/nextjs-standalone/src/lib/tools/explore-sidecar.ts +18 -2
- package/templates/nextjs-standalone/src/lib/tools/explore.ts +246 -54
- package/templates/nextjs-standalone/src/lib/tools/index.ts +17 -0
- package/templates/nextjs-standalone/src/lib/tools/python-nsjail.ts +11 -139
- package/templates/nextjs-standalone/src/lib/tools/python-sandbox.ts +9 -132
- package/templates/nextjs-standalone/src/lib/tools/python-sidecar.ts +184 -3
- package/templates/nextjs-standalone/src/lib/tools/python-stream.ts +33 -0
- package/templates/nextjs-standalone/src/lib/tools/python-wrapper.ts +129 -0
- package/templates/nextjs-standalone/src/lib/tools/python.ts +115 -15
- package/templates/nextjs-standalone/src/lib/tools/registry.ts +14 -2
- package/templates/nextjs-standalone/src/lib/tools/sql.ts +778 -362
- package/templates/nextjs-standalone/src/lib/tracing.ts +16 -0
- package/templates/nextjs-standalone/src/lib/whatsapp/store.ts +198 -0
- package/templates/nextjs-standalone/src/lib/workspace.ts +89 -0
- package/templates/nextjs-standalone/src/progress.ts +121 -0
- package/templates/nextjs-standalone/src/types/data-table.ts +48 -0
- package/templates/nextjs-standalone/src/ui/atlas-chat-reexport.ts +3 -0
- package/templates/nextjs-standalone/src/ui/components/actions/action-approval-card.tsx +26 -19
- package/templates/nextjs-standalone/src/ui/components/actions/action-status-badge.tsx +3 -3
- package/templates/nextjs-standalone/src/ui/components/admin/admin-layout.tsx +57 -39
- package/templates/nextjs-standalone/src/ui/components/admin/admin-sidebar.tsx +213 -35
- package/templates/nextjs-standalone/src/ui/components/admin/delivery-status-badge.tsx +53 -0
- package/templates/nextjs-standalone/src/ui/components/admin/empty-state.tsx +27 -6
- package/templates/nextjs-standalone/src/ui/components/admin/entity-detail.tsx +3 -52
- package/templates/nextjs-standalone/src/ui/components/admin/error-banner.tsx +2 -2
- package/templates/nextjs-standalone/src/ui/components/admin/feature-disabled.tsx +28 -5
- package/templates/nextjs-standalone/src/ui/components/admin-content-wrapper.tsx +87 -0
- package/templates/nextjs-standalone/src/ui/components/atlas-chat.tsx +449 -166
- package/templates/nextjs-standalone/src/ui/components/branding-head.tsx +41 -0
- package/templates/nextjs-standalone/src/ui/components/chart/chart-detection.ts +62 -5
- package/templates/nextjs-standalone/src/ui/components/chart/result-chart.tsx +316 -125
- package/templates/nextjs-standalone/src/ui/components/chat/api-key-bar.tsx +4 -4
- package/templates/nextjs-standalone/src/ui/components/chat/data-table.tsx +45 -4
- package/templates/nextjs-standalone/src/ui/components/chat/error-banner.tsx +86 -5
- package/templates/nextjs-standalone/src/ui/components/chat/follow-up-chips.tsx +29 -0
- package/templates/nextjs-standalone/src/ui/components/chat/markdown.tsx +24 -0
- package/templates/nextjs-standalone/src/ui/components/chat/prompt-library.tsx +206 -0
- package/templates/nextjs-standalone/src/ui/components/chat/python-result-card.tsx +106 -78
- package/templates/nextjs-standalone/src/ui/components/chat/result-card-base.tsx +101 -0
- package/templates/nextjs-standalone/src/ui/components/chat/share-dialog.tsx +377 -0
- package/templates/nextjs-standalone/src/ui/components/chat/sql-result-card.tsx +94 -73
- package/templates/nextjs-standalone/src/ui/components/chat/suggestion-chips.tsx +46 -0
- package/templates/nextjs-standalone/src/ui/components/chat/tool-part.tsx +16 -4
- package/templates/nextjs-standalone/src/ui/components/conversations/conversation-item.tsx +48 -17
- package/templates/nextjs-standalone/src/ui/components/conversations/conversation-list.tsx +38 -24
- package/templates/nextjs-standalone/src/ui/components/conversations/conversation-sidebar.tsx +66 -7
- package/templates/nextjs-standalone/src/ui/components/conversations/delete-confirmation.tsx +9 -2
- package/templates/nextjs-standalone/src/ui/components/error-boundary.tsx +66 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/delete-cell-dialog.tsx +48 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/fork-branch-selector.tsx +68 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/notebook-cell-input.tsx +76 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/notebook-cell-output.tsx +58 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/notebook-cell-toolbar.tsx +91 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/notebook-cell.tsx +119 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/notebook-empty-state.tsx +19 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/notebook-export.ts +287 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/notebook-input-bar.tsx +49 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/notebook-shell.tsx +266 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/notebook-text-cell.tsx +152 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/types.ts +39 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/use-keyboard-nav.ts +109 -0
- package/templates/nextjs-standalone/src/ui/components/notebook/use-notebook.ts +684 -0
- package/templates/nextjs-standalone/src/ui/components/org-switcher.tsx +111 -0
- package/templates/nextjs-standalone/src/ui/components/region-picker.tsx +103 -0
- package/templates/nextjs-standalone/src/ui/components/schema-explorer/schema-explorer.tsx +522 -0
- package/templates/nextjs-standalone/src/ui/components/social-icons.tsx +26 -0
- package/templates/nextjs-standalone/src/ui/components/tour/guided-tour.tsx +81 -0
- package/templates/nextjs-standalone/src/ui/components/tour/index.ts +5 -0
- package/templates/nextjs-standalone/src/ui/components/tour/nav-bar.tsx +100 -0
- package/templates/nextjs-standalone/src/ui/components/tour/tour-overlay.tsx +298 -0
- package/templates/nextjs-standalone/src/ui/components/tour/tour-steps.ts +43 -0
- package/templates/nextjs-standalone/src/ui/components/tour/types.ts +21 -0
- package/templates/nextjs-standalone/src/ui/components/tour/use-tour.ts +193 -0
- package/templates/nextjs-standalone/src/ui/context-reexport.ts +3 -0
- package/templates/nextjs-standalone/src/ui/hooks/theme-init-script.ts +17 -0
- package/templates/nextjs-standalone/src/ui/hooks/use-admin-fetch.ts +38 -30
- package/templates/nextjs-standalone/src/ui/hooks/use-admin-mutation.ts +188 -0
- package/templates/nextjs-standalone/src/ui/hooks/use-atlas-transport.ts +225 -0
- package/templates/nextjs-standalone/src/ui/hooks/use-branding.ts +68 -0
- package/templates/nextjs-standalone/src/ui/hooks/use-conversations.ts +106 -83
- package/templates/nextjs-standalone/src/ui/hooks/use-dark-mode.ts +134 -10
- package/templates/nextjs-standalone/src/ui/hooks/use-deploy-mode.ts +36 -0
- package/templates/nextjs-standalone/src/ui/hooks/use-platform-admin-guard.ts +49 -0
- package/templates/nextjs-standalone/src/ui/lib/action-types.ts +11 -63
- package/templates/nextjs-standalone/src/ui/lib/admin-schemas.ts +744 -0
- package/templates/nextjs-standalone/src/ui/lib/fetch-client.ts +84 -0
- package/templates/nextjs-standalone/src/ui/lib/fetch-error.ts +54 -0
- package/templates/nextjs-standalone/src/ui/lib/helpers.ts +94 -1
- package/templates/nextjs-standalone/src/ui/lib/types.ts +149 -140
- package/templates/nextjs-standalone/tsconfig.json +3 -2
- package/templates/docker/src/api/__tests__/actions.test.ts +0 -683
- package/templates/docker/src/api/__tests__/admin.test.ts +0 -820
- package/templates/docker/src/api/__tests__/auth.test.ts +0 -165
- package/templates/docker/src/api/__tests__/chat.test.ts +0 -376
- package/templates/docker/src/api/__tests__/conversations.test.ts +0 -555
- package/templates/docker/src/api/__tests__/cors.test.ts +0 -135
- package/templates/docker/src/api/__tests__/health-plugin.test.ts +0 -176
- package/templates/docker/src/api/__tests__/health.test.ts +0 -283
- package/templates/docker/src/api/__tests__/query.test.ts +0 -891
- package/templates/docker/src/api/__tests__/scheduled-tasks.test.ts +0 -601
- package/templates/docker/src/api/__tests__/slack.test.ts +0 -847
- package/templates/docker/src/lib/__tests__/agent-cache.test.ts +0 -439
- package/templates/docker/src/lib/__tests__/agent-dialect.test.ts +0 -131
- package/templates/docker/src/lib/__tests__/agent-health-annotations.test.ts +0 -166
- package/templates/docker/src/lib/__tests__/agent-integration.test.ts +0 -516
- package/templates/docker/src/lib/__tests__/config-actions.test.ts +0 -166
- package/templates/docker/src/lib/__tests__/config.test.ts +0 -1113
- package/templates/docker/src/lib/__tests__/conversations.test.ts +0 -589
- package/templates/docker/src/lib/__tests__/errors.test.ts +0 -256
- package/templates/docker/src/lib/__tests__/logger.test.ts +0 -200
- package/templates/docker/src/lib/__tests__/plugin-aware-validation.test.ts +0 -321
- package/templates/docker/src/lib/__tests__/providers.test.ts +0 -130
- package/templates/docker/src/lib/__tests__/rls.test.ts +0 -435
- package/templates/docker/src/lib/__tests__/scheduled-task-types.test.ts +0 -124
- package/templates/docker/src/lib/__tests__/scheduled-tasks.test.ts +0 -550
- package/templates/docker/src/lib/__tests__/semantic-index.test.ts +0 -547
- package/templates/docker/src/lib/__tests__/semantic-multisource.test.ts +0 -544
- package/templates/docker/src/lib/__tests__/semantic.test.ts +0 -363
- package/templates/docker/src/lib/__tests__/startup-actions.test.ts +0 -461
- package/templates/docker/src/lib/__tests__/startup-first-run.test.ts +0 -429
- package/templates/docker/src/lib/__tests__/startup.test.ts +0 -470
- package/templates/docker/src/lib/__tests__/tracing.test.ts +0 -28
- package/templates/docker/src/lib/auth/__tests__/audit.test.ts +0 -418
- package/templates/docker/src/lib/auth/__tests__/byot-integration.test.ts +0 -222
- package/templates/docker/src/lib/auth/__tests__/byot.test.ts +0 -366
- package/templates/docker/src/lib/auth/__tests__/detect.test.ts +0 -190
- package/templates/docker/src/lib/auth/__tests__/managed.test.ts +0 -173
- package/templates/docker/src/lib/auth/__tests__/middleware.test.ts +0 -456
- package/templates/docker/src/lib/auth/__tests__/migrate.test.ts +0 -203
- package/templates/docker/src/lib/auth/__tests__/permissions.test.ts +0 -225
- package/templates/docker/src/lib/auth/__tests__/server.test.ts +0 -34
- package/templates/docker/src/lib/auth/__tests__/simple-key.test.ts +0 -176
- package/templates/docker/src/lib/auth/__tests__/types.test.ts +0 -44
- package/templates/docker/src/lib/db/__tests__/connection.test.ts +0 -144
- package/templates/docker/src/lib/db/__tests__/internal.test.ts +0 -387
- package/templates/docker/src/lib/db/__tests__/registry-health.test.ts +0 -190
- package/templates/docker/src/lib/db/__tests__/registry-pool-limits.test.ts +0 -137
- package/templates/docker/src/lib/db/__tests__/registry.test.ts +0 -398
- package/templates/docker/src/lib/db/__tests__/source-rate-limit.test.ts +0 -130
- package/templates/docker/src/lib/errors.ts +0 -154
- package/templates/docker/src/lib/plugins/__tests__/hooks-integration.test.ts +0 -204
- package/templates/docker/src/lib/plugins/__tests__/hooks.test.ts +0 -529
- package/templates/docker/src/lib/plugins/__tests__/migrate.test.ts +0 -875
- package/templates/docker/src/lib/plugins/__tests__/registry.test.ts +0 -373
- package/templates/docker/src/lib/plugins/__tests__/tools.test.ts +0 -49
- package/templates/docker/src/lib/plugins/__tests__/wiring.test.ts +0 -799
- package/templates/docker/src/lib/scheduler/__tests__/delivery.test.ts +0 -192
- package/templates/docker/src/lib/scheduler/__tests__/engine.test.ts +0 -248
- package/templates/docker/src/lib/scheduler/__tests__/format-email.test.ts +0 -96
- package/templates/docker/src/lib/scheduler/__tests__/format-slack.test.ts +0 -78
- package/templates/docker/src/lib/scheduler/__tests__/format-webhook.test.ts +0 -78
- package/templates/docker/src/lib/scheduler/index.ts +0 -7
- package/templates/docker/src/lib/slack/__tests__/api.test.ts +0 -160
- package/templates/docker/src/lib/slack/__tests__/format.test.ts +0 -237
- package/templates/docker/src/lib/slack/__tests__/store.test.ts +0 -188
- package/templates/docker/src/lib/slack/__tests__/threads.test.ts +0 -112
- package/templates/docker/src/lib/slack/__tests__/verify.test.ts +0 -111
- package/templates/docker/src/lib/tools/__tests__/action-permissions.test.ts +0 -594
- package/templates/docker/src/lib/tools/__tests__/custom-validation.test.ts +0 -240
- package/templates/docker/src/lib/tools/__tests__/explore-backend.test.ts +0 -267
- package/templates/docker/src/lib/tools/__tests__/explore-nsjail.test.ts +0 -506
- package/templates/docker/src/lib/tools/__tests__/explore-plugin.test.ts +0 -374
- package/templates/docker/src/lib/tools/__tests__/explore-sdk-compat.test.ts +0 -82
- package/templates/docker/src/lib/tools/__tests__/explore-sidecar.test.ts +0 -210
- package/templates/docker/src/lib/tools/__tests__/python-nsjail.test.ts +0 -515
- package/templates/docker/src/lib/tools/__tests__/python-sandbox.test.ts +0 -397
- package/templates/docker/src/lib/tools/__tests__/python-sidecar.test.ts +0 -365
- package/templates/docker/src/lib/tools/__tests__/python.test.ts +0 -331
- package/templates/docker/src/lib/tools/__tests__/registry-actions.test.ts +0 -132
- package/templates/docker/src/lib/tools/__tests__/registry.test.ts +0 -242
- package/templates/docker/src/lib/tools/__tests__/sql-audit.test.ts +0 -227
- package/templates/docker/src/lib/tools/__tests__/sql-connection-whitelist.test.ts +0 -100
- package/templates/docker/src/lib/tools/__tests__/sql-ratelimit.test.ts +0 -227
- package/templates/docker/src/lib/tools/__tests__/sql.test.ts +0 -709
- package/templates/docker/src/lib/tools/actions/__tests__/audit.test.ts +0 -211
- package/templates/docker/src/lib/tools/actions/__tests__/email.test.ts +0 -378
- package/templates/docker/src/lib/tools/actions/__tests__/handler.test.ts +0 -681
- package/templates/docker/src/lib/tools/actions/__tests__/jira.test.ts +0 -427
- package/templates/docker/src/test-setup.ts +0 -38
- package/templates/docker/src/types/vercel-sandbox.d.ts +0 -61
- package/templates/docker/src/ui/components/chat/managed-auth-card.tsx +0 -116
- package/templates/nextjs-standalone/src/api/__tests__/actions.test.ts +0 -683
- package/templates/nextjs-standalone/src/api/__tests__/admin.test.ts +0 -820
- package/templates/nextjs-standalone/src/api/__tests__/auth.test.ts +0 -165
- package/templates/nextjs-standalone/src/api/__tests__/chat.test.ts +0 -376
- package/templates/nextjs-standalone/src/api/__tests__/conversations.test.ts +0 -555
- package/templates/nextjs-standalone/src/api/__tests__/cors.test.ts +0 -135
- package/templates/nextjs-standalone/src/api/__tests__/health-plugin.test.ts +0 -176
- package/templates/nextjs-standalone/src/api/__tests__/health.test.ts +0 -283
- package/templates/nextjs-standalone/src/api/__tests__/query.test.ts +0 -891
- package/templates/nextjs-standalone/src/api/__tests__/scheduled-tasks.test.ts +0 -601
- package/templates/nextjs-standalone/src/api/__tests__/slack.test.ts +0 -847
- package/templates/nextjs-standalone/src/app/global-error.tsx +0 -68
- package/templates/nextjs-standalone/src/lib/__tests__/agent-cache.test.ts +0 -439
- package/templates/nextjs-standalone/src/lib/__tests__/agent-dialect.test.ts +0 -131
- package/templates/nextjs-standalone/src/lib/__tests__/agent-health-annotations.test.ts +0 -166
- package/templates/nextjs-standalone/src/lib/__tests__/agent-integration.test.ts +0 -516
- package/templates/nextjs-standalone/src/lib/__tests__/config-actions.test.ts +0 -166
- package/templates/nextjs-standalone/src/lib/__tests__/config.test.ts +0 -1113
- package/templates/nextjs-standalone/src/lib/__tests__/conversations.test.ts +0 -589
- package/templates/nextjs-standalone/src/lib/__tests__/errors.test.ts +0 -256
- package/templates/nextjs-standalone/src/lib/__tests__/logger.test.ts +0 -200
- package/templates/nextjs-standalone/src/lib/__tests__/plugin-aware-validation.test.ts +0 -321
- package/templates/nextjs-standalone/src/lib/__tests__/providers.test.ts +0 -130
- package/templates/nextjs-standalone/src/lib/__tests__/rls.test.ts +0 -435
- package/templates/nextjs-standalone/src/lib/__tests__/scheduled-task-types.test.ts +0 -124
- package/templates/nextjs-standalone/src/lib/__tests__/scheduled-tasks.test.ts +0 -550
- package/templates/nextjs-standalone/src/lib/__tests__/semantic-index.test.ts +0 -547
- package/templates/nextjs-standalone/src/lib/__tests__/semantic-multisource.test.ts +0 -544
- package/templates/nextjs-standalone/src/lib/__tests__/semantic.test.ts +0 -363
- package/templates/nextjs-standalone/src/lib/__tests__/startup-actions.test.ts +0 -461
- package/templates/nextjs-standalone/src/lib/__tests__/startup-first-run.test.ts +0 -429
- package/templates/nextjs-standalone/src/lib/__tests__/startup.test.ts +0 -470
- package/templates/nextjs-standalone/src/lib/__tests__/tracing.test.ts +0 -28
- package/templates/nextjs-standalone/src/lib/auth/__tests__/audit.test.ts +0 -418
- package/templates/nextjs-standalone/src/lib/auth/__tests__/byot-integration.test.ts +0 -222
- package/templates/nextjs-standalone/src/lib/auth/__tests__/byot.test.ts +0 -366
- package/templates/nextjs-standalone/src/lib/auth/__tests__/detect.test.ts +0 -190
- package/templates/nextjs-standalone/src/lib/auth/__tests__/managed.test.ts +0 -173
- package/templates/nextjs-standalone/src/lib/auth/__tests__/middleware.test.ts +0 -456
- package/templates/nextjs-standalone/src/lib/auth/__tests__/migrate.test.ts +0 -203
- package/templates/nextjs-standalone/src/lib/auth/__tests__/permissions.test.ts +0 -225
- package/templates/nextjs-standalone/src/lib/auth/__tests__/server.test.ts +0 -34
- package/templates/nextjs-standalone/src/lib/auth/__tests__/simple-key.test.ts +0 -176
- package/templates/nextjs-standalone/src/lib/auth/__tests__/types.test.ts +0 -44
- package/templates/nextjs-standalone/src/lib/db/__tests__/connection.test.ts +0 -144
- package/templates/nextjs-standalone/src/lib/db/__tests__/internal.test.ts +0 -387
- package/templates/nextjs-standalone/src/lib/db/__tests__/registry-health.test.ts +0 -190
- package/templates/nextjs-standalone/src/lib/db/__tests__/registry-pool-limits.test.ts +0 -137
- package/templates/nextjs-standalone/src/lib/db/__tests__/registry.test.ts +0 -398
- package/templates/nextjs-standalone/src/lib/db/__tests__/source-rate-limit.test.ts +0 -130
- package/templates/nextjs-standalone/src/lib/errors.ts +0 -154
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/hooks-integration.test.ts +0 -204
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/hooks.test.ts +0 -529
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/migrate.test.ts +0 -875
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/registry.test.ts +0 -373
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/tools.test.ts +0 -49
- package/templates/nextjs-standalone/src/lib/plugins/__tests__/wiring.test.ts +0 -799
- package/templates/nextjs-standalone/src/lib/scheduler/__tests__/delivery.test.ts +0 -192
- package/templates/nextjs-standalone/src/lib/scheduler/__tests__/engine.test.ts +0 -248
- package/templates/nextjs-standalone/src/lib/scheduler/__tests__/format-email.test.ts +0 -96
- package/templates/nextjs-standalone/src/lib/scheduler/__tests__/format-slack.test.ts +0 -78
- package/templates/nextjs-standalone/src/lib/scheduler/__tests__/format-webhook.test.ts +0 -78
- package/templates/nextjs-standalone/src/lib/scheduler/index.ts +0 -7
- package/templates/nextjs-standalone/src/lib/slack/__tests__/api.test.ts +0 -160
- package/templates/nextjs-standalone/src/lib/slack/__tests__/format.test.ts +0 -237
- package/templates/nextjs-standalone/src/lib/slack/__tests__/store.test.ts +0 -188
- package/templates/nextjs-standalone/src/lib/slack/__tests__/threads.test.ts +0 -112
- package/templates/nextjs-standalone/src/lib/slack/__tests__/verify.test.ts +0 -111
- package/templates/nextjs-standalone/src/lib/tools/__tests__/action-permissions.test.ts +0 -594
- package/templates/nextjs-standalone/src/lib/tools/__tests__/custom-validation.test.ts +0 -240
- package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-backend.test.ts +0 -267
- package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-nsjail.test.ts +0 -506
- package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-plugin.test.ts +0 -374
- package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-sdk-compat.test.ts +0 -82
- package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-sidecar.test.ts +0 -210
- package/templates/nextjs-standalone/src/lib/tools/__tests__/python-nsjail.test.ts +0 -515
- package/templates/nextjs-standalone/src/lib/tools/__tests__/python-sandbox.test.ts +0 -397
- package/templates/nextjs-standalone/src/lib/tools/__tests__/python-sidecar.test.ts +0 -365
- package/templates/nextjs-standalone/src/lib/tools/__tests__/python.test.ts +0 -331
- package/templates/nextjs-standalone/src/lib/tools/__tests__/registry-actions.test.ts +0 -132
- package/templates/nextjs-standalone/src/lib/tools/__tests__/registry.test.ts +0 -242
- package/templates/nextjs-standalone/src/lib/tools/__tests__/sql-audit.test.ts +0 -227
- package/templates/nextjs-standalone/src/lib/tools/__tests__/sql-connection-whitelist.test.ts +0 -100
- package/templates/nextjs-standalone/src/lib/tools/__tests__/sql-ratelimit.test.ts +0 -227
- package/templates/nextjs-standalone/src/lib/tools/__tests__/sql.test.ts +0 -709
- package/templates/nextjs-standalone/src/lib/tools/actions/__tests__/audit.test.ts +0 -211
- package/templates/nextjs-standalone/src/lib/tools/actions/__tests__/email.test.ts +0 -378
- package/templates/nextjs-standalone/src/lib/tools/actions/__tests__/handler.test.ts +0 -681
- package/templates/nextjs-standalone/src/lib/tools/actions/__tests__/jira.test.ts +0 -427
- package/templates/nextjs-standalone/src/test-setup.ts +0 -38
- package/templates/nextjs-standalone/src/ui/components/chat/managed-auth-card.tsx +0 -116
|
@@ -0,0 +1,852 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Semantic layer setup wizard API routes.
|
|
3
|
+
*
|
|
4
|
+
* Mounted at /api/v1/wizard. Requires admin role.
|
|
5
|
+
* Powers the guided semantic layer setup UI — a web replacement for `atlas init`.
|
|
6
|
+
*
|
|
7
|
+
* Flow: profile → generate → preview → save
|
|
8
|
+
*
|
|
9
|
+
* 1. POST /profile — List tables/views from a connected datasource
|
|
10
|
+
* 2. POST /generate — Profile selected tables + generate entity YAML
|
|
11
|
+
* 3. POST /preview — Preview agent behavior with generated entities
|
|
12
|
+
* 4. POST /save — Persist entities to org-scoped semantic layer
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import * as fs from "fs";
|
|
16
|
+
import * as path from "path";
|
|
17
|
+
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
18
|
+
import { Effect } from "effect";
|
|
19
|
+
import { runEffect } from "@atlas/api/lib/effect/hono";
|
|
20
|
+
import { RequestContext, AuthContext } from "@atlas/api/lib/effect/services";
|
|
21
|
+
import { HTTPException } from "hono/http-exception";
|
|
22
|
+
import { createLogger } from "@atlas/api/lib/logger";
|
|
23
|
+
import { validationHook } from "./validation-hook";
|
|
24
|
+
import { connections, detectDBType } from "@atlas/api/lib/db/connection";
|
|
25
|
+
import { hasInternalDB, internalQuery, decryptUrl } from "@atlas/api/lib/db/internal";
|
|
26
|
+
import { _resetWhitelists } from "@atlas/api/lib/semantic";
|
|
27
|
+
import { syncEntityToDisk } from "@atlas/api/lib/semantic/sync";
|
|
28
|
+
import { adminAuth, requestContext, type AuthEnv } from "./middleware";
|
|
29
|
+
import { ErrorSchema, AuthErrorSchema } from "./shared-schemas";
|
|
30
|
+
import {
|
|
31
|
+
type ProfilingResult,
|
|
32
|
+
OBJECT_TYPES,
|
|
33
|
+
FK_SOURCES,
|
|
34
|
+
PARTITION_STRATEGIES,
|
|
35
|
+
listPostgresObjects,
|
|
36
|
+
listMySQLObjects,
|
|
37
|
+
profilePostgres,
|
|
38
|
+
profileMySQL,
|
|
39
|
+
analyzeTableProfiles,
|
|
40
|
+
generateEntityYAML,
|
|
41
|
+
generateCatalogYAML,
|
|
42
|
+
generateGlossaryYAML,
|
|
43
|
+
generateMetricYAML,
|
|
44
|
+
outputDirForDatasource,
|
|
45
|
+
} from "@atlas/api/lib/profiler";
|
|
46
|
+
|
|
47
|
+
const log = createLogger("wizard");
|
|
48
|
+
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
// Schemas
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
|
|
53
|
+
const ProfileRequestSchema = z.object({
|
|
54
|
+
connectionId: z.string().min(1),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const ProfileResponseSchema = z.object({
|
|
58
|
+
connectionId: z.string(),
|
|
59
|
+
dbType: z.string(),
|
|
60
|
+
schema: z.string(),
|
|
61
|
+
tables: z.array(z.record(z.string(), z.unknown())),
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const GenerateRequestSchema = z.object({
|
|
65
|
+
connectionId: z.string().min(1),
|
|
66
|
+
tables: z.array(z.string()).min(1),
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const WizardEntityColumnSchema = z.object({
|
|
70
|
+
name: z.string(),
|
|
71
|
+
type: z.string(),
|
|
72
|
+
mappedType: z.string().optional(),
|
|
73
|
+
nullable: z.boolean(),
|
|
74
|
+
isPrimaryKey: z.boolean(),
|
|
75
|
+
isForeignKey: z.boolean(),
|
|
76
|
+
isEnumLike: z.boolean(),
|
|
77
|
+
sampleValues: z.array(z.string()),
|
|
78
|
+
uniqueCount: z.number().nullable(),
|
|
79
|
+
nullCount: z.number().nullable(),
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const WizardForeignKeySchema = z.object({
|
|
83
|
+
fromColumn: z.string(),
|
|
84
|
+
toTable: z.string(),
|
|
85
|
+
toColumn: z.string(),
|
|
86
|
+
source: z.enum(FK_SOURCES),
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const WizardInferredForeignKeySchema = z.object({
|
|
90
|
+
fromColumn: z.string(),
|
|
91
|
+
toTable: z.string(),
|
|
92
|
+
toColumn: z.string(),
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const WizardEntityResultSchema = z.object({
|
|
96
|
+
tableName: z.string(),
|
|
97
|
+
objectType: z.enum(OBJECT_TYPES),
|
|
98
|
+
rowCount: z.number(),
|
|
99
|
+
columnCount: z.number(),
|
|
100
|
+
yaml: z.string(),
|
|
101
|
+
profile: z.object({
|
|
102
|
+
columns: z.array(WizardEntityColumnSchema),
|
|
103
|
+
primaryKeys: z.array(z.string()),
|
|
104
|
+
foreignKeys: z.array(WizardForeignKeySchema),
|
|
105
|
+
inferredForeignKeys: z.array(WizardInferredForeignKeySchema),
|
|
106
|
+
flags: z.object({
|
|
107
|
+
possiblyAbandoned: z.boolean(),
|
|
108
|
+
possiblyDenormalized: z.boolean(),
|
|
109
|
+
}),
|
|
110
|
+
notes: z.array(z.string()),
|
|
111
|
+
}),
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const GenerateResponseSchema = z.object({
|
|
115
|
+
connectionId: z.string(),
|
|
116
|
+
dbType: z.string(),
|
|
117
|
+
schema: z.string(),
|
|
118
|
+
entities: z.array(WizardEntityResultSchema),
|
|
119
|
+
errors: z.array(z.object({ table: z.string(), error: z.string() })),
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const PreviewRequestSchema = z.object({
|
|
123
|
+
question: z.string().min(1),
|
|
124
|
+
entities: z.array(z.object({ tableName: z.string(), yaml: z.string() })).min(1),
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const PreviewResponseSchema = z.record(z.string(), z.unknown());
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Zod schema for a column profile (snake_case wire format).
|
|
131
|
+
* Keep in sync with ColumnProfile from @useatlas/types.
|
|
132
|
+
*/
|
|
133
|
+
const ColumnProfileSchema = z.object({
|
|
134
|
+
name: z.string(),
|
|
135
|
+
type: z.string(),
|
|
136
|
+
nullable: z.boolean(),
|
|
137
|
+
unique_count: z.number().nullable(),
|
|
138
|
+
null_count: z.number().nullable(),
|
|
139
|
+
sample_values: z.array(z.string()),
|
|
140
|
+
is_primary_key: z.boolean(),
|
|
141
|
+
is_foreign_key: z.boolean(),
|
|
142
|
+
fk_target_table: z.string().nullable(),
|
|
143
|
+
fk_target_column: z.string().nullable(),
|
|
144
|
+
is_enum_like: z.boolean(),
|
|
145
|
+
profiler_notes: z.array(z.string()),
|
|
146
|
+
}).refine(
|
|
147
|
+
(col) => !col.is_foreign_key || (col.fk_target_table !== null && col.fk_target_column !== null),
|
|
148
|
+
{ message: "fk_target_table and fk_target_column must be non-null when is_foreign_key is true" },
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Zod schema for a foreign key.
|
|
153
|
+
* Keep in sync with ForeignKey from @useatlas/types.
|
|
154
|
+
*/
|
|
155
|
+
const ForeignKeySchema = z.object({
|
|
156
|
+
from_column: z.string().min(1),
|
|
157
|
+
to_table: z.string().min(1),
|
|
158
|
+
to_column: z.string().min(1),
|
|
159
|
+
source: z.enum(FK_SOURCES),
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Zod schema for a table profile (snake_case wire format).
|
|
164
|
+
* Derived from const tuples in @useatlas/types — no manual enum sync needed.
|
|
165
|
+
*/
|
|
166
|
+
const TableProfileSchema = z.object({
|
|
167
|
+
table_name: z.string(),
|
|
168
|
+
object_type: z.enum(OBJECT_TYPES),
|
|
169
|
+
row_count: z.number(),
|
|
170
|
+
columns: z.array(ColumnProfileSchema),
|
|
171
|
+
primary_key_columns: z.array(z.string()),
|
|
172
|
+
foreign_keys: z.array(ForeignKeySchema),
|
|
173
|
+
inferred_foreign_keys: z.array(ForeignKeySchema),
|
|
174
|
+
profiler_notes: z.array(z.string()),
|
|
175
|
+
table_flags: z.object({
|
|
176
|
+
possibly_abandoned: z.boolean(),
|
|
177
|
+
possibly_denormalized: z.boolean(),
|
|
178
|
+
}),
|
|
179
|
+
matview_populated: z.boolean().optional(),
|
|
180
|
+
partition_info: z.object({
|
|
181
|
+
strategy: z.enum(PARTITION_STRATEGIES),
|
|
182
|
+
key: z.string(),
|
|
183
|
+
children: z.array(z.string()),
|
|
184
|
+
}).optional(),
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
const SaveRequestSchema = z.object({
|
|
188
|
+
connectionId: z.string().min(1),
|
|
189
|
+
entities: z.array(z.object({ tableName: z.string(), yaml: z.string() })).min(1),
|
|
190
|
+
schema: z.string().optional(),
|
|
191
|
+
profiles: z.array(TableProfileSchema).optional(),
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const SaveResponseSchema = z.object({
|
|
195
|
+
saved: z.boolean(),
|
|
196
|
+
orgId: z.string().nullable(),
|
|
197
|
+
connectionId: z.string(),
|
|
198
|
+
entityCount: z.number(),
|
|
199
|
+
files: z.array(z.string()),
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
// ---------------------------------------------------------------------------
|
|
203
|
+
// Route definitions
|
|
204
|
+
// ---------------------------------------------------------------------------
|
|
205
|
+
|
|
206
|
+
const profileRoute = createRoute({
|
|
207
|
+
method: "post",
|
|
208
|
+
path: "/profile",
|
|
209
|
+
tags: ["Wizard"],
|
|
210
|
+
summary: "List tables from a connected datasource",
|
|
211
|
+
description:
|
|
212
|
+
"Discovers tables, views, and materialized views in a connected database for the wizard table selection step. " +
|
|
213
|
+
"Supports PostgreSQL and MySQL datasources. Requires admin role.",
|
|
214
|
+
request: {
|
|
215
|
+
body: {
|
|
216
|
+
content: {
|
|
217
|
+
"application/json": {
|
|
218
|
+
schema: ProfileRequestSchema,
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
responses: {
|
|
224
|
+
200: {
|
|
225
|
+
description: "Table list from the connected datasource",
|
|
226
|
+
content: { "application/json": { schema: ProfileResponseSchema } },
|
|
227
|
+
},
|
|
228
|
+
400: {
|
|
229
|
+
description: "Invalid request (missing connectionId or unsupported database type)",
|
|
230
|
+
content: { "application/json": { schema: ErrorSchema } },
|
|
231
|
+
},
|
|
232
|
+
401: {
|
|
233
|
+
description: "Authentication required",
|
|
234
|
+
content: { "application/json": { schema: AuthErrorSchema } },
|
|
235
|
+
},
|
|
236
|
+
403: {
|
|
237
|
+
description: "Forbidden — admin role required",
|
|
238
|
+
content: { "application/json": { schema: AuthErrorSchema } },
|
|
239
|
+
},
|
|
240
|
+
404: {
|
|
241
|
+
description: "Connection not found",
|
|
242
|
+
content: { "application/json": { schema: ErrorSchema } },
|
|
243
|
+
},
|
|
244
|
+
429: {
|
|
245
|
+
description: "Rate limit exceeded",
|
|
246
|
+
content: { "application/json": { schema: AuthErrorSchema } },
|
|
247
|
+
},
|
|
248
|
+
500: {
|
|
249
|
+
description: "Connection resolution or profiling failed",
|
|
250
|
+
content: { "application/json": { schema: ErrorSchema } },
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
const generateRoute = createRoute({
|
|
256
|
+
method: "post",
|
|
257
|
+
path: "/generate",
|
|
258
|
+
tags: ["Wizard"],
|
|
259
|
+
summary: "Profile tables and generate entity YAML",
|
|
260
|
+
description:
|
|
261
|
+
"Profiles selected tables from a connected datasource and generates entity YAML definitions " +
|
|
262
|
+
"with dimensions, measures, joins, query patterns, and heuristic flags. Requires admin role.",
|
|
263
|
+
request: {
|
|
264
|
+
body: {
|
|
265
|
+
content: {
|
|
266
|
+
"application/json": {
|
|
267
|
+
schema: GenerateRequestSchema,
|
|
268
|
+
},
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
responses: {
|
|
273
|
+
200: {
|
|
274
|
+
description: "Generated entity YAML definitions with profiling metadata",
|
|
275
|
+
content: { "application/json": { schema: GenerateResponseSchema } },
|
|
276
|
+
},
|
|
277
|
+
400: {
|
|
278
|
+
description: "Invalid request (missing connectionId, empty tables, or unsupported database type)",
|
|
279
|
+
content: { "application/json": { schema: ErrorSchema } },
|
|
280
|
+
},
|
|
281
|
+
401: {
|
|
282
|
+
description: "Authentication required",
|
|
283
|
+
content: { "application/json": { schema: AuthErrorSchema } },
|
|
284
|
+
},
|
|
285
|
+
403: {
|
|
286
|
+
description: "Forbidden — admin role required",
|
|
287
|
+
content: { "application/json": { schema: AuthErrorSchema } },
|
|
288
|
+
},
|
|
289
|
+
404: {
|
|
290
|
+
description: "Connection not found",
|
|
291
|
+
content: { "application/json": { schema: ErrorSchema } },
|
|
292
|
+
},
|
|
293
|
+
429: {
|
|
294
|
+
description: "Rate limit exceeded",
|
|
295
|
+
content: { "application/json": { schema: AuthErrorSchema } },
|
|
296
|
+
},
|
|
297
|
+
500: {
|
|
298
|
+
description: "Profiling or generation failed",
|
|
299
|
+
content: { "application/json": { schema: ErrorSchema } },
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
const previewRoute = createRoute({
|
|
305
|
+
method: "post",
|
|
306
|
+
path: "/preview",
|
|
307
|
+
tags: ["Wizard"],
|
|
308
|
+
summary: "Preview agent behavior with entities",
|
|
309
|
+
description:
|
|
310
|
+
"Shows how the agent would interpret the semantic layer when answering a question, " +
|
|
311
|
+
"given a set of candidate entity YAML definitions. Requires admin role.",
|
|
312
|
+
request: {
|
|
313
|
+
body: {
|
|
314
|
+
content: {
|
|
315
|
+
"application/json": {
|
|
316
|
+
schema: PreviewRequestSchema,
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
responses: {
|
|
322
|
+
200: {
|
|
323
|
+
description: "Preview of how the agent would see the semantic layer",
|
|
324
|
+
content: { "application/json": { schema: PreviewResponseSchema } },
|
|
325
|
+
},
|
|
326
|
+
400: {
|
|
327
|
+
description: "Invalid request (missing question or entities)",
|
|
328
|
+
content: { "application/json": { schema: ErrorSchema } },
|
|
329
|
+
},
|
|
330
|
+
401: {
|
|
331
|
+
description: "Authentication required",
|
|
332
|
+
content: { "application/json": { schema: AuthErrorSchema } },
|
|
333
|
+
},
|
|
334
|
+
403: {
|
|
335
|
+
description: "Forbidden — admin role required",
|
|
336
|
+
content: { "application/json": { schema: AuthErrorSchema } },
|
|
337
|
+
},
|
|
338
|
+
429: {
|
|
339
|
+
description: "Rate limit exceeded",
|
|
340
|
+
content: { "application/json": { schema: AuthErrorSchema } },
|
|
341
|
+
},
|
|
342
|
+
500: {
|
|
343
|
+
description: "Internal server error",
|
|
344
|
+
content: { "application/json": { schema: ErrorSchema } },
|
|
345
|
+
},
|
|
346
|
+
},
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
const saveRoute = createRoute({
|
|
350
|
+
method: "post",
|
|
351
|
+
path: "/save",
|
|
352
|
+
tags: ["Wizard"],
|
|
353
|
+
summary: "Save entities to org-scoped semantic layer",
|
|
354
|
+
description:
|
|
355
|
+
"Persists generated entity YAML files to the organization's semantic layer directory on disk. " +
|
|
356
|
+
"Validates table names for path traversal, syncs to the internal database if available, " +
|
|
357
|
+
"and resets the semantic whitelist cache. Requires admin role and an active organization.",
|
|
358
|
+
request: {
|
|
359
|
+
body: {
|
|
360
|
+
content: {
|
|
361
|
+
"application/json": {
|
|
362
|
+
schema: SaveRequestSchema,
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
},
|
|
366
|
+
},
|
|
367
|
+
responses: {
|
|
368
|
+
201: {
|
|
369
|
+
description: "Entities saved to disk",
|
|
370
|
+
content: { "application/json": { schema: SaveResponseSchema } },
|
|
371
|
+
},
|
|
372
|
+
400: {
|
|
373
|
+
description: "Invalid request (missing connectionId, empty entities, invalid table name, or no active organization)",
|
|
374
|
+
content: { "application/json": { schema: ErrorSchema } },
|
|
375
|
+
},
|
|
376
|
+
401: {
|
|
377
|
+
description: "Authentication required",
|
|
378
|
+
content: { "application/json": { schema: AuthErrorSchema } },
|
|
379
|
+
},
|
|
380
|
+
403: {
|
|
381
|
+
description: "Forbidden — admin role required",
|
|
382
|
+
content: { "application/json": { schema: AuthErrorSchema } },
|
|
383
|
+
},
|
|
384
|
+
429: {
|
|
385
|
+
description: "Rate limit exceeded",
|
|
386
|
+
content: { "application/json": { schema: AuthErrorSchema } },
|
|
387
|
+
},
|
|
388
|
+
500: {
|
|
389
|
+
description: "Failed to save entities",
|
|
390
|
+
content: { "application/json": { schema: ErrorSchema } },
|
|
391
|
+
},
|
|
392
|
+
},
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
// ---------------------------------------------------------------------------
|
|
396
|
+
// Router
|
|
397
|
+
// ---------------------------------------------------------------------------
|
|
398
|
+
|
|
399
|
+
const wizard = new OpenAPIHono<AuthEnv>({
|
|
400
|
+
defaultHook: validationHook,
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
wizard.use(adminAuth);
|
|
404
|
+
wizard.use(requestContext);
|
|
405
|
+
|
|
406
|
+
wizard.onError((err, c) => {
|
|
407
|
+
if (err instanceof HTTPException) {
|
|
408
|
+
// Middleware-thrown HTTPExceptions carry a JSON Response
|
|
409
|
+
if (err.res) return err.res;
|
|
410
|
+
// Framework 400 for malformed JSON
|
|
411
|
+
if (err.status === 400) {
|
|
412
|
+
return c.json({ error: "invalid_request", message: "Invalid JSON body." }, 400);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
throw err;
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
// ---------------------------------------------------------------------------
|
|
419
|
+
// POST /profile — List tables/views from a connected datasource
|
|
420
|
+
// ---------------------------------------------------------------------------
|
|
421
|
+
|
|
422
|
+
wizard.openapi(profileRoute, async (c) => {
|
|
423
|
+
return runEffect(c, Effect.gen(function* () {
|
|
424
|
+
const { requestId } = yield* RequestContext;
|
|
425
|
+
const { user } = yield* AuthContext;
|
|
426
|
+
|
|
427
|
+
const { connectionId } = c.req.valid("json");
|
|
428
|
+
|
|
429
|
+
// Look up the connection URL — resolveConnectionUrl throws on infrastructure errors
|
|
430
|
+
const connUrlResult = yield* Effect.tryPromise({
|
|
431
|
+
try: () => resolveConnectionUrl(connectionId, user?.activeOrganizationId),
|
|
432
|
+
catch: (err) => err instanceof Error ? err : new Error(String(err)),
|
|
433
|
+
}).pipe(Effect.either);
|
|
434
|
+
|
|
435
|
+
if (connUrlResult._tag === "Left") {
|
|
436
|
+
const err = connUrlResult.left;
|
|
437
|
+
log.error({ err, requestId, connectionId }, "Failed to resolve connection URL");
|
|
438
|
+
return c.json({
|
|
439
|
+
error: "connection_resolution_failed",
|
|
440
|
+
message: "Failed to resolve connection. Check server logs for details.",
|
|
441
|
+
requestId,
|
|
442
|
+
}, 500);
|
|
443
|
+
}
|
|
444
|
+
const connUrl = connUrlResult.right;
|
|
445
|
+
if (!connUrl) {
|
|
446
|
+
return c.json({ error: "not_found", message: `Connection "${connectionId}" not found.` }, 404);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
const { url, dbType, schema } = connUrl;
|
|
450
|
+
|
|
451
|
+
const profileResult = yield* Effect.tryPromise({
|
|
452
|
+
try: async () => {
|
|
453
|
+
let objects;
|
|
454
|
+
switch (dbType) {
|
|
455
|
+
case "postgres":
|
|
456
|
+
objects = await listPostgresObjects(url, schema, log);
|
|
457
|
+
break;
|
|
458
|
+
case "mysql":
|
|
459
|
+
objects = await listMySQLObjects(url);
|
|
460
|
+
break;
|
|
461
|
+
default:
|
|
462
|
+
return { error: "unsupported_db" as const, dbType };
|
|
463
|
+
}
|
|
464
|
+
return { ok: true as const, objects };
|
|
465
|
+
},
|
|
466
|
+
catch: (err) => err instanceof Error ? err : new Error(String(err)),
|
|
467
|
+
}).pipe(Effect.either);
|
|
468
|
+
|
|
469
|
+
if (profileResult._tag === "Left") {
|
|
470
|
+
const err = profileResult.left;
|
|
471
|
+
log.error({ err, requestId, connectionId }, "Wizard profile failed");
|
|
472
|
+
return c.json({
|
|
473
|
+
error: "profile_failed",
|
|
474
|
+
message: `Failed to list tables: ${err.message}`,
|
|
475
|
+
requestId,
|
|
476
|
+
}, 500);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
const profileData = profileResult.right;
|
|
480
|
+
if ("error" in profileData) {
|
|
481
|
+
return c.json({
|
|
482
|
+
error: "unsupported_db",
|
|
483
|
+
message: `Wizard profiling is currently supported for PostgreSQL and MySQL. Got: ${profileData.dbType}`,
|
|
484
|
+
}, 400);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
log.info({ requestId, connectionId, dbType, tableCount: profileData.objects.length }, "Wizard profile complete");
|
|
488
|
+
|
|
489
|
+
return c.json({
|
|
490
|
+
connectionId,
|
|
491
|
+
dbType,
|
|
492
|
+
schema,
|
|
493
|
+
tables: profileData.objects.map((o) => ({
|
|
494
|
+
name: o.name,
|
|
495
|
+
type: o.type,
|
|
496
|
+
})),
|
|
497
|
+
}, 200);
|
|
498
|
+
}), { label: "wizard profile" });
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
// ---------------------------------------------------------------------------
|
|
502
|
+
// POST /generate — Profile selected tables and generate entity YAML
|
|
503
|
+
// ---------------------------------------------------------------------------
|
|
504
|
+
|
|
505
|
+
wizard.openapi(generateRoute, async (c) => {
|
|
506
|
+
return runEffect(c, Effect.gen(function* () {
|
|
507
|
+
const { requestId } = yield* RequestContext;
|
|
508
|
+
const { user } = yield* AuthContext;
|
|
509
|
+
|
|
510
|
+
const { connectionId, tables: tableNames } = c.req.valid("json");
|
|
511
|
+
|
|
512
|
+
const connUrlResult = yield* Effect.tryPromise({
|
|
513
|
+
try: () => resolveConnectionUrl(connectionId, user?.activeOrganizationId),
|
|
514
|
+
catch: (err) => err instanceof Error ? err : new Error(String(err)),
|
|
515
|
+
}).pipe(Effect.either);
|
|
516
|
+
|
|
517
|
+
if (connUrlResult._tag === "Left") {
|
|
518
|
+
const err = connUrlResult.left;
|
|
519
|
+
log.error({ err, requestId, connectionId }, "Failed to resolve connection URL");
|
|
520
|
+
return c.json({
|
|
521
|
+
error: "connection_resolution_failed",
|
|
522
|
+
message: "Failed to resolve connection. Check server logs for details.",
|
|
523
|
+
requestId,
|
|
524
|
+
}, 500);
|
|
525
|
+
}
|
|
526
|
+
const connUrl = connUrlResult.right;
|
|
527
|
+
if (!connUrl) {
|
|
528
|
+
return c.json({ error: "not_found", message: `Connection "${connectionId}" not found.` }, 404);
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
const { url, dbType, schema } = connUrl;
|
|
532
|
+
|
|
533
|
+
const genResult = yield* Effect.tryPromise({
|
|
534
|
+
try: async () => {
|
|
535
|
+
let result: ProfilingResult;
|
|
536
|
+
switch (dbType) {
|
|
537
|
+
case "postgres":
|
|
538
|
+
result = await profilePostgres(url, tableNames, undefined, schema, undefined, log);
|
|
539
|
+
break;
|
|
540
|
+
case "mysql":
|
|
541
|
+
result = await profileMySQL(url, tableNames, undefined, undefined, log);
|
|
542
|
+
break;
|
|
543
|
+
default:
|
|
544
|
+
return { error: "unsupported_db" as const, dbType };
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// Run heuristics (returns new array — no mutation)
|
|
548
|
+
const analyzedProfiles = analyzeTableProfiles(result.profiles);
|
|
549
|
+
|
|
550
|
+
// Generate entity YAML for each profile
|
|
551
|
+
const sourceId = connectionId === "default" ? undefined : connectionId;
|
|
552
|
+
const entities = analyzedProfiles.map((profile) => ({
|
|
553
|
+
tableName: profile.table_name,
|
|
554
|
+
objectType: profile.object_type,
|
|
555
|
+
rowCount: profile.row_count,
|
|
556
|
+
columnCount: profile.columns.length,
|
|
557
|
+
yaml: generateEntityYAML(profile, analyzedProfiles, dbType, schema, sourceId),
|
|
558
|
+
profile: {
|
|
559
|
+
columns: profile.columns.map((col) => ({
|
|
560
|
+
name: col.name,
|
|
561
|
+
type: col.type,
|
|
562
|
+
mappedType: col.is_enum_like ? "enum" : undefined,
|
|
563
|
+
nullable: col.nullable,
|
|
564
|
+
isPrimaryKey: col.is_primary_key,
|
|
565
|
+
isForeignKey: col.is_foreign_key,
|
|
566
|
+
isEnumLike: col.is_enum_like,
|
|
567
|
+
sampleValues: col.sample_values.slice(0, 5),
|
|
568
|
+
uniqueCount: col.unique_count,
|
|
569
|
+
nullCount: col.null_count,
|
|
570
|
+
})),
|
|
571
|
+
primaryKeys: profile.primary_key_columns,
|
|
572
|
+
foreignKeys: profile.foreign_keys.map((fk) => ({
|
|
573
|
+
fromColumn: fk.from_column,
|
|
574
|
+
toTable: fk.to_table,
|
|
575
|
+
toColumn: fk.to_column,
|
|
576
|
+
source: fk.source,
|
|
577
|
+
})),
|
|
578
|
+
inferredForeignKeys: profile.inferred_foreign_keys.map((fk) => ({
|
|
579
|
+
fromColumn: fk.from_column,
|
|
580
|
+
toTable: fk.to_table,
|
|
581
|
+
toColumn: fk.to_column,
|
|
582
|
+
})),
|
|
583
|
+
flags: {
|
|
584
|
+
possiblyAbandoned: profile.table_flags.possibly_abandoned,
|
|
585
|
+
possiblyDenormalized: profile.table_flags.possibly_denormalized,
|
|
586
|
+
},
|
|
587
|
+
notes: profile.profiler_notes,
|
|
588
|
+
},
|
|
589
|
+
}));
|
|
590
|
+
|
|
591
|
+
return { ok: true as const, analyzedProfiles, entities, errors: result.errors };
|
|
592
|
+
},
|
|
593
|
+
catch: (err) => err instanceof Error ? err : new Error(String(err)),
|
|
594
|
+
}).pipe(Effect.either);
|
|
595
|
+
|
|
596
|
+
if (genResult._tag === "Left") {
|
|
597
|
+
const err = genResult.left;
|
|
598
|
+
log.error({ err, requestId, connectionId }, "Wizard generate failed");
|
|
599
|
+
return c.json({
|
|
600
|
+
error: "generate_failed",
|
|
601
|
+
message: `Failed to profile tables: ${err.message}`,
|
|
602
|
+
requestId,
|
|
603
|
+
}, 500);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
const genData = genResult.right;
|
|
607
|
+
if ("error" in genData) {
|
|
608
|
+
return c.json({
|
|
609
|
+
error: "unsupported_db",
|
|
610
|
+
message: `Wizard profiling is currently supported for PostgreSQL and MySQL. Got: ${genData.dbType}`,
|
|
611
|
+
}, 400);
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
log.info({
|
|
615
|
+
requestId,
|
|
616
|
+
connectionId,
|
|
617
|
+
dbType,
|
|
618
|
+
profiledCount: genData.analyzedProfiles.length,
|
|
619
|
+
errorCount: genData.errors.length,
|
|
620
|
+
}, "Wizard generate complete");
|
|
621
|
+
|
|
622
|
+
return c.json({
|
|
623
|
+
connectionId,
|
|
624
|
+
dbType,
|
|
625
|
+
schema,
|
|
626
|
+
entities: genData.entities,
|
|
627
|
+
errors: genData.errors,
|
|
628
|
+
}, 200);
|
|
629
|
+
}), { label: "wizard generate" });
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
// ---------------------------------------------------------------------------
|
|
633
|
+
// POST /preview — Preview agent behavior with generated entities
|
|
634
|
+
// ---------------------------------------------------------------------------
|
|
635
|
+
|
|
636
|
+
wizard.openapi(previewRoute, async (c) => {
|
|
637
|
+
return runEffect(c, Effect.gen(function* () {
|
|
638
|
+
const { requestId } = yield* RequestContext;
|
|
639
|
+
|
|
640
|
+
const { question, entities } = c.req.valid("json");
|
|
641
|
+
|
|
642
|
+
// Build a semantic context summary from the provided entity YAMLs
|
|
643
|
+
// (Zod already validated that entities are { tableName: string; yaml: string }[])
|
|
644
|
+
const entitySummaries = entities
|
|
645
|
+
.map((e) => `--- ${e.tableName} ---\n${e.yaml}`)
|
|
646
|
+
.join("\n\n");
|
|
647
|
+
|
|
648
|
+
// Generate a preview response showing what the agent would see
|
|
649
|
+
const preview = {
|
|
650
|
+
question,
|
|
651
|
+
semanticContext: `The agent would see ${entities.length} entity definitions when answering this question.`,
|
|
652
|
+
availableTables: entities.map((e) => e.tableName),
|
|
653
|
+
entityCount: entities.length,
|
|
654
|
+
sampleEntityYaml: entitySummaries.slice(0, 2000),
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
log.info({ requestId, question, entityCount: entities.length }, "Wizard preview generated");
|
|
658
|
+
|
|
659
|
+
return c.json(preview, 200);
|
|
660
|
+
}), { label: "wizard preview" });
|
|
661
|
+
});
|
|
662
|
+
|
|
663
|
+
// ---------------------------------------------------------------------------
|
|
664
|
+
// POST /save — Save entities to org-scoped semantic layer
|
|
665
|
+
// ---------------------------------------------------------------------------
|
|
666
|
+
|
|
667
|
+
wizard.openapi(saveRoute, async (c) => {
|
|
668
|
+
return runEffect(c, Effect.gen(function* () {
|
|
669
|
+
const { requestId } = yield* RequestContext;
|
|
670
|
+
const { user } = yield* AuthContext;
|
|
671
|
+
|
|
672
|
+
const orgId = user?.activeOrganizationId;
|
|
673
|
+
if (!orgId) {
|
|
674
|
+
return c.json({ error: "no_organization", message: "No active organization. Create a workspace first." }, 400);
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
const body = c.req.valid("json");
|
|
678
|
+
const { connectionId, entities } = body;
|
|
679
|
+
|
|
680
|
+
// Path traversal protection: validate all table names before writing any files
|
|
681
|
+
const SAFE_TABLE_NAME = /^[a-zA-Z_][a-zA-Z0-9_.-]*$/;
|
|
682
|
+
for (const entity of entities) {
|
|
683
|
+
if (!SAFE_TABLE_NAME.test(entity.tableName) || entity.tableName.includes("..")) {
|
|
684
|
+
return c.json({
|
|
685
|
+
error: "invalid_request",
|
|
686
|
+
message: `Invalid table name: "${entity.tableName}". Only letters, digits, underscores, hyphens, and dots are allowed.`,
|
|
687
|
+
}, 400);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
try {
|
|
692
|
+
// Write entities to disk (org-scoped)
|
|
693
|
+
const sourceId = connectionId === "default" ? "default" : connectionId;
|
|
694
|
+
const outputBase = outputDirForDatasource(sourceId, orgId);
|
|
695
|
+
const entitiesDir = path.join(outputBase, "entities");
|
|
696
|
+
const metricsDir = path.join(outputBase, "metrics");
|
|
697
|
+
|
|
698
|
+
fs.mkdirSync(entitiesDir, { recursive: true });
|
|
699
|
+
fs.mkdirSync(metricsDir, { recursive: true });
|
|
700
|
+
|
|
701
|
+
const savedFiles: string[] = [];
|
|
702
|
+
|
|
703
|
+
// Write entity YAMLs (table names already validated above)
|
|
704
|
+
for (const entity of entities) {
|
|
705
|
+
const safeName = path.basename(entity.tableName);
|
|
706
|
+
const filePath = path.join(entitiesDir, `${safeName}.yml`);
|
|
707
|
+
fs.writeFileSync(filePath, entity.yaml, "utf-8");
|
|
708
|
+
savedFiles.push(`entities/${safeName}.yml`);
|
|
709
|
+
|
|
710
|
+
// Also write to org-scoped semantic directory (semantic/.orgs/{orgId}/)
|
|
711
|
+
// so the explore tool can discover this entity.
|
|
712
|
+
if (hasInternalDB()) {
|
|
713
|
+
yield* Effect.promise(() => syncEntityToDisk(orgId, entity.tableName, "entity", entity.yaml).catch((err) => {
|
|
714
|
+
log.warn({ err: err instanceof Error ? err.message : String(err), tableName: entity.tableName }, "Disk sync after wizard save failed");
|
|
715
|
+
}));
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
// Generate catalog, glossary, and metric files from raw profile data.
|
|
720
|
+
// The wizard frontend does not send raw profile data — it sends
|
|
721
|
+
// pre-generated entity YAML via { connectionId, entities } instead.
|
|
722
|
+
// This branch handles callers (e.g. future CLI integrations) that
|
|
723
|
+
// provide raw TableProfile[] data for server-side generation.
|
|
724
|
+
const { schema: bodySchema, profiles: profileData } = body;
|
|
725
|
+
if (profileData && profileData.length > 0) {
|
|
726
|
+
const profiles = profileData;
|
|
727
|
+
const resolvedSchema = bodySchema ?? "public";
|
|
728
|
+
|
|
729
|
+
const catalogYaml = generateCatalogYAML(profiles);
|
|
730
|
+
const catalogPath = path.join(outputBase, "catalog.yml");
|
|
731
|
+
fs.writeFileSync(catalogPath, catalogYaml, "utf-8");
|
|
732
|
+
savedFiles.push("catalog.yml");
|
|
733
|
+
|
|
734
|
+
const glossaryYaml = generateGlossaryYAML(profiles);
|
|
735
|
+
const glossaryPath = path.join(outputBase, "glossary.yml");
|
|
736
|
+
fs.writeFileSync(glossaryPath, glossaryYaml, "utf-8");
|
|
737
|
+
savedFiles.push("glossary.yml");
|
|
738
|
+
|
|
739
|
+
// Generate metric files (sanitize table_name from profiles)
|
|
740
|
+
for (const profile of profiles) {
|
|
741
|
+
if (!profile.table_name || !SAFE_TABLE_NAME.test(profile.table_name)) continue;
|
|
742
|
+
const metricYaml = generateMetricYAML(profile, resolvedSchema);
|
|
743
|
+
if (metricYaml) {
|
|
744
|
+
const safeMetricName = path.basename(profile.table_name);
|
|
745
|
+
const filePath = path.join(metricsDir, `${safeMetricName}.yml`);
|
|
746
|
+
fs.writeFileSync(filePath, metricYaml, "utf-8");
|
|
747
|
+
savedFiles.push(`metrics/${safeMetricName}.yml`);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
// Reset semantic whitelist cache so new entities are queryable
|
|
753
|
+
_resetWhitelists();
|
|
754
|
+
|
|
755
|
+
log.info({
|
|
756
|
+
requestId,
|
|
757
|
+
orgId,
|
|
758
|
+
connectionId,
|
|
759
|
+
entityCount: entities.length,
|
|
760
|
+
fileCount: savedFiles.length,
|
|
761
|
+
}, "Wizard save complete");
|
|
762
|
+
|
|
763
|
+
return c.json({
|
|
764
|
+
saved: true,
|
|
765
|
+
orgId,
|
|
766
|
+
connectionId,
|
|
767
|
+
entityCount: entities.length,
|
|
768
|
+
files: savedFiles,
|
|
769
|
+
}, 201);
|
|
770
|
+
} catch (err) {
|
|
771
|
+
log.error({ err: err instanceof Error ? err : new Error(String(err)), requestId, orgId }, "Wizard save failed");
|
|
772
|
+
return c.json({
|
|
773
|
+
error: "save_failed",
|
|
774
|
+
message: `Failed to save entities: ${err instanceof Error ? err.message : String(err)}`,
|
|
775
|
+
requestId,
|
|
776
|
+
}, 500);
|
|
777
|
+
}
|
|
778
|
+
}), { label: "wizard save" });
|
|
779
|
+
});
|
|
780
|
+
|
|
781
|
+
// ---------------------------------------------------------------------------
|
|
782
|
+
// Helpers
|
|
783
|
+
// ---------------------------------------------------------------------------
|
|
784
|
+
|
|
785
|
+
interface ResolvedConnection {
|
|
786
|
+
url: string;
|
|
787
|
+
dbType: ReturnType<typeof detectDBType>;
|
|
788
|
+
schema: string;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* Resolve a connection URL from either the runtime ConnectionRegistry
|
|
793
|
+
* or the internal database (encrypted connections table).
|
|
794
|
+
*
|
|
795
|
+
* Returns the resolved connection, or null if the connection does not exist.
|
|
796
|
+
* Throws on infrastructure errors (e.g. database unreachable, pool exhaustion,
|
|
797
|
+
* decryption failure, missing encryption key) so callers can distinguish
|
|
798
|
+
* "not found" from "lookup failed".
|
|
799
|
+
*/
|
|
800
|
+
async function resolveConnectionUrl(
|
|
801
|
+
connectionId: string,
|
|
802
|
+
orgId?: string | null,
|
|
803
|
+
): Promise<ResolvedConnection | null> {
|
|
804
|
+
// First try: runtime registry (works for self-hosted / env-var connections)
|
|
805
|
+
if (connections.has(connectionId)) {
|
|
806
|
+
const entry = connections.describe().find((c) => c.id === connectionId);
|
|
807
|
+
if (entry) {
|
|
808
|
+
// Get the actual URL from the registry's internal state
|
|
809
|
+
// The describe() method masks the URL, so we need the raw URL for profiling.
|
|
810
|
+
// Check internal DB first (it has the encrypted URL).
|
|
811
|
+
if (hasInternalDB()) {
|
|
812
|
+
const rows = await internalQuery<{ url: string; schema_name: string | null }>(
|
|
813
|
+
"SELECT url, schema_name FROM connections WHERE id = $1",
|
|
814
|
+
[connectionId],
|
|
815
|
+
);
|
|
816
|
+
if (rows.length > 0) {
|
|
817
|
+
const url = decryptUrl(rows[0].url);
|
|
818
|
+
const dbType = detectDBType(url);
|
|
819
|
+
return { url, dbType, schema: rows[0].schema_name ?? "public" };
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
// Fallback: try ATLAS_DATASOURCE_URL for the "default" connection
|
|
824
|
+
if (connectionId === "default" && process.env.ATLAS_DATASOURCE_URL) {
|
|
825
|
+
const url = process.env.ATLAS_DATASOURCE_URL;
|
|
826
|
+
const dbType = detectDBType(url);
|
|
827
|
+
return { url, dbType, schema: "public" };
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
// Second try: internal DB only (connection not in runtime registry)
|
|
833
|
+
if (hasInternalDB()) {
|
|
834
|
+
const orgFilter = orgId ? " AND (org_id = $2 OR org_id IS NULL)" : "";
|
|
835
|
+
const params: unknown[] = [connectionId];
|
|
836
|
+
if (orgId) params.push(orgId);
|
|
837
|
+
|
|
838
|
+
const rows = await internalQuery<{ url: string; schema_name: string | null }>(
|
|
839
|
+
`SELECT url, schema_name FROM connections WHERE id = $1${orgFilter}`,
|
|
840
|
+
params,
|
|
841
|
+
);
|
|
842
|
+
if (rows.length > 0) {
|
|
843
|
+
const url = decryptUrl(rows[0].url);
|
|
844
|
+
const dbType = detectDBType(url);
|
|
845
|
+
return { url, dbType, schema: rows[0].schema_name ?? "public" };
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
return null;
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
export { wizard };
|