@kelpie/server 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/consumerEmailDomains.d.ts +2 -0
- package/dist/lib/consumerEmailDomains.d.ts.map +1 -0
- package/dist/lib/consumerEmailDomains.js +62 -0
- package/dist/lib/consumerEmailDomains.js.map +1 -0
- package/dist/lib/email.d.ts +7 -0
- package/dist/lib/email.d.ts.map +1 -1
- package/dist/lib/email.js.map +1 -1
- package/dist/lib/emailContent.d.ts +33 -0
- package/dist/lib/emailContent.d.ts.map +1 -0
- package/dist/lib/emailContent.js +54 -0
- package/dist/lib/emailContent.js.map +1 -0
- package/dist/lib/emailDomainAutoLink.d.ts +27 -0
- package/dist/lib/emailDomainAutoLink.d.ts.map +1 -0
- package/dist/lib/emailDomainAutoLink.js +119 -0
- package/dist/lib/emailDomainAutoLink.js.map +1 -0
- package/dist/lib/ids.d.ts +13 -0
- package/dist/lib/ids.d.ts.map +1 -1
- package/dist/lib/ids.js +13 -0
- package/dist/lib/ids.js.map +1 -1
- package/dist/modules/activities/repository.d.ts.map +1 -1
- package/dist/modules/activities/repository.js +19 -20
- package/dist/modules/activities/repository.js.map +1 -1
- package/dist/modules/activities/wording.d.ts +12 -0
- package/dist/modules/activities/wording.d.ts.map +1 -1
- package/dist/modules/activities/wording.js +16 -0
- package/dist/modules/activities/wording.js.map +1 -1
- package/dist/modules/agent-tasks/catalog.d.ts.map +1 -1
- package/dist/modules/agent-tasks/catalog.js +62 -0
- package/dist/modules/agent-tasks/catalog.js.map +1 -1
- package/dist/modules/agent-tasks/resolve.d.ts.map +1 -1
- package/dist/modules/agent-tasks/resolve.js +42 -9
- package/dist/modules/agent-tasks/resolve.js.map +1 -1
- package/dist/modules/agent-tasks/routes.d.ts +2 -0
- package/dist/modules/agent-tasks/routes.d.ts.map +1 -1
- package/dist/modules/attachedRecords.d.ts +6 -1
- package/dist/modules/attachedRecords.d.ts.map +1 -1
- package/dist/modules/attachedRecords.js +18 -2
- package/dist/modules/attachedRecords.js.map +1 -1
- package/dist/modules/auth/preferences.d.ts +11 -1
- package/dist/modules/auth/preferences.d.ts.map +1 -1
- package/dist/modules/auth/preferences.js +11 -0
- package/dist/modules/auth/preferences.js.map +1 -1
- package/dist/modules/auth/routes.d.ts.map +1 -1
- package/dist/modules/auth/routes.js +18 -0
- package/dist/modules/auth/routes.js.map +1 -1
- package/dist/modules/auth/schema.d.ts +20 -0
- package/dist/modules/auth/schema.d.ts.map +1 -1
- package/dist/modules/auth/schema.js +11 -1
- package/dist/modules/auth/schema.js.map +1 -1
- package/dist/modules/auth/service.d.ts.map +1 -1
- package/dist/modules/auth/service.js +27 -3
- package/dist/modules/auth/service.js.map +1 -1
- package/dist/modules/companies/index.d.ts.map +1 -1
- package/dist/modules/companies/index.js +3 -1
- package/dist/modules/companies/index.js.map +1 -1
- package/dist/modules/companies/repository.d.ts +2 -0
- package/dist/modules/companies/repository.d.ts.map +1 -1
- package/dist/modules/companies/repository.js +1 -0
- package/dist/modules/companies/repository.js.map +1 -1
- package/dist/modules/companies/routes.d.ts +16 -0
- package/dist/modules/companies/routes.d.ts.map +1 -1
- package/dist/modules/companies/routes.js +18 -0
- package/dist/modules/companies/routes.js.map +1 -1
- package/dist/modules/companies/schema.d.ts +37 -0
- package/dist/modules/companies/schema.d.ts.map +1 -1
- package/dist/modules/companies/schema.js +10 -1
- package/dist/modules/companies/schema.js.map +1 -1
- package/dist/modules/companies/service.d.ts +6 -0
- package/dist/modules/companies/service.d.ts.map +1 -1
- package/dist/modules/companies/service.js +45 -11
- package/dist/modules/companies/service.js.map +1 -1
- package/dist/modules/consent-purposes/capabilities.d.ts +7 -0
- package/dist/modules/consent-purposes/capabilities.d.ts.map +1 -0
- package/dist/modules/consent-purposes/capabilities.js +10 -0
- package/dist/modules/consent-purposes/capabilities.js.map +1 -0
- package/dist/modules/consent-purposes/events.d.ts +38 -0
- package/dist/modules/consent-purposes/events.d.ts.map +1 -0
- package/dist/modules/consent-purposes/events.js +17 -0
- package/dist/modules/consent-purposes/events.js.map +1 -0
- package/dist/modules/consent-purposes/index.d.ts +13 -0
- package/dist/modules/consent-purposes/index.d.ts.map +1 -0
- package/dist/modules/consent-purposes/index.js +41 -0
- package/dist/modules/consent-purposes/index.js.map +1 -0
- package/dist/modules/consent-purposes/repository.d.ts +21 -0
- package/dist/modules/consent-purposes/repository.d.ts.map +1 -0
- package/dist/modules/consent-purposes/repository.js +98 -0
- package/dist/modules/consent-purposes/repository.js.map +1 -0
- package/dist/modules/consent-purposes/routes.d.ts +39 -0
- package/dist/modules/consent-purposes/routes.d.ts.map +1 -0
- package/dist/modules/consent-purposes/routes.js +79 -0
- package/dist/modules/consent-purposes/routes.js.map +1 -0
- package/dist/modules/consent-purposes/schema.d.ts +175 -0
- package/dist/modules/consent-purposes/schema.d.ts.map +1 -0
- package/dist/modules/consent-purposes/schema.js +35 -0
- package/dist/modules/consent-purposes/schema.js.map +1 -0
- package/dist/modules/consent-purposes/service.d.ts +50 -0
- package/dist/modules/consent-purposes/service.d.ts.map +1 -0
- package/dist/modules/consent-purposes/service.js +263 -0
- package/dist/modules/consent-purposes/service.js.map +1 -0
- package/dist/modules/consent-purposes/starters.d.ts +17 -0
- package/dist/modules/consent-purposes/starters.d.ts.map +1 -0
- package/dist/modules/consent-purposes/starters.js +15 -0
- package/dist/modules/consent-purposes/starters.js.map +1 -0
- package/dist/modules/consent-purposes/tools.d.ts +4 -0
- package/dist/modules/consent-purposes/tools.d.ts.map +1 -0
- package/dist/modules/consent-purposes/tools.js +29 -0
- package/dist/modules/consent-purposes/tools.js.map +1 -0
- package/dist/modules/core.d.ts.map +1 -1
- package/dist/modules/core.js +21 -0
- package/dist/modules/core.js.map +1 -1
- package/dist/modules/custom-fields/capabilities.d.ts +12 -0
- package/dist/modules/custom-fields/capabilities.d.ts.map +1 -0
- package/dist/modules/custom-fields/capabilities.js +15 -0
- package/dist/modules/custom-fields/capabilities.js.map +1 -0
- package/dist/modules/custom-fields/events.d.ts +49 -0
- package/dist/modules/custom-fields/events.d.ts.map +1 -0
- package/dist/modules/custom-fields/events.js +25 -0
- package/dist/modules/custom-fields/events.js.map +1 -0
- package/dist/modules/custom-fields/index.d.ts +19 -0
- package/dist/modules/custom-fields/index.d.ts.map +1 -0
- package/dist/modules/custom-fields/index.js +46 -0
- package/dist/modules/custom-fields/index.js.map +1 -0
- package/dist/modules/custom-fields/repository.d.ts +37 -0
- package/dist/modules/custom-fields/repository.d.ts.map +1 -0
- package/dist/modules/custom-fields/repository.js +144 -0
- package/dist/modules/custom-fields/repository.js.map +1 -0
- package/dist/modules/custom-fields/routes.d.ts +44 -0
- package/dist/modules/custom-fields/routes.d.ts.map +1 -0
- package/dist/modules/custom-fields/routes.js +103 -0
- package/dist/modules/custom-fields/routes.js.map +1 -0
- package/dist/modules/custom-fields/schema.d.ts +215 -0
- package/dist/modules/custom-fields/schema.d.ts.map +1 -0
- package/dist/modules/custom-fields/schema.js +43 -0
- package/dist/modules/custom-fields/schema.js.map +1 -0
- package/dist/modules/custom-fields/service.d.ts +57 -0
- package/dist/modules/custom-fields/service.d.ts.map +1 -0
- package/dist/modules/custom-fields/service.js +273 -0
- package/dist/modules/custom-fields/service.js.map +1 -0
- package/dist/modules/custom-fields/tools.d.ts +4 -0
- package/dist/modules/custom-fields/tools.d.ts.map +1 -0
- package/dist/modules/custom-fields/tools.js +38 -0
- package/dist/modules/custom-fields/tools.js.map +1 -0
- package/dist/modules/custom-fields/values.d.ts +49 -0
- package/dist/modules/custom-fields/values.d.ts.map +1 -0
- package/dist/modules/custom-fields/values.js +249 -0
- package/dist/modules/custom-fields/values.js.map +1 -0
- package/dist/modules/custom-fields/wire.d.ts +12 -0
- package/dist/modules/custom-fields/wire.d.ts.map +1 -0
- package/dist/modules/custom-fields/wire.js +30 -0
- package/dist/modules/custom-fields/wire.js.map +1 -0
- package/dist/modules/dashboard/repository.d.ts.map +1 -1
- package/dist/modules/dashboard/repository.js +4 -3
- package/dist/modules/dashboard/repository.js.map +1 -1
- package/dist/modules/deals/index.d.ts +2 -1
- package/dist/modules/deals/index.d.ts.map +1 -1
- package/dist/modules/deals/index.js +5 -2
- package/dist/modules/deals/index.js.map +1 -1
- package/dist/modules/deals/repository.d.ts +0 -16
- package/dist/modules/deals/repository.d.ts.map +1 -1
- package/dist/modules/deals/repository.js +6 -76
- package/dist/modules/deals/repository.js.map +1 -1
- package/dist/modules/deals/routes.d.ts +14 -0
- package/dist/modules/deals/routes.d.ts.map +1 -1
- package/dist/modules/deals/routes.js +7 -0
- package/dist/modules/deals/routes.js.map +1 -1
- package/dist/modules/deals/schema.d.ts +20 -42
- package/dist/modules/deals/schema.d.ts.map +1 -1
- package/dist/modules/deals/schema.js +6 -11
- package/dist/modules/deals/schema.js.map +1 -1
- package/dist/modules/deals/service.d.ts +13 -2
- package/dist/modules/deals/service.d.ts.map +1 -1
- package/dist/modules/deals/service.js +43 -20
- package/dist/modules/deals/service.js.map +1 -1
- package/dist/modules/decisions/repository.d.ts.map +1 -1
- package/dist/modules/decisions/repository.js +2 -0
- package/dist/modules/decisions/repository.js.map +1 -1
- package/dist/modules/decisions/routes.d.ts +1 -0
- package/dist/modules/decisions/routes.d.ts.map +1 -1
- package/dist/modules/email-domain-linker/index.d.ts +12 -0
- package/dist/modules/email-domain-linker/index.d.ts.map +1 -0
- package/dist/modules/email-domain-linker/index.js +34 -0
- package/dist/modules/email-domain-linker/index.js.map +1 -0
- package/dist/modules/email-domain-linker/routes.d.ts +14 -0
- package/dist/modules/email-domain-linker/routes.d.ts.map +1 -0
- package/dist/modules/email-domain-linker/routes.js +15 -0
- package/dist/modules/email-domain-linker/routes.js.map +1 -0
- package/dist/modules/email-domain-linker/service.d.ts +37 -0
- package/dist/modules/email-domain-linker/service.d.ts.map +1 -0
- package/dist/modules/email-domain-linker/service.js +63 -0
- package/dist/modules/email-domain-linker/service.js.map +1 -0
- package/dist/modules/enquiries/events.d.ts +44 -0
- package/dist/modules/enquiries/events.d.ts.map +1 -0
- package/dist/modules/enquiries/events.js +19 -0
- package/dist/modules/enquiries/events.js.map +1 -0
- package/dist/modules/enquiries/index.d.ts +13 -0
- package/dist/modules/enquiries/index.d.ts.map +1 -0
- package/dist/modules/enquiries/index.js +44 -0
- package/dist/modules/enquiries/index.js.map +1 -0
- package/dist/modules/enquiries/repository.d.ts +30 -0
- package/dist/modules/enquiries/repository.d.ts.map +1 -0
- package/dist/modules/enquiries/repository.js +94 -0
- package/dist/modules/enquiries/repository.js.map +1 -0
- package/dist/modules/enquiries/routes.d.ts +52 -0
- package/dist/modules/enquiries/routes.d.ts.map +1 -0
- package/dist/modules/enquiries/routes.js +127 -0
- package/dist/modules/enquiries/routes.js.map +1 -0
- package/dist/modules/enquiries/schema.d.ts +290 -0
- package/dist/modules/enquiries/schema.d.ts.map +1 -0
- package/dist/modules/enquiries/schema.js +52 -0
- package/dist/modules/enquiries/schema.js.map +1 -0
- package/dist/modules/enquiries/service.d.ts +85 -0
- package/dist/modules/enquiries/service.d.ts.map +1 -0
- package/dist/modules/enquiries/service.js +370 -0
- package/dist/modules/enquiries/service.js.map +1 -0
- package/dist/modules/enquiries/tools.d.ts +4 -0
- package/dist/modules/enquiries/tools.d.ts.map +1 -0
- package/dist/modules/enquiries/tools.js +50 -0
- package/dist/modules/enquiries/tools.js.map +1 -0
- package/dist/modules/eventCatalogs.d.ts +4 -0
- package/dist/modules/eventCatalogs.d.ts.map +1 -1
- package/dist/modules/eventCatalogs.js +4 -0
- package/dist/modules/eventCatalogs.js.map +1 -1
- package/dist/modules/forms/embed.d.ts +20 -6
- package/dist/modules/forms/embed.d.ts.map +1 -1
- package/dist/modules/forms/embed.js +359 -43
- package/dist/modules/forms/embed.js.map +1 -1
- package/dist/modules/forms/events.d.ts +20 -7
- package/dist/modules/forms/events.d.ts.map +1 -1
- package/dist/modules/forms/events.js +20 -2
- package/dist/modules/forms/events.js.map +1 -1
- package/dist/modules/forms/fields.d.ts +14 -1
- package/dist/modules/forms/fields.d.ts.map +1 -1
- package/dist/modules/forms/fields.js +87 -3
- package/dist/modules/forms/fields.js.map +1 -1
- package/dist/modules/forms/index.d.ts.map +1 -1
- package/dist/modules/forms/index.js +12 -1
- package/dist/modules/forms/index.js.map +1 -1
- package/dist/modules/forms/mapping.d.ts +62 -5
- package/dist/modules/forms/mapping.d.ts.map +1 -1
- package/dist/modules/forms/mapping.js +139 -5
- package/dist/modules/forms/mapping.js.map +1 -1
- package/dist/modules/forms/publicRoutes.d.ts.map +1 -1
- package/dist/modules/forms/publicRoutes.js +29 -1
- package/dist/modules/forms/publicRoutes.js.map +1 -1
- package/dist/modules/forms/repository.d.ts +31 -0
- package/dist/modules/forms/repository.d.ts.map +1 -1
- package/dist/modules/forms/repository.js +90 -1
- package/dist/modules/forms/repository.js.map +1 -1
- package/dist/modules/forms/routes.d.ts +83 -1
- package/dist/modules/forms/routes.d.ts.map +1 -1
- package/dist/modules/forms/routes.js +185 -2
- package/dist/modules/forms/routes.js.map +1 -1
- package/dist/modules/forms/schema.d.ts +672 -1
- package/dist/modules/forms/schema.d.ts.map +1 -1
- package/dist/modules/forms/schema.js +146 -3
- package/dist/modules/forms/schema.js.map +1 -1
- package/dist/modules/forms/service.d.ts +54 -1
- package/dist/modules/forms/service.d.ts.map +1 -1
- package/dist/modules/forms/service.js +338 -28
- package/dist/modules/forms/service.js.map +1 -1
- package/dist/modules/forms/submission.d.ts +15 -0
- package/dist/modules/forms/submission.d.ts.map +1 -1
- package/dist/modules/forms/submission.js +418 -40
- package/dist/modules/forms/submission.js.map +1 -1
- package/dist/modules/import-export/drafts.d.ts +10 -0
- package/dist/modules/import-export/drafts.d.ts.map +1 -1
- package/dist/modules/import-export/drafts.js +16 -2
- package/dist/modules/import-export/drafts.js.map +1 -1
- package/dist/modules/import-export/exportRows.d.ts +7 -4
- package/dist/modules/import-export/exportRows.d.ts.map +1 -1
- package/dist/modules/import-export/exportRows.js +20 -5
- package/dist/modules/import-export/exportRows.js.map +1 -1
- package/dist/modules/import-export/plan.d.ts +12 -1
- package/dist/modules/import-export/plan.d.ts.map +1 -1
- package/dist/modules/import-export/plan.js +29 -2
- package/dist/modules/import-export/plan.js.map +1 -1
- package/dist/modules/import-export/presets.d.ts.map +1 -1
- package/dist/modules/import-export/presets.js +10 -0
- package/dist/modules/import-export/presets.js.map +1 -1
- package/dist/modules/import-export/repository.d.ts +11 -1
- package/dist/modules/import-export/repository.d.ts.map +1 -1
- package/dist/modules/import-export/repository.js +42 -9
- package/dist/modules/import-export/repository.js.map +1 -1
- package/dist/modules/import-export/routes.d.ts.map +1 -1
- package/dist/modules/import-export/routes.js +4 -0
- package/dist/modules/import-export/routes.js.map +1 -1
- package/dist/modules/import-export/schema.d.ts +17 -0
- package/dist/modules/import-export/schema.d.ts.map +1 -1
- package/dist/modules/import-export/schema.js +11 -0
- package/dist/modules/import-export/schema.js.map +1 -1
- package/dist/modules/import-export/service.d.ts +6 -0
- package/dist/modules/import-export/service.d.ts.map +1 -1
- package/dist/modules/import-export/service.js +14 -2
- package/dist/modules/import-export/service.js.map +1 -1
- package/dist/modules/import-export/streams.d.ts.map +1 -1
- package/dist/modules/import-export/streams.js +3 -3
- package/dist/modules/import-export/streams.js.map +1 -1
- package/dist/modules/import-export/tools.d.ts.map +1 -1
- package/dist/modules/import-export/tools.js +8 -0
- package/dist/modules/import-export/tools.js.map +1 -1
- package/dist/modules/import-export/validation.d.ts.map +1 -1
- package/dist/modules/import-export/validation.js +22 -1
- package/dist/modules/import-export/validation.js.map +1 -1
- package/dist/modules/import-export/writes.d.ts.map +1 -1
- package/dist/modules/import-export/writes.js +37 -4
- package/dist/modules/import-export/writes.js.map +1 -1
- package/dist/modules/lists/events.d.ts +42 -0
- package/dist/modules/lists/events.d.ts.map +1 -0
- package/dist/modules/lists/events.js +16 -0
- package/dist/modules/lists/events.js.map +1 -0
- package/dist/modules/lists/index.d.ts +10 -0
- package/dist/modules/lists/index.d.ts.map +1 -0
- package/dist/modules/lists/index.js +35 -0
- package/dist/modules/lists/index.js.map +1 -0
- package/dist/modules/lists/repository.d.ts +80 -0
- package/dist/modules/lists/repository.d.ts.map +1 -0
- package/dist/modules/lists/repository.js +178 -0
- package/dist/modules/lists/repository.js.map +1 -0
- package/dist/modules/lists/routes.d.ts +55 -0
- package/dist/modules/lists/routes.d.ts.map +1 -0
- package/dist/modules/lists/routes.js +168 -0
- package/dist/modules/lists/routes.js.map +1 -0
- package/dist/modules/lists/schema.d.ts +281 -0
- package/dist/modules/lists/schema.d.ts.map +1 -0
- package/dist/modules/lists/schema.js +83 -0
- package/dist/modules/lists/schema.js.map +1 -0
- package/dist/modules/lists/service.d.ts +82 -0
- package/dist/modules/lists/service.d.ts.map +1 -0
- package/dist/modules/lists/service.js +262 -0
- package/dist/modules/lists/service.js.map +1 -0
- package/dist/modules/lists/tools.d.ts +4 -0
- package/dist/modules/lists/tools.d.ts.map +1 -0
- package/dist/modules/lists/tools.js +86 -0
- package/dist/modules/lists/tools.js.map +1 -0
- package/dist/modules/mcp/index.d.ts.map +1 -1
- package/dist/modules/mcp/index.js +5 -0
- package/dist/modules/mcp/index.js.map +1 -1
- package/dist/modules/notes/routes.d.ts +1 -0
- package/dist/modules/notes/routes.d.ts.map +1 -1
- package/dist/modules/opportunities/index.d.ts.map +1 -1
- package/dist/modules/opportunities/index.js +3 -1
- package/dist/modules/opportunities/index.js.map +1 -1
- package/dist/modules/opportunities/repository.d.ts +2 -0
- package/dist/modules/opportunities/repository.d.ts.map +1 -1
- package/dist/modules/opportunities/repository.js +4 -0
- package/dist/modules/opportunities/repository.js.map +1 -1
- package/dist/modules/opportunities/routes.d.ts +16 -0
- package/dist/modules/opportunities/routes.d.ts.map +1 -1
- package/dist/modules/opportunities/routes.js +13 -0
- package/dist/modules/opportunities/routes.js.map +1 -1
- package/dist/modules/opportunities/schema.d.ts +20 -0
- package/dist/modules/opportunities/schema.d.ts.map +1 -1
- package/dist/modules/opportunities/schema.js +6 -1
- package/dist/modules/opportunities/schema.js.map +1 -1
- package/dist/modules/opportunities/service.d.ts +20 -3
- package/dist/modules/opportunities/service.d.ts.map +1 -1
- package/dist/modules/opportunities/service.js +99 -18
- package/dist/modules/opportunities/service.js.map +1 -1
- package/dist/modules/opportunities/tools.d.ts.map +1 -1
- package/dist/modules/opportunities/tools.js +2 -0
- package/dist/modules/opportunities/tools.js.map +1 -1
- package/dist/modules/partnerships/index.d.ts.map +1 -1
- package/dist/modules/partnerships/index.js +3 -1
- package/dist/modules/partnerships/index.js.map +1 -1
- package/dist/modules/partnerships/repository.d.ts +0 -17
- package/dist/modules/partnerships/repository.d.ts.map +1 -1
- package/dist/modules/partnerships/repository.js +6 -82
- package/dist/modules/partnerships/repository.js.map +1 -1
- package/dist/modules/partnerships/routes.d.ts +14 -0
- package/dist/modules/partnerships/routes.d.ts.map +1 -1
- package/dist/modules/partnerships/routes.js +7 -0
- package/dist/modules/partnerships/routes.js.map +1 -1
- package/dist/modules/partnerships/schema.d.ts +20 -41
- package/dist/modules/partnerships/schema.d.ts.map +1 -1
- package/dist/modules/partnerships/schema.js +6 -10
- package/dist/modules/partnerships/schema.js.map +1 -1
- package/dist/modules/partnerships/service.d.ts +11 -1
- package/dist/modules/partnerships/service.d.ts.map +1 -1
- package/dist/modules/partnerships/service.js +43 -20
- package/dist/modules/partnerships/service.js.map +1 -1
- package/dist/modules/people/consentHydration.d.ts +26 -0
- package/dist/modules/people/consentHydration.d.ts.map +1 -0
- package/dist/modules/people/consentHydration.js +100 -0
- package/dist/modules/people/consentHydration.js.map +1 -0
- package/dist/modules/people/index.d.ts.map +1 -1
- package/dist/modules/people/index.js +3 -1
- package/dist/modules/people/index.js.map +1 -1
- package/dist/modules/people/personConsentWrites.d.ts +40 -0
- package/dist/modules/people/personConsentWrites.d.ts.map +1 -0
- package/dist/modules/people/personConsentWrites.js +98 -0
- package/dist/modules/people/personConsentWrites.js.map +1 -0
- package/dist/modules/people/repository.d.ts +11 -0
- package/dist/modules/people/repository.d.ts.map +1 -1
- package/dist/modules/people/repository.js +21 -1
- package/dist/modules/people/repository.js.map +1 -1
- package/dist/modules/people/routes.d.ts +57 -4
- package/dist/modules/people/routes.d.ts.map +1 -1
- package/dist/modules/people/routes.js +104 -5
- package/dist/modules/people/routes.js.map +1 -1
- package/dist/modules/people/schema.d.ts +366 -1
- package/dist/modules/people/schema.d.ts.map +1 -1
- package/dist/modules/people/schema.js +92 -2
- package/dist/modules/people/schema.js.map +1 -1
- package/dist/modules/people/service.d.ts +30 -1
- package/dist/modules/people/service.d.ts.map +1 -1
- package/dist/modules/people/service.js +131 -36
- package/dist/modules/people/service.js.map +1 -1
- package/dist/modules/people/tools.d.ts.map +1 -1
- package/dist/modules/people/tools.js +4 -1
- package/dist/modules/people/tools.js.map +1 -1
- package/dist/modules/personLinks.d.ts +79 -0
- package/dist/modules/personLinks.d.ts.map +1 -0
- package/dist/modules/personLinks.js +155 -0
- package/dist/modules/personLinks.js.map +1 -0
- package/dist/modules/pipelines/routes.d.ts +1 -0
- package/dist/modules/pipelines/routes.d.ts.map +1 -1
- package/dist/modules/plans/routes.d.ts +1 -0
- package/dist/modules/plans/routes.d.ts.map +1 -1
- package/dist/modules/positions/routes.d.ts.map +1 -1
- package/dist/modules/positions/routes.js +4 -2
- package/dist/modules/positions/routes.js.map +1 -1
- package/dist/modules/raises/index.d.ts.map +1 -1
- package/dist/modules/raises/index.js +3 -1
- package/dist/modules/raises/index.js.map +1 -1
- package/dist/modules/raises/repository.d.ts +0 -17
- package/dist/modules/raises/repository.d.ts.map +1 -1
- package/dist/modules/raises/repository.js +6 -77
- package/dist/modules/raises/repository.js.map +1 -1
- package/dist/modules/raises/routes.d.ts +14 -0
- package/dist/modules/raises/routes.d.ts.map +1 -1
- package/dist/modules/raises/routes.js +7 -0
- package/dist/modules/raises/routes.js.map +1 -1
- package/dist/modules/raises/schema.d.ts +20 -41
- package/dist/modules/raises/schema.d.ts.map +1 -1
- package/dist/modules/raises/schema.js +6 -10
- package/dist/modules/raises/schema.js.map +1 -1
- package/dist/modules/raises/service.d.ts +11 -1
- package/dist/modules/raises/service.d.ts.map +1 -1
- package/dist/modules/raises/service.js +41 -18
- package/dist/modules/raises/service.js.map +1 -1
- package/dist/modules/recordTargets.d.ts.map +1 -1
- package/dist/modules/recordTargets.js +2 -0
- package/dist/modules/recordTargets.js.map +1 -1
- package/dist/modules/references.d.ts +10 -0
- package/dist/modules/references.d.ts.map +1 -1
- package/dist/modules/references.js +27 -4
- package/dist/modules/references.js.map +1 -1
- package/dist/modules/sample-data/fixture.d.ts +160 -0
- package/dist/modules/sample-data/fixture.d.ts.map +1 -0
- package/dist/modules/sample-data/fixture.js +501 -0
- package/dist/modules/sample-data/fixture.js.map +1 -0
- package/dist/modules/sample-data/index.d.ts +11 -0
- package/dist/modules/sample-data/index.d.ts.map +1 -0
- package/dist/modules/sample-data/index.js +44 -0
- package/dist/modules/sample-data/index.js.map +1 -0
- package/dist/modules/sample-data/routes.d.ts +15 -0
- package/dist/modules/sample-data/routes.d.ts.map +1 -0
- package/dist/modules/sample-data/routes.js +25 -0
- package/dist/modules/sample-data/routes.js.map +1 -0
- package/dist/modules/sample-data/service.d.ts +39 -0
- package/dist/modules/sample-data/service.d.ts.map +1 -0
- package/dist/modules/sample-data/service.js +481 -0
- package/dist/modules/sample-data/service.js.map +1 -0
- package/dist/modules/sample-data/tools.d.ts +4 -0
- package/dist/modules/sample-data/tools.d.ts.map +1 -0
- package/dist/modules/sample-data/tools.js +22 -0
- package/dist/modules/sample-data/tools.js.map +1 -0
- package/dist/modules/search/index.d.ts +1 -1
- package/dist/modules/search/index.d.ts.map +1 -1
- package/dist/modules/search/index.js +2 -1
- package/dist/modules/search/index.js.map +1 -1
- package/dist/modules/search/repository.d.ts +1 -0
- package/dist/modules/search/repository.d.ts.map +1 -1
- package/dist/modules/search/repository.js +23 -0
- package/dist/modules/search/repository.js.map +1 -1
- package/dist/modules/search/service.d.ts +3 -3
- package/dist/modules/search/service.d.ts.map +1 -1
- package/dist/modules/search/service.js +5 -4
- package/dist/modules/search/service.js.map +1 -1
- package/dist/modules/smtp-email/index.d.ts +1 -0
- package/dist/modules/smtp-email/index.d.ts.map +1 -1
- package/dist/modules/smtp-email/index.js +1 -0
- package/dist/modules/smtp-email/index.js.map +1 -1
- package/dist/modules/stagedRecords.d.ts +3 -3
- package/dist/modules/stagedRecords.d.ts.map +1 -1
- package/dist/modules/stagedRecords.js +9 -0
- package/dist/modules/stagedRecords.js.map +1 -1
- package/dist/modules/webhooks/payloads.d.ts.map +1 -1
- package/dist/modules/webhooks/payloads.js +15 -2
- package/dist/modules/webhooks/payloads.js.map +1 -1
- package/dist/modules/workspace/repository.d.ts +2 -0
- package/dist/modules/workspace/repository.d.ts.map +1 -1
- package/dist/modules/workspace/repository.js +7 -0
- package/dist/modules/workspace/repository.js.map +1 -1
- package/dist/modules/workspace/service.d.ts.map +1 -1
- package/dist/modules/workspace/service.js +20 -1
- package/dist/modules/workspace/service.js.map +1 -1
- package/dist/modules/workspace/starters.d.ts.map +1 -1
- package/dist/modules/workspace/starters.js +5 -0
- package/dist/modules/workspace/starters.js.map +1 -1
- package/dist/runtime/events.d.ts +1 -1
- package/dist/runtime/events.d.ts.map +1 -1
- package/dist/runtime/events.js +1 -0
- package/dist/runtime/events.js.map +1 -1
- package/dist/schema/index.d.ts +4 -0
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +4 -0
- package/dist/schema/index.js.map +1 -1
- package/dist/testing/database.d.ts +5 -1
- package/dist/testing/database.d.ts.map +1 -1
- package/dist/testing/database.js +81 -10
- package/dist/testing/database.js.map +1 -1
- package/migrations/0021_certain_maggott.sql +30 -0
- package/migrations/0022_stormy_manta.sql +1 -0
- package/migrations/0023_funny_maddog.sql +1 -0
- package/migrations/0024_third_king_cobra.sql +46 -0
- package/migrations/0025_worthless_chimera.sql +3 -0
- package/migrations/0026_late_aqueduct.sql +46 -0
- package/migrations/0027_brainy_silver_sable.sql +3 -0
- package/migrations/0028_freezing_scrambler.sql +19 -0
- package/migrations/0029_custom_fields.sql +26 -0
- package/migrations/0030_enquiries.sql +79 -0
- package/migrations/0031_consent.sql +45 -0
- package/migrations/0032_form_field_statement.sql +1 -0
- package/migrations/0033_form_field_consent_purpose_ids.sql +5 -0
- package/migrations/0034_drop_form_field_consent_purpose_id.sql +1 -0
- package/migrations/0035_form_field_consent_purpose_labels.sql +1 -0
- package/migrations/0036_form_field_notice_type.sql +2 -0
- package/migrations/meta/0021_snapshot.json +5389 -0
- package/migrations/meta/0022_snapshot.json +5396 -0
- package/migrations/meta/0023_snapshot.json +5403 -0
- package/migrations/meta/0024_snapshot.json +5516 -0
- package/migrations/meta/0025_snapshot.json +5336 -0
- package/migrations/meta/0026_snapshot.json +5710 -0
- package/migrations/meta/0027_snapshot.json +5716 -0
- package/migrations/meta/0028_snapshot.json +5740 -0
- package/migrations/meta/0029_snapshot.json +5935 -0
- package/migrations/meta/0030_snapshot.json +6245 -0
- package/migrations/meta/0031_snapshot.json +6572 -0
- package/migrations/meta/0032_snapshot.json +6578 -0
- package/migrations/meta/0033_snapshot.json +6572 -0
- package/migrations/meta/0034_snapshot.json +6566 -0
- package/migrations/meta/0035_snapshot.json +6573 -0
- package/migrations/meta/0036_snapshot.json +6573 -0
- package/migrations/meta/_journal.json +112 -0
- package/package.json +3 -2
- package/src/lib/consumerEmailDomains.ts +62 -0
- package/src/lib/email.ts +7 -0
- package/src/lib/emailContent.ts +91 -0
- package/src/lib/emailDomainAutoLink.ts +165 -0
- package/src/lib/ids.ts +13 -0
- package/src/modules/activities/repository.ts +22 -23
- package/src/modules/activities/wording.ts +18 -0
- package/src/modules/agent-tasks/catalog.ts +63 -0
- package/src/modules/agent-tasks/resolve.ts +64 -24
- package/src/modules/attachedRecords.ts +37 -3
- package/src/modules/auth/preferences.ts +13 -1
- package/src/modules/auth/routes.ts +22 -0
- package/src/modules/auth/schema.ts +12 -2
- package/src/modules/auth/service.ts +37 -3
- package/src/modules/companies/index.ts +3 -1
- package/src/modules/companies/repository.ts +3 -0
- package/src/modules/companies/routes.ts +20 -0
- package/src/modules/companies/schema.ts +11 -1
- package/src/modules/companies/service.ts +72 -12
- package/src/modules/consent-purposes/capabilities.ts +12 -0
- package/src/modules/consent-purposes/events.ts +38 -0
- package/src/modules/consent-purposes/index.ts +48 -0
- package/src/modules/consent-purposes/repository.ts +163 -0
- package/src/modules/consent-purposes/routes.ts +122 -0
- package/src/modules/consent-purposes/schema.ts +46 -0
- package/src/modules/consent-purposes/service.ts +423 -0
- package/src/modules/consent-purposes/starters.ts +32 -0
- package/src/modules/consent-purposes/tools.ts +44 -0
- package/src/modules/core.ts +21 -0
- package/src/modules/custom-fields/capabilities.ts +17 -0
- package/src/modules/custom-fields/events.ts +51 -0
- package/src/modules/custom-fields/index.ts +61 -0
- package/src/modules/custom-fields/repository.ts +225 -0
- package/src/modules/custom-fields/routes.ts +155 -0
- package/src/modules/custom-fields/schema.ts +61 -0
- package/src/modules/custom-fields/service.ts +439 -0
- package/src/modules/custom-fields/tools.ts +53 -0
- package/src/modules/custom-fields/values.ts +352 -0
- package/src/modules/custom-fields/wire.ts +32 -0
- package/src/modules/dashboard/repository.ts +4 -3
- package/src/modules/deals/index.ts +5 -2
- package/src/modules/deals/repository.ts +6 -106
- package/src/modules/deals/routes.ts +7 -0
- package/src/modules/deals/schema.ts +7 -15
- package/src/modules/deals/service.ts +92 -23
- package/src/modules/decisions/repository.ts +2 -0
- package/src/modules/email-domain-linker/index.ts +40 -0
- package/src/modules/email-domain-linker/routes.ts +40 -0
- package/src/modules/email-domain-linker/service.ts +122 -0
- package/src/modules/enquiries/events.ts +45 -0
- package/src/modules/enquiries/index.ts +50 -0
- package/src/modules/enquiries/repository.ts +164 -0
- package/src/modules/enquiries/routes.ts +172 -0
- package/src/modules/enquiries/schema.ts +59 -0
- package/src/modules/enquiries/service.ts +644 -0
- package/src/modules/enquiries/tools.ts +66 -0
- package/src/modules/eventCatalogs.ts +4 -0
- package/src/modules/forms/embed.ts +391 -44
- package/src/modules/forms/events.ts +30 -2
- package/src/modules/forms/fields.ts +102 -2
- package/src/modules/forms/index.ts +12 -1
- package/src/modules/forms/mapping.ts +183 -6
- package/src/modules/forms/publicRoutes.ts +43 -1
- package/src/modules/forms/repository.ts +162 -1
- package/src/modules/forms/routes.ts +212 -2
- package/src/modules/forms/schema.ts +166 -4
- package/src/modules/forms/service.ts +565 -41
- package/src/modules/forms/submission.ts +718 -44
- package/src/modules/import-export/drafts.ts +20 -1
- package/src/modules/import-export/exportRows.ts +21 -5
- package/src/modules/import-export/plan.ts +47 -2
- package/src/modules/import-export/presets.ts +10 -0
- package/src/modules/import-export/repository.ts +73 -8
- package/src/modules/import-export/routes.ts +4 -0
- package/src/modules/import-export/schema.ts +11 -0
- package/src/modules/import-export/service.ts +28 -2
- package/src/modules/import-export/streams.ts +3 -1
- package/src/modules/import-export/tools.ts +10 -0
- package/src/modules/import-export/validation.ts +28 -0
- package/src/modules/import-export/writes.ts +70 -5
- package/src/modules/lists/events.ts +41 -0
- package/src/modules/lists/index.ts +41 -0
- package/src/modules/lists/repository.ts +343 -0
- package/src/modules/lists/routes.ts +255 -0
- package/src/modules/lists/schema.ts +95 -0
- package/src/modules/lists/service.ts +505 -0
- package/src/modules/lists/tools.ts +128 -0
- package/src/modules/mcp/index.ts +5 -0
- package/src/modules/opportunities/index.ts +3 -1
- package/src/modules/opportunities/repository.ts +11 -0
- package/src/modules/opportunities/routes.ts +13 -0
- package/src/modules/opportunities/schema.ts +7 -1
- package/src/modules/opportunities/service.ts +188 -22
- package/src/modules/opportunities/tools.ts +2 -0
- package/src/modules/partnerships/index.ts +3 -1
- package/src/modules/partnerships/repository.ts +6 -117
- package/src/modules/partnerships/routes.ts +7 -0
- package/src/modules/partnerships/schema.ts +7 -14
- package/src/modules/partnerships/service.ts +93 -22
- package/src/modules/people/consentHydration.ts +167 -0
- package/src/modules/people/index.ts +3 -1
- package/src/modules/people/personConsentWrites.ts +177 -0
- package/src/modules/people/repository.ts +31 -0
- package/src/modules/people/routes.ts +127 -18
- package/src/modules/people/schema.ts +109 -3
- package/src/modules/people/service.ts +205 -39
- package/src/modules/people/tools.ts +5 -1
- package/src/modules/personLinks.ts +278 -0
- package/src/modules/positions/routes.ts +4 -2
- package/src/modules/raises/index.ts +3 -1
- package/src/modules/raises/repository.ts +6 -107
- package/src/modules/raises/routes.ts +7 -0
- package/src/modules/raises/schema.ts +7 -14
- package/src/modules/raises/service.ts +91 -20
- package/src/modules/recordTargets.ts +2 -0
- package/src/modules/references.ts +43 -4
- package/src/modules/sample-data/fixture.ts +690 -0
- package/src/modules/sample-data/index.ts +51 -0
- package/src/modules/sample-data/routes.ts +50 -0
- package/src/modules/sample-data/service.ts +679 -0
- package/src/modules/sample-data/tools.ts +32 -0
- package/src/modules/search/index.ts +2 -1
- package/src/modules/search/repository.ts +33 -1
- package/src/modules/search/service.ts +7 -5
- package/src/modules/smtp-email/index.ts +8 -1
- package/src/modules/stagedRecords.ts +18 -3
- package/src/modules/webhooks/payloads.ts +20 -2
- package/src/modules/workspace/repository.ts +12 -0
- package/src/modules/workspace/service.ts +27 -1
- package/src/modules/workspace/starters.ts +5 -0
- package/src/runtime/events.ts +1 -0
- package/src/schema/index.ts +4 -0
- package/src/testing/database.ts +97 -11
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { and,
|
|
1
|
+
import { and, eq, ilike, inArray, or, sql } from 'drizzle-orm';
|
|
2
2
|
import { keysetCondition, orderByWindow, textSort, timestampSort } from '../../lib/pagination.js';
|
|
3
3
|
import { arrayContainsPattern, containsPattern } from '../../lib/search.js';
|
|
4
4
|
import { companies } from '../companies/schema.js';
|
|
5
|
-
import {
|
|
5
|
+
import { anyPersonLinked } from '../personLinks.js';
|
|
6
6
|
import { workspaceMembers } from '../workspace/schema.js';
|
|
7
|
-
import {
|
|
7
|
+
import { deals } from './schema.js';
|
|
8
8
|
/** The sort fields `?sort=` documents for deals. Nullable columns (value, close date) stay out: a keyset cannot seek past a null. */
|
|
9
9
|
export const DEAL_SORTS = {
|
|
10
10
|
name: textSort(deals.name, (deal) => deal.name),
|
|
@@ -25,14 +25,6 @@ function companyNameMatches(pattern) {
|
|
|
25
25
|
and ${companies.name} ilike ${pattern}
|
|
26
26
|
)`;
|
|
27
27
|
}
|
|
28
|
-
function hasAnyOfPeople(personIds) {
|
|
29
|
-
return sql `exists (
|
|
30
|
-
select 1
|
|
31
|
-
from ${dealPeople}
|
|
32
|
-
where ${dealPeople.dealId} = ${deals.id}
|
|
33
|
-
and ${inArray(dealPeople.personId, personIds)}
|
|
34
|
-
)`;
|
|
35
|
-
}
|
|
36
28
|
function matchesTerm(term) {
|
|
37
29
|
const pattern = containsPattern(term);
|
|
38
30
|
return or(ilike(deals.name, pattern), ilike(deals.summary, pattern), arrayContainsPattern(deals.tags, pattern), arrayContainsPattern(deals.competitors, pattern), companyNameMatches(pattern));
|
|
@@ -43,7 +35,9 @@ function conditionsFor(workspaceId, filters) {
|
|
|
43
35
|
filters.term === undefined ? undefined : matchesTerm(filters.term),
|
|
44
36
|
filters.companyIds === undefined ? undefined : inArray(deals.companyId, filters.companyIds),
|
|
45
37
|
filters.stageIds === undefined ? undefined : inArray(deals.stageId, filters.stageIds),
|
|
46
|
-
filters.personIds === undefined
|
|
38
|
+
filters.personIds === undefined
|
|
39
|
+
? undefined
|
|
40
|
+
: anyPersonLinked('deal', deals.id, deals.workspaceId, filters.personIds),
|
|
47
41
|
];
|
|
48
42
|
}
|
|
49
43
|
/** @returns Up to `window.fetchLimit` rows: one more than the page, so the caller can tell there is a next one. */
|
|
@@ -85,70 +79,6 @@ export async function deleteDeal(db, workspaceId, id) {
|
|
|
85
79
|
.returning({ id: deals.id });
|
|
86
80
|
return deleted.length;
|
|
87
81
|
}
|
|
88
|
-
/** The people on one deal. Ordered by id so a response is stable across reads. */
|
|
89
|
-
export async function listPersonIds(db, dealId) {
|
|
90
|
-
const rows = await db
|
|
91
|
-
.select({ personId: dealPeople.personId })
|
|
92
|
-
.from(dealPeople)
|
|
93
|
-
.where(eq(dealPeople.dealId, dealId))
|
|
94
|
-
.orderBy(asc(dealPeople.personId));
|
|
95
|
-
return rows.map((row) => row.personId);
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* The people on each of a page of deals, in one query rather than one per row.
|
|
99
|
-
*
|
|
100
|
-
* @returns Ids missing from the map have no people.
|
|
101
|
-
*/
|
|
102
|
-
export async function listPersonIdsFor(db, dealIds) {
|
|
103
|
-
if (dealIds.length === 0) {
|
|
104
|
-
return new Map();
|
|
105
|
-
}
|
|
106
|
-
const rows = await db
|
|
107
|
-
.select({ dealId: dealPeople.dealId, personId: dealPeople.personId })
|
|
108
|
-
.from(dealPeople)
|
|
109
|
-
.where(inArray(dealPeople.dealId, dealIds))
|
|
110
|
-
.orderBy(asc(dealPeople.personId));
|
|
111
|
-
const byDeal = new Map();
|
|
112
|
-
for (const row of rows) {
|
|
113
|
-
const existing = byDeal.get(row.dealId);
|
|
114
|
-
if (existing === undefined) {
|
|
115
|
-
byDeal.set(row.dealId, [row.personId]);
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
existing.push(row.personId);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return byDeal;
|
|
122
|
-
}
|
|
123
|
-
export async function insertDealPeople(db, dealId, personIds) {
|
|
124
|
-
if (personIds.length === 0) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
await db.insert(dealPeople).values(personIds.map((personId) => ({ dealId, personId })));
|
|
128
|
-
}
|
|
129
|
-
export async function deleteDealPeople(db, dealId, personIds) {
|
|
130
|
-
if (personIds.length === 0) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
await db
|
|
134
|
-
.delete(dealPeople)
|
|
135
|
-
.where(and(eq(dealPeople.dealId, dealId), inArray(dealPeople.personId, personIds)));
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* The names of these people in this workspace, keyed by id. An id missing from
|
|
139
|
-
* the map does not exist here, which is how `person_ids` is validated. Reads the
|
|
140
|
-
* `people` *table*, per the cross-relation rule in `architecture.md`.
|
|
141
|
-
*/
|
|
142
|
-
export async function findPeopleNamed(db, workspaceId, personIds) {
|
|
143
|
-
if (personIds.length === 0) {
|
|
144
|
-
return new Map();
|
|
145
|
-
}
|
|
146
|
-
const rows = await db
|
|
147
|
-
.select({ id: people.id, name: people.name })
|
|
148
|
-
.from(people)
|
|
149
|
-
.where(and(eq(people.workspaceId, workspaceId), inArray(people.id, personIds)));
|
|
150
|
-
return new Map(rows.map((row) => [row.id, row.name]));
|
|
151
|
-
}
|
|
152
82
|
/** Whether a member belongs to this workspace, for validating `owner_id`. */
|
|
153
83
|
export async function memberExists(db, workspaceId, memberId) {
|
|
154
84
|
const [found] = await db
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.js","sourceRoot":"","sources":["../../../src/modules/deals/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"repository.js","sourceRoot":"","sources":["../../../src/modules/deals/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAG9D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAEjG,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAE3E,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAOnC,qIAAqI;AACrI,MAAM,CAAC,MAAM,UAAU,GAA+B;IACpD,IAAI,EAAE,QAAQ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,KAAK,UAAU,YAAY,CAChC,EAAa,EACb,WAAmB,EACnB,QAAgB;IAEhB,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,EAAE;SACrB,MAAM,CAAC,EAAE,EAAE,EAAE,gBAAgB,CAAC,EAAE,EAAE,CAAC;SACnC,IAAI,CAAC,gBAAgB,CAAC;SACtB,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,gBAAgB,CAAC,WAAW,EAAE,WAAW,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC;SAC5F,KAAK,CAAC,CAAC,CAAC,CAAA;IAEX,OAAO,KAAK,KAAK,SAAS,CAAA;AAC5B,CAAC"}
|
|
@@ -23,6 +23,13 @@ export declare const createBody: z.ZodObject<{
|
|
|
23
23
|
summary: z.ZodDefault<z.ZodString>;
|
|
24
24
|
tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
25
25
|
external_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
26
|
+
custom_fields: z.ZodDefault<z.ZodType<Readonly<Record<string, string | number | boolean | string[] | {
|
|
27
|
+
amount_cents: number;
|
|
28
|
+
currency: string;
|
|
29
|
+
} | null>>, unknown, z.core.$ZodTypeInternals<Readonly<Record<string, string | number | boolean | string[] | {
|
|
30
|
+
amount_cents: number;
|
|
31
|
+
currency: string;
|
|
32
|
+
} | null>>, unknown>>>;
|
|
26
33
|
}, z.core.$strict>;
|
|
27
34
|
export declare const updateBody: z.ZodObject<{
|
|
28
35
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -39,6 +46,13 @@ export declare const updateBody: z.ZodObject<{
|
|
|
39
46
|
summary: z.ZodOptional<z.ZodString>;
|
|
40
47
|
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
41
48
|
external_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
49
|
+
custom_fields: z.ZodOptional<z.ZodType<Readonly<Record<string, string | number | boolean | string[] | {
|
|
50
|
+
amount_cents: number;
|
|
51
|
+
currency: string;
|
|
52
|
+
} | null>>, unknown, z.core.$ZodTypeInternals<Readonly<Record<string, string | number | boolean | string[] | {
|
|
53
|
+
amount_cents: number;
|
|
54
|
+
currency: string;
|
|
55
|
+
} | null>>, unknown>>>;
|
|
42
56
|
}, z.core.$strict>;
|
|
43
57
|
export interface DealsRoutesDependencies extends CredentialDependencies {
|
|
44
58
|
readonly service: DealsService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../../src/modules/deals/routes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../../src/modules/deals/routes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAA;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAEpE,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAuB5F;;;;;GAKG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;kBAerB,CAAA;AAEF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;kBAAsC,CAAA;AAE7D,MAAM,WAAW,uBAAwB,SAAQ,sBAAsB;IACrE,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAA;CAC/B;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,GAAG,eAAe,CAkB/E;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,GAAG,eAAe,CAkB/E;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAqBpE;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,uBAAuB,GAAG,IAAI,CA+C1F"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { customFieldsPatchShape } from '@kelpie/schemas';
|
|
1
2
|
import { z } from 'zod';
|
|
2
3
|
import { isoDateSchema } from '../../lib/dates.js';
|
|
3
4
|
import { pageBody, readIdFilter, readJsonBody, readListParameters } from '../../lib/http.js';
|
|
4
5
|
import { resolveActorFrom } from '../auth/credentials.js';
|
|
6
|
+
import { renderCustomFieldsForWire } from '../custom-fields/wire.js';
|
|
5
7
|
/** Wire shapes for `/v1/deals`. Bodies are strict; an unknown field is a 422, per `api.md`. */
|
|
6
8
|
/** The full field set, without defaults. `createBody` adds those; `updateBody` makes it partial. */
|
|
7
9
|
const dealShape = {
|
|
@@ -19,6 +21,7 @@ const dealShape = {
|
|
|
19
21
|
summary: z.string(),
|
|
20
22
|
tags: z.array(z.string().min(1)),
|
|
21
23
|
external_id: z.string().min(1).nullable(),
|
|
24
|
+
custom_fields: customFieldsPatchShape,
|
|
22
25
|
};
|
|
23
26
|
/**
|
|
24
27
|
* Only `name` and `company_id` are required. An absent `stage_id` lands in the
|
|
@@ -40,6 +43,7 @@ export const createBody = z.strictObject({
|
|
|
40
43
|
summary: dealShape.summary.default(''),
|
|
41
44
|
tags: dealShape.tags.default([]),
|
|
42
45
|
external_id: dealShape.external_id.default(null),
|
|
46
|
+
custom_fields: dealShape.custom_fields.default({}),
|
|
43
47
|
});
|
|
44
48
|
export const updateBody = z.strictObject(dealShape).partial();
|
|
45
49
|
export function toCreateInput(body) {
|
|
@@ -58,6 +62,7 @@ export function toCreateInput(body) {
|
|
|
58
62
|
summary: body.summary,
|
|
59
63
|
tags: body.tags,
|
|
60
64
|
externalId: body.external_id,
|
|
65
|
+
customFields: body.custom_fields,
|
|
61
66
|
};
|
|
62
67
|
}
|
|
63
68
|
export function toUpdateInput(body) {
|
|
@@ -76,6 +81,7 @@ export function toUpdateInput(body) {
|
|
|
76
81
|
...(body.summary === undefined ? {} : { summary: body.summary }),
|
|
77
82
|
...(body.tags === undefined ? {} : { tags: body.tags }),
|
|
78
83
|
...(body.external_id === undefined ? {} : { externalId: body.external_id }),
|
|
84
|
+
...(body.custom_fields === undefined ? {} : { customFields: body.custom_fields }),
|
|
79
85
|
};
|
|
80
86
|
}
|
|
81
87
|
export function dealResponse(deal) {
|
|
@@ -95,6 +101,7 @@ export function dealResponse(deal) {
|
|
|
95
101
|
summary: deal.summary,
|
|
96
102
|
tags: deal.tags,
|
|
97
103
|
external_id: deal.externalId,
|
|
104
|
+
custom_fields: renderCustomFieldsForWire(deal.customFields),
|
|
98
105
|
created_at: deal.createdAt.toISOString(),
|
|
99
106
|
updated_at: deal.updatedAt.toISOString(),
|
|
100
107
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../../src/modules/deals/routes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../../src/modules/deals/routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAExD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAE5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAEzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAA;AAGpE,+FAA+F;AAE/F,oGAAoG;AACpG,MAAM,SAAS,GAAG;IAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,UAAU,EAAE,CAAC,CAAC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C,IAAI,CAAC,EACvB,aAAa,CAAC,IAAI,CAAC,CACpB,CAAA;QAED,OAAO,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAA;IACzC,CAAC,CAAC,CAAA;IAEF,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QAC5C,MAAM,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,YAAY,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;QAEvF,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IAChC,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CustomFieldValue } from '@kelpie/schemas';
|
|
1
2
|
/**
|
|
2
3
|
* The sales pipeline. Money is integer cents plus a currency code, never a float
|
|
3
4
|
* (`api.md`).
|
|
@@ -316,6 +317,25 @@ export declare const deals: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
316
317
|
identity: undefined;
|
|
317
318
|
generated: undefined;
|
|
318
319
|
}, {}, {}>;
|
|
320
|
+
customFields: import("drizzle-orm/pg-core").PgColumn<{
|
|
321
|
+
name: "custom_fields";
|
|
322
|
+
tableName: "deals";
|
|
323
|
+
dataType: "json";
|
|
324
|
+
columnType: "PgJsonb";
|
|
325
|
+
data: Readonly<Record<string, CustomFieldValue>>;
|
|
326
|
+
driverParam: unknown;
|
|
327
|
+
notNull: true;
|
|
328
|
+
hasDefault: true;
|
|
329
|
+
isPrimaryKey: false;
|
|
330
|
+
isAutoincrement: false;
|
|
331
|
+
hasRuntimeDefault: false;
|
|
332
|
+
enumValues: undefined;
|
|
333
|
+
baseColumn: never;
|
|
334
|
+
identity: undefined;
|
|
335
|
+
generated: undefined;
|
|
336
|
+
}, {}, {
|
|
337
|
+
$type: Readonly<Record<string, CustomFieldValue>>;
|
|
338
|
+
}>;
|
|
319
339
|
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
320
340
|
name: "created_at";
|
|
321
341
|
tableName: "deals";
|
|
@@ -374,46 +394,4 @@ export declare const deals: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
374
394
|
};
|
|
375
395
|
dialect: 'pg';
|
|
376
396
|
}>;
|
|
377
|
-
/** People attached to a deal. Restrict on person: a deal contact cannot vanish. */
|
|
378
|
-
export declare const dealPeople: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
379
|
-
name: "deal_people";
|
|
380
|
-
schema: undefined;
|
|
381
|
-
columns: {
|
|
382
|
-
dealId: import("drizzle-orm/pg-core").PgColumn<{
|
|
383
|
-
name: "deal_id";
|
|
384
|
-
tableName: "deal_people";
|
|
385
|
-
dataType: "string";
|
|
386
|
-
columnType: "PgText";
|
|
387
|
-
data: string;
|
|
388
|
-
driverParam: string;
|
|
389
|
-
notNull: true;
|
|
390
|
-
hasDefault: false;
|
|
391
|
-
isPrimaryKey: false;
|
|
392
|
-
isAutoincrement: false;
|
|
393
|
-
hasRuntimeDefault: false;
|
|
394
|
-
enumValues: [string, ...string[]];
|
|
395
|
-
baseColumn: never;
|
|
396
|
-
identity: undefined;
|
|
397
|
-
generated: undefined;
|
|
398
|
-
}, {}, {}>;
|
|
399
|
-
personId: import("drizzle-orm/pg-core").PgColumn<{
|
|
400
|
-
name: "person_id";
|
|
401
|
-
tableName: "deal_people";
|
|
402
|
-
dataType: "string";
|
|
403
|
-
columnType: "PgText";
|
|
404
|
-
data: string;
|
|
405
|
-
driverParam: string;
|
|
406
|
-
notNull: true;
|
|
407
|
-
hasDefault: false;
|
|
408
|
-
isPrimaryKey: false;
|
|
409
|
-
isAutoincrement: false;
|
|
410
|
-
hasRuntimeDefault: false;
|
|
411
|
-
enumValues: [string, ...string[]];
|
|
412
|
-
baseColumn: never;
|
|
413
|
-
identity: undefined;
|
|
414
|
-
generated: undefined;
|
|
415
|
-
}, {}, {}>;
|
|
416
|
-
};
|
|
417
|
-
dialect: 'pg';
|
|
418
|
-
}>;
|
|
419
397
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/modules/deals/schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/modules/deals/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AASvD;;;;;;GAMG;AACH,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8CjB,CAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { bigint, date, index,
|
|
1
|
+
import { bigint, date, index, jsonb, pgTable, text } from 'drizzle-orm/pg-core';
|
|
2
2
|
import { createdAt, primaryId, searchVector, updatedAt } from '../../lib/columns.js';
|
|
3
3
|
import { companies } from '../companies/schema.js';
|
|
4
|
-
import { people } from '../people/schema.js';
|
|
5
4
|
import { pipelineStages } from '../pipelines/schema.js';
|
|
6
5
|
import { workspaceMembers, workspaces } from '../workspace/schema.js';
|
|
7
6
|
/**
|
|
@@ -33,6 +32,11 @@ export const deals = pgTable('deals', {
|
|
|
33
32
|
summary: text('summary').notNull().default(''),
|
|
34
33
|
tags: text('tags').array().notNull().default([]),
|
|
35
34
|
externalId: text('external_id'),
|
|
35
|
+
// Workspace-defined fields, keyed by definition key. See people/schema.ts.
|
|
36
|
+
customFields: jsonb('custom_fields')
|
|
37
|
+
.$type()
|
|
38
|
+
.notNull()
|
|
39
|
+
.default({}),
|
|
36
40
|
createdAt: createdAt(),
|
|
37
41
|
updatedAt: updatedAt(),
|
|
38
42
|
searchVector: searchVector(() => [
|
|
@@ -49,13 +53,4 @@ export const deals = pgTable('deals', {
|
|
|
49
53
|
index('deals_stage_idx').on(table.stageId),
|
|
50
54
|
index('deals_search_idx').using('gin', table.searchVector),
|
|
51
55
|
]);
|
|
52
|
-
/** People attached to a deal. Restrict on person: a deal contact cannot vanish. */
|
|
53
|
-
export const dealPeople = pgTable('deal_people', {
|
|
54
|
-
dealId: text('deal_id')
|
|
55
|
-
.notNull()
|
|
56
|
-
.references(() => deals.id, { onDelete: 'cascade' }),
|
|
57
|
-
personId: text('person_id')
|
|
58
|
-
.notNull()
|
|
59
|
-
.references(() => people.id, { onDelete: 'restrict' }),
|
|
60
|
-
}, (table) => [primaryKey({ columns: [table.dealId, table.personId] })]);
|
|
61
56
|
//# sourceMappingURL=schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/modules/deals/schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/modules/deals/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAE/E,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAEpF,OAAO,EAAE,SAAS,EAAE,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ClD,KAAK,CAAC,mBAAmB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC;IAC9C,KAAK,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC;IAC1C,KAAK,CAAC,kBAAkB,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC;CAC3D,CACF,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CustomFieldWireValue } from '@kelpie/schemas';
|
|
1
2
|
import type { Database } from '../../lib/database.ts';
|
|
2
3
|
import type { IdFactory } from '../../lib/ids.ts';
|
|
3
4
|
import type { ListQueryParameters, Page } from '../../lib/pagination.ts';
|
|
@@ -5,12 +6,13 @@ import type { TransactionScope } from '../../runtime/transaction.ts';
|
|
|
5
6
|
import type { ActivityRecorder } from '../activities/recorder.ts';
|
|
6
7
|
import type { Actor } from '../auth/actor.ts';
|
|
7
8
|
import './events.ts';
|
|
9
|
+
import type { CustomFieldValuesValidator } from '../custom-fields/values.ts';
|
|
8
10
|
import type { DealFilters, DealRecord } from './repository.ts';
|
|
9
11
|
/**
|
|
10
12
|
* Deals: the sales pipeline, and the first of the four staged objects.
|
|
11
13
|
*
|
|
12
|
-
* People attach through `
|
|
13
|
-
* the
|
|
14
|
+
* People attach through `person_links` and appear as `person_ids` on the wire;
|
|
15
|
+
* the polymorphic link table is a storage detail. A stage move is an ordinary PATCH of
|
|
14
16
|
* `stage_id`, and it is the one change that files a `stage_changed` activity and
|
|
15
17
|
* a `stage.changed` event instead of the generic update pair.
|
|
16
18
|
*/
|
|
@@ -20,6 +22,7 @@ export interface DealsDependencies {
|
|
|
20
22
|
readonly createId: IdFactory;
|
|
21
23
|
readonly now: () => Date;
|
|
22
24
|
readonly recordActivity: ActivityRecorder;
|
|
25
|
+
readonly customFields: CustomFieldValuesValidator;
|
|
23
26
|
}
|
|
24
27
|
/** A deal as the API returns one: the stored row minus tenancy, plus its people. */
|
|
25
28
|
export type DealView = Omit<DealRecord, 'workspaceId'> & {
|
|
@@ -42,6 +45,8 @@ export interface CreateDealInput {
|
|
|
42
45
|
readonly summary: string;
|
|
43
46
|
readonly tags: readonly string[];
|
|
44
47
|
readonly externalId: string | null;
|
|
48
|
+
/** Wire shape for a create body: `null` values are ignored, non-null are validated. */
|
|
49
|
+
readonly customFields: Readonly<Record<string, CustomFieldWireValue | null>> | undefined;
|
|
45
50
|
}
|
|
46
51
|
/** PATCH semantics: an absent field is left alone, and null clears a nullable one. */
|
|
47
52
|
export interface UpdateDealInput {
|
|
@@ -60,6 +65,12 @@ export interface UpdateDealInput {
|
|
|
60
65
|
readonly summary?: string | undefined;
|
|
61
66
|
readonly tags?: readonly string[] | undefined;
|
|
62
67
|
readonly externalId?: string | null | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Partial merge patch (wire shape): sent keys change, `null` clears a key,
|
|
70
|
+
* absent keys are left alone. The whole object is undefined when the caller
|
|
71
|
+
* sent nothing at all. Unknown keys are `422`.
|
|
72
|
+
*/
|
|
73
|
+
readonly customFields?: Readonly<Record<string, CustomFieldWireValue | null>> | undefined;
|
|
63
74
|
}
|
|
64
75
|
export interface DealsService {
|
|
65
76
|
list(actor: Actor, filters: DealFilters, query: ListQueryParameters): Promise<Page<DealView>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/modules/deals/service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/modules/deals/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAG3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAErD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAEjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,yBAA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attachedRecords.js';
|
|
9
9
|
import * as companyRepository from '../companies/repository.js';
|
|
10
|
+
import * as personLinks from '../personLinks.js';
|
|
10
11
|
import * as pipelineRepository from '../pipelines/repository.js';
|
|
11
12
|
import * as repository from './repository.js';
|
|
12
13
|
import { DEAL_SORTS, DEFAULT_DEAL_SORT } from './repository.js';
|
|
@@ -96,7 +97,7 @@ export function createDealsService(dependencies) {
|
|
|
96
97
|
}
|
|
97
98
|
/** @returns Each person's name, for the link activities. Any id missing here is a 404. */
|
|
98
99
|
async function requirePeople(workspaceId, personIds) {
|
|
99
|
-
const named = await
|
|
100
|
+
const named = await personLinks.findPeopleNamed(dependencies.db, workspaceId, personIds);
|
|
100
101
|
const missing = personIds.filter((id) => !named.has(id));
|
|
101
102
|
if (missing.length > 0) {
|
|
102
103
|
throw new AppError('not_found', 'Person not found', missing.map((id) => ({ field: 'person_ids', message: `No person ${id} here` })));
|
|
@@ -104,8 +105,8 @@ export function createDealsService(dependencies) {
|
|
|
104
105
|
return named;
|
|
105
106
|
}
|
|
106
107
|
/** @returns The page's views, with every deal's people fetched in one query. */
|
|
107
|
-
async function toViews(records) {
|
|
108
|
-
const peopleByDeal = await
|
|
108
|
+
async function toViews(workspaceId, records) {
|
|
109
|
+
const peopleByDeal = await personLinks.listPersonIdsFor(dependencies.db, workspaceId, 'deal', records.map((record) => record.id));
|
|
109
110
|
return records.map((record) => toView(record, peopleByDeal.get(record.id) ?? []));
|
|
110
111
|
}
|
|
111
112
|
return {
|
|
@@ -114,12 +115,15 @@ export function createDealsService(dependencies) {
|
|
|
114
115
|
const window = readListWindow(query, DEAL_SORTS, DEFAULT_DEAL_SORT);
|
|
115
116
|
const rows = await repository.listDeals(dependencies.db, workspaceId, filters, window);
|
|
116
117
|
const page = toPage(rows, window, (deal) => deal.id);
|
|
117
|
-
return { items: await toViews(page.items), nextCursor: page.nextCursor };
|
|
118
|
+
return { items: await toViews(workspaceId, page.items), nextCursor: page.nextCursor };
|
|
118
119
|
},
|
|
119
120
|
async get(actor, id) {
|
|
120
121
|
const workspaceId = requireWorkspaceId(actor);
|
|
121
122
|
const deal = await require(workspaceId, id);
|
|
122
|
-
return toView(deal, await
|
|
123
|
+
return toView(deal, await personLinks.listPersonIds(dependencies.db, workspaceId, {
|
|
124
|
+
targetType: 'deal',
|
|
125
|
+
targetId: id,
|
|
126
|
+
}));
|
|
123
127
|
},
|
|
124
128
|
async create(actor, input) {
|
|
125
129
|
const workspaceId = requireWorkspaceId(actor);
|
|
@@ -135,6 +139,7 @@ export function createDealsService(dependencies) {
|
|
|
135
139
|
const named = await requirePeople(workspaceId, personIds);
|
|
136
140
|
const id = dependencies.createId('deal');
|
|
137
141
|
return dependencies.transaction(async ({ tx, events }) => {
|
|
142
|
+
const customFields = await dependencies.customFields.forCreate(tx, workspaceId, 'deal', input.customFields);
|
|
138
143
|
const created = await repository.insertDeal(tx, {
|
|
139
144
|
id,
|
|
140
145
|
workspaceId,
|
|
@@ -151,8 +156,9 @@ export function createDealsService(dependencies) {
|
|
|
151
156
|
summary: input.summary,
|
|
152
157
|
tags: [...input.tags],
|
|
153
158
|
externalId: input.externalId,
|
|
159
|
+
customFields,
|
|
154
160
|
});
|
|
155
|
-
await
|
|
161
|
+
await personLinks.linkPeople(tx, dependencies.createId, workspaceId, { targetType: 'deal', targetId: id }, personIds);
|
|
156
162
|
await dependencies.recordActivity(tx, workspaceId, actor, {
|
|
157
163
|
targetType: 'deal',
|
|
158
164
|
targetId: id,
|
|
@@ -187,27 +193,33 @@ export function createDealsService(dependencies) {
|
|
|
187
193
|
if (typeof changes.ownerId === 'string' && changes.ownerId !== existing.ownerId) {
|
|
188
194
|
await requireOwner(workspaceId, changes.ownerId);
|
|
189
195
|
}
|
|
190
|
-
const currentPeople = await
|
|
196
|
+
const currentPeople = await personLinks.listPersonIds(dependencies.db, workspaceId, {
|
|
197
|
+
targetType: 'deal',
|
|
198
|
+
targetId: id,
|
|
199
|
+
});
|
|
191
200
|
const nextPeople = changes.personIds === undefined ? undefined : [...new Set(changes.personIds)];
|
|
192
201
|
const added = nextPeople === undefined ? [] : nextPeople.filter((personId) => !currentPeople.includes(personId));
|
|
193
202
|
const removed = nextPeople === undefined ? [] : currentPeople.filter((personId) => !nextPeople.includes(personId));
|
|
194
203
|
const named = await requirePeople(workspaceId, [...added, ...removed]);
|
|
195
204
|
const columns = toStoredColumns(changes);
|
|
196
|
-
const
|
|
205
|
+
const scalarChanged = changedKeys(existing, columns);
|
|
197
206
|
const linksChanged = added.length > 0 || removed.length > 0;
|
|
198
|
-
if (changed.length === 0 && !linksChanged) {
|
|
199
|
-
return toView(existing, currentPeople);
|
|
200
|
-
}
|
|
201
207
|
return dependencies.transaction(async ({ tx, events }) => {
|
|
208
|
+
const cf = await dependencies.customFields.forUpdate(tx, workspaceId, 'deal', existing.customFields, changes.customFields);
|
|
209
|
+
const customFieldsChanged = cf !== undefined && cf.changedPaths.length > 0;
|
|
210
|
+
if (scalarChanged.length === 0 && !linksChanged && !customFieldsChanged) {
|
|
211
|
+
return toView(existing, currentPeople);
|
|
212
|
+
}
|
|
202
213
|
const updated = await repository.updateDeal(tx, workspaceId, id, {
|
|
203
214
|
...columns,
|
|
215
|
+
...(customFieldsChanged ? { customFields: cf.merged } : {}),
|
|
204
216
|
updatedAt: dependencies.now(),
|
|
205
217
|
});
|
|
206
218
|
if (updated === undefined) {
|
|
207
219
|
throw AppError.notFound('Deal not found');
|
|
208
220
|
}
|
|
209
|
-
await
|
|
210
|
-
await
|
|
221
|
+
await personLinks.linkPeople(tx, dependencies.createId, workspaceId, { targetType: 'deal', targetId: id }, added);
|
|
222
|
+
await personLinks.unlinkPeople(tx, workspaceId, { targetType: 'deal', targetId: id }, removed);
|
|
211
223
|
if (stageMove !== undefined) {
|
|
212
224
|
await dependencies.recordActivity(tx, workspaceId, actor, {
|
|
213
225
|
targetType: 'deal',
|
|
@@ -216,13 +228,18 @@ export function createDealsService(dependencies) {
|
|
|
216
228
|
...describeStageChange(stageMove.from.label, stageMove.to.label),
|
|
217
229
|
});
|
|
218
230
|
}
|
|
219
|
-
const otherChanged =
|
|
220
|
-
|
|
231
|
+
const otherChanged = scalarChanged.filter((field) => field !== 'stageId');
|
|
232
|
+
const customFieldPaths = cf?.changedPaths ?? [];
|
|
233
|
+
const activityChanged = [...otherChanged, ...customFieldPaths];
|
|
234
|
+
if (activityChanged.length > 0) {
|
|
235
|
+
const labels = { ...DEAL_FIELD_LABELS, ...cf?.labels };
|
|
236
|
+
const before = { ...existing, ...cf?.flatBefore };
|
|
237
|
+
const after = { ...columns, ...cf?.flatAfter };
|
|
221
238
|
await dependencies.recordActivity(tx, workspaceId, actor, {
|
|
222
239
|
targetType: 'deal',
|
|
223
240
|
targetId: id,
|
|
224
241
|
kind: 'updated',
|
|
225
|
-
...describeUpdate(
|
|
242
|
+
...describeUpdate(activityChanged, labels, before, after),
|
|
226
243
|
});
|
|
227
244
|
}
|
|
228
245
|
// Links land on the deal's timeline only: a person's page already rolls
|
|
@@ -244,7 +261,13 @@ export function createDealsService(dependencies) {
|
|
|
244
261
|
...describeUnlink('person', named.get(personId) ?? personId),
|
|
245
262
|
});
|
|
246
263
|
}
|
|
247
|
-
events.emit('deals.deal.updated', { type: 'deal', id }, {
|
|
264
|
+
events.emit('deals.deal.updated', { type: 'deal', id }, {
|
|
265
|
+
changed: [
|
|
266
|
+
...scalarChanged,
|
|
267
|
+
...(linksChanged ? ['personIds'] : []),
|
|
268
|
+
...customFieldPaths,
|
|
269
|
+
],
|
|
270
|
+
});
|
|
248
271
|
if (stageMove !== undefined) {
|
|
249
272
|
events.emit('deals.deal.stage_changed', { type: 'deal', id }, { fromStageId: stageMove.from.id, toStageId: stageMove.to.id });
|
|
250
273
|
}
|
|
@@ -255,9 +278,9 @@ export function createDealsService(dependencies) {
|
|
|
255
278
|
const workspaceId = requireWorkspaceId(actor);
|
|
256
279
|
await dependencies.transaction(async ({ tx, events }) => {
|
|
257
280
|
await require(workspaceId, id);
|
|
258
|
-
//
|
|
259
|
-
//
|
|
260
|
-
//
|
|
281
|
+
// Form submissions unlink themselves through `set null`; notes,
|
|
282
|
+
// activities, decisions, plan items, and person_links have no key back
|
|
283
|
+
// to the deal, so they are removed here, in the same transaction.
|
|
261
284
|
await deleteRecordsAttachedTo(tx, workspaceId, 'deal', id);
|
|
262
285
|
await repository.deleteDeal(tx, workspaceId, id);
|
|
263
286
|
events.emit('deals.deal.deleted', { type: 'deal', id }, {});
|