@elevasis/core 0.12.0 → 0.13.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.
@@ -0,0 +1,90 @@
1
+ import type { AcqDealRow } from './types'
2
+
3
+ export interface Action {
4
+ key: string
5
+ label: string
6
+ kind: 'transition' | 'edit' | 'modal'
7
+ payload?: Record<string, unknown>
8
+ }
9
+
10
+ // Stage order inlined from DEFAULT_ORGANIZATION_MODEL_SALES (single caller).
11
+ // Update here if the default pipeline changes.
12
+ const STAGE_ORDER = ['interested', 'proposal', 'closing', 'closed_won', 'closed_lost', 'nurturing'] as const
13
+
14
+ type DefaultStageKey = (typeof STAGE_ORDER)[number]
15
+
16
+ function isDefaultStage(key: string | null | undefined): key is DefaultStageKey {
17
+ return STAGE_ORDER.includes(key as DefaultStageKey)
18
+ }
19
+
20
+ function transitionAction(stageKey: DefaultStageKey): Action {
21
+ const labels: Record<DefaultStageKey, string> = {
22
+ interested: 'Move to Interested',
23
+ proposal: 'Move to Proposal',
24
+ closing: 'Move to Closing',
25
+ closed_won: 'Close Won',
26
+ closed_lost: 'Close Lost',
27
+ nurturing: 'Move to Nurturing'
28
+ }
29
+ return {
30
+ key: `move_to_${stageKey}`,
31
+ label: labels[stageKey],
32
+ kind: 'transition',
33
+ payload: { stageKey }
34
+ }
35
+ }
36
+
37
+ function interestedActions(stateKey: string | null | undefined): Action[] {
38
+ const base: Action[] = [transitionAction('proposal'), transitionAction('closed_lost'), transitionAction('nurturing')]
39
+
40
+ if (stateKey === 'discovery_replied') {
41
+ return [...base, { key: 'send_link', label: 'Send Booking Link', kind: 'modal' }]
42
+ }
43
+
44
+ if (stateKey === 'discovery_link_sent') {
45
+ return [...base, { key: 'send_nudge', label: 'Send Nudge', kind: 'modal' }]
46
+ }
47
+
48
+ if (stateKey === 'discovery_nudging') {
49
+ return [
50
+ ...base,
51
+ { key: 'send_nudge', label: 'Send Nudge', kind: 'modal' },
52
+ { key: 'mark_no_show', label: 'Mark No-Show', kind: 'transition' }
53
+ ]
54
+ }
55
+
56
+ if (stateKey === 'discovery_booking_cancelled') {
57
+ return [...base, { key: 'rebook', label: 'Rebook', kind: 'modal' }]
58
+ }
59
+
60
+ return base
61
+ }
62
+
63
+ function proposalActions(): Action[] {
64
+ return [transitionAction('closing'), transitionAction('closed_lost'), transitionAction('nurturing')]
65
+ }
66
+
67
+ function closingActions(): Action[] {
68
+ return [transitionAction('closed_won'), transitionAction('closed_lost'), transitionAction('nurturing')]
69
+ }
70
+
71
+ export function deriveActions(deal: AcqDealRow): Action[] {
72
+ const stage = deal.stage_key
73
+
74
+ if (!isDefaultStage(stage)) {
75
+ return []
76
+ }
77
+
78
+ switch (stage) {
79
+ case 'interested':
80
+ return interestedActions(deal.state_key)
81
+ case 'proposal':
82
+ return proposalActions()
83
+ case 'closing':
84
+ return closingActions()
85
+ case 'closed_won':
86
+ case 'closed_lost':
87
+ case 'nurturing':
88
+ return []
89
+ }
90
+ }
@@ -1,109 +1,111 @@
1
- export * from './types'
2
- // Export api-schemas selectively to avoid re-exporting names already defined in types.ts
3
- // (DealStage, AcqDealTaskKind are declared as union types there; api-schemas re-infers them from Zod)
4
- export {
5
- AcqCompanyStatusSchema,
6
- AcqContactStatusSchema,
7
- AcqEmailValidSchema,
8
- CompanyIdParamsSchema,
9
- ContactIdParamsSchema,
10
- ListCompaniesQuerySchema,
11
- ListContactsQuerySchema,
12
- CreateCompanyRequestSchema,
13
- UpdateCompanyRequestSchema,
14
- CreateContactRequestSchema,
15
- UpdateContactRequestSchema,
16
- AcqCompanyResponseSchema,
17
- AcqCompanyListResponseSchema,
18
- AcqContactResponseSchema,
19
- AcqContactListResponseSchema,
20
- AcqCompanySchemas,
21
- AcqContactSchemas,
22
- DealStageSchema,
23
- AcqDealTaskKindSchema,
24
- DealIdParamsSchema,
25
- DealTaskIdParamsSchema,
26
- ListDealsQuerySchema,
27
- ListDealTasksDueQuerySchema,
28
- CreateDealNoteRequestSchema,
29
- CreateDealTaskRequestSchema,
30
- SyncDealStageRequestSchema,
31
- DealContactSummarySchema,
32
- DealListItemSchema,
33
- DealListResponseSchema,
34
- DealDetailResponseSchema,
35
- DealNoteResponseSchema,
36
- DealNoteListResponseSchema,
37
- DealTaskResponseSchema,
38
- DealTaskListResponseSchema,
39
- DealSchemas,
40
- ListQualificationSchema,
41
- ListEnrichmentSchema,
42
- ListPersonalizationSchema,
43
- PipelineStepSchema,
44
- ListPipelineSchema,
45
- ListConfigSchema,
46
- ListStageCountsSchema,
47
- ListTelemetrySchema,
48
- ListIdParamsSchema,
49
- CreateListRequestSchema,
50
- UpdateListRequestSchema,
51
- UpdateListConfigRequestSchema,
52
- AddCompaniesToListRequestSchema,
53
- RemoveCompaniesFromListRequestSchema,
54
- AddContactsToListRequestSchema,
55
- RecordListExecutionRequestSchema,
56
- AcqListResponseSchema,
57
- AcqListListResponseSchema,
58
- ListTelemetryResponseSchema,
59
- ListTelemetryListResponseSchema,
60
- ListExecutionSummarySchema,
61
- ListExecutionsResponseSchema,
62
- AcqListSchemas,
63
- type CompanyIdParams,
64
- type ContactIdParams,
65
- type ListCompaniesQuery,
66
- type ListContactsQuery,
67
- type CreateCompanyRequest,
68
- type UpdateCompanyRequest,
69
- type CreateContactRequest,
70
- type UpdateContactRequest,
71
- type AcqCompanyResponse,
72
- type AcqCompanyListResponse,
73
- type AcqContactResponse,
74
- type AcqContactListResponse,
75
- type AcqCompanyStatus,
76
- type AcqContactStatus,
77
- type AcqEmailValid,
78
- type DealIdParams,
79
- type DealTaskIdParams,
80
- type ListDealsQuery,
81
- type ListDealTasksDueQuery,
82
- type CreateDealNoteRequest,
83
- type CreateDealTaskRequest,
84
- type SyncDealStageRequest,
85
- type DealListResponse,
86
- type DealDetailResponse,
87
- type DealNoteResponse,
88
- type DealNoteListResponse,
89
- type DealTaskResponse,
90
- type DealTaskListResponse,
91
- type ListConfigInput,
92
- type ListStageCountsInput,
93
- type ListTelemetryInput,
94
- type PipelineStepInput,
95
- type ListIdParams,
96
- type CreateListRequest,
97
- type UpdateListRequest,
98
- type UpdateListConfigRequest,
99
- type AddCompaniesToListRequest,
100
- type RemoveCompaniesFromListRequest,
101
- type AddContactsToListRequest,
102
- type RecordListExecutionRequest,
103
- type AcqListResponse,
104
- type AcqListListResponse,
105
- type ListTelemetryResponse,
106
- type ListTelemetryListResponse,
107
- type ListExecutionSummaryInput,
108
- type ListExecutionsResponse
109
- } from './api-schemas'
1
+ export * from './types'
2
+ export * from './activity-events'
3
+ export * from './derive-actions'
4
+ // Export api-schemas selectively to avoid re-exporting names already defined in types.ts
5
+ // (DealStage, AcqDealTaskKind are declared as union types there; api-schemas re-infers them from Zod)
6
+ export {
7
+ AcqCompanyStatusSchema,
8
+ AcqContactStatusSchema,
9
+ AcqEmailValidSchema,
10
+ CompanyIdParamsSchema,
11
+ ContactIdParamsSchema,
12
+ ListCompaniesQuerySchema,
13
+ ListContactsQuerySchema,
14
+ CreateCompanyRequestSchema,
15
+ UpdateCompanyRequestSchema,
16
+ CreateContactRequestSchema,
17
+ UpdateContactRequestSchema,
18
+ AcqCompanyResponseSchema,
19
+ AcqCompanyListResponseSchema,
20
+ AcqContactResponseSchema,
21
+ AcqContactListResponseSchema,
22
+ AcqCompanySchemas,
23
+ AcqContactSchemas,
24
+ DealStageSchema,
25
+ AcqDealTaskKindSchema,
26
+ DealIdParamsSchema,
27
+ DealTaskIdParamsSchema,
28
+ ListDealsQuerySchema,
29
+ ListDealTasksDueQuerySchema,
30
+ CreateDealNoteRequestSchema,
31
+ CreateDealTaskRequestSchema,
32
+ TransitionItemRequestSchema,
33
+ DealContactSummarySchema,
34
+ DealListItemSchema,
35
+ DealListResponseSchema,
36
+ DealDetailResponseSchema,
37
+ DealNoteResponseSchema,
38
+ DealNoteListResponseSchema,
39
+ DealTaskResponseSchema,
40
+ DealTaskListResponseSchema,
41
+ DealSchemas,
42
+ ListQualificationSchema,
43
+ ListEnrichmentSchema,
44
+ ListPersonalizationSchema,
45
+ PipelineStepSchema,
46
+ ListPipelineSchema,
47
+ ListConfigSchema,
48
+ ListStageCountsSchema,
49
+ ListTelemetrySchema,
50
+ ListIdParamsSchema,
51
+ CreateListRequestSchema,
52
+ UpdateListRequestSchema,
53
+ UpdateListConfigRequestSchema,
54
+ AddCompaniesToListRequestSchema,
55
+ RemoveCompaniesFromListRequestSchema,
56
+ AddContactsToListRequestSchema,
57
+ RecordListExecutionRequestSchema,
58
+ AcqListResponseSchema,
59
+ AcqListListResponseSchema,
60
+ ListTelemetryResponseSchema,
61
+ ListTelemetryListResponseSchema,
62
+ ListExecutionSummarySchema,
63
+ ListExecutionsResponseSchema,
64
+ AcqListSchemas,
65
+ type CompanyIdParams,
66
+ type ContactIdParams,
67
+ type ListCompaniesQuery,
68
+ type ListContactsQuery,
69
+ type CreateCompanyRequest,
70
+ type UpdateCompanyRequest,
71
+ type CreateContactRequest,
72
+ type UpdateContactRequest,
73
+ type AcqCompanyResponse,
74
+ type AcqCompanyListResponse,
75
+ type AcqContactResponse,
76
+ type AcqContactListResponse,
77
+ type AcqCompanyStatus,
78
+ type AcqContactStatus,
79
+ type AcqEmailValid,
80
+ type DealIdParams,
81
+ type DealTaskIdParams,
82
+ type ListDealsQuery,
83
+ type ListDealTasksDueQuery,
84
+ type CreateDealNoteRequest,
85
+ type CreateDealTaskRequest,
86
+ type TransitionItemRequest,
87
+ type DealListResponse,
88
+ type DealDetailResponse,
89
+ type DealNoteResponse,
90
+ type DealNoteListResponse,
91
+ type DealTaskResponse,
92
+ type DealTaskListResponse,
93
+ type ListConfigInput,
94
+ type ListStageCountsInput,
95
+ type ListTelemetryInput,
96
+ type PipelineStepInput,
97
+ type ListIdParams,
98
+ type CreateListRequest,
99
+ type UpdateListRequest,
100
+ type UpdateListConfigRequest,
101
+ type AddCompaniesToListRequest,
102
+ type RemoveCompaniesFromListRequest,
103
+ type AddContactsToListRequest,
104
+ type RecordListExecutionRequest,
105
+ type AcqListResponse,
106
+ type AcqListListResponse,
107
+ type ListTelemetryResponse,
108
+ type ListTelemetryListResponse,
109
+ type ListExecutionSummaryInput,
110
+ type ListExecutionsResponse
111
+ } from './api-schemas'