@elevasis/core 0.14.0 → 0.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.
Files changed (36) hide show
  1. package/dist/index.d.ts +60 -0
  2. package/dist/index.js +198 -1
  3. package/dist/organization-model/index.d.ts +60 -0
  4. package/dist/organization-model/index.js +198 -1
  5. package/dist/test-utils/index.d.ts +399 -363
  6. package/dist/test-utils/index.js +198 -1
  7. package/package.json +3 -3
  8. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +444 -309
  9. package/src/business/acquisition/activity-events.ts +12 -3
  10. package/src/business/acquisition/api-schemas.test.ts +315 -4
  11. package/src/business/acquisition/api-schemas.ts +140 -17
  12. package/src/business/acquisition/build-templates.ts +44 -0
  13. package/src/business/acquisition/crm-next-action.test.ts +262 -0
  14. package/src/business/acquisition/crm-next-action.ts +220 -0
  15. package/src/business/acquisition/crm-priority.test.ts +216 -0
  16. package/src/business/acquisition/crm-priority.ts +349 -0
  17. package/src/business/acquisition/crm-state-actions.test.ts +12 -21
  18. package/src/business/acquisition/deal-ownership.test.ts +351 -0
  19. package/src/business/acquisition/deal-ownership.ts +120 -0
  20. package/src/business/acquisition/derive-actions.test.ts +101 -37
  21. package/src/business/acquisition/derive-actions.ts +49 -24
  22. package/src/business/acquisition/index.ts +163 -149
  23. package/src/business/acquisition/types.ts +48 -4
  24. package/src/execution/engine/index.ts +4 -3
  25. package/src/execution/engine/tools/lead-service-types.ts +68 -51
  26. package/src/execution/engine/tools/platform/acquisition/list-tools.ts +6 -5
  27. package/src/execution/engine/tools/platform/acquisition/types.ts +3 -1
  28. package/src/execution/engine/tools/registry.ts +4 -3
  29. package/src/execution/engine/tools/tool-maps.ts +821 -816
  30. package/src/organization-model/domains/prospecting.ts +204 -1
  31. package/src/organization-model/domains/sales.test.ts +218 -0
  32. package/src/organization-model/domains/sales.ts +558 -366
  33. package/src/organization-model/types.ts +2 -2
  34. package/src/platform/constants/versions.ts +1 -1
  35. package/src/reference/_generated/contracts.md +444 -309
  36. package/src/supabase/database.types.ts +2978 -2958
@@ -18,10 +18,10 @@ import type {
18
18
  ScrapingConfig,
19
19
  IcpRubric,
20
20
  PipelineConfig,
21
- ListTelemetry,
22
- DealDetail
23
- } from '../../../business/acquisition/types'
24
- import type { ListProgress } from '../../../business/acquisition/api-schemas'
21
+ ListTelemetry,
22
+ DealDetail
23
+ } from '../../../business/acquisition/types'
24
+ import type { ListProgress, ProcessingStageStatus } from '../../../business/acquisition/api-schemas'
25
25
 
