@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
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { KelpieModule } from '../../runtime/module.ts'
|
|
2
|
+
import { CUSTOM_FIELDS_LIMIT } from './capabilities.ts'
|
|
3
|
+
import { customFieldsEvents } from './events.ts'
|
|
4
|
+
import { mountCustomFieldsRoutes } from './routes.ts'
|
|
5
|
+
import * as schema from './schema.ts'
|
|
6
|
+
import { createCustomFieldDefinitionsService } from './service.ts'
|
|
7
|
+
import { registerCustomFieldsTools } from './tools.ts'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Custom fields: workspace-defined attributes for the six taggable record
|
|
11
|
+
* types. Structural because records carry values keyed by definition key, so a
|
|
12
|
+
* disabled module would leave the values on records with no way to read them.
|
|
13
|
+
*
|
|
14
|
+
* Requires the six object modules only for schema visibility: the strip-on-
|
|
15
|
+
* delete pass reads their tables through `stripKeyFromRecords`, and drizzle-kit
|
|
16
|
+
* needs the barrel to see them registered before this module's schema loads.
|
|
17
|
+
* Runtime dependency runs the other way — the six modules `requires` this one
|
|
18
|
+
* so the validator is present when they register.
|
|
19
|
+
*
|
|
20
|
+
* Exports the values factory so the six object modules can inject it into
|
|
21
|
+
* their services (`createCustomFieldValues` is the cross-module seam here).
|
|
22
|
+
*/
|
|
23
|
+
export {
|
|
24
|
+
createCustomFieldValues,
|
|
25
|
+
} from './values.ts'
|
|
26
|
+
export type {
|
|
27
|
+
CustomFieldValuesValidator,
|
|
28
|
+
CustomFieldsMerge,
|
|
29
|
+
StoredCustomFieldValue,
|
|
30
|
+
} from './values.ts'
|
|
31
|
+
|
|
32
|
+
export function createCustomFieldsModule(migrationsDirectory: string): KelpieModule {
|
|
33
|
+
return {
|
|
34
|
+
id: 'custom-fields',
|
|
35
|
+
requires: ['workspace'],
|
|
36
|
+
structural: true,
|
|
37
|
+
events: customFieldsEvents,
|
|
38
|
+
|
|
39
|
+
register(context) {
|
|
40
|
+
context.entitlements.declare(CUSTOM_FIELDS_LIMIT)
|
|
41
|
+
|
|
42
|
+
const service = createCustomFieldDefinitionsService({
|
|
43
|
+
db: context.db,
|
|
44
|
+
transaction: context.transaction,
|
|
45
|
+
createId: context.createId,
|
|
46
|
+
now: context.now,
|
|
47
|
+
entitlements: context.entitlements,
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
context.schema(schema, migrationsDirectory)
|
|
51
|
+
|
|
52
|
+
context.routes((router) => {
|
|
53
|
+
mountCustomFieldsRoutes(router, { db: context.db, now: context.now, service })
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
registerCustomFieldsTools(context.mcp, service)
|
|
57
|
+
|
|
58
|
+
return Promise.resolve()
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { and, asc, eq, ilike, inArray, sql } from 'drizzle-orm'
|
|
2
|
+
import type { SQL } from 'drizzle-orm'
|
|
3
|
+
|
|
4
|
+
import { keysetCondition, orderByWindow, textSort, timestampSort } from '../../lib/pagination.ts'
|
|
5
|
+
import type { ListWindow, SortableFields } from '../../lib/pagination.ts'
|
|
6
|
+
import { containsPattern } from '../../lib/search.ts'
|
|
7
|
+
import type { Queryable } from '../../runtime/transaction.ts'
|
|
8
|
+
import { companies } from '../companies/schema.ts'
|
|
9
|
+
import { deals } from '../deals/schema.ts'
|
|
10
|
+
import { enquiries } from '../enquiries/schema.ts'
|
|
11
|
+
import { opportunities } from '../opportunities/schema.ts'
|
|
12
|
+
import { partnerships } from '../partnerships/schema.ts'
|
|
13
|
+
import { people } from '../people/schema.ts'
|
|
14
|
+
import { raises } from '../raises/schema.ts'
|
|
15
|
+
import type { CustomFieldObjectType } from './schema.ts'
|
|
16
|
+
import { customFieldDefinitions } from './schema.ts'
|
|
17
|
+
|
|
18
|
+
export type CustomFieldDefinitionRecord = typeof customFieldDefinitions.$inferSelect
|
|
19
|
+
export type CustomFieldDefinitionColumns = typeof customFieldDefinitions.$inferInsert
|
|
20
|
+
|
|
21
|
+
export const CUSTOM_FIELD_DEFINITION_SORTS: SortableFields<CustomFieldDefinitionRecord> = {
|
|
22
|
+
sort_order: {
|
|
23
|
+
column: customFieldDefinitions.sortOrder,
|
|
24
|
+
valueOf: (row) => String(row.sortOrder),
|
|
25
|
+
parse: (value) => {
|
|
26
|
+
const parsed = Number(value)
|
|
27
|
+
if (!Number.isInteger(parsed)) {
|
|
28
|
+
throw new Error('sort_order cursor is not a whole number')
|
|
29
|
+
}
|
|
30
|
+
return parsed
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
label: textSort(customFieldDefinitions.label, (row) => row.label),
|
|
34
|
+
key: textSort(customFieldDefinitions.key, (row) => row.key),
|
|
35
|
+
created_at: timestampSort(customFieldDefinitions.createdAt, (row) => row.createdAt),
|
|
36
|
+
updated_at: timestampSort(customFieldDefinitions.updatedAt, (row) => row.updatedAt),
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const DEFAULT_CUSTOM_FIELD_DEFINITION_SORT = 'sort_order'
|
|
40
|
+
|
|
41
|
+
export interface CustomFieldDefinitionFilters {
|
|
42
|
+
readonly term?: string | undefined
|
|
43
|
+
readonly objectType?: CustomFieldObjectType | undefined
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function conditionsFor(
|
|
47
|
+
workspaceId: string,
|
|
48
|
+
filters: CustomFieldDefinitionFilters,
|
|
49
|
+
): (SQL | undefined)[] {
|
|
50
|
+
return [
|
|
51
|
+
eq(customFieldDefinitions.workspaceId, workspaceId),
|
|
52
|
+
filters.term === undefined
|
|
53
|
+
? undefined
|
|
54
|
+
: ilike(customFieldDefinitions.label, containsPattern(filters.term)),
|
|
55
|
+
filters.objectType === undefined
|
|
56
|
+
? undefined
|
|
57
|
+
: eq(customFieldDefinitions.objectType, filters.objectType),
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function listDefinitions(
|
|
62
|
+
db: Queryable,
|
|
63
|
+
workspaceId: string,
|
|
64
|
+
filters: CustomFieldDefinitionFilters,
|
|
65
|
+
window: ListWindow<CustomFieldDefinitionRecord>,
|
|
66
|
+
): Promise<CustomFieldDefinitionRecord[]> {
|
|
67
|
+
return db
|
|
68
|
+
.select()
|
|
69
|
+
.from(customFieldDefinitions)
|
|
70
|
+
.where(
|
|
71
|
+
and(...conditionsFor(workspaceId, filters), keysetCondition(window, customFieldDefinitions.id)),
|
|
72
|
+
)
|
|
73
|
+
.orderBy(...orderByWindow(window, customFieldDefinitions.id))
|
|
74
|
+
.limit(window.fetchLimit)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export async function findDefinition(
|
|
78
|
+
db: Queryable,
|
|
79
|
+
workspaceId: string,
|
|
80
|
+
id: string,
|
|
81
|
+
): Promise<CustomFieldDefinitionRecord | undefined> {
|
|
82
|
+
const [found] = await db
|
|
83
|
+
.select()
|
|
84
|
+
.from(customFieldDefinitions)
|
|
85
|
+
.where(and(eq(customFieldDefinitions.workspaceId, workspaceId), eq(customFieldDefinitions.id, id)))
|
|
86
|
+
.limit(1)
|
|
87
|
+
|
|
88
|
+
return found
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Every definition for one workspace, ordered as the editor renders them.
|
|
93
|
+
*
|
|
94
|
+
* Not paged: a workspace's whole set is small (hard cap 100 per object type),
|
|
95
|
+
* and every write path — validation, delete-strip — needs the definitions for
|
|
96
|
+
* one object type at once.
|
|
97
|
+
*/
|
|
98
|
+
export function definitionsForObject(
|
|
99
|
+
db: Queryable,
|
|
100
|
+
workspaceId: string,
|
|
101
|
+
objectType: CustomFieldObjectType,
|
|
102
|
+
): Promise<CustomFieldDefinitionRecord[]> {
|
|
103
|
+
return db
|
|
104
|
+
.select()
|
|
105
|
+
.from(customFieldDefinitions)
|
|
106
|
+
.where(
|
|
107
|
+
and(
|
|
108
|
+
eq(customFieldDefinitions.workspaceId, workspaceId),
|
|
109
|
+
eq(customFieldDefinitions.objectType, objectType),
|
|
110
|
+
),
|
|
111
|
+
)
|
|
112
|
+
.orderBy(asc(customFieldDefinitions.sortOrder), asc(customFieldDefinitions.id))
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export async function countDefinitions(
|
|
116
|
+
db: Queryable,
|
|
117
|
+
workspaceId: string,
|
|
118
|
+
): Promise<number> {
|
|
119
|
+
const [row] = await db
|
|
120
|
+
.select({ count: sql<number>`count(*)::int` })
|
|
121
|
+
.from(customFieldDefinitions)
|
|
122
|
+
.where(eq(customFieldDefinitions.workspaceId, workspaceId))
|
|
123
|
+
|
|
124
|
+
return Number(row?.count ?? 0)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export async function insertDefinition(
|
|
128
|
+
db: Queryable,
|
|
129
|
+
values: CustomFieldDefinitionColumns,
|
|
130
|
+
): Promise<CustomFieldDefinitionRecord> {
|
|
131
|
+
const [created] = await db.insert(customFieldDefinitions).values(values).returning()
|
|
132
|
+
|
|
133
|
+
if (created === undefined) {
|
|
134
|
+
throw new Error(`Inserting custom_field_definition ${values.id} returned no row`)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return created
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export async function updateDefinition(
|
|
141
|
+
db: Queryable,
|
|
142
|
+
workspaceId: string,
|
|
143
|
+
id: string,
|
|
144
|
+
changes: Partial<CustomFieldDefinitionColumns>,
|
|
145
|
+
): Promise<CustomFieldDefinitionRecord | undefined> {
|
|
146
|
+
const [updated] = await db
|
|
147
|
+
.update(customFieldDefinitions)
|
|
148
|
+
.set(changes)
|
|
149
|
+
.where(and(eq(customFieldDefinitions.workspaceId, workspaceId), eq(customFieldDefinitions.id, id)))
|
|
150
|
+
.returning()
|
|
151
|
+
|
|
152
|
+
return updated
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export async function deleteDefinition(
|
|
156
|
+
db: Queryable,
|
|
157
|
+
workspaceId: string,
|
|
158
|
+
id: string,
|
|
159
|
+
): Promise<number> {
|
|
160
|
+
const deleted = await db
|
|
161
|
+
.delete(customFieldDefinitions)
|
|
162
|
+
.where(and(eq(customFieldDefinitions.workspaceId, workspaceId), eq(customFieldDefinitions.id, id)))
|
|
163
|
+
.returning({ id: customFieldDefinitions.id })
|
|
164
|
+
|
|
165
|
+
return deleted.length
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* The tables `custom_fields` lives on, keyed by object type. A one-directional
|
|
170
|
+
* import: this module knows every carrier so that a definition delete can strip
|
|
171
|
+
* its key from the right table without every object module having to opt in.
|
|
172
|
+
*/
|
|
173
|
+
const TABLES = {
|
|
174
|
+
person: people,
|
|
175
|
+
company: companies,
|
|
176
|
+
deal: deals,
|
|
177
|
+
opportunity: opportunities,
|
|
178
|
+
partnership: partnerships,
|
|
179
|
+
raise: raises,
|
|
180
|
+
enquiry: enquiries,
|
|
181
|
+
} as const
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Removes one key from every record of one object type in one workspace.
|
|
185
|
+
*
|
|
186
|
+
* Uses `?` to skip rows that never carried the key, so the write set is only
|
|
187
|
+
* the rows that actually held a value. The `-` operator on jsonb returns the
|
|
188
|
+
* object without that key; a key that was not present is a no-op.
|
|
189
|
+
*/
|
|
190
|
+
export async function stripKeyFromRecords(
|
|
191
|
+
db: Queryable,
|
|
192
|
+
workspaceId: string,
|
|
193
|
+
objectType: CustomFieldObjectType,
|
|
194
|
+
key: string,
|
|
195
|
+
): Promise<number> {
|
|
196
|
+
const table = TABLES[objectType]
|
|
197
|
+
const stripped = await db
|
|
198
|
+
.update(table)
|
|
199
|
+
.set({
|
|
200
|
+
customFields: sql`${table.customFields} - ${key}`,
|
|
201
|
+
})
|
|
202
|
+
.where(and(eq(table.workspaceId, workspaceId), sql`${table.customFields} ? ${key}`))
|
|
203
|
+
.returning({ id: table.id })
|
|
204
|
+
|
|
205
|
+
return stripped.length
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** Bulk row read for a caller that already has a set of ids to update. */
|
|
209
|
+
export async function readCustomFieldsById(
|
|
210
|
+
db: Queryable,
|
|
211
|
+
workspaceId: string,
|
|
212
|
+
objectType: CustomFieldObjectType,
|
|
213
|
+
ids: readonly string[],
|
|
214
|
+
): Promise<Map<string, Readonly<Record<string, unknown>>>> {
|
|
215
|
+
if (ids.length === 0) {
|
|
216
|
+
return new Map()
|
|
217
|
+
}
|
|
218
|
+
const table = TABLES[objectType]
|
|
219
|
+
const rows = await db
|
|
220
|
+
.select({ id: table.id, customFields: table.customFields })
|
|
221
|
+
.from(table)
|
|
222
|
+
.where(and(eq(table.workspaceId, workspaceId), inArray(table.id, [...ids])))
|
|
223
|
+
|
|
224
|
+
return new Map(rows.map((row) => [row.id, row.customFields]))
|
|
225
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import type { Context, Hono } from 'hono'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
import { AppError } from '../../lib/errors.ts'
|
|
5
|
+
import { pageBody, readJsonBody, readListParameters } from '../../lib/http.ts'
|
|
6
|
+
import type { Actor } from '../auth/actor.ts'
|
|
7
|
+
import { resolveActorFrom } from '../auth/credentials.ts'
|
|
8
|
+
import type { CredentialDependencies } from '../auth/credentials.ts'
|
|
9
|
+
import { CUSTOM_FIELD_OBJECT_TYPES, CUSTOM_FIELD_TYPES } from './schema.ts'
|
|
10
|
+
import type { CustomFieldObjectType } from './schema.ts'
|
|
11
|
+
import type {
|
|
12
|
+
CreateCustomFieldDefinitionInput,
|
|
13
|
+
CustomFieldDefinitionView,
|
|
14
|
+
CustomFieldDefinitionsService,
|
|
15
|
+
UpdateCustomFieldDefinitionInput,
|
|
16
|
+
} from './service.ts'
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Wire shapes for `/v1/custom_fields`.
|
|
20
|
+
*
|
|
21
|
+
* `key`, `type`, and `object_type` are only on the create body: the update
|
|
22
|
+
* body omits them, and a strict PATCH answers `422` for any of the three.
|
|
23
|
+
* `options` accepts any string list here; per-type membership (and the
|
|
24
|
+
* "options only on select-like types" rule) live in the service.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
const optionsSchema = z.array(z.string().min(1).max(120)).max(100)
|
|
28
|
+
|
|
29
|
+
export const createBody = z.strictObject({
|
|
30
|
+
object_type: z.enum(CUSTOM_FIELD_OBJECT_TYPES),
|
|
31
|
+
key: z.string().min(1).max(64),
|
|
32
|
+
label: z.string().min(1).max(120),
|
|
33
|
+
type: z.enum(CUSTOM_FIELD_TYPES),
|
|
34
|
+
options: optionsSchema.default([]),
|
|
35
|
+
description: z.string().max(2000).default(''),
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
export const updateBody = z
|
|
39
|
+
.strictObject({
|
|
40
|
+
label: z.string().min(1).max(120),
|
|
41
|
+
description: z.string().max(2000),
|
|
42
|
+
options: optionsSchema,
|
|
43
|
+
sort_order: z.number().int().min(0),
|
|
44
|
+
})
|
|
45
|
+
.partial()
|
|
46
|
+
|
|
47
|
+
export interface CustomFieldsRoutesDependencies extends CredentialDependencies {
|
|
48
|
+
readonly service: CustomFieldDefinitionsService
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function toCreateInput(
|
|
52
|
+
body: z.infer<typeof createBody>,
|
|
53
|
+
): CreateCustomFieldDefinitionInput {
|
|
54
|
+
return {
|
|
55
|
+
objectType: body.object_type,
|
|
56
|
+
key: body.key,
|
|
57
|
+
label: body.label,
|
|
58
|
+
type: body.type,
|
|
59
|
+
options: body.options,
|
|
60
|
+
description: body.description,
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function toUpdateInput(
|
|
65
|
+
body: z.infer<typeof updateBody>,
|
|
66
|
+
): UpdateCustomFieldDefinitionInput {
|
|
67
|
+
return {
|
|
68
|
+
...(body.label === undefined ? {} : { label: body.label }),
|
|
69
|
+
...(body.description === undefined ? {} : { description: body.description }),
|
|
70
|
+
...(body.options === undefined ? {} : { options: body.options }),
|
|
71
|
+
...(body.sort_order === undefined ? {} : { sortOrder: body.sort_order }),
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function customFieldDefinitionResponse(
|
|
76
|
+
definition: CustomFieldDefinitionView,
|
|
77
|
+
): Record<string, unknown> {
|
|
78
|
+
return {
|
|
79
|
+
id: definition.id,
|
|
80
|
+
object_type: definition.objectType,
|
|
81
|
+
key: definition.key,
|
|
82
|
+
label: definition.label,
|
|
83
|
+
type: definition.type,
|
|
84
|
+
options: definition.options,
|
|
85
|
+
description: definition.description,
|
|
86
|
+
sort_order: definition.sortOrder,
|
|
87
|
+
created_at: definition.createdAt.toISOString(),
|
|
88
|
+
updated_at: definition.updatedAt.toISOString(),
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function readObjectTypeFilter(context: Context): CustomFieldObjectType | undefined {
|
|
93
|
+
const raw = context.req.query('object_type')
|
|
94
|
+
if (raw === undefined) {
|
|
95
|
+
return undefined
|
|
96
|
+
}
|
|
97
|
+
if (!CUSTOM_FIELD_OBJECT_TYPES.includes(raw as CustomFieldObjectType)) {
|
|
98
|
+
throw AppError.validationFailed('That is not a record type custom fields attach to', [
|
|
99
|
+
{ field: 'object_type', message: `Unknown object type "${raw}"` },
|
|
100
|
+
])
|
|
101
|
+
}
|
|
102
|
+
return raw as CustomFieldObjectType
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function mountCustomFieldsRoutes(
|
|
106
|
+
router: Hono,
|
|
107
|
+
dependencies: CustomFieldsRoutesDependencies,
|
|
108
|
+
): void {
|
|
109
|
+
const requireActor = (context: Context): Promise<Actor> =>
|
|
110
|
+
resolveActorFrom(dependencies, context)
|
|
111
|
+
|
|
112
|
+
router.get('/custom_fields', async (context) => {
|
|
113
|
+
const page = await dependencies.service.list(
|
|
114
|
+
await requireActor(context),
|
|
115
|
+
{
|
|
116
|
+
term: context.req.query('q'),
|
|
117
|
+
objectType: readObjectTypeFilter(context),
|
|
118
|
+
},
|
|
119
|
+
readListParameters(context),
|
|
120
|
+
)
|
|
121
|
+
return context.json(pageBody(page, customFieldDefinitionResponse))
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
router.post('/custom_fields', async (context) => {
|
|
125
|
+
const body = await readJsonBody(context, createBody)
|
|
126
|
+
const definition = await dependencies.service.create(
|
|
127
|
+
await requireActor(context),
|
|
128
|
+
toCreateInput(body),
|
|
129
|
+
)
|
|
130
|
+
return context.json(customFieldDefinitionResponse(definition), 201)
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
router.get('/custom_fields/:id', async (context) => {
|
|
134
|
+
const definition = await dependencies.service.get(
|
|
135
|
+
await requireActor(context),
|
|
136
|
+
context.req.param('id'),
|
|
137
|
+
)
|
|
138
|
+
return context.json(customFieldDefinitionResponse(definition))
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
router.patch('/custom_fields/:id', async (context) => {
|
|
142
|
+
const body = await readJsonBody(context, updateBody)
|
|
143
|
+
const definition = await dependencies.service.update(
|
|
144
|
+
await requireActor(context),
|
|
145
|
+
context.req.param('id'),
|
|
146
|
+
toUpdateInput(body),
|
|
147
|
+
)
|
|
148
|
+
return context.json(customFieldDefinitionResponse(definition))
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
router.delete('/custom_fields/:id', async (context) => {
|
|
152
|
+
await dependencies.service.remove(await requireActor(context), context.req.param('id'))
|
|
153
|
+
return context.body(null, 204)
|
|
154
|
+
})
|
|
155
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { CUSTOM_FIELD_OBJECT_TYPES, CUSTOM_FIELD_TYPES } from '@kelpie/schemas'
|
|
2
|
+
import { index, integer, jsonb, pgTable, text, unique } from 'drizzle-orm/pg-core'
|
|
3
|
+
|
|
4
|
+
import { checkOneOf, createdAt, primaryId, updatedAt } from '../../lib/columns.ts'
|
|
5
|
+
import { workspaces } from '../workspace/schema.ts'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Workspace-defined field definitions for the six taggable record types.
|
|
9
|
+
*
|
|
10
|
+
* `key` and `type` are set at create and are immutable after: a rename would
|
|
11
|
+
* strand every record's value under an old key, and a type swap would leave the
|
|
12
|
+
* jsonb value in the wrong shape. The strict PATCH body naturally refuses
|
|
13
|
+
* either as a `422`.
|
|
14
|
+
*
|
|
15
|
+
* `options` is stored as jsonb rather than `text[]` so future option metadata
|
|
16
|
+
* (colours, an archived flag) can be added without a migration. Empty for every
|
|
17
|
+
* type but `select` and `multi_select`; the service enforces that half of the
|
|
18
|
+
* rule.
|
|
19
|
+
*
|
|
20
|
+
* Re-exports the two arrays so the routes layer reads them from here alongside
|
|
21
|
+
* the tables they constrain.
|
|
22
|
+
*/
|
|
23
|
+
export { CUSTOM_FIELD_OBJECT_TYPES, CUSTOM_FIELD_TYPES } from '@kelpie/schemas'
|
|
24
|
+
export type { CustomFieldObjectType, CustomFieldType } from '@kelpie/schemas'
|
|
25
|
+
|
|
26
|
+
export const customFieldDefinitions = pgTable(
|
|
27
|
+
'custom_field_definitions',
|
|
28
|
+
{
|
|
29
|
+
id: primaryId(),
|
|
30
|
+
workspaceId: text('workspace_id')
|
|
31
|
+
.notNull()
|
|
32
|
+
.references(() => workspaces.id, { onDelete: 'cascade' }),
|
|
33
|
+
objectType: text('object_type').notNull(),
|
|
34
|
+
key: text('key').notNull(),
|
|
35
|
+
label: text('label').notNull(),
|
|
36
|
+
type: text('type').notNull(),
|
|
37
|
+
options: jsonb('options').$type<readonly string[]>().notNull().default([]),
|
|
38
|
+
description: text('description').notNull().default(''),
|
|
39
|
+
sortOrder: integer('sort_order').notNull(),
|
|
40
|
+
createdAt: createdAt(),
|
|
41
|
+
updatedAt: updatedAt(),
|
|
42
|
+
},
|
|
43
|
+
(table) => [
|
|
44
|
+
index('custom_field_definitions_workspace_idx').on(table.workspaceId),
|
|
45
|
+
index('custom_field_definitions_workspace_object_idx').on(
|
|
46
|
+
table.workspaceId,
|
|
47
|
+
table.objectType,
|
|
48
|
+
),
|
|
49
|
+
unique('custom_field_definitions_workspace_object_key_key').on(
|
|
50
|
+
table.workspaceId,
|
|
51
|
+
table.objectType,
|
|
52
|
+
table.key,
|
|
53
|
+
),
|
|
54
|
+
checkOneOf(
|
|
55
|
+
'custom_field_definitions_object_type_check',
|
|
56
|
+
table.objectType,
|
|
57
|
+
CUSTOM_FIELD_OBJECT_TYPES,
|
|
58
|
+
),
|
|
59
|
+
checkOneOf('custom_field_definitions_type_check', table.type, CUSTOM_FIELD_TYPES),
|
|
60
|
+
],
|
|
61
|
+
)
|