@elevasis/sdk 1.16.0 → 1.18.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/cli.cjs +382 -175
- package/dist/index.d.ts +390 -73
- package/dist/index.js +1087 -62
- package/dist/node/index.d.ts +3 -0
- package/dist/node/index.js +34 -1
- package/dist/test-utils/index.d.ts +108 -71
- package/dist/test-utils/index.js +1872 -667
- package/dist/types/worker/index.d.ts +3 -2
- package/dist/worker/index.js +1373 -2
- package/package.json +2 -2
- package/reference/claude-config/rules/package-taxonomy.md +33 -0
- package/reference/claude-config/rules/vibe.md +23 -0
- package/reference/claude-config/skills/knowledge/SKILL.md +37 -5
- package/reference/claude-config/skills/project/SKILL.md +21 -0
- package/reference/claude-config/skills/tutorial/SKILL.md +13 -3
- package/reference/claude-config/sync-notes/2026-05-04-knowledge-bundle.md +83 -0
- package/reference/claude-config/sync-notes/2026-05-05-list-builder.md +42 -0
- package/reference/claude-config/sync-notes/2026-05-06-sdk-changes-release-train.md +37 -0
- package/reference/scaffold/reference/contracts.md +78 -65
- package/reference/scaffold/reference/feature-registry.md +1 -1
- package/reference/spine/spine-primer.md +99 -0
package/dist/worker/index.js
CHANGED
|
@@ -3652,6 +3652,29 @@ function estimateTokens(text) {
|
|
|
3652
3652
|
const chars = content.length;
|
|
3653
3653
|
return Math.ceil(chars / 3.5);
|
|
3654
3654
|
}
|
|
3655
|
+
var UuidSchema = z.string().uuid();
|
|
3656
|
+
var NonEmptyStringSchema = z.string().trim().min(1).max(1e3);
|
|
3657
|
+
z.enum(["agent", "workflow"]);
|
|
3658
|
+
z.enum(["agent", "workflow", "scheduler", "api"]);
|
|
3659
|
+
z.string().trim().toLowerCase().min(1, "Credential name required").max(100, "Credential name too long (max 100 chars)").regex(
|
|
3660
|
+
/^[a-z0-9]+(-[a-z0-9]+)+$/,
|
|
3661
|
+
"Credential name must be lowercase letters, numbers, and hyphens in format: service-environment (e.g., gmail-prod, attio-dev)"
|
|
3662
|
+
);
|
|
3663
|
+
z.enum(["google-sheets", "google-calendar", "dropbox"]);
|
|
3664
|
+
z.string().min(10, "Authorization code too short").max(1e3, "Authorization code too long");
|
|
3665
|
+
z.string().min(10, "State parameter too short").max(2048, "State parameter too long");
|
|
3666
|
+
z.string().trim().transform((str) => str.replace(/[<>'"]/g, ""));
|
|
3667
|
+
z.string().email();
|
|
3668
|
+
z.string().url();
|
|
3669
|
+
z.object({
|
|
3670
|
+
limit: z.coerce.number().int().min(1).max(100).default(20),
|
|
3671
|
+
offset: z.coerce.number().int().min(0).default(0)
|
|
3672
|
+
});
|
|
3673
|
+
z.string().datetime();
|
|
3674
|
+
z.object({
|
|
3675
|
+
startDate: z.string().datetime(),
|
|
3676
|
+
endDate: z.string().datetime()
|
|
3677
|
+
});
|
|
3655
3678
|
|
|
3656
3679
|
// ../core/src/platform/constants/limits.ts
|
|
3657
3680
|
var MAX_SESSION_MEMORY_KEYS = 25;
|
|
@@ -4580,6 +4603,1167 @@ Fix the errors and generate a valid output.
|
|
|
4580
4603
|
}
|
|
4581
4604
|
}
|
|
4582
4605
|
};
|
|
4606
|
+
var ORGANIZATION_MODEL_ICON_TOKENS = [
|
|
4607
|
+
"nav.dashboard",
|
|
4608
|
+
"nav.calendar",
|
|
4609
|
+
"nav.sales",
|
|
4610
|
+
"nav.crm",
|
|
4611
|
+
"nav.lead-gen",
|
|
4612
|
+
"nav.projects",
|
|
4613
|
+
"nav.operations",
|
|
4614
|
+
"nav.monitoring",
|
|
4615
|
+
"nav.knowledge",
|
|
4616
|
+
"nav.settings",
|
|
4617
|
+
"nav.admin",
|
|
4618
|
+
"nav.archive",
|
|
4619
|
+
"knowledge.playbook",
|
|
4620
|
+
"knowledge.strategy",
|
|
4621
|
+
"knowledge.reference",
|
|
4622
|
+
"feature.dashboard",
|
|
4623
|
+
"feature.calendar",
|
|
4624
|
+
"feature.sales",
|
|
4625
|
+
"feature.crm",
|
|
4626
|
+
"feature.finance",
|
|
4627
|
+
"feature.lead-gen",
|
|
4628
|
+
"feature.platform",
|
|
4629
|
+
"feature.projects",
|
|
4630
|
+
"feature.operations",
|
|
4631
|
+
"feature.knowledge",
|
|
4632
|
+
"feature.monitoring",
|
|
4633
|
+
"feature.settings",
|
|
4634
|
+
"feature.admin",
|
|
4635
|
+
"feature.archive",
|
|
4636
|
+
"feature.seo",
|
|
4637
|
+
"resource.agent",
|
|
4638
|
+
"resource.workflow",
|
|
4639
|
+
"resource.integration",
|
|
4640
|
+
"resource.database",
|
|
4641
|
+
"resource.user",
|
|
4642
|
+
"resource.team",
|
|
4643
|
+
"integration.gmail",
|
|
4644
|
+
"integration.google-sheets",
|
|
4645
|
+
"integration.attio",
|
|
4646
|
+
"surface.dashboard",
|
|
4647
|
+
"surface.calendar",
|
|
4648
|
+
"surface.overview",
|
|
4649
|
+
"surface.command-view",
|
|
4650
|
+
"surface.command-queue",
|
|
4651
|
+
"surface.pipeline",
|
|
4652
|
+
"surface.lists",
|
|
4653
|
+
"surface.resources",
|
|
4654
|
+
"surface.settings",
|
|
4655
|
+
"status.success",
|
|
4656
|
+
"status.error",
|
|
4657
|
+
"status.warning",
|
|
4658
|
+
"status.info",
|
|
4659
|
+
"status.pending",
|
|
4660
|
+
"action.approve",
|
|
4661
|
+
"action.reject",
|
|
4662
|
+
"action.retry",
|
|
4663
|
+
"action.edit",
|
|
4664
|
+
"action.view",
|
|
4665
|
+
"action.launch",
|
|
4666
|
+
"action.message",
|
|
4667
|
+
"action.escalate",
|
|
4668
|
+
"action.promote",
|
|
4669
|
+
"action.submit",
|
|
4670
|
+
"action.email"
|
|
4671
|
+
];
|
|
4672
|
+
var CustomIconTokenSchema = z.string().trim().max(80).regex(/^custom\.[a-z0-9]+(?:[-._][a-z0-9]+)*$/, "Custom icon tokens must start with custom.");
|
|
4673
|
+
var OrganizationModelBuiltinIconTokenSchema = z.enum(ORGANIZATION_MODEL_ICON_TOKENS);
|
|
4674
|
+
var OrganizationModelIconTokenSchema = z.union([
|
|
4675
|
+
OrganizationModelBuiltinIconTokenSchema,
|
|
4676
|
+
CustomIconTokenSchema
|
|
4677
|
+
]);
|
|
4678
|
+
|
|
4679
|
+
// ../core/src/organization-model/domains/shared.ts
|
|
4680
|
+
var ModelIdSchema = z.string().trim().min(1).max(100).regex(/^[a-z0-9]+(?:[-._][a-z0-9]+)*$/, "IDs must be lowercase and use -, _, or . separators");
|
|
4681
|
+
var LabelSchema = z.string().trim().min(1).max(120);
|
|
4682
|
+
var DescriptionSchema = z.string().trim().min(1).max(2e3);
|
|
4683
|
+
var ColorTokenSchema = z.string().trim().min(1).max(50);
|
|
4684
|
+
var IconNameSchema = OrganizationModelIconTokenSchema;
|
|
4685
|
+
z.string().trim().startsWith("/").max(300);
|
|
4686
|
+
var ReferenceIdsSchema = z.array(ModelIdSchema).default([]);
|
|
4687
|
+
var DisplayMetadataSchema = z.object({
|
|
4688
|
+
label: LabelSchema,
|
|
4689
|
+
description: DescriptionSchema.optional(),
|
|
4690
|
+
color: ColorTokenSchema.optional(),
|
|
4691
|
+
icon: IconNameSchema.optional()
|
|
4692
|
+
});
|
|
4693
|
+
var TechStackEntrySchema = z.object({
|
|
4694
|
+
/** Name of the external platform (e.g. "HubSpot", "Stripe", "Notion"). */
|
|
4695
|
+
platform: z.string().trim().min(1).max(200),
|
|
4696
|
+
/** Free-form description of what this integration is used for. */
|
|
4697
|
+
purpose: z.string().trim().min(1).max(500),
|
|
4698
|
+
/**
|
|
4699
|
+
* Health of the credential backing this integration.
|
|
4700
|
+
* - configured: credential present and valid
|
|
4701
|
+
* - pending: not yet set up
|
|
4702
|
+
* - expired: credential existed but has lapsed
|
|
4703
|
+
* - missing: expected but not present
|
|
4704
|
+
*/
|
|
4705
|
+
credentialStatus: z.enum(["configured", "pending", "expired", "missing"]),
|
|
4706
|
+
/**
|
|
4707
|
+
* Whether this integration is the primary system of record for its domain
|
|
4708
|
+
* (e.g. HubSpot is SoR for contacts). Defaults to false.
|
|
4709
|
+
*/
|
|
4710
|
+
isSystemOfRecord: z.boolean().default(false)
|
|
4711
|
+
});
|
|
4712
|
+
DisplayMetadataSchema.extend({
|
|
4713
|
+
id: ModelIdSchema,
|
|
4714
|
+
resourceId: z.string().trim().min(1).max(255),
|
|
4715
|
+
resourceType: z.enum(["workflow", "agent", "trigger", "integration", "external", "human_checkpoint"]),
|
|
4716
|
+
featureIds: ReferenceIdsSchema,
|
|
4717
|
+
entityIds: ReferenceIdsSchema,
|
|
4718
|
+
surfaceIds: ReferenceIdsSchema,
|
|
4719
|
+
capabilityIds: ReferenceIdsSchema,
|
|
4720
|
+
/** Optional tech-stack metadata for external-SaaS integrations. */
|
|
4721
|
+
techStack: TechStackEntrySchema.optional()
|
|
4722
|
+
});
|
|
4723
|
+
|
|
4724
|
+
// ../core/src/organization-model/domains/sales.ts
|
|
4725
|
+
var SalesStageSemanticClassSchema = z.enum(["open", "active", "nurturing", "closed_won", "closed_lost"]);
|
|
4726
|
+
var SalesStageSchema = DisplayMetadataSchema.extend({
|
|
4727
|
+
id: ModelIdSchema,
|
|
4728
|
+
order: z.number().int().min(0),
|
|
4729
|
+
semanticClass: SalesStageSemanticClassSchema,
|
|
4730
|
+
surfaceIds: ReferenceIdsSchema,
|
|
4731
|
+
resourceIds: ReferenceIdsSchema
|
|
4732
|
+
});
|
|
4733
|
+
var SalesPipelineSchema = z.object({
|
|
4734
|
+
id: ModelIdSchema,
|
|
4735
|
+
label: z.string().trim().min(1).max(120),
|
|
4736
|
+
description: DescriptionSchema.optional(),
|
|
4737
|
+
entityId: ModelIdSchema,
|
|
4738
|
+
stages: z.array(SalesStageSchema).min(1)
|
|
4739
|
+
});
|
|
4740
|
+
z.object({
|
|
4741
|
+
entityId: ModelIdSchema,
|
|
4742
|
+
defaultPipelineId: ModelIdSchema,
|
|
4743
|
+
pipelines: z.array(SalesPipelineSchema).min(1)
|
|
4744
|
+
});
|
|
4745
|
+
var LEAD_GEN_STAGE_CATALOG = {
|
|
4746
|
+
// Prospecting — company population
|
|
4747
|
+
scraped: {
|
|
4748
|
+
key: "scraped",
|
|
4749
|
+
label: "Scraped",
|
|
4750
|
+
description: "Company was scraped from a source directory (Apify actor run).",
|
|
4751
|
+
order: 1,
|
|
4752
|
+
entity: "company"
|
|
4753
|
+
},
|
|
4754
|
+
populated: {
|
|
4755
|
+
key: "populated",
|
|
4756
|
+
label: "Companies found",
|
|
4757
|
+
description: "Companies have been found and added to the lead-gen list.",
|
|
4758
|
+
order: 2,
|
|
4759
|
+
entity: "company"
|
|
4760
|
+
},
|
|
4761
|
+
extracted: {
|
|
4762
|
+
key: "extracted",
|
|
4763
|
+
label: "Websites analyzed",
|
|
4764
|
+
description: "Company websites have been analyzed for business signals.",
|
|
4765
|
+
order: 3,
|
|
4766
|
+
entity: "company"
|
|
4767
|
+
},
|
|
4768
|
+
enriched: {
|
|
4769
|
+
key: "enriched",
|
|
4770
|
+
label: "Enriched",
|
|
4771
|
+
description: "Company or contact enriched with third-party data (e.g. Tomba, Anymailfinder).",
|
|
4772
|
+
order: 4,
|
|
4773
|
+
entity: "company"
|
|
4774
|
+
},
|
|
4775
|
+
"decision-makers-enriched": {
|
|
4776
|
+
key: "decision-makers-enriched",
|
|
4777
|
+
label: "Decision-makers found",
|
|
4778
|
+
description: "Decision-maker contacts discovered and attached to a qualified company.",
|
|
4779
|
+
order: 6,
|
|
4780
|
+
entity: "company"
|
|
4781
|
+
},
|
|
4782
|
+
// Prospecting — contact discovery
|
|
4783
|
+
discovered: {
|
|
4784
|
+
key: "discovered",
|
|
4785
|
+
label: "Decision-makers found",
|
|
4786
|
+
description: "Decision-maker contact details have been found.",
|
|
4787
|
+
order: 5,
|
|
4788
|
+
entity: "contact"
|
|
4789
|
+
},
|
|
4790
|
+
verified: {
|
|
4791
|
+
key: "verified",
|
|
4792
|
+
label: "Emails verified",
|
|
4793
|
+
description: "Contact email addresses have been checked for deliverability.",
|
|
4794
|
+
order: 7,
|
|
4795
|
+
entity: "contact"
|
|
4796
|
+
},
|
|
4797
|
+
// Qualification
|
|
4798
|
+
qualified: {
|
|
4799
|
+
key: "qualified",
|
|
4800
|
+
label: "Companies qualified",
|
|
4801
|
+
description: "Companies have been scored against the qualification criteria.",
|
|
4802
|
+
order: 8,
|
|
4803
|
+
entity: "company"
|
|
4804
|
+
},
|
|
4805
|
+
// Outreach
|
|
4806
|
+
personalized: {
|
|
4807
|
+
key: "personalized",
|
|
4808
|
+
label: "Personalized",
|
|
4809
|
+
description: "Outreach message personalized for the contact (Instantly personalization workflow).",
|
|
4810
|
+
order: 9,
|
|
4811
|
+
entity: "contact"
|
|
4812
|
+
},
|
|
4813
|
+
uploaded: {
|
|
4814
|
+
key: "uploaded",
|
|
4815
|
+
label: "Reviewed and exported",
|
|
4816
|
+
description: "Approved records have been reviewed and exported for handoff.",
|
|
4817
|
+
order: 10,
|
|
4818
|
+
entity: "contact"
|
|
4819
|
+
},
|
|
4820
|
+
interested: {
|
|
4821
|
+
key: "interested",
|
|
4822
|
+
label: "Interested",
|
|
4823
|
+
description: "Contact replied with a positive signal (Instantly reply-handler transition).",
|
|
4824
|
+
order: 11,
|
|
4825
|
+
entity: "contact"
|
|
4826
|
+
}
|
|
4827
|
+
};
|
|
4828
|
+
|
|
4829
|
+
// ../core/src/organization-model/domains/prospecting.ts
|
|
4830
|
+
var ProspectingLifecycleStageSchema = DisplayMetadataSchema.extend({
|
|
4831
|
+
id: ModelIdSchema,
|
|
4832
|
+
order: z.number().int().min(0)
|
|
4833
|
+
});
|
|
4834
|
+
var ProspectingBuildTemplateStepSchema = DisplayMetadataSchema.extend({
|
|
4835
|
+
id: ModelIdSchema,
|
|
4836
|
+
primaryEntity: z.enum(["company", "contact"]),
|
|
4837
|
+
outputs: z.array(z.enum(["company", "contact", "export"])).min(1),
|
|
4838
|
+
stageKey: ModelIdSchema,
|
|
4839
|
+
dependsOn: z.array(ModelIdSchema).optional(),
|
|
4840
|
+
dependencyMode: z.literal("per-record-eligibility"),
|
|
4841
|
+
capabilityKey: ModelIdSchema,
|
|
4842
|
+
defaultBatchSize: z.number().int().positive(),
|
|
4843
|
+
maxBatchSize: z.number().int().positive()
|
|
4844
|
+
}).refine((step) => step.defaultBatchSize <= step.maxBatchSize, {
|
|
4845
|
+
message: "defaultBatchSize must be less than or equal to maxBatchSize",
|
|
4846
|
+
path: ["defaultBatchSize"]
|
|
4847
|
+
});
|
|
4848
|
+
var ProspectingBuildTemplateSchema = DisplayMetadataSchema.extend({
|
|
4849
|
+
id: ModelIdSchema,
|
|
4850
|
+
steps: z.array(ProspectingBuildTemplateStepSchema).min(1)
|
|
4851
|
+
});
|
|
4852
|
+
var CAPABILITY_REGISTRY = {
|
|
4853
|
+
"lead-gen.company.source": "lgn-import-workflow",
|
|
4854
|
+
"lead-gen.company.apollo-import": "lgn-01c-apollo-import-workflow",
|
|
4855
|
+
"lead-gen.contact.discover": "lgn-04-email-discovery-workflow",
|
|
4856
|
+
"lead-gen.contact.verify-email": "lgn-05-email-verification-workflow",
|
|
4857
|
+
"lead-gen.company.website-extract": "lgn-02-website-extract-workflow",
|
|
4858
|
+
"lead-gen.company.qualify": "lgn-03-company-qualification-workflow",
|
|
4859
|
+
"lead-gen.company.dtc-subscription-qualify": "lgn-03b-dtc-subscription-score-workflow",
|
|
4860
|
+
"lead-gen.contact.apollo-decision-maker-enrich": "lgn-04b-apollo-decision-maker-enrich-workflow",
|
|
4861
|
+
"lead-gen.contact.personalize": "ist-personalization-workflow",
|
|
4862
|
+
"lead-gen.review.outreach-ready": "ist-upload-contacts-workflow",
|
|
4863
|
+
"lead-gen.export.list": "lgn-06-export-list-workflow",
|
|
4864
|
+
"lead-gen.company.cleanup": "lgn-company-cleanup-workflow"
|
|
4865
|
+
};
|
|
4866
|
+
var PROSPECTING_STEPS = {
|
|
4867
|
+
localServices: {
|
|
4868
|
+
sourceCompanies: {
|
|
4869
|
+
id: "source-companies",
|
|
4870
|
+
label: "Companies found",
|
|
4871
|
+
primaryEntity: "company",
|
|
4872
|
+
outputs: ["company"],
|
|
4873
|
+
stageKey: "populated",
|
|
4874
|
+
dependencyMode: "per-record-eligibility",
|
|
4875
|
+
capabilityKey: "lead-gen.company.source",
|
|
4876
|
+
defaultBatchSize: 100,
|
|
4877
|
+
maxBatchSize: 250
|
|
4878
|
+
},
|
|
4879
|
+
analyzeWebsites: {
|
|
4880
|
+
id: "analyze-websites",
|
|
4881
|
+
label: "Websites analyzed",
|
|
4882
|
+
primaryEntity: "company",
|
|
4883
|
+
outputs: ["company"],
|
|
4884
|
+
stageKey: "extracted",
|
|
4885
|
+
dependsOn: ["source-companies"],
|
|
4886
|
+
dependencyMode: "per-record-eligibility",
|
|
4887
|
+
capabilityKey: "lead-gen.company.website-extract",
|
|
4888
|
+
defaultBatchSize: 50,
|
|
4889
|
+
maxBatchSize: 100
|
|
4890
|
+
},
|
|
4891
|
+
qualifyCompanies: {
|
|
4892
|
+
id: "qualify-companies",
|
|
4893
|
+
label: "Companies qualified",
|
|
4894
|
+
primaryEntity: "company",
|
|
4895
|
+
outputs: ["company"],
|
|
4896
|
+
stageKey: "qualified",
|
|
4897
|
+
dependsOn: ["analyze-websites"],
|
|
4898
|
+
dependencyMode: "per-record-eligibility",
|
|
4899
|
+
capabilityKey: "lead-gen.company.qualify",
|
|
4900
|
+
defaultBatchSize: 100,
|
|
4901
|
+
maxBatchSize: 250
|
|
4902
|
+
},
|
|
4903
|
+
findContacts: {
|
|
4904
|
+
id: "find-contacts",
|
|
4905
|
+
label: "Decision-makers found",
|
|
4906
|
+
primaryEntity: "contact",
|
|
4907
|
+
outputs: ["contact"],
|
|
4908
|
+
stageKey: "discovered",
|
|
4909
|
+
dependsOn: ["qualify-companies"],
|
|
4910
|
+
dependencyMode: "per-record-eligibility",
|
|
4911
|
+
capabilityKey: "lead-gen.contact.discover",
|
|
4912
|
+
defaultBatchSize: 50,
|
|
4913
|
+
maxBatchSize: 100
|
|
4914
|
+
},
|
|
4915
|
+
verifyEmails: {
|
|
4916
|
+
id: "verify-emails",
|
|
4917
|
+
label: "Emails verified",
|
|
4918
|
+
primaryEntity: "contact",
|
|
4919
|
+
outputs: ["contact"],
|
|
4920
|
+
stageKey: "verified",
|
|
4921
|
+
dependsOn: ["find-contacts"],
|
|
4922
|
+
dependencyMode: "per-record-eligibility",
|
|
4923
|
+
capabilityKey: "lead-gen.contact.verify-email",
|
|
4924
|
+
defaultBatchSize: 100,
|
|
4925
|
+
maxBatchSize: 500
|
|
4926
|
+
},
|
|
4927
|
+
personalize: {
|
|
4928
|
+
id: "personalize",
|
|
4929
|
+
label: "Personalize",
|
|
4930
|
+
primaryEntity: "contact",
|
|
4931
|
+
outputs: ["contact"],
|
|
4932
|
+
stageKey: "personalized",
|
|
4933
|
+
dependsOn: ["verify-emails"],
|
|
4934
|
+
dependencyMode: "per-record-eligibility",
|
|
4935
|
+
capabilityKey: "lead-gen.contact.personalize",
|
|
4936
|
+
defaultBatchSize: 25,
|
|
4937
|
+
maxBatchSize: 100
|
|
4938
|
+
},
|
|
4939
|
+
review: {
|
|
4940
|
+
id: "review",
|
|
4941
|
+
label: "Reviewed and exported",
|
|
4942
|
+
primaryEntity: "contact",
|
|
4943
|
+
outputs: ["export"],
|
|
4944
|
+
stageKey: "uploaded",
|
|
4945
|
+
dependsOn: ["personalize"],
|
|
4946
|
+
dependencyMode: "per-record-eligibility",
|
|
4947
|
+
capabilityKey: "lead-gen.review.outreach-ready",
|
|
4948
|
+
defaultBatchSize: 25,
|
|
4949
|
+
maxBatchSize: 100
|
|
4950
|
+
}
|
|
4951
|
+
},
|
|
4952
|
+
dtcApolloClickup: {
|
|
4953
|
+
importApolloSearch: {
|
|
4954
|
+
id: "import-apollo-search",
|
|
4955
|
+
label: "Companies found",
|
|
4956
|
+
description: "Pull companies and seed contact data from a predefined Apollo search or list.",
|
|
4957
|
+
primaryEntity: "company",
|
|
4958
|
+
outputs: ["company", "contact"],
|
|
4959
|
+
stageKey: "populated",
|
|
4960
|
+
dependencyMode: "per-record-eligibility",
|
|
4961
|
+
capabilityKey: "lead-gen.company.apollo-import",
|
|
4962
|
+
defaultBatchSize: 250,
|
|
4963
|
+
maxBatchSize: 1e3
|
|
4964
|
+
},
|
|
4965
|
+
analyzeWebsites: {
|
|
4966
|
+
id: "analyze-websites",
|
|
4967
|
+
label: "Websites analyzed",
|
|
4968
|
+
description: "Extract subscription, product, retention, and tech-stack signals from each brand website.",
|
|
4969
|
+
primaryEntity: "company",
|
|
4970
|
+
outputs: ["company"],
|
|
4971
|
+
stageKey: "extracted",
|
|
4972
|
+
dependsOn: ["import-apollo-search"],
|
|
4973
|
+
dependencyMode: "per-record-eligibility",
|
|
4974
|
+
capabilityKey: "lead-gen.company.website-extract",
|
|
4975
|
+
defaultBatchSize: 50,
|
|
4976
|
+
maxBatchSize: 100
|
|
4977
|
+
},
|
|
4978
|
+
scoreDtcFit: {
|
|
4979
|
+
id: "score-dtc-fit",
|
|
4980
|
+
label: "Companies qualified",
|
|
4981
|
+
description: "Classify subscription potential, consumable-product fit, retention maturity, and disqualifiers.",
|
|
4982
|
+
primaryEntity: "company",
|
|
4983
|
+
outputs: ["company"],
|
|
4984
|
+
stageKey: "qualified",
|
|
4985
|
+
dependsOn: ["analyze-websites"],
|
|
4986
|
+
dependencyMode: "per-record-eligibility",
|
|
4987
|
+
capabilityKey: "lead-gen.company.dtc-subscription-qualify",
|
|
4988
|
+
defaultBatchSize: 100,
|
|
4989
|
+
maxBatchSize: 250
|
|
4990
|
+
},
|
|
4991
|
+
enrichDecisionMakers: {
|
|
4992
|
+
id: "enrich-decision-makers",
|
|
4993
|
+
label: "Decision-makers found",
|
|
4994
|
+
description: "Use Apollo to find qualified contacts at qualified companies - founders, retention leads, lifecycle leads, and marketing owners.",
|
|
4995
|
+
primaryEntity: "company",
|
|
4996
|
+
outputs: ["contact"],
|
|
4997
|
+
stageKey: "decision-makers-enriched",
|
|
4998
|
+
dependsOn: ["score-dtc-fit"],
|
|
4999
|
+
dependencyMode: "per-record-eligibility",
|
|
5000
|
+
capabilityKey: "lead-gen.contact.apollo-decision-maker-enrich",
|
|
5001
|
+
defaultBatchSize: 100,
|
|
5002
|
+
maxBatchSize: 250
|
|
5003
|
+
},
|
|
5004
|
+
verifyEmails: {
|
|
5005
|
+
id: "verify-emails",
|
|
5006
|
+
label: "Emails verified",
|
|
5007
|
+
description: "Verify deliverability before the QC and handoff step.",
|
|
5008
|
+
primaryEntity: "contact",
|
|
5009
|
+
outputs: ["contact"],
|
|
5010
|
+
stageKey: "verified",
|
|
5011
|
+
dependsOn: ["enrich-decision-makers"],
|
|
5012
|
+
dependencyMode: "per-record-eligibility",
|
|
5013
|
+
capabilityKey: "lead-gen.contact.verify-email",
|
|
5014
|
+
defaultBatchSize: 250,
|
|
5015
|
+
maxBatchSize: 500
|
|
5016
|
+
},
|
|
5017
|
+
reviewAndExport: {
|
|
5018
|
+
id: "review-and-export",
|
|
5019
|
+
label: "Reviewed and exported",
|
|
5020
|
+
description: "Operator QC approves or rejects leads, then approved records are exported as a lead list.",
|
|
5021
|
+
primaryEntity: "company",
|
|
5022
|
+
outputs: ["export"],
|
|
5023
|
+
stageKey: "uploaded",
|
|
5024
|
+
dependsOn: ["verify-emails"],
|
|
5025
|
+
dependencyMode: "per-record-eligibility",
|
|
5026
|
+
capabilityKey: "lead-gen.export.list",
|
|
5027
|
+
defaultBatchSize: 100,
|
|
5028
|
+
maxBatchSize: 250
|
|
5029
|
+
}
|
|
5030
|
+
}
|
|
5031
|
+
};
|
|
5032
|
+
z.object({
|
|
5033
|
+
listEntityId: ModelIdSchema,
|
|
5034
|
+
companyEntityId: ModelIdSchema,
|
|
5035
|
+
contactEntityId: ModelIdSchema,
|
|
5036
|
+
description: DescriptionSchema.optional(),
|
|
5037
|
+
companyStages: z.array(ProspectingLifecycleStageSchema).min(1),
|
|
5038
|
+
contactStages: z.array(ProspectingLifecycleStageSchema).min(1),
|
|
5039
|
+
defaultBuildTemplateId: ModelIdSchema,
|
|
5040
|
+
buildTemplates: z.array(ProspectingBuildTemplateSchema).min(1)
|
|
5041
|
+
});
|
|
5042
|
+
function toProspectingLifecycleStage(stage) {
|
|
5043
|
+
return {
|
|
5044
|
+
id: stage.key,
|
|
5045
|
+
label: stage.label,
|
|
5046
|
+
order: stage.order
|
|
5047
|
+
};
|
|
5048
|
+
}
|
|
5049
|
+
function leadGenStagesForEntity(entity) {
|
|
5050
|
+
return Object.values(LEAD_GEN_STAGE_CATALOG).filter((stage) => stage.entity === entity).sort((a, b) => a.order - b.order).map(toProspectingLifecycleStage);
|
|
5051
|
+
}
|
|
5052
|
+
var DEFAULT_ORGANIZATION_MODEL_PROSPECTING = {
|
|
5053
|
+
companyStages: leadGenStagesForEntity("company"),
|
|
5054
|
+
contactStages: leadGenStagesForEntity("contact"),
|
|
5055
|
+
buildTemplates: [
|
|
5056
|
+
{
|
|
5057
|
+
id: "local-services",
|
|
5058
|
+
label: "Local Services Prospecting",
|
|
5059
|
+
description: "Curated local-services list build using company sourcing, website analysis, qualification, contact discovery, verification, personalization, and review.",
|
|
5060
|
+
steps: [
|
|
5061
|
+
PROSPECTING_STEPS.localServices.sourceCompanies,
|
|
5062
|
+
PROSPECTING_STEPS.localServices.analyzeWebsites,
|
|
5063
|
+
PROSPECTING_STEPS.localServices.qualifyCompanies,
|
|
5064
|
+
PROSPECTING_STEPS.localServices.findContacts,
|
|
5065
|
+
PROSPECTING_STEPS.localServices.verifyEmails,
|
|
5066
|
+
PROSPECTING_STEPS.localServices.personalize,
|
|
5067
|
+
PROSPECTING_STEPS.localServices.review
|
|
5068
|
+
]
|
|
5069
|
+
},
|
|
5070
|
+
{
|
|
5071
|
+
id: "dtc-subscription-apollo-clickup",
|
|
5072
|
+
label: "DTC Subscription Apollo Export",
|
|
5073
|
+
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.",
|
|
5074
|
+
steps: [
|
|
5075
|
+
PROSPECTING_STEPS.dtcApolloClickup.importApolloSearch,
|
|
5076
|
+
PROSPECTING_STEPS.dtcApolloClickup.analyzeWebsites,
|
|
5077
|
+
PROSPECTING_STEPS.dtcApolloClickup.scoreDtcFit,
|
|
5078
|
+
PROSPECTING_STEPS.dtcApolloClickup.enrichDecisionMakers,
|
|
5079
|
+
PROSPECTING_STEPS.dtcApolloClickup.verifyEmails,
|
|
5080
|
+
PROSPECTING_STEPS.dtcApolloClickup.reviewAndExport
|
|
5081
|
+
]
|
|
5082
|
+
}
|
|
5083
|
+
]
|
|
5084
|
+
};
|
|
5085
|
+
|
|
5086
|
+
// ../core/src/business/acquisition/build-templates.ts
|
|
5087
|
+
var PROSPECTING_BUILD_TEMPLATE_OPTIONS = DEFAULT_ORGANIZATION_MODEL_PROSPECTING.buildTemplates.map(
|
|
5088
|
+
({ id, label, description }) => ({
|
|
5089
|
+
id,
|
|
5090
|
+
label,
|
|
5091
|
+
description
|
|
5092
|
+
})
|
|
5093
|
+
);
|
|
5094
|
+
function isProspectingBuildTemplateId(value) {
|
|
5095
|
+
return PROSPECTING_BUILD_TEMPLATE_OPTIONS.some((template) => template.id === value);
|
|
5096
|
+
}
|
|
5097
|
+
var ProcessingStageStatusSchema = z.enum(["success", "no_result", "skipped", "error"]);
|
|
5098
|
+
var LeadGenStageKeySchema = z.string().refine((value) => Object.prototype.hasOwnProperty.call(LEAD_GEN_STAGE_CATALOG, value), {
|
|
5099
|
+
message: "processing state key must match LEAD_GEN_STAGE_CATALOG"
|
|
5100
|
+
});
|
|
5101
|
+
var LeadGenCapabilityKeySchema = z.string().refine((value) => Object.prototype.hasOwnProperty.call(CAPABILITY_REGISTRY, value), {
|
|
5102
|
+
message: "capabilityKey must match CAPABILITY_REGISTRY"
|
|
5103
|
+
});
|
|
5104
|
+
var ProcessingStateEntrySchema = z.object({
|
|
5105
|
+
status: ProcessingStageStatusSchema,
|
|
5106
|
+
data: z.unknown().optional()
|
|
5107
|
+
}).passthrough();
|
|
5108
|
+
var ProcessingStateSchema = z.record(LeadGenStageKeySchema, ProcessingStateEntrySchema);
|
|
5109
|
+
var CompanyProcessingStateSchema = ProcessingStateSchema;
|
|
5110
|
+
var ContactProcessingStateSchema = ProcessingStateSchema;
|
|
5111
|
+
var DealStageSchema = z.enum(["interested", "proposal", "closing", "closed_won", "closed_lost", "nurturing"]);
|
|
5112
|
+
var AcqDealTaskKindSchema = z.enum(["call", "email", "meeting", "other"]);
|
|
5113
|
+
z.object({
|
|
5114
|
+
dealId: UuidSchema
|
|
5115
|
+
});
|
|
5116
|
+
z.object({
|
|
5117
|
+
dealId: UuidSchema,
|
|
5118
|
+
taskId: UuidSchema
|
|
5119
|
+
});
|
|
5120
|
+
z.object({
|
|
5121
|
+
stage: DealStageSchema.optional(),
|
|
5122
|
+
search: z.string().optional(),
|
|
5123
|
+
limit: z.coerce.number().int().positive().default(50),
|
|
5124
|
+
offset: z.coerce.number().int().min(0).default(0)
|
|
5125
|
+
}).strict();
|
|
5126
|
+
z.object({
|
|
5127
|
+
search: z.string().trim().min(1).max(200).optional(),
|
|
5128
|
+
limit: z.coerce.number().int().min(1).max(25).default(10)
|
|
5129
|
+
}).strict();
|
|
5130
|
+
z.object({
|
|
5131
|
+
window: z.enum(["overdue", "today", "today_and_overdue", "upcoming"]).optional(),
|
|
5132
|
+
assigneeUserId: UuidSchema.optional()
|
|
5133
|
+
}).strict();
|
|
5134
|
+
z.object({
|
|
5135
|
+
body: z.string().trim().min(1).max(1e4)
|
|
5136
|
+
}).strict();
|
|
5137
|
+
z.object({
|
|
5138
|
+
title: z.string().trim().min(1).max(255),
|
|
5139
|
+
description: z.string().nullable().optional(),
|
|
5140
|
+
kind: AcqDealTaskKindSchema.optional(),
|
|
5141
|
+
dueAt: z.string().datetime().nullable().optional(),
|
|
5142
|
+
assigneeUserId: UuidSchema.nullable().optional()
|
|
5143
|
+
}).strict();
|
|
5144
|
+
z.object({
|
|
5145
|
+
pipelineKey: z.string().min(1),
|
|
5146
|
+
stageKey: z.string().min(1),
|
|
5147
|
+
stateKey: z.string().nullable().optional(),
|
|
5148
|
+
reason: z.string().optional(),
|
|
5149
|
+
expectedUpdatedAt: z.string().datetime().optional()
|
|
5150
|
+
}).strict();
|
|
5151
|
+
z.object({
|
|
5152
|
+
stateKey: z.string().min(1),
|
|
5153
|
+
reason: z.string().optional(),
|
|
5154
|
+
expectedUpdatedAt: z.string().datetime().optional()
|
|
5155
|
+
}).strict();
|
|
5156
|
+
z.object({
|
|
5157
|
+
dealId: UuidSchema,
|
|
5158
|
+
actionKey: NonEmptyStringSchema
|
|
5159
|
+
}).strict();
|
|
5160
|
+
z.object({
|
|
5161
|
+
payload: z.record(z.string(), z.unknown()).optional()
|
|
5162
|
+
}).strict();
|
|
5163
|
+
var DealContactSummarySchema = z.object({
|
|
5164
|
+
id: z.string(),
|
|
5165
|
+
first_name: z.string().nullable(),
|
|
5166
|
+
last_name: z.string().nullable(),
|
|
5167
|
+
email: z.string(),
|
|
5168
|
+
title: z.string().nullable(),
|
|
5169
|
+
headline: z.string().nullable(),
|
|
5170
|
+
linkedin_url: z.string().nullable(),
|
|
5171
|
+
processing_state: ProcessingStateSchema.nullable(),
|
|
5172
|
+
enrichment_data: z.record(z.string(), z.unknown()).nullable(),
|
|
5173
|
+
company: z.object({
|
|
5174
|
+
id: z.string(),
|
|
5175
|
+
name: z.string(),
|
|
5176
|
+
domain: z.string().nullable(),
|
|
5177
|
+
website: z.string().nullable(),
|
|
5178
|
+
linkedin_url: z.string().nullable(),
|
|
5179
|
+
segment: z.string().nullable(),
|
|
5180
|
+
category: z.string().nullable(),
|
|
5181
|
+
num_employees: z.number().nullable()
|
|
5182
|
+
}).nullable()
|
|
5183
|
+
});
|
|
5184
|
+
var DealPrioritySchema = z.object({
|
|
5185
|
+
bucketKey: z.enum(["needs_response", "follow_up_due", "waiting", "stale", "closed_low"]),
|
|
5186
|
+
rank: z.number().int(),
|
|
5187
|
+
label: z.string(),
|
|
5188
|
+
color: z.string(),
|
|
5189
|
+
reason: z.string(),
|
|
5190
|
+
latestActivityAt: z.string().nullable(),
|
|
5191
|
+
nextActionAt: z.string().nullable()
|
|
5192
|
+
});
|
|
5193
|
+
var DealListItemSchema = z.object({
|
|
5194
|
+
// acq_deals columns
|
|
5195
|
+
id: z.string(),
|
|
5196
|
+
organization_id: z.string(),
|
|
5197
|
+
contact_id: z.string().nullable(),
|
|
5198
|
+
contact_email: z.string(),
|
|
5199
|
+
pipeline_key: z.string(),
|
|
5200
|
+
stage_key: z.string().nullable(),
|
|
5201
|
+
state_key: z.string().nullable(),
|
|
5202
|
+
activity_log: z.unknown(),
|
|
5203
|
+
discovery_data: z.unknown().nullable(),
|
|
5204
|
+
discovery_submitted_at: z.string().nullable(),
|
|
5205
|
+
discovery_submitted_by: z.string().nullable(),
|
|
5206
|
+
proposal_data: z.unknown().nullable(),
|
|
5207
|
+
proposal_sent_at: z.string().nullable(),
|
|
5208
|
+
proposal_pdf_url: z.string().nullable(),
|
|
5209
|
+
signature_envelope_id: z.string().nullable(),
|
|
5210
|
+
source_list_id: z.string().nullable(),
|
|
5211
|
+
source_type: z.string().nullable(),
|
|
5212
|
+
initial_fee: z.number().nullable(),
|
|
5213
|
+
monthly_fee: z.number().nullable(),
|
|
5214
|
+
closed_lost_at: z.string().nullable(),
|
|
5215
|
+
closed_lost_reason: z.string().nullable(),
|
|
5216
|
+
created_at: z.string(),
|
|
5217
|
+
updated_at: z.string(),
|
|
5218
|
+
priority: DealPrioritySchema,
|
|
5219
|
+
ownership: z.enum(["us", "them"]).nullable(),
|
|
5220
|
+
nextAction: z.string().nullable(),
|
|
5221
|
+
// joined relation
|
|
5222
|
+
contact: DealContactSummarySchema.nullable()
|
|
5223
|
+
});
|
|
5224
|
+
z.object({
|
|
5225
|
+
data: z.array(DealListItemSchema),
|
|
5226
|
+
total: z.number().int(),
|
|
5227
|
+
limit: z.number().int(),
|
|
5228
|
+
offset: z.number().int()
|
|
5229
|
+
});
|
|
5230
|
+
var DealStageSummarySchema = z.object({
|
|
5231
|
+
stage: z.string(),
|
|
5232
|
+
count: z.number().int(),
|
|
5233
|
+
totalValue: z.number(),
|
|
5234
|
+
oldestUpdatedAt: z.string().nullable(),
|
|
5235
|
+
newestUpdatedAt: z.string().nullable()
|
|
5236
|
+
});
|
|
5237
|
+
var StaleDealSummarySchema = z.object({
|
|
5238
|
+
id: z.string(),
|
|
5239
|
+
contactEmail: z.string(),
|
|
5240
|
+
stageKey: z.string(),
|
|
5241
|
+
updatedAt: z.string(),
|
|
5242
|
+
daysStale: z.number().int()
|
|
5243
|
+
});
|
|
5244
|
+
z.object({
|
|
5245
|
+
totalDeals: z.number().int(),
|
|
5246
|
+
openDeals: z.number().int(),
|
|
5247
|
+
wonDeals: z.number().int(),
|
|
5248
|
+
lostDeals: z.number().int(),
|
|
5249
|
+
winRate: z.number(),
|
|
5250
|
+
avgDealSize: z.number(),
|
|
5251
|
+
totalPipelineValue: z.number(),
|
|
5252
|
+
stageSummary: z.array(DealStageSummarySchema),
|
|
5253
|
+
staleDeals: z.array(StaleDealSummarySchema)
|
|
5254
|
+
});
|
|
5255
|
+
var DealLookupItemSchema = z.object({
|
|
5256
|
+
id: z.string(),
|
|
5257
|
+
contactEmail: z.string(),
|
|
5258
|
+
stageKey: z.string().nullable(),
|
|
5259
|
+
updatedAt: z.string(),
|
|
5260
|
+
contactName: z.string().nullable(),
|
|
5261
|
+
companyName: z.string().nullable(),
|
|
5262
|
+
displayLabel: z.string()
|
|
5263
|
+
});
|
|
5264
|
+
z.array(DealLookupItemSchema);
|
|
5265
|
+
var ConversationMessageSchema = z.object({
|
|
5266
|
+
id: z.string(),
|
|
5267
|
+
direction: z.enum(["inbound", "outbound"]),
|
|
5268
|
+
fromEmail: z.string(),
|
|
5269
|
+
toEmail: z.string(),
|
|
5270
|
+
subject: z.string().nullable(),
|
|
5271
|
+
body: z.string(),
|
|
5272
|
+
sentAt: z.string().nullable()
|
|
5273
|
+
});
|
|
5274
|
+
var DealConversationSchema = z.object({
|
|
5275
|
+
messages: z.array(ConversationMessageSchema)
|
|
5276
|
+
});
|
|
5277
|
+
DealListItemSchema.extend({
|
|
5278
|
+
conversation: DealConversationSchema
|
|
5279
|
+
});
|
|
5280
|
+
var DealNoteResponseSchema = z.object({
|
|
5281
|
+
id: z.string(),
|
|
5282
|
+
dealId: z.string(),
|
|
5283
|
+
organizationId: z.string(),
|
|
5284
|
+
authorUserId: z.string().nullable(),
|
|
5285
|
+
body: z.string(),
|
|
5286
|
+
createdAt: z.string(),
|
|
5287
|
+
updatedAt: z.string()
|
|
5288
|
+
});
|
|
5289
|
+
z.array(DealNoteResponseSchema);
|
|
5290
|
+
var DealTaskResponseSchema = z.object({
|
|
5291
|
+
id: z.string(),
|
|
5292
|
+
organizationId: z.string(),
|
|
5293
|
+
dealId: z.string(),
|
|
5294
|
+
title: z.string(),
|
|
5295
|
+
description: z.string().nullable(),
|
|
5296
|
+
kind: AcqDealTaskKindSchema,
|
|
5297
|
+
dueAt: z.string().nullable(),
|
|
5298
|
+
assigneeUserId: z.string().nullable(),
|
|
5299
|
+
completedAt: z.string().nullable(),
|
|
5300
|
+
completedByUserId: z.string().nullable(),
|
|
5301
|
+
createdAt: z.string(),
|
|
5302
|
+
updatedAt: z.string(),
|
|
5303
|
+
createdByUserId: z.string().nullable()
|
|
5304
|
+
});
|
|
5305
|
+
z.array(DealTaskResponseSchema);
|
|
5306
|
+
var ListStatusSchema = z.enum(["draft", "enriching", "launched", "closing", "archived"]);
|
|
5307
|
+
var ScrapingConfigSchema = z.object({
|
|
5308
|
+
vertical: z.string().trim().max(255).optional(),
|
|
5309
|
+
geography: z.string().trim().max(500).optional(),
|
|
5310
|
+
size: z.string().trim().max(255).optional(),
|
|
5311
|
+
apifyInput: z.record(z.string(), z.unknown()).optional()
|
|
5312
|
+
});
|
|
5313
|
+
var IcpRubricSchema = z.object({
|
|
5314
|
+
qualificationRubricKey: z.string().trim().max(255).nullish(),
|
|
5315
|
+
targetDescription: z.string().optional(),
|
|
5316
|
+
minReviewCount: z.number().int().min(0).optional(),
|
|
5317
|
+
minRating: z.number().min(0).max(5).optional(),
|
|
5318
|
+
excludeFranchises: z.boolean().optional(),
|
|
5319
|
+
customRules: z.string().optional()
|
|
5320
|
+
});
|
|
5321
|
+
var PipelineStageSchema = z.object({
|
|
5322
|
+
key: z.string().refine((value) => Object.prototype.hasOwnProperty.call(LEAD_GEN_STAGE_CATALOG, value), {
|
|
5323
|
+
message: "pipeline stage key must match LEAD_GEN_STAGE_CATALOG"
|
|
5324
|
+
}),
|
|
5325
|
+
label: z.string().optional(),
|
|
5326
|
+
enabled: z.boolean().optional(),
|
|
5327
|
+
order: z.number().int().optional()
|
|
5328
|
+
});
|
|
5329
|
+
var PipelineConfigSchema = z.object({
|
|
5330
|
+
stages: z.array(PipelineStageSchema).optional()
|
|
5331
|
+
});
|
|
5332
|
+
var BuildPlanSnapshotStepSchema = z.object({
|
|
5333
|
+
id: z.string().trim().min(1).max(100),
|
|
5334
|
+
label: z.string().trim().min(1).max(120),
|
|
5335
|
+
description: z.string().trim().min(1).max(2e3).optional(),
|
|
5336
|
+
primaryEntity: z.enum(["company", "contact"]),
|
|
5337
|
+
outputs: z.array(z.enum(["company", "contact", "export"])).min(1),
|
|
5338
|
+
stageKey: LeadGenStageKeySchema,
|
|
5339
|
+
dependsOn: z.array(z.string().trim().min(1).max(100)).optional(),
|
|
5340
|
+
dependencyMode: z.literal("per-record-eligibility"),
|
|
5341
|
+
capabilityKey: LeadGenCapabilityKeySchema,
|
|
5342
|
+
defaultBatchSize: z.number().int().positive(),
|
|
5343
|
+
maxBatchSize: z.number().int().positive()
|
|
5344
|
+
}).refine((step) => step.defaultBatchSize <= step.maxBatchSize, {
|
|
5345
|
+
message: "defaultBatchSize must be less than or equal to maxBatchSize",
|
|
5346
|
+
path: ["defaultBatchSize"]
|
|
5347
|
+
});
|
|
5348
|
+
var BuildPlanSnapshotSchema = z.object({
|
|
5349
|
+
templateId: z.string().trim().min(1).max(100),
|
|
5350
|
+
templateLabel: z.string().trim().min(1).max(120),
|
|
5351
|
+
steps: z.array(BuildPlanSnapshotStepSchema).min(1)
|
|
5352
|
+
}).superRefine((snapshot, ctx) => {
|
|
5353
|
+
const stepIds = /* @__PURE__ */ new Set();
|
|
5354
|
+
snapshot.steps.forEach((step, index) => {
|
|
5355
|
+
if (stepIds.has(step.id)) {
|
|
5356
|
+
ctx.addIssue({
|
|
5357
|
+
code: z.ZodIssueCode.custom,
|
|
5358
|
+
message: `duplicate build-plan step id "${step.id}"`,
|
|
5359
|
+
path: ["steps", index, "id"]
|
|
5360
|
+
});
|
|
5361
|
+
}
|
|
5362
|
+
stepIds.add(step.id);
|
|
5363
|
+
});
|
|
5364
|
+
snapshot.steps.forEach((step, index) => {
|
|
5365
|
+
for (const dependencyId of step.dependsOn ?? []) {
|
|
5366
|
+
if (!stepIds.has(dependencyId)) {
|
|
5367
|
+
ctx.addIssue({
|
|
5368
|
+
code: z.ZodIssueCode.custom,
|
|
5369
|
+
message: `dependsOn references unknown build-plan step "${dependencyId}"`,
|
|
5370
|
+
path: ["steps", index, "dependsOn"]
|
|
5371
|
+
});
|
|
5372
|
+
}
|
|
5373
|
+
}
|
|
5374
|
+
});
|
|
5375
|
+
});
|
|
5376
|
+
var AcqListMetadataSchema = z.object({
|
|
5377
|
+
buildPlanSnapshot: BuildPlanSnapshotSchema.optional()
|
|
5378
|
+
}).catchall(z.unknown());
|
|
5379
|
+
var ProspectingBuildTemplateIdSchema = z.string().trim().min(1).max(100).refine(isProspectingBuildTemplateId, {
|
|
5380
|
+
message: "buildTemplateId must match a known prospecting build template"
|
|
5381
|
+
});
|
|
5382
|
+
var ListStageCountsSchema = z.object({
|
|
5383
|
+
// Attempted counts by canonical lead-gen stage. The detailed status
|
|
5384
|
+
// distribution lives on ListProgress; telemetry keeps the overview payload small.
|
|
5385
|
+
stageCounts: z.object({
|
|
5386
|
+
populated: z.number().int(),
|
|
5387
|
+
extracted: z.number().int(),
|
|
5388
|
+
qualified: z.number().int(),
|
|
5389
|
+
discovered: z.number().int(),
|
|
5390
|
+
verified: z.number().int(),
|
|
5391
|
+
personalized: z.number().int(),
|
|
5392
|
+
uploaded: z.number().int()
|
|
5393
|
+
}),
|
|
5394
|
+
deliverability: z.object({
|
|
5395
|
+
valid: z.number().int(),
|
|
5396
|
+
risky: z.number().int(),
|
|
5397
|
+
invalid: z.number().int(),
|
|
5398
|
+
unknown: z.number().int(),
|
|
5399
|
+
bounced: z.number().int()
|
|
5400
|
+
})
|
|
5401
|
+
});
|
|
5402
|
+
var ListTelemetrySchema = z.object({
|
|
5403
|
+
listId: UuidSchema,
|
|
5404
|
+
totalCompanies: z.number().int(),
|
|
5405
|
+
totalContacts: z.number().int(),
|
|
5406
|
+
stageCounts: ListStageCountsSchema.shape.stageCounts,
|
|
5407
|
+
deliverability: ListStageCountsSchema.shape.deliverability,
|
|
5408
|
+
activeWorkflows: z.array(z.string()).optional()
|
|
5409
|
+
});
|
|
5410
|
+
z.object({
|
|
5411
|
+
listId: UuidSchema
|
|
5412
|
+
});
|
|
5413
|
+
z.object({
|
|
5414
|
+
name: z.string().trim().min(1).max(255),
|
|
5415
|
+
description: z.string().trim().nullable().optional(),
|
|
5416
|
+
status: ListStatusSchema.optional(),
|
|
5417
|
+
buildTemplateId: ProspectingBuildTemplateIdSchema.optional(),
|
|
5418
|
+
scrapingConfig: ScrapingConfigSchema.optional(),
|
|
5419
|
+
icp: IcpRubricSchema.optional(),
|
|
5420
|
+
pipelineConfig: PipelineConfigSchema.optional()
|
|
5421
|
+
}).strict();
|
|
5422
|
+
z.object({
|
|
5423
|
+
name: z.string().trim().min(1).max(255).optional(),
|
|
5424
|
+
description: z.string().trim().nullable().optional(),
|
|
5425
|
+
batchIds: z.array(z.string()).optional(),
|
|
5426
|
+
buildTemplateId: ProspectingBuildTemplateIdSchema.optional(),
|
|
5427
|
+
confirmBuildTemplateChange: z.literal(true).optional()
|
|
5428
|
+
}).strict().refine(
|
|
5429
|
+
(data) => data.name !== void 0 || data.description !== void 0 || data.batchIds !== void 0 || data.buildTemplateId !== void 0,
|
|
5430
|
+
{
|
|
5431
|
+
message: "At least one field (name, description, batchIds, or buildTemplateId) must be provided"
|
|
5432
|
+
}
|
|
5433
|
+
).refine((data) => data.buildTemplateId === void 0 || data.confirmBuildTemplateChange === true, {
|
|
5434
|
+
message: "confirmBuildTemplateChange must be true when changing buildTemplateId",
|
|
5435
|
+
path: ["confirmBuildTemplateChange"]
|
|
5436
|
+
});
|
|
5437
|
+
z.object({
|
|
5438
|
+
status: ListStatusSchema
|
|
5439
|
+
}).strict();
|
|
5440
|
+
z.object({
|
|
5441
|
+
scrapingConfig: ScrapingConfigSchema.partial().optional(),
|
|
5442
|
+
icp: IcpRubricSchema.partial().optional(),
|
|
5443
|
+
pipelineConfig: PipelineConfigSchema.partial().optional()
|
|
5444
|
+
}).strict().refine((data) => data.scrapingConfig !== void 0 || data.icp !== void 0 || data.pipelineConfig !== void 0, {
|
|
5445
|
+
message: "At least one of scrapingConfig, icp, or pipelineConfig must be provided"
|
|
5446
|
+
});
|
|
5447
|
+
z.object({
|
|
5448
|
+
companyIds: z.array(UuidSchema).min(1).max(1e3)
|
|
5449
|
+
}).strict();
|
|
5450
|
+
z.object({
|
|
5451
|
+
companyIds: z.array(UuidSchema).min(1).max(1e3)
|
|
5452
|
+
}).strict();
|
|
5453
|
+
z.object({
|
|
5454
|
+
contactIds: z.array(UuidSchema).min(1).max(1e3)
|
|
5455
|
+
}).strict();
|
|
5456
|
+
z.object({
|
|
5457
|
+
executionId: UuidSchema,
|
|
5458
|
+
configSnapshot: z.record(z.string(), z.unknown()).optional()
|
|
5459
|
+
}).strict();
|
|
5460
|
+
var AcqListResponseSchema = z.object({
|
|
5461
|
+
id: z.string(),
|
|
5462
|
+
organizationId: z.string(),
|
|
5463
|
+
name: z.string(),
|
|
5464
|
+
description: z.string().nullable(),
|
|
5465
|
+
batchIds: z.array(z.string()),
|
|
5466
|
+
instantlyCampaignId: z.string().nullable(),
|
|
5467
|
+
/** Lifecycle status (draft | enriching | launched | closing | archived). */
|
|
5468
|
+
status: ListStatusSchema,
|
|
5469
|
+
metadata: AcqListMetadataSchema,
|
|
5470
|
+
launchedAt: z.string().nullable(),
|
|
5471
|
+
completedAt: z.string().nullable(),
|
|
5472
|
+
createdAt: z.string(),
|
|
5473
|
+
/** Scraping criteria stored as jsonb on the row. */
|
|
5474
|
+
scrapingConfig: ScrapingConfigSchema,
|
|
5475
|
+
/** ICP / qualification rubric stored as jsonb on the row. */
|
|
5476
|
+
icp: IcpRubricSchema,
|
|
5477
|
+
/** Pipeline presentation contract stored as jsonb on the row. */
|
|
5478
|
+
pipelineConfig: PipelineConfigSchema
|
|
5479
|
+
});
|
|
5480
|
+
z.array(AcqListResponseSchema);
|
|
5481
|
+
z.array(ListTelemetrySchema);
|
|
5482
|
+
var ListStageProgressSchema = z.object({
|
|
5483
|
+
total: z.number().int().min(0),
|
|
5484
|
+
attempted: z.number().int().min(0),
|
|
5485
|
+
success: z.number().int().min(0),
|
|
5486
|
+
noResult: z.number().int().min(0),
|
|
5487
|
+
skipped: z.number().int().min(0),
|
|
5488
|
+
error: z.number().int().min(0),
|
|
5489
|
+
other: z.number().int().min(0),
|
|
5490
|
+
notAttempted: z.number().int().min(0)
|
|
5491
|
+
});
|
|
5492
|
+
z.object({
|
|
5493
|
+
totalMembers: z.number().int().min(0),
|
|
5494
|
+
totalCompanies: z.number().int().min(0),
|
|
5495
|
+
byCompanyStage: z.record(z.string(), ListStageProgressSchema),
|
|
5496
|
+
byContactStage: z.record(z.string(), ListStageProgressSchema)
|
|
5497
|
+
});
|
|
5498
|
+
var ListExecutionSummarySchema = z.object({
|
|
5499
|
+
executionId: z.string(),
|
|
5500
|
+
resourceId: z.string(),
|
|
5501
|
+
status: z.string(),
|
|
5502
|
+
createdAt: z.string(),
|
|
5503
|
+
completedAt: z.string().nullable(),
|
|
5504
|
+
durationMs: z.number().int().nullable(),
|
|
5505
|
+
input: z.unknown().nullable().optional()
|
|
5506
|
+
});
|
|
5507
|
+
z.array(ListExecutionSummarySchema);
|
|
5508
|
+
var QueryBooleanSchema = z.preprocess((value) => {
|
|
5509
|
+
if (value === "true" || value === "1" || value === true) return true;
|
|
5510
|
+
if (value === "false" || value === "0" || value === false) return false;
|
|
5511
|
+
return value;
|
|
5512
|
+
}, z.boolean());
|
|
5513
|
+
var AcqCompanyStatusSchema = z.enum(["active", "invalid"]);
|
|
5514
|
+
var AcqContactStatusSchema = z.enum(["active", "invalid"]);
|
|
5515
|
+
var AcqEmailValidSchema = z.enum(["VALID", "INVALID", "RISKY", "UNKNOWN"]);
|
|
5516
|
+
z.object({
|
|
5517
|
+
companyId: UuidSchema
|
|
5518
|
+
});
|
|
5519
|
+
z.object({
|
|
5520
|
+
contactId: UuidSchema
|
|
5521
|
+
});
|
|
5522
|
+
z.object({
|
|
5523
|
+
search: z.string().trim().min(1).max(200).optional(),
|
|
5524
|
+
listId: UuidSchema.optional(),
|
|
5525
|
+
domain: z.string().trim().min(1).max(255).optional(),
|
|
5526
|
+
website: z.string().trim().min(1).max(2048).optional(),
|
|
5527
|
+
segment: z.string().trim().min(1).max(255).optional(),
|
|
5528
|
+
category: z.string().trim().min(1).max(255).optional(),
|
|
5529
|
+
pipelineStatus: z.unknown().optional(),
|
|
5530
|
+
batchId: z.string().trim().min(1).max(255).optional(),
|
|
5531
|
+
status: AcqCompanyStatusSchema.optional(),
|
|
5532
|
+
includeAll: QueryBooleanSchema.optional(),
|
|
5533
|
+
limit: z.coerce.number().int().min(1).max(5e3).default(50),
|
|
5534
|
+
offset: z.coerce.number().int().min(0).default(0)
|
|
5535
|
+
}).strict();
|
|
5536
|
+
z.object({
|
|
5537
|
+
search: z.string().trim().min(1).max(200).optional(),
|
|
5538
|
+
listId: UuidSchema.optional(),
|
|
5539
|
+
openingLineIsNull: QueryBooleanSchema.optional(),
|
|
5540
|
+
batchId: z.string().trim().min(1).max(255).optional(),
|
|
5541
|
+
contactStatus: AcqContactStatusSchema.optional(),
|
|
5542
|
+
limit: z.coerce.number().int().min(1).max(5e3).default(5e3),
|
|
5543
|
+
offset: z.coerce.number().int().min(0).default(0)
|
|
5544
|
+
}).strict();
|
|
5545
|
+
z.object({
|
|
5546
|
+
name: z.string().trim().min(1).max(255),
|
|
5547
|
+
domain: z.string().trim().min(1).max(255).optional(),
|
|
5548
|
+
linkedinUrl: z.string().trim().url().optional(),
|
|
5549
|
+
website: z.string().trim().url().optional(),
|
|
5550
|
+
numEmployees: z.number().int().min(0).optional(),
|
|
5551
|
+
foundedYear: z.number().int().optional(),
|
|
5552
|
+
locationCity: z.string().trim().min(1).max(255).optional(),
|
|
5553
|
+
locationState: z.string().trim().min(1).max(255).optional(),
|
|
5554
|
+
category: z.string().trim().min(1).max(255).optional(),
|
|
5555
|
+
source: z.string().trim().min(1).max(255).optional(),
|
|
5556
|
+
batchId: z.string().trim().min(1).max(255).optional(),
|
|
5557
|
+
pipelineStatus: z.unknown().optional(),
|
|
5558
|
+
verticalResearch: z.string().trim().min(1).max(5e3).optional()
|
|
5559
|
+
}).strict();
|
|
5560
|
+
z.object({
|
|
5561
|
+
name: z.string().trim().min(1).max(255).optional(),
|
|
5562
|
+
domain: z.string().trim().min(1).max(255).optional(),
|
|
5563
|
+
linkedinUrl: z.string().trim().url().optional(),
|
|
5564
|
+
website: z.string().trim().url().optional(),
|
|
5565
|
+
numEmployees: z.number().int().min(0).optional(),
|
|
5566
|
+
foundedYear: z.number().int().optional(),
|
|
5567
|
+
locationCity: z.string().trim().min(1).max(255).optional(),
|
|
5568
|
+
locationState: z.string().trim().min(1).max(255).optional(),
|
|
5569
|
+
category: z.string().trim().min(1).max(255).optional(),
|
|
5570
|
+
segment: z.string().trim().min(1).max(255).optional(),
|
|
5571
|
+
processingState: CompanyProcessingStateSchema.optional(),
|
|
5572
|
+
pipelineStatus: z.unknown().optional(),
|
|
5573
|
+
enrichmentData: z.record(z.string(), z.unknown()).optional(),
|
|
5574
|
+
source: z.string().trim().min(1).max(255).optional(),
|
|
5575
|
+
batchId: z.string().trim().min(1).max(255).optional(),
|
|
5576
|
+
status: AcqCompanyStatusSchema.optional(),
|
|
5577
|
+
verticalResearch: z.string().trim().min(1).max(5e3).nullable().optional()
|
|
5578
|
+
}).strict().refine(
|
|
5579
|
+
(data) => data.name !== void 0 || data.domain !== void 0 || data.linkedinUrl !== void 0 || data.website !== void 0 || data.numEmployees !== void 0 || data.foundedYear !== void 0 || data.locationCity !== void 0 || data.locationState !== void 0 || data.category !== void 0 || data.segment !== void 0 || data.processingState !== void 0 || data.pipelineStatus !== void 0 || data.enrichmentData !== void 0 || data.source !== void 0 || data.batchId !== void 0 || data.status !== void 0 || data.verticalResearch !== void 0,
|
|
5580
|
+
{
|
|
5581
|
+
message: "At least one field must be provided"
|
|
5582
|
+
}
|
|
5583
|
+
);
|
|
5584
|
+
z.object({
|
|
5585
|
+
email: z.string().trim().email(),
|
|
5586
|
+
companyId: UuidSchema.optional(),
|
|
5587
|
+
firstName: z.string().trim().min(1).max(255).optional(),
|
|
5588
|
+
lastName: z.string().trim().min(1).max(255).optional(),
|
|
5589
|
+
linkedinUrl: z.string().trim().url().optional(),
|
|
5590
|
+
title: z.string().trim().min(1).max(255).optional(),
|
|
5591
|
+
source: z.string().trim().min(1).max(255).optional(),
|
|
5592
|
+
sourceId: z.string().trim().min(1).max(255).optional(),
|
|
5593
|
+
batchId: z.string().trim().min(1).max(255).optional(),
|
|
5594
|
+
pipelineStatus: z.unknown().optional()
|
|
5595
|
+
}).strict();
|
|
5596
|
+
z.object({
|
|
5597
|
+
companyId: UuidSchema.optional(),
|
|
5598
|
+
emailValid: AcqEmailValidSchema.optional(),
|
|
5599
|
+
firstName: z.string().trim().min(1).max(255).optional(),
|
|
5600
|
+
lastName: z.string().trim().min(1).max(255).optional(),
|
|
5601
|
+
linkedinUrl: z.string().trim().url().optional(),
|
|
5602
|
+
title: z.string().trim().min(1).max(255).optional(),
|
|
5603
|
+
headline: z.string().trim().min(1).max(5e3).optional(),
|
|
5604
|
+
filterReason: z.string().trim().min(1).max(5e3).optional(),
|
|
5605
|
+
openingLine: z.string().trim().min(1).max(5e3).optional(),
|
|
5606
|
+
processingState: ContactProcessingStateSchema.optional(),
|
|
5607
|
+
pipelineStatus: z.unknown().optional(),
|
|
5608
|
+
enrichmentData: z.record(z.string(), z.unknown()).optional(),
|
|
5609
|
+
status: AcqContactStatusSchema.optional()
|
|
5610
|
+
}).strict().refine(
|
|
5611
|
+
(data) => data.companyId !== void 0 || data.emailValid !== void 0 || data.firstName !== void 0 || data.lastName !== void 0 || data.linkedinUrl !== void 0 || data.title !== void 0 || data.headline !== void 0 || data.filterReason !== void 0 || data.openingLine !== void 0 || data.processingState !== void 0 || data.pipelineStatus !== void 0 || data.enrichmentData !== void 0 || data.status !== void 0,
|
|
5612
|
+
{
|
|
5613
|
+
message: "At least one field must be provided"
|
|
5614
|
+
}
|
|
5615
|
+
);
|
|
5616
|
+
var AcqCompanyResponseSchema = z.object({
|
|
5617
|
+
id: z.string(),
|
|
5618
|
+
organizationId: z.string(),
|
|
5619
|
+
name: z.string(),
|
|
5620
|
+
domain: z.string().nullable(),
|
|
5621
|
+
linkedinUrl: z.string().nullable(),
|
|
5622
|
+
website: z.string().nullable(),
|
|
5623
|
+
numEmployees: z.number().nullable(),
|
|
5624
|
+
foundedYear: z.number().nullable(),
|
|
5625
|
+
locationCity: z.string().nullable(),
|
|
5626
|
+
locationState: z.string().nullable(),
|
|
5627
|
+
category: z.string().nullable(),
|
|
5628
|
+
categoryPain: z.string().nullable(),
|
|
5629
|
+
segment: z.string().nullable(),
|
|
5630
|
+
processingState: CompanyProcessingStateSchema.nullable(),
|
|
5631
|
+
pipelineStatus: z.unknown().nullable().optional(),
|
|
5632
|
+
enrichmentData: z.record(z.string(), z.unknown()).nullable(),
|
|
5633
|
+
source: z.string().nullable(),
|
|
5634
|
+
batchId: z.string().nullable(),
|
|
5635
|
+
status: AcqCompanyStatusSchema,
|
|
5636
|
+
contactCount: z.number().int().min(0),
|
|
5637
|
+
verticalResearch: z.string().nullable(),
|
|
5638
|
+
createdAt: z.string(),
|
|
5639
|
+
updatedAt: z.string()
|
|
5640
|
+
});
|
|
5641
|
+
z.object({
|
|
5642
|
+
data: z.array(AcqCompanyResponseSchema),
|
|
5643
|
+
total: z.number().int(),
|
|
5644
|
+
limit: z.number().int(),
|
|
5645
|
+
offset: z.number().int()
|
|
5646
|
+
});
|
|
5647
|
+
z.object({
|
|
5648
|
+
segments: z.array(z.string()),
|
|
5649
|
+
categories: z.array(z.string()),
|
|
5650
|
+
statuses: z.array(AcqCompanyStatusSchema)
|
|
5651
|
+
});
|
|
5652
|
+
var AcqContactCompanySummarySchema = z.object({
|
|
5653
|
+
id: z.string(),
|
|
5654
|
+
name: z.string(),
|
|
5655
|
+
domain: z.string().nullable(),
|
|
5656
|
+
website: z.string().nullable(),
|
|
5657
|
+
linkedinUrl: z.string().nullable(),
|
|
5658
|
+
segment: z.string().nullable(),
|
|
5659
|
+
category: z.string().nullable(),
|
|
5660
|
+
status: AcqCompanyStatusSchema
|
|
5661
|
+
});
|
|
5662
|
+
var AcqContactResponseSchema = z.object({
|
|
5663
|
+
id: z.string(),
|
|
5664
|
+
organizationId: z.string(),
|
|
5665
|
+
companyId: z.string().nullable(),
|
|
5666
|
+
email: z.string(),
|
|
5667
|
+
emailValid: AcqEmailValidSchema.nullable(),
|
|
5668
|
+
firstName: z.string().nullable(),
|
|
5669
|
+
lastName: z.string().nullable(),
|
|
5670
|
+
linkedinUrl: z.string().nullable(),
|
|
5671
|
+
title: z.string().nullable(),
|
|
5672
|
+
headline: z.string().nullable(),
|
|
5673
|
+
filterReason: z.string().nullable(),
|
|
5674
|
+
openingLine: z.string().nullable(),
|
|
5675
|
+
source: z.string().nullable(),
|
|
5676
|
+
sourceId: z.string().nullable(),
|
|
5677
|
+
processingState: ContactProcessingStateSchema.nullable(),
|
|
5678
|
+
pipelineStatus: z.unknown().nullable().optional(),
|
|
5679
|
+
enrichmentData: z.record(z.string(), z.unknown()).nullable(),
|
|
5680
|
+
attioPersonId: z.string().nullable(),
|
|
5681
|
+
batchId: z.string().nullable(),
|
|
5682
|
+
status: AcqContactStatusSchema,
|
|
5683
|
+
company: AcqContactCompanySummarySchema.nullable().optional(),
|
|
5684
|
+
createdAt: z.string(),
|
|
5685
|
+
updatedAt: z.string()
|
|
5686
|
+
});
|
|
5687
|
+
z.object({
|
|
5688
|
+
data: z.array(AcqContactResponseSchema),
|
|
5689
|
+
total: z.number().int(),
|
|
5690
|
+
limit: z.number().int(),
|
|
5691
|
+
offset: z.number().int()
|
|
5692
|
+
});
|
|
5693
|
+
var AcqArtifactOwnerKindSchema = z.enum(["company", "contact", "deal", "list", "list_member"]);
|
|
5694
|
+
z.object({
|
|
5695
|
+
ownerKind: AcqArtifactOwnerKindSchema,
|
|
5696
|
+
ownerId: UuidSchema
|
|
5697
|
+
}).strict();
|
|
5698
|
+
z.object({
|
|
5699
|
+
ownerKind: AcqArtifactOwnerKindSchema,
|
|
5700
|
+
ownerId: UuidSchema,
|
|
5701
|
+
kind: z.string().trim().min(1).max(255),
|
|
5702
|
+
content: z.record(z.string(), z.unknown()),
|
|
5703
|
+
sourceExecutionId: UuidSchema.optional()
|
|
5704
|
+
}).strict();
|
|
5705
|
+
var AcqArtifactResponseSchema = z.object({
|
|
5706
|
+
id: z.string(),
|
|
5707
|
+
organizationId: z.string(),
|
|
5708
|
+
ownerKind: z.string(),
|
|
5709
|
+
ownerId: z.string(),
|
|
5710
|
+
kind: z.string(),
|
|
5711
|
+
content: z.record(z.string(), z.unknown()),
|
|
5712
|
+
sourceExecutionId: z.string().nullable(),
|
|
5713
|
+
createdBy: z.string().nullable(),
|
|
5714
|
+
createdAt: z.string(),
|
|
5715
|
+
version: z.number().int()
|
|
5716
|
+
});
|
|
5717
|
+
z.object({
|
|
5718
|
+
artifacts: z.array(AcqArtifactResponseSchema)
|
|
5719
|
+
});
|
|
5720
|
+
z.object({
|
|
5721
|
+
limit: z.coerce.number().int().min(1).max(500).default(50),
|
|
5722
|
+
offset: z.coerce.number().int().min(0).default(0)
|
|
5723
|
+
}).strict();
|
|
5724
|
+
z.object({
|
|
5725
|
+
memberId: UuidSchema
|
|
5726
|
+
});
|
|
5727
|
+
var AcqListMemberContactSummarySchema = z.object({
|
|
5728
|
+
id: z.string(),
|
|
5729
|
+
email: z.string(),
|
|
5730
|
+
firstName: z.string().nullable(),
|
|
5731
|
+
lastName: z.string().nullable(),
|
|
5732
|
+
title: z.string().nullable(),
|
|
5733
|
+
linkedinUrl: z.string().nullable(),
|
|
5734
|
+
companyId: z.string().nullable()
|
|
5735
|
+
});
|
|
5736
|
+
var AcqListMemberResponseSchema = z.object({
|
|
5737
|
+
id: z.string(),
|
|
5738
|
+
listId: z.string(),
|
|
5739
|
+
contactId: z.string(),
|
|
5740
|
+
pipelineKey: z.string(),
|
|
5741
|
+
stageKey: z.string(),
|
|
5742
|
+
stateKey: z.string(),
|
|
5743
|
+
activityLog: z.unknown(),
|
|
5744
|
+
addedAt: z.string(),
|
|
5745
|
+
addedBy: z.string().nullable(),
|
|
5746
|
+
sourceExecutionId: z.string().nullable(),
|
|
5747
|
+
contact: AcqListMemberContactSummarySchema.nullable()
|
|
5748
|
+
});
|
|
5749
|
+
z.object({
|
|
5750
|
+
members: z.array(AcqListMemberResponseSchema)
|
|
5751
|
+
});
|
|
5752
|
+
z.object({
|
|
5753
|
+
listCompanyId: UuidSchema
|
|
5754
|
+
});
|
|
5755
|
+
z.object({
|
|
5756
|
+
id: z.string(),
|
|
5757
|
+
listId: z.string(),
|
|
5758
|
+
companyId: z.string(),
|
|
5759
|
+
pipelineKey: z.string(),
|
|
5760
|
+
stageKey: z.string(),
|
|
5761
|
+
stateKey: z.string(),
|
|
5762
|
+
activityLog: z.unknown(),
|
|
5763
|
+
addedAt: z.string(),
|
|
5764
|
+
addedBy: z.string().nullable(),
|
|
5765
|
+
sourceExecutionId: z.string().nullable()
|
|
5766
|
+
});
|
|
4583
5767
|
var RETRYABLE_CODES = /* @__PURE__ */ new Set([
|
|
4584
5768
|
"rate_limit_exceeded",
|
|
4585
5769
|
"network_error",
|
|
@@ -5067,7 +6251,9 @@ var list = createAdapter("list", [
|
|
|
5067
6251
|
"getConfig",
|
|
5068
6252
|
"recordExecution",
|
|
5069
6253
|
"updateCompanyStage",
|
|
5070
|
-
"updateContactStage"
|
|
6254
|
+
"updateContactStage",
|
|
6255
|
+
"listPendingCompanyIds",
|
|
6256
|
+
"listPendingContactIds"
|
|
5071
6257
|
]);
|
|
5072
6258
|
|
|
5073
6259
|
// src/worker/adapters/pdf.ts
|
|
@@ -5081,6 +6267,191 @@ var execution = createAdapter("execution", ["trigger", "triggerAsync"]);
|
|
|
5081
6267
|
|
|
5082
6268
|
// src/worker/adapters/email.ts
|
|
5083
6269
|
var email = createAdapter("email", ["send"]);
|
|
6270
|
+
var listBuilderStageKeys = Object.keys(LEAD_GEN_STAGE_CATALOG);
|
|
6271
|
+
var ListBuilderStageKeySchema = z.enum(listBuilderStageKeys);
|
|
6272
|
+
|
|
6273
|
+
// src/worker/list-builder-workflow.ts
|
|
6274
|
+
var ListBuilderResultSchema = z.object({
|
|
6275
|
+
entity: z.enum(["company", "contact"]),
|
|
6276
|
+
id: z.string().min(1),
|
|
6277
|
+
status: ProcessingStageStatusSchema,
|
|
6278
|
+
stageKey: ListBuilderStageKeySchema.optional(),
|
|
6279
|
+
data: z.unknown().optional()
|
|
6280
|
+
});
|
|
6281
|
+
var ListBuilderResultsSchema = z.array(ListBuilderResultSchema);
|
|
6282
|
+
function getObjectShape(schema) {
|
|
6283
|
+
const candidate = schema;
|
|
6284
|
+
if ("shape" in candidate && candidate.shape && typeof candidate.shape === "object") {
|
|
6285
|
+
return candidate.shape;
|
|
6286
|
+
}
|
|
6287
|
+
return null;
|
|
6288
|
+
}
|
|
6289
|
+
function assertNoReservedInputKeys(schema) {
|
|
6290
|
+
const shape = getObjectShape(schema);
|
|
6291
|
+
if (!shape) {
|
|
6292
|
+
return;
|
|
6293
|
+
}
|
|
6294
|
+
const reservedKeys = ["params", "batch"].filter((key) => Object.prototype.hasOwnProperty.call(shape, key));
|
|
6295
|
+
if (reservedKeys.length > 0) {
|
|
6296
|
+
throw new Error(`listBuilderWorkflow inputSchema cannot define reserved top-level key(s): ${reservedKeys.join(", ")}`);
|
|
6297
|
+
}
|
|
6298
|
+
}
|
|
6299
|
+
function resolveListAdapter(context) {
|
|
6300
|
+
const contextWithAdapters = context;
|
|
6301
|
+
return contextWithAdapters.adapters?.list ?? list;
|
|
6302
|
+
}
|
|
6303
|
+
function getRecordId(record) {
|
|
6304
|
+
return record.id;
|
|
6305
|
+
}
|
|
6306
|
+
function assertResultStageTarget(result, defaultStageKey) {
|
|
6307
|
+
const stageKey = result.stageKey ?? defaultStageKey;
|
|
6308
|
+
const catalogEntry = LEAD_GEN_STAGE_CATALOG[stageKey];
|
|
6309
|
+
if (!catalogEntry) {
|
|
6310
|
+
throw new Error(`listBuilderWorkflow result stageKey "${stageKey}" is not in LEAD_GEN_STAGE_CATALOG`);
|
|
6311
|
+
}
|
|
6312
|
+
if (catalogEntry.entity !== result.entity) {
|
|
6313
|
+
throw new Error(
|
|
6314
|
+
`listBuilderWorkflow result for ${result.entity} "${result.id}" targets ${catalogEntry.entity} stage "${stageKey}"; set result.stageKey to a ${result.entity} stage`
|
|
6315
|
+
);
|
|
6316
|
+
}
|
|
6317
|
+
return stageKey;
|
|
6318
|
+
}
|
|
6319
|
+
async function filterPendingRecords(records, params, context, options) {
|
|
6320
|
+
if (params.forceRefresh) {
|
|
6321
|
+
return records;
|
|
6322
|
+
}
|
|
6323
|
+
if (!params.listId) {
|
|
6324
|
+
if (params.batchId) {
|
|
6325
|
+
context.logger.warn(
|
|
6326
|
+
`[list-builder] batchId-only input for stage "${options.buildStep.stageKey}" cannot apply pending-ID filter; processing loaded records without resolving batchId to listId.`
|
|
6327
|
+
);
|
|
6328
|
+
}
|
|
6329
|
+
return records;
|
|
6330
|
+
}
|
|
6331
|
+
const listAdapter = resolveListAdapter(context);
|
|
6332
|
+
const limit = typeof params.limit === "number" ? params.limit : void 0;
|
|
6333
|
+
const pendingIds = options.buildStep.primaryEntity === "company" ? await listAdapter.listPendingCompanyIds({ listId: params.listId, stageKey: options.buildStep.stageKey, limit }) : await listAdapter.listPendingContactIds({ listId: params.listId, stageKey: options.buildStep.stageKey, limit });
|
|
6334
|
+
const pending = new Set(pendingIds);
|
|
6335
|
+
return records.filter((record) => pending.has(getRecordId(record)));
|
|
6336
|
+
}
|
|
6337
|
+
async function dispatchResults(envelope, context) {
|
|
6338
|
+
if (!envelope.batch.listId) {
|
|
6339
|
+
if (envelope.results.length > 0) {
|
|
6340
|
+
context.logger.warn(
|
|
6341
|
+
`[list-builder] stage "${envelope.batch.stageKey}" produced ${envelope.results.length} result(s), but no listId was provided; stage updates were skipped.`
|
|
6342
|
+
);
|
|
6343
|
+
}
|
|
6344
|
+
return envelope.results;
|
|
6345
|
+
}
|
|
6346
|
+
const listAdapter = resolveListAdapter(context);
|
|
6347
|
+
for (const result of envelope.results) {
|
|
6348
|
+
const stage = assertResultStageTarget(result, envelope.batch.stageKey);
|
|
6349
|
+
if (result.entity === "company") {
|
|
6350
|
+
await listAdapter.updateCompanyStage({
|
|
6351
|
+
listId: envelope.batch.listId,
|
|
6352
|
+
companyId: result.id,
|
|
6353
|
+
stage,
|
|
6354
|
+
status: result.status,
|
|
6355
|
+
...result.data !== void 0 ? { data: result.data } : {},
|
|
6356
|
+
executionId: context.executionId
|
|
6357
|
+
});
|
|
6358
|
+
continue;
|
|
6359
|
+
}
|
|
6360
|
+
await listAdapter.updateContactStage({
|
|
6361
|
+
listId: envelope.batch.listId,
|
|
6362
|
+
contactId: result.id,
|
|
6363
|
+
stage,
|
|
6364
|
+
status: result.status,
|
|
6365
|
+
...result.data !== void 0 ? { data: result.data } : {},
|
|
6366
|
+
executionId: context.executionId
|
|
6367
|
+
});
|
|
6368
|
+
}
|
|
6369
|
+
return envelope.results;
|
|
6370
|
+
}
|
|
6371
|
+
function listBuilderWorkflow(options) {
|
|
6372
|
+
const stageKey = ListBuilderStageKeySchema.parse(options.buildStep.stageKey);
|
|
6373
|
+
assertNoReservedInputKeys(options.inputSchema);
|
|
6374
|
+
const outputSchema = options.outputSchema ?? ListBuilderResultsSchema;
|
|
6375
|
+
const batchSchema = z.object({
|
|
6376
|
+
records: z.array(z.object({ id: z.string().min(1) }).passthrough()),
|
|
6377
|
+
stageKey: ListBuilderStageKeySchema,
|
|
6378
|
+
listId: z.string().optional()
|
|
6379
|
+
});
|
|
6380
|
+
const envelopeSchema = z.object({
|
|
6381
|
+
params: options.inputSchema,
|
|
6382
|
+
batch: batchSchema,
|
|
6383
|
+
results: ListBuilderResultsSchema
|
|
6384
|
+
});
|
|
6385
|
+
return {
|
|
6386
|
+
config: options.config,
|
|
6387
|
+
contract: {
|
|
6388
|
+
inputSchema: options.inputSchema,
|
|
6389
|
+
outputSchema
|
|
6390
|
+
},
|
|
6391
|
+
stageImplemented: stageKey,
|
|
6392
|
+
steps: {
|
|
6393
|
+
"prepare-batch": {
|
|
6394
|
+
id: "prepare-batch",
|
|
6395
|
+
name: `Prepare ${options.buildStep.label}`,
|
|
6396
|
+
description: `Load and filter records for ${options.buildStep.label}.`,
|
|
6397
|
+
inputSchema: options.inputSchema,
|
|
6398
|
+
outputSchema: envelopeSchema,
|
|
6399
|
+
handler: async (rawInput, context) => {
|
|
6400
|
+
const params = options.inputSchema.parse(rawInput);
|
|
6401
|
+
const runtimeContext = context;
|
|
6402
|
+
const initialRecords = await options.loadRecords(params, context);
|
|
6403
|
+
const additionallyFilteredRecords = options.additionalFilter ? await options.additionalFilter(initialRecords, params) : initialRecords;
|
|
6404
|
+
const records = await filterPendingRecords(
|
|
6405
|
+
additionallyFilteredRecords,
|
|
6406
|
+
params,
|
|
6407
|
+
runtimeContext,
|
|
6408
|
+
options
|
|
6409
|
+
);
|
|
6410
|
+
return {
|
|
6411
|
+
params,
|
|
6412
|
+
batch: {
|
|
6413
|
+
records,
|
|
6414
|
+
stageKey,
|
|
6415
|
+
listId: params.listId
|
|
6416
|
+
},
|
|
6417
|
+
results: []
|
|
6418
|
+
};
|
|
6419
|
+
},
|
|
6420
|
+
next: { type: "linear", target: "run-handler" }
|
|
6421
|
+
},
|
|
6422
|
+
"run-handler": {
|
|
6423
|
+
id: "run-handler",
|
|
6424
|
+
name: options.buildStep.label,
|
|
6425
|
+
description: options.buildStep.description ?? `Process ${options.buildStep.label}.`,
|
|
6426
|
+
inputSchema: envelopeSchema,
|
|
6427
|
+
outputSchema: envelopeSchema,
|
|
6428
|
+
handler: async (rawInput, context) => {
|
|
6429
|
+
const envelope = envelopeSchema.parse(rawInput);
|
|
6430
|
+
const results = await options.handler(envelope, context);
|
|
6431
|
+
return {
|
|
6432
|
+
...envelope,
|
|
6433
|
+
results: ListBuilderResultsSchema.parse(results)
|
|
6434
|
+
};
|
|
6435
|
+
},
|
|
6436
|
+
next: { type: "linear", target: "dispatch-results" }
|
|
6437
|
+
},
|
|
6438
|
+
"dispatch-results": {
|
|
6439
|
+
id: "dispatch-results",
|
|
6440
|
+
name: `Dispatch ${options.buildStep.label} Results`,
|
|
6441
|
+
description: `Persist ${options.buildStep.stageKey} processing-state results.`,
|
|
6442
|
+
inputSchema: envelopeSchema,
|
|
6443
|
+
outputSchema,
|
|
6444
|
+
handler: async (rawInput, context) => {
|
|
6445
|
+
const envelope = envelopeSchema.parse(rawInput);
|
|
6446
|
+
const results = await dispatchResults(envelope, context);
|
|
6447
|
+
return outputSchema.parse(results);
|
|
6448
|
+
},
|
|
6449
|
+
next: null
|
|
6450
|
+
}
|
|
6451
|
+
},
|
|
6452
|
+
entryPoint: "prepare-batch"
|
|
6453
|
+
};
|
|
6454
|
+
}
|
|
5084
6455
|
|
|
5085
6456
|
// src/worker/index.ts
|
|
5086
6457
|
function captureConsole(executionId, logs) {
|
|
@@ -5452,4 +6823,4 @@ if (workerData != null && workerData.kind === "static") {
|
|
|
5452
6823
|
})();
|
|
5453
6824
|
}
|
|
5454
6825
|
|
|
5455
|
-
export { PlatformToolError, acqDb, approval, createAdapter, createAnymailfinderAdapter, createApifyAdapter, createAttioAdapter, createDropboxAdapter, createGmailAdapter, createGoogleSheetsAdapter, createInstantlyAdapter, createMillionVerifierAdapter, createResendAdapter, createSignatureApiAdapter, createStripeAdapter, createTombaAdapter, crm, email, executeWorkflow, execution, list, llm, notifications, pdf, platform, projects, scheduler, startWorker, storage };
|
|
6826
|
+
export { ListBuilderResultSchema, ListBuilderResultsSchema, PlatformToolError, acqDb, approval, createAdapter, createAnymailfinderAdapter, createApifyAdapter, createAttioAdapter, createDropboxAdapter, createGmailAdapter, createGoogleSheetsAdapter, createInstantlyAdapter, createMillionVerifierAdapter, createResendAdapter, createSignatureApiAdapter, createStripeAdapter, createTombaAdapter, crm, email, executeWorkflow, execution, list, listBuilderWorkflow, llm, notifications, pdf, platform, projects, scheduler, startWorker, storage };
|