@elevasis/core 0.13.0 → 0.15.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/index.d.ts +1 -1
- package/dist/index.js +9 -2
- package/dist/organization-model/index.d.ts +1 -1
- package/dist/organization-model/index.js +9 -2
- package/dist/test-utils/index.d.ts +463 -377
- package/dist/test-utils/index.js +9 -2
- package/package.json +1 -1
- package/src/_gen/__tests__/__snapshots__/contracts.md.snap +2336 -0
- package/src/business/acquisition/activity-events.test.ts +250 -0
- package/src/business/acquisition/activity-events.ts +7 -65
- package/src/business/acquisition/api-schemas.test.ts +1180 -0
- package/src/business/acquisition/api-schemas.ts +317 -73
- package/src/business/acquisition/crm-state-actions.test.ts +160 -0
- package/src/business/acquisition/derive-actions.test.ts +518 -0
- package/src/business/acquisition/derive-actions.ts +101 -78
- package/src/business/acquisition/index.ts +51 -9
- package/src/business/acquisition/stateful.ts +30 -0
- package/src/business/acquisition/types.ts +48 -80
- package/src/execution/engine/index.ts +437 -434
- package/src/execution/engine/tools/integration/server/adapters/attio/__tests__/attio-crud.integration.test.ts +363 -360
- package/src/execution/engine/tools/integration/server/adapters/attio/fetch/get-record/index.test.ts +162 -186
- package/src/execution/engine/tools/integration/server/adapters/attio/fetch/list-records/index.test.ts +316 -338
- package/src/execution/engine/tools/integration/server/adapters/gmail/gmail-adapter.ts +204 -210
- package/src/execution/engine/tools/integration/server/adapters/resend/fetch/send-email/index.test.ts +88 -0
- package/src/execution/engine/tools/integration/server/adapters/resend/fetch/send-email/index.ts +141 -134
- package/src/execution/engine/tools/integration/server/adapters/resend/fetch/utils/types.ts +76 -75
- package/src/execution/engine/tools/integration/service.test.ts +34 -9
- package/src/execution/engine/tools/integration/service.ts +6 -3
- package/src/execution/engine/tools/lead-service-types.ts +934 -874
- package/src/execution/engine/tools/platform/acquisition/types.ts +266 -260
- package/src/execution/engine/tools/registry.ts +701 -699
- package/src/execution/engine/tools/tool-maps.ts +30 -2
- package/src/execution/engine/workflow/types.ts +11 -0
- package/src/organization-model/contracts.ts +4 -4
- package/src/organization-model/domains/navigation.ts +62 -62
- package/src/organization-model/domains/sales.test.ts +189 -0
- package/src/organization-model/domains/sales.ts +456 -94
- package/src/organization-model/published.ts +21 -21
- package/src/organization-model/resolve.ts +21 -8
- package/src/platform/constants/versions.ts +1 -1
- package/src/reference/_generated/contracts.md +2336 -0
- package/src/supabase/database.types.ts +2958 -2886
|
@@ -231,6 +231,8 @@ import type {
|
|
|
231
231
|
RecordDealActivityParams,
|
|
232
232
|
AddContactsToListParams,
|
|
233
233
|
AddContactsToListResult,
|
|
234
|
+
AddCompaniesToListParams,
|
|
235
|
+
AddCompaniesToListResult,
|
|
234
236
|
BulkImportParams,
|
|
235
237
|
BulkImportResult,
|
|
236
238
|
BulkImportCompaniesParams,
|
|
@@ -249,7 +251,9 @@ import type {
|
|
|
249
251
|
DeleteDealParams,
|
|
250
252
|
DealFilters,
|
|
251
253
|
DealPipelineAnalytics,
|
|
252
|
-
|
|
254
|
+
ScrapingConfig,
|
|
255
|
+
IcpRubric,
|
|
256
|
+
PipelineConfig,
|
|
253
257
|
RecordListExecutionParams,
|
|
254
258
|
UpdateCompanyStageParams,
|
|
255
259
|
UpdateContactStageParams,
|
|
@@ -573,6 +577,7 @@ export type LeadToolMap = {
|
|
|
573
577
|
updateList: { params: { id: string } & UpdateListParams; result: AcqList }
|
|
574
578
|
deleteList: { params: { id: string }; result: void }
|
|
575
579
|
addContactsToList: { params: Omit<AddContactsToListParams, 'organizationId'>; result: AddContactsToListResult }
|
|
580
|
+
addCompaniesToList: { params: Omit<AddCompaniesToListParams, 'organizationId'>; result: AddCompaniesToListResult }
|
|
576
581
|
updateCompanyStage: {
|
|
577
582
|
params: Omit<UpdateCompanyStageParams, 'organizationId'>
|
|
578
583
|
result: void
|
|
@@ -675,6 +680,26 @@ export type LeadToolMap = {
|
|
|
675
680
|
params: { posts: Omit<UpsertSocialPostParams, 'organizationId'>[] }
|
|
676
681
|
result: UpsertSocialPostsResult
|
|
677
682
|
}
|
|
683
|
+
setDealStateKey: {
|
|
684
|
+
params: {
|
|
685
|
+
dealId: string
|
|
686
|
+
stateKey: string
|
|
687
|
+
}
|
|
688
|
+
result: { ok: true }
|
|
689
|
+
}
|
|
690
|
+
// CRM workflow helpers
|
|
691
|
+
transitionDeal: {
|
|
692
|
+
params: {
|
|
693
|
+
dealId: string
|
|
694
|
+
toStage: string
|
|
695
|
+
toState?: string
|
|
696
|
+
}
|
|
697
|
+
result: { deal: AcqDeal }
|
|
698
|
+
}
|
|
699
|
+
loadDeal: {
|
|
700
|
+
params: { dealId: string }
|
|
701
|
+
result: DealDetail | null
|
|
702
|
+
}
|
|
678
703
|
}
|
|
679
704
|
|
|
680
705
|
// ---------------------------------------------------------------------------
|
|
@@ -682,7 +707,10 @@ export type LeadToolMap = {
|
|
|
682
707
|
// ---------------------------------------------------------------------------
|
|
683
708
|
|
|
684
709
|
export type ListToolMap = {
|
|
685
|
-
getConfig: {
|
|
710
|
+
getConfig: {
|
|
711
|
+
params: { listId: string }
|
|
712
|
+
result: { scrapingConfig: ScrapingConfig; icp: IcpRubric; pipelineConfig: PipelineConfig }
|
|
713
|
+
}
|
|
686
714
|
recordExecution: {
|
|
687
715
|
params: Omit<RecordListExecutionParams, 'organizationId'>
|
|
688
716
|
result: void
|
|
@@ -82,6 +82,17 @@ export interface WorkflowDefinition {
|
|
|
82
82
|
* If provided, workflow appears in Execution Runner UI
|
|
83
83
|
*/
|
|
84
84
|
interface?: ExecutionInterface
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Lead-gen processing stage this workflow implements (optional).
|
|
88
|
+
* Must match a key in the platform lead-gen stage catalog.
|
|
89
|
+
* Used by org-os graph derivation to surface workflow→stage edges and
|
|
90
|
+
* by pipeline_config validation to confirm each catalog stage has an
|
|
91
|
+
* implementing workflow before a list is activated.
|
|
92
|
+
*
|
|
93
|
+
* Example: stageImplemented: 'verified' on the email-verification workflow.
|
|
94
|
+
*/
|
|
95
|
+
stageImplemented?: string
|
|
85
96
|
}
|
|
86
97
|
|
|
87
98
|
/**
|
|
@@ -9,7 +9,7 @@ export const MONITORING_FEATURE_ID = 'monitoring' as const
|
|
|
9
9
|
export const SETTINGS_FEATURE_ID = 'settings' as const
|
|
10
10
|
export const SEO_FEATURE_ID = 'seo' as const
|
|
11
11
|
|
|
12
|
-
export const SALES_PIPELINE_SURFACE_ID = 'crm.pipeline' as const
|
|
13
|
-
export const PROSPECTING_LISTS_SURFACE_ID = 'lead-gen.lists' as const
|
|
14
|
-
export const OPERATIONS_COMMAND_VIEW_SURFACE_ID = 'operations.command-view' as const
|
|
15
|
-
export const SETTINGS_ROLES_SURFACE_ID = 'settings.roles' as const
|
|
12
|
+
export const SALES_PIPELINE_SURFACE_ID = 'crm.pipeline' as const
|
|
13
|
+
export const PROSPECTING_LISTS_SURFACE_ID = 'lead-gen.lists' as const
|
|
14
|
+
export const OPERATIONS_COMMAND_VIEW_SURFACE_ID = 'operations.command-view' as const
|
|
15
|
+
export const SETTINGS_ROLES_SURFACE_ID = 'settings.roles' as const
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod'
|
|
2
|
-
import {
|
|
3
|
-
OPERATIONS_COMMAND_VIEW_SURFACE_ID,
|
|
4
|
-
PROJECTS_VIEW_CAPABILITY_ID,
|
|
5
|
-
PROJECTS_FEATURE_ID,
|
|
6
|
-
PROJECTS_INDEX_SURFACE_ID,
|
|
7
|
-
SETTINGS_ROLES_SURFACE_ID
|
|
8
|
-
} from '../contracts'
|
|
2
|
+
import {
|
|
3
|
+
OPERATIONS_COMMAND_VIEW_SURFACE_ID,
|
|
4
|
+
PROJECTS_VIEW_CAPABILITY_ID,
|
|
5
|
+
PROJECTS_FEATURE_ID,
|
|
6
|
+
PROJECTS_INDEX_SURFACE_ID,
|
|
7
|
+
SETTINGS_ROLES_SURFACE_ID
|
|
8
|
+
} from '../contracts'
|
|
9
9
|
import { DescriptionSchema, IconNameSchema, LabelSchema, ModelIdSchema, PathSchema, ReferenceIdsSchema } from './shared'
|
|
10
10
|
|
|
11
11
|
export const SurfaceTypeSchema = z.enum(['page', 'dashboard', 'graph', 'detail', 'list', 'settings'])
|
|
@@ -15,10 +15,10 @@ export const SurfaceDefinitionSchema = z.object({
|
|
|
15
15
|
label: LabelSchema,
|
|
16
16
|
path: PathSchema,
|
|
17
17
|
surfaceType: SurfaceTypeSchema,
|
|
18
|
-
description: DescriptionSchema.optional(),
|
|
19
|
-
enabled: z.boolean().default(true),
|
|
20
|
-
devOnly: z.boolean().optional(),
|
|
21
|
-
icon: IconNameSchema.optional(),
|
|
18
|
+
description: DescriptionSchema.optional(),
|
|
19
|
+
enabled: z.boolean().default(true),
|
|
20
|
+
devOnly: z.boolean().optional(),
|
|
21
|
+
icon: IconNameSchema.optional(),
|
|
22
22
|
featureId: ModelIdSchema.optional(),
|
|
23
23
|
featureIds: ReferenceIdsSchema,
|
|
24
24
|
entityIds: ReferenceIdsSchema,
|
|
@@ -92,16 +92,16 @@ export const DEFAULT_ORGANIZATION_MODEL_NAVIGATION: z.infer<typeof OrganizationM
|
|
|
92
92
|
resourceIds: [],
|
|
93
93
|
capabilityIds: [PROJECTS_VIEW_CAPABILITY_ID]
|
|
94
94
|
},
|
|
95
|
-
{
|
|
96
|
-
id: OPERATIONS_COMMAND_VIEW_SURFACE_ID,
|
|
97
|
-
label: 'Command View',
|
|
98
|
-
path: '/operations/command-view',
|
|
99
|
-
surfaceType: 'graph',
|
|
100
|
-
enabled: true,
|
|
101
|
-
devOnly: true,
|
|
102
|
-
featureId: 'operations',
|
|
103
|
-
featureIds: ['operations'],
|
|
104
|
-
entityIds: [],
|
|
95
|
+
{
|
|
96
|
+
id: OPERATIONS_COMMAND_VIEW_SURFACE_ID,
|
|
97
|
+
label: 'Command View',
|
|
98
|
+
path: '/operations/command-view',
|
|
99
|
+
surfaceType: 'graph',
|
|
100
|
+
enabled: true,
|
|
101
|
+
devOnly: true,
|
|
102
|
+
featureId: 'operations',
|
|
103
|
+
featureIds: ['operations'],
|
|
104
|
+
entityIds: [],
|
|
105
105
|
resourceIds: [],
|
|
106
106
|
capabilityIds: ['operations.command-view']
|
|
107
107
|
},
|
|
@@ -261,45 +261,45 @@ export const DEFAULT_ORGANIZATION_MODEL_NAVIGATION: z.infer<typeof OrganizationM
|
|
|
261
261
|
resourceIds: [],
|
|
262
262
|
capabilityIds: []
|
|
263
263
|
},
|
|
264
|
-
{
|
|
265
|
-
id: 'settings.appearance',
|
|
266
|
-
label: 'Appearance',
|
|
267
|
-
path: '/settings/appearance',
|
|
264
|
+
{
|
|
265
|
+
id: 'settings.appearance',
|
|
266
|
+
label: 'Appearance',
|
|
267
|
+
path: '/settings/appearance',
|
|
268
|
+
surfaceType: 'settings',
|
|
269
|
+
enabled: true,
|
|
270
|
+
featureId: 'settings',
|
|
271
|
+
featureIds: ['settings'],
|
|
272
|
+
entityIds: [],
|
|
273
|
+
resourceIds: [],
|
|
274
|
+
capabilityIds: []
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
id: SETTINGS_ROLES_SURFACE_ID,
|
|
278
|
+
label: 'My Roles',
|
|
279
|
+
path: '/settings/roles',
|
|
268
280
|
surfaceType: 'settings',
|
|
269
281
|
enabled: true,
|
|
270
282
|
featureId: 'settings',
|
|
271
283
|
featureIds: ['settings'],
|
|
272
284
|
entityIds: [],
|
|
273
|
-
resourceIds: [],
|
|
274
|
-
capabilityIds: []
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
id:
|
|
278
|
-
label: '
|
|
279
|
-
path: '/settings/
|
|
280
|
-
surfaceType: 'settings',
|
|
281
|
-
enabled: true,
|
|
282
|
-
featureId: 'settings',
|
|
283
|
-
featureIds: ['settings'],
|
|
284
|
-
entityIds: [],
|
|
285
|
-
resourceIds: [],
|
|
286
|
-
capabilityIds: []
|
|
287
|
-
},
|
|
288
|
-
{
|
|
289
|
-
id: 'settings.organization',
|
|
290
|
-
label: 'Organization',
|
|
291
|
-
path: '/settings/organization',
|
|
285
|
+
resourceIds: [],
|
|
286
|
+
capabilityIds: []
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
id: 'settings.organization',
|
|
290
|
+
label: 'Organization',
|
|
291
|
+
path: '/settings/organization',
|
|
292
292
|
surfaceType: 'settings',
|
|
293
293
|
enabled: true,
|
|
294
294
|
featureId: 'settings',
|
|
295
295
|
featureIds: ['settings'],
|
|
296
296
|
entityIds: [],
|
|
297
|
-
resourceIds: [],
|
|
298
|
-
capabilityIds: []
|
|
299
|
-
},
|
|
300
|
-
{
|
|
301
|
-
id: 'settings.credentials',
|
|
302
|
-
label: 'Credentials',
|
|
297
|
+
resourceIds: [],
|
|
298
|
+
capabilityIds: []
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
id: 'settings.credentials',
|
|
302
|
+
label: 'Credentials',
|
|
303
303
|
path: '/settings/credentials',
|
|
304
304
|
surfaceType: 'settings',
|
|
305
305
|
enabled: true,
|
|
@@ -355,12 +355,12 @@ export const DEFAULT_ORGANIZATION_MODEL_NAVIGATION: z.infer<typeof OrganizationM
|
|
|
355
355
|
},
|
|
356
356
|
{
|
|
357
357
|
id: 'primary-operations',
|
|
358
|
-
label: 'Operations',
|
|
359
|
-
placement: 'primary',
|
|
360
|
-
surfaceIds: [
|
|
361
|
-
OPERATIONS_COMMAND_VIEW_SURFACE_ID,
|
|
362
|
-
'operations.overview',
|
|
363
|
-
'operations.resources',
|
|
358
|
+
label: 'Operations',
|
|
359
|
+
placement: 'primary',
|
|
360
|
+
surfaceIds: [
|
|
361
|
+
OPERATIONS_COMMAND_VIEW_SURFACE_ID,
|
|
362
|
+
'operations.overview',
|
|
363
|
+
'operations.resources',
|
|
364
364
|
'operations.command-queue',
|
|
365
365
|
'operations.sessions',
|
|
366
366
|
'operations.task-scheduler'
|
|
@@ -385,12 +385,12 @@ export const DEFAULT_ORGANIZATION_MODEL_NAVIGATION: z.infer<typeof OrganizationM
|
|
|
385
385
|
label: 'Settings',
|
|
386
386
|
placement: 'bottom',
|
|
387
387
|
surfaceIds: [
|
|
388
|
-
'settings.account',
|
|
389
|
-
'settings.appearance',
|
|
390
|
-
SETTINGS_ROLES_SURFACE_ID,
|
|
391
|
-
'settings.organization',
|
|
392
|
-
'settings.credentials',
|
|
393
|
-
'settings.api-keys',
|
|
388
|
+
'settings.account',
|
|
389
|
+
'settings.appearance',
|
|
390
|
+
SETTINGS_ROLES_SURFACE_ID,
|
|
391
|
+
'settings.organization',
|
|
392
|
+
'settings.credentials',
|
|
393
|
+
'settings.api-keys',
|
|
394
394
|
'settings.webhooks',
|
|
395
395
|
'settings.deployments'
|
|
396
396
|
]
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import {
|
|
3
|
+
CRM_PIPELINE_DEFINITION,
|
|
4
|
+
CRM_DISCOVERY_REPLIED_STATE,
|
|
5
|
+
CRM_DISCOVERY_LINK_SENT_STATE,
|
|
6
|
+
CRM_DISCOVERY_NUDGING_STATE,
|
|
7
|
+
CRM_DISCOVERY_BOOKING_CANCELLED_STATE,
|
|
8
|
+
CRM_REPLY_SENT_STATE,
|
|
9
|
+
CRM_FOLLOWUP_1_SENT_STATE,
|
|
10
|
+
CRM_FOLLOWUP_2_SENT_STATE,
|
|
11
|
+
CRM_FOLLOWUP_3_SENT_STATE,
|
|
12
|
+
getValidStatesForStage,
|
|
13
|
+
findPipeline,
|
|
14
|
+
ACQ_LIST_MEMBERS_LEAD_GEN_PIPELINE,
|
|
15
|
+
ACQ_LIST_COMPANIES_LEAD_GEN_PIPELINE,
|
|
16
|
+
LEAD_GEN_PIPELINE_DEFINITIONS
|
|
17
|
+
} from './sales'
|
|
18
|
+
|
|
19
|
+
describe('CRM_PIPELINE_DEFINITION', () => {
|
|
20
|
+
it('has pipelineKey "crm"', () => {
|
|
21
|
+
expect(CRM_PIPELINE_DEFINITION.pipelineKey).toBe('crm')
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('has entityKey "crm.deal"', () => {
|
|
25
|
+
expect(CRM_PIPELINE_DEFINITION.entityKey).toBe('crm.deal')
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('has exactly 6 stages', () => {
|
|
29
|
+
expect(CRM_PIPELINE_DEFINITION.stages).toHaveLength(6)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('stage keys are interested, proposal, closing, closed_won, closed_lost, nurturing in order', () => {
|
|
33
|
+
const keys = CRM_PIPELINE_DEFINITION.stages.map((s) => s.stageKey)
|
|
34
|
+
expect(keys).toEqual(['interested', 'proposal', 'closing', 'closed_won', 'closed_lost', 'nurturing'])
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it('interested stage has exactly 8 states', () => {
|
|
38
|
+
const interested = CRM_PIPELINE_DEFINITION.stages.find((s) => s.stageKey === 'interested')
|
|
39
|
+
expect(interested?.states).toHaveLength(8)
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('interested stage contains all 8 expected state constants', () => {
|
|
43
|
+
const interested = CRM_PIPELINE_DEFINITION.stages.find((s) => s.stageKey === 'interested')!
|
|
44
|
+
const stateKeys = interested.states.map((s) => s.stateKey)
|
|
45
|
+
expect(stateKeys).toContain(CRM_DISCOVERY_REPLIED_STATE.stateKey)
|
|
46
|
+
expect(stateKeys).toContain(CRM_DISCOVERY_LINK_SENT_STATE.stateKey)
|
|
47
|
+
expect(stateKeys).toContain(CRM_DISCOVERY_NUDGING_STATE.stateKey)
|
|
48
|
+
expect(stateKeys).toContain(CRM_DISCOVERY_BOOKING_CANCELLED_STATE.stateKey)
|
|
49
|
+
expect(stateKeys).toContain(CRM_REPLY_SENT_STATE.stateKey)
|
|
50
|
+
expect(stateKeys).toContain(CRM_FOLLOWUP_1_SENT_STATE.stateKey)
|
|
51
|
+
expect(stateKeys).toContain(CRM_FOLLOWUP_2_SENT_STATE.stateKey)
|
|
52
|
+
expect(stateKeys).toContain(CRM_FOLLOWUP_3_SENT_STATE.stateKey)
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('interested stage states reference the exported constants by identity', () => {
|
|
56
|
+
const interested = CRM_PIPELINE_DEFINITION.stages.find((s) => s.stageKey === 'interested')!
|
|
57
|
+
expect(interested.states).toContain(CRM_DISCOVERY_REPLIED_STATE)
|
|
58
|
+
expect(interested.states).toContain(CRM_FOLLOWUP_3_SENT_STATE)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it.each(['proposal', 'closing', 'closed_won', 'closed_lost', 'nurturing'])(
|
|
62
|
+
'%s stage has an empty states array',
|
|
63
|
+
(stageKey) => {
|
|
64
|
+
const stage = CRM_PIPELINE_DEFINITION.stages.find((s) => s.stageKey === stageKey)
|
|
65
|
+
expect(stage).toBeDefined()
|
|
66
|
+
expect(stage?.states).toHaveLength(0)
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
it('closed_won stage has empty states array', () => {
|
|
71
|
+
const stage = CRM_PIPELINE_DEFINITION.stages.find((s) => s.stageKey === 'closed_won')
|
|
72
|
+
expect(stage?.states).toEqual([])
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it('closed_lost stage has empty states array', () => {
|
|
76
|
+
const stage = CRM_PIPELINE_DEFINITION.stages.find((s) => s.stageKey === 'closed_lost')
|
|
77
|
+
expect(stage?.states).toEqual([])
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
describe('CRM state constant shapes', () => {
|
|
82
|
+
it('CRM_DISCOVERY_REPLIED_STATE has correct stateKey and label', () => {
|
|
83
|
+
expect(CRM_DISCOVERY_REPLIED_STATE).toEqual({ stateKey: 'discovery_replied', label: 'Discovery Replied' })
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
it('CRM_FOLLOWUP_1_SENT_STATE has correct stateKey and label', () => {
|
|
87
|
+
expect(CRM_FOLLOWUP_1_SENT_STATE).toEqual({ stateKey: 'followup_1_sent', label: 'Follow-up 1 Sent' })
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it('CRM_FOLLOWUP_2_SENT_STATE has correct stateKey and label', () => {
|
|
91
|
+
expect(CRM_FOLLOWUP_2_SENT_STATE).toEqual({ stateKey: 'followup_2_sent', label: 'Follow-up 2 Sent' })
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
it('CRM_FOLLOWUP_3_SENT_STATE has correct stateKey and label', () => {
|
|
95
|
+
expect(CRM_FOLLOWUP_3_SENT_STATE).toEqual({ stateKey: 'followup_3_sent', label: 'Follow-up 3 Sent' })
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
describe('getValidStatesForStage', () => {
|
|
100
|
+
it('returns all 8 states for the interested stage', () => {
|
|
101
|
+
const states = getValidStatesForStage(CRM_PIPELINE_DEFINITION, 'interested')
|
|
102
|
+
expect(states).toHaveLength(8)
|
|
103
|
+
expect(states.map((s) => s.stateKey)).toContain('discovery_replied')
|
|
104
|
+
expect(states.map((s) => s.stateKey)).toContain('followup_3_sent')
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
it('returns empty array for the proposal stage (no states defined)', () => {
|
|
108
|
+
const states = getValidStatesForStage(CRM_PIPELINE_DEFINITION, 'proposal')
|
|
109
|
+
expect(states).toEqual([])
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it('returns empty array for the closing stage (no states defined)', () => {
|
|
113
|
+
const states = getValidStatesForStage(CRM_PIPELINE_DEFINITION, 'closing')
|
|
114
|
+
expect(states).toEqual([])
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it('returns empty array for closed_won stage', () => {
|
|
118
|
+
const states = getValidStatesForStage(CRM_PIPELINE_DEFINITION, 'closed_won')
|
|
119
|
+
expect(states).toEqual([])
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
it('returns empty array for closed_lost stage', () => {
|
|
123
|
+
const states = getValidStatesForStage(CRM_PIPELINE_DEFINITION, 'closed_lost')
|
|
124
|
+
expect(states).toEqual([])
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
it('returns empty array for nurturing stage (no states defined)', () => {
|
|
128
|
+
const states = getValidStatesForStage(CRM_PIPELINE_DEFINITION, 'nurturing')
|
|
129
|
+
expect(states).toEqual([])
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
it('returns empty array for an unknown stage key', () => {
|
|
133
|
+
const states = getValidStatesForStage(CRM_PIPELINE_DEFINITION, 'unknown_stage')
|
|
134
|
+
expect(states).toEqual([])
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
it('returns empty array for an empty string stage key', () => {
|
|
138
|
+
const states = getValidStatesForStage(CRM_PIPELINE_DEFINITION, '')
|
|
139
|
+
expect(states).toEqual([])
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
it('is case-sensitive — "Interested" does not match "interested"', () => {
|
|
143
|
+
const states = getValidStatesForStage(CRM_PIPELINE_DEFINITION, 'Interested')
|
|
144
|
+
expect(states).toEqual([])
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
it('works with the lead-gen member pipeline for known stage', () => {
|
|
148
|
+
const states = getValidStatesForStage(ACQ_LIST_MEMBERS_LEAD_GEN_PIPELINE, 'outreach')
|
|
149
|
+
expect(states.length).toBeGreaterThan(0)
|
|
150
|
+
expect(states.map((s) => s.stateKey)).toContain('personalized')
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
it('works with the lead-gen member pipeline for unknown stage', () => {
|
|
154
|
+
const states = getValidStatesForStage(ACQ_LIST_MEMBERS_LEAD_GEN_PIPELINE, 'nonexistent')
|
|
155
|
+
expect(states).toEqual([])
|
|
156
|
+
})
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
describe('findPipeline', () => {
|
|
160
|
+
it('finds a pipeline by pipelineKey when present', () => {
|
|
161
|
+
const found = findPipeline(LEAD_GEN_PIPELINE_DEFINITIONS['acq.list-member'], 'lead-gen')
|
|
162
|
+
expect(found).toBe(ACQ_LIST_MEMBERS_LEAD_GEN_PIPELINE)
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
it('returns undefined for an unknown pipelineKey', () => {
|
|
166
|
+
const found = findPipeline(LEAD_GEN_PIPELINE_DEFINITIONS['acq.list-member'], 'crm')
|
|
167
|
+
expect(found).toBeUndefined()
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
it('returns undefined for an empty array', () => {
|
|
171
|
+
const found = findPipeline([], 'lead-gen')
|
|
172
|
+
expect(found).toBeUndefined()
|
|
173
|
+
})
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
describe('LEAD_GEN_PIPELINE_DEFINITIONS', () => {
|
|
177
|
+
it('has entries for acq.list-member and acq.list-company', () => {
|
|
178
|
+
expect(LEAD_GEN_PIPELINE_DEFINITIONS).toHaveProperty('acq.list-member')
|
|
179
|
+
expect(LEAD_GEN_PIPELINE_DEFINITIONS).toHaveProperty('acq.list-company')
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
it('acq.list-member entry contains the ACQ_LIST_MEMBERS_LEAD_GEN_PIPELINE', () => {
|
|
183
|
+
expect(LEAD_GEN_PIPELINE_DEFINITIONS['acq.list-member']).toContain(ACQ_LIST_MEMBERS_LEAD_GEN_PIPELINE)
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
it('acq.list-company entry contains the ACQ_LIST_COMPANIES_LEAD_GEN_PIPELINE', () => {
|
|
187
|
+
expect(LEAD_GEN_PIPELINE_DEFINITIONS['acq.list-company']).toContain(ACQ_LIST_COMPANIES_LEAD_GEN_PIPELINE)
|
|
188
|
+
})
|
|
189
|
+
})
|