@elevasis/sdk 1.10.0 → 1.12.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 +52 -149
- package/dist/index.d.ts +468 -198
- package/dist/index.js +225 -147
- package/dist/test-utils/index.d.ts +272 -99
- package/dist/test-utils/index.js +4756 -125
- package/dist/types/worker/adapters/llm.d.ts +1 -1
- package/dist/worker/index.js +14 -6
- package/package.json +2 -2
- package/reference/claude-config/rules/agent-start-here.md +14 -14
- package/reference/claude-config/skills/configure/SKILL.md +3 -3
- package/reference/claude-config/skills/setup/SKILL.md +6 -6
- package/reference/claude-config/sync-notes/2026-04-25-auth-role-system-and-settings-roles.md +55 -0
- package/reference/claude-config/sync-notes/2026-04-27-crm-hitl-action-layer-cutover.md +101 -0
- package/reference/cli.mdx +57 -0
- package/reference/deployment/provided-features.mdx +40 -267
- package/reference/examples/organization-model.ts +99 -564
- package/reference/packages/core/src/organization-model/README.md +102 -97
- package/reference/resources/types.mdx +72 -163
- package/reference/scaffold/core/organization-graph.mdx +92 -272
- package/reference/scaffold/core/organization-model.mdx +155 -320
- package/reference/scaffold/index.mdx +3 -0
- package/reference/scaffold/operations/propagation-pipeline.md +4 -1
- package/reference/scaffold/operations/scaffold-maintenance.md +3 -0
- package/reference/scaffold/operations/workflow-recipes.md +13 -10
- package/reference/scaffold/recipes/add-a-feature.md +105 -158
- package/reference/scaffold/recipes/add-a-resource.md +88 -158
- package/reference/scaffold/recipes/customize-organization-model.md +144 -400
- package/reference/scaffold/recipes/extend-a-base-entity.md +11 -8
- package/reference/scaffold/recipes/gate-by-feature-or-admin.md +117 -158
- package/reference/scaffold/recipes/index.md +3 -0
- package/reference/scaffold/reference/contracts.md +107 -435
- package/reference/scaffold/reference/feature-registry.md +11 -8
- package/reference/scaffold/reference/glossary.md +74 -105
- package/reference/scaffold/ui/composition-extensibility.mdx +3 -0
- package/reference/scaffold/ui/customization.md +3 -0
- package/reference/scaffold/ui/feature-flags-and-gating.md +29 -231
- package/reference/scaffold/ui/feature-shell.mdx +53 -219
- package/reference/scaffold/ui/recipes.md +65 -397
- package/reference/claude-config/logs/pre-edit-vibe-gate.log +0 -40
- package/reference/claude-config/logs/scaffold-registry-reminder.log +0 -38
package/dist/index.js
CHANGED
|
@@ -38,126 +38,6 @@ var ToolingError = class extends ExecutionError {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
// ../core/src/platform/registry/domains.ts
|
|
42
|
-
var DOMAINS = {
|
|
43
|
-
// Business domains
|
|
44
|
-
INBOUND_PIPELINE: "inbound-pipeline",
|
|
45
|
-
LEAD_GEN_PIPELINE: "lead-gen-pipeline",
|
|
46
|
-
SUPPORT: "support",
|
|
47
|
-
CLIENT_SUPPORT: "client-support",
|
|
48
|
-
DELIVERY: "delivery",
|
|
49
|
-
OPERATIONS: "operations",
|
|
50
|
-
FINANCE: "finance",
|
|
51
|
-
EXECUTIVE: "executive",
|
|
52
|
-
INSTANTLY: "instantly",
|
|
53
|
-
// Technical domains
|
|
54
|
-
TESTING: "testing",
|
|
55
|
-
INTERNAL: "internal",
|
|
56
|
-
INTEGRATION: "integration",
|
|
57
|
-
UTILITY: "utility",
|
|
58
|
-
DIAGNOSTIC: "diagnostic"
|
|
59
|
-
};
|
|
60
|
-
var INBOUND_PIPELINE_DOMAIN = {
|
|
61
|
-
id: DOMAINS.INBOUND_PIPELINE,
|
|
62
|
-
name: "Inbound Pipeline",
|
|
63
|
-
description: "End-to-end inbound client acquisition from first reply to onboarding",
|
|
64
|
-
color: "blue"
|
|
65
|
-
};
|
|
66
|
-
var LEAD_GEN_PIPELINE_DOMAIN = {
|
|
67
|
-
id: DOMAINS.LEAD_GEN_PIPELINE,
|
|
68
|
-
name: "Lead Gen Pipeline",
|
|
69
|
-
description: "Lead scraping, enrichment, qualification, and personalization",
|
|
70
|
-
color: "cyan"
|
|
71
|
-
};
|
|
72
|
-
var SUPPORT_DOMAIN = {
|
|
73
|
-
id: DOMAINS.SUPPORT,
|
|
74
|
-
name: "Customer Support",
|
|
75
|
-
description: "Ticket triage, knowledge base, escalations",
|
|
76
|
-
color: "green"
|
|
77
|
-
};
|
|
78
|
-
var CLIENT_SUPPORT_DOMAIN = {
|
|
79
|
-
id: DOMAINS.CLIENT_SUPPORT,
|
|
80
|
-
name: "Client Support",
|
|
81
|
-
description: "Client change requests, bug reports, and feature requests",
|
|
82
|
-
color: "teal"
|
|
83
|
-
};
|
|
84
|
-
var DELIVERY_DOMAIN = {
|
|
85
|
-
id: DOMAINS.DELIVERY,
|
|
86
|
-
name: "Client Delivery",
|
|
87
|
-
description: "Project execution and milestone tracking",
|
|
88
|
-
color: "orange"
|
|
89
|
-
};
|
|
90
|
-
var OPERATIONS_DOMAIN = {
|
|
91
|
-
id: DOMAINS.OPERATIONS,
|
|
92
|
-
name: "Operations",
|
|
93
|
-
description: "Internal business operations and administration",
|
|
94
|
-
color: "violet"
|
|
95
|
-
};
|
|
96
|
-
var FINANCE_DOMAIN = {
|
|
97
|
-
id: DOMAINS.FINANCE,
|
|
98
|
-
name: "Finance",
|
|
99
|
-
description: "Billing, invoicing, and financial operations",
|
|
100
|
-
color: "pink"
|
|
101
|
-
};
|
|
102
|
-
var EXECUTIVE_DOMAIN = {
|
|
103
|
-
id: DOMAINS.EXECUTIVE,
|
|
104
|
-
name: "Executive Operations",
|
|
105
|
-
description: "High-level business orchestration and decision-making",
|
|
106
|
-
color: "indigo"
|
|
107
|
-
};
|
|
108
|
-
var TESTING_DOMAIN = {
|
|
109
|
-
id: DOMAINS.TESTING,
|
|
110
|
-
name: "Testing",
|
|
111
|
-
description: "Test resources and development workflows",
|
|
112
|
-
color: "gray"
|
|
113
|
-
};
|
|
114
|
-
var INTERNAL_DOMAIN = {
|
|
115
|
-
id: DOMAINS.INTERNAL,
|
|
116
|
-
name: "Internal",
|
|
117
|
-
description: "Internal platform resources",
|
|
118
|
-
color: "dark"
|
|
119
|
-
};
|
|
120
|
-
var INTEGRATION_DOMAIN = {
|
|
121
|
-
id: DOMAINS.INTEGRATION,
|
|
122
|
-
name: "Integration",
|
|
123
|
-
description: "External service integrations",
|
|
124
|
-
color: "teal"
|
|
125
|
-
};
|
|
126
|
-
var INSTANTLY_DOMAIN = {
|
|
127
|
-
id: DOMAINS.INSTANTLY,
|
|
128
|
-
name: "Instantly Toolkit",
|
|
129
|
-
description: "Instantly campaign creation, analytics, and optimization",
|
|
130
|
-
color: "lime"
|
|
131
|
-
};
|
|
132
|
-
var UTILITY_DOMAIN = {
|
|
133
|
-
id: DOMAINS.UTILITY,
|
|
134
|
-
name: "Utility",
|
|
135
|
-
description: "Utility workflows for maintenance and diagnostics",
|
|
136
|
-
color: "grape"
|
|
137
|
-
};
|
|
138
|
-
var DIAGNOSTIC_DOMAIN = {
|
|
139
|
-
id: DOMAINS.DIAGNOSTIC,
|
|
140
|
-
name: "Diagnostic",
|
|
141
|
-
description: "Diagnostic workflows for testing integrations and services",
|
|
142
|
-
color: "yellow"
|
|
143
|
-
};
|
|
144
|
-
var DOMAIN_MAP = {
|
|
145
|
-
[DOMAINS.INBOUND_PIPELINE]: INBOUND_PIPELINE_DOMAIN,
|
|
146
|
-
[DOMAINS.LEAD_GEN_PIPELINE]: LEAD_GEN_PIPELINE_DOMAIN,
|
|
147
|
-
[DOMAINS.SUPPORT]: SUPPORT_DOMAIN,
|
|
148
|
-
[DOMAINS.CLIENT_SUPPORT]: CLIENT_SUPPORT_DOMAIN,
|
|
149
|
-
[DOMAINS.DELIVERY]: DELIVERY_DOMAIN,
|
|
150
|
-
[DOMAINS.OPERATIONS]: OPERATIONS_DOMAIN,
|
|
151
|
-
[DOMAINS.FINANCE]: FINANCE_DOMAIN,
|
|
152
|
-
[DOMAINS.EXECUTIVE]: EXECUTIVE_DOMAIN,
|
|
153
|
-
[DOMAINS.TESTING]: TESTING_DOMAIN,
|
|
154
|
-
[DOMAINS.INTERNAL]: INTERNAL_DOMAIN,
|
|
155
|
-
[DOMAINS.INSTANTLY]: INSTANTLY_DOMAIN,
|
|
156
|
-
[DOMAINS.INTEGRATION]: INTEGRATION_DOMAIN,
|
|
157
|
-
[DOMAINS.UTILITY]: UTILITY_DOMAIN,
|
|
158
|
-
[DOMAINS.DIAGNOSTIC]: DIAGNOSTIC_DOMAIN
|
|
159
|
-
};
|
|
160
|
-
|
|
161
41
|
// ../core/src/platform/registry/reserved.ts
|
|
162
42
|
var RESERVED_RESOURCE_IDS = /* @__PURE__ */ new Set(["command-center-assistant"]);
|
|
163
43
|
Array.from(RESERVED_RESOURCE_IDS);
|
|
@@ -2952,16 +2832,6 @@ function serializeAllOrganizations(registry) {
|
|
|
2952
2832
|
}
|
|
2953
2833
|
return cache;
|
|
2954
2834
|
}
|
|
2955
|
-
function deriveDomainDefinitions(resources) {
|
|
2956
|
-
const domainIds = /* @__PURE__ */ new Set();
|
|
2957
|
-
resources.workflows?.forEach((w) => w.config.domains?.forEach((d) => domainIds.add(d)));
|
|
2958
|
-
resources.agents?.forEach((a) => a.config.domains?.forEach((d) => domainIds.add(d)));
|
|
2959
|
-
resources.triggers?.forEach((t) => t.domains?.forEach((d) => domainIds.add(d)));
|
|
2960
|
-
resources.integrations?.forEach((i) => i.domains?.forEach((d) => domainIds.add(d)));
|
|
2961
|
-
resources.externalResources?.forEach((e) => e.domains?.forEach((d) => domainIds.add(d)));
|
|
2962
|
-
resources.humanCheckpoints?.forEach((h) => h.domains?.forEach((d) => domainIds.add(d)));
|
|
2963
|
-
return Array.from(domainIds).map((id) => DOMAIN_MAP[id]);
|
|
2964
|
-
}
|
|
2965
2835
|
function serializeOrganization(resources) {
|
|
2966
2836
|
const workflowDefinitions = /* @__PURE__ */ new Map();
|
|
2967
2837
|
const workflowResources = [];
|
|
@@ -2976,7 +2846,9 @@ function serializeOrganization(resources) {
|
|
|
2976
2846
|
description: workflow.config.description,
|
|
2977
2847
|
version: workflow.config.version,
|
|
2978
2848
|
type: "workflow",
|
|
2979
|
-
status: workflow.config.status
|
|
2849
|
+
status: workflow.config.status,
|
|
2850
|
+
links: workflow.config.links,
|
|
2851
|
+
category: workflow.config.category
|
|
2980
2852
|
});
|
|
2981
2853
|
commandViewWorkflows.push({
|
|
2982
2854
|
resourceId,
|
|
@@ -2985,7 +2857,8 @@ function serializeOrganization(resources) {
|
|
|
2985
2857
|
version: workflow.config.version,
|
|
2986
2858
|
type: "workflow",
|
|
2987
2859
|
status: workflow.config.status,
|
|
2988
|
-
|
|
2860
|
+
links: workflow.config.links,
|
|
2861
|
+
category: workflow.config.category,
|
|
2989
2862
|
stepCount: Object.keys(workflow.steps).length,
|
|
2990
2863
|
entryPoint: workflow.entryPoint
|
|
2991
2864
|
});
|
|
@@ -3003,7 +2876,9 @@ function serializeOrganization(resources) {
|
|
|
3003
2876
|
description: agent.config.description,
|
|
3004
2877
|
version: agent.config.version,
|
|
3005
2878
|
type: "agent",
|
|
3006
|
-
status: agent.config.status
|
|
2879
|
+
status: agent.config.status,
|
|
2880
|
+
links: agent.config.links,
|
|
2881
|
+
category: agent.config.category
|
|
3007
2882
|
});
|
|
3008
2883
|
commandViewAgents.push({
|
|
3009
2884
|
resourceId,
|
|
@@ -3012,7 +2887,8 @@ function serializeOrganization(resources) {
|
|
|
3012
2887
|
version: agent.config.version,
|
|
3013
2888
|
type: "agent",
|
|
3014
2889
|
status: agent.config.status,
|
|
3015
|
-
|
|
2890
|
+
links: agent.config.links,
|
|
2891
|
+
category: agent.config.category,
|
|
3016
2892
|
modelProvider: agent.modelConfig.provider,
|
|
3017
2893
|
modelId: agent.modelConfig.model,
|
|
3018
2894
|
toolCount: agent.tools.length,
|
|
@@ -3026,7 +2902,6 @@ function serializeOrganization(resources) {
|
|
|
3026
2902
|
const integrations = resources.integrations ?? [];
|
|
3027
2903
|
const externalResources = resources.externalResources ?? [];
|
|
3028
2904
|
const humanCheckpoints = resources.humanCheckpoints ?? [];
|
|
3029
|
-
const domainDefinitions = deriveDomainDefinitions(resources);
|
|
3030
2905
|
return {
|
|
3031
2906
|
version: resources.version,
|
|
3032
2907
|
resources: {
|
|
@@ -3045,8 +2920,7 @@ function serializeOrganization(resources) {
|
|
|
3045
2920
|
integrations,
|
|
3046
2921
|
externalResources,
|
|
3047
2922
|
humanCheckpoints,
|
|
3048
|
-
edges
|
|
3049
|
-
domainDefinitions
|
|
2923
|
+
edges
|
|
3050
2924
|
},
|
|
3051
2925
|
triggers,
|
|
3052
2926
|
integrations,
|
|
@@ -3178,6 +3052,12 @@ var ResourceRegistry = class {
|
|
|
3178
3052
|
* Static and remote resources coexist in the same org.
|
|
3179
3053
|
*/
|
|
3180
3054
|
remoteResources = /* @__PURE__ */ new Map();
|
|
3055
|
+
/**
|
|
3056
|
+
* System configs for first-class platform resources.
|
|
3057
|
+
* Key: "orgName/resourceId", Value: SystemConfig.
|
|
3058
|
+
* Registered at startup alongside registerStaticResources().
|
|
3059
|
+
*/
|
|
3060
|
+
systemConfigs = /* @__PURE__ */ new Map();
|
|
3181
3061
|
/**
|
|
3182
3062
|
* Validates registry on construction
|
|
3183
3063
|
* - Checks for duplicate resourceIds within organizations
|
|
@@ -3225,7 +3105,9 @@ var ResourceRegistry = class {
|
|
|
3225
3105
|
if (!existingOrg) return void 0;
|
|
3226
3106
|
const remoteIds = this.getRemoteResourceIds(orgName);
|
|
3227
3107
|
if (remoteIds.size === 0) return existingOrg;
|
|
3228
|
-
const relationships = existingOrg.relationships ? Object.fromEntries(
|
|
3108
|
+
const relationships = existingOrg.relationships ? Object.fromEntries(
|
|
3109
|
+
Object.entries(existingOrg.relationships).filter(([resourceId]) => !remoteIds.has(resourceId))
|
|
3110
|
+
) : void 0;
|
|
3229
3111
|
return {
|
|
3230
3112
|
...existingOrg,
|
|
3231
3113
|
version: existingOrg.version ?? "0.0.0",
|
|
@@ -3304,7 +3186,8 @@ var ResourceRegistry = class {
|
|
|
3304
3186
|
version: def.config.version,
|
|
3305
3187
|
type: def.config.type,
|
|
3306
3188
|
status: def.config.status,
|
|
3307
|
-
|
|
3189
|
+
links: def.config.links,
|
|
3190
|
+
category: def.config.category,
|
|
3308
3191
|
origin: this.remoteResources.has(`${organizationName}/${def.config.resourceId}`) ? "remote" : "local"
|
|
3309
3192
|
})).filter((resource) => !environment || resource.status === environment);
|
|
3310
3193
|
const agents = (orgResources.agents || []).map((def) => ({
|
|
@@ -3314,7 +3197,8 @@ var ResourceRegistry = class {
|
|
|
3314
3197
|
version: def.config.version,
|
|
3315
3198
|
type: def.config.type,
|
|
3316
3199
|
status: def.config.status,
|
|
3317
|
-
|
|
3200
|
+
links: def.config.links,
|
|
3201
|
+
category: def.config.category,
|
|
3318
3202
|
sessionCapable: def.config.sessionCapable ?? false,
|
|
3319
3203
|
origin: this.remoteResources.has(`${organizationName}/${def.config.resourceId}`) ? "remote" : "local"
|
|
3320
3204
|
})).filter((resource) => !environment || resource.status === environment);
|
|
@@ -3533,18 +3417,33 @@ var ResourceRegistry = class {
|
|
|
3533
3417
|
}
|
|
3534
3418
|
}
|
|
3535
3419
|
/**
|
|
3536
|
-
* Get remote configuration for a specific resource
|
|
3420
|
+
* Get remote configuration for a specific resource.
|
|
3537
3421
|
*
|
|
3538
|
-
* Returns
|
|
3539
|
-
* or null
|
|
3540
|
-
* Used by the execution coordinator to
|
|
3422
|
+
* Returns RemoteOrgConfig for externally-deployed resources, SystemConfig for
|
|
3423
|
+
* first-class platform resources, or null for static in-process resources.
|
|
3424
|
+
* Used by the execution coordinator to determine the execution path.
|
|
3541
3425
|
*
|
|
3542
3426
|
* @param orgName - Organization name
|
|
3543
3427
|
* @param resourceId - Resource ID
|
|
3544
|
-
* @returns Remote config or null
|
|
3428
|
+
* @returns Remote or System config, or null
|
|
3545
3429
|
*/
|
|
3546
3430
|
getRemoteConfig(orgName, resourceId) {
|
|
3547
|
-
|
|
3431
|
+
const key = `${orgName}/${resourceId}`;
|
|
3432
|
+
return this.remoteResources.get(key) ?? this.systemConfigs.get(key) ?? null;
|
|
3433
|
+
}
|
|
3434
|
+
/**
|
|
3435
|
+
* Register a System config for a first-class platform resource.
|
|
3436
|
+
*
|
|
3437
|
+
* Called at startup alongside registerStaticResources() so that
|
|
3438
|
+
* getRemoteConfig('system', resourceId) returns truthy and the execution
|
|
3439
|
+
* coordinator routes the resource through the worker-thread path.
|
|
3440
|
+
*
|
|
3441
|
+
* @param orgName - Organization name (typically 'system')
|
|
3442
|
+
* @param resourceId - Resource ID
|
|
3443
|
+
* @param config - SystemConfig with kind:'static' and moduleId
|
|
3444
|
+
*/
|
|
3445
|
+
registerSystemConfig(orgName, resourceId, config) {
|
|
3446
|
+
this.systemConfigs.set(`${orgName}/${resourceId}`, config);
|
|
3548
3447
|
}
|
|
3549
3448
|
/**
|
|
3550
3449
|
* Check if an organization has any remote (externally deployed) resources
|
|
@@ -3767,5 +3666,184 @@ var ResourceRegistry = class {
|
|
|
3767
3666
|
return results;
|
|
3768
3667
|
}
|
|
3769
3668
|
};
|
|
3669
|
+
var StageChangeEventSchema = z.object({
|
|
3670
|
+
type: z.literal("stage_change"),
|
|
3671
|
+
timestamp: z.string().datetime(),
|
|
3672
|
+
stageBefore: z.string(),
|
|
3673
|
+
stageAfter: z.string(),
|
|
3674
|
+
reason: z.string().optional()
|
|
3675
|
+
});
|
|
3676
|
+
var StateChangeEventSchema = z.object({
|
|
3677
|
+
type: z.literal("state_change"),
|
|
3678
|
+
timestamp: z.string().datetime(),
|
|
3679
|
+
stateBefore: z.string().nullable(),
|
|
3680
|
+
stateAfter: z.string().nullable(),
|
|
3681
|
+
reason: z.string().optional()
|
|
3682
|
+
});
|
|
3683
|
+
var ActionTakenEventSchema = z.object({
|
|
3684
|
+
type: z.literal("action_taken"),
|
|
3685
|
+
timestamp: z.string().datetime(),
|
|
3686
|
+
actionKey: z.string(),
|
|
3687
|
+
payload: z.record(z.string(), z.unknown()).optional()
|
|
3688
|
+
});
|
|
3689
|
+
var ApprovalCreatedEventSchema = z.object({
|
|
3690
|
+
type: z.literal("approval_created"),
|
|
3691
|
+
timestamp: z.string().datetime(),
|
|
3692
|
+
commandId: z.string(),
|
|
3693
|
+
dealStageBefore: z.string().optional(),
|
|
3694
|
+
dealStageAfter: z.string().optional()
|
|
3695
|
+
});
|
|
3696
|
+
var ApprovalResolvedEventSchema = z.object({
|
|
3697
|
+
type: z.literal("approval_resolved"),
|
|
3698
|
+
timestamp: z.string().datetime(),
|
|
3699
|
+
commandId: z.string(),
|
|
3700
|
+
resolution: z.enum(["superseded"]),
|
|
3701
|
+
originResourceType: z.string().optional()
|
|
3702
|
+
});
|
|
3703
|
+
var ApprovalStaleEventSchema = z.object({
|
|
3704
|
+
type: z.literal("approval_stale"),
|
|
3705
|
+
timestamp: z.string().datetime(),
|
|
3706
|
+
commandId: z.string(),
|
|
3707
|
+
dealStageBefore: z.string().optional(),
|
|
3708
|
+
dealStageAfter: z.string().optional()
|
|
3709
|
+
});
|
|
3710
|
+
var TaskCreatedEventSchema = z.object({
|
|
3711
|
+
type: z.literal("task_created"),
|
|
3712
|
+
timestamp: z.string().datetime(),
|
|
3713
|
+
taskId: z.string()
|
|
3714
|
+
});
|
|
3715
|
+
var DealCreatedEventSchema = z.object({
|
|
3716
|
+
type: z.literal("deal_created"),
|
|
3717
|
+
timestamp: z.string().datetime()
|
|
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
|
+
var ActivityEventSchema = z.discriminatedUnion("type", [
|
|
3764
|
+
StageChangeEventSchema,
|
|
3765
|
+
StateChangeEventSchema,
|
|
3766
|
+
ActionTakenEventSchema,
|
|
3767
|
+
ApprovalCreatedEventSchema,
|
|
3768
|
+
ApprovalResolvedEventSchema,
|
|
3769
|
+
ApprovalStaleEventSchema,
|
|
3770
|
+
TaskCreatedEventSchema,
|
|
3771
|
+
DealCreatedEventSchema,
|
|
3772
|
+
ReplyReceivedEventSchema,
|
|
3773
|
+
ReplySentToLeadEventSchema,
|
|
3774
|
+
BookingNudgeSentEventSchema,
|
|
3775
|
+
ReminderSentEventSchema,
|
|
3776
|
+
BookingCancelledEventSchema,
|
|
3777
|
+
DiscoverySubmittedEventSchema,
|
|
3778
|
+
MovedToNurturingEventSchema,
|
|
3779
|
+
NoShowEventSchema,
|
|
3780
|
+
FollowupEmailSentEventSchema
|
|
3781
|
+
]);
|
|
3782
|
+
|
|
3783
|
+
// ../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 [];
|
|
3846
|
+
}
|
|
3847
|
+
}
|
|
3770
3848
|
|
|
3771
|
-
export { ExecutionError, RegistryValidationError, ResourceRegistry, StepType, ToolingError };
|
|
3849
|
+
export { ActivityEventSchema, ExecutionError, RegistryValidationError, ResourceRegistry, StepType, ToolingError, deriveActions };
|