26
26
  export type {
27
27
  AcqList,
@@ -32,8 +32,9 @@ export type {
32
32
  ListStatus,
33
33
  ScrapingConfig,
34
34
  IcpRubric,
35
- PipelineConfig,
36
- ListTelemetry,
35
+ PipelineConfig,
36
+ ProcessingStageStatus,
37
+ ListTelemetry,
37
38
  DealDetail,
38
39
  ListProgress
39
40
  }
@@ -58,19 +59,20 @@ export interface CreateListParams {
58
59
  description?: string
59
60
  type?: string
60
61
  batchIds?: string[]
61
- instantlyCampaignId?: string
62
- status?: ListStatus
63
- metadata?: Record<string, unknown>
64
- scrapingConfig?: ScrapingConfig
65
- icp?: IcpRubric
62
+ instantlyCampaignId?: string
63
+ status?: ListStatus
64
+ buildTemplateId?: string
65
+ metadata?: Record<string, unknown>
66
+ scrapingConfig?: ScrapingConfig
67
+ icp?: IcpRubric
66
68
  pipelineConfig?: PipelineConfig
67
69
  }
68
70
 
69
- export interface UpdateListParams {
70
- name?: string
71
- description?: string
72
- batchIds?: string[]
73
- }
71
+ export interface UpdateListParams {
72
+ name?: string
73
+ description?: string
74
+ batchIds?: string[]
75
+ }
74
76
 
75
77
  export interface UpdateListStatusParams {
76
78
  organizationId: string
@@ -192,10 +194,14 @@ export interface UpsertDealParams {
192
194
  /** Deal origin: 'instantly', 'referral', 'inbound', 'manual' */
193
195
  sourceType?: 'instantly' | 'referral' | 'inbound' | 'manual'
194
196
  /** Optional discovery data JSONB to set on upsert */
195
- discoveryData?: unknown
196
- /** Optional proposal data JSONB to set on upsert */
197
- proposalData?: unknown
198
- }
197
+ discoveryData?: unknown
198
+ /** Optional proposal data JSONB to set on upsert */
199
+ proposalData?: unknown
200
+ /** Instantly email UUID used to hydrate the reply thread */
201
+ instantlyThreadUuid?: string
202
+ /** Instantly sender account for direction detection */
203
+ instantlyEmailAccount?: string
204
+ }
199
205
 
200
206
  export interface UpdateDiscoveryDataParams {
201
207
  organizationId: string
@@ -229,19 +235,26 @@ export interface UpdateCloseLostReasonParams {
229
235
  reason: string
230
236
  }
231
237
 
232
- export interface UpdateFeesParams {
233
- organizationId: string
234
- contactEmail?: string
235
- dealId?: string
236
- initialFee?: number
237
- monthlyFee?: number
238
- }
239
-
240
- export interface TransitionItemParams {
241
- organizationId: string
242
- dealId: string
243
- pipelineKey: string
244
- stageKey: string
238
+ export interface UpdateFeesParams {
239
+ organizationId: string
240
+ contactEmail?: string
241
+ dealId?: string
242
+ initialFee?: number
243
+ monthlyFee?: number
244
+ }
245
+
246
+ export interface CacheInstantlyThreadIdsParams {
247
+ organizationId: string
248
+ dealId: string
249
+ instantlyThreadUuid: string
250
+ instantlyEmailAccount: string
251
+ }
252
+
253
+ export interface TransitionItemParams {
254
+ organizationId: string
255
+ dealId: string
256
+ pipelineKey: string
257
+ stageKey: string
245
258
  stateKey?: string | null
246
259
  reason?: string
247
260
  expectedUpdatedAt?: string
@@ -501,21 +514,23 @@ export interface UpdateListConfigParams {
501
514
  pipelineConfig?: PipelineConfig
502
515
  }
503
516
 
504
- export interface UpdateCompanyStageParams {
505
- organizationId: string
506
- listId: string
507
- companyId: string
508
- stage: string
509
- executionId?: string
510
- }
511
-
512
- export interface UpdateContactStageParams {
513
- organizationId: string
514
- listId: string
515
- contactId: string
516
- stage: string
517
- executionId?: string
518
- }
517
+ export interface UpdateCompanyStageParams {
518
+ organizationId: string
519
+ listId: string
520
+ companyId: string
521
+ stage: string
522
+ status?: ProcessingStageStatus
523
+ executionId?: string
524
+ }
525
+
526
+ export interface UpdateContactStageParams {
527
+ organizationId: string
528
+ listId: string
529
+ contactId: string
530
+ stage: string
531
+ status?: ProcessingStageStatus
532
+ executionId?: string
533
+ }
519
534
 
520
535
  export interface AddCompaniesToListParams {
521
536
  organizationId: string
@@ -841,9 +856,11 @@ export interface ILeadService {
841
856
 
842
857
  updateCloseLostReason(params: UpdateCloseLostReasonParams): Promise<void>
843
858
 
844
- updateFees(params: UpdateFeesParams): Promise<void>
845
-
846
- transitionItem(params: TransitionItemParams): Promise<void>
859
+ updateFees(params: UpdateFeesParams): Promise<void>
860
+
861
+ cacheInstantlyThreadIds(params: CacheInstantlyThreadIdsParams): Promise<void>
862
+
863
+ transitionItem(params: TransitionItemParams): Promise<void>
847
864
 
848
865
  setContactNurture(params: SetContactNurtureParams): Promise<void>
849
866
 
@@ -38,13 +38,14 @@ export function createAcqListCreateTool(): Tool {
38
38
  if (!leadService) throw serviceUnavailable('LeadService')
39
39
  if (!executionContext?.organizationId) throw serviceUnavailable('ExecutionContext', { reason: 'organizationId required for multi-tenant isolation' })
40
40
 
41
- const typedInput = input as { name: string; description?: string }
41
+ const typedInput = input as { name: string; description?: string; buildTemplateId?: string }
42
42
 
43
43
  const result = await leadService.createList({
44
- organizationId: executionContext.organizationId,
45
- name: typedInput.name,
46
- description: typedInput.description
47
- })
44
+ organizationId: executionContext.organizationId,
45
+ name: typedInput.name,
46
+ description: typedInput.description,
47
+ buildTemplateId: typedInput.buildTemplateId
48
+ })
48
49
 
49
50
  return {
50
51
  id: result.id,
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod'
2
+ import { isProspectingBuildTemplateId } from '../../../../../business/acquisition/build-templates'
2
3
 
3
4
  // ============================================
4
5
  // LIST SCHEMAS
@@ -6,7 +7,8 @@ import { z } from 'zod'
6
7
 
7
8
  export const CreateListInputSchema = z.object({
8
9
  name: z.string().min(1),
9
- description: z.string().optional()
10
+ description: z.string().optional(),
11
+ buildTemplateId: z.string().refine(isProspectingBuildTemplateId).optional()
10
12
  })
11
13
 
12
14
  export const UpdateListInputSchema = z.object({
@@ -557,9 +557,10 @@ export {
557
557
  type UpdateProposalDataParams,
558
558
  type MarkProposalSentParams,
559
559
  type MarkProposalReviewedParams,
560
- type UpdateCloseLostReasonParams,
561
- type UpdateFeesParams,
562
- type TransitionItemParams,
560
+ type UpdateCloseLostReasonParams,
561
+ type UpdateFeesParams,
562
+ type CacheInstantlyThreadIdsParams,
563
+ type TransitionItemParams,
563
564
  type SetContactNurtureParams,
564
565
  type CancelSchedulesAndHitlByEmailParams,
565
566
  type CancelHitlByDealIdParams,