@elevasis/core 0.20.0 → 0.21.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.
Files changed (30) hide show
  1. package/dist/index.d.ts +108 -0
  2. package/dist/index.js +177 -27
  3. package/dist/knowledge/index.d.ts +54 -0
  4. package/dist/organization-model/index.d.ts +108 -0
  5. package/dist/organization-model/index.js +177 -27
  6. package/dist/test-utils/index.d.ts +54 -0
  7. package/dist/test-utils/index.js +177 -27
  8. package/package.json +3 -3
  9. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +6 -1
  10. package/src/business/acquisition/api-schemas.test.ts +25 -0
  11. package/src/business/acquisition/api-schemas.ts +125 -2
  12. package/src/business/acquisition/build-templates.test.ts +28 -0
  13. package/src/business/acquisition/build-templates.ts +20 -8
  14. package/src/business/acquisition/types.ts +6 -1
  15. package/src/execution/engine/tools/integration/server/adapters/apify/apify-adapter.test.ts +55 -0
  16. package/src/execution/engine/tools/integration/server/adapters/apify/apify-adapter.ts +107 -41
  17. package/src/execution/engine/tools/integration/server/adapters/apollo/apollo-adapter.test.ts +48 -0
  18. package/src/execution/engine/tools/integration/server/adapters/apollo/apollo-adapter.ts +99 -0
  19. package/src/execution/engine/tools/integration/server/adapters/apollo/index.ts +1 -0
  20. package/src/execution/engine/tools/integration/server/adapters/clickup/clickup-adapter.test.ts +18 -0
  21. package/src/execution/engine/tools/integration/server/adapters/clickup/clickup-adapter.ts +194 -0
  22. package/src/execution/engine/tools/integration/server/adapters/clickup/index.ts +7 -0
  23. package/src/integrations/credentials/api-schemas.ts +21 -2
  24. package/src/integrations/credentials/schemas.ts +200 -164
  25. package/src/organization-model/__tests__/prospecting-ssot.test.ts +7 -4
  26. package/src/organization-model/domains/prospecting.ts +182 -25
  27. package/src/organization-model/domains/sales.ts +24 -3
  28. package/src/platform/constants/versions.ts +1 -1
  29. package/src/reference/_generated/contracts.md +6 -1
  30. package/src/server.ts +2 -0
@@ -239,6 +239,13 @@ var LEAD_GEN_STAGE_CATALOG = {
239
239
  order: 2,
240
240
  entity: "company"
241
241
  },
