@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,647 @@
|
|
|
1
|
+
import { createDashboardStorageSchema } from "@agent-native/core/dashboard-storage";
|
|
2
|
+
import { getDialect } from "@agent-native/core/db";
|
|
3
|
+
import {
|
|
4
|
+
createSharesTable,
|
|
5
|
+
integer,
|
|
6
|
+
now,
|
|
7
|
+
ownableColumns,
|
|
8
|
+
real,
|
|
9
|
+
table,
|
|
10
|
+
text,
|
|
11
|
+
} from "@agent-native/core/db/schema";
|
|
12
|
+
import { customType as pgCustomType } from "drizzle-orm/pg-core";
|
|
13
|
+
import { integer as sqliteInteger } from "drizzle-orm/sqlite-core";
|
|
14
|
+
|
|
15
|
+
import { CRM_ATTRIBUTE_TYPES } from "../../shared/crm-attributes.js";
|
|
16
|
+
|
|
17
|
+
const pgIntegerBoolean = pgCustomType<{
|
|
18
|
+
data: boolean;
|
|
19
|
+
driverData: number;
|
|
20
|
+
}>({
|
|
21
|
+
dataType: () => "integer",
|
|
22
|
+
fromDriver: (value) => value !== 0,
|
|
23
|
+
toDriver: (value) => (value ? 1 : 0),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const sqliteBoolean = <TName extends string>(name: TName) =>
|
|
27
|
+
sqliteInteger(name, { mode: "boolean" });
|
|
28
|
+
|
|
29
|
+
const portableBoolean: typeof sqliteBoolean = ((name: string) =>
|
|
30
|
+
getDialect() === "postgres"
|
|
31
|
+
? pgIntegerBoolean(name)
|
|
32
|
+
: sqliteBoolean(name)) as unknown as typeof sqliteBoolean;
|
|
33
|
+
|
|
34
|
+
export const crmConnections = table("crm_connections", {
|
|
35
|
+
id: text("id").primaryKey(),
|
|
36
|
+
provider: text("provider", {
|
|
37
|
+
enum: ["hubspot", "salesforce", "native", "custom"],
|
|
38
|
+
}).notNull(),
|
|
39
|
+
workspaceConnectionId: text("workspace_connection_id"),
|
|
40
|
+
label: text("label").notNull(),
|
|
41
|
+
accountId: text("account_id"),
|
|
42
|
+
// `hybrid` is deprecated — kept so existing rows stay valid, treated as
|
|
43
|
+
// `mirrored`. Per-attribute `authority` replaced it. See shared/crm-contract.ts.
|
|
44
|
+
mode: text("mode", { enum: ["connected", "hybrid", "native"] })
|
|
45
|
+
.notNull()
|
|
46
|
+
.default("connected"),
|
|
47
|
+
status: text("status", {
|
|
48
|
+
enum: ["connected", "syncing", "error", "disconnected"],
|
|
49
|
+
})
|
|
50
|
+
.notNull()
|
|
51
|
+
.default("connected"),
|
|
52
|
+
selectedPipelinesJson: text("selected_pipelines_json")
|
|
53
|
+
.notNull()
|
|
54
|
+
.default("[]"),
|
|
55
|
+
selectedObjectTypesJson: text("selected_object_types_json")
|
|
56
|
+
.notNull()
|
|
57
|
+
.default("[]"),
|
|
58
|
+
accessScopeKey: text("access_scope_key").notNull(),
|
|
59
|
+
accessScopeJson: text("access_scope_json").notNull().default("{}"),
|
|
60
|
+
lastSyncedAt: text("last_synced_at"),
|
|
61
|
+
lastError: text("last_error"),
|
|
62
|
+
createdAt: text("created_at").notNull().default(now()),
|
|
63
|
+
updatedAt: text("updated_at").notNull().default(now()),
|
|
64
|
+
...ownableColumns(),
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export const crmConnectionShares = createSharesTable("crm_connection_shares");
|
|
68
|
+
|
|
69
|
+
export const crmObjects = table("crm_objects", {
|
|
70
|
+
id: text("id").primaryKey(),
|
|
71
|
+
connectionId: text("connection_id").notNull(),
|
|
72
|
+
provider: text("provider").notNull(),
|
|
73
|
+
objectType: text("object_type").notNull(),
|
|
74
|
+
kind: text("kind", {
|
|
75
|
+
enum: ["account", "person", "opportunity", "activity", "task", "custom"],
|
|
76
|
+
}).notNull(),
|
|
77
|
+
label: text("label").notNull(),
|
|
78
|
+
pluralLabel: text("plural_label").notNull(),
|
|
79
|
+
custom: portableBoolean("custom").notNull().default(false),
|
|
80
|
+
queryable: portableBoolean("queryable").notNull().default(true),
|
|
81
|
+
searchable: portableBoolean("searchable").notNull().default(true),
|
|
82
|
+
createable: portableBoolean("createable").notNull().default(false),
|
|
83
|
+
updateable: portableBoolean("updateable").notNull().default(false),
|
|
84
|
+
deleteable: portableBoolean("deleteable").notNull().default(false),
|
|
85
|
+
capabilitiesJson: text("capabilities_json").notNull().default("{}"),
|
|
86
|
+
createdAt: text("created_at").notNull().default(now()),
|
|
87
|
+
updatedAt: text("updated_at").notNull().default(now()),
|
|
88
|
+
...ownableColumns(),
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export const crmObjectShares = createSharesTable("crm_object_shares");
|
|
92
|
+
|
|
93
|
+
export const crmFieldPolicies = table("crm_field_policies", {
|
|
94
|
+
id: text("id").primaryKey(),
|
|
95
|
+
connectionId: text("connection_id").notNull(),
|
|
96
|
+
objectType: text("object_type").notNull(),
|
|
97
|
+
fieldName: text("field_name").notNull(),
|
|
98
|
+
label: text("label").notNull(),
|
|
99
|
+
valueType: text("value_type").notNull(),
|
|
100
|
+
storagePolicy: text("storage_policy", {
|
|
101
|
+
enum: [
|
|
102
|
+
"mirrored",
|
|
103
|
+
"remote-only",
|
|
104
|
+
"redacted",
|
|
105
|
+
"derived-local",
|
|
106
|
+
"local-authoritative",
|
|
107
|
+
],
|
|
108
|
+
})
|
|
109
|
+
.notNull()
|
|
110
|
+
.default("remote-only"),
|
|
111
|
+
sensitive: portableBoolean("sensitive").notNull().default(false),
|
|
112
|
+
readable: portableBoolean("readable").notNull().default(true),
|
|
113
|
+
createable: portableBoolean("createable").notNull().default(false),
|
|
114
|
+
updateable: portableBoolean("updateable").notNull().default(false),
|
|
115
|
+
required: portableBoolean("required").notNull().default(false),
|
|
116
|
+
metadataJson: text("metadata_json").notNull().default("{}"),
|
|
117
|
+
// --- typed attribute surface (additive; `crm_field_policies` IS the attribute table) ---
|
|
118
|
+
attributeType: text("attribute_type", { enum: CRM_ATTRIBUTE_TYPES })
|
|
119
|
+
.notNull()
|
|
120
|
+
.default("text"),
|
|
121
|
+
target: text("target", { enum: ["object", "list"] })
|
|
122
|
+
.notNull()
|
|
123
|
+
.default("object"),
|
|
124
|
+
// `object_type` deliberately mirrors `target_id` for list attributes too, so
|
|
125
|
+
// the legacy unique index (connection_id, object_type, field_name) keeps
|
|
126
|
+
// guarding one attribute per target without a second unique index.
|
|
127
|
+
targetId: text("target_id"),
|
|
128
|
+
apiSlug: text("api_slug"),
|
|
129
|
+
description: text("description"),
|
|
130
|
+
multi: portableBoolean("multi").notNull().default(false),
|
|
131
|
+
inverseAttributeId: text("inverse_attribute_id"),
|
|
132
|
+
authority: text("authority", {
|
|
133
|
+
enum: ["provider", "derived-local", "local-authoritative"],
|
|
134
|
+
})
|
|
135
|
+
.notNull()
|
|
136
|
+
.default("provider"),
|
|
137
|
+
historyTracked: portableBoolean("history_tracked").notNull().default(true),
|
|
138
|
+
fillMode: text("fill_mode", {
|
|
139
|
+
enum: ["agent-summarize", "agent-classify", "agent-research", "formula"],
|
|
140
|
+
}),
|
|
141
|
+
fillConfigJson: text("fill_config_json").notNull().default("{}"),
|
|
142
|
+
configJson: text("config_json").notNull().default("{}"),
|
|
143
|
+
uniqueValue: portableBoolean("unique_value").notNull().default(false),
|
|
144
|
+
archived: portableBoolean("archived").notNull().default(false),
|
|
145
|
+
position: integer("position").notNull().default(0),
|
|
146
|
+
createdAt: text("created_at").notNull().default(now()),
|
|
147
|
+
updatedAt: text("updated_at").notNull().default(now()),
|
|
148
|
+
...ownableColumns(),
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
export const crmFieldPolicyShares = createSharesTable(
|
|
152
|
+
"crm_field_policy_shares",
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
export const crmAttributeOptions = table("crm_attribute_options", {
|
|
156
|
+
id: text("id").primaryKey(),
|
|
157
|
+
attributeId: text("attribute_id").notNull(),
|
|
158
|
+
value: text("value").notNull(),
|
|
159
|
+
title: text("title").notNull(),
|
|
160
|
+
color: text("color"),
|
|
161
|
+
position: integer("position").notNull().default(0),
|
|
162
|
+
archived: portableBoolean("archived").notNull().default(false),
|
|
163
|
+
/** `status` attributes only: stage SLA in days. */
|
|
164
|
+
targetDays: integer("target_days"),
|
|
165
|
+
/** `status` attributes only. */
|
|
166
|
+
celebrate: portableBoolean("celebrate").notNull().default(false),
|
|
167
|
+
createdAt: text("created_at").notNull().default(now()),
|
|
168
|
+
updatedAt: text("updated_at").notNull().default(now()),
|
|
169
|
+
...ownableColumns(),
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
export const crmAttributeOptionShares = createSharesTable(
|
|
173
|
+
"crm_attribute_option_shares",
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
export const crmRecords = table("crm_records", {
|
|
177
|
+
id: text("id").primaryKey(),
|
|
178
|
+
connectionId: text("connection_id").notNull(),
|
|
179
|
+
provider: text("provider").notNull(),
|
|
180
|
+
objectType: text("object_type").notNull(),
|
|
181
|
+
kind: text("kind", {
|
|
182
|
+
enum: ["account", "person", "opportunity", "activity", "task", "custom"],
|
|
183
|
+
}).notNull(),
|
|
184
|
+
remoteId: text("remote_id").notNull(),
|
|
185
|
+
displayName: text("display_name").notNull(),
|
|
186
|
+
primaryEmail: text("primary_email"),
|
|
187
|
+
domain: text("domain"),
|
|
188
|
+
stage: text("stage"),
|
|
189
|
+
pipelineId: text("pipeline_id"),
|
|
190
|
+
pipelineName: text("pipeline_name"),
|
|
191
|
+
ownerRemoteId: text("owner_remote_id"),
|
|
192
|
+
ownerName: text("owner_name"),
|
|
193
|
+
amount: real("amount"),
|
|
194
|
+
currencyCode: text("currency_code"),
|
|
195
|
+
closeDate: text("close_date"),
|
|
196
|
+
desiredCadenceDays: integer("desired_cadence_days"),
|
|
197
|
+
lastMeaningfulInteractionAt: text("last_meaningful_interaction_at"),
|
|
198
|
+
nextContactAt: text("next_contact_at"),
|
|
199
|
+
remoteRevision: text("remote_revision"),
|
|
200
|
+
remoteUpdatedAt: text("remote_updated_at"),
|
|
201
|
+
lastSyncedAt: text("last_synced_at"),
|
|
202
|
+
accessScopeKey: text("access_scope_key").notNull(),
|
|
203
|
+
accessScopeJson: text("access_scope_json").notNull().default("{}"),
|
|
204
|
+
tombstone: portableBoolean("tombstone").notNull().default(false),
|
|
205
|
+
createdAt: text("created_at").notNull().default(now()),
|
|
206
|
+
updatedAt: text("updated_at").notNull().default(now()),
|
|
207
|
+
...ownableColumns(),
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
export const crmRecordShares = createSharesTable("crm_record_shares");
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Bitemporal attribute values. The current value of an attribute is the row
|
|
214
|
+
* with `activeUntil IS NULL`; every superseded value keeps its own row with the
|
|
215
|
+
* instant it stopped being current. All writes go through
|
|
216
|
+
* `server/lib/record-fields.ts` — a direct insert here bypasses the equality
|
|
217
|
+
* check that keeps mirror syncs from writing a new history row every pass.
|
|
218
|
+
*/
|
|
219
|
+
export const crmRecordFields = table("crm_record_fields", {
|
|
220
|
+
id: text("id").primaryKey(),
|
|
221
|
+
recordId: text("record_id").notNull(),
|
|
222
|
+
/**
|
|
223
|
+
* Set when this row holds a LIST-ENTRY attribute value rather than a record
|
|
224
|
+
* attribute value. `recordId` stays populated either way (it is NOT NULL and
|
|
225
|
+
* cannot be loosened additively), so the discriminator is `entryId IS NULL`.
|
|
226
|
+
*/
|
|
227
|
+
entryId: text("entry_id"),
|
|
228
|
+
fieldPolicyId: text("field_policy_id"),
|
|
229
|
+
attributeId: text("attribute_id"),
|
|
230
|
+
fieldName: text("field_name").notNull(),
|
|
231
|
+
valueType: text("value_type").notNull(),
|
|
232
|
+
storagePolicy: text("storage_policy", {
|
|
233
|
+
enum: ["mirrored", "derived-local", "local-authoritative"],
|
|
234
|
+
}).notNull(),
|
|
235
|
+
stringValue: text("string_value"),
|
|
236
|
+
numberValue: real("number_value"),
|
|
237
|
+
booleanValue: portableBoolean("boolean_value"),
|
|
238
|
+
jsonValue: text("json_value"),
|
|
239
|
+
// ISO 8601, not the `datetime('now')` SQL default the older timestamp columns
|
|
240
|
+
// use: this column is ordered against `activeUntil` in history queries, and
|
|
241
|
+
// `"… 20:56:04"` sorts before `"…T20:56:04Z"` for the same instant.
|
|
242
|
+
activeFrom: text("active_from")
|
|
243
|
+
.notNull()
|
|
244
|
+
.$defaultFn(() => new Date().toISOString()),
|
|
245
|
+
/** Null means this row is the current value. */
|
|
246
|
+
activeUntil: text("active_until"),
|
|
247
|
+
actorType: text("actor_type", {
|
|
248
|
+
enum: ["user", "agent", "automation", "provider", "system"],
|
|
249
|
+
})
|
|
250
|
+
.notNull()
|
|
251
|
+
.default("system"),
|
|
252
|
+
actorId: text("actor_id"),
|
|
253
|
+
// Sparse composite sub-fields. Columns, not json_extract: a WHERE clause over
|
|
254
|
+
// JSON is dialect-divergent, and these are what the grid filters on.
|
|
255
|
+
emailLocal: text("email_local"),
|
|
256
|
+
emailDomain: text("email_domain"),
|
|
257
|
+
emailRootDomain: text("email_root_domain"),
|
|
258
|
+
phoneE164: text("phone_e164"),
|
|
259
|
+
phoneCountry: text("phone_country"),
|
|
260
|
+
domainRoot: text("domain_root"),
|
|
261
|
+
nameFirst: text("name_first"),
|
|
262
|
+
nameLast: text("name_last"),
|
|
263
|
+
provenanceJson: text("provenance_json").notNull().default("[]"),
|
|
264
|
+
accessScopeKey: text("access_scope_key").notNull().default("unverified"),
|
|
265
|
+
accessScopeJson: text("access_scope_json").notNull().default("{}"),
|
|
266
|
+
remoteRevision: text("remote_revision"),
|
|
267
|
+
createdAt: text("created_at").notNull().default(now()),
|
|
268
|
+
updatedAt: text("updated_at").notNull().default(now()),
|
|
269
|
+
...ownableColumns(),
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
export const crmRecordFieldShares = createSharesTable(
|
|
273
|
+
"crm_record_field_shares",
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Lists are local-authoritative on every backend, including HubSpot and
|
|
278
|
+
* Salesforce. `source: "imported"` records where a list came from; it never
|
|
279
|
+
* makes the provider authoritative for its membership.
|
|
280
|
+
*/
|
|
281
|
+
export const crmLists = table("crm_lists", {
|
|
282
|
+
id: text("id").primaryKey(),
|
|
283
|
+
connectionId: text("connection_id").notNull(),
|
|
284
|
+
name: text("name").notNull(),
|
|
285
|
+
apiSlug: text("api_slug").notNull(),
|
|
286
|
+
parentObjectType: text("parent_object_type").notNull(),
|
|
287
|
+
description: text("description").notNull().default(""),
|
|
288
|
+
defaultViewId: text("default_view_id"),
|
|
289
|
+
archived: portableBoolean("archived").notNull().default(false),
|
|
290
|
+
position: integer("position").notNull().default(0),
|
|
291
|
+
source: text("source", { enum: ["local", "imported"] })
|
|
292
|
+
.notNull()
|
|
293
|
+
.default("local"),
|
|
294
|
+
sourceRemoteId: text("source_remote_id"),
|
|
295
|
+
lastSyncedAt: text("last_synced_at"),
|
|
296
|
+
createdAt: text("created_at").notNull().default(now()),
|
|
297
|
+
updatedAt: text("updated_at").notNull().default(now()),
|
|
298
|
+
...ownableColumns(),
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
export const crmListShares = createSharesTable("crm_list_shares");
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* A record may hold more than one entry in the same list (two open renewals for
|
|
305
|
+
* one account, say), so there is deliberately no unique `(list_id, record_id)`.
|
|
306
|
+
*/
|
|
307
|
+
export const crmListEntries = table("crm_list_entries", {
|
|
308
|
+
id: text("id").primaryKey(),
|
|
309
|
+
listId: text("list_id").notNull(),
|
|
310
|
+
recordId: text("record_id").notNull(),
|
|
311
|
+
position: integer("position").notNull().default(0),
|
|
312
|
+
createdByActorType: text("created_by_actor_type", {
|
|
313
|
+
enum: ["user", "agent", "automation", "provider", "system"],
|
|
314
|
+
})
|
|
315
|
+
.notNull()
|
|
316
|
+
.default("system"),
|
|
317
|
+
createdByActorId: text("created_by_actor_id"),
|
|
318
|
+
createdAt: text("created_at").notNull().default(now()),
|
|
319
|
+
updatedAt: text("updated_at").notNull().default(now()),
|
|
320
|
+
...ownableColumns(),
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
export const crmListEntryShares = createSharesTable("crm_list_entry_shares");
|
|
324
|
+
|
|
325
|
+
export const crmRelationships = table("crm_relationships", {
|
|
326
|
+
id: text("id").primaryKey(),
|
|
327
|
+
connectionId: text("connection_id").notNull(),
|
|
328
|
+
fromRecordId: text("from_record_id").notNull(),
|
|
329
|
+
toRecordId: text("to_record_id").notNull(),
|
|
330
|
+
relationshipType: text("relationship_type").notNull(),
|
|
331
|
+
label: text("label"),
|
|
332
|
+
inverseLabel: text("inverse_label"),
|
|
333
|
+
sourceField: text("source_field"),
|
|
334
|
+
remoteRelationshipId: text("remote_relationship_id"),
|
|
335
|
+
remoteRevision: text("remote_revision"),
|
|
336
|
+
tombstone: portableBoolean("tombstone").notNull().default(false),
|
|
337
|
+
lastSyncedAt: text("last_synced_at"),
|
|
338
|
+
createdAt: text("created_at").notNull().default(now()),
|
|
339
|
+
updatedAt: text("updated_at").notNull().default(now()),
|
|
340
|
+
...ownableColumns(),
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
export const crmRelationshipShares = createSharesTable(
|
|
344
|
+
"crm_relationship_shares",
|
|
345
|
+
);
|
|
346
|
+
|
|
347
|
+
export const crmInteractions = table("crm_interactions", {
|
|
348
|
+
id: text("id").primaryKey(),
|
|
349
|
+
recordId: text("record_id").notNull(),
|
|
350
|
+
connectionId: text("connection_id"),
|
|
351
|
+
kind: text("kind", {
|
|
352
|
+
enum: ["call", "meeting", "email", "note", "message", "other"],
|
|
353
|
+
}).notNull(),
|
|
354
|
+
direction: text("direction", {
|
|
355
|
+
enum: ["inbound", "outbound", "internal", "unknown"],
|
|
356
|
+
})
|
|
357
|
+
.notNull()
|
|
358
|
+
.default("unknown"),
|
|
359
|
+
title: text("title").notNull(),
|
|
360
|
+
summary: text("summary").notNull().default(""),
|
|
361
|
+
occurredAt: text("occurred_at").notNull(),
|
|
362
|
+
meaningful: portableBoolean("meaningful").notNull().default(true),
|
|
363
|
+
providerObjectType: text("provider_object_type"),
|
|
364
|
+
providerRemoteId: text("provider_remote_id"),
|
|
365
|
+
sourceApp: text("source_app"),
|
|
366
|
+
sourceUrl: text("source_url"),
|
|
367
|
+
participantsJson: text("participants_json").notNull().default("[]"),
|
|
368
|
+
createdAt: text("created_at").notNull().default(now()),
|
|
369
|
+
updatedAt: text("updated_at").notNull().default(now()),
|
|
370
|
+
...ownableColumns(),
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
export const crmInteractionShares = createSharesTable("crm_interaction_shares");
|
|
374
|
+
|
|
375
|
+
export const crmCallEvidence = table("crm_call_evidence", {
|
|
376
|
+
id: text("id").primaryKey(),
|
|
377
|
+
interactionId: text("interaction_id"),
|
|
378
|
+
recordId: text("record_id").notNull(),
|
|
379
|
+
sourceApp: text("source_app").notNull().default("clips"),
|
|
380
|
+
artifactType: text("artifact_type").notNull().default("call-evidence"),
|
|
381
|
+
artifactId: text("artifact_id").notNull(),
|
|
382
|
+
sourceUrl: text("source_url").notNull(),
|
|
383
|
+
quote: text("quote").notNull().default(""),
|
|
384
|
+
speaker: text("speaker"),
|
|
385
|
+
startSeconds: real("start_seconds"),
|
|
386
|
+
endSeconds: real("end_seconds"),
|
|
387
|
+
summary: text("summary").notNull().default(""),
|
|
388
|
+
capturedAt: text("captured_at").notNull(),
|
|
389
|
+
createdAt: text("created_at").notNull().default(now()),
|
|
390
|
+
updatedAt: text("updated_at").notNull().default(now()),
|
|
391
|
+
...ownableColumns(),
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
export const crmCallEvidenceShares = createSharesTable(
|
|
395
|
+
"crm_call_evidence_shares",
|
|
396
|
+
);
|
|
397
|
+
|
|
398
|
+
export const crmSignalTrackers = table("crm_signal_trackers", {
|
|
399
|
+
id: text("id").primaryKey(),
|
|
400
|
+
name: text("name").notNull(),
|
|
401
|
+
description: text("description").notNull().default(""),
|
|
402
|
+
kind: text("kind", { enum: ["keyword", "smart"] }).notNull(),
|
|
403
|
+
keywordsJson: text("keywords_json").notNull().default("[]"),
|
|
404
|
+
classifierPrompt: text("classifier_prompt").notNull().default(""),
|
|
405
|
+
enabled: portableBoolean("enabled").notNull().default(true),
|
|
406
|
+
isDefault: portableBoolean("is_default").notNull().default(false),
|
|
407
|
+
createdAt: text("created_at").notNull().default(now()),
|
|
408
|
+
updatedAt: text("updated_at").notNull().default(now()),
|
|
409
|
+
...ownableColumns(),
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
export const crmSignalTrackerShares = createSharesTable(
|
|
413
|
+
"crm_signal_tracker_shares",
|
|
414
|
+
);
|
|
415
|
+
|
|
416
|
+
export const crmSignalRuns = table("crm_signal_runs", {
|
|
417
|
+
id: text("id").primaryKey(),
|
|
418
|
+
trackerId: text("tracker_id"),
|
|
419
|
+
recordId: text("record_id").notNull(),
|
|
420
|
+
kind: text("kind", { enum: ["keyword", "smart", "summary"] }).notNull(),
|
|
421
|
+
status: text("status", {
|
|
422
|
+
enum: ["queued", "running", "completed", "failed"],
|
|
423
|
+
})
|
|
424
|
+
.notNull()
|
|
425
|
+
.default("queued"),
|
|
426
|
+
evidenceCount: integer("evidence_count").notNull().default(0),
|
|
427
|
+
model: text("model"),
|
|
428
|
+
modelVersion: text("model_version"),
|
|
429
|
+
idempotencyKey: text("idempotency_key").notNull(),
|
|
430
|
+
error: text("error"),
|
|
431
|
+
createdAt: text("created_at").notNull().default(now()),
|
|
432
|
+
updatedAt: text("updated_at").notNull().default(now()),
|
|
433
|
+
completedAt: text("completed_at"),
|
|
434
|
+
...ownableColumns(),
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
export const crmSignalRunShares = createSharesTable("crm_signal_run_shares");
|
|
438
|
+
|
|
439
|
+
export const crmSignals = table("crm_signals", {
|
|
440
|
+
id: text("id").primaryKey(),
|
|
441
|
+
runId: text("run_id"),
|
|
442
|
+
trackerId: text("tracker_id"),
|
|
443
|
+
recordId: text("record_id").notNull(),
|
|
444
|
+
evidenceId: text("evidence_id").notNull(),
|
|
445
|
+
kind: text("kind", {
|
|
446
|
+
enum: ["moment", "call-summary", "next-step"],
|
|
447
|
+
}).notNull(),
|
|
448
|
+
label: text("label").notNull(),
|
|
449
|
+
quote: text("quote").notNull().default(""),
|
|
450
|
+
speaker: text("speaker"),
|
|
451
|
+
startSeconds: real("start_seconds"),
|
|
452
|
+
endSeconds: real("end_seconds"),
|
|
453
|
+
summary: text("summary").notNull().default(""),
|
|
454
|
+
confidence: real("confidence").notNull().default(0),
|
|
455
|
+
detector: text("detector", { enum: ["keyword", "agent"] }).notNull(),
|
|
456
|
+
model: text("model"),
|
|
457
|
+
modelVersion: text("model_version"),
|
|
458
|
+
reviewStatus: text("review_status", {
|
|
459
|
+
enum: ["unreviewed", "confirmed", "dismissed"],
|
|
460
|
+
})
|
|
461
|
+
.notNull()
|
|
462
|
+
.default("unreviewed"),
|
|
463
|
+
idempotencyKey: text("idempotency_key").notNull(),
|
|
464
|
+
createdAt: text("created_at").notNull().default(now()),
|
|
465
|
+
updatedAt: text("updated_at").notNull().default(now()),
|
|
466
|
+
...ownableColumns(),
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
export const crmSignalShares = createSharesTable("crm_signal_shares");
|
|
470
|
+
|
|
471
|
+
export const crmTasks = table("crm_tasks", {
|
|
472
|
+
id: text("id").primaryKey(),
|
|
473
|
+
recordId: text("record_id"),
|
|
474
|
+
title: text("title").notNull(),
|
|
475
|
+
description: text("description").notNull().default(""),
|
|
476
|
+
status: text("status", { enum: ["open", "done", "cancelled"] })
|
|
477
|
+
.notNull()
|
|
478
|
+
.default("open"),
|
|
479
|
+
dueAt: text("due_at"),
|
|
480
|
+
assignedTo: text("assigned_to"),
|
|
481
|
+
authority: text("authority", { enum: ["local", "provider"] })
|
|
482
|
+
.notNull()
|
|
483
|
+
.default("local"),
|
|
484
|
+
connectionId: text("connection_id"),
|
|
485
|
+
providerObjectType: text("provider_object_type"),
|
|
486
|
+
providerRemoteId: text("provider_remote_id"),
|
|
487
|
+
remoteRevision: text("remote_revision"),
|
|
488
|
+
completedAt: text("completed_at"),
|
|
489
|
+
createdAt: text("created_at").notNull().default(now()),
|
|
490
|
+
updatedAt: text("updated_at").notNull().default(now()),
|
|
491
|
+
...ownableColumns(),
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
export const crmTaskShares = createSharesTable("crm_task_shares");
|
|
495
|
+
|
|
496
|
+
export const crmSavedViews = table("crm_saved_views", {
|
|
497
|
+
id: text("id").primaryKey(),
|
|
498
|
+
name: text("name").notNull(),
|
|
499
|
+
description: text("description").notNull().default(""),
|
|
500
|
+
// `kind` predates typed views and holds the RECORD kind (account/person/
|
|
501
|
+
// opportunity) that crm-store.ts validates. The table-vs-board discriminator
|
|
502
|
+
// is `viewKind`; do not repurpose `kind`.
|
|
503
|
+
kind: text("kind"),
|
|
504
|
+
viewKind: text("view_kind", { enum: ["table", "board"] })
|
|
505
|
+
.notNull()
|
|
506
|
+
.default("table"),
|
|
507
|
+
targetKind: text("target_kind", { enum: ["object", "list"] })
|
|
508
|
+
.notNull()
|
|
509
|
+
.default("object"),
|
|
510
|
+
targetId: text("target_id"),
|
|
511
|
+
/** Board views only; must reference a `status` attribute. */
|
|
512
|
+
groupByAttributeId: text("group_by_attribute_id"),
|
|
513
|
+
// personal-vs-shared is the framework `visibility` column from
|
|
514
|
+
// ownableColumns(): "private" is personal, "org" is shared. No second column.
|
|
515
|
+
filtersJson: text("filters_json").notNull().default("{}"),
|
|
516
|
+
columnsJson: text("columns_json").notNull().default("[]"),
|
|
517
|
+
sortJson: text("sort_json").notNull().default("[]"),
|
|
518
|
+
dataProgramId: text("data_program_id"),
|
|
519
|
+
pinned: portableBoolean("pinned").notNull().default(false),
|
|
520
|
+
createdAt: text("created_at").notNull().default(now()),
|
|
521
|
+
updatedAt: text("updated_at").notNull().default(now()),
|
|
522
|
+
...ownableColumns(),
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
export const crmSavedViewShares = createSharesTable("crm_saved_view_shares");
|
|
526
|
+
|
|
527
|
+
export const crmMutations = table("crm_mutations", {
|
|
528
|
+
id: text("id").primaryKey(),
|
|
529
|
+
recordId: text("record_id"),
|
|
530
|
+
connectionId: text("connection_id"),
|
|
531
|
+
operation: text("operation", {
|
|
532
|
+
enum: ["create", "update", "delete", "associate", "disassociate"],
|
|
533
|
+
}).notNull(),
|
|
534
|
+
initiatedBy: text("initiated_by", {
|
|
535
|
+
enum: ["human", "agent", "automation"],
|
|
536
|
+
}).notNull(),
|
|
537
|
+
target: text("target", { enum: ["local", "provider"] }).notNull(),
|
|
538
|
+
policyDecision: text("policy_decision", {
|
|
539
|
+
enum: ["execute", "propose", "require-approval", "deny"],
|
|
540
|
+
}).notNull(),
|
|
541
|
+
risk: text("risk").notNull().default("routine"),
|
|
542
|
+
status: text("status", {
|
|
543
|
+
enum: ["pending", "approved", "applied", "rejected", "conflict", "failed"],
|
|
544
|
+
})
|
|
545
|
+
.notNull()
|
|
546
|
+
.default("pending"),
|
|
547
|
+
patchJson: text("patch_json").notNull().default("{}"),
|
|
548
|
+
beforeJson: text("before_json").notNull().default("{}"),
|
|
549
|
+
afterJson: text("after_json").notNull().default("{}"),
|
|
550
|
+
idempotencyKey: text("idempotency_key").notNull(),
|
|
551
|
+
expectedRemoteRevision: text("expected_remote_revision"),
|
|
552
|
+
providerRemoteRevision: text("provider_remote_revision"),
|
|
553
|
+
approvedBy: text("approved_by"),
|
|
554
|
+
approvedAt: text("approved_at"),
|
|
555
|
+
appliedAt: text("applied_at"),
|
|
556
|
+
error: text("error"),
|
|
557
|
+
createdAt: text("created_at").notNull().default(now()),
|
|
558
|
+
updatedAt: text("updated_at").notNull().default(now()),
|
|
559
|
+
...ownableColumns(),
|
|
560
|
+
});
|
|
561
|
+
|
|
562
|
+
export const crmMutationShares = createSharesTable("crm_mutation_shares");
|
|
563
|
+
|
|
564
|
+
export const crmSyncRuns = table("crm_sync_runs", {
|
|
565
|
+
id: text("id").primaryKey(),
|
|
566
|
+
connectionId: text("connection_id").notNull(),
|
|
567
|
+
status: text("status", {
|
|
568
|
+
enum: ["running", "success", "partial", "failed"],
|
|
569
|
+
})
|
|
570
|
+
.notNull()
|
|
571
|
+
.default("running"),
|
|
572
|
+
scopeJson: text("scope_json").notNull().default("{}"),
|
|
573
|
+
cursor: text("cursor"),
|
|
574
|
+
recordsUpserted: integer("records_upserted").notNull().default(0),
|
|
575
|
+
tombstonesApplied: integer("tombstones_applied").notNull().default(0),
|
|
576
|
+
relationshipsUpserted: integer("relationships_upserted").notNull().default(0),
|
|
577
|
+
error: text("error"),
|
|
578
|
+
startedAt: text("started_at").notNull(),
|
|
579
|
+
completedAt: text("completed_at"),
|
|
580
|
+
createdAt: text("created_at").notNull().default(now()),
|
|
581
|
+
updatedAt: text("updated_at").notNull().default(now()),
|
|
582
|
+
...ownableColumns(),
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
export const crmSyncRunShares = createSharesTable("crm_sync_run_shares");
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* One enrichment pass over a scope of records.
|
|
589
|
+
*
|
|
590
|
+
* Two rows make one gated enrichment: a `verify` run that gathers evidence
|
|
591
|
+
* without touching contact data, and — only after a human approves some of its
|
|
592
|
+
* records — a `spend` run whose `inputRecordIdsJson` is built from those
|
|
593
|
+
* approvals alone. That frozen id list is the structural bound on spend: the
|
|
594
|
+
* paid pass never sees an unapproved record, rather than filtering one out.
|
|
595
|
+
*/
|
|
596
|
+
export const crmEnrichmentRuns = table("crm_enrichment_runs", {
|
|
597
|
+
id: text("id").primaryKey(),
|
|
598
|
+
/**
|
|
599
|
+
* What a duplicate run is "the same scope" as, keyed `${scopeKind}:${scopeId}`.
|
|
600
|
+
* An ad-hoc `records` scope has no natural id, so `scopeId` is a deterministic
|
|
601
|
+
* hash of its sorted record ids — without that, the duplicate-run guard either
|
|
602
|
+
* collides across unrelated ad-hoc runs or never matches, and a double-click
|
|
603
|
+
* buys the same contacts twice.
|
|
604
|
+
*/
|
|
605
|
+
scopeKind: text("scope_kind", {
|
|
606
|
+
enum: ["object", "list", "records"],
|
|
607
|
+
}).notNull(),
|
|
608
|
+
scopeId: text("scope_id").notNull(),
|
|
609
|
+
phase: text("phase", { enum: ["verify", "spend"] }).notNull(),
|
|
610
|
+
status: text("status", {
|
|
611
|
+
enum: ["queued", "running", "completed", "failed"],
|
|
612
|
+
})
|
|
613
|
+
.notNull()
|
|
614
|
+
.default("queued"),
|
|
615
|
+
/** `spend` only: the verify run whose approved evidence built this input set. */
|
|
616
|
+
sourceRunId: text("source_run_id"),
|
|
617
|
+
slotsJson: text("slots_json").notNull().default("[]"),
|
|
618
|
+
inputRecordIdsJson: text("input_record_ids_json").notNull().default("[]"),
|
|
619
|
+
/** Per-record slot outcomes. Bounded facts and errors only — never payloads. */
|
|
620
|
+
outcomesJson: text("outcomes_json").notNull().default("[]"),
|
|
621
|
+
estimateJson: text("estimate_json").notNull().default("{}"),
|
|
622
|
+
costUnits: real("cost_units"),
|
|
623
|
+
/** Atomic claim: write a unique nonce, read it back, only the winner proceeds. */
|
|
624
|
+
claimNonce: text("claim_nonce"),
|
|
625
|
+
claimedAt: text("claimed_at"),
|
|
626
|
+
error: text("error"),
|
|
627
|
+
startedAt: text("started_at").notNull(),
|
|
628
|
+
completedAt: text("completed_at"),
|
|
629
|
+
createdAt: text("created_at").notNull().default(now()),
|
|
630
|
+
updatedAt: text("updated_at").notNull().default(now()),
|
|
631
|
+
...ownableColumns(),
|
|
632
|
+
});
|
|
633
|
+
|
|
634
|
+
export const crmEnrichmentRunShares = createSharesTable(
|
|
635
|
+
"crm_enrichment_run_shares",
|
|
636
|
+
);
|
|
637
|
+
|
|
638
|
+
const crmDashboardStorageSchema = createDashboardStorageSchema({
|
|
639
|
+
dashboardsTable: "crm_dashboards",
|
|
640
|
+
revisionsTable: "crm_dashboard_revisions",
|
|
641
|
+
sharesTable: "crm_dashboard_shares",
|
|
642
|
+
});
|
|
643
|
+
|
|
644
|
+
export const crmDashboards = crmDashboardStorageSchema.dashboards;
|
|
645
|
+
export const crmDashboardRevisions =
|
|
646
|
+
crmDashboardStorageSchema.dashboardRevisions;
|
|
647
|
+
export const crmDashboardShares = crmDashboardStorageSchema.dashboardShares;
|