@elevasis/core 0.28.0 → 0.30.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/auth/index.d.ts +5289 -0
- package/dist/auth/index.js +595 -0
- package/dist/index.d.ts +11 -11
- package/dist/knowledge/index.d.ts +1 -1
- package/dist/organization-model/index.d.ts +11 -11
- package/dist/test-utils/index.d.ts +24 -1
- package/package.json +7 -3
- package/src/__tests__/publish.test.ts +8 -7
- package/src/auth/__tests__/access-key-coverage.test.ts +42 -0
- package/src/auth/__tests__/access-key-scan.ts +117 -0
- package/src/auth/__tests__/access-keys.test.ts +81 -0
- package/src/auth/__tests__/access-model.test.ts +257 -0
- package/src/auth/__tests__/access-test-fixtures.ts +50 -0
- package/src/auth/__tests__/key-catalog-drift.test.ts +33 -0
- package/src/auth/__tests__/platform-admin-bypass-parity.test.ts +67 -0
- package/src/auth/access-keys.ts +173 -0
- package/src/auth/access-model.ts +185 -0
- package/src/auth/index.ts +6 -2
- package/src/auth/multi-tenancy/memberships/membership.ts +2 -4
- package/src/auth/multi-tenancy/permissions.ts +1 -1
- package/src/auth/multi-tenancy/types.ts +3 -12
- 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/domains/prospecting.ts +2 -327
- package/src/organization-model/migration-helpers.ts +16 -12
- package/src/reference/_generated/contracts.md +352 -328
- package/src/reference/glossary.md +8 -6
- package/src/supabase/database.types.ts +13 -0
|
@@ -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
|
+
})
|
|
@@ -1,98 +1,87 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
+
}
|