@elevasis/core 0.20.0 → 0.22.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 +524 -6
- package/dist/index.js +417 -42
- package/dist/knowledge/index.d.ts +151 -1
- package/dist/organization-model/index.d.ts +524 -6
- package/dist/organization-model/index.js +417 -42
- package/dist/test-utils/index.d.ts +270 -1
- package/dist/test-utils/index.js +407 -41
- package/package.json +5 -5
- package/src/_gen/__tests__/__snapshots__/contracts.md.snap +501 -303
- package/src/auth/multi-tenancy/permissions.ts +20 -8
- package/src/business/README.md +2 -2
- package/src/business/acquisition/api-schemas.test.ts +198 -0
- package/src/business/acquisition/api-schemas.ts +250 -9
- package/src/business/acquisition/build-templates.test.ts +28 -0
- package/src/business/acquisition/build-templates.ts +20 -8
- package/src/business/acquisition/index.ts +12 -0
- package/src/business/acquisition/types.ts +6 -1
- package/src/business/clients/api-schemas.test.ts +115 -0
- package/src/business/clients/api-schemas.ts +158 -0
- package/src/business/clients/index.ts +1 -0
- package/src/business/deals/api-schemas.ts +8 -0
- package/src/business/index.ts +5 -2
- package/src/business/projects/types.ts +19 -0
- package/src/execution/engine/__tests__/fixtures/test-agents.ts +10 -8
- package/src/execution/engine/agent/core/__tests__/agent.test.ts +16 -12
- package/src/execution/engine/agent/core/__tests__/error-passthrough.test.ts +4 -3
- package/src/execution/engine/agent/core/types.ts +25 -15
- package/src/execution/engine/agent/index.ts +6 -4
- package/src/execution/engine/agent/reasoning/__tests__/request-builder.test.ts +24 -18
- package/src/execution/engine/index.ts +3 -0
- package/src/execution/engine/tools/integration/server/adapters/apify/apify-adapter.test.ts +55 -0
- package/src/execution/engine/tools/integration/server/adapters/apify/apify-adapter.ts +107 -41
- package/src/execution/engine/tools/integration/server/adapters/apollo/apollo-adapter.test.ts +48 -0
- package/src/execution/engine/tools/integration/server/adapters/apollo/apollo-adapter.ts +99 -0
- package/src/execution/engine/tools/integration/server/adapters/apollo/index.ts +1 -0
- package/src/execution/engine/tools/integration/server/adapters/clickup/clickup-adapter.test.ts +18 -0
- package/src/execution/engine/tools/integration/server/adapters/clickup/clickup-adapter.ts +194 -0
- package/src/execution/engine/tools/integration/server/adapters/clickup/index.ts +7 -0
- package/src/execution/engine/workflow/types.ts +7 -0
- package/src/integrations/credentials/api-schemas.ts +21 -2
- package/src/integrations/credentials/schemas.ts +200 -164
- package/src/organization-model/README.md +10 -3
- package/src/organization-model/__tests__/defaults.test.ts +6 -0
- package/src/organization-model/__tests__/domains/resources.test.ts +188 -0
- package/src/organization-model/__tests__/domains/roles.test.ts +402 -347
- package/src/organization-model/__tests__/domains/systems.test.ts +193 -0
- package/src/organization-model/__tests__/knowledge.test.ts +39 -0
- package/src/organization-model/__tests__/prospecting-ssot.test.ts +7 -4
- package/src/organization-model/__tests__/resolve.test.ts +1 -1
- package/src/organization-model/defaults.ts +24 -3
- package/src/organization-model/domains/knowledge.ts +3 -2
- package/src/organization-model/domains/prospecting.ts +182 -25
- package/src/organization-model/domains/resources.ts +88 -0
- package/src/organization-model/domains/roles.ts +93 -55
- package/src/organization-model/domains/sales.ts +24 -3
- package/src/organization-model/domains/systems.ts +46 -0
- package/src/organization-model/icons.ts +1 -0
- package/src/organization-model/index.ts +2 -0
- package/src/organization-model/organization-model.mdx +33 -14
- package/src/organization-model/published.ts +52 -1
- package/src/organization-model/schema.ts +121 -0
- package/src/organization-model/types.ts +46 -1
- package/src/platform/api/types.ts +38 -35
- package/src/platform/constants/versions.ts +1 -1
- package/src/platform/registry/__tests__/resource-registry.test.ts +2051 -2005
- package/src/platform/registry/__tests__/validation.test.ts +1343 -1086
- package/src/platform/registry/index.ts +14 -0
- package/src/platform/registry/resource-registry.ts +40 -2
- package/src/platform/registry/serialization.ts +241 -202
- package/src/platform/registry/serialized-types.ts +1 -0
- package/src/platform/registry/types.ts +411 -361
- package/src/platform/registry/validation.ts +743 -513
- package/src/projects/api-schemas.ts +290 -267
- package/src/reference/_generated/contracts.md +501 -303
- package/src/reference/glossary.md +8 -3
- package/src/server.ts +2 -0
- package/src/supabase/database.types.ts +121 -0
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod'
|
|
2
2
|
import { UuidSchema, NonEmptyStringSchema } from '../../platform/utils/validation'
|
|
3
3
|
import { CRM_PIPELINE_DEFINITION, LEAD_GEN_STAGE_CATALOG } from '../../organization-model/domains/sales'
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
CAPABILITY_REGISTRY,
|
|
6
|
+
CredentialRequirementSchema,
|
|
7
|
+
RecordColumnConfigSchema
|
|
8
|
+
} from '../../organization-model/domains/prospecting'
|
|
5
9
|
import { isProspectingBuildTemplateId } from './build-templates'
|
|
6
10
|
export { CrmPriorityBucketKeySchema, CrmPriorityBucketOverrideSchema, CrmPriorityOverrideSchema } from './crm-priority'
|
|
7
11
|
export type { CrmPriorityBucketOverride, CrmPriorityOverride, ResolvedCrmPriorityRuleConfig } from './crm-priority'
|
|
@@ -80,6 +84,9 @@ export const DealTaskIdParamsSchema = z.object({
|
|
|
80
84
|
export const ListDealsQuerySchema = z
|
|
81
85
|
.object({
|
|
82
86
|
stage: DealStageSchema.optional(),
|
|
87
|
+
list: UuidSchema.optional(),
|
|
88
|
+
batch: z.string().trim().min(1).max(255).optional(),
|
|
89
|
+
staleSince: z.string().datetime().optional(),
|
|
83
90
|
search: z.string().optional(),
|
|
84
91
|
limit: z.coerce.number().int().positive().default(50),
|
|
85
92
|
offset: z.coerce.number().int().min(0).default(0)
|
|
@@ -211,6 +218,7 @@ export const DealListItemSchema = z.object({
|
|
|
211
218
|
// acq_deals columns
|
|
212
219
|
id: z.string(),
|
|
213
220
|
organization_id: z.string(),
|
|
221
|
+
client_id: z.string().nullable().optional(),
|
|
214
222
|
contact_id: z.string().nullable(),
|
|
215
223
|
contact_email: z.string(),
|
|
216
224
|
pipeline_key: z.string(),
|
|
@@ -300,12 +308,39 @@ export const DealConversationSchema = z.object({
|
|
|
300
308
|
messages: z.array(ConversationMessageSchema)
|
|
301
309
|
})
|
|
302
310
|
|
|
311
|
+
export const DealLineageListRefSchema = z.object({
|
|
312
|
+
id: z.string(),
|
|
313
|
+
name: z.string(),
|
|
314
|
+
status: z.string()
|
|
315
|
+
})
|
|
316
|
+
|
|
317
|
+
export const DealLineageProjectRefSchema = z.object({
|
|
318
|
+
id: z.string(),
|
|
319
|
+
name: z.string(),
|
|
320
|
+
kind: z.string(),
|
|
321
|
+
status: z.string(),
|
|
322
|
+
updatedAt: z.string()
|
|
323
|
+
})
|
|
324
|
+
|
|
325
|
+
export const DealLineageClientRefSchema = z.object({
|
|
326
|
+
id: z.string(),
|
|
327
|
+
name: z.string(),
|
|
328
|
+
status: z.string()
|
|
329
|
+
})
|
|
330
|
+
|
|
331
|
+
export const DealLineageSchema = z.object({
|
|
332
|
+
list: DealLineageListRefSchema.nullable(),
|
|
333
|
+
projects: z.array(DealLineageProjectRefSchema),
|
|
334
|
+
client: DealLineageClientRefSchema.nullable()
|
|
335
|
+
})
|
|
336
|
+
|
|
303
337
|
/**
|
|
304
338
|
* Deal detail shape — currently the same as a list item (full joined record).
|
|
305
339
|
* Additive fields keep existing DealListItem callers compatible.
|
|
306
340
|
*/
|
|
307
341
|
export const DealDetailResponseSchema = DealListItemSchema.extend({
|
|
308
|
-
conversation: DealConversationSchema
|
|
342
|
+
conversation: DealConversationSchema,
|
|
343
|
+
lineage: DealLineageSchema.optional()
|
|
309
344
|
})
|
|
310
345
|
|
|
311
346
|
/**
|
|
@@ -378,6 +413,10 @@ export const DealSchemas = {
|
|
|
378
413
|
DealSummaryResponse: DealSummaryResponseSchema,
|
|
379
414
|
DealLookupResponse: DealLookupResponseSchema,
|
|
380
415
|
ConversationMessage: ConversationMessageSchema,
|
|
416
|
+
DealLineageListRef: DealLineageListRefSchema,
|
|
417
|
+
DealLineageProjectRef: DealLineageProjectRefSchema,
|
|
418
|
+
DealLineageClientRef: DealLineageClientRefSchema,
|
|
419
|
+
DealLineage: DealLineageSchema,
|
|
381
420
|
DealDetailResponse: DealDetailResponseSchema,
|
|
382
421
|
DealNoteResponse: DealNoteResponseSchema,
|
|
383
422
|
DealNoteListResponse: DealNoteListResponseSchema,
|
|
@@ -411,6 +450,10 @@ export type DealSummaryResponse = z.infer<typeof DealSummaryResponseSchema>
|
|
|
411
450
|
export type DealLookupItem = z.infer<typeof DealLookupItemSchema>
|
|
412
451
|
export type DealLookupResponse = z.infer<typeof DealLookupResponseSchema>
|
|
413
452
|
export type ConversationMessage = z.infer<typeof ConversationMessageSchema>
|
|
453
|
+
export type DealLineageListRef = z.infer<typeof DealLineageListRefSchema>
|
|
454
|
+
export type DealLineageProjectRef = z.infer<typeof DealLineageProjectRefSchema>
|
|
455
|
+
export type DealLineageClientRef = z.infer<typeof DealLineageClientRefSchema>
|
|
456
|
+
export type DealLineage = z.infer<typeof DealLineageSchema>
|
|
414
457
|
export type DealDetailResponse = z.infer<typeof DealDetailResponseSchema>
|
|
415
458
|
export type DealNoteResponse = z.infer<typeof DealNoteResponseSchema>
|
|
416
459
|
export type DealNoteListResponse = z.infer<typeof DealNoteListResponseSchema>
|
|
@@ -496,11 +539,21 @@ export const BuildPlanSnapshotStepSchema = z
|
|
|
496
539
|
primaryEntity: z.enum(['company', 'contact']),
|
|
497
540
|
outputs: z.array(z.enum(['company', 'contact', 'export'])).min(1),
|
|
498
541
|
stageKey: LeadGenStageKeySchema,
|
|
542
|
+
recordEntity: z.enum(['company', 'contact']).optional(),
|
|
543
|
+
recordsStageKey: LeadGenStageKeySchema.optional(),
|
|
544
|
+
recordSourceStageKey: LeadGenStageKeySchema.optional(),
|
|
499
545
|
dependsOn: z.array(z.string().trim().min(1).max(100)).optional(),
|
|
500
546
|
dependencyMode: z.literal('per-record-eligibility'),
|
|
501
547
|
capabilityKey: LeadGenCapabilityKeySchema,
|
|
502
548
|
defaultBatchSize: z.number().int().positive(),
|
|
503
|
-
maxBatchSize: z.number().int().positive()
|
|
549
|
+
maxBatchSize: z.number().int().positive(),
|
|
550
|
+
recordColumns: z
|
|
551
|
+
.object({
|
|
552
|
+
company: z.array(RecordColumnConfigSchema).optional(),
|
|
553
|
+
contact: z.array(RecordColumnConfigSchema).optional()
|
|
554
|
+
})
|
|
555
|
+
.optional(),
|
|
556
|
+
credentialRequirements: z.array(CredentialRequirementSchema).optional()
|
|
504
557
|
})
|
|
505
558
|
.refine((step) => step.defaultBatchSize <= step.maxBatchSize, {
|
|
506
559
|
message: 'defaultBatchSize must be less than or equal to maxBatchSize',
|
|
@@ -718,6 +771,30 @@ export const ListTelemetryResponseSchema = ListTelemetrySchema
|
|
|
718
771
|
|
|
719
772
|
export const ListTelemetryListResponseSchema = z.array(ListTelemetrySchema)
|
|
720
773
|
|
|
774
|
+
const QueryBooleanSchema = z.preprocess((value) => {
|
|
775
|
+
if (value === 'true' || value === '1' || value === true) return true
|
|
776
|
+
if (value === 'false' || value === '0' || value === false) return false
|
|
777
|
+
return value
|
|
778
|
+
}, z.boolean())
|
|
779
|
+
|
|
780
|
+
export const ListReadQuerySchema = z
|
|
781
|
+
.object({
|
|
782
|
+
status: ListStatusSchema.optional(),
|
|
783
|
+
batch: z.string().trim().min(1).max(255).optional(),
|
|
784
|
+
vertical: z.string().trim().min(1).max(255).optional(),
|
|
785
|
+
limit: z.coerce.number().int().min(1).max(500).optional(),
|
|
786
|
+
offset: z.coerce.number().int().min(0).optional()
|
|
787
|
+
})
|
|
788
|
+
.strict()
|
|
789
|
+
|
|
790
|
+
export const GetListQuerySchema = z
|
|
791
|
+
.object({
|
|
792
|
+
includeDeals: QueryBooleanSchema.default(true),
|
|
793
|
+
includeProgress: QueryBooleanSchema.default(false),
|
|
794
|
+
dealLimit: z.coerce.number().int().min(0).max(100).default(25)
|
|
795
|
+
})
|
|
796
|
+
.strict()
|
|
797
|
+
|
|
721
798
|
/**
|
|
722
799
|
* Per-stage progress aggregate for a single pipeline stage.
|
|
723
800
|
* `attempted` counts terminal statuses, including success, no-result, skipped,
|
|
@@ -747,6 +824,47 @@ export const ListProgressResponseSchema = z.object({
|
|
|
747
824
|
byContactStage: z.record(z.string(), ListStageProgressSchema)
|
|
748
825
|
})
|
|
749
826
|
|
|
827
|
+
export const AcqListDealRefSchema = z.object({
|
|
828
|
+
id: z.string(),
|
|
829
|
+
contactEmail: z.string(),
|
|
830
|
+
stageKey: z.string().nullable(),
|
|
831
|
+
stateKey: z.string().nullable(),
|
|
832
|
+
sourceType: z.string().nullable(),
|
|
833
|
+
lastActivityAt: z.string()
|
|
834
|
+
})
|
|
835
|
+
|
|
836
|
+
export const AcqListLineageSchema = z.object({
|
|
837
|
+
deals: z.object({
|
|
838
|
+
total: z.number().int().min(0),
|
|
839
|
+
refs: z.array(AcqListDealRefSchema),
|
|
840
|
+
truncated: z.boolean()
|
|
841
|
+
})
|
|
842
|
+
})
|
|
843
|
+
|
|
844
|
+
export const AcqListDetailResponseSchema = AcqListResponseSchema.extend({
|
|
845
|
+
lineage: AcqListLineageSchema.optional(),
|
|
846
|
+
progress: ListProgressResponseSchema.optional()
|
|
847
|
+
})
|
|
848
|
+
|
|
849
|
+
export const AcqListStatusListItemSchema = z.object({
|
|
850
|
+
listId: z.string(),
|
|
851
|
+
name: z.string(),
|
|
852
|
+
status: ListStatusSchema,
|
|
853
|
+
totalCompanies: z.number().int().min(0),
|
|
854
|
+
totalContacts: z.number().int().min(0),
|
|
855
|
+
totalDeals: z.number().int().min(0),
|
|
856
|
+
createdAt: z.string()
|
|
857
|
+
})
|
|
858
|
+
|
|
859
|
+
export const AcqListStatusResponseSchema = z.object({
|
|
860
|
+
totalLists: z.number().int().min(0),
|
|
861
|
+
totalCompanies: z.number().int().min(0),
|
|
862
|
+
totalContacts: z.number().int().min(0),
|
|
863
|
+
totalDeals: z.number().int().min(0),
|
|
864
|
+
byStatus: z.record(z.string(), z.number().int().min(0)),
|
|
865
|
+
lists: z.array(AcqListStatusListItemSchema)
|
|
866
|
+
})
|
|
867
|
+
|
|
750
868
|
/**
|
|
751
869
|
* Row from acq_list_executions joined with the execution summary,
|
|
752
870
|
* shaped for the /lists/:id/executions response.
|
|
@@ -767,12 +885,6 @@ export const ListExecutionsResponseSchema = z.array(ListExecutionSummarySchema)
|
|
|
767
885
|
// Company / Contact API Schemas
|
|
768
886
|
// ---------------------------------------------------------------------------
|
|
769
887
|
|
|
770
|
-
const QueryBooleanSchema = z.preprocess((value) => {
|
|
771
|
-
if (value === 'true' || value === '1' || value === true) return true
|
|
772
|
-
if (value === 'false' || value === '0' || value === false) return false
|
|
773
|
-
return value
|
|
774
|
-
}, z.boolean())
|
|
775
|
-
|
|
776
888
|
export const AcqCompanyStatusSchema = z.enum(['active', 'invalid'])
|
|
777
889
|
export const AcqContactStatusSchema = z.enum(['active', 'invalid'])
|
|
778
890
|
export const AcqEmailValidSchema = z.enum(['VALID', 'INVALID', 'RISKY', 'UNKNOWN'])
|
|
@@ -817,6 +929,7 @@ export const ListContactsQuerySchema = z
|
|
|
817
929
|
export const CreateCompanyRequestSchema = z
|
|
818
930
|
.object({
|
|
819
931
|
name: z.string().trim().min(1).max(255),
|
|
932
|
+
clientId: UuidSchema.nullable().optional(),
|
|
820
933
|
domain: z.string().trim().min(1).max(255).optional(),
|
|
821
934
|
linkedinUrl: z.string().trim().url().optional(),
|
|
822
935
|
website: z.string().trim().url().optional(),
|
|
@@ -835,6 +948,7 @@ export const CreateCompanyRequestSchema = z
|
|
|
835
948
|
export const UpdateCompanyRequestSchema = z
|
|
836
949
|
.object({
|
|
837
950
|
name: z.string().trim().min(1).max(255).optional(),
|
|
951
|
+
clientId: UuidSchema.nullable().optional(),
|
|
838
952
|
domain: z.string().trim().min(1).max(255).optional(),
|
|
839
953
|
linkedinUrl: z.string().trim().url().optional(),
|
|
840
954
|
website: z.string().trim().url().optional(),
|
|
@@ -856,6 +970,7 @@ export const UpdateCompanyRequestSchema = z
|
|
|
856
970
|
.refine(
|
|
857
971
|
(data) =>
|
|
858
972
|
data.name !== undefined ||
|
|
973
|
+
data.clientId !== undefined ||
|
|
859
974
|
data.domain !== undefined ||
|
|
860
975
|
data.linkedinUrl !== undefined ||
|
|
861
976
|
data.website !== undefined ||
|
|
@@ -880,6 +995,7 @@ export const UpdateCompanyRequestSchema = z
|
|
|
880
995
|
export const CreateContactRequestSchema = z
|
|
881
996
|
.object({
|
|
882
997
|
email: z.string().trim().email(),
|
|
998
|
+
clientId: UuidSchema.nullable().optional(),
|
|
883
999
|
companyId: UuidSchema.optional(),
|
|
884
1000
|
firstName: z.string().trim().min(1).max(255).optional(),
|
|
885
1001
|
lastName: z.string().trim().min(1).max(255).optional(),
|
|
@@ -895,6 +1011,7 @@ export const CreateContactRequestSchema = z
|
|
|
895
1011
|
export const UpdateContactRequestSchema = z
|
|
896
1012
|
.object({
|
|
897
1013
|
companyId: UuidSchema.optional(),
|
|
1014
|
+
clientId: UuidSchema.nullable().optional(),
|
|
898
1015
|
emailValid: AcqEmailValidSchema.optional(),
|
|
899
1016
|
firstName: z.string().trim().min(1).max(255).optional(),
|
|
900
1017
|
lastName: z.string().trim().min(1).max(255).optional(),
|
|
@@ -912,6 +1029,7 @@ export const UpdateContactRequestSchema = z
|
|
|
912
1029
|
.refine(
|
|
913
1030
|
(data) =>
|
|
914
1031
|
data.companyId !== undefined ||
|
|
1032
|
+
data.clientId !== undefined ||
|
|
915
1033
|
data.emailValid !== undefined ||
|
|
916
1034
|
data.firstName !== undefined ||
|
|
917
1035
|
data.lastName !== undefined ||
|
|
@@ -932,6 +1050,7 @@ export const UpdateContactRequestSchema = z
|
|
|
932
1050
|
export const AcqCompanyResponseSchema = z.object({
|
|
933
1051
|
id: z.string(),
|
|
934
1052
|
organizationId: z.string(),
|
|
1053
|
+
clientId: z.string().nullable().optional(),
|
|
935
1054
|
name: z.string(),
|
|
936
1055
|
domain: z.string().nullable(),
|
|
937
1056
|
linkedinUrl: z.string().nullable(),
|
|
@@ -982,6 +1101,7 @@ export const AcqContactCompanySummarySchema = z.object({
|
|
|
982
1101
|
export const AcqContactResponseSchema = z.object({
|
|
983
1102
|
id: z.string(),
|
|
984
1103
|
organizationId: z.string(),
|
|
1104
|
+
clientId: z.string().nullable().optional(),
|
|
985
1105
|
companyId: z.string().nullable(),
|
|
986
1106
|
email: z.string(),
|
|
987
1107
|
emailValid: AcqEmailValidSchema.nullable(),
|
|
@@ -1063,6 +1183,33 @@ export const ListMembersQuerySchema = z
|
|
|
1063
1183
|
})
|
|
1064
1184
|
.strict()
|
|
1065
1185
|
|
|
1186
|
+
export const ListRecordEntitySchema = z.enum(['company', 'contact'])
|
|
1187
|
+
|
|
1188
|
+
export const ListRecordsQuerySchema = z
|
|
1189
|
+
.object({
|
|
1190
|
+
entity: ListRecordEntitySchema,
|
|
1191
|
+
stage: LeadGenStageKeySchema.optional(),
|
|
1192
|
+
limit: z.coerce.number().int().min(1).max(500).default(50),
|
|
1193
|
+
offset: z.coerce.number().int().min(0).default(0)
|
|
1194
|
+
})
|
|
1195
|
+
.strict()
|
|
1196
|
+
.superRefine((query, ctx) => {
|
|
1197
|
+
if (!query.stage) return
|
|
1198
|
+
|
|
1199
|
+
const stage = LEAD_GEN_STAGE_CATALOG[query.stage]
|
|
1200
|
+
const validEntity =
|
|
1201
|
+
stage?.entity === query.entity ||
|
|
1202
|
+
stage?.additionalEntities?.includes(query.entity) ||
|
|
1203
|
+
stage?.recordEntity === query.entity
|
|
1204
|
+
if (!validEntity) {
|
|
1205
|
+
ctx.addIssue({
|
|
1206
|
+
code: z.ZodIssueCode.custom,
|
|
1207
|
+
message: `stage "${query.stage}" is not valid for ${query.entity} records`,
|
|
1208
|
+
path: ['stage']
|
|
1209
|
+
})
|
|
1210
|
+
}
|
|
1211
|
+
})
|
|
1212
|
+
|
|
1066
1213
|
export const MemberIdParamsSchema = z.object({
|
|
1067
1214
|
memberId: UuidSchema
|
|
1068
1215
|
})
|
|
@@ -1095,6 +1242,77 @@ export const AcqListMembersResponseSchema = z.object({
|
|
|
1095
1242
|
members: z.array(AcqListMemberResponseSchema)
|
|
1096
1243
|
})
|
|
1097
1244
|
|
|
1245
|
+
export const AcqListRecordCompanySummarySchema = z.object({
|
|
1246
|
+
id: z.string(),
|
|
1247
|
+
name: z.string(),
|
|
1248
|
+
domain: z.string().nullable(),
|
|
1249
|
+
website: z.string().nullable(),
|
|
1250
|
+
linkedinUrl: z.string().nullable(),
|
|
1251
|
+
numEmployees: z.number().nullable(),
|
|
1252
|
+
foundedYear: z.number().nullable(),
|
|
1253
|
+
locationCity: z.string().nullable(),
|
|
1254
|
+
locationState: z.string().nullable(),
|
|
1255
|
+
category: z.string().nullable(),
|
|
1256
|
+
segment: z.string().nullable(),
|
|
1257
|
+
status: AcqCompanyStatusSchema,
|
|
1258
|
+
qualificationScore: z.number().nullable(),
|
|
1259
|
+
qualificationSignals: z.record(z.string(), z.unknown()).nullable(),
|
|
1260
|
+
qualificationRubricKey: z.string().nullable()
|
|
1261
|
+
})
|
|
1262
|
+
|
|
1263
|
+
export const AcqListRecordContactSummarySchema = z.object({
|
|
1264
|
+
id: z.string(),
|
|
1265
|
+
email: z.string(),
|
|
1266
|
+
firstName: z.string().nullable(),
|
|
1267
|
+
lastName: z.string().nullable(),
|
|
1268
|
+
title: z.string().nullable(),
|
|
1269
|
+
headline: z.string().nullable(),
|
|
1270
|
+
linkedinUrl: z.string().nullable(),
|
|
1271
|
+
companyId: z.string().nullable(),
|
|
1272
|
+
status: AcqContactStatusSchema,
|
|
1273
|
+
qualificationScore: z.number().nullable(),
|
|
1274
|
+
qualificationSignals: z.record(z.string(), z.unknown()).nullable(),
|
|
1275
|
+
qualificationRubricKey: z.string().nullable()
|
|
1276
|
+
})
|
|
1277
|
+
|
|
1278
|
+
const ListRecordBaseSchema = z.object({
|
|
1279
|
+
id: z.string(),
|
|
1280
|
+
listId: z.string(),
|
|
1281
|
+
pipelineKey: z.string(),
|
|
1282
|
+
stageKey: z.string(),
|
|
1283
|
+
stateKey: z.string(),
|
|
1284
|
+
activityLog: z.unknown(),
|
|
1285
|
+
addedAt: z.string(),
|
|
1286
|
+
addedBy: z.string().nullable(),
|
|
1287
|
+
sourceExecutionId: z.string().nullable(),
|
|
1288
|
+
processingState: z.record(z.string(), z.unknown()).nullable(),
|
|
1289
|
+
enrichmentData: z.record(z.string(), z.unknown()).nullable()
|
|
1290
|
+
})
|
|
1291
|
+
|
|
1292
|
+
export const AcqListCompanyRecordRowSchema = ListRecordBaseSchema.extend({
|
|
1293
|
+
entity: z.literal('company'),
|
|
1294
|
+
companyId: z.string(),
|
|
1295
|
+
company: AcqListRecordCompanySummarySchema.nullable()
|
|
1296
|
+
})
|
|
1297
|
+
|
|
1298
|
+
export const AcqListContactRecordRowSchema = ListRecordBaseSchema.extend({
|
|
1299
|
+
entity: z.literal('contact'),
|
|
1300
|
+
contactId: z.string(),
|
|
1301
|
+
contact: AcqListRecordContactSummarySchema.nullable()
|
|
1302
|
+
})
|
|
1303
|
+
|
|
1304
|
+
export const ListRecordRowSchema = z.discriminatedUnion('entity', [
|
|
1305
|
+
AcqListCompanyRecordRowSchema,
|
|
1306
|
+
AcqListContactRecordRowSchema
|
|
1307
|
+
])
|
|
1308
|
+
|
|
1309
|
+
export const ListRecordsResponseSchema = z.object({
|
|
1310
|
+
data: z.array(ListRecordRowSchema),
|
|
1311
|
+
total: z.number().int().min(0),
|
|
1312
|
+
limit: z.number().int().min(1),
|
|
1313
|
+
offset: z.number().int().min(0)
|
|
1314
|
+
})
|
|
1315
|
+
|
|
1098
1316
|
// ---------------------------------------------------------------------------
|
|
1099
1317
|
// Track B: List Companies API Schemas
|
|
1100
1318
|
// ---------------------------------------------------------------------------
|
|
@@ -1185,6 +1403,8 @@ export const AcqListSchemas = {
|
|
|
1185
1403
|
ListTelemetry: ListTelemetrySchema,
|
|
1186
1404
|
|
|
1187
1405
|
// Requests
|
|
1406
|
+
ListReadQuery: ListReadQuerySchema,
|
|
1407
|
+
GetListQuery: GetListQuerySchema,
|
|
1188
1408
|
CreateListRequest: CreateListRequestSchema,
|
|
1189
1409
|
UpdateListRequest: UpdateListRequestSchema,
|
|
1190
1410
|
UpdateListStatusRequest: UpdateListStatusRequestSchema,
|
|
@@ -1196,7 +1416,11 @@ export const AcqListSchemas = {
|
|
|
1196
1416
|
|
|
1197
1417
|
// Responses
|
|
1198
1418
|
AcqListResponse: AcqListResponseSchema,
|
|
1419
|
+
AcqListDetailResponse: AcqListDetailResponseSchema,
|
|
1199
1420
|
AcqListListResponse: AcqListListResponseSchema,
|
|
1421
|
+
AcqListDealRef: AcqListDealRefSchema,
|
|
1422
|
+
AcqListLineage: AcqListLineageSchema,
|
|
1423
|
+
AcqListStatusResponse: AcqListStatusResponseSchema,
|
|
1200
1424
|
ListTelemetryResponse: ListTelemetryResponseSchema,
|
|
1201
1425
|
ListTelemetryListResponse: ListTelemetryListResponseSchema,
|
|
1202
1426
|
ListExecutionsResponse: ListExecutionsResponseSchema,
|
|
@@ -1216,9 +1440,14 @@ export const AcqSubstrateSchemas = {
|
|
|
1216
1440
|
|
|
1217
1441
|
// List members
|
|
1218
1442
|
ListMembersQuery: ListMembersQuerySchema,
|
|
1443
|
+
ListRecordsQuery: ListRecordsQuerySchema,
|
|
1219
1444
|
MemberIdParams: MemberIdParamsSchema,
|
|
1220
1445
|
AcqListMemberResponse: AcqListMemberResponseSchema,
|
|
1221
1446
|
AcqListMembersResponse: AcqListMembersResponseSchema,
|
|
1447
|
+
AcqListCompanyRecordRow: AcqListCompanyRecordRowSchema,
|
|
1448
|
+
AcqListContactRecordRow: AcqListContactRecordRowSchema,
|
|
1449
|
+
ListRecordRow: ListRecordRowSchema,
|
|
1450
|
+
ListRecordsResponse: ListRecordsResponseSchema,
|
|
1222
1451
|
|
|
1223
1452
|
// List companies
|
|
1224
1453
|
ListCompanyIdParams: ListCompanyIdParamsSchema,
|
|
@@ -1242,10 +1471,16 @@ export type CreateArtifactRequest = z.infer<typeof CreateArtifactRequestSchema>
|
|
|
1242
1471
|
export type AcqArtifactResponse = z.infer<typeof AcqArtifactResponseSchema>
|
|
1243
1472
|
export type AcqArtifactListResponse = z.infer<typeof AcqArtifactListResponseSchema>
|
|
1244
1473
|
export type ListMembersQuery = z.infer<typeof ListMembersQuerySchema>
|
|
1474
|
+
export type ListRecordEntity = z.infer<typeof ListRecordEntitySchema>
|
|
1475
|
+
export type ListRecordsQuery = z.infer<typeof ListRecordsQuerySchema>
|
|
1245
1476
|
export type MemberIdParams = z.infer<typeof MemberIdParamsSchema>
|
|
1246
1477
|
export type AcqListMemberContactSummary = z.infer<typeof AcqListMemberContactSummarySchema>
|
|
1247
1478
|
export type AcqListMemberResponse = z.infer<typeof AcqListMemberResponseSchema>
|
|
1248
1479
|
export type AcqListMembersResponse = z.infer<typeof AcqListMembersResponseSchema>
|
|
1480
|
+
export type AcqListCompanyRecordRow = z.infer<typeof AcqListCompanyRecordRowSchema>
|
|
1481
|
+
export type AcqListContactRecordRow = z.infer<typeof AcqListContactRecordRowSchema>
|
|
1482
|
+
export type ListRecordRow = z.infer<typeof ListRecordRowSchema>
|
|
1483
|
+
export type ListRecordsResponse = z.infer<typeof ListRecordsResponseSchema>
|
|
1249
1484
|
export type ListCompanyIdParams = z.infer<typeof ListCompanyIdParamsSchema>
|
|
1250
1485
|
export type AcqListCompanyResponse = z.infer<typeof AcqListCompanyResponseSchema>
|
|
1251
1486
|
|
|
@@ -1264,6 +1499,8 @@ export type ProcessingStageStatus = z.infer<typeof ProcessingStageStatusSchema>
|
|
|
1264
1499
|
export type ListStageCountsInput = z.infer<typeof ListStageCountsSchema>['stageCounts']
|
|
1265
1500
|
export type ListTelemetryInput = z.infer<typeof ListTelemetrySchema>
|
|
1266
1501
|
export type ListIdParams = z.infer<typeof ListIdParamsSchema>
|
|
1502
|
+
export type ListReadQuery = z.infer<typeof ListReadQuerySchema>
|
|
1503
|
+
export type GetListQuery = z.infer<typeof GetListQuerySchema>
|
|
1267
1504
|
export type CreateListRequest = z.infer<typeof CreateListRequestSchema>
|
|
1268
1505
|
export type UpdateListRequest = z.infer<typeof UpdateListRequestSchema>
|
|
1269
1506
|
export type UpdateListStatusRequest = z.infer<typeof UpdateListStatusRequestSchema>
|
|
@@ -1273,7 +1510,11 @@ export type RemoveCompaniesFromListRequest = z.infer<typeof RemoveCompaniesFromL
|
|
|
1273
1510
|
export type AddContactsToListRequest = z.infer<typeof AddContactsToListRequestSchema>
|
|
1274
1511
|
export type RecordListExecutionRequest = z.infer<typeof RecordListExecutionRequestSchema>
|
|
1275
1512
|
export type AcqListResponse = z.infer<typeof AcqListResponseSchema>
|
|
1513
|
+
export type AcqListDetailResponse = z.infer<typeof AcqListDetailResponseSchema>
|
|
1276
1514
|
export type AcqListListResponse = z.infer<typeof AcqListListResponseSchema>
|
|
1515
|
+
export type AcqListDealRef = z.infer<typeof AcqListDealRefSchema>
|
|
1516
|
+
export type AcqListLineage = z.infer<typeof AcqListLineageSchema>
|
|
1517
|
+
export type AcqListStatusResponse = z.infer<typeof AcqListStatusResponseSchema>
|
|
1277
1518
|
export type ListTelemetryResponse = z.infer<typeof ListTelemetryResponseSchema>
|
|
1278
1519
|
export type ListTelemetryListResponse = z.infer<typeof ListTelemetryListResponseSchema>
|
|
1279
1520
|
export type ListExecutionSummaryInput = z.infer<typeof ListExecutionSummarySchema>
|
|
@@ -180,12 +180,40 @@ describe('createBuildPlanSnapshotFromTemplateId — "dtc-subscription-apollo-cli
|
|
|
180
180
|
expect(first?.outputs).toContain('contact')
|
|
181
181
|
})
|
|
182
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
|
+
|
|
183
201
|
it('the final step (review-and-export) outputs export', () => {
|
|
184
202
|
const last = snapshot?.steps[snapshot.steps.length - 1]
|
|
185
203
|
expect(last?.id).toBe('review-and-export')
|
|
186
204
|
expect(last?.outputs).toContain('export')
|
|
187
205
|
})
|
|
188
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
|
+
|
|
189
217
|
it('steps with descriptions in the catalog include description in the snapshot', () => {
|
|
190
218
|
const withDesc = snapshot?.steps.filter((step) => step.description !== undefined) ?? []
|
|
191
219
|
expect(withDesc.length).toBeGreaterThan(0)
|
|
@@ -29,16 +29,28 @@ export function createBuildPlanSnapshotFromTemplateId(templateId: string): Build
|
|
|
29
29
|
primaryEntity: step.primaryEntity,
|
|
30
30
|
outputs: [...step.outputs],
|
|
31
31
|
stageKey: step.stageKey,
|
|
32
|
+
recordsStageKey: step.recordsStageKey ?? step.stageKey,
|
|
33
|
+
recordSourceStageKey: step.recordSourceStageKey ?? step.recordsStageKey ?? step.stageKey,
|
|
32
34
|
dependencyMode: step.dependencyMode,
|
|
33
35
|
capabilityKey: step.capabilityKey,
|
|
34
36
|
defaultBatchSize: step.defaultBatchSize,
|
|
35
37
|
maxBatchSize: step.maxBatchSize
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (step.description) snapshotStep.description = step.description
|
|
39
|
-
if (step.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (step.description) snapshotStep.description = step.description
|
|
41
|
+
if (step.recordEntity) snapshotStep.recordEntity = step.recordEntity
|
|
42
|
+
if (step.dependsOn?.length) snapshotStep.dependsOn = [...step.dependsOn]
|
|
43
|
+
if (step.credentialRequirements?.length) {
|
|
44
|
+
snapshotStep.credentialRequirements = step.credentialRequirements.map((requirement) => ({ ...requirement }))
|
|
45
|
+
}
|
|
46
|
+
if (step.recordColumns) {
|
|
47
|
+
snapshotStep.recordColumns = {
|
|
48
|
+
...(step.recordColumns.company ? { company: step.recordColumns.company.map((column) => ({ ...column })) } : {}),
|
|
49
|
+
...(step.recordColumns.contact ? { contact: step.recordColumns.contact.map((column) => ({ ...column })) } : {})
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return snapshotStep
|
|
54
|
+
})
|
|
55
|
+
}
|
|
44
56
|
}
|
|
@@ -61,6 +61,8 @@ export {
|
|
|
61
61
|
ListStageCountsSchema,
|
|
62
62
|
ListTelemetrySchema,
|
|
63
63
|
ListIdParamsSchema,
|
|
64
|
+
ListReadQuerySchema,
|
|
65
|
+
GetListQuerySchema,
|
|
64
66
|
CreateListRequestSchema,
|
|
65
67
|
UpdateListRequestSchema,
|
|
66
68
|
UpdateListStatusRequestSchema,
|
|
@@ -70,7 +72,11 @@ export {
|
|
|
70
72
|
AddContactsToListRequestSchema,
|
|
71
73
|
RecordListExecutionRequestSchema,
|
|
72
74
|
AcqListResponseSchema,
|
|
75
|
+
AcqListDetailResponseSchema,
|
|
73
76
|
AcqListListResponseSchema,
|
|
77
|
+
AcqListDealRefSchema,
|
|
78
|
+
AcqListLineageSchema,
|
|
79
|
+
AcqListStatusResponseSchema,
|
|
74
80
|
ListTelemetryResponseSchema,
|
|
75
81
|
ListTelemetryListResponseSchema,
|
|
76
82
|
ListExecutionSummarySchema,
|
|
@@ -144,6 +150,8 @@ export {
|
|
|
144
150
|
type ListStageCountsInput,
|
|
145
151
|
type ListTelemetryInput,
|
|
146
152
|
type ListIdParams,
|
|
153
|
+
type ListReadQuery,
|
|
154
|
+
type GetListQuery,
|
|
147
155
|
type CreateListRequest,
|
|
148
156
|
type UpdateListRequest,
|
|
149
157
|
type UpdateListStatusRequest,
|
|
@@ -153,7 +161,11 @@ export {
|
|
|
153
161
|
type AddContactsToListRequest,
|
|
154
162
|
type RecordListExecutionRequest,
|
|
155
163
|
type AcqListResponse,
|
|
164
|
+
type AcqListDetailResponse,
|
|
156
165
|
type AcqListListResponse,
|
|
166
|
+
type AcqListDealRef,
|
|
167
|
+
type AcqListLineage,
|
|
168
|
+
type AcqListStatusResponse,
|
|
157
169
|
type ListTelemetryResponse,
|
|
158
170
|
type ListTelemetryListResponse,
|
|
159
171
|
type ListExecutionSummaryInput,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Database } from '../../supabase/database.types'
|
|
2
|
-
import type { Capability } from '../../organization-model/domains/prospecting'
|
|
2
|
+
import type { Capability, CredentialRequirement, RecordColumnConfig } from '../../organization-model/domains/prospecting'
|
|
3
3
|
import type { LEAD_GEN_STAGE_CATALOG } from '../../organization-model/domains/sales'
|
|
4
4
|
import type { PipelineStage, ProcessingStageStatus } from './api-schemas'
|
|
5
5
|
|
|
@@ -167,11 +167,16 @@ export interface BuildPlanSnapshotStep {
|
|
|
167
167
|
primaryEntity: BuildPlanSnapshotPrimaryEntity
|
|
168
168
|
outputs: BuildPlanSnapshotOutput[]
|
|
169
169
|
stageKey: string
|
|
170
|
+
recordEntity?: BuildPlanSnapshotPrimaryEntity
|
|
171
|
+
recordsStageKey?: string
|
|
172
|
+
recordSourceStageKey?: string
|
|
170
173
|
dependsOn?: string[]
|
|
171
174
|
dependencyMode: BuildPlanSnapshotDependencyMode
|
|
172
175
|
capabilityKey: string
|
|
173
176
|
defaultBatchSize: number
|
|
174
177
|
maxBatchSize: number
|
|
178
|
+
recordColumns?: Partial<Record<BuildPlanSnapshotPrimaryEntity, RecordColumnConfig[]>>
|
|
179
|
+
credentialRequirements?: CredentialRequirement[]
|
|
175
180
|
}
|
|
176
181
|
|
|
177
182
|
export interface BuildPlanSnapshot {
|