@elevasis/sdk 1.14.1 → 1.15.1

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.
@@ -888,6 +888,26 @@ export interface AcqContact {
888
888
  export type DealStage = 'interested' | 'proposal' | 'closing' | 'closed_won' | 'closed_lost' | 'nurturing'
889
889
  ```
890
890
 
891
+ ### `DealPriorityBucketKey`
892
+
893
+ ```typescript
894
+ export type DealPriorityBucketKey = 'needs_response' | 'follow_up_due' | 'waiting' | 'stale' | 'closed_low'
895
+ ```
896
+
897
+ ### `DealPriority`
898
+
899
+ ```typescript
900
+ export interface DealPriority {
901
+ bucketKey: DealPriorityBucketKey
902
+ rank: number
903
+ label: string
904
+ color: string
905
+ reason: string
906
+ latestActivityAt: string | null
907
+ nextActionAt: string | null
908
+ }
909
+ ```
910
+
891
911
  ### `KanbanStageConfig`
892
912
 
893
913
  ```typescript
@@ -944,8 +964,11 @@ export interface DealFilters {
944
964
 
945
965
  ```typescript
946
966
  /** Deal list item with joined contact and company data */
947
- export interface DealListItem extends AcqDealRow {
948
- contact: DealContact | null
967
+ export interface DealListItem extends AcqDealRow {
968
+ priority: DealPriority
969
+ ownership: 'us' | 'them' | null
970
+ nextAction: string | null
971
+ contact: DealContact | null
949
972
  }
950
973
  ```
951
974
 
@@ -986,6 +1009,66 @@ export interface AcqDealTask {
986
1009
  }
987
1010
  ```
988
1011
 
1012
+ ### `CrmPriorityBucketKey`
1013
+
1014
+ ```typescript
1015
+ export type CrmPriorityBucketKey = 'needs_response' | 'follow_up_due' | 'waiting' | 'stale' | 'closed_low'
1016
+ ```
1017
+
1018
+ ### `CrmPriorityBucketDefinition`
1019
+
1020
+ ```typescript
1021
+ export interface CrmPriorityBucketDefinition {
1022
+ bucketKey: CrmPriorityBucketKey
1023
+ label: string
1024
+ /** Lower ranks sort first in deal lists and pipeline columns. */
1025
+ rank: number
1026
+ /** UI color token. Consumers may map this to their design system. */
1027
+ color: string
1028
+ }
1029
+ ```
1030
+
1031
+ ### `CrmPriorityRuleConfig`
1032
+
1033
+ ```typescript
1034
+ export interface CrmPriorityRuleConfig {
1035
+ buckets: CrmPriorityBucketDefinition[]
1036
+ closedStageKeys: string[]
1037
+ followUpAfterDaysByStateKey: Record<string, number>
1038
+ staleAfterDays: number
1039
+ }
1040
+ ```
1041
+
1042
+ ### `CRM_PRIORITY_BUCKETS`
1043
+
1044
+ ```typescript
1045
+ export const CRM_PRIORITY_BUCKETS: CrmPriorityBucketDefinition[] = [
1046
+ { bucketKey: 'needs_response', label: 'Needs Response', rank: 10, color: 'red' },
1047
+ { bucketKey: 'follow_up_due', label: 'Follow-up Due', rank: 20, color: 'orange' },
1048
+ { bucketKey: 'waiting', label: 'Waiting', rank: 30, color: 'blue' },
1049
+ { bucketKey: 'stale', label: 'Stale', rank: 40, color: 'gray' },
1050
+ { bucketKey: 'closed_low', label: 'Closed', rank: 50, color: 'dark' }
1051
+ ]
1052
+ ```
1053
+
1054
+ ### `DEFAULT_CRM_PRIORITY_RULE_CONFIG`
1055
+
1056
+ ```typescript
1057
+ export const DEFAULT_CRM_PRIORITY_RULE_CONFIG: CrmPriorityRuleConfig = {
1058
+ buckets: CRM_PRIORITY_BUCKETS,
1059
+ closedStageKeys: ['closed_won', 'closed_lost'],
1060
+ followUpAfterDaysByStateKey: {
1061
+ discovery_link_sent: 3,
1062
+ discovery_nudging: 2,
1063
+ reply_sent: 3,
1064
+ followup_1_sent: 3,
1065
+ followup_2_sent: 5,
1066
+ followup_3_sent: 7
1067
+ },
1068
+ staleAfterDays: 14
1069
+ }
1070
+ ```
1071
+
989
1072
  ### `DealStageSchema`
990
1073
 
991
1074
  ```typescript
@@ -1141,6 +1224,20 @@ export const DealContactSummarySchema = z.object({
1141
1224
  })
1142
1225
  ```
1143
1226
 
1227
+ ### `DealPrioritySchema`
1228
+
1229
+ ```typescript
1230
+ export const DealPrioritySchema = z.object({
1231
+ bucketKey: z.enum(['needs_response', 'follow_up_due', 'waiting', 'stale', 'closed_low']),
1232
+ rank: z.number().int(),
1233
+ label: z.string(),
1234
+ color: z.string(),
1235
+ reason: z.string(),
1236
+ latestActivityAt: z.string().nullable(),
1237
+ nextActionAt: z.string().nullable()
1238
+ })
1239
+ ```
1240
+
1144
1241
  ### `DealListItemSchema`
1145
1242
 
1146
1243
  ```typescript
@@ -1171,10 +1268,13 @@ export const DealListItemSchema = z.object({
1171
1268
  monthly_fee: z.number().nullable(),
1172
1269
  closed_lost_at: z.string().nullable(),
1173
1270
  closed_lost_reason: z.string().nullable(),
1174
- created_at: z.string(),
1175
- updated_at: z.string(),
1176
- // joined relation
1177
- contact: DealContactSummarySchema.nullable()
1271
+ created_at: z.string(),
1272
+ updated_at: z.string(),
1273
+ priority: DealPrioritySchema,
1274
+ ownership: z.enum(['us', 'them']).nullable(),
1275
+ nextAction: z.string().nullable(),
1276
+ // joined relation
1277
+ contact: DealContactSummarySchema.nullable()
1178
1278
  })
1179
1279
  ```
1180
1280
 
@@ -1194,9 +1294,11 @@ export const DealListResponseSchema = z.object({
1194
1294
  ```typescript
1195
1295
  /**
1196
1296
  * Deal detail shape — currently the same as a list item (full joined record).
1197
- * useDealDetail returns DealDetail which is typed as DealListItem.
1297
+ * Additive fields keep existing DealListItem callers compatible.
1198
1298
  */
1199
- export const DealDetailResponseSchema = DealListItemSchema
1299
+ export const DealDetailResponseSchema = DealListItemSchema.extend({
1300
+ conversation: DealConversationSchema
1301
+ })
1200
1302
  ```
1201
1303
 
1202
1304
  ### `DealNoteResponseSchema`
@@ -1269,13 +1371,16 @@ export const DealSchemas = {
1269
1371
  CreateDealNoteRequest: CreateDealNoteRequestSchema,
1270
1372
  CreateDealTaskRequest: CreateDealTaskRequestSchema,
1271
1373
  TransitionItemRequest: TransitionItemRequestSchema,
1374
+ TransitionDealStateRequest: TransitionDealStateRequestSchema,
1272
1375
  ExecuteActionParams: ExecuteActionParamsSchema,
1273
1376
  ExecuteActionRequest: ExecuteActionRequestSchema,
1274
1377
 
1275
1378
  // Responses
1379
+ DealPriority: DealPrioritySchema,
1276
1380
  DealListResponse: DealListResponseSchema,
1277
1381
  DealSummaryResponse: DealSummaryResponseSchema,
1278
1382
  DealLookupResponse: DealLookupResponseSchema,
1383
+ ConversationMessage: ConversationMessageSchema,
1279
1384
  DealDetailResponse: DealDetailResponseSchema,
1280
1385
  DealNoteResponse: DealNoteResponseSchema,
1281
1386
  DealNoteListResponse: DealNoteListResponseSchema,
@@ -1297,12 +1402,12 @@ export interface Action {
1297
1402
  ### `ActionDef`
1298
1403
 
1299
1404
  ```typescript
1300
- export interface ActionDef {
1301
- key: string
1302
- label: string
1303
- isAvailableFor: (deal: AcqDealRow) => boolean
1304
- workflowId: string
1305
- payloadSchema?: z.ZodTypeAny
1405
+ export interface ActionDef {
1406
+ key: string
1407
+ label: string
1408
+ isAvailableFor: (deal: AcqDealRow) => boolean
1409
+ workflowId: string
1410
+ payloadSchema?: z.ZodTypeAny
1306
1411
  }
1307
1412
  ```
1308
1413
 
@@ -1343,20 +1448,22 @@ export const DEFAULT_CRM_ACTIONS: ActionDef[] = [
1343
1448
  workflowId: 'move_to_nurturing-workflow'
1344
1449
  },
1345
1450
  {
1346
- key: 'send_reply',
1347
- label: 'Send Reply',
1348
- isAvailableFor: (deal) =>
1349
- deal.stage_key === 'interested' &&
1350
- (deal.state_key === 'discovery_replied' ||
1351
- deal.state_key === 'discovery_link_sent' ||
1352
- deal.state_key === 'discovery_nudging'),
1451
+ key: 'send_reply',
1452
+ label: 'Send Reply',
1453
+ isAvailableFor: (deal) =>
1454
+ deal.stage_key === 'interested' &&
1455
+ isOurReplyAction(deal) &&
1456
+ (deal.state_key === CRM_DISCOVERY_REPLIED_STATE.stateKey ||
1457
+ deal.state_key === CRM_DISCOVERY_LINK_SENT_STATE.stateKey ||
1458
+ deal.state_key === CRM_DISCOVERY_NUDGING_STATE.stateKey),
1353
1459
  workflowId: 'crm-send-reply-workflow',
1354
1460
  payloadSchema: SendReplyActionPayloadSchema
1355
1461
  },
1356
1462
  {
1357
1463
  key: 'send_link',
1358
1464
  label: 'Send Booking Link',
1359
- isAvailableFor: (deal) => deal.stage_key === 'interested' && deal.state_key === 'discovery_replied',
1465
+ isAvailableFor: (deal) =>
1466
+ deal.stage_key === 'interested' && deal.state_key === CRM_DISCOVERY_REPLIED_STATE.stateKey,
1360
1467
  workflowId: 'crm-send-booking-link-workflow'
1361
1468
  },
1362
1469
  {
@@ -1364,13 +1471,15 @@ export const DEFAULT_CRM_ACTIONS: ActionDef[] = [
1364
1471
  label: 'Send Nudge',
1365
1472
  isAvailableFor: (deal) =>
1366
1473
  deal.stage_key === 'interested' &&
1367
- (deal.state_key === 'discovery_link_sent' || deal.state_key === 'discovery_nudging'),
1474
+ (deal.state_key === CRM_DISCOVERY_LINK_SENT_STATE.stateKey ||
1475
+ deal.state_key === CRM_DISCOVERY_NUDGING_STATE.stateKey),
1368
1476
  workflowId: 'crm-send-nudge-workflow'
1369
1477
  },
1370
1478
  {
1371
1479
  key: 'mark_no_show',
1372
1480
  label: 'Mark No-Show',
1373
- isAvailableFor: (deal) => deal.stage_key === 'interested' && deal.state_key === 'discovery_nudging',
1481
+ isAvailableFor: (deal) =>
1482
+ deal.stage_key === 'interested' && deal.state_key === CRM_DISCOVERY_NUDGING_STATE.stateKey,
1374
1483
  // Mirrors the auto-timeout precedent in operations/sales/crm/pipeline/timeout-actions.ts:
1375
1484
  // both manual-click and timeout move the deal to closed_lost. The action_taken activity
1376
1485
  // event captures operator intent and distinguishes the manual variant from the timed one.
@@ -1379,7 +1488,8 @@ export const DEFAULT_CRM_ACTIONS: ActionDef[] = [
1379
1488
  {
1380
1489
  key: 'rebook',
1381
1490
  label: 'Rebook',
1382
- isAvailableFor: (deal) => deal.stage_key === 'interested' && deal.state_key === 'discovery_booking_cancelled',
1491
+ isAvailableFor: (deal) =>
1492
+ deal.stage_key === 'interested' && deal.state_key === CRM_DISCOVERY_BOOKING_CANCELLED_STATE.stateKey,
1383
1493
  workflowId: 'crm-rebook-workflow'
1384
1494
  }
1385
1495
  ]
@@ -1388,19 +1498,19 @@ export const DEFAULT_CRM_ACTIONS: ActionDef[] = [
1388
1498
  ### `CrmToolMap`
1389
1499
 
1390
1500
  ```typescript
1391
- export type CrmToolMap = {
1392
- getRecentActivity: { params: CrmRecentActivityParams; result: RecentActivityEntry[] }
1393
- listDeals: { params: CrmListDealsParams; result: DealListItem[] }
1394
- getDeal: { params: CrmGetDealParams; result: DealDetail | null }
1395
- getDealByEmail: { params: CrmGetDealByEmailParams; result: DealDetail | null }
1396
- createDealNote: { params: CrmDealNoteParams; result: AcqDealNote }
1397
- listDealNotes: { params: Omit<ListDealNotesParams, 'organizationId'>; result: AcqDealNote[] }
1398
- createDealTask: { params: CrmDealTaskParams; result: AcqDealTask }
1399
- listDealTasks: { params: Omit<ListDealTasksParams, 'organizationId'>; result: AcqDealTask[] }
1400
- listDealTasksDue: { params: CrmTaskDueParams; result: AcqDealTask[] }
1401
- completeDealTask: { params: Omit<CompleteDealTaskParams, 'organizationId'>; result: AcqDealTask }
1402
- recordActivity: { params: CrmRecordActivityParams; result: void }
1403
- deleteDeal: { params: CrmDeleteDealParams; result: void }
1501
+ export type CrmToolMap = {
1502
+ getRecentActivity: { params: CrmRecentActivityParams; result: RecentActivityEntry[] }
1503
+ listDeals: { params: CrmListDealsParams; result: DealListItem[] }
1504
+ getDeal: { params: CrmGetDealParams; result: DealDetail | null }
1505
+ getDealByEmail: { params: CrmGetDealByEmailParams; result: DealDetail | null }
1506
+ createDealNote: { params: CrmDealNoteParams; result: AcqDealNote }
1507
+ listDealNotes: { params: Omit<ListDealNotesParams, 'organizationId'>; result: AcqDealNote[] }
1508
+ createDealTask: { params: CrmDealTaskParams; result: AcqDealTask }
1509
+ listDealTasks: { params: Omit<ListDealTasksParams, 'organizationId'>; result: AcqDealTask[] }
1510
+ listDealTasksDue: { params: CrmTaskDueParams; result: AcqDealTask[] }
1511
+ completeDealTask: { params: Omit<CompleteDealTaskParams, 'organizationId'>; result: AcqDealTask }
1512
+ recordActivity: { params: CrmRecordActivityParams; result: void }
1513
+ deleteDeal: { params: CrmDeleteDealParams; result: void }
1404
1514
  }
1405
1515
  ```
1406
1516
 
@@ -1556,7 +1666,7 @@ export interface AcqList {
1556
1666
  scrapingConfig: ScrapingConfig
1557
1667
  icp: IcpRubric
1558
1668
  pipelineConfig: PipelineConfig
1559
- metadata: Record<string, unknown>
1669
+ metadata: AcqListMetadata
1560
1670
  launchedAt: Date | null
1561
1671
  completedAt: Date | null
1562
1672
  createdAt: Date
@@ -1642,6 +1752,7 @@ export interface AcqContact {
1642
1752
  /**
1643
1753
  * Live-scan aggregate telemetry for a single list, computed on demand from
1644
1754
  * the list junction tables and current contact deliverability state.
1755
+ * `stageCounts` are attempted counts from list-row processing_state.
1645
1756
  */
1646
1757
  export interface ListTelemetry {
1647
1758
  listId: string
@@ -1672,6 +1783,8 @@ export interface ListTelemetry {
1672
1783
 
1673
1784
  ```typescript
1674
1785
  export const ListStageCountsSchema = z.object({
1786
+ // Attempted counts by canonical lead-gen stage. The detailed status
1787
+ // distribution lives on ListProgress; telemetry keeps the overview payload small.
1675
1788
  stageCounts: z.object({
1676
1789
  populated: z.number().int(),
1677
1790
  extracted: z.number().int(),
@@ -1720,6 +1833,7 @@ export const CreateListRequestSchema = z
1720
1833
  name: z.string().trim().min(1).max(255),
1721
1834
  description: z.string().trim().nullable().optional(),
1722
1835
  status: ListStatusSchema.optional(),
1836
+ buildTemplateId: ProspectingBuildTemplateIdSchema.optional(),
1723
1837
  scrapingConfig: ScrapingConfigSchema.optional(),
1724
1838
  icp: IcpRubricSchema.optional(),
1725
1839
  pipelineConfig: PipelineConfigSchema.optional()
@@ -1734,11 +1848,24 @@ export const UpdateListRequestSchema = z
1734
1848
  .object({
1735
1849
  name: z.string().trim().min(1).max(255).optional(),
1736
1850
  description: z.string().trim().nullable().optional(),
1737
- batchIds: z.array(z.string()).optional()
1851
+ batchIds: z.array(z.string()).optional(),
1852
+ buildTemplateId: ProspectingBuildTemplateIdSchema.optional(),
1853
+ confirmBuildTemplateChange: z.literal(true).optional()
1738
1854
  })
1739
1855
  .strict()
1740
- .refine((data) => data.name !== undefined || data.description !== undefined || data.batchIds !== undefined, {
1741
- message: 'At least one field (name, description, or batchIds) must be provided'
1856
+ .refine(
1857
+ (data) =>
1858
+ data.name !== undefined ||
1859
+ data.description !== undefined ||
1860
+ data.batchIds !== undefined ||
1861
+ data.buildTemplateId !== undefined,
1862
+ {
1863
+ message: 'At least one field (name, description, batchIds, or buildTemplateId) must be provided'
1864
+ }
1865
+ )
1866
+ .refine((data) => data.buildTemplateId === undefined || data.confirmBuildTemplateChange === true, {
1867
+ message: 'confirmBuildTemplateChange must be true when changing buildTemplateId',
1868
+ path: ['confirmBuildTemplateChange']
1742
1869
  })
1743
1870
  ```
1744
1871
 
@@ -1815,12 +1942,11 @@ export const AcqListResponseSchema = z.object({
1815
1942
  organizationId: z.string(),
1816
1943
  name: z.string(),
1817
1944
  description: z.string().nullable(),
1818
- type: z.string(),
1819
1945
  batchIds: z.array(z.string()),
1820
1946
  instantlyCampaignId: z.string().nullable(),
1821
1947
  /** Lifecycle status (draft | enriching | launched | closing | archived). */
1822
1948
  status: ListStatusSchema,
1823
- metadata: z.record(z.string(), z.unknown()),
1949
+ metadata: AcqListMetadataSchema,
1824
1950
  launchedAt: z.string().nullable(),
1825
1951
  completedAt: z.string().nullable(),
1826
1952
  createdAt: z.string(),
@@ -2354,6 +2480,10 @@ export const AcqListSchemas = {
2354
2480
  IcpRubric: IcpRubricSchema,
2355
2481
  PipelineConfig: PipelineConfigSchema,
2356
2482
  PipelineStage: PipelineStageSchema,
2483
+ BuildPlanSnapshot: BuildPlanSnapshotSchema,
2484
+ BuildPlanSnapshotStep: BuildPlanSnapshotStepSchema,
2485
+ AcqListMetadata: AcqListMetadataSchema,
2486
+ ProcessingStageStatus: ProcessingStageStatusSchema,
2357
2487
  ListStageCounts: ListStageCountsSchema,
2358
2488
  ListTelemetry: ListTelemetrySchema,
2359
2489
 
@@ -2449,134 +2579,134 @@ export const StatefulSchema = z.object({
2449
2579
  ### `StatefulStateDefinition`
2450
2580
 
2451
2581
  ```typescript
2452
- /** One state within a stage — minimal shape: key + display label. */
2453
- export interface StatefulStateDefinition {
2454
- /** Matches state_key values written by workflow steps. */
2455
- stateKey: string
2456
- label: string
2582
+ /** One state within a stage — minimal shape: key + display label. */
2583
+ export interface StatefulStateDefinition {
2584
+ /** Matches state_key values written by workflow steps. */
2585
+ stateKey: string
2586
+ label: string
2457
2587
  }
2458
2588
  ```
2459
2589
 
2460
2590
  ### `StatefulStageDefinition`
2461
2591
 
2462
2592
  ```typescript
2463
- /** One stage within a pipeline — has a stage_key and an ordered list of valid states. */
2464
- export interface StatefulStageDefinition {
2465
- /** Matches stage_key values written by workflow steps. */
2466
- stageKey: string
2467
- label: string
2468
- states: StatefulStateDefinition[]
2593
+ /** One stage within a pipeline — has a stage_key and an ordered list of valid states. */
2594
+ export interface StatefulStageDefinition {
2595
+ /** Matches stage_key values written by workflow steps. */
2596
+ stageKey: string
2597
+ label: string
2598
+ states: StatefulStateDefinition[]
2469
2599
  }
2470
2600
  ```
2471
2601
 
2472
2602
  ### `StatefulPipelineDefinition`
2473
2603
 
2474
2604
  ```typescript
2475
- /**
2476
- * Pipeline definition for a single entity participating in the Stateful trait.
2477
- * Parallel to acq_deals' pipeline_key concept but structured for lead-gen entities.
2478
- */
2479
- export interface StatefulPipelineDefinition {
2480
- /** Matches pipeline_key values in the database (e.g. 'lead-gen'). */
2481
- pipelineKey: string
2482
- label: string
2483
- /** Entity this pipeline applies to (e.g. 'acq.list', 'acq.list-member', 'acq.list-company'). */
2484
- entityKey: string
2485
- stages: StatefulStageDefinition[]
2605
+ /**
2606
+ * Pipeline definition for a single entity participating in the Stateful trait.
2607
+ * Parallel to acq_deals' pipeline_key concept but structured for lead-gen entities.
2608
+ */
2609
+ export interface StatefulPipelineDefinition {
2610
+ /** Matches pipeline_key values in the database (e.g. 'lead-gen'). */
2611
+ pipelineKey: string
2612
+ label: string
2613
+ /** Entity this pipeline applies to (e.g. 'acq.list', 'acq.list-member', 'acq.list-company'). */
2614
+ entityKey: string
2615
+ stages: StatefulStageDefinition[]
2486
2616
  }
2487
2617
  ```
2488
2618
 
2489
2619
  ### `ACQ_LIST_MEMBERS_LEAD_GEN_PIPELINE`
2490
2620
 
2491
2621
  ```typescript
2492
- /**
2493
- * Lead-gen pipeline definition for acq_list_members (contacts).
2494
- * Three stages matching the post-restructure sales subdomain tree.
2495
- *
2496
- * Note: members visit outreach and prospecting states depending on which
2497
- * workflow last processed them. stage_key is set per-transition by the workflow.
2498
- */
2499
- export const ACQ_LIST_MEMBERS_LEAD_GEN_PIPELINE: StatefulPipelineDefinition = {
2500
- pipelineKey: 'lead-gen',
2501
- label: 'Lead Generation',
2502
- entityKey: 'acq.list-member',
2503
- stages: [
2504
- {
2505
- stageKey: 'outreach',
2506
- label: 'Outreach',
2507
- states: [
2508
- PENDING_STATE,
2509
- { stateKey: 'personalized', label: 'Personalized' },
2510
- { stateKey: 'uploaded', label: 'Uploaded' },
2511
- { stateKey: 'interested', label: 'Interested' }
2512
- ]
2513
- },
2514
- {
2515
- stageKey: 'prospecting',
2516
- label: 'Prospecting',
2517
- states: [
2518
- PENDING_STATE,
2519
- { stateKey: 'discovered', label: 'Discovered' },
2520
- { stateKey: 'verified', label: 'Verified' }
2521
- ]
2522
- },
2523
- {
2524
- stageKey: 'qualification',
2525
- label: 'Qualification',
2526
- states: [PENDING_STATE]
2527
- }
2528
- ]
2622
+ /**
2623
+ * Lead-gen pipeline definition for acq_list_members (contacts).
2624
+ * Three stages matching the post-restructure sales subdomain tree.
2625
+ *
2626
+ * Note: members visit outreach and prospecting states depending on which
2627
+ * workflow last processed them. stage_key is set per-transition by the workflow.
2628
+ */
2629
+ export const ACQ_LIST_MEMBERS_LEAD_GEN_PIPELINE: StatefulPipelineDefinition = {
2630
+ pipelineKey: 'lead-gen',
2631
+ label: 'Lead Generation',
2632
+ entityKey: 'acq.list-member',
2633
+ stages: [
2634
+ {
2635
+ stageKey: 'outreach',
2636
+ label: 'Outreach',
2637
+ states: [
2638
+ PENDING_STATE,
2639
+ { stateKey: 'personalized', label: 'Personalized' },
2640
+ { stateKey: 'uploaded', label: 'Uploaded' },
2641
+ { stateKey: 'interested', label: 'Interested' }
2642
+ ]
2643
+ },
2644
+ {
2645
+ stageKey: 'prospecting',
2646
+ label: 'Prospecting',
2647
+ states: [
2648
+ PENDING_STATE,
2649
+ { stateKey: 'discovered', label: 'Discovered' },
2650
+ { stateKey: 'verified', label: 'Verified' }
2651
+ ]
2652
+ },
2653
+ {
2654
+ stageKey: 'qualification',
2655
+ label: 'Qualification',
2656
+ states: [PENDING_STATE]
2657
+ }
2658
+ ]
2529
2659
  }
2530
2660
  ```
2531
2661
 
2532
2662
  ### `ACQ_LIST_COMPANIES_LEAD_GEN_PIPELINE`
2533
2663
 
2534
2664
  ```typescript
2535
- /**
2536
- * Lead-gen pipeline definition for acq_list_companies.
2537
- * Three stages matching the post-restructure sales subdomain tree.
2538
- *
2539
- * Note: companies visit prospecting and qualification states depending on which
2540
- * workflow last processed them. stage_key is set per-transition by the workflow.
2541
- */
2542
- export const ACQ_LIST_COMPANIES_LEAD_GEN_PIPELINE: StatefulPipelineDefinition = {
2543
- pipelineKey: 'lead-gen',
2544
- label: 'Lead Generation',
2545
- entityKey: 'acq.list-company',
2546
- stages: [
2547
- {
2548
- stageKey: 'outreach',
2549
- label: 'Outreach',
2550
- states: [PENDING_STATE]
2551
- },
2552
- {
2553
- stageKey: 'prospecting',
2554
- label: 'Prospecting',
2555
- states: [
2556
- PENDING_STATE,
2557
- { stateKey: 'populated', label: 'Populated' },
2558
- { stateKey: 'extracted', label: 'Extracted' }
2559
- ]
2560
- },
2561
- {
2562
- stageKey: 'qualification',
2563
- label: 'Qualification',
2564
- states: [PENDING_STATE, { stateKey: 'qualified', label: 'Qualified' }]
2565
- }
2566
- ]
2665
+ /**
2666
+ * Lead-gen pipeline definition for acq_list_companies.
2667
+ * Three stages matching the post-restructure sales subdomain tree.
2668
+ *
2669
+ * Note: companies visit prospecting and qualification states depending on which
2670
+ * workflow last processed them. stage_key is set per-transition by the workflow.
2671
+ */
2672
+ export const ACQ_LIST_COMPANIES_LEAD_GEN_PIPELINE: StatefulPipelineDefinition = {
2673
+ pipelineKey: 'lead-gen',
2674
+ label: 'Lead Generation',
2675
+ entityKey: 'acq.list-company',
2676
+ stages: [
2677
+ {
2678
+ stageKey: 'outreach',
2679
+ label: 'Outreach',
2680
+ states: [PENDING_STATE]
2681
+ },
2682
+ {
2683
+ stageKey: 'prospecting',
2684
+ label: 'Prospecting',
2685
+ states: [
2686
+ PENDING_STATE,
2687
+ { stateKey: 'populated', label: 'Populated' },
2688
+ { stateKey: 'extracted', label: 'Extracted' }
2689
+ ]
2690
+ },
2691
+ {
2692
+ stageKey: 'qualification',
2693
+ label: 'Qualification',
2694
+ states: [PENDING_STATE, { stateKey: 'qualified', label: 'Qualified' }]
2695
+ }
2696
+ ]
2567
2697
  }
2568
2698
  ```
2569
2699
 
2570
2700
  ### `LEAD_GEN_PIPELINE_DEFINITIONS`
2571
2701
 
2572
2702
  ```typescript
2573
- /**
2574
- * All lead-gen pipeline definitions indexed by entity key.
2575
- * Use findPipeline() to locate a definition by pipeline_key within any of these arrays.
2576
- */
2577
- export const LEAD_GEN_PIPELINE_DEFINITIONS: Record<string, StatefulPipelineDefinition[]> = {
2578
- 'acq.list-member': [ACQ_LIST_MEMBERS_LEAD_GEN_PIPELINE],
2579
- 'acq.list-company': [ACQ_LIST_COMPANIES_LEAD_GEN_PIPELINE]
2703
+ /**
2704
+ * All lead-gen pipeline definitions indexed by entity key.
2705
+ * Use findPipeline() to locate a definition by pipeline_key within any of these arrays.
2706
+ */
2707
+ export const LEAD_GEN_PIPELINE_DEFINITIONS: Record<string, StatefulPipelineDefinition[]> = {
2708
+ 'acq.list-member': [ACQ_LIST_MEMBERS_LEAD_GEN_PIPELINE],
2709
+ 'acq.list-company': [ACQ_LIST_COMPANIES_LEAD_GEN_PIPELINE]
2580
2710
  }
2581
2711
  ```
2582
2712
 
@@ -2609,11 +2739,12 @@ export interface CreateListParams {
2609
2739
  description?: string
2610
2740
  type?: string
2611
2741
  batchIds?: string[]
2612
- instantlyCampaignId?: string
2613
- status?: ListStatus
2614
- metadata?: Record<string, unknown>
2615
- scrapingConfig?: ScrapingConfig
2616
- icp?: IcpRubric
2742
+ instantlyCampaignId?: string
2743
+ status?: ListStatus
2744
+ buildTemplateId?: string
2745
+ metadata?: Record<string, unknown>
2746
+ scrapingConfig?: ScrapingConfig
2747
+ icp?: IcpRubric
2617
2748
  pipelineConfig?: PipelineConfig
2618
2749
  }
2619
2750
  ```
@@ -2621,10 +2752,10 @@ export interface CreateListParams {
2621
2752
  ### `UpdateListParams`
2622
2753
 
2623
2754
  ```typescript
2624
- export interface UpdateListParams {
2625
- name?: string
2626
- description?: string
2627
- batchIds?: string[]
2755
+ export interface UpdateListParams {
2756
+ name?: string
2757
+ description?: string
2758
+ batchIds?: string[]
2628
2759
  }
2629
2760
  ```
2630
2761
 
@@ -2835,24 +2966,26 @@ export interface UpdateListConfigParams {
2835
2966
  ### `UpdateCompanyStageParams`
2836
2967
 
2837
2968
  ```typescript
2838
- export interface UpdateCompanyStageParams {
2839
- organizationId: string
2840
- listId: string
2841
- companyId: string
2842
- stage: string
2843
- executionId?: string
2969
+ export interface UpdateCompanyStageParams {
2970
+ organizationId: string
2971
+ listId: string
2972
+ companyId: string
2973
+ stage: string
2974
+ status?: ProcessingStageStatus
2975
+ executionId?: string
2844
2976
  }
2845
2977
  ```
2846
2978
 
2847
2979
  ### `UpdateContactStageParams`
2848
2980
 
2849
2981
  ```typescript
2850
- export interface UpdateContactStageParams {
2851
- organizationId: string
2852
- listId: string
2853
- contactId: string
2854
- stage: string
2855
- executionId?: string
2982
+ export interface UpdateContactStageParams {
2983
+ organizationId: string
2984
+ listId: string
2985
+ contactId: string
2986
+ stage: string
2987
+ status?: ProcessingStageStatus
2988
+ executionId?: string
2856
2989
  }
2857
2990
  ```
2858
2991
 
@@ -2976,157 +3109,159 @@ export interface BulkImportCompaniesResult {
2976
3109
  ### `LeadToolMap`
2977
3110
 
2978
3111
  ```typescript
2979
- export type LeadToolMap = {
2980
- // List operations
2981
- listLists: { params: Record<string, never>; result: AcqList[] }
2982
- createList: { params: Omit<CreateListParams, 'organizationId'>; result: AcqList }
2983
- updateList: { params: { id: string } & UpdateListParams; result: AcqList }
2984
- deleteList: { params: { id: string }; result: void }
2985
- addContactsToList: { params: Omit<AddContactsToListParams, 'organizationId'>; result: AddContactsToListResult }
2986
- updateCompanyStage: {
2987
- params: Omit<UpdateCompanyStageParams, 'organizationId'>
2988
- result: void
2989
- }
2990
- updateContactStage: {
2991
- params: Omit<UpdateContactStageParams, 'organizationId'>
2992
- result: void
2993
- }
2994
- // Company operations
2995
- createCompany: { params: Omit<CreateCompanyParams, 'organizationId'>; result: AcqCompany }
2996
- upsertCompany: { params: Omit<UpsertCompanyParams, 'organizationId'>; result: AcqCompany }
2997
- updateCompany: { params: { id: string } & UpdateCompanyParams; result: AcqCompany }
2998
- getCompany: { params: { id: string }; result: AcqCompany | null }
2999
- listCompanies: { params: CompanyFilters; result: AcqCompany[] }
3000
- deleteCompany: { params: { id: string }; result: void }
3001
- // Contact operations
3002
- createContact: { params: Omit<CreateContactParams, 'organizationId'>; result: AcqContact }
3003
- upsertContact: { params: Omit<UpsertContactParams, 'organizationId'>; result: AcqContact }
3004
- updateContact: { params: { id: string } & UpdateContactParams; result: AcqContact }
3005
- getContact: { params: { id: string }; result: AcqContact | null }
3006
- getContactByEmail: { params: { email: string }; result: AcqContact | null }
3007
- listContacts: {
3008
- params: ContactFilters & { limit?: number; offset?: number }
3009
- result: PaginatedResult<AcqContact>
3010
- }
3011
- deleteContact: { params: { id: string }; result: void }
3012
- bulkImportContacts: { params: Omit<BulkImportParams, 'organizationId'>; result: BulkImportResult }
3013
- bulkImportCompanies: {
3014
- params: Omit<BulkImportCompaniesParams, 'organizationId'>
3015
- result: BulkImportCompaniesResult
3016
- }
3017
- deactivateContactsByCompany: {
3018
- params: { companyId: string }
3019
- result: { deactivated: number }
3020
- }
3021
- // Deal operations
3022
- upsertDeal: { params: Omit<UpsertDealParams, 'organizationId'>; result: AcqDeal }
3023
- getDealByEmail: { params: { email: string }; result: AcqDeal | null }
3024
- getDealByEnvelopeId: { params: { envelopeId: string }; result: AcqDeal | null }
3025
- updateDealEnvelopeId: { params: { dealId: string; envelopeId: string }; result: AcqDeal | null }
3026
- getDealById: { params: Omit<GetDealByIdParams, 'organizationId'>; result: AcqDeal | null }
3027
- getContactById: { params: Omit<GetContactByIdParams, 'organizationId'>; result: AcqContact | null }
3028
- getCompanyById: { params: Omit<GetCompanyByIdParams, 'organizationId'>; result: AcqCompany | null }
3029
- // Deal-sync operations
3030
- updateDiscoveryData: { params: Omit<UpdateDiscoveryDataParams, 'organizationId'>; result: void }
3031
- updateProposalData: { params: Omit<UpdateProposalDataParams, 'organizationId'>; result: void }
3032
- markProposalSent: { params: Omit<MarkProposalSentParams, 'organizationId'>; result: void }
3033
- markProposalReviewed: { params: Omit<MarkProposalReviewedParams, 'organizationId'>; result: void }
3034
- updateCloseLostReason: { params: Omit<UpdateCloseLostReasonParams, 'organizationId'>; result: void }
3035
- updateFees: { params: Omit<UpdateFeesParams, 'organizationId'>; result: void }
3036
- transitionItem: { params: Omit<TransitionItemParams, 'organizationId'>; result: void }
3037
- setContactNurture: { params: Omit<SetContactNurtureParams, 'organizationId'>; result: void }
3038
- cancelSchedulesAndHitlByEmail: {
3039
- params: Omit<CancelSchedulesAndHitlByEmailParams, 'organizationId'>
3040
- result: { schedulesCancelled: number; hitlDeleted: number }
3041
- }
3042
- cancelHitlByDealId: { params: Omit<CancelHitlByDealIdParams, 'organizationId'>; result: { hitlDeleted: number } }
3043
- clearDealFields: { params: Omit<ClearDealFieldsParams, 'organizationId'>; result: void }
3044
- deleteDeal: { params: Omit<DeleteDealParams, 'organizationId'>; result: void }
3045
- recordDealActivity: {
3046
- params: Omit<RecordDealActivityParams, 'organizationId'>
3047
- result: void
3048
- }
3049
- // Deal note operations
3050
- createDealNote: {
3051
- params: Omit<CreateDealNoteParams, 'organizationId'>
3052
- result: AcqDealNote
3053
- }
3054
- listDealNotes: {
3055
- params: Omit<ListDealNotesParams, 'organizationId'>
3056
- result: AcqDealNote[]
3057
- }
3058
- // Deal task operations
3059
- createDealTask: {
3060
- params: Omit<CreateDealTaskParams, 'organizationId'>
3061
- result: AcqDealTask
3062
- }
3063
- listDealTasks: {
3064
- params: Omit<ListDealTasksParams, 'organizationId'>
3065
- result: AcqDealTask[]
3066
- }
3067
- listDealTasksDue: {
3068
- params: Omit<ListDealTasksDueParams, 'organizationId'>
3069
- result: AcqDealTask[]
3070
- }
3071
- completeDealTask: {
3072
- params: Omit<CompleteDealTaskParams, 'organizationId'>
3073
- result: AcqDealTask
3074
- }
3075
- // Deal query & analytics operations
3076
- listDeals: { params: DealFilters; result: AcqDeal[] }
3077
- getDealPipelineAnalytics: { params: { recentLimit?: number }; result: DealPipelineAnalytics }
3078
- // Enrichment data operations
3079
- mergeEnrichmentData: {
3080
- params: { id: string; table: 'acq_companies' | 'acq_contacts'; data: Record<string, unknown> }
3081
- result: void
3082
- }
3083
- // Social monitoring operations
3084
- upsertSocialPosts: {
3085
- params: { posts: Omit<UpsertSocialPostParams, 'organizationId'>[] }
3086
- result: UpsertSocialPostsResult
3087
- }
3088
- setDealStateKey: {
3089
- params: {
3090
- dealId: string
3091
- stateKey: string
3092
- }
3093
- result: { ok: true }
3094
- }
3095
- // CRM workflow helpers
3096
- transitionDeal: {
3097
- params: {
3098
- dealId: string
3099
- toStage: string
3100
- toState?: string
3101
- }
3102
- result: { deal: AcqDeal }
3103
- }
3104
- loadDeal: {
3105
- params: { dealId: string }
3106
- result: DealDetail | null
3107
- }
3112
+ export type LeadToolMap = {
3113
+ // List operations
3114
+ listLists: { params: Record<string, never>; result: AcqList[] }
3115
+ createList: { params: Omit<CreateListParams, 'organizationId'>; result: AcqList }
3116
+ updateList: { params: { id: string } & UpdateListParams; result: AcqList }
3117
+ deleteList: { params: { id: string }; result: void }
3118
+ addContactsToList: { params: Omit<AddContactsToListParams, 'organizationId'>; result: AddContactsToListResult }
3119
+ addCompaniesToList: { params: Omit<AddCompaniesToListParams, 'organizationId'>; result: AddCompaniesToListResult }
3120
+ updateCompanyStage: {
3121
+ params: Omit<UpdateCompanyStageParams, 'organizationId'>
3122
+ result: void
3123
+ }
3124
+ updateContactStage: {
3125
+ params: Omit<UpdateContactStageParams, 'organizationId'>
3126
+ result: void
3127
+ }
3128
+ // Company operations
3129
+ createCompany: { params: Omit<CreateCompanyParams, 'organizationId'>; result: AcqCompany }
3130
+ upsertCompany: { params: Omit<UpsertCompanyParams, 'organizationId'>; result: AcqCompany }
3131
+ updateCompany: { params: { id: string } & UpdateCompanyParams; result: AcqCompany }
3132
+ getCompany: { params: { id: string }; result: AcqCompany | null }
3133
+ listCompanies: { params: CompanyFilters; result: AcqCompany[] }
3134
+ deleteCompany: { params: { id: string }; result: void }
3135
+ // Contact operations
3136
+ createContact: { params: Omit<CreateContactParams, 'organizationId'>; result: AcqContact }
3137
+ upsertContact: { params: Omit<UpsertContactParams, 'organizationId'>; result: AcqContact }
3138
+ updateContact: { params: { id: string } & UpdateContactParams; result: AcqContact }
3139
+ getContact: { params: { id: string }; result: AcqContact | null }
3140
+ getContactByEmail: { params: { email: string }; result: AcqContact | null }
3141
+ listContacts: {
3142
+ params: ContactFilters & { limit?: number; offset?: number }
3143
+ result: PaginatedResult<AcqContact>
3144
+ }
3145
+ deleteContact: { params: { id: string }; result: void }
3146
+ bulkImportContacts: { params: Omit<BulkImportParams, 'organizationId'>; result: BulkImportResult }
3147
+ bulkImportCompanies: {
3148
+ params: Omit<BulkImportCompaniesParams, 'organizationId'>
3149
+ result: BulkImportCompaniesResult
3150
+ }
3151
+ deactivateContactsByCompany: {
3152
+ params: { companyId: string }
3153
+ result: { deactivated: number }
3154
+ }
3155
+ // Deal operations
3156
+ upsertDeal: { params: Omit<UpsertDealParams, 'organizationId'>; result: AcqDeal }
3157
+ getDealByEmail: { params: { email: string }; result: AcqDeal | null }
3158
+ getDealByEnvelopeId: { params: { envelopeId: string }; result: AcqDeal | null }
3159
+ updateDealEnvelopeId: { params: { dealId: string; envelopeId: string }; result: AcqDeal | null }
3160
+ getDealById: { params: Omit<GetDealByIdParams, 'organizationId'>; result: AcqDeal | null }
3161
+ getContactById: { params: Omit<GetContactByIdParams, 'organizationId'>; result: AcqContact | null }
3162
+ getCompanyById: { params: Omit<GetCompanyByIdParams, 'organizationId'>; result: AcqCompany | null }
3163
+ // Deal-sync operations
3164
+ updateDiscoveryData: { params: Omit<UpdateDiscoveryDataParams, 'organizationId'>; result: void }
3165
+ updateProposalData: { params: Omit<UpdateProposalDataParams, 'organizationId'>; result: void }
3166
+ markProposalSent: { params: Omit<MarkProposalSentParams, 'organizationId'>; result: void }
3167
+ markProposalReviewed: { params: Omit<MarkProposalReviewedParams, 'organizationId'>; result: void }
3168
+ updateCloseLostReason: { params: Omit<UpdateCloseLostReasonParams, 'organizationId'>; result: void }
3169
+ updateFees: { params: Omit<UpdateFeesParams, 'organizationId'>; result: void }
3170
+ cacheInstantlyThreadIds: { params: Omit<CacheInstantlyThreadIdsParams, 'organizationId'>; result: void }
3171
+ transitionItem: { params: Omit<TransitionItemParams, 'organizationId'>; result: void }
3172
+ setContactNurture: { params: Omit<SetContactNurtureParams, 'organizationId'>; result: void }
3173
+ cancelSchedulesAndHitlByEmail: {
3174
+ params: Omit<CancelSchedulesAndHitlByEmailParams, 'organizationId'>
3175
+ result: { schedulesCancelled: number; hitlDeleted: number }
3176
+ }
3177
+ cancelHitlByDealId: { params: Omit<CancelHitlByDealIdParams, 'organizationId'>; result: { hitlDeleted: number } }
3178
+ clearDealFields: { params: Omit<ClearDealFieldsParams, 'organizationId'>; result: void }
3179
+ deleteDeal: { params: Omit<DeleteDealParams, 'organizationId'>; result: void }
3180
+ recordDealActivity: {
3181
+ params: Omit<RecordDealActivityParams, 'organizationId'>
3182
+ result: void
3183
+ }
3184
+ // Deal note operations
3185
+ createDealNote: {
3186
+ params: Omit<CreateDealNoteParams, 'organizationId'>
3187
+ result: AcqDealNote
3188
+ }
3189
+ listDealNotes: {
3190
+ params: Omit<ListDealNotesParams, 'organizationId'>
3191
+ result: AcqDealNote[]
3192
+ }
3193
+ // Deal task operations
3194
+ createDealTask: {
3195
+ params: Omit<CreateDealTaskParams, 'organizationId'>
3196
+ result: AcqDealTask
3197
+ }
3198
+ listDealTasks: {
3199
+ params: Omit<ListDealTasksParams, 'organizationId'>
3200
+ result: AcqDealTask[]
3201
+ }
3202
+ listDealTasksDue: {
3203
+ params: Omit<ListDealTasksDueParams, 'organizationId'>
3204
+ result: AcqDealTask[]
3205
+ }
3206
+ completeDealTask: {
3207
+ params: Omit<CompleteDealTaskParams, 'organizationId'>
3208
+ result: AcqDealTask
3209
+ }
3210
+ // Deal query & analytics operations
3211
+ listDeals: { params: DealFilters; result: AcqDeal[] }
3212
+ getDealPipelineAnalytics: { params: { recentLimit?: number }; result: DealPipelineAnalytics }
3213
+ // Enrichment data operations
3214
+ mergeEnrichmentData: {
3215
+ params: { id: string; table: 'acq_companies' | 'acq_contacts'; data: Record<string, unknown> }
3216
+ result: void
3217
+ }
3218
+ // Social monitoring operations
3219
+ upsertSocialPosts: {
3220
+ params: { posts: Omit<UpsertSocialPostParams, 'organizationId'>[] }
3221
+ result: UpsertSocialPostsResult
3222
+ }
3223
+ setDealStateKey: {
3224
+ params: {
3225
+ dealId: string
3226
+ stateKey: string
3227
+ }
3228
+ result: { ok: true }
3229
+ }
3230
+ // CRM workflow helpers
3231
+ transitionDeal: {
3232
+ params: {
3233
+ dealId: string
3234
+ toStage: string
3235
+ toState?: string
3236
+ }
3237
+ result: { deal: AcqDeal }
3238
+ }
3239
+ loadDeal: {
3240
+ params: { dealId: string }
3241
+ result: DealDetail | null
3242
+ }
3108
3243
  }
3109
3244
  ```
3110
3245
 
3111
3246
  ### `ListToolMap`
3112
3247
 
3113
3248
  ```typescript
3114
- export type ListToolMap = {
3115
- getConfig: {
3116
- params: { listId: string }
3117
- result: { scrapingConfig: ScrapingConfig; icp: IcpRubric; pipelineConfig: PipelineConfig }
3118
- }
3119
- recordExecution: {
3120
- params: Omit<RecordListExecutionParams, 'organizationId'>
3121
- result: void
3122
- }
3123
- updateCompanyStage: {
3124
- params: Omit<UpdateCompanyStageParams, 'organizationId'>
3125
- result: void
3126
- }
3127
- updateContactStage: {
3128
- params: Omit<UpdateContactStageParams, 'organizationId'>
3129
- result: void
3130
- }
3249
+ export type ListToolMap = {
3250
+ getConfig: {
3251
+ params: { listId: string }
3252
+ result: { scrapingConfig: ScrapingConfig; icp: IcpRubric; pipelineConfig: PipelineConfig }
3253
+ }
3254
+ recordExecution: {
3255
+ params: Omit<RecordListExecutionParams, 'organizationId'>
3256
+ result: void
3257
+ }
3258
+ updateCompanyStage: {
3259
+ params: Omit<UpdateCompanyStageParams, 'organizationId'>
3260
+ result: void
3261
+ }
3262
+ updateContactStage: {
3263
+ params: Omit<UpdateContactStageParams, 'organizationId'>
3264
+ result: void
3265
+ }
3131
3266
  }
3132
3267
  ```