@elevasis/core 0.27.0 → 0.29.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 +146 -89
- package/dist/index.js +116 -46
- package/dist/knowledge/index.d.ts +21 -21
- package/dist/organization-model/index.d.ts +146 -89
- package/dist/organization-model/index.js +116 -46
- package/dist/test-utils/index.d.ts +20 -17
- package/dist/test-utils/index.js +22 -20
- package/package.json +1 -1
- package/src/business/acquisition/api-schemas.test.ts +59 -8
- package/src/business/acquisition/api-schemas.ts +10 -5
- package/src/business/acquisition/build-templates.test.ts +187 -240
- package/src/business/acquisition/build-templates.ts +87 -98
- package/src/business/acquisition/types.ts +390 -389
- package/src/execution/engine/index.ts +6 -4
- package/src/execution/engine/tools/lead-service-types.ts +63 -34
- package/src/execution/engine/tools/platform/acquisition/types.ts +7 -8
- package/src/execution/engine/tools/registry.ts +6 -4
- package/src/execution/engine/tools/tool-maps.ts +23 -1
- 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/domains/actions.ts +13 -0
- 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/prospecting.ts +2 -327
- package/src/organization-model/domains/roles.ts +109 -96
- 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 +42 -0
- package/src/organization-model/migration-helpers.ts +16 -12
- package/src/organization-model/published.ts +27 -2
- package/src/platform/constants/versions.ts +1 -1
- package/src/reference/_generated/contracts.md +376 -352
- package/src/supabase/database.types.ts +3 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod'
|
|
2
2
|
import { UuidSchema, NonEmptyStringSchema } from '../../platform/utils/validation'
|
|
3
3
|
import { CredentialRequirementSchema, RecordColumnConfigSchema } from '../../organization-model/domains/prospecting'
|
|
4
|
-
import { isProspectingBuildTemplateId } from './build-templates'
|
|
5
4
|
export { CrmPriorityBucketKeySchema, CrmPriorityBucketOverrideSchema, CrmPriorityOverrideSchema } from './crm-priority'
|
|
6
5
|
export type { CrmPriorityBucketOverride, CrmPriorityOverride, ResolvedCrmPriorityRuleConfig } from './crm-priority'
|
|
7
6
|
|
|
@@ -508,12 +507,15 @@ export const PipelineStageSchema = z.object({
|
|
|
508
507
|
order: z.number().int().optional()
|
|
509
508
|
})
|
|
510
509
|
|
|
510
|
+
export const DataModeSchema = z.enum(['mock', 'live'])
|
|
511
|
+
|
|
511
512
|
/**
|
|
512
513
|
* Pipeline presentation contract stored in `acq_lists.pipeline_config` jsonb.
|
|
513
514
|
* `stages[].key` validates against the catalog; the rest is presentation only.
|
|
514
515
|
*/
|
|
515
516
|
export const PipelineConfigSchema = z.object({
|
|
516
|
-
stages: z.array(PipelineStageSchema).optional()
|
|
517
|
+
stages: z.array(PipelineStageSchema).optional(),
|
|
518
|
+
dataMode: DataModeSchema.optional()
|
|
517
519
|
})
|
|
518
520
|
|
|
519
521
|
export const BuildPlanSnapshotStepSchema = z
|
|
@@ -584,9 +586,10 @@ export const AcqListMetadataSchema = z
|
|
|
584
586
|
})
|
|
585
587
|
.catchall(z.unknown())
|
|
586
588
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
589
|
+
// Build-template IDs are tenant-owned OM catalog entries. Published core only
|
|
590
|
+
// validates the transport shape; API/services validate membership against the
|
|
591
|
+
// tenant's resolved Organization Model before creating or changing snapshots.
|
|
592
|
+
export const ProspectingBuildTemplateIdSchema = z.string().trim().min(1).max(100)
|
|
590
593
|
|
|
591
594
|
// ---------------------------------------------------------------------------
|
|
592
595
|
// List telemetry / progress schemas
|
|
@@ -1360,6 +1363,7 @@ export const AcqListSchemas = {
|
|
|
1360
1363
|
ScrapingConfig: ScrapingConfigSchema,
|
|
1361
1364
|
IcpRubric: IcpRubricSchema,
|
|
1362
1365
|
PipelineConfig: PipelineConfigSchema,
|
|
1366
|
+
DataMode: DataModeSchema,
|
|
1363
1367
|
PipelineStage: PipelineStageSchema,
|
|
1364
1368
|
BuildPlanSnapshot: BuildPlanSnapshotSchema,
|
|
1365
1369
|
BuildPlanSnapshotStep: BuildPlanSnapshotStepSchema,
|
|
@@ -1459,6 +1463,7 @@ export type ListStatus = z.infer<typeof ListStatusSchema>
|
|
|
1459
1463
|
export type ScrapingConfig = z.infer<typeof ScrapingConfigSchema>
|
|
1460
1464
|
export type IcpRubric = z.infer<typeof IcpRubricSchema>
|
|
1461
1465
|
export type PipelineStage = z.infer<typeof PipelineStageSchema>
|
|
1466
|
+
export type DataMode = z.infer<typeof DataModeSchema>
|
|
1462
1467
|
export type PipelineConfig = z.infer<typeof PipelineConfigSchema>
|
|
1463
1468
|
export type BuildPlanSnapshotStep = z.infer<typeof BuildPlanSnapshotStepSchema>
|
|
1464
1469
|
export type BuildPlanSnapshot = z.infer<typeof BuildPlanSnapshotSchema>
|
|
@@ -1,240 +1,187 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
createBuildPlanSnapshotFromTemplateId,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
it('
|
|
80
|
-
expect(
|
|
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
|
-
it('
|
|
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
|
-
expect(
|
|
180
|
-
expect(
|
|
181
|
-
})
|
|
182
|
-
|
|
183
|
-
it('
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
key: 'apollo',
|
|
189
|
-
provider: 'apollo',
|
|
190
|
-
credentialType: 'api-key-secret',
|
|
191
|
-
label: 'Apollo API key',
|
|
192
|
-
required: true,
|
|
193
|
-
selectionMode: 'single',
|
|
194
|
-
inputPath: 'credential'
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
expect(importApolloSearch?.credentialRequirements).toEqual([expectedRequirement])
|
|
198
|
-
expect(enrichDecisionMakers?.credentialRequirements).toEqual([expectedRequirement])
|
|
199
|
-
})
|
|
200
|
-
|
|
201
|
-
it('the final step (review-and-export) outputs export', () => {
|
|
202
|
-
const last = snapshot?.steps[snapshot.steps.length - 1]
|
|
203
|
-
expect(last?.id).toBe('review-and-export')
|
|
204
|
-
expect(last?.outputs).toContain('export')
|
|
205
|
-
})
|
|
206
|
-
|
|
207
|
-
it('preserves contact records metadata for the company-owned decision-maker step', () => {
|
|
208
|
-
const decisionMakers = snapshot?.steps.find((step) => step.id === 'enrich-decision-makers')
|
|
209
|
-
expect(decisionMakers).toMatchObject({
|
|
210
|
-
primaryEntity: 'company',
|
|
211
|
-
recordEntity: 'contact',
|
|
212
|
-
stageKey: 'decision-makers-enriched'
|
|
213
|
-
})
|
|
214
|
-
expect(decisionMakers?.recordColumns?.contact?.length).toBeGreaterThan(0)
|
|
215
|
-
})
|
|
216
|
-
|
|
217
|
-
it('steps with descriptions in the catalog include description in the snapshot', () => {
|
|
218
|
-
const withDesc = snapshot?.steps.filter((step) => step.description !== undefined) ?? []
|
|
219
|
-
expect(withDesc.length).toBeGreaterThan(0)
|
|
220
|
-
for (const step of withDesc) {
|
|
221
|
-
expect(typeof step.description).toBe('string')
|
|
222
|
-
expect(step.description!.length).toBeGreaterThan(0)
|
|
223
|
-
}
|
|
224
|
-
})
|
|
225
|
-
})
|
|
226
|
-
|
|
227
|
-
// ---------------------------------------------------------------------------
|
|
228
|
-
// Snapshot shape contract — applies to every valid template id
|
|
229
|
-
// ---------------------------------------------------------------------------
|
|
230
|
-
|
|
231
|
-
describe('createBuildPlanSnapshotFromTemplateId — shape contract for all templates', () => {
|
|
232
|
-
it('returns a snapshot for every id that isProspectingBuildTemplateId reports valid', () => {
|
|
233
|
-
for (const option of PROSPECTING_BUILD_TEMPLATE_OPTIONS) {
|
|
234
|
-
const snapshot = createBuildPlanSnapshotFromTemplateId(option.id)
|
|
235
|
-
expect(snapshot).not.toBeNull()
|
|
236
|
-
expect(snapshot?.templateId).toBe(option.id)
|
|
237
|
-
expect(snapshot?.steps.length).toBeGreaterThan(0)
|
|
238
|
-
}
|
|
239
|
-
})
|
|
240
|
-
})
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import type { ProspectingBuildTemplate } from '../../organization-model/domains/prospecting'
|
|
3
|
+
import {
|
|
4
|
+
createBuildPlanSnapshotFromTemplate,
|
|
5
|
+
createBuildPlanSnapshotFromTemplateId,
|
|
6
|
+
getProspectingBuildTemplateOptions,
|
|
7
|
+
isProspectingBuildTemplateId
|
|
8
|
+
} from './build-templates'
|
|
9
|
+
|
|
10
|
+
const templates: ProspectingBuildTemplate[] = [
|
|
11
|
+
{
|
|
12
|
+
id: 'source-and-qualify',
|
|
13
|
+
label: 'Source and Qualify',
|
|
14
|
+
description: 'Source companies, analyze websites, and qualify fit.',
|
|
15
|
+
steps: [
|
|
16
|
+
{
|
|
17
|
+
id: 'source-companies',
|
|
18
|
+
label: 'Companies found',
|
|
19
|
+
primaryEntity: 'company',
|
|
20
|
+
outputs: ['company'],
|
|
21
|
+
stageKey: 'populated',
|
|
22
|
+
dependencyMode: 'per-record-eligibility',
|
|
23
|
+
actionKey: 'lead-gen.company.source',
|
|
24
|
+
defaultBatchSize: 100,
|
|
25
|
+
maxBatchSize: 250,
|
|
26
|
+
recordColumns: {
|
|
27
|
+
company: [{ key: 'name', label: 'Company', path: 'company.name' }]
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: 'qualify-companies',
|
|
32
|
+
label: 'Companies qualified',
|
|
33
|
+
description: 'Score companies against the active ICP.',
|
|
34
|
+
primaryEntity: 'company',
|
|
35
|
+
outputs: ['company'],
|
|
36
|
+
stageKey: 'qualified',
|
|
37
|
+
dependsOn: ['source-companies'],
|
|
38
|
+
dependencyMode: 'per-record-eligibility',
|
|
39
|
+
actionKey: 'lead-gen.company.qualify',
|
|
40
|
+
defaultBatchSize: 50,
|
|
41
|
+
maxBatchSize: 100
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: 'export-ready',
|
|
47
|
+
label: 'Export Ready',
|
|
48
|
+
steps: [
|
|
49
|
+
{
|
|
50
|
+
id: 'review-and-export',
|
|
51
|
+
label: 'Reviewed and exported',
|
|
52
|
+
primaryEntity: 'company',
|
|
53
|
+
outputs: ['export'],
|
|
54
|
+
stageKey: 'uploaded',
|
|
55
|
+
recordsStageKey: 'uploaded',
|
|
56
|
+
recordSourceStageKey: 'qualified',
|
|
57
|
+
dependencyMode: 'per-record-eligibility',
|
|
58
|
+
actionKey: 'lead-gen.export.list',
|
|
59
|
+
defaultBatchSize: 25,
|
|
60
|
+
maxBatchSize: 100,
|
|
61
|
+
credentialRequirements: [
|
|
62
|
+
{
|
|
63
|
+
key: 'export',
|
|
64
|
+
provider: 'export-provider',
|
|
65
|
+
credentialType: 'api-key-secret',
|
|
66
|
+
label: 'Export API token',
|
|
67
|
+
required: true,
|
|
68
|
+
selectionMode: 'single',
|
|
69
|
+
inputPath: 'credential',
|
|
70
|
+
verifyOnRun: true
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
describe('getProspectingBuildTemplateOptions', () => {
|
|
79
|
+
it('projects option metadata from caller-supplied templates', () => {
|
|
80
|
+
expect(getProspectingBuildTemplateOptions(templates)).toEqual([
|
|
81
|
+
{
|
|
82
|
+
id: 'source-and-qualify',
|
|
83
|
+
label: 'Source and Qualify',
|
|
84
|
+
description: 'Source companies, analyze websites, and qualify fit.'
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: 'export-ready',
|
|
88
|
+
label: 'Export Ready',
|
|
89
|
+
description: undefined
|
|
90
|
+
}
|
|
91
|
+
])
|
|
92
|
+
})
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
describe('isProspectingBuildTemplateId', () => {
|
|
96
|
+
it('checks membership against caller-supplied templates', () => {
|
|
97
|
+
expect(isProspectingBuildTemplateId('source-and-qualify', templates)).toBe(true)
|
|
98
|
+
expect(isProspectingBuildTemplateId('not-a-template', templates)).toBe(false)
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
it('has no published default template catalog', () => {
|
|
102
|
+
expect(isProspectingBuildTemplateId('source-and-qualify')).toBe(false)
|
|
103
|
+
})
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
describe('createBuildPlanSnapshotFromTemplate', () => {
|
|
107
|
+
it('creates an immutable build-plan snapshot shape from a supplied template', () => {
|
|
108
|
+
const snapshot = createBuildPlanSnapshotFromTemplate(templates[0]!)
|
|
109
|
+
|
|
110
|
+
expect(snapshot).toMatchObject({
|
|
111
|
+
templateId: 'source-and-qualify',
|
|
112
|
+
templateLabel: 'Source and Qualify',
|
|
113
|
+
steps: [
|
|
114
|
+
{
|
|
115
|
+
id: 'source-companies',
|
|
116
|
+
label: 'Companies found',
|
|
117
|
+
primaryEntity: 'company',
|
|
118
|
+
outputs: ['company'],
|
|
119
|
+
stageKey: 'populated',
|
|
120
|
+
recordsStageKey: 'populated',
|
|
121
|
+
recordSourceStageKey: 'populated',
|
|
122
|
+
dependencyMode: 'per-record-eligibility',
|
|
123
|
+
actionKey: 'lead-gen.company.source',
|
|
124
|
+
defaultBatchSize: 100,
|
|
125
|
+
maxBatchSize: 250,
|
|
126
|
+
recordColumns: {
|
|
127
|
+
company: [{ key: 'name', label: 'Company', path: 'company.name' }]
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
id: 'qualify-companies',
|
|
132
|
+
dependsOn: ['source-companies'],
|
|
133
|
+
description: 'Score companies against the active ICP.'
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
})
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
it('copies array/object fields so subsequent snapshots are isolated', () => {
|
|
140
|
+
const snapshotA = createBuildPlanSnapshotFromTemplate(templates[0]!)
|
|
141
|
+
const snapshotB = createBuildPlanSnapshotFromTemplate(templates[0]!)
|
|
142
|
+
|
|
143
|
+
snapshotA.steps[0]?.outputs.push('export')
|
|
144
|
+
snapshotA.steps[0]?.recordColumns?.company?.push({ key: 'domain', label: 'Domain', path: 'company.domain' })
|
|
145
|
+
|
|
146
|
+
expect(snapshotB.steps[0]?.outputs).toEqual(['company'])
|
|
147
|
+
expect(snapshotB.steps[0]?.recordColumns?.company).toEqual([
|
|
148
|
+
{ key: 'name', label: 'Company', path: 'company.name' }
|
|
149
|
+
])
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
it('preserves credential requirements and explicit record stage fields', () => {
|
|
153
|
+
const snapshot = createBuildPlanSnapshotFromTemplate(templates[1]!)
|
|
154
|
+
|
|
155
|
+
expect(snapshot.steps[0]).toMatchObject({
|
|
156
|
+
id: 'review-and-export',
|
|
157
|
+
recordsStageKey: 'uploaded',
|
|
158
|
+
recordSourceStageKey: 'qualified',
|
|
159
|
+
credentialRequirements: [
|
|
160
|
+
{
|
|
161
|
+
key: 'export',
|
|
162
|
+
provider: 'export-provider',
|
|
163
|
+
credentialType: 'api-key-secret',
|
|
164
|
+
label: 'Export API token',
|
|
165
|
+
required: true,
|
|
166
|
+
selectionMode: 'single',
|
|
167
|
+
inputPath: 'credential',
|
|
168
|
+
verifyOnRun: true
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
})
|
|
172
|
+
})
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
describe('createBuildPlanSnapshotFromTemplateId', () => {
|
|
176
|
+
it('creates snapshots from caller-supplied template catalogs', () => {
|
|
177
|
+
const snapshot = createBuildPlanSnapshotFromTemplateId('export-ready', templates)
|
|
178
|
+
|
|
179
|
+
expect(snapshot?.templateId).toBe('export-ready')
|
|
180
|
+
expect(snapshot?.steps).toHaveLength(1)
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
it('returns null for unknown ids or when no template catalog is supplied', () => {
|
|
184
|
+
expect(createBuildPlanSnapshotFromTemplateId('not-a-template', templates)).toBeNull()
|
|
185
|
+
expect(createBuildPlanSnapshotFromTemplateId('source-and-qualify')).toBeNull()
|
|
186
|
+
})
|
|
187
|
+
})
|