@kelpie/server 0.5.2 → 0.7.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/README.md +5 -2
- package/dist/app.d.ts +13 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +9 -0
- package/dist/app.js.map +1 -1
- package/dist/boot.d.ts +42 -0
- package/dist/boot.d.ts.map +1 -0
- package/dist/boot.js +57 -0
- package/dist/boot.js.map +1 -0
- package/dist/index.d.ts +20 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/actor.d.ts +9 -1
- package/dist/lib/actor.d.ts.map +1 -1
- package/dist/lib/actor.js +13 -0
- package/dist/lib/actor.js.map +1 -1
- package/dist/lib/config.d.ts +51 -6
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +11 -5
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/email.d.ts +15 -63
- package/dist/lib/email.d.ts.map +1 -1
- package/dist/lib/email.js +13 -65
- package/dist/lib/email.js.map +1 -1
- package/dist/lib/fromEnv.d.ts +60 -0
- package/dist/lib/fromEnv.d.ts.map +1 -0
- package/dist/lib/fromEnv.js +94 -0
- package/dist/lib/fromEnv.js.map +1 -0
- package/dist/lib/ids.d.ts +6 -0
- package/dist/lib/ids.d.ts.map +1 -1
- package/dist/lib/ids.js +6 -0
- package/dist/lib/ids.js.map +1 -1
- package/dist/lib/kelpieConfigFile.d.ts +129 -0
- package/dist/lib/kelpieConfigFile.d.ts.map +1 -0
- package/dist/lib/kelpieConfigFile.js +112 -0
- package/dist/lib/kelpieConfigFile.js.map +1 -0
- package/dist/lib/logger.d.ts +38 -7
- package/dist/lib/logger.d.ts.map +1 -1
- package/dist/lib/logger.js +58 -20
- package/dist/lib/logger.js.map +1 -1
- package/dist/modules/agent-tasks/index.d.ts.map +1 -1
- package/dist/modules/agent-tasks/index.js +4 -1
- package/dist/modules/agent-tasks/index.js.map +1 -1
- package/dist/modules/agent-tasks/prompt.d.ts +36 -6
- package/dist/modules/agent-tasks/prompt.d.ts.map +1 -1
- package/dist/modules/agent-tasks/prompt.js +33 -4
- package/dist/modules/agent-tasks/prompt.js.map +1 -1
- package/dist/modules/agent-tasks/service.d.ts.map +1 -1
- package/dist/modules/agent-tasks/service.js +3 -2
- package/dist/modules/agent-tasks/service.js.map +1 -1
- package/dist/modules/agent-tasks/wire.d.ts +11 -0
- package/dist/modules/agent-tasks/wire.d.ts.map +1 -1
- package/dist/modules/agent-tasks/wire.js +1 -0
- package/dist/modules/agent-tasks/wire.js.map +1 -1
- package/dist/modules/auth/index.d.ts.map +1 -1
- package/dist/modules/auth/index.js +8 -7
- package/dist/modules/auth/index.js.map +1 -1
- package/dist/modules/companies/events.d.ts +22 -0
- package/dist/modules/companies/events.d.ts.map +1 -0
- package/dist/modules/companies/events.js +8 -0
- package/dist/modules/companies/events.js.map +1 -0
- package/dist/modules/companies/index.d.ts.map +1 -1
- package/dist/modules/companies/index.js +2 -0
- package/dist/modules/companies/index.js.map +1 -1
- package/dist/modules/companies/service.d.ts +1 -0
- package/dist/modules/companies/service.d.ts.map +1 -1
- package/dist/modules/companies/service.js +8 -11
- package/dist/modules/companies/service.js.map +1 -1
- package/dist/modules/core.d.ts.map +1 -1
- package/dist/modules/core.js +4 -0
- package/dist/modules/core.js.map +1 -1
- package/dist/modules/deals/events.d.ts +31 -0
- package/dist/modules/deals/events.d.ts.map +1 -0
- package/dist/modules/deals/events.js +12 -0
- package/dist/modules/deals/events.js.map +1 -0
- package/dist/modules/deals/index.d.ts.map +1 -1
- package/dist/modules/deals/index.js +2 -0
- package/dist/modules/deals/index.js.map +1 -1
- package/dist/modules/deals/service.d.ts +1 -0
- package/dist/modules/deals/service.d.ts.map +1 -1
- package/dist/modules/deals/service.js +9 -18
- package/dist/modules/deals/service.js.map +1 -1
- package/dist/modules/decisions/events.d.ts +21 -0
- package/dist/modules/decisions/events.d.ts.map +1 -0
- package/dist/modules/decisions/events.js +11 -0
- package/dist/modules/decisions/events.js.map +1 -0
- package/dist/modules/decisions/index.d.ts.map +1 -1
- package/dist/modules/decisions/index.js +2 -0
- package/dist/modules/decisions/index.js.map +1 -1
- package/dist/modules/decisions/service.d.ts +1 -0
- package/dist/modules/decisions/service.d.ts.map +1 -1
- package/dist/modules/decisions/service.js +4 -7
- package/dist/modules/decisions/service.js.map +1 -1
- package/dist/modules/eventCatalogs.d.ts +35 -0
- package/dist/modules/eventCatalogs.d.ts.map +1 -0
- package/dist/modules/eventCatalogs.js +35 -0
- package/dist/modules/eventCatalogs.js.map +1 -0
- package/dist/modules/forms/events.d.ts +37 -0
- package/dist/modules/forms/events.d.ts.map +1 -0
- package/dist/modules/forms/events.js +15 -0
- package/dist/modules/forms/events.js.map +1 -0
- package/dist/modules/forms/index.d.ts.map +1 -1
- package/dist/modules/forms/index.js +2 -0
- package/dist/modules/forms/index.js.map +1 -1
- package/dist/modules/forms/service.d.ts +1 -0
- package/dist/modules/forms/service.d.ts.map +1 -1
- package/dist/modules/forms/service.js +8 -11
- package/dist/modules/forms/service.js.map +1 -1
- package/dist/modules/forms/submission.d.ts +5 -0
- package/dist/modules/forms/submission.d.ts.map +1 -1
- package/dist/modules/forms/submission.js +54 -28
- package/dist/modules/forms/submission.js.map +1 -1
- package/dist/modules/handbook/events.d.ts +28 -0
- package/dist/modules/handbook/events.d.ts.map +1 -0
- package/dist/modules/handbook/events.js +14 -0
- package/dist/modules/handbook/events.js.map +1 -0
- package/dist/modules/handbook/index.d.ts.map +1 -1
- package/dist/modules/handbook/index.js +2 -0
- package/dist/modules/handbook/index.js.map +1 -1
- package/dist/modules/handbook/service.d.ts +1 -0
- package/dist/modules/handbook/service.d.ts.map +1 -1
- package/dist/modules/handbook/service.js +8 -15
- package/dist/modules/handbook/service.js.map +1 -1
- package/dist/modules/hiring/candidates.d.ts +1 -0
- package/dist/modules/hiring/candidates.d.ts.map +1 -1
- package/dist/modules/hiring/candidates.js +8 -11
- package/dist/modules/hiring/candidates.js.map +1 -1
- package/dist/modules/hiring/events.d.ts +35 -0
- package/dist/modules/hiring/events.d.ts.map +1 -0
- package/dist/modules/hiring/events.js +11 -0
- package/dist/modules/hiring/events.js.map +1 -0
- package/dist/modules/hiring/index.d.ts.map +1 -1
- package/dist/modules/hiring/index.js +2 -0
- package/dist/modules/hiring/index.js.map +1 -1
- package/dist/modules/hiring/roles.d.ts +1 -0
- package/dist/modules/hiring/roles.d.ts.map +1 -1
- package/dist/modules/hiring/roles.js +8 -11
- package/dist/modules/hiring/roles.js.map +1 -1
- package/dist/modules/import-export/drafts.d.ts +9 -0
- package/dist/modules/import-export/drafts.d.ts.map +1 -1
- package/dist/modules/import-export/drafts.js +25 -0
- package/dist/modules/import-export/drafts.js.map +1 -1
- package/dist/modules/import-export/events.d.ts +22 -0
- package/dist/modules/import-export/events.d.ts.map +1 -0
- package/dist/modules/import-export/events.js +12 -0
- package/dist/modules/import-export/events.js.map +1 -0
- package/dist/modules/import-export/exportRows.d.ts +9 -0
- package/dist/modules/import-export/exportRows.d.ts.map +1 -1
- package/dist/modules/import-export/exportRows.js +10 -1
- package/dist/modules/import-export/exportRows.js.map +1 -1
- package/dist/modules/import-export/index.d.ts.map +1 -1
- package/dist/modules/import-export/index.js +2 -0
- package/dist/modules/import-export/index.js.map +1 -1
- package/dist/modules/import-export/plan.d.ts +23 -1
- package/dist/modules/import-export/plan.d.ts.map +1 -1
- package/dist/modules/import-export/plan.js +62 -3
- 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 +25 -0
- package/dist/modules/import-export/presets.js.map +1 -1
- package/dist/modules/import-export/repository.d.ts +17 -0
- package/dist/modules/import-export/repository.d.ts.map +1 -1
- package/dist/modules/import-export/repository.js +21 -1
- 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 -1
- package/dist/modules/import-export/routes.js.map +1 -1
- package/dist/modules/import-export/schema.d.ts +55 -0
- package/dist/modules/import-export/schema.d.ts.map +1 -1
- package/dist/modules/import-export/schema.js +13 -1
- package/dist/modules/import-export/schema.js.map +1 -1
- package/dist/modules/import-export/service.d.ts +9 -1
- package/dist/modules/import-export/service.d.ts.map +1 -1
- package/dist/modules/import-export/service.js +104 -17
- package/dist/modules/import-export/service.js.map +1 -1
- package/dist/modules/import-export/tools.d.ts.map +1 -1
- package/dist/modules/import-export/tools.js +7 -1
- package/dist/modules/import-export/tools.js.map +1 -1
- package/dist/modules/import-export/writes.d.ts +16 -0
- package/dist/modules/import-export/writes.d.ts.map +1 -1
- package/dist/modules/import-export/writes.js +77 -2
- package/dist/modules/import-export/writes.js.map +1 -1
- package/dist/modules/notes/events.d.ts +22 -0
- package/dist/modules/notes/events.d.ts.map +1 -0
- package/dist/modules/notes/events.js +12 -0
- package/dist/modules/notes/events.js.map +1 -0
- package/dist/modules/notes/index.d.ts.map +1 -1
- package/dist/modules/notes/index.js +2 -0
- package/dist/modules/notes/index.js.map +1 -1
- package/dist/modules/notes/service.d.ts +1 -0
- package/dist/modules/notes/service.d.ts.map +1 -1
- package/dist/modules/notes/service.js +4 -7
- package/dist/modules/notes/service.js.map +1 -1
- package/dist/modules/opportunities/events.d.ts +31 -0
- package/dist/modules/opportunities/events.d.ts.map +1 -0
- package/dist/modules/opportunities/events.js +12 -0
- package/dist/modules/opportunities/events.js.map +1 -0
- package/dist/modules/opportunities/index.d.ts.map +1 -1
- package/dist/modules/opportunities/index.js +2 -0
- package/dist/modules/opportunities/index.js.map +1 -1
- package/dist/modules/opportunities/service.d.ts +1 -0
- package/dist/modules/opportunities/service.d.ts.map +1 -1
- package/dist/modules/opportunities/service.js +9 -18
- package/dist/modules/opportunities/service.js.map +1 -1
- package/dist/modules/partnerships/events.d.ts +31 -0
- package/dist/modules/partnerships/events.d.ts.map +1 -0
- package/dist/modules/partnerships/events.js +12 -0
- package/dist/modules/partnerships/events.js.map +1 -0
- package/dist/modules/partnerships/index.d.ts.map +1 -1
- package/dist/modules/partnerships/index.js +2 -0
- package/dist/modules/partnerships/index.js.map +1 -1
- package/dist/modules/partnerships/service.d.ts +1 -0
- package/dist/modules/partnerships/service.d.ts.map +1 -1
- package/dist/modules/partnerships/service.js +9 -18
- package/dist/modules/partnerships/service.js.map +1 -1
- package/dist/modules/people/events.d.ts +28 -0
- package/dist/modules/people/events.d.ts.map +1 -0
- package/dist/modules/people/events.js +18 -0
- package/dist/modules/people/events.js.map +1 -0
- package/dist/modules/people/index.d.ts.map +1 -1
- package/dist/modules/people/index.js +2 -0
- package/dist/modules/people/index.js.map +1 -1
- package/dist/modules/people/service.d.ts +1 -0
- package/dist/modules/people/service.d.ts.map +1 -1
- package/dist/modules/people/service.js +8 -11
- package/dist/modules/people/service.js.map +1 -1
- package/dist/modules/pipelines/service.d.ts +4 -0
- package/dist/modules/pipelines/service.d.ts.map +1 -1
- package/dist/modules/pipelines/service.js +31 -8
- package/dist/modules/pipelines/service.js.map +1 -1
- package/dist/modules/plans/events.d.ts +21 -0
- package/dist/modules/plans/events.d.ts.map +1 -0
- package/dist/modules/plans/events.js +11 -0
- package/dist/modules/plans/events.js.map +1 -0
- package/dist/modules/plans/index.d.ts.map +1 -1
- package/dist/modules/plans/index.js +2 -0
- package/dist/modules/plans/index.js.map +1 -1
- package/dist/modules/plans/service.d.ts +1 -0
- package/dist/modules/plans/service.d.ts.map +1 -1
- package/dist/modules/plans/service.js +6 -14
- package/dist/modules/plans/service.js.map +1 -1
- package/dist/modules/positions/events.d.ts +22 -0
- package/dist/modules/positions/events.d.ts.map +1 -0
- package/dist/modules/positions/events.js +8 -0
- package/dist/modules/positions/events.js.map +1 -0
- package/dist/modules/positions/index.d.ts.map +1 -1
- package/dist/modules/positions/index.js +2 -0
- package/dist/modules/positions/index.js.map +1 -1
- package/dist/modules/positions/service.d.ts +1 -0
- package/dist/modules/positions/service.d.ts.map +1 -1
- package/dist/modules/positions/service.js +8 -11
- package/dist/modules/positions/service.js.map +1 -1
- package/dist/modules/raises/events.d.ts +31 -0
- package/dist/modules/raises/events.d.ts.map +1 -0
- package/dist/modules/raises/events.js +12 -0
- package/dist/modules/raises/events.js.map +1 -0
- package/dist/modules/raises/index.d.ts.map +1 -1
- package/dist/modules/raises/index.js +2 -0
- package/dist/modules/raises/index.js.map +1 -1
- package/dist/modules/raises/service.d.ts +1 -0
- package/dist/modules/raises/service.d.ts.map +1 -1
- package/dist/modules/raises/service.js +9 -18
- package/dist/modules/raises/service.js.map +1 -1
- package/dist/modules/reseal.d.ts +55 -0
- package/dist/modules/reseal.d.ts.map +1 -1
- package/dist/modules/reseal.js +90 -1
- package/dist/modules/reseal.js.map +1 -1
- package/dist/modules/smtp-email/index.d.ts +69 -0
- package/dist/modules/smtp-email/index.d.ts.map +1 -0
- package/dist/modules/smtp-email/index.js +82 -0
- package/dist/modules/smtp-email/index.js.map +1 -0
- package/dist/modules/webhooks/index.d.ts.map +1 -1
- package/dist/modules/webhooks/index.js +5 -1
- package/dist/modules/webhooks/index.js.map +1 -1
- package/dist/modules/webhooks/payloads.d.ts +22 -7
- package/dist/modules/webhooks/payloads.d.ts.map +1 -1
- package/dist/modules/webhooks/payloads.js +63 -44
- package/dist/modules/webhooks/payloads.js.map +1 -1
- package/dist/modules/workspace/events.d.ts +52 -0
- package/dist/modules/workspace/events.d.ts.map +1 -0
- package/dist/modules/workspace/events.js +16 -0
- package/dist/modules/workspace/events.js.map +1 -0
- package/dist/modules/workspace/index.d.ts.map +1 -1
- package/dist/modules/workspace/index.js +6 -2
- package/dist/modules/workspace/index.js.map +1 -1
- package/dist/modules/workspace/service.d.ts +1 -0
- package/dist/modules/workspace/service.d.ts.map +1 -1
- package/dist/modules/workspace/service.js +13 -15
- package/dist/modules/workspace/service.js.map +1 -1
- package/dist/runtime/events.d.ts +86 -108
- package/dist/runtime/events.d.ts.map +1 -1
- package/dist/runtime/events.js +123 -52
- package/dist/runtime/events.js.map +1 -1
- package/dist/runtime/module.d.ts +54 -2
- package/dist/runtime/module.d.ts.map +1 -1
- package/dist/runtime/registry.d.ts +23 -0
- package/dist/runtime/registry.d.ts.map +1 -1
- package/dist/runtime/registry.js +102 -2
- package/dist/runtime/registry.js.map +1 -1
- package/dist/runtime/transaction.d.ts +29 -4
- package/dist/runtime/transaction.d.ts.map +1 -1
- package/dist/runtime/transaction.js +48 -7
- package/dist/runtime/transaction.js.map +1 -1
- package/dist/testing/app.d.ts +5 -1
- package/dist/testing/app.d.ts.map +1 -1
- package/dist/testing/app.js +13 -3
- package/dist/testing/app.js.map +1 -1
- package/dist/testing/database.d.ts.map +1 -1
- package/dist/testing/database.js +6 -3
- package/dist/testing/database.js.map +1 -1
- package/dist/testing/services.d.ts +21 -1
- package/dist/testing/services.d.ts.map +1 -1
- package/dist/testing/services.js +20 -5
- package/dist/testing/services.js.map +1 -1
- package/migrations/0019_sharp_red_skull.sql +4 -0
- package/migrations/0020_early_nemesis.sql +2 -0
- package/migrations/meta/0019_snapshot.json +5138 -0
- package/migrations/meta/0020_snapshot.json +5138 -0
- package/migrations/meta/_journal.json +14 -0
- package/package.json +5 -2
- package/src/app.ts +26 -0
- package/src/boot.ts +89 -0
- package/src/index.ts +52 -9
- package/src/lib/actor.ts +15 -1
- package/src/lib/config.ts +65 -7
- package/src/lib/email.ts +22 -92
- package/src/lib/fromEnv.ts +143 -0
- package/src/lib/ids.ts +6 -0
- package/src/lib/kelpieConfigFile.ts +291 -0
- package/src/lib/logger.ts +92 -34
- package/src/modules/agent-tasks/index.ts +4 -1
- package/src/modules/agent-tasks/prompt.ts +57 -9
- package/src/modules/agent-tasks/service.ts +3 -2
- package/src/modules/agent-tasks/wire.ts +12 -0
- package/src/modules/auth/index.ts +11 -9
- package/src/modules/companies/events.ts +25 -0
- package/src/modules/companies/index.ts +2 -0
- package/src/modules/companies/service.ts +8 -11
- package/src/modules/core.ts +4 -0
- package/src/modules/deals/events.ts +34 -0
- package/src/modules/deals/index.ts +2 -0
- package/src/modules/deals/service.ts +17 -18
- package/src/modules/decisions/events.ts +24 -0
- package/src/modules/decisions/index.ts +2 -0
- package/src/modules/decisions/service.ts +8 -7
- package/src/modules/eventCatalogs.ts +35 -0
- package/src/modules/forms/events.ts +37 -0
- package/src/modules/forms/index.ts +2 -0
- package/src/modules/forms/service.ts +12 -11
- package/src/modules/forms/submission.ts +80 -29
- package/src/modules/handbook/events.ts +31 -0
- package/src/modules/handbook/index.ts +2 -0
- package/src/modules/handbook/service.ts +8 -15
- package/src/modules/hiring/candidates.ts +8 -11
- package/src/modules/hiring/events.ts +36 -0
- package/src/modules/hiring/index.ts +2 -0
- package/src/modules/hiring/roles.ts +8 -11
- package/src/modules/import-export/drafts.ts +27 -0
- package/src/modules/import-export/events.ts +25 -0
- package/src/modules/import-export/exportRows.ts +10 -1
- package/src/modules/import-export/index.ts +2 -0
- package/src/modules/import-export/plan.ts +107 -5
- package/src/modules/import-export/presets.ts +25 -0
- package/src/modules/import-export/repository.ts +35 -1
- package/src/modules/import-export/routes.ts +5 -0
- package/src/modules/import-export/schema.ts +13 -0
- package/src/modules/import-export/service.ts +153 -19
- package/src/modules/import-export/tools.ts +9 -0
- package/src/modules/import-export/writes.ts +116 -3
- package/src/modules/notes/events.ts +25 -0
- package/src/modules/notes/index.ts +2 -0
- package/src/modules/notes/service.ts +8 -7
- package/src/modules/opportunities/events.ts +34 -0
- package/src/modules/opportunities/index.ts +2 -0
- package/src/modules/opportunities/service.ts +17 -18
- package/src/modules/partnerships/events.ts +34 -0
- package/src/modules/partnerships/index.ts +2 -0
- package/src/modules/partnerships/service.ts +17 -18
- package/src/modules/people/events.ts +36 -0
- package/src/modules/people/index.ts +2 -0
- package/src/modules/people/service.ts +97 -87
- package/src/modules/pipelines/service.ts +47 -8
- package/src/modules/plans/events.ts +24 -0
- package/src/modules/plans/index.ts +2 -0
- package/src/modules/plans/service.ts +14 -14
- package/src/modules/positions/events.ts +25 -0
- package/src/modules/positions/index.ts +2 -0
- package/src/modules/positions/service.ts +8 -11
- package/src/modules/raises/events.ts +34 -0
- package/src/modules/raises/index.ts +2 -0
- package/src/modules/raises/service.ts +17 -18
- package/src/modules/reseal.ts +144 -1
- package/src/modules/smtp-email/index.ts +119 -0
- package/src/modules/webhooks/index.ts +5 -1
- package/src/modules/webhooks/payloads.ts +94 -48
- package/src/modules/workspace/events.ts +46 -0
- package/src/modules/workspace/index.ts +6 -2
- package/src/modules/workspace/service.ts +37 -15
- package/src/runtime/events.ts +268 -107
- package/src/runtime/module.ts +55 -2
- package/src/runtime/registry.ts +169 -1
- package/src/runtime/transaction.ts +94 -17
- package/src/testing/app.ts +18 -4
- package/src/testing/database.ts +6 -3
- package/src/testing/services.ts +34 -5
|
@@ -10,8 +10,10 @@ import type { TransactionScope } from '../../runtime/transaction.ts'
|
|
|
10
10
|
import type { ActivityRecorder } from '../activities/recorder.ts'
|
|
11
11
|
import { describeCreation, describeUpdate } from '../activities/wording.ts'
|
|
12
12
|
import type { FieldLabels } from '../activities/wording.ts'
|
|
13
|
+
import { toEventActor } from '../../lib/actor.ts'
|
|
13
14
|
import type { Actor } from '../auth/actor.ts'
|
|
14
15
|
import { requireWorkspaceId } from '../auth/actor.ts'
|
|
16
|
+
import './events.ts'
|
|
15
17
|
import {
|
|
16
18
|
deleteRecordsAttachedTo,
|
|
17
19
|
deleteRecordsAttachedToCandidaciesOf,
|
|
@@ -160,45 +162,48 @@ export function createPeopleService(dependencies: PeopleDependencies): PeopleSer
|
|
|
160
162
|
const workspaceId = requireWorkspaceId(actor)
|
|
161
163
|
const id = dependencies.createId('person')
|
|
162
164
|
|
|
163
|
-
return dependencies.transaction(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
165
|
+
return dependencies.transaction(
|
|
166
|
+
async ({ tx, events }) => {
|
|
167
|
+
let created: PersonRecord
|
|
168
|
+
|
|
169
|
+
try {
|
|
170
|
+
created = await repository.insertPerson(tx, {
|
|
171
|
+
id,
|
|
172
|
+
workspaceId,
|
|
173
|
+
name: input.name,
|
|
174
|
+
email: input.email === null ? null : normaliseEmail(input.email),
|
|
175
|
+
phones: input.phones,
|
|
176
|
+
socialProfiles: input.socialProfiles,
|
|
177
|
+
timezone: input.timezone,
|
|
178
|
+
location: input.location,
|
|
179
|
+
preferredChannel: input.preferredChannel,
|
|
180
|
+
influence: input.influence,
|
|
181
|
+
relationship: input.relationship,
|
|
182
|
+
summary: input.summary,
|
|
183
|
+
tags: [...input.tags],
|
|
184
|
+
lastContactedAt: input.lastContactedAt,
|
|
185
|
+
})
|
|
186
|
+
} catch (error: unknown) {
|
|
187
|
+
if (postgresErrorCode(error) === UNIQUE_VIOLATION) {
|
|
188
|
+
throw duplicateEmail()
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
throw error
|
|
186
192
|
}
|
|
187
193
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
kind: 'created',
|
|
195
|
-
...describeCreation('Person'),
|
|
196
|
-
})
|
|
194
|
+
await dependencies.recordActivity(tx, workspaceId, actor, {
|
|
195
|
+
targetType: 'person',
|
|
196
|
+
targetId: created.id,
|
|
197
|
+
kind: 'created',
|
|
198
|
+
...describeCreation('Person'),
|
|
199
|
+
})
|
|
197
200
|
|
|
198
|
-
|
|
201
|
+
events.emit('people.person.created', { type: 'person', id: created.id }, {})
|
|
199
202
|
|
|
200
|
-
|
|
201
|
-
|
|
203
|
+
return toView(created)
|
|
204
|
+
},
|
|
205
|
+
{ workspaceId, actor: toEventActor(actor) },
|
|
206
|
+
)
|
|
202
207
|
},
|
|
203
208
|
|
|
204
209
|
async update(actor, id, changes) {
|
|
@@ -214,71 +219,76 @@ export function createPeopleService(dependencies: PeopleDependencies): PeopleSer
|
|
|
214
219
|
return toView(existing)
|
|
215
220
|
}
|
|
216
221
|
|
|
217
|
-
return dependencies.transaction(
|
|
218
|
-
|
|
222
|
+
return dependencies.transaction(
|
|
223
|
+
async ({ tx, events }) => {
|
|
224
|
+
let updated: PersonRecord | undefined
|
|
225
|
+
|
|
226
|
+
try {
|
|
227
|
+
updated = await repository.updatePerson(tx, workspaceId, id, {
|
|
228
|
+
...columns,
|
|
229
|
+
updatedAt: dependencies.now(),
|
|
230
|
+
})
|
|
231
|
+
} catch (error: unknown) {
|
|
232
|
+
if (postgresErrorCode(error) === UNIQUE_VIOLATION) {
|
|
233
|
+
throw duplicateEmail()
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
throw error
|
|
237
|
+
}
|
|
219
238
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
...columns,
|
|
223
|
-
updatedAt: dependencies.now(),
|
|
224
|
-
})
|
|
225
|
-
} catch (error: unknown) {
|
|
226
|
-
if (postgresErrorCode(error) === UNIQUE_VIOLATION) {
|
|
227
|
-
throw duplicateEmail()
|
|
239
|
+
if (updated === undefined) {
|
|
240
|
+
throw AppError.notFound('Person not found')
|
|
228
241
|
}
|
|
229
242
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
recordId: id,
|
|
248
|
-
changedFields: changed,
|
|
249
|
-
})
|
|
250
|
-
|
|
251
|
-
return toView(updated)
|
|
252
|
-
})
|
|
243
|
+
await dependencies.recordActivity(tx, workspaceId, actor, {
|
|
244
|
+
targetType: 'person',
|
|
245
|
+
targetId: id,
|
|
246
|
+
kind: 'updated',
|
|
247
|
+
...describeUpdate(changed, PERSON_FIELD_LABELS, existing, columns),
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
events.emit(
|
|
251
|
+
'people.person.updated',
|
|
252
|
+
{ type: 'person', id },
|
|
253
|
+
{ changed },
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
return toView(updated)
|
|
257
|
+
},
|
|
258
|
+
{ workspaceId, actor: toEventActor(actor) },
|
|
259
|
+
)
|
|
253
260
|
},
|
|
254
261
|
|
|
255
262
|
async remove(actor, id) {
|
|
256
263
|
const workspaceId = requireWorkspaceId(actor)
|
|
257
264
|
|
|
258
|
-
await dependencies.transaction(
|
|
259
|
-
|
|
265
|
+
await dependencies.transaction(
|
|
266
|
+
async ({ tx, events }) => {
|
|
267
|
+
await require(workspaceId, id)
|
|
260
268
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
269
|
+
// Notes, activities and decisions carry no foreign key to their target,
|
|
270
|
+
// so nothing in the database removes them. Same transaction: if the
|
|
271
|
+
// delete below is refused, these come back with it.
|
|
272
|
+
await deleteRecordsAttachedTo(tx, workspaceId, 'person', id)
|
|
265
273
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
274
|
+
// The candidacy rows themselves cascade, which is why their interview
|
|
275
|
+
// notes have to be taken here: no hiring service sees that delete.
|
|
276
|
+
await deleteRecordsAttachedToCandidaciesOf(tx, workspaceId, id)
|
|
269
277
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
278
|
+
try {
|
|
279
|
+
await repository.deletePerson(tx, workspaceId, id)
|
|
280
|
+
} catch (error: unknown) {
|
|
281
|
+
if (isReferenceViolation(error)) {
|
|
282
|
+
throw referencedElsewhere(error, 'person')
|
|
283
|
+
}
|
|
276
284
|
|
|
277
|
-
|
|
278
|
-
|
|
285
|
+
throw error
|
|
286
|
+
}
|
|
279
287
|
|
|
280
|
-
|
|
281
|
-
|
|
288
|
+
events.emit('people.person.deleted', { type: 'person', id }, {})
|
|
289
|
+
},
|
|
290
|
+
{ workspaceId, actor: toEventActor(actor) },
|
|
291
|
+
)
|
|
282
292
|
},
|
|
283
293
|
}
|
|
284
294
|
}
|
|
@@ -8,8 +8,15 @@ import type { ListQueryParameters, Page } from '../../lib/pagination.ts'
|
|
|
8
8
|
import type { Transaction, TransactionScope } from '../../runtime/transaction.ts'
|
|
9
9
|
import type { ActivityRecorder } from '../activities/recorder.ts'
|
|
10
10
|
import { describeStageChange } from '../activities/wording.ts'
|
|
11
|
+
import { toEventActor } from '../../lib/actor.ts'
|
|
11
12
|
import type { Actor } from '../auth/actor.ts'
|
|
12
13
|
import { requireWorkspaceId } from '../auth/actor.ts'
|
|
14
|
+
// The four owning modules register their `<kind>.<obj>.stage_changed` events;
|
|
15
|
+
// pipelines fires them from cascade reassignments.
|
|
16
|
+
import '../deals/events.ts'
|
|
17
|
+
import '../opportunities/events.ts'
|
|
18
|
+
import '../partnerships/events.ts'
|
|
19
|
+
import '../raises/events.ts'
|
|
13
20
|
import { referencedElsewhere } from '../references.ts'
|
|
14
21
|
import { reassignStagedRecords } from '../stagedRecords.ts'
|
|
15
22
|
import * as repository from './repository.ts'
|
|
@@ -310,13 +317,7 @@ export function createPipelineStagesService(
|
|
|
310
317
|
kind: 'stage_changed',
|
|
311
318
|
...describeStageChange(stage.label, moveTo.label),
|
|
312
319
|
})
|
|
313
|
-
events
|
|
314
|
-
workspaceId,
|
|
315
|
-
objectType: kind,
|
|
316
|
-
recordId,
|
|
317
|
-
fromStageId: stage.id,
|
|
318
|
-
toStageId: moveTo.id,
|
|
319
|
-
})
|
|
320
|
+
emitStageChangedFor(events, kind, recordId, stage.id, moveTo.id)
|
|
320
321
|
}
|
|
321
322
|
}
|
|
322
323
|
|
|
@@ -333,7 +334,45 @@ export function createPipelineStagesService(
|
|
|
333
334
|
}
|
|
334
335
|
|
|
335
336
|
await renumber(tx, workspaceId, rows.filter((row) => row.id !== id))
|
|
336
|
-
})
|
|
337
|
+
}, { workspaceId, actor: toEventActor(actor) })
|
|
337
338
|
},
|
|
338
339
|
}
|
|
339
340
|
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Dispatches the stage-changed envelope for a moved record. Each of the four
|
|
344
|
+
* staged object types has its own event name in its owning module's catalog;
|
|
345
|
+
* pipelines is the emitter, not the owner.
|
|
346
|
+
*/
|
|
347
|
+
function emitStageChangedFor(
|
|
348
|
+
events: import('../../runtime/transaction.ts').BufferedEvents,
|
|
349
|
+
kind: PipelineKind,
|
|
350
|
+
recordId: string,
|
|
351
|
+
fromStageId: string,
|
|
352
|
+
toStageId: string,
|
|
353
|
+
): void {
|
|
354
|
+
const data = { fromStageId, toStageId } as const
|
|
355
|
+
|
|
356
|
+
switch (kind) {
|
|
357
|
+
case 'deal':
|
|
358
|
+
events.emit('deals.deal.stage_changed', { type: 'deal', id: recordId }, data)
|
|
359
|
+
break
|
|
360
|
+
case 'opportunity':
|
|
361
|
+
events.emit(
|
|
362
|
+
'opportunities.opportunity.stage_changed',
|
|
363
|
+
{ type: 'opportunity', id: recordId },
|
|
364
|
+
data,
|
|
365
|
+
)
|
|
366
|
+
break
|
|
367
|
+
case 'partnership':
|
|
368
|
+
events.emit(
|
|
369
|
+
'partnerships.partnership.stage_changed',
|
|
370
|
+
{ type: 'partnership', id: recordId },
|
|
371
|
+
data,
|
|
372
|
+
)
|
|
373
|
+
break
|
|
374
|
+
case 'raise':
|
|
375
|
+
events.emit('raises.raise.stage_changed', { type: 'raise', id: recordId }, data)
|
|
376
|
+
break
|
|
377
|
+
}
|
|
378
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
import type { ModuleEventCatalog } from '../../runtime/module.ts'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Domain events published by the plans module.
|
|
7
|
+
*
|
|
8
|
+
* `target` is the record the plan item attaches to; the plan item's own id
|
|
9
|
+
* lives in `data`.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const plansEvents = {
|
|
13
|
+
'plans.plan_item.completed': z.object({ planItemId: z.string() }),
|
|
14
|
+
} satisfies ModuleEventCatalog
|
|
15
|
+
|
|
16
|
+
export interface PlanItemCompletedData {
|
|
17
|
+
readonly planItemId: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare module '../../runtime/events.ts' {
|
|
21
|
+
interface KelpieEventMap {
|
|
22
|
+
'plans.plan_item.completed': PlanItemCompletedData
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { KelpieModule } from '../../runtime/module.ts'
|
|
2
|
+
import { plansEvents } from './events.ts'
|
|
2
3
|
import { mountPlansRoutes } from './routes.ts'
|
|
3
4
|
import * as schema from './schema.ts'
|
|
4
5
|
import { createPlansService } from './service.ts'
|
|
@@ -16,6 +17,7 @@ export function createPlansModule(migrationsDirectory: string): KelpieModule {
|
|
|
16
17
|
id: 'plans',
|
|
17
18
|
requires: ['workspace'],
|
|
18
19
|
structural: true,
|
|
20
|
+
events: plansEvents,
|
|
19
21
|
|
|
20
22
|
register(context) {
|
|
21
23
|
const service = createPlansService({
|
|
@@ -5,8 +5,10 @@ import type { IdFactory } from '../../lib/ids.ts'
|
|
|
5
5
|
import { mapPage, readListWindow, toPage } from '../../lib/pagination.ts'
|
|
6
6
|
import type { ListQueryParameters, Page } from '../../lib/pagination.ts'
|
|
7
7
|
import type { TransactionScope } from '../../runtime/transaction.ts'
|
|
8
|
+
import { toEventActor } from '../../lib/actor.ts'
|
|
8
9
|
import type { Actor } from '../auth/actor.ts'
|
|
9
10
|
import { requireWorkspaceId } from '../auth/actor.ts'
|
|
11
|
+
import './events.ts'
|
|
10
12
|
import { targetExists } from '../recordTargets.ts'
|
|
11
13
|
import * as repository from './repository.ts'
|
|
12
14
|
import { DEFAULT_PLAN_ITEM_SORT, PLAN_ITEM_SORTS } from './repository.ts'
|
|
@@ -149,16 +151,15 @@ export function createPlansService(dependencies: PlansDependencies): PlansServic
|
|
|
149
151
|
// as already finished. A consumer watching for completed work cares that
|
|
150
152
|
// the work is done, not whether it passed through `todo` on the way.
|
|
151
153
|
if (created.status === 'done') {
|
|
152
|
-
events.emit(
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
})
|
|
154
|
+
events.emit(
|
|
155
|
+
'plans.plan_item.completed',
|
|
156
|
+
{ type: created.targetType, id: created.targetId },
|
|
157
|
+
{ planItemId: created.id },
|
|
158
|
+
)
|
|
158
159
|
}
|
|
159
160
|
|
|
160
161
|
return toView(created)
|
|
161
|
-
})
|
|
162
|
+
}, { workspaceId, actor: toEventActor(actor) })
|
|
162
163
|
},
|
|
163
164
|
|
|
164
165
|
async update(actor, id, changes) {
|
|
@@ -196,16 +197,15 @@ export function createPlansService(dependencies: PlansDependencies): PlansServic
|
|
|
196
197
|
// On the transition only. Re-sending `done` on a finished item changes
|
|
197
198
|
// nothing, and it is caught above before it reaches here.
|
|
198
199
|
if (changed.includes('status') && updated.status === 'done') {
|
|
199
|
-
events.emit(
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
})
|
|
200
|
+
events.emit(
|
|
201
|
+
'plans.plan_item.completed',
|
|
202
|
+
{ type: updated.targetType, id: updated.targetId },
|
|
203
|
+
{ planItemId: updated.id },
|
|
204
|
+
)
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
return toView(updated)
|
|
208
|
-
})
|
|
208
|
+
}, { workspaceId, actor: toEventActor(actor) })
|
|
209
209
|
},
|
|
210
210
|
|
|
211
211
|
async remove(actor, id) {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
import type { ModuleEventCatalog } from '../../runtime/module.ts'
|
|
4
|
+
|
|
5
|
+
/** Domain events published by the positions module. */
|
|
6
|
+
|
|
7
|
+
export const positionsEvents = {
|
|
8
|
+
'positions.position.created': z.object({}).strict(),
|
|
9
|
+
'positions.position.updated': z.object({ changed: z.array(z.string()).readonly() }),
|
|
10
|
+
'positions.position.deleted': z.object({}).strict(),
|
|
11
|
+
} satisfies ModuleEventCatalog
|
|
12
|
+
|
|
13
|
+
export type PositionCreatedData = Record<string, never>
|
|
14
|
+
export interface PositionUpdatedData {
|
|
15
|
+
readonly changed: readonly string[]
|
|
16
|
+
}
|
|
17
|
+
export type PositionDeletedData = Record<string, never>
|
|
18
|
+
|
|
19
|
+
declare module '../../runtime/events.ts' {
|
|
20
|
+
interface KelpieEventMap {
|
|
21
|
+
'positions.position.created': PositionCreatedData
|
|
22
|
+
'positions.position.updated': PositionUpdatedData
|
|
23
|
+
'positions.position.deleted': PositionDeletedData
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { KelpieModule } from '../../runtime/module.ts'
|
|
2
2
|
import { createActivityRecorder } from '../activities/index.ts'
|
|
3
|
+
import { positionsEvents } from './events.ts'
|
|
3
4
|
import { mountPositionsRoutes } from './routes.ts'
|
|
4
5
|
import * as schema from './schema.ts'
|
|
5
6
|
import { createPositionsService } from './service.ts'
|
|
@@ -15,6 +16,7 @@ export function createPositionsModule(migrationsDirectory: string): KelpieModule
|
|
|
15
16
|
return {
|
|
16
17
|
id: 'positions',
|
|
17
18
|
requires: ['people', 'companies', 'activities'],
|
|
19
|
+
events: positionsEvents,
|
|
18
20
|
|
|
19
21
|
register(context) {
|
|
20
22
|
const service = createPositionsService({
|
|
@@ -7,8 +7,10 @@ import type { ListQueryParameters, Page } from '../../lib/pagination.ts'
|
|
|
7
7
|
import type { TransactionScope } from '../../runtime/transaction.ts'
|
|
8
8
|
import type { ActivityRecorder } from '../activities/recorder.ts'
|
|
9
9
|
import { describeLink, describeUnlink } from '../activities/wording.ts'
|
|
10
|
+
import { toEventActor } from '../../lib/actor.ts'
|
|
10
11
|
import type { Actor } from '../auth/actor.ts'
|
|
11
12
|
import { requireWorkspaceId } from '../auth/actor.ts'
|
|
13
|
+
import './events.ts'
|
|
12
14
|
import * as companyRepository from '../companies/repository.ts'
|
|
13
15
|
import * as personRepository from '../people/repository.ts'
|
|
14
16
|
import * as repository from './repository.ts'
|
|
@@ -174,10 +176,10 @@ export function createPositionsService(dependencies: PositionsDependencies): Pos
|
|
|
174
176
|
...describeLink('person', ends.personName),
|
|
175
177
|
})
|
|
176
178
|
|
|
177
|
-
events.emit('
|
|
179
|
+
events.emit('positions.position.created', { type: 'position', id: created.id }, {})
|
|
178
180
|
|
|
179
181
|
return toView(created)
|
|
180
|
-
})
|
|
182
|
+
}, { workspaceId, actor: toEventActor(actor) })
|
|
181
183
|
},
|
|
182
184
|
|
|
183
185
|
async update(actor, id, changes) {
|
|
@@ -210,15 +212,10 @@ export function createPositionsService(dependencies: PositionsDependencies): Pos
|
|
|
210
212
|
throw AppError.notFound('Position not found')
|
|
211
213
|
}
|
|
212
214
|
|
|
213
|
-
events.emit('
|
|
214
|
-
workspaceId,
|
|
215
|
-
objectType: 'position',
|
|
216
|
-
recordId: id,
|
|
217
|
-
changedFields: ['title'],
|
|
218
|
-
})
|
|
215
|
+
events.emit('positions.position.updated', { type: 'position', id }, { changed: ['title'] })
|
|
219
216
|
|
|
220
217
|
return toView(updated)
|
|
221
|
-
})
|
|
218
|
+
}, { workspaceId, actor: toEventActor(actor) })
|
|
222
219
|
},
|
|
223
220
|
|
|
224
221
|
async remove(actor, id) {
|
|
@@ -246,8 +243,8 @@ export function createPositionsService(dependencies: PositionsDependencies): Pos
|
|
|
246
243
|
...describeUnlink('person', ends.personName),
|
|
247
244
|
})
|
|
248
245
|
|
|
249
|
-
events.emit('
|
|
250
|
-
})
|
|
246
|
+
events.emit('positions.position.deleted', { type: 'position', id }, {})
|
|
247
|
+
}, { workspaceId, actor: toEventActor(actor) })
|
|
251
248
|
},
|
|
252
249
|
}
|
|
253
250
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
import type { ModuleEventCatalog } from '../../runtime/module.ts'
|
|
4
|
+
|
|
5
|
+
/** Domain events published by the raises module. */
|
|
6
|
+
|
|
7
|
+
export const raisesEvents = {
|
|
8
|
+
'raises.raise.created': z.object({}).strict(),
|
|
9
|
+
'raises.raise.updated': z.object({ changed: z.array(z.string()).readonly() }),
|
|
10
|
+
'raises.raise.deleted': z.object({}).strict(),
|
|
11
|
+
'raises.raise.stage_changed': z.object({
|
|
12
|
+
fromStageId: z.string().nullable(),
|
|
13
|
+
toStageId: z.string(),
|
|
14
|
+
}),
|
|
15
|
+
} satisfies ModuleEventCatalog
|
|
16
|
+
|
|
17
|
+
export type RaiseCreatedData = Record<string, never>
|
|
18
|
+
export interface RaiseUpdatedData {
|
|
19
|
+
readonly changed: readonly string[]
|
|
20
|
+
}
|
|
21
|
+
export type RaiseDeletedData = Record<string, never>
|
|
22
|
+
export interface RaiseStageChangedData {
|
|
23
|
+
readonly fromStageId: string | null
|
|
24
|
+
readonly toStageId: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare module '../../runtime/events.ts' {
|
|
28
|
+
interface KelpieEventMap {
|
|
29
|
+
'raises.raise.created': RaiseCreatedData
|
|
30
|
+
'raises.raise.updated': RaiseUpdatedData
|
|
31
|
+
'raises.raise.deleted': RaiseDeletedData
|
|
32
|
+
'raises.raise.stage_changed': RaiseStageChangedData
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { KelpieModule } from '../../runtime/module.ts'
|
|
2
2
|
import { createActivityRecorder } from '../activities/index.ts'
|
|
3
|
+
import { raisesEvents } from './events.ts'
|
|
3
4
|
import { mountRaisesRoutes } from './routes.ts'
|
|
4
5
|
import * as schema from './schema.ts'
|
|
5
6
|
import { createRaisesService } from './service.ts'
|
|
@@ -17,6 +18,7 @@ export function createRaisesModule(migrationsDirectory: string): KelpieModule {
|
|
|
17
18
|
return {
|
|
18
19
|
id: 'raises',
|
|
19
20
|
requires: ['companies', 'people', 'pipelines', 'activities'],
|
|
21
|
+
events: raisesEvents,
|
|
20
22
|
|
|
21
23
|
register(context) {
|
|
22
24
|
const service = createRaisesService({
|
|
@@ -14,8 +14,10 @@ import {
|
|
|
14
14
|
describeUpdate,
|
|
15
15
|
} from '../activities/wording.ts'
|
|
16
16
|
import type { FieldLabels } from '../activities/wording.ts'
|
|
17
|
+
import { toEventActor } from '../../lib/actor.ts'
|
|
17
18
|
import type { Actor } from '../auth/actor.ts'
|
|
18
19
|
import { actorMemberId, requireWorkspaceId } from '../auth/actor.ts'
|
|
20
|
+
import './events.ts'
|
|
19
21
|
import { deleteRecordsAttachedTo } from '../attachedRecords.ts'
|
|
20
22
|
import * as companyRepository from '../companies/repository.ts'
|
|
21
23
|
import * as pipelineRepository from '../pipelines/repository.ts'
|
|
@@ -301,10 +303,10 @@ export function createRaisesService(dependencies: RaisesDependencies): RaisesSer
|
|
|
301
303
|
})
|
|
302
304
|
}
|
|
303
305
|
|
|
304
|
-
events.emit('
|
|
306
|
+
events.emit('raises.raise.created', { type: 'raise', id }, {})
|
|
305
307
|
|
|
306
308
|
return toView(created, personIds)
|
|
307
|
-
})
|
|
309
|
+
}, { workspaceId, actor: toEventActor(actor) })
|
|
308
310
|
},
|
|
309
311
|
|
|
310
312
|
async update(actor, id, changes) {
|
|
@@ -402,25 +404,22 @@ export function createRaisesService(dependencies: RaisesDependencies): RaisesSer
|
|
|
402
404
|
})
|
|
403
405
|
}
|
|
404
406
|
|
|
405
|
-
events.emit(
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
})
|
|
407
|
+
events.emit(
|
|
408
|
+
'raises.raise.updated',
|
|
409
|
+
{ type: 'raise', id },
|
|
410
|
+
{ changed: linksChanged ? [...changed, 'personIds'] : changed },
|
|
411
|
+
)
|
|
411
412
|
|
|
412
413
|
if (stageMove !== undefined) {
|
|
413
|
-
events.emit(
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
toStageId: stageMove.to.id,
|
|
419
|
-
})
|
|
414
|
+
events.emit(
|
|
415
|
+
'raises.raise.stage_changed',
|
|
416
|
+
{ type: 'raise', id },
|
|
417
|
+
{ fromStageId: stageMove.from.id, toStageId: stageMove.to.id },
|
|
418
|
+
)
|
|
420
419
|
}
|
|
421
420
|
|
|
422
421
|
return toView(updated, nextPeople ?? currentPeople)
|
|
423
|
-
})
|
|
422
|
+
}, { workspaceId, actor: toEventActor(actor) })
|
|
424
423
|
},
|
|
425
424
|
|
|
426
425
|
async remove(actor, id) {
|
|
@@ -435,8 +434,8 @@ export function createRaisesService(dependencies: RaisesDependencies): RaisesSer
|
|
|
435
434
|
await deleteRecordsAttachedTo(tx, workspaceId, 'raise', id)
|
|
436
435
|
await repository.deleteRaise(tx, workspaceId, id)
|
|
437
436
|
|
|
438
|
-
events.emit('
|
|
439
|
-
})
|
|
437
|
+
events.emit('raises.raise.deleted', { type: 'raise', id }, {})
|
|
438
|
+
}, { workspaceId, actor: toEventActor(actor) })
|
|
440
439
|
},
|
|
441
440
|
}
|
|
442
441
|
}
|