@kelpie/server 0.10.0 → 0.11.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/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/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/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/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/meta/0038_snapshot.json +6554 -0
- package/migrations/meta/_journal.json +42 -0
- package/package.json +2 -2
- package/src/app.ts +3 -0
- package/src/lib/actor.ts +3 -1
- package/src/lib/apiKeyScopes.ts +213 -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/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/testing/fixtures.ts +1 -0
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { and, asc, eq, gt, inArray, sql } from 'drizzle-orm'
|
|
2
2
|
|
|
3
|
+
import type { CustomFieldValue } from '@kelpie/schemas'
|
|
3
4
|
import type { Queryable } from '../../runtime/transaction.ts'
|
|
4
5
|
import { users } from '../auth/schema.ts'
|
|
5
6
|
import { companies } from '../companies/schema.ts'
|
|
6
7
|
import { consentPurposes } from '../consent-purposes/schema.ts'
|
|
8
|
+
import { customFieldDefinitions } from '../custom-fields/schema.ts'
|
|
9
|
+
import type { CustomFieldDefinitionRecord } from '../custom-fields/repository.ts'
|
|
7
10
|
import { deals } from '../deals/schema.ts'
|
|
11
|
+
import { enquiries } from '../enquiries/schema.ts'
|
|
12
|
+
import { opportunities } from '../opportunities/schema.ts'
|
|
13
|
+
import { partnerships } from '../partnerships/schema.ts'
|
|
8
14
|
import { people, personConsents, personLinks } from '../people/schema.ts'
|
|
9
15
|
import { pipelineStages } from '../pipelines/schema.ts'
|
|
10
16
|
import { positions } from '../positions/schema.ts'
|
|
17
|
+
import { raises } from '../raises/schema.ts'
|
|
11
18
|
import { workspaceMembers } from '../workspace/schema.ts'
|
|
12
19
|
import type { MatchKeyParts } from './mapping.ts'
|
|
13
20
|
import { importJobRows, importJobs } from './schema.ts'
|
|
@@ -364,6 +371,150 @@ export function findDealKeysByCompany(
|
|
|
364
371
|
)
|
|
365
372
|
}
|
|
366
373
|
|
|
374
|
+
export function findOpportunityKeysByName(
|
|
375
|
+
db: Queryable,
|
|
376
|
+
workspaceId: string,
|
|
377
|
+
names: readonly string[],
|
|
378
|
+
): Promise<KeyedRecord[]> {
|
|
379
|
+
return overChunks(names, (chunk) =>
|
|
380
|
+
db
|
|
381
|
+
.select({ id: opportunities.id, name: opportunities.name })
|
|
382
|
+
.from(opportunities)
|
|
383
|
+
.where(
|
|
384
|
+
and(
|
|
385
|
+
eq(opportunities.workspaceId, workspaceId),
|
|
386
|
+
inArray(sql<string>`lower(${opportunities.name})`, [...chunk]),
|
|
387
|
+
),
|
|
388
|
+
),
|
|
389
|
+
).then((rows) => rows.map((row) => ({ id: row.id, parts: { name: row.name } })))
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
export function findOpportunityKeysByCompany(
|
|
393
|
+
db: Queryable,
|
|
394
|
+
workspaceId: string,
|
|
395
|
+
domains: readonly string[],
|
|
396
|
+
): Promise<KeyedRecord[]> {
|
|
397
|
+
return overChunks(domains, (chunk) =>
|
|
398
|
+
db
|
|
399
|
+
.select({ id: opportunities.id, name: opportunities.name, companyDomain: companies.domain })
|
|
400
|
+
.from(opportunities)
|
|
401
|
+
.leftJoin(companies, eq(companies.id, opportunities.companyId))
|
|
402
|
+
.where(and(eq(opportunities.workspaceId, workspaceId), inArray(companies.domain, [...chunk]))),
|
|
403
|
+
).then((rows) =>
|
|
404
|
+
rows.map((row) => ({
|
|
405
|
+
id: row.id,
|
|
406
|
+
parts: { name: row.name, company_domain: row.companyDomain },
|
|
407
|
+
})),
|
|
408
|
+
)
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
export function findEnquiryKeysByName(
|
|
412
|
+
db: Queryable,
|
|
413
|
+
workspaceId: string,
|
|
414
|
+
names: readonly string[],
|
|
415
|
+
): Promise<KeyedRecord[]> {
|
|
416
|
+
return overChunks(names, (chunk) =>
|
|
417
|
+
db
|
|
418
|
+
.select({ id: enquiries.id, name: enquiries.name })
|
|
419
|
+
.from(enquiries)
|
|
420
|
+
.where(
|
|
421
|
+
and(
|
|
422
|
+
eq(enquiries.workspaceId, workspaceId),
|
|
423
|
+
inArray(sql<string>`lower(${enquiries.name})`, [...chunk]),
|
|
424
|
+
),
|
|
425
|
+
),
|
|
426
|
+
).then((rows) => rows.map((row) => ({ id: row.id, parts: { name: row.name } })))
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
export function findEnquiryKeysByCompany(
|
|
430
|
+
db: Queryable,
|
|
431
|
+
workspaceId: string,
|
|
432
|
+
domains: readonly string[],
|
|
433
|
+
): Promise<KeyedRecord[]> {
|
|
434
|
+
return overChunks(domains, (chunk) =>
|
|
435
|
+
db
|
|
436
|
+
.select({ id: enquiries.id, name: enquiries.name, companyDomain: companies.domain })
|
|
437
|
+
.from(enquiries)
|
|
438
|
+
.leftJoin(companies, eq(companies.id, enquiries.companyId))
|
|
439
|
+
.where(and(eq(enquiries.workspaceId, workspaceId), inArray(companies.domain, [...chunk]))),
|
|
440
|
+
).then((rows) =>
|
|
441
|
+
rows.map((row) => ({
|
|
442
|
+
id: row.id,
|
|
443
|
+
parts: { name: row.name, company_domain: row.companyDomain },
|
|
444
|
+
})),
|
|
445
|
+
)
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
export function findPartnershipKeysByCompany(
|
|
449
|
+
db: Queryable,
|
|
450
|
+
workspaceId: string,
|
|
451
|
+
domains: readonly string[],
|
|
452
|
+
): Promise<KeyedRecord[]> {
|
|
453
|
+
return overChunks(domains, (chunk) =>
|
|
454
|
+
db
|
|
455
|
+
.select({ id: partnerships.id, name: partnerships.name, companyDomain: companies.domain })
|
|
456
|
+
.from(partnerships)
|
|
457
|
+
.innerJoin(companies, eq(companies.id, partnerships.companyId))
|
|
458
|
+
.where(and(eq(partnerships.workspaceId, workspaceId), inArray(companies.domain, [...chunk]))),
|
|
459
|
+
).then((rows) =>
|
|
460
|
+
rows.map((row) => ({
|
|
461
|
+
id: row.id,
|
|
462
|
+
parts: { name: row.name, company_domain: row.companyDomain },
|
|
463
|
+
})),
|
|
464
|
+
)
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
export function findRaiseKeysByCompany(
|
|
468
|
+
db: Queryable,
|
|
469
|
+
workspaceId: string,
|
|
470
|
+
domains: readonly string[],
|
|
471
|
+
): Promise<KeyedRecord[]> {
|
|
472
|
+
return overChunks(domains, (chunk) =>
|
|
473
|
+
db
|
|
474
|
+
.select({ id: raises.id, name: raises.name, companyDomain: companies.domain })
|
|
475
|
+
.from(raises)
|
|
476
|
+
.innerJoin(companies, eq(companies.id, raises.companyId))
|
|
477
|
+
.where(and(eq(raises.workspaceId, workspaceId), inArray(companies.domain, [...chunk]))),
|
|
478
|
+
).then((rows) =>
|
|
479
|
+
rows.map((row) => ({
|
|
480
|
+
id: row.id,
|
|
481
|
+
parts: { name: row.name, company_domain: row.companyDomain },
|
|
482
|
+
})),
|
|
483
|
+
)
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
export function findCustomFieldDefinitionKeys(
|
|
487
|
+
db: Queryable,
|
|
488
|
+
workspaceId: string,
|
|
489
|
+
objectTypes: readonly string[],
|
|
490
|
+
keys: readonly string[],
|
|
491
|
+
): Promise<KeyedRecord[]> {
|
|
492
|
+
if (objectTypes.length === 0 || keys.length === 0) {
|
|
493
|
+
return Promise.resolve([])
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
return db
|
|
497
|
+
.select({
|
|
498
|
+
id: customFieldDefinitions.id,
|
|
499
|
+
objectType: customFieldDefinitions.objectType,
|
|
500
|
+
key: customFieldDefinitions.key,
|
|
501
|
+
})
|
|
502
|
+
.from(customFieldDefinitions)
|
|
503
|
+
.where(
|
|
504
|
+
and(
|
|
505
|
+
eq(customFieldDefinitions.workspaceId, workspaceId),
|
|
506
|
+
inArray(customFieldDefinitions.objectType, [...objectTypes]),
|
|
507
|
+
inArray(customFieldDefinitions.key, [...keys]),
|
|
508
|
+
),
|
|
509
|
+
)
|
|
510
|
+
.then((rows) =>
|
|
511
|
+
rows.map((row) => ({
|
|
512
|
+
id: row.id,
|
|
513
|
+
parts: { object_type: row.objectType, key: row.key },
|
|
514
|
+
})),
|
|
515
|
+
)
|
|
516
|
+
}
|
|
517
|
+
|
|
367
518
|
export function findPersonIdsByEmail(
|
|
368
519
|
db: Queryable,
|
|
369
520
|
workspaceId: string,
|
|
@@ -428,18 +579,27 @@ export function listMemberEmails(
|
|
|
428
579
|
.where(eq(workspaceMembers.workspaceId, workspaceId))
|
|
429
580
|
}
|
|
430
581
|
|
|
431
|
-
/**
|
|
432
|
-
export function
|
|
582
|
+
/** A pipeline's stages, for resolving a stage name in a row. */
|
|
583
|
+
export function listPipelineStages(
|
|
433
584
|
db: Queryable,
|
|
434
585
|
workspaceId: string,
|
|
586
|
+
kind: import('../pipelines/schema.ts').PipelineKind,
|
|
435
587
|
): Promise<{ id: string; slug: string; label: string }[]> {
|
|
436
588
|
return db
|
|
437
589
|
.select({ id: pipelineStages.id, slug: pipelineStages.slug, label: pipelineStages.label })
|
|
438
590
|
.from(pipelineStages)
|
|
439
|
-
.where(and(eq(pipelineStages.workspaceId, workspaceId), eq(pipelineStages.kind,
|
|
591
|
+
.where(and(eq(pipelineStages.workspaceId, workspaceId), eq(pipelineStages.kind, kind)))
|
|
440
592
|
.orderBy(asc(pipelineStages.sortOrder), asc(pipelineStages.id))
|
|
441
593
|
}
|
|
442
594
|
|
|
595
|
+
/** @deprecated Use `listPipelineStages` with kind `deal`. */
|
|
596
|
+
export function listDealStages(
|
|
597
|
+
db: Queryable,
|
|
598
|
+
workspaceId: string,
|
|
599
|
+
): Promise<{ id: string; slug: string; label: string }[]> {
|
|
600
|
+
return listPipelineStages(db, workspaceId, 'deal')
|
|
601
|
+
}
|
|
602
|
+
|
|
443
603
|
/* Export readers. Keyset by id, which is a ULID and therefore creation order. */
|
|
444
604
|
|
|
445
605
|
export interface ExportCompanyRow {
|
|
@@ -456,6 +616,7 @@ export interface ExportCompanyRow {
|
|
|
456
616
|
readonly tags: readonly string[]
|
|
457
617
|
readonly website: string | null
|
|
458
618
|
readonly hq: string | null
|
|
619
|
+
readonly customFields: Readonly<Record<string, CustomFieldValue>>
|
|
459
620
|
}
|
|
460
621
|
|
|
461
622
|
export function readCompanies(
|
|
@@ -478,6 +639,7 @@ export function readCompanies(
|
|
|
478
639
|
tags: companies.tags,
|
|
479
640
|
website: companies.website,
|
|
480
641
|
hq: companies.hq,
|
|
642
|
+
customFields: companies.customFields,
|
|
481
643
|
})
|
|
482
644
|
.from(companies)
|
|
483
645
|
.where(and(eq(companies.workspaceId, workspaceId), gt(companies.id, after)))
|
|
@@ -507,6 +669,7 @@ export interface ExportPersonRow {
|
|
|
507
669
|
* Purposes at their default (no explicit `person_consents` row) are omitted.
|
|
508
670
|
*/
|
|
509
671
|
readonly consents: string
|
|
672
|
+
readonly customFields: Readonly<Record<string, CustomFieldValue>>
|
|
510
673
|
}
|
|
511
674
|
|
|
512
675
|
export async function readPeople(
|
|
@@ -532,6 +695,7 @@ export async function readPeople(
|
|
|
532
695
|
tags: people.tags,
|
|
533
696
|
phones: people.phones,
|
|
534
697
|
doNotContact: people.doNotContact,
|
|
698
|
+
customFields: people.customFields,
|
|
535
699
|
})
|
|
536
700
|
.from(people)
|
|
537
701
|
.where(and(eq(people.workspaceId, workspaceId), gt(people.id, after)))
|
|
@@ -622,6 +786,7 @@ export interface ExportDealRow {
|
|
|
622
786
|
readonly summary: string
|
|
623
787
|
readonly tags: readonly string[]
|
|
624
788
|
readonly externalId: string | null
|
|
789
|
+
readonly customFields: Readonly<Record<string, CustomFieldValue>>
|
|
625
790
|
}
|
|
626
791
|
|
|
627
792
|
/**
|
|
@@ -648,6 +813,7 @@ export function readDeals(
|
|
|
648
813
|
summary: deals.summary,
|
|
649
814
|
tags: deals.tags,
|
|
650
815
|
externalId: deals.externalId,
|
|
816
|
+
customFields: deals.customFields,
|
|
651
817
|
})
|
|
652
818
|
.from(deals)
|
|
653
819
|
.innerJoin(companies, eq(companies.id, deals.companyId))
|
|
@@ -659,44 +825,220 @@ export function readDeals(
|
|
|
659
825
|
.limit(EXPORT_PAGE)
|
|
660
826
|
}
|
|
661
827
|
|
|
662
|
-
/** The addresses of the people
|
|
663
|
-
export async function
|
|
828
|
+
/** The addresses of the people linked to each of a page of pipeline records. */
|
|
829
|
+
export async function readLinkedPersonEmails(
|
|
664
830
|
db: Queryable,
|
|
665
831
|
workspaceId: string,
|
|
666
|
-
|
|
832
|
+
targetType: string,
|
|
833
|
+
targetIds: readonly string[],
|
|
667
834
|
): Promise<ReadonlyMap<string, readonly string[]>> {
|
|
668
|
-
if (
|
|
835
|
+
if (targetIds.length === 0) {
|
|
669
836
|
return new Map()
|
|
670
837
|
}
|
|
671
838
|
|
|
672
839
|
const rows = await db
|
|
673
|
-
.select({
|
|
840
|
+
.select({ targetId: personLinks.targetId, email: people.email })
|
|
674
841
|
.from(personLinks)
|
|
675
842
|
.innerJoin(people, eq(people.id, personLinks.personId))
|
|
676
843
|
.where(
|
|
677
844
|
and(
|
|
678
845
|
eq(personLinks.workspaceId, workspaceId),
|
|
679
|
-
eq(personLinks.targetType,
|
|
680
|
-
inArray(personLinks.targetId, [...
|
|
846
|
+
eq(personLinks.targetType, targetType),
|
|
847
|
+
inArray(personLinks.targetId, [...targetIds]),
|
|
681
848
|
),
|
|
682
849
|
)
|
|
683
850
|
.orderBy(asc(people.email))
|
|
684
851
|
|
|
685
|
-
const
|
|
852
|
+
const byTarget = new Map<string, string[]>()
|
|
686
853
|
|
|
687
854
|
for (const row of rows) {
|
|
688
855
|
if (row.email === null) {
|
|
689
856
|
continue
|
|
690
857
|
}
|
|
691
858
|
|
|
692
|
-
const existing =
|
|
859
|
+
const existing = byTarget.get(row.targetId)
|
|
693
860
|
|
|
694
861
|
if (existing === undefined) {
|
|
695
|
-
|
|
862
|
+
byTarget.set(row.targetId, [row.email])
|
|
696
863
|
} else {
|
|
697
864
|
existing.push(row.email)
|
|
698
865
|
}
|
|
699
866
|
}
|
|
700
867
|
|
|
701
|
-
return
|
|
868
|
+
return byTarget
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
/** @deprecated Use {@link readLinkedPersonEmails} with `targetType: 'deal'`. */
|
|
872
|
+
export async function readDealPersonEmails(
|
|
873
|
+
db: Queryable,
|
|
874
|
+
workspaceId: string,
|
|
875
|
+
dealIds: readonly string[],
|
|
876
|
+
): Promise<ReadonlyMap<string, readonly string[]>> {
|
|
877
|
+
return readLinkedPersonEmails(db, workspaceId, 'deal', dealIds)
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
interface PipelineExportRow {
|
|
881
|
+
readonly id: string
|
|
882
|
+
readonly name: string
|
|
883
|
+
readonly companyDomain: string | null
|
|
884
|
+
readonly stageSlug: string
|
|
885
|
+
readonly ownerEmail: string | null
|
|
886
|
+
readonly summary: string
|
|
887
|
+
readonly tags: readonly string[]
|
|
888
|
+
readonly customFields: Readonly<Record<string, CustomFieldValue>>
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
export interface ExportOpportunityRow extends PipelineExportRow {
|
|
892
|
+
readonly kind: string
|
|
893
|
+
readonly expectedClose: string | null
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
export function readOpportunities(
|
|
897
|
+
db: Queryable,
|
|
898
|
+
workspaceId: string,
|
|
899
|
+
after: string,
|
|
900
|
+
): Promise<ExportOpportunityRow[]> {
|
|
901
|
+
return db
|
|
902
|
+
.select({
|
|
903
|
+
id: opportunities.id,
|
|
904
|
+
name: opportunities.name,
|
|
905
|
+
kind: opportunities.kind,
|
|
906
|
+
companyDomain: companies.domain,
|
|
907
|
+
stageSlug: pipelineStages.slug,
|
|
908
|
+
ownerEmail: users.email,
|
|
909
|
+
expectedClose: opportunities.expectedClose,
|
|
910
|
+
summary: opportunities.summary,
|
|
911
|
+
tags: opportunities.tags,
|
|
912
|
+
customFields: opportunities.customFields,
|
|
913
|
+
})
|
|
914
|
+
.from(opportunities)
|
|
915
|
+
.leftJoin(companies, eq(companies.id, opportunities.companyId))
|
|
916
|
+
.innerJoin(pipelineStages, eq(pipelineStages.id, opportunities.stageId))
|
|
917
|
+
.leftJoin(workspaceMembers, eq(workspaceMembers.id, opportunities.ownerId))
|
|
918
|
+
.leftJoin(users, eq(users.id, workspaceMembers.userId))
|
|
919
|
+
.where(and(eq(opportunities.workspaceId, workspaceId), gt(opportunities.id, after)))
|
|
920
|
+
.orderBy(asc(opportunities.id))
|
|
921
|
+
.limit(EXPORT_PAGE)
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
export interface ExportEnquiryRow extends PipelineExportRow {
|
|
925
|
+
readonly source: string
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
export function readEnquiries(
|
|
929
|
+
db: Queryable,
|
|
930
|
+
workspaceId: string,
|
|
931
|
+
after: string,
|
|
932
|
+
): Promise<ExportEnquiryRow[]> {
|
|
933
|
+
return db
|
|
934
|
+
.select({
|
|
935
|
+
id: enquiries.id,
|
|
936
|
+
name: enquiries.name,
|
|
937
|
+
source: enquiries.source,
|
|
938
|
+
companyDomain: companies.domain,
|
|
939
|
+
stageSlug: pipelineStages.slug,
|
|
940
|
+
ownerEmail: users.email,
|
|
941
|
+
summary: enquiries.summary,
|
|
942
|
+
tags: enquiries.tags,
|
|
943
|
+
customFields: enquiries.customFields,
|
|
944
|
+
})
|
|
945
|
+
.from(enquiries)
|
|
946
|
+
.leftJoin(companies, eq(companies.id, enquiries.companyId))
|
|
947
|
+
.innerJoin(pipelineStages, eq(pipelineStages.id, enquiries.stageId))
|
|
948
|
+
.leftJoin(workspaceMembers, eq(workspaceMembers.id, enquiries.ownerId))
|
|
949
|
+
.leftJoin(users, eq(users.id, workspaceMembers.userId))
|
|
950
|
+
.where(and(eq(enquiries.workspaceId, workspaceId), gt(enquiries.id, after)))
|
|
951
|
+
.orderBy(asc(enquiries.id))
|
|
952
|
+
.limit(EXPORT_PAGE)
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
export interface ExportPartnershipRow extends PipelineExportRow {
|
|
956
|
+
readonly kind: string
|
|
957
|
+
readonly nextTouchpoint: string | null
|
|
958
|
+
readonly goals: string
|
|
959
|
+
readonly successLooksLike: string
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
export function readPartnerships(
|
|
963
|
+
db: Queryable,
|
|
964
|
+
workspaceId: string,
|
|
965
|
+
after: string,
|
|
966
|
+
): Promise<ExportPartnershipRow[]> {
|
|
967
|
+
return db
|
|
968
|
+
.select({
|
|
969
|
+
id: partnerships.id,
|
|
970
|
+
name: partnerships.name,
|
|
971
|
+
companyDomain: companies.domain,
|
|
972
|
+
stageSlug: pipelineStages.slug,
|
|
973
|
+
kind: partnerships.kind,
|
|
974
|
+
nextTouchpoint: partnerships.nextTouchpoint,
|
|
975
|
+
ownerEmail: users.email,
|
|
976
|
+
goals: partnerships.goals,
|
|
977
|
+
successLooksLike: partnerships.successLooksLike,
|
|
978
|
+
summary: partnerships.summary,
|
|
979
|
+
tags: partnerships.tags,
|
|
980
|
+
customFields: partnerships.customFields,
|
|
981
|
+
})
|
|
982
|
+
.from(partnerships)
|
|
983
|
+
.innerJoin(companies, eq(companies.id, partnerships.companyId))
|
|
984
|
+
.innerJoin(pipelineStages, eq(pipelineStages.id, partnerships.stageId))
|
|
985
|
+
.leftJoin(workspaceMembers, eq(workspaceMembers.id, partnerships.ownerId))
|
|
986
|
+
.leftJoin(users, eq(users.id, workspaceMembers.userId))
|
|
987
|
+
.where(and(eq(partnerships.workspaceId, workspaceId), gt(partnerships.id, after)))
|
|
988
|
+
.orderBy(asc(partnerships.id))
|
|
989
|
+
.limit(EXPORT_PAGE)
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
export interface ExportRaiseRow extends PipelineExportRow {
|
|
993
|
+
readonly checkSizeCents: number | null
|
|
994
|
+
readonly currency: string | null
|
|
995
|
+
readonly thesisFit: string
|
|
996
|
+
readonly passReason: string | null
|
|
997
|
+
readonly expectedClose: string | null
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
export function readRaises(
|
|
1001
|
+
db: Queryable,
|
|
1002
|
+
workspaceId: string,
|
|
1003
|
+
after: string,
|
|
1004
|
+
): Promise<ExportRaiseRow[]> {
|
|
1005
|
+
return db
|
|
1006
|
+
.select({
|
|
1007
|
+
id: raises.id,
|
|
1008
|
+
name: raises.name,
|
|
1009
|
+
companyDomain: companies.domain,
|
|
1010
|
+
stageSlug: pipelineStages.slug,
|
|
1011
|
+
checkSizeCents: raises.checkSizeCents,
|
|
1012
|
+
currency: raises.currency,
|
|
1013
|
+
thesisFit: raises.thesisFit,
|
|
1014
|
+
passReason: raises.passReason,
|
|
1015
|
+
ownerEmail: users.email,
|
|
1016
|
+
expectedClose: raises.expectedClose,
|
|
1017
|
+
summary: raises.summary,
|
|
1018
|
+
tags: raises.tags,
|
|
1019
|
+
customFields: raises.customFields,
|
|
1020
|
+
})
|
|
1021
|
+
.from(raises)
|
|
1022
|
+
.innerJoin(companies, eq(companies.id, raises.companyId))
|
|
1023
|
+
.innerJoin(pipelineStages, eq(pipelineStages.id, raises.stageId))
|
|
1024
|
+
.leftJoin(workspaceMembers, eq(workspaceMembers.id, raises.ownerId))
|
|
1025
|
+
.leftJoin(users, eq(users.id, workspaceMembers.userId))
|
|
1026
|
+
.where(and(eq(raises.workspaceId, workspaceId), gt(raises.id, after)))
|
|
1027
|
+
.orderBy(asc(raises.id))
|
|
1028
|
+
.limit(EXPORT_PAGE)
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
export function readCustomFieldDefinitions(
|
|
1032
|
+
db: Queryable,
|
|
1033
|
+
workspaceId: string,
|
|
1034
|
+
after: string,
|
|
1035
|
+
): Promise<CustomFieldDefinitionRecord[]> {
|
|
1036
|
+
return db
|
|
1037
|
+
.select()
|
|
1038
|
+
.from(customFieldDefinitions)
|
|
1039
|
+
.where(
|
|
1040
|
+
and(eq(customFieldDefinitions.workspaceId, workspaceId), gt(customFieldDefinitions.id, after)),
|
|
1041
|
+
)
|
|
1042
|
+
.orderBy(asc(customFieldDefinitions.id))
|
|
1043
|
+
.limit(EXPORT_PAGE)
|
|
702
1044
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
EXPORT_OBJECTS,
|
|
2
3
|
IMPORT_CONFLICT_MODES,
|
|
3
4
|
IMPORT_OBJECTS,
|
|
4
5
|
IMPORT_SOURCES,
|
|
@@ -6,7 +7,7 @@ import {
|
|
|
6
7
|
ON_MISSING_COMPANY,
|
|
7
8
|
defaultMatchKeyId,
|
|
8
9
|
} from '@kelpie/schemas'
|
|
9
|
-
import type {
|
|
10
|
+
import type { ExportObject, ImportColumnMap } from '@kelpie/schemas'
|
|
10
11
|
import type { Context, Hono } from 'hono'
|
|
11
12
|
import { stream } from 'hono/streaming'
|
|
12
13
|
import { z } from 'zod'
|
|
@@ -29,7 +30,7 @@ import type { ImportExportService, ImportJobView } from './service.ts'
|
|
|
29
30
|
/** The file name a download is offered under. */
|
|
30
31
|
const DOWNLOAD_PREFIX = 'kelpie'
|
|
31
32
|
|
|
32
|
-
const objectFile = z.enum(
|
|
33
|
+
const objectFile = z.enum(EXPORT_OBJECTS.map((object) => `${object}.csv`) as [string, ...string[]])
|
|
33
34
|
|
|
34
35
|
/**
|
|
35
36
|
* `column_map` arrives as a JSON string inside the form, since a multipart field
|
|
@@ -78,16 +79,16 @@ export function importJobResponse(job: ImportJobView): Record<string, unknown> {
|
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
/** `people.csv` → `people`. The route's own param, so an unknown one is a 404. */
|
|
81
|
-
function readObjectFile(context: Context):
|
|
82
|
+
function readObjectFile(context: Context): ExportObject {
|
|
82
83
|
const parsed = objectFile.safeParse(context.req.param('file'))
|
|
83
84
|
|
|
84
85
|
if (!parsed.success) {
|
|
85
86
|
throw AppError.notFound(
|
|
86
|
-
`Export ${
|
|
87
|
+
`Export ${EXPORT_OBJECTS.map((object) => `${object}.csv`).join(', ')}`,
|
|
87
88
|
)
|
|
88
89
|
}
|
|
89
90
|
|
|
90
|
-
return parsed.data.replace(/\.csv$/u, '') as
|
|
91
|
+
return parsed.data.replace(/\.csv$/u, '') as ExportObject
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
function csvHeaders(fileName: string): Record<string, string> {
|
|
@@ -198,11 +199,10 @@ export function mountImportExportRoutes(
|
|
|
198
199
|
|
|
199
200
|
router.get('/export/templates/:file', async (context) => {
|
|
200
201
|
const object = readObjectFile(context)
|
|
201
|
-
|
|
202
|
-
await requireActor(context)
|
|
202
|
+
const actor = await requireActor(context)
|
|
203
203
|
|
|
204
204
|
return context.body(
|
|
205
|
-
dependencies.service.templateCsv(object),
|
|
205
|
+
await dependencies.service.templateCsv(actor, object),
|
|
206
206
|
200,
|
|
207
207
|
csvHeaders(`${DOWNLOAD_PREFIX}-${object}-template.csv`),
|
|
208
208
|
)
|