@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,776 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effect Services for Atlas.
|
|
3
|
+
*
|
|
4
|
+
* Defines Context.Tag services that replace global singletons with
|
|
5
|
+
* dependency-injected, scope-managed resources.
|
|
6
|
+
*
|
|
7
|
+
* ConnectionRegistry service (P4):
|
|
8
|
+
* - Pool lifecycle via Effect.acquireRelease
|
|
9
|
+
* - Health checks via Effect.repeat + Schedule.spaced (no setInterval)
|
|
10
|
+
* - Drain cooldown managed by ConnectionRegistry class via Set + Effect.sleep
|
|
11
|
+
* - Graceful shutdown via Effect.Scope (no manual ordering)
|
|
12
|
+
*
|
|
13
|
+
* PluginRegistry service (P5):
|
|
14
|
+
* - Health checks via Effect.repeat + Schedule.spaced (60s periodic)
|
|
15
|
+
* - Teardown via Effect.addFinalizer (delegates to class LIFO teardown)
|
|
16
|
+
* - Wired layer variant with type-level ConnectionRegistry dependency
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { Context, Effect, Layer, Duration, Schedule, Fiber } from "effect";
|
|
20
|
+
import type {
|
|
21
|
+
ConnectionRegistry as ConnectionRegistryClass,
|
|
22
|
+
DBConnection,
|
|
23
|
+
DBType,
|
|
24
|
+
ConnectionConfig,
|
|
25
|
+
ConnectionMetadata,
|
|
26
|
+
HealthCheckResult,
|
|
27
|
+
ConnectionPluginMeta,
|
|
28
|
+
OrgPoolSettings,
|
|
29
|
+
} from "@atlas/api/lib/db/connection";
|
|
30
|
+
import type { PoolMetrics, OrgPoolMetrics } from "@useatlas/types";
|
|
31
|
+
import { createLogger } from "@atlas/api/lib/logger";
|
|
32
|
+
import type {
|
|
33
|
+
PluginRegistry as PluginRegistryClass,
|
|
34
|
+
PluginLike,
|
|
35
|
+
PluginContextLike,
|
|
36
|
+
PluginHealthResult,
|
|
37
|
+
PluginType,
|
|
38
|
+
PluginStatus,
|
|
39
|
+
PluginDescription,
|
|
40
|
+
} from "@atlas/api/lib/plugins/registry";
|
|
41
|
+
|
|
42
|
+
const log = createLogger("effect:connection");
|
|
43
|
+
|
|
44
|
+
// ── Service interface ────────────────────────────────────────────────
|
|
45
|
+
|
|
46
|
+
/** Typed contract for the ConnectionRegistry Effect service. */
|
|
47
|
+
export interface ConnectionRegistryShape {
|
|
48
|
+
// --- Query operations ---
|
|
49
|
+
get(id: string): DBConnection;
|
|
50
|
+
getDefault(): DBConnection;
|
|
51
|
+
getForOrg(orgId: string, connectionId?: string): DBConnection;
|
|
52
|
+
|
|
53
|
+
// --- Registration ---
|
|
54
|
+
register(id: string, config: ConnectionConfig): void;
|
|
55
|
+
registerDirect(
|
|
56
|
+
id: string,
|
|
57
|
+
conn: DBConnection,
|
|
58
|
+
dbType: DBType,
|
|
59
|
+
description?: string,
|
|
60
|
+
validate?: (query: string) => { valid: boolean; reason?: string } | Promise<{ valid: boolean; reason?: string }>,
|
|
61
|
+
meta?: ConnectionPluginMeta,
|
|
62
|
+
): void;
|
|
63
|
+
unregister(id: string): boolean;
|
|
64
|
+
has(id: string): boolean;
|
|
65
|
+
|
|
66
|
+
// --- Metadata ---
|
|
67
|
+
list(): string[];
|
|
68
|
+
describe(): ConnectionMetadata[];
|
|
69
|
+
getDBType(id: string): DBType;
|
|
70
|
+
getTargetHost(id: string): string;
|
|
71
|
+
getValidator(id: string): ((query: string) => { valid: boolean; reason?: string } | Promise<{ valid: boolean; reason?: string }>) | undefined;
|
|
72
|
+
getParserDialect(id: string): string | undefined;
|
|
73
|
+
getForbiddenPatterns(id: string): RegExp[];
|
|
74
|
+
|
|
75
|
+
// --- Health ---
|
|
76
|
+
healthCheck(id: string): Promise<HealthCheckResult>;
|
|
77
|
+
|
|
78
|
+
// --- Pool management ---
|
|
79
|
+
drain(id: string): Promise<{ drained: boolean; message: string }>;
|
|
80
|
+
drainOrg(orgId: string): Promise<{ drained: number }>;
|
|
81
|
+
warmup(count?: number): Promise<void>;
|
|
82
|
+
|
|
83
|
+
// --- Metrics ---
|
|
84
|
+
recordQuery(id: string, durationMs: number, orgId?: string): void;
|
|
85
|
+
recordError(id: string, orgId?: string): void;
|
|
86
|
+
recordSuccess(id: string, orgId?: string): void;
|
|
87
|
+
getPoolMetrics(id: string): PoolMetrics;
|
|
88
|
+
getAllPoolMetrics(): PoolMetrics[];
|
|
89
|
+
getOrgPoolMetrics(orgId?: string): OrgPoolMetrics[];
|
|
90
|
+
|
|
91
|
+
// --- Org pool config ---
|
|
92
|
+
setOrgPoolConfig(config: Partial<Omit<OrgPoolSettings, "enabled">>): void;
|
|
93
|
+
isOrgPoolingEnabled(): boolean;
|
|
94
|
+
getOrgPoolConfig(): Readonly<OrgPoolSettings>;
|
|
95
|
+
getPoolWarnings(): string[];
|
|
96
|
+
listOrgs(): string[];
|
|
97
|
+
listOrgConnections(orgId: string): string[];
|
|
98
|
+
hasOrgPool(orgId: string, connectionId?: string): boolean;
|
|
99
|
+
|
|
100
|
+
// --- Config ---
|
|
101
|
+
setMaxTotalConnections(n: number): void;
|
|
102
|
+
|
|
103
|
+
// --- Lifecycle (managed by Effect scope — callers should not call directly) ---
|
|
104
|
+
shutdown(): Promise<void>;
|
|
105
|
+
_reset(): void;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// ── Context.Tag ──────────────────────────────────────────────────────
|
|
109
|
+
|
|
110
|
+
export class ConnectionRegistry extends Context.Tag("ConnectionRegistry")<
|
|
111
|
+
ConnectionRegistry,
|
|
112
|
+
ConnectionRegistryShape
|
|
113
|
+
>() {}
|
|
114
|
+
|
|
115
|
+
const HEALTH_CHECK_INTERVAL_MS = 60_000;
|
|
116
|
+
|
|
117
|
+
// ── Live Layer ───────────────────────────────────────────────────────
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Create the Live layer for ConnectionRegistry.
|
|
121
|
+
*
|
|
122
|
+
* Wraps a ConnectionRegistryClass instance with Effect-managed lifecycle:
|
|
123
|
+
* - Health checks: Effect.repeat + Schedule.spaced (replaces setInterval)
|
|
124
|
+
* - Drain cooldown: Effect.Ref<Set<string>> + Effect.sleep (replaces Date.now)
|
|
125
|
+
* - Shutdown: Effect.addFinalizer (replaces manual ordering)
|
|
126
|
+
*
|
|
127
|
+
* @param createImpl - Factory for the underlying registry instance.
|
|
128
|
+
* Defaults to creating a new ConnectionRegistryClass from the connection module.
|
|
129
|
+
*/
|
|
130
|
+
export function makeConnectionRegistryLive(
|
|
131
|
+
createImpl?: () => ConnectionRegistryClass,
|
|
132
|
+
): Layer.Layer<ConnectionRegistry> {
|
|
133
|
+
return Layer.scoped(
|
|
134
|
+
ConnectionRegistry,
|
|
135
|
+
Effect.gen(function* () {
|
|
136
|
+
// Create underlying registry (lazy import to avoid circular deps)
|
|
137
|
+
const impl = createImpl
|
|
138
|
+
? createImpl()
|
|
139
|
+
: yield* Effect.sync(() => {
|
|
140
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
141
|
+
const mod = require("@atlas/api/lib/db/connection");
|
|
142
|
+
return new mod.ConnectionRegistry() as ConnectionRegistryClass;
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// --- Health check fiber ---
|
|
146
|
+
const healthCheckAll = Effect.gen(function* () {
|
|
147
|
+
const ids = impl.list();
|
|
148
|
+
yield* Effect.forEach(
|
|
149
|
+
ids,
|
|
150
|
+
(id) =>
|
|
151
|
+
Effect.tryPromise({
|
|
152
|
+
try: () => impl.healthCheck(id),
|
|
153
|
+
catch: (err) =>
|
|
154
|
+
err instanceof Error ? err.message : String(err),
|
|
155
|
+
}).pipe(
|
|
156
|
+
Effect.catchAll((errMsg) => {
|
|
157
|
+
log.warn({ connectionId: id, err: errMsg }, "Periodic health check failed");
|
|
158
|
+
return Effect.void;
|
|
159
|
+
}),
|
|
160
|
+
),
|
|
161
|
+
{ concurrency: "unbounded" },
|
|
162
|
+
);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const healthFiber = yield* Effect.fork(
|
|
166
|
+
healthCheckAll.pipe(
|
|
167
|
+
// Catch expected failures but let defects (programming errors) crash the fiber.
|
|
168
|
+
// The inner forEach already catches individual health check failures, so this
|
|
169
|
+
// outer handler is a safety net for unexpected errors in the cycle itself.
|
|
170
|
+
Effect.catchAllCause((cause) => {
|
|
171
|
+
const msg = cause.toString();
|
|
172
|
+
log.warn({ err: msg }, "Health check cycle failed");
|
|
173
|
+
return Effect.void;
|
|
174
|
+
}),
|
|
175
|
+
Effect.repeat(Schedule.spaced(Duration.millis(HEALTH_CHECK_INTERVAL_MS))),
|
|
176
|
+
Effect.asVoid,
|
|
177
|
+
),
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
// --- Scope finalizer for graceful shutdown ---
|
|
181
|
+
yield* Effect.addFinalizer(() =>
|
|
182
|
+
Effect.gen(function* () {
|
|
183
|
+
yield* Fiber.interrupt(healthFiber);
|
|
184
|
+
yield* Effect.promise(() => impl.shutdown());
|
|
185
|
+
log.info("ConnectionRegistry shut down via Effect scope");
|
|
186
|
+
}),
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
// --- Build service interface ---
|
|
190
|
+
const service: ConnectionRegistryShape = {
|
|
191
|
+
// Query operations — delegate directly
|
|
192
|
+
get: (id) => impl.get(id),
|
|
193
|
+
getDefault: () => impl.getDefault(),
|
|
194
|
+
getForOrg: (orgId, connectionId) => impl.getForOrg(orgId, connectionId),
|
|
195
|
+
|
|
196
|
+
// Registration
|
|
197
|
+
register: (id, config) => impl.register(id, config),
|
|
198
|
+
registerDirect: (id, conn, dbType, description, validate, meta) =>
|
|
199
|
+
impl.registerDirect(id, conn, dbType, description, validate, meta),
|
|
200
|
+
unregister: (id) => impl.unregister(id),
|
|
201
|
+
has: (id) => impl.has(id),
|
|
202
|
+
|
|
203
|
+
// Metadata
|
|
204
|
+
list: () => impl.list(),
|
|
205
|
+
describe: () => impl.describe(),
|
|
206
|
+
getDBType: (id) => impl.getDBType(id),
|
|
207
|
+
getTargetHost: (id) => impl.getTargetHost(id),
|
|
208
|
+
getValidator: (id) => impl.getValidator(id),
|
|
209
|
+
getParserDialect: (id) => impl.getParserDialect(id),
|
|
210
|
+
getForbiddenPatterns: (id) => impl.getForbiddenPatterns(id),
|
|
211
|
+
|
|
212
|
+
// Health — managed by the fiber, but expose direct access too
|
|
213
|
+
healthCheck: (id) => impl.healthCheck(id),
|
|
214
|
+
|
|
215
|
+
// Pool management — drain cooldown is managed by the impl via Set + Effect.sleep
|
|
216
|
+
drain: (id) => impl.drain(id),
|
|
217
|
+
drainOrg: (orgId) => impl.drainOrg(orgId),
|
|
218
|
+
warmup: (count) => impl.warmup(count),
|
|
219
|
+
|
|
220
|
+
// Metrics
|
|
221
|
+
recordQuery: (id, durationMs, orgId) => impl.recordQuery(id, durationMs, orgId),
|
|
222
|
+
recordError: (id, orgId) => impl.recordError(id, orgId),
|
|
223
|
+
recordSuccess: (id, orgId) => impl.recordSuccess(id, orgId),
|
|
224
|
+
getPoolMetrics: (id) => impl.getPoolMetrics(id),
|
|
225
|
+
getAllPoolMetrics: () => impl.getAllPoolMetrics(),
|
|
226
|
+
getOrgPoolMetrics: (orgId) => impl.getOrgPoolMetrics(orgId),
|
|
227
|
+
|
|
228
|
+
// Org pool config
|
|
229
|
+
setOrgPoolConfig: (config) => impl.setOrgPoolConfig(config),
|
|
230
|
+
isOrgPoolingEnabled: () => impl.isOrgPoolingEnabled(),
|
|
231
|
+
getOrgPoolConfig: () => impl.getOrgPoolConfig(),
|
|
232
|
+
getPoolWarnings: () => impl.getPoolWarnings(),
|
|
233
|
+
listOrgs: () => impl.listOrgs(),
|
|
234
|
+
listOrgConnections: (orgId) => impl.listOrgConnections(orgId),
|
|
235
|
+
hasOrgPool: (orgId, connectionId) => impl.hasOrgPool(orgId, connectionId),
|
|
236
|
+
|
|
237
|
+
// Config
|
|
238
|
+
setMaxTotalConnections: (n) => impl.setMaxTotalConnections(n),
|
|
239
|
+
|
|
240
|
+
// Lifecycle — exposed but managed by scope
|
|
241
|
+
shutdown: () => impl.shutdown(),
|
|
242
|
+
_reset: () => impl._reset(),
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
return service;
|
|
246
|
+
}),
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** Default Live layer using the global ConnectionRegistry constructor. */
|
|
251
|
+
export const ConnectionRegistryLive: Layer.Layer<ConnectionRegistry> =
|
|
252
|
+
makeConnectionRegistryLive();
|
|
253
|
+
|
|
254
|
+
// ── Test helper ──────────────────────────────────────────────────────
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Create a test Layer from a partial service implementation.
|
|
258
|
+
*
|
|
259
|
+
* Provides a ConnectionRegistry service backed by stub methods.
|
|
260
|
+
* Unspecified methods throw with a descriptive error.
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* ```ts
|
|
264
|
+
* const TestLayer = createTestLayer({
|
|
265
|
+
* get: () => mockConn,
|
|
266
|
+
* getDefault: () => mockConn,
|
|
267
|
+
* list: () => ["default"],
|
|
268
|
+
* });
|
|
269
|
+
* const result = await Effect.runPromise(
|
|
270
|
+
* program.pipe(Effect.provide(TestLayer))
|
|
271
|
+
* );
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
274
|
+
export function createTestLayer(
|
|
275
|
+
partial: Partial<ConnectionRegistryShape>,
|
|
276
|
+
): Layer.Layer<ConnectionRegistry> {
|
|
277
|
+
const handler: ProxyHandler<ConnectionRegistryShape> = {
|
|
278
|
+
get(_target, prop: string | symbol) {
|
|
279
|
+
// Ignore symbols (Symbol.toPrimitive, Symbol.toStringTag, etc.) and
|
|
280
|
+
// well-known properties that runtimes/libraries probe for (then, toJSON)
|
|
281
|
+
if (typeof prop === "symbol") return undefined;
|
|
282
|
+
if (prop === "then" || prop === "toJSON") return undefined;
|
|
283
|
+
if (prop in partial) {
|
|
284
|
+
return (partial as Record<string, unknown>)[prop];
|
|
285
|
+
}
|
|
286
|
+
return (..._args: unknown[]) => {
|
|
287
|
+
throw new Error(
|
|
288
|
+
`ConnectionRegistry test stub: "${prop}" was called but not provided in createTestLayer()`,
|
|
289
|
+
);
|
|
290
|
+
};
|
|
291
|
+
},
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
const stubService = new Proxy({} as ConnectionRegistryShape, handler);
|
|
295
|
+
return Layer.succeed(ConnectionRegistry, stubService);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// ══════════════════════════════════════════════════════════════════════
|
|
299
|
+
// ██ Plugin Registry Service (P5)
|
|
300
|
+
// ══════════════════════════════════════════════════════════════════════
|
|
301
|
+
|
|
302
|
+
const pluginLog = createLogger("effect:plugin");
|
|
303
|
+
|
|
304
|
+
// ── Service interface ────────────────────────────────────────────────
|
|
305
|
+
|
|
306
|
+
/** Typed contract for the PluginRegistry Effect service. */
|
|
307
|
+
export interface PluginRegistryShape {
|
|
308
|
+
// --- Registration ---
|
|
309
|
+
register(plugin: PluginLike): void;
|
|
310
|
+
|
|
311
|
+
// --- Lifecycle ---
|
|
312
|
+
initializeAll(
|
|
313
|
+
ctx: PluginContextLike,
|
|
314
|
+
): Promise<{ succeeded: string[]; failed: string[] }>;
|
|
315
|
+
healthCheckAll(): Promise<
|
|
316
|
+
Map<string, PluginHealthResult & { status: PluginStatus }>
|
|
317
|
+
>;
|
|
318
|
+
teardownAll(): Promise<void>;
|
|
319
|
+
|
|
320
|
+
// --- Query ---
|
|
321
|
+
get(id: string): PluginLike | undefined;
|
|
322
|
+
getStatus(id: string): PluginStatus | undefined;
|
|
323
|
+
getByType(type: PluginType): PluginLike[];
|
|
324
|
+
getAll(): PluginLike[];
|
|
325
|
+
getAllHealthy(): PluginLike[];
|
|
326
|
+
describe(): PluginDescription[];
|
|
327
|
+
|
|
328
|
+
// --- Enable/disable ---
|
|
329
|
+
enable(id: string): boolean;
|
|
330
|
+
disable(id: string): boolean;
|
|
331
|
+
isEnabled(id: string): boolean;
|
|
332
|
+
|
|
333
|
+
// --- Size ---
|
|
334
|
+
readonly size: number;
|
|
335
|
+
|
|
336
|
+
// --- Test only ---
|
|
337
|
+
_reset(): void;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// ── Context.Tag ──────────────────────────────────────────────────────
|
|
341
|
+
|
|
342
|
+
export class PluginRegistry extends Context.Tag("PluginRegistry")<
|
|
343
|
+
PluginRegistry,
|
|
344
|
+
PluginRegistryShape
|
|
345
|
+
>() {}
|
|
346
|
+
|
|
347
|
+
const PLUGIN_HEALTH_CHECK_INTERVAL_MS = 60_000;
|
|
348
|
+
|
|
349
|
+
// ── Shared Layer internals ───────────────────────────────────────────
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Build the PluginRegistry service + health-check fiber + scope finalizer.
|
|
353
|
+
* Shared between makePluginRegistryLive and makeWiredPluginRegistryLive.
|
|
354
|
+
*/
|
|
355
|
+
function buildPluginService(impl: PluginRegistryClass) {
|
|
356
|
+
return Effect.gen(function* () {
|
|
357
|
+
// --- Health check fiber (replaces on-demand-only checks) ---
|
|
358
|
+
const healthCheckCycle = Effect.tryPromise({
|
|
359
|
+
try: () => impl.healthCheckAll(),
|
|
360
|
+
catch: (err) => (err instanceof Error ? err.message : String(err)),
|
|
361
|
+
}).pipe(
|
|
362
|
+
Effect.catchAll((errMsg) => {
|
|
363
|
+
pluginLog.warn({ err: errMsg }, "Periodic plugin health check failed");
|
|
364
|
+
return Effect.void;
|
|
365
|
+
}),
|
|
366
|
+
);
|
|
367
|
+
|
|
368
|
+
const healthFiber = yield* Effect.fork(
|
|
369
|
+
healthCheckCycle.pipe(
|
|
370
|
+
Effect.catchAllCause((cause) => {
|
|
371
|
+
pluginLog.warn(
|
|
372
|
+
{ err: cause.toString() },
|
|
373
|
+
"Plugin health check cycle failed",
|
|
374
|
+
);
|
|
375
|
+
return Effect.void;
|
|
376
|
+
}),
|
|
377
|
+
Effect.repeat(
|
|
378
|
+
Schedule.spaced(Duration.millis(PLUGIN_HEALTH_CHECK_INTERVAL_MS)),
|
|
379
|
+
),
|
|
380
|
+
Effect.asVoid,
|
|
381
|
+
),
|
|
382
|
+
);
|
|
383
|
+
|
|
384
|
+
// --- Scope finalizer for graceful shutdown ---
|
|
385
|
+
// addFinalizer triggers teardownAll on scope close;
|
|
386
|
+
// teardownAll iterates plugins in reverse registration order (LIFO) internally.
|
|
387
|
+
yield* Effect.addFinalizer(() =>
|
|
388
|
+
Effect.gen(function* () {
|
|
389
|
+
yield* Fiber.interrupt(healthFiber);
|
|
390
|
+
yield* Effect.tryPromise({
|
|
391
|
+
try: () => impl.teardownAll(),
|
|
392
|
+
catch: (err) => (err instanceof Error ? err.message : String(err)),
|
|
393
|
+
}).pipe(
|
|
394
|
+
Effect.catchAll((errMsg) => {
|
|
395
|
+
pluginLog.error({ err: errMsg }, "PluginRegistry teardownAll failed during shutdown");
|
|
396
|
+
return Effect.void;
|
|
397
|
+
}),
|
|
398
|
+
);
|
|
399
|
+
pluginLog.info("PluginRegistry shut down via Effect scope");
|
|
400
|
+
}),
|
|
401
|
+
);
|
|
402
|
+
|
|
403
|
+
// --- Build service interface (delegates to underlying impl) ---
|
|
404
|
+
const service: PluginRegistryShape = {
|
|
405
|
+
register: (plugin) => impl.register(plugin),
|
|
406
|
+
initializeAll: (ctx) => impl.initializeAll(ctx),
|
|
407
|
+
healthCheckAll: () => impl.healthCheckAll(),
|
|
408
|
+
teardownAll: () => impl.teardownAll(),
|
|
409
|
+
get: (id) => impl.get(id),
|
|
410
|
+
getStatus: (id) => impl.getStatus(id),
|
|
411
|
+
getByType: (type) => impl.getByType(type),
|
|
412
|
+
getAll: () => impl.getAll(),
|
|
413
|
+
getAllHealthy: () => impl.getAllHealthy(),
|
|
414
|
+
describe: () => impl.describe(),
|
|
415
|
+
enable: (id) => impl.enable(id),
|
|
416
|
+
disable: (id) => impl.disable(id),
|
|
417
|
+
isEnabled: (id) => impl.isEnabled(id),
|
|
418
|
+
get size() {
|
|
419
|
+
return impl.size;
|
|
420
|
+
},
|
|
421
|
+
_reset: () => impl._reset(),
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
return service;
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/** Create the underlying PluginRegistry class instance. */
|
|
429
|
+
function createPluginImpl(createImpl?: () => PluginRegistryClass) {
|
|
430
|
+
return createImpl
|
|
431
|
+
? Effect.sync(createImpl)
|
|
432
|
+
: Effect.sync(() => {
|
|
433
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
434
|
+
const mod = require("@atlas/api/lib/plugins/registry");
|
|
435
|
+
return new mod.PluginRegistry() as PluginRegistryClass;
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// ── Live Layer ───────────────────────────────────────────────────────
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Create the Live layer for PluginRegistry.
|
|
443
|
+
*
|
|
444
|
+
* Wraps a PluginRegistryClass instance with Effect-managed lifecycle:
|
|
445
|
+
* - Health checks: Effect.repeat + Schedule.spaced (60s interval)
|
|
446
|
+
* - Teardown: Effect.addFinalizer (delegates to impl.teardownAll which runs LIFO)
|
|
447
|
+
*
|
|
448
|
+
* @param createImpl - Factory for the underlying registry instance.
|
|
449
|
+
* Defaults to creating a new PluginRegistryClass from the plugin module.
|
|
450
|
+
*/
|
|
451
|
+
export function makePluginRegistryLive(
|
|
452
|
+
createImpl?: () => PluginRegistryClass,
|
|
453
|
+
): Layer.Layer<PluginRegistry> {
|
|
454
|
+
return Layer.scoped(
|
|
455
|
+
PluginRegistry,
|
|
456
|
+
Effect.gen(function* () {
|
|
457
|
+
const impl = yield* createPluginImpl(createImpl);
|
|
458
|
+
return yield* buildPluginService(impl);
|
|
459
|
+
}),
|
|
460
|
+
);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/** Default Live layer using the global PluginRegistry constructor. */
|
|
464
|
+
export const PluginRegistryLive: Layer.Layer<PluginRegistry> =
|
|
465
|
+
makePluginRegistryLive();
|
|
466
|
+
|
|
467
|
+
// ── Wired Layer ──────────────────────────────────────────────────────
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Config for building a PluginRegistry Layer that registers, initializes,
|
|
471
|
+
* and wires plugins as part of Layer construction.
|
|
472
|
+
*/
|
|
473
|
+
export interface PluginWiringConfig {
|
|
474
|
+
/** Plugins to register (from atlas.config.ts). */
|
|
475
|
+
readonly plugins: ReadonlyArray<PluginLike>;
|
|
476
|
+
/** Context passed to plugin.initialize(). */
|
|
477
|
+
readonly context: PluginContextLike;
|
|
478
|
+
/** Hono app instance for mounting interaction plugin routes. */
|
|
479
|
+
readonly app?: { route(path: string, subApp: unknown): void };
|
|
480
|
+
/** Tool registry for action plugin tools. */
|
|
481
|
+
readonly toolRegistry?: { register(tool: unknown): void };
|
|
482
|
+
/** Schema migration callback (runs before initialize). */
|
|
483
|
+
readonly runMigrations?: (
|
|
484
|
+
allPlugins: ReadonlyArray<PluginLike>,
|
|
485
|
+
) => Promise<void>;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Create a Layer that registers, initializes, and wires plugins.
|
|
490
|
+
*
|
|
491
|
+
* Declares ConnectionRegistry as a dependency — the type system enforces
|
|
492
|
+
* that connections must be available before plugin datasources can be wired.
|
|
493
|
+
* This replaces the imperative startup sequence in server.ts with type-safe
|
|
494
|
+
* Layer composition where dependency ordering is enforced at the type level.
|
|
495
|
+
*
|
|
496
|
+
* Startup sequence:
|
|
497
|
+
* register → migrate → initialize → wire datasources → wire actions →
|
|
498
|
+
* wire context → wire interactions → health check loop → teardown
|
|
499
|
+
*/
|
|
500
|
+
export function makeWiredPluginRegistryLive(
|
|
501
|
+
config: PluginWiringConfig,
|
|
502
|
+
createImpl?: () => PluginRegistryClass,
|
|
503
|
+
): Layer.Layer<PluginRegistry, never, ConnectionRegistry> {
|
|
504
|
+
return Layer.scoped(
|
|
505
|
+
PluginRegistry,
|
|
506
|
+
Effect.gen(function* () {
|
|
507
|
+
// Dependency: ConnectionRegistry must be provided before wiring.
|
|
508
|
+
// This is enforced at the type level — the Layer won't compile
|
|
509
|
+
// without ConnectionRegistry in the provided context.
|
|
510
|
+
const connRegistry = yield* ConnectionRegistry;
|
|
511
|
+
|
|
512
|
+
const impl = yield* createPluginImpl(createImpl);
|
|
513
|
+
|
|
514
|
+
// --- Registration ---
|
|
515
|
+
for (const plugin of config.plugins) {
|
|
516
|
+
impl.register(plugin);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// --- Schema migrations (before initialize so plugins can use their tables) ---
|
|
520
|
+
if (config.runMigrations) {
|
|
521
|
+
yield* Effect.tryPromise({
|
|
522
|
+
try: () => config.runMigrations!(impl.getAll()),
|
|
523
|
+
catch: (err) => (err instanceof Error ? err.message : String(err)),
|
|
524
|
+
}).pipe(
|
|
525
|
+
Effect.catchAll((errMsg) => {
|
|
526
|
+
pluginLog.error({ err: errMsg }, "Plugin schema migrations failed");
|
|
527
|
+
return Effect.void;
|
|
528
|
+
}),
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
// --- Initialize all ---
|
|
533
|
+
const { succeeded, failed } = yield* Effect.tryPromise({
|
|
534
|
+
try: () => impl.initializeAll(config.context),
|
|
535
|
+
catch: (err) => (err instanceof Error ? err.message : String(err)),
|
|
536
|
+
}).pipe(
|
|
537
|
+
Effect.catchAll((errMsg) => {
|
|
538
|
+
pluginLog.error({ err: errMsg }, "Plugin initializeAll threw unexpectedly");
|
|
539
|
+
return Effect.succeed({ succeeded: [] as string[], failed: [] as string[] });
|
|
540
|
+
}),
|
|
541
|
+
);
|
|
542
|
+
if (failed.length > 0) {
|
|
543
|
+
pluginLog.error(
|
|
544
|
+
{ succeeded, failed },
|
|
545
|
+
`Plugin initialization completed with ${failed.length} failure(s)`,
|
|
546
|
+
);
|
|
547
|
+
} else if (succeeded.length > 0) {
|
|
548
|
+
pluginLog.info({ succeeded }, "All plugins initialized");
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
// --- Wire datasources (ConnectionRegistry from Layer context) ---
|
|
552
|
+
// Bridge: ConnectionRegistryShape ↔ class (structural match for registerDirect)
|
|
553
|
+
const dsResult = yield* Effect.tryPromise({
|
|
554
|
+
try: async () => {
|
|
555
|
+
const { wireDatasourcePlugins } = await import(
|
|
556
|
+
"@atlas/api/lib/plugins/wiring"
|
|
557
|
+
);
|
|
558
|
+
return wireDatasourcePlugins(
|
|
559
|
+
impl,
|
|
560
|
+
connRegistry as unknown as ConnectionRegistryClass,
|
|
561
|
+
);
|
|
562
|
+
},
|
|
563
|
+
catch: (err) => (err instanceof Error ? err.message : String(err)),
|
|
564
|
+
}).pipe(
|
|
565
|
+
Effect.catchAll((errMsg) => {
|
|
566
|
+
pluginLog.error({ err: errMsg }, "Datasource wiring failed entirely");
|
|
567
|
+
return Effect.succeed({ wired: [] as string[], failed: [] as Array<{ pluginId: string; error: string }>, dialectHints: [] as Array<{ pluginId: string; dialect: string }>, entityFailures: [] as Array<{ pluginId: string; error: string }> });
|
|
568
|
+
}),
|
|
569
|
+
);
|
|
570
|
+
if (dsResult.failed.length > 0) {
|
|
571
|
+
pluginLog.error({ failed: dsResult.failed }, "Some datasource plugins failed to wire");
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
// --- Wire actions ---
|
|
575
|
+
if (config.toolRegistry) {
|
|
576
|
+
const actResult = yield* Effect.tryPromise({
|
|
577
|
+
try: async () => {
|
|
578
|
+
const { wireActionPlugins } = await import(
|
|
579
|
+
"@atlas/api/lib/plugins/wiring"
|
|
580
|
+
);
|
|
581
|
+
return wireActionPlugins(impl, config.toolRegistry as never);
|
|
582
|
+
},
|
|
583
|
+
catch: (err) => (err instanceof Error ? err.message : String(err)),
|
|
584
|
+
}).pipe(
|
|
585
|
+
Effect.catchAll((errMsg) => {
|
|
586
|
+
pluginLog.error({ err: errMsg }, "Action wiring failed entirely");
|
|
587
|
+
return Effect.succeed({ wired: [] as string[], failed: [] as Array<{ pluginId: string; error: string }> });
|
|
588
|
+
}),
|
|
589
|
+
);
|
|
590
|
+
if (actResult.failed.length > 0) {
|
|
591
|
+
pluginLog.error({ failed: actResult.failed }, "Some action plugins failed to wire");
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
// --- Wire context ---
|
|
596
|
+
const ctxResult = yield* Effect.tryPromise({
|
|
597
|
+
try: async () => {
|
|
598
|
+
const { wireContextPlugins } = await import(
|
|
599
|
+
"@atlas/api/lib/plugins/wiring"
|
|
600
|
+
);
|
|
601
|
+
return wireContextPlugins(impl);
|
|
602
|
+
},
|
|
603
|
+
catch: (err) => (err instanceof Error ? err.message : String(err)),
|
|
604
|
+
}).pipe(
|
|
605
|
+
Effect.catchAll((errMsg) => {
|
|
606
|
+
pluginLog.error({ err: errMsg }, "Context wiring failed entirely");
|
|
607
|
+
return Effect.succeed({ fragments: [] as string[], failed: [] as Array<{ pluginId: string; error: string }> });
|
|
608
|
+
}),
|
|
609
|
+
);
|
|
610
|
+
if (ctxResult.failed.length > 0) {
|
|
611
|
+
pluginLog.error({ failed: ctxResult.failed }, "Some context plugins failed to load");
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
// --- Wire interaction routes ---
|
|
615
|
+
if (config.app) {
|
|
616
|
+
const intResult = yield* Effect.tryPromise({
|
|
617
|
+
try: async () => {
|
|
618
|
+
const { wireInteractionPlugins } = await import(
|
|
619
|
+
"@atlas/api/lib/plugins/wiring"
|
|
620
|
+
);
|
|
621
|
+
return wireInteractionPlugins(impl, config.app);
|
|
622
|
+
},
|
|
623
|
+
catch: (err) => (err instanceof Error ? err.message : String(err)),
|
|
624
|
+
}).pipe(
|
|
625
|
+
Effect.catchAll((errMsg) => {
|
|
626
|
+
pluginLog.error({ err: errMsg }, "Interaction wiring failed entirely");
|
|
627
|
+
return Effect.succeed({ wired: [] as string[], failed: [] as Array<{ pluginId: string; error: string }> });
|
|
628
|
+
}),
|
|
629
|
+
);
|
|
630
|
+
if (intResult.failed.length > 0) {
|
|
631
|
+
pluginLog.error({ failed: intResult.failed }, "Some interaction plugins failed to wire");
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
return yield* buildPluginService(impl);
|
|
636
|
+
}),
|
|
637
|
+
);
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
// ── Test helper ──────────────────────────────────────────────────────
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* Create a test Layer from a partial PluginRegistry service implementation.
|
|
644
|
+
*
|
|
645
|
+
* Provides a PluginRegistry service backed by stub methods.
|
|
646
|
+
* Unspecified methods throw with a descriptive error.
|
|
647
|
+
*
|
|
648
|
+
* @example
|
|
649
|
+
* ```ts
|
|
650
|
+
* const TestLayer = createPluginTestLayer({
|
|
651
|
+
* getAll: () => [],
|
|
652
|
+
* describe: () => [],
|
|
653
|
+
* });
|
|
654
|
+
* const result = await Effect.runPromise(
|
|
655
|
+
* program.pipe(Effect.provide(TestLayer))
|
|
656
|
+
* );
|
|
657
|
+
* ```
|
|
658
|
+
*/
|
|
659
|
+
export function createPluginTestLayer(
|
|
660
|
+
partial: Partial<PluginRegistryShape>,
|
|
661
|
+
): Layer.Layer<PluginRegistry> {
|
|
662
|
+
const handler: ProxyHandler<PluginRegistryShape> = {
|
|
663
|
+
get(_target, prop: string | symbol) {
|
|
664
|
+
if (typeof prop === "symbol") return undefined;
|
|
665
|
+
if (prop === "then" || prop === "toJSON") return undefined;
|
|
666
|
+
if (prop in partial) {
|
|
667
|
+
return (partial as Record<string, unknown>)[prop];
|
|
668
|
+
}
|
|
669
|
+
return (..._args: unknown[]) => {
|
|
670
|
+
throw new Error(
|
|
671
|
+
`PluginRegistry test stub: "${prop}" was called but not provided in createPluginTestLayer()`,
|
|
672
|
+
);
|
|
673
|
+
};
|
|
674
|
+
},
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
const stubService = new Proxy({} as PluginRegistryShape, handler);
|
|
678
|
+
return Layer.succeed(PluginRegistry, stubService);
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
// ══════════════════════════════════════════════════════════════════════
|
|
682
|
+
// ██ Request Context Service (P8)
|
|
683
|
+
// ══════════════════════════════════════════════════════════════════════
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* Per-request context available to all Effect programs running within
|
|
687
|
+
* a route handler. Bridges from Hono's `c.get("requestId")`.
|
|
688
|
+
*/
|
|
689
|
+
export interface RequestContextShape {
|
|
690
|
+
readonly requestId: string;
|
|
691
|
+
readonly startTime: number;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
export class RequestContext extends Context.Tag("RequestContext")<
|
|
695
|
+
RequestContext,
|
|
696
|
+
RequestContextShape
|
|
697
|
+
>() {}
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* Create a RequestContext Layer from concrete values.
|
|
701
|
+
* Used by runHandler to bridge Hono context → Effect Context.
|
|
702
|
+
*/
|
|
703
|
+
export function makeRequestContextLayer(
|
|
704
|
+
requestId: string,
|
|
705
|
+
startTime?: number,
|
|
706
|
+
): Layer.Layer<RequestContext> {
|
|
707
|
+
return Layer.succeed(RequestContext, {
|
|
708
|
+
requestId,
|
|
709
|
+
startTime: startTime ?? Date.now(),
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/** Create a test Layer for RequestContext. */
|
|
714
|
+
export function createRequestContextTestLayer(
|
|
715
|
+
partial: Partial<RequestContextShape> = {},
|
|
716
|
+
): Layer.Layer<RequestContext> {
|
|
717
|
+
return Layer.succeed(RequestContext, {
|
|
718
|
+
requestId: partial.requestId ?? "test-request-id",
|
|
719
|
+
startTime: partial.startTime ?? Date.now(),
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
// ══════════════════════════════════════════════════════════════════════
|
|
724
|
+
// ██ Auth Context Service (P8)
|
|
725
|
+
// ══════════════════════════════════════════════════════════════════════
|
|
726
|
+
|
|
727
|
+
type AtlasUser = import("@useatlas/types/auth").AtlasUser;
|
|
728
|
+
type AuthMode = import("@useatlas/types/auth").AuthMode;
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* Authenticated user context available to Effect programs.
|
|
732
|
+
* Bridges from Hono's `c.get("authResult")`.
|
|
733
|
+
*
|
|
734
|
+
* Only provided when the request is authenticated (`authResult.authenticated === true`).
|
|
735
|
+
* Programs that `yield* AuthContext` will fail with a missing-service error
|
|
736
|
+
* if auth middleware has not run — this is the compile-time guarantee that
|
|
737
|
+
* replaces the runtime `c.get("authResult")` check.
|
|
738
|
+
*/
|
|
739
|
+
export interface AuthContextShape {
|
|
740
|
+
readonly mode: AuthMode;
|
|
741
|
+
/** Authenticated user. Undefined only in "none" auth mode (local dev). */
|
|
742
|
+
readonly user: AtlasUser | undefined;
|
|
743
|
+
/** Convenience: active org ID from user, or undefined. */
|
|
744
|
+
readonly orgId: string | undefined;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
export class AuthContext extends Context.Tag("AuthContext")<
|
|
748
|
+
AuthContext,
|
|
749
|
+
AuthContextShape
|
|
750
|
+
>() {}
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Create an AuthContext Layer from an authenticated AuthResult.
|
|
754
|
+
* Used by runHandler to bridge Hono context → Effect Context.
|
|
755
|
+
*/
|
|
756
|
+
export function makeAuthContextLayer(
|
|
757
|
+
mode: AuthMode,
|
|
758
|
+
user: AtlasUser | undefined,
|
|
759
|
+
): Layer.Layer<AuthContext> {
|
|
760
|
+
return Layer.succeed(AuthContext, {
|
|
761
|
+
mode,
|
|
762
|
+
user,
|
|
763
|
+
orgId: user?.activeOrganizationId,
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
/** Create a test Layer for AuthContext. */
|
|
768
|
+
export function createAuthContextTestLayer(
|
|
769
|
+
partial: Partial<AuthContextShape> = {},
|
|
770
|
+
): Layer.Layer<AuthContext> {
|
|
771
|
+
return Layer.succeed(AuthContext, {
|
|
772
|
+
mode: partial.mode ?? "none",
|
|
773
|
+
user: partial.user,
|
|
774
|
+
orgId: partial.orgId ?? partial.user?.activeOrganizationId,
|
|
775
|
+
});
|
|
776
|
+
}
|