@elevasis/core 0.28.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.
@@ -1,240 +1,187 @@
1
- import { describe, expect, it } from 'vitest'
2
- import {
3
- DEFAULT_PROSPECTING_BUILD_TEMPLATE_ID,
4
- PROSPECTING_BUILD_TEMPLATE_OPTIONS,
5
- createBuildPlanSnapshotFromTemplateId,
6
- isProspectingBuildTemplateId
7
- } from './build-templates'
8
-
9
- // ---------------------------------------------------------------------------
10
- // isProspectingBuildTemplateId
11
- // ---------------------------------------------------------------------------
12
-
13
- describe('isProspectingBuildTemplateId', () => {
14
- it('returns true for every id in PROSPECTING_BUILD_TEMPLATE_OPTIONS', () => {
15
- for (const option of PROSPECTING_BUILD_TEMPLATE_OPTIONS) {
16
- expect(isProspectingBuildTemplateId(option.id)).toBe(true)
17
- }
18
- })
19
-
20
- it('returns true for the known "local-services" template id', () => {
21
- expect(isProspectingBuildTemplateId('local-services')).toBe(true)
22
- })
23
-
24
- it('returns true for the known "dtc-subscription-apollo-clickup" template id', () => {
25
- expect(isProspectingBuildTemplateId('dtc-subscription-apollo-clickup')).toBe(true)
26
- })
27
-
28
- it('returns false for an unknown string', () => {
29
- expect(isProspectingBuildTemplateId('not-a-template')).toBe(false)
30
- })
31
-
32
- it('returns false for an empty string', () => {
33
- expect(isProspectingBuildTemplateId('')).toBe(false)
34
- })
35
-
36
- it('returns false for a partial id match', () => {
37
- expect(isProspectingBuildTemplateId('local')).toBe(false)
38
- expect(isProspectingBuildTemplateId('dtc-subscription')).toBe(false)
39
- })
40
-
41
- it('returns false for a whitespace-padded id', () => {
42
- expect(isProspectingBuildTemplateId(' local-services ')).toBe(false)
43
- })
44
-
45
- it('verifies PROSPECTING_BUILD_TEMPLATE_OPTIONS contains at least two entries', () => {
46
- expect(PROSPECTING_BUILD_TEMPLATE_OPTIONS.length).toBeGreaterThanOrEqual(2)
47
- })
48
-
49
- it('verifies DEFAULT_PROSPECTING_BUILD_TEMPLATE_ID is itself a valid template id', () => {
50
- expect(isProspectingBuildTemplateId(DEFAULT_PROSPECTING_BUILD_TEMPLATE_ID)).toBe(true)
51
- })
52
- })
53
-
54
- // ---------------------------------------------------------------------------
55
- // createBuildPlanSnapshotFromTemplateId — unknown id
56
- // ---------------------------------------------------------------------------
57
-
58
- describe('createBuildPlanSnapshotFromTemplateId — unknown id', () => {
59
- it('returns null for an unknown template id', () => {
60
- expect(createBuildPlanSnapshotFromTemplateId('not-a-template')).toBeNull()
61
- })
62
-
63
- it('returns null for an empty string', () => {
64
- expect(createBuildPlanSnapshotFromTemplateId('')).toBeNull()
65
- })
66
- })
67
-
68
- // ---------------------------------------------------------------------------
69
- // createBuildPlanSnapshotFromTemplateId — "local-services"
70
- // ---------------------------------------------------------------------------
71
-
72
- describe('createBuildPlanSnapshotFromTemplateId — "local-services"', () => {
73
- const snapshot = createBuildPlanSnapshotFromTemplateId('local-services')
74
-
75
- it('returns a non-null snapshot', () => {
76
- expect(snapshot).not.toBeNull()
77
- })
78
-
79
- it('preserves the template id in the snapshot', () => {
80
- expect(snapshot?.templateId).toBe('local-services')
81
- })
82
-
83
- it('includes a non-empty templateLabel', () => {
84
- expect(snapshot?.templateLabel).toBeTruthy()
85
- })
86
-
87
- it('produces a steps array with length matching the catalog (7 steps)', () => {
88
- expect(snapshot?.steps).toHaveLength(7)
89
- })
90
-
91
- it('every step has required fields: id, label, primaryEntity, outputs, stageKey, dependencyMode, actionKey', () => {
92
- for (const step of snapshot?.steps ?? []) {
93
- expect(step.id).toBeTruthy()
94
- expect(step.label).toBeTruthy()
95
- expect(['company', 'contact']).toContain(step.primaryEntity)
96
- expect(step.outputs.length).toBeGreaterThanOrEqual(1)
97
- expect(step.stageKey).toBeTruthy()
98
- expect(step.dependencyMode).toBe('per-record-eligibility')
99
- expect(step.actionKey).toBeTruthy()
100
- }
101
- })
102
-
103
- it('every step has positive defaultBatchSize and maxBatchSize', () => {
104
- for (const step of snapshot?.steps ?? []) {
105
- expect(step.defaultBatchSize).toBeGreaterThan(0)
106
- expect(step.maxBatchSize).toBeGreaterThanOrEqual(step.defaultBatchSize)
107
- }
108
- })
109
-
110
- it('steps with declared dependsOn in the catalog have dependsOn in the snapshot', () => {
111
- const withDeps = snapshot?.steps.filter((step) => step.dependsOn !== undefined) ?? []
112
- expect(withDeps.length).toBeGreaterThan(0)
113
- for (const step of withDeps) {
114
- expect(Array.isArray(step.dependsOn)).toBe(true)
115
- expect((step.dependsOn ?? []).length).toBeGreaterThan(0)
116
- }
117
- })
118
-
119
- it('the first step (source-companies) has no dependsOn', () => {
120
- const first = snapshot?.steps[0]
121
- expect(first?.id).toBe('source-companies')
122
- expect(first?.dependsOn).toBeUndefined()
123
- })
124
-
125
- it('outputs arrays are copies (mutation does not affect subsequent calls)', () => {
126
- const snapshotA = createBuildPlanSnapshotFromTemplateId('local-services')
127
- const snapshotB = createBuildPlanSnapshotFromTemplateId('local-services')
128
- snapshotA?.steps[0]?.outputs.push('export' as never)
129
- expect(snapshotB?.steps[0]?.outputs).not.toContain('export')
130
- })
131
- })
132
-
133
- // ---------------------------------------------------------------------------
134
- // createBuildPlanSnapshotFromTemplateId — "dtc-subscription-apollo-clickup"
135
- // ---------------------------------------------------------------------------
136
-
137
- describe('createBuildPlanSnapshotFromTemplateId — "dtc-subscription-apollo-clickup"', () => {
138
- const snapshot = createBuildPlanSnapshotFromTemplateId('dtc-subscription-apollo-clickup')
139
-
140
- it('returns a non-null snapshot', () => {
141
- expect(snapshot).not.toBeNull()
142
- })
143
-
144
- it('preserves the template id in the snapshot', () => {
145
- expect(snapshot?.templateId).toBe('dtc-subscription-apollo-clickup')
146
- })
147
-
148
- it('produces a steps array with length matching the catalog (6 steps)', () => {
149
- expect(snapshot?.steps).toHaveLength(6)
150
- })
151
-
152
- it('every step has required fields: id, label, primaryEntity, outputs, stageKey, dependencyMode, actionKey', () => {
153
- for (const step of snapshot?.steps ?? []) {
154
- expect(step.id).toBeTruthy()
155
- expect(step.label).toBeTruthy()
156
- expect(['company', 'contact']).toContain(step.primaryEntity)
157
- expect(step.outputs.length).toBeGreaterThanOrEqual(1)
158
- expect(step.stageKey).toBeTruthy()
159
- expect(step.dependencyMode).toBe('per-record-eligibility')
160
- expect(step.actionKey).toBeTruthy()
161
- }
162
- })
163
-
164
- it('every step has positive defaultBatchSize and maxBatchSize', () => {
165
- for (const step of snapshot?.steps ?? []) {
166
- expect(step.defaultBatchSize).toBeGreaterThan(0)
167
- expect(step.maxBatchSize).toBeGreaterThanOrEqual(step.defaultBatchSize)
168
- }
169
- })
170
-
171
- it('the first step (import-apollo-search) has no dependsOn', () => {
172
- const first = snapshot?.steps[0]
173
- expect(first?.id).toBe('import-apollo-search')
174
- expect(first?.dependsOn).toBeUndefined()
175
- })
176
-
177
- it('the first step outputs both company and contact', () => {
178
- const first = snapshot?.steps[0]
179
- expect(first?.outputs).toContain('company')
180
- expect(first?.outputs).toContain('contact')
181
- })
182
-
183
- it('preserves Apollo credential requirements for source import and decision-maker enrichment', () => {
184
- const importApolloSearch = snapshot?.steps.find((step) => step.id === 'import-apollo-search')
185
- const enrichDecisionMakers = snapshot?.steps.find((step) => step.id === 'enrich-decision-makers')
186
-
187
- const expectedRequirement = {
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
+ })
@@ -1,98 +1,87 @@
1
- // Phase 4: DEFAULT_ORGANIZATION_MODEL_PROSPECTING was deleted (compound domain removed per D8).
2
- // Build-template definitions are now sourced inline from PROSPECTING_STEPS, which retains
3
- // the step catalog. The template catalog (id, label, description, steps[]) is declared here
4
- // as a local constant — Wave 2 will author these as system.content entries on the canonical OM.
5
- import {
6
- PROSPECTING_STEPS,
7
- type CredentialRequirement,
8
- type ListBuilderStep,
9
- type RecordColumnConfig
10
- } from '../../organization-model/domains/prospecting'
11
- import type { BuildPlanSnapshot, BuildPlanSnapshotStep } from './types'
12
-
13
- interface BuildTemplateCatalogEntry {
14
- id: string
15
- label: string
16
- description?: string
17
- steps: ListBuilderStep[]
18
- }
19
-
20
- // Template catalog — mirrors the data that lived in DEFAULT_ORGANIZATION_MODEL_PROSPECTING.buildTemplates.
21
- // Wave 2 canonical OM will author these as (kind:'schema', type:'template') content nodes.
22
- const BUILD_TEMPLATE_CATALOG: BuildTemplateCatalogEntry[] = [
23
- {
24
- id: 'local-services',
25
- label: 'Local Services',
26
- description: 'Source, analyze, qualify, and personalize local service businesses for outreach.',
27
- steps: Object.values(PROSPECTING_STEPS.localServices)
28
- },
29
- {
30
- id: 'dtc-subscription-apollo-clickup',
31
- label: 'DTC Subscription (Apollo + ClickUp)',
32
- description:
33
- 'Import DTC brand leads from Apollo, crawl their websites, score fit, enrich contacts, and export via ClickUp.',
34
- steps: Object.values(PROSPECTING_STEPS.dtcApolloClickup)
35
- }
36
- ]
37
-
38
- export const DEFAULT_PROSPECTING_BUILD_TEMPLATE_ID = 'local-services'
39
-
40
- export const PROSPECTING_BUILD_TEMPLATE_OPTIONS = BUILD_TEMPLATE_CATALOG.map(({ id, label, description }) => ({
41
- id,
42
- label,
43
- description
44
- }))
45
-
46
- export function isProspectingBuildTemplateId(value: string): boolean {
47
- return PROSPECTING_BUILD_TEMPLATE_OPTIONS.some((template) => template.id === value)
48
- }
49
-
50
- export function createBuildPlanSnapshotFromTemplateId(templateId: string): BuildPlanSnapshot | null {
51
- const template = BUILD_TEMPLATE_CATALOG.find((item: BuildTemplateCatalogEntry) => item.id === templateId)
52
- if (!template) return null
53
-
54
- return {
55
- templateId: template.id,
56
- templateLabel: template.label,
57
- steps: template.steps.map((step: ListBuilderStep): BuildPlanSnapshotStep => {
58
- const snapshotStep: BuildPlanSnapshotStep = {
59
- id: step.id,
60
- label: step.label,
61
- primaryEntity: step.primaryEntity,
62
- outputs: [...step.outputs],
63
- stageKey: step.stageKey,
64
- recordsStageKey: step.recordsStageKey ?? step.stageKey,
65
- recordSourceStageKey: step.recordSourceStageKey ?? step.recordsStageKey ?? step.stageKey,
66
- dependencyMode: step.dependencyMode,
67
- actionKey: step.actionKey,
68
- defaultBatchSize: step.defaultBatchSize,
69
- maxBatchSize: step.maxBatchSize
70
- }
71
-
72
- if (step.description) snapshotStep.description = step.description
73
- if (step.recordEntity) snapshotStep.recordEntity = step.recordEntity
74
- if (step.dependsOn?.length) snapshotStep.dependsOn = [...step.dependsOn]
75
- if (step.credentialRequirements?.length) {
76
- snapshotStep.credentialRequirements = step.credentialRequirements.map((requirement: CredentialRequirement) => ({
77
- ...requirement
78
- }))
79
- }
80
- if (step.recordColumns) {
81
- snapshotStep.recordColumns = {
82
- ...(step.recordColumns.company
83
- ? {
84
- company: step.recordColumns.company.map((column: RecordColumnConfig) => ({ ...column }))
85
- }
86
- : {}),
87
- ...(step.recordColumns.contact
88
- ? {
89
- contact: step.recordColumns.contact.map((column: RecordColumnConfig) => ({ ...column }))
90
- }
91
- : {})
92
- }
93
- }
94
-
95
- return snapshotStep
96
- })
97
- }
98
- }
1
+ import type {
2
+ CredentialRequirement,
3
+ ListBuilderStep,
4
+ ProspectingBuildTemplate,
5
+ RecordColumnConfig
6
+ } from '../../organization-model/domains/prospecting'
7
+ import type { BuildPlanSnapshot, BuildPlanSnapshotStep } from './types'
8
+
9
+ export interface ProspectingBuildTemplateOption {
10
+ id: string
11
+ label: string
12
+ description?: string | undefined
13
+ }
14
+
15
+ export function getProspectingBuildTemplateOptions(
16
+ templates: readonly ProspectingBuildTemplate[]
17
+ ): ProspectingBuildTemplateOption[] {
18
+ return templates.map(({ id, label, description }) => ({
19
+ id,
20
+ label,
21
+ description
22
+ }))
23
+ }
24
+
25
+ export function isProspectingBuildTemplateId(
26
+ value: string,
27
+ templates: readonly ProspectingBuildTemplate[] = []
28
+ ): boolean {
29
+ return templates.some((template) => template.id === value)
30
+ }
31
+
32
+ export function createBuildPlanSnapshotFromTemplate(template: ProspectingBuildTemplate): BuildPlanSnapshot {
33
+ return {
34
+ templateId: template.id,
35
+ templateLabel: template.label,
36
+ steps: template.steps.map((step: ListBuilderStep): BuildPlanSnapshotStep => {
37
+ const snapshotStep: BuildPlanSnapshotStep = {
38
+ id: step.id,
39
+ label: step.label,
40
+ primaryEntity: step.primaryEntity,
41
+ outputs: [...step.outputs],
42
+ stageKey: step.stageKey,
43
+ recordsStageKey: step.recordsStageKey ?? step.stageKey,
44
+ recordSourceStageKey: step.recordSourceStageKey ?? step.recordsStageKey ?? step.stageKey,
45
+ dependencyMode: step.dependencyMode,
46
+ actionKey: step.actionKey,
47
+ defaultBatchSize: step.defaultBatchSize,
48
+ maxBatchSize: step.maxBatchSize
49
+ }
50
+
51
+ if (step.description) snapshotStep.description = step.description
52
+ if (step.recordEntity) snapshotStep.recordEntity = step.recordEntity
53
+ if (step.dependsOn?.length) snapshotStep.dependsOn = [...step.dependsOn]
54
+ if (step.credentialRequirements?.length) {
55
+ snapshotStep.credentialRequirements = step.credentialRequirements.map((requirement: CredentialRequirement) => ({
56
+ ...requirement
57
+ }))
58
+ }
59
+ if (step.recordColumns) {
60
+ snapshotStep.recordColumns = {
61
+ ...(step.recordColumns.company
62
+ ? {
63
+ company: step.recordColumns.company.map((column: RecordColumnConfig) => ({ ...column }))
64
+ }
65
+ : {}),
66
+ ...(step.recordColumns.contact
67
+ ? {
68
+ contact: step.recordColumns.contact.map((column: RecordColumnConfig) => ({ ...column }))
69
+ }
70
+ : {})
71
+ }
72
+ }
73
+
74
+ return snapshotStep
75
+ })
76
+ }
77
+ }
78
+
79
+ export function createBuildPlanSnapshotFromTemplateId(
80
+ templateId: string,
81
+ templates: readonly ProspectingBuildTemplate[] = []
82
+ ): BuildPlanSnapshot | null {
83
+ const template = templates.find((item) => item.id === templateId)
84
+ if (!template) return null
85
+
86
+ return createBuildPlanSnapshotFromTemplate(template)
87
+ }