242
+ crawled: {
243
+ key: "crawled",
244
+ label: "Websites crawled",
245
+ description: "Company websites have been crawled (e.g. via Apify) and raw page content stored for downstream LLM analysis.",
246
+ order: 2.5,
247
+ entity: "company"
248
+ },
242
249
  extracted: {
243
250
  key: "extracted",
244
251
  label: "Websites analyzed",
@@ -258,7 +265,9 @@ var LEAD_GEN_STAGE_CATALOG = {
258
265
  label: "Decision-makers found",
259
266
  description: "Decision-maker contacts discovered and attached to a qualified company.",
260
267
  order: 6,
261
- entity: "company"
268
+ entity: "company",
269
+ recordEntity: "contact",
270
+ recordStageKey: "discovered"
262
271
  },
263
272
  // Prospecting — contact discovery
264
273
  discovered: {
@@ -296,7 +305,8 @@ var LEAD_GEN_STAGE_CATALOG = {
296
305
  label: "Reviewed and exported",
297
306
  description: "Approved records have been reviewed and exported for handoff.",
298
307
  order: 10,
299
- entity: "contact"
308
+ entity: "company",
309
+ additionalEntities: ["contact"]
300
310
  },
301
311
  interested: {
302
312
  key: "interested",
@@ -366,18 +376,47 @@ var FeatureSchema = z.object({
366
376
  });
367
377
  var ProspectingLifecycleStageSchema = DisplayMetadataSchema.extend({
368
378
  id: ModelIdSchema,
369
- order: z.number().int().min(0)
379
+ order: z.number().min(0)
380
+ });
381
+ var RecordColumnConfigSchema = z.object({
382
+ key: ModelIdSchema,
383
+ label: z.string().trim().min(1).max(120),
384
+ path: z.string().trim().min(1).max(500),
385
+ width: z.union([z.number().positive(), z.string().trim().min(1).max(100)]).optional(),
386
+ renderType: z.enum(["text", "badge", "datetime", "count", "json"]).optional(),
387
+ badgeColor: z.string().trim().min(1).max(40).optional()
388
+ });
389
+ var RecordColumnsConfigSchema = z.object({
390
+ company: z.array(RecordColumnConfigSchema).optional(),
391
+ contact: z.array(RecordColumnConfigSchema).optional()
392
+ }).refine((columns) => Boolean(columns.company?.length || columns.contact?.length), {
393
+ message: "recordColumns must include at least one entity column set"
394
+ });
395
+ var CredentialRequirementSchema = z.object({
396
+ key: ModelIdSchema,
397
+ provider: ModelIdSchema,
398
+ credentialType: z.enum(["api-key", "api-key-secret", "oauth", "webhook-secret"]),
399
+ label: z.string().trim().min(1).max(120),
400
+ required: z.boolean(),
401
+ selectionMode: z.enum(["single", "multiple"]).optional(),
402
+ inputPath: z.string().trim().min(1).max(500),
403
+ verifyOnRun: z.boolean().optional()
370
404
  });
371
405
  var ProspectingBuildTemplateStepSchema = DisplayMetadataSchema.extend({
372
406
  id: ModelIdSchema,
373
407
  primaryEntity: z.enum(["company", "contact"]),
374
408
  outputs: z.array(z.enum(["company", "contact", "export"])).min(1),
375
409
  stageKey: ModelIdSchema,
410
+ recordEntity: z.enum(["company", "contact"]).optional(),
411
+ recordsStageKey: ModelIdSchema.optional(),
412
+ recordSourceStageKey: ModelIdSchema.optional(),
376
413
  dependsOn: z.array(ModelIdSchema).optional(),
377
414
  dependencyMode: z.literal("per-record-eligibility"),
378
415
  capabilityKey: ModelIdSchema,
379
416
  defaultBatchSize: z.number().int().positive(),
380
- maxBatchSize: z.number().int().positive()
417
+ maxBatchSize: z.number().int().positive(),
418
+ recordColumns: RecordColumnsConfigSchema.optional(),
419
+ credentialRequirements: z.array(CredentialRequirementSchema).optional()
381
420
  }).refine((step) => step.defaultBatchSize <= step.maxBatchSize, {
382
421
  message: "defaultBatchSize must be less than or equal to maxBatchSize",
383
422
  path: ["defaultBatchSize"]
@@ -386,6 +425,62 @@ var ProspectingBuildTemplateSchema = DisplayMetadataSchema.extend({
386
425
  id: ModelIdSchema,
387
426
  steps: z.array(ProspectingBuildTemplateStepSchema).min(1)
388
427
  });
428
+ var DTC_RECORD_COLUMNS = {
429
+ populated: {
430
+ company: [
431
+ { key: "name", label: "Company", path: "company.name" },
432
+ { key: "domain", label: "Domain", path: "company.domain" },
433
+ { key: "employee-count", label: "Employees", path: "company.numEmployees", renderType: "count" },
434
+ { key: "apollo-industry", label: "Apollo industry", path: "company.category" },
435
+ { key: "location", label: "Location", path: "company.locationState" }
436
+ ]
437
+ },
438
+ crawled: {
439
+ company: [
440
+ { key: "name", label: "Company", path: "company.name" },
441
+ { key: "domain", label: "Domain", path: "company.domain" },
442
+ { key: "page-count", label: "Pages", path: "company.enrichmentData.websiteCrawl.pageCount", renderType: "count" },
443
+ { key: "crawl-status", label: "Crawl status", path: "processingState.crawled.status", renderType: "badge" }
444
+ ]
445
+ },
446
+ extracted: {
447
+ company: [
448
+ { key: "name", label: "Company", path: "company.name" },
449
+ { key: "domain", label: "Domain", path: "company.domain" },
450
+ { key: "description", label: "Description", path: "company.enrichmentData.websiteCrawl.companyDescription" },
451
+ { key: "services", label: "Services", path: "company.enrichmentData.websiteCrawl.services", renderType: "json" },
452
+ { key: "automation-gaps", label: "Automation gaps", path: "company.enrichmentData.websiteCrawl.automationGaps", renderType: "json" },
453
+ { key: "contact-count", label: "Contacts", path: "company.enrichmentData.websiteCrawl.emailCount", renderType: "count" }
454
+ ]
455
+ },
456
+ qualified: {
457
+ company: [
458
+ { key: "name", label: "Company", path: "company.name" },
459
+ { key: "domain", label: "Domain", path: "company.domain" },
460
+ { key: "score", label: "Score", path: "company.qualificationScore", renderType: "badge", badgeColor: "green" },
461
+ { key: "signals", label: "Signals", path: "company.qualificationSignals", renderType: "json" },
462
+ { key: "disqualified-reason", label: "Disqualified reason", path: "processingState.qualified.data.disqualifiedReason" }
463
+ ]
464
+ },
465
+ decisionMakers: {
466
+ contact: [
467
+ { key: "name", label: "Name", path: "contact.name" },
468
+ { key: "title", label: "Title", path: "contact.title" },
469
+ { key: "email", label: "Email", path: "contact.email" },
470
+ { key: "linkedin", label: "LinkedIn", path: "contact.linkedinUrl" },
471
+ { key: "priority-score", label: "Priority", path: "contact.enrichmentData.apollo.priorityScore", renderType: "badge" }
472
+ ]
473
+ },
474
+ uploaded: {
475
+ company: [
476
+ { key: "name", label: "Company", path: "company.name" },
477
+ { key: "domain", label: "Domain", path: "company.domain" },
478
+ { key: "contacts", label: "Contacts", path: "company.enrichmentData.approvedLeadListExport.contacts", renderType: "json" },
479
+ { key: "score", label: "Score", path: "company.qualificationScore", renderType: "badge", badgeColor: "green" },
480
+ { key: "approval", label: "Approval", path: "company.enrichmentData.approvedLeadListExport.approvalStatus", renderType: "badge" }
481
+ ]
482
+ }
483
+ };
389
484
  z.object({
390
485
  id: ModelIdSchema,
391
486
  label: z.string(),
@@ -489,7 +584,45 @@ var PROSPECTING_STEPS = {
489
584
  dependencyMode: "per-record-eligibility",
490
585
  capabilityKey: "lead-gen.company.apollo-import",
491
586
  defaultBatchSize: 250,
492
- maxBatchSize: 1e3
587
+ maxBatchSize: 1e3,
588
+ recordColumns: DTC_RECORD_COLUMNS.populated,
589
+ credentialRequirements: [
590
+ {
591
+ key: "apollo",
592
+ provider: "apollo",
593
+ credentialType: "api-key-secret",
594
+ label: "Apollo API key",
595
+ required: true,
596
+ selectionMode: "single",
597
+ inputPath: "credential"
598
+ }
599
+ ]
600
+ },
601
+ apifyCrawl: {
602
+ id: "apify-crawl",
603
+ label: "Websites crawled",
604
+ description: "Crawl company websites via Apify and store raw page markdown in enrichmentData.websiteCrawl.pages for downstream LLM analysis. Overwrites the synthetic seed Apollo Import wrote with real page content.",
605
+ primaryEntity: "company",
606
+ outputs: ["company"],
607
+ stageKey: "crawled",
608
+ dependsOn: ["import-apollo-search"],
609
+ dependencyMode: "per-record-eligibility",
610
+ capabilityKey: "lead-gen.company.apify-crawl",
611
+ defaultBatchSize: 50,
612
+ maxBatchSize: 100,
613
+ recordColumns: DTC_RECORD_COLUMNS.crawled,
614
+ credentialRequirements: [
615
+ {
616
+ key: "apify",
617
+ provider: "apify",
618
+ credentialType: "api-key-secret",
619
+ label: "Apify API token",
620
+ required: true,
621
+ selectionMode: "single",
622
+ inputPath: "credential",
623
+ verifyOnRun: true
624
+ }
625
+ ]
493
626
  },
494
627
  analyzeWebsites: {
495
628
  id: "analyze-websites",
@@ -498,11 +631,12 @@ var PROSPECTING_STEPS = {
498
631
  primaryEntity: "company",
499
632
  outputs: ["company"],
500
633
  stageKey: "extracted",
501
- dependsOn: ["import-apollo-search"],
634
+ dependsOn: ["apify-crawl"],
502
635
  dependencyMode: "per-record-eligibility",
503
636
  capabilityKey: "lead-gen.company.website-extract",
504
637
  defaultBatchSize: 50,
505
- maxBatchSize: 100
638
+ maxBatchSize: 100,
639
+ recordColumns: DTC_RECORD_COLUMNS.extracted
506
640
  },
507
641
  scoreDtcFit: {
508
642
  id: "score-dtc-fit",
@@ -515,7 +649,8 @@ var PROSPECTING_STEPS = {
515
649
  dependencyMode: "per-record-eligibility",
516
650
  capabilityKey: "lead-gen.company.dtc-subscription-qualify",
517
651
  defaultBatchSize: 100,
518
- maxBatchSize: 250
652
+ maxBatchSize: 250,
653
+ recordColumns: DTC_RECORD_COLUMNS.qualified
519
654
  },
520
655
  enrichDecisionMakers: {
521
656
  id: "enrich-decision-makers",
@@ -524,37 +659,52 @@ var PROSPECTING_STEPS = {
524
659
  primaryEntity: "company",
525
660
  outputs: ["contact"],
526
661
  stageKey: "decision-makers-enriched",
662
+ recordEntity: "contact",
527
663
  dependsOn: ["score-dtc-fit"],
528
664
  dependencyMode: "per-record-eligibility",
529
665
  capabilityKey: "lead-gen.contact.apollo-decision-maker-enrich",
530
666
  defaultBatchSize: 100,
531
- maxBatchSize: 250
532
- },
533
- verifyEmails: {
534
- id: "verify-emails",
535
- label: "Emails verified",
536
- description: "Verify deliverability before the QC and handoff step.",
537
- primaryEntity: "contact",
538
- outputs: ["contact"],
539
- stageKey: "verified",
540
- dependsOn: ["enrich-decision-makers"],
541
- dependencyMode: "per-record-eligibility",
542
- capabilityKey: "lead-gen.contact.verify-email",
543
- defaultBatchSize: 250,
544
- maxBatchSize: 500
667
+ maxBatchSize: 250,
668
+ recordColumns: DTC_RECORD_COLUMNS.decisionMakers,
669
+ credentialRequirements: [
670
+ {
671
+ key: "apollo",
672
+ provider: "apollo",
673
+ credentialType: "api-key-secret",
674
+ label: "Apollo API key",
675
+ required: true,
676
+ selectionMode: "single",
677
+ inputPath: "credential"
678
+ }
679
+ ]
545
680
  },
546
681
  reviewAndExport: {
547
682
  id: "review-and-export",
548
683
  label: "Reviewed and exported",
549
- description: "Operator QC approves or rejects leads, then approved records are exported as a lead list.",
684
+ description: "Operator QC approves or rejects qualified companies, then approved records are exported as a lead list with unverified emails.",
550
685
  primaryEntity: "company",
551
686
  outputs: ["export"],
552
687
  stageKey: "uploaded",
553
- dependsOn: ["verify-emails"],
688
+ recordsStageKey: "uploaded",
689
+ recordSourceStageKey: "qualified",
690
+ dependsOn: ["enrich-decision-makers"],
554
691
  dependencyMode: "per-record-eligibility",
555
692
  capabilityKey: "lead-gen.export.list",
556
693
  defaultBatchSize: 100,
557
- maxBatchSize: 250
694
+ maxBatchSize: 250,
695
+ recordColumns: DTC_RECORD_COLUMNS.uploaded,
696
+ credentialRequirements: [
697
+ {
698
+ key: "clickup",
699
+ provider: "clickup",
700
+ credentialType: "api-key-secret",
701
+ label: "ClickUp API token",
702
+ required: true,
703
+ selectionMode: "single",
704
+ inputPath: "clickupCredential",
705
+ verifyOnRun: true
706
+ }
707
+ ]
558
708
  }
559
709
  }
560
710
  };
@@ -576,7 +726,7 @@ function toProspectingLifecycleStage(stage) {
576
726
  };
577
727
  }
578
728
  function leadGenStagesForEntity(entity) {
579
- return Object.values(LEAD_GEN_STAGE_CATALOG).filter((stage) => stage.entity === entity).sort((a, b) => a.order - b.order).map(toProspectingLifecycleStage);
729
+ return Object.values(LEAD_GEN_STAGE_CATALOG).filter((stage) => stage.entity === entity || stage.additionalEntities?.includes(entity)).sort((a, b) => a.order - b.order).map(toProspectingLifecycleStage);
580
730
  }
581
731
  var DEFAULT_ORGANIZATION_MODEL_PROSPECTING = {
582
732
  listEntityId: "leadgen.list",
@@ -606,10 +756,10 @@ var DEFAULT_ORGANIZATION_MODEL_PROSPECTING = {
606
756
  description: "Prospecting pipeline for DTC subscription or subscription-ready brands where Apollo is the source and contact-enrichment layer, Elevasis handles company research and fit scoring, and approved leads export as an approved lead list.",
607
757
  steps: [
608
758
  PROSPECTING_STEPS.dtcApolloClickup.importApolloSearch,
759
+ PROSPECTING_STEPS.dtcApolloClickup.apifyCrawl,
609
760
  PROSPECTING_STEPS.dtcApolloClickup.analyzeWebsites,
610
761
  PROSPECTING_STEPS.dtcApolloClickup.scoreDtcFit,
611
762
  PROSPECTING_STEPS.dtcApolloClickup.enrichDecisionMakers,
612
- PROSPECTING_STEPS.dtcApolloClickup.verifyEmails,
613
763
  PROSPECTING_STEPS.dtcApolloClickup.reviewAndExport
614
764
  ]
615
765
  }
@@ -3978,11 +3978,65 @@ declare const OrganizationModelSchema: z.ZodObject<{
3978
3978
  export: "export";
3979
3979
  }>>;
3980
3980
  stageKey: z.ZodString;
3981
+ recordEntity: z.ZodOptional<z.ZodEnum<{
3982
+ company: "company";
3983
+ contact: "contact";
3984
+ }>>;
3985
+ recordsStageKey: z.ZodOptional<z.ZodString>;
3986
+ recordSourceStageKey: z.ZodOptional<z.ZodString>;
3981
3987
  dependsOn: z.ZodOptional<z.ZodArray<z.ZodString>>;
3982
3988
  dependencyMode: z.ZodLiteral<"per-record-eligibility">;
3983
3989
  capabilityKey: z.ZodString;
3984
3990
  defaultBatchSize: z.ZodNumber;
3985
3991
  maxBatchSize: z.ZodNumber;
3992
+ recordColumns: z.ZodOptional<z.ZodObject<{
3993
+ company: z.ZodOptional<z.ZodArray<z.ZodObject<{
3994
+ key: z.ZodString;
3995
+ label: z.ZodString;
3996
+ path: z.ZodString;
3997
+ width: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
3998
+ renderType: z.ZodOptional<z.ZodEnum<{
3999
+ text: "text";
4000
+ badge: "badge";
4001
+ datetime: "datetime";
4002
+ count: "count";
4003
+ json: "json";
4004
+ }>>;
4005
+ badgeColor: z.ZodOptional<z.ZodString>;
4006
+ }, z.core.$strip>>>;
4007
+ contact: z.ZodOptional<z.ZodArray<z.ZodObject<{
4008
+ key: z.ZodString;
4009
+ label: z.ZodString;
4010
+ path: z.ZodString;
4011
+ width: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
4012
+ renderType: z.ZodOptional<z.ZodEnum<{
4013
+ text: "text";
4014
+ badge: "badge";
4015
+ datetime: "datetime";
4016
+ count: "count";
4017
+ json: "json";
4018
+ }>>;
4019
+ badgeColor: z.ZodOptional<z.ZodString>;
4020
+ }, z.core.$strip>>>;
4021
+ }, z.core.$strip>>;
4022
+ credentialRequirements: z.ZodOptional<z.ZodArray<z.ZodObject<{
4023
+ key: z.ZodString;
4024
+ provider: z.ZodString;
4025
+ credentialType: z.ZodEnum<{
4026
+ "api-key": "api-key";
4027
+ "api-key-secret": "api-key-secret";
4028
+ oauth: "oauth";
4029
+ "webhook-secret": "webhook-secret";
4030
+ }>;
4031
+ label: z.ZodString;
4032
+ required: z.ZodBoolean;
4033
+ selectionMode: z.ZodOptional<z.ZodEnum<{
4034
+ single: "single";
4035
+ multiple: "multiple";
4036
+ }>>;
4037
+ inputPath: z.ZodString;
4038
+ verifyOnRun: z.ZodOptional<z.ZodBoolean>;
4039
+ }, z.core.$strip>>>;
3986
4040
  }, z.core.$strip>>;
3987
4041
  }, z.core.$strip>>;
3988
4042
  }, z.core.$strip>;