@agent-native/core 0.137.7 → 0.138.0
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/agent-native.eject.json +2 -0
- package/corpus/README.md +1 -1
- package/corpus/templates/analytics/.agents/skills/agent-native-docs/SKILL.md +23 -3
- package/corpus/templates/analytics/.agents/skills/agent-native-toolkit/SKILL.md +16 -0
- package/corpus/templates/analytics/.agents/skills/data-querying/SKILL.md +15 -0
- package/corpus/templates/analytics/.agents/skills/frontend-design/SKILL.md +23 -2
- package/corpus/templates/analytics/.agents/skills/frontend-design/references/visual-direction.md +99 -0
- package/corpus/templates/analytics/AGENTS.md +2 -2
- package/corpus/templates/analytics/actions/get-first-party-analytics-health.ts +65 -0
- package/corpus/templates/analytics/actions/provider-api-catalog.ts +3 -6
- package/corpus/templates/analytics/actions/provider-api-docs.ts +3 -6
- package/corpus/templates/analytics/actions/provider-api-request.ts +3 -6
- package/corpus/templates/analytics/actions/query-agent-native-analytics.ts +3 -3
- package/corpus/templates/analytics/agent-native.json +12 -0
- package/corpus/templates/analytics/app/i18n-data.ts +162 -0
- package/corpus/templates/analytics/app/pages/DataSources.tsx +126 -1
- package/corpus/templates/analytics/changelog/2026-08-05-analytics-now-flags-neon-pressure-and-guides-high-volume-tra.md +6 -0
- package/corpus/templates/analytics/changelog/2026-08-05-first-party-analytics-uses-compact-rollups-for-faster-usage-.md +6 -0
- package/corpus/templates/analytics/server/db/schema.ts +52 -0
- package/corpus/templates/analytics/server/lib/credential-keys.ts +3 -0
- package/corpus/templates/analytics/server/lib/first-party-analytics-health.ts +397 -0
- package/corpus/templates/analytics/server/lib/first-party-analytics-rollups.ts +182 -0
- package/corpus/templates/analytics/server/lib/first-party-analytics.ts +86 -15
- package/corpus/templates/analytics/server/lib/provider-api.ts +20 -1
- package/corpus/templates/analytics/server/lib/replay-storage.ts +1 -1
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +1 -0
- package/corpus/templates/analytics/server/plugins/db.ts +60 -0
- package/corpus/templates/assets/.agents/skills/agent-native-docs/SKILL.md +23 -3
- package/corpus/templates/assets/.agents/skills/agent-native-toolkit/SKILL.md +16 -0
- package/corpus/templates/assets/.agents/skills/frontend-design/SKILL.md +23 -2
- package/corpus/templates/assets/.agents/skills/frontend-design/references/visual-direction.md +99 -0
- package/corpus/templates/assets/agent-native.json +12 -0
- package/corpus/templates/assets/server/lib/generation.ts +8 -8
- package/corpus/templates/assets/server/lib/storage.ts +1 -1
- package/corpus/templates/assets/server/plugins/onboarding.ts +1 -1
- package/corpus/templates/brain/.agents/skills/agent-native-docs/SKILL.md +23 -3
- package/corpus/templates/brain/.agents/skills/agent-native-toolkit/SKILL.md +16 -0
- package/corpus/templates/brain/.agents/skills/frontend-design/SKILL.md +23 -2
- package/corpus/templates/brain/.agents/skills/frontend-design/references/visual-direction.md +99 -0
- package/corpus/templates/brain/agent-native.json +12 -0
- package/corpus/templates/calendar/.agents/skills/agent-native-docs/SKILL.md +23 -3
- package/corpus/templates/calendar/.agents/skills/agent-native-toolkit/SKILL.md +16 -0
- package/corpus/templates/calendar/.agents/skills/frontend-design/SKILL.md +23 -2
- package/corpus/templates/calendar/.agents/skills/frontend-design/references/visual-direction.md +99 -0
- package/corpus/templates/calendar/agent-native.json +12 -0
- package/corpus/templates/chat/.agents/skills/agent-native-docs/SKILL.md +23 -3
- package/corpus/templates/chat/.agents/skills/agent-native-toolkit/SKILL.md +16 -0
- package/corpus/templates/chat/.agents/skills/frontend-design/SKILL.md +23 -2
- package/corpus/templates/chat/.agents/skills/frontend-design/references/visual-direction.md +99 -0
- package/corpus/templates/chat/AGENTS.md +3 -0
- package/corpus/templates/chat/DESIGN.md +28 -0
- package/corpus/templates/chat/agent-native.json +12 -0
- package/corpus/templates/clips/.agents/skills/agent-native-docs/SKILL.md +23 -3
- package/corpus/templates/clips/.agents/skills/agent-native-toolkit/SKILL.md +16 -0
- package/corpus/templates/clips/.agents/skills/frontend-design/SKILL.md +23 -2
- package/corpus/templates/clips/.agents/skills/frontend-design/references/visual-direction.md +99 -0
- package/corpus/templates/clips/actions/cleanup-transcript.ts +2 -2
- package/corpus/templates/clips/actions/delete-recording-permanent.ts +3 -0
- package/corpus/templates/clips/actions/get-playback-position.ts +68 -0
- package/corpus/templates/clips/actions/import-loom-recording.ts +2 -2
- package/corpus/templates/clips/actions/save-playback-position.ts +80 -0
- package/corpus/templates/clips/actions/set-thumbnail.ts +1 -1
- package/corpus/templates/clips/agent-native.json +12 -0
- package/corpus/templates/clips/app/components/player/video-player.tsx +54 -5
- package/corpus/templates/clips/app/components/recorder/pre-record-panel.tsx +65 -18
- package/corpus/templates/clips/app/hooks/use-playback-position.ts +188 -0
- package/corpus/templates/clips/app/hooks/use-view-tracking.ts +6 -24
- package/corpus/templates/clips/app/i18n/en-US.ts +4 -0
- package/corpus/templates/clips/app/lib/playback-position.ts +99 -0
- package/corpus/templates/clips/app/lib/viewer-session.ts +29 -0
- package/corpus/templates/clips/changelog/2026-08-05-clip-buffering-now-uses-buffering-copy-after-playback.md +6 -0
- package/corpus/templates/clips/changelog/2026-08-05-clips-remembers-your-playback-position-when-you-reopen-a-cli.md +6 -0
- package/corpus/templates/clips/desktop/package.json +1 -0
- package/corpus/templates/clips/desktop/src/app.tsx +70 -6
- package/corpus/templates/clips/desktop/src/components/AlertDialog.tsx +131 -0
- package/corpus/templates/clips/desktop/src/styles.css +129 -0
- package/corpus/templates/clips/learnings.defaults.md +1 -1
- package/corpus/templates/clips/server/db/schema.ts +18 -0
- package/corpus/templates/clips/server/lib/public-agent-context.ts +1 -1
- package/corpus/templates/clips/server/lib/video-storage.ts +1 -1
- package/corpus/templates/clips/server/plugins/db.ts +15 -0
- package/corpus/templates/clips/server/routes/api/media/index.post.ts +1 -1
- package/corpus/templates/content/.agents/skills/agent-native-docs/SKILL.md +23 -3
- package/corpus/templates/content/.agents/skills/agent-native-toolkit/SKILL.md +16 -0
- package/corpus/templates/content/.agents/skills/document-editing/references/databases.md +13 -0
- package/corpus/templates/content/.agents/skills/frontend-design/SKILL.md +23 -2
- package/corpus/templates/content/.agents/skills/frontend-design/references/visual-direction.md +99 -0
- package/corpus/templates/content/AGENTS.md +1 -0
- package/corpus/templates/content/actions/_content-database-mutation-lock.ts +41 -0
- package/corpus/templates/content/actions/_content-database-row-migration.ts +569 -0
- package/corpus/templates/content/actions/_database-source-utils.ts +82 -36
- package/corpus/templates/content/actions/_database-utils.ts +5 -0
- package/corpus/templates/content/actions/_delete-content-space.ts +25 -11
- package/corpus/templates/content/actions/add-database-item.ts +60 -42
- package/corpus/templates/content/actions/attach-content-database-source.ts +2 -0
- package/corpus/templates/content/actions/configure-document-property.ts +99 -104
- package/corpus/templates/content/actions/delete-content-database.ts +19 -7
- package/corpus/templates/content/actions/delete-document-property.ts +47 -58
- package/corpus/templates/content/actions/delete-document.ts +390 -167
- package/corpus/templates/content/actions/disconnect-content-database-source.ts +41 -24
- package/corpus/templates/content/actions/duplicate-database-item.ts +63 -31
- package/corpus/templates/content/actions/duplicate-database-items.ts +86 -43
- package/corpus/templates/content/actions/duplicate-document-property.ts +37 -14
- package/corpus/templates/content/actions/migrate-content-database-rows.ts +830 -0
- package/corpus/templates/content/actions/move-database-item.ts +14 -0
- package/corpus/templates/content/actions/permanently-delete-document.ts +27 -6
- package/corpus/templates/content/actions/remove-database-items.ts +13 -0
- package/corpus/templates/content/actions/reorder-document-property.ts +45 -46
- package/corpus/templates/content/actions/set-document-property.ts +68 -28
- package/corpus/templates/content/actions/submit-content-database-form.ts +49 -0
- package/corpus/templates/content/actions/transcribe-media.ts +1 -1
- package/corpus/templates/content/agent-native.json +12 -0
- package/corpus/templates/content/app/components/editor/image-upload.ts +2 -2
- package/corpus/templates/content/app/i18n-data.ts +1 -1
- package/corpus/templates/content/changelog/2026-08-01-content-can-reorganize-every-row-in-an-existing-database-as-.md +6 -0
- package/corpus/templates/content/parity/matrix.md +1 -1
- package/corpus/templates/content/parity/matrix.ts +4 -2
- package/corpus/templates/content/server/db/schema.ts +30 -0
- package/corpus/templates/content/server/plugins/db.ts +24 -0
- package/corpus/templates/content/server/plugins/onboarding.ts +2 -2
- package/corpus/templates/crm/.agents/skills/agent-native-docs/SKILL.md +23 -3
- package/corpus/templates/crm/.agents/skills/agent-native-toolkit/SKILL.md +16 -0
- package/corpus/templates/crm/agent-native.json +12 -0
- package/corpus/templates/design/.agents/skills/agent-native-docs/SKILL.md +23 -3
- package/corpus/templates/design/.agents/skills/agent-native-toolkit/SKILL.md +16 -0
- package/corpus/templates/design/.agents/skills/design-generation/SKILL.md +2 -0
- package/corpus/templates/design/.agents/skills/frontend-design/SKILL.md +23 -2
- package/corpus/templates/design/.agents/skills/frontend-design/references/visual-direction.md +99 -0
- package/corpus/templates/design/CODE_NATIVE_DESIGN_STUDIO_IMPLEMENTATION_PLAN.md +2 -2
- package/corpus/templates/design/DESIGN-STUDIO-PLAN.md +2 -2
- package/corpus/templates/design/actions/apply-design-token-edit.ts +1 -1
- package/corpus/templates/design/actions/capture-design-state.ts +1 -1
- package/corpus/templates/design/actions/connect-builder-app.ts +2 -2
- package/corpus/templates/design/actions/create-design-branch.ts +1 -1
- package/corpus/templates/design/actions/create-fusion-app.ts +3 -3
- package/corpus/templates/design/actions/deploy-design-preview.ts +1 -1
- package/corpus/templates/design/actions/generate-design.ts +3 -2
- package/corpus/templates/design/actions/get-component-details.ts +1 -1
- package/corpus/templates/design/actions/get-design-branch-diff.ts +1 -1
- package/corpus/templates/design/actions/index-components.ts +3 -3
- package/corpus/templates/design/actions/index-design-system-with-builder.ts +1 -1
- package/corpus/templates/design/actions/migrate-inline-design-to-app.ts +3 -3
- package/corpus/templates/design/actions/open-component-source.ts +1 -1
- package/corpus/templates/design/actions/update-design.ts +96 -14
- package/corpus/templates/design/agent-native.json +12 -0
- package/corpus/templates/design/app/components/design/DesignImportPanel.tsx +7 -2
- package/corpus/templates/design/app/components/design/FigmaHydrationDialog.tsx +11 -2
- package/corpus/templates/design/app/components/design/edit-panel/component-section.tsx +1 -1
- package/corpus/templates/design/app/components/editor/PromptDialog.tsx +8 -1
- package/corpus/templates/design/app/i18n-data.ts +53 -22
- package/corpus/templates/design/app/lib/design-file-upload.ts +2 -3
- package/corpus/templates/design/app/lib/upload-limits.ts +4 -0
- package/corpus/templates/design/app/pages/DesignSystemSetup.tsx +1 -1
- package/corpus/templates/design/changelog/2026-08-05-chat-attachments-now-warn-before-upload-when-they-exceed-the.md +6 -0
- package/corpus/templates/design/changelog/2026-08-05-figma-fig-uploads-now-show-a-clear-4-mb-limit-up-front-inste.md +6 -0
- package/corpus/templates/design/scripts/qa-figma-stress-import.ts +1 -1
- package/corpus/templates/design/server/handlers/import-design-file.ts +9 -5
- package/corpus/templates/design/server/handlers/uploads.ts +13 -9
- package/corpus/templates/design/server/lib/fig-file-limits.ts +2 -1
- package/corpus/templates/design/server/lib/figma-image-hydration.ts +1 -1
- package/corpus/templates/design/server/lib/figma-node-import.ts +1 -1
- package/corpus/templates/design/server/lib/request-body-limits.ts +11 -0
- package/corpus/templates/design/shared/canvas-frames.ts +81 -0
- package/corpus/templates/design/shared/design-source-capabilities.ts +25 -9
- package/corpus/templates/dispatch/.agents/skills/agent-native-docs/SKILL.md +23 -3
- package/corpus/templates/dispatch/.agents/skills/agent-native-toolkit/SKILL.md +16 -0
- package/corpus/templates/dispatch/.agents/skills/frontend-design/SKILL.md +23 -2
- package/corpus/templates/dispatch/.agents/skills/frontend-design/references/visual-direction.md +99 -0
- package/corpus/templates/dispatch/agent-native.json +12 -0
- package/corpus/templates/factory/.agents/skills/agent-native-docs/SKILL.md +23 -3
- package/corpus/templates/factory/.agents/skills/agent-native-toolkit/SKILL.md +16 -0
- package/corpus/templates/factory/.agents/skills/frontend-design/SKILL.md +23 -2
- package/corpus/templates/factory/.agents/skills/frontend-design/references/visual-direction.md +99 -0
- package/corpus/templates/factory/agent-native.json +12 -0
- package/corpus/templates/forms/.agents/skills/agent-native-docs/SKILL.md +23 -3
- package/corpus/templates/forms/.agents/skills/agent-native-toolkit/SKILL.md +16 -0
- package/corpus/templates/forms/.agents/skills/frontend-design/SKILL.md +23 -2
- package/corpus/templates/forms/.agents/skills/frontend-design/references/visual-direction.md +99 -0
- package/corpus/templates/forms/actions/export-responses.ts +1 -1
- package/corpus/templates/forms/agent-native.json +12 -0
- package/corpus/templates/macros/.agents/skills/agent-native-docs/SKILL.md +23 -3
- package/corpus/templates/macros/.agents/skills/agent-native-toolkit/SKILL.md +16 -0
- package/corpus/templates/macros/.agents/skills/frontend-design/SKILL.md +23 -2
- package/corpus/templates/macros/.agents/skills/frontend-design/references/visual-direction.md +99 -0
- package/corpus/templates/macros/agent-native.json +12 -0
- package/corpus/templates/mail/.agents/skills/agent-native-docs/SKILL.md +23 -3
- package/corpus/templates/mail/.agents/skills/agent-native-toolkit/SKILL.md +16 -0
- package/corpus/templates/mail/.agents/skills/frontend-design/SKILL.md +23 -2
- package/corpus/templates/mail/.agents/skills/frontend-design/references/visual-direction.md +99 -0
- package/corpus/templates/mail/agent-native.json +12 -0
- package/corpus/templates/mail/app/i18n/en-US.ts +1 -1
- package/corpus/templates/mail/server/lib/media-upload.ts +1 -1
- package/corpus/templates/plan/.agents/skills/agent-native-docs/SKILL.md +23 -3
- package/corpus/templates/plan/.agents/skills/agent-native-toolkit/SKILL.md +16 -0
- package/corpus/templates/plan/.agents/skills/frontend-design/SKILL.md +23 -2
- package/corpus/templates/plan/.agents/skills/frontend-design/references/visual-direction.md +99 -0
- package/corpus/templates/plan/agent-native.json +12 -0
- package/corpus/templates/plan/server/lib/plan-assets.ts +1 -1
- package/corpus/templates/slides/.agents/skills/agent-native-docs/SKILL.md +23 -3
- package/corpus/templates/slides/.agents/skills/agent-native-toolkit/SKILL.md +16 -0
- package/corpus/templates/slides/.agents/skills/frontend-design/SKILL.md +23 -2
- package/corpus/templates/slides/.agents/skills/frontend-design/references/visual-direction.md +99 -0
- package/corpus/templates/slides/actions/generate-image-api.ts +1 -1
- package/corpus/templates/slides/actions/generate-slides-ai.ts +1 -1
- package/corpus/templates/slides/actions/import-file.ts +2 -2
- package/corpus/templates/slides/actions/index-design-system-with-builder.ts +1 -1
- package/corpus/templates/slides/agent-native.json +12 -0
- package/corpus/templates/slides/app/components/design-system/DesignSystemSetup.tsx +1 -1
- package/corpus/templates/slides/app/i18n/en-US.ts +2 -2
- package/corpus/templates/slides/app/lib/deck-sorting.ts +19 -0
- package/corpus/templates/slides/app/lib/image-drop-to-agent.ts +1 -1
- package/corpus/templates/slides/app/pages/Index.tsx +7 -2
- package/corpus/templates/slides/changelog/2026-08-05-decks-are-now-sorted-by-most-recently-updated.md +6 -0
- package/corpus/templates/slides/server/handlers/assets.ts +1 -1
- package/corpus/templates/slides/server/handlers/uploads.ts +1 -1
- package/corpus/templates/tasks/.agents/skills/agent-native-docs/SKILL.md +23 -3
- package/corpus/templates/tasks/.agents/skills/agent-native-toolkit/SKILL.md +16 -0
- package/corpus/templates/tasks/.agents/skills/frontend-design/SKILL.md +23 -2
- package/corpus/templates/tasks/.agents/skills/frontend-design/references/visual-direction.md +99 -0
- package/corpus/templates/tasks/agent-native.json +12 -0
- package/dist/action.d.ts +6 -0
- package/dist/agent/engine/builder-engine.js +2 -2
- package/dist/agent/engine/credential-errors.d.ts +1 -1
- package/dist/agent/engine/credential-errors.js +2 -2
- package/dist/agent/production-agent.js +3 -2
- package/dist/brand-kit/fig/index.js +1 -1
- package/dist/cli/agent.js +45 -3
- package/dist/cli/code-agent-executor.js +2 -1
- package/dist/cli/create.d.ts +9 -1
- package/dist/cli/create.js +94 -1
- package/dist/cli/doctor.d.ts +8 -11
- package/dist/cli/doctor.js +92 -24
- package/dist/cli/index.js +6 -5
- package/dist/client/AgentAskPopover.d.ts +3 -1
- package/dist/client/AgentAskPopover.js +2 -2
- package/dist/client/AgentPanel.js +9 -3
- package/dist/client/AssistantChat.js +54 -33
- package/dist/client/MultiTabAssistantChat.js +1 -1
- package/dist/client/RouteTransitionIndicator.d.ts +7 -0
- package/dist/client/RouteTransitionIndicator.js +31 -0
- package/dist/client/agent-engine-key.js +1 -1
- package/dist/client/app-providers.js +11 -2
- package/dist/client/chat/message-components.js +1 -1
- package/dist/client/chat/run-recovery.js +1 -1
- package/dist/client/chat/tool-call-display.d.ts +3 -1
- package/dist/client/chat/tool-call-display.js +4 -3
- package/dist/client/chat-model-groups.d.ts +6 -0
- package/dist/client/chat-model-groups.js +11 -0
- package/dist/client/error-format.js +1 -1
- package/dist/client/i18n.js +1 -1
- package/dist/client/onboarding/FirstRunOnboarding.d.ts +5 -1
- package/dist/client/onboarding/FirstRunOnboarding.js +29 -13
- package/dist/client/onboarding/first-run-enabled.d.ts +6 -1
- package/dist/client/onboarding/first-run-enabled.js +33 -3
- package/dist/client/onboarding/use-onboarding.js +16 -11
- package/dist/client/require-session.js +13 -4
- package/dist/client/resources/mcp-integration-catalog.js +26 -0
- package/dist/client/resources/mcp-integration-logos.js +4 -0
- package/dist/client/route-warmup.js +56 -10
- package/dist/client/settings/AccountSettingsCard.js +78 -3
- package/dist/client/settings/SettingsPanel.js +1 -1
- package/dist/client/settings/VoiceTranscriptionSection.js +2 -2
- package/dist/client/settings/useBuilderStatus.js +1 -1
- package/dist/client/setup-connections/useBuilderConnectCardController.js +1 -1
- package/dist/client/ui/index.d.ts +1 -0
- package/dist/client/ui/index.js +1 -0
- package/dist/client/uploads/upload-editor-image.js +1 -1
- package/dist/client/use-chat-threads.js +3 -0
- package/dist/client/use-session.d.ts +11 -0
- package/dist/client/use-session.js +34 -6
- package/dist/collab/routes.d.ts +2 -2
- package/dist/config.d.ts +48 -0
- package/dist/config.js +111 -0
- package/dist/db/migrations.js +5 -0
- package/dist/eject/provider-api-definitions.d.ts +1 -1
- package/dist/eject/provider-api-definitions.js +1 -0
- package/dist/eject/remote-mcp-presets.js +1 -0
- package/dist/extensions/web-search-tool.js +2 -2
- package/dist/file-upload/actions/upload-image.js +1 -1
- package/dist/file-upload/registry.js +1 -1
- package/dist/guards/index.d.ts +3 -0
- package/dist/guards/index.js +2 -0
- package/dist/guards/no-empty-migrations.d.ts +14 -0
- package/dist/guards/no-empty-migrations.js +126 -0
- package/dist/index.browser.d.ts +1 -0
- package/dist/index.browser.js +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/localization/default-messages.d.ts +24 -0
- package/dist/localization/default-messages.js +26 -2
- package/dist/notifications/routes.d.ts +6 -6
- package/dist/onboarding/app-profile.js +1 -1
- package/dist/onboarding/plugin.d.ts +2 -0
- package/dist/onboarding/plugin.js +29 -2
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +16 -16
- package/dist/provider-api/actions/provider-api.d.ts +13 -13
- package/dist/provider-api/index.d.ts +4 -4
- package/dist/provider-api/index.js +35 -0
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/resources/handlers.js +1 -1
- package/dist/scripts/docs/framework-search.d.ts +9 -0
- package/dist/scripts/docs/framework-search.js +239 -0
- package/dist/scripts/docs/index.js +1 -0
- package/dist/scripts/docs/search.d.ts +10 -0
- package/dist/scripts/docs/search.js +1 -1
- package/dist/scripts/docs/source-search.d.ts +10 -2
- package/dist/scripts/docs/source-search.js +108 -41
- package/dist/search-utils/index.d.ts +11 -0
- package/dist/search-utils/index.js +72 -0
- package/dist/server/action-change.d.ts +6 -0
- package/dist/server/action-change.js +28 -14
- package/dist/server/action-discovery.js +9 -0
- package/dist/server/action-routes.js +1 -0
- package/dist/server/agent-chat/browser-team-tools.js +1 -1
- package/dist/server/agent-chat/script-entries.js +43 -2
- package/dist/server/auth-login-mode.d.ts +8 -0
- package/dist/server/auth-login-mode.js +17 -0
- package/dist/server/auth.js +100 -15
- package/dist/server/better-auth-instance.d.ts +36 -0
- package/dist/server/better-auth-instance.js +25 -3
- package/dist/server/builder-design-systems.js +1 -1
- package/dist/server/core-routes-plugin.js +17 -14
- package/dist/server/credential-provider.js +3 -3
- package/dist/server/email-templates.d.ts +7 -0
- package/dist/server/email-templates.js +24 -0
- package/dist/server/email.d.ts +17 -0
- package/dist/server/email.js +22 -1
- package/dist/server/framework-request-handler.js +6 -0
- package/dist/server/onboarding-html.d.ts +2 -0
- package/dist/server/onboarding-html.js +169 -8
- package/dist/server/realtime-token.d.ts +1 -1
- package/dist/server/realtime-voice.js +1 -1
- package/dist/server/sentry.d.ts +1 -1
- package/dist/server/transcribe-voice.js +3 -3
- package/dist/shared/first-run-onboarding.d.ts +1 -0
- package/dist/shared/first-run-onboarding.js +1 -0
- package/dist/templates/chat/.agents/skills/agent-native-docs/SKILL.md +23 -3
- package/dist/templates/chat/.agents/skills/agent-native-toolkit/SKILL.md +16 -0
- package/dist/templates/chat/.agents/skills/frontend-design/SKILL.md +23 -2
- package/dist/templates/chat/.agents/skills/frontend-design/references/visual-direction.md +99 -0
- package/dist/templates/chat/AGENTS.md +3 -0
- package/dist/templates/chat/DESIGN.md +28 -0
- package/dist/templates/chat/agent-native.json +12 -0
- package/dist/templates/default/.agents/skills/agent-native-docs/SKILL.md +23 -3
- package/dist/templates/default/.agents/skills/agent-native-toolkit/SKILL.md +16 -0
- package/dist/templates/default/.agents/skills/frontend-design/SKILL.md +23 -2
- package/dist/templates/default/.agents/skills/frontend-design/references/visual-direction.md +99 -0
- package/dist/templates/default/AGENTS.md +4 -0
- package/dist/templates/default/DESIGN.md +30 -0
- package/dist/templates/default/agent-native.json +9 -0
- package/dist/templates/default/app/i18n/ar-SA.ts +2 -2
- package/dist/templates/default/app/i18n/de-DE.ts +2 -2
- package/dist/templates/default/app/i18n/en-US.ts +2 -2
- package/dist/templates/default/app/i18n/es-ES.ts +2 -2
- package/dist/templates/default/app/i18n/fr-FR.ts +2 -2
- package/dist/templates/default/app/i18n/hi-IN.ts +2 -2
- package/dist/templates/default/app/i18n/ja-JP.ts +2 -2
- package/dist/templates/default/app/i18n/ko-KR.ts +2 -2
- package/dist/templates/default/app/i18n/pt-BR.ts +2 -2
- package/dist/templates/default/app/i18n/zh-CN.ts +2 -2
- package/dist/templates/default/app/i18n/zh-TW.ts +1 -1
- package/dist/templates/default/package.json +1 -0
- package/dist/templates/headless/.agents/skills/agent-native-docs/SKILL.md +23 -3
- package/dist/templates/headless/.agents/skills/agent-native-toolkit/SKILL.md +16 -0
- package/dist/templates/headless/agent-native.json +9 -0
- package/dist/templates/headless/package.json +2 -0
- package/dist/templates/workspace-core/.agents/skills/agent-native-docs/SKILL.md +23 -3
- package/dist/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +16 -0
- package/dist/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +23 -2
- package/dist/templates/workspace-core/.agents/skills/frontend-design/references/visual-direction.md +99 -0
- package/dist/templates/workspace-core/AGENTS.md +3 -0
- package/dist/templates/workspace-core/DESIGN.md +35 -0
- package/dist/templates/workspace-root/AGENTS.md +3 -0
- package/dist/templates/workspace-root/DESIGN.md +35 -0
- package/dist/templates/workspace-root/agent-native.json +9 -0
- package/dist/templates/workspace-root/package.json +3 -0
- package/dist/transcription/builder-transcription.js +1 -1
- package/dist/user-profile/actions/change-password.d.ts +8 -0
- package/dist/user-profile/actions/change-password.js +24 -0
- package/dist/user-profile/actions/get-auth-methods.d.ts +6 -0
- package/dist/user-profile/actions/get-auth-methods.js +23 -0
- package/dist/user-profile/actions/set-password.d.ts +7 -0
- package/dist/user-profile/actions/set-password.js +23 -0
- package/dist/vite/client.d.ts +8 -1
- package/dist/vite/client.js +63 -12
- package/dist/vite/index.d.ts +1 -0
- package/dist/vite/index.js +1 -0
- package/docs/AGENTS.md +7 -2
- package/docs/SKILL.md +7 -5
- package/docs/content/agent-native-config.mdx +165 -0
- package/docs/content/agent-native-toolkit.mdx +1 -1
- package/docs/content/deployment.mdx +7 -2
- package/docs/content/doctor.mdx +21 -13
- package/docs/content/environment-variables.mdx +158 -0
- package/docs/content/file-uploads.mdx +1 -1
- package/docs/content/getting-started.mdx +1 -1
- package/docs/content/key-concepts.mdx +1 -1
- package/docs/content/multi-app-workspace.mdx +1 -1
- package/docs/content/template-clips-ai-and-editing.mdx +6 -6
- package/docs/content/template-clips-developers.mdx +3 -3
- package/docs/content/toolkit-settings.mdx +1 -1
- package/docs/content/voice-input.mdx +4 -4
- package/package.json +6 -2
- package/src/eject/provider-api-definitions.ts +1 -0
- package/src/eject/remote-mcp-presets.ts +1 -0
- package/src/templates/chat/.agents/skills/agent-native-docs/SKILL.md +23 -3
- package/src/templates/chat/.agents/skills/agent-native-toolkit/SKILL.md +16 -0
- package/src/templates/chat/.agents/skills/frontend-design/SKILL.md +23 -2
- package/src/templates/chat/.agents/skills/frontend-design/references/visual-direction.md +99 -0
- package/src/templates/chat/AGENTS.md +3 -0
- package/src/templates/chat/DESIGN.md +28 -0
- package/src/templates/chat/agent-native.json +12 -0
- package/src/templates/default/.agents/skills/agent-native-docs/SKILL.md +23 -3
- package/src/templates/default/.agents/skills/agent-native-toolkit/SKILL.md +16 -0
- package/src/templates/default/.agents/skills/frontend-design/SKILL.md +23 -2
- package/src/templates/default/.agents/skills/frontend-design/references/visual-direction.md +99 -0
- package/src/templates/default/AGENTS.md +4 -0
- package/src/templates/default/DESIGN.md +30 -0
- package/src/templates/default/agent-native.json +9 -0
- package/src/templates/default/app/i18n/ar-SA.ts +2 -2
- package/src/templates/default/app/i18n/de-DE.ts +2 -2
- package/src/templates/default/app/i18n/en-US.ts +2 -2
- package/src/templates/default/app/i18n/es-ES.ts +2 -2
- package/src/templates/default/app/i18n/fr-FR.ts +2 -2
- package/src/templates/default/app/i18n/hi-IN.ts +2 -2
- package/src/templates/default/app/i18n/ja-JP.ts +2 -2
- package/src/templates/default/app/i18n/ko-KR.ts +2 -2
- package/src/templates/default/app/i18n/pt-BR.ts +2 -2
- package/src/templates/default/app/i18n/zh-CN.ts +2 -2
- package/src/templates/default/app/i18n/zh-TW.ts +1 -1
- package/src/templates/default/package.json +1 -0
- package/src/templates/headless/.agents/skills/agent-native-docs/SKILL.md +23 -3
- package/src/templates/headless/.agents/skills/agent-native-toolkit/SKILL.md +16 -0
- package/src/templates/headless/agent-native.json +9 -0
- package/src/templates/headless/package.json +2 -0
- package/src/templates/workspace-core/.agents/skills/agent-native-docs/SKILL.md +23 -3
- package/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +16 -0
- package/src/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +23 -2
- package/src/templates/workspace-core/.agents/skills/frontend-design/references/visual-direction.md +99 -0
- package/src/templates/workspace-core/AGENTS.md +3 -0
- package/src/templates/workspace-core/DESIGN.md +35 -0
- package/src/templates/workspace-root/AGENTS.md +3 -0
- package/src/templates/workspace-root/DESIGN.md +35 -0
- package/src/templates/workspace-root/agent-native.json +9 -0
- package/src/templates/workspace-root/package.json +3 -0
|
@@ -86,6 +86,7 @@ import {
|
|
|
86
86
|
type ExistingBuilderSourceRowIdentity,
|
|
87
87
|
} from "./_builder-cms-source-adapter.js";
|
|
88
88
|
import { mergeBuilderCmsWriteSettingsIntoJson } from "./_builder-cms-write-settings.js";
|
|
89
|
+
import { lockContentDatabaseMutation } from "./_content-database-mutation-lock.js";
|
|
89
90
|
import { ensureDocumentsFilesMembership } from "./_content-files.js";
|
|
90
91
|
import {
|
|
91
92
|
organizationContentSpaceId,
|
|
@@ -7018,26 +7019,42 @@ export async function replaceSourceMetadata(args: {
|
|
|
7018
7019
|
})
|
|
7019
7020
|
.where(eq(schema.contentDatabaseSources.id, args.source.id));
|
|
7020
7021
|
} else {
|
|
7021
|
-
await db.
|
|
7022
|
-
|
|
7023
|
-
|
|
7024
|
-
|
|
7025
|
-
|
|
7026
|
-
|
|
7027
|
-
|
|
7028
|
-
|
|
7029
|
-
|
|
7030
|
-
|
|
7031
|
-
|
|
7032
|
-
|
|
7022
|
+
await db.transaction(async (tx) => {
|
|
7023
|
+
await lockContentDatabaseMutation(
|
|
7024
|
+
tx as unknown as ReturnType<typeof getDb>,
|
|
7025
|
+
args.database.id,
|
|
7026
|
+
);
|
|
7027
|
+
const [existing] = await tx
|
|
7028
|
+
.select({ id: schema.contentDatabaseSources.id })
|
|
7029
|
+
.from(schema.contentDatabaseSources)
|
|
7030
|
+
.where(eq(schema.contentDatabaseSources.databaseId, args.database.id))
|
|
7031
|
+
.limit(1);
|
|
7032
|
+
if (existing) {
|
|
7033
|
+
throw new Error(
|
|
7034
|
+
"Database source state changed before attachment completed.",
|
|
7035
|
+
);
|
|
7036
|
+
}
|
|
7037
|
+
await tx.insert(schema.contentDatabaseSources).values({
|
|
7038
|
+
id: sourceId,
|
|
7039
|
+
ownerEmail: args.database.ownerEmail,
|
|
7040
|
+
orgId: args.database.orgId,
|
|
7041
|
+
databaseId: args.database.id,
|
|
7033
7042
|
sourceType: args.sourceType,
|
|
7043
|
+
sourceName: args.sourceName,
|
|
7034
7044
|
sourceTable: args.sourceTable,
|
|
7035
|
-
|
|
7036
|
-
|
|
7037
|
-
|
|
7038
|
-
|
|
7039
|
-
|
|
7040
|
-
|
|
7045
|
+
syncState: "linked",
|
|
7046
|
+
freshness: "fresh",
|
|
7047
|
+
capabilitiesJson: sourceCapabilitiesForType(args.sourceType),
|
|
7048
|
+
metadataJson: serializeSourceMetadataRecord({
|
|
7049
|
+
sourceType: args.sourceType,
|
|
7050
|
+
sourceTable: args.sourceTable,
|
|
7051
|
+
}),
|
|
7052
|
+
lastRefreshedAt: args.now,
|
|
7053
|
+
lastSourceUpdatedAt: args.now,
|
|
7054
|
+
lastError: null,
|
|
7055
|
+
createdAt: args.now,
|
|
7056
|
+
updatedAt: args.now,
|
|
7057
|
+
});
|
|
7041
7058
|
});
|
|
7042
7059
|
}
|
|
7043
7060
|
|
|
@@ -7050,6 +7067,7 @@ export async function replaceSourceMetadata(args: {
|
|
|
7050
7067
|
*/
|
|
7051
7068
|
export async function insertSecondarySource(args: {
|
|
7052
7069
|
database: ContentDatabaseRow;
|
|
7070
|
+
expectedPrimarySourceId: string;
|
|
7053
7071
|
sourceType: ContentDatabaseSourceType;
|
|
7054
7072
|
sourceName: string;
|
|
7055
7073
|
sourceTable: string;
|
|
@@ -7057,26 +7075,54 @@ export async function insertSecondarySource(args: {
|
|
|
7057
7075
|
}): Promise<string> {
|
|
7058
7076
|
const db = getDb();
|
|
7059
7077
|
const sourceId = crypto.randomUUID();
|
|
7060
|
-
await db.
|
|
7061
|
-
|
|
7062
|
-
|
|
7063
|
-
|
|
7064
|
-
|
|
7065
|
-
|
|
7066
|
-
|
|
7067
|
-
|
|
7068
|
-
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
|
|
7078
|
+
await db.transaction(async (tx) => {
|
|
7079
|
+
await lockContentDatabaseMutation(
|
|
7080
|
+
tx as unknown as ReturnType<typeof getDb>,
|
|
7081
|
+
args.database.id,
|
|
7082
|
+
);
|
|
7083
|
+
const sources = await tx
|
|
7084
|
+
.select({
|
|
7085
|
+
id: schema.contentDatabaseSources.id,
|
|
7086
|
+
sourceType: schema.contentDatabaseSources.sourceType,
|
|
7087
|
+
sourceTable: schema.contentDatabaseSources.sourceTable,
|
|
7088
|
+
})
|
|
7089
|
+
.from(schema.contentDatabaseSources)
|
|
7090
|
+
.where(eq(schema.contentDatabaseSources.databaseId, args.database.id));
|
|
7091
|
+
if (!sources.some((source) => source.id === args.expectedPrimarySourceId)) {
|
|
7092
|
+
throw new Error(
|
|
7093
|
+
"Database source state changed before attachment completed.",
|
|
7094
|
+
);
|
|
7095
|
+
}
|
|
7096
|
+
if (
|
|
7097
|
+
sources.some(
|
|
7098
|
+
(source) =>
|
|
7099
|
+
source.sourceType === args.sourceType &&
|
|
7100
|
+
source.sourceTable === args.sourceTable,
|
|
7101
|
+
)
|
|
7102
|
+
) {
|
|
7103
|
+
throw new Error(`"${args.sourceTable}" is already attached as a source.`);
|
|
7104
|
+
}
|
|
7105
|
+
await tx.insert(schema.contentDatabaseSources).values({
|
|
7106
|
+
id: sourceId,
|
|
7107
|
+
ownerEmail: args.database.ownerEmail,
|
|
7108
|
+
orgId: args.database.orgId,
|
|
7109
|
+
databaseId: args.database.id,
|
|
7072
7110
|
sourceType: args.sourceType,
|
|
7111
|
+
sourceName: args.sourceName,
|
|
7073
7112
|
sourceTable: args.sourceTable,
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7113
|
+
syncState: "linked",
|
|
7114
|
+
freshness: "fresh",
|
|
7115
|
+
capabilitiesJson: sourceCapabilitiesForType(args.sourceType),
|
|
7116
|
+
metadataJson: serializeSourceMetadataRecord({
|
|
7117
|
+
sourceType: args.sourceType,
|
|
7118
|
+
sourceTable: args.sourceTable,
|
|
7119
|
+
}),
|
|
7120
|
+
lastRefreshedAt: args.now,
|
|
7121
|
+
lastSourceUpdatedAt: args.now,
|
|
7122
|
+
lastError: null,
|
|
7123
|
+
createdAt: args.now,
|
|
7124
|
+
updatedAt: args.now,
|
|
7125
|
+
});
|
|
7080
7126
|
});
|
|
7081
7127
|
return sourceId;
|
|
7082
7128
|
}
|
|
@@ -1448,6 +1448,11 @@ export async function deleteDatabaseDataForDocument(
|
|
|
1448
1448
|
await db
|
|
1449
1449
|
.delete(schema.contentDatabaseSources)
|
|
1450
1450
|
.where(eq(schema.contentDatabaseSources.databaseId, database.id));
|
|
1451
|
+
await db
|
|
1452
|
+
.delete(schema.contentDatabaseMigrationReceipts)
|
|
1453
|
+
.where(
|
|
1454
|
+
eq(schema.contentDatabaseMigrationReceipts.databaseId, database.id),
|
|
1455
|
+
);
|
|
1451
1456
|
await db
|
|
1452
1457
|
.delete(schema.documentPropertyDefinitions)
|
|
1453
1458
|
.where(eq(schema.documentPropertyDefinitions.databaseId, database.id));
|
|
@@ -2,11 +2,15 @@ import { and, eq } from "drizzle-orm";
|
|
|
2
2
|
|
|
3
3
|
import { getDb, schema } from "../server/db/index.js";
|
|
4
4
|
import { resolveContentSpaceAccess } from "./_content-space-access.js";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
deleteDocumentRootsRecursive,
|
|
7
|
+
PermanentDeleteScopeChangedError,
|
|
8
|
+
} from "./delete-document.js";
|
|
6
9
|
|
|
7
10
|
type Db = ReturnType<typeof getDb>;
|
|
11
|
+
const MAX_DELETE_SCOPE_ATTEMPTS = 3;
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
async function deleteUserContentSpaceOnce(db: Db, spaceId: string) {
|
|
10
14
|
return db.transaction(async (tx) => {
|
|
11
15
|
const scopedDb = tx as unknown as Db;
|
|
12
16
|
const access = await resolveContentSpaceAccess(spaceId, "editor", {
|
|
@@ -45,14 +49,9 @@ export async function deleteUserContentSpace(db: Db, spaceId: string) {
|
|
|
45
49
|
await scopedDb
|
|
46
50
|
.delete(schema.contentSpaceCatalogItems)
|
|
47
51
|
.where(eq(schema.contentSpaceCatalogItems.id, mapping.id));
|
|
48
|
-
const
|
|
49
|
-
scopedDb,
|
|
50
|
-
mapping.documentId,
|
|
51
|
-
access.space.ownerEmail,
|
|
52
|
-
);
|
|
53
|
-
const deletedWorkspaceDocuments = await deleteDocumentRecursive(
|
|
52
|
+
const deletedDocuments = await deleteDocumentRootsRecursive(
|
|
54
53
|
scopedDb,
|
|
55
|
-
filesDatabase.documentId,
|
|
54
|
+
[mapping.documentId, filesDatabase.documentId],
|
|
56
55
|
access.space.ownerEmail,
|
|
57
56
|
);
|
|
58
57
|
|
|
@@ -77,8 +76,23 @@ export async function deleteUserContentSpace(db: Db, spaceId: string) {
|
|
|
77
76
|
|
|
78
77
|
return {
|
|
79
78
|
spaceId,
|
|
80
|
-
deletedDocuments:
|
|
81
|
-
deletedCatalogDocuments.length + deletedWorkspaceDocuments.length,
|
|
79
|
+
deletedDocuments: deletedDocuments.length,
|
|
82
80
|
};
|
|
83
81
|
});
|
|
84
82
|
}
|
|
83
|
+
|
|
84
|
+
export async function deleteUserContentSpace(db: Db, spaceId: string) {
|
|
85
|
+
for (let attempt = 1; attempt <= MAX_DELETE_SCOPE_ATTEMPTS; attempt += 1) {
|
|
86
|
+
try {
|
|
87
|
+
return await deleteUserContentSpaceOnce(db, spaceId);
|
|
88
|
+
} catch (error) {
|
|
89
|
+
if (
|
|
90
|
+
!(error instanceof PermanentDeleteScopeChangedError) ||
|
|
91
|
+
attempt === MAX_DELETE_SCOPE_ATTEMPTS
|
|
92
|
+
) {
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
throw new Error("Workspace deletion did not complete.");
|
|
98
|
+
}
|
|
@@ -10,6 +10,10 @@ import {
|
|
|
10
10
|
isComputedPropertyType,
|
|
11
11
|
type DocumentPropertyType,
|
|
12
12
|
} from "../shared/properties.js";
|
|
13
|
+
import {
|
|
14
|
+
lockContentDatabaseMutation,
|
|
15
|
+
touchContentDatabase,
|
|
16
|
+
} from "./_content-database-mutation-lock.js";
|
|
13
17
|
import { ensureDocumentFilesMembership } from "./_content-files.js";
|
|
14
18
|
import { getContentDatabaseResponse } from "./_database-utils.js";
|
|
15
19
|
import {
|
|
@@ -97,54 +101,68 @@ export default defineAction({
|
|
|
97
101
|
.where(eq(schema.documentShares.resourceId, database.documentId));
|
|
98
102
|
|
|
99
103
|
const initialValues = Object.entries(propertyValues ?? {});
|
|
100
|
-
const propertyValueRows: Array<
|
|
101
|
-
typeof schema.documentPropertyValues.$inferInsert
|
|
102
|
-
> = [];
|
|
103
|
-
if (initialValues.length > 0) {
|
|
104
|
-
const requestedPropertyIds = initialValues.map(
|
|
105
|
-
([propertyId]) => propertyId,
|
|
106
|
-
);
|
|
107
|
-
const definitions = await db
|
|
108
|
-
.select()
|
|
109
|
-
.from(schema.documentPropertyDefinitions)
|
|
110
|
-
.where(
|
|
111
|
-
and(
|
|
112
|
-
eq(
|
|
113
|
-
schema.documentPropertyDefinitions.ownerEmail,
|
|
114
|
-
database.ownerEmail,
|
|
115
|
-
),
|
|
116
|
-
eq(schema.documentPropertyDefinitions.databaseId, databaseId),
|
|
117
|
-
inArray(
|
|
118
|
-
schema.documentPropertyDefinitions.id,
|
|
119
|
-
requestedPropertyIds,
|
|
120
|
-
),
|
|
121
|
-
),
|
|
122
|
-
);
|
|
123
|
-
const definitionById = new Map(
|
|
124
|
-
definitions.map((definition) => [definition.id, definition]),
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
for (const [propertyId, value] of initialValues) {
|
|
128
|
-
const definition = definitionById.get(propertyId);
|
|
129
|
-
const type = definition?.type as DocumentPropertyType | undefined;
|
|
130
|
-
if (!definition || !type || isComputedPropertyType(type)) continue;
|
|
131
|
-
propertyValueRows.push({
|
|
132
|
-
id: nanoid(),
|
|
133
|
-
ownerEmail: database.ownerEmail,
|
|
134
|
-
documentId,
|
|
135
|
-
propertyId,
|
|
136
|
-
valueJson: normalizedValueJson(type, value),
|
|
137
|
-
createdAt: now,
|
|
138
|
-
updatedAt: now,
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
104
|
|
|
143
105
|
await withPositionLock(
|
|
144
106
|
documentsPositionScope(database.ownerEmail, database.documentId),
|
|
145
107
|
() =>
|
|
146
108
|
withPositionLock(databaseItemsPositionScope(databaseId), async () => {
|
|
147
109
|
await db.transaction(async (tx) => {
|
|
110
|
+
await lockContentDatabaseMutation(
|
|
111
|
+
tx as unknown as ReturnType<typeof getDb>,
|
|
112
|
+
databaseId,
|
|
113
|
+
);
|
|
114
|
+
await touchContentDatabase(
|
|
115
|
+
tx as unknown as ReturnType<typeof getDb>,
|
|
116
|
+
databaseId,
|
|
117
|
+
now,
|
|
118
|
+
);
|
|
119
|
+
const propertyValueRows: Array<
|
|
120
|
+
typeof schema.documentPropertyValues.$inferInsert
|
|
121
|
+
> = [];
|
|
122
|
+
if (initialValues.length > 0) {
|
|
123
|
+
const requestedPropertyIds = initialValues.map(
|
|
124
|
+
([propertyId]) => propertyId,
|
|
125
|
+
);
|
|
126
|
+
const definitions = await tx
|
|
127
|
+
.select()
|
|
128
|
+
.from(schema.documentPropertyDefinitions)
|
|
129
|
+
.where(
|
|
130
|
+
and(
|
|
131
|
+
eq(
|
|
132
|
+
schema.documentPropertyDefinitions.ownerEmail,
|
|
133
|
+
database.ownerEmail,
|
|
134
|
+
),
|
|
135
|
+
eq(
|
|
136
|
+
schema.documentPropertyDefinitions.databaseId,
|
|
137
|
+
databaseId,
|
|
138
|
+
),
|
|
139
|
+
inArray(
|
|
140
|
+
schema.documentPropertyDefinitions.id,
|
|
141
|
+
requestedPropertyIds,
|
|
142
|
+
),
|
|
143
|
+
),
|
|
144
|
+
);
|
|
145
|
+
const definitionById = new Map(
|
|
146
|
+
definitions.map((definition) => [definition.id, definition]),
|
|
147
|
+
);
|
|
148
|
+
for (const [propertyId, value] of initialValues) {
|
|
149
|
+
const definition = definitionById.get(propertyId);
|
|
150
|
+
const type = definition?.type as
|
|
151
|
+
| DocumentPropertyType
|
|
152
|
+
| undefined;
|
|
153
|
+
if (!definition || !type || isComputedPropertyType(type))
|
|
154
|
+
continue;
|
|
155
|
+
propertyValueRows.push({
|
|
156
|
+
id: nanoid(),
|
|
157
|
+
ownerEmail: database.ownerEmail,
|
|
158
|
+
documentId,
|
|
159
|
+
propertyId,
|
|
160
|
+
valueJson: normalizedValueJson(type, value),
|
|
161
|
+
createdAt: now,
|
|
162
|
+
updatedAt: now,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
148
166
|
const [maxDocPos] = await tx
|
|
149
167
|
.select({ max: sql<number>`COALESCE(MAX(position), -1)` })
|
|
150
168
|
.from(schema.documents)
|
|
@@ -398,6 +398,7 @@ export default defineAction({
|
|
|
398
398
|
|
|
399
399
|
const secondaryId = await insertSecondarySource({
|
|
400
400
|
database,
|
|
401
|
+
expectedPrimarySourceId: existingSource.id,
|
|
401
402
|
sourceType,
|
|
402
403
|
sourceName,
|
|
403
404
|
sourceTable,
|
|
@@ -491,6 +492,7 @@ export default defineAction({
|
|
|
491
492
|
additionalRead.state === "live" ? additionalRead.entries : [];
|
|
492
493
|
const additionalSourceId = await insertSecondarySource({
|
|
493
494
|
database,
|
|
495
|
+
expectedPrimarySourceId: existingSource.id,
|
|
494
496
|
sourceType,
|
|
495
497
|
sourceName,
|
|
496
498
|
sourceTable,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineAction } from "@agent-native/core";
|
|
2
2
|
import { writeAppState } from "@agent-native/core/application-state";
|
|
3
3
|
import { assertAccess } from "@agent-native/core/sharing";
|
|
4
|
-
import { and, eq,
|
|
4
|
+
import { and, eq, sql } from "drizzle-orm";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
|
|
7
7
|
import { getDb, schema } from "../server/db/index.js";
|
|
@@ -16,6 +16,8 @@ import {
|
|
|
16
16
|
normalizePropertyVisibility,
|
|
17
17
|
type DocumentPropertyType,
|
|
18
18
|
} from "../shared/properties.js";
|
|
19
|
+
import { lockContentDatabaseMutation } from "./_content-database-mutation-lock.js";
|
|
20
|
+
import { lockDatabaseMemberships } from "./_database-membership-lock.js";
|
|
19
21
|
import {
|
|
20
22
|
propertyDefinitionsPositionScope,
|
|
21
23
|
withPositionLock,
|
|
@@ -101,7 +103,7 @@ export default defineAction({
|
|
|
101
103
|
const now = new Date().toISOString();
|
|
102
104
|
const name = args.name.trim();
|
|
103
105
|
const type = args.type as DocumentPropertyType;
|
|
104
|
-
|
|
106
|
+
const optionsJson = optionsForNewProperty(type, args.options as any);
|
|
105
107
|
const database = await resolvePropertyDatabaseForDocument(
|
|
106
108
|
document,
|
|
107
109
|
args.databaseId,
|
|
@@ -114,13 +116,12 @@ export default defineAction({
|
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
if (args.id) {
|
|
117
|
-
const propertyId = args.id;
|
|
118
119
|
const [existing] = await db
|
|
119
120
|
.select()
|
|
120
121
|
.from(schema.documentPropertyDefinitions)
|
|
121
122
|
.where(
|
|
122
123
|
and(
|
|
123
|
-
eq(schema.documentPropertyDefinitions.id,
|
|
124
|
+
eq(schema.documentPropertyDefinitions.id, args.id),
|
|
124
125
|
eq(
|
|
125
126
|
schema.documentPropertyDefinitions.ownerEmail,
|
|
126
127
|
document.ownerEmail,
|
|
@@ -128,95 +129,79 @@ export default defineAction({
|
|
|
128
129
|
eq(schema.documentPropertyDefinitions.databaseId, database.id),
|
|
129
130
|
),
|
|
130
131
|
);
|
|
131
|
-
if (!existing) throw new Error(`Property "${
|
|
132
|
-
if (existing.systemRole) {
|
|
133
|
-
throw new Error("System properties cannot be changed.");
|
|
134
|
-
}
|
|
135
|
-
if (
|
|
136
|
-
isComputedPropertyType(existing.type as DocumentPropertyType) &&
|
|
137
|
-
existing.type !== type
|
|
138
|
-
) {
|
|
139
|
-
throw new Error("Computed property types cannot be changed.");
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const existingOptions = parsePropertyOptions(existing.optionsJson);
|
|
143
|
-
const existingIsPrimaryBlocks =
|
|
144
|
-
isBlocksPropertyType(existing.type as DocumentPropertyType) &&
|
|
145
|
-
isPrimaryBlocksField(existingOptions);
|
|
146
|
-
|
|
147
|
-
// The primary "Content" Blocks field backs the document body — it can be
|
|
148
|
-
// renamed/hidden but not retyped (delete it from the database view to
|
|
149
|
-
// remove the body). Block the type switch defensively.
|
|
150
|
-
if (existingIsPrimaryBlocks && existing.type !== type) {
|
|
151
|
-
throw new Error(
|
|
152
|
-
"The primary Content (Blocks) field cannot change type. Delete it from the database view to remove the body.",
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// Preserve the primary flag when re-saving the primary Blocks field (a
|
|
157
|
-
// rename or visibility change must NOT demote it to a normal Blocks field).
|
|
158
|
-
if (existingIsPrimaryBlocks && isBlocksPropertyType(type)) {
|
|
159
|
-
optionsJson = serializePropertyOptions({ blocks: { primary: true } });
|
|
160
|
-
}
|
|
161
|
-
|
|
132
|
+
if (!existing) throw new Error(`Property "${args.id}" not found`);
|
|
162
133
|
await db.transaction(async (tx) => {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
.
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
eq(schema.contentDatabases.ownerEmail, document.ownerEmail),
|
|
171
|
-
isNull(schema.contentDatabases.deletedAt),
|
|
172
|
-
),
|
|
173
|
-
)
|
|
174
|
-
.returning({ id: schema.contentDatabases.id });
|
|
175
|
-
if (!lockedDatabase) throw new Error("Database is no longer active.");
|
|
176
|
-
const [lockedExisting] = await tx
|
|
177
|
-
.update(schema.documentPropertyDefinitions)
|
|
178
|
-
.set({
|
|
179
|
-
updatedAt: sql`${schema.documentPropertyDefinitions.updatedAt}`,
|
|
180
|
-
})
|
|
134
|
+
await lockContentDatabaseMutation(
|
|
135
|
+
tx as unknown as ReturnType<typeof getDb>,
|
|
136
|
+
database.id,
|
|
137
|
+
);
|
|
138
|
+
let [lockedDefinition] = await tx
|
|
139
|
+
.select()
|
|
140
|
+
.from(schema.documentPropertyDefinitions)
|
|
181
141
|
.where(
|
|
182
142
|
and(
|
|
183
|
-
eq(schema.documentPropertyDefinitions.id,
|
|
143
|
+
eq(schema.documentPropertyDefinitions.id, args.id!),
|
|
184
144
|
eq(
|
|
185
145
|
schema.documentPropertyDefinitions.ownerEmail,
|
|
186
146
|
document.ownerEmail,
|
|
187
147
|
),
|
|
188
148
|
eq(schema.documentPropertyDefinitions.databaseId, database.id),
|
|
189
149
|
),
|
|
190
|
-
)
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if (lockedExisting.systemRole)
|
|
150
|
+
);
|
|
151
|
+
if (!lockedDefinition)
|
|
152
|
+
throw new Error(`Property "${args.id}" not found`);
|
|
153
|
+
if (lockedDefinition.systemRole) {
|
|
195
154
|
throw new Error("System properties cannot be changed.");
|
|
155
|
+
}
|
|
196
156
|
if (
|
|
197
|
-
isComputedPropertyType(
|
|
198
|
-
|
|
157
|
+
isComputedPropertyType(
|
|
158
|
+
lockedDefinition.type as DocumentPropertyType,
|
|
159
|
+
) &&
|
|
160
|
+
lockedDefinition.type !== type
|
|
199
161
|
) {
|
|
200
162
|
throw new Error("Computed property types cannot be changed.");
|
|
201
163
|
}
|
|
164
|
+
|
|
165
|
+
const lockedOptions = parsePropertyOptions(
|
|
166
|
+
lockedDefinition.optionsJson,
|
|
167
|
+
);
|
|
202
168
|
const lockedIsPrimaryBlocks =
|
|
203
|
-
isBlocksPropertyType(
|
|
204
|
-
isPrimaryBlocksField(
|
|
205
|
-
|
|
206
|
-
);
|
|
207
|
-
if (lockedIsPrimaryBlocks && lockedExisting.type !== type) {
|
|
169
|
+
isBlocksPropertyType(lockedDefinition.type as DocumentPropertyType) &&
|
|
170
|
+
isPrimaryBlocksField(lockedOptions);
|
|
171
|
+
if (lockedIsPrimaryBlocks && lockedDefinition.type !== type) {
|
|
208
172
|
throw new Error(
|
|
209
173
|
"The primary Content (Blocks) field cannot change type. Delete it from the database view to remove the body.",
|
|
210
174
|
);
|
|
211
175
|
}
|
|
212
|
-
|
|
213
|
-
|
|
176
|
+
if (lockedDefinition.type !== type) {
|
|
177
|
+
const memberships = await tx
|
|
178
|
+
.select({ id: schema.contentDatabaseItems.id })
|
|
179
|
+
.from(schema.contentDatabaseItems)
|
|
180
|
+
.where(eq(schema.contentDatabaseItems.databaseId, database.id));
|
|
181
|
+
await lockDatabaseMemberships(
|
|
182
|
+
tx,
|
|
183
|
+
memberships.map((membership) => membership.id),
|
|
184
|
+
);
|
|
185
|
+
[lockedDefinition] = await tx
|
|
186
|
+
.select()
|
|
187
|
+
.from(schema.documentPropertyDefinitions)
|
|
188
|
+
.where(
|
|
189
|
+
and(
|
|
190
|
+
eq(schema.documentPropertyDefinitions.id, args.id!),
|
|
191
|
+
eq(
|
|
192
|
+
schema.documentPropertyDefinitions.ownerEmail,
|
|
193
|
+
document.ownerEmail,
|
|
194
|
+
),
|
|
195
|
+
eq(schema.documentPropertyDefinitions.databaseId, database.id),
|
|
196
|
+
),
|
|
197
|
+
);
|
|
198
|
+
if (!lockedDefinition) {
|
|
199
|
+
throw new Error(`Property "${args.id}" not found`);
|
|
200
|
+
}
|
|
214
201
|
const [mappedSourceField] = await tx
|
|
215
202
|
.select({ id: schema.contentDatabaseSourceFields.id })
|
|
216
203
|
.from(schema.contentDatabaseSourceFields)
|
|
217
|
-
.where(
|
|
218
|
-
eq(schema.contentDatabaseSourceFields.propertyId, propertyId),
|
|
219
|
-
)
|
|
204
|
+
.where(eq(schema.contentDatabaseSourceFields.propertyId, args.id!))
|
|
220
205
|
.limit(1);
|
|
221
206
|
if (mappedSourceField) {
|
|
222
207
|
throw new Error(
|
|
@@ -227,7 +212,7 @@ export default defineAction({
|
|
|
227
212
|
.delete(schema.documentPropertyValues)
|
|
228
213
|
.where(
|
|
229
214
|
and(
|
|
230
|
-
eq(schema.documentPropertyValues.propertyId,
|
|
215
|
+
eq(schema.documentPropertyValues.propertyId, args.id!),
|
|
231
216
|
eq(
|
|
232
217
|
schema.documentPropertyValues.ownerEmail,
|
|
233
218
|
document.ownerEmail,
|
|
@@ -239,18 +224,19 @@ export default defineAction({
|
|
|
239
224
|
.where(
|
|
240
225
|
and(
|
|
241
226
|
eq(schema.contentDatabaseItemKeyClaims.databaseId, database.id),
|
|
242
|
-
eq(schema.contentDatabaseItemKeyClaims.propertyId,
|
|
227
|
+
eq(schema.contentDatabaseItemKeyClaims.propertyId, args.id!),
|
|
243
228
|
),
|
|
244
229
|
);
|
|
245
|
-
// Switching a Blocks field to another type drops its independent content.
|
|
246
230
|
if (
|
|
247
|
-
isBlocksPropertyType(
|
|
231
|
+
isBlocksPropertyType(
|
|
232
|
+
lockedDefinition.type as DocumentPropertyType,
|
|
233
|
+
) &&
|
|
248
234
|
!isBlocksPropertyType(type)
|
|
249
235
|
) {
|
|
250
236
|
await tx
|
|
251
237
|
.delete(schema.documentBlockFieldContents)
|
|
252
238
|
.where(
|
|
253
|
-
eq(schema.documentBlockFieldContents.propertyId,
|
|
239
|
+
eq(schema.documentBlockFieldContents.propertyId, args.id!),
|
|
254
240
|
);
|
|
255
241
|
}
|
|
256
242
|
}
|
|
@@ -265,7 +251,7 @@ export default defineAction({
|
|
|
265
251
|
type,
|
|
266
252
|
visibility:
|
|
267
253
|
args.visibility === undefined
|
|
268
|
-
? normalizePropertyVisibility(
|
|
254
|
+
? normalizePropertyVisibility(lockedDefinition.visibility)
|
|
269
255
|
: normalizePropertyVisibility(args.visibility),
|
|
270
256
|
optionsJson:
|
|
271
257
|
lockedIsPrimaryBlocks && isBlocksPropertyType(type)
|
|
@@ -273,40 +259,49 @@ export default defineAction({
|
|
|
273
259
|
: optionsJson,
|
|
274
260
|
updatedAt: now,
|
|
275
261
|
})
|
|
276
|
-
.where(eq(schema.documentPropertyDefinitions.id,
|
|
262
|
+
.where(eq(schema.documentPropertyDefinitions.id, args.id!));
|
|
277
263
|
});
|
|
278
264
|
} else {
|
|
279
265
|
await withPositionLock(
|
|
280
266
|
propertyDefinitionsPositionScope(database.id),
|
|
281
267
|
async () => {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
.from(schema.documentPropertyDefinitions)
|
|
287
|
-
.where(
|
|
288
|
-
and(
|
|
289
|
-
eq(
|
|
290
|
-
schema.documentPropertyDefinitions.ownerEmail,
|
|
291
|
-
document.ownerEmail,
|
|
292
|
-
),
|
|
293
|
-
eq(schema.documentPropertyDefinitions.databaseId, database.id),
|
|
294
|
-
),
|
|
268
|
+
await db.transaction(async (tx) => {
|
|
269
|
+
await lockContentDatabaseMutation(
|
|
270
|
+
tx as unknown as ReturnType<typeof getDb>,
|
|
271
|
+
database.id,
|
|
295
272
|
);
|
|
273
|
+
const [maxPos] = await tx
|
|
274
|
+
.select({
|
|
275
|
+
max: sql<number>`COALESCE(MAX(position), -1)`,
|
|
276
|
+
})
|
|
277
|
+
.from(schema.documentPropertyDefinitions)
|
|
278
|
+
.where(
|
|
279
|
+
and(
|
|
280
|
+
eq(
|
|
281
|
+
schema.documentPropertyDefinitions.ownerEmail,
|
|
282
|
+
document.ownerEmail,
|
|
283
|
+
),
|
|
284
|
+
eq(
|
|
285
|
+
schema.documentPropertyDefinitions.databaseId,
|
|
286
|
+
database.id,
|
|
287
|
+
),
|
|
288
|
+
),
|
|
289
|
+
);
|
|
296
290
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
291
|
+
await tx.insert(schema.documentPropertyDefinitions).values({
|
|
292
|
+
id: nanoid(),
|
|
293
|
+
ownerEmail: document.ownerEmail,
|
|
294
|
+
orgId: document.orgId ?? null,
|
|
295
|
+
databaseId: database.id,
|
|
296
|
+
name,
|
|
297
|
+
description: args.description?.trim() ?? "",
|
|
298
|
+
type,
|
|
299
|
+
visibility: normalizePropertyVisibility(args.visibility),
|
|
300
|
+
optionsJson,
|
|
301
|
+
position: (maxPos?.max ?? -1) + 1,
|
|
302
|
+
createdAt: now,
|
|
303
|
+
updatedAt: now,
|
|
304
|
+
});
|
|
310
305
|
});
|
|
311
306
|
},
|
|
312
307
|
);
|