@elevasis/sdk 1.12.0 → 1.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3716,50 +3716,6 @@ var DealCreatedEventSchema = z.object({
3716
3716
  type: z.literal("deal_created"),
3717
3717
  timestamp: z.string().datetime()
3718
3718
  });
3719
- var ReplyReceivedEventSchema = z.object({
3720
- type: z.literal("reply_received"),
3721
- timestamp: z.string().datetime(),
3722
- messageId: z.string().optional(),
3723
- source: z.string().optional()
3724
- });
3725
- var ReplySentToLeadEventSchema = z.object({
3726
- type: z.literal("reply_sent_to_lead"),
3727
- timestamp: z.string().datetime(),
3728
- messageId: z.string().optional(),
3729
- source: z.string().optional()
3730
- });
3731
- var BookingNudgeSentEventSchema = z.object({
3732
- type: z.literal("booking_nudge_sent"),
3733
- timestamp: z.string().datetime(),
3734
- followupDay: z.number()
3735
- });
3736
- var ReminderSentEventSchema = z.object({
3737
- type: z.literal("reminder_sent"),
3738
- timestamp: z.string().datetime(),
3739
- followupDay: z.number().optional()
3740
- });
3741
- var BookingCancelledEventSchema = z.object({
3742
- type: z.literal("booking_cancelled"),
3743
- timestamp: z.string().datetime(),
3744
- reason: z.string().optional()
3745
- });
3746
- var DiscoverySubmittedEventSchema = z.object({
3747
- type: z.literal("discovery_submitted"),
3748
- timestamp: z.string().datetime()
3749
- });
3750
- var MovedToNurturingEventSchema = z.object({
3751
- type: z.literal("moved_to_nurturing"),
3752
- timestamp: z.string().datetime()
3753
- });
3754
- var NoShowEventSchema = z.object({
3755
- type: z.literal("no_show"),
3756
- timestamp: z.string().datetime()
3757
- });
3758
- var FollowupEmailSentEventSchema = z.object({
3759
- type: z.literal("followup_email_sent"),
3760
- timestamp: z.string().datetime(),
3761
- followupDay: z.number().optional()
3762
- });
3763
3719
  var ActivityEventSchema = z.discriminatedUnion("type", [
3764
3720
  StageChangeEventSchema,
3765
3721
  StateChangeEventSchema,
@@ -3768,82 +3724,71 @@ var ActivityEventSchema = z.discriminatedUnion("type", [
3768
3724
  ApprovalResolvedEventSchema,
3769
3725
  ApprovalStaleEventSchema,
3770
3726
  TaskCreatedEventSchema,
3771
- DealCreatedEventSchema,
3772
- ReplyReceivedEventSchema,
3773
- ReplySentToLeadEventSchema,
3774
- BookingNudgeSentEventSchema,
3775
- ReminderSentEventSchema,
3776
- BookingCancelledEventSchema,
3777
- DiscoverySubmittedEventSchema,
3778
- MovedToNurturingEventSchema,
3779
- NoShowEventSchema,
3780
- FollowupEmailSentEventSchema
3727
+ DealCreatedEventSchema
3781
3728
  ]);
3782
3729
 
3783
3730
  // ../core/src/business/acquisition/derive-actions.ts
3784
- var STAGE_ORDER = ["interested", "proposal", "closing", "closed_won", "closed_lost", "nurturing"];
3785
- function isDefaultStage(key) {
3786
- return STAGE_ORDER.includes(key);
3787
- }
3788
- function transitionAction(stageKey) {
3789
- const labels = {
3790
- interested: "Move to Interested",
3791
- proposal: "Move to Proposal",
3792
- closing: "Move to Closing",
3793
- closed_won: "Close Won",
3794
- closed_lost: "Close Lost",
3795
- nurturing: "Move to Nurturing"
3796
- };
3797
- return {
3798
- key: `move_to_${stageKey}`,
3799
- label: labels[stageKey],
3800
- kind: "transition",
3801
- payload: { stageKey }
3802
- };
3803
- }
3804
- function interestedActions(stateKey) {
3805
- const base = [transitionAction("proposal"), transitionAction("closed_lost"), transitionAction("nurturing")];
3806
- if (stateKey === "discovery_replied") {
3807
- return [...base, { key: "send_link", label: "Send Booking Link", kind: "modal" }];
3808
- }
3809
- if (stateKey === "discovery_link_sent") {
3810
- return [...base, { key: "send_nudge", label: "Send Nudge", kind: "modal" }];
3811
- }
3812
- if (stateKey === "discovery_nudging") {
3813
- return [
3814
- ...base,
3815
- { key: "send_nudge", label: "Send Nudge", kind: "modal" },
3816
- { key: "mark_no_show", label: "Mark No-Show", kind: "transition" }
3817
- ];
3818
- }
3819
- if (stateKey === "discovery_booking_cancelled") {
3820
- return [...base, { key: "rebook", label: "Rebook", kind: "modal" }];
3821
- }
3822
- return base;
3823
- }
3824
- function proposalActions() {
3825
- return [transitionAction("closing"), transitionAction("closed_lost"), transitionAction("nurturing")];
3826
- }
3827
- function closingActions() {
3828
- return [transitionAction("closed_won"), transitionAction("closed_lost"), transitionAction("nurturing")];
3829
- }
3830
- function deriveActions(deal) {
3831
- const stage = deal.stage_key;
3832
- if (!isDefaultStage(stage)) {
3833
- return [];
3834
- }
3835
- switch (stage) {
3836
- case "interested":
3837
- return interestedActions(deal.state_key);
3838
- case "proposal":
3839
- return proposalActions();
3840
- case "closing":
3841
- return closingActions();
3842
- case "closed_won":
3843
- case "closed_lost":
3844
- case "nurturing":
3845
- return [];
3731
+ var DEFAULT_CRM_ACTIONS = [
3732
+ {
3733
+ key: "move_to_proposal",
3734
+ label: "Move to Proposal",
3735
+ isAvailableFor: (deal) => deal.stage_key === "interested",
3736
+ workflowId: "move_to_proposal-workflow"
3737
+ },
3738
+ {
3739
+ key: "move_to_closing",
3740
+ label: "Move to Closing",
3741
+ isAvailableFor: (deal) => deal.stage_key === "proposal",
3742
+ workflowId: "move_to_closing-workflow"
3743
+ },
3744
+ {
3745
+ key: "move_to_closed_won",
3746
+ label: "Close Won",
3747
+ isAvailableFor: (deal) => deal.stage_key === "closing",
3748
+ workflowId: "move_to_closed_won-workflow"
3749
+ },
3750
+ {
3751
+ key: "move_to_closed_lost",
3752
+ label: "Close Lost",
3753
+ isAvailableFor: (deal) => deal.stage_key === "interested" || deal.stage_key === "proposal" || deal.stage_key === "closing",
3754
+ workflowId: "move_to_closed_lost-workflow"
3755
+ },
3756
+ {
3757
+ key: "move_to_nurturing",
3758
+ label: "Move to Nurturing",
3759
+ isAvailableFor: (deal) => deal.stage_key === "interested" || deal.stage_key === "proposal" || deal.stage_key === "closing",
3760
+ workflowId: "move_to_nurturing-workflow"
3761
+ },
3762
+ {
3763
+ key: "send_link",
3764
+ label: "Send Booking Link",
3765
+ isAvailableFor: (deal) => deal.stage_key === "interested" && deal.state_key === "discovery_replied",
3766
+ workflowId: "crm-send-booking-link-workflow"
3767
+ },
3768
+ {
3769
+ key: "send_nudge",
3770
+ label: "Send Nudge",
3771
+ isAvailableFor: (deal) => deal.stage_key === "interested" && (deal.state_key === "discovery_link_sent" || deal.state_key === "discovery_nudging"),
3772
+ workflowId: "crm-send-nudge-workflow"
3773
+ },
3774
+ {
3775
+ key: "mark_no_show",
3776
+ label: "Mark No-Show",
3777
+ isAvailableFor: (deal) => deal.stage_key === "interested" && deal.state_key === "discovery_nudging",
3778
+ // Mirrors the auto-timeout precedent in operations/sales/crm/pipeline/timeout-actions.ts:
3779
+ // both manual-click and timeout move the deal to closed_lost. The action_taken activity
3780
+ // event captures operator intent and distinguishes the manual variant from the timed one.
3781
+ workflowId: "mark_no_show-workflow"
3782
+ },
3783
+ {
3784
+ key: "rebook",
3785
+ label: "Rebook",
3786
+ isAvailableFor: (deal) => deal.stage_key === "interested" && deal.state_key === "discovery_booking_cancelled",
3787
+ workflowId: "crm-rebook-workflow"
3846
3788
  }
3789
+ ];
3790
+ function deriveActions(deal, actions = DEFAULT_CRM_ACTIONS) {
3791
+ return actions.filter((a) => a.isAvailableFor(deal)).map(({ key, label, payloadSchema }) => ({ key, label, payloadSchema }));
3847
3792
  }
3848
3793
 
3849
- export { ActivityEventSchema, ExecutionError, RegistryValidationError, ResourceRegistry, StepType, ToolingError, deriveActions };
3794
+ export { ActivityEventSchema, DEFAULT_CRM_ACTIONS, ExecutionError, RegistryValidationError, ResourceRegistry, StepType, ToolingError, deriveActions };