@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
|
@@ -1,875 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from "bun:test";
|
|
2
|
-
import {
|
|
3
|
-
generateMigrationSQL,
|
|
4
|
-
generateColumnMigrations,
|
|
5
|
-
runPluginMigrations,
|
|
6
|
-
applyMigrations,
|
|
7
|
-
ensureMigrationsTable,
|
|
8
|
-
getAppliedMigrations,
|
|
9
|
-
diffSchema,
|
|
10
|
-
prefixTableName,
|
|
11
|
-
type MigrateDB,
|
|
12
|
-
type MigrationStatement,
|
|
13
|
-
} from "../migrate";
|
|
14
|
-
|
|
15
|
-
// ---------------------------------------------------------------------------
|
|
16
|
-
// Mock DB
|
|
17
|
-
// ---------------------------------------------------------------------------
|
|
18
|
-
|
|
19
|
-
interface QueryLog {
|
|
20
|
-
sql: string;
|
|
21
|
-
params?: unknown[];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function makeMockDB(opts?: {
|
|
25
|
-
existingMigrations?: Array<{ plugin_id: string; table_name: string; sql_hash: string }>;
|
|
26
|
-
existingTables?: string[];
|
|
27
|
-
/** Map of table name → existing column names (for information_schema.columns queries) */
|
|
28
|
-
existingColumns?: Record<string, string[]>;
|
|
29
|
-
failOnCreate?: boolean;
|
|
30
|
-
}): MigrateDB & { queries: QueryLog[] } {
|
|
31
|
-
const queries: QueryLog[] = [];
|
|
32
|
-
const existingMigrations = [...(opts?.existingMigrations ?? [])];
|
|
33
|
-
const existingTables = opts?.existingTables ?? [];
|
|
34
|
-
const existingColumns = opts?.existingColumns ?? {};
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
queries,
|
|
38
|
-
async query(sql: string, params?: unknown[]) {
|
|
39
|
-
queries.push({ sql, params });
|
|
40
|
-
|
|
41
|
-
if (opts?.failOnCreate && sql.includes("CREATE TABLE") && !sql.includes("plugin_migrations")) {
|
|
42
|
-
throw new Error("permission denied for schema public");
|
|
43
|
-
}
|
|
44
|
-
if (sql.includes("FROM plugin_migrations")) {
|
|
45
|
-
return { rows: existingMigrations };
|
|
46
|
-
}
|
|
47
|
-
// Track migrations inserted via applyMigrations
|
|
48
|
-
if (sql.includes("INSERT INTO plugin_migrations") && params) {
|
|
49
|
-
existingMigrations.push({
|
|
50
|
-
plugin_id: String(params[0]),
|
|
51
|
-
table_name: String(params[1]),
|
|
52
|
-
sql_hash: String(params[2]),
|
|
53
|
-
});
|
|
54
|
-
return { rows: [] };
|
|
55
|
-
}
|
|
56
|
-
if (sql.includes("FROM pg_tables")) {
|
|
57
|
-
return { rows: existingTables.map((t) => ({ tablename: t })) };
|
|
58
|
-
}
|
|
59
|
-
if (sql.includes("information_schema.columns") && params?.[0]) {
|
|
60
|
-
const tableName = String(params[0]);
|
|
61
|
-
const cols = existingColumns[tableName] ?? [];
|
|
62
|
-
return { rows: cols.map((c) => ({ column_name: c })) };
|
|
63
|
-
}
|
|
64
|
-
return { rows: [] };
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// ---------------------------------------------------------------------------
|
|
70
|
-
// Helpers
|
|
71
|
-
// ---------------------------------------------------------------------------
|
|
72
|
-
|
|
73
|
-
function makePlugin(
|
|
74
|
-
id: string,
|
|
75
|
-
schema: Record<string, { fields: Record<string, unknown> }>,
|
|
76
|
-
) {
|
|
77
|
-
return { id, schema };
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// ---------------------------------------------------------------------------
|
|
81
|
-
// prefixTableName
|
|
82
|
-
// ---------------------------------------------------------------------------
|
|
83
|
-
|
|
84
|
-
describe("prefixTableName", () => {
|
|
85
|
-
test("basic prefixing", () => {
|
|
86
|
-
expect(prefixTableName("jira", "tickets")).toBe("plugin_jira_tickets");
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
test("replaces dashes with underscores", () => {
|
|
90
|
-
expect(prefixTableName("my-plugin", "user-tokens")).toBe("plugin_my_plugin_user_tokens");
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
test("replaces dots with underscores", () => {
|
|
94
|
-
expect(prefixTableName("com.example", "data")).toBe("plugin_com_example_data");
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
// ---------------------------------------------------------------------------
|
|
99
|
-
// generateMigrationSQL
|
|
100
|
-
// ---------------------------------------------------------------------------
|
|
101
|
-
|
|
102
|
-
describe("generateMigrationSQL", () => {
|
|
103
|
-
test("generates CREATE TABLE for string, number, boolean, date types", () => {
|
|
104
|
-
const plugins = [
|
|
105
|
-
makePlugin("test", {
|
|
106
|
-
items: {
|
|
107
|
-
fields: {
|
|
108
|
-
name: { type: "string", required: true },
|
|
109
|
-
count: { type: "number" },
|
|
110
|
-
active: { type: "boolean" },
|
|
111
|
-
due_date: { type: "date" },
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
}),
|
|
115
|
-
];
|
|
116
|
-
|
|
117
|
-
const stmts = generateMigrationSQL(plugins as Parameters<typeof generateMigrationSQL>[0]);
|
|
118
|
-
expect(stmts).toHaveLength(1);
|
|
119
|
-
|
|
120
|
-
const sql = stmts[0].sql;
|
|
121
|
-
expect(sql).toContain('CREATE TABLE IF NOT EXISTS "plugin_test_items"');
|
|
122
|
-
expect(sql).toContain('"name" TEXT NOT NULL');
|
|
123
|
-
expect(sql).toContain('"count" INTEGER');
|
|
124
|
-
expect(sql).toContain('"active" BOOLEAN');
|
|
125
|
-
expect(sql).toContain('"due_date" TIMESTAMPTZ');
|
|
126
|
-
expect(sql).toContain('"id" UUID PRIMARY KEY DEFAULT gen_random_uuid()');
|
|
127
|
-
expect(sql).toContain('"created_at" TIMESTAMPTZ DEFAULT now()');
|
|
128
|
-
expect(sql).toContain('"updated_at" TIMESTAMPTZ DEFAULT now()');
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
test("handles UNIQUE constraint", () => {
|
|
132
|
-
const plugins = [
|
|
133
|
-
makePlugin("test", {
|
|
134
|
-
users: {
|
|
135
|
-
fields: {
|
|
136
|
-
email: { type: "string", required: true, unique: true },
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
}),
|
|
140
|
-
];
|
|
141
|
-
|
|
142
|
-
const stmts = generateMigrationSQL(plugins as Parameters<typeof generateMigrationSQL>[0]);
|
|
143
|
-
expect(stmts[0].sql).toContain('"email" TEXT NOT NULL UNIQUE');
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
test("handles DEFAULT values", () => {
|
|
147
|
-
const plugins = [
|
|
148
|
-
makePlugin("test", {
|
|
149
|
-
settings: {
|
|
150
|
-
fields: {
|
|
151
|
-
label: { type: "string", defaultValue: "untitled" },
|
|
152
|
-
priority: { type: "number", defaultValue: 0 },
|
|
153
|
-
enabled: { type: "boolean", defaultValue: true },
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
}),
|
|
157
|
-
];
|
|
158
|
-
|
|
159
|
-
const stmts = generateMigrationSQL(plugins as Parameters<typeof generateMigrationSQL>[0]);
|
|
160
|
-
const sql = stmts[0].sql;
|
|
161
|
-
expect(sql).toContain("DEFAULT 'untitled'");
|
|
162
|
-
expect(sql).toContain("DEFAULT 0");
|
|
163
|
-
expect(sql).toContain("DEFAULT true");
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
test("handles FOREIGN KEY references", () => {
|
|
167
|
-
const plugins = [
|
|
168
|
-
makePlugin("test", {
|
|
169
|
-
projects: { fields: { name: { type: "string" } } },
|
|
170
|
-
tasks: {
|
|
171
|
-
fields: {
|
|
172
|
-
project_id: {
|
|
173
|
-
type: "string",
|
|
174
|
-
references: { model: "projects", field: "id" },
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
}),
|
|
179
|
-
];
|
|
180
|
-
|
|
181
|
-
const stmts = generateMigrationSQL(plugins as Parameters<typeof generateMigrationSQL>[0]);
|
|
182
|
-
const taskStmt = stmts.find((s) => s.tableName === "tasks");
|
|
183
|
-
expect(taskStmt).toBeDefined();
|
|
184
|
-
expect(taskStmt!.sql).toContain(
|
|
185
|
-
'FOREIGN KEY ("project_id") REFERENCES "plugin_test_projects"("id")'
|
|
186
|
-
);
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
test("escapes single quotes in default values", () => {
|
|
190
|
-
const plugins = [
|
|
191
|
-
makePlugin("test", {
|
|
192
|
-
items: {
|
|
193
|
-
fields: {
|
|
194
|
-
label: { type: "string", defaultValue: "it's a test" },
|
|
195
|
-
},
|
|
196
|
-
},
|
|
197
|
-
}),
|
|
198
|
-
];
|
|
199
|
-
|
|
200
|
-
const stmts = generateMigrationSQL(plugins as Parameters<typeof generateMigrationSQL>[0]);
|
|
201
|
-
expect(stmts[0].sql).toContain("DEFAULT 'it''s a test'");
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
test("skips plugins without schema", () => {
|
|
205
|
-
const plugins = [{ id: "no-schema" }];
|
|
206
|
-
const stmts = generateMigrationSQL(plugins as Parameters<typeof generateMigrationSQL>[0]);
|
|
207
|
-
expect(stmts).toHaveLength(0);
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
test("generates multiple tables from one plugin", () => {
|
|
211
|
-
const plugins = [
|
|
212
|
-
makePlugin("crm", {
|
|
213
|
-
contacts: { fields: { name: { type: "string" } } },
|
|
214
|
-
deals: { fields: { value: { type: "number" } } },
|
|
215
|
-
}),
|
|
216
|
-
];
|
|
217
|
-
|
|
218
|
-
const stmts = generateMigrationSQL(plugins as Parameters<typeof generateMigrationSQL>[0]);
|
|
219
|
-
expect(stmts).toHaveLength(2);
|
|
220
|
-
expect(stmts.map((s) => s.prefixedName).sort()).toEqual([
|
|
221
|
-
"plugin_crm_contacts",
|
|
222
|
-
"plugin_crm_deals",
|
|
223
|
-
]);
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
test("generates statements from multiple plugins", () => {
|
|
227
|
-
const plugins = [
|
|
228
|
-
makePlugin("a", { items: { fields: { x: { type: "string" } } } }),
|
|
229
|
-
makePlugin("b", { things: { fields: { y: { type: "number" } } } }),
|
|
230
|
-
];
|
|
231
|
-
|
|
232
|
-
const stmts = generateMigrationSQL(plugins as Parameters<typeof generateMigrationSQL>[0]);
|
|
233
|
-
expect(stmts).toHaveLength(2);
|
|
234
|
-
expect(stmts[0].pluginId).toBe("a");
|
|
235
|
-
expect(stmts[1].pluginId).toBe("b");
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
test("generates deterministic hash for same SQL", () => {
|
|
239
|
-
const plugins = [
|
|
240
|
-
makePlugin("test", { items: { fields: { x: { type: "string" } } } }),
|
|
241
|
-
];
|
|
242
|
-
|
|
243
|
-
const stmts1 = generateMigrationSQL(plugins as Parameters<typeof generateMigrationSQL>[0]);
|
|
244
|
-
const stmts2 = generateMigrationSQL(plugins as Parameters<typeof generateMigrationSQL>[0]);
|
|
245
|
-
expect(stmts1[0].hash).toBe(stmts2[0].hash);
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
test("generates different hashes for different SQL", () => {
|
|
249
|
-
const plugins1 = [makePlugin("test", { items: { fields: { x: { type: "string" } } } })];
|
|
250
|
-
const plugins2 = [makePlugin("test", { items: { fields: { x: { type: "number" } } } })];
|
|
251
|
-
|
|
252
|
-
const stmts1 = generateMigrationSQL(plugins1 as Parameters<typeof generateMigrationSQL>[0]);
|
|
253
|
-
const stmts2 = generateMigrationSQL(plugins2 as Parameters<typeof generateMigrationSQL>[0]);
|
|
254
|
-
expect(stmts1[0].hash).not.toBe(stmts2[0].hash);
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
test("throws on unknown field type", () => {
|
|
258
|
-
const plugins = [makePlugin("test", { items: { fields: { data: { type: "json" } } } })];
|
|
259
|
-
expect(() => generateMigrationSQL(plugins as Parameters<typeof generateMigrationSQL>[0]))
|
|
260
|
-
.toThrow(/Unknown field type "json"/);
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
test("rejects field names with special characters", () => {
|
|
264
|
-
const plugins = [makePlugin("test", {
|
|
265
|
-
items: { fields: { 'foo"; DROP TABLE x; --': { type: "string" } } },
|
|
266
|
-
})];
|
|
267
|
-
expect(() => generateMigrationSQL(plugins as Parameters<typeof generateMigrationSQL>[0]))
|
|
268
|
-
.toThrow(/Invalid identifier/);
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
test("rejects references.field with special characters", () => {
|
|
272
|
-
const plugins = [makePlugin("test", {
|
|
273
|
-
parent: { fields: { name: { type: "string" } } },
|
|
274
|
-
child: {
|
|
275
|
-
fields: {
|
|
276
|
-
parent_id: {
|
|
277
|
-
type: "string",
|
|
278
|
-
references: { model: "parent", field: 'id"); DROP TABLE x; --' },
|
|
279
|
-
},
|
|
280
|
-
},
|
|
281
|
-
},
|
|
282
|
-
})];
|
|
283
|
-
expect(() => generateMigrationSQL(plugins as Parameters<typeof generateMigrationSQL>[0]))
|
|
284
|
-
.toThrow(/Invalid identifier/);
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
test("rejects NaN as default value", () => {
|
|
288
|
-
const plugins = [makePlugin("test", {
|
|
289
|
-
items: { fields: { count: { type: "number", defaultValue: NaN } } },
|
|
290
|
-
})];
|
|
291
|
-
expect(() => generateMigrationSQL(plugins as Parameters<typeof generateMigrationSQL>[0]))
|
|
292
|
-
.toThrow(/Invalid numeric defaultValue/);
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
test("rejects Infinity as default value", () => {
|
|
296
|
-
const plugins = [makePlugin("test", {
|
|
297
|
-
items: { fields: { count: { type: "number", defaultValue: Infinity } } },
|
|
298
|
-
})];
|
|
299
|
-
expect(() => generateMigrationSQL(plugins as Parameters<typeof generateMigrationSQL>[0]))
|
|
300
|
-
.toThrow(/Invalid numeric defaultValue/);
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
test("rejects unsupported defaultValue types", () => {
|
|
304
|
-
const plugins = [makePlugin("test", {
|
|
305
|
-
items: { fields: { data: { type: "string", defaultValue: { raw: "NOW()" } } } },
|
|
306
|
-
})];
|
|
307
|
-
expect(() => generateMigrationSQL(plugins as Parameters<typeof generateMigrationSQL>[0]))
|
|
308
|
-
.toThrow(/Unsupported defaultValue type/);
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
test("generates table with only auto-columns when fields is empty", () => {
|
|
312
|
-
const plugins = [makePlugin("test", { empty_table: { fields: {} } })];
|
|
313
|
-
const stmts = generateMigrationSQL(plugins as Parameters<typeof generateMigrationSQL>[0]);
|
|
314
|
-
expect(stmts).toHaveLength(1);
|
|
315
|
-
expect(stmts[0].sql).toContain('"id" UUID PRIMARY KEY');
|
|
316
|
-
expect(stmts[0].sql).toContain('"created_at"');
|
|
317
|
-
expect(stmts[0].sql).toContain('"updated_at"');
|
|
318
|
-
});
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
// ---------------------------------------------------------------------------
|
|
322
|
-
// ensureMigrationsTable
|
|
323
|
-
// ---------------------------------------------------------------------------
|
|
324
|
-
|
|
325
|
-
describe("ensureMigrationsTable", () => {
|
|
326
|
-
test("creates the plugin_migrations table", async () => {
|
|
327
|
-
const db = makeMockDB();
|
|
328
|
-
await ensureMigrationsTable(db);
|
|
329
|
-
expect(db.queries).toHaveLength(1);
|
|
330
|
-
expect(db.queries[0].sql).toContain("CREATE TABLE IF NOT EXISTS plugin_migrations");
|
|
331
|
-
});
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
// ---------------------------------------------------------------------------
|
|
335
|
-
// getAppliedMigrations
|
|
336
|
-
// ---------------------------------------------------------------------------
|
|
337
|
-
|
|
338
|
-
describe("getAppliedMigrations", () => {
|
|
339
|
-
test("returns set of applied migration keys", async () => {
|
|
340
|
-
const db = makeMockDB({
|
|
341
|
-
existingMigrations: [
|
|
342
|
-
{ plugin_id: "test", table_name: "items", sql_hash: "abc123" },
|
|
343
|
-
],
|
|
344
|
-
});
|
|
345
|
-
const applied = await getAppliedMigrations(db);
|
|
346
|
-
expect(applied.has("test:items:abc123")).toBe(true);
|
|
347
|
-
expect(applied.size).toBe(1);
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
test("returns empty set when no migrations", async () => {
|
|
351
|
-
const db = makeMockDB();
|
|
352
|
-
const applied = await getAppliedMigrations(db);
|
|
353
|
-
expect(applied.size).toBe(0);
|
|
354
|
-
});
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
// ---------------------------------------------------------------------------
|
|
358
|
-
// applyMigrations
|
|
359
|
-
// ---------------------------------------------------------------------------
|
|
360
|
-
|
|
361
|
-
describe("applyMigrations", () => {
|
|
362
|
-
test("applies new migrations and records them", async () => {
|
|
363
|
-
const db = makeMockDB();
|
|
364
|
-
const stmts: MigrationStatement[] = [
|
|
365
|
-
{
|
|
366
|
-
pluginId: "test",
|
|
367
|
-
tableName: "items",
|
|
368
|
-
prefixedName: "plugin_test_items",
|
|
369
|
-
sql: 'CREATE TABLE IF NOT EXISTS "plugin_test_items" ("id" UUID PRIMARY KEY);',
|
|
370
|
-
hash: "aabb0011",
|
|
371
|
-
},
|
|
372
|
-
];
|
|
373
|
-
|
|
374
|
-
const result = await applyMigrations(db, stmts);
|
|
375
|
-
expect(result.applied).toEqual(["plugin_test_items"]);
|
|
376
|
-
expect(result.skipped).toHaveLength(0);
|
|
377
|
-
|
|
378
|
-
// Should have: ensureMigrationsTable, getAppliedMigrations, CREATE TABLE, INSERT into plugin_migrations
|
|
379
|
-
const createTableQuery = db.queries.find((q) => q.sql.includes("plugin_test_items"));
|
|
380
|
-
expect(createTableQuery).toBeDefined();
|
|
381
|
-
|
|
382
|
-
const insertQuery = db.queries.find((q) => q.sql.includes("INSERT INTO plugin_migrations"));
|
|
383
|
-
expect(insertQuery).toBeDefined();
|
|
384
|
-
expect(insertQuery!.params).toEqual(["test", "items", "aabb0011"]);
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
test("skips already-applied migrations", async () => {
|
|
388
|
-
const db = makeMockDB({
|
|
389
|
-
existingMigrations: [
|
|
390
|
-
{ plugin_id: "test", table_name: "items", sql_hash: "aabb0011" },
|
|
391
|
-
],
|
|
392
|
-
});
|
|
393
|
-
|
|
394
|
-
const stmts: MigrationStatement[] = [
|
|
395
|
-
{
|
|
396
|
-
pluginId: "test",
|
|
397
|
-
tableName: "items",
|
|
398
|
-
prefixedName: "plugin_test_items",
|
|
399
|
-
sql: 'CREATE TABLE IF NOT EXISTS "plugin_test_items" ("id" UUID PRIMARY KEY);',
|
|
400
|
-
hash: "aabb0011",
|
|
401
|
-
},
|
|
402
|
-
];
|
|
403
|
-
|
|
404
|
-
const result = await applyMigrations(db, stmts);
|
|
405
|
-
expect(result.applied).toHaveLength(0);
|
|
406
|
-
expect(result.skipped).toEqual(["plugin_test_items"]);
|
|
407
|
-
|
|
408
|
-
// Should NOT have a CREATE TABLE query (only ensureMigrations + getApplied)
|
|
409
|
-
const createTableQuery = db.queries.find(
|
|
410
|
-
(q) => q.sql.includes("plugin_test_items") && q.sql.includes("CREATE TABLE"),
|
|
411
|
-
);
|
|
412
|
-
expect(createTableQuery).toBeUndefined();
|
|
413
|
-
});
|
|
414
|
-
|
|
415
|
-
test("applies changed migration (different hash)", async () => {
|
|
416
|
-
const db = makeMockDB({
|
|
417
|
-
existingMigrations: [
|
|
418
|
-
{ plugin_id: "test", table_name: "items", sql_hash: "old_hash" },
|
|
419
|
-
],
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
const stmts: MigrationStatement[] = [
|
|
423
|
-
{
|
|
424
|
-
pluginId: "test",
|
|
425
|
-
tableName: "items",
|
|
426
|
-
prefixedName: "plugin_test_items",
|
|
427
|
-
sql: 'CREATE TABLE IF NOT EXISTS "plugin_test_items" ("id" UUID PRIMARY KEY, "name" TEXT);',
|
|
428
|
-
hash: "new_hash",
|
|
429
|
-
},
|
|
430
|
-
];
|
|
431
|
-
|
|
432
|
-
const result = await applyMigrations(db, stmts);
|
|
433
|
-
expect(result.applied).toEqual(["plugin_test_items"]);
|
|
434
|
-
expect(result.skipped).toHaveLength(0);
|
|
435
|
-
});
|
|
436
|
-
|
|
437
|
-
test("handles multiple statements with mixed state", async () => {
|
|
438
|
-
const db = makeMockDB({
|
|
439
|
-
existingMigrations: [
|
|
440
|
-
{ plugin_id: "a", table_name: "existing", sql_hash: "hash1" },
|
|
441
|
-
],
|
|
442
|
-
});
|
|
443
|
-
|
|
444
|
-
const stmts: MigrationStatement[] = [
|
|
445
|
-
{
|
|
446
|
-
pluginId: "a",
|
|
447
|
-
tableName: "existing",
|
|
448
|
-
prefixedName: "plugin_a_existing",
|
|
449
|
-
sql: "CREATE TABLE ...",
|
|
450
|
-
hash: "hash1",
|
|
451
|
-
},
|
|
452
|
-
{
|
|
453
|
-
pluginId: "b",
|
|
454
|
-
tableName: "new_table",
|
|
455
|
-
prefixedName: "plugin_b_new_table",
|
|
456
|
-
sql: "CREATE TABLE ...",
|
|
457
|
-
hash: "hash2",
|
|
458
|
-
},
|
|
459
|
-
];
|
|
460
|
-
|
|
461
|
-
const result = await applyMigrations(db, stmts);
|
|
462
|
-
expect(result.applied).toEqual(["plugin_b_new_table"]);
|
|
463
|
-
expect(result.skipped).toEqual(["plugin_a_existing"]);
|
|
464
|
-
});
|
|
465
|
-
|
|
466
|
-
test("handles empty statements array", async () => {
|
|
467
|
-
const db = makeMockDB();
|
|
468
|
-
const result = await applyMigrations(db, []);
|
|
469
|
-
expect(result.applied).toHaveLength(0);
|
|
470
|
-
expect(result.skipped).toHaveLength(0);
|
|
471
|
-
});
|
|
472
|
-
|
|
473
|
-
test("propagates db errors with context", async () => {
|
|
474
|
-
const db = makeMockDB({ failOnCreate: true });
|
|
475
|
-
const stmts: MigrationStatement[] = [
|
|
476
|
-
{
|
|
477
|
-
pluginId: "test",
|
|
478
|
-
tableName: "items",
|
|
479
|
-
prefixedName: "plugin_test_items",
|
|
480
|
-
sql: 'CREATE TABLE IF NOT EXISTS "plugin_test_items" ("id" UUID PRIMARY KEY);',
|
|
481
|
-
hash: "abc",
|
|
482
|
-
},
|
|
483
|
-
];
|
|
484
|
-
|
|
485
|
-
await expect(applyMigrations(db, stmts)).rejects.toThrow(/plugin_test_items/);
|
|
486
|
-
await expect(applyMigrations(db, stmts)).rejects.toThrow(/permission denied/);
|
|
487
|
-
});
|
|
488
|
-
});
|
|
489
|
-
|
|
490
|
-
// ---------------------------------------------------------------------------
|
|
491
|
-
// diffSchema
|
|
492
|
-
// ---------------------------------------------------------------------------
|
|
493
|
-
|
|
494
|
-
describe("diffSchema", () => {
|
|
495
|
-
test("identifies new and existing tables", async () => {
|
|
496
|
-
const db = makeMockDB({
|
|
497
|
-
existingTables: ["plugin_test_items"],
|
|
498
|
-
});
|
|
499
|
-
|
|
500
|
-
const stmts: MigrationStatement[] = [
|
|
501
|
-
{
|
|
502
|
-
pluginId: "test",
|
|
503
|
-
tableName: "items",
|
|
504
|
-
prefixedName: "plugin_test_items",
|
|
505
|
-
sql: "",
|
|
506
|
-
hash: "",
|
|
507
|
-
},
|
|
508
|
-
{
|
|
509
|
-
pluginId: "test",
|
|
510
|
-
tableName: "users",
|
|
511
|
-
prefixedName: "plugin_test_users",
|
|
512
|
-
sql: "",
|
|
513
|
-
hash: "",
|
|
514
|
-
},
|
|
515
|
-
];
|
|
516
|
-
|
|
517
|
-
const diff = await diffSchema(db, stmts);
|
|
518
|
-
expect(diff.existingTables).toEqual(["plugin_test_items"]);
|
|
519
|
-
expect(diff.newTables).toEqual(["plugin_test_users"]);
|
|
520
|
-
});
|
|
521
|
-
|
|
522
|
-
test("all new when no tables exist", async () => {
|
|
523
|
-
const db = makeMockDB();
|
|
524
|
-
|
|
525
|
-
const stmts: MigrationStatement[] = [
|
|
526
|
-
{ pluginId: "x", tableName: "a", prefixedName: "plugin_x_a", sql: "", hash: "" },
|
|
527
|
-
];
|
|
528
|
-
|
|
529
|
-
const diff = await diffSchema(db, stmts);
|
|
530
|
-
expect(diff.newTables).toEqual(["plugin_x_a"]);
|
|
531
|
-
expect(diff.existingTables).toHaveLength(0);
|
|
532
|
-
});
|
|
533
|
-
|
|
534
|
-
test("returns empty diff for empty statements", async () => {
|
|
535
|
-
const db = makeMockDB({ existingTables: ["some_table"] });
|
|
536
|
-
const diff = await diffSchema(db, []);
|
|
537
|
-
expect(diff.newTables).toHaveLength(0);
|
|
538
|
-
expect(diff.existingTables).toHaveLength(0);
|
|
539
|
-
});
|
|
540
|
-
});
|
|
541
|
-
|
|
542
|
-
// ---------------------------------------------------------------------------
|
|
543
|
-
// generateColumnMigrations
|
|
544
|
-
// ---------------------------------------------------------------------------
|
|
545
|
-
|
|
546
|
-
describe("generateColumnMigrations", () => {
|
|
547
|
-
test("generates ALTER TABLE for missing columns", async () => {
|
|
548
|
-
const db = makeMockDB({
|
|
549
|
-
existingColumns: {
|
|
550
|
-
plugin_test_items: ["id", "name", "created_at", "updated_at"],
|
|
551
|
-
},
|
|
552
|
-
});
|
|
553
|
-
const plugins = [
|
|
554
|
-
makePlugin("test", {
|
|
555
|
-
items: {
|
|
556
|
-
fields: {
|
|
557
|
-
name: { type: "string", required: true },
|
|
558
|
-
priority: { type: "number" },
|
|
559
|
-
active: { type: "boolean" },
|
|
560
|
-
},
|
|
561
|
-
},
|
|
562
|
-
}),
|
|
563
|
-
];
|
|
564
|
-
|
|
565
|
-
const stmts = await generateColumnMigrations(
|
|
566
|
-
db,
|
|
567
|
-
plugins as Parameters<typeof generateColumnMigrations>[1],
|
|
568
|
-
);
|
|
569
|
-
|
|
570
|
-
// name already exists, priority and active are new
|
|
571
|
-
expect(stmts).toHaveLength(2);
|
|
572
|
-
expect(stmts[0].sql).toContain('ALTER TABLE "plugin_test_items"');
|
|
573
|
-
expect(stmts[0].sql).toContain('"priority" INTEGER');
|
|
574
|
-
expect(stmts[1].sql).toContain('"active" BOOLEAN');
|
|
575
|
-
});
|
|
576
|
-
|
|
577
|
-
test("skips tables that don't exist yet", async () => {
|
|
578
|
-
const db = makeMockDB({
|
|
579
|
-
existingColumns: {}, // no tables in DB
|
|
580
|
-
});
|
|
581
|
-
const plugins = [
|
|
582
|
-
makePlugin("test", {
|
|
583
|
-
items: { fields: { name: { type: "string" } } },
|
|
584
|
-
}),
|
|
585
|
-
];
|
|
586
|
-
|
|
587
|
-
const stmts = await generateColumnMigrations(
|
|
588
|
-
db,
|
|
589
|
-
plugins as Parameters<typeof generateColumnMigrations>[1],
|
|
590
|
-
);
|
|
591
|
-
expect(stmts).toHaveLength(0);
|
|
592
|
-
});
|
|
593
|
-
|
|
594
|
-
test("returns empty when all columns already exist", async () => {
|
|
595
|
-
const db = makeMockDB({
|
|
596
|
-
existingColumns: {
|
|
597
|
-
plugin_test_items: ["id", "name", "count", "created_at", "updated_at"],
|
|
598
|
-
},
|
|
599
|
-
});
|
|
600
|
-
const plugins = [
|
|
601
|
-
makePlugin("test", {
|
|
602
|
-
items: {
|
|
603
|
-
fields: {
|
|
604
|
-
name: { type: "string" },
|
|
605
|
-
count: { type: "number" },
|
|
606
|
-
},
|
|
607
|
-
},
|
|
608
|
-
}),
|
|
609
|
-
];
|
|
610
|
-
|
|
611
|
-
const stmts = await generateColumnMigrations(
|
|
612
|
-
db,
|
|
613
|
-
plugins as Parameters<typeof generateColumnMigrations>[1],
|
|
614
|
-
);
|
|
615
|
-
expect(stmts).toHaveLength(0);
|
|
616
|
-
});
|
|
617
|
-
|
|
618
|
-
test("handles case-insensitive column matching", async () => {
|
|
619
|
-
const db = makeMockDB({
|
|
620
|
-
existingColumns: {
|
|
621
|
-
plugin_test_items: ["id", "MyColumn", "created_at", "updated_at"],
|
|
622
|
-
},
|
|
623
|
-
});
|
|
624
|
-
const plugins = [
|
|
625
|
-
makePlugin("test", {
|
|
626
|
-
items: {
|
|
627
|
-
fields: {
|
|
628
|
-
mycolumn: { type: "string" },
|
|
629
|
-
},
|
|
630
|
-
},
|
|
631
|
-
}),
|
|
632
|
-
];
|
|
633
|
-
|
|
634
|
-
const stmts = await generateColumnMigrations(
|
|
635
|
-
db,
|
|
636
|
-
plugins as Parameters<typeof generateColumnMigrations>[1],
|
|
637
|
-
);
|
|
638
|
-
// MyColumn matches mycolumn (case-insensitive)
|
|
639
|
-
expect(stmts).toHaveLength(0);
|
|
640
|
-
});
|
|
641
|
-
|
|
642
|
-
test("skips plugins without schema", async () => {
|
|
643
|
-
const db = makeMockDB();
|
|
644
|
-
const plugins = [{ id: "no-schema" }];
|
|
645
|
-
|
|
646
|
-
const stmts = await generateColumnMigrations(
|
|
647
|
-
db,
|
|
648
|
-
plugins as Parameters<typeof generateColumnMigrations>[1],
|
|
649
|
-
);
|
|
650
|
-
expect(stmts).toHaveLength(0);
|
|
651
|
-
});
|
|
652
|
-
|
|
653
|
-
test("generates columns with constraints", async () => {
|
|
654
|
-
const db = makeMockDB({
|
|
655
|
-
existingColumns: {
|
|
656
|
-
plugin_test_items: ["id", "created_at", "updated_at"],
|
|
657
|
-
},
|
|
658
|
-
});
|
|
659
|
-
const plugins = [
|
|
660
|
-
makePlugin("test", {
|
|
661
|
-
items: {
|
|
662
|
-
fields: {
|
|
663
|
-
email: { type: "string", required: true, unique: true },
|
|
664
|
-
priority: { type: "number", defaultValue: 0 },
|
|
665
|
-
},
|
|
666
|
-
},
|
|
667
|
-
}),
|
|
668
|
-
];
|
|
669
|
-
|
|
670
|
-
const stmts = await generateColumnMigrations(
|
|
671
|
-
db,
|
|
672
|
-
plugins as Parameters<typeof generateColumnMigrations>[1],
|
|
673
|
-
);
|
|
674
|
-
expect(stmts).toHaveLength(2);
|
|
675
|
-
expect(stmts[0].sql).toContain('"email" TEXT NOT NULL UNIQUE');
|
|
676
|
-
expect(stmts[1].sql).toContain('"priority" INTEGER DEFAULT 0');
|
|
677
|
-
});
|
|
678
|
-
|
|
679
|
-
test("generates deterministic hashes for ALTER statements", async () => {
|
|
680
|
-
const db = makeMockDB({
|
|
681
|
-
existingColumns: {
|
|
682
|
-
plugin_test_items: ["id", "created_at", "updated_at"],
|
|
683
|
-
},
|
|
684
|
-
});
|
|
685
|
-
const plugins = [
|
|
686
|
-
makePlugin("test", {
|
|
687
|
-
items: { fields: { name: { type: "string" } } },
|
|
688
|
-
}),
|
|
689
|
-
];
|
|
690
|
-
|
|
691
|
-
const stmts1 = await generateColumnMigrations(
|
|
692
|
-
db,
|
|
693
|
-
plugins as Parameters<typeof generateColumnMigrations>[1],
|
|
694
|
-
);
|
|
695
|
-
const stmts2 = await generateColumnMigrations(
|
|
696
|
-
db,
|
|
697
|
-
plugins as Parameters<typeof generateColumnMigrations>[1],
|
|
698
|
-
);
|
|
699
|
-
expect(stmts1[0].hash).toBe(stmts2[0].hash);
|
|
700
|
-
});
|
|
701
|
-
});
|
|
702
|
-
|
|
703
|
-
// ---------------------------------------------------------------------------
|
|
704
|
-
// runPluginMigrations
|
|
705
|
-
// ---------------------------------------------------------------------------
|
|
706
|
-
|
|
707
|
-
describe("runPluginMigrations", () => {
|
|
708
|
-
test("runs CREATE TABLE and ALTER TABLE in sequence", async () => {
|
|
709
|
-
const db = makeMockDB({
|
|
710
|
-
// Simulate a table that was just created with only auto-columns —
|
|
711
|
-
// Phase 2 detects the missing user-declared column
|
|
712
|
-
existingColumns: {
|
|
713
|
-
plugin_test_items: ["id", "created_at", "updated_at"],
|
|
714
|
-
},
|
|
715
|
-
});
|
|
716
|
-
const plugins = [
|
|
717
|
-
makePlugin("test", {
|
|
718
|
-
items: {
|
|
719
|
-
fields: {
|
|
720
|
-
name: { type: "string" },
|
|
721
|
-
},
|
|
722
|
-
},
|
|
723
|
-
}),
|
|
724
|
-
];
|
|
725
|
-
|
|
726
|
-
const result = await runPluginMigrations(
|
|
727
|
-
db,
|
|
728
|
-
plugins as Parameters<typeof runPluginMigrations>[1],
|
|
729
|
-
);
|
|
730
|
-
|
|
731
|
-
// Phase 1: CREATE TABLE (1 table) + Phase 2: ALTER TABLE ADD COLUMN (1 column)
|
|
732
|
-
expect(result.applied).toEqual(["plugin_test_items", "plugin_test_items"]);
|
|
733
|
-
// Should have both CREATE TABLE and ALTER TABLE queries
|
|
734
|
-
const createQuery = db.queries.find((q) =>
|
|
735
|
-
q.sql.includes("CREATE TABLE") && q.sql.includes("plugin_test_items"),
|
|
736
|
-
);
|
|
737
|
-
expect(createQuery).toBeDefined();
|
|
738
|
-
const alterQuery = db.queries.find((q) =>
|
|
739
|
-
q.sql.includes("ALTER TABLE") && q.sql.includes('"name"'),
|
|
740
|
-
);
|
|
741
|
-
expect(alterQuery).toBeDefined();
|
|
742
|
-
});
|
|
743
|
-
|
|
744
|
-
test("merges results from both phases correctly", async () => {
|
|
745
|
-
const db = makeMockDB({
|
|
746
|
-
existingColumns: {
|
|
747
|
-
plugin_a_items: ["id", "x", "created_at", "updated_at"],
|
|
748
|
-
// plugin_b_things doesn't exist — no columns, Phase 2 skips it
|
|
749
|
-
},
|
|
750
|
-
});
|
|
751
|
-
const plugins = [
|
|
752
|
-
makePlugin("a", { items: { fields: { x: { type: "string" }, y: { type: "number" } } } }),
|
|
753
|
-
makePlugin("b", { things: { fields: { z: { type: "boolean" } } } }),
|
|
754
|
-
];
|
|
755
|
-
|
|
756
|
-
const result = await runPluginMigrations(
|
|
757
|
-
db,
|
|
758
|
-
plugins as Parameters<typeof runPluginMigrations>[1],
|
|
759
|
-
);
|
|
760
|
-
|
|
761
|
-
// Phase 1: 2 CREATE TABLE statements applied
|
|
762
|
-
// Phase 2: 1 ALTER TABLE for plugin_a_items.y (x already exists, plugin_b skipped)
|
|
763
|
-
expect(result.applied).toEqual([
|
|
764
|
-
"plugin_a_items", "plugin_b_things", "plugin_a_items",
|
|
765
|
-
]);
|
|
766
|
-
});
|
|
767
|
-
|
|
768
|
-
test("handles plugins with no schema", async () => {
|
|
769
|
-
const db = makeMockDB();
|
|
770
|
-
const plugins = [{ id: "no-schema" }];
|
|
771
|
-
|
|
772
|
-
const result = await runPluginMigrations(
|
|
773
|
-
db,
|
|
774
|
-
plugins as Parameters<typeof runPluginMigrations>[1],
|
|
775
|
-
);
|
|
776
|
-
expect(result.applied).toEqual([]);
|
|
777
|
-
expect(result.skipped).toEqual([]);
|
|
778
|
-
});
|
|
779
|
-
|
|
780
|
-
test("skips column migrations when no new columns needed", async () => {
|
|
781
|
-
const db = makeMockDB({
|
|
782
|
-
existingColumns: {
|
|
783
|
-
plugin_test_items: ["id", "name", "created_at", "updated_at"],
|
|
784
|
-
},
|
|
785
|
-
});
|
|
786
|
-
const plugins = [
|
|
787
|
-
makePlugin("test", {
|
|
788
|
-
items: {
|
|
789
|
-
fields: {
|
|
790
|
-
name: { type: "string" },
|
|
791
|
-
},
|
|
792
|
-
},
|
|
793
|
-
}),
|
|
794
|
-
];
|
|
795
|
-
|
|
796
|
-
await runPluginMigrations(
|
|
797
|
-
db,
|
|
798
|
-
plugins as Parameters<typeof runPluginMigrations>[1],
|
|
799
|
-
);
|
|
800
|
-
|
|
801
|
-
// ALTER TABLE should not appear (no new columns)
|
|
802
|
-
const alterQuery = db.queries.find((q) => q.sql.includes("ALTER TABLE"));
|
|
803
|
-
expect(alterQuery).toBeUndefined();
|
|
804
|
-
});
|
|
805
|
-
|
|
806
|
-
test("propagates Phase 1 errors and skips Phase 2", async () => {
|
|
807
|
-
const db = makeMockDB({ failOnCreate: true });
|
|
808
|
-
const plugins = [
|
|
809
|
-
makePlugin("test", {
|
|
810
|
-
items: { fields: { name: { type: "string" } } },
|
|
811
|
-
}),
|
|
812
|
-
];
|
|
813
|
-
|
|
814
|
-
await expect(
|
|
815
|
-
runPluginMigrations(db, plugins as Parameters<typeof runPluginMigrations>[1]),
|
|
816
|
-
).rejects.toThrow(/permission denied/);
|
|
817
|
-
|
|
818
|
-
// No ALTER TABLE queries should have been attempted
|
|
819
|
-
const alterQuery = db.queries.find((q) => q.sql.includes("ALTER TABLE"));
|
|
820
|
-
expect(alterQuery).toBeUndefined();
|
|
821
|
-
});
|
|
822
|
-
|
|
823
|
-
test("idempotent when run twice", async () => {
|
|
824
|
-
const db = makeMockDB({
|
|
825
|
-
existingColumns: {
|
|
826
|
-
plugin_test_items: ["id", "name", "created_at", "updated_at"],
|
|
827
|
-
},
|
|
828
|
-
});
|
|
829
|
-
const plugins = [
|
|
830
|
-
makePlugin("test", {
|
|
831
|
-
items: {
|
|
832
|
-
fields: { name: { type: "string" } },
|
|
833
|
-
},
|
|
834
|
-
}),
|
|
835
|
-
];
|
|
836
|
-
|
|
837
|
-
const result1 = await runPluginMigrations(
|
|
838
|
-
db,
|
|
839
|
-
plugins as Parameters<typeof runPluginMigrations>[1],
|
|
840
|
-
);
|
|
841
|
-
const result2 = await runPluginMigrations(
|
|
842
|
-
db,
|
|
843
|
-
plugins as Parameters<typeof runPluginMigrations>[1],
|
|
844
|
-
);
|
|
845
|
-
|
|
846
|
-
// First run applies CREATE TABLE
|
|
847
|
-
expect(result1.applied).toEqual(["plugin_test_items"]);
|
|
848
|
-
// Second run skips it (already tracked in plugin_migrations)
|
|
849
|
-
expect(result2.applied).toEqual([]);
|
|
850
|
-
expect(result2.skipped).toEqual(["plugin_test_items"]);
|
|
851
|
-
});
|
|
852
|
-
});
|
|
853
|
-
|
|
854
|
-
// ---------------------------------------------------------------------------
|
|
855
|
-
// generateColumnMigrations — error context
|
|
856
|
-
// ---------------------------------------------------------------------------
|
|
857
|
-
|
|
858
|
-
describe("generateColumnMigrations error context", () => {
|
|
859
|
-
test("wraps fieldToSQL errors with plugin and table context", async () => {
|
|
860
|
-
const db = makeMockDB({
|
|
861
|
-
existingColumns: {
|
|
862
|
-
plugin_test_items: ["id", "created_at", "updated_at"],
|
|
863
|
-
},
|
|
864
|
-
});
|
|
865
|
-
const plugins = [
|
|
866
|
-
makePlugin("test", {
|
|
867
|
-
items: { fields: { "bad name!": { type: "string" } } },
|
|
868
|
-
}),
|
|
869
|
-
];
|
|
870
|
-
|
|
871
|
-
await expect(
|
|
872
|
-
generateColumnMigrations(db, plugins as Parameters<typeof generateColumnMigrations>[1]),
|
|
873
|
-
).rejects.toThrow(/Plugin "test", table "plugin_test_items"/);
|
|
874
|
-
});
|
|
875
|
-
});
|