@elevasis/core 0.26.0 → 0.27.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.
Files changed (34) hide show
  1. package/dist/index.d.ts +5 -5
  2. package/dist/index.js +209 -173
  3. package/dist/knowledge/index.d.ts +21 -21
  4. package/dist/organization-model/index.d.ts +5 -5
  5. package/dist/organization-model/index.js +209 -173
  6. package/dist/test-utils/index.d.ts +2 -2
  7. package/dist/test-utils/index.js +182 -126
  8. package/package.json +1 -1
  9. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +976 -1063
  10. package/src/business/acquisition/api-schemas.test.ts +1962 -1841
  11. package/src/business/acquisition/api-schemas.ts +1461 -1464
  12. package/src/business/acquisition/crm-next-action.test.ts +45 -25
  13. package/src/business/acquisition/crm-next-action.ts +227 -220
  14. package/src/business/acquisition/crm-priority.test.ts +41 -8
  15. package/src/business/acquisition/crm-priority.ts +365 -349
  16. package/src/business/acquisition/crm-state-actions.test.ts +208 -153
  17. package/src/business/acquisition/derive-actions.test.ts +90 -13
  18. package/src/business/acquisition/derive-actions.ts +8 -139
  19. package/src/business/acquisition/ontology-validation.ts +72 -158
  20. package/src/business/pdf/sections/investment.ts +1 -1
  21. package/src/business/pdf/sections/summary-investment.ts +1 -1
  22. package/src/execution/engine/tools/tool-maps.ts +872 -831
  23. package/src/organization-model/__tests__/cross-ref.test.ts +167 -0
  24. package/src/organization-model/__tests__/published-zero-leak.test.ts +60 -1
  25. package/src/organization-model/__tests__/resolve.test.ts +1 -1
  26. package/src/organization-model/__tests__/schema-refinements.test.ts +72 -0
  27. package/src/organization-model/cross-ref.ts +175 -0
  28. package/src/organization-model/domains/branding.ts +6 -6
  29. package/src/organization-model/domains/sales.test.ts +104 -218
  30. package/src/organization-model/domains/sales.ts +212 -375
  31. package/src/organization-model/index.ts +1 -0
  32. package/src/organization-model/schema-refinements.ts +667 -0
  33. package/src/organization-model/schema.ts +8 -715
  34. package/src/reference/_generated/contracts.md +976 -1063
