@kelpie/server 0.10.0 → 0.12.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/app.d.ts.map +1 -1
- package/dist/app.js +2 -0
- package/dist/app.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/actor.d.ts +3 -1
- package/dist/lib/actor.d.ts.map +1 -1
- package/dist/lib/actor.js.map +1 -1
- package/dist/lib/apiKeyScopes.d.ts +8 -0
- package/dist/lib/apiKeyScopes.d.ts.map +1 -0
- package/dist/lib/apiKeyScopes.js +166 -0
- package/dist/lib/apiKeyScopes.js.map +1 -0
- package/dist/lib/errors.d.ts +18 -0
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/errors.js +17 -0
- package/dist/lib/errors.js.map +1 -1
- package/dist/modules/activities/repository.d.ts +2 -0
- package/dist/modules/activities/repository.d.ts.map +1 -1
- package/dist/modules/activities/repository.js +9 -0
- package/dist/modules/activities/repository.js.map +1 -1
- package/dist/modules/agent-tasks/repository.d.ts +2 -0
- package/dist/modules/agent-tasks/repository.d.ts.map +1 -1
- package/dist/modules/agent-tasks/repository.js +9 -0
- package/dist/modules/agent-tasks/repository.js.map +1 -1
- package/dist/modules/api-keys/routes.d.ts.map +1 -1
- package/dist/modules/api-keys/routes.js +4 -1
- package/dist/modules/api-keys/routes.js.map +1 -1
- package/dist/modules/api-keys/schema.d.ts +43 -0
- package/dist/modules/api-keys/schema.d.ts.map +1 -1
- package/dist/modules/api-keys/schema.js +2 -0
- package/dist/modules/api-keys/schema.js.map +1 -1
- package/dist/modules/api-keys/scopeMiddleware.d.ts +8 -0
- package/dist/modules/api-keys/scopeMiddleware.d.ts.map +1 -0
- package/dist/modules/api-keys/scopeMiddleware.js +21 -0
- package/dist/modules/api-keys/scopeMiddleware.js.map +1 -0
- package/dist/modules/api-keys/service.d.ts +3 -1
- package/dist/modules/api-keys/service.d.ts.map +1 -1
- package/dist/modules/api-keys/service.js +26 -1
- package/dist/modules/api-keys/service.js.map +1 -1
- package/dist/modules/auth/credentials.d.ts.map +1 -1
- package/dist/modules/auth/credentials.js +2 -0
- package/dist/modules/auth/credentials.js.map +1 -1
- package/dist/modules/auth/index.d.ts.map +1 -1
- package/dist/modules/auth/index.js +21 -4
- package/dist/modules/auth/index.js.map +1 -1
- package/dist/modules/auth/repository.d.ts +2 -1
- package/dist/modules/auth/repository.d.ts.map +1 -1
- package/dist/modules/auth/repository.js +1 -0
- package/dist/modules/auth/repository.js.map +1 -1
- package/dist/modules/auth/routes.d.ts.map +1 -1
- package/dist/modules/auth/routes.js +2 -6
- package/dist/modules/auth/routes.js.map +1 -1
- package/dist/modules/auth/schema.d.ts +18 -1
- package/dist/modules/auth/schema.d.ts.map +1 -1
- package/dist/modules/auth/schema.js +12 -1
- package/dist/modules/auth/schema.js.map +1 -1
- package/dist/modules/auth/service.d.ts +18 -0
- package/dist/modules/auth/service.d.ts.map +1 -1
- package/dist/modules/auth/service.js +95 -6
- package/dist/modules/auth/service.js.map +1 -1
- package/dist/modules/auth/session.d.ts +12 -0
- package/dist/modules/auth/session.d.ts.map +1 -1
- package/dist/modules/auth/session.js +12 -0
- package/dist/modules/auth/session.js.map +1 -1
- package/dist/modules/consent-purposes/index.d.ts +1 -1
- package/dist/modules/consent-purposes/index.js +1 -1
- package/dist/modules/consent-purposes/schema.d.ts +3 -3
- package/dist/modules/consent-purposes/schema.js +3 -3
- package/dist/modules/consent-purposes/service.d.ts +1 -1
- package/dist/modules/consent-purposes/service.d.ts.map +1 -1
- package/dist/modules/consent-purposes/service.js +7 -16
- package/dist/modules/consent-purposes/service.js.map +1 -1
- package/dist/modules/consent-purposes/starters.d.ts +1 -1
- package/dist/modules/consent-purposes/tools.js +1 -1
- package/dist/modules/consent-purposes/tools.js.map +1 -1
- package/dist/modules/conversions/clearPointers.d.ts +10 -0
- package/dist/modules/conversions/clearPointers.d.ts.map +1 -0
- package/dist/modules/conversions/clearPointers.js +40 -0
- package/dist/modules/conversions/clearPointers.js.map +1 -0
- package/dist/modules/conversions/factory.d.ts +5 -0
- package/dist/modules/conversions/factory.d.ts.map +1 -0
- package/dist/modules/conversions/factory.js +18 -0
- package/dist/modules/conversions/factory.js.map +1 -0
- package/dist/modules/conversions/fieldMap.d.ts +55 -0
- package/dist/modules/conversions/fieldMap.d.ts.map +1 -0
- package/dist/modules/conversions/fieldMap.js +398 -0
- package/dist/modules/conversions/fieldMap.js.map +1 -0
- package/dist/modules/conversions/index.d.ts +7 -0
- package/dist/modules/conversions/index.d.ts.map +1 -0
- package/dist/modules/conversions/index.js +6 -0
- package/dist/modules/conversions/index.js.map +1 -0
- package/dist/modules/conversions/mcp.d.ts +7 -0
- package/dist/modules/conversions/mcp.d.ts.map +1 -0
- package/dist/modules/conversions/mcp.js +47 -0
- package/dist/modules/conversions/mcp.js.map +1 -0
- package/dist/modules/conversions/repoint.d.ts +19 -0
- package/dist/modules/conversions/repoint.d.ts.map +1 -0
- package/dist/modules/conversions/repoint.js +51 -0
- package/dist/modules/conversions/repoint.js.map +1 -0
- package/dist/modules/conversions/routes.d.ts +26 -0
- package/dist/modules/conversions/routes.d.ts.map +1 -0
- package/dist/modules/conversions/routes.js +23 -0
- package/dist/modules/conversions/routes.js.map +1 -0
- package/dist/modules/conversions/service.d.ts +28 -0
- package/dist/modules/conversions/service.d.ts.map +1 -0
- package/dist/modules/conversions/service.js +170 -0
- package/dist/modules/conversions/service.js.map +1 -0
- package/dist/modules/conversions/wire.d.ts +4 -0
- package/dist/modules/conversions/wire.d.ts.map +1 -0
- package/dist/modules/conversions/wire.js +28 -0
- package/dist/modules/conversions/wire.js.map +1 -0
- package/dist/modules/deals/events.d.ts +9 -0
- package/dist/modules/deals/events.d.ts.map +1 -1
- package/dist/modules/deals/events.js +4 -0
- package/dist/modules/deals/events.js.map +1 -1
- package/dist/modules/deals/index.d.ts.map +1 -1
- package/dist/modules/deals/index.js +4 -2
- package/dist/modules/deals/index.js.map +1 -1
- package/dist/modules/deals/routes.d.ts +2 -0
- package/dist/modules/deals/routes.d.ts.map +1 -1
- package/dist/modules/deals/routes.js +8 -1
- package/dist/modules/deals/routes.js.map +1 -1
- package/dist/modules/deals/schema.d.ts +34 -0
- package/dist/modules/deals/schema.d.ts.map +1 -1
- package/dist/modules/deals/schema.js +7 -2
- package/dist/modules/deals/schema.js.map +1 -1
- package/dist/modules/deals/service.d.ts.map +1 -1
- package/dist/modules/deals/service.js +2 -0
- package/dist/modules/deals/service.js.map +1 -1
- package/dist/modules/deals/tools.d.ts +2 -1
- package/dist/modules/deals/tools.d.ts.map +1 -1
- package/dist/modules/deals/tools.js +3 -1
- package/dist/modules/deals/tools.js.map +1 -1
- package/dist/modules/decisions/repository.d.ts +2 -1
- package/dist/modules/decisions/repository.d.ts.map +1 -1
- package/dist/modules/decisions/repository.js +9 -1
- package/dist/modules/decisions/repository.js.map +1 -1
- package/dist/modules/enquiries/events.d.ts +6 -2
- package/dist/modules/enquiries/events.d.ts.map +1 -1
- package/dist/modules/enquiries/events.js +5 -1
- package/dist/modules/enquiries/events.js.map +1 -1
- package/dist/modules/enquiries/index.d.ts.map +1 -1
- package/dist/modules/enquiries/index.js +4 -2
- package/dist/modules/enquiries/index.js.map +1 -1
- package/dist/modules/enquiries/routes.d.ts +2 -0
- package/dist/modules/enquiries/routes.d.ts.map +1 -1
- package/dist/modules/enquiries/routes.js +9 -9
- package/dist/modules/enquiries/routes.js.map +1 -1
- package/dist/modules/enquiries/schema.d.ts +36 -1
- package/dist/modules/enquiries/schema.d.ts.map +1 -1
- package/dist/modules/enquiries/schema.js +9 -3
- package/dist/modules/enquiries/schema.js.map +1 -1
- package/dist/modules/enquiries/service.d.ts +0 -8
- package/dist/modules/enquiries/service.d.ts.map +1 -1
- package/dist/modules/enquiries/service.js +3 -95
- package/dist/modules/enquiries/service.js.map +1 -1
- package/dist/modules/enquiries/tools.d.ts +2 -1
- package/dist/modules/enquiries/tools.d.ts.map +1 -1
- package/dist/modules/enquiries/tools.js +4 -16
- package/dist/modules/enquiries/tools.js.map +1 -1
- package/dist/modules/forms/applyMappedFields.d.ts +20 -0
- package/dist/modules/forms/applyMappedFields.d.ts.map +1 -0
- package/dist/modules/forms/applyMappedFields.js +169 -0
- package/dist/modules/forms/applyMappedFields.js.map +1 -0
- package/dist/modules/forms/applySubmissionFields.d.ts +18 -0
- package/dist/modules/forms/applySubmissionFields.d.ts.map +1 -0
- package/dist/modules/forms/applySubmissionFields.js +230 -0
- package/dist/modules/forms/applySubmissionFields.js.map +1 -0
- package/dist/modules/forms/fields.d.ts +7 -2
- package/dist/modules/forms/fields.d.ts.map +1 -1
- package/dist/modules/forms/fields.js +17 -6
- package/dist/modules/forms/fields.js.map +1 -1
- package/dist/modules/forms/mapping.d.ts +8 -2
- package/dist/modules/forms/mapping.d.ts.map +1 -1
- package/dist/modules/forms/mapping.js +11 -0
- package/dist/modules/forms/mapping.js.map +1 -1
- package/dist/modules/forms/repository.d.ts +0 -5
- package/dist/modules/forms/repository.d.ts.map +1 -1
- package/dist/modules/forms/repository.js +0 -2
- package/dist/modules/forms/repository.js.map +1 -1
- package/dist/modules/forms/routes.d.ts +2 -30
- package/dist/modules/forms/routes.d.ts.map +1 -1
- package/dist/modules/forms/routes.js +2 -2
- package/dist/modules/forms/routes.js.map +1 -1
- package/dist/modules/forms/schema.d.ts.map +1 -1
- package/dist/modules/forms/schema.js +1 -2
- package/dist/modules/forms/schema.js.map +1 -1
- package/dist/modules/forms/service.d.ts.map +1 -1
- package/dist/modules/forms/service.js +18 -3
- package/dist/modules/forms/service.js.map +1 -1
- package/dist/modules/forms/starters.d.ts +31 -0
- package/dist/modules/forms/starters.d.ts.map +1 -0
- package/dist/modules/forms/starters.js +94 -0
- package/dist/modules/forms/starters.js.map +1 -0
- package/dist/modules/forms/submission.d.ts +1 -0
- package/dist/modules/forms/submission.d.ts.map +1 -1
- package/dist/modules/forms/submission.js +58 -37
- package/dist/modules/forms/submission.js.map +1 -1
- package/dist/modules/import-export/customFieldCsv.d.ts +9 -0
- package/dist/modules/import-export/customFieldCsv.d.ts.map +1 -0
- package/dist/modules/import-export/customFieldCsv.js +39 -0
- package/dist/modules/import-export/customFieldCsv.js.map +1 -0
- package/dist/modules/import-export/customFieldImport.d.ts +19 -0
- package/dist/modules/import-export/customFieldImport.d.ts.map +1 -0
- package/dist/modules/import-export/customFieldImport.js +76 -0
- package/dist/modules/import-export/customFieldImport.js.map +1 -0
- package/dist/modules/import-export/drafts.d.ts +57 -3
- package/dist/modules/import-export/drafts.d.ts.map +1 -1
- package/dist/modules/import-export/drafts.js +65 -3
- package/dist/modules/import-export/drafts.js.map +1 -1
- package/dist/modules/import-export/exportRows.d.ts +15 -13
- package/dist/modules/import-export/exportRows.d.ts.map +1 -1
- package/dist/modules/import-export/exportRows.js +99 -26
- package/dist/modules/import-export/exportRows.js.map +1 -1
- package/dist/modules/import-export/plan.d.ts +42 -11
- package/dist/modules/import-export/plan.d.ts.map +1 -1
- package/dist/modules/import-export/plan.js +198 -56
- package/dist/modules/import-export/plan.js.map +1 -1
- package/dist/modules/import-export/repository.d.ts +58 -2
- package/dist/modules/import-export/repository.d.ts.map +1 -1
- package/dist/modules/import-export/repository.js +201 -12
- 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 +5 -5
- package/dist/modules/import-export/routes.js.map +1 -1
- package/dist/modules/import-export/service.d.ts +8 -3
- package/dist/modules/import-export/service.d.ts.map +1 -1
- package/dist/modules/import-export/service.js +133 -40
- package/dist/modules/import-export/service.js.map +1 -1
- package/dist/modules/import-export/streams.d.ts +2 -2
- package/dist/modules/import-export/streams.d.ts.map +1 -1
- package/dist/modules/import-export/streams.js +50 -9
- 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 +13 -7
- package/dist/modules/import-export/tools.js.map +1 -1
- package/dist/modules/import-export/validation.d.ts +5 -1
- package/dist/modules/import-export/validation.d.ts.map +1 -1
- package/dist/modules/import-export/validation.js +89 -2
- package/dist/modules/import-export/validation.js.map +1 -1
- package/dist/modules/import-export/writes.d.ts +2 -1
- package/dist/modules/import-export/writes.d.ts.map +1 -1
- package/dist/modules/import-export/writes.js +358 -25
- package/dist/modules/import-export/writes.js.map +1 -1
- package/dist/modules/lists/repository.d.ts +0 -1
- package/dist/modules/lists/repository.d.ts.map +1 -1
- package/dist/modules/lists/repository.js +0 -1
- package/dist/modules/lists/repository.js.map +1 -1
- package/dist/modules/lists/routes.d.ts +0 -2
- package/dist/modules/lists/routes.d.ts.map +1 -1
- package/dist/modules/lists/routes.js +0 -8
- package/dist/modules/lists/routes.js.map +1 -1
- package/dist/modules/lists/schema.d.ts +0 -17
- package/dist/modules/lists/schema.d.ts.map +1 -1
- package/dist/modules/lists/schema.js +0 -10
- package/dist/modules/lists/schema.js.map +1 -1
- package/dist/modules/lists/service.d.ts +2 -14
- package/dist/modules/lists/service.d.ts.map +1 -1
- package/dist/modules/lists/service.js +7 -53
- package/dist/modules/lists/service.js.map +1 -1
- package/dist/modules/lists/starters.d.ts +12 -0
- package/dist/modules/lists/starters.d.ts.map +1 -0
- package/dist/modules/lists/starters.js +4 -0
- package/dist/modules/lists/starters.js.map +1 -0
- package/dist/modules/mcp/protocol.d.ts.map +1 -1
- package/dist/modules/mcp/protocol.js +13 -0
- package/dist/modules/mcp/protocol.js.map +1 -1
- package/dist/modules/notes/repository.d.ts +2 -0
- package/dist/modules/notes/repository.d.ts.map +1 -1
- package/dist/modules/notes/repository.js +9 -0
- package/dist/modules/notes/repository.js.map +1 -1
- package/dist/modules/opportunities/events.d.ts +9 -0
- package/dist/modules/opportunities/events.d.ts.map +1 -1
- package/dist/modules/opportunities/events.js +4 -0
- package/dist/modules/opportunities/events.js.map +1 -1
- package/dist/modules/opportunities/index.d.ts.map +1 -1
- package/dist/modules/opportunities/index.js +4 -2
- package/dist/modules/opportunities/index.js.map +1 -1
- package/dist/modules/opportunities/routes.d.ts +2 -0
- package/dist/modules/opportunities/routes.d.ts.map +1 -1
- package/dist/modules/opportunities/routes.js +8 -1
- package/dist/modules/opportunities/routes.js.map +1 -1
- package/dist/modules/opportunities/schema.d.ts +34 -0
- package/dist/modules/opportunities/schema.d.ts.map +1 -1
- package/dist/modules/opportunities/schema.js +7 -2
- package/dist/modules/opportunities/schema.js.map +1 -1
- package/dist/modules/opportunities/service.d.ts.map +1 -1
- package/dist/modules/opportunities/service.js +2 -0
- package/dist/modules/opportunities/service.js.map +1 -1
- package/dist/modules/opportunities/tools.d.ts +2 -1
- package/dist/modules/opportunities/tools.d.ts.map +1 -1
- package/dist/modules/opportunities/tools.js +3 -1
- package/dist/modules/opportunities/tools.js.map +1 -1
- package/dist/modules/partnerships/events.d.ts +9 -0
- package/dist/modules/partnerships/events.d.ts.map +1 -1
- package/dist/modules/partnerships/events.js +4 -0
- package/dist/modules/partnerships/events.js.map +1 -1
- package/dist/modules/partnerships/index.d.ts.map +1 -1
- package/dist/modules/partnerships/index.js +4 -2
- package/dist/modules/partnerships/index.js.map +1 -1
- package/dist/modules/partnerships/routes.d.ts +2 -0
- package/dist/modules/partnerships/routes.d.ts.map +1 -1
- package/dist/modules/partnerships/routes.js +8 -1
- package/dist/modules/partnerships/routes.js.map +1 -1
- package/dist/modules/partnerships/schema.d.ts +34 -0
- package/dist/modules/partnerships/schema.d.ts.map +1 -1
- package/dist/modules/partnerships/schema.js +7 -2
- package/dist/modules/partnerships/schema.js.map +1 -1
- package/dist/modules/partnerships/service.d.ts.map +1 -1
- package/dist/modules/partnerships/service.js +2 -0
- package/dist/modules/partnerships/service.js.map +1 -1
- package/dist/modules/partnerships/tools.d.ts +2 -1
- package/dist/modules/partnerships/tools.d.ts.map +1 -1
- package/dist/modules/partnerships/tools.js +3 -1
- package/dist/modules/partnerships/tools.js.map +1 -1
- package/dist/modules/people/personConsentWrites.d.ts +1 -1
- package/dist/modules/people/schema.js +1 -1
- package/dist/modules/people/schema.js.map +1 -1
- package/dist/modules/plans/repository.d.ts +2 -0
- package/dist/modules/plans/repository.d.ts.map +1 -1
- package/dist/modules/plans/repository.js +9 -0
- package/dist/modules/plans/repository.js.map +1 -1
- package/dist/modules/raises/events.d.ts +9 -0
- package/dist/modules/raises/events.d.ts.map +1 -1
- package/dist/modules/raises/events.js +4 -0
- package/dist/modules/raises/events.js.map +1 -1
- package/dist/modules/raises/index.d.ts.map +1 -1
- package/dist/modules/raises/index.js +4 -2
- package/dist/modules/raises/index.js.map +1 -1
- package/dist/modules/raises/routes.d.ts +2 -0
- package/dist/modules/raises/routes.d.ts.map +1 -1
- package/dist/modules/raises/routes.js +8 -1
- package/dist/modules/raises/routes.js.map +1 -1
- package/dist/modules/raises/schema.d.ts +34 -0
- package/dist/modules/raises/schema.d.ts.map +1 -1
- package/dist/modules/raises/schema.js +7 -2
- package/dist/modules/raises/schema.js.map +1 -1
- package/dist/modules/raises/service.d.ts.map +1 -1
- package/dist/modules/raises/service.js +2 -0
- package/dist/modules/raises/service.js.map +1 -1
- package/dist/modules/raises/tools.d.ts +2 -1
- package/dist/modules/raises/tools.d.ts.map +1 -1
- package/dist/modules/raises/tools.js +3 -1
- package/dist/modules/raises/tools.js.map +1 -1
- package/dist/modules/workspace/routes.d.ts +0 -2
- package/dist/modules/workspace/routes.d.ts.map +1 -1
- package/dist/modules/workspace/routes.js +0 -6
- package/dist/modules/workspace/routes.js.map +1 -1
- package/dist/modules/workspace/schema.d.ts +0 -34
- package/dist/modules/workspace/schema.d.ts.map +1 -1
- package/dist/modules/workspace/schema.js +0 -2
- package/dist/modules/workspace/schema.js.map +1 -1
- package/dist/modules/workspace/seedStarterForms.d.ts +17 -0
- package/dist/modules/workspace/seedStarterForms.d.ts.map +1 -0
- package/dist/modules/workspace/seedStarterForms.js +71 -0
- package/dist/modules/workspace/seedStarterForms.js.map +1 -0
- package/dist/modules/workspace/service.d.ts +0 -4
- package/dist/modules/workspace/service.d.ts.map +1 -1
- package/dist/modules/workspace/service.js +20 -10
- package/dist/modules/workspace/service.js.map +1 -1
- package/dist/modules/workspace/tools.js +1 -1
- package/dist/modules/workspace/tools.js.map +1 -1
- package/dist/runtime/module.d.ts +63 -1
- package/dist/runtime/module.d.ts.map +1 -1
- package/dist/runtime/registry.d.ts.map +1 -1
- package/dist/runtime/registry.js +40 -2
- package/dist/runtime/registry.js.map +1 -1
- package/dist/testing/fixtures.d.ts.map +1 -1
- package/dist/testing/fixtures.js +1 -0
- package/dist/testing/fixtures.js.map +1 -1
- package/migrations/0037_drop_lists_consent_purpose_id.sql +2 -0
- package/migrations/0038_smart_white_queen.sql +2 -0
- package/migrations/0039_form_map_to_open.sql +1 -0
- package/migrations/0040_pipeline_converted_to.sql +20 -0
- package/migrations/0041_api_key_scopes.sql +1 -0
- package/migrations/0042_drop_workspace_identity.sql +2 -0
- package/migrations/0043_external_sign_in.sql +2 -0
- package/migrations/meta/0038_snapshot.json +6554 -0
- package/migrations/meta/_journal.json +49 -0
- package/package.json +2 -2
- package/src/app.ts +3 -0
- package/src/index.ts +13 -1
- package/src/lib/actor.ts +3 -1
- package/src/lib/apiKeyScopes.ts +213 -0
- package/src/lib/errors.ts +30 -0
- package/src/modules/activities/repository.ts +24 -0
- package/src/modules/agent-tasks/repository.ts +24 -0
- package/src/modules/api-keys/routes.ts +5 -0
- package/src/modules/api-keys/schema.ts +2 -0
- package/src/modules/api-keys/scopeMiddleware.ts +30 -0
- package/src/modules/api-keys/service.ts +36 -2
- package/src/modules/auth/credentials.ts +4 -0
- package/src/modules/auth/index.ts +25 -4
- package/src/modules/auth/repository.ts +2 -1
- package/src/modules/auth/routes.ts +2 -8
- package/src/modules/auth/schema.ts +12 -1
- package/src/modules/auth/service.ts +143 -6
- package/src/modules/auth/session.ts +14 -0
- package/src/modules/consent-purposes/index.ts +1 -1
- package/src/modules/consent-purposes/schema.ts +3 -3
- package/src/modules/consent-purposes/service.ts +7 -16
- package/src/modules/consent-purposes/starters.ts +1 -1
- package/src/modules/consent-purposes/tools.ts +1 -1
- package/src/modules/conversions/clearPointers.ts +81 -0
- package/src/modules/conversions/factory.ts +20 -0
- package/src/modules/conversions/fieldMap.ts +548 -0
- package/src/modules/conversions/index.ts +6 -0
- package/src/modules/conversions/mcp.ts +71 -0
- package/src/modules/conversions/repoint.ts +146 -0
- package/src/modules/conversions/routes.ts +68 -0
- package/src/modules/conversions/service.ts +310 -0
- package/src/modules/conversions/wire.ts +42 -0
- package/src/modules/deals/events.ts +9 -0
- package/src/modules/deals/index.ts +4 -2
- package/src/modules/deals/routes.ts +11 -1
- package/src/modules/deals/schema.ts +10 -2
- package/src/modules/deals/service.ts +3 -0
- package/src/modules/deals/tools.ts +9 -1
- package/src/modules/decisions/repository.ts +23 -1
- package/src/modules/enquiries/events.ts +8 -2
- package/src/modules/enquiries/index.ts +4 -2
- package/src/modules/enquiries/routes.ts +11 -13
- package/src/modules/enquiries/schema.ts +12 -3
- package/src/modules/enquiries/service.ts +3 -150
- package/src/modules/enquiries/tools.ts +9 -18
- package/src/modules/forms/applyMappedFields.ts +248 -0
- package/src/modules/forms/applySubmissionFields.ts +435 -0
- package/src/modules/forms/fields.ts +31 -7
- package/src/modules/forms/mapping.ts +20 -3
- package/src/modules/forms/repository.ts +0 -7
- package/src/modules/forms/routes.ts +1 -2
- package/src/modules/forms/schema.ts +0 -2
- package/src/modules/forms/service.ts +31 -4
- package/src/modules/forms/starters.ts +129 -0
- package/src/modules/forms/submission.ts +135 -69
- package/src/modules/import-export/customFieldCsv.ts +55 -0
- package/src/modules/import-export/customFieldImport.ts +111 -0
- package/src/modules/import-export/drafts.ts +151 -3
- package/src/modules/import-export/exportRows.ts +222 -68
- package/src/modules/import-export/plan.ts +321 -67
- package/src/modules/import-export/repository.ts +356 -14
- package/src/modules/import-export/routes.ts +8 -8
- package/src/modules/import-export/service.ts +208 -45
- package/src/modules/import-export/streams.ts +95 -13
- package/src/modules/import-export/tools.ts +14 -6
- package/src/modules/import-export/validation.ts +128 -0
- package/src/modules/import-export/writes.ts +559 -27
- package/src/modules/lists/repository.ts +0 -2
- package/src/modules/lists/routes.ts +0 -8
- package/src/modules/lists/schema.ts +0 -10
- package/src/modules/lists/service.ts +9 -107
- package/src/modules/lists/starters.ts +16 -0
- package/src/modules/mcp/protocol.ts +18 -0
- package/src/modules/notes/repository.ts +24 -0
- package/src/modules/opportunities/events.ts +9 -0
- package/src/modules/opportunities/index.ts +4 -2
- package/src/modules/opportunities/routes.ts +11 -1
- package/src/modules/opportunities/schema.ts +10 -2
- package/src/modules/opportunities/service.ts +3 -0
- package/src/modules/opportunities/tools.ts +9 -1
- package/src/modules/partnerships/events.ts +9 -0
- package/src/modules/partnerships/index.ts +4 -2
- package/src/modules/partnerships/routes.ts +11 -1
- package/src/modules/partnerships/schema.ts +10 -2
- package/src/modules/partnerships/service.ts +3 -0
- package/src/modules/partnerships/tools.ts +9 -1
- package/src/modules/people/personConsentWrites.ts +1 -1
- package/src/modules/people/schema.ts +1 -1
- package/src/modules/plans/repository.ts +24 -0
- package/src/modules/raises/events.ts +9 -0
- package/src/modules/raises/index.ts +4 -2
- package/src/modules/raises/routes.ts +11 -1
- package/src/modules/raises/schema.ts +10 -2
- package/src/modules/raises/service.ts +3 -0
- package/src/modules/raises/tools.ts +9 -1
- package/src/modules/workspace/routes.ts +0 -6
- package/src/modules/workspace/schema.ts +0 -2
- package/src/modules/workspace/seedStarterForms.ts +98 -0
- package/src/modules/workspace/service.ts +23 -15
- package/src/modules/workspace/tools.ts +1 -1
- package/src/runtime/module.ts +70 -1
- package/src/runtime/registry.ts +54 -0
- package/src/testing/fixtures.ts +1 -0
|
@@ -5,11 +5,37 @@ import type {
|
|
|
5
5
|
ImportObject,
|
|
6
6
|
MatchKeyOption,
|
|
7
7
|
OnMissingCompany,
|
|
8
|
+
PipelineKind,
|
|
8
9
|
} from '@kelpie/schemas'
|
|
10
|
+
import { pipelineKindForImport } from '@kelpie/schemas'
|
|
9
11
|
|
|
10
12
|
import { normaliseDomain, normaliseEmail } from '../../lib/normalisation.ts'
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
+
import type { CustomFieldDefinitionRecord } from '../custom-fields/repository.ts'
|
|
14
|
+
import {
|
|
15
|
+
customFieldWireValues,
|
|
16
|
+
extractCustomFieldRaw,
|
|
17
|
+
} from './customFieldImport.ts'
|
|
18
|
+
import {
|
|
19
|
+
affiliationCompanyDraft,
|
|
20
|
+
companyDraft,
|
|
21
|
+
customFieldDefinitionDraft,
|
|
22
|
+
dealFieldsDraft,
|
|
23
|
+
enquiryFieldsDraft,
|
|
24
|
+
opportunityFieldsDraft,
|
|
25
|
+
partnershipFieldsDraft,
|
|
26
|
+
personDraft,
|
|
27
|
+
raiseFieldsDraft,
|
|
28
|
+
} from './drafts.ts'
|
|
29
|
+
import type {
|
|
30
|
+
CompanyDraft,
|
|
31
|
+
CustomFieldDefinitionDraft,
|
|
32
|
+
DealFieldsDraft,
|
|
33
|
+
EnquiryFieldsDraft,
|
|
34
|
+
OpportunityFieldsDraft,
|
|
35
|
+
PartnershipFieldsDraft,
|
|
36
|
+
PersonDraft,
|
|
37
|
+
RaiseFieldsDraft,
|
|
38
|
+
} from './drafts.ts'
|
|
13
39
|
import { buildMatchKey, splitList } from './mapping.ts'
|
|
14
40
|
import { aliasedStageSlug } from './presets.ts'
|
|
15
41
|
import type { StoredRowError } from './schema.ts'
|
|
@@ -35,8 +61,8 @@ export interface ImportLookups {
|
|
|
35
61
|
readonly companyIdByName: ReadonlyMap<string, string>
|
|
36
62
|
/** Workspace member id by the address of the user behind it. */
|
|
37
63
|
readonly memberIdByEmail: ReadonlyMap<string, string>
|
|
38
|
-
/**
|
|
39
|
-
readonly
|
|
64
|
+
/** Pipeline stage id, keyed by both its slug and its folded label. */
|
|
65
|
+
readonly stageIdByName: ReadonlyMap<string, string>
|
|
40
66
|
}
|
|
41
67
|
|
|
42
68
|
export interface PlanContext {
|
|
@@ -48,6 +74,9 @@ export interface PlanContext {
|
|
|
48
74
|
/** The consent purpose the job grants for each row's consent_status. Null when not set. */
|
|
49
75
|
readonly consentPurposeId: string | null
|
|
50
76
|
readonly lookups: ImportLookups
|
|
77
|
+
/** Workspace custom field definitions when the object carries custom field values. */
|
|
78
|
+
readonly customFieldDefinitions: readonly CustomFieldDefinitionRecord[]
|
|
79
|
+
readonly baseColumnKeys: ReadonlySet<string>
|
|
51
80
|
}
|
|
52
81
|
|
|
53
82
|
/**
|
|
@@ -90,16 +119,45 @@ export type ImportWrite =
|
|
|
90
119
|
readonly stageId: string
|
|
91
120
|
readonly ownerId: string | null
|
|
92
121
|
readonly personIds: readonly string[]
|
|
93
|
-
/**
|
|
94
|
-
* Whether the row said anything about the deal's contacts.
|
|
95
|
-
*
|
|
96
|
-
* An empty `personIds` means two different things — the column was not
|
|
97
|
-
* mapped, or it was mapped and left blank — and only a filled-in cell is
|
|
98
|
-
* the file stating the list. Without this an update would clear the
|
|
99
|
-
* contacts of every deal in a file that never carried the column.
|
|
100
|
-
*/
|
|
101
122
|
readonly setsPeople: boolean
|
|
102
123
|
}
|
|
124
|
+
| {
|
|
125
|
+
readonly object: 'opportunities'
|
|
126
|
+
readonly draft: OpportunityFieldsDraft
|
|
127
|
+
readonly companyId: string | null
|
|
128
|
+
readonly stageId: string
|
|
129
|
+
readonly ownerId: string | null
|
|
130
|
+
readonly personIds: readonly string[]
|
|
131
|
+
readonly setsPeople: boolean
|
|
132
|
+
}
|
|
133
|
+
| {
|
|
134
|
+
readonly object: 'enquiries'
|
|
135
|
+
readonly draft: EnquiryFieldsDraft
|
|
136
|
+
readonly companyId: string | null
|
|
137
|
+
readonly stageId: string
|
|
138
|
+
readonly ownerId: string | null
|
|
139
|
+
readonly personIds: readonly string[]
|
|
140
|
+
readonly setsPeople: boolean
|
|
141
|
+
}
|
|
142
|
+
| {
|
|
143
|
+
readonly object: 'partnerships'
|
|
144
|
+
readonly draft: PartnershipFieldsDraft
|
|
145
|
+
readonly companyId: string
|
|
146
|
+
readonly stageId: string
|
|
147
|
+
readonly ownerId: string | null
|
|
148
|
+
readonly personIds: readonly string[]
|
|
149
|
+
readonly setsPeople: boolean
|
|
150
|
+
}
|
|
151
|
+
| {
|
|
152
|
+
readonly object: 'raises'
|
|
153
|
+
readonly draft: RaiseFieldsDraft
|
|
154
|
+
readonly companyId: string
|
|
155
|
+
readonly stageId: string
|
|
156
|
+
readonly ownerId: string | null
|
|
157
|
+
readonly personIds: readonly string[]
|
|
158
|
+
readonly setsPeople: boolean
|
|
159
|
+
}
|
|
160
|
+
| { readonly object: 'custom_fields'; readonly draft: CustomFieldDefinitionDraft }
|
|
103
161
|
|
|
104
162
|
export type RowPlan =
|
|
105
163
|
| { readonly action: 'error'; readonly errors: readonly StoredRowError[] }
|
|
@@ -139,24 +197,131 @@ function error(...errors: readonly StoredRowError[]): RowPlan {
|
|
|
139
197
|
return { action: 'error', errors }
|
|
140
198
|
}
|
|
141
199
|
|
|
200
|
+
function customFieldsForRow(
|
|
201
|
+
context: PlanContext,
|
|
202
|
+
mapped: Readonly<Record<string, string>>,
|
|
203
|
+
): Readonly<Record<string, import('@kelpie/schemas').CustomFieldWireValue>> {
|
|
204
|
+
const raw = extractCustomFieldRaw(mapped, context.baseColumnKeys)
|
|
205
|
+
|
|
206
|
+
return customFieldWireValues(raw, context.customFieldDefinitions)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const PIPELINE_LABEL: Readonly<Record<PipelineKind, string>> = {
|
|
210
|
+
deal: 'deal',
|
|
211
|
+
opportunity: 'opportunity',
|
|
212
|
+
enquiry: 'enquiry',
|
|
213
|
+
partnership: 'partnership',
|
|
214
|
+
raise: 'fundraising',
|
|
215
|
+
}
|
|
216
|
+
|
|
142
217
|
/**
|
|
143
|
-
* The stage a
|
|
218
|
+
* The stage a pipeline row names, as a stage of this workspace.
|
|
144
219
|
*
|
|
145
|
-
* Its own slug first, then its label, then the vendor alias table
|
|
146
|
-
* label because a rename leaves the slug alone, which is the whole reason an
|
|
147
|
-
* import addresses stages by slug (`pipeline_stages` in `schema.md`).
|
|
220
|
+
* Its own slug first, then its label, then the vendor alias table for deals.
|
|
148
221
|
*/
|
|
149
|
-
function resolveStageId(
|
|
222
|
+
function resolveStageId(context: PlanContext, raw: string): string | undefined {
|
|
150
223
|
const folded = raw.trim().toLowerCase()
|
|
151
|
-
const direct = lookups.
|
|
224
|
+
const direct = context.lookups.stageIdByName.get(folded)
|
|
152
225
|
|
|
153
226
|
if (direct !== undefined) {
|
|
154
227
|
return direct
|
|
155
228
|
}
|
|
156
229
|
|
|
157
|
-
const
|
|
230
|
+
const kind = pipelineKindForImport(context.object)
|
|
231
|
+
|
|
232
|
+
if (kind === 'deal') {
|
|
233
|
+
const aliased = aliasedStageSlug(raw)
|
|
234
|
+
|
|
235
|
+
return aliased === undefined ? undefined : context.lookups.stageIdByName.get(aliased)
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return undefined
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function pipelineStageError(context: PlanContext, raw: string): StoredRowError {
|
|
242
|
+
const kind = pipelineKindForImport(context.object)
|
|
243
|
+
const label = kind === null ? 'pipeline' : PIPELINE_LABEL[kind]
|
|
244
|
+
|
|
245
|
+
return {
|
|
246
|
+
field: 'stage',
|
|
247
|
+
message: `"${raw.trim()}" is not a stage of this workspace's ${label} pipeline`,
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
interface ResolvedPeople {
|
|
252
|
+
readonly ownerId: string | null
|
|
253
|
+
readonly personIds: readonly string[]
|
|
254
|
+
readonly setsPeople: boolean
|
|
255
|
+
readonly problems: readonly StoredRowError[]
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function resolveOwnerAndPeople(
|
|
259
|
+
context: PlanContext,
|
|
260
|
+
mapped: Readonly<Record<string, string>>,
|
|
261
|
+
): ResolvedPeople {
|
|
262
|
+
const problems: StoredRowError[] = []
|
|
263
|
+
const ownerEmail = normaliseEmail(mapped.owner_email ?? '')
|
|
264
|
+
const ownerId = ownerEmail === null ? null : (context.lookups.memberIdByEmail.get(ownerEmail) ?? null)
|
|
265
|
+
|
|
266
|
+
if (ownerEmail !== null && ownerId === null) {
|
|
267
|
+
problems.push({
|
|
268
|
+
field: 'owner_email',
|
|
269
|
+
message: `Nobody in this workspace is ${ownerEmail}. Leave the column unmapped to import without owners`,
|
|
270
|
+
})
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const personIds: string[] = []
|
|
274
|
+
|
|
275
|
+
for (const raw of splitList(mapped.person_emails)) {
|
|
276
|
+
const address = normaliseEmail(raw)
|
|
277
|
+
const personId = address === null ? undefined : context.lookups.personIdByEmail.get(address)
|
|
278
|
+
|
|
279
|
+
if (personId === undefined) {
|
|
280
|
+
problems.push({ field: 'person_emails', message: `No person here has the address ${raw}` })
|
|
281
|
+
continue
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
personIds.push(personId)
|
|
285
|
+
}
|
|
158
286
|
|
|
159
|
-
return
|
|
287
|
+
return {
|
|
288
|
+
ownerId,
|
|
289
|
+
personIds: [...new Set(personIds)],
|
|
290
|
+
setsPeople: (mapped.person_emails ?? '').trim().length > 0,
|
|
291
|
+
problems,
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function resolveCompanyId(
|
|
296
|
+
context: PlanContext,
|
|
297
|
+
mapped: Readonly<Record<string, string>>,
|
|
298
|
+
required: boolean,
|
|
299
|
+
): { readonly companyId: string | null; readonly problems: readonly StoredRowError[] } {
|
|
300
|
+
const problems: StoredRowError[] = []
|
|
301
|
+
const domainRaw = (mapped.company_domain ?? '').trim()
|
|
302
|
+
|
|
303
|
+
if (domainRaw.length === 0) {
|
|
304
|
+
if (required) {
|
|
305
|
+
problems.push({
|
|
306
|
+
field: 'company_domain',
|
|
307
|
+
message: 'No company here has that domain. Import companies first',
|
|
308
|
+
})
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return { companyId: null, problems }
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
const domain = normaliseDomain(domainRaw)
|
|
315
|
+
const companyId = domain === null ? undefined : context.lookups.companyIdByDomain.get(domain)
|
|
316
|
+
|
|
317
|
+
if (companyId === undefined) {
|
|
318
|
+
problems.push({
|
|
319
|
+
field: 'company_domain',
|
|
320
|
+
message: 'No company here has that domain. Import companies first',
|
|
321
|
+
})
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return { companyId: companyId ?? null, problems }
|
|
160
325
|
}
|
|
161
326
|
|
|
162
327
|
function planPosition(context: PlanContext, mapped: Readonly<Record<string, string>>): ImportWrite | RowPlan {
|
|
@@ -184,90 +349,166 @@ function planPosition(context: PlanContext, mapped: Readonly<Record<string, stri
|
|
|
184
349
|
return { object: 'positions', personId, companyId, title: (mapped.title ?? '').trim() }
|
|
185
350
|
}
|
|
186
351
|
|
|
187
|
-
/**
|
|
188
|
-
* A deal's company, stage, owner and contacts.
|
|
189
|
-
*
|
|
190
|
-
* A missing company fails the row rather than creating a stub, per
|
|
191
|
-
* `import-export.md`. An `owner_email` that names nobody in the workspace also
|
|
192
|
-
* fails it: the mockup silently resolves that to the importer, and quietly
|
|
193
|
-
* moving another person's deals onto whoever ran the import is worse data than a
|
|
194
|
-
* refused row. Unmapping the column is the way to import without owners.
|
|
195
|
-
*/
|
|
196
352
|
function planDeal(context: PlanContext, mapped: Readonly<Record<string, string>>): ImportWrite | RowPlan {
|
|
197
|
-
const
|
|
198
|
-
const
|
|
199
|
-
const
|
|
353
|
+
const customFields = customFieldsForRow(context, mapped)
|
|
354
|
+
const { companyId, problems: companyProblems } = resolveCompanyId(context, mapped, true)
|
|
355
|
+
const stageId = resolveStageId(context, mapped.stage ?? '')
|
|
356
|
+
const people = resolveOwnerAndPeople(context, mapped)
|
|
357
|
+
const problems = [...companyProblems, ...people.problems]
|
|
200
358
|
|
|
201
|
-
if (
|
|
202
|
-
problems.push(
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
359
|
+
if (stageId === undefined) {
|
|
360
|
+
problems.push(pipelineStageError(context, mapped.stage ?? ''))
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if (problems.length > 0 || companyId === null || stageId === undefined) {
|
|
364
|
+
return error(...problems)
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
return {
|
|
368
|
+
object: 'deals',
|
|
369
|
+
draft: dealFieldsDraft(mapped, customFields),
|
|
370
|
+
companyId,
|
|
371
|
+
stageId,
|
|
372
|
+
ownerId: people.ownerId,
|
|
373
|
+
personIds: people.personIds,
|
|
374
|
+
setsPeople: people.setsPeople,
|
|
206
375
|
}
|
|
376
|
+
}
|
|
207
377
|
|
|
208
|
-
|
|
378
|
+
function planOpportunity(
|
|
379
|
+
context: PlanContext,
|
|
380
|
+
mapped: Readonly<Record<string, string>>,
|
|
381
|
+
): ImportWrite | RowPlan {
|
|
382
|
+
const customFields = customFieldsForRow(context, mapped)
|
|
383
|
+
const { companyId, problems: companyProblems } = resolveCompanyId(context, mapped, false)
|
|
384
|
+
const stageId = resolveStageId(context, mapped.stage ?? '')
|
|
385
|
+
const people = resolveOwnerAndPeople(context, mapped)
|
|
386
|
+
const problems = [...companyProblems, ...people.problems]
|
|
209
387
|
|
|
210
388
|
if (stageId === undefined) {
|
|
211
|
-
problems.push(
|
|
212
|
-
field: 'stage',
|
|
213
|
-
message: `"${(mapped.stage ?? '').trim()}" is not a stage of this workspace's deal pipeline`,
|
|
214
|
-
})
|
|
389
|
+
problems.push(pipelineStageError(context, mapped.stage ?? ''))
|
|
215
390
|
}
|
|
216
391
|
|
|
217
|
-
|
|
218
|
-
|
|
392
|
+
if (problems.length > 0 || stageId === undefined) {
|
|
393
|
+
return error(...problems)
|
|
394
|
+
}
|
|
219
395
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
396
|
+
return {
|
|
397
|
+
object: 'opportunities',
|
|
398
|
+
draft: opportunityFieldsDraft(mapped, customFields),
|
|
399
|
+
companyId,
|
|
400
|
+
stageId,
|
|
401
|
+
ownerId: people.ownerId,
|
|
402
|
+
personIds: people.personIds,
|
|
403
|
+
setsPeople: people.setsPeople,
|
|
225
404
|
}
|
|
405
|
+
}
|
|
226
406
|
|
|
227
|
-
|
|
407
|
+
function planEnquiry(context: PlanContext, mapped: Readonly<Record<string, string>>): ImportWrite | RowPlan {
|
|
408
|
+
const customFields = customFieldsForRow(context, mapped)
|
|
409
|
+
const { companyId, problems: companyProblems } = resolveCompanyId(context, mapped, false)
|
|
410
|
+
const stageId = resolveStageId(context, mapped.stage ?? '')
|
|
411
|
+
const people = resolveOwnerAndPeople(context, mapped)
|
|
412
|
+
const problems = [...companyProblems, ...people.problems]
|
|
228
413
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
414
|
+
if (stageId === undefined) {
|
|
415
|
+
problems.push(pipelineStageError(context, mapped.stage ?? ''))
|
|
416
|
+
}
|
|
232
417
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}
|
|
418
|
+
if (problems.length > 0 || stageId === undefined) {
|
|
419
|
+
return error(...problems)
|
|
420
|
+
}
|
|
237
421
|
|
|
238
|
-
|
|
422
|
+
return {
|
|
423
|
+
object: 'enquiries',
|
|
424
|
+
draft: enquiryFieldsDraft(mapped, customFields),
|
|
425
|
+
companyId,
|
|
426
|
+
stageId,
|
|
427
|
+
ownerId: people.ownerId,
|
|
428
|
+
personIds: people.personIds,
|
|
429
|
+
setsPeople: people.setsPeople,
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function planPartnership(
|
|
434
|
+
context: PlanContext,
|
|
435
|
+
mapped: Readonly<Record<string, string>>,
|
|
436
|
+
): ImportWrite | RowPlan {
|
|
437
|
+
const customFields = customFieldsForRow(context, mapped)
|
|
438
|
+
const { companyId, problems: companyProblems } = resolveCompanyId(context, mapped, true)
|
|
439
|
+
const stageId = resolveStageId(context, mapped.stage ?? '')
|
|
440
|
+
const people = resolveOwnerAndPeople(context, mapped)
|
|
441
|
+
const problems = [...companyProblems, ...people.problems]
|
|
442
|
+
|
|
443
|
+
if (stageId === undefined) {
|
|
444
|
+
problems.push(pipelineStageError(context, mapped.stage ?? ''))
|
|
239
445
|
}
|
|
240
446
|
|
|
241
|
-
if (problems.length > 0 || companyId ===
|
|
447
|
+
if (problems.length > 0 || companyId === null || stageId === undefined) {
|
|
242
448
|
return error(...problems)
|
|
243
449
|
}
|
|
244
450
|
|
|
245
451
|
return {
|
|
246
|
-
object: '
|
|
247
|
-
draft:
|
|
452
|
+
object: 'partnerships',
|
|
453
|
+
draft: partnershipFieldsDraft(mapped, customFields),
|
|
248
454
|
companyId,
|
|
249
455
|
stageId,
|
|
250
|
-
ownerId,
|
|
251
|
-
personIds:
|
|
252
|
-
setsPeople:
|
|
456
|
+
ownerId: people.ownerId,
|
|
457
|
+
personIds: people.personIds,
|
|
458
|
+
setsPeople: people.setsPeople,
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
function planRaise(context: PlanContext, mapped: Readonly<Record<string, string>>): ImportWrite | RowPlan {
|
|
463
|
+
const customFields = customFieldsForRow(context, mapped)
|
|
464
|
+
const { companyId, problems: companyProblems } = resolveCompanyId(context, mapped, true)
|
|
465
|
+
const stageId = resolveStageId(context, mapped.stage ?? '')
|
|
466
|
+
const people = resolveOwnerAndPeople(context, mapped)
|
|
467
|
+
const problems = [...companyProblems, ...people.problems]
|
|
468
|
+
|
|
469
|
+
if (stageId === undefined) {
|
|
470
|
+
problems.push(pipelineStageError(context, mapped.stage ?? ''))
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
if (problems.length > 0 || companyId === null || stageId === undefined) {
|
|
474
|
+
return error(...problems)
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
return {
|
|
478
|
+
object: 'raises',
|
|
479
|
+
draft: raiseFieldsDraft(mapped, customFields),
|
|
480
|
+
companyId,
|
|
481
|
+
stageId,
|
|
482
|
+
ownerId: people.ownerId,
|
|
483
|
+
personIds: people.personIds,
|
|
484
|
+
setsPeople: people.setsPeople,
|
|
253
485
|
}
|
|
254
486
|
}
|
|
255
487
|
|
|
488
|
+
function planCustomFieldDefinition(
|
|
489
|
+
_context: PlanContext,
|
|
490
|
+
mapped: Readonly<Record<string, string>>,
|
|
491
|
+
): ImportWrite {
|
|
492
|
+
return { object: 'custom_fields', draft: customFieldDefinitionDraft(mapped) }
|
|
493
|
+
}
|
|
494
|
+
|
|
256
495
|
function isRowPlan(value: ImportWrite | RowPlan): value is RowPlan {
|
|
257
496
|
return 'action' in value
|
|
258
497
|
}
|
|
259
498
|
|
|
260
499
|
/** Resolves every reference the row names into the write it would perform. */
|
|
261
500
|
function resolveWrite(context: PlanContext, mapped: Readonly<Record<string, string>>): ImportWrite | RowPlan {
|
|
501
|
+
const customFields = customFieldsForRow(context, mapped)
|
|
502
|
+
|
|
262
503
|
switch (context.object) {
|
|
263
504
|
case 'companies':
|
|
264
|
-
return { object: 'companies', draft: companyDraft(mapped) }
|
|
505
|
+
return { object: 'companies', draft: companyDraft(mapped, customFields) }
|
|
265
506
|
case 'people': {
|
|
266
507
|
const write: {
|
|
267
508
|
object: 'people'
|
|
268
509
|
draft: PersonDraft
|
|
269
510
|
consent?: ImportConsentGrant
|
|
270
|
-
} = { object: 'people', draft: personDraft(mapped) }
|
|
511
|
+
} = { object: 'people', draft: personDraft(mapped, customFields) }
|
|
271
512
|
const consent = readConsentGrant(context, mapped)
|
|
272
513
|
if (consent !== undefined) {
|
|
273
514
|
write.consent = consent
|
|
@@ -278,6 +519,16 @@ function resolveWrite(context: PlanContext, mapped: Readonly<Record<string, stri
|
|
|
278
519
|
return planPosition(context, mapped)
|
|
279
520
|
case 'deals':
|
|
280
521
|
return planDeal(context, mapped)
|
|
522
|
+
case 'opportunities':
|
|
523
|
+
return planOpportunity(context, mapped)
|
|
524
|
+
case 'enquiries':
|
|
525
|
+
return planEnquiry(context, mapped)
|
|
526
|
+
case 'partnerships':
|
|
527
|
+
return planPartnership(context, mapped)
|
|
528
|
+
case 'raises':
|
|
529
|
+
return planRaise(context, mapped)
|
|
530
|
+
case 'custom_fields':
|
|
531
|
+
return planCustomFieldDefinition(context, mapped)
|
|
281
532
|
}
|
|
282
533
|
}
|
|
283
534
|
|
|
@@ -383,7 +634,10 @@ function withAffiliation(
|
|
|
383
634
|
* otherwise the job's conflict mode decides between `skip` and `update`.
|
|
384
635
|
*/
|
|
385
636
|
export function planRow(context: PlanContext, mapped: Readonly<Record<string, string>>): RowPlan {
|
|
386
|
-
const invalid = validateRow(context.object, context.matchKey, mapped
|
|
637
|
+
const invalid = validateRow(context.object, context.matchKey, mapped, {
|
|
638
|
+
baseColumnKeys: context.baseColumnKeys,
|
|
639
|
+
customFieldDefinitions: context.customFieldDefinitions,
|
|
640
|
+
})
|
|
387
641
|
|
|
388
642
|
if (invalid.length > 0) {
|
|
389
643
|
return error(...invalid)
|