@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,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace-defined consent purposes.
|
|
3
|
+
*
|
|
4
|
+
* Every capture site — a form's consent field, a list, an import job, the
|
|
5
|
+
* manual override on a Person — names one of these. `slug` is set at create
|
|
6
|
+
* and immutable after: a rename would strand every form/list/import that
|
|
7
|
+
* names it and every `person_consents` row that carries it (identified by
|
|
8
|
+
* the purpose id). The strict PATCH body naturally refuses either as a `422`.
|
|
9
|
+
*
|
|
10
|
+
* `default_status` is the workspace default: a person without an explicit
|
|
11
|
+
* `person_consents` row for this purpose inherits it.
|
|
12
|
+
*/
|
|
13
|
+
export { CONSENT_PURPOSE_STATUSES } from '@kelpie/schemas';
|
|
14
|
+
export type { ConsentPurposeStatus } from '@kelpie/schemas';
|
|
15
|
+
export declare const consentPurposes: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
16
|
+
name: "consent_purposes";
|
|
17
|
+
schema: undefined;
|
|
18
|
+
columns: {
|
|
19
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
20
|
+
name: "id";
|
|
21
|
+
tableName: "consent_purposes";
|
|
22
|
+
dataType: "string";
|
|
23
|
+
columnType: "PgText";
|
|
24
|
+
data: string;
|
|
25
|
+
driverParam: string;
|
|
26
|
+
notNull: true;
|
|
27
|
+
hasDefault: false;
|
|
28
|
+
isPrimaryKey: true;
|
|
29
|
+
isAutoincrement: false;
|
|
30
|
+
hasRuntimeDefault: false;
|
|
31
|
+
enumValues: [string, ...string[]];
|
|
32
|
+
baseColumn: never;
|
|
33
|
+
identity: undefined;
|
|
34
|
+
generated: undefined;
|
|
35
|
+
}, {}, {}>;
|
|
36
|
+
workspaceId: import("drizzle-orm/pg-core").PgColumn<{
|
|
37
|
+
name: "workspace_id";
|
|
38
|
+
tableName: "consent_purposes";
|
|
39
|
+
dataType: "string";
|
|
40
|
+
columnType: "PgText";
|
|
41
|
+
data: string;
|
|
42
|
+
driverParam: string;
|
|
43
|
+
notNull: true;
|
|
44
|
+
hasDefault: false;
|
|
45
|
+
isPrimaryKey: false;
|
|
46
|
+
isAutoincrement: false;
|
|
47
|
+
hasRuntimeDefault: false;
|
|
48
|
+
enumValues: [string, ...string[]];
|
|
49
|
+
baseColumn: never;
|
|
50
|
+
identity: undefined;
|
|
51
|
+
generated: undefined;
|
|
52
|
+
}, {}, {}>;
|
|
53
|
+
slug: import("drizzle-orm/pg-core").PgColumn<{
|
|
54
|
+
name: "slug";
|
|
55
|
+
tableName: "consent_purposes";
|
|
56
|
+
dataType: "string";
|
|
57
|
+
columnType: "PgText";
|
|
58
|
+
data: string;
|
|
59
|
+
driverParam: string;
|
|
60
|
+
notNull: true;
|
|
61
|
+
hasDefault: false;
|
|
62
|
+
isPrimaryKey: false;
|
|
63
|
+
isAutoincrement: false;
|
|
64
|
+
hasRuntimeDefault: false;
|
|
65
|
+
enumValues: [string, ...string[]];
|
|
66
|
+
baseColumn: never;
|
|
67
|
+
identity: undefined;
|
|
68
|
+
generated: undefined;
|
|
69
|
+
}, {}, {}>;
|
|
70
|
+
label: import("drizzle-orm/pg-core").PgColumn<{
|
|
71
|
+
name: "label";
|
|
72
|
+
tableName: "consent_purposes";
|
|
73
|
+
dataType: "string";
|
|
74
|
+
columnType: "PgText";
|
|
75
|
+
data: string;
|
|
76
|
+
driverParam: string;
|
|
77
|
+
notNull: true;
|
|
78
|
+
hasDefault: false;
|
|
79
|
+
isPrimaryKey: false;
|
|
80
|
+
isAutoincrement: false;
|
|
81
|
+
hasRuntimeDefault: false;
|
|
82
|
+
enumValues: [string, ...string[]];
|
|
83
|
+
baseColumn: never;
|
|
84
|
+
identity: undefined;
|
|
85
|
+
generated: undefined;
|
|
86
|
+
}, {}, {}>;
|
|
87
|
+
description: import("drizzle-orm/pg-core").PgColumn<{
|
|
88
|
+
name: "description";
|
|
89
|
+
tableName: "consent_purposes";
|
|
90
|
+
dataType: "string";
|
|
91
|
+
columnType: "PgText";
|
|
92
|
+
data: string;
|
|
93
|
+
driverParam: string;
|
|
94
|
+
notNull: true;
|
|
95
|
+
hasDefault: true;
|
|
96
|
+
isPrimaryKey: false;
|
|
97
|
+
isAutoincrement: false;
|
|
98
|
+
hasRuntimeDefault: false;
|
|
99
|
+
enumValues: [string, ...string[]];
|
|
100
|
+
baseColumn: never;
|
|
101
|
+
identity: undefined;
|
|
102
|
+
generated: undefined;
|
|
103
|
+
}, {}, {}>;
|
|
104
|
+
defaultStatus: import("drizzle-orm/pg-core").PgColumn<{
|
|
105
|
+
name: "default_status";
|
|
106
|
+
tableName: "consent_purposes";
|
|
107
|
+
dataType: "string";
|
|
108
|
+
columnType: "PgText";
|
|
109
|
+
data: string;
|
|
110
|
+
driverParam: string;
|
|
111
|
+
notNull: true;
|
|
112
|
+
hasDefault: true;
|
|
113
|
+
isPrimaryKey: false;
|
|
114
|
+
isAutoincrement: false;
|
|
115
|
+
hasRuntimeDefault: false;
|
|
116
|
+
enumValues: [string, ...string[]];
|
|
117
|
+
baseColumn: never;
|
|
118
|
+
identity: undefined;
|
|
119
|
+
generated: undefined;
|
|
120
|
+
}, {}, {}>;
|
|
121
|
+
sortOrder: import("drizzle-orm/pg-core").PgColumn<{
|
|
122
|
+
name: "sort_order";
|
|
123
|
+
tableName: "consent_purposes";
|
|
124
|
+
dataType: "number";
|
|
125
|
+
columnType: "PgInteger";
|
|
126
|
+
data: number;
|
|
127
|
+
driverParam: string | number;
|
|
128
|
+
notNull: true;
|
|
129
|
+
hasDefault: false;
|
|
130
|
+
isPrimaryKey: false;
|
|
131
|
+
isAutoincrement: false;
|
|
132
|
+
hasRuntimeDefault: false;
|
|
133
|
+
enumValues: undefined;
|
|
134
|
+
baseColumn: never;
|
|
135
|
+
identity: undefined;
|
|
136
|
+
generated: undefined;
|
|
137
|
+
}, {}, {}>;
|
|
138
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
139
|
+
name: "created_at";
|
|
140
|
+
tableName: "consent_purposes";
|
|
141
|
+
dataType: "date";
|
|
142
|
+
columnType: "PgTimestamp";
|
|
143
|
+
data: Date;
|
|
144
|
+
driverParam: string;
|
|
145
|
+
notNull: true;
|
|
146
|
+
hasDefault: true;
|
|
147
|
+
isPrimaryKey: false;
|
|
148
|
+
isAutoincrement: false;
|
|
149
|
+
hasRuntimeDefault: false;
|
|
150
|
+
enumValues: undefined;
|
|
151
|
+
baseColumn: never;
|
|
152
|
+
identity: undefined;
|
|
153
|
+
generated: undefined;
|
|
154
|
+
}, {}, {}>;
|
|
155
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
156
|
+
name: "updated_at";
|
|
157
|
+
tableName: "consent_purposes";
|
|
158
|
+
dataType: "date";
|
|
159
|
+
columnType: "PgTimestamp";
|
|
160
|
+
data: Date;
|
|
161
|
+
driverParam: string;
|
|
162
|
+
notNull: true;
|
|
163
|
+
hasDefault: true;
|
|
164
|
+
isPrimaryKey: false;
|
|
165
|
+
isAutoincrement: false;
|
|
166
|
+
hasRuntimeDefault: false;
|
|
167
|
+
enumValues: undefined;
|
|
168
|
+
baseColumn: never;
|
|
169
|
+
identity: undefined;
|
|
170
|
+
generated: undefined;
|
|
171
|
+
}, {}, {}>;
|
|
172
|
+
};
|
|
173
|
+
dialect: 'pg';
|
|
174
|
+
}>;
|
|
175
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/modules/consent-purposes/schema.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,YAAY,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAE3D,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwB3B,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CONSENT_PURPOSE_STATUSES } from '@kelpie/schemas';
|
|
2
|
+
import { index, integer, pgTable, text, unique } from 'drizzle-orm/pg-core';
|
|
3
|
+
import { checkOneOf, createdAt, primaryId, updatedAt } from '../../lib/columns.js';
|
|
4
|
+
import { workspaces } from '../workspace/schema.js';
|
|
5
|
+
/**
|
|
6
|
+
* Workspace-defined consent purposes.
|
|
7
|
+
*
|
|
8
|
+
* Every capture site — a form's consent field, a list, an import job, the
|
|
9
|
+
* manual override on a Person — names one of these. `slug` is set at create
|
|
10
|
+
* and immutable after: a rename would strand every form/list/import that
|
|
11
|
+
* names it and every `person_consents` row that carries it (identified by
|
|
12
|
+
* the purpose id). The strict PATCH body naturally refuses either as a `422`.
|
|
13
|
+
*
|
|
14
|
+
* `default_status` is the workspace default: a person without an explicit
|
|
15
|
+
* `person_consents` row for this purpose inherits it.
|
|
16
|
+
*/
|
|
17
|
+
export { CONSENT_PURPOSE_STATUSES } from '@kelpie/schemas';
|
|
18
|
+
export const consentPurposes = pgTable('consent_purposes', {
|
|
19
|
+
id: primaryId(),
|
|
20
|
+
workspaceId: text('workspace_id')
|
|
21
|
+
.notNull()
|
|
22
|
+
.references(() => workspaces.id, { onDelete: 'cascade' }),
|
|
23
|
+
slug: text('slug').notNull(),
|
|
24
|
+
label: text('label').notNull(),
|
|
25
|
+
description: text('description').notNull().default(''),
|
|
26
|
+
defaultStatus: text('default_status').notNull().default('unknown'),
|
|
27
|
+
sortOrder: integer('sort_order').notNull(),
|
|
28
|
+
createdAt: createdAt(),
|
|
29
|
+
updatedAt: updatedAt(),
|
|
30
|
+
}, (table) => [
|
|
31
|
+
index('consent_purposes_workspace_idx').on(table.workspaceId),
|
|
32
|
+
unique('consent_purposes_workspace_slug_key').on(table.workspaceId, table.slug),
|
|
33
|
+
checkOneOf('consent_purposes_default_status_check', table.defaultStatus, CONSENT_PURPOSE_STATUSES),
|
|
34
|
+
]);
|
|
35
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/modules/consent-purposes/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAE3E,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAEnD;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AAG1D,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CACpC,kBAAkB,EAClB;IACE,EAAE,EAAE,SAAS,EAAE;IACf,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC;SAC9B,OAAO,EAAE;SACT,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IAC3D,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE;IAC5B,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE;IAC9B,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IACtD,aAAa,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC;IAClE,SAAS,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IAC1C,SAAS,EAAE,SAAS,EAAE;IACtB,SAAS,EAAE,SAAS,EAAE;CACvB,EACD,CAAC,KAAK,EAAE,EAAE,CAAC;IACT,KAAK,CAAC,gCAAgC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC;IAC7D,MAAM,CAAC,qCAAqC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC;IAC/E,UAAU,CACR,uCAAuC,EACvC,KAAK,CAAC,aAAa,EACnB,wBAAwB,CACzB;CACF,CACF,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ConsentPurposeStatus } from '@kelpie/schemas';
|
|
2
|
+
import type { Database } from '../../lib/database.ts';
|
|
3
|
+
import type { IdFactory } from '../../lib/ids.ts';
|
|
4
|
+
import type { ListQueryParameters, Page } from '../../lib/pagination.ts';
|
|
5
|
+
import type { EntitlementRegistry } from '../../runtime/entitlements.ts';
|
|
6
|
+
import type { TransactionScope } from '../../runtime/transaction.ts';
|
|
7
|
+
import type { Actor } from '../auth/actor.ts';
|
|
8
|
+
import './events.ts';
|
|
9
|
+
import type { ConsentPurposeFilters, ConsentPurposeRecord } from './repository.ts';
|
|
10
|
+
/**
|
|
11
|
+
* CRUD for the workspace's consent purposes.
|
|
12
|
+
*
|
|
13
|
+
* Reads are open to any workspace member — every capture site needs to list
|
|
14
|
+
* them to render its purpose picker. Writes need the admin role: a purpose
|
|
15
|
+
* change touches every form, list, and import job that names it, and it is
|
|
16
|
+
* team-wide config rather than a per-user preference.
|
|
17
|
+
*/
|
|
18
|
+
/** Hard cap per workspace. Bites when the entitlement leaves the count unlimited. */
|
|
19
|
+
export declare const CONSENT_PURPOSES_HARD_CAP = 50;
|
|
20
|
+
export interface ConsentPurposesDependencies {
|
|
21
|
+
readonly db: Database;
|
|
22
|
+
readonly transaction: TransactionScope;
|
|
23
|
+
readonly createId: IdFactory;
|
|
24
|
+
readonly now: () => Date;
|
|
25
|
+
readonly entitlements: EntitlementRegistry;
|
|
26
|
+
}
|
|
27
|
+
/** What the API returns: the stored row minus the tenancy column. */
|
|
28
|
+
export type ConsentPurposeView = Omit<ConsentPurposeRecord, 'workspaceId'>;
|
|
29
|
+
export interface CreateConsentPurposeInput {
|
|
30
|
+
readonly slug: string;
|
|
31
|
+
readonly label: string;
|
|
32
|
+
readonly description: string;
|
|
33
|
+
readonly defaultStatus: ConsentPurposeStatus;
|
|
34
|
+
}
|
|
35
|
+
/** PATCH semantics: `slug` is immutable and refused by the route body. */
|
|
36
|
+
export interface UpdateConsentPurposeInput {
|
|
37
|
+
readonly label?: string | undefined;
|
|
38
|
+
readonly description?: string | undefined;
|
|
39
|
+
readonly defaultStatus?: ConsentPurposeStatus | undefined;
|
|
40
|
+
readonly sortOrder?: number | undefined;
|
|
41
|
+
}
|
|
42
|
+
export interface ConsentPurposesService {
|
|
43
|
+
list(actor: Actor, filters: ConsentPurposeFilters, query: ListQueryParameters): Promise<Page<ConsentPurposeView>>;
|
|
44
|
+
get(actor: Actor, id: string): Promise<ConsentPurposeView>;
|
|
45
|
+
create(actor: Actor, input: CreateConsentPurposeInput): Promise<ConsentPurposeView>;
|
|
46
|
+
update(actor: Actor, id: string, changes: UpdateConsentPurposeInput): Promise<ConsentPurposeView>;
|
|
47
|
+
remove(actor: Actor, id: string): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
export declare function createConsentPurposesService(dependencies: ConsentPurposesDependencies): ConsentPurposesService;
|
|
50
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/modules/consent-purposes/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAU3D,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,yBAAyB,CAAA;AACxE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AAExE,OAAO,KAAK,EAAe,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AACjF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAM7C,OAAO,aAAa,CAAA;AAMpB,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,iBAAiB,CAAA;AAExB;;;;;;;GAOG;AAEH,qFAAqF;AACrF,eAAO,MAAM,yBAAyB,KAAK,CAAA;AAQ3C,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAA;I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EAAE,yBAAyB,GACjC,OAAO,CAAC,kBAAkB,CAAC,CAAA;IAC9B,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAChD;AAyFD,wBAAgB,4BAA4B,CAC1C,YAAY,EAAE,2BAA2B,GACxC,sBAAsB,CA6OxB"}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { CONSENT_PURPOSE_STATUSES } from '@kelpie/schemas';
|
|
2
|
+
import { and, eq, sql } from 'drizzle-orm';
|
|
3
|
+
import { toEventActor } from '../../lib/actor.js';
|
|
4
|
+
import { changedKeys } from '../../lib/changes.js';
|
|
5
|
+
import { FOREIGN_KEY_VIOLATION, UNIQUE_VIOLATION, postgresErrorCode, } from '../../lib/database.js';
|
|
6
|
+
import { AppError } from '../../lib/errors.js';
|
|
7
|
+
import { mapPage, readListWindow, toPage } from '../../lib/pagination.js';
|
|
8
|
+
import { limitFor } from '../../runtime/entitlements.js';
|
|
9
|
+
import { requireWorkspaceId } from '../auth/actor.js';
|
|
10
|
+
import { formFields } from '../forms/schema.js';
|
|
11
|
+
import { lists } from '../lists/schema.js';
|
|
12
|
+
import { roleAllows } from '../workspace/roles.js';
|
|
13
|
+
import { CONSENT_PURPOSES_LIMIT } from './capabilities.js';
|
|
14
|
+
import './events.js';
|
|
15
|
+
import * as repository from './repository.js';
|
|
16
|
+
import { CONSENT_PURPOSE_SORTS, DEFAULT_CONSENT_PURPOSE_SORT, } from './repository.js';
|
|
17
|
+
/**
|
|
18
|
+
* CRUD for the workspace's consent purposes.
|
|
19
|
+
*
|
|
20
|
+
* Reads are open to any workspace member — every capture site needs to list
|
|
21
|
+
* them to render its purpose picker. Writes need the admin role: a purpose
|
|
22
|
+
* change touches every form, list, and import job that names it, and it is
|
|
23
|
+
* team-wide config rather than a per-user preference.
|
|
24
|
+
*/
|
|
25
|
+
/** Hard cap per workspace. Bites when the entitlement leaves the count unlimited. */
|
|
26
|
+
export const CONSENT_PURPOSES_HARD_CAP = 50;
|
|
27
|
+
const KEY_PATTERN = /^[a-z][a-z0-9_]*$/u;
|
|
28
|
+
const MAX_SLUG_LENGTH = 64;
|
|
29
|
+
const MAX_LABEL_LENGTH = 120;
|
|
30
|
+
const MIN_LABEL_LENGTH = 1;
|
|
31
|
+
const MAX_DESCRIPTION_LENGTH = 2000;
|
|
32
|
+
function toView(record) {
|
|
33
|
+
const { workspaceId: _workspaceId, ...view } = record;
|
|
34
|
+
return view;
|
|
35
|
+
}
|
|
36
|
+
function fieldError(field, message) {
|
|
37
|
+
return AppError.validationFailed('That consent purpose is not valid', [{ field, message }]);
|
|
38
|
+
}
|
|
39
|
+
function duplicateSlug() {
|
|
40
|
+
return AppError.conflict('Another consent purpose already uses that slug', [
|
|
41
|
+
{ field: 'slug', message: 'Already in use' },
|
|
42
|
+
]);
|
|
43
|
+
}
|
|
44
|
+
function validateSlug(slug) {
|
|
45
|
+
if (slug.length === 0 || slug.length > MAX_SLUG_LENGTH) {
|
|
46
|
+
throw fieldError('slug', `1 to ${String(MAX_SLUG_LENGTH)} characters`);
|
|
47
|
+
}
|
|
48
|
+
if (!KEY_PATTERN.test(slug)) {
|
|
49
|
+
throw fieldError('slug', 'Lowercase letters, digits and underscores; must start with a letter');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function validateLabel(label) {
|
|
53
|
+
if (label.length < MIN_LABEL_LENGTH || label.length > MAX_LABEL_LENGTH) {
|
|
54
|
+
throw fieldError('label', `${String(MIN_LABEL_LENGTH)} to ${String(MAX_LABEL_LENGTH)} characters`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function validateDescription(description) {
|
|
58
|
+
if (description.length > MAX_DESCRIPTION_LENGTH) {
|
|
59
|
+
throw fieldError('description', `At most ${String(MAX_DESCRIPTION_LENGTH)} characters`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function validateDefaultStatus(status) {
|
|
63
|
+
if (!CONSENT_PURPOSE_STATUSES.includes(status)) {
|
|
64
|
+
throw fieldError('default_status', `Unknown status "${status}"`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A purpose still named by a form's consent field or a list's
|
|
69
|
+
* `consent_purpose_id` cannot be deleted. Counted here so the 409 lists both
|
|
70
|
+
* types; the FK on either side would refuse the delete on its own but only
|
|
71
|
+
* name one.
|
|
72
|
+
*/
|
|
73
|
+
async function referencingTypes(db, workspaceId, id) {
|
|
74
|
+
const [fieldRow, listRow] = await Promise.all([
|
|
75
|
+
db
|
|
76
|
+
.select({ count: sql `count(*)::int` })
|
|
77
|
+
.from(formFields)
|
|
78
|
+
.where(and(eq(formFields.workspaceId, workspaceId),
|
|
79
|
+
// The array contains this purpose id. A form field carries a set of
|
|
80
|
+
// purposes; the delete is refused if any field still lists this one.
|
|
81
|
+
sql `${id} = ANY(${formFields.consentPurposeIds})`)),
|
|
82
|
+
db
|
|
83
|
+
.select({ count: sql `count(*)::int` })
|
|
84
|
+
.from(lists)
|
|
85
|
+
.where(and(eq(lists.workspaceId, workspaceId), eq(lists.consentPurposeId, id))),
|
|
86
|
+
]);
|
|
87
|
+
const referencing = [];
|
|
88
|
+
if (Number(fieldRow[0]?.count ?? 0) > 0) {
|
|
89
|
+
referencing.push('form_field');
|
|
90
|
+
}
|
|
91
|
+
if (Number(listRow[0]?.count ?? 0) > 0) {
|
|
92
|
+
referencing.push('list');
|
|
93
|
+
}
|
|
94
|
+
return referencing;
|
|
95
|
+
}
|
|
96
|
+
export function createConsentPurposesService(dependencies) {
|
|
97
|
+
function requireAdminWorkspace(actor) {
|
|
98
|
+
const workspaceId = requireWorkspaceId(actor);
|
|
99
|
+
if (actor.role === null || !roleAllows(actor.role, 'admin')) {
|
|
100
|
+
throw new AppError('forbidden', 'This action needs the admin role');
|
|
101
|
+
}
|
|
102
|
+
return workspaceId;
|
|
103
|
+
}
|
|
104
|
+
async function require(workspaceId, id) {
|
|
105
|
+
const purpose = await repository.findPurpose(dependencies.db, workspaceId, id);
|
|
106
|
+
if (purpose === undefined) {
|
|
107
|
+
throw AppError.notFound('Consent purpose not found');
|
|
108
|
+
}
|
|
109
|
+
return purpose;
|
|
110
|
+
}
|
|
111
|
+
async function renumber(tx, workspaceId, order) {
|
|
112
|
+
for (const [index, purpose] of order.entries()) {
|
|
113
|
+
if (purpose.sortOrder !== index) {
|
|
114
|
+
await repository.updatePurpose(tx, workspaceId, purpose.id, {
|
|
115
|
+
sortOrder: index,
|
|
116
|
+
updatedAt: dependencies.now(),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
async function moveToPosition(tx, workspaceId, purpose, position) {
|
|
122
|
+
const rows = await repository.purposesForWorkspace(tx, workspaceId);
|
|
123
|
+
const target = rows.find((row) => row.id === purpose.id);
|
|
124
|
+
if (target === undefined) {
|
|
125
|
+
throw AppError.notFound('Consent purpose not found');
|
|
126
|
+
}
|
|
127
|
+
if (position < 0 || position >= rows.length) {
|
|
128
|
+
throw fieldError('sort_order', `Use 0 to ${String(rows.length - 1)}`);
|
|
129
|
+
}
|
|
130
|
+
const reordered = rows.filter((row) => row.id !== purpose.id);
|
|
131
|
+
reordered.splice(position, 0, target);
|
|
132
|
+
await renumber(tx, workspaceId, reordered);
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
async list(actor, filters, query) {
|
|
136
|
+
const workspaceId = requireWorkspaceId(actor);
|
|
137
|
+
const window = readListWindow(query, CONSENT_PURPOSE_SORTS, DEFAULT_CONSENT_PURPOSE_SORT);
|
|
138
|
+
const rows = await repository.listPurposes(dependencies.db, workspaceId, filters, window);
|
|
139
|
+
return mapPage(toPage(rows, window, (row) => row.id), toView);
|
|
140
|
+
},
|
|
141
|
+
async get(actor, id) {
|
|
142
|
+
return toView(await require(requireWorkspaceId(actor), id));
|
|
143
|
+
},
|
|
144
|
+
async create(actor, input) {
|
|
145
|
+
const workspaceId = requireAdminWorkspace(actor);
|
|
146
|
+
validateSlug(input.slug);
|
|
147
|
+
validateLabel(input.label);
|
|
148
|
+
validateDescription(input.description);
|
|
149
|
+
validateDefaultStatus(input.defaultStatus);
|
|
150
|
+
const limit = await limitFor(dependencies.entitlements, workspaceId, CONSENT_PURPOSES_LIMIT.name);
|
|
151
|
+
if (limit !== null) {
|
|
152
|
+
const total = await repository.countPurposes(dependencies.db, workspaceId);
|
|
153
|
+
if (total >= limit) {
|
|
154
|
+
throw new AppError('entitlement_required', `Your plan allows ${String(limit)} consent purpose${limit === 1 ? '' : 's'}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const id = dependencies.createId('consentPurpose');
|
|
158
|
+
return dependencies.transaction(async ({ tx, events }) => {
|
|
159
|
+
const existing = await repository.purposesForWorkspace(tx, workspaceId);
|
|
160
|
+
if (existing.length >= CONSENT_PURPOSES_HARD_CAP) {
|
|
161
|
+
throw AppError.conflict(`A workspace may define at most ${String(CONSENT_PURPOSES_HARD_CAP)} consent purposes`, [{ field: 'slug', message: 'Limit reached' }]);
|
|
162
|
+
}
|
|
163
|
+
let created;
|
|
164
|
+
try {
|
|
165
|
+
created = await repository.insertPurpose(tx, {
|
|
166
|
+
id,
|
|
167
|
+
workspaceId,
|
|
168
|
+
slug: input.slug,
|
|
169
|
+
label: input.label,
|
|
170
|
+
description: input.description,
|
|
171
|
+
defaultStatus: input.defaultStatus,
|
|
172
|
+
sortOrder: (existing.at(-1)?.sortOrder ?? -1) + 1,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
if (postgresErrorCode(error) === UNIQUE_VIOLATION) {
|
|
177
|
+
throw duplicateSlug();
|
|
178
|
+
}
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
181
|
+
events.emit('consent_purposes.purpose.created', { type: 'consent_purpose', id: created.id }, { slug: created.slug });
|
|
182
|
+
return toView(created);
|
|
183
|
+
}, { workspaceId, actor: toEventActor(actor) });
|
|
184
|
+
},
|
|
185
|
+
async update(actor, id, changes) {
|
|
186
|
+
const workspaceId = requireAdminWorkspace(actor);
|
|
187
|
+
const existing = await require(workspaceId, id);
|
|
188
|
+
if (changes.label !== undefined) {
|
|
189
|
+
validateLabel(changes.label);
|
|
190
|
+
}
|
|
191
|
+
if (changes.description !== undefined) {
|
|
192
|
+
validateDescription(changes.description);
|
|
193
|
+
}
|
|
194
|
+
if (changes.defaultStatus !== undefined) {
|
|
195
|
+
validateDefaultStatus(changes.defaultStatus);
|
|
196
|
+
}
|
|
197
|
+
const columns = {
|
|
198
|
+
...(changes.label === undefined ? {} : { label: changes.label }),
|
|
199
|
+
...(changes.description === undefined ? {} : { description: changes.description }),
|
|
200
|
+
...(changes.defaultStatus === undefined
|
|
201
|
+
? {}
|
|
202
|
+
: { defaultStatus: changes.defaultStatus }),
|
|
203
|
+
};
|
|
204
|
+
const changed = changedKeys(existing, columns);
|
|
205
|
+
const position = changes.sortOrder;
|
|
206
|
+
if (changed.length === 0 && position === undefined) {
|
|
207
|
+
return toView(existing);
|
|
208
|
+
}
|
|
209
|
+
return dependencies.transaction(async ({ tx, events }) => {
|
|
210
|
+
if (position !== undefined) {
|
|
211
|
+
await moveToPosition(tx, workspaceId, existing, position);
|
|
212
|
+
}
|
|
213
|
+
let updated;
|
|
214
|
+
if (changed.length > 0) {
|
|
215
|
+
updated = await repository.updatePurpose(tx, workspaceId, id, {
|
|
216
|
+
...columns,
|
|
217
|
+
updatedAt: dependencies.now(),
|
|
218
|
+
});
|
|
219
|
+
if (updated === undefined) {
|
|
220
|
+
throw AppError.notFound('Consent purpose not found');
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
updated = await repository.findPurpose(tx, workspaceId, id);
|
|
225
|
+
if (updated === undefined) {
|
|
226
|
+
throw AppError.notFound('Consent purpose not found');
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (changed.length > 0 || position !== undefined) {
|
|
230
|
+
const changedPaths = [
|
|
231
|
+
...changed,
|
|
232
|
+
...(position !== undefined && position !== existing.sortOrder ? ['sortOrder'] : []),
|
|
233
|
+
];
|
|
234
|
+
events.emit('consent_purposes.purpose.updated', { type: 'consent_purpose', id }, { slug: updated.slug, changed: changedPaths });
|
|
235
|
+
}
|
|
236
|
+
return toView(updated);
|
|
237
|
+
}, { workspaceId, actor: toEventActor(actor) });
|
|
238
|
+
},
|
|
239
|
+
async remove(actor, id) {
|
|
240
|
+
const workspaceId = requireAdminWorkspace(actor);
|
|
241
|
+
const existing = await require(workspaceId, id);
|
|
242
|
+
await dependencies.transaction(async ({ tx, events }) => {
|
|
243
|
+
const referencing = await referencingTypes(tx, workspaceId, id);
|
|
244
|
+
if (referencing.length > 0) {
|
|
245
|
+
throw AppError.conflict('Remove this purpose from every form and list that names it before deleting it', referencing.map((type) => ({ field: type, message: 'still references this purpose' })));
|
|
246
|
+
}
|
|
247
|
+
try {
|
|
248
|
+
await repository.deletePurpose(tx, workspaceId, id);
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
if (postgresErrorCode(error) === FOREIGN_KEY_VIOLATION) {
|
|
252
|
+
throw AppError.conflict('Remove this purpose from every form and list that names it before deleting it', [{ field: 'id', message: 'still referenced' }]);
|
|
253
|
+
}
|
|
254
|
+
throw error;
|
|
255
|
+
}
|
|
256
|
+
const survivors = await repository.purposesForWorkspace(tx, workspaceId);
|
|
257
|
+
await renumber(tx, workspaceId, survivors);
|
|
258
|
+
events.emit('consent_purposes.purpose.deleted', { type: 'consent_purpose', id }, { slug: existing.slug });
|
|
259
|
+
}, { workspaceId, actor: toEventActor(actor) });
|
|
260
|
+
},
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/modules/consent-purposes/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE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S,GAAG,MAAM,UAAU,CAAC,oBAAoB,CAAC,EAAE,EAAE,WAAW,CAAC,CAAA;gBACxE,MAAM,QAAQ,CAAC,EAAE,EAAE,WAAW,EAAE,SAAS,CAAC,CAAA;gBAE1C,MAAM,CAAC,IAAI,CACT,kCAAkC,EAClC,EAAE,IAAI,EAAE,iBAAiB,EAAE,EAAE,EAAE,EAC/B,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CACxB,CAAA;YACH,CAAC,EACD,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,CAC5C,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ConsentPurposeStatus } from '@kelpie/schemas';
|
|
2
|
+
/**
|
|
3
|
+
* The purposes a new workspace starts with. Data, not migrations: a workspace
|
|
4
|
+
* owner may rename, reorder, or delete them, and add any others they need.
|
|
5
|
+
*
|
|
6
|
+
* Both starters default to `unknown` — silence about a person's wishes is not
|
|
7
|
+
* a grant, and every capture site (forms, lists, imports, manual override)
|
|
8
|
+
* writes an explicit `person_consents` row when consent is actually given.
|
|
9
|
+
*/
|
|
10
|
+
export interface StarterConsentPurpose {
|
|
11
|
+
readonly slug: string;
|
|
12
|
+
readonly label: string;
|
|
13
|
+
readonly description: string;
|
|
14
|
+
readonly defaultStatus: ConsentPurposeStatus;
|
|
15
|
+
}
|
|
16
|
+
export declare const STARTER_CONSENT_PURPOSES: readonly StarterConsentPurpose[];
|
|
17
|
+
//# sourceMappingURL=starters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"starters.d.ts","sourceRoot":"","sources":["../../../src/modules/consent-purposes/starters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAE3D;;;;;;;GAOG;AAEH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,aAAa,EAAE,oBAAoB,CAAA;CAC7C;AAED,eAAO,MAAM,wBAAwB,EAAE,SAAS,qBAAqB,EAapE,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const STARTER_CONSENT_PURPOSES = [
|
|
2
|
+
{
|
|
3
|
+
slug: 'contact',
|
|
4
|
+
label: 'Contact',
|
|
5
|
+
description: 'Being contacted by the workspace about our work together.',
|
|
6
|
+
defaultStatus: 'unknown',
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
slug: 'marketing',
|
|
10
|
+
label: 'Marketing',
|
|
11
|
+
description: 'Marketing communications — newsletters, product updates, and campaigns.',
|
|
12
|
+
defaultStatus: 'unknown',
|
|
13
|
+
},
|
|
14
|
+
];
|
|
15
|
+
//# sourceMappingURL=starters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"starters.js","sourceRoot":"","sources":["../../../src/modules/consent-purposes/starters.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,MAAM,wBAAwB,GAAqC;IACxE;QACE,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;QAChB,WAAW,EAAE,2DAA2D;QACxE,aAAa,EAAE,SAAS;KACzB;IACD;QACE,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,WAAW;QAClB,WAAW,EAAE,yEAAyE;QACtF,aAAa,EAAE,SAAS;KACzB;CACF,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { McpToolRegistry } from '../../runtime/module.ts';
|
|
2
|
+
import type { ConsentPurposesService } from './service.ts';
|
|
3
|
+
export declare function registerConsentPurposesTools(mcp: McpToolRegistry, service: ConsentPurposesService): void;
|
|
4
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/modules/consent-purposes/tools.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAS9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAa1D,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,eAAe,EACpB,OAAO,EAAE,sBAAsB,GAC9B,IAAI,CAgBN"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { idArg, listWindowShape, registerCrudTools, termArg } from '../crudTools.js';
|
|
3
|
+
import { createBody, consentPurposeResponse, toCreateInput, toUpdateInput, updateBody, } from './routes.js';
|
|
4
|
+
/**
|
|
5
|
+
* `consent_purposes_*`. Same schemas and mappers as `/v1/consent_purposes`, so
|
|
6
|
+
* the REST surface and the MCP one cannot drift. Agents list purposes before
|
|
7
|
+
* a person consent write so they know which slugs the workspace defines.
|
|
8
|
+
*/
|
|
9
|
+
const listArgs = z.strictObject({
|
|
10
|
+
...listWindowShape,
|
|
11
|
+
q: termArg,
|
|
12
|
+
});
|
|
13
|
+
export function registerConsentPurposesTools(mcp, service) {
|
|
14
|
+
registerCrudTools(mcp, {
|
|
15
|
+
resource: 'consent_purposes',
|
|
16
|
+
subject: 'consent purpose',
|
|
17
|
+
about: 'A workspace-defined consent purpose. Read these before writing a person ' +
|
|
18
|
+
'consent or setting a form/list/import purpose_id.',
|
|
19
|
+
service,
|
|
20
|
+
render: consentPurposeResponse,
|
|
21
|
+
listArgs,
|
|
22
|
+
toFilters: (args) => ({ term: args.q }),
|
|
23
|
+
createArgs: createBody,
|
|
24
|
+
toCreateInput,
|
|
25
|
+
updateArgs: updateBody.extend({ id: idArg }),
|
|
26
|
+
toUpdateInput,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/modules/consent-purposes/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACpF,OAAO,EACL,UAAU,EACV,sBAAsB,EACtB,aAAa,EACb,aAAa,EACb,UAAU,GACX,MAAM,aAAa,CAAA;AAGpB;;;;GAIG;AAEH,MAAM,QAAQ,GAAG,CAAC,CAAC,YAAY,CAAC;IAC9B,GAAG,eAAe;IAClB,CAAC,EAAE,OAAO;CACX,CAAC,CAAA;AAEF,MAAM,UAAU,4BAA4B,CAC1C,GAAoB,EACpB,OAA+B;IAE/B,iBAAiB,CAAC,GAAG,EAAE;QACrB,QAAQ,EAAE,kBAAkB;QAC5B,OAAO,EAAE,iBAAiB;QAC1B,KAAK,EACH,0EAA0E;YAC1E,mDAAmD;QACrD,OAAO;QACP,MAAM,EAAE,sBAAsB;QAC9B,QAAQ;QACR,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC;QACvC,UAAU,EAAE,UAAU;QACtB,aAAa;QACb,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;QAC5C,aAAa;KACd,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/modules/core.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/modules/core.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAgCxD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB,QAA8D,CAAA;AAElG,eAAO,MAAM,WAAW,EAAE,SAAS,YAAY,EA4C9C,CAAA"}
|