@elevasis/core 0.26.0 → 0.28.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 +162 -105
- package/dist/index.js +280 -174
- package/dist/knowledge/index.d.ts +43 -43
- package/dist/organization-model/index.d.ts +162 -105
- package/dist/organization-model/index.js +280 -174
- package/dist/test-utils/index.d.ts +20 -20
- package/dist/test-utils/index.js +184 -126
- package/package.json +3 -3
- package/src/_gen/__tests__/__snapshots__/contracts.md.snap +976 -1063
- package/src/business/acquisition/api-schemas.test.ts +1962 -1841
- package/src/business/acquisition/api-schemas.ts +1461 -1464
- package/src/business/acquisition/crm-next-action.test.ts +45 -25
- package/src/business/acquisition/crm-next-action.ts +227 -220
- package/src/business/acquisition/crm-priority.test.ts +41 -8
- package/src/business/acquisition/crm-priority.ts +365 -349
- package/src/business/acquisition/crm-state-actions.test.ts +208 -153
- package/src/business/acquisition/derive-actions.test.ts +90 -13
- package/src/business/acquisition/derive-actions.ts +8 -139
- package/src/business/acquisition/ontology-validation.ts +72 -158
- package/src/business/pdf/sections/investment.ts +1 -1
- package/src/business/pdf/sections/summary-investment.ts +1 -1
- package/src/execution/engine/tools/tool-maps.ts +872 -831
- package/src/organization-model/__tests__/cross-ref.test.ts +167 -0
- package/src/organization-model/__tests__/define-domain-record.test.ts +289 -0
- package/src/organization-model/__tests__/om-spine-doc-contract.test.ts +56 -0
- package/src/organization-model/__tests__/published-zero-leak.test.ts +60 -1
- package/src/organization-model/__tests__/resolve.test.ts +1 -1
- package/src/organization-model/__tests__/schema-refinements.test.ts +72 -0
- package/src/organization-model/cross-ref.ts +175 -0
- package/src/organization-model/domains/actions.ts +13 -0
- package/src/organization-model/domains/branding.ts +6 -6
- package/src/organization-model/domains/customers.ts +95 -78
- package/src/organization-model/domains/entities.ts +157 -144
- package/src/organization-model/domains/goals.ts +100 -83
- package/src/organization-model/domains/knowledge.ts +106 -93
- package/src/organization-model/domains/offerings.ts +88 -71
- package/src/organization-model/domains/policies.ts +115 -102
- package/src/organization-model/domains/roles.ts +109 -96
- package/src/organization-model/domains/sales.test.ts +104 -218
- package/src/organization-model/domains/sales.ts +212 -375
- package/src/organization-model/domains/statuses.ts +351 -339
- package/src/organization-model/domains/systems.ts +176 -164
- package/src/organization-model/helpers.ts +331 -306
- package/src/organization-model/index.ts +43 -0
- package/src/organization-model/published.ts +27 -2
- package/src/organization-model/schema-refinements.ts +667 -0
- package/src/organization-model/schema.ts +8 -715
- package/src/platform/constants/versions.ts +1 -1
- package/src/reference/_generated/contracts.md +1000 -1087
|
@@ -1,380 +1,217 @@
|
|
|
1
|
-
import { z } from 'zod'
|
|
2
|
-
import { DescriptionSchema, DisplayMetadataSchema, ModelIdSchema, ReferenceIdsSchema } from './shared'
|
|
3
|
-
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import { DescriptionSchema, DisplayMetadataSchema, ModelIdSchema, ReferenceIdsSchema } from './shared'
|
|
3
|
+
|
|
4
4
|
export type { LeadGenStageCatalogEntry } from '../catalogs/lead-gen'
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
// OrganizationModelSalesSchema and DEFAULT_ORGANIZATION_MODEL_SALES are retired.
|
|
7
7
|
// Pipeline/stage data lives in System.ontology.catalogTypes on the owning system
|
|
8
8
|
// (e.g. sales.crm). Use getAllPipelines() / getStagesInPipeline() from
|
|
9
9
|
// migration-helpers to read pipeline data portably.
|
|
10
|
-
//
|
|
11
|
-
// SalesStageSemanticClassSchema, SalesStageSchema, SalesPipelineSchema are retained
|
|
12
|
-
// below as TypeScript types used by CRM business logic and
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
{ bucketKey: 'closed_low', label: 'Closed', rank: 50, color: 'dark' }
|
|
219
|
-
]
|
|
220
|
-
|
|
221
|
-
export const DEFAULT_CRM_PRIORITY_RULE_CONFIG: CrmPriorityRuleConfig = {
|
|
222
|
-
buckets: CRM_PRIORITY_BUCKETS,
|
|
223
|
-
closedStageKeys: ['closed_won', 'closed_lost'],
|
|
224
|
-
followUpAfterDaysByStateKey: {
|
|
225
|
-
discovery_link_sent: 3,
|
|
226
|
-
discovery_nudging: 2,
|
|
227
|
-
reply_sent: 3,
|
|
228
|
-
followup_1_sent: 3,
|
|
229
|
-
followup_2_sent: 5,
|
|
230
|
-
followup_3_sent: 7
|
|
231
|
-
},
|
|
232
|
-
staleAfterDays: 14
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
// ============================================================================
|
|
236
|
-
// CRM Next-Action Rule Config
|
|
237
|
-
//
|
|
238
|
-
// Maps (state_key, ownership) → suggested action key from DEFAULT_CRM_ACTIONS.
|
|
239
|
-
// Per-org overrides live at organizations.config.crm.next_actions; merged at
|
|
240
|
-
// evaluator read time (same pattern as priority). The evaluator returns the
|
|
241
|
-
// action's `key` string, or null for closed deals / unrecognised combinations.
|
|
242
|
-
// ============================================================================
|
|
243
|
-
|
|
244
|
-
export interface CrmNextActionMapping {
|
|
245
|
-
/** state_key to match, or '*' for any state. */
|
|
246
|
-
stateKey: string
|
|
247
|
-
/** ownership value to match ('us' | 'them'), or '*' for any. */
|
|
248
|
-
ownership: 'us' | 'them' | '*'
|
|
249
|
-
/** Action key from DEFAULT_CRM_ACTIONS (or a custom org-defined key). */
|
|
250
|
-
actionKey: string
|
|
251
|
-
/**
|
|
252
|
-
* When true, this mapping only fires if age >= staleAfterDays.
|
|
253
|
-
* Defaults to false.
|
|
254
|
-
*/
|
|
255
|
-
requiresStale?: boolean
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
export interface CrmNextActionRuleConfig {
|
|
259
|
-
mappings: CrmNextActionMapping[]
|
|
260
|
-
/** Fallback action key when ownership === 'us' and no explicit mapping matches. */
|
|
261
|
-
ownershipUsFallback: string
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* Default next-action rule config. Evaluated in order — first match wins.
|
|
266
|
-
*
|
|
267
|
-
* Mapping table (state_key, ownership) → action_key:
|
|
268
|
-
* (discovery_link_sent, 'them') → 'send_nudge' (after staleAfterDays)
|
|
269
|
-
* (discovery_replied, 'us') → 'send_reply'
|
|
270
|
-
* (discovery_nudging, 'them') → 'send_nudge'
|
|
271
|
-
* (*, 'us') → ownershipUsFallback ('send_reply')
|
|
272
|
-
*
|
|
273
|
-
* Closed deals → null (handled before mapping evaluation).
|
|
274
|
-
*/
|
|
275
|
-
export const DEFAULT_CRM_NEXT_ACTION_RULE_CONFIG: CrmNextActionRuleConfig = {
|
|
276
|
-
mappings: [
|
|
277
|
-
{
|
|
278
|
-
stateKey: 'discovery_link_sent',
|
|
279
|
-
ownership: 'them',
|
|
280
|
-
actionKey: 'send_nudge',
|
|
281
|
-
requiresStale: true
|
|
282
|
-
},
|
|
283
|
-
{
|
|
284
|
-
stateKey: 'discovery_replied',
|
|
285
|
-
ownership: 'us',
|
|
286
|
-
actionKey: 'send_reply'
|
|
287
|
-
},
|
|
288
|
-
{
|
|
289
|
-
stateKey: 'discovery_nudging',
|
|
290
|
-
ownership: 'them',
|
|
291
|
-
actionKey: 'send_nudge'
|
|
292
|
-
}
|
|
293
|
-
],
|
|
294
|
-
ownershipUsFallback: 'send_reply'
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
/** Common states that appear across multiple stages. */
|
|
298
|
-
const PENDING_STATE: StatefulStateDefinition = { stateKey: 'pending', label: 'Pending' }
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* Lead-gen pipeline definition for acq_list_members (contacts).
|
|
302
|
-
* Three stages matching the post-restructure sales subdomain tree.
|
|
303
|
-
*
|
|
304
|
-
* Note: members visit outreach and prospecting states depending on which
|
|
305
|
-
* workflow last processed them. stage_key is set per-transition by the workflow.
|
|
306
|
-
*/
|
|
307
|
-
export const ACQ_LIST_MEMBERS_LEAD_GEN_PIPELINE: StatefulPipelineDefinition = {
|
|
308
|
-
pipelineKey: 'lead-gen',
|
|
309
|
-
label: 'Lead Generation',
|
|
310
|
-
entityKey: 'acq.list-member',
|
|
311
|
-
stages: [
|
|
312
|
-
{
|
|
313
|
-
stageKey: 'outreach',
|
|
314
|
-
label: 'Outreach',
|
|
315
|
-
states: [
|
|
316
|
-
PENDING_STATE,
|
|
317
|
-
{ stateKey: 'personalized', label: 'Personalized' },
|
|
318
|
-
{ stateKey: 'uploaded', label: 'Uploaded' },
|
|
319
|
-
{ stateKey: 'interested', label: 'Interested' }
|
|
320
|
-
]
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
stageKey: 'prospecting',
|
|
324
|
-
label: 'Prospecting',
|
|
325
|
-
states: [
|
|
326
|
-
PENDING_STATE,
|
|
327
|
-
{ stateKey: 'discovered', label: 'Discovered' },
|
|
328
|
-
{ stateKey: 'verified', label: 'Verified' }
|
|
329
|
-
]
|
|
330
|
-
},
|
|
331
|
-
{
|
|
332
|
-
stageKey: 'qualification',
|
|
333
|
-
label: 'Qualification',
|
|
334
|
-
states: [PENDING_STATE]
|
|
335
|
-
}
|
|
336
|
-
]
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* Lead-gen pipeline definition for acq_list_companies.
|
|
341
|
-
* Three stages matching the post-restructure sales subdomain tree.
|
|
342
|
-
*
|
|
343
|
-
* Note: companies visit prospecting and qualification states depending on which
|
|
344
|
-
* workflow last processed them. stage_key is set per-transition by the workflow.
|
|
345
|
-
*/
|
|
346
|
-
export const ACQ_LIST_COMPANIES_LEAD_GEN_PIPELINE: StatefulPipelineDefinition = {
|
|
347
|
-
pipelineKey: 'lead-gen',
|
|
348
|
-
label: 'Lead Generation',
|
|
349
|
-
entityKey: 'acq.list-company',
|
|
350
|
-
stages: [
|
|
351
|
-
{
|
|
352
|
-
stageKey: 'outreach',
|
|
353
|
-
label: 'Outreach',
|
|
354
|
-
states: [PENDING_STATE, { stateKey: 'uploaded', label: 'Uploaded' }]
|
|
355
|
-
},
|
|
356
|
-
{
|
|
357
|
-
stageKey: 'prospecting',
|
|
358
|
-
label: 'Prospecting',
|
|
359
|
-
states: [
|
|
360
|
-
PENDING_STATE,
|
|
361
|
-
{ stateKey: 'populated', label: 'Populated' },
|
|
362
|
-
{ stateKey: 'extracted', label: 'Extracted' }
|
|
363
|
-
]
|
|
364
|
-
},
|
|
365
|
-
{
|
|
366
|
-
stageKey: 'qualification',
|
|
367
|
-
label: 'Qualification',
|
|
368
|
-
states: [PENDING_STATE, { stateKey: 'qualified', label: 'Qualified' }]
|
|
369
|
-
}
|
|
370
|
-
]
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
* All lead-gen pipeline definitions indexed by entity key.
|
|
375
|
-
* Use findPipeline() to locate a definition by pipeline_key within any of these arrays.
|
|
376
|
-
*/
|
|
377
|
-
export const LEAD_GEN_PIPELINE_DEFINITIONS: Record<string, StatefulPipelineDefinition[]> = {
|
|
378
|
-
'acq.list-member': [ACQ_LIST_MEMBERS_LEAD_GEN_PIPELINE],
|
|
379
|
-
'acq.list-company': [ACQ_LIST_COMPANIES_LEAD_GEN_PIPELINE]
|
|
380
|
-
}
|
|
10
|
+
//
|
|
11
|
+
// SalesStageSemanticClassSchema, SalesStageSchema, SalesPipelineSchema are retained
|
|
12
|
+
// below as TypeScript types used by generic CRM business logic and stateful
|
|
13
|
+
// pipeline definitions. Elevasis CRM runtime constants live in @repo/elevasis-core.
|
|
14
|
+
|
|
15
|
+
export const SalesStageSemanticClassSchema = z.enum(['open', 'active', 'nurturing', 'closed_won', 'closed_lost'])
|
|
16
|
+
|
|
17
|
+
export const SalesStageSchema = DisplayMetadataSchema.extend({
|
|
18
|
+
id: ModelIdSchema,
|
|
19
|
+
order: z.number().int().min(0),
|
|
20
|
+
semanticClass: SalesStageSemanticClassSchema,
|
|
21
|
+
surfaceIds: ReferenceIdsSchema,
|
|
22
|
+
resourceIds: ReferenceIdsSchema
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
export const SalesPipelineSchema = z.object({
|
|
26
|
+
id: ModelIdSchema,
|
|
27
|
+
label: z.string().trim().min(1).max(120),
|
|
28
|
+
description: DescriptionSchema.optional(),
|
|
29
|
+
entityId: ModelIdSchema,
|
|
30
|
+
stages: z.array(SalesStageSchema).min(1)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
// ============================================================================
|
|
34
|
+
// Generic Stateful Pipeline Types
|
|
35
|
+
// ============================================================================
|
|
36
|
+
|
|
37
|
+
/** One state within a stage: minimal shape of key + display label. */
|
|
38
|
+
export interface StatefulStateDefinition {
|
|
39
|
+
/** Matches state_key values written by workflow steps. */
|
|
40
|
+
stateKey: string
|
|
41
|
+
label: string
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** One stage within a pipeline: has a stage_key and ordered valid states. */
|
|
45
|
+
export interface StatefulStageDefinition {
|
|
46
|
+
/** Matches stage_key values written by workflow steps. */
|
|
47
|
+
stageKey: string
|
|
48
|
+
label: string
|
|
49
|
+
/** UI color token. Consumers may map this to their design system. */
|
|
50
|
+
color?: string
|
|
51
|
+
states: StatefulStateDefinition[]
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Pipeline definition for a single entity participating in the Stateful trait.
|
|
56
|
+
* Parallel to acq_deals' pipeline_key concept but structured for any entity.
|
|
57
|
+
*/
|
|
58
|
+
export interface StatefulPipelineDefinition {
|
|
59
|
+
/** Matches pipeline_key values in the database. */
|
|
60
|
+
pipelineKey: string
|
|
61
|
+
label: string
|
|
62
|
+
/** Entity this pipeline applies to. */
|
|
63
|
+
entityKey: string
|
|
64
|
+
stages: StatefulStageDefinition[]
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type CrmPriorityBucketKey = 'needs_response' | 'follow_up_due' | 'waiting' | 'stale' | 'closed_low'
|
|
68
|
+
|
|
69
|
+
export interface CrmPriorityBucketDefinition {
|
|
70
|
+
bucketKey: CrmPriorityBucketKey
|
|
71
|
+
label: string
|
|
72
|
+
/** Lower ranks sort first in deal lists and pipeline columns. */
|
|
73
|
+
rank: number
|
|
74
|
+
/** UI color token. Consumers may map this to their design system. */
|
|
75
|
+
color: string
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface CrmPriorityRuleConfig {
|
|
79
|
+
buckets: CrmPriorityBucketDefinition[]
|
|
80
|
+
closedStageKeys: string[]
|
|
81
|
+
followUpAfterDaysByStateKey: Record<string, number>
|
|
82
|
+
staleAfterDays: number
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Find a pipeline definition by pipeline_key within an array of definitions.
|
|
87
|
+
* Preferred over direct array indexing since the model is array-based.
|
|
88
|
+
*/
|
|
89
|
+
export function findPipeline(
|
|
90
|
+
definitions: StatefulPipelineDefinition[],
|
|
91
|
+
pipelineKey: string
|
|
92
|
+
): StatefulPipelineDefinition | undefined {
|
|
93
|
+
return definitions.find((def) => def.pipelineKey === pipelineKey)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Returns the valid states for a given stage within a pipeline definition.
|
|
98
|
+
* Returns an empty array if the stage is not found.
|
|
99
|
+
*/
|
|
100
|
+
export function getValidStatesForStage(
|
|
101
|
+
definition: StatefulPipelineDefinition,
|
|
102
|
+
stageKey: string
|
|
103
|
+
): StatefulStateDefinition[] {
|
|
104
|
+
return definition.stages.find((s) => s.stageKey === stageKey)?.states ?? []
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// ============================================================================
|
|
108
|
+
// CRM Next-Action Rule Config Types
|
|
109
|
+
//
|
|
110
|
+
// Generic rule config types only. Elevasis-specific CRM runtime mappings live
|
|
111
|
+
// in @repo/elevasis-core, not in the published @repo/core surface.
|
|
112
|
+
// ============================================================================
|
|
113
|
+
|
|
114
|
+
export interface CrmNextActionMapping {
|
|
115
|
+
/** state_key to match, or '*' for any state. */
|
|
116
|
+
stateKey: string
|
|
117
|
+
/** ownership value to match ('us' | 'them'), or '*' for any. */
|
|
118
|
+
ownership: 'us' | 'them' | '*'
|
|
119
|
+
/** Action key from a caller-supplied action catalog. */
|
|
120
|
+
actionKey: string
|
|
121
|
+
/**
|
|
122
|
+
* When true, this mapping only fires if age >= staleAfterDays.
|
|
123
|
+
* Defaults to false.
|
|
124
|
+
*/
|
|
125
|
+
requiresStale?: boolean
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface CrmNextActionRuleConfig {
|
|
129
|
+
mappings: CrmNextActionMapping[]
|
|
130
|
+
/** Fallback action key when ownership === 'us' and no explicit mapping matches. */
|
|
131
|
+
ownershipUsFallback?: string | null
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Common states that appear across multiple stages. */
|
|
135
|
+
const PENDING_STATE: StatefulStateDefinition = { stateKey: 'pending', label: 'Pending' }
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Lead-gen pipeline definition for acq_list_members (contacts).
|
|
139
|
+
* Three stages matching the post-restructure sales subdomain tree.
|
|
140
|
+
*
|
|
141
|
+
* Note: members visit outreach and prospecting states depending on which
|
|
142
|
+
* workflow last processed them. stage_key is set per-transition by the workflow.
|
|
143
|
+
*/
|
|
144
|
+
export const ACQ_LIST_MEMBERS_LEAD_GEN_PIPELINE: StatefulPipelineDefinition = {
|
|
145
|
+
pipelineKey: 'lead-gen',
|
|
146
|
+
label: 'Lead Generation',
|
|
147
|
+
entityKey: 'acq.list-member',
|
|
148
|
+
stages: [
|
|
149
|
+
{
|
|
150
|
+
stageKey: 'outreach',
|
|
151
|
+
label: 'Outreach',
|
|
152
|
+
states: [
|
|
153
|
+
PENDING_STATE,
|
|
154
|
+
{ stateKey: 'personalized', label: 'Personalized' },
|
|
155
|
+
{ stateKey: 'uploaded', label: 'Uploaded' },
|
|
156
|
+
{ stateKey: 'interested', label: 'Interested' }
|
|
157
|
+
]
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
stageKey: 'prospecting',
|
|
161
|
+
label: 'Prospecting',
|
|
162
|
+
states: [
|
|
163
|
+
PENDING_STATE,
|
|
164
|
+
{ stateKey: 'discovered', label: 'Discovered' },
|
|
165
|
+
{ stateKey: 'verified', label: 'Verified' }
|
|
166
|
+
]
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
stageKey: 'qualification',
|
|
170
|
+
label: 'Qualification',
|
|
171
|
+
states: [PENDING_STATE]
|
|
172
|
+
}
|
|
173
|
+
]
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Lead-gen pipeline definition for acq_list_companies.
|
|
178
|
+
* Three stages matching the post-restructure sales subdomain tree.
|
|
179
|
+
*
|
|
180
|
+
* Note: companies visit prospecting and qualification states depending on which
|
|
181
|
+
* workflow last processed them. stage_key is set per-transition by the workflow.
|
|
182
|
+
*/
|
|
183
|
+
export const ACQ_LIST_COMPANIES_LEAD_GEN_PIPELINE: StatefulPipelineDefinition = {
|
|
184
|
+
pipelineKey: 'lead-gen',
|
|
185
|
+
label: 'Lead Generation',
|
|
186
|
+
entityKey: 'acq.list-company',
|
|
187
|
+
stages: [
|
|
188
|
+
{
|
|
189
|
+
stageKey: 'outreach',
|
|
190
|
+
label: 'Outreach',
|
|
191
|
+
states: [PENDING_STATE, { stateKey: 'uploaded', label: 'Uploaded' }]
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
stageKey: 'prospecting',
|
|
195
|
+
label: 'Prospecting',
|
|
196
|
+
states: [
|
|
197
|
+
PENDING_STATE,
|
|
198
|
+
{ stateKey: 'populated', label: 'Populated' },
|
|
199
|
+
{ stateKey: 'extracted', label: 'Extracted' }
|
|
200
|
+
]
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
stageKey: 'qualification',
|
|
204
|
+
label: 'Qualification',
|
|
205
|
+
states: [PENDING_STATE, { stateKey: 'qualified', label: 'Qualified' }]
|
|
206
|
+
}
|
|
207
|
+
]
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* All lead-gen pipeline definitions indexed by entity key.
|
|
212
|
+
* Use findPipeline() to locate a definition by pipeline_key within any array.
|
|
213
|
+
*/
|
|
214
|
+
export const LEAD_GEN_PIPELINE_DEFINITIONS: Record<string, StatefulPipelineDefinition[]> = {
|
|
215
|
+
'acq.list-member': [ACQ_LIST_MEMBERS_LEAD_GEN_PIPELINE],
|
|
216
|
+
'acq.list-company': [ACQ_LIST_COMPANIES_LEAD_GEN_PIPELINE]
|
|
217
|
+
}
|