@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/index.js
CHANGED
|
@@ -37,15 +37,15 @@ var ToolingError = class extends ExecutionError {
|
|
|
37
37
|
this.details = details;
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
-
z.string().uuid();
|
|
41
|
-
z.string().trim().min(1).max(1e3);
|
|
40
|
+
var UuidSchema = z.string().uuid();
|
|
41
|
+
var NonEmptyStringSchema = z.string().trim().min(1).max(1e3);
|
|
42
42
|
z.enum(["agent", "workflow"]);
|
|
43
43
|
z.enum(["agent", "workflow", "scheduler", "api"]);
|
|
44
44
|
z.string().trim().toLowerCase().min(1, "Credential name required").max(100, "Credential name too long (max 100 chars)").regex(
|
|
45
45
|
/^[a-z0-9]+(-[a-z0-9]+)+$/,
|
|
46
46
|
"Credential name must be lowercase letters, numbers, and hyphens in format: service-environment (e.g., gmail-prod, attio-dev)"
|
|
47
47
|
);
|
|
48
|
-
z.enum(["google-sheets", "dropbox"]);
|
|
48
|
+
z.enum(["google-sheets", "google-calendar", "dropbox"]);
|
|
49
49
|
z.string().min(10, "Authorization code too short").max(1e3, "Authorization code too long");
|
|
50
50
|
z.string().min(10, "State parameter too short").max(2048, "State parameter too long");
|
|
51
51
|
z.string().trim().transform((str) => str.replace(/[<>'"]/g, ""));
|
|
@@ -62,6 +62,7 @@ z.object({
|
|
|
62
62
|
});
|
|
63
63
|
var ORGANIZATION_MODEL_ICON_TOKENS = [
|
|
64
64
|
"nav.dashboard",
|
|
65
|
+
"nav.calendar",
|
|
65
66
|
"nav.sales",
|
|
66
67
|
"nav.crm",
|
|
67
68
|
"nav.lead-gen",
|
|
@@ -76,6 +77,7 @@ var ORGANIZATION_MODEL_ICON_TOKENS = [
|
|
|
76
77
|
"knowledge.strategy",
|
|
77
78
|
"knowledge.reference",
|
|
78
79
|
"feature.dashboard",
|
|
80
|
+
"feature.calendar",
|
|
79
81
|
"feature.sales",
|
|
80
82
|
"feature.crm",
|
|
81
83
|
"feature.finance",
|
|
@@ -99,6 +101,7 @@ var ORGANIZATION_MODEL_ICON_TOKENS = [
|
|
|
99
101
|
"integration.google-sheets",
|
|
100
102
|
"integration.attio",
|
|
101
103
|
"surface.dashboard",
|
|
104
|
+
"surface.calendar",
|
|
102
105
|
"surface.overview",
|
|
103
106
|
"surface.command-view",
|
|
104
107
|
"surface.command-queue",
|
|
@@ -202,6 +205,344 @@ var CRM_DISCOVERY_NUDGING_STATE = {
|
|
|
202
205
|
stateKey: "discovery_nudging"};
|
|
203
206
|
var CRM_DISCOVERY_BOOKING_CANCELLED_STATE = {
|
|
204
207
|
stateKey: "discovery_booking_cancelled"};
|
|
208
|
+
var LEAD_GEN_STAGE_CATALOG = {
|
|
209
|
+
// Prospecting — company population
|
|
210
|
+
scraped: {
|
|
211
|
+
key: "scraped",
|
|
212
|
+
label: "Scraped",
|
|
213
|
+
description: "Company was scraped from a source directory (Apify actor run).",
|
|
214
|
+
order: 1,
|
|
215
|
+
entity: "company"
|
|
216
|
+
},
|
|
217
|
+
populated: {
|
|
218
|
+
key: "populated",
|
|
219
|
+
label: "Companies found",
|
|
220
|
+
description: "Companies have been found and added to the lead-gen list.",
|
|
221
|
+
order: 2,
|
|
222
|
+
entity: "company"
|
|
223
|
+
},
|
|
224
|
+
extracted: {
|
|
225
|
+
key: "extracted",
|
|
226
|
+
label: "Websites analyzed",
|
|
227
|
+
description: "Company websites have been analyzed for business signals.",
|
|
228
|
+
order: 3,
|
|
229
|
+
entity: "company"
|
|
230
|
+
},
|
|
231
|
+
enriched: {
|
|
232
|
+
key: "enriched",
|
|
233
|
+
label: "Enriched",
|
|
234
|
+
description: "Company or contact enriched with third-party data (e.g. Tomba, Anymailfinder).",
|
|
235
|
+
order: 4,
|
|
236
|
+
entity: "company"
|
|
237
|
+
},
|
|
238
|
+
"decision-makers-enriched": {
|
|
239
|
+
key: "decision-makers-enriched",
|
|
240
|
+
label: "Decision-makers found",
|
|
241
|
+
description: "Decision-maker contacts discovered and attached to a qualified company.",
|
|
242
|
+
order: 6,
|
|
243
|
+
entity: "company"
|
|
244
|
+
},
|
|
245
|
+
// Prospecting — contact discovery
|
|
246
|
+
discovered: {
|
|
247
|
+
key: "discovered",
|
|
248
|
+
label: "Decision-makers found",
|
|
249
|
+
description: "Decision-maker contact details have been found.",
|
|
250
|
+
order: 5,
|
|
251
|
+
entity: "contact"
|
|
252
|
+
},
|
|
253
|
+
verified: {
|
|
254
|
+
key: "verified",
|
|
255
|
+
label: "Emails verified",
|
|
256
|
+
description: "Contact email addresses have been checked for deliverability.",
|
|
257
|
+
order: 7,
|
|
258
|
+
entity: "contact"
|
|
259
|
+
},
|
|
260
|
+
// Qualification
|
|
261
|
+
qualified: {
|
|
262
|
+
key: "qualified",
|
|
263
|
+
label: "Companies qualified",
|
|
264
|
+
description: "Companies have been scored against the qualification criteria.",
|
|
265
|
+
order: 8,
|
|
266
|
+
entity: "company"
|
|
267
|
+
},
|
|
268
|
+
// Outreach
|
|
269
|
+
personalized: {
|
|
270
|
+
key: "personalized",
|
|
271
|
+
label: "Personalized",
|
|
272
|
+
description: "Outreach message personalized for the contact (Instantly personalization workflow).",
|
|
273
|
+
order: 9,
|
|
274
|
+
entity: "contact"
|
|
275
|
+
},
|
|
276
|
+
uploaded: {
|
|
277
|
+
key: "uploaded",
|
|
278
|
+
label: "Reviewed and exported",
|
|
279
|
+
description: "Approved records have been reviewed and exported for handoff.",
|
|
280
|
+
order: 10,
|
|
281
|
+
entity: "contact"
|
|
282
|
+
},
|
|
283
|
+
interested: {
|
|
284
|
+
key: "interested",
|
|
285
|
+
label: "Interested",
|
|
286
|
+
description: "Contact replied with a positive signal (Instantly reply-handler transition).",
|
|
287
|
+
order: 11,
|
|
288
|
+
entity: "contact"
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
var ProspectingLifecycleStageSchema = DisplayMetadataSchema.extend({
|
|
292
|
+
id: ModelIdSchema,
|
|
293
|
+
order: z.number().int().min(0)
|
|
294
|
+
});
|
|
295
|
+
var ProspectingBuildTemplateStepSchema = DisplayMetadataSchema.extend({
|
|
296
|
+
id: ModelIdSchema,
|
|
297
|
+
primaryEntity: z.enum(["company", "contact"]),
|
|
298
|
+
outputs: z.array(z.enum(["company", "contact", "export"])).min(1),
|
|
299
|
+
stageKey: ModelIdSchema,
|
|
300
|
+
dependsOn: z.array(ModelIdSchema).optional(),
|
|
301
|
+
dependencyMode: z.literal("per-record-eligibility"),
|
|
302
|
+
capabilityKey: ModelIdSchema,
|
|
303
|
+
defaultBatchSize: z.number().int().positive(),
|
|
304
|
+
maxBatchSize: z.number().int().positive()
|
|
305
|
+
}).refine((step) => step.defaultBatchSize <= step.maxBatchSize, {
|
|
306
|
+
message: "defaultBatchSize must be less than or equal to maxBatchSize",
|
|
307
|
+
path: ["defaultBatchSize"]
|
|
308
|
+
});
|
|
309
|
+
var ProspectingBuildTemplateSchema = DisplayMetadataSchema.extend({
|
|
310
|
+
id: ModelIdSchema,
|
|
311
|
+
steps: z.array(ProspectingBuildTemplateStepSchema).min(1)
|
|
312
|
+
});
|
|
313
|
+
var CAPABILITY_REGISTRY = {
|
|
314
|
+
"lead-gen.company.source": "lgn-import-workflow",
|
|
315
|
+
"lead-gen.company.apollo-import": "lgn-01c-apollo-import-workflow",
|
|
316
|
+
"lead-gen.contact.discover": "lgn-04-email-discovery-workflow",
|
|
317
|
+
"lead-gen.contact.verify-email": "lgn-05-email-verification-workflow",
|
|
318
|
+
"lead-gen.company.website-extract": "lgn-02-website-extract-workflow",
|
|
319
|
+
"lead-gen.company.qualify": "lgn-03-company-qualification-workflow",
|
|
320
|
+
"lead-gen.company.dtc-subscription-qualify": "lgn-03b-dtc-subscription-score-workflow",
|
|
321
|
+
"lead-gen.contact.apollo-decision-maker-enrich": "lgn-04b-apollo-decision-maker-enrich-workflow",
|
|
322
|
+
"lead-gen.contact.personalize": "ist-personalization-workflow",
|
|
323
|
+
"lead-gen.review.outreach-ready": "ist-upload-contacts-workflow",
|
|
324
|
+
"lead-gen.export.list": "lgn-06-export-list-workflow",
|
|
325
|
+
"lead-gen.company.cleanup": "lgn-company-cleanup-workflow"
|
|
326
|
+
};
|
|
327
|
+
var PROSPECTING_STEPS = {
|
|
328
|
+
localServices: {
|
|
329
|
+
sourceCompanies: {
|
|
330
|
+
id: "source-companies",
|
|
331
|
+
label: "Companies found",
|
|
332
|
+
primaryEntity: "company",
|
|
333
|
+
outputs: ["company"],
|
|
334
|
+
stageKey: "populated",
|
|
335
|
+
dependencyMode: "per-record-eligibility",
|
|
336
|
+
capabilityKey: "lead-gen.company.source",
|
|
337
|
+
defaultBatchSize: 100,
|
|
338
|
+
maxBatchSize: 250
|
|
339
|
+
},
|
|
340
|
+
analyzeWebsites: {
|
|
341
|
+
id: "analyze-websites",
|
|
342
|
+
label: "Websites analyzed",
|
|
343
|
+
primaryEntity: "company",
|
|
344
|
+
outputs: ["company"],
|
|
345
|
+
stageKey: "extracted",
|
|
346
|
+
dependsOn: ["source-companies"],
|
|
347
|
+
dependencyMode: "per-record-eligibility",
|
|
348
|
+
capabilityKey: "lead-gen.company.website-extract",
|
|
349
|
+
defaultBatchSize: 50,
|
|
350
|
+
maxBatchSize: 100
|
|
351
|
+
},
|
|
352
|
+
qualifyCompanies: {
|
|
353
|
+
id: "qualify-companies",
|
|
354
|
+
label: "Companies qualified",
|
|
355
|
+
primaryEntity: "company",
|
|
356
|
+
outputs: ["company"],
|
|
357
|
+
stageKey: "qualified",
|
|
358
|
+
dependsOn: ["analyze-websites"],
|
|
359
|
+
dependencyMode: "per-record-eligibility",
|
|
360
|
+
capabilityKey: "lead-gen.company.qualify",
|
|
361
|
+
defaultBatchSize: 100,
|
|
362
|
+
maxBatchSize: 250
|
|
363
|
+
},
|
|
364
|
+
findContacts: {
|
|
365
|
+
id: "find-contacts",
|
|
366
|
+
label: "Decision-makers found",
|
|
367
|
+
primaryEntity: "contact",
|
|
368
|
+
outputs: ["contact"],
|
|
369
|
+
stageKey: "discovered",
|
|
370
|
+
dependsOn: ["qualify-companies"],
|
|
371
|
+
dependencyMode: "per-record-eligibility",
|
|
372
|
+
capabilityKey: "lead-gen.contact.discover",
|
|
373
|
+
defaultBatchSize: 50,
|
|
374
|
+
maxBatchSize: 100
|
|
375
|
+
},
|
|
376
|
+
verifyEmails: {
|
|
377
|
+
id: "verify-emails",
|
|
378
|
+
label: "Emails verified",
|
|
379
|
+
primaryEntity: "contact",
|
|
380
|
+
outputs: ["contact"],
|
|
381
|
+
stageKey: "verified",
|
|
382
|
+
dependsOn: ["find-contacts"],
|
|
383
|
+
dependencyMode: "per-record-eligibility",
|
|
384
|
+
capabilityKey: "lead-gen.contact.verify-email",
|
|
385
|
+
defaultBatchSize: 100,
|
|
386
|
+
maxBatchSize: 500
|
|
387
|
+
},
|
|
388
|
+
personalize: {
|
|
389
|
+
id: "personalize",
|
|
390
|
+
label: "Personalize",
|
|
391
|
+
primaryEntity: "contact",
|
|
392
|
+
outputs: ["contact"],
|
|
393
|
+
stageKey: "personalized",
|
|
394
|
+
dependsOn: ["verify-emails"],
|
|
395
|
+
dependencyMode: "per-record-eligibility",
|
|
396
|
+
capabilityKey: "lead-gen.contact.personalize",
|
|
397
|
+
defaultBatchSize: 25,
|
|
398
|
+
maxBatchSize: 100
|
|
399
|
+
},
|
|
400
|
+
review: {
|
|
401
|
+
id: "review",
|
|
402
|
+
label: "Reviewed and exported",
|
|
403
|
+
primaryEntity: "contact",
|
|
404
|
+
outputs: ["export"],
|
|
405
|
+
stageKey: "uploaded",
|
|
406
|
+
dependsOn: ["personalize"],
|
|
407
|
+
dependencyMode: "per-record-eligibility",
|
|
408
|
+
capabilityKey: "lead-gen.review.outreach-ready",
|
|
409
|
+
defaultBatchSize: 25,
|
|
410
|
+
maxBatchSize: 100
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
dtcApolloClickup: {
|
|
414
|
+
importApolloSearch: {
|
|
415
|
+
id: "import-apollo-search",
|
|
416
|
+
label: "Companies found",
|
|
417
|
+
description: "Pull companies and seed contact data from a predefined Apollo search or list.",
|
|
418
|
+
primaryEntity: "company",
|
|
419
|
+
outputs: ["company", "contact"],
|
|
420
|
+
stageKey: "populated",
|
|
421
|
+
dependencyMode: "per-record-eligibility",
|
|
422
|
+
capabilityKey: "lead-gen.company.apollo-import",
|
|
423
|
+
defaultBatchSize: 250,
|
|
424
|
+
maxBatchSize: 1e3
|
|
425
|
+
},
|
|
426
|
+
analyzeWebsites: {
|
|
427
|
+
id: "analyze-websites",
|
|
428
|
+
label: "Websites analyzed",
|
|
429
|
+
description: "Extract subscription, product, retention, and tech-stack signals from each brand website.",
|
|
430
|
+
primaryEntity: "company",
|
|
431
|
+
outputs: ["company"],
|
|
432
|
+
stageKey: "extracted",
|
|
433
|
+
dependsOn: ["import-apollo-search"],
|
|
434
|
+
dependencyMode: "per-record-eligibility",
|
|
435
|
+
capabilityKey: "lead-gen.company.website-extract",
|
|
436
|
+
defaultBatchSize: 50,
|
|
437
|
+
maxBatchSize: 100
|
|
438
|
+
},
|
|
439
|
+
scoreDtcFit: {
|
|
440
|
+
id: "score-dtc-fit",
|
|
441
|
+
label: "Companies qualified",
|
|
442
|
+
description: "Classify subscription potential, consumable-product fit, retention maturity, and disqualifiers.",
|
|
443
|
+
primaryEntity: "company",
|
|
444
|
+
outputs: ["company"],
|
|
445
|
+
stageKey: "qualified",
|
|
446
|
+
dependsOn: ["analyze-websites"],
|
|
447
|
+
dependencyMode: "per-record-eligibility",
|
|
448
|
+
capabilityKey: "lead-gen.company.dtc-subscription-qualify",
|
|
449
|
+
defaultBatchSize: 100,
|
|
450
|
+
maxBatchSize: 250
|
|
451
|
+
},
|
|
452
|
+
enrichDecisionMakers: {
|
|
453
|
+
id: "enrich-decision-makers",
|
|
454
|
+
label: "Decision-makers found",
|
|
455
|
+
description: "Use Apollo to find qualified contacts at qualified companies - founders, retention leads, lifecycle leads, and marketing owners.",
|
|
456
|
+
primaryEntity: "company",
|
|
457
|
+
outputs: ["contact"],
|
|
458
|
+
stageKey: "decision-makers-enriched",
|
|
459
|
+
dependsOn: ["score-dtc-fit"],
|
|
460
|
+
dependencyMode: "per-record-eligibility",
|
|
461
|
+
capabilityKey: "lead-gen.contact.apollo-decision-maker-enrich",
|
|
462
|
+
defaultBatchSize: 100,
|
|
463
|
+
maxBatchSize: 250
|
|
464
|
+
},
|
|
465
|
+
verifyEmails: {
|
|
466
|
+
id: "verify-emails",
|
|
467
|
+
label: "Emails verified",
|
|
468
|
+
description: "Verify deliverability before the QC and handoff step.",
|
|
469
|
+
primaryEntity: "contact",
|
|
470
|
+
outputs: ["contact"],
|
|
471
|
+
stageKey: "verified",
|
|
472
|
+
dependsOn: ["enrich-decision-makers"],
|
|
473
|
+
dependencyMode: "per-record-eligibility",
|
|
474
|
+
capabilityKey: "lead-gen.contact.verify-email",
|
|
475
|
+
defaultBatchSize: 250,
|
|
476
|
+
maxBatchSize: 500
|
|
477
|
+
},
|
|
478
|
+
reviewAndExport: {
|
|
479
|
+
id: "review-and-export",
|
|
480
|
+
label: "Reviewed and exported",
|
|
481
|
+
description: "Operator QC approves or rejects leads, then approved records are exported as a lead list.",
|
|
482
|
+
primaryEntity: "company",
|
|
483
|
+
outputs: ["export"],
|
|
484
|
+
stageKey: "uploaded",
|
|
485
|
+
dependsOn: ["verify-emails"],
|
|
486
|
+
dependencyMode: "per-record-eligibility",
|
|
487
|
+
capabilityKey: "lead-gen.export.list",
|
|
488
|
+
defaultBatchSize: 100,
|
|
489
|
+
maxBatchSize: 250
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
z.object({
|
|
494
|
+
listEntityId: ModelIdSchema,
|
|
495
|
+
companyEntityId: ModelIdSchema,
|
|
496
|
+
contactEntityId: ModelIdSchema,
|
|
497
|
+
description: DescriptionSchema.optional(),
|
|
498
|
+
companyStages: z.array(ProspectingLifecycleStageSchema).min(1),
|
|
499
|
+
contactStages: z.array(ProspectingLifecycleStageSchema).min(1),
|
|
500
|
+
defaultBuildTemplateId: ModelIdSchema,
|
|
501
|
+
buildTemplates: z.array(ProspectingBuildTemplateSchema).min(1)
|
|
502
|
+
});
|
|
503
|
+
function toProspectingLifecycleStage(stage) {
|
|
504
|
+
return {
|
|
505
|
+
id: stage.key,
|
|
506
|
+
label: stage.label,
|
|
507
|
+
order: stage.order
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
function leadGenStagesForEntity(entity) {
|
|
511
|
+
return Object.values(LEAD_GEN_STAGE_CATALOG).filter((stage) => stage.entity === entity).sort((a, b) => a.order - b.order).map(toProspectingLifecycleStage);
|
|
512
|
+
}
|
|
513
|
+
var DEFAULT_ORGANIZATION_MODEL_PROSPECTING = {
|
|
514
|
+
companyStages: leadGenStagesForEntity("company"),
|
|
515
|
+
contactStages: leadGenStagesForEntity("contact"),
|
|
516
|
+
buildTemplates: [
|
|
517
|
+
{
|
|
518
|
+
id: "local-services",
|
|
519
|
+
label: "Local Services Prospecting",
|
|
520
|
+
description: "Curated local-services list build using company sourcing, website analysis, qualification, contact discovery, verification, personalization, and review.",
|
|
521
|
+
steps: [
|
|
522
|
+
PROSPECTING_STEPS.localServices.sourceCompanies,
|
|
523
|
+
PROSPECTING_STEPS.localServices.analyzeWebsites,
|
|
524
|
+
PROSPECTING_STEPS.localServices.qualifyCompanies,
|
|
525
|
+
PROSPECTING_STEPS.localServices.findContacts,
|
|
526
|
+
PROSPECTING_STEPS.localServices.verifyEmails,
|
|
527
|
+
PROSPECTING_STEPS.localServices.personalize,
|
|
528
|
+
PROSPECTING_STEPS.localServices.review
|
|
529
|
+
]
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
id: "dtc-subscription-apollo-clickup",
|
|
533
|
+
label: "DTC Subscription Apollo Export",
|
|
534
|
+
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.",
|
|
535
|
+
steps: [
|
|
536
|
+
PROSPECTING_STEPS.dtcApolloClickup.importApolloSearch,
|
|
537
|
+
PROSPECTING_STEPS.dtcApolloClickup.analyzeWebsites,
|
|
538
|
+
PROSPECTING_STEPS.dtcApolloClickup.scoreDtcFit,
|
|
539
|
+
PROSPECTING_STEPS.dtcApolloClickup.enrichDecisionMakers,
|
|
540
|
+
PROSPECTING_STEPS.dtcApolloClickup.verifyEmails,
|
|
541
|
+
PROSPECTING_STEPS.dtcApolloClickup.reviewAndExport
|
|
542
|
+
]
|
|
543
|
+
}
|
|
544
|
+
]
|
|
545
|
+
};
|
|
205
546
|
|
|
206
547
|
// ../core/src/platform/registry/reserved.ts
|
|
207
548
|
var RESERVED_RESOURCE_IDS = /* @__PURE__ */ new Set(["command-center-assistant"]);
|
|
@@ -3789,6 +4130,746 @@ var ResourceRegistry = class {
|
|
|
3789
4130
|
return cache.commandView;
|
|
3790
4131
|
}
|
|
3791
4132
|
};
|
|
4133
|
+
|
|
4134
|
+
// ../core/src/business/acquisition/build-templates.ts
|
|
4135
|
+
var PROSPECTING_BUILD_TEMPLATE_OPTIONS = DEFAULT_ORGANIZATION_MODEL_PROSPECTING.buildTemplates.map(
|
|
4136
|
+
({ id, label, description }) => ({
|
|
4137
|
+
id,
|
|
4138
|
+
label,
|
|
4139
|
+
description
|
|
4140
|
+
})
|
|
4141
|
+
);
|
|
4142
|
+
function isProspectingBuildTemplateId(value) {
|
|
4143
|
+
return PROSPECTING_BUILD_TEMPLATE_OPTIONS.some((template) => template.id === value);
|
|
4144
|
+
}
|
|
4145
|
+
|
|
4146
|
+
// ../core/src/business/acquisition/deal-ownership.ts
|
|
4147
|
+
var INBOUND_EVENT_TYPES = ["reply_received"];
|
|
4148
|
+
var OUTBOUND_EVENT_TYPES = [
|
|
4149
|
+
"reply_sent_to_lead",
|
|
4150
|
+
"booking_nudge_sent",
|
|
4151
|
+
"reminder_sent",
|
|
4152
|
+
"rebook_sent",
|
|
4153
|
+
"followup_email_sent",
|
|
4154
|
+
"reply_followup_sent",
|
|
4155
|
+
"lead_deferred_next_step"
|
|
4156
|
+
];
|
|
4157
|
+
var INBOUND_SET = new Set(INBOUND_EVENT_TYPES);
|
|
4158
|
+
var OUTBOUND_SET = new Set(OUTBOUND_EVENT_TYPES);
|
|
4159
|
+
function getDealOwnership(deal) {
|
|
4160
|
+
if (deal.state_key === "closed_won" || deal.state_key === "closed_lost") {
|
|
4161
|
+
return null;
|
|
4162
|
+
}
|
|
4163
|
+
if (!Array.isArray(deal.activity_log)) return null;
|
|
4164
|
+
let latestInboundMs = null;
|
|
4165
|
+
let latestOutboundMs = null;
|
|
4166
|
+
for (const entry of deal.activity_log) {
|
|
4167
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
|
|
4168
|
+
const record = entry;
|
|
4169
|
+
const type = typeof record.type === "string" ? record.type : null;
|
|
4170
|
+
if (!type) continue;
|
|
4171
|
+
const isInbound = INBOUND_SET.has(type);
|
|
4172
|
+
const isOutbound = OUTBOUND_SET.has(type);
|
|
4173
|
+
if (!isInbound && !isOutbound) continue;
|
|
4174
|
+
const occurredAt = resolveTimestamp(record);
|
|
4175
|
+
if (occurredAt === null) continue;
|
|
4176
|
+
if (isInbound && (latestInboundMs === null || occurredAt > latestInboundMs)) {
|
|
4177
|
+
latestInboundMs = occurredAt;
|
|
4178
|
+
}
|
|
4179
|
+
if (isOutbound && (latestOutboundMs === null || occurredAt > latestOutboundMs)) {
|
|
4180
|
+
latestOutboundMs = occurredAt;
|
|
4181
|
+
}
|
|
4182
|
+
}
|
|
4183
|
+
if (latestInboundMs === null && latestOutboundMs === null) return null;
|
|
4184
|
+
if (latestOutboundMs !== null && (latestInboundMs === null || latestOutboundMs >= latestInboundMs)) {
|
|
4185
|
+
return "them";
|
|
4186
|
+
}
|
|
4187
|
+
return "us";
|
|
4188
|
+
}
|
|
4189
|
+
function resolveTimestamp(record) {
|
|
4190
|
+
return parseMs(record.timestamp) ?? parseMs(record.occurredAt) ?? parseMs(record.createdAt) ?? parseMs(record.updatedAt) ?? parseMs(record.sentAt) ?? null;
|
|
4191
|
+
}
|
|
4192
|
+
function parseMs(value) {
|
|
4193
|
+
if (value instanceof Date) {
|
|
4194
|
+
const ms2 = value.getTime();
|
|
4195
|
+
return Number.isNaN(ms2) ? null : ms2;
|
|
4196
|
+
}
|
|
4197
|
+
if (typeof value !== "string") return null;
|
|
4198
|
+
const ms = new Date(value).getTime();
|
|
4199
|
+
return Number.isNaN(ms) ? null : ms;
|
|
4200
|
+
}
|
|
4201
|
+
|
|
4202
|
+
// ../core/src/business/acquisition/api-schemas.ts
|
|
4203
|
+
var ProcessingStageStatusSchema = z.enum(["success", "no_result", "skipped", "error"]);
|
|
4204
|
+
var LeadGenStageKeySchema = z.string().refine((value) => Object.prototype.hasOwnProperty.call(LEAD_GEN_STAGE_CATALOG, value), {
|
|
4205
|
+
message: "processing state key must match LEAD_GEN_STAGE_CATALOG"
|
|
4206
|
+
});
|
|
4207
|
+
var LeadGenCapabilityKeySchema = z.string().refine((value) => Object.prototype.hasOwnProperty.call(CAPABILITY_REGISTRY, value), {
|
|
4208
|
+
message: "capabilityKey must match CAPABILITY_REGISTRY"
|
|
4209
|
+
});
|
|
4210
|
+
var ProcessingStateEntrySchema = z.object({
|
|
4211
|
+
status: ProcessingStageStatusSchema,
|
|
4212
|
+
data: z.unknown().optional()
|
|
4213
|
+
}).passthrough();
|
|
4214
|
+
var ProcessingStateSchema = z.record(LeadGenStageKeySchema, ProcessingStateEntrySchema);
|
|
4215
|
+
var CompanyProcessingStateSchema = ProcessingStateSchema;
|
|
4216
|
+
var ContactProcessingStateSchema = ProcessingStateSchema;
|
|
4217
|
+
var DealStageSchema = z.enum(["interested", "proposal", "closing", "closed_won", "closed_lost", "nurturing"]);
|
|
4218
|
+
var AcqDealTaskKindSchema = z.enum(["call", "email", "meeting", "other"]);
|
|
4219
|
+
z.object({
|
|
4220
|
+
dealId: UuidSchema
|
|
4221
|
+
});
|
|
4222
|
+
z.object({
|
|
4223
|
+
dealId: UuidSchema,
|
|
4224
|
+
taskId: UuidSchema
|
|
4225
|
+
});
|
|
4226
|
+
z.object({
|
|
4227
|
+
stage: DealStageSchema.optional(),
|
|
4228
|
+
search: z.string().optional(),
|
|
4229
|
+
limit: z.coerce.number().int().positive().default(50),
|
|
4230
|
+
offset: z.coerce.number().int().min(0).default(0)
|
|
4231
|
+
}).strict();
|
|
4232
|
+
z.object({
|
|
4233
|
+
search: z.string().trim().min(1).max(200).optional(),
|
|
4234
|
+
limit: z.coerce.number().int().min(1).max(25).default(10)
|
|
4235
|
+
}).strict();
|
|
4236
|
+
z.object({
|
|
4237
|
+
window: z.enum(["overdue", "today", "today_and_overdue", "upcoming"]).optional(),
|
|
4238
|
+
assigneeUserId: UuidSchema.optional()
|
|
4239
|
+
}).strict();
|
|
4240
|
+
z.object({
|
|
4241
|
+
body: z.string().trim().min(1).max(1e4)
|
|
4242
|
+
}).strict();
|
|
4243
|
+
z.object({
|
|
4244
|
+
title: z.string().trim().min(1).max(255),
|
|
4245
|
+
description: z.string().nullable().optional(),
|
|
4246
|
+
kind: AcqDealTaskKindSchema.optional(),
|
|
4247
|
+
dueAt: z.string().datetime().nullable().optional(),
|
|
4248
|
+
assigneeUserId: UuidSchema.nullable().optional()
|
|
4249
|
+
}).strict();
|
|
4250
|
+
z.object({
|
|
4251
|
+
pipelineKey: z.string().min(1),
|
|
4252
|
+
stageKey: z.string().min(1),
|
|
4253
|
+
stateKey: z.string().nullable().optional(),
|
|
4254
|
+
reason: z.string().optional(),
|
|
4255
|
+
expectedUpdatedAt: z.string().datetime().optional()
|
|
4256
|
+
}).strict();
|
|
4257
|
+
z.object({
|
|
4258
|
+
stateKey: z.string().min(1),
|
|
4259
|
+
reason: z.string().optional(),
|
|
4260
|
+
expectedUpdatedAt: z.string().datetime().optional()
|
|
4261
|
+
}).strict();
|
|
4262
|
+
z.object({
|
|
4263
|
+
dealId: UuidSchema,
|
|
4264
|
+
actionKey: NonEmptyStringSchema
|
|
4265
|
+
}).strict();
|
|
4266
|
+
z.object({
|
|
4267
|
+
payload: z.record(z.string(), z.unknown()).optional()
|
|
4268
|
+
}).strict();
|
|
4269
|
+
var DealContactSummarySchema = z.object({
|
|
4270
|
+
id: z.string(),
|
|
4271
|
+
first_name: z.string().nullable(),
|
|
4272
|
+
last_name: z.string().nullable(),
|
|
4273
|
+
email: z.string(),
|
|
4274
|
+
title: z.string().nullable(),
|
|
4275
|
+
headline: z.string().nullable(),
|
|
4276
|
+
linkedin_url: z.string().nullable(),
|
|
4277
|
+
processing_state: ProcessingStateSchema.nullable(),
|
|
4278
|
+
enrichment_data: z.record(z.string(), z.unknown()).nullable(),
|
|
4279
|
+
company: z.object({
|
|
4280
|
+
id: z.string(),
|
|
4281
|
+
name: z.string(),
|
|
4282
|
+
domain: z.string().nullable(),
|
|
4283
|
+
website: z.string().nullable(),
|
|
4284
|
+
linkedin_url: z.string().nullable(),
|
|
4285
|
+
segment: z.string().nullable(),
|
|
4286
|
+
category: z.string().nullable(),
|
|
4287
|
+
num_employees: z.number().nullable()
|
|
4288
|
+
}).nullable()
|
|
4289
|
+
});
|
|
4290
|
+
var DealPrioritySchema = z.object({
|
|
4291
|
+
bucketKey: z.enum(["needs_response", "follow_up_due", "waiting", "stale", "closed_low"]),
|
|
4292
|
+
rank: z.number().int(),
|
|
4293
|
+
label: z.string(),
|
|
4294
|
+
color: z.string(),
|
|
4295
|
+
reason: z.string(),
|
|
4296
|
+
latestActivityAt: z.string().nullable(),
|
|
4297
|
+
nextActionAt: z.string().nullable()
|
|
4298
|
+
});
|
|
4299
|
+
var DealListItemSchema = z.object({
|
|
4300
|
+
// acq_deals columns
|
|
4301
|
+
id: z.string(),
|
|
4302
|
+
organization_id: z.string(),
|
|
4303
|
+
contact_id: z.string().nullable(),
|
|
4304
|
+
contact_email: z.string(),
|
|
4305
|
+
pipeline_key: z.string(),
|
|
4306
|
+
stage_key: z.string().nullable(),
|
|
4307
|
+
state_key: z.string().nullable(),
|
|
4308
|
+
activity_log: z.unknown(),
|
|
4309
|
+
discovery_data: z.unknown().nullable(),
|
|
4310
|
+
discovery_submitted_at: z.string().nullable(),
|
|
4311
|
+
discovery_submitted_by: z.string().nullable(),
|
|
4312
|
+
proposal_data: z.unknown().nullable(),
|
|
4313
|
+
proposal_sent_at: z.string().nullable(),
|
|
4314
|
+
proposal_pdf_url: z.string().nullable(),
|
|
4315
|
+
signature_envelope_id: z.string().nullable(),
|
|
4316
|
+
source_list_id: z.string().nullable(),
|
|
4317
|
+
source_type: z.string().nullable(),
|
|
4318
|
+
initial_fee: z.number().nullable(),
|
|
4319
|
+
monthly_fee: z.number().nullable(),
|
|
4320
|
+
closed_lost_at: z.string().nullable(),
|
|
4321
|
+
closed_lost_reason: z.string().nullable(),
|
|
4322
|
+
created_at: z.string(),
|
|
4323
|
+
updated_at: z.string(),
|
|
4324
|
+
priority: DealPrioritySchema,
|
|
4325
|
+
ownership: z.enum(["us", "them"]).nullable(),
|
|
4326
|
+
nextAction: z.string().nullable(),
|
|
4327
|
+
// joined relation
|
|
4328
|
+
contact: DealContactSummarySchema.nullable()
|
|
4329
|
+
});
|
|
4330
|
+
z.object({
|
|
4331
|
+
data: z.array(DealListItemSchema),
|
|
4332
|
+
total: z.number().int(),
|
|
4333
|
+
limit: z.number().int(),
|
|
4334
|
+
offset: z.number().int()
|
|
4335
|
+
});
|
|
4336
|
+
var DealStageSummarySchema = z.object({
|
|
4337
|
+
stage: z.string(),
|
|
4338
|
+
count: z.number().int(),
|
|
4339
|
+
totalValue: z.number(),
|
|
4340
|
+
oldestUpdatedAt: z.string().nullable(),
|
|
4341
|
+
newestUpdatedAt: z.string().nullable()
|
|
4342
|
+
});
|
|
4343
|
+
var StaleDealSummarySchema = z.object({
|
|
4344
|
+
id: z.string(),
|
|
4345
|
+
contactEmail: z.string(),
|
|
4346
|
+
stageKey: z.string(),
|
|
4347
|
+
updatedAt: z.string(),
|
|
4348
|
+
daysStale: z.number().int()
|
|
4349
|
+
});
|
|
4350
|
+
z.object({
|
|
4351
|
+
totalDeals: z.number().int(),
|
|
4352
|
+
openDeals: z.number().int(),
|
|
4353
|
+
wonDeals: z.number().int(),
|
|
4354
|
+
lostDeals: z.number().int(),
|
|
4355
|
+
winRate: z.number(),
|
|
4356
|
+
avgDealSize: z.number(),
|
|
4357
|
+
totalPipelineValue: z.number(),
|
|
4358
|
+
stageSummary: z.array(DealStageSummarySchema),
|
|
4359
|
+
staleDeals: z.array(StaleDealSummarySchema)
|
|
4360
|
+
});
|
|
4361
|
+
var DealLookupItemSchema = z.object({
|
|
4362
|
+
id: z.string(),
|
|
4363
|
+
contactEmail: z.string(),
|
|
4364
|
+
stageKey: z.string().nullable(),
|
|
4365
|
+
updatedAt: z.string(),
|
|
4366
|
+
contactName: z.string().nullable(),
|
|
4367
|
+
companyName: z.string().nullable(),
|
|
4368
|
+
displayLabel: z.string()
|
|
4369
|
+
});
|
|
4370
|
+
z.array(DealLookupItemSchema);
|
|
4371
|
+
var ConversationMessageSchema = z.object({
|
|
4372
|
+
id: z.string(),
|
|
4373
|
+
direction: z.enum(["inbound", "outbound"]),
|
|
4374
|
+
fromEmail: z.string(),
|
|
4375
|
+
toEmail: z.string(),
|
|
4376
|
+
subject: z.string().nullable(),
|
|
4377
|
+
body: z.string(),
|
|
4378
|
+
sentAt: z.string().nullable()
|
|
4379
|
+
});
|
|
4380
|
+
var DealConversationSchema = z.object({
|
|
4381
|
+
messages: z.array(ConversationMessageSchema)
|
|
4382
|
+
});
|
|
4383
|
+
DealListItemSchema.extend({
|
|
4384
|
+
conversation: DealConversationSchema
|
|
4385
|
+
});
|
|
4386
|
+
var DealNoteResponseSchema = z.object({
|
|
4387
|
+
id: z.string(),
|
|
4388
|
+
dealId: z.string(),
|
|
4389
|
+
organizationId: z.string(),
|
|
4390
|
+
authorUserId: z.string().nullable(),
|
|
4391
|
+
body: z.string(),
|
|
4392
|
+
createdAt: z.string(),
|
|
4393
|
+
updatedAt: z.string()
|
|
4394
|
+
});
|
|
4395
|
+
z.array(DealNoteResponseSchema);
|
|
4396
|
+
var DealTaskResponseSchema = z.object({
|
|
4397
|
+
id: z.string(),
|
|
4398
|
+
organizationId: z.string(),
|
|
4399
|
+
dealId: z.string(),
|
|
4400
|
+
title: z.string(),
|
|
4401
|
+
description: z.string().nullable(),
|
|
4402
|
+
kind: AcqDealTaskKindSchema,
|
|
4403
|
+
dueAt: z.string().nullable(),
|
|
4404
|
+
assigneeUserId: z.string().nullable(),
|
|
4405
|
+
completedAt: z.string().nullable(),
|
|
4406
|
+
completedByUserId: z.string().nullable(),
|
|
4407
|
+
createdAt: z.string(),
|
|
4408
|
+
updatedAt: z.string(),
|
|
4409
|
+
createdByUserId: z.string().nullable()
|
|
4410
|
+
});
|
|
4411
|
+
z.array(DealTaskResponseSchema);
|
|
4412
|
+
var ListStatusSchema = z.enum(["draft", "enriching", "launched", "closing", "archived"]);
|
|
4413
|
+
var ScrapingConfigSchema = z.object({
|
|
4414
|
+
vertical: z.string().trim().max(255).optional(),
|
|
4415
|
+
geography: z.string().trim().max(500).optional(),
|
|
4416
|
+
size: z.string().trim().max(255).optional(),
|
|
4417
|
+
apifyInput: z.record(z.string(), z.unknown()).optional()
|
|
4418
|
+
});
|
|
4419
|
+
var IcpRubricSchema = z.object({
|
|
4420
|
+
qualificationRubricKey: z.string().trim().max(255).nullish(),
|
|
4421
|
+
targetDescription: z.string().optional(),
|
|
4422
|
+
minReviewCount: z.number().int().min(0).optional(),
|
|
4423
|
+
minRating: z.number().min(0).max(5).optional(),
|
|
4424
|
+
excludeFranchises: z.boolean().optional(),
|
|
4425
|
+
customRules: z.string().optional()
|
|
4426
|
+
});
|
|
4427
|
+
var PipelineStageSchema = z.object({
|
|
4428
|
+
key: z.string().refine((value) => Object.prototype.hasOwnProperty.call(LEAD_GEN_STAGE_CATALOG, value), {
|
|
4429
|
+
message: "pipeline stage key must match LEAD_GEN_STAGE_CATALOG"
|
|
4430
|
+
}),
|
|
4431
|
+
label: z.string().optional(),
|
|
4432
|
+
enabled: z.boolean().optional(),
|
|
4433
|
+
order: z.number().int().optional()
|
|
4434
|
+
});
|
|
4435
|
+
var PipelineConfigSchema = z.object({
|
|
4436
|
+
stages: z.array(PipelineStageSchema).optional()
|
|
4437
|
+
});
|
|
4438
|
+
var BuildPlanSnapshotStepSchema = z.object({
|
|
4439
|
+
id: z.string().trim().min(1).max(100),
|
|
4440
|
+
label: z.string().trim().min(1).max(120),
|
|
4441
|
+
description: z.string().trim().min(1).max(2e3).optional(),
|
|
4442
|
+
primaryEntity: z.enum(["company", "contact"]),
|
|
4443
|
+
outputs: z.array(z.enum(["company", "contact", "export"])).min(1),
|
|
4444
|
+
stageKey: LeadGenStageKeySchema,
|
|
4445
|
+
dependsOn: z.array(z.string().trim().min(1).max(100)).optional(),
|
|
4446
|
+
dependencyMode: z.literal("per-record-eligibility"),
|
|
4447
|
+
capabilityKey: LeadGenCapabilityKeySchema,
|
|
4448
|
+
defaultBatchSize: z.number().int().positive(),
|
|
4449
|
+
maxBatchSize: z.number().int().positive()
|
|
4450
|
+
}).refine((step) => step.defaultBatchSize <= step.maxBatchSize, {
|
|
4451
|
+
message: "defaultBatchSize must be less than or equal to maxBatchSize",
|
|
4452
|
+
path: ["defaultBatchSize"]
|
|
4453
|
+
});
|
|
4454
|
+
var BuildPlanSnapshotSchema = z.object({
|
|
4455
|
+
templateId: z.string().trim().min(1).max(100),
|
|
4456
|
+
templateLabel: z.string().trim().min(1).max(120),
|
|
4457
|
+
steps: z.array(BuildPlanSnapshotStepSchema).min(1)
|
|
4458
|
+
}).superRefine((snapshot, ctx) => {
|
|
4459
|
+
const stepIds = /* @__PURE__ */ new Set();
|
|
4460
|
+
snapshot.steps.forEach((step, index) => {
|
|
4461
|
+
if (stepIds.has(step.id)) {
|
|
4462
|
+
ctx.addIssue({
|
|
4463
|
+
code: z.ZodIssueCode.custom,
|
|
4464
|
+
message: `duplicate build-plan step id "${step.id}"`,
|
|
4465
|
+
path: ["steps", index, "id"]
|
|
4466
|
+
});
|
|
4467
|
+
}
|
|
4468
|
+
stepIds.add(step.id);
|
|
4469
|
+
});
|
|
4470
|
+
snapshot.steps.forEach((step, index) => {
|
|
4471
|
+
for (const dependencyId of step.dependsOn ?? []) {
|
|
4472
|
+
if (!stepIds.has(dependencyId)) {
|
|
4473
|
+
ctx.addIssue({
|
|
4474
|
+
code: z.ZodIssueCode.custom,
|
|
4475
|
+
message: `dependsOn references unknown build-plan step "${dependencyId}"`,
|
|
4476
|
+
path: ["steps", index, "dependsOn"]
|
|
4477
|
+
});
|
|
4478
|
+
}
|
|
4479
|
+
}
|
|
4480
|
+
});
|
|
4481
|
+
});
|
|
4482
|
+
var AcqListMetadataSchema = z.object({
|
|
4483
|
+
buildPlanSnapshot: BuildPlanSnapshotSchema.optional()
|
|
4484
|
+
}).catchall(z.unknown());
|
|
4485
|
+
var ProspectingBuildTemplateIdSchema = z.string().trim().min(1).max(100).refine(isProspectingBuildTemplateId, {
|
|
4486
|
+
message: "buildTemplateId must match a known prospecting build template"
|
|
4487
|
+
});
|
|
4488
|
+
var ListStageCountsSchema = z.object({
|
|
4489
|
+
// Attempted counts by canonical lead-gen stage. The detailed status
|
|
4490
|
+
// distribution lives on ListProgress; telemetry keeps the overview payload small.
|
|
4491
|
+
stageCounts: z.object({
|
|
4492
|
+
populated: z.number().int(),
|
|
4493
|
+
extracted: z.number().int(),
|
|
4494
|
+
qualified: z.number().int(),
|
|
4495
|
+
discovered: z.number().int(),
|
|
4496
|
+
verified: z.number().int(),
|
|
4497
|
+
personalized: z.number().int(),
|
|
4498
|
+
uploaded: z.number().int()
|
|
4499
|
+
}),
|
|
4500
|
+
deliverability: z.object({
|
|
4501
|
+
valid: z.number().int(),
|
|
4502
|
+
risky: z.number().int(),
|
|
4503
|
+
invalid: z.number().int(),
|
|
4504
|
+
unknown: z.number().int(),
|
|
4505
|
+
bounced: z.number().int()
|
|
4506
|
+
})
|
|
4507
|
+
});
|
|
4508
|
+
var ListTelemetrySchema = z.object({
|
|
4509
|
+
listId: UuidSchema,
|
|
4510
|
+
totalCompanies: z.number().int(),
|
|
4511
|
+
totalContacts: z.number().int(),
|
|
4512
|
+
stageCounts: ListStageCountsSchema.shape.stageCounts,
|
|
4513
|
+
deliverability: ListStageCountsSchema.shape.deliverability,
|
|
4514
|
+
activeWorkflows: z.array(z.string()).optional()
|
|
4515
|
+
});
|
|
4516
|
+
z.object({
|
|
4517
|
+
listId: UuidSchema
|
|
4518
|
+
});
|
|
4519
|
+
z.object({
|
|
4520
|
+
name: z.string().trim().min(1).max(255),
|
|
4521
|
+
description: z.string().trim().nullable().optional(),
|
|
4522
|
+
status: ListStatusSchema.optional(),
|
|
4523
|
+
buildTemplateId: ProspectingBuildTemplateIdSchema.optional(),
|
|
4524
|
+
scrapingConfig: ScrapingConfigSchema.optional(),
|
|
4525
|
+
icp: IcpRubricSchema.optional(),
|
|
4526
|
+
pipelineConfig: PipelineConfigSchema.optional()
|
|
4527
|
+
}).strict();
|
|
4528
|
+
z.object({
|
|
4529
|
+
name: z.string().trim().min(1).max(255).optional(),
|
|
4530
|
+
description: z.string().trim().nullable().optional(),
|
|
4531
|
+
batchIds: z.array(z.string()).optional(),
|
|
4532
|
+
buildTemplateId: ProspectingBuildTemplateIdSchema.optional(),
|
|
4533
|
+
confirmBuildTemplateChange: z.literal(true).optional()
|
|
4534
|
+
}).strict().refine(
|
|
4535
|
+
(data) => data.name !== void 0 || data.description !== void 0 || data.batchIds !== void 0 || data.buildTemplateId !== void 0,
|
|
4536
|
+
{
|
|
4537
|
+
message: "At least one field (name, description, batchIds, or buildTemplateId) must be provided"
|
|
4538
|
+
}
|
|
4539
|
+
).refine((data) => data.buildTemplateId === void 0 || data.confirmBuildTemplateChange === true, {
|
|
4540
|
+
message: "confirmBuildTemplateChange must be true when changing buildTemplateId",
|
|
4541
|
+
path: ["confirmBuildTemplateChange"]
|
|
4542
|
+
});
|
|
4543
|
+
z.object({
|
|
4544
|
+
status: ListStatusSchema
|
|
4545
|
+
}).strict();
|
|
4546
|
+
z.object({
|
|
4547
|
+
scrapingConfig: ScrapingConfigSchema.partial().optional(),
|
|
4548
|
+
icp: IcpRubricSchema.partial().optional(),
|
|
4549
|
+
pipelineConfig: PipelineConfigSchema.partial().optional()
|
|
4550
|
+
}).strict().refine((data) => data.scrapingConfig !== void 0 || data.icp !== void 0 || data.pipelineConfig !== void 0, {
|
|
4551
|
+
message: "At least one of scrapingConfig, icp, or pipelineConfig must be provided"
|
|
4552
|
+
});
|
|
4553
|
+
z.object({
|
|
4554
|
+
companyIds: z.array(UuidSchema).min(1).max(1e3)
|
|
4555
|
+
}).strict();
|
|
4556
|
+
z.object({
|
|
4557
|
+
companyIds: z.array(UuidSchema).min(1).max(1e3)
|
|
4558
|
+
}).strict();
|
|
4559
|
+
z.object({
|
|
4560
|
+
contactIds: z.array(UuidSchema).min(1).max(1e3)
|
|
4561
|
+
}).strict();
|
|
4562
|
+
z.object({
|
|
4563
|
+
executionId: UuidSchema,
|
|
4564
|
+
configSnapshot: z.record(z.string(), z.unknown()).optional()
|
|
4565
|
+
}).strict();
|
|
4566
|
+
var AcqListResponseSchema = z.object({
|
|
4567
|
+
id: z.string(),
|
|
4568
|
+
organizationId: z.string(),
|
|
4569
|
+
name: z.string(),
|
|
4570
|
+
description: z.string().nullable(),
|
|
4571
|
+
batchIds: z.array(z.string()),
|
|
4572
|
+
instantlyCampaignId: z.string().nullable(),
|
|
4573
|
+
/** Lifecycle status (draft | enriching | launched | closing | archived). */
|
|
4574
|
+
status: ListStatusSchema,
|
|
4575
|
+
metadata: AcqListMetadataSchema,
|
|
4576
|
+
launchedAt: z.string().nullable(),
|
|
4577
|
+
completedAt: z.string().nullable(),
|
|
4578
|
+
createdAt: z.string(),
|
|
4579
|
+
/** Scraping criteria stored as jsonb on the row. */
|
|
4580
|
+
scrapingConfig: ScrapingConfigSchema,
|
|
4581
|
+
/** ICP / qualification rubric stored as jsonb on the row. */
|
|
4582
|
+
icp: IcpRubricSchema,
|
|
4583
|
+
/** Pipeline presentation contract stored as jsonb on the row. */
|
|
4584
|
+
pipelineConfig: PipelineConfigSchema
|
|
4585
|
+
});
|
|
4586
|
+
z.array(AcqListResponseSchema);
|
|
4587
|
+
z.array(ListTelemetrySchema);
|
|
4588
|
+
var ListStageProgressSchema = z.object({
|
|
4589
|
+
total: z.number().int().min(0),
|
|
4590
|
+
attempted: z.number().int().min(0),
|
|
4591
|
+
success: z.number().int().min(0),
|
|
4592
|
+
noResult: z.number().int().min(0),
|
|
4593
|
+
skipped: z.number().int().min(0),
|
|
4594
|
+
error: z.number().int().min(0),
|
|
4595
|
+
other: z.number().int().min(0),
|
|
4596
|
+
notAttempted: z.number().int().min(0)
|
|
4597
|
+
});
|
|
4598
|
+
z.object({
|
|
4599
|
+
totalMembers: z.number().int().min(0),
|
|
4600
|
+
totalCompanies: z.number().int().min(0),
|
|
4601
|
+
byCompanyStage: z.record(z.string(), ListStageProgressSchema),
|
|
4602
|
+
byContactStage: z.record(z.string(), ListStageProgressSchema)
|
|
4603
|
+
});
|
|
4604
|
+
var ListExecutionSummarySchema = z.object({
|
|
4605
|
+
executionId: z.string(),
|
|
4606
|
+
resourceId: z.string(),
|
|
4607
|
+
status: z.string(),
|
|
4608
|
+
createdAt: z.string(),
|
|
4609
|
+
completedAt: z.string().nullable(),
|
|
4610
|
+
durationMs: z.number().int().nullable(),
|
|
4611
|
+
input: z.unknown().nullable().optional()
|
|
4612
|
+
});
|
|
4613
|
+
z.array(ListExecutionSummarySchema);
|
|
4614
|
+
var QueryBooleanSchema = z.preprocess((value) => {
|
|
4615
|
+
if (value === "true" || value === "1" || value === true) return true;
|
|
4616
|
+
if (value === "false" || value === "0" || value === false) return false;
|
|
4617
|
+
return value;
|
|
4618
|
+
}, z.boolean());
|
|
4619
|
+
var AcqCompanyStatusSchema = z.enum(["active", "invalid"]);
|
|
4620
|
+
var AcqContactStatusSchema = z.enum(["active", "invalid"]);
|
|
4621
|
+
var AcqEmailValidSchema = z.enum(["VALID", "INVALID", "RISKY", "UNKNOWN"]);
|
|
4622
|
+
z.object({
|
|
4623
|
+
companyId: UuidSchema
|
|
4624
|
+
});
|
|
4625
|
+
z.object({
|
|
4626
|
+
contactId: UuidSchema
|
|
4627
|
+
});
|
|
4628
|
+
z.object({
|
|
4629
|
+
search: z.string().trim().min(1).max(200).optional(),
|
|
4630
|
+
listId: UuidSchema.optional(),
|
|
4631
|
+
domain: z.string().trim().min(1).max(255).optional(),
|
|
4632
|
+
website: z.string().trim().min(1).max(2048).optional(),
|
|
4633
|
+
segment: z.string().trim().min(1).max(255).optional(),
|
|
4634
|
+
category: z.string().trim().min(1).max(255).optional(),
|
|
4635
|
+
pipelineStatus: z.unknown().optional(),
|
|
4636
|
+
batchId: z.string().trim().min(1).max(255).optional(),
|
|
4637
|
+
status: AcqCompanyStatusSchema.optional(),
|
|
4638
|
+
includeAll: QueryBooleanSchema.optional(),
|
|
4639
|
+
limit: z.coerce.number().int().min(1).max(5e3).default(50),
|
|
4640
|
+
offset: z.coerce.number().int().min(0).default(0)
|
|
4641
|
+
}).strict();
|
|
4642
|
+
z.object({
|
|
4643
|
+
search: z.string().trim().min(1).max(200).optional(),
|
|
4644
|
+
listId: UuidSchema.optional(),
|
|
4645
|
+
openingLineIsNull: QueryBooleanSchema.optional(),
|
|
4646
|
+
batchId: z.string().trim().min(1).max(255).optional(),
|
|
4647
|
+
contactStatus: AcqContactStatusSchema.optional(),
|
|
4648
|
+
limit: z.coerce.number().int().min(1).max(5e3).default(5e3),
|
|
4649
|
+
offset: z.coerce.number().int().min(0).default(0)
|
|
4650
|
+
}).strict();
|
|
4651
|
+
z.object({
|
|
4652
|
+
name: z.string().trim().min(1).max(255),
|
|
4653
|
+
domain: z.string().trim().min(1).max(255).optional(),
|
|
4654
|
+
linkedinUrl: z.string().trim().url().optional(),
|
|
4655
|
+
website: z.string().trim().url().optional(),
|
|
4656
|
+
numEmployees: z.number().int().min(0).optional(),
|
|
4657
|
+
foundedYear: z.number().int().optional(),
|
|
4658
|
+
locationCity: z.string().trim().min(1).max(255).optional(),
|
|
4659
|
+
locationState: z.string().trim().min(1).max(255).optional(),
|
|
4660
|
+
category: z.string().trim().min(1).max(255).optional(),
|
|
4661
|
+
source: z.string().trim().min(1).max(255).optional(),
|
|
4662
|
+
batchId: z.string().trim().min(1).max(255).optional(),
|
|
4663
|
+
pipelineStatus: z.unknown().optional(),
|
|
4664
|
+
verticalResearch: z.string().trim().min(1).max(5e3).optional()
|
|
4665
|
+
}).strict();
|
|
4666
|
+
z.object({
|
|
4667
|
+
name: z.string().trim().min(1).max(255).optional(),
|
|
4668
|
+
domain: z.string().trim().min(1).max(255).optional(),
|
|
4669
|
+
linkedinUrl: z.string().trim().url().optional(),
|
|
4670
|
+
website: z.string().trim().url().optional(),
|
|
4671
|
+
numEmployees: z.number().int().min(0).optional(),
|
|
4672
|
+
foundedYear: z.number().int().optional(),
|
|
4673
|
+
locationCity: z.string().trim().min(1).max(255).optional(),
|
|
4674
|
+
locationState: z.string().trim().min(1).max(255).optional(),
|
|
4675
|
+
category: z.string().trim().min(1).max(255).optional(),
|
|
4676
|
+
segment: z.string().trim().min(1).max(255).optional(),
|
|
4677
|
+
processingState: CompanyProcessingStateSchema.optional(),
|
|
4678
|
+
pipelineStatus: z.unknown().optional(),
|
|
4679
|
+
enrichmentData: z.record(z.string(), z.unknown()).optional(),
|
|
4680
|
+
source: z.string().trim().min(1).max(255).optional(),
|
|
4681
|
+
batchId: z.string().trim().min(1).max(255).optional(),
|
|
4682
|
+
status: AcqCompanyStatusSchema.optional(),
|
|
4683
|
+
verticalResearch: z.string().trim().min(1).max(5e3).nullable().optional()
|
|
4684
|
+
}).strict().refine(
|
|
4685
|
+
(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,
|
|
4686
|
+
{
|
|
4687
|
+
message: "At least one field must be provided"
|
|
4688
|
+
}
|
|
4689
|
+
);
|
|
4690
|
+
z.object({
|
|
4691
|
+
email: z.string().trim().email(),
|
|
4692
|
+
companyId: UuidSchema.optional(),
|
|
4693
|
+
firstName: z.string().trim().min(1).max(255).optional(),
|
|
4694
|
+
lastName: z.string().trim().min(1).max(255).optional(),
|
|
4695
|
+
linkedinUrl: z.string().trim().url().optional(),
|
|
4696
|
+
title: z.string().trim().min(1).max(255).optional(),
|
|
4697
|
+
source: z.string().trim().min(1).max(255).optional(),
|
|
4698
|
+
sourceId: z.string().trim().min(1).max(255).optional(),
|
|
4699
|
+
batchId: z.string().trim().min(1).max(255).optional(),
|
|
4700
|
+
pipelineStatus: z.unknown().optional()
|
|
4701
|
+
}).strict();
|
|
4702
|
+
z.object({
|
|
4703
|
+
companyId: UuidSchema.optional(),
|
|
4704
|
+
emailValid: AcqEmailValidSchema.optional(),
|
|
4705
|
+
firstName: z.string().trim().min(1).max(255).optional(),
|
|
4706
|
+
lastName: z.string().trim().min(1).max(255).optional(),
|
|
4707
|
+
linkedinUrl: z.string().trim().url().optional(),
|
|
4708
|
+
title: z.string().trim().min(1).max(255).optional(),
|
|
4709
|
+
headline: z.string().trim().min(1).max(5e3).optional(),
|
|
4710
|
+
filterReason: z.string().trim().min(1).max(5e3).optional(),
|
|
4711
|
+
openingLine: z.string().trim().min(1).max(5e3).optional(),
|
|
4712
|
+
processingState: ContactProcessingStateSchema.optional(),
|
|
4713
|
+
pipelineStatus: z.unknown().optional(),
|
|
4714
|
+
enrichmentData: z.record(z.string(), z.unknown()).optional(),
|
|
4715
|
+
status: AcqContactStatusSchema.optional()
|
|
4716
|
+
}).strict().refine(
|
|
4717
|
+
(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,
|
|
4718
|
+
{
|
|
4719
|
+
message: "At least one field must be provided"
|
|
4720
|
+
}
|
|
4721
|
+
);
|
|
4722
|
+
var AcqCompanyResponseSchema = z.object({
|
|
4723
|
+
id: z.string(),
|
|
4724
|
+
organizationId: z.string(),
|
|
4725
|
+
name: z.string(),
|
|
4726
|
+
domain: z.string().nullable(),
|
|
4727
|
+
linkedinUrl: z.string().nullable(),
|
|
4728
|
+
website: z.string().nullable(),
|
|
4729
|
+
numEmployees: z.number().nullable(),
|
|
4730
|
+
foundedYear: z.number().nullable(),
|
|
4731
|
+
locationCity: z.string().nullable(),
|
|
4732
|
+
locationState: z.string().nullable(),
|
|
4733
|
+
category: z.string().nullable(),
|
|
4734
|
+
categoryPain: z.string().nullable(),
|
|
4735
|
+
segment: z.string().nullable(),
|
|
4736
|
+
processingState: CompanyProcessingStateSchema.nullable(),
|
|
4737
|
+
pipelineStatus: z.unknown().nullable().optional(),
|
|
4738
|
+
enrichmentData: z.record(z.string(), z.unknown()).nullable(),
|
|
4739
|
+
source: z.string().nullable(),
|
|
4740
|
+
batchId: z.string().nullable(),
|
|
4741
|
+
status: AcqCompanyStatusSchema,
|
|
4742
|
+
contactCount: z.number().int().min(0),
|
|
4743
|
+
verticalResearch: z.string().nullable(),
|
|
4744
|
+
createdAt: z.string(),
|
|
4745
|
+
updatedAt: z.string()
|
|
4746
|
+
});
|
|
4747
|
+
z.object({
|
|
4748
|
+
data: z.array(AcqCompanyResponseSchema),
|
|
4749
|
+
total: z.number().int(),
|
|
4750
|
+
limit: z.number().int(),
|
|
4751
|
+
offset: z.number().int()
|
|
4752
|
+
});
|
|
4753
|
+
z.object({
|
|
4754
|
+
segments: z.array(z.string()),
|
|
4755
|
+
categories: z.array(z.string()),
|
|
4756
|
+
statuses: z.array(AcqCompanyStatusSchema)
|
|
4757
|
+
});
|
|
4758
|
+
var AcqContactCompanySummarySchema = z.object({
|
|
4759
|
+
id: z.string(),
|
|
4760
|
+
name: z.string(),
|
|
4761
|
+
domain: z.string().nullable(),
|
|
4762
|
+
website: z.string().nullable(),
|
|
4763
|
+
linkedinUrl: z.string().nullable(),
|
|
4764
|
+
segment: z.string().nullable(),
|
|
4765
|
+
category: z.string().nullable(),
|
|
4766
|
+
status: AcqCompanyStatusSchema
|
|
4767
|
+
});
|
|
4768
|
+
var AcqContactResponseSchema = z.object({
|
|
4769
|
+
id: z.string(),
|
|
4770
|
+
organizationId: z.string(),
|
|
4771
|
+
companyId: z.string().nullable(),
|
|
4772
|
+
email: z.string(),
|
|
4773
|
+
emailValid: AcqEmailValidSchema.nullable(),
|
|
4774
|
+
firstName: z.string().nullable(),
|
|
4775
|
+
lastName: z.string().nullable(),
|
|
4776
|
+
linkedinUrl: z.string().nullable(),
|
|
4777
|
+
title: z.string().nullable(),
|
|
4778
|
+
headline: z.string().nullable(),
|
|
4779
|
+
filterReason: z.string().nullable(),
|
|
4780
|
+
openingLine: z.string().nullable(),
|
|
4781
|
+
source: z.string().nullable(),
|
|
4782
|
+
sourceId: z.string().nullable(),
|
|
4783
|
+
processingState: ContactProcessingStateSchema.nullable(),
|
|
4784
|
+
pipelineStatus: z.unknown().nullable().optional(),
|
|
4785
|
+
enrichmentData: z.record(z.string(), z.unknown()).nullable(),
|
|
4786
|
+
attioPersonId: z.string().nullable(),
|
|
4787
|
+
batchId: z.string().nullable(),
|
|
4788
|
+
status: AcqContactStatusSchema,
|
|
4789
|
+
company: AcqContactCompanySummarySchema.nullable().optional(),
|
|
4790
|
+
createdAt: z.string(),
|
|
4791
|
+
updatedAt: z.string()
|
|
4792
|
+
});
|
|
4793
|
+
z.object({
|
|
4794
|
+
data: z.array(AcqContactResponseSchema),
|
|
4795
|
+
total: z.number().int(),
|
|
4796
|
+
limit: z.number().int(),
|
|
4797
|
+
offset: z.number().int()
|
|
4798
|
+
});
|
|
4799
|
+
var AcqArtifactOwnerKindSchema = z.enum(["company", "contact", "deal", "list", "list_member"]);
|
|
4800
|
+
z.object({
|
|
4801
|
+
ownerKind: AcqArtifactOwnerKindSchema,
|
|
4802
|
+
ownerId: UuidSchema
|
|
4803
|
+
}).strict();
|
|
4804
|
+
z.object({
|
|
4805
|
+
ownerKind: AcqArtifactOwnerKindSchema,
|
|
4806
|
+
ownerId: UuidSchema,
|
|
4807
|
+
kind: z.string().trim().min(1).max(255),
|
|
4808
|
+
content: z.record(z.string(), z.unknown()),
|
|
4809
|
+
sourceExecutionId: UuidSchema.optional()
|
|
4810
|
+
}).strict();
|
|
4811
|
+
var AcqArtifactResponseSchema = z.object({
|
|
4812
|
+
id: z.string(),
|
|
4813
|
+
organizationId: z.string(),
|
|
4814
|
+
ownerKind: z.string(),
|
|
4815
|
+
ownerId: z.string(),
|
|
4816
|
+
kind: z.string(),
|
|
4817
|
+
content: z.record(z.string(), z.unknown()),
|
|
4818
|
+
sourceExecutionId: z.string().nullable(),
|
|
4819
|
+
createdBy: z.string().nullable(),
|
|
4820
|
+
createdAt: z.string(),
|
|
4821
|
+
version: z.number().int()
|
|
4822
|
+
});
|
|
4823
|
+
z.object({
|
|
4824
|
+
artifacts: z.array(AcqArtifactResponseSchema)
|
|
4825
|
+
});
|
|
4826
|
+
z.object({
|
|
4827
|
+
limit: z.coerce.number().int().min(1).max(500).default(50),
|
|
4828
|
+
offset: z.coerce.number().int().min(0).default(0)
|
|
4829
|
+
}).strict();
|
|
4830
|
+
z.object({
|
|
4831
|
+
memberId: UuidSchema
|
|
4832
|
+
});
|
|
4833
|
+
var AcqListMemberContactSummarySchema = z.object({
|
|
4834
|
+
id: z.string(),
|
|
4835
|
+
email: z.string(),
|
|
4836
|
+
firstName: z.string().nullable(),
|
|
4837
|
+
lastName: z.string().nullable(),
|
|
4838
|
+
title: z.string().nullable(),
|
|
4839
|
+
linkedinUrl: z.string().nullable(),
|
|
4840
|
+
companyId: z.string().nullable()
|
|
4841
|
+
});
|
|
4842
|
+
var AcqListMemberResponseSchema = z.object({
|
|
4843
|
+
id: z.string(),
|
|
4844
|
+
listId: z.string(),
|
|
4845
|
+
contactId: z.string(),
|
|
4846
|
+
pipelineKey: z.string(),
|
|
4847
|
+
stageKey: z.string(),
|
|
4848
|
+
stateKey: z.string(),
|
|
4849
|
+
activityLog: z.unknown(),
|
|
4850
|
+
addedAt: z.string(),
|
|
4851
|
+
addedBy: z.string().nullable(),
|
|
4852
|
+
sourceExecutionId: z.string().nullable(),
|
|
4853
|
+
contact: AcqListMemberContactSummarySchema.nullable()
|
|
4854
|
+
});
|
|
4855
|
+
z.object({
|
|
4856
|
+
members: z.array(AcqListMemberResponseSchema)
|
|
4857
|
+
});
|
|
4858
|
+
z.object({
|
|
4859
|
+
listCompanyId: UuidSchema
|
|
4860
|
+
});
|
|
4861
|
+
z.object({
|
|
4862
|
+
id: z.string(),
|
|
4863
|
+
listId: z.string(),
|
|
4864
|
+
companyId: z.string(),
|
|
4865
|
+
pipelineKey: z.string(),
|
|
4866
|
+
stageKey: z.string(),
|
|
4867
|
+
stateKey: z.string(),
|
|
4868
|
+
activityLog: z.unknown(),
|
|
4869
|
+
addedAt: z.string(),
|
|
4870
|
+
addedBy: z.string().nullable(),
|
|
4871
|
+
sourceExecutionId: z.string().nullable()
|
|
4872
|
+
});
|
|
3792
4873
|
var StageChangeEventSchema = z.object({
|
|
3793
4874
|
type: z.literal("stage_change"),
|
|
3794
4875
|
timestamp: z.string().datetime(),
|
|
@@ -3857,64 +4938,6 @@ var ActivityEventSchema = z.discriminatedUnion("type", [
|
|
|
3857
4938
|
DealCreatedEventSchema,
|
|
3858
4939
|
ActionFailedEventSchema
|
|
3859
4940
|
]);
|
|
3860
|
-
|
|
3861
|
-
// ../core/src/business/acquisition/deal-ownership.ts
|
|
3862
|
-
var INBOUND_EVENT_TYPES = ["reply_received"];
|
|
3863
|
-
var OUTBOUND_EVENT_TYPES = [
|
|
3864
|
-
"reply_sent_to_lead",
|
|
3865
|
-
"booking_nudge_sent",
|
|
3866
|
-
"reminder_sent",
|
|
3867
|
-
"rebook_sent",
|
|
3868
|
-
"followup_email_sent",
|
|
3869
|
-
"reply_followup_sent",
|
|
3870
|
-
"lead_deferred_next_step"
|
|
3871
|
-
];
|
|
3872
|
-
var INBOUND_SET = new Set(INBOUND_EVENT_TYPES);
|
|
3873
|
-
var OUTBOUND_SET = new Set(OUTBOUND_EVENT_TYPES);
|
|
3874
|
-
function getDealOwnership(deal) {
|
|
3875
|
-
if (deal.state_key === "closed_won" || deal.state_key === "closed_lost") {
|
|
3876
|
-
return null;
|
|
3877
|
-
}
|
|
3878
|
-
if (!Array.isArray(deal.activity_log)) return null;
|
|
3879
|
-
let latestInboundMs = null;
|
|
3880
|
-
let latestOutboundMs = null;
|
|
3881
|
-
for (const entry of deal.activity_log) {
|
|
3882
|
-
if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
|
|
3883
|
-
const record = entry;
|
|
3884
|
-
const type = typeof record.type === "string" ? record.type : null;
|
|
3885
|
-
if (!type) continue;
|
|
3886
|
-
const isInbound = INBOUND_SET.has(type);
|
|
3887
|
-
const isOutbound = OUTBOUND_SET.has(type);
|
|
3888
|
-
if (!isInbound && !isOutbound) continue;
|
|
3889
|
-
const occurredAt = resolveTimestamp(record);
|
|
3890
|
-
if (occurredAt === null) continue;
|
|
3891
|
-
if (isInbound && (latestInboundMs === null || occurredAt > latestInboundMs)) {
|
|
3892
|
-
latestInboundMs = occurredAt;
|
|
3893
|
-
}
|
|
3894
|
-
if (isOutbound && (latestOutboundMs === null || occurredAt > latestOutboundMs)) {
|
|
3895
|
-
latestOutboundMs = occurredAt;
|
|
3896
|
-
}
|
|
3897
|
-
}
|
|
3898
|
-
if (latestInboundMs === null && latestOutboundMs === null) return null;
|
|
3899
|
-
if (latestOutboundMs !== null && (latestInboundMs === null || latestOutboundMs >= latestInboundMs)) {
|
|
3900
|
-
return "them";
|
|
3901
|
-
}
|
|
3902
|
-
return "us";
|
|
3903
|
-
}
|
|
3904
|
-
function resolveTimestamp(record) {
|
|
3905
|
-
return parseMs(record.timestamp) ?? parseMs(record.occurredAt) ?? parseMs(record.createdAt) ?? parseMs(record.updatedAt) ?? parseMs(record.sentAt) ?? null;
|
|
3906
|
-
}
|
|
3907
|
-
function parseMs(value) {
|
|
3908
|
-
if (value instanceof Date) {
|
|
3909
|
-
const ms2 = value.getTime();
|
|
3910
|
-
return Number.isNaN(ms2) ? null : ms2;
|
|
3911
|
-
}
|
|
3912
|
-
if (typeof value !== "string") return null;
|
|
3913
|
-
const ms = new Date(value).getTime();
|
|
3914
|
-
return Number.isNaN(ms) ? null : ms;
|
|
3915
|
-
}
|
|
3916
|
-
|
|
3917
|
-
// ../core/src/business/acquisition/derive-actions.ts
|
|
3918
4941
|
var SendReplyActionPayloadSchema = z.object({
|
|
3919
4942
|
replyBody: z.string().trim().min(1).max(1e4)
|
|
3920
4943
|
}).strict();
|
|
@@ -3993,5 +5016,7 @@ function isOurReplyAction(deal) {
|
|
|
3993
5016
|
}
|
|
3994
5017
|
return (deal.ownership ?? getDealOwnership(deal)) === "us";
|
|
3995
5018
|
}
|
|
5019
|
+
var listBuilderStageKeys = Object.keys(LEAD_GEN_STAGE_CATALOG);
|
|
5020
|
+
var ListBuilderStageKeySchema = z.enum(listBuilderStageKeys);
|
|
3996
5021
|
|
|
3997
|
-
export { ActivityEventSchema, DEFAULT_CRM_ACTIONS, EmailSchema, ExecutionError, RegistryValidationError, ResourceRegistry, StepType, ToolingError, deriveActions };
|
|
5022
|
+
export { ActivityEventSchema, BuildPlanSnapshotStepSchema, ProspectingBuildTemplateSchema as BuildTemplateSchema, DEFAULT_CRM_ACTIONS, EmailSchema, ExecutionError, LEAD_GEN_STAGE_CATALOG, ListBuilderStageKeySchema, ProcessingStageStatusSchema, RegistryValidationError, ResourceRegistry, StepType, ToolingError, deriveActions };
|