@@ -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 the Stateful pipeline definitions.
13
-
14
- export const SalesStageSemanticClassSchema = z.enum(['open', 'active', 'nurturing', 'closed_won', 'closed_lost'])
15
-
16
- export const SalesStageSchema = DisplayMetadataSchema.extend({
17
- id: ModelIdSchema,
18
- order: z.number().int().min(0),
19
- semanticClass: SalesStageSemanticClassSchema,
20
- surfaceIds: ReferenceIdsSchema,
21
- resourceIds: ReferenceIdsSchema
22
- })
23
-
24
- export const SalesPipelineSchema = z.object({
25
- id: ModelIdSchema,
26
- label: z.string().trim().min(1).max(120),
27
- description: DescriptionSchema.optional(),
28
- entityId: ModelIdSchema,
29
- stages: z.array(SalesStageSchema).min(1)
30
- })
31
-
32
- // ============================================================================
33
- // Lead-Gen Stateful Pipeline Definitions (Decision N8, Wave 4)
34
- //
35
- // Defines the (pipeline_key, stage_key, state_key) vocabulary for the three
36
- // entities that carry the Stateful trait via Track B:
37
- // - acq_lists (pipeline_key='lead-gen', stage_key='lifecycle')
38
- // - acq_list_members (pipeline_key='lead-gen', stages: outreach / prospecting / qualification)
39
- // - acq_list_companies (pipeline_key='lead-gen', stages: outreach / prospecting / qualification)
40
- //
41
- // DB columns (pipeline_key, stage_key, state_key) remain free-form text with no
42
- // CHECK constraint — new states can be introduced without a migration (Decision N8).
43
- // These definitions are the org-specific source of truth consumed by UI and tooling.
44
- //
45
- // State vocabularies sourced from the post-restructure sales tree (W3 canonical):
46
- // outreach/:
47
- // - personalized (instantly-personalization.ts → contacts)
48
- // - uploaded (instantly-upload.ts → contacts)
49
- // - interested (instantly-reply-handler.ts contacts, initial reply transition)
50
- // prospecting/:
51
- // - populated (apify-acquire.ts, apify-scrape.ts → companies)
52
- // - crawled (apify-website-crawl.ts → companies)
53
- // - extracted (website-extract.ts → companies)
54
- // - discovered (email-discovery.ts, anymailfinder-enrich.ts → contacts)
55
- // - verified (email-verification.ts contacts)
56
- // qualification/:
57
- // - qualified (company-qualification.ts → companies)
58
- //
59
- // The 'pending' state is the W2 backfill default (coalesce(stage, 'pending')).
60
- // It is valid in any stage and represents "not yet processed by a workflow step".
61
- // ============================================================================
62
-
63
- /** One state within a stage — minimal shape: key + display label. */
64
- export interface StatefulStateDefinition {
65
- /** Matches state_key values written by workflow steps. */
66
- stateKey: string
67
- label: string
68
- }
69
-
70
- /** One stage within a pipeline — has a stage_key and an ordered list of valid states. */
71
- export interface StatefulStageDefinition {
72
- /** Matches stage_key values written by workflow steps. */
73
- stageKey: string
74
- label: string
75
- /** UI color token. Consumers may map this to their design system. */
76
- color?: string
77
- states: StatefulStateDefinition[]
78
- }
79
-
80
- /**
81
- * Pipeline definition for a single entity participating in the Stateful trait.
82
- * Parallel to acq_deals' pipeline_key concept but structured for lead-gen entities.
83
- */
84
- export interface StatefulPipelineDefinition {
85
- /** Matches pipeline_key values in the database (e.g. 'lead-gen'). */
86
- pipelineKey: string
87
- label: string
88
- /** Entity this pipeline applies to (e.g. 'acq.list', 'acq.list-member', 'acq.list-company'). */
89
- entityKey: string
90
- stages: StatefulStageDefinition[]
91
- }
92
-
93
- export type CrmPriorityBucketKey = 'needs_response' | 'follow_up_due' | 'waiting' | 'stale' | 'closed_low'
94
-
95
- export interface CrmPriorityBucketDefinition {
96
- bucketKey: CrmPriorityBucketKey
97
- label: string
98
- /** Lower ranks sort first in deal lists and pipeline columns. */
99
- rank: number
100
- /** UI color token. Consumers may map this to their design system. */
101
- color: string
102
- }
103
-
104
- export interface CrmPriorityRuleConfig {
105
- buckets: CrmPriorityBucketDefinition[]
106
- closedStageKeys: string[]
107
- followUpAfterDaysByStateKey: Record<string, number>
108
- staleAfterDays: number
109
- }
110
-
111
- /**
112
- * Find a pipeline definition by pipeline_key within an array of definitions.
113
- * Preferred over direct array indexing since the model is array-based (not keyed).
114
- */
115
- export function findPipeline(
116
- definitions: StatefulPipelineDefinition[],
117
- pipelineKey: string
118
- ): StatefulPipelineDefinition | undefined {
119
- return definitions.find((def) => def.pipelineKey === pipelineKey)
120
- }
121
-
122
- /**
123
- * Returns the valid states for a given stage within a pipeline definition.
124
- * Returns an empty array if the stage is not found.
125
- */
126
- export function getValidStatesForStage(
127
- definition: StatefulPipelineDefinition,
128
- stageKey: string
129
- ): StatefulStateDefinition[] {
130
- return definition.stages.find((s) => s.stageKey === stageKey)?.states ?? []
131
- }
132
-
133
- // ============================================================================
134
- // CRM Stateful Pipeline Definition
135
- //
136
- // Defines the (pipeline_key, stage_key, state_key) vocabulary for crm.deal
137
- // entities. Stage keys match DEFAULT_ORGANIZATION_MODEL_SALES.pipelines[0].stages.
138
- //
139
- // State vocabularies sourced from the CRM action/handler tree:
140
- // interested/:
141
- // - discovery_replied (instantly-reply-handler.ts first/subsequent reply)
142
- // - discovery_link_sent (crm-send-booking-link.ts, crm-rebook.ts booking link sent)
143
- // - discovery_nudging (crm-send-nudge.ts → nudge sent after link)
144
- // - discovery_booking_cancelled (booking-revert.ts Cal cancellation webhook)
145
- // - reply_sent (crm-send-reply.ts → operator reply sent)
146
- // - followup_1_sent (crm-reply-followup.ts day=3)
147
- // - followup_2_sent (crm-reply-followup.ts day=5)
148
- // - followup_3_sent (crm-reply-followup.ts day=7)
149
- // proposal, closing, closed_won, closed_lost, nurturing: no observed sub-states
150
- // ============================================================================
151
-
152
- export const CRM_DISCOVERY_REPLIED_STATE: StatefulStateDefinition = {
153
- stateKey: 'discovery_replied',
154
- label: 'Discovery Replied'
155
- }
156
- export const CRM_DISCOVERY_LINK_SENT_STATE: StatefulStateDefinition = {
157
- stateKey: 'discovery_link_sent',
158
- label: 'Discovery Link Sent'
159
- }
160
- export const CRM_DISCOVERY_NUDGING_STATE: StatefulStateDefinition = {
161
- stateKey: 'discovery_nudging',
162
- label: 'Discovery Nudging'
163
- }
164
- export const CRM_DISCOVERY_BOOKING_CANCELLED_STATE: StatefulStateDefinition = {
165
- stateKey: 'discovery_booking_cancelled',
166
- label: 'Discovery Booking Cancelled'
167
- }
168
- export const CRM_REPLY_SENT_STATE: StatefulStateDefinition = {
169
- stateKey: 'reply_sent',
170
- label: 'Reply Sent'
171
- }
172
- export const CRM_FOLLOWUP_1_SENT_STATE: StatefulStateDefinition = {
173
- stateKey: 'followup_1_sent',
174
- label: 'Follow-up 1 Sent'
175
- }
176
- export const CRM_FOLLOWUP_2_SENT_STATE: StatefulStateDefinition = {
177
- stateKey: 'followup_2_sent',
178
- label: 'Follow-up 2 Sent'
179
- }
180
- export const CRM_FOLLOWUP_3_SENT_STATE: StatefulStateDefinition = {
181
- stateKey: 'followup_3_sent',
182
- label: 'Follow-up 3 Sent'
183
- }
184
-
185
- export const CRM_PIPELINE_DEFINITION: StatefulPipelineDefinition = {
186
- pipelineKey: 'crm',
187
- label: 'CRM',
188
- entityKey: 'crm.deal',
189
- stages: [
190
- {
191
- stageKey: 'interested',
192
- label: 'Interested',
193
- color: 'blue',
194
- states: [
195
- CRM_DISCOVERY_REPLIED_STATE,
196
- CRM_DISCOVERY_LINK_SENT_STATE,
197
- CRM_DISCOVERY_NUDGING_STATE,
198
- CRM_DISCOVERY_BOOKING_CANCELLED_STATE,
199
- CRM_REPLY_SENT_STATE,
200
- CRM_FOLLOWUP_1_SENT_STATE,
201
- CRM_FOLLOWUP_2_SENT_STATE,
202
- CRM_FOLLOWUP_3_SENT_STATE
203
- ]
204
- },
205
- { stageKey: 'proposal', label: 'Proposal', color: 'yellow', states: [] },
206
- { stageKey: 'closing', label: 'Closing', color: 'orange', states: [] },
207
- { stageKey: 'closed_won', label: 'Closed Won', color: 'green', states: [] },
208
- { stageKey: 'closed_lost', label: 'Closed Lost', color: 'red', states: [] },
209
- { stageKey: 'nurturing', label: 'Nurturing', color: 'grape', states: [] }
210
- ]
211
- }
212
-
213
- export const CRM_PRIORITY_BUCKETS: CrmPriorityBucketDefinition[] = [
214
- { bucketKey: 'needs_response', label: 'Needs Response', rank: 10, color: 'red' },
215
- { bucketKey: 'follow_up_due', label: 'Follow-up Due', rank: 20, color: 'orange' },
216
- { bucketKey: 'waiting', label: 'Waiting', rank: 30, color: 'blue' },
217
- { bucketKey: 'stale', label: 'Stale', rank: 40, color: 'gray' },
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
+ }
@@ -1,3 +1,4 @@
1
+ export * from './cross-ref'
1
2
  export * from './schema'
2
3
  export * from './types'
3
4
  export * from './ontology'