@agent-native/core 0.134.1 → 0.135.1
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/corpus/README.md +3 -3
- package/corpus/core/CHANGELOG.md +113 -0
- package/corpus/core/package.json +3 -2
- package/corpus/core/src/automations/service.ts +41 -4
- package/corpus/core/src/cli/mcp-config-writers.ts +27 -21
- package/corpus/core/src/client/agent-page/AgentJobsTab.tsx +187 -85
- package/corpus/core/src/client/agent-page/AutomationDetailsDialog.tsx +208 -0
- package/corpus/core/src/client/agent-page/AutomationScheduleDialog.tsx +180 -0
- package/corpus/core/src/client/agent-page/TimezoneSelect.tsx +241 -0
- package/corpus/core/src/client/agent-page/use-jobs.ts +50 -10
- package/corpus/core/src/client/org/OrgSwitcher.tsx +26 -0
- package/corpus/core/src/client/settings/AccountSettingsCard.tsx +35 -31
- package/corpus/core/src/client/settings/SchedulingTimezoneField.tsx +71 -0
- package/corpus/core/src/client/settings/SettingsRow.tsx +113 -0
- package/corpus/core/src/client/settings/agent-settings-search.ts +2 -1
- package/corpus/core/src/client/settings/index.ts +6 -0
- package/corpus/core/src/integrations/identity.ts +2 -12
- package/corpus/core/src/jobs/actions/list-automation-runs.ts +33 -0
- package/corpus/core/src/jobs/actions/list-recurring-jobs.ts +27 -6
- package/corpus/core/src/jobs/actions/manage-recurring-job.ts +41 -9
- package/corpus/core/src/jobs/background-automation-runner.ts +88 -0
- package/corpus/core/src/jobs/cron.ts +52 -6
- package/corpus/core/src/jobs/frontmatter.ts +20 -0
- package/corpus/core/src/jobs/run-history.ts +242 -0
- package/corpus/core/src/jobs/scheduler.ts +73 -18
- package/corpus/core/src/jobs/tools.ts +54 -6
- package/corpus/core/src/localization/actions/get-localization-preference.ts +2 -2
- package/corpus/core/src/localization/actions/set-localization-preference.ts +49 -11
- package/corpus/core/src/localization/default-messages.ts +27 -0
- package/corpus/core/src/localization/shared.ts +39 -6
- package/corpus/core/src/localization/user-timezone.ts +36 -0
- package/corpus/core/src/org/app-roles-handlers.ts +1 -9
- package/corpus/core/src/org/index.ts +2 -0
- package/corpus/core/src/org/membership.ts +18 -0
- package/corpus/core/src/review/actions/create-review-comment.ts +4 -1
- package/corpus/core/src/review/actions/reply-review-comment.ts +4 -1
- package/corpus/core/src/review/index.ts +5 -0
- package/corpus/core/src/review/notifications.ts +163 -0
- package/corpus/core/src/review/types.ts +7 -0
- package/corpus/core/src/server/action-discovery.ts +4 -0
- package/corpus/core/src/server/activity-notifications.ts +174 -0
- package/corpus/core/src/server/app-name.ts +31 -0
- package/corpus/core/src/server/better-auth-instance.ts +4 -4
- package/corpus/core/src/server/email-templates.ts +70 -14
- package/corpus/core/src/server/email.ts +66 -3
- package/corpus/core/src/server/index.ts +10 -0
- package/corpus/core/src/sharing/access.ts +44 -2
- package/corpus/core/src/sharing/index.ts +5 -0
- package/corpus/core/src/sharing/recipients.ts +67 -0
- package/corpus/core/src/triggers/actions/list-automations.ts +27 -8
- package/corpus/core/src/triggers/actions/manage-automation.ts +17 -6
- package/corpus/core/src/triggers/actions.ts +16 -4
- package/corpus/core/src/triggers/dispatcher.ts +44 -30
- package/corpus/core/src/triggers/routes.ts +19 -6
- package/corpus/core/src/vitest-config.ts +68 -0
- package/corpus/core/vitest.config.ts +5 -0
- package/corpus/templates/analytics/app/pages/Settings.tsx +37 -53
- package/corpus/templates/analytics/changelog/2026-08-01-new-error-alerts-now-reach-you-by-email-and-a-scheduled-dash.md +6 -0
- package/corpus/templates/analytics/server/jobs/dashboard-report.ts +43 -0
- package/corpus/templates/analytics/server/lib/error-capture.ts +5 -1
- package/corpus/templates/analytics/vitest.config.ts +16 -12
- package/corpus/templates/assets/actions/refresh-generation-run.ts +3 -0
- package/corpus/templates/assets/app/components/ui/switch.tsx +1 -0
- package/corpus/templates/assets/app/hooks/use-assets-prefs.ts +55 -0
- package/corpus/templates/assets/app/i18n-data.ts +30 -0
- package/corpus/templates/assets/app/routes/settings.tsx +58 -55
- package/corpus/templates/assets/changelog/2026-08-01-get-an-email-when-a-generation-you-started-finishes-or-fails.md +6 -0
- package/corpus/templates/assets/server/lib/generation-run-notifications.ts +89 -0
- package/corpus/templates/assets/server/lib/video-runs.ts +8 -1
- package/corpus/templates/assets/server/routes/_agent-native/assets/user-prefs.get.ts +17 -0
- package/corpus/templates/assets/server/routes/_agent-native/assets/user-prefs.put.ts +36 -0
- package/corpus/templates/assets/shared/assets-user-prefs.ts +10 -0
- package/corpus/templates/assets/vitest.config.ts +16 -12
- package/corpus/templates/brain/app/routes/settings.tsx +15 -15
- package/corpus/templates/brain/vitest.config.ts +16 -12
- package/corpus/templates/calendar/app/pages/Settings.tsx +32 -40
- package/corpus/templates/calendar/changelog/2026-08-01-language-and-appearance-now-sit-together-in-one-preferences-.md +6 -0
- package/corpus/templates/calendar/vitest.config.ts +16 -12
- package/corpus/templates/chat/app/routes/settings.tsx +14 -22
- package/corpus/templates/chat/vitest.config.ts +9 -0
- package/corpus/templates/clips/.agents/skills/video-editing/SKILL.md +31 -0
- package/corpus/templates/clips/AGENTS.md +1 -0
- package/corpus/templates/clips/actions/add-comment.ts +12 -1
- package/corpus/templates/clips/actions/create-meeting.ts +2 -2
- package/corpus/templates/clips/actions/create-recording.ts +2 -2
- package/corpus/templates/clips/actions/finalize-recording.ts +42 -6
- package/corpus/templates/clips/actions/generate-filmstrip.ts +154 -0
- package/corpus/templates/clips/actions/get-recording-player-data.ts +6 -0
- package/corpus/templates/clips/actions/import-loom-recording.ts +2 -2
- package/corpus/templates/clips/actions/lib/ensure-recording-filmstrip.ts +258 -0
- package/corpus/templates/clips/actions/lib/ensure-seekable-video.ts +11 -3
- package/corpus/templates/clips/actions/react-to-comment.ts +13 -0
- package/corpus/templates/clips/actions/react-to-recording.ts +10 -1
- package/corpus/templates/clips/actions/reply-to-comment.ts +12 -1
- package/corpus/templates/clips/actions/stitch-recordings.ts +2 -2
- package/corpus/templates/clips/app/components/editor/editor-layout.tsx +152 -23
- package/corpus/templates/clips/app/components/editor/waveform.tsx +237 -75
- package/corpus/templates/clips/app/components/recorder/recorder-engine.ts +23 -1
- package/corpus/templates/clips/app/components/settings/ai-setup-section.tsx +441 -0
- package/corpus/templates/clips/app/components/settings/slack-section.tsx +329 -0
- package/corpus/templates/clips/app/components/settings/types.ts +14 -0
- package/corpus/templates/clips/app/components/settings/video-storage-section.tsx +443 -0
- package/corpus/templates/clips/app/hooks/use-secret-status.ts +69 -0
- package/corpus/templates/clips/app/i18n/en-US.ts +9 -1
- package/corpus/templates/clips/app/lib/video-filmstrip.ts +262 -0
- package/corpus/templates/clips/app/routes/_app.settings._index.tsx +165 -1351
- package/corpus/templates/clips/changelog/2026-07-27-saved-clips-now-resume-from-the-last-uploaded-byte-after-an-.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-31-editor-timeline-now-shows-video-frames-behind-the-waveform-g.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-31-email-notifications-now-go-out-when-someone-comments-on-or-r.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-31-you-can-now-set-a-default-visibility-for-new-recordings-in-s.md +6 -0
- package/corpus/templates/clips/changelog/2026-08-01-email-notifications-for-comments-and-reactions-now-actually-.md +6 -0
- package/corpus/templates/clips/changelog/2026-08-03-the-desktop-app-now-opens-directly-beneath-its-tray-icon-on-.md +6 -0
- package/corpus/templates/clips/chrome-extension/package.json +1 -0
- package/corpus/templates/clips/chrome-extension/vitest.config.ts +9 -0
- package/corpus/templates/clips/desktop/package.json +1 -0
- package/corpus/templates/clips/desktop/src/app.tsx +17 -1
- package/corpus/templates/clips/desktop/src/lib/recorder.ts +331 -36
- package/corpus/templates/clips/desktop/src/lib/upload-recovery.ts +129 -0
- package/corpus/templates/clips/desktop/src-tauri/src/native_screen.rs +815 -15
- package/corpus/templates/clips/desktop/src-tauri/src/tray.rs +61 -11
- package/corpus/templates/clips/desktop/vitest.config.ts +9 -0
- package/corpus/templates/clips/server/db/schema.ts +17 -0
- package/corpus/templates/clips/server/jobs/media-verification.ts +4 -0
- package/corpus/templates/clips/server/lib/activity-notifications.ts +185 -0
- package/corpus/templates/clips/server/lib/recording-media-cleanup.ts +2 -0
- package/corpus/templates/clips/server/lib/recording-upload-state.ts +46 -9
- package/corpus/templates/clips/server/lib/recordings.ts +24 -0
- package/corpus/templates/clips/server/lib/resumable-session.ts +10 -4
- package/corpus/templates/clips/server/lib/transactional-email-templates.ts +109 -0
- package/corpus/templates/clips/server/lib/upload-interruption.ts +8 -0
- package/corpus/templates/clips/server/lib/upload-lease.ts +50 -4
- package/corpus/templates/clips/server/lib/video-filmstrip-sprite.ts +207 -0
- package/corpus/templates/clips/server/lib/video-remux.ts +13 -4
- package/corpus/templates/clips/server/plugins/db.ts +16 -0
- package/corpus/templates/clips/server/routes/api/_agent-native-background/post-finalize-worker.post.ts +4 -0
- package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/abort.post.ts +123 -36
- package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/chunk.post.ts +159 -29
- package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/interrupt.post.ts +197 -0
- package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/reset-chunks.post.ts +193 -39
- package/corpus/templates/clips/server/routes/api/uploads/[recordingId]/resume.get.ts +191 -12
- package/corpus/templates/clips/shared/clips-ai-prefs.ts +6 -0
- package/corpus/templates/clips/shared/feature-flags.ts +12 -0
- package/corpus/templates/clips/shared/recording-core.ts +4 -0
- package/corpus/templates/clips/vitest.config.ts +23 -19
- package/corpus/templates/content/actions/_database-utils.ts +113 -4
- package/corpus/templates/content/actions/add-comment.ts +15 -1
- package/corpus/templates/content/actions/get-document.ts +84 -3
- package/corpus/templates/content/actions/list-documents.ts +1 -0
- package/corpus/templates/content/app/components/editor/BuilderBodySyncingNotice.tsx +9 -2
- package/corpus/templates/content/app/components/editor/DocumentEditor.tsx +34 -15
- package/corpus/templates/content/app/components/editor/DocumentToolbar.tsx +55 -13
- package/corpus/templates/content/app/components/editor/body-hydration.ts +12 -6
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +2 -3
- package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +5 -12
- package/corpus/templates/content/app/components/ui/switch.tsx +1 -0
- package/corpus/templates/content/app/hooks/use-content-database.ts +16 -27
- package/corpus/templates/content/app/hooks/use-content-prefs.ts +55 -0
- package/corpus/templates/content/app/hooks/use-create-page.ts +3 -6
- package/corpus/templates/content/app/hooks/use-document-properties.ts +9 -16
- package/corpus/templates/content/app/hooks/use-document-versions.ts +3 -3
- package/corpus/templates/content/app/hooks/use-documents.ts +85 -29
- package/corpus/templates/content/app/hooks/use-notion.ts +15 -13
- package/corpus/templates/content/app/i18n-data.ts +72 -1
- package/corpus/templates/content/app/lib/document-query.ts +36 -0
- package/corpus/templates/content/app/routes/_app.settings.tsx +47 -18
- package/corpus/templates/content/changelog/2026-07-30-breadcrumb-menus-now-hide-internal-system-pages.md +6 -0
- package/corpus/templates/content/changelog/2026-08-01-get-an-email-when-someone-comments-on-replies-in-or-mentions.md +6 -0
- package/corpus/templates/content/changelog/2026-08-02-pages-opened-from-a-database-now-keep-that-database-s-fields.md +6 -0
- package/corpus/templates/content/server/lib/comment-notifications.ts +146 -0
- package/corpus/templates/content/server/lib/document-context.ts +11 -6
- package/corpus/templates/content/server/routes/_agent-native/content/user-prefs.get.ts +17 -0
- package/corpus/templates/content/server/routes/_agent-native/content/user-prefs.put.ts +36 -0
- package/corpus/templates/content/shared/api.ts +8 -0
- package/corpus/templates/content/shared/content-user-prefs.ts +11 -0
- package/corpus/templates/content/vitest.config.ts +20 -16
- package/corpus/templates/crm/app/routes/settings.tsx +14 -22
- package/corpus/templates/crm/vitest.config.ts +8 -4
- package/corpus/templates/design/app/routes/settings.tsx +14 -22
- package/corpus/templates/design/changelog/2026-08-01-review-comments-replies-and-mentions-now-send-an-email-to-th.md +6 -0
- package/corpus/templates/design/vitest.config.ts +18 -12
- package/corpus/templates/dispatch/app/routes/settings.tsx +26 -40
- package/corpus/templates/dispatch/vitest.config.ts +11 -7
- package/corpus/templates/factory/app/routes/settings.tsx +14 -22
- package/corpus/templates/factory/vitest.config.ts +9 -0
- package/corpus/templates/forms/app/routes/_app.settings.tsx +14 -22
- package/corpus/templates/forms/vitest.config.ts +27 -23
- package/corpus/templates/macros/app/routes/settings.tsx +14 -22
- package/corpus/templates/macros/vitest.config.ts +16 -12
- package/corpus/templates/mail/app/pages/SettingsPage.tsx +14 -16
- package/corpus/templates/mail/vitest.config.ts +16 -12
- package/corpus/templates/plan/app/routes/settings.tsx +30 -44
- package/corpus/templates/plan/vitest.config.ts +24 -20
- package/corpus/templates/slides/actions/add-slide-comment.ts +12 -1
- package/corpus/templates/slides/app/components/ui/switch.tsx +1 -0
- package/corpus/templates/slides/app/hooks/use-slides-prefs.ts +55 -0
- package/corpus/templates/slides/app/i18n/en-US.ts +4 -0
- package/corpus/templates/slides/app/routes/settings.tsx +45 -22
- package/corpus/templates/slides/changelog/2026-08-01-get-an-email-when-someone-comments-on-or-replies-in-your-dec.md +6 -0
- package/corpus/templates/slides/server/lib/comment-notifications.ts +182 -0
- package/corpus/templates/slides/server/routes/_agent-native/slides/user-prefs.get.ts +16 -0
- package/corpus/templates/slides/server/routes/_agent-native/slides/user-prefs.put.ts +36 -0
- package/corpus/templates/slides/shared/slides-user-prefs.ts +11 -0
- package/corpus/templates/slides/vitest.config.ts +17 -13
- package/corpus/templates/tasks/app/components/layout/Sidebar.tsx +2 -0
- package/corpus/templates/tasks/app/routes/settings.tsx +14 -22
- package/corpus/templates/tasks/vitest.config.ts +17 -13
- package/corpus/toolkit/CHANGELOG.md +9 -0
- package/corpus/toolkit/package.json +1 -1
- package/corpus/toolkit/vitest.config.ts +3 -0
- package/dist/automations/service.d.ts +2 -0
- package/dist/automations/service.d.ts.map +1 -1
- package/dist/automations/service.js +29 -4
- package/dist/automations/service.js.map +1 -1
- package/dist/cli/mcp-config-writers.d.ts.map +1 -1
- package/dist/cli/mcp-config-writers.js +24 -23
- package/dist/cli/mcp-config-writers.js.map +1 -1
- package/dist/client/agent-page/AgentJobsTab.d.ts.map +1 -1
- package/dist/client/agent-page/AgentJobsTab.js +86 -29
- package/dist/client/agent-page/AgentJobsTab.js.map +1 -1
- package/dist/client/agent-page/AutomationDetailsDialog.d.ts +21 -0
- package/dist/client/agent-page/AutomationDetailsDialog.d.ts.map +1 -0
- package/dist/client/agent-page/AutomationDetailsDialog.js +33 -0
- package/dist/client/agent-page/AutomationDetailsDialog.js.map +1 -0
- package/dist/client/agent-page/AutomationScheduleDialog.d.ts +15 -0
- package/dist/client/agent-page/AutomationScheduleDialog.d.ts.map +1 -0
- package/dist/client/agent-page/AutomationScheduleDialog.js +46 -0
- package/dist/client/agent-page/AutomationScheduleDialog.js.map +1 -0
- package/dist/client/agent-page/TimezoneSelect.d.ts +17 -0
- package/dist/client/agent-page/TimezoneSelect.d.ts.map +1 -0
- package/dist/client/agent-page/TimezoneSelect.js +107 -0
- package/dist/client/agent-page/TimezoneSelect.js.map +1 -0
- package/dist/client/agent-page/use-jobs.d.ts +20 -7
- package/dist/client/agent-page/use-jobs.d.ts.map +1 -1
- package/dist/client/agent-page/use-jobs.js +24 -4
- package/dist/client/agent-page/use-jobs.js.map +1 -1
- package/dist/client/org/OrgSwitcher.d.ts +8 -1
- package/dist/client/org/OrgSwitcher.d.ts.map +1 -1
- package/dist/client/org/OrgSwitcher.js +8 -2
- package/dist/client/org/OrgSwitcher.js.map +1 -1
- package/dist/client/settings/AccountSettingsCard.d.ts.map +1 -1
- package/dist/client/settings/AccountSettingsCard.js +10 -9
- package/dist/client/settings/AccountSettingsCard.js.map +1 -1
- package/dist/client/settings/SchedulingTimezoneField.d.ts +10 -0
- package/dist/client/settings/SchedulingTimezoneField.d.ts.map +1 -0
- package/dist/client/settings/SchedulingTimezoneField.js +30 -0
- package/dist/client/settings/SchedulingTimezoneField.js.map +1 -0
- package/dist/client/settings/SettingsRow.d.ts +36 -0
- package/dist/client/settings/SettingsRow.d.ts.map +1 -0
- package/dist/client/settings/SettingsRow.js +15 -0
- package/dist/client/settings/SettingsRow.js.map +1 -0
- package/dist/client/settings/agent-settings-search.d.ts.map +1 -1
- package/dist/client/settings/agent-settings-search.js +1 -1
- package/dist/client/settings/agent-settings-search.js.map +1 -1
- package/dist/client/settings/index.d.ts +1 -0
- package/dist/client/settings/index.d.ts.map +1 -1
- package/dist/client/settings/index.js +1 -0
- package/dist/client/settings/index.js.map +1 -1
- package/dist/file-upload/actions/upload-image.d.ts +1 -1
- package/dist/integrations/identity.d.ts.map +1 -1
- package/dist/integrations/identity.js +2 -11
- package/dist/integrations/identity.js.map +1 -1
- package/dist/jobs/actions/list-automation-runs.d.ts +8 -0
- package/dist/jobs/actions/list-automation-runs.d.ts.map +1 -0
- package/dist/jobs/actions/list-automation-runs.js +29 -0
- package/dist/jobs/actions/list-automation-runs.js.map +1 -0
- package/dist/jobs/actions/list-recurring-jobs.d.ts +2 -0
- package/dist/jobs/actions/list-recurring-jobs.d.ts.map +1 -1
- package/dist/jobs/actions/list-recurring-jobs.js +20 -7
- package/dist/jobs/actions/list-recurring-jobs.js.map +1 -1
- package/dist/jobs/actions/manage-recurring-job.d.ts +2 -0
- package/dist/jobs/actions/manage-recurring-job.js +30 -9
- package/dist/jobs/actions/manage-recurring-job.js.map +1 -1
- package/dist/jobs/background-automation-runner.d.ts.map +1 -1
- package/dist/jobs/background-automation-runner.js +60 -0
- package/dist/jobs/background-automation-runner.js.map +1 -1
- package/dist/jobs/cron.d.ts +16 -2
- package/dist/jobs/cron.d.ts.map +1 -1
- package/dist/jobs/cron.js +43 -6
- package/dist/jobs/cron.js.map +1 -1
- package/dist/jobs/frontmatter.d.ts +12 -0
- package/dist/jobs/frontmatter.d.ts.map +1 -1
- package/dist/jobs/frontmatter.js +8 -0
- package/dist/jobs/frontmatter.js.map +1 -1
- package/dist/jobs/run-history.d.ts +56 -0
- package/dist/jobs/run-history.d.ts.map +1 -0
- package/dist/jobs/run-history.js +169 -0
- package/dist/jobs/run-history.js.map +1 -0
- package/dist/jobs/scheduler.d.ts.map +1 -1
- package/dist/jobs/scheduler.js +51 -18
- package/dist/jobs/scheduler.js.map +1 -1
- package/dist/jobs/tools.d.ts.map +1 -1
- package/dist/jobs/tools.js +37 -6
- package/dist/jobs/tools.js.map +1 -1
- package/dist/localization/actions/get-localization-preference.d.ts +1 -2
- package/dist/localization/actions/get-localization-preference.d.ts.map +1 -1
- package/dist/localization/actions/get-localization-preference.js.map +1 -1
- package/dist/localization/actions/set-localization-preference.d.ts +3 -3
- package/dist/localization/actions/set-localization-preference.d.ts.map +1 -1
- package/dist/localization/actions/set-localization-preference.js +33 -8
- package/dist/localization/actions/set-localization-preference.js.map +1 -1
- package/dist/localization/default-messages.d.ts +25 -0
- package/dist/localization/default-messages.d.ts.map +1 -1
- package/dist/localization/default-messages.js +25 -0
- package/dist/localization/default-messages.js.map +1 -1
- package/dist/localization/shared.d.ts +16 -1
- package/dist/localization/shared.d.ts.map +1 -1
- package/dist/localization/shared.js +22 -4
- package/dist/localization/shared.js.map +1 -1
- package/dist/localization/user-timezone.d.ts +11 -0
- package/dist/localization/user-timezone.d.ts.map +1 -0
- package/dist/localization/user-timezone.js +31 -0
- package/dist/localization/user-timezone.js.map +1 -0
- package/dist/notifications/routes.d.ts +4 -4
- package/dist/observability/routes.d.ts +3 -3
- package/dist/org/app-roles-handlers.d.ts.map +1 -1
- package/dist/org/app-roles-handlers.js +1 -8
- package/dist/org/app-roles-handlers.js.map +1 -1
- package/dist/org/index.d.ts +1 -0
- package/dist/org/index.d.ts.map +1 -1
- package/dist/org/index.js +1 -0
- package/dist/org/index.js.map +1 -1
- package/dist/org/membership.d.ts +6 -0
- package/dist/org/membership.d.ts.map +1 -0
- package/dist/org/membership.js +16 -0
- package/dist/org/membership.js.map +1 -0
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +13 -13
- package/dist/provider-api/actions/provider-api.d.ts +8 -8
- package/dist/provider-api/corpus-jobs.d.ts +2 -2
- package/dist/review/actions/create-review-comment.d.ts +32 -1
- package/dist/review/actions/create-review-comment.d.ts.map +1 -1
- package/dist/review/actions/create-review-comment.js +3 -1
- package/dist/review/actions/create-review-comment.js.map +1 -1
- package/dist/review/actions/reply-review-comment.d.ts +32 -1
- package/dist/review/actions/reply-review-comment.d.ts.map +1 -1
- package/dist/review/actions/reply-review-comment.js +3 -1
- package/dist/review/actions/reply-review-comment.js.map +1 -1
- package/dist/review/index.d.ts +1 -0
- package/dist/review/index.d.ts.map +1 -1
- package/dist/review/index.js +1 -0
- package/dist/review/index.js.map +1 -1
- package/dist/review/notifications.d.ts +24 -0
- package/dist/review/notifications.d.ts.map +1 -0
- package/dist/review/notifications.js +123 -0
- package/dist/review/notifications.js.map +1 -0
- package/dist/review/types.d.ts +5 -0
- package/dist/review/types.d.ts.map +1 -1
- package/dist/review/types.js.map +1 -1
- package/dist/server/action-discovery.d.ts.map +1 -1
- package/dist/server/action-discovery.js +4 -0
- package/dist/server/action-discovery.js.map +1 -1
- package/dist/server/activity-notifications.d.ts +61 -0
- package/dist/server/activity-notifications.d.ts.map +1 -0
- package/dist/server/activity-notifications.js +103 -0
- package/dist/server/activity-notifications.js.map +1 -0
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/app-name.d.ts +18 -0
- package/dist/server/app-name.d.ts.map +1 -1
- package/dist/server/app-name.js +31 -0
- package/dist/server/app-name.js.map +1 -1
- package/dist/server/better-auth-instance.js +4 -4
- package/dist/server/better-auth-instance.js.map +1 -1
- package/dist/server/email-templates.d.ts +12 -0
- package/dist/server/email-templates.d.ts.map +1 -1
- package/dist/server/email-templates.js +57 -14
- package/dist/server/email-templates.js.map +1 -1
- package/dist/server/email.d.ts +12 -0
- package/dist/server/email.d.ts.map +1 -1
- package/dist/server/email.js +52 -5
- package/dist/server/email.js.map +1 -1
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/dist/sharing/access.d.ts.map +1 -1
- package/dist/sharing/access.js +32 -2
- package/dist/sharing/access.js.map +1 -1
- package/dist/sharing/index.d.ts +1 -0
- package/dist/sharing/index.d.ts.map +1 -1
- package/dist/sharing/index.js +1 -0
- package/dist/sharing/index.js.map +1 -1
- package/dist/sharing/recipients.d.ts +31 -0
- package/dist/sharing/recipients.d.ts.map +1 -0
- package/dist/sharing/recipients.js +40 -0
- package/dist/sharing/recipients.js.map +1 -0
- package/dist/templates/chat/app/routes/settings.tsx +14 -22
- package/dist/templates/chat/vitest.config.ts +9 -0
- package/dist/triggers/actions/list-automations.d.ts +2 -0
- package/dist/triggers/actions/list-automations.d.ts.map +1 -1
- package/dist/triggers/actions/list-automations.js +19 -8
- package/dist/triggers/actions/list-automations.js.map +1 -1
- package/dist/triggers/actions/manage-automation.d.ts +6 -0
- package/dist/triggers/actions/manage-automation.js +12 -6
- package/dist/triggers/actions/manage-automation.js.map +1 -1
- package/dist/triggers/actions.d.ts.map +1 -1
- package/dist/triggers/actions.js +15 -4
- package/dist/triggers/actions.js.map +1 -1
- package/dist/triggers/dispatcher.d.ts.map +1 -1
- package/dist/triggers/dispatcher.js +19 -17
- package/dist/triggers/dispatcher.js.map +1 -1
- package/dist/triggers/routes.d.ts.map +1 -1
- package/dist/triggers/routes.js +6 -6
- package/dist/triggers/routes.js.map +1 -1
- package/dist/vitest-config.d.ts +10 -0
- package/dist/vitest-config.d.ts.map +1 -0
- package/dist/vitest-config.js +55 -0
- package/dist/vitest-config.js.map +1 -0
- package/package.json +5 -4
- package/src/automations/service.ts +41 -4
- package/src/cli/mcp-config-writers.ts +27 -21
- package/src/client/agent-page/AgentJobsTab.tsx +187 -85
- package/src/client/agent-page/AutomationDetailsDialog.tsx +208 -0
- package/src/client/agent-page/AutomationScheduleDialog.tsx +180 -0
- package/src/client/agent-page/TimezoneSelect.tsx +241 -0
- package/src/client/agent-page/use-jobs.ts +50 -10
- package/src/client/org/OrgSwitcher.tsx +26 -0
- package/src/client/settings/AccountSettingsCard.tsx +35 -31
- package/src/client/settings/SchedulingTimezoneField.tsx +71 -0
- package/src/client/settings/SettingsRow.tsx +113 -0
- package/src/client/settings/agent-settings-search.ts +2 -1
- package/src/client/settings/index.ts +6 -0
- package/src/integrations/identity.ts +2 -12
- package/src/jobs/actions/list-automation-runs.ts +33 -0
- package/src/jobs/actions/list-recurring-jobs.ts +27 -6
- package/src/jobs/actions/manage-recurring-job.ts +41 -9
- package/src/jobs/background-automation-runner.ts +88 -0
- package/src/jobs/cron.ts +52 -6
- package/src/jobs/frontmatter.ts +20 -0
- package/src/jobs/run-history.ts +242 -0
- package/src/jobs/scheduler.ts +73 -18
- package/src/jobs/tools.ts +54 -6
- package/src/localization/actions/get-localization-preference.ts +2 -2
- package/src/localization/actions/set-localization-preference.ts +49 -11
- package/src/localization/default-messages.ts +27 -0
- package/src/localization/shared.ts +39 -6
- package/src/localization/user-timezone.ts +36 -0
- package/src/org/app-roles-handlers.ts +1 -9
- package/src/org/index.ts +2 -0
- package/src/org/membership.ts +18 -0
- package/src/review/actions/create-review-comment.ts +4 -1
- package/src/review/actions/reply-review-comment.ts +4 -1
- package/src/review/index.ts +5 -0
- package/src/review/notifications.ts +163 -0
- package/src/review/types.ts +7 -0
- package/src/server/action-discovery.ts +4 -0
- package/src/server/activity-notifications.ts +174 -0
- package/src/server/app-name.ts +31 -0
- package/src/server/better-auth-instance.ts +4 -4
- package/src/server/email-templates.ts +70 -14
- package/src/server/email.ts +66 -3
- package/src/server/index.ts +10 -0
- package/src/sharing/access.ts +44 -2
- package/src/sharing/index.ts +5 -0
- package/src/sharing/recipients.ts +67 -0
- package/src/templates/chat/app/routes/settings.tsx +14 -22
- package/src/templates/chat/vitest.config.ts +9 -0
- package/src/triggers/actions/list-automations.ts +27 -8
- package/src/triggers/actions/manage-automation.ts +17 -6
- package/src/triggers/actions.ts +16 -4
- package/src/triggers/dispatcher.ts +44 -30
- package/src/triggers/routes.ts +19 -6
- package/src/vitest-config.ts +68 -0
|
@@ -204,6 +204,7 @@ import {
|
|
|
204
204
|
} from "@/hooks/use-document-properties";
|
|
205
205
|
import {
|
|
206
206
|
isDocumentUpdateConflict,
|
|
207
|
+
documentQueryFilter,
|
|
207
208
|
type DocumentUpdateResult,
|
|
208
209
|
useDeleteDocument,
|
|
209
210
|
useDocument,
|
|
@@ -4853,9 +4854,7 @@ function DatabaseItemPreview({
|
|
|
4853
4854
|
void queryClient.invalidateQueries({
|
|
4854
4855
|
queryKey: contentDatabaseQueryKey(databaseDocumentId),
|
|
4855
4856
|
});
|
|
4856
|
-
void queryClient.invalidateQueries(
|
|
4857
|
-
queryKey: ["action", "get-document", { id: document.id }],
|
|
4858
|
-
});
|
|
4857
|
+
void queryClient.invalidateQueries(documentQueryFilter(document.id));
|
|
4859
4858
|
void queryClient.invalidateQueries({
|
|
4860
4859
|
queryKey: ["action", "list-documents"],
|
|
4861
4860
|
});
|
|
@@ -126,6 +126,7 @@ import {
|
|
|
126
126
|
useUpdateDocument,
|
|
127
127
|
buildDocumentTree,
|
|
128
128
|
filterDocumentTreeDocuments,
|
|
129
|
+
documentQueryFilter,
|
|
129
130
|
} from "@/hooks/use-documents";
|
|
130
131
|
import { useLocalStorage } from "@/hooks/use-local-storage";
|
|
131
132
|
import {
|
|
@@ -1191,16 +1192,12 @@ export function DocumentSidebar({
|
|
|
1191
1192
|
created,
|
|
1192
1193
|
);
|
|
1193
1194
|
if (nextId !== id) {
|
|
1194
|
-
queryClient.removeQueries(
|
|
1195
|
-
queryKey: ["action", "get-document", { id }],
|
|
1196
|
-
});
|
|
1195
|
+
queryClient.removeQueries(documentQueryFilter(id));
|
|
1197
1196
|
navigateToDocument(nextId);
|
|
1198
1197
|
}
|
|
1199
1198
|
// Replace optimistic doc with real server doc + clear any 404 error
|
|
1200
1199
|
// state from the in-flight fetch that ran before create completed.
|
|
1201
|
-
queryClient.invalidateQueries(
|
|
1202
|
-
queryKey: ["action", "get-document", { id: nextId }],
|
|
1203
|
-
});
|
|
1200
|
+
queryClient.invalidateQueries(documentQueryFilter(nextId));
|
|
1204
1201
|
queryClient.invalidateQueries({
|
|
1205
1202
|
queryKey: ["action", "list-documents"],
|
|
1206
1203
|
});
|
|
@@ -1214,9 +1211,7 @@ export function DocumentSidebar({
|
|
|
1214
1211
|
queryClient.invalidateQueries({
|
|
1215
1212
|
queryKey: ["action", "list-documents"],
|
|
1216
1213
|
});
|
|
1217
|
-
queryClient.removeQueries(
|
|
1218
|
-
queryKey: ["action", "get-document", { id }],
|
|
1219
|
-
});
|
|
1214
|
+
queryClient.removeQueries(documentQueryFilter(id));
|
|
1220
1215
|
if (rootFilesDatabaseId) {
|
|
1221
1216
|
queryClient.setQueryData<ContentDatabaseResponse>(
|
|
1222
1217
|
contentDatabaseByIdQueryKey(rootFilesDatabaseId),
|
|
@@ -1300,9 +1295,7 @@ export function DocumentSidebar({
|
|
|
1300
1295
|
);
|
|
1301
1296
|
});
|
|
1302
1297
|
for (const deletedId of deletedIds) {
|
|
1303
|
-
queryClient.removeQueries(
|
|
1304
|
-
queryKey: ["action", "get-document", { id: deletedId }],
|
|
1305
|
-
});
|
|
1298
|
+
queryClient.removeQueries(documentQueryFilter(deletedId));
|
|
1306
1299
|
}
|
|
1307
1300
|
|
|
1308
1301
|
if (activeDeleted) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@agent-native/toolkit/ui/switch";
|
|
@@ -57,6 +57,8 @@ import type {
|
|
|
57
57
|
import type { Query, QueryClient } from "@tanstack/react-query";
|
|
58
58
|
import { useQueryClient } from "@tanstack/react-query";
|
|
59
59
|
|
|
60
|
+
import { documentQueryFilter } from "../lib/document-query";
|
|
61
|
+
|
|
60
62
|
export function contentDatabaseQueryKey(documentId: string) {
|
|
61
63
|
return ["action", "get-content-database", { documentId }] as const;
|
|
62
64
|
}
|
|
@@ -421,9 +423,7 @@ export function clearDeletedContentDatabaseFromCache(
|
|
|
421
423
|
documentId: string,
|
|
422
424
|
) {
|
|
423
425
|
queryClient.removeQueries(contentDatabaseQueryFilter(documentId));
|
|
424
|
-
queryClient.removeQueries(
|
|
425
|
-
queryKey: ["action", "get-document", { id: documentId }],
|
|
426
|
-
});
|
|
426
|
+
queryClient.removeQueries(documentQueryFilter(documentId));
|
|
427
427
|
queryClient.invalidateQueries({
|
|
428
428
|
queryKey: ["action", "get-content-database"],
|
|
429
429
|
});
|
|
@@ -713,20 +713,14 @@ export function useCreateContentDatabase(documentId: string | null) {
|
|
|
713
713
|
{
|
|
714
714
|
onSuccess: (data) => {
|
|
715
715
|
if (documentId) {
|
|
716
|
-
queryClient.invalidateQueries(
|
|
717
|
-
queryKey: ["action", "get-document", { id: documentId }],
|
|
718
|
-
});
|
|
716
|
+
queryClient.invalidateQueries(documentQueryFilter(documentId));
|
|
719
717
|
queryClient.invalidateQueries({
|
|
720
718
|
queryKey: contentDatabaseQueryKey(documentId),
|
|
721
719
|
});
|
|
722
720
|
}
|
|
723
|
-
queryClient.invalidateQueries(
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
"get-document",
|
|
727
|
-
{ id: data.database.documentId },
|
|
728
|
-
],
|
|
729
|
-
});
|
|
721
|
+
queryClient.invalidateQueries(
|
|
722
|
+
documentQueryFilter(data.database.documentId),
|
|
723
|
+
);
|
|
730
724
|
queryClient.invalidateQueries({
|
|
731
725
|
queryKey: ["action", "list-documents"],
|
|
732
726
|
});
|
|
@@ -743,17 +737,11 @@ export function useCreateInlineContentDatabase(hostDocumentId: string | null) {
|
|
|
743
737
|
>("create-inline-content-database", {
|
|
744
738
|
onSuccess: (data) => {
|
|
745
739
|
if (hostDocumentId) {
|
|
746
|
-
queryClient.invalidateQueries(
|
|
747
|
-
queryKey: ["action", "get-document", { id: hostDocumentId }],
|
|
748
|
-
});
|
|
740
|
+
queryClient.invalidateQueries(documentQueryFilter(hostDocumentId));
|
|
749
741
|
}
|
|
750
|
-
queryClient.invalidateQueries(
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
"get-document",
|
|
754
|
-
{ id: data.block.databaseDocumentId },
|
|
755
|
-
],
|
|
756
|
-
});
|
|
742
|
+
queryClient.invalidateQueries(
|
|
743
|
+
documentQueryFilter(data.block.databaseDocumentId),
|
|
744
|
+
);
|
|
757
745
|
queryClient.invalidateQueries({
|
|
758
746
|
queryKey: contentDatabaseQueryKey(data.block.databaseDocumentId),
|
|
759
747
|
});
|
|
@@ -1488,7 +1476,10 @@ export function useProcessBuilderBodyHydration(documentId: string) {
|
|
|
1488
1476
|
|
|
1489
1477
|
export function invalidateBuilderBodyHydrationQueries(
|
|
1490
1478
|
queryClient: {
|
|
1491
|
-
invalidateQueries: (filters: {
|
|
1479
|
+
invalidateQueries: (filters: {
|
|
1480
|
+
queryKey?: readonly unknown[];
|
|
1481
|
+
predicate?: (query: { queryKey: readonly unknown[] }) => boolean;
|
|
1482
|
+
}) => unknown;
|
|
1492
1483
|
},
|
|
1493
1484
|
documentId: string,
|
|
1494
1485
|
variables?: Pick<ProcessBuilderBodyHydrationRequest, "documentId"> | null,
|
|
@@ -1501,9 +1492,7 @@ export function invalidateBuilderBodyHydrationQueries(
|
|
|
1501
1492
|
queryKey: ["action", "get-content-database-source", { documentId }],
|
|
1502
1493
|
});
|
|
1503
1494
|
if (variables?.documentId) {
|
|
1504
|
-
queryClient.invalidateQueries(
|
|
1505
|
-
queryKey: ["action", "get-document", { id: variables.documentId }],
|
|
1506
|
-
});
|
|
1495
|
+
queryClient.invalidateQueries(documentQueryFilter(variables.documentId));
|
|
1507
1496
|
}
|
|
1508
1497
|
}
|
|
1509
1498
|
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { agentNativePath } from "@agent-native/core/client/api-path";
|
|
2
|
+
import type { ContentUserPrefs } from "@shared/content-user-prefs";
|
|
3
|
+
import { useCallback, useEffect, useState } from "react";
|
|
4
|
+
|
|
5
|
+
const PREFS_PATH = "/_agent-native/content/user-prefs";
|
|
6
|
+
|
|
7
|
+
export interface ContentPrefsState {
|
|
8
|
+
prefs: ContentUserPrefs;
|
|
9
|
+
loading: boolean;
|
|
10
|
+
/** Applies the patch optimistically and rolls back if the write fails. */
|
|
11
|
+
save: (patch: ContentUserPrefs) => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function useContentPrefs(): ContentPrefsState {
|
|
15
|
+
const [prefs, setPrefs] = useState<ContentUserPrefs>({});
|
|
16
|
+
const [loading, setLoading] = useState(true);
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
let cancelled = false;
|
|
20
|
+
void (async () => {
|
|
21
|
+
try {
|
|
22
|
+
const res = await fetch(agentNativePath(PREFS_PATH));
|
|
23
|
+
const json = res.ok ? await res.json() : null;
|
|
24
|
+
if (cancelled) return;
|
|
25
|
+
if (json && typeof json === "object" && !("error" in json)) {
|
|
26
|
+
setPrefs(json as ContentUserPrefs);
|
|
27
|
+
}
|
|
28
|
+
} finally {
|
|
29
|
+
if (!cancelled) setLoading(false);
|
|
30
|
+
}
|
|
31
|
+
})();
|
|
32
|
+
return () => {
|
|
33
|
+
cancelled = true;
|
|
34
|
+
};
|
|
35
|
+
}, []);
|
|
36
|
+
|
|
37
|
+
const save = useCallback(
|
|
38
|
+
async (patch: ContentUserPrefs) => {
|
|
39
|
+
const previous = prefs;
|
|
40
|
+
setPrefs((current) => ({ ...current, ...patch }));
|
|
41
|
+
const res = await fetch(agentNativePath(PREFS_PATH), {
|
|
42
|
+
method: "PUT",
|
|
43
|
+
headers: { "Content-Type": "application/json" },
|
|
44
|
+
body: JSON.stringify(patch),
|
|
45
|
+
});
|
|
46
|
+
if (!res.ok) {
|
|
47
|
+
setPrefs(previous);
|
|
48
|
+
throw new Error(`Save failed (${res.status})`);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
[prefs],
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
return { prefs, loading, save };
|
|
55
|
+
}
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
import { useContentSpaces } from "@/hooks/use-content-spaces";
|
|
13
13
|
import { useCreateDocument } from "@/hooks/use-documents";
|
|
14
14
|
import { useLocalStorage } from "@/hooks/use-local-storage";
|
|
15
|
+
import { documentQueryFilter } from "@/lib/document-query";
|
|
15
16
|
import { markDocumentCreationPending } from "@/lib/optimistic-document";
|
|
16
17
|
|
|
17
18
|
const LIST_DOCUMENTS_QUERY_KEY = [
|
|
@@ -103,9 +104,7 @@ export function useCreatePage(opts?: {
|
|
|
103
104
|
);
|
|
104
105
|
// Replace optimistic doc with real server doc + clear any 404 error
|
|
105
106
|
// state from the in-flight fetch that ran before create completed.
|
|
106
|
-
queryClient.invalidateQueries(
|
|
107
|
-
queryKey: ["action", "get-document", { id }],
|
|
108
|
-
});
|
|
107
|
+
queryClient.invalidateQueries(documentQueryFilter(id));
|
|
109
108
|
queryClient.invalidateQueries({
|
|
110
109
|
queryKey: ["action", "list-documents"],
|
|
111
110
|
});
|
|
@@ -115,9 +114,7 @@ export function useCreatePage(opts?: {
|
|
|
115
114
|
queryClient.invalidateQueries({
|
|
116
115
|
queryKey: ["action", "list-documents"],
|
|
117
116
|
});
|
|
118
|
-
queryClient.removeQueries(
|
|
119
|
-
queryKey: ["action", "get-document", { id }],
|
|
120
|
-
});
|
|
117
|
+
queryClient.removeQueries(documentQueryFilter(id));
|
|
121
118
|
if (shouldNavigate) navigate("/");
|
|
122
119
|
toast.error("Failed to create page", {
|
|
123
120
|
description:
|
|
@@ -22,7 +22,10 @@ import {
|
|
|
22
22
|
contentDatabaseQueryKey,
|
|
23
23
|
removeDocumentPropertyFromDatabaseResponse,
|
|
24
24
|
} from "./use-content-database";
|
|
25
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
documentPropertiesQueryKey,
|
|
27
|
+
documentQueryFilter,
|
|
28
|
+
} from "./use-documents";
|
|
26
29
|
|
|
27
30
|
type DatabaseScopedRequest = { databaseId: string };
|
|
28
31
|
|
|
@@ -91,9 +94,7 @@ export function useConfigureDocumentProperty(
|
|
|
91
94
|
queryClient.invalidateQueries({
|
|
92
95
|
queryKey: documentPropertiesQueryKey(documentId, databaseId),
|
|
93
96
|
});
|
|
94
|
-
queryClient.invalidateQueries(
|
|
95
|
-
queryKey: ["action", "get-document", { id: documentId }],
|
|
96
|
-
});
|
|
97
|
+
queryClient.invalidateQueries(documentQueryFilter(documentId));
|
|
97
98
|
queryClient.invalidateQueries(
|
|
98
99
|
contentDatabaseConstrainedQueryFilter(databaseDocumentId),
|
|
99
100
|
);
|
|
@@ -158,9 +159,7 @@ export function useSetDocumentProperty(
|
|
|
158
159
|
queryClient.invalidateQueries({
|
|
159
160
|
queryKey: documentPropertiesQueryKey(variables.documentId, databaseId),
|
|
160
161
|
});
|
|
161
|
-
queryClient.invalidateQueries(
|
|
162
|
-
queryKey: ["action", "get-document", { id: variables.documentId }],
|
|
163
|
-
});
|
|
162
|
+
queryClient.invalidateQueries(documentQueryFilter(variables.documentId));
|
|
164
163
|
queryClient.invalidateQueries(
|
|
165
164
|
contentDatabaseConstrainedQueryFilter(databaseDocumentId),
|
|
166
165
|
);
|
|
@@ -195,9 +194,7 @@ export function useDuplicateDocumentProperty(
|
|
|
195
194
|
queryClient.invalidateQueries({
|
|
196
195
|
queryKey: documentPropertiesQueryKey(documentId, databaseId),
|
|
197
196
|
});
|
|
198
|
-
queryClient.invalidateQueries(
|
|
199
|
-
queryKey: ["action", "get-document", { id: documentId }],
|
|
200
|
-
});
|
|
197
|
+
queryClient.invalidateQueries(documentQueryFilter(documentId));
|
|
201
198
|
queryClient.invalidateQueries({
|
|
202
199
|
...contentDatabaseQueryFilter(databaseDocumentId),
|
|
203
200
|
});
|
|
@@ -220,9 +217,7 @@ export function useReorderDocumentProperty(
|
|
|
220
217
|
queryClient.invalidateQueries({
|
|
221
218
|
queryKey: documentPropertiesQueryKey(documentId, databaseId),
|
|
222
219
|
});
|
|
223
|
-
queryClient.invalidateQueries(
|
|
224
|
-
queryKey: ["action", "get-document", { id: documentId }],
|
|
225
|
-
});
|
|
220
|
+
queryClient.invalidateQueries(documentQueryFilter(documentId));
|
|
226
221
|
queryClient.invalidateQueries({
|
|
227
222
|
queryKey: contentDatabaseQueryKey(databaseDocumentId),
|
|
228
223
|
});
|
|
@@ -277,9 +272,7 @@ export function useDeleteDocumentProperty(
|
|
|
277
272
|
queryClient.invalidateQueries({
|
|
278
273
|
queryKey: documentPropertiesQueryKey(documentId, databaseId),
|
|
279
274
|
});
|
|
280
|
-
queryClient.invalidateQueries(
|
|
281
|
-
queryKey: ["action", "get-document", { id: documentId }],
|
|
282
|
-
});
|
|
275
|
+
queryClient.invalidateQueries(documentQueryFilter(documentId));
|
|
283
276
|
queryClient.invalidateQueries({
|
|
284
277
|
...contentDatabaseQueryFilter(databaseDocumentId),
|
|
285
278
|
});
|
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
import type { Document, DocumentVersion } from "@shared/api";
|
|
6
6
|
import { useQueryClient } from "@tanstack/react-query";
|
|
7
7
|
|
|
8
|
+
import { documentQueryFilter } from "./use-documents";
|
|
9
|
+
|
|
8
10
|
export function useDocumentVersions(documentId: string | null) {
|
|
9
11
|
return useActionQuery<DocumentVersion[]>(
|
|
10
12
|
"list-document-versions",
|
|
@@ -29,9 +31,7 @@ export function useRestoreDocumentVersion(documentId: string) {
|
|
|
29
31
|
queryClient.invalidateQueries({
|
|
30
32
|
queryKey: ["action", "list-document-versions", { documentId }],
|
|
31
33
|
});
|
|
32
|
-
queryClient.invalidateQueries(
|
|
33
|
-
queryKey: ["action", "get-document", { id: documentId }],
|
|
34
|
-
});
|
|
34
|
+
queryClient.invalidateQueries(documentQueryFilter(documentId));
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
37
|
);
|
|
@@ -19,23 +19,50 @@ import { useQueryClient } from "@tanstack/react-query";
|
|
|
19
19
|
import { toast } from "sonner";
|
|
20
20
|
|
|
21
21
|
import type { DocumentUpdateConflictResponse } from "../../actions/update-document";
|
|
22
|
+
import {
|
|
23
|
+
documentQueryFilter,
|
|
24
|
+
documentQueryKey,
|
|
25
|
+
type DocumentQueryContext,
|
|
26
|
+
} from "../lib/document-query";
|
|
22
27
|
import {
|
|
23
28
|
removeOptimisticItemFromContentDatabase,
|
|
24
29
|
useRestoreContentDatabase,
|
|
25
30
|
} from "./use-content-database";
|
|
26
31
|
|
|
32
|
+
export {
|
|
33
|
+
documentQueryFilter,
|
|
34
|
+
documentQueryKey,
|
|
35
|
+
type DocumentQueryContext,
|
|
36
|
+
} from "../lib/document-query";
|
|
37
|
+
|
|
27
38
|
export type { DocumentUpdateConflictResponse };
|
|
28
39
|
|
|
40
|
+
export type PageOwnedDocumentCachePatch = Pick<
|
|
41
|
+
Partial<Document>,
|
|
42
|
+
| "id"
|
|
43
|
+
| "parentId"
|
|
44
|
+
| "title"
|
|
45
|
+
| "content"
|
|
46
|
+
| "description"
|
|
47
|
+
| "icon"
|
|
48
|
+
| "position"
|
|
49
|
+
| "isFavorite"
|
|
50
|
+
| "hideFromSearch"
|
|
51
|
+
| "visibility"
|
|
52
|
+
| "accessRole"
|
|
53
|
+
| "canEdit"
|
|
54
|
+
| "canManage"
|
|
55
|
+
| "source"
|
|
56
|
+
| "createdAt"
|
|
57
|
+
| "updatedAt"
|
|
58
|
+
>;
|
|
59
|
+
|
|
29
60
|
export const LIST_DOCUMENTS_QUERY_KEY = [
|
|
30
61
|
"action",
|
|
31
62
|
"list-documents",
|
|
32
63
|
undefined,
|
|
33
64
|
] as const;
|
|
34
65
|
|
|
35
|
-
export function documentQueryKey(documentId: string) {
|
|
36
|
-
return ["action", "get-document", { id: documentId }] as const;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
66
|
export function documentPropertiesQueryKey(
|
|
40
67
|
documentId: string,
|
|
41
68
|
databaseId: string,
|
|
@@ -74,7 +101,27 @@ export function mergeDocumentIntoDocumentCache(
|
|
|
74
101
|
old: unknown,
|
|
75
102
|
document: Document,
|
|
76
103
|
) {
|
|
77
|
-
|
|
104
|
+
const pageOwnedPatch: PageOwnedDocumentCachePatch = {
|
|
105
|
+
id: document.id,
|
|
106
|
+
parentId: document.parentId,
|
|
107
|
+
title: document.title,
|
|
108
|
+
content: document.content,
|
|
109
|
+
description: document.description,
|
|
110
|
+
icon: document.icon,
|
|
111
|
+
position: document.position,
|
|
112
|
+
isFavorite: document.isFavorite,
|
|
113
|
+
hideFromSearch: document.hideFromSearch,
|
|
114
|
+
visibility: document.visibility,
|
|
115
|
+
accessRole: document.accessRole,
|
|
116
|
+
canEdit: document.canEdit,
|
|
117
|
+
canManage: document.canManage,
|
|
118
|
+
source: document.source,
|
|
119
|
+
createdAt: document.createdAt,
|
|
120
|
+
updatedAt: document.updatedAt,
|
|
121
|
+
};
|
|
122
|
+
return old && typeof old === "object"
|
|
123
|
+
? { ...old, ...pageOwnedPatch }
|
|
124
|
+
: pageOwnedPatch;
|
|
78
125
|
}
|
|
79
126
|
|
|
80
127
|
export function mergeDocumentIntoListDocumentsCache(
|
|
@@ -157,9 +204,9 @@ function patchDocumentWithFavoriteMembershipInDatabaseCache(
|
|
|
157
204
|
export function patchDocumentCaches(
|
|
158
205
|
queryClient: Pick<QueryClient, "setQueryData" | "setQueriesData">,
|
|
159
206
|
documentId: string,
|
|
160
|
-
patch:
|
|
207
|
+
patch: PageOwnedDocumentCachePatch,
|
|
161
208
|
) {
|
|
162
|
-
queryClient.
|
|
209
|
+
queryClient.setQueriesData(documentQueryFilter(documentId), (old: unknown) =>
|
|
163
210
|
old && typeof old === "object" ? { ...old, ...patch } : old,
|
|
164
211
|
);
|
|
165
212
|
queryClient.setQueryData(LIST_DOCUMENTS_QUERY_KEY, (old: unknown) =>
|
|
@@ -219,7 +266,7 @@ export function patchContentSpaceNameCaches(
|
|
|
219
266
|
export function documentUpdateSuccessPatch(
|
|
220
267
|
data: DocumentUpdateResponse,
|
|
221
268
|
variables: DocumentUpdateRequestWithCas,
|
|
222
|
-
):
|
|
269
|
+
): PageOwnedDocumentCachePatch {
|
|
223
270
|
return {
|
|
224
271
|
updatedAt: data.updatedAt,
|
|
225
272
|
...(variables.title !== undefined ? { title: data.title } : {}),
|
|
@@ -289,13 +336,28 @@ export const DOCUMENT_QUERY_FRESHNESS_OPTIONS = {
|
|
|
289
336
|
retry: false,
|
|
290
337
|
};
|
|
291
338
|
|
|
292
|
-
export function useDocument(
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
339
|
+
export function useDocument(
|
|
340
|
+
id: string | null,
|
|
341
|
+
context: DocumentQueryContext = {},
|
|
342
|
+
) {
|
|
343
|
+
return useActionQuery<Document>(
|
|
344
|
+
"get-document",
|
|
345
|
+
id
|
|
346
|
+
? {
|
|
347
|
+
id,
|
|
348
|
+
...(context.databaseId ? { databaseId: context.databaseId } : {}),
|
|
349
|
+
...(context.databaseDocumentId
|
|
350
|
+
? { databaseDocumentId: context.databaseDocumentId }
|
|
351
|
+
: {}),
|
|
352
|
+
}
|
|
353
|
+
: undefined,
|
|
354
|
+
{
|
|
355
|
+
enabled: !!id,
|
|
356
|
+
// Doc-not-found / no-access errors are deterministic — retrying just keeps
|
|
357
|
+
// the spinner up for ~7s before the UI can render "Not found".
|
|
358
|
+
...DOCUMENT_QUERY_FRESHNESS_OPTIONS,
|
|
359
|
+
},
|
|
360
|
+
);
|
|
299
361
|
}
|
|
300
362
|
|
|
301
363
|
export interface PreviewDocumentDraftRecord {
|
|
@@ -368,7 +430,7 @@ export function useUpdateDocument() {
|
|
|
368
430
|
};
|
|
369
431
|
if (Object.keys(optimisticPatch).length === 0) return undefined;
|
|
370
432
|
|
|
371
|
-
const
|
|
433
|
+
const documentFilter = documentQueryFilter(variables.id);
|
|
372
434
|
const databaseFilter = {
|
|
373
435
|
queryKey: ["action", "get-content-database"],
|
|
374
436
|
} as const;
|
|
@@ -376,14 +438,14 @@ export function useUpdateDocument() {
|
|
|
376
438
|
queryKey: ["action", "list-content-spaces"],
|
|
377
439
|
} as const;
|
|
378
440
|
await Promise.all([
|
|
379
|
-
queryClient.cancelQueries(
|
|
441
|
+
queryClient.cancelQueries(documentFilter),
|
|
380
442
|
queryClient.cancelQueries({ queryKey: LIST_DOCUMENTS_QUERY_KEY }),
|
|
381
443
|
queryClient.cancelQueries(databaseFilter),
|
|
382
444
|
queryClient.cancelQueries(contentSpacesFilter),
|
|
383
445
|
]);
|
|
384
446
|
|
|
385
447
|
const previous: Array<[readonly unknown[], unknown]> = [
|
|
386
|
-
|
|
448
|
+
...queryClient.getQueriesData(documentFilter),
|
|
387
449
|
[
|
|
388
450
|
LIST_DOCUMENTS_QUERY_KEY,
|
|
389
451
|
queryClient.getQueryData(LIST_DOCUMENTS_QUERY_KEY),
|
|
@@ -423,8 +485,8 @@ export function useUpdateDocument() {
|
|
|
423
485
|
// just-applied write.
|
|
424
486
|
if (isDocumentUpdateConflict(data)) {
|
|
425
487
|
const serverDocument = data.document;
|
|
426
|
-
queryClient.
|
|
427
|
-
|
|
488
|
+
queryClient.setQueriesData(
|
|
489
|
+
documentQueryFilter(variables.id),
|
|
428
490
|
(old: unknown) =>
|
|
429
491
|
mergeDocumentIntoDocumentCache(old, serverDocument),
|
|
430
492
|
);
|
|
@@ -453,9 +515,7 @@ export function useUpdateDocument() {
|
|
|
453
515
|
queryKey: ["action", "get-content-database"],
|
|
454
516
|
});
|
|
455
517
|
}
|
|
456
|
-
queryClient.invalidateQueries(
|
|
457
|
-
queryKey: ["action", "get-document", { id: variables.id }],
|
|
458
|
-
});
|
|
518
|
+
queryClient.invalidateQueries(documentQueryFilter(variables.id));
|
|
459
519
|
queryClient.invalidateQueries({
|
|
460
520
|
queryKey: ["action", "list-documents"],
|
|
461
521
|
});
|
|
@@ -525,9 +585,7 @@ export function useDeleteDocument() {
|
|
|
525
585
|
queryClient.invalidateQueries({
|
|
526
586
|
queryKey: ["action", "list-documents"],
|
|
527
587
|
});
|
|
528
|
-
queryClient.invalidateQueries(
|
|
529
|
-
queryKey: ["action", "get-document", { id: variables.id }],
|
|
530
|
-
});
|
|
588
|
+
queryClient.invalidateQueries(documentQueryFilter(variables.id));
|
|
531
589
|
queryClient.invalidateQueries({
|
|
532
590
|
queryKey: ["action", "get-content-database"],
|
|
533
591
|
});
|
|
@@ -606,9 +664,7 @@ export function useMoveDocument() {
|
|
|
606
664
|
queryClient.invalidateQueries({
|
|
607
665
|
queryKey: ["action", "list-documents"],
|
|
608
666
|
});
|
|
609
|
-
queryClient.invalidateQueries(
|
|
610
|
-
queryKey: ["action", "get-document", { id: variables.id }],
|
|
611
|
-
});
|
|
667
|
+
queryClient.invalidateQueries(documentQueryFilter(variables.id));
|
|
612
668
|
},
|
|
613
669
|
},
|
|
614
670
|
);
|
|
@@ -16,6 +16,8 @@ import type {
|
|
|
16
16
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
17
17
|
import { useEffect, useRef } from "react";
|
|
18
18
|
|
|
19
|
+
import { documentQueryFilter } from "./use-documents";
|
|
20
|
+
|
|
19
21
|
// The server signs a `redirect` query param into the OAuth `state` and the
|
|
20
22
|
// callback route sends the user back there once the connection completes. If
|
|
21
23
|
// we never send it, `state.redirectPath` defaults to "/" server-side and
|
|
@@ -55,9 +57,7 @@ export function invalidateDocumentQueries(
|
|
|
55
57
|
// path after every debounced editor save). Invalidating the bare ["action"]
|
|
56
58
|
// key would refetch every mounted query app-wide (sidebar tree, comments,
|
|
57
59
|
// database views, search, connection status, ...) on each cycle.
|
|
58
|
-
queryClient.invalidateQueries(
|
|
59
|
-
queryKey: ["action", "get-document", { id: documentId }],
|
|
60
|
-
});
|
|
60
|
+
queryClient.invalidateQueries(documentQueryFilter(documentId));
|
|
61
61
|
queryClient.invalidateQueries({
|
|
62
62
|
queryKey: ["action", "list-documents"],
|
|
63
63
|
});
|
|
@@ -155,21 +155,23 @@ export function useDocumentSyncStatus(
|
|
|
155
155
|
|
|
156
156
|
lastObservedSyncedAtRef.current = query.data.lastSyncedAt;
|
|
157
157
|
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
]);
|
|
158
|
+
const cachedDocuments = queryClient
|
|
159
|
+
.getQueriesData<Document>(documentQueryFilter(normalizedDocumentId))
|
|
160
|
+
.map(([, document]) => document)
|
|
161
|
+
.filter((document): document is Document => !!document);
|
|
163
162
|
const syncedLocalUpdatedAt = query.data.lastPushedLocalUpdatedAt;
|
|
164
163
|
|
|
165
164
|
if (
|
|
166
|
-
|
|
165
|
+
cachedDocuments.some(
|
|
166
|
+
(cachedDocument) =>
|
|
167
|
+
!!cachedDocument.updatedAt &&
|
|
168
|
+
!!syncedLocalUpdatedAt &&
|
|
169
|
+
syncedLocalUpdatedAt > cachedDocument.updatedAt,
|
|
170
|
+
) &&
|
|
167
171
|
syncedLocalUpdatedAt &&
|
|
168
|
-
|
|
172
|
+
cachedDocuments.length > 0
|
|
169
173
|
) {
|
|
170
|
-
queryClient.invalidateQueries(
|
|
171
|
-
queryKey: ["action", "get-document", { id: normalizedDocumentId }],
|
|
172
|
-
});
|
|
174
|
+
queryClient.invalidateQueries(documentQueryFilter(normalizedDocumentId));
|
|
173
175
|
queryClient.invalidateQueries({ queryKey: ["action", "list-documents"] });
|
|
174
176
|
}
|
|
175
177
|
}, [
|