@agent-native/core 0.123.0 → 0.123.2
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 +1 -1
- package/corpus/core/CHANGELOG.md +24 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/cli/templates-meta.ts +12 -0
- package/corpus/core/src/deploy/build.ts +8 -0
- package/corpus/core/src/server/builder-browser.ts +76 -0
- package/corpus/core/src/server/core-routes-plugin.ts +15 -5
- package/corpus/templates/assets/app/global.css +0 -4
- package/corpus/templates/assets/app/routes/brand-kits.$id.tsx +195 -167
- package/corpus/templates/assets/changelog/2026-07-23-drafts-preview-panel-now-fills-the-full-width-with-a-large-p.md +6 -0
- package/corpus/templates/content/actions/_builder-cms-source-adapter.ts +1 -0
- package/corpus/templates/content/actions/_builder-cms-write-client.ts +55 -9
- package/corpus/templates/content/actions/_database-source-utils.ts +756 -182
- package/corpus/templates/content/actions/change-content-database-source-role.ts +21 -20
- package/corpus/templates/content/actions/execute-builder-source-execution.ts +49 -8
- package/corpus/templates/content/actions/materialize-builder-required-fields.ts +42 -9
- package/corpus/templates/content/actions/prepare-builder-source-review.ts +88 -90
- package/corpus/templates/content/actions/preview-builder-source-review.ts +4 -3
- package/corpus/templates/content/actions/refresh-content-database-source.ts +36 -9
- package/corpus/templates/content/actions/set-content-database-source-write-mode.ts +28 -24
- package/corpus/templates/content/app/components/editor/BubbleToolbar.tsx +62 -12
- package/corpus/templates/content/app/components/editor/DocumentEditor.tsx +91 -16
- package/corpus/templates/content/app/components/editor/DocumentProperties.tsx +15 -1
- package/corpus/templates/content/app/components/editor/SlashCommandMenu.tsx +234 -44
- package/corpus/templates/content/app/components/editor/VisualEditor.tsx +194 -16
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +95 -42
- package/corpus/templates/content/app/components/editor/database-sources/BuilderSourceReviewDialog.tsx +4 -2
- package/corpus/templates/content/app/components/editor/extensions/CodeBlockNode.tsx +10 -166
- package/corpus/templates/content/app/components/editor/extensions/VideoBlock.tsx +32 -8
- package/corpus/templates/content/app/components/editor/extensions/VideoNode.ts +14 -0
- package/corpus/templates/content/app/components/editor/registrySlashItems.ts +5 -1
- package/corpus/templates/content/app/hooks/use-content-database.ts +59 -2
- package/corpus/templates/content/app/hooks/use-documents.ts +18 -26
- package/corpus/templates/content/app/root.tsx +1 -6
- package/corpus/templates/content/changelog/2026-07-24-builder-can-now-publish-approved-updates-to-entries-that-are.md +6 -0
- package/corpus/templates/content/changelog/2026-07-24-builder-collection-loading-no-longer-restarts-from-the-begin.md +6 -0
- package/corpus/templates/content/changelog/2026-07-24-builder-connections-now-complete-securely-from-netlify-deplo.md +6 -0
- package/corpus/templates/content/changelog/2026-07-24-builder-draft-creation-now-scopes-execution-to-the-selected-.md +6 -0
- package/corpus/templates/content/changelog/2026-07-24-builder-review-now-distinguishes-preparing-a-safe-dry-run-from.md +6 -0
- package/corpus/templates/content/changelog/2026-07-24-builder-source-imports-now-recover-from-a-transient-paginati.md +6 -0
- package/corpus/templates/content/changelog/2026-07-24-builder-source-refresh-now-preserves-the-provider-bound-fiel.md +6 -0
- package/corpus/templates/content/changelog/2026-07-24-builder-update-reviews-now-open-reliably-on-large-collection.md +6 -0
- package/corpus/templates/content/changelog/2026-07-24-builder-write-policy-controls-now-reflect-successful-changes.md +6 -0
- package/corpus/templates/content/changelog/2026-07-24-date-properties-now-save-reliably-when-selected-with-the-nat.md +6 -0
- package/corpus/templates/content/changelog/2026-07-24-editor-slash-search-now-keeps-multi-word-block-names-open.md +6 -0
- package/corpus/templates/content/changelog/2026-07-24-exact-editor-slash-commands-now-execute-on-enter-even-if-the.md +6 -0
- package/corpus/templates/content/changelog/2026-07-24-new-collaborative-pages-now-save-their-first-edits.md +6 -0
- package/corpus/templates/content/changelog/2026-07-24-new-local-builder-rows-no-longer-remain-locked-behind-a-none.md +6 -0
- package/corpus/templates/content/changelog/2026-07-24-opening-or-closing-a-collaborative-document-no-longer-lets-u.md +6 -0
- package/corpus/templates/content/changelog/2026-07-24-selected-text-now-opens-the-link-editor-with-command-k-or-co.md +6 -0
- package/corpus/templates/content/changelog/2026-07-24-slash-menu-block-choices-no-longer-stall-pointer-interaction.md +6 -0
- package/corpus/templates/content/changelog/2026-07-24-uploaded-and-embedded-media-now-stay-intact-while-collaborative-document-drafts-save.md +6 -0
- package/corpus/templates/content/changelog/2026-07-24-video-link-insertion-now-keeps-its-source-panel-open-while-t.md +6 -0
- package/corpus/templates/content/changelog/2026-07-26-builder-publishing-now-shows-safe-validation-details-instead.md +6 -0
- package/corpus/templates/content/changelog/2026-07-26-builder-reviews-stay-responsive-on-large-collections-and-pre.md +6 -0
- package/corpus/templates/content/changelog/2026-07-26-collaborative-documents-no-longer-flash-duplicated-recent-bl.md +6 -0
- package/corpus/templates/content/changelog/2026-07-26-corrected-builder-updates-are-now-reviewed-separately-from-f.md +6 -0
- package/corpus/templates/content/changelog/2026-07-26-documents-now-remain-read-only-until-their-live-collaborativ.md +6 -0
- package/corpus/templates/content/changelog/2026-07-26-slash-command-menus-now-stay-reachable-when-editing-near-the.md +6 -0
- package/corpus/templates/content/changelog/2026-07-26-the-slash-menu-now-shows-one-clear-callout-choice-instead-of.md +6 -0
- package/corpus/templates/content/shared/api.ts +1 -0
- package/corpus/templates/content/shared/builder-mdx.ts +73 -16
- package/corpus/templates/crm/.agents/skills/agent-native-docs/SKILL.md +115 -0
- package/corpus/templates/crm/.agents/skills/agent-native-toolkit/SKILL.md +177 -0
- package/corpus/templates/crm/.agents/skills/crm/SKILL.md +205 -0
- package/corpus/templates/crm/.agents/skills/customizing-agent-native/SKILL.md +220 -0
- package/corpus/templates/crm/.agents/skills/feature-flags/SKILL.md +169 -0
- package/corpus/templates/crm/.agents/skills/sharing/SKILL.md +228 -0
- package/corpus/templates/crm/.agents/skills/storing-data/SKILL.md +178 -0
- package/corpus/templates/crm/.agents/skills/upgrade-agent-native/SKILL.md +122 -0
- package/corpus/templates/crm/.env.example +5 -0
- package/corpus/templates/crm/AGENTS.md +82 -0
- package/corpus/templates/crm/CHANGELOG.md +25 -0
- package/corpus/templates/crm/DEVELOPING.md +66 -0
- package/corpus/templates/crm/README.md +122 -0
- package/corpus/templates/crm/_gitignore +12 -0
- package/corpus/templates/crm/actions/_crm-action-utils.ts +98 -0
- package/corpus/templates/crm/actions/_crm-attribute-utils.ts +219 -0
- package/corpus/templates/crm/actions/_crm-dashboard.ts +69 -0
- package/corpus/templates/crm/actions/_crm-data-program-actions.ts +15 -0
- package/corpus/templates/crm/actions/_crm-list-utils.ts +775 -0
- package/corpus/templates/crm/actions/_crm-signal-utils.ts +79 -0
- package/corpus/templates/crm/actions/add-crm-record-to-list.ts +164 -0
- package/corpus/templates/crm/actions/apply-crm-proposals.ts +291 -0
- package/corpus/templates/crm/actions/archive-crm-attribute.ts +69 -0
- package/corpus/templates/crm/actions/attach-call-evidence.ts +170 -0
- package/corpus/templates/crm/actions/configure-crm-connection.ts +126 -0
- package/corpus/templates/crm/actions/configure-native-crm.ts +44 -0
- package/corpus/templates/crm/actions/create-crm-attribute.ts +350 -0
- package/corpus/templates/crm/actions/create-crm-list.ts +194 -0
- package/corpus/templates/crm/actions/create-crm-record.ts +148 -0
- package/corpus/templates/crm/actions/create-crm-signal-tracker.ts +58 -0
- package/corpus/templates/crm/actions/delete-crm-saved-view.ts +68 -0
- package/corpus/templates/crm/actions/delete-staged-dataset.ts +14 -0
- package/corpus/templates/crm/actions/estimate-crm-enrichment.ts +229 -0
- package/corpus/templates/crm/actions/find-crm-duplicates.ts +87 -0
- package/corpus/templates/crm/actions/get-crm-automation-recipe.ts +36 -0
- package/corpus/templates/crm/actions/get-crm-dashboard-panel.ts +35 -0
- package/corpus/templates/crm/actions/get-crm-dashboard.ts +14 -0
- package/corpus/templates/crm/actions/get-crm-overview.ts +13 -0
- package/corpus/templates/crm/actions/get-crm-pipeline-data.ts +61 -0
- package/corpus/templates/crm/actions/get-crm-record-page.ts +287 -0
- package/corpus/templates/crm/actions/get-crm-record.ts +75 -0
- package/corpus/templates/crm/actions/get-crm-workspace.ts +364 -0
- package/corpus/templates/crm/actions/install-crm-pipeline-dashboard.ts +81 -0
- package/corpus/templates/crm/actions/list-crm-attributes.ts +71 -0
- package/corpus/templates/crm/actions/list-crm-connections.ts +68 -0
- package/corpus/templates/crm/actions/list-crm-dashboard-revisions.ts +15 -0
- package/corpus/templates/crm/actions/list-crm-dashboards.ts +15 -0
- package/corpus/templates/crm/actions/list-crm-enrichment-slots.ts +28 -0
- package/corpus/templates/crm/actions/list-crm-list-entries.ts +192 -0
- package/corpus/templates/crm/actions/list-crm-lists.ts +80 -0
- package/corpus/templates/crm/actions/list-crm-proposals.ts +55 -0
- package/corpus/templates/crm/actions/list-crm-record-field-history.ts +201 -0
- package/corpus/templates/crm/actions/list-crm-record-values.ts +200 -0
- package/corpus/templates/crm/actions/list-crm-records.ts +103 -0
- package/corpus/templates/crm/actions/list-crm-saved-views.ts +66 -0
- package/corpus/templates/crm/actions/list-crm-signal-hits.ts +43 -0
- package/corpus/templates/crm/actions/list-crm-signal-trackers.ts +32 -0
- package/corpus/templates/crm/actions/list-crm-tasks.ts +22 -0
- package/corpus/templates/crm/actions/list-staged-datasets.ts +14 -0
- package/corpus/templates/crm/actions/list-workspace-connections.ts +47 -0
- package/corpus/templates/crm/actions/manage-crm-attribute-option.ts +272 -0
- package/corpus/templates/crm/actions/manage-crm-signal-tracker.ts +87 -0
- package/corpus/templates/crm/actions/manage-crm-task.ts +132 -0
- package/corpus/templates/crm/actions/merge-crm-records.ts +691 -0
- package/corpus/templates/crm/actions/navigate.ts +54 -0
- package/corpus/templates/crm/actions/provider-api-catalog.ts +22 -0
- package/corpus/templates/crm/actions/provider-api-docs.ts +54 -0
- package/corpus/templates/crm/actions/provider-api-request.ts +92 -0
- package/corpus/templates/crm/actions/query-staged-dataset.ts +44 -0
- package/corpus/templates/crm/actions/record-crm-call-insight.ts +160 -0
- package/corpus/templates/crm/actions/record-crm-smart-signal.ts +150 -0
- package/corpus/templates/crm/actions/remove-crm-list-entry.ts +79 -0
- package/corpus/templates/crm/actions/restore-crm-dashboard-revision.ts +23 -0
- package/corpus/templates/crm/actions/review-crm-signal.ts +31 -0
- package/corpus/templates/crm/actions/run-crm-attribute-fill.ts +443 -0
- package/corpus/templates/crm/actions/run-crm-enrichment.ts +647 -0
- package/corpus/templates/crm/actions/run-crm-saved-view-program.ts +103 -0
- package/corpus/templates/crm/actions/run-crm-signal-trackers.ts +265 -0
- package/corpus/templates/crm/actions/run.ts +7 -0
- package/corpus/templates/crm/actions/save-crm-dashboard.ts +51 -0
- package/corpus/templates/crm/actions/save-crm-saved-view.ts +296 -0
- package/corpus/templates/crm/actions/sync-crm.ts +146 -0
- package/corpus/templates/crm/actions/update-crm-attribute.ts +111 -0
- package/corpus/templates/crm/actions/update-crm-list-entry.ts +102 -0
- package/corpus/templates/crm/actions/update-crm-list.ts +97 -0
- package/corpus/templates/crm/actions/update-crm-record.ts +543 -0
- package/corpus/templates/crm/actions/view-screen.ts +324 -0
- package/corpus/templates/crm/agent-native.app-skill.json +69 -0
- package/corpus/templates/crm/app/components/crm/CreateCrmRecordDialog.tsx +158 -0
- package/corpus/templates/crm/app/components/crm/CrmDashboardPanel.tsx +78 -0
- package/corpus/templates/crm/app/components/crm/CrmSignalsPanel.tsx +220 -0
- package/corpus/templates/crm/app/components/crm/IntelligenceSettings.tsx +414 -0
- package/corpus/templates/crm/app/components/crm/RecordActions.tsx +648 -0
- package/corpus/templates/crm/app/components/crm/RecordGrid.tsx +488 -0
- package/corpus/templates/crm/app/components/crm/RecordWorkspace.tsx +232 -0
- package/corpus/templates/crm/app/components/crm/SavedViewDataProgram.tsx +93 -0
- package/corpus/templates/crm/app/components/crm/Surface.tsx +97 -0
- package/corpus/templates/crm/app/components/crm/WorkOverview.tsx +180 -0
- package/corpus/templates/crm/app/components/crm/board/CrmBoard.tsx +988 -0
- package/corpus/templates/crm/app/components/crm/board/board-model.ts +399 -0
- package/corpus/templates/crm/app/components/crm/board/entry-filter.ts +150 -0
- package/corpus/templates/crm/app/components/crm/board/view-draft.ts +227 -0
- package/corpus/templates/crm/app/components/crm/grid/CrmGrid.tsx +1033 -0
- package/corpus/templates/crm/app/components/crm/grid/GridCell.tsx +620 -0
- package/corpus/templates/crm/app/components/crm/grid/clipboard.ts +84 -0
- package/corpus/templates/crm/app/components/crm/grid/model.ts +304 -0
- package/corpus/templates/crm/app/components/crm/grid/navigation.ts +220 -0
- package/corpus/templates/crm/app/components/crm/grid/query.ts +214 -0
- package/corpus/templates/crm/app/components/crm/record/AttributePanel.tsx +192 -0
- package/corpus/templates/crm/app/components/crm/record/FieldHistory.tsx +179 -0
- package/corpus/templates/crm/app/components/crm/record/RecordHeader.tsx +103 -0
- package/corpus/templates/crm/app/components/crm/record/RecordLists.tsx +235 -0
- package/corpus/templates/crm/app/components/crm/record/RecordTabs.tsx +206 -0
- package/corpus/templates/crm/app/components/crm/record/field-editors.tsx +245 -0
- package/corpus/templates/crm/app/components/crm/record/record-data.ts +603 -0
- package/corpus/templates/crm/app/components/crm/settings/AdvancedSettings.tsx +49 -0
- package/corpus/templates/crm/app/components/crm/settings/AttributeOptionsEditor.tsx +441 -0
- package/corpus/templates/crm/app/components/crm/settings/ConnectionSettings.tsx +169 -0
- package/corpus/templates/crm/app/components/crm/settings/FieldsSettings.tsx +935 -0
- package/corpus/templates/crm/app/components/crm/settings/ListsSettings.tsx +339 -0
- package/corpus/templates/crm/app/components/crm/settings/settings-admin.ts +377 -0
- package/corpus/templates/crm/app/components/crm/shared/AttributeValueParts.tsx +69 -0
- package/corpus/templates/crm/app/components/crm/shared/attribute-value.ts +591 -0
- package/corpus/templates/crm/app/components/layout/CrmCommandMenu.tsx +556 -0
- package/corpus/templates/crm/app/components/layout/CrmLayout.tsx +130 -0
- package/corpus/templates/crm/app/components/layout/CrmSidebar.tsx +407 -0
- package/corpus/templates/crm/app/components/layout/command-palette-search.ts +126 -0
- package/corpus/templates/crm/app/components/layout/crm-ui-intents.ts +41 -0
- package/corpus/templates/crm/app/components/layout/sidebar-collapse.ts +40 -0
- package/corpus/templates/crm/app/components/layout/sidebar-lists.ts +109 -0
- package/corpus/templates/crm/app/components/ui/alert-dialog.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/badge.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/button.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/card.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/checkbox.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/dialog.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/dropdown-menu.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/hover-card.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/input.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/label.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/popover.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/select.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/sheet.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/skeleton.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/switch.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/table.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/tabs.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/textarea.tsx +1 -0
- package/corpus/templates/crm/app/components/ui/toolkit-provider.tsx +17 -0
- package/corpus/templates/crm/app/components/ui/tooltip.tsx +1 -0
- package/corpus/templates/crm/app/design-system.ts +3 -0
- package/corpus/templates/crm/app/entry.client.tsx +19 -0
- package/corpus/templates/crm/app/entry.server.tsx +10 -0
- package/corpus/templates/crm/app/global.css +167 -0
- package/corpus/templates/crm/app/hooks/use-keyboard-shortcuts.ts +206 -0
- package/corpus/templates/crm/app/hooks/use-navigation-state.ts +48 -0
- package/corpus/templates/crm/app/i18n/en-US.ts +684 -0
- package/corpus/templates/crm/app/i18n/index.ts +34 -0
- package/corpus/templates/crm/app/lib/dashboard.ts +13 -0
- package/corpus/templates/crm/app/lib/navigation.ts +17 -0
- package/corpus/templates/crm/app/lib/tab-id.ts +1 -0
- package/corpus/templates/crm/app/lib/types.ts +172 -0
- package/corpus/templates/crm/app/lib/utils.ts +1 -0
- package/corpus/templates/crm/app/root.tsx +93 -0
- package/corpus/templates/crm/app/routes/_index.tsx +26 -0
- package/corpus/templates/crm/app/routes/accounts.tsx +41 -0
- package/corpus/templates/crm/app/routes/agent.tsx +5 -0
- package/corpus/templates/crm/app/routes/ask.tsx +53 -0
- package/corpus/templates/crm/app/routes/dashboard.tsx +118 -0
- package/corpus/templates/crm/app/routes/lists.tsx +228 -0
- package/corpus/templates/crm/app/routes/opportunities.tsx +41 -0
- package/corpus/templates/crm/app/routes/people.tsx +41 -0
- package/corpus/templates/crm/app/routes/proposals.tsx +388 -0
- package/corpus/templates/crm/app/routes/records.$recordId.tsx +53 -0
- package/corpus/templates/crm/app/routes/records.tsx +64 -0
- package/corpus/templates/crm/app/routes/settings.tsx +118 -0
- package/corpus/templates/crm/app/routes/setup.tsx +308 -0
- package/corpus/templates/crm/app/routes/tasks.tsx +252 -0
- package/corpus/templates/crm/app/routes/views.tsx +683 -0
- package/corpus/templates/crm/app/routes.ts +19 -0
- package/corpus/templates/crm/app/vite-env.d.ts +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-any-list-or-view-can-be-shown-as-a-board-grouped-by-stage-so.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-crm-now-finds-likely-duplicate-records-and-tells-you-exactly.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-enrichment-now-shows-what-a-run-will-cost-before-it-starts-g.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-lists-turn-any-set-of-records-into-a-pipeline-with-its-own-s.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-moving-a-record-or-list-entry-into-a-stage-that-was-retired-.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-opening-a-record-now-shows-one-page-with-its-fields-the-list.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-press-cmd-k-to-jump-to-any-record-list-view-or-setting-and-u.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-provider-record-edits-now-show-an-exact-before-after-diff-an.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-record-page-attribute-labels-now-read-in-full-instead-of-bei.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-records-now-use-typed-fields-currency-dates-ratings-status-s.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-retyping-a-value-on-the-record-page-now-replaces-it-instead-.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-settings-now-has-fields-and-lists-tabs-for-adding-fields-edi.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-the-proposal-review-now-shows-the-field-that-actually-change.md +6 -0
- package/corpus/templates/crm/changelog/2026-07-26-the-record-grid-is-now-a-real-spreadsheet-filter-sort-and-pa.md +6 -0
- package/corpus/templates/crm/components.json +20 -0
- package/corpus/templates/crm/docs/architecture/crm-contract.md +214 -0
- package/corpus/templates/crm/docs/features/README.md +55 -0
- package/corpus/templates/crm/docs/features/f1-records-and-fields.mdx +52 -0
- package/corpus/templates/crm/docs/features/f2-lists-pipelines-and-views.mdx +48 -0
- package/corpus/templates/crm/docs/features/f3-work-and-record-quality.mdx +40 -0
- package/corpus/templates/crm/docs/features/f4-evidence-and-chat.mdx +47 -0
- package/corpus/templates/crm/learnings.defaults.md +5 -0
- package/corpus/templates/crm/netlify.toml +11 -0
- package/corpus/templates/crm/package.json +61 -0
- package/corpus/templates/crm/public/favicon.svg +1 -0
- package/corpus/templates/crm/public/icon-180.svg +1 -0
- package/corpus/templates/crm/public/manifest.json +11 -0
- package/corpus/templates/crm/react-router.config.ts +7 -0
- package/corpus/templates/crm/server/crm/adapter.ts +32 -0
- package/corpus/templates/crm/server/crm/crm-field-firewall.ts +64 -0
- package/corpus/templates/crm/server/crm/crm-mirror.ts +721 -0
- package/corpus/templates/crm/server/crm/field-policy-attributes.ts +48 -0
- package/corpus/templates/crm/server/crm/hubspot-adapter.ts +1146 -0
- package/corpus/templates/crm/server/crm/native-adapter.ts +1810 -0
- package/corpus/templates/crm/server/crm/provider-record-link.ts +264 -0
- package/corpus/templates/crm/server/crm/read-through.ts +207 -0
- package/corpus/templates/crm/server/crm/salesforce-adapter.ts +1255 -0
- package/corpus/templates/crm/server/db/crm-store.ts +1112 -0
- package/corpus/templates/crm/server/db/index.ts +191 -0
- package/corpus/templates/crm/server/db/schema.ts +647 -0
- package/corpus/templates/crm/server/lib/crm-query.ts +1558 -0
- package/corpus/templates/crm/server/lib/dedupe.ts +714 -0
- package/corpus/templates/crm/server/lib/enrichment-cost.ts +381 -0
- package/corpus/templates/crm/server/lib/enrichment-slots.ts +519 -0
- package/corpus/templates/crm/server/lib/intelligence/default-detectors.ts +65 -0
- package/corpus/templates/crm/server/lib/intelligence/evidence.ts +105 -0
- package/corpus/templates/crm/server/lib/intelligence/keyword-detector.ts +94 -0
- package/corpus/templates/crm/server/lib/intelligence/smart-detector.ts +39 -0
- package/corpus/templates/crm/server/lib/intelligence/summary.ts +19 -0
- package/corpus/templates/crm/server/lib/lifecycle.ts +634 -0
- package/corpus/templates/crm/server/lib/provider-api.ts +64 -0
- package/corpus/templates/crm/server/middleware/auth.ts +4 -0
- package/corpus/templates/crm/server/plugins/agent-chat.ts +65 -0
- package/corpus/templates/crm/server/plugins/auth.ts +14 -0
- package/corpus/templates/crm/server/plugins/core-routes.ts +17 -0
- package/corpus/templates/crm/server/plugins/db.ts +738 -0
- package/corpus/templates/crm/server/routes/[...page].get.ts +5 -0
- package/corpus/templates/crm/shared/crm-attributes.ts +469 -0
- package/corpus/templates/crm/shared/crm-automation-recipes.ts +132 -0
- package/corpus/templates/crm/shared/crm-contract.ts +417 -0
- package/corpus/templates/crm/shared/crm-navigation.ts +190 -0
- package/corpus/templates/crm/shared/crm-sales-config.ts +63 -0
- package/corpus/templates/crm/ssr-entry.ts +11 -0
- package/corpus/templates/crm/tsconfig.json +24 -0
- package/corpus/templates/crm/vite.config.ts +15 -0
- package/corpus/templates/crm/vitest.config.ts +5 -0
- package/corpus/templates/design/app/i18n-data.ts +12 -12
- package/corpus/templates/design/changelog/2026-07-26-apply-design-updates-from-a-centered-top-toolbar-without-cov.md +6 -0
- package/corpus/toolkit/CHANGELOG.md +6 -0
- package/corpus/toolkit/package.json +1 -1
- package/corpus/toolkit/src/editor/useCollabReconcile.ts +14 -1
- package/dist/cli/templates-meta.d.ts.map +1 -1
- package/dist/cli/templates-meta.js +12 -0
- package/dist/cli/templates-meta.js.map +1 -1
- package/dist/collab/routes.d.ts +2 -2
- package/dist/deploy/build.js +6 -0
- package/dist/deploy/build.js.map +1 -1
- package/dist/observability/routes.d.ts +3 -3
- package/dist/server/builder-browser.d.ts +13 -0
- package/dist/server/builder-browser.d.ts.map +1 -1
- package/dist/server/builder-browser.js +59 -0
- package/dist/server/builder-browser.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +10 -5
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/package.json +2 -2
- package/src/cli/templates-meta.ts +12 -0
- package/src/deploy/build.ts +8 -0
- package/src/server/builder-browser.ts +76 -0
- package/src/server/core-routes-plugin.ts +15 -5
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lists index. A list is the workflow overlay over one object type: its entries
|
|
3
|
+
* and their attribute values are local on every backend, so a pipeline works
|
|
4
|
+
* over a HubSpot or Salesforce mirror without a provider write.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
useActionMutation,
|
|
9
|
+
useActionQuery,
|
|
10
|
+
} from "@agent-native/core/client/hooks";
|
|
11
|
+
import { useT } from "@agent-native/core/client/i18n";
|
|
12
|
+
import { IconList, IconPlus } from "@tabler/icons-react";
|
|
13
|
+
import { useState } from "react";
|
|
14
|
+
import { Link, useNavigate } from "react-router";
|
|
15
|
+
import { toast } from "sonner";
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
LoadingRows,
|
|
19
|
+
PageHeader,
|
|
20
|
+
SetupEmptyState,
|
|
21
|
+
} from "@/components/crm/Surface";
|
|
22
|
+
import { Badge } from "@/components/ui/badge";
|
|
23
|
+
import { Button } from "@/components/ui/button";
|
|
24
|
+
import {
|
|
25
|
+
Dialog,
|
|
26
|
+
DialogContent,
|
|
27
|
+
DialogDescription,
|
|
28
|
+
DialogFooter,
|
|
29
|
+
DialogHeader,
|
|
30
|
+
DialogTitle,
|
|
31
|
+
DialogTrigger,
|
|
32
|
+
} from "@/components/ui/dialog";
|
|
33
|
+
import { Input } from "@/components/ui/input";
|
|
34
|
+
import { Label } from "@/components/ui/label";
|
|
35
|
+
import {
|
|
36
|
+
Select,
|
|
37
|
+
SelectContent,
|
|
38
|
+
SelectItem,
|
|
39
|
+
SelectTrigger,
|
|
40
|
+
SelectValue,
|
|
41
|
+
} from "@/components/ui/select";
|
|
42
|
+
|
|
43
|
+
interface ListsResponse {
|
|
44
|
+
lists: Array<{
|
|
45
|
+
id: string;
|
|
46
|
+
name: string;
|
|
47
|
+
description: string | null;
|
|
48
|
+
parentObjectType: string;
|
|
49
|
+
entryCount: number;
|
|
50
|
+
defaultViewId: string | null;
|
|
51
|
+
archived: boolean;
|
|
52
|
+
}>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const OBJECT_TYPES = ["accounts", "people", "opportunities"] as const;
|
|
56
|
+
|
|
57
|
+
/** Opens the list's default view, or an ad-hoc board when it has none. */
|
|
58
|
+
export function listHref(listId: string): string {
|
|
59
|
+
return `/views?list=${encodeURIComponent(listId)}`;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default function ListsRoute() {
|
|
63
|
+
const t = useT();
|
|
64
|
+
const query = useActionQuery<ListsResponse>(
|
|
65
|
+
"list-crm-lists" as never,
|
|
66
|
+
{ limit: 100 } as never,
|
|
67
|
+
);
|
|
68
|
+
const lists = query.data?.lists ?? [];
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<>
|
|
72
|
+
<PageHeader
|
|
73
|
+
eyebrow={t("lists.eyebrow")}
|
|
74
|
+
title={t("lists.title")}
|
|
75
|
+
description={t("lists.description")}
|
|
76
|
+
actions={<CreateListDialog onCreated={() => void query.refetch()} />}
|
|
77
|
+
/>
|
|
78
|
+
{query.isLoading ? (
|
|
79
|
+
<LoadingRows rows={5} />
|
|
80
|
+
) : query.error ? (
|
|
81
|
+
<div className="m-5 rounded-lg border border-border/70 bg-card p-4 sm:m-7">
|
|
82
|
+
<p className="text-sm text-muted-foreground">
|
|
83
|
+
{query.error instanceof Error
|
|
84
|
+
? query.error.message
|
|
85
|
+
: t("lists.loadFailed")}
|
|
86
|
+
</p>
|
|
87
|
+
<Button
|
|
88
|
+
size="sm"
|
|
89
|
+
variant="outline"
|
|
90
|
+
className="mt-3"
|
|
91
|
+
onClick={() => void query.refetch()}
|
|
92
|
+
>
|
|
93
|
+
{t("lists.retry")}
|
|
94
|
+
</Button>
|
|
95
|
+
</div>
|
|
96
|
+
) : lists.length ? (
|
|
97
|
+
<div className="grid gap-2 p-5 sm:grid-cols-2 sm:p-7 xl:grid-cols-3">
|
|
98
|
+
{lists.map((list) => (
|
|
99
|
+
<Link
|
|
100
|
+
key={list.id}
|
|
101
|
+
to={listHref(list.id)}
|
|
102
|
+
className="group rounded-lg border border-border/70 bg-card p-4 transition-colors hover:bg-muted/50"
|
|
103
|
+
>
|
|
104
|
+
<div className="flex items-start gap-3">
|
|
105
|
+
<IconList className="mt-0.5 size-4 text-muted-foreground" />
|
|
106
|
+
<div className="min-w-0 flex-1">
|
|
107
|
+
<p className="truncate text-sm font-medium">{list.name}</p>
|
|
108
|
+
{list.description ? (
|
|
109
|
+
<p className="mt-1 line-clamp-2 text-sm text-muted-foreground">
|
|
110
|
+
{list.description}
|
|
111
|
+
</p>
|
|
112
|
+
) : null}
|
|
113
|
+
<div className="mt-3 flex flex-wrap gap-2">
|
|
114
|
+
<Badge variant="secondary" className="font-normal">
|
|
115
|
+
{t("lists.entryCount", { count: list.entryCount })}
|
|
116
|
+
</Badge>
|
|
117
|
+
<Badge variant="outline" className="font-normal">
|
|
118
|
+
{list.parentObjectType}
|
|
119
|
+
</Badge>
|
|
120
|
+
</div>
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
123
|
+
</Link>
|
|
124
|
+
))}
|
|
125
|
+
</div>
|
|
126
|
+
) : (
|
|
127
|
+
<SetupEmptyState
|
|
128
|
+
title={t("lists.emptyTitle")}
|
|
129
|
+
description={t("lists.emptyDescription")}
|
|
130
|
+
/>
|
|
131
|
+
)}
|
|
132
|
+
</>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function CreateListDialog({ onCreated }: { onCreated: () => void }) {
|
|
137
|
+
const t = useT();
|
|
138
|
+
const navigate = useNavigate();
|
|
139
|
+
const [open, setOpen] = useState(false);
|
|
140
|
+
const [name, setName] = useState("");
|
|
141
|
+
const [description, setDescription] = useState("");
|
|
142
|
+
const [parentObjectType, setParentObjectType] = useState<string>("accounts");
|
|
143
|
+
const create = useActionMutation<{ id: string }, Record<string, unknown>>(
|
|
144
|
+
"create-crm-list" as never,
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
async function createList() {
|
|
148
|
+
try {
|
|
149
|
+
const list = await create.mutateAsync({
|
|
150
|
+
name: name.trim(),
|
|
151
|
+
parentObjectType,
|
|
152
|
+
...(description.trim() ? { description: description.trim() } : {}),
|
|
153
|
+
});
|
|
154
|
+
setOpen(false);
|
|
155
|
+
onCreated();
|
|
156
|
+
navigate(listHref(list.id));
|
|
157
|
+
} catch (error) {
|
|
158
|
+
toast.error(
|
|
159
|
+
error instanceof Error ? error.message : t("lists.createFailed"),
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return (
|
|
165
|
+
<Dialog open={open} onOpenChange={setOpen}>
|
|
166
|
+
<DialogTrigger asChild>
|
|
167
|
+
<Button size="sm" className="gap-2">
|
|
168
|
+
<IconPlus className="size-4" />
|
|
169
|
+
{t("lists.newList")}
|
|
170
|
+
</Button>
|
|
171
|
+
</DialogTrigger>
|
|
172
|
+
<DialogContent className="sm:max-w-lg">
|
|
173
|
+
<DialogHeader>
|
|
174
|
+
<DialogTitle>{t("lists.createTitle")}</DialogTitle>
|
|
175
|
+
<DialogDescription>{t("lists.createDescription")}</DialogDescription>
|
|
176
|
+
</DialogHeader>
|
|
177
|
+
<div className="grid gap-4 py-2">
|
|
178
|
+
<div className="grid gap-2">
|
|
179
|
+
<Label htmlFor="list-name">{t("lists.nameLabel")}</Label>
|
|
180
|
+
<Input
|
|
181
|
+
id="list-name"
|
|
182
|
+
value={name}
|
|
183
|
+
maxLength={120}
|
|
184
|
+
onChange={(event) => setName(event.target.value)}
|
|
185
|
+
/>
|
|
186
|
+
</div>
|
|
187
|
+
<div className="grid gap-2">
|
|
188
|
+
<Label htmlFor="list-object">{t("lists.objectTypeLabel")}</Label>
|
|
189
|
+
<Select
|
|
190
|
+
value={parentObjectType}
|
|
191
|
+
onValueChange={setParentObjectType}
|
|
192
|
+
>
|
|
193
|
+
<SelectTrigger id="list-object">
|
|
194
|
+
<SelectValue />
|
|
195
|
+
</SelectTrigger>
|
|
196
|
+
<SelectContent>
|
|
197
|
+
{OBJECT_TYPES.map((objectType) => (
|
|
198
|
+
<SelectItem key={objectType} value={objectType}>
|
|
199
|
+
{t(`lists.objectType.${objectType}`)}
|
|
200
|
+
</SelectItem>
|
|
201
|
+
))}
|
|
202
|
+
</SelectContent>
|
|
203
|
+
</Select>
|
|
204
|
+
</div>
|
|
205
|
+
<div className="grid gap-2">
|
|
206
|
+
<Label htmlFor="list-description">
|
|
207
|
+
{t("lists.descriptionLabel")}
|
|
208
|
+
</Label>
|
|
209
|
+
<Input
|
|
210
|
+
id="list-description"
|
|
211
|
+
value={description}
|
|
212
|
+
maxLength={500}
|
|
213
|
+
onChange={(event) => setDescription(event.target.value)}
|
|
214
|
+
/>
|
|
215
|
+
</div>
|
|
216
|
+
</div>
|
|
217
|
+
<DialogFooter>
|
|
218
|
+
<Button
|
|
219
|
+
disabled={!name.trim() || create.isPending}
|
|
220
|
+
onClick={() => void createList()}
|
|
221
|
+
>
|
|
222
|
+
{t("lists.createList")}
|
|
223
|
+
</Button>
|
|
224
|
+
</DialogFooter>
|
|
225
|
+
</DialogContent>
|
|
226
|
+
</Dialog>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useActionQuery } from "@agent-native/core/client/hooks";
|
|
2
|
+
import { useSearchParams } from "react-router";
|
|
3
|
+
|
|
4
|
+
import { CreateCrmRecordDialog } from "@/components/crm/CreateCrmRecordDialog";
|
|
5
|
+
import { RecordGrid } from "@/components/crm/RecordGrid";
|
|
6
|
+
import { SavedViewDataProgram } from "@/components/crm/SavedViewDataProgram";
|
|
7
|
+
import { PageHeader } from "@/components/crm/Surface";
|
|
8
|
+
import { normalizeRecords } from "@/lib/types";
|
|
9
|
+
|
|
10
|
+
export function meta() {
|
|
11
|
+
return [{ title: "Opportunities · CRM" }];
|
|
12
|
+
}
|
|
13
|
+
export default function OpportunitiesRoute() {
|
|
14
|
+
const [searchParams] = useSearchParams();
|
|
15
|
+
const viewId = searchParams.get("view") ?? undefined;
|
|
16
|
+
const query = useActionQuery<unknown>(
|
|
17
|
+
"list-crm-records" as never,
|
|
18
|
+
{ kind: "opportunity", viewId } as never,
|
|
19
|
+
);
|
|
20
|
+
return (
|
|
21
|
+
<>
|
|
22
|
+
<PageHeader
|
|
23
|
+
eyebrow="Records"
|
|
24
|
+
title="Opportunities"
|
|
25
|
+
description={
|
|
26
|
+
viewId
|
|
27
|
+
? "Opportunities matching this saved view."
|
|
28
|
+
: "Opportunities in your Native SQL workspace and connected CRM mirrors."
|
|
29
|
+
}
|
|
30
|
+
actions={<CreateCrmRecordDialog kind="opportunity" />}
|
|
31
|
+
/>
|
|
32
|
+
<SavedViewDataProgram data={query.data} />
|
|
33
|
+
<RecordGrid
|
|
34
|
+
kind="opportunity"
|
|
35
|
+
records={normalizeRecords(query.data, "opportunity")}
|
|
36
|
+
isLoading={query.isLoading}
|
|
37
|
+
emptyTitle="No opportunities yet"
|
|
38
|
+
/>
|
|
39
|
+
</>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useActionQuery } from "@agent-native/core/client/hooks";
|
|
2
|
+
import { useSearchParams } from "react-router";
|
|
3
|
+
|
|
4
|
+
import { CreateCrmRecordDialog } from "@/components/crm/CreateCrmRecordDialog";
|
|
5
|
+
import { RecordGrid } from "@/components/crm/RecordGrid";
|
|
6
|
+
import { SavedViewDataProgram } from "@/components/crm/SavedViewDataProgram";
|
|
7
|
+
import { PageHeader } from "@/components/crm/Surface";
|
|
8
|
+
import { normalizeRecords } from "@/lib/types";
|
|
9
|
+
|
|
10
|
+
export function meta() {
|
|
11
|
+
return [{ title: "People · CRM" }];
|
|
12
|
+
}
|
|
13
|
+
export default function PeopleRoute() {
|
|
14
|
+
const [searchParams] = useSearchParams();
|
|
15
|
+
const viewId = searchParams.get("view") ?? undefined;
|
|
16
|
+
const query = useActionQuery<unknown>(
|
|
17
|
+
"list-crm-records" as never,
|
|
18
|
+
{ kind: "person", viewId } as never,
|
|
19
|
+
);
|
|
20
|
+
return (
|
|
21
|
+
<>
|
|
22
|
+
<PageHeader
|
|
23
|
+
eyebrow="Records"
|
|
24
|
+
title="People"
|
|
25
|
+
description={
|
|
26
|
+
viewId
|
|
27
|
+
? "People matching this saved view."
|
|
28
|
+
: "People in your Native SQL workspace and connected CRM mirrors."
|
|
29
|
+
}
|
|
30
|
+
actions={<CreateCrmRecordDialog kind="person" />}
|
|
31
|
+
/>
|
|
32
|
+
<SavedViewDataProgram data={query.data} />
|
|
33
|
+
<RecordGrid
|
|
34
|
+
kind="person"
|
|
35
|
+
records={normalizeRecords(query.data, "person")}
|
|
36
|
+
isLoading={query.isLoading}
|
|
37
|
+
emptyTitle="No people yet"
|
|
38
|
+
/>
|
|
39
|
+
</>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useActionMutation,
|
|
3
|
+
useActionQuery,
|
|
4
|
+
} from "@agent-native/core/client/hooks";
|
|
5
|
+
import { useT } from "@agent-native/core/client/i18n";
|
|
6
|
+
import { IconExternalLink, IconShieldCheck } from "@tabler/icons-react";
|
|
7
|
+
import { useState } from "react";
|
|
8
|
+
import { Link } from "react-router";
|
|
9
|
+
import { toast } from "sonner";
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
LoadingRows,
|
|
13
|
+
PageHeader,
|
|
14
|
+
SetupEmptyState,
|
|
15
|
+
} from "@/components/crm/Surface";
|
|
16
|
+
import {
|
|
17
|
+
AlertDialog,
|
|
18
|
+
AlertDialogAction,
|
|
19
|
+
AlertDialogCancel,
|
|
20
|
+
AlertDialogContent,
|
|
21
|
+
AlertDialogDescription,
|
|
22
|
+
AlertDialogFooter,
|
|
23
|
+
AlertDialogHeader,
|
|
24
|
+
AlertDialogTitle,
|
|
25
|
+
AlertDialogTrigger,
|
|
26
|
+
} from "@/components/ui/alert-dialog";
|
|
27
|
+
import { Badge } from "@/components/ui/badge";
|
|
28
|
+
import { Button } from "@/components/ui/button";
|
|
29
|
+
|
|
30
|
+
interface ProposalField {
|
|
31
|
+
name: string;
|
|
32
|
+
before?: unknown;
|
|
33
|
+
after?: unknown;
|
|
34
|
+
beforeKnown?: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface ProposalPreview {
|
|
38
|
+
id: string;
|
|
39
|
+
recordId?: string;
|
|
40
|
+
recordName?: string;
|
|
41
|
+
provider?: string;
|
|
42
|
+
operation: string;
|
|
43
|
+
status: string;
|
|
44
|
+
risk?: string;
|
|
45
|
+
createdAt?: string;
|
|
46
|
+
appliedAt?: string;
|
|
47
|
+
recordUrl?: string;
|
|
48
|
+
recordUrlUnavailableReason?: string;
|
|
49
|
+
fields?: ProposalField[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
interface PreparedHandoff {
|
|
53
|
+
proposalId: string;
|
|
54
|
+
providerLabel: string;
|
|
55
|
+
recordUrl: string | null;
|
|
56
|
+
recordUrlUnavailableReason: string | null;
|
|
57
|
+
fields: Array<{
|
|
58
|
+
name: string;
|
|
59
|
+
beforeKnown: boolean;
|
|
60
|
+
before: unknown;
|
|
61
|
+
after: unknown;
|
|
62
|
+
}>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default function ProposalsRoute() {
|
|
66
|
+
const t = useT();
|
|
67
|
+
const query = useActionQuery<unknown>(
|
|
68
|
+
"list-crm-proposals" as never,
|
|
69
|
+
{ limit: 100 } as never,
|
|
70
|
+
);
|
|
71
|
+
const prepare = useActionMutation<PreparedHandoff, { proposalId: string }>(
|
|
72
|
+
"apply-crm-proposals" as never,
|
|
73
|
+
);
|
|
74
|
+
const proposals = normalizeProposals(query.data);
|
|
75
|
+
const [preparingIds, setPreparingIds] = useState<Set<string>>(new Set());
|
|
76
|
+
|
|
77
|
+
async function prepareHandoff(proposal: ProposalPreview) {
|
|
78
|
+
setPreparingIds((current) => new Set(current).add(proposal.id));
|
|
79
|
+
try {
|
|
80
|
+
const handoff = await prepare.mutateAsync({ proposalId: proposal.id });
|
|
81
|
+
await query.refetch();
|
|
82
|
+
// Never phrased as a completed upstream write, and never as a failure.
|
|
83
|
+
toast.info(
|
|
84
|
+
t("proposals.preparedToast", { provider: handoff.providerLabel }),
|
|
85
|
+
);
|
|
86
|
+
} catch (error) {
|
|
87
|
+
toast.error(
|
|
88
|
+
error instanceof Error
|
|
89
|
+
? error.message
|
|
90
|
+
: t("proposals.prepareFailedToast"),
|
|
91
|
+
);
|
|
92
|
+
} finally {
|
|
93
|
+
setPreparingIds((current) => {
|
|
94
|
+
const next = new Set(current);
|
|
95
|
+
next.delete(proposal.id);
|
|
96
|
+
return next;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<>
|
|
103
|
+
<PageHeader
|
|
104
|
+
eyebrow={t("proposals.eyebrow")}
|
|
105
|
+
title={t("proposals.title")}
|
|
106
|
+
description={t("proposals.description")}
|
|
107
|
+
/>
|
|
108
|
+
{query.isLoading ? (
|
|
109
|
+
<LoadingRows rows={6} />
|
|
110
|
+
) : proposals.length ? (
|
|
111
|
+
<div className="grid gap-3 p-5 sm:p-7">
|
|
112
|
+
{proposals.map((proposal) => (
|
|
113
|
+
<section
|
|
114
|
+
key={proposal.id}
|
|
115
|
+
className="rounded-lg border border-border/70 bg-card p-4"
|
|
116
|
+
>
|
|
117
|
+
<div className="flex flex-wrap items-start justify-between gap-3">
|
|
118
|
+
<div>
|
|
119
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
120
|
+
<p className="text-sm font-medium">
|
|
121
|
+
{proposal.recordName || t("proposals.untitledRecord")}
|
|
122
|
+
</p>
|
|
123
|
+
<Badge variant="secondary" className="font-normal">
|
|
124
|
+
{t(`proposals.status.${statusKey(proposal)}`)}
|
|
125
|
+
</Badge>
|
|
126
|
+
{proposal.risk ? (
|
|
127
|
+
<Badge
|
|
128
|
+
variant="outline"
|
|
129
|
+
className="font-normal capitalize"
|
|
130
|
+
>
|
|
131
|
+
{proposal.risk}
|
|
132
|
+
</Badge>
|
|
133
|
+
) : null}
|
|
134
|
+
</div>
|
|
135
|
+
<p className="mt-1 text-xs text-muted-foreground">
|
|
136
|
+
{proposal.operation}
|
|
137
|
+
{proposal.createdAt
|
|
138
|
+
? ` · ${formatDate(proposal.createdAt)}`
|
|
139
|
+
: ""}
|
|
140
|
+
</p>
|
|
141
|
+
</div>
|
|
142
|
+
<div className="flex items-center gap-2">
|
|
143
|
+
{proposal.recordId ? (
|
|
144
|
+
<Button
|
|
145
|
+
asChild
|
|
146
|
+
variant="ghost"
|
|
147
|
+
size="sm"
|
|
148
|
+
className="gap-1.5"
|
|
149
|
+
>
|
|
150
|
+
<Link
|
|
151
|
+
to={`/records/${encodeURIComponent(proposal.recordId)}`}
|
|
152
|
+
>
|
|
153
|
+
{t("proposals.openRecord")}
|
|
154
|
+
<IconExternalLink className="size-3.5" />
|
|
155
|
+
</Link>
|
|
156
|
+
</Button>
|
|
157
|
+
) : null}
|
|
158
|
+
{proposal.status === "pending" ? (
|
|
159
|
+
<PrepareButton
|
|
160
|
+
proposal={proposal}
|
|
161
|
+
pending={preparingIds.has(proposal.id)}
|
|
162
|
+
onPrepare={() => void prepareHandoff(proposal)}
|
|
163
|
+
/>
|
|
164
|
+
) : proposal.recordUrl ? (
|
|
165
|
+
<Button asChild size="sm" className="gap-1.5">
|
|
166
|
+
<a
|
|
167
|
+
href={proposal.recordUrl}
|
|
168
|
+
target="_blank"
|
|
169
|
+
rel="noopener noreferrer"
|
|
170
|
+
>
|
|
171
|
+
{t("proposals.completeUpstream", {
|
|
172
|
+
provider: providerLabel(proposal.provider),
|
|
173
|
+
})}
|
|
174
|
+
<IconExternalLink className="size-3.5" />
|
|
175
|
+
</a>
|
|
176
|
+
</Button>
|
|
177
|
+
) : null}
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
{proposal.status === "approved" && !proposal.appliedAt ? (
|
|
181
|
+
<p className="mt-3 text-xs text-muted-foreground">
|
|
182
|
+
{t("proposals.handedOffNote", {
|
|
183
|
+
provider: providerLabel(proposal.provider),
|
|
184
|
+
})}
|
|
185
|
+
</p>
|
|
186
|
+
) : null}
|
|
187
|
+
{proposal.recordUrl ||
|
|
188
|
+
proposal.status === "pending" ||
|
|
189
|
+
!proposal.recordUrlUnavailableReason ? null : (
|
|
190
|
+
<p className="mt-3 text-xs text-muted-foreground">
|
|
191
|
+
{t("proposals.recordLinkUnavailable", {
|
|
192
|
+
provider: providerLabel(proposal.provider),
|
|
193
|
+
reason: proposal.recordUrlUnavailableReason,
|
|
194
|
+
})}
|
|
195
|
+
</p>
|
|
196
|
+
)}
|
|
197
|
+
<ProposalFields fields={proposal.fields} />
|
|
198
|
+
</section>
|
|
199
|
+
))}
|
|
200
|
+
</div>
|
|
201
|
+
) : (
|
|
202
|
+
<SetupEmptyState
|
|
203
|
+
title={t("proposals.emptyTitle")}
|
|
204
|
+
description={t("proposals.emptyDescription")}
|
|
205
|
+
/>
|
|
206
|
+
)}
|
|
207
|
+
</>
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function PrepareButton({
|
|
212
|
+
proposal,
|
|
213
|
+
pending,
|
|
214
|
+
onPrepare,
|
|
215
|
+
}: {
|
|
216
|
+
proposal: ProposalPreview;
|
|
217
|
+
pending: boolean;
|
|
218
|
+
onPrepare: () => void;
|
|
219
|
+
}) {
|
|
220
|
+
const t = useT();
|
|
221
|
+
const provider = providerLabel(proposal.provider);
|
|
222
|
+
return (
|
|
223
|
+
<AlertDialog>
|
|
224
|
+
<AlertDialogTrigger asChild>
|
|
225
|
+
<Button size="sm" className="gap-1.5" disabled={pending}>
|
|
226
|
+
<IconShieldCheck className="size-4" />{" "}
|
|
227
|
+
{t("proposals.prepareChange", { provider })}
|
|
228
|
+
</Button>
|
|
229
|
+
</AlertDialogTrigger>
|
|
230
|
+
<AlertDialogContent>
|
|
231
|
+
<AlertDialogHeader>
|
|
232
|
+
<AlertDialogTitle>
|
|
233
|
+
{t("proposals.prepareTitle", { provider })}
|
|
234
|
+
</AlertDialogTitle>
|
|
235
|
+
<AlertDialogDescription>
|
|
236
|
+
{t("proposals.prepareDescription", {
|
|
237
|
+
provider,
|
|
238
|
+
record: proposal.recordName || t("proposals.untitledRecord"),
|
|
239
|
+
})}
|
|
240
|
+
</AlertDialogDescription>
|
|
241
|
+
</AlertDialogHeader>
|
|
242
|
+
<ProposalFields fields={proposal.fields} />
|
|
243
|
+
{proposal.recordUrl || !proposal.recordUrlUnavailableReason ? null : (
|
|
244
|
+
<p className="text-sm text-muted-foreground">
|
|
245
|
+
{t("proposals.recordLinkUnavailable", {
|
|
246
|
+
provider,
|
|
247
|
+
reason: proposal.recordUrlUnavailableReason,
|
|
248
|
+
})}
|
|
249
|
+
</p>
|
|
250
|
+
)}
|
|
251
|
+
<AlertDialogFooter>
|
|
252
|
+
<AlertDialogCancel>{t("proposals.cancel")}</AlertDialogCancel>
|
|
253
|
+
{/* The upstream tab has to open from the click itself — opening it
|
|
254
|
+
after the prepare round-trip trips popup blockers. */}
|
|
255
|
+
{proposal.recordUrl ? (
|
|
256
|
+
<AlertDialogAction asChild>
|
|
257
|
+
<a
|
|
258
|
+
href={proposal.recordUrl}
|
|
259
|
+
target="_blank"
|
|
260
|
+
rel="noopener noreferrer"
|
|
261
|
+
onClick={onPrepare}
|
|
262
|
+
>
|
|
263
|
+
{t("proposals.prepareAndOpen", { provider })}
|
|
264
|
+
</a>
|
|
265
|
+
</AlertDialogAction>
|
|
266
|
+
) : (
|
|
267
|
+
<AlertDialogAction onClick={onPrepare}>
|
|
268
|
+
{t("proposals.prepareWithoutLink")}
|
|
269
|
+
</AlertDialogAction>
|
|
270
|
+
)}
|
|
271
|
+
</AlertDialogFooter>
|
|
272
|
+
</AlertDialogContent>
|
|
273
|
+
</AlertDialog>
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function ProposalFields({ fields }: { fields?: ProposalField[] }) {
|
|
278
|
+
const t = useT();
|
|
279
|
+
if (!fields?.length) {
|
|
280
|
+
return (
|
|
281
|
+
<p className="mt-4 text-sm text-muted-foreground">
|
|
282
|
+
{t("proposals.fieldPreviewUnavailable")}
|
|
283
|
+
</p>
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
return (
|
|
287
|
+
<dl className="mt-4 divide-y divide-border/70 overflow-x-auto rounded-md border border-border/70">
|
|
288
|
+
{fields.slice(0, 20).map((field) => (
|
|
289
|
+
<div
|
|
290
|
+
key={field.name}
|
|
291
|
+
className="grid grid-cols-[8rem_1fr_1fr] gap-3 px-3 py-2 text-sm"
|
|
292
|
+
>
|
|
293
|
+
<dt className="truncate text-muted-foreground">{field.name}</dt>
|
|
294
|
+
<dd className="break-words text-muted-foreground">
|
|
295
|
+
{field.beforeKnown === false
|
|
296
|
+
? t("proposals.notMirrored")
|
|
297
|
+
: displayValue(field.before, t)}
|
|
298
|
+
</dd>
|
|
299
|
+
<dd className="break-words font-medium">
|
|
300
|
+
{displayValue(field.after, t)}
|
|
301
|
+
</dd>
|
|
302
|
+
</div>
|
|
303
|
+
))}
|
|
304
|
+
</dl>
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* `approved` without `appliedAt` is a prepared handoff, not an upstream write.
|
|
310
|
+
* Labelling it "Approved" would read as done.
|
|
311
|
+
*/
|
|
312
|
+
function statusKey(proposal: ProposalPreview) {
|
|
313
|
+
if (proposal.status === "approved" && !proposal.appliedAt) return "prepared";
|
|
314
|
+
return proposal.status;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function providerLabel(provider?: string) {
|
|
318
|
+
return provider === "salesforce" ? "Salesforce" : "HubSpot";
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function normalizeProposals(data: unknown): ProposalPreview[] {
|
|
322
|
+
const rows =
|
|
323
|
+
isObject(data) && Array.isArray(data.proposals) ? data.proposals : [];
|
|
324
|
+
return rows.flatMap((row) => {
|
|
325
|
+
if (!isObject(row) || typeof row.id !== "string") return [];
|
|
326
|
+
const fields = Array.isArray(row.fields)
|
|
327
|
+
? row.fields.flatMap((field) =>
|
|
328
|
+
isObject(field) && typeof field.name === "string"
|
|
329
|
+
? [
|
|
330
|
+
{
|
|
331
|
+
name: field.name,
|
|
332
|
+
before: field.before,
|
|
333
|
+
after: field.after,
|
|
334
|
+
...(typeof field.beforeKnown === "boolean"
|
|
335
|
+
? { beforeKnown: field.beforeKnown }
|
|
336
|
+
: {}),
|
|
337
|
+
},
|
|
338
|
+
]
|
|
339
|
+
: [],
|
|
340
|
+
)
|
|
341
|
+
: undefined;
|
|
342
|
+
return [
|
|
343
|
+
{
|
|
344
|
+
id: row.id,
|
|
345
|
+
recordId: typeof row.recordId === "string" ? row.recordId : undefined,
|
|
346
|
+
recordName:
|
|
347
|
+
typeof row.recordName === "string" ? row.recordName : undefined,
|
|
348
|
+
provider: typeof row.provider === "string" ? row.provider : undefined,
|
|
349
|
+
operation: typeof row.operation === "string" ? row.operation : "update",
|
|
350
|
+
status: typeof row.status === "string" ? row.status : "pending",
|
|
351
|
+
risk: typeof row.risk === "string" ? row.risk : undefined,
|
|
352
|
+
createdAt:
|
|
353
|
+
typeof row.createdAt === "string" ? row.createdAt : undefined,
|
|
354
|
+
appliedAt:
|
|
355
|
+
typeof row.appliedAt === "string" ? row.appliedAt : undefined,
|
|
356
|
+
recordUrl:
|
|
357
|
+
typeof row.recordUrl === "string" ? row.recordUrl : undefined,
|
|
358
|
+
recordUrlUnavailableReason:
|
|
359
|
+
typeof row.recordUrlUnavailableReason === "string"
|
|
360
|
+
? row.recordUrlUnavailableReason
|
|
361
|
+
: undefined,
|
|
362
|
+
fields,
|
|
363
|
+
},
|
|
364
|
+
];
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
function isObject(value: unknown): value is Record<string, unknown> {
|
|
369
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function displayValue(
|
|
373
|
+
value: unknown,
|
|
374
|
+
t: (key: string, options?: Record<string, unknown>) => string,
|
|
375
|
+
) {
|
|
376
|
+
if (value === null || value === undefined || value === "")
|
|
377
|
+
return t("proposals.emptyValue");
|
|
378
|
+
if (typeof value === "string" || typeof value === "number")
|
|
379
|
+
return String(value);
|
|
380
|
+
if (typeof value === "boolean")
|
|
381
|
+
return value ? t("proposals.booleanTrue") : t("proposals.booleanFalse");
|
|
382
|
+
return t("proposals.structuredValue");
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function formatDate(value: string) {
|
|
386
|
+
const date = new Date(value);
|
|
387
|
+
return Number.isNaN(date.valueOf()) ? value : date.toLocaleString();
|
|
388
|
+
}
|