@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
|
@@ -8,35 +8,52 @@ import type {
|
|
|
8
8
|
ContentDatabaseResponse,
|
|
9
9
|
DisconnectContentDatabaseSourceRequest,
|
|
10
10
|
} from "../shared/api.js";
|
|
11
|
+
import { lockContentDatabaseMutation } from "./_content-database-mutation-lock.js";
|
|
11
12
|
import {
|
|
12
13
|
getExistingSource,
|
|
13
14
|
resolveDatabaseForSourceMutation,
|
|
14
15
|
} from "./_database-source-utils.js";
|
|
15
16
|
import { getContentDatabaseResponse } from "./_database-utils.js";
|
|
16
17
|
|
|
17
|
-
async function deleteSourceRecords(sourceId: string) {
|
|
18
|
+
async function deleteSourceRecords(databaseId: string, sourceId: string) {
|
|
18
19
|
const db = getDb();
|
|
19
|
-
await db
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
20
|
+
await db.transaction(async (tx) => {
|
|
21
|
+
await lockContentDatabaseMutation(
|
|
22
|
+
tx as unknown as ReturnType<typeof getDb>,
|
|
23
|
+
databaseId,
|
|
24
|
+
);
|
|
25
|
+
const [source] = await tx
|
|
26
|
+
.select({ id: schema.contentDatabaseSources.id })
|
|
27
|
+
.from(schema.contentDatabaseSources)
|
|
28
|
+
.where(
|
|
29
|
+
and(
|
|
30
|
+
eq(schema.contentDatabaseSources.id, sourceId),
|
|
31
|
+
eq(schema.contentDatabaseSources.databaseId, databaseId),
|
|
32
|
+
),
|
|
33
|
+
);
|
|
34
|
+
if (!source) return;
|
|
35
|
+
await tx
|
|
36
|
+
.delete(schema.contentDatabaseBodyHydrationQueue)
|
|
37
|
+
.where(eq(schema.contentDatabaseBodyHydrationQueue.sourceId, sourceId));
|
|
38
|
+
await tx
|
|
39
|
+
.delete(schema.contentDatabaseSourceExecutions)
|
|
40
|
+
.where(eq(schema.contentDatabaseSourceExecutions.sourceId, sourceId));
|
|
41
|
+
await tx
|
|
42
|
+
.delete(schema.contentDatabaseSourceChangeReviews)
|
|
43
|
+
.where(eq(schema.contentDatabaseSourceChangeReviews.sourceId, sourceId));
|
|
44
|
+
await tx
|
|
45
|
+
.delete(schema.contentDatabaseSourceChangeSets)
|
|
46
|
+
.where(eq(schema.contentDatabaseSourceChangeSets.sourceId, sourceId));
|
|
47
|
+
await tx
|
|
48
|
+
.delete(schema.contentDatabaseSourceRows)
|
|
49
|
+
.where(eq(schema.contentDatabaseSourceRows.sourceId, sourceId));
|
|
50
|
+
await tx
|
|
51
|
+
.delete(schema.contentDatabaseSourceFields)
|
|
52
|
+
.where(eq(schema.contentDatabaseSourceFields.sourceId, sourceId));
|
|
53
|
+
await tx
|
|
54
|
+
.delete(schema.contentDatabaseSources)
|
|
55
|
+
.where(eq(schema.contentDatabaseSources.id, sourceId));
|
|
56
|
+
});
|
|
40
57
|
}
|
|
41
58
|
|
|
42
59
|
export default defineAction({
|
|
@@ -70,13 +87,13 @@ export default defineAction({
|
|
|
70
87
|
eq(schema.contentDatabaseSources.databaseId, database.id),
|
|
71
88
|
),
|
|
72
89
|
);
|
|
73
|
-
if (target) await deleteSourceRecords(target.id);
|
|
90
|
+
if (target) await deleteSourceRecords(database.id, target.id);
|
|
74
91
|
return getContentDatabaseResponse(database.id, { limit: 100, offset: 0 });
|
|
75
92
|
}
|
|
76
93
|
|
|
77
94
|
const source = await getExistingSource(database.id);
|
|
78
95
|
if (source) {
|
|
79
|
-
await deleteSourceRecords(source.id);
|
|
96
|
+
await deleteSourceRecords(database.id, source.id);
|
|
80
97
|
}
|
|
81
98
|
|
|
82
99
|
return getContentDatabaseResponse(database.id, { limit: 100, offset: 0 });
|
|
@@ -6,6 +6,10 @@ import { and, eq, gte, isNull, sql } from "drizzle-orm";
|
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
|
|
8
8
|
import { getDb, schema } from "../server/db/index.js";
|
|
9
|
+
import {
|
|
10
|
+
lockContentDatabaseMutation,
|
|
11
|
+
touchContentDatabase,
|
|
12
|
+
} from "./_content-database-mutation-lock.js";
|
|
9
13
|
import { ensureDocumentFilesMembership } from "./_content-files.js";
|
|
10
14
|
import { assertNotWorkspaceCatalogDocuments } from "./_content-space-catalog-guards.js";
|
|
11
15
|
import { getContentDatabaseResponse } from "./_database-utils.js";
|
|
@@ -69,15 +73,6 @@ export default defineAction({
|
|
|
69
73
|
const now = new Date().toISOString();
|
|
70
74
|
const nextDocumentId = nanoid();
|
|
71
75
|
const nextItemId = nanoid();
|
|
72
|
-
const nextTitle =
|
|
73
|
-
title?.trim() || `Copy of ${row.document.title.trim() || "Untitled"}`;
|
|
74
|
-
const nextPosition = row.item.position + 1;
|
|
75
|
-
|
|
76
|
-
const values = await db
|
|
77
|
-
.select()
|
|
78
|
-
.from(schema.documentPropertyValues)
|
|
79
|
-
.where(eq(schema.documentPropertyValues.documentId, row.document.id));
|
|
80
|
-
|
|
81
76
|
const inheritedShares = await db
|
|
82
77
|
.select({
|
|
83
78
|
principalType: schema.documentShares.principalType,
|
|
@@ -88,18 +83,52 @@ export default defineAction({
|
|
|
88
83
|
.where(eq(schema.documentShares.resourceId, row.database.documentId));
|
|
89
84
|
|
|
90
85
|
await db.transaction(async (tx) => {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
.
|
|
86
|
+
await lockContentDatabaseMutation(
|
|
87
|
+
tx as unknown as ReturnType<typeof getDb>,
|
|
88
|
+
row.database.id,
|
|
89
|
+
);
|
|
90
|
+
await touchContentDatabase(
|
|
91
|
+
tx as unknown as ReturnType<typeof getDb>,
|
|
92
|
+
row.database.id,
|
|
93
|
+
now,
|
|
94
|
+
);
|
|
95
|
+
const [lockedRow] = await tx
|
|
96
|
+
.select({
|
|
97
|
+
item: schema.contentDatabaseItems,
|
|
98
|
+
document: schema.documents,
|
|
99
|
+
})
|
|
100
|
+
.from(schema.contentDatabaseItems)
|
|
101
|
+
.innerJoin(
|
|
102
|
+
schema.documents,
|
|
103
|
+
eq(schema.documents.id, schema.contentDatabaseItems.documentId),
|
|
104
|
+
)
|
|
94
105
|
.where(
|
|
95
106
|
and(
|
|
96
|
-
eq(schema.
|
|
97
|
-
eq(schema.
|
|
98
|
-
|
|
107
|
+
eq(schema.contentDatabaseItems.id, row.item.id),
|
|
108
|
+
eq(schema.contentDatabaseItems.databaseId, row.database.id),
|
|
109
|
+
eq(schema.contentDatabaseItems.documentId, row.document.id),
|
|
110
|
+
isNull(schema.documents.trashedAt),
|
|
99
111
|
),
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
|
|
112
|
+
);
|
|
113
|
+
if (!lockedRow) {
|
|
114
|
+
throw new Error("Database row changed while duplication was waiting.");
|
|
115
|
+
}
|
|
116
|
+
if (lockedRow.document.spaceId !== row.database.spaceId) {
|
|
117
|
+
throw new Error(
|
|
118
|
+
"Cannot duplicate a database row across Content spaces.",
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const nextTitle =
|
|
123
|
+
title?.trim() ||
|
|
124
|
+
`Copy of ${lockedRow.document.title.trim() || "Untitled"}`;
|
|
125
|
+
const nextPosition = lockedRow.item.position + 1;
|
|
126
|
+
const values = await tx
|
|
127
|
+
.select()
|
|
128
|
+
.from(schema.documentPropertyValues)
|
|
129
|
+
.where(
|
|
130
|
+
eq(schema.documentPropertyValues.documentId, lockedRow.document.id),
|
|
131
|
+
);
|
|
103
132
|
const [claimedSource] = await tx
|
|
104
133
|
.select({ id: schema.contentDatabaseItemKeyClaims.id })
|
|
105
134
|
.from(schema.contentDatabaseItemKeyClaims)
|
|
@@ -123,7 +152,10 @@ export default defineAction({
|
|
|
123
152
|
})
|
|
124
153
|
.where(
|
|
125
154
|
and(
|
|
126
|
-
eq(
|
|
155
|
+
eq(
|
|
156
|
+
schema.contentDatabaseItems.databaseId,
|
|
157
|
+
lockedRow.item.databaseId,
|
|
158
|
+
),
|
|
127
159
|
gte(schema.contentDatabaseItems.position, nextPosition),
|
|
128
160
|
),
|
|
129
161
|
);
|
|
@@ -136,7 +168,7 @@ export default defineAction({
|
|
|
136
168
|
})
|
|
137
169
|
.where(
|
|
138
170
|
and(
|
|
139
|
-
eq(schema.documents.ownerEmail,
|
|
171
|
+
eq(schema.documents.ownerEmail, lockedRow.document.ownerEmail),
|
|
140
172
|
eq(schema.documents.parentId, row.database.documentId),
|
|
141
173
|
gte(schema.documents.position, nextPosition),
|
|
142
174
|
),
|
|
@@ -145,25 +177,25 @@ export default defineAction({
|
|
|
145
177
|
await tx.insert(schema.documents).values({
|
|
146
178
|
id: nextDocumentId,
|
|
147
179
|
spaceId: row.database.spaceId,
|
|
148
|
-
ownerEmail:
|
|
149
|
-
orgId:
|
|
180
|
+
ownerEmail: lockedRow.document.ownerEmail,
|
|
181
|
+
orgId: lockedRow.document.orgId,
|
|
150
182
|
parentId: row.database.documentId,
|
|
151
183
|
title: nextTitle,
|
|
152
|
-
content:
|
|
153
|
-
icon:
|
|
184
|
+
content: lockedRow.document.content,
|
|
185
|
+
icon: lockedRow.document.icon,
|
|
154
186
|
position: nextPosition,
|
|
155
187
|
isFavorite: 0,
|
|
156
|
-
hideFromSearch:
|
|
157
|
-
visibility:
|
|
188
|
+
hideFromSearch: lockedRow.document.hideFromSearch,
|
|
189
|
+
visibility: lockedRow.document.visibility,
|
|
158
190
|
createdAt: now,
|
|
159
191
|
updatedAt: now,
|
|
160
192
|
});
|
|
161
193
|
|
|
162
194
|
await tx.insert(schema.contentDatabaseItems).values({
|
|
163
195
|
id: nextItemId,
|
|
164
|
-
ownerEmail:
|
|
165
|
-
orgId:
|
|
166
|
-
databaseId:
|
|
196
|
+
ownerEmail: lockedRow.item.ownerEmail,
|
|
197
|
+
orgId: lockedRow.item.orgId,
|
|
198
|
+
databaseId: lockedRow.item.databaseId,
|
|
167
199
|
documentId: nextDocumentId,
|
|
168
200
|
position: nextPosition,
|
|
169
201
|
createdAt: now,
|
|
@@ -178,7 +210,7 @@ export default defineAction({
|
|
|
178
210
|
principalType: share.principalType,
|
|
179
211
|
principalId: share.principalId,
|
|
180
212
|
role: share.role,
|
|
181
|
-
createdBy: getRequestUserEmail() ??
|
|
213
|
+
createdBy: getRequestUserEmail() ?? lockedRow.document.ownerEmail,
|
|
182
214
|
createdAt: now,
|
|
183
215
|
})),
|
|
184
216
|
);
|
|
@@ -188,7 +220,7 @@ export default defineAction({
|
|
|
188
220
|
await tx.insert(schema.documentPropertyValues).values(
|
|
189
221
|
values.map((value) => ({
|
|
190
222
|
id: nanoid(),
|
|
191
|
-
ownerEmail:
|
|
223
|
+
ownerEmail: lockedRow.document.ownerEmail,
|
|
192
224
|
documentId: nextDocumentId,
|
|
193
225
|
propertyId: value.propertyId,
|
|
194
226
|
valueJson: value.valueJson,
|
|
@@ -2,9 +2,13 @@ import { defineAction } from "@agent-native/core";
|
|
|
2
2
|
import { writeAppState } from "@agent-native/core/application-state";
|
|
3
3
|
import { getRequestUserEmail } from "@agent-native/core/server/request-context";
|
|
4
4
|
import { assertAccess } from "@agent-native/core/sharing";
|
|
5
|
-
import { and, eq, gte, inArray, isNull, sql } from "drizzle-orm";
|
|
5
|
+
import { and, asc, eq, gte, inArray, isNull, sql } from "drizzle-orm";
|
|
6
6
|
|
|
7
7
|
import { getDb, schema } from "../server/db/index.js";
|
|
8
|
+
import {
|
|
9
|
+
lockContentDatabaseMutation,
|
|
10
|
+
touchContentDatabase,
|
|
11
|
+
} from "./_content-database-mutation-lock.js";
|
|
8
12
|
import { ensureDocumentsFilesMembership } from "./_content-files.js";
|
|
9
13
|
import { assertNotWorkspaceCatalogDocuments } from "./_content-space-catalog-guards.js";
|
|
10
14
|
import {
|
|
@@ -41,32 +45,8 @@ export default defineAction({
|
|
|
41
45
|
);
|
|
42
46
|
const sourceItemIds = rows.map((row) => row.item.id);
|
|
43
47
|
const now = new Date().toISOString();
|
|
44
|
-
const insertionPosition =
|
|
45
|
-
Math.max(...rows.map((row) => row.item.position)) + 1;
|
|
46
48
|
const currentUserEmail = getRequestUserEmail() ?? database.ownerEmail;
|
|
47
49
|
|
|
48
|
-
const values =
|
|
49
|
-
sourceDocumentIds.length > 0
|
|
50
|
-
? await db
|
|
51
|
-
.select()
|
|
52
|
-
.from(schema.documentPropertyValues)
|
|
53
|
-
.where(
|
|
54
|
-
inArray(
|
|
55
|
-
schema.documentPropertyValues.documentId,
|
|
56
|
-
sourceDocumentIds,
|
|
57
|
-
),
|
|
58
|
-
)
|
|
59
|
-
: [];
|
|
60
|
-
const valuesByDocumentId = new Map<
|
|
61
|
-
string,
|
|
62
|
-
Array<typeof schema.documentPropertyValues.$inferSelect>
|
|
63
|
-
>();
|
|
64
|
-
for (const value of values) {
|
|
65
|
-
const list = valuesByDocumentId.get(value.documentId) ?? [];
|
|
66
|
-
list.push(value);
|
|
67
|
-
valuesByDocumentId.set(value.documentId, list);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
50
|
const inheritedShares = await db
|
|
71
51
|
.select({
|
|
72
52
|
principalType: schema.documentShares.principalType,
|
|
@@ -76,28 +56,63 @@ export default defineAction({
|
|
|
76
56
|
.from(schema.documentShares)
|
|
77
57
|
.where(eq(schema.documentShares.resourceId, database.documentId));
|
|
78
58
|
|
|
79
|
-
const duplicates = rows.map((row
|
|
59
|
+
const duplicates = rows.map((row) => ({
|
|
80
60
|
sourceItemId: row.item.id,
|
|
81
61
|
sourceDocumentId: row.document.id,
|
|
82
62
|
duplicatedItemId: nanoid(),
|
|
83
63
|
duplicatedDocumentId: nanoid(),
|
|
84
|
-
position: insertionPosition + index,
|
|
85
|
-
row,
|
|
86
64
|
}));
|
|
87
65
|
|
|
88
66
|
await db.transaction(async (tx) => {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
.
|
|
67
|
+
await lockContentDatabaseMutation(
|
|
68
|
+
tx as unknown as ReturnType<typeof getDb>,
|
|
69
|
+
database.id,
|
|
70
|
+
);
|
|
71
|
+
await touchContentDatabase(
|
|
72
|
+
tx as unknown as ReturnType<typeof getDb>,
|
|
73
|
+
database.id,
|
|
74
|
+
now,
|
|
75
|
+
);
|
|
76
|
+
const lockedRows = await tx
|
|
77
|
+
.select({
|
|
78
|
+
item: schema.contentDatabaseItems,
|
|
79
|
+
document: schema.documents,
|
|
80
|
+
})
|
|
81
|
+
.from(schema.contentDatabaseItems)
|
|
82
|
+
.innerJoin(
|
|
83
|
+
schema.documents,
|
|
84
|
+
eq(schema.documents.id, schema.contentDatabaseItems.documentId),
|
|
85
|
+
)
|
|
92
86
|
.where(
|
|
93
87
|
and(
|
|
94
|
-
eq(schema.
|
|
95
|
-
|
|
96
|
-
isNull(schema.
|
|
88
|
+
eq(schema.contentDatabaseItems.databaseId, database.id),
|
|
89
|
+
inArray(schema.contentDatabaseItems.id, sourceItemIds),
|
|
90
|
+
isNull(schema.documents.trashedAt),
|
|
97
91
|
),
|
|
98
92
|
)
|
|
99
|
-
.
|
|
100
|
-
|
|
93
|
+
.orderBy(asc(schema.contentDatabaseItems.position));
|
|
94
|
+
const lockedRowsByItemId = new Map(
|
|
95
|
+
lockedRows.map((lockedRow) => [lockedRow.item.id, lockedRow]),
|
|
96
|
+
);
|
|
97
|
+
if (
|
|
98
|
+
lockedRows.length !== rows.length ||
|
|
99
|
+
rows.some(
|
|
100
|
+
(row) =>
|
|
101
|
+
lockedRowsByItemId.get(row.item.id)?.document.id !==
|
|
102
|
+
row.document.id,
|
|
103
|
+
)
|
|
104
|
+
) {
|
|
105
|
+
throw new Error("Database rows changed while duplication was waiting.");
|
|
106
|
+
}
|
|
107
|
+
if (
|
|
108
|
+
lockedRows.some(
|
|
109
|
+
(lockedRow) => lockedRow.document.spaceId !== database.spaceId,
|
|
110
|
+
)
|
|
111
|
+
) {
|
|
112
|
+
throw new Error(
|
|
113
|
+
"Cannot duplicate database rows across Content spaces.",
|
|
114
|
+
);
|
|
115
|
+
}
|
|
101
116
|
const [claimedSource] = await tx
|
|
102
117
|
.select({ id: schema.contentDatabaseItemKeyClaims.id })
|
|
103
118
|
.from(schema.contentDatabaseItemKeyClaims)
|
|
@@ -116,10 +131,38 @@ export default defineAction({
|
|
|
116
131
|
"Rows with active stable-key claims cannot be duplicated.",
|
|
117
132
|
);
|
|
118
133
|
}
|
|
134
|
+
const insertionPosition =
|
|
135
|
+
Math.max(...lockedRows.map((lockedRow) => lockedRow.item.position)) + 1;
|
|
136
|
+
const lockedDuplicates = duplicates.map((duplicate, index) => ({
|
|
137
|
+
...duplicate,
|
|
138
|
+
position: insertionPosition + index,
|
|
139
|
+
row: lockedRowsByItemId.get(duplicate.sourceItemId)!,
|
|
140
|
+
}));
|
|
141
|
+
const values =
|
|
142
|
+
sourceDocumentIds.length > 0
|
|
143
|
+
? await tx
|
|
144
|
+
.select()
|
|
145
|
+
.from(schema.documentPropertyValues)
|
|
146
|
+
.where(
|
|
147
|
+
inArray(
|
|
148
|
+
schema.documentPropertyValues.documentId,
|
|
149
|
+
sourceDocumentIds,
|
|
150
|
+
),
|
|
151
|
+
)
|
|
152
|
+
: [];
|
|
153
|
+
const valuesByDocumentId = new Map<
|
|
154
|
+
string,
|
|
155
|
+
Array<typeof schema.documentPropertyValues.$inferSelect>
|
|
156
|
+
>();
|
|
157
|
+
for (const value of values) {
|
|
158
|
+
const list = valuesByDocumentId.get(value.documentId) ?? [];
|
|
159
|
+
list.push(value);
|
|
160
|
+
valuesByDocumentId.set(value.documentId, list);
|
|
161
|
+
}
|
|
119
162
|
await tx
|
|
120
163
|
.update(schema.contentDatabaseItems)
|
|
121
164
|
.set({
|
|
122
|
-
position: sql`${schema.contentDatabaseItems.position} + ${
|
|
165
|
+
position: sql`${schema.contentDatabaseItems.position} + ${lockedDuplicates.length}`,
|
|
123
166
|
updatedAt: now,
|
|
124
167
|
})
|
|
125
168
|
.where(
|
|
@@ -132,7 +175,7 @@ export default defineAction({
|
|
|
132
175
|
await tx
|
|
133
176
|
.update(schema.documents)
|
|
134
177
|
.set({
|
|
135
|
-
position: sql`${schema.documents.position} + ${
|
|
178
|
+
position: sql`${schema.documents.position} + ${lockedDuplicates.length}`,
|
|
136
179
|
updatedAt: now,
|
|
137
180
|
})
|
|
138
181
|
.where(
|
|
@@ -144,7 +187,7 @@ export default defineAction({
|
|
|
144
187
|
);
|
|
145
188
|
|
|
146
189
|
await tx.insert(schema.documents).values(
|
|
147
|
-
|
|
190
|
+
lockedDuplicates.map((duplicate) => ({
|
|
148
191
|
id: duplicate.duplicatedDocumentId,
|
|
149
192
|
spaceId: database.spaceId,
|
|
150
193
|
ownerEmail: duplicate.row.document.ownerEmail,
|
|
@@ -163,7 +206,7 @@ export default defineAction({
|
|
|
163
206
|
);
|
|
164
207
|
|
|
165
208
|
await tx.insert(schema.contentDatabaseItems).values(
|
|
166
|
-
|
|
209
|
+
lockedDuplicates.map((duplicate) => ({
|
|
167
210
|
id: duplicate.duplicatedItemId,
|
|
168
211
|
ownerEmail: duplicate.row.item.ownerEmail,
|
|
169
212
|
orgId: duplicate.row.item.orgId,
|
|
@@ -175,7 +218,7 @@ export default defineAction({
|
|
|
175
218
|
})),
|
|
176
219
|
);
|
|
177
220
|
|
|
178
|
-
const duplicatedValues =
|
|
221
|
+
const duplicatedValues = lockedDuplicates.flatMap((duplicate) =>
|
|
179
222
|
(valuesByDocumentId.get(duplicate.sourceDocumentId) ?? []).map(
|
|
180
223
|
(value) => ({
|
|
181
224
|
id: nanoid(),
|
|
@@ -194,7 +237,7 @@ export default defineAction({
|
|
|
194
237
|
|
|
195
238
|
if (inheritedShares.length > 0) {
|
|
196
239
|
await tx.insert(schema.documentShares).values(
|
|
197
|
-
|
|
240
|
+
lockedDuplicates.flatMap((duplicate) =>
|
|
198
241
|
inheritedShares.map((share) => ({
|
|
199
242
|
id: nanoid(),
|
|
200
243
|
resourceId: duplicate.duplicatedDocumentId,
|
|
@@ -209,7 +252,7 @@ export default defineAction({
|
|
|
209
252
|
}
|
|
210
253
|
await ensureDocumentsFilesMembership(
|
|
211
254
|
tx,
|
|
212
|
-
|
|
255
|
+
lockedDuplicates.map((duplicate) => duplicate.duplicatedDocumentId),
|
|
213
256
|
now,
|
|
214
257
|
);
|
|
215
258
|
});
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
serializePropertyOptions,
|
|
11
11
|
type DocumentPropertyType,
|
|
12
12
|
} from "../shared/properties.js";
|
|
13
|
+
import { lockContentDatabaseMutation } from "./_content-database-mutation-lock.js";
|
|
13
14
|
import { lockDatabaseMemberships } from "./_database-membership-lock.js";
|
|
14
15
|
import {
|
|
15
16
|
propertyDefinitionsPositionScope,
|
|
@@ -65,19 +66,14 @@ export default defineAction({
|
|
|
65
66
|
|
|
66
67
|
const now = new Date().toISOString();
|
|
67
68
|
const newPropertyId = nanoid();
|
|
68
|
-
const isBlocks = isBlocksPropertyType(
|
|
69
|
-
definition.type as DocumentPropertyType,
|
|
70
|
-
);
|
|
71
|
-
// A duplicated Blocks field is a brand-new, independent, EMPTY field — never
|
|
72
|
-
// primary (only one field backs the body) and with no copied content.
|
|
73
|
-
const optionsJson = isBlocks
|
|
74
|
-
? serializePropertyOptions({ blocks: { primary: false } })
|
|
75
|
-
: definition.optionsJson;
|
|
76
|
-
|
|
77
69
|
await withPositionLock(
|
|
78
70
|
propertyDefinitionsPositionScope(database.id),
|
|
79
71
|
async () => {
|
|
80
72
|
await db.transaction(async (tx) => {
|
|
73
|
+
await lockContentDatabaseMutation(
|
|
74
|
+
tx as unknown as ReturnType<typeof getDb>,
|
|
75
|
+
database.id,
|
|
76
|
+
);
|
|
81
77
|
const memberships = await tx
|
|
82
78
|
.select({ id: schema.contentDatabaseItems.id })
|
|
83
79
|
.from(schema.contentDatabaseItems)
|
|
@@ -86,6 +82,33 @@ export default defineAction({
|
|
|
86
82
|
tx,
|
|
87
83
|
memberships.map((membership) => membership.id),
|
|
88
84
|
);
|
|
85
|
+
const [lockedDefinition] = await tx
|
|
86
|
+
.select()
|
|
87
|
+
.from(schema.documentPropertyDefinitions)
|
|
88
|
+
.where(
|
|
89
|
+
and(
|
|
90
|
+
eq(schema.documentPropertyDefinitions.id, propertyId),
|
|
91
|
+
eq(
|
|
92
|
+
schema.documentPropertyDefinitions.ownerEmail,
|
|
93
|
+
document.ownerEmail,
|
|
94
|
+
),
|
|
95
|
+
eq(schema.documentPropertyDefinitions.databaseId, database.id),
|
|
96
|
+
),
|
|
97
|
+
);
|
|
98
|
+
if (!lockedDefinition) {
|
|
99
|
+
throw new Error(`Property "${propertyId}" not found`);
|
|
100
|
+
}
|
|
101
|
+
if (lockedDefinition.systemRole) {
|
|
102
|
+
throw new Error("System properties cannot be duplicated.");
|
|
103
|
+
}
|
|
104
|
+
const isBlocks = isBlocksPropertyType(
|
|
105
|
+
lockedDefinition.type as DocumentPropertyType,
|
|
106
|
+
);
|
|
107
|
+
// A duplicated Blocks field is a brand-new, independent, EMPTY field — never
|
|
108
|
+
// primary (only one field backs the body) and with no copied content.
|
|
109
|
+
const optionsJson = isBlocks
|
|
110
|
+
? serializePropertyOptions({ blocks: { primary: false } })
|
|
111
|
+
: lockedDefinition.optionsJson;
|
|
89
112
|
|
|
90
113
|
const [maxPos] = await tx
|
|
91
114
|
.select({
|
|
@@ -104,12 +127,12 @@ export default defineAction({
|
|
|
104
127
|
|
|
105
128
|
await tx.insert(schema.documentPropertyDefinitions).values({
|
|
106
129
|
id: newPropertyId,
|
|
107
|
-
ownerEmail:
|
|
108
|
-
orgId:
|
|
130
|
+
ownerEmail: lockedDefinition.ownerEmail,
|
|
131
|
+
orgId: lockedDefinition.orgId,
|
|
109
132
|
databaseId: database.id,
|
|
110
|
-
name: `${
|
|
111
|
-
type:
|
|
112
|
-
visibility:
|
|
133
|
+
name: `${lockedDefinition.name} copy`,
|
|
134
|
+
type: lockedDefinition.type,
|
|
135
|
+
visibility: lockedDefinition.visibility,
|
|
113
136
|
optionsJson,
|
|
114
137
|
position: (maxPos?.max ?? -1) + 1,
|
|
115
138
|
createdAt: now,
|