@elevasis/sdk 1.20.2 → 1.22.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 +4220 -1583
- package/dist/index.d.ts +1035 -481
- package/dist/index.js +7381 -4187
- package/dist/node/index.d.ts +1 -3
- package/dist/node/index.js +40 -49
- package/dist/test-utils/index.d.ts +699 -123
- package/dist/test-utils/index.js +3826 -630
- package/dist/worker/index.js +3616 -442
- package/package.json +3 -3
- package/reference/_navigation.md +9 -7
- package/reference/_reference-manifest.json +1 -1
- package/reference/claude-config/hooks/post-edit-validate.mjs +98 -98
- package/reference/claude-config/hooks/scaffold-registry-reminder.mjs +188 -188
- package/reference/claude-config/hooks/tool-failure-recovery.mjs +73 -73
- package/reference/claude-config/registries/graph-skills.json +4 -4
- package/reference/claude-config/registries/knowledge-flags.json +0 -2
- package/reference/claude-config/rules/active-change-index.md +80 -80
- package/reference/claude-config/rules/agent-start-here.md +277 -273
- package/reference/claude-config/rules/deployment.md +57 -57
- package/reference/claude-config/rules/error-handling.md +56 -56
- package/reference/claude-config/rules/execution.md +40 -40
- package/reference/claude-config/rules/frontend.md +4 -4
- package/reference/claude-config/rules/observability.md +31 -31
- package/reference/claude-config/rules/operations.md +29 -17
- package/reference/claude-config/rules/organization-model.md +108 -40
- package/reference/claude-config/rules/organization-os.md +115 -113
- package/reference/claude-config/rules/package-taxonomy.md +33 -33
- package/reference/claude-config/rules/platform.md +42 -42
- package/reference/claude-config/rules/shared-types.md +49 -46
- package/reference/claude-config/rules/task-tracking.md +47 -47
- package/reference/claude-config/rules/ui.md +200 -200
- package/reference/claude-config/rules/vibe.md +235 -231
- package/reference/claude-config/scripts/statusline-command.js +18 -18
- package/reference/claude-config/settings.json +34 -34
- package/reference/claude-config/skills/deploy/{SKILL.md → skill.md} +156 -156
- package/reference/claude-config/skills/dsp/SKILL.md +66 -66
- package/reference/claude-config/skills/elevasis/SKILL.md +235 -235
- package/reference/claude-config/skills/explore/SKILL.md +6 -6
- package/reference/claude-config/skills/git-sync/SKILL.md +126 -126
- package/reference/claude-config/skills/knowledge/SKILL.md +330 -271
- package/reference/claude-config/skills/knowledge/operations/codify-level-a.md +100 -100
- package/reference/claude-config/skills/knowledge/operations/codify-level-b.md +159 -158
- package/reference/claude-config/skills/knowledge/operations/customers.md +109 -109
- package/reference/claude-config/skills/knowledge/operations/features.md +76 -113
- package/reference/claude-config/skills/knowledge/operations/goals.md +118 -118
- package/reference/claude-config/skills/knowledge/operations/identity.md +93 -93
- package/reference/claude-config/skills/knowledge/operations/labels.md +94 -89
- package/reference/claude-config/skills/knowledge/operations/offerings.md +109 -109
- package/reference/claude-config/skills/knowledge/operations/roles.md +99 -99
- package/reference/claude-config/skills/knowledge/operations/techStack.md +30 -30
- package/reference/claude-config/skills/project/SKILL.md +1088 -1088
- package/reference/claude-config/skills/run-ui/SKILL.md +73 -73
- package/reference/claude-config/skills/save/SKILL.md +3 -3
- package/reference/claude-config/skills/setup/SKILL.md +275 -275
- package/reference/claude-config/skills/status/SKILL.md +59 -59
- package/reference/claude-config/skills/submit-request/SKILL.md +180 -180
- package/reference/claude-config/skills/sync/SKILL.md +47 -47
- package/reference/claude-config/skills/tutorial/SKILL.md +259 -259
- package/reference/claude-config/skills/tutorial/progress-template.md +74 -74
- package/reference/claude-config/skills/tutorial/technical.md +1303 -1306
- package/reference/claude-config/skills/tutorial/vibe-coder.md +890 -890
- package/reference/claude-config/sync-notes/2026-04-22-git-sync-and-sync-notes.md +27 -27
- package/reference/claude-config/sync-notes/2026-04-22-lead-gen-deliverability-removal.md +30 -30
- package/reference/claude-config/sync-notes/2026-04-24-test-utils-and-template-tests.md +73 -73
- package/reference/claude-config/sync-notes/2026-04-24-ui-consolidation-and-sdk-cli-train.md +86 -86
- package/reference/claude-config/sync-notes/2026-04-25-auth-role-system-and-settings-roles.md +55 -55
- package/reference/claude-config/sync-notes/2026-04-27-crm-hitl-action-layer-cutover.md +97 -97
- package/reference/claude-config/sync-notes/2026-04-27-lead-gen-substrate-train.md +112 -112
- package/reference/claude-config/sync-notes/2026-04-29-crm-state-and-lead-gen-processing-status.md +93 -93
- package/reference/claude-config/sync-notes/2026-05-02-crm-ownership-next-action.md +58 -58
- package/reference/claude-config/sync-notes/2026-05-02-template-hardcode-workos-config.md +56 -56
- package/reference/claude-config/sync-notes/2026-05-04-elevasis-workspace.md +71 -71
- package/reference/claude-config/sync-notes/2026-05-04-knowledge-bundle.md +83 -83
- package/reference/claude-config/sync-notes/2026-05-04-template-skills-run-ui-and-tutorial.md +59 -59
- package/reference/claude-config/sync-notes/2026-05-05-list-builder.md +42 -42
- package/reference/claude-config/sync-notes/2026-05-06-crm-spine.md +60 -60
- package/reference/claude-config/sync-notes/2026-05-06-sdk-changes-release-train.md +37 -37
- package/reference/claude-config/sync-notes/2026-05-07-sdk-changes-release-train.md +34 -34
- package/reference/claude-config/sync-notes/2026-05-08-resource-governance-scaffold-guidance.md +38 -38
- package/reference/claude-config/sync-notes/2026-05-09-clients-domain.md +32 -32
- package/reference/claude-config/sync-notes/2026-05-09-command-system.md +33 -33
- package/reference/claude-config/sync-notes/2026-05-09-resource-governance-and-misc.md +69 -69
- package/reference/claude-config/sync-notes/2026-05-12-sdk-ready-release-train.md +30 -0
- package/reference/claude-config/sync-notes/2026-05-14-organization-model-ontology-refactor.md +42 -0
- package/reference/claude-config/sync-notes/README.md +43 -43
- package/reference/cli.mdx +808 -668
- package/reference/concepts.mdx +146 -146
- package/reference/deployment/api.mdx +297 -297
- package/reference/deployment/command-center.mdx +209 -209
- package/reference/deployment/index.mdx +195 -195
- package/reference/deployment/provided-features.mdx +107 -93
- package/reference/deployment/ui-execution.mdx +250 -250
- package/reference/examples/organization-model.ts +147 -84
- package/reference/framework/agent.mdx +156 -156
- package/reference/framework/index.mdx +195 -195
- package/reference/framework/interaction-guidance.mdx +182 -182
- package/reference/framework/memory.mdx +326 -326
- package/reference/framework/project-structure.mdx +282 -282
- package/reference/framework/tutorial-system.mdx +135 -135
- package/reference/getting-started.mdx +142 -142
- package/reference/index.mdx +106 -106
- package/reference/packages/core/src/README.md +14 -14
- package/reference/packages/core/src/business/README.md +2 -2
- package/reference/packages/core/src/knowledge/README.md +33 -32
- package/reference/packages/core/src/organization-model/README.md +149 -109
- package/reference/packages/core/src/test-utils/README.md +37 -37
- package/reference/packages/ui/src/api/README.md +18 -18
- package/reference/packages/ui/src/app/README.md +24 -24
- package/reference/packages/ui/src/auth/README.md +18 -18
- package/reference/packages/ui/src/components/README.md +24 -24
- package/reference/packages/ui/src/execution/README.md +16 -16
- package/reference/packages/ui/src/features/README.md +28 -28
- package/reference/packages/ui/src/graph/README.md +16 -16
- package/reference/packages/ui/src/hooks/README.md +23 -23
- package/reference/packages/ui/src/initialization/README.md +19 -19
- package/reference/packages/ui/src/knowledge/README.md +31 -31
- package/reference/packages/ui/src/organization/README.md +18 -18
- package/reference/packages/ui/src/profile/README.md +19 -19
- package/reference/packages/ui/src/provider/README.md +32 -32
- package/reference/packages/ui/src/router/README.md +18 -18
- package/reference/packages/ui/src/sse/README.md +13 -13
- package/reference/packages/ui/src/test-utils/README.md +7 -7
- package/reference/packages/ui/src/theme/README.md +23 -23
- package/reference/packages/ui/src/theme/presets/README.md +19 -19
- package/reference/packages/ui/src/types/README.md +16 -16
- package/reference/packages/ui/src/utils/README.md +18 -18
- package/reference/packages/ui/src/zustand/README.md +18 -18
- package/reference/platform-tools/adapters-integration.mdx +301 -301
- package/reference/platform-tools/adapters-platform.mdx +553 -553
- package/reference/platform-tools/index.mdx +217 -217
- package/reference/platform-tools/type-safety.mdx +82 -82
- package/reference/resources/index.mdx +349 -349
- package/reference/resources/patterns.mdx +449 -449
- package/reference/resources/types.mdx +116 -116
- package/reference/roadmap.mdx +165 -165
- package/reference/runtime.mdx +173 -173
- package/reference/scaffold/core/organization-graph.mdx +110 -89
- package/reference/scaffold/core/organization-model.mdx +226 -171
- package/reference/scaffold/index.mdx +67 -67
- package/reference/scaffold/operations/propagation-pipeline.md +77 -77
- package/reference/scaffold/operations/scaffold-maintenance.md +10 -10
- package/reference/scaffold/operations/workflow-recipes.md +138 -138
- package/reference/scaffold/recipes/add-a-feature.md +310 -88
- package/reference/scaffold/recipes/add-a-resource.md +137 -117
- package/reference/scaffold/recipes/customize-crm-actions.md +439 -439
- package/reference/scaffold/recipes/customize-knowledge-browser.md +384 -0
- package/reference/scaffold/recipes/customize-organization-model.md +281 -118
- package/reference/scaffold/recipes/extend-a-base-entity.md +8 -8
- package/reference/scaffold/recipes/extend-crm.md +40 -39
- package/reference/scaffold/recipes/extend-lead-gen.md +400 -401
- package/reference/scaffold/recipes/gate-by-feature-or-admin.md +118 -114
- package/reference/scaffold/recipes/index.md +47 -46
- package/reference/scaffold/recipes/query-the-knowledge-graph.md +227 -0
- package/reference/scaffold/reference/contracts.md +2389 -2121
- package/reference/scaffold/reference/feature-registry.md +9 -20
- package/reference/scaffold/reference/glossary.md +76 -76
- package/reference/scaffold/ui/composition-extensibility.mdx +233 -233
- package/reference/scaffold/ui/customization.md +243 -243
- package/reference/scaffold/ui/feature-flags-and-gating.md +46 -46
- package/reference/scaffold/ui/feature-shell.mdx +72 -72
- package/reference/scaffold/ui/recipes.md +221 -213
- package/reference/spine/spine-primer.md +96 -96
- package/reference/templates/index.mdx +47 -47
- package/reference/troubleshooting.mdx +223 -223
package/dist/test-utils/index.js
CHANGED
|
@@ -6512,73 +6512,78 @@ Fix the errors and generate a valid output.
|
|
|
6512
6512
|
}
|
|
6513
6513
|
};
|
|
6514
6514
|
var ORGANIZATION_MODEL_ICON_TOKENS = [
|
|
6515
|
-
|
|
6516
|
-
"
|
|
6517
|
-
"
|
|
6518
|
-
"
|
|
6519
|
-
"
|
|
6520
|
-
"
|
|
6521
|
-
"
|
|
6522
|
-
"
|
|
6523
|
-
"
|
|
6524
|
-
"
|
|
6525
|
-
"
|
|
6526
|
-
"
|
|
6527
|
-
"
|
|
6528
|
-
"
|
|
6529
|
-
"
|
|
6530
|
-
"
|
|
6531
|
-
"
|
|
6532
|
-
|
|
6533
|
-
"
|
|
6534
|
-
"
|
|
6535
|
-
"
|
|
6536
|
-
|
|
6537
|
-
"
|
|
6538
|
-
"
|
|
6539
|
-
"
|
|
6540
|
-
"
|
|
6541
|
-
"
|
|
6542
|
-
"
|
|
6543
|
-
|
|
6544
|
-
"
|
|
6545
|
-
"
|
|
6546
|
-
"
|
|
6547
|
-
|
|
6548
|
-
"
|
|
6549
|
-
"
|
|
6550
|
-
"
|
|
6551
|
-
"
|
|
6552
|
-
"
|
|
6553
|
-
"
|
|
6554
|
-
|
|
6555
|
-
"
|
|
6556
|
-
"
|
|
6557
|
-
"
|
|
6558
|
-
"
|
|
6559
|
-
"
|
|
6560
|
-
"
|
|
6561
|
-
"
|
|
6562
|
-
"
|
|
6563
|
-
"
|
|
6564
|
-
"
|
|
6565
|
-
"
|
|
6566
|
-
|
|
6567
|
-
"
|
|
6568
|
-
"
|
|
6569
|
-
"
|
|
6570
|
-
"
|
|
6571
|
-
"
|
|
6572
|
-
|
|
6573
|
-
"
|
|
6574
|
-
"
|
|
6575
|
-
"
|
|
6576
|
-
"
|
|
6577
|
-
"
|
|
6578
|
-
"
|
|
6579
|
-
"
|
|
6515
|
+
// Navigation / app areas
|
|
6516
|
+
"dashboard",
|
|
6517
|
+
"calendar",
|
|
6518
|
+
"sales",
|
|
6519
|
+
"crm",
|
|
6520
|
+
"lead-gen",
|
|
6521
|
+
"projects",
|
|
6522
|
+
"operations",
|
|
6523
|
+
"monitoring",
|
|
6524
|
+
"knowledge",
|
|
6525
|
+
"settings",
|
|
6526
|
+
"admin",
|
|
6527
|
+
"archive",
|
|
6528
|
+
"business",
|
|
6529
|
+
"finance",
|
|
6530
|
+
"platform",
|
|
6531
|
+
"seo",
|
|
6532
|
+
// Knowledge kinds
|
|
6533
|
+
"playbook",
|
|
6534
|
+
"strategy",
|
|
6535
|
+
"reference",
|
|
6536
|
+
// Resource kinds
|
|
6537
|
+
"agent",
|
|
6538
|
+
"workflow",
|
|
6539
|
+
"integration",
|
|
6540
|
+
"database",
|
|
6541
|
+
"user",
|
|
6542
|
+
"team",
|
|
6543
|
+
// Integration specifics
|
|
6544
|
+
"gmail",
|
|
6545
|
+
"google-sheets",
|
|
6546
|
+
"attio",
|
|
6547
|
+
// Surface / UI views
|
|
6548
|
+
"overview",
|
|
6549
|
+
"command-view",
|
|
6550
|
+
"command-queue",
|
|
6551
|
+
"pipeline",
|
|
6552
|
+
"lists",
|
|
6553
|
+
"resources",
|
|
6554
|
+
// Actions
|
|
6555
|
+
"approve",
|
|
6556
|
+
"reject",
|
|
6557
|
+
"retry",
|
|
6558
|
+
"edit",
|
|
6559
|
+
"view",
|
|
6560
|
+
"launch",
|
|
6561
|
+
"message",
|
|
6562
|
+
"escalate",
|
|
6563
|
+
"promote",
|
|
6564
|
+
"submit",
|
|
6565
|
+
"email",
|
|
6566
|
+
// Status
|
|
6567
|
+
"success",
|
|
6568
|
+
"error",
|
|
6569
|
+
"warning",
|
|
6570
|
+
"info",
|
|
6571
|
+
"pending",
|
|
6572
|
+
// OM / UI group icons
|
|
6573
|
+
"bolt",
|
|
6574
|
+
"building",
|
|
6575
|
+
"briefcase",
|
|
6576
|
+
"apps",
|
|
6577
|
+
"graph",
|
|
6578
|
+
"shield",
|
|
6579
|
+
"users",
|
|
6580
|
+
"chart-bar",
|
|
6581
|
+
"search"
|
|
6580
6582
|
];
|
|
6581
|
-
var CustomIconTokenSchema = z.string().trim().max(80).regex(
|
|
6583
|
+
var CustomIconTokenSchema = z.string().trim().max(80).regex(
|
|
6584
|
+
/^custom\.[a-z0-9]+(?:[-._][a-z0-9]+)*$/,
|
|
6585
|
+
'Custom icon tokens must start with "custom." followed by lowercase alphanumeric segments'
|
|
6586
|
+
);
|
|
6582
6587
|
var OrganizationModelBuiltinIconTokenSchema = z.enum(ORGANIZATION_MODEL_ICON_TOKENS);
|
|
6583
6588
|
var OrganizationModelIconTokenSchema = z.union([
|
|
6584
6589
|
OrganizationModelBuiltinIconTokenSchema,
|
|
@@ -6591,7 +6596,7 @@ var LabelSchema = z.string().trim().min(1).max(120);
|
|
|
6591
6596
|
var DescriptionSchema = z.string().trim().min(1).max(2e3);
|
|
6592
6597
|
var ColorTokenSchema = z.string().trim().min(1).max(50);
|
|
6593
6598
|
var IconNameSchema = OrganizationModelIconTokenSchema;
|
|
6594
|
-
z.string().trim().startsWith("/").max(300);
|
|
6599
|
+
var PathSchema = z.string().trim().startsWith("/").max(300);
|
|
6595
6600
|
var ReferenceIdsSchema = z.array(ModelIdSchema).default([]);
|
|
6596
6601
|
var DisplayMetadataSchema = z.object({
|
|
6597
6602
|
label: LabelSchema,
|
|
@@ -6622,380 +6627,556 @@ DisplayMetadataSchema.extend({
|
|
|
6622
6627
|
id: ModelIdSchema,
|
|
6623
6628
|
resourceId: z.string().trim().min(1).max(255),
|
|
6624
6629
|
resourceType: z.enum(["workflow", "agent", "trigger", "integration", "external", "human_checkpoint"]),
|
|
6625
|
-
|
|
6630
|
+
systemIds: ReferenceIdsSchema,
|
|
6626
6631
|
entityIds: ReferenceIdsSchema,
|
|
6627
6632
|
surfaceIds: ReferenceIdsSchema,
|
|
6628
|
-
|
|
6633
|
+
actionIds: ReferenceIdsSchema,
|
|
6629
6634
|
/** Optional tech-stack metadata for external-SaaS integrations. */
|
|
6630
6635
|
techStack: TechStackEntrySchema.optional()
|
|
6631
6636
|
});
|
|
6632
6637
|
|
|
6633
|
-
// ../core/src/organization-model/domains/
|
|
6634
|
-
var
|
|
6635
|
-
var
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
6639
|
-
|
|
6640
|
-
|
|
6638
|
+
// ../core/src/organization-model/domains/entities.ts
|
|
6639
|
+
var EntityIdSchema = ModelIdSchema;
|
|
6640
|
+
var EntityLinkKindSchema = z.enum(["belongs-to", "has-many", "has-one", "many-to-many"]).meta({ label: "Link kind" });
|
|
6641
|
+
var EntityLinkSchema = z.object({
|
|
6642
|
+
toEntity: EntityIdSchema.meta({ ref: "entity" }),
|
|
6643
|
+
kind: EntityLinkKindSchema,
|
|
6644
|
+
via: z.string().trim().min(1).max(255).optional(),
|
|
6645
|
+
label: LabelSchema.optional()
|
|
6641
6646
|
});
|
|
6642
|
-
var
|
|
6643
|
-
id:
|
|
6644
|
-
|
|
6647
|
+
var EntitySchema = z.object({
|
|
6648
|
+
id: EntityIdSchema,
|
|
6649
|
+
/** Domain-map iteration order. Convention: multiples of 10 (10, 20, 30, ...) to allow easy insertion. */
|
|
6650
|
+
order: z.number(),
|
|
6651
|
+
label: LabelSchema,
|
|
6645
6652
|
description: DescriptionSchema.optional(),
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
defaultPipelineId: ModelIdSchema,
|
|
6652
|
-
pipelines: z.array(SalesPipelineSchema).min(1)
|
|
6653
|
+
ownedBySystemId: ModelIdSchema.meta({ ref: "system" }),
|
|
6654
|
+
table: z.string().trim().min(1).max(255).optional(),
|
|
6655
|
+
rowSchema: ModelIdSchema.optional(),
|
|
6656
|
+
stateCatalogId: ModelIdSchema.optional(),
|
|
6657
|
+
links: z.array(EntityLinkSchema).optional()
|
|
6653
6658
|
});
|
|
6654
|
-
var
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
stateKey: "discovery_booking_cancelled",
|
|
6668
|
-
label: "Discovery Booking Cancelled"
|
|
6669
|
-
};
|
|
6670
|
-
var CRM_REPLY_SENT_STATE = {
|
|
6671
|
-
stateKey: "reply_sent",
|
|
6672
|
-
label: "Reply Sent"
|
|
6673
|
-
};
|
|
6674
|
-
var CRM_FOLLOWUP_1_SENT_STATE = {
|
|
6675
|
-
stateKey: "followup_1_sent",
|
|
6676
|
-
label: "Follow-up 1 Sent"
|
|
6677
|
-
};
|
|
6678
|
-
var CRM_FOLLOWUP_2_SENT_STATE = {
|
|
6679
|
-
stateKey: "followup_2_sent",
|
|
6680
|
-
label: "Follow-up 2 Sent"
|
|
6681
|
-
};
|
|
6682
|
-
var CRM_FOLLOWUP_3_SENT_STATE = {
|
|
6683
|
-
stateKey: "followup_3_sent",
|
|
6684
|
-
label: "Follow-up 3 Sent"
|
|
6685
|
-
};
|
|
6686
|
-
var CRM_PIPELINE_DEFINITION = {
|
|
6687
|
-
pipelineKey: "crm",
|
|
6688
|
-
stages: [
|
|
6689
|
-
{
|
|
6690
|
-
stageKey: "interested",
|
|
6691
|
-
label: "Interested",
|
|
6692
|
-
color: "blue",
|
|
6693
|
-
states: [
|
|
6694
|
-
CRM_DISCOVERY_REPLIED_STATE,
|
|
6695
|
-
CRM_DISCOVERY_LINK_SENT_STATE,
|
|
6696
|
-
CRM_DISCOVERY_NUDGING_STATE,
|
|
6697
|
-
CRM_DISCOVERY_BOOKING_CANCELLED_STATE,
|
|
6698
|
-
CRM_REPLY_SENT_STATE,
|
|
6699
|
-
CRM_FOLLOWUP_1_SENT_STATE,
|
|
6700
|
-
CRM_FOLLOWUP_2_SENT_STATE,
|
|
6701
|
-
CRM_FOLLOWUP_3_SENT_STATE
|
|
6702
|
-
]
|
|
6703
|
-
},
|
|
6704
|
-
{ stageKey: "proposal", label: "Proposal", color: "yellow", states: [] },
|
|
6705
|
-
{ stageKey: "closing", label: "Closing", color: "orange", states: [] },
|
|
6706
|
-
{ stageKey: "closed_won", label: "Closed Won", color: "green", states: [] },
|
|
6707
|
-
{ stageKey: "closed_lost", label: "Closed Lost", color: "red", states: [] },
|
|
6708
|
-
{ stageKey: "nurturing", label: "Nurturing", color: "grape", states: [] }
|
|
6709
|
-
]
|
|
6710
|
-
};
|
|
6711
|
-
var LEAD_GEN_STAGE_CATALOG = {
|
|
6712
|
-
// Prospecting — company population
|
|
6713
|
-
scraped: {
|
|
6714
|
-
key: "scraped",
|
|
6715
|
-
label: "Scraped",
|
|
6716
|
-
description: "Company was scraped from a source directory (Apify actor run).",
|
|
6717
|
-
order: 1,
|
|
6718
|
-
entity: "company"
|
|
6719
|
-
},
|
|
6720
|
-
populated: {
|
|
6721
|
-
key: "populated",
|
|
6722
|
-
label: "Companies found",
|
|
6723
|
-
description: "Companies have been found and added to the lead-gen list.",
|
|
6724
|
-
order: 2,
|
|
6725
|
-
entity: "company"
|
|
6726
|
-
},
|
|
6727
|
-
crawled: {
|
|
6728
|
-
key: "crawled",
|
|
6729
|
-
label: "Websites crawled",
|
|
6730
|
-
description: "Company websites have been crawled (e.g. via Apify) and raw page content stored for downstream LLM analysis.",
|
|
6731
|
-
order: 2.5,
|
|
6732
|
-
entity: "company"
|
|
6733
|
-
},
|
|
6734
|
-
extracted: {
|
|
6735
|
-
key: "extracted",
|
|
6736
|
-
label: "Websites analyzed",
|
|
6737
|
-
description: "Company websites have been analyzed for business signals.",
|
|
6738
|
-
order: 3,
|
|
6739
|
-
entity: "company"
|
|
6740
|
-
},
|
|
6741
|
-
enriched: {
|
|
6742
|
-
key: "enriched",
|
|
6743
|
-
label: "Enriched",
|
|
6744
|
-
description: "Company or contact enriched with third-party data (e.g. Tomba, Anymailfinder).",
|
|
6745
|
-
order: 4,
|
|
6746
|
-
entity: "company"
|
|
6659
|
+
var EntitiesDomainSchema = z.record(z.string(), EntitySchema).refine((record) => Object.entries(record).every(([key, entry]) => entry.id === key), {
|
|
6660
|
+
message: "Each entity entry id must match its map key"
|
|
6661
|
+
}).default({});
|
|
6662
|
+
var ENTITY_ENTRY_INPUTS = [
|
|
6663
|
+
{
|
|
6664
|
+
id: "crm.deal",
|
|
6665
|
+
order: 10,
|
|
6666
|
+
label: "Deal",
|
|
6667
|
+
description: "A CRM opportunity or sales pipeline record.",
|
|
6668
|
+
ownedBySystemId: "sales.crm",
|
|
6669
|
+
table: "crm_deals",
|
|
6670
|
+
stateCatalogId: "crm.pipeline",
|
|
6671
|
+
links: [{ toEntity: "crm.contact", kind: "has-many", via: "deal_contacts", label: "contacts" }]
|
|
6747
6672
|
},
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
recordStageKey: "discovered"
|
|
6673
|
+
{
|
|
6674
|
+
id: "crm.contact",
|
|
6675
|
+
order: 20,
|
|
6676
|
+
label: "CRM Contact",
|
|
6677
|
+
description: "A person associated with a CRM relationship or deal.",
|
|
6678
|
+
ownedBySystemId: "sales.crm",
|
|
6679
|
+
table: "crm_contacts"
|
|
6756
6680
|
},
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
label: "
|
|
6761
|
-
description: "
|
|
6762
|
-
|
|
6763
|
-
|
|
6681
|
+
{
|
|
6682
|
+
id: "leadgen.list",
|
|
6683
|
+
order: 30,
|
|
6684
|
+
label: "Lead List",
|
|
6685
|
+
description: "A prospecting list that groups companies and contacts for acquisition workflows.",
|
|
6686
|
+
ownedBySystemId: "sales.lead-gen",
|
|
6687
|
+
table: "acq_lists",
|
|
6688
|
+
links: [
|
|
6689
|
+
{ toEntity: "leadgen.company", kind: "has-many", via: "acq_list_companies", label: "companies" },
|
|
6690
|
+
{ toEntity: "leadgen.contact", kind: "has-many", via: "acq_list_members", label: "contacts" }
|
|
6691
|
+
]
|
|
6764
6692
|
},
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6693
|
+
{
|
|
6694
|
+
id: "leadgen.company",
|
|
6695
|
+
order: 40,
|
|
6696
|
+
label: "Lead Company",
|
|
6697
|
+
description: "A company record sourced, enriched, and qualified during prospecting.",
|
|
6698
|
+
ownedBySystemId: "sales.lead-gen",
|
|
6699
|
+
table: "acq_list_companies",
|
|
6700
|
+
stateCatalogId: "lead-gen.company",
|
|
6701
|
+
links: [
|
|
6702
|
+
{ toEntity: "leadgen.list", kind: "belongs-to", via: "list_id", label: "list" },
|
|
6703
|
+
{ toEntity: "leadgen.contact", kind: "has-many", via: "company_id", label: "contacts" }
|
|
6704
|
+
]
|
|
6771
6705
|
},
|
|
6772
|
-
|
|
6773
|
-
|
|
6774
|
-
|
|
6775
|
-
label: "
|
|
6776
|
-
description: "
|
|
6777
|
-
|
|
6778
|
-
|
|
6706
|
+
{
|
|
6707
|
+
id: "leadgen.contact",
|
|
6708
|
+
order: 50,
|
|
6709
|
+
label: "Lead Contact",
|
|
6710
|
+
description: "A prospect contact discovered or enriched during lead generation.",
|
|
6711
|
+
ownedBySystemId: "sales.lead-gen",
|
|
6712
|
+
table: "acq_list_members",
|
|
6713
|
+
stateCatalogId: "lead-gen.contact",
|
|
6714
|
+
links: [
|
|
6715
|
+
{ toEntity: "leadgen.list", kind: "belongs-to", via: "list_id", label: "list" },
|
|
6716
|
+
{ toEntity: "leadgen.company", kind: "belongs-to", via: "company_id", label: "company" }
|
|
6717
|
+
]
|
|
6779
6718
|
},
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
label: "
|
|
6784
|
-
description: "
|
|
6785
|
-
|
|
6786
|
-
|
|
6719
|
+
{
|
|
6720
|
+
id: "delivery.project",
|
|
6721
|
+
order: 60,
|
|
6722
|
+
label: "Project",
|
|
6723
|
+
description: "A client delivery project.",
|
|
6724
|
+
ownedBySystemId: "projects",
|
|
6725
|
+
table: "projects",
|
|
6726
|
+
links: [
|
|
6727
|
+
{ toEntity: "delivery.milestone", kind: "has-many", via: "project_id", label: "milestones" },
|
|
6728
|
+
{ toEntity: "delivery.task", kind: "has-many", via: "project_id", label: "tasks" }
|
|
6729
|
+
]
|
|
6787
6730
|
},
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
|
|
6731
|
+
{
|
|
6732
|
+
id: "delivery.milestone",
|
|
6733
|
+
order: 70,
|
|
6734
|
+
label: "Milestone",
|
|
6735
|
+
description: "A delivery checkpoint within a project.",
|
|
6736
|
+
ownedBySystemId: "projects",
|
|
6737
|
+
table: "project_milestones",
|
|
6738
|
+
links: [
|
|
6739
|
+
{ toEntity: "delivery.project", kind: "belongs-to", via: "project_id", label: "project" },
|
|
6740
|
+
{ toEntity: "delivery.task", kind: "has-many", via: "milestone_id", label: "tasks" }
|
|
6741
|
+
]
|
|
6795
6742
|
},
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
|
|
6743
|
+
{
|
|
6744
|
+
id: "delivery.task",
|
|
6745
|
+
order: 80,
|
|
6746
|
+
label: "Task",
|
|
6747
|
+
description: "A delivery task that can move through the task status catalog.",
|
|
6748
|
+
ownedBySystemId: "projects",
|
|
6749
|
+
table: "project_tasks",
|
|
6750
|
+
stateCatalogId: "delivery.task",
|
|
6751
|
+
links: [
|
|
6752
|
+
{ toEntity: "delivery.project", kind: "belongs-to", via: "project_id", label: "project" },
|
|
6753
|
+
{ toEntity: "delivery.milestone", kind: "belongs-to", via: "milestone_id", label: "milestone" }
|
|
6754
|
+
]
|
|
6802
6755
|
}
|
|
6803
|
-
|
|
6756
|
+
];
|
|
6757
|
+
var DEFAULT_ORGANIZATION_MODEL_ENTITIES = Object.fromEntries(
|
|
6758
|
+
ENTITY_ENTRY_INPUTS.map((entity) => {
|
|
6759
|
+
const parsed = EntitySchema.parse(entity);
|
|
6760
|
+
return [parsed.id, parsed];
|
|
6761
|
+
})
|
|
6762
|
+
);
|
|
6804
6763
|
|
|
6805
|
-
// ../core/src/organization-model/domains/
|
|
6806
|
-
var
|
|
6807
|
-
|
|
6808
|
-
|
|
6764
|
+
// ../core/src/organization-model/domains/actions.ts
|
|
6765
|
+
var ActionResourceIdSchema = z.string().trim().min(1).max(255).regex(/^[A-Za-z0-9]+(?:[-._][A-Za-z0-9]+)*$/, "Resource IDs must use letters, numbers, -, _, or . separators");
|
|
6766
|
+
z.enum(["slash-command", "mcp-tool", "api-endpoint", "script-execution"]).meta({ label: "Invocation kind" });
|
|
6767
|
+
var ActionIdSchema = ModelIdSchema;
|
|
6768
|
+
var ActionScopeSchema = z.union([
|
|
6769
|
+
z.literal("global"),
|
|
6770
|
+
z.object({
|
|
6771
|
+
domain: ModelIdSchema
|
|
6772
|
+
})
|
|
6773
|
+
]);
|
|
6774
|
+
var ActionRefSchema = z.object({
|
|
6775
|
+
actionId: ActionIdSchema.meta({ ref: "action" }),
|
|
6776
|
+
intent: z.enum(["exposes", "consumes"]).meta({ label: "Intent" })
|
|
6809
6777
|
});
|
|
6810
|
-
var
|
|
6811
|
-
|
|
6812
|
-
|
|
6813
|
-
|
|
6814
|
-
width: z.union([z.number().positive(), z.string().trim().min(1).max(100)]).optional(),
|
|
6815
|
-
renderType: z.enum(["text", "badge", "datetime", "count", "json"]).optional(),
|
|
6816
|
-
badgeColor: z.string().trim().min(1).max(40).optional()
|
|
6778
|
+
var SlashCommandInvocationSchema = z.object({
|
|
6779
|
+
kind: z.literal("slash-command"),
|
|
6780
|
+
command: z.string().trim().min(1).max(200).regex(/^\/[^\s].*$/, "Slash commands must start with /"),
|
|
6781
|
+
toolFactory: ModelIdSchema.optional()
|
|
6817
6782
|
});
|
|
6818
|
-
var
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
message: "recordColumns must include at least one entity column set"
|
|
6783
|
+
var McpToolInvocationSchema = z.object({
|
|
6784
|
+
kind: z.literal("mcp-tool"),
|
|
6785
|
+
server: ModelIdSchema,
|
|
6786
|
+
name: ModelIdSchema
|
|
6823
6787
|
});
|
|
6824
|
-
var
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
selectionMode: z.enum(["single", "multiple"]).optional(),
|
|
6831
|
-
inputPath: z.string().trim().min(1).max(500),
|
|
6832
|
-
verifyOnRun: z.boolean().optional()
|
|
6788
|
+
var ApiEndpointInvocationSchema = z.object({
|
|
6789
|
+
kind: z.literal("api-endpoint"),
|
|
6790
|
+
method: z.enum(["GET", "POST", "PATCH", "DELETE"]).meta({ label: "HTTP method" }),
|
|
6791
|
+
path: z.string().trim().startsWith("/").max(500),
|
|
6792
|
+
requestSchema: ModelIdSchema.optional(),
|
|
6793
|
+
responseSchema: ModelIdSchema.optional()
|
|
6833
6794
|
});
|
|
6834
|
-
var
|
|
6835
|
-
|
|
6836
|
-
|
|
6837
|
-
outputs: z.array(z.enum(["company", "contact", "export"])).min(1),
|
|
6838
|
-
stageKey: ModelIdSchema,
|
|
6839
|
-
recordEntity: z.enum(["company", "contact"]).optional(),
|
|
6840
|
-
recordsStageKey: ModelIdSchema.optional(),
|
|
6841
|
-
recordSourceStageKey: ModelIdSchema.optional(),
|
|
6842
|
-
dependsOn: z.array(ModelIdSchema).optional(),
|
|
6843
|
-
dependencyMode: z.literal("per-record-eligibility"),
|
|
6844
|
-
capabilityKey: ModelIdSchema,
|
|
6845
|
-
defaultBatchSize: z.number().int().positive(),
|
|
6846
|
-
maxBatchSize: z.number().int().positive(),
|
|
6847
|
-
recordColumns: RecordColumnsConfigSchema.optional(),
|
|
6848
|
-
credentialRequirements: z.array(CredentialRequirementSchema).optional()
|
|
6849
|
-
}).refine((step) => step.defaultBatchSize <= step.maxBatchSize, {
|
|
6850
|
-
message: "defaultBatchSize must be less than or equal to maxBatchSize",
|
|
6851
|
-
path: ["defaultBatchSize"]
|
|
6795
|
+
var ScriptExecutionInvocationSchema = z.object({
|
|
6796
|
+
kind: z.literal("script-execution"),
|
|
6797
|
+
resourceId: ActionResourceIdSchema
|
|
6852
6798
|
});
|
|
6853
|
-
var
|
|
6854
|
-
|
|
6855
|
-
|
|
6799
|
+
var ActionInvocationSchema = z.discriminatedUnion("kind", [
|
|
6800
|
+
SlashCommandInvocationSchema,
|
|
6801
|
+
McpToolInvocationSchema,
|
|
6802
|
+
ApiEndpointInvocationSchema,
|
|
6803
|
+
ScriptExecutionInvocationSchema
|
|
6804
|
+
]);
|
|
6805
|
+
var ActionSchema = z.object({
|
|
6806
|
+
id: ActionIdSchema,
|
|
6807
|
+
/** Domain-map iteration order. Convention: multiples of 10 (10, 20, 30, ...) to allow easy insertion. */
|
|
6808
|
+
order: z.number(),
|
|
6809
|
+
label: LabelSchema,
|
|
6810
|
+
description: DescriptionSchema.optional(),
|
|
6811
|
+
scope: ActionScopeSchema.default("global"),
|
|
6812
|
+
resourceId: ActionResourceIdSchema.optional(),
|
|
6813
|
+
affects: z.array(EntityIdSchema.meta({ ref: "entity" })).optional(),
|
|
6814
|
+
invocations: z.array(ActionInvocationSchema).default([]),
|
|
6815
|
+
knowledge: z.array(ModelIdSchema.meta({ ref: "knowledge" })).default([]).optional(),
|
|
6816
|
+
lifecycle: z.enum(["draft", "beta", "active", "deprecated", "archived"]).meta({ label: "Lifecycle", color: "teal" }).default("active")
|
|
6856
6817
|
});
|
|
6857
|
-
var
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6818
|
+
var ActionsDomainSchema = z.record(z.string(), ActionSchema).refine((record) => Object.entries(record).every(([key, entry]) => entry.id === key), {
|
|
6819
|
+
message: "Each action entry id must match its map key"
|
|
6820
|
+
}).default({});
|
|
6821
|
+
var LEAD_GEN_ACTION_ENTRY_INPUTS = [
|
|
6822
|
+
{
|
|
6823
|
+
id: "lead-gen.company.source",
|
|
6824
|
+
order: 10,
|
|
6825
|
+
label: "Source companies",
|
|
6826
|
+
description: "Import source companies from a list provider.",
|
|
6827
|
+
scope: { domain: "sales" },
|
|
6828
|
+
resourceId: "lgn-import-workflow",
|
|
6829
|
+
invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/source" }]
|
|
6866
6830
|
},
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
extracted: {
|
|
6876
|
-
company: [
|
|
6877
|
-
{ key: "name", label: "Company", path: "company.name" },
|
|
6878
|
-
{ key: "domain", label: "Domain", path: "company.domain" },
|
|
6879
|
-
{ key: "description", label: "Description", path: "company.enrichmentData.websiteCrawl.companyDescription" },
|
|
6880
|
-
{ key: "services", label: "Services", path: "company.enrichmentData.websiteCrawl.services", renderType: "json" },
|
|
6881
|
-
{ key: "automation-gaps", label: "Automation gaps", path: "company.enrichmentData.websiteCrawl.automationGaps", renderType: "json" },
|
|
6882
|
-
{ key: "contact-count", label: "Contacts", path: "company.enrichmentData.websiteCrawl.emailCount", renderType: "count" }
|
|
6883
|
-
]
|
|
6884
|
-
},
|
|
6885
|
-
qualified: {
|
|
6886
|
-
company: [
|
|
6887
|
-
{ key: "name", label: "Company", path: "company.name" },
|
|
6888
|
-
{ key: "domain", label: "Domain", path: "company.domain" },
|
|
6889
|
-
{ key: "score", label: "Score", path: "company.qualificationScore", renderType: "badge", badgeColor: "green" },
|
|
6890
|
-
{ key: "signals", label: "Signals", path: "company.qualificationSignals", renderType: "json" },
|
|
6891
|
-
{ key: "disqualified-reason", label: "Disqualified reason", path: "processingState.qualified.data.disqualifiedReason" }
|
|
6892
|
-
]
|
|
6893
|
-
},
|
|
6894
|
-
decisionMakers: {
|
|
6895
|
-
contact: [
|
|
6896
|
-
{ key: "name", label: "Name", path: "contact.name" },
|
|
6897
|
-
{ key: "title", label: "Title", path: "contact.title" },
|
|
6898
|
-
{ key: "email", label: "Email", path: "contact.email" },
|
|
6899
|
-
{ key: "linkedin", label: "LinkedIn", path: "contact.linkedinUrl" },
|
|
6900
|
-
{ key: "priority-score", label: "Priority", path: "contact.enrichmentData.apollo.priorityScore", renderType: "badge" }
|
|
6901
|
-
]
|
|
6902
|
-
},
|
|
6903
|
-
uploaded: {
|
|
6904
|
-
company: [
|
|
6905
|
-
{ key: "name", label: "Company", path: "company.name" },
|
|
6906
|
-
{ key: "domain", label: "Domain", path: "company.domain" },
|
|
6907
|
-
{ key: "contacts", label: "Contacts", path: "company.enrichmentData.approvedLeadListExport.contacts", renderType: "json" },
|
|
6908
|
-
{ key: "score", label: "Score", path: "company.qualificationScore", renderType: "badge", badgeColor: "green" },
|
|
6909
|
-
{ key: "approval", label: "Approval", path: "company.enrichmentData.approvedLeadListExport.approvalStatus", renderType: "badge" }
|
|
6910
|
-
]
|
|
6911
|
-
}
|
|
6912
|
-
};
|
|
6913
|
-
z.object({
|
|
6914
|
-
id: ModelIdSchema,
|
|
6915
|
-
label: z.string(),
|
|
6916
|
-
description: z.string(),
|
|
6917
|
-
resourceId: ModelIdSchema
|
|
6918
|
-
});
|
|
6919
|
-
var CAPABILITY_REGISTRY = [
|
|
6920
|
-
{
|
|
6921
|
-
id: "lead-gen.company.source",
|
|
6922
|
-
label: "Source companies",
|
|
6923
|
-
description: "Import source companies from a list provider.",
|
|
6924
|
-
resourceId: "lgn-import-workflow"
|
|
6925
|
-
},
|
|
6926
|
-
{
|
|
6927
|
-
id: "lead-gen.company.apollo-import",
|
|
6928
|
-
label: "Import from Apollo",
|
|
6929
|
-
description: "Pull companies and seed contact data from an Apollo search or list.",
|
|
6930
|
-
resourceId: "lgn-01c-apollo-import-workflow"
|
|
6831
|
+
{
|
|
6832
|
+
id: "lead-gen.company.apollo-import",
|
|
6833
|
+
order: 20,
|
|
6834
|
+
label: "Import from Apollo",
|
|
6835
|
+
description: "Pull companies and seed contact data from an Apollo search or list.",
|
|
6836
|
+
scope: { domain: "sales" },
|
|
6837
|
+
resourceId: "lgn-01c-apollo-import-workflow",
|
|
6838
|
+
invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/apollo-import" }]
|
|
6931
6839
|
},
|
|
6932
6840
|
{
|
|
6933
6841
|
id: "lead-gen.contact.discover",
|
|
6842
|
+
order: 30,
|
|
6934
6843
|
label: "Discover contact emails",
|
|
6935
6844
|
description: "Find email addresses for contacts at qualified companies.",
|
|
6936
|
-
|
|
6845
|
+
scope: { domain: "sales" },
|
|
6846
|
+
resourceId: "lgn-04-email-discovery-workflow",
|
|
6847
|
+
invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/contacts/discover" }]
|
|
6937
6848
|
},
|
|
6938
6849
|
{
|
|
6939
6850
|
id: "lead-gen.contact.verify-email",
|
|
6851
|
+
order: 40,
|
|
6940
6852
|
label: "Verify emails",
|
|
6941
6853
|
description: "Check email deliverability before outreach.",
|
|
6942
|
-
|
|
6854
|
+
scope: { domain: "sales" },
|
|
6855
|
+
resourceId: "lgn-05-email-verification-workflow",
|
|
6856
|
+
invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/contacts/verify-email" }]
|
|
6943
6857
|
},
|
|
6944
6858
|
{
|
|
6945
6859
|
id: "lead-gen.company.apify-crawl",
|
|
6860
|
+
order: 50,
|
|
6946
6861
|
label: "Crawl websites",
|
|
6947
6862
|
description: "Crawl company websites via Apify and store raw page markdown in enrichmentData.websiteCrawl.pages for downstream LLM analysis.",
|
|
6948
|
-
|
|
6863
|
+
scope: { domain: "sales" },
|
|
6864
|
+
resourceId: "lgn-02a-apify-website-crawl-workflow",
|
|
6865
|
+
invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/apify-crawl" }]
|
|
6949
6866
|
},
|
|
6950
6867
|
{
|
|
6951
6868
|
id: "lead-gen.company.website-extract",
|
|
6869
|
+
order: 60,
|
|
6952
6870
|
label: "Extract website signals",
|
|
6953
6871
|
description: "Scrape and analyze company websites for qualification signals.",
|
|
6954
|
-
|
|
6872
|
+
scope: { domain: "sales" },
|
|
6873
|
+
resourceId: "lgn-02-website-extract-workflow",
|
|
6874
|
+
invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/website-extract" }]
|
|
6955
6875
|
},
|
|
6956
6876
|
{
|
|
6957
6877
|
id: "lead-gen.company.qualify",
|
|
6878
|
+
order: 70,
|
|
6958
6879
|
label: "Qualify companies",
|
|
6959
6880
|
description: "Score and filter companies against the ICP rubric.",
|
|
6960
|
-
|
|
6881
|
+
scope: { domain: "sales" },
|
|
6882
|
+
resourceId: "lgn-03-company-qualification-workflow",
|
|
6883
|
+
invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/qualify" }]
|
|
6961
6884
|
},
|
|
6962
6885
|
{
|
|
6963
6886
|
id: "lead-gen.company.dtc-subscription-qualify",
|
|
6887
|
+
order: 80,
|
|
6964
6888
|
label: "Qualify DTC subscription fit",
|
|
6965
6889
|
description: "Classify subscription potential and consumable-product fit for DTC brands.",
|
|
6966
|
-
|
|
6890
|
+
scope: { domain: "sales" },
|
|
6891
|
+
resourceId: "lgn-03b-dtc-subscription-score-workflow",
|
|
6892
|
+
invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/dtc-subscription-qualify" }]
|
|
6967
6893
|
},
|
|
6968
6894
|
{
|
|
6969
6895
|
id: "lead-gen.contact.apollo-decision-maker-enrich",
|
|
6896
|
+
order: 90,
|
|
6970
6897
|
label: "Enrich decision-makers",
|
|
6971
6898
|
description: "Find and enrich qualified contacts at qualified companies via Apollo.",
|
|
6972
|
-
|
|
6899
|
+
scope: { domain: "sales" },
|
|
6900
|
+
resourceId: "lgn-04b-apollo-decision-maker-enrich-workflow",
|
|
6901
|
+
invocations: [
|
|
6902
|
+
{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/contacts/apollo-decision-maker-enrich" }
|
|
6903
|
+
]
|
|
6973
6904
|
},
|
|
6974
6905
|
{
|
|
6975
6906
|
id: "lead-gen.contact.personalize",
|
|
6907
|
+
order: 100,
|
|
6976
6908
|
label: "Personalize outreach",
|
|
6977
6909
|
description: "Generate personalized opening lines for each contact.",
|
|
6978
|
-
|
|
6910
|
+
scope: { domain: "sales" },
|
|
6911
|
+
resourceId: "ist-personalization-workflow",
|
|
6912
|
+
invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/contacts/personalize" }]
|
|
6979
6913
|
},
|
|
6980
6914
|
{
|
|
6981
6915
|
id: "lead-gen.review.outreach-ready",
|
|
6916
|
+
order: 110,
|
|
6982
6917
|
label: "Upload to outreach",
|
|
6983
6918
|
description: "Upload approved contacts to the outreach sequence after QC review.",
|
|
6984
|
-
|
|
6919
|
+
scope: { domain: "sales" },
|
|
6920
|
+
resourceId: "ist-upload-contacts-workflow",
|
|
6921
|
+
invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/review/outreach-ready" }]
|
|
6985
6922
|
},
|
|
6986
6923
|
{
|
|
6987
6924
|
id: "lead-gen.export.list",
|
|
6925
|
+
order: 120,
|
|
6988
6926
|
label: "Export lead list",
|
|
6989
6927
|
description: "Export approved leads as a downloadable lead list.",
|
|
6990
|
-
|
|
6928
|
+
scope: { domain: "sales" },
|
|
6929
|
+
resourceId: "lgn-06-export-list-workflow",
|
|
6930
|
+
invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/export/list" }]
|
|
6991
6931
|
},
|
|
6992
6932
|
{
|
|
6993
6933
|
id: "lead-gen.company.cleanup",
|
|
6934
|
+
order: 130,
|
|
6994
6935
|
label: "Clean up companies",
|
|
6995
6936
|
description: "Remove disqualified or duplicate companies from the list.",
|
|
6996
|
-
|
|
6937
|
+
scope: { domain: "sales" },
|
|
6938
|
+
resourceId: "lgn-company-cleanup-workflow",
|
|
6939
|
+
invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/cleanup" }]
|
|
6940
|
+
}
|
|
6941
|
+
];
|
|
6942
|
+
var LEAD_GEN_ACTION_ENTRIES = Object.fromEntries(
|
|
6943
|
+
LEAD_GEN_ACTION_ENTRY_INPUTS.map((action) => {
|
|
6944
|
+
const parsed = ActionSchema.parse(action);
|
|
6945
|
+
return [parsed.id, parsed];
|
|
6946
|
+
})
|
|
6947
|
+
);
|
|
6948
|
+
var CRM_ACTION_ENTRY_INPUTS = [
|
|
6949
|
+
{
|
|
6950
|
+
id: "send_reply",
|
|
6951
|
+
order: 210,
|
|
6952
|
+
label: "Send Reply",
|
|
6953
|
+
description: "Send a contextual reply for an active CRM deal.",
|
|
6954
|
+
scope: { domain: "sales" },
|
|
6955
|
+
resourceId: "crm-send-reply-workflow",
|
|
6956
|
+
affects: ["crm.deal"]
|
|
6957
|
+
},
|
|
6958
|
+
{
|
|
6959
|
+
id: "send_link",
|
|
6960
|
+
order: 220,
|
|
6961
|
+
label: "Send Booking Link",
|
|
6962
|
+
description: "Send a booking link to move a deal toward a scheduled call.",
|
|
6963
|
+
scope: { domain: "sales" },
|
|
6964
|
+
resourceId: "crm-send-booking-link-workflow",
|
|
6965
|
+
affects: ["crm.deal"]
|
|
6966
|
+
},
|
|
6967
|
+
{
|
|
6968
|
+
id: "send_nudge",
|
|
6969
|
+
order: 230,
|
|
6970
|
+
label: "Send Nudge",
|
|
6971
|
+
description: "Send a follow-up nudge for a stalled CRM deal.",
|
|
6972
|
+
scope: { domain: "sales" },
|
|
6973
|
+
resourceId: "crm-send-nudge-workflow",
|
|
6974
|
+
affects: ["crm.deal"]
|
|
6975
|
+
},
|
|
6976
|
+
{
|
|
6977
|
+
id: "rebook",
|
|
6978
|
+
order: 240,
|
|
6979
|
+
label: "Rebook",
|
|
6980
|
+
description: "Rebook a missed or rescheduled CRM appointment.",
|
|
6981
|
+
scope: { domain: "sales" },
|
|
6982
|
+
resourceId: "crm-rebook-workflow",
|
|
6983
|
+
affects: ["crm.deal"]
|
|
6984
|
+
},
|
|
6985
|
+
{
|
|
6986
|
+
id: "move_to_proposal",
|
|
6987
|
+
order: 250,
|
|
6988
|
+
label: "Move to Proposal",
|
|
6989
|
+
description: "Advance a qualified CRM deal into the proposal stage.",
|
|
6990
|
+
scope: { domain: "sales" },
|
|
6991
|
+
resourceId: "move_to_proposal-workflow",
|
|
6992
|
+
affects: ["crm.deal"]
|
|
6993
|
+
},
|
|
6994
|
+
{
|
|
6995
|
+
id: "move_to_closing",
|
|
6996
|
+
order: 260,
|
|
6997
|
+
label: "Move to Closing",
|
|
6998
|
+
description: "Advance a proposal-stage CRM deal into closing.",
|
|
6999
|
+
scope: { domain: "sales" },
|
|
7000
|
+
resourceId: "move_to_closing-workflow",
|
|
7001
|
+
affects: ["crm.deal"]
|
|
7002
|
+
},
|
|
7003
|
+
{
|
|
7004
|
+
id: "move_to_closed_won",
|
|
7005
|
+
order: 270,
|
|
7006
|
+
label: "Close Won",
|
|
7007
|
+
description: "Mark a CRM deal as closed won.",
|
|
7008
|
+
scope: { domain: "sales" },
|
|
7009
|
+
resourceId: "move_to_closed_won-workflow",
|
|
7010
|
+
affects: ["crm.deal"]
|
|
7011
|
+
},
|
|
7012
|
+
{
|
|
7013
|
+
id: "move_to_closed_lost",
|
|
7014
|
+
order: 280,
|
|
7015
|
+
label: "Close Lost",
|
|
7016
|
+
description: "Mark a CRM deal as closed lost.",
|
|
7017
|
+
scope: { domain: "sales" },
|
|
7018
|
+
resourceId: "move_to_closed_lost-workflow",
|
|
7019
|
+
affects: ["crm.deal"]
|
|
7020
|
+
},
|
|
7021
|
+
{
|
|
7022
|
+
id: "move_to_nurturing",
|
|
7023
|
+
order: 290,
|
|
7024
|
+
label: "Move to Nurturing",
|
|
7025
|
+
description: "Move a CRM deal into nurturing for future follow-up.",
|
|
7026
|
+
scope: { domain: "sales" },
|
|
7027
|
+
resourceId: "move_to_nurturing-workflow",
|
|
7028
|
+
affects: ["crm.deal"]
|
|
6997
7029
|
}
|
|
6998
7030
|
];
|
|
7031
|
+
var CRM_ACTION_ENTRIES = Object.fromEntries(
|
|
7032
|
+
CRM_ACTION_ENTRY_INPUTS.map((action) => {
|
|
7033
|
+
const parsed = ActionSchema.parse(action);
|
|
7034
|
+
return [parsed.id, parsed];
|
|
7035
|
+
})
|
|
7036
|
+
);
|
|
7037
|
+
var DEFAULT_ORGANIZATION_MODEL_ACTIONS = {
|
|
7038
|
+
...LEAD_GEN_ACTION_ENTRIES,
|
|
7039
|
+
...CRM_ACTION_ENTRIES
|
|
7040
|
+
};
|
|
7041
|
+
|
|
7042
|
+
// ../core/src/organization-model/domains/prospecting.ts
|
|
7043
|
+
DisplayMetadataSchema.extend({
|
|
7044
|
+
id: ModelIdSchema,
|
|
7045
|
+
order: z.number().min(0)
|
|
7046
|
+
});
|
|
7047
|
+
var RecordColumnConfigSchema = z.object({
|
|
7048
|
+
key: ModelIdSchema,
|
|
7049
|
+
label: z.string().trim().min(1).max(120),
|
|
7050
|
+
path: z.string().trim().min(1).max(500),
|
|
7051
|
+
width: z.union([z.number().positive(), z.string().trim().min(1).max(100)]).optional(),
|
|
7052
|
+
renderType: z.enum(["text", "badge", "datetime", "count", "json"]).optional(),
|
|
7053
|
+
badgeColor: z.string().trim().min(1).max(40).optional()
|
|
7054
|
+
});
|
|
7055
|
+
var RecordColumnsConfigSchema = z.object({
|
|
7056
|
+
company: z.array(RecordColumnConfigSchema).optional(),
|
|
7057
|
+
contact: z.array(RecordColumnConfigSchema).optional()
|
|
7058
|
+
}).refine((columns) => Boolean(columns.company?.length || columns.contact?.length), {
|
|
7059
|
+
message: "recordColumns must include at least one entity column set"
|
|
7060
|
+
});
|
|
7061
|
+
var CredentialRequirementSchema = z.object({
|
|
7062
|
+
key: ModelIdSchema,
|
|
7063
|
+
provider: ModelIdSchema,
|
|
7064
|
+
credentialType: z.enum(["api-key", "api-key-secret", "oauth", "webhook-secret"]),
|
|
7065
|
+
label: z.string().trim().min(1).max(120),
|
|
7066
|
+
required: z.boolean(),
|
|
7067
|
+
selectionMode: z.enum(["single", "multiple"]).optional(),
|
|
7068
|
+
inputPath: z.string().trim().min(1).max(500),
|
|
7069
|
+
verifyOnRun: z.boolean().optional()
|
|
7070
|
+
});
|
|
7071
|
+
var ProspectingBuildTemplateStepSchema = DisplayMetadataSchema.extend({
|
|
7072
|
+
id: ModelIdSchema,
|
|
7073
|
+
primaryEntity: z.enum(["company", "contact"]),
|
|
7074
|
+
outputs: z.array(z.enum(["company", "contact", "export"])).min(1),
|
|
7075
|
+
stageKey: ModelIdSchema,
|
|
7076
|
+
recordEntity: z.enum(["company", "contact"]).optional(),
|
|
7077
|
+
recordsStageKey: ModelIdSchema.optional(),
|
|
7078
|
+
recordSourceStageKey: ModelIdSchema.optional(),
|
|
7079
|
+
dependsOn: z.array(ModelIdSchema).optional(),
|
|
7080
|
+
dependencyMode: z.literal("per-record-eligibility"),
|
|
7081
|
+
actionKey: ModelIdSchema,
|
|
7082
|
+
defaultBatchSize: z.number().int().positive(),
|
|
7083
|
+
maxBatchSize: z.number().int().positive(),
|
|
7084
|
+
recordColumns: RecordColumnsConfigSchema.optional(),
|
|
7085
|
+
credentialRequirements: z.array(CredentialRequirementSchema).optional()
|
|
7086
|
+
}).refine((step) => step.defaultBatchSize <= step.maxBatchSize, {
|
|
7087
|
+
message: "defaultBatchSize must be less than or equal to maxBatchSize",
|
|
7088
|
+
path: ["defaultBatchSize"]
|
|
7089
|
+
});
|
|
7090
|
+
DisplayMetadataSchema.extend({
|
|
7091
|
+
id: ModelIdSchema,
|
|
7092
|
+
steps: z.array(ProspectingBuildTemplateStepSchema).min(1)
|
|
7093
|
+
});
|
|
7094
|
+
var DTC_RECORD_COLUMNS = {
|
|
7095
|
+
populated: {
|
|
7096
|
+
company: [
|
|
7097
|
+
{ key: "name", label: "Company", path: "company.name" },
|
|
7098
|
+
{ key: "domain", label: "Domain", path: "company.domain" },
|
|
7099
|
+
{ key: "employee-count", label: "Employees", path: "company.numEmployees", renderType: "count" },
|
|
7100
|
+
{ key: "apollo-industry", label: "Apollo industry", path: "company.category" },
|
|
7101
|
+
{ key: "location", label: "Location", path: "company.locationState" }
|
|
7102
|
+
]
|
|
7103
|
+
},
|
|
7104
|
+
crawled: {
|
|
7105
|
+
company: [
|
|
7106
|
+
{ key: "name", label: "Company", path: "company.name" },
|
|
7107
|
+
{ key: "domain", label: "Domain", path: "company.domain" },
|
|
7108
|
+
{ key: "page-count", label: "Pages", path: "company.enrichmentData.websiteCrawl.pageCount", renderType: "count" },
|
|
7109
|
+
{ key: "crawl-status", label: "Crawl status", path: "processingState.crawled.status", renderType: "badge" }
|
|
7110
|
+
]
|
|
7111
|
+
},
|
|
7112
|
+
extracted: {
|
|
7113
|
+
company: [
|
|
7114
|
+
{ key: "name", label: "Company", path: "company.name" },
|
|
7115
|
+
{ key: "domain", label: "Domain", path: "company.domain" },
|
|
7116
|
+
{ key: "description", label: "Description", path: "company.enrichmentData.websiteCrawl.companyDescription" },
|
|
7117
|
+
{ key: "services", label: "Services", path: "company.enrichmentData.websiteCrawl.services", renderType: "json" },
|
|
7118
|
+
{
|
|
7119
|
+
key: "automation-gaps",
|
|
7120
|
+
label: "Automation gaps",
|
|
7121
|
+
path: "company.enrichmentData.websiteCrawl.automationGaps",
|
|
7122
|
+
renderType: "json"
|
|
7123
|
+
},
|
|
7124
|
+
{
|
|
7125
|
+
key: "contact-count",
|
|
7126
|
+
label: "Contacts",
|
|
7127
|
+
path: "company.enrichmentData.websiteCrawl.emailCount",
|
|
7128
|
+
renderType: "count"
|
|
7129
|
+
}
|
|
7130
|
+
]
|
|
7131
|
+
},
|
|
7132
|
+
qualified: {
|
|
7133
|
+
company: [
|
|
7134
|
+
{ key: "name", label: "Company", path: "company.name" },
|
|
7135
|
+
{ key: "domain", label: "Domain", path: "company.domain" },
|
|
7136
|
+
{ key: "score", label: "Score", path: "company.qualificationScore", renderType: "badge", badgeColor: "green" },
|
|
7137
|
+
{ key: "signals", label: "Signals", path: "company.qualificationSignals", renderType: "json" },
|
|
7138
|
+
{
|
|
7139
|
+
key: "disqualified-reason",
|
|
7140
|
+
label: "Disqualified reason",
|
|
7141
|
+
path: "processingState.qualified.data.disqualifiedReason"
|
|
7142
|
+
}
|
|
7143
|
+
]
|
|
7144
|
+
},
|
|
7145
|
+
decisionMakers: {
|
|
7146
|
+
contact: [
|
|
7147
|
+
{ key: "name", label: "Name", path: "contact.name" },
|
|
7148
|
+
{ key: "title", label: "Title", path: "contact.title" },
|
|
7149
|
+
{ key: "email", label: "Email", path: "contact.email" },
|
|
7150
|
+
{ key: "linkedin", label: "LinkedIn", path: "contact.linkedinUrl" },
|
|
7151
|
+
{
|
|
7152
|
+
key: "priority-score",
|
|
7153
|
+
label: "Priority",
|
|
7154
|
+
path: "contact.enrichmentData.apollo.priorityScore",
|
|
7155
|
+
renderType: "badge"
|
|
7156
|
+
}
|
|
7157
|
+
]
|
|
7158
|
+
},
|
|
7159
|
+
uploaded: {
|
|
7160
|
+
company: [
|
|
7161
|
+
{ key: "name", label: "Company", path: "company.name" },
|
|
7162
|
+
{ key: "domain", label: "Domain", path: "company.domain" },
|
|
7163
|
+
{
|
|
7164
|
+
key: "contacts",
|
|
7165
|
+
label: "Contacts",
|
|
7166
|
+
path: "company.enrichmentData.approvedLeadListExport.contacts",
|
|
7167
|
+
renderType: "json"
|
|
7168
|
+
},
|
|
7169
|
+
{ key: "score", label: "Score", path: "company.qualificationScore", renderType: "badge", badgeColor: "green" },
|
|
7170
|
+
{
|
|
7171
|
+
key: "approval",
|
|
7172
|
+
label: "Approval",
|
|
7173
|
+
path: "company.enrichmentData.approvedLeadListExport.approvalStatus",
|
|
7174
|
+
renderType: "badge"
|
|
7175
|
+
}
|
|
7176
|
+
]
|
|
7177
|
+
}
|
|
7178
|
+
};
|
|
7179
|
+
Object.values(LEAD_GEN_ACTION_ENTRIES);
|
|
6999
7180
|
var PROSPECTING_STEPS = {
|
|
7000
7181
|
localServices: {
|
|
7001
7182
|
sourceCompanies: {
|
|
@@ -7005,292 +7186,3287 @@ var PROSPECTING_STEPS = {
|
|
|
7005
7186
|
outputs: ["company"],
|
|
7006
7187
|
stageKey: "populated",
|
|
7007
7188
|
dependencyMode: "per-record-eligibility",
|
|
7008
|
-
|
|
7189
|
+
actionKey: "lead-gen.company.source",
|
|
7190
|
+
defaultBatchSize: 100,
|
|
7191
|
+
maxBatchSize: 250
|
|
7192
|
+
},
|
|
7193
|
+
analyzeWebsites: {
|
|
7194
|
+
id: "analyze-websites",
|
|
7195
|
+
label: "Websites analyzed",
|
|
7196
|
+
primaryEntity: "company",
|
|
7197
|
+
outputs: ["company"],
|
|
7198
|
+
stageKey: "extracted",
|
|
7199
|
+
dependsOn: ["source-companies"],
|
|
7200
|
+
dependencyMode: "per-record-eligibility",
|
|
7201
|
+
actionKey: "lead-gen.company.website-extract",
|
|
7202
|
+
defaultBatchSize: 50,
|
|
7203
|
+
maxBatchSize: 100
|
|
7204
|
+
},
|
|
7205
|
+
qualifyCompanies: {
|
|
7206
|
+
id: "qualify-companies",
|
|
7207
|
+
label: "Companies qualified",
|
|
7208
|
+
primaryEntity: "company",
|
|
7209
|
+
outputs: ["company"],
|
|
7210
|
+
stageKey: "qualified",
|
|
7211
|
+
dependsOn: ["analyze-websites"],
|
|
7212
|
+
dependencyMode: "per-record-eligibility",
|
|
7213
|
+
actionKey: "lead-gen.company.qualify",
|
|
7009
7214
|
defaultBatchSize: 100,
|
|
7010
7215
|
maxBatchSize: 250
|
|
7011
7216
|
},
|
|
7012
|
-
|
|
7013
|
-
id: "
|
|
7014
|
-
label: "
|
|
7015
|
-
primaryEntity: "
|
|
7016
|
-
outputs: ["
|
|
7017
|
-
stageKey: "
|
|
7018
|
-
dependsOn: ["
|
|
7019
|
-
dependencyMode: "per-record-eligibility",
|
|
7020
|
-
|
|
7021
|
-
defaultBatchSize: 50,
|
|
7022
|
-
maxBatchSize: 100
|
|
7217
|
+
findContacts: {
|
|
7218
|
+
id: "find-contacts",
|
|
7219
|
+
label: "Decision-makers found",
|
|
7220
|
+
primaryEntity: "contact",
|
|
7221
|
+
outputs: ["contact"],
|
|
7222
|
+
stageKey: "discovered",
|
|
7223
|
+
dependsOn: ["qualify-companies"],
|
|
7224
|
+
dependencyMode: "per-record-eligibility",
|
|
7225
|
+
actionKey: "lead-gen.contact.discover",
|
|
7226
|
+
defaultBatchSize: 50,
|
|
7227
|
+
maxBatchSize: 100
|
|
7228
|
+
},
|
|
7229
|
+
verifyEmails: {
|
|
7230
|
+
id: "verify-emails",
|
|
7231
|
+
label: "Emails verified",
|
|
7232
|
+
primaryEntity: "contact",
|
|
7233
|
+
outputs: ["contact"],
|
|
7234
|
+
stageKey: "verified",
|
|
7235
|
+
dependsOn: ["find-contacts"],
|
|
7236
|
+
dependencyMode: "per-record-eligibility",
|
|
7237
|
+
actionKey: "lead-gen.contact.verify-email",
|
|
7238
|
+
defaultBatchSize: 100,
|
|
7239
|
+
maxBatchSize: 500
|
|
7240
|
+
},
|
|
7241
|
+
personalize: {
|
|
7242
|
+
id: "personalize",
|
|
7243
|
+
label: "Personalize",
|
|
7244
|
+
primaryEntity: "contact",
|
|
7245
|
+
outputs: ["contact"],
|
|
7246
|
+
stageKey: "personalized",
|
|
7247
|
+
dependsOn: ["verify-emails"],
|
|
7248
|
+
dependencyMode: "per-record-eligibility",
|
|
7249
|
+
actionKey: "lead-gen.contact.personalize",
|
|
7250
|
+
defaultBatchSize: 25,
|
|
7251
|
+
maxBatchSize: 100
|
|
7252
|
+
},
|
|
7253
|
+
review: {
|
|
7254
|
+
id: "review",
|
|
7255
|
+
label: "Reviewed and exported",
|
|
7256
|
+
primaryEntity: "contact",
|
|
7257
|
+
outputs: ["export"],
|
|
7258
|
+
stageKey: "uploaded",
|
|
7259
|
+
dependsOn: ["personalize"],
|
|
7260
|
+
dependencyMode: "per-record-eligibility",
|
|
7261
|
+
actionKey: "lead-gen.review.outreach-ready",
|
|
7262
|
+
defaultBatchSize: 25,
|
|
7263
|
+
maxBatchSize: 100
|
|
7264
|
+
}
|
|
7265
|
+
},
|
|
7266
|
+
dtcApolloClickup: {
|
|
7267
|
+
importApolloSearch: {
|
|
7268
|
+
id: "import-apollo-search",
|
|
7269
|
+
label: "Companies found",
|
|
7270
|
+
description: "Pull companies and seed contact data from a predefined Apollo search or list.",
|
|
7271
|
+
primaryEntity: "company",
|
|
7272
|
+
outputs: ["company", "contact"],
|
|
7273
|
+
stageKey: "populated",
|
|
7274
|
+
dependencyMode: "per-record-eligibility",
|
|
7275
|
+
actionKey: "lead-gen.company.apollo-import",
|
|
7276
|
+
defaultBatchSize: 250,
|
|
7277
|
+
maxBatchSize: 1e3,
|
|
7278
|
+
recordColumns: DTC_RECORD_COLUMNS.populated,
|
|
7279
|
+
credentialRequirements: [
|
|
7280
|
+
{
|
|
7281
|
+
key: "apollo",
|
|
7282
|
+
provider: "apollo",
|
|
7283
|
+
credentialType: "api-key-secret",
|
|
7284
|
+
label: "Apollo API key",
|
|
7285
|
+
required: true,
|
|
7286
|
+
selectionMode: "single",
|
|
7287
|
+
inputPath: "credential"
|
|
7288
|
+
}
|
|
7289
|
+
]
|
|
7290
|
+
},
|
|
7291
|
+
apifyCrawl: {
|
|
7292
|
+
id: "apify-crawl",
|
|
7293
|
+
label: "Websites crawled",
|
|
7294
|
+
description: "Crawl company websites via Apify and store raw page markdown in enrichmentData.websiteCrawl.pages for downstream LLM analysis. Overwrites the synthetic seed Apollo Import wrote with real page content.",
|
|
7295
|
+
primaryEntity: "company",
|
|
7296
|
+
outputs: ["company"],
|
|
7297
|
+
stageKey: "crawled",
|
|
7298
|
+
dependsOn: ["import-apollo-search"],
|
|
7299
|
+
dependencyMode: "per-record-eligibility",
|
|
7300
|
+
actionKey: "lead-gen.company.apify-crawl",
|
|
7301
|
+
defaultBatchSize: 50,
|
|
7302
|
+
maxBatchSize: 100,
|
|
7303
|
+
recordColumns: DTC_RECORD_COLUMNS.crawled,
|
|
7304
|
+
credentialRequirements: [
|
|
7305
|
+
{
|
|
7306
|
+
key: "apify",
|
|
7307
|
+
provider: "apify",
|
|
7308
|
+
credentialType: "api-key-secret",
|
|
7309
|
+
label: "Apify API token",
|
|
7310
|
+
required: true,
|
|
7311
|
+
selectionMode: "single",
|
|
7312
|
+
inputPath: "credential",
|
|
7313
|
+
verifyOnRun: true
|
|
7314
|
+
}
|
|
7315
|
+
]
|
|
7316
|
+
},
|
|
7317
|
+
analyzeWebsites: {
|
|
7318
|
+
id: "analyze-websites",
|
|
7319
|
+
label: "Websites analyzed",
|
|
7320
|
+
description: "Extract subscription, product, retention, and tech-stack signals from each brand website.",
|
|
7321
|
+
primaryEntity: "company",
|
|
7322
|
+
outputs: ["company"],
|
|
7323
|
+
stageKey: "extracted",
|
|
7324
|
+
dependsOn: ["apify-crawl"],
|
|
7325
|
+
dependencyMode: "per-record-eligibility",
|
|
7326
|
+
actionKey: "lead-gen.company.website-extract",
|
|
7327
|
+
defaultBatchSize: 50,
|
|
7328
|
+
maxBatchSize: 100,
|
|
7329
|
+
recordColumns: DTC_RECORD_COLUMNS.extracted
|
|
7330
|
+
},
|
|
7331
|
+
scoreDtcFit: {
|
|
7332
|
+
id: "score-dtc-fit",
|
|
7333
|
+
label: "Companies qualified",
|
|
7334
|
+
description: "Classify subscription potential, consumable-product fit, retention maturity, and disqualifiers.",
|
|
7335
|
+
primaryEntity: "company",
|
|
7336
|
+
outputs: ["company"],
|
|
7337
|
+
stageKey: "qualified",
|
|
7338
|
+
dependsOn: ["analyze-websites"],
|
|
7339
|
+
dependencyMode: "per-record-eligibility",
|
|
7340
|
+
actionKey: "lead-gen.company.dtc-subscription-qualify",
|
|
7341
|
+
defaultBatchSize: 100,
|
|
7342
|
+
maxBatchSize: 250,
|
|
7343
|
+
recordColumns: DTC_RECORD_COLUMNS.qualified
|
|
7344
|
+
},
|
|
7345
|
+
enrichDecisionMakers: {
|
|
7346
|
+
id: "enrich-decision-makers",
|
|
7347
|
+
label: "Decision-makers found",
|
|
7348
|
+
description: "Use Apollo to find qualified contacts at qualified companies - founders, retention leads, lifecycle leads, and marketing owners.",
|
|
7349
|
+
primaryEntity: "company",
|
|
7350
|
+
outputs: ["contact"],
|
|
7351
|
+
stageKey: "decision-makers-enriched",
|
|
7352
|
+
recordEntity: "contact",
|
|
7353
|
+
dependsOn: ["score-dtc-fit"],
|
|
7354
|
+
dependencyMode: "per-record-eligibility",
|
|
7355
|
+
actionKey: "lead-gen.contact.apollo-decision-maker-enrich",
|
|
7356
|
+
defaultBatchSize: 100,
|
|
7357
|
+
maxBatchSize: 250,
|
|
7358
|
+
recordColumns: DTC_RECORD_COLUMNS.decisionMakers,
|
|
7359
|
+
credentialRequirements: [
|
|
7360
|
+
{
|
|
7361
|
+
key: "apollo",
|
|
7362
|
+
provider: "apollo",
|
|
7363
|
+
credentialType: "api-key-secret",
|
|
7364
|
+
label: "Apollo API key",
|
|
7365
|
+
required: true,
|
|
7366
|
+
selectionMode: "single",
|
|
7367
|
+
inputPath: "credential"
|
|
7368
|
+
}
|
|
7369
|
+
]
|
|
7370
|
+
},
|
|
7371
|
+
reviewAndExport: {
|
|
7372
|
+
id: "review-and-export",
|
|
7373
|
+
label: "Reviewed and exported",
|
|
7374
|
+
description: "Operator QC approves or rejects qualified companies, then approved records are exported as a lead list with unverified emails.",
|
|
7375
|
+
primaryEntity: "company",
|
|
7376
|
+
outputs: ["export"],
|
|
7377
|
+
stageKey: "uploaded",
|
|
7378
|
+
recordsStageKey: "uploaded",
|
|
7379
|
+
recordSourceStageKey: "qualified",
|
|
7380
|
+
dependsOn: ["enrich-decision-makers"],
|
|
7381
|
+
dependencyMode: "per-record-eligibility",
|
|
7382
|
+
actionKey: "lead-gen.export.list",
|
|
7383
|
+
defaultBatchSize: 100,
|
|
7384
|
+
maxBatchSize: 250,
|
|
7385
|
+
recordColumns: DTC_RECORD_COLUMNS.uploaded,
|
|
7386
|
+
credentialRequirements: [
|
|
7387
|
+
{
|
|
7388
|
+
key: "clickup",
|
|
7389
|
+
provider: "clickup",
|
|
7390
|
+
credentialType: "api-key-secret",
|
|
7391
|
+
label: "ClickUp API token",
|
|
7392
|
+
required: true,
|
|
7393
|
+
selectionMode: "single",
|
|
7394
|
+
inputPath: "clickupCredential",
|
|
7395
|
+
verifyOnRun: true
|
|
7396
|
+
}
|
|
7397
|
+
]
|
|
7398
|
+
}
|
|
7399
|
+
}
|
|
7400
|
+
};
|
|
7401
|
+
|
|
7402
|
+
// ../core/src/business/acquisition/build-templates.ts
|
|
7403
|
+
var BUILD_TEMPLATE_CATALOG = [
|
|
7404
|
+
{
|
|
7405
|
+
id: "local-services",
|
|
7406
|
+
label: "Local Services",
|
|
7407
|
+
description: "Source, analyze, qualify, and personalize local service businesses for outreach.",
|
|
7408
|
+
steps: Object.values(PROSPECTING_STEPS.localServices)
|
|
7409
|
+
},
|
|
7410
|
+
{
|
|
7411
|
+
id: "dtc-subscription-apollo-clickup",
|
|
7412
|
+
label: "DTC Subscription (Apollo + ClickUp)",
|
|
7413
|
+
description: "Import DTC brand leads from Apollo, crawl their websites, score fit, enrich contacts, and export via ClickUp.",
|
|
7414
|
+
steps: Object.values(PROSPECTING_STEPS.dtcApolloClickup)
|
|
7415
|
+
}
|
|
7416
|
+
];
|
|
7417
|
+
var PROSPECTING_BUILD_TEMPLATE_OPTIONS = BUILD_TEMPLATE_CATALOG.map(({ id, label, description }) => ({
|
|
7418
|
+
id,
|
|
7419
|
+
label,
|
|
7420
|
+
description
|
|
7421
|
+
}));
|
|
7422
|
+
function isProspectingBuildTemplateId(value) {
|
|
7423
|
+
return PROSPECTING_BUILD_TEMPLATE_OPTIONS.some((template) => template.id === value);
|
|
7424
|
+
}
|
|
7425
|
+
|
|
7426
|
+
// ../core/src/organization-model/catalogs/lead-gen.ts
|
|
7427
|
+
var LEAD_GEN_STAGE_CATALOG = {
|
|
7428
|
+
// Prospecting - company population
|
|
7429
|
+
scraped: {
|
|
7430
|
+
key: "scraped",
|
|
7431
|
+
label: "Scraped",
|
|
7432
|
+
description: "Company was scraped from a source directory (Apify actor run).",
|
|
7433
|
+
order: 1,
|
|
7434
|
+
entity: "company"
|
|
7435
|
+
},
|
|
7436
|
+
populated: {
|
|
7437
|
+
key: "populated",
|
|
7438
|
+
label: "Companies found",
|
|
7439
|
+
description: "Companies have been found and added to the lead-gen list.",
|
|
7440
|
+
order: 2,
|
|
7441
|
+
entity: "company"
|
|
7442
|
+
},
|
|
7443
|
+
crawled: {
|
|
7444
|
+
key: "crawled",
|
|
7445
|
+
label: "Websites crawled",
|
|
7446
|
+
description: "Company websites have been crawled (e.g. via Apify) and raw page content stored for downstream LLM analysis.",
|
|
7447
|
+
order: 2.5,
|
|
7448
|
+
entity: "company"
|
|
7449
|
+
},
|
|
7450
|
+
extracted: {
|
|
7451
|
+
key: "extracted",
|
|
7452
|
+
label: "Websites analyzed",
|
|
7453
|
+
description: "Company websites have been analyzed for business signals.",
|
|
7454
|
+
order: 3,
|
|
7455
|
+
entity: "company"
|
|
7456
|
+
},
|
|
7457
|
+
enriched: {
|
|
7458
|
+
key: "enriched",
|
|
7459
|
+
label: "Enriched",
|
|
7460
|
+
description: "Company or contact enriched with third-party data (e.g. Tomba, Anymailfinder).",
|
|
7461
|
+
order: 4,
|
|
7462
|
+
entity: "company"
|
|
7463
|
+
},
|
|
7464
|
+
"decision-makers-enriched": {
|
|
7465
|
+
key: "decision-makers-enriched",
|
|
7466
|
+
label: "Decision-makers found",
|
|
7467
|
+
description: "Decision-maker contacts discovered and attached to a qualified company.",
|
|
7468
|
+
order: 6,
|
|
7469
|
+
entity: "company",
|
|
7470
|
+
recordEntity: "contact",
|
|
7471
|
+
recordStageKey: "discovered"
|
|
7472
|
+
},
|
|
7473
|
+
// Prospecting - contact discovery
|
|
7474
|
+
discovered: {
|
|
7475
|
+
key: "discovered",
|
|
7476
|
+
label: "Decision-makers found",
|
|
7477
|
+
description: "Decision-maker contact details have been found.",
|
|
7478
|
+
order: 5,
|
|
7479
|
+
entity: "contact"
|
|
7480
|
+
},
|
|
7481
|
+
verified: {
|
|
7482
|
+
key: "verified",
|
|
7483
|
+
label: "Emails verified",
|
|
7484
|
+
description: "Contact email addresses have been checked for deliverability.",
|
|
7485
|
+
order: 7,
|
|
7486
|
+
entity: "contact"
|
|
7487
|
+
},
|
|
7488
|
+
// Qualification
|
|
7489
|
+
qualified: {
|
|
7490
|
+
key: "qualified",
|
|
7491
|
+
label: "Companies qualified",
|
|
7492
|
+
description: "Companies have been scored against the qualification criteria.",
|
|
7493
|
+
order: 8,
|
|
7494
|
+
entity: "company"
|
|
7495
|
+
},
|
|
7496
|
+
// Outreach
|
|
7497
|
+
personalized: {
|
|
7498
|
+
key: "personalized",
|
|
7499
|
+
label: "Personalized",
|
|
7500
|
+
description: "Outreach message personalized for the contact (Instantly personalization workflow).",
|
|
7501
|
+
order: 9,
|
|
7502
|
+
entity: "contact"
|
|
7503
|
+
},
|
|
7504
|
+
uploaded: {
|
|
7505
|
+
key: "uploaded",
|
|
7506
|
+
label: "Reviewed and exported",
|
|
7507
|
+
description: "Approved records have been reviewed and exported for handoff.",
|
|
7508
|
+
order: 10,
|
|
7509
|
+
entity: "company",
|
|
7510
|
+
additionalEntities: ["contact"]
|
|
7511
|
+
},
|
|
7512
|
+
interested: {
|
|
7513
|
+
key: "interested",
|
|
7514
|
+
label: "Interested",
|
|
7515
|
+
description: "Contact replied with a positive signal (Instantly reply-handler transition).",
|
|
7516
|
+
order: 11,
|
|
7517
|
+
entity: "contact"
|
|
7518
|
+
}
|
|
7519
|
+
};
|
|
7520
|
+
|
|
7521
|
+
// ../core/src/organization-model/domains/sales.ts
|
|
7522
|
+
var SalesStageSemanticClassSchema = z.enum(["open", "active", "nurturing", "closed_won", "closed_lost"]);
|
|
7523
|
+
var SalesStageSchema = DisplayMetadataSchema.extend({
|
|
7524
|
+
id: ModelIdSchema,
|
|
7525
|
+
order: z.number().int().min(0),
|
|
7526
|
+
semanticClass: SalesStageSemanticClassSchema,
|
|
7527
|
+
surfaceIds: ReferenceIdsSchema,
|
|
7528
|
+
resourceIds: ReferenceIdsSchema
|
|
7529
|
+
});
|
|
7530
|
+
z.object({
|
|
7531
|
+
id: ModelIdSchema,
|
|
7532
|
+
label: z.string().trim().min(1).max(120),
|
|
7533
|
+
description: DescriptionSchema.optional(),
|
|
7534
|
+
entityId: ModelIdSchema,
|
|
7535
|
+
stages: z.array(SalesStageSchema).min(1)
|
|
7536
|
+
});
|
|
7537
|
+
var CRM_DISCOVERY_REPLIED_STATE = {
|
|
7538
|
+
stateKey: "discovery_replied",
|
|
7539
|
+
label: "Discovery Replied"
|
|
7540
|
+
};
|
|
7541
|
+
var CRM_DISCOVERY_LINK_SENT_STATE = {
|
|
7542
|
+
stateKey: "discovery_link_sent",
|
|
7543
|
+
label: "Discovery Link Sent"
|
|
7544
|
+
};
|
|
7545
|
+
var CRM_DISCOVERY_NUDGING_STATE = {
|
|
7546
|
+
stateKey: "discovery_nudging",
|
|
7547
|
+
label: "Discovery Nudging"
|
|
7548
|
+
};
|
|
7549
|
+
var CRM_DISCOVERY_BOOKING_CANCELLED_STATE = {
|
|
7550
|
+
stateKey: "discovery_booking_cancelled",
|
|
7551
|
+
label: "Discovery Booking Cancelled"
|
|
7552
|
+
};
|
|
7553
|
+
var CRM_REPLY_SENT_STATE = {
|
|
7554
|
+
stateKey: "reply_sent",
|
|
7555
|
+
label: "Reply Sent"
|
|
7556
|
+
};
|
|
7557
|
+
var CRM_FOLLOWUP_1_SENT_STATE = {
|
|
7558
|
+
stateKey: "followup_1_sent",
|
|
7559
|
+
label: "Follow-up 1 Sent"
|
|
7560
|
+
};
|
|
7561
|
+
var CRM_FOLLOWUP_2_SENT_STATE = {
|
|
7562
|
+
stateKey: "followup_2_sent",
|
|
7563
|
+
label: "Follow-up 2 Sent"
|
|
7564
|
+
};
|
|
7565
|
+
var CRM_FOLLOWUP_3_SENT_STATE = {
|
|
7566
|
+
stateKey: "followup_3_sent",
|
|
7567
|
+
label: "Follow-up 3 Sent"
|
|
7568
|
+
};
|
|
7569
|
+
var CRM_PIPELINE_DEFINITION = {
|
|
7570
|
+
pipelineKey: "crm",
|
|
7571
|
+
label: "CRM",
|
|
7572
|
+
entityKey: "crm.deal",
|
|
7573
|
+
stages: [
|
|
7574
|
+
{
|
|
7575
|
+
stageKey: "interested",
|
|
7576
|
+
label: "Interested",
|
|
7577
|
+
color: "blue",
|
|
7578
|
+
states: [
|
|
7579
|
+
CRM_DISCOVERY_REPLIED_STATE,
|
|
7580
|
+
CRM_DISCOVERY_LINK_SENT_STATE,
|
|
7581
|
+
CRM_DISCOVERY_NUDGING_STATE,
|
|
7582
|
+
CRM_DISCOVERY_BOOKING_CANCELLED_STATE,
|
|
7583
|
+
CRM_REPLY_SENT_STATE,
|
|
7584
|
+
CRM_FOLLOWUP_1_SENT_STATE,
|
|
7585
|
+
CRM_FOLLOWUP_2_SENT_STATE,
|
|
7586
|
+
CRM_FOLLOWUP_3_SENT_STATE
|
|
7587
|
+
]
|
|
7588
|
+
},
|
|
7589
|
+
{ stageKey: "proposal", label: "Proposal", color: "yellow", states: [] },
|
|
7590
|
+
{ stageKey: "closing", label: "Closing", color: "orange", states: [] },
|
|
7591
|
+
{ stageKey: "closed_won", label: "Closed Won", color: "green", states: [] },
|
|
7592
|
+
{ stageKey: "closed_lost", label: "Closed Lost", color: "red", states: [] },
|
|
7593
|
+
{ stageKey: "nurturing", label: "Nurturing", color: "grape", states: [] }
|
|
7594
|
+
]
|
|
7595
|
+
};
|
|
7596
|
+
var OrganizationModelBrandingSchema = z.object({
|
|
7597
|
+
organizationName: LabelSchema,
|
|
7598
|
+
productName: LabelSchema,
|
|
7599
|
+
shortName: z.string().trim().min(1).max(40),
|
|
7600
|
+
description: DescriptionSchema.optional(),
|
|
7601
|
+
logos: z.object({
|
|
7602
|
+
light: z.string().trim().min(1).max(2048).optional(),
|
|
7603
|
+
dark: z.string().trim().min(1).max(2048).optional()
|
|
7604
|
+
}).default({})
|
|
7605
|
+
});
|
|
7606
|
+
var DEFAULT_ORGANIZATION_MODEL_BRANDING = {
|
|
7607
|
+
organizationName: "Default Organization",
|
|
7608
|
+
productName: "Elevasis",
|
|
7609
|
+
shortName: "Elevasis",
|
|
7610
|
+
logos: {}
|
|
7611
|
+
};
|
|
7612
|
+
var BusinessHoursDaySchema = z.object({
|
|
7613
|
+
open: z.string().trim().regex(/^\d{2}:\d{2}$/, "Expected HH:MM format"),
|
|
7614
|
+
close: z.string().trim().regex(/^\d{2}:\d{2}$/, "Expected HH:MM format")
|
|
7615
|
+
});
|
|
7616
|
+
var BusinessHoursSchema = z.object({
|
|
7617
|
+
monday: BusinessHoursDaySchema.optional(),
|
|
7618
|
+
tuesday: BusinessHoursDaySchema.optional(),
|
|
7619
|
+
wednesday: BusinessHoursDaySchema.optional(),
|
|
7620
|
+
thursday: BusinessHoursDaySchema.optional(),
|
|
7621
|
+
friday: BusinessHoursDaySchema.optional(),
|
|
7622
|
+
saturday: BusinessHoursDaySchema.optional(),
|
|
7623
|
+
sunday: BusinessHoursDaySchema.optional()
|
|
7624
|
+
}).default({});
|
|
7625
|
+
var IdentityDomainSchema = z.object({
|
|
7626
|
+
/** Why the organization exists — one or two plain-language sentences. */
|
|
7627
|
+
mission: z.string().trim().max(1e3).default(""),
|
|
7628
|
+
/** Long-term direction the organization is moving toward. */
|
|
7629
|
+
vision: z.string().trim().max(1e3).default(""),
|
|
7630
|
+
/** Legal registered name of the entity. */
|
|
7631
|
+
legalName: z.string().trim().max(200).default(""),
|
|
7632
|
+
/**
|
|
7633
|
+
* Type of legal entity (e.g. "LLC", "Corporation", "Sole Proprietor",
|
|
7634
|
+
* "Non-profit"). Free-form string so it covers any jurisdiction.
|
|
7635
|
+
*/
|
|
7636
|
+
entityType: z.string().trim().max(100).default(""),
|
|
7637
|
+
/**
|
|
7638
|
+
* Primary jurisdiction of registration or operation
|
|
7639
|
+
* (e.g. "United States – Delaware", "Canada – Ontario").
|
|
7640
|
+
*/
|
|
7641
|
+
jurisdiction: z.string().trim().max(200).default(""),
|
|
7642
|
+
/**
|
|
7643
|
+
* Industry category — broad classification (e.g. "Marketing Agency",
|
|
7644
|
+
* "Software / SaaS", "Professional Services").
|
|
7645
|
+
*/
|
|
7646
|
+
industryCategory: z.string().trim().max(200).default(""),
|
|
7647
|
+
/**
|
|
7648
|
+
* Geographic focus — where the organization primarily operates or serves
|
|
7649
|
+
* (e.g. "North America", "Global", "Southeast Asia").
|
|
7650
|
+
*/
|
|
7651
|
+
geographicFocus: z.string().trim().max(200).default(""),
|
|
7652
|
+
/**
|
|
7653
|
+
* IANA timezone identifier for the organization's primary operating timezone
|
|
7654
|
+
* (e.g. "America/Los_Angeles", "Europe/London", "UTC").
|
|
7655
|
+
*/
|
|
7656
|
+
timeZone: z.string().trim().max(100).default("UTC"),
|
|
7657
|
+
/** Typical operating hours per day of week. Empty object means not configured. */
|
|
7658
|
+
businessHours: BusinessHoursSchema,
|
|
7659
|
+
/**
|
|
7660
|
+
* Long-form markdown capturing client context, problem narrative, and domain
|
|
7661
|
+
* background. Populated by /setup; surfaced to agents as organizational context.
|
|
7662
|
+
* Optional — many projects have no external client.
|
|
7663
|
+
*/
|
|
7664
|
+
clientBrief: z.string().trim().default("")
|
|
7665
|
+
});
|
|
7666
|
+
var DEFAULT_ORGANIZATION_MODEL_IDENTITY = {
|
|
7667
|
+
mission: "",
|
|
7668
|
+
vision: "",
|
|
7669
|
+
legalName: "",
|
|
7670
|
+
entityType: "",
|
|
7671
|
+
jurisdiction: "",
|
|
7672
|
+
industryCategory: "",
|
|
7673
|
+
geographicFocus: "",
|
|
7674
|
+
timeZone: "UTC",
|
|
7675
|
+
businessHours: {},
|
|
7676
|
+
clientBrief: ""
|
|
7677
|
+
};
|
|
7678
|
+
var FirmographicsSchema = z.object({
|
|
7679
|
+
/** Industry vertical (e.g. "Marketing Agency", "Legal", "Real Estate"). */
|
|
7680
|
+
industry: z.string().trim().max(200).optional(),
|
|
7681
|
+
/**
|
|
7682
|
+
* Company headcount band (e.g. "1–10", "11–50", "51–200", "200+").
|
|
7683
|
+
* Free-form string to accommodate any band notation.
|
|
7684
|
+
*/
|
|
7685
|
+
companySize: z.string().trim().max(100).optional(),
|
|
7686
|
+
/**
|
|
7687
|
+
* Primary geographic region the segment operates in or is targeted from
|
|
7688
|
+
* (e.g. "North America", "Europe", "Global").
|
|
7689
|
+
*/
|
|
7690
|
+
region: z.string().trim().max(200).optional()
|
|
7691
|
+
});
|
|
7692
|
+
var CustomerSegmentSchema = z.object({
|
|
7693
|
+
/** Stable unique identifier for the segment (e.g. "segment-smb-agencies"). */
|
|
7694
|
+
id: z.string().trim().min(1).max(100),
|
|
7695
|
+
/** Domain-map iteration order. Convention: multiples of 10 (10, 20, 30, ...) to allow easy insertion. */
|
|
7696
|
+
order: z.number(),
|
|
7697
|
+
/** Human-readable name shown to agents and in UI (e.g. "SMB Marketing Agencies"). */
|
|
7698
|
+
name: z.string().trim().max(200).default(""),
|
|
7699
|
+
/** One or two sentences describing who this segment is. */
|
|
7700
|
+
description: z.string().trim().max(2e3).default(""),
|
|
7701
|
+
/**
|
|
7702
|
+
* The primary job(s) this segment is trying to get done — the goal they hire
|
|
7703
|
+
* a product/service to accomplish. Plain-language narrative or bullet list.
|
|
7704
|
+
*/
|
|
7705
|
+
jobsToBeDone: z.string().trim().max(2e3).default(""),
|
|
7706
|
+
/**
|
|
7707
|
+
* Pains — frustrations, obstacles, and risks the segment experiences
|
|
7708
|
+
* when trying to accomplish their jobs-to-be-done.
|
|
7709
|
+
*/
|
|
7710
|
+
pains: z.array(z.string().trim().max(500)).default([]),
|
|
7711
|
+
/**
|
|
7712
|
+
* Gains — outcomes and benefits the segment desires; positive motivators
|
|
7713
|
+
* beyond merely resolving pains.
|
|
7714
|
+
*/
|
|
7715
|
+
gains: z.array(z.string().trim().max(500)).default([]),
|
|
7716
|
+
/** Firmographic profile for targeting and filtering. */
|
|
7717
|
+
firmographics: FirmographicsSchema.default({}),
|
|
7718
|
+
/**
|
|
7719
|
+
* Value proposition — one or two sentences stating why this organization's
|
|
7720
|
+
* offering is uniquely suited for this segment's needs.
|
|
7721
|
+
*/
|
|
7722
|
+
valueProp: z.string().trim().max(2e3).default("")
|
|
7723
|
+
});
|
|
7724
|
+
var CustomersDomainSchema = z.record(z.string(), CustomerSegmentSchema).refine((record) => Object.entries(record).every(([key, entry]) => entry.id === key), {
|
|
7725
|
+
message: "Each segment entry id must match its map key"
|
|
7726
|
+
}).default({});
|
|
7727
|
+
var DEFAULT_ORGANIZATION_MODEL_CUSTOMERS = {};
|
|
7728
|
+
var PricingModelSchema = z.enum(["one-time", "subscription", "usage-based", "custom"]).meta({ label: "Pricing model", color: "green" });
|
|
7729
|
+
var ProductSchema = z.object({
|
|
7730
|
+
/** Stable unique identifier for the product (e.g. "product-starter-plan"). */
|
|
7731
|
+
id: z.string().trim().min(1).max(100),
|
|
7732
|
+
/** Domain-map iteration order. Convention: multiples of 10 (10, 20, 30, ...) to allow easy insertion. */
|
|
7733
|
+
order: z.number(),
|
|
7734
|
+
/** Human-readable name shown to agents and in UI (e.g. "Starter Plan"). */
|
|
7735
|
+
name: z.string().trim().max(200).default(""),
|
|
7736
|
+
/** One or two sentences describing what this product/service delivers. */
|
|
7737
|
+
description: z.string().trim().max(2e3).default(""),
|
|
7738
|
+
/**
|
|
7739
|
+
* How this product is priced:
|
|
7740
|
+
* - "one-time" — single purchase (setup fee, project fee)
|
|
7741
|
+
* - "subscription" — recurring (monthly/annual SaaS, retainer)
|
|
7742
|
+
* - "usage-based" — metered by consumption (API calls, seats)
|
|
7743
|
+
* - "custom" — negotiated or bespoke pricing
|
|
7744
|
+
*/
|
|
7745
|
+
pricingModel: PricingModelSchema.default("custom"),
|
|
7746
|
+
/** Base price amount (≥ 0). Currency unit defined by `currency`. */
|
|
7747
|
+
price: z.number().min(0).default(0),
|
|
7748
|
+
/**
|
|
7749
|
+
* ISO 4217 currency code (e.g. "USD", "EUR", "GBP").
|
|
7750
|
+
* Free-form string to accommodate any currency; defaults to "USD".
|
|
7751
|
+
*/
|
|
7752
|
+
currency: z.string().trim().max(10).default("USD"),
|
|
7753
|
+
/**
|
|
7754
|
+
* IDs of customer segments this product targets.
|
|
7755
|
+
* Each id must reference a declared `customers.segments[].id`.
|
|
7756
|
+
* Cross-reference enforced in `OrganizationModelSchema.superRefine()`.
|
|
7757
|
+
*/
|
|
7758
|
+
targetSegmentIds: z.array(z.string().trim().min(1)).default([]),
|
|
7759
|
+
/**
|
|
7760
|
+
* Optional: ID of the platform system responsible for delivering this product.
|
|
7761
|
+
* When present, must reference a declared `systems.systems[].id`.
|
|
7762
|
+
* Cross-reference enforced in `OrganizationModelSchema.superRefine()`.
|
|
7763
|
+
*/
|
|
7764
|
+
deliveryFeatureId: z.string().trim().min(1).optional()
|
|
7765
|
+
});
|
|
7766
|
+
var OfferingsDomainSchema = z.record(z.string(), ProductSchema).refine((record) => Object.entries(record).every(([key, entry]) => entry.id === key), {
|
|
7767
|
+
message: "Each product entry id must match its map key"
|
|
7768
|
+
}).default({});
|
|
7769
|
+
var DEFAULT_ORGANIZATION_MODEL_OFFERINGS = {};
|
|
7770
|
+
var ContentNodeBaseSchema = z.object({
|
|
7771
|
+
/** Human-readable label for the content node. */
|
|
7772
|
+
label: z.string().trim().min(1).max(120).meta({ label: "Label" }),
|
|
7773
|
+
/** Optional one-paragraph description. */
|
|
7774
|
+
description: z.string().trim().min(1).max(2e3).optional().meta({ label: "Description" }),
|
|
7775
|
+
/** Optional display order within the system content map. */
|
|
7776
|
+
order: z.number().int().optional().meta({ label: "Order" }),
|
|
7777
|
+
/**
|
|
7778
|
+
* Local NodeId of the parent content node within the SAME system.
|
|
7779
|
+
* Per B4/L9: MUST resolve to a sibling in the same `system.content` map.
|
|
7780
|
+
* Per L19: parent and child MUST share the same `kind` (meta-category).
|
|
7781
|
+
*/
|
|
7782
|
+
parentContentId: z.string().trim().min(1).max(200).optional().meta({ label: "Parent content id" })
|
|
7783
|
+
});
|
|
7784
|
+
var ContentNodeSchema = ContentNodeBaseSchema.extend({
|
|
7785
|
+
/** Meta-category (e.g. 'schema', 'config', 'knowledge', tenant-defined). */
|
|
7786
|
+
kind: z.string().trim().min(1).max(100).meta({ label: "Kind" }),
|
|
7787
|
+
/** Specific family within the meta-category (e.g. 'pipeline', 'kv'). */
|
|
7788
|
+
type: z.string().trim().min(1).max(100).meta({ label: "Type" }),
|
|
7789
|
+
/** Payload data; validated against registered payloadSchema when (kind, type) is known. */
|
|
7790
|
+
data: z.record(z.string(), z.unknown()).optional().meta({ label: "Data" })
|
|
7791
|
+
});
|
|
7792
|
+
z.object({
|
|
7793
|
+
/** Meta-category (tenant-defined or registry-shipped). */
|
|
7794
|
+
kind: z.string().trim().min(1).max(100).meta({ label: "Kind" }),
|
|
7795
|
+
/** Specific family within the meta-category. */
|
|
7796
|
+
type: z.string().trim().min(1).max(100).meta({ label: "Type" }),
|
|
7797
|
+
/** Human-readable label shown in the KB tree and describe views. */
|
|
7798
|
+
label: z.string().trim().min(1).max(120).meta({ label: "Label" }),
|
|
7799
|
+
/** Optional description. */
|
|
7800
|
+
description: z.string().trim().min(1).max(2e3).optional().meta({ label: "Description" }),
|
|
7801
|
+
/**
|
|
7802
|
+
* Which KB tree group this extension renders in.
|
|
7803
|
+
* Per L6: 'business-model' places it alongside Customers / Offerings / Goals.
|
|
7804
|
+
*/
|
|
7805
|
+
treeGroup: z.union([z.enum(["profile", "business-model", "systems", "graph", "governance-wiring"]), z.string().min(1).max(100)]).meta({ label: "Tree group" }),
|
|
7806
|
+
/** Untyped payload; shape governed by the registered payloadSchema when available. */
|
|
7807
|
+
data: z.record(z.string(), z.unknown()).optional().meta({ label: "Data" })
|
|
7808
|
+
});
|
|
7809
|
+
var OntologyKindSchema = z.enum([
|
|
7810
|
+
"object",
|
|
7811
|
+
"link",
|
|
7812
|
+
"action",
|
|
7813
|
+
"catalog",
|
|
7814
|
+
"event",
|
|
7815
|
+
"interface",
|
|
7816
|
+
"value-type",
|
|
7817
|
+
"property",
|
|
7818
|
+
"group",
|
|
7819
|
+
"surface"
|
|
7820
|
+
]);
|
|
7821
|
+
var SYSTEM_PATH_PATTERN = "[a-z0-9][a-z0-9-]*(?:\\.[a-z0-9][a-z0-9-]*)*";
|
|
7822
|
+
var LOCAL_ID_PATTERN = "[a-z0-9][a-z0-9._-]*";
|
|
7823
|
+
var ONTOLOGY_ID_PATTERN = `^(global|${SYSTEM_PATH_PATTERN}):(${OntologyKindSchema.options.join("|")})\\/(${LOCAL_ID_PATTERN})$`;
|
|
7824
|
+
var ONTOLOGY_ID_REGEX = new RegExp(ONTOLOGY_ID_PATTERN);
|
|
7825
|
+
var OntologyIdSchema = z.string().trim().min(1).max(300).regex(
|
|
7826
|
+
ONTOLOGY_ID_REGEX,
|
|
7827
|
+
"Ontology IDs must use <system-path>:<kind>/<local-id> or global:<kind>/<local-id>"
|
|
7828
|
+
);
|
|
7829
|
+
function parseOntologyId(id) {
|
|
7830
|
+
const normalized = OntologyIdSchema.parse(id);
|
|
7831
|
+
const match = ONTOLOGY_ID_REGEX.exec(normalized);
|
|
7832
|
+
if (match === null) {
|
|
7833
|
+
throw new Error(`Invalid ontology ID "${id}"`);
|
|
7834
|
+
}
|
|
7835
|
+
return {
|
|
7836
|
+
id: normalized,
|
|
7837
|
+
scope: match[1],
|
|
7838
|
+
kind: match[2],
|
|
7839
|
+
localId: match[3],
|
|
7840
|
+
isGlobal: match[1] === "global"
|
|
7841
|
+
};
|
|
7842
|
+
}
|
|
7843
|
+
function formatOntologyId(input) {
|
|
7844
|
+
return OntologyIdSchema.parse(`${input.scope}:${input.kind}/${input.localId}`);
|
|
7845
|
+
}
|
|
7846
|
+
var OntologyReferenceListSchema = z.array(OntologyIdSchema).default([]).optional();
|
|
7847
|
+
var OntologyRecordBaseSchema = z.object({
|
|
7848
|
+
id: OntologyIdSchema,
|
|
7849
|
+
label: z.string().trim().min(1).max(160).optional(),
|
|
7850
|
+
description: z.string().trim().min(1).max(2e3).optional(),
|
|
7851
|
+
ownerSystemId: z.string().trim().min(1).max(200).optional(),
|
|
7852
|
+
aliases: z.array(OntologyIdSchema).optional()
|
|
7853
|
+
}).passthrough();
|
|
7854
|
+
var OntologyObjectTypeSchema = OntologyRecordBaseSchema.extend({
|
|
7855
|
+
properties: z.record(z.string().trim().min(1).max(200), z.unknown()).optional(),
|
|
7856
|
+
storage: z.record(z.string(), z.unknown()).optional()
|
|
7857
|
+
});
|
|
7858
|
+
var OntologyLinkTypeSchema = OntologyRecordBaseSchema.extend({
|
|
7859
|
+
from: OntologyIdSchema,
|
|
7860
|
+
to: OntologyIdSchema,
|
|
7861
|
+
cardinality: z.string().trim().min(1).max(80).optional(),
|
|
7862
|
+
via: z.string().trim().min(1).max(255).optional()
|
|
7863
|
+
});
|
|
7864
|
+
var OntologyActionTypeSchema = OntologyRecordBaseSchema.extend({
|
|
7865
|
+
actsOn: OntologyReferenceListSchema,
|
|
7866
|
+
input: z.record(z.string().trim().min(1).max(200), z.unknown()).optional(),
|
|
7867
|
+
effects: z.array(z.record(z.string(), z.unknown())).optional()
|
|
7868
|
+
});
|
|
7869
|
+
var OntologyCatalogTypeSchema = OntologyRecordBaseSchema.extend({
|
|
7870
|
+
kind: z.string().trim().min(1).max(120).optional(),
|
|
7871
|
+
appliesTo: OntologyIdSchema.optional(),
|
|
7872
|
+
entries: z.record(z.string().trim().min(1).max(200), z.unknown()).optional()
|
|
7873
|
+
});
|
|
7874
|
+
var OntologyEventTypeSchema = OntologyRecordBaseSchema.extend({
|
|
7875
|
+
payload: z.record(z.string().trim().min(1).max(200), z.unknown()).optional()
|
|
7876
|
+
});
|
|
7877
|
+
var OntologyInterfaceTypeSchema = OntologyRecordBaseSchema.extend({
|
|
7878
|
+
properties: z.record(z.string().trim().min(1).max(200), z.unknown()).optional()
|
|
7879
|
+
});
|
|
7880
|
+
var OntologyValueTypeSchema = OntologyRecordBaseSchema.extend({
|
|
7881
|
+
primitive: z.string().trim().min(1).max(120).optional()
|
|
7882
|
+
});
|
|
7883
|
+
var OntologySharedPropertySchema = OntologyRecordBaseSchema.extend({
|
|
7884
|
+
valueType: OntologyIdSchema.optional(),
|
|
7885
|
+
searchable: z.boolean().optional(),
|
|
7886
|
+
pii: z.boolean().optional()
|
|
7887
|
+
});
|
|
7888
|
+
var OntologyGroupSchema = OntologyRecordBaseSchema.extend({
|
|
7889
|
+
members: OntologyReferenceListSchema
|
|
7890
|
+
});
|
|
7891
|
+
var OntologySurfaceTypeSchema = OntologyRecordBaseSchema.extend({
|
|
7892
|
+
route: z.string().trim().min(1).max(500).optional()
|
|
7893
|
+
});
|
|
7894
|
+
var OntologyScopeSchema = z.object({
|
|
7895
|
+
objectTypes: z.record(OntologyIdSchema, OntologyObjectTypeSchema).default({}).optional(),
|
|
7896
|
+
linkTypes: z.record(OntologyIdSchema, OntologyLinkTypeSchema).default({}).optional(),
|
|
7897
|
+
actionTypes: z.record(OntologyIdSchema, OntologyActionTypeSchema).default({}).optional(),
|
|
7898
|
+
catalogTypes: z.record(OntologyIdSchema, OntologyCatalogTypeSchema).default({}).optional(),
|
|
7899
|
+
eventTypes: z.record(OntologyIdSchema, OntologyEventTypeSchema).default({}).optional(),
|
|
7900
|
+
interfaceTypes: z.record(OntologyIdSchema, OntologyInterfaceTypeSchema).default({}).optional(),
|
|
7901
|
+
valueTypes: z.record(OntologyIdSchema, OntologyValueTypeSchema).default({}).optional(),
|
|
7902
|
+
sharedProperties: z.record(OntologyIdSchema, OntologySharedPropertySchema).default({}).optional(),
|
|
7903
|
+
groups: z.record(OntologyIdSchema, OntologyGroupSchema).default({}).optional(),
|
|
7904
|
+
surfaces: z.record(OntologyIdSchema, OntologySurfaceTypeSchema).default({}).optional()
|
|
7905
|
+
}).default({});
|
|
7906
|
+
var DEFAULT_ONTOLOGY_SCOPE = {
|
|
7907
|
+
valueTypes: {
|
|
7908
|
+
"global:value-type/uuid": {
|
|
7909
|
+
id: "global:value-type/uuid",
|
|
7910
|
+
label: "UUID",
|
|
7911
|
+
primitive: "string"
|
|
7912
|
+
},
|
|
7913
|
+
"global:value-type/text": {
|
|
7914
|
+
id: "global:value-type/text",
|
|
7915
|
+
label: "Text",
|
|
7916
|
+
primitive: "string"
|
|
7917
|
+
},
|
|
7918
|
+
"global:value-type/url": {
|
|
7919
|
+
id: "global:value-type/url",
|
|
7920
|
+
label: "URL",
|
|
7921
|
+
primitive: "string"
|
|
7922
|
+
},
|
|
7923
|
+
"global:value-type/email": {
|
|
7924
|
+
id: "global:value-type/email",
|
|
7925
|
+
label: "Email",
|
|
7926
|
+
primitive: "string"
|
|
7927
|
+
}
|
|
7928
|
+
}
|
|
7929
|
+
};
|
|
7930
|
+
var SCOPE_KIND = {
|
|
7931
|
+
objectTypes: "object",
|
|
7932
|
+
linkTypes: "link",
|
|
7933
|
+
actionTypes: "action",
|
|
7934
|
+
catalogTypes: "catalog",
|
|
7935
|
+
eventTypes: "event",
|
|
7936
|
+
interfaceTypes: "interface",
|
|
7937
|
+
valueTypes: "value-type",
|
|
7938
|
+
sharedProperties: "property",
|
|
7939
|
+
groups: "group",
|
|
7940
|
+
surfaces: "surface"
|
|
7941
|
+
};
|
|
7942
|
+
var SCOPE_KEYS = Object.keys(SCOPE_KIND);
|
|
7943
|
+
function listResolvedOntologyRecords(index2) {
|
|
7944
|
+
return SCOPE_KEYS.flatMap((scopeKey) => {
|
|
7945
|
+
const kind = SCOPE_KIND[scopeKey];
|
|
7946
|
+
return Object.entries(index2[scopeKey]).sort(([leftId], [rightId]) => leftId.localeCompare(rightId)).map(([id, record]) => ({
|
|
7947
|
+
id,
|
|
7948
|
+
kind,
|
|
7949
|
+
record
|
|
7950
|
+
}));
|
|
7951
|
+
});
|
|
7952
|
+
}
|
|
7953
|
+
function originFromContext(context) {
|
|
7954
|
+
return {
|
|
7955
|
+
kind: context.kind,
|
|
7956
|
+
source: context.source,
|
|
7957
|
+
path: context.path,
|
|
7958
|
+
...context.systemPath !== void 0 ? { systemPath: context.systemPath } : {},
|
|
7959
|
+
...context.legacyId !== void 0 ? { legacyId: context.legacyId } : {}
|
|
7960
|
+
};
|
|
7961
|
+
}
|
|
7962
|
+
function createEmptyIndex() {
|
|
7963
|
+
return {
|
|
7964
|
+
objectTypes: {},
|
|
7965
|
+
linkTypes: {},
|
|
7966
|
+
actionTypes: {},
|
|
7967
|
+
catalogTypes: {},
|
|
7968
|
+
eventTypes: {},
|
|
7969
|
+
interfaceTypes: {},
|
|
7970
|
+
valueTypes: {},
|
|
7971
|
+
sharedProperties: {},
|
|
7972
|
+
groups: {},
|
|
7973
|
+
surfaces: {}
|
|
7974
|
+
};
|
|
7975
|
+
}
|
|
7976
|
+
function sortResolvedOntologyIndex(index2) {
|
|
7977
|
+
const sorted = createEmptyIndex();
|
|
7978
|
+
for (const scopeKey of SCOPE_KEYS) {
|
|
7979
|
+
const target = sorted[scopeKey];
|
|
7980
|
+
for (const [id, record] of Object.entries(index2[scopeKey]).sort(
|
|
7981
|
+
([leftId], [rightId]) => leftId.localeCompare(rightId)
|
|
7982
|
+
)) {
|
|
7983
|
+
target[id] = record;
|
|
7984
|
+
}
|
|
7985
|
+
}
|
|
7986
|
+
return sorted;
|
|
7987
|
+
}
|
|
7988
|
+
function childSystemsOf(system) {
|
|
7989
|
+
return system.systems ?? system.subsystems ?? {};
|
|
7990
|
+
}
|
|
7991
|
+
function addRecord(index2, diagnostics, sourcesById, scopeKey, record, context) {
|
|
7992
|
+
let parsed;
|
|
7993
|
+
try {
|
|
7994
|
+
parsed = parseOntologyId(record.id);
|
|
7995
|
+
} catch {
|
|
7996
|
+
diagnostics.push({
|
|
7997
|
+
code: "invalid_ontology_id",
|
|
7998
|
+
message: `Invalid ontology ID "${record.id}" from ${context.source} at ${context.path.join(".")}`,
|
|
7999
|
+
id: record.id,
|
|
8000
|
+
path: context.path,
|
|
8001
|
+
source: context.source,
|
|
8002
|
+
origin: originFromContext(context)
|
|
8003
|
+
});
|
|
8004
|
+
return;
|
|
8005
|
+
}
|
|
8006
|
+
const expectedKind = SCOPE_KIND[scopeKey];
|
|
8007
|
+
if (parsed.kind !== expectedKind) {
|
|
8008
|
+
diagnostics.push({
|
|
8009
|
+
code: "ontology_kind_mismatch",
|
|
8010
|
+
message: `Ontology ID "${record.id}" has kind "${parsed.kind}" but was authored in ${scopeKey} (${expectedKind}) at ${context.path.join(".")}`,
|
|
8011
|
+
id: record.id,
|
|
8012
|
+
path: context.path,
|
|
8013
|
+
source: context.source,
|
|
8014
|
+
origin: originFromContext(context)
|
|
8015
|
+
});
|
|
8016
|
+
return;
|
|
8017
|
+
}
|
|
8018
|
+
const existing = sourcesById.get(parsed.id);
|
|
8019
|
+
if (existing !== void 0) {
|
|
8020
|
+
diagnostics.push({
|
|
8021
|
+
code: "duplicate_ontology_id",
|
|
8022
|
+
message: `Duplicate ontology ID "${parsed.id}" from ${context.source} at ${context.path.join(".")} conflicts with ${existing.source} at ${existing.path.join(".")}`,
|
|
8023
|
+
id: parsed.id,
|
|
8024
|
+
path: context.path,
|
|
8025
|
+
source: context.source,
|
|
8026
|
+
origin: originFromContext(context),
|
|
8027
|
+
existingSource: existing.source,
|
|
8028
|
+
existingOrigin: originFromContext(existing)
|
|
8029
|
+
});
|
|
8030
|
+
return;
|
|
8031
|
+
}
|
|
8032
|
+
sourcesById.set(parsed.id, context);
|
|
8033
|
+
index2[scopeKey][parsed.id] = {
|
|
8034
|
+
...record,
|
|
8035
|
+
origin: originFromContext(context)
|
|
8036
|
+
};
|
|
8037
|
+
}
|
|
8038
|
+
function addScope(index2, diagnostics, sourcesById, scope, source, path) {
|
|
8039
|
+
if (scope === void 0) return;
|
|
8040
|
+
for (const scopeKey of SCOPE_KEYS) {
|
|
8041
|
+
const records = scope[scopeKey] ?? {};
|
|
8042
|
+
for (const [key, record] of Object.entries(records)) {
|
|
8043
|
+
addRecord(index2, diagnostics, sourcesById, scopeKey, record, {
|
|
8044
|
+
source,
|
|
8045
|
+
path: [...path, scopeKey, key],
|
|
8046
|
+
kind: "authored",
|
|
8047
|
+
systemPath: source.startsWith("system:") ? source.slice("system:".length, -".ontology".length) : void 0
|
|
8048
|
+
});
|
|
8049
|
+
}
|
|
8050
|
+
}
|
|
8051
|
+
}
|
|
8052
|
+
function legacyObjectId(entity) {
|
|
8053
|
+
return formatOntologyId({ scope: entity.ownedBySystemId, kind: "object", localId: entity.id });
|
|
8054
|
+
}
|
|
8055
|
+
function legacyActionOwner(action, entities) {
|
|
8056
|
+
const firstAffectedEntityId = action.affects?.find((entityId) => entities[entityId] !== void 0);
|
|
8057
|
+
if (firstAffectedEntityId !== void 0) {
|
|
8058
|
+
return entities[firstAffectedEntityId].ownedBySystemId;
|
|
8059
|
+
}
|
|
8060
|
+
if (typeof action.scope === "object") {
|
|
8061
|
+
return action.scope.domain;
|
|
8062
|
+
}
|
|
8063
|
+
return "global";
|
|
8064
|
+
}
|
|
8065
|
+
function addLegacyEntityProjections(index2, diagnostics, sourcesById, entities) {
|
|
8066
|
+
for (const entity of Object.values(entities)) {
|
|
8067
|
+
const objectType = {
|
|
8068
|
+
id: legacyObjectId(entity),
|
|
8069
|
+
label: entity.label,
|
|
8070
|
+
description: entity.description,
|
|
8071
|
+
ownerSystemId: entity.ownedBySystemId,
|
|
8072
|
+
...entity.table !== void 0 ? {
|
|
8073
|
+
storage: {
|
|
8074
|
+
kind: "table",
|
|
8075
|
+
table: entity.table
|
|
8076
|
+
}
|
|
8077
|
+
} : {},
|
|
8078
|
+
legacyEntityId: entity.id,
|
|
8079
|
+
...entity.rowSchema !== void 0 ? { rowSchema: entity.rowSchema } : {},
|
|
8080
|
+
...entity.stateCatalogId !== void 0 ? { stateCatalogId: entity.stateCatalogId } : {}
|
|
8081
|
+
};
|
|
8082
|
+
addRecord(index2, diagnostics, sourcesById, "objectTypes", objectType, {
|
|
8083
|
+
source: "legacy.entities",
|
|
8084
|
+
path: ["entities", entity.id],
|
|
8085
|
+
kind: "projected",
|
|
8086
|
+
systemPath: entity.ownedBySystemId,
|
|
8087
|
+
legacyId: entity.id
|
|
8088
|
+
});
|
|
8089
|
+
entity.links?.forEach((link, linkIndex) => {
|
|
8090
|
+
const targetEntity = entities[link.toEntity];
|
|
8091
|
+
if (targetEntity === void 0) return;
|
|
8092
|
+
const linkType = {
|
|
8093
|
+
id: formatOntologyId({
|
|
8094
|
+
scope: entity.ownedBySystemId,
|
|
8095
|
+
kind: "link",
|
|
8096
|
+
localId: `${entity.id}-${link.toEntity}-${linkIndex}`
|
|
8097
|
+
}),
|
|
8098
|
+
label: link.label ?? link.kind,
|
|
8099
|
+
ownerSystemId: entity.ownedBySystemId,
|
|
8100
|
+
from: legacyObjectId(entity),
|
|
8101
|
+
to: legacyObjectId(targetEntity),
|
|
8102
|
+
cardinality: link.kind,
|
|
8103
|
+
...link.via !== void 0 ? { via: link.via } : {},
|
|
8104
|
+
legacyEntityId: entity.id
|
|
8105
|
+
};
|
|
8106
|
+
addRecord(index2, diagnostics, sourcesById, "linkTypes", linkType, {
|
|
8107
|
+
source: "legacy.entities.links",
|
|
8108
|
+
path: ["entities", entity.id, "links", linkIndex],
|
|
8109
|
+
kind: "projected",
|
|
8110
|
+
systemPath: entity.ownedBySystemId,
|
|
8111
|
+
legacyId: `${entity.id}.links.${linkIndex}`
|
|
8112
|
+
});
|
|
8113
|
+
});
|
|
8114
|
+
}
|
|
8115
|
+
}
|
|
8116
|
+
function addLegacyActionProjections(index2, diagnostics, sourcesById, actions, entities) {
|
|
8117
|
+
for (const action of Object.values(actions)) {
|
|
8118
|
+
const ownerSystemId = legacyActionOwner(action, entities);
|
|
8119
|
+
const actionType = {
|
|
8120
|
+
id: formatOntologyId({ scope: ownerSystemId, kind: "action", localId: action.id }),
|
|
8121
|
+
label: action.label,
|
|
8122
|
+
description: action.description,
|
|
8123
|
+
ownerSystemId,
|
|
8124
|
+
actsOn: action.affects?.map((entityId) => entities[entityId] ? legacyObjectId(entities[entityId]) : void 0).filter((id) => id !== void 0),
|
|
8125
|
+
...action.resourceId !== void 0 ? { resourceId: action.resourceId } : {},
|
|
8126
|
+
...action.invocations !== void 0 ? { invocations: action.invocations } : {},
|
|
8127
|
+
...action.lifecycle !== void 0 ? { lifecycle: action.lifecycle } : {},
|
|
8128
|
+
legacyActionId: action.id
|
|
8129
|
+
};
|
|
8130
|
+
addRecord(index2, diagnostics, sourcesById, "actionTypes", actionType, {
|
|
8131
|
+
source: "legacy.actions",
|
|
8132
|
+
path: ["actions", action.id],
|
|
8133
|
+
kind: "projected",
|
|
8134
|
+
systemPath: ownerSystemId,
|
|
8135
|
+
legacyId: action.id
|
|
8136
|
+
});
|
|
8137
|
+
}
|
|
8138
|
+
}
|
|
8139
|
+
function addSystemContentProjections(index2, diagnostics, sourcesById, systemPath, system, schemaPath) {
|
|
8140
|
+
const content = system.content ?? {};
|
|
8141
|
+
for (const [localId, node] of Object.entries(content)) {
|
|
8142
|
+
if (node.kind !== "schema") continue;
|
|
8143
|
+
const entries = Object.fromEntries(
|
|
8144
|
+
Object.entries(content).filter(([, candidate]) => candidate.parentContentId === localId).map(([entryId, candidate]) => [
|
|
8145
|
+
entryId,
|
|
8146
|
+
{
|
|
8147
|
+
label: candidate.label ?? entryId,
|
|
8148
|
+
type: candidate.type,
|
|
8149
|
+
...candidate.description !== void 0 ? { description: candidate.description } : {},
|
|
8150
|
+
...candidate.data !== void 0 ? candidate.data : {}
|
|
8151
|
+
}
|
|
8152
|
+
])
|
|
8153
|
+
);
|
|
8154
|
+
const catalogType = {
|
|
8155
|
+
id: formatOntologyId({ scope: systemPath, kind: "catalog", localId }),
|
|
8156
|
+
label: node.label ?? localId,
|
|
8157
|
+
description: node.description,
|
|
8158
|
+
ownerSystemId: systemPath,
|
|
8159
|
+
kind: node.type,
|
|
8160
|
+
...typeof node.data?.["entityId"] === "string" ? { appliesTo: formatOntologyId({ scope: systemPath, kind: "object", localId: node.data["entityId"] }) } : {},
|
|
8161
|
+
...Object.keys(entries).length > 0 ? { entries } : {},
|
|
8162
|
+
...node.data !== void 0 ? { data: node.data } : {},
|
|
8163
|
+
legacyContentId: `${systemPath}:${localId}`
|
|
8164
|
+
};
|
|
8165
|
+
addRecord(index2, diagnostics, sourcesById, "catalogTypes", catalogType, {
|
|
8166
|
+
source: "legacy.system.content",
|
|
8167
|
+
path: [...schemaPath, "content", localId],
|
|
8168
|
+
kind: "projected",
|
|
8169
|
+
systemPath,
|
|
8170
|
+
legacyId: `${systemPath}:${localId}`
|
|
8171
|
+
});
|
|
8172
|
+
}
|
|
8173
|
+
}
|
|
8174
|
+
function addSystemScopes(index2, diagnostics, sourcesById, systems, prefix, schemaPath) {
|
|
8175
|
+
for (const [key, system] of Object.entries(systems)) {
|
|
8176
|
+
const systemPath = prefix ? `${prefix}.${key}` : key;
|
|
8177
|
+
const currentPath = [...schemaPath, key];
|
|
8178
|
+
addScope(index2, diagnostics, sourcesById, system.ontology, `system:${systemPath}.ontology`, [
|
|
8179
|
+
...currentPath,
|
|
8180
|
+
"ontology"
|
|
8181
|
+
]);
|
|
8182
|
+
addSystemContentProjections(index2, diagnostics, sourcesById, systemPath, system, currentPath);
|
|
8183
|
+
addSystemScopes(index2, diagnostics, sourcesById, childSystemsOf(system), systemPath, [
|
|
8184
|
+
...currentPath,
|
|
8185
|
+
system.systems !== void 0 ? "systems" : "subsystems"
|
|
8186
|
+
]);
|
|
8187
|
+
}
|
|
8188
|
+
}
|
|
8189
|
+
function compileOrganizationOntology(model) {
|
|
8190
|
+
const ontology = createEmptyIndex();
|
|
8191
|
+
const diagnostics = [];
|
|
8192
|
+
const sourcesById = /* @__PURE__ */ new Map();
|
|
8193
|
+
addScope(ontology, diagnostics, sourcesById, model.ontology, "organization.ontology", ["ontology"]);
|
|
8194
|
+
addSystemScopes(ontology, diagnostics, sourcesById, model.systems ?? {}, "", ["systems"]);
|
|
8195
|
+
addLegacyEntityProjections(ontology, diagnostics, sourcesById, model.entities ?? {});
|
|
8196
|
+
addLegacyActionProjections(ontology, diagnostics, sourcesById, model.actions ?? {}, model.entities ?? {});
|
|
8197
|
+
return { ontology: sortResolvedOntologyIndex(ontology), diagnostics };
|
|
8198
|
+
}
|
|
8199
|
+
|
|
8200
|
+
// ../core/src/organization-model/domains/systems.ts
|
|
8201
|
+
var SystemKindSchema = z.enum(["product", "operational", "platform", "diagnostic"]).meta({ label: "System kind", color: "blue" });
|
|
8202
|
+
var SystemLifecycleSchema = z.enum(["draft", "beta", "active", "deprecated", "archived"]).meta({ label: "Lifecycle", color: "teal" });
|
|
8203
|
+
var SystemStatusSchema = z.enum(["active", "deprecated", "archived"]).meta({ label: "Status", color: "teal" });
|
|
8204
|
+
var SystemIdSchema = ModelIdSchema;
|
|
8205
|
+
var SystemPathSchema = z.string().trim().min(1).regex(
|
|
8206
|
+
/^[a-z0-9][a-z0-9-]*(?:\.[a-z0-9][a-z0-9-]*)*$/,
|
|
8207
|
+
'must be a dotted lowercase path (e.g. "sales.lead-gen" or "sales.crm")'
|
|
8208
|
+
);
|
|
8209
|
+
var UiPositionSchema = z.enum(["sidebar-primary", "sidebar-bottom"]).meta({ label: "UI position" });
|
|
8210
|
+
var NodeIdStringSchema = z.string().trim().min(1).max(200).regex(
|
|
8211
|
+
/^[a-z][a-z-]*:([a-z0-9-]+)(\.[a-z0-9-]+)*(:[a-z0-9.-]+)*$/,
|
|
8212
|
+
"Node references must use kind:dotted-path (e.g. system:sales.crm or content-node:sales.crm:pipeline-id)"
|
|
8213
|
+
);
|
|
8214
|
+
var SystemUiSchema = z.object({
|
|
8215
|
+
path: PathSchema,
|
|
8216
|
+
surfaces: ReferenceIdsSchema,
|
|
8217
|
+
icon: IconNameSchema.optional(),
|
|
8218
|
+
order: z.number().int().optional()
|
|
8219
|
+
});
|
|
8220
|
+
var JsonValueSchema = z.lazy(
|
|
8221
|
+
() => z.union([
|
|
8222
|
+
z.string(),
|
|
8223
|
+
z.number(),
|
|
8224
|
+
z.boolean(),
|
|
8225
|
+
z.null(),
|
|
8226
|
+
z.array(JsonValueSchema),
|
|
8227
|
+
z.record(z.string(), JsonValueSchema)
|
|
8228
|
+
])
|
|
8229
|
+
);
|
|
8230
|
+
var SystemConfigSchema = z.record(z.string().trim().min(1).max(200), JsonValueSchema).default({}).optional();
|
|
8231
|
+
var SystemEntrySchema = z.object({
|
|
8232
|
+
/** Stable tenant-defined system id (e.g. "sys.lead-gen" or "sales.crm"). */
|
|
8233
|
+
id: SystemIdSchema,
|
|
8234
|
+
/** Human-readable system label shown in UI, governance, and operations surfaces. */
|
|
8235
|
+
label: LabelSchema.optional(),
|
|
8236
|
+
/** @deprecated Use label. Accepted for pre-consolidation System declarations. */
|
|
8237
|
+
title: LabelSchema.optional(),
|
|
8238
|
+
/** One-paragraph purpose statement for the bounded context. */
|
|
8239
|
+
description: DescriptionSchema.optional(),
|
|
8240
|
+
/** Closed system shape enum; catalog values remain tenant-defined. */
|
|
8241
|
+
kind: SystemKindSchema.optional(),
|
|
8242
|
+
/** Optional self-reference for System hierarchy. */
|
|
8243
|
+
parentSystemId: SystemIdSchema.optional(),
|
|
8244
|
+
/** Optional UI presence. Systems without UI omit this. */
|
|
8245
|
+
ui: SystemUiSchema.optional(),
|
|
8246
|
+
/** Canonical lifecycle state. Replaces Feature.enabled/devOnly and System.status. */
|
|
8247
|
+
lifecycle: SystemLifecycleSchema.optional(),
|
|
8248
|
+
/** Optional role responsible for this system. */
|
|
8249
|
+
responsibleRoleId: ModelIdSchema.meta({ ref: "role" }).optional(),
|
|
8250
|
+
/** Optional knowledge nodes that govern this system. */
|
|
8251
|
+
governedByKnowledge: z.array(ModelIdSchema.meta({ ref: "knowledge" })).default([]).optional(),
|
|
8252
|
+
/** Optional actions this system exposes or consumes. */
|
|
8253
|
+
actions: z.array(ActionRefSchema).optional(),
|
|
8254
|
+
/** Optional operational policies that apply to this system. */
|
|
8255
|
+
policies: z.array(ModelIdSchema.meta({ ref: "policy" })).default([]).optional(),
|
|
8256
|
+
/** Optional goals this system contributes to. */
|
|
8257
|
+
drivesGoals: z.array(ModelIdSchema.meta({ ref: "goal" })).default([]).optional(),
|
|
8258
|
+
/** @deprecated Use lifecycle. Accepted for one publish cycle. */
|
|
8259
|
+
status: SystemStatusSchema.optional(),
|
|
8260
|
+
/** @deprecated Use ui.path. Kept for one-cycle Feature compatibility. */
|
|
8261
|
+
path: PathSchema.optional(),
|
|
8262
|
+
/** @deprecated Use ui.icon. Kept for one-cycle Feature compatibility. */
|
|
8263
|
+
icon: IconNameSchema.optional(),
|
|
8264
|
+
/** @deprecated Feature color token, retained for one-cycle compatibility. */
|
|
8265
|
+
color: ColorTokenSchema.optional(),
|
|
8266
|
+
/** @deprecated UI placement hint, retained for one-cycle compatibility. */
|
|
8267
|
+
uiPosition: UiPositionSchema.optional(),
|
|
8268
|
+
/** @deprecated Use lifecycle. */
|
|
8269
|
+
enabled: z.boolean().optional(),
|
|
8270
|
+
/** @deprecated Use lifecycle: "beta". */
|
|
8271
|
+
devOnly: z.boolean().optional(),
|
|
8272
|
+
requiresAdmin: z.boolean().optional(),
|
|
8273
|
+
/** Domain-map iteration order. Convention: multiples of 10 (10, 20, 30, ...) to allow easy insertion. */
|
|
8274
|
+
order: z.number(),
|
|
8275
|
+
/**
|
|
8276
|
+
* System-local JSON settings and defaults. Strongly typed OM fields,
|
|
8277
|
+
* secrets, credentials, and runtime state stay outside this bucket.
|
|
8278
|
+
*/
|
|
8279
|
+
config: SystemConfigSchema,
|
|
8280
|
+
/**
|
|
8281
|
+
* System-owned ontology declarations. `systems` is now the canonical child
|
|
8282
|
+
* key; this scope holds the object, action, catalog, link, event, and
|
|
8283
|
+
* shared contract records owned by this system.
|
|
8284
|
+
*/
|
|
8285
|
+
ontology: OntologyScopeSchema.optional(),
|
|
8286
|
+
/**
|
|
8287
|
+
* @deprecated Compatibility-only bridge for old tenant content nodes and
|
|
8288
|
+
* migration readers. New schema/catalog authoring belongs in ontology;
|
|
8289
|
+
* new system-local settings belong in config. Bridge nodes are keyed by
|
|
8290
|
+
* local NodeId and may still project to content-node:* graph IDs.
|
|
8291
|
+
*/
|
|
8292
|
+
content: z.record(z.string().trim().min(1).max(200), ContentNodeSchema).optional(),
|
|
8293
|
+
/**
|
|
8294
|
+
* Recursive child systems, authored via nesting (per L11).
|
|
8295
|
+
* The key is the local system id; the full path is computed by joining
|
|
8296
|
+
* ancestor keys with `.` (e.g. parent key `'sales'` + child key `'crm'` → `'sales.crm'`).
|
|
8297
|
+
* Per Phase 4: `id` and `parentSystemId` fields will be removed in favour of
|
|
8298
|
+
* position-derived paths. Both still exist on this schema for backward compat.
|
|
8299
|
+
*/
|
|
8300
|
+
systems: z.lazy(() => z.record(z.string().trim().min(1).max(100), SystemEntrySchema)).optional(),
|
|
8301
|
+
/** @deprecated Use systems. Accepted as a compatibility alias during the ontology bridge. */
|
|
8302
|
+
subsystems: z.lazy(() => z.record(z.string().trim().min(1).max(100), SystemEntrySchema)).optional()
|
|
8303
|
+
}).refine((system) => system.label !== void 0 || system.title !== void 0, {
|
|
8304
|
+
path: ["label"],
|
|
8305
|
+
message: "System must provide label or title"
|
|
8306
|
+
}).transform((system) => {
|
|
8307
|
+
const normalizedSystem = system.systems !== void 0 && system.subsystems === void 0 ? { ...system, subsystems: system.systems } : system;
|
|
8308
|
+
if (normalizedSystem.status === void 0) return normalizedSystem;
|
|
8309
|
+
console.warn("[organization-model] System.status is deprecated; use System.lifecycle instead.");
|
|
8310
|
+
return normalizedSystem.lifecycle === void 0 ? { ...normalizedSystem, lifecycle: normalizedSystem.status } : normalizedSystem;
|
|
8311
|
+
});
|
|
8312
|
+
var SystemsDomainSchema = z.record(z.string(), SystemEntrySchema).refine((record) => Object.entries(record).every(([key, entry]) => entry.id === key), {
|
|
8313
|
+
message: "Each system entry id must match its map key"
|
|
8314
|
+
}).default({});
|
|
8315
|
+
var DEFAULT_ORGANIZATION_MODEL_SYSTEMS = {};
|
|
8316
|
+
|
|
8317
|
+
// ../core/src/organization-model/domains/resources.ts
|
|
8318
|
+
z.enum(["workflow", "agent", "integration", "script"]).meta({ label: "Resource kind", color: "orange" });
|
|
8319
|
+
var ResourceGovernanceStatusSchema = z.enum(["active", "deprecated", "archived"]).meta({ label: "Governance status", color: "teal" });
|
|
8320
|
+
var AgentKindSchema = z.enum(["orchestrator", "specialist", "utility", "platform"]).meta({ label: "Agent kind", color: "violet" });
|
|
8321
|
+
var ScriptResourceLanguageSchema = z.enum(["shell", "sql", "typescript", "python"]).meta({ label: "Language" });
|
|
8322
|
+
var CodeReferenceRoleSchema = z.enum(["entrypoint", "handler", "schema", "test", "docs", "config"]).meta({ label: "Code reference role", color: "blue" });
|
|
8323
|
+
var ResourceIdSchema = z.string().trim().min(1).max(255).regex(/^[A-Za-z0-9]+(?:[-._][A-Za-z0-9]+)*$/, "Resource IDs must use letters, numbers, -, _, or . separators");
|
|
8324
|
+
var EventIdSchema = z.string().trim().min(1).max(300).regex(
|
|
8325
|
+
/^[A-Za-z0-9]+(?:[-._][A-Za-z0-9]+)*:[a-z0-9]+(?:[-._][a-z0-9]+)*$/,
|
|
8326
|
+
"Event IDs must use <owner-id>:<event-key>"
|
|
8327
|
+
);
|
|
8328
|
+
var EventKeySchema = ModelIdSchema;
|
|
8329
|
+
var EventEmissionDescriptorSchema = z.object({
|
|
8330
|
+
eventKey: EventKeySchema,
|
|
8331
|
+
label: z.string().trim().min(1).max(120),
|
|
8332
|
+
payloadSchema: ModelIdSchema.optional(),
|
|
8333
|
+
lifecycle: SystemLifecycleSchema.optional()
|
|
8334
|
+
});
|
|
8335
|
+
EventEmissionDescriptorSchema.extend({
|
|
8336
|
+
id: EventIdSchema,
|
|
8337
|
+
ownerId: z.union([ResourceIdSchema, ModelIdSchema]),
|
|
8338
|
+
ownerKind: z.enum(["resource", "entity"]).meta({ label: "Owner kind" })
|
|
8339
|
+
});
|
|
8340
|
+
var ResourceOntologyBindingSchema = z.object({
|
|
8341
|
+
implements: z.array(OntologyIdSchema).optional(),
|
|
8342
|
+
reads: z.array(OntologyIdSchema).optional(),
|
|
8343
|
+
writes: z.array(OntologyIdSchema).optional(),
|
|
8344
|
+
usesCatalogs: z.array(OntologyIdSchema).optional(),
|
|
8345
|
+
emits: z.array(OntologyIdSchema).optional()
|
|
8346
|
+
});
|
|
8347
|
+
var CodeReferenceSchema = z.object({
|
|
8348
|
+
path: z.string().trim().min(1).max(500).regex(/^[A-Za-z0-9_./$@()[\] -]+$/, "Code reference paths must be repo-relative paths"),
|
|
8349
|
+
role: CodeReferenceRoleSchema,
|
|
8350
|
+
symbol: z.string().trim().min(1).max(200).optional(),
|
|
8351
|
+
description: z.string().trim().min(1).max(300).optional()
|
|
8352
|
+
});
|
|
8353
|
+
var ResourceEntryBaseSchema = z.object({
|
|
8354
|
+
/** Canonical resource id; runtime resourceId derives from this value. */
|
|
8355
|
+
id: ResourceIdSchema,
|
|
8356
|
+
/** Domain-map iteration order. Convention: multiples of 10 (10, 20, 30, ...) to allow easy insertion. */
|
|
8357
|
+
order: z.number().default(0),
|
|
8358
|
+
/** Required single System membership — value is a dot-separated system path (e.g. "sales.lead-gen"). */
|
|
8359
|
+
systemPath: SystemPathSchema.meta({ ref: "system" }),
|
|
8360
|
+
/** Optional role responsible for maintaining this resource. */
|
|
8361
|
+
ownerRoleId: ModelIdSchema.meta({ ref: "role" }).optional(),
|
|
8362
|
+
status: ResourceGovernanceStatusSchema,
|
|
8363
|
+
/**
|
|
8364
|
+
* Ontology contract bindings for the semantic work this resource performs.
|
|
8365
|
+
* `emits` stays nested here so top-level resource emits descriptors remain
|
|
8366
|
+
* compatible with graph event projection during the bridge.
|
|
8367
|
+
*/
|
|
8368
|
+
ontology: ResourceOntologyBindingSchema.optional(),
|
|
8369
|
+
/** Repo-relative implementation breadcrumbs for agents and operators. */
|
|
8370
|
+
codeRefs: z.array(CodeReferenceSchema).default([])
|
|
8371
|
+
});
|
|
8372
|
+
var WorkflowResourceEntrySchema = ResourceEntryBaseSchema.extend({
|
|
8373
|
+
kind: z.literal("workflow"),
|
|
8374
|
+
/** Mirrors WorkflowConfig.actionKey when the runtime workflow has one. */
|
|
8375
|
+
actionKey: z.string().trim().min(1).max(255).optional(),
|
|
8376
|
+
emits: z.array(EventEmissionDescriptorSchema).optional()
|
|
8377
|
+
});
|
|
8378
|
+
var AgentResourceEntrySchema = ResourceEntryBaseSchema.extend({
|
|
8379
|
+
kind: z.literal("agent"),
|
|
8380
|
+
/** Mirrors code-side AgentConfig.kind. */
|
|
8381
|
+
agentKind: AgentKindSchema,
|
|
8382
|
+
/** Role this agent embodies, if any. */
|
|
8383
|
+
actsAsRoleId: ModelIdSchema.meta({ ref: "role" }).optional(),
|
|
8384
|
+
/** Mirrors AgentConfig.sessionCapable. */
|
|
8385
|
+
sessionCapable: z.boolean(),
|
|
8386
|
+
/** Broad/composite callable entry points orchestrated by this agent. */
|
|
8387
|
+
invocations: z.array(ActionInvocationSchema).default([]),
|
|
8388
|
+
emits: z.array(EventEmissionDescriptorSchema).optional()
|
|
8389
|
+
});
|
|
8390
|
+
var IntegrationResourceEntrySchema = ResourceEntryBaseSchema.extend({
|
|
8391
|
+
kind: z.literal("integration"),
|
|
8392
|
+
provider: z.string().trim().min(1).max(100)
|
|
8393
|
+
});
|
|
8394
|
+
var ScriptResourceSourceSchema = z.union([
|
|
8395
|
+
z.string().trim().min(1).max(5e4),
|
|
8396
|
+
z.object({
|
|
8397
|
+
file: z.string().trim().min(1).max(500)
|
|
8398
|
+
})
|
|
8399
|
+
]);
|
|
8400
|
+
var ScriptResourceEntrySchema = ResourceEntryBaseSchema.extend({
|
|
8401
|
+
kind: z.literal("script"),
|
|
8402
|
+
language: ScriptResourceLanguageSchema,
|
|
8403
|
+
source: ScriptResourceSourceSchema
|
|
8404
|
+
});
|
|
8405
|
+
var ResourceEntrySchema = z.discriminatedUnion("kind", [
|
|
8406
|
+
WorkflowResourceEntrySchema,
|
|
8407
|
+
AgentResourceEntrySchema,
|
|
8408
|
+
IntegrationResourceEntrySchema,
|
|
8409
|
+
ScriptResourceEntrySchema
|
|
8410
|
+
]);
|
|
8411
|
+
var ResourcesDomainSchema = z.record(z.string(), ResourceEntrySchema).refine((record) => Object.entries(record).every(([key, entry]) => entry.id === key), {
|
|
8412
|
+
message: "Each resource entry id must match its map key"
|
|
8413
|
+
}).default({});
|
|
8414
|
+
var DEFAULT_ORGANIZATION_MODEL_RESOURCES = {};
|
|
8415
|
+
|
|
8416
|
+
// ../core/src/organization-model/domains/roles.ts
|
|
8417
|
+
var RoleIdSchema = ModelIdSchema;
|
|
8418
|
+
var HumanRoleHolderSchema = z.object({
|
|
8419
|
+
kind: z.literal("human"),
|
|
8420
|
+
userId: z.string().trim().min(1).max(200)
|
|
8421
|
+
});
|
|
8422
|
+
var AgentRoleHolderSchema = z.object({
|
|
8423
|
+
kind: z.literal("agent"),
|
|
8424
|
+
agentId: ResourceIdSchema.meta({ ref: "resource" })
|
|
8425
|
+
});
|
|
8426
|
+
var TeamRoleHolderSchema = z.object({
|
|
8427
|
+
kind: z.literal("team"),
|
|
8428
|
+
memberIds: z.array(z.string().trim().min(1).max(200)).min(1)
|
|
8429
|
+
});
|
|
8430
|
+
var RoleHolderSchema = z.discriminatedUnion("kind", [
|
|
8431
|
+
HumanRoleHolderSchema,
|
|
8432
|
+
AgentRoleHolderSchema,
|
|
8433
|
+
TeamRoleHolderSchema
|
|
8434
|
+
]);
|
|
8435
|
+
var RoleHoldersSchema = z.union([RoleHolderSchema, z.array(RoleHolderSchema).min(1)]);
|
|
8436
|
+
var RoleSchema = z.object({
|
|
8437
|
+
/** Stable unique identifier for the role (e.g. "role-ceo", "role-head-of-sales"). */
|
|
8438
|
+
id: RoleIdSchema,
|
|
8439
|
+
/** Domain-map iteration order. Convention: multiples of 10 (10, 20, 30, ...) to allow easy insertion. */
|
|
8440
|
+
order: z.number(),
|
|
8441
|
+
/** Human-readable title shown to agents and in UI (e.g. "CEO", "Head of Sales"). */
|
|
8442
|
+
title: z.string().trim().min(1).max(200),
|
|
8443
|
+
/**
|
|
8444
|
+
* List of responsibilities this role owns - plain-language descriptions of
|
|
8445
|
+
* what the person in this role is accountable for delivering.
|
|
8446
|
+
* Defaults to empty array so minimal role definitions stay concise.
|
|
8447
|
+
*/
|
|
8448
|
+
responsibilities: z.array(z.string().trim().max(500)).default([]),
|
|
8449
|
+
/**
|
|
8450
|
+
* Optional: ID of another role this role reports to.
|
|
8451
|
+
* When present, must reference another `roles[].id` in the same organization.
|
|
8452
|
+
*/
|
|
8453
|
+
reportsToId: RoleIdSchema.meta({ ref: "role" }).optional(),
|
|
8454
|
+
/**
|
|
8455
|
+
* Optional: human, agent, or team holder currently filling this role.
|
|
8456
|
+
* Agent holders reference OM Resource IDs and are validated at the model level.
|
|
8457
|
+
*/
|
|
8458
|
+
heldBy: RoleHoldersSchema.optional(),
|
|
8459
|
+
/**
|
|
8460
|
+
* Optional Systems this role is accountable for.
|
|
8461
|
+
* Cross-reference enforced in `OrganizationModelSchema.superRefine()`.
|
|
8462
|
+
*/
|
|
8463
|
+
responsibleFor: z.array(SystemIdSchema.meta({ ref: "system" })).optional()
|
|
8464
|
+
});
|
|
8465
|
+
var RolesDomainSchema = z.record(z.string(), RoleSchema).refine((record) => Object.entries(record).every(([key, entry]) => entry.id === key), {
|
|
8466
|
+
message: "Each role entry id must match its map key"
|
|
8467
|
+
}).default({});
|
|
8468
|
+
var DEFAULT_ORGANIZATION_MODEL_ROLES = {};
|
|
8469
|
+
var KeyResultSchema = z.object({
|
|
8470
|
+
/** Stable unique identifier for the measurable outcome (e.g. "kr-revenue-q1"). */
|
|
8471
|
+
id: z.string().trim().min(1).max(100),
|
|
8472
|
+
/** Plain-language description of this measurable outcome (e.g. "Increase trial-to-paid conversion"). */
|
|
8473
|
+
description: z.string().trim().min(1).max(500),
|
|
8474
|
+
/**
|
|
8475
|
+
* What is being measured — the metric name (e.g. "monthly revenue", "NPS score",
|
|
8476
|
+
* "trial-to-paid conversion rate"). Free-form string.
|
|
8477
|
+
*/
|
|
8478
|
+
targetMetric: z.string().trim().min(1).max(200),
|
|
8479
|
+
/** Current measured value. Defaults to 0 when not yet tracked. */
|
|
8480
|
+
currentValue: z.number().default(0),
|
|
8481
|
+
/**
|
|
8482
|
+
* Target value to reach for this measurable outcome to be considered achieved.
|
|
8483
|
+
* Optional — omit if the outcome is directional (e.g. "reduce churn") without
|
|
8484
|
+
* a hard numeric target.
|
|
8485
|
+
*/
|
|
8486
|
+
targetValue: z.number().optional()
|
|
8487
|
+
});
|
|
8488
|
+
var ISO_DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
8489
|
+
var ObjectiveSchema = z.object({
|
|
8490
|
+
/** Stable unique identifier for the goal (e.g. "goal-grow-arr-q1-2026"). */
|
|
8491
|
+
id: z.string().trim().min(1).max(100),
|
|
8492
|
+
/** Domain-map iteration order. Convention: multiples of 10 (10, 20, 30, ...) to allow easy insertion. */
|
|
8493
|
+
order: z.number(),
|
|
8494
|
+
/** Plain-language description of what the organization wants to achieve. */
|
|
8495
|
+
description: z.string().trim().min(1).max(1e3),
|
|
8496
|
+
/**
|
|
8497
|
+
* Start of the period this goal is active for — ISO 8601 date string (YYYY-MM-DD).
|
|
8498
|
+
* Must be strictly before `periodEnd`.
|
|
8499
|
+
*/
|
|
8500
|
+
periodStart: z.string().regex(ISO_DATE_REGEX, "periodStart must be an ISO date string (YYYY-MM-DD)"),
|
|
8501
|
+
/**
|
|
8502
|
+
* End of the period this goal is active for — ISO 8601 date string (YYYY-MM-DD).
|
|
8503
|
+
* Must be strictly after `periodStart`.
|
|
8504
|
+
* Enforced via `OrganizationModelSchema.superRefine()`.
|
|
8505
|
+
*/
|
|
8506
|
+
periodEnd: z.string().regex(ISO_DATE_REGEX, "periodEnd must be an ISO date string (YYYY-MM-DD)"),
|
|
8507
|
+
/**
|
|
8508
|
+
* List of measurable outcomes that define success for this goal.
|
|
8509
|
+
* Defaults to empty array so goals can be declared before outcomes are defined.
|
|
8510
|
+
*/
|
|
8511
|
+
keyResults: z.array(KeyResultSchema).default([])
|
|
8512
|
+
});
|
|
8513
|
+
var GoalsDomainSchema = z.record(z.string(), ObjectiveSchema).refine((record) => Object.entries(record).every(([key, entry]) => entry.id === key), {
|
|
8514
|
+
message: "Each objective entry id must match its map key"
|
|
8515
|
+
}).default({});
|
|
8516
|
+
var DEFAULT_ORGANIZATION_MODEL_GOALS = {};
|
|
8517
|
+
var PolicyIdSchema = ModelIdSchema;
|
|
8518
|
+
var PolicyApplicabilitySchema = z.object({
|
|
8519
|
+
systemIds: z.array(ModelIdSchema.meta({ ref: "system" })).default([]),
|
|
8520
|
+
actionIds: z.array(ModelIdSchema.meta({ ref: "action" })).default([]),
|
|
8521
|
+
resourceIds: z.array(ModelIdSchema.meta({ ref: "resource" })).default([]),
|
|
8522
|
+
roleIds: z.array(ModelIdSchema.meta({ ref: "role" })).default([])
|
|
8523
|
+
});
|
|
8524
|
+
var PolicyTriggerSchema = z.discriminatedUnion("kind", [
|
|
8525
|
+
z.object({
|
|
8526
|
+
kind: z.literal("event"),
|
|
8527
|
+
eventId: EventIdSchema.meta({ ref: "event" })
|
|
8528
|
+
}),
|
|
8529
|
+
z.object({
|
|
8530
|
+
kind: z.literal("action-invocation"),
|
|
8531
|
+
actionId: ModelIdSchema.meta({ ref: "action" })
|
|
8532
|
+
}),
|
|
8533
|
+
z.object({
|
|
8534
|
+
kind: z.literal("schedule"),
|
|
8535
|
+
cron: z.string().trim().min(1).max(120)
|
|
8536
|
+
}),
|
|
8537
|
+
z.object({
|
|
8538
|
+
kind: z.literal("manual")
|
|
8539
|
+
})
|
|
8540
|
+
]);
|
|
8541
|
+
var PolicyPredicateSchema = z.discriminatedUnion("kind", [
|
|
8542
|
+
z.object({
|
|
8543
|
+
kind: z.literal("always")
|
|
8544
|
+
}),
|
|
8545
|
+
z.object({
|
|
8546
|
+
kind: z.literal("expression"),
|
|
8547
|
+
expression: z.string().trim().min(1).max(2e3)
|
|
8548
|
+
}),
|
|
8549
|
+
z.object({
|
|
8550
|
+
kind: z.literal("threshold"),
|
|
8551
|
+
metric: ModelIdSchema,
|
|
8552
|
+
operator: z.enum(["lt", "lte", "eq", "gte", "gt"]).meta({ label: "Operator" }),
|
|
8553
|
+
value: z.number()
|
|
8554
|
+
})
|
|
8555
|
+
]);
|
|
8556
|
+
var PolicyEffectSchema = z.discriminatedUnion("kind", [
|
|
8557
|
+
z.object({
|
|
8558
|
+
kind: z.literal("require-approval"),
|
|
8559
|
+
roleId: ModelIdSchema.meta({ ref: "role" }).optional()
|
|
8560
|
+
}),
|
|
8561
|
+
z.object({
|
|
8562
|
+
kind: z.literal("invoke-action"),
|
|
8563
|
+
actionId: ModelIdSchema.meta({ ref: "action" })
|
|
8564
|
+
}),
|
|
8565
|
+
z.object({
|
|
8566
|
+
kind: z.literal("notify-role"),
|
|
8567
|
+
roleId: ModelIdSchema.meta({ ref: "role" })
|
|
8568
|
+
}),
|
|
8569
|
+
z.object({
|
|
8570
|
+
kind: z.literal("block")
|
|
8571
|
+
})
|
|
8572
|
+
]);
|
|
8573
|
+
var PolicySchema = z.object({
|
|
8574
|
+
id: PolicyIdSchema,
|
|
8575
|
+
/** Domain-map iteration order. Convention: multiples of 10 (10, 20, 30, ...) to allow easy insertion. */
|
|
8576
|
+
order: z.number(),
|
|
8577
|
+
label: LabelSchema,
|
|
8578
|
+
description: DescriptionSchema.optional(),
|
|
8579
|
+
trigger: PolicyTriggerSchema,
|
|
8580
|
+
predicate: PolicyPredicateSchema.default({ kind: "always" }),
|
|
8581
|
+
actions: z.array(PolicyEffectSchema).min(1),
|
|
8582
|
+
appliesTo: PolicyApplicabilitySchema.default({
|
|
8583
|
+
systemIds: [],
|
|
8584
|
+
actionIds: [],
|
|
8585
|
+
resourceIds: [],
|
|
8586
|
+
roleIds: []
|
|
8587
|
+
}),
|
|
8588
|
+
lifecycle: z.enum(["draft", "beta", "active", "deprecated", "archived"]).meta({ label: "Lifecycle", color: "teal" }).default("active")
|
|
8589
|
+
});
|
|
8590
|
+
var PoliciesDomainSchema = z.record(z.string(), PolicySchema).refine((record) => Object.entries(record).every(([key, entry]) => entry.id === key), {
|
|
8591
|
+
message: "Each policy entry id must match its map key"
|
|
8592
|
+
}).default({});
|
|
8593
|
+
var DEFAULT_ORGANIZATION_MODEL_POLICIES = {};
|
|
8594
|
+
|
|
8595
|
+
// ../core/src/organization-model/content-kinds/registry.ts
|
|
8596
|
+
function defineContentType(def) {
|
|
8597
|
+
return def;
|
|
8598
|
+
}
|
|
8599
|
+
var PipelinePayloadSchema = z.object({
|
|
8600
|
+
/**
|
|
8601
|
+
* Local NodeId of the entity this pipeline applies to (e.g. 'crm.deal').
|
|
8602
|
+
* `.meta({ ref: 'entity' })` enables SchemaDrivenFieldList to render a
|
|
8603
|
+
* clickable graph link to the referenced entity node.
|
|
8604
|
+
*/
|
|
8605
|
+
entityId: z.string().trim().min(1).max(200).meta({ label: "Entity", ref: "entity", hint: "The entity type this pipeline tracks" }),
|
|
8606
|
+
/**
|
|
8607
|
+
* Optional Kanban column color token for UI rendering.
|
|
8608
|
+
*/
|
|
8609
|
+
kanbanColor: z.string().trim().min(1).max(40).optional().meta({ label: "Kanban color", hint: "UI color token" })
|
|
8610
|
+
});
|
|
8611
|
+
var pipelineKind = defineContentType({
|
|
8612
|
+
kind: "schema",
|
|
8613
|
+
type: "pipeline",
|
|
8614
|
+
label: "Pipeline",
|
|
8615
|
+
description: "A named progression pipeline that applies to a specific entity type.",
|
|
8616
|
+
payloadSchema: PipelinePayloadSchema,
|
|
8617
|
+
parentTypes: []
|
|
8618
|
+
});
|
|
8619
|
+
var StagePayloadSchema = z.object({
|
|
8620
|
+
/**
|
|
8621
|
+
* Semantic classification for this stage.
|
|
8622
|
+
* Drives color, icon, and CRM-priority logic in consuming views.
|
|
8623
|
+
* Optional — prospecting stages use data.entityKind instead.
|
|
8624
|
+
* Enum aligned with SalesStageSemanticClassSchema (sales.ts).
|
|
8625
|
+
*/
|
|
8626
|
+
semanticClass: z.enum(["open", "active", "nurturing", "closed_won", "closed_lost", "won", "lost", "closed"]).optional().meta({ label: "Semantic class", hint: "Semantic meaning of this stage", color: "blue" })
|
|
8627
|
+
});
|
|
8628
|
+
var stageKind = defineContentType({
|
|
8629
|
+
kind: "schema",
|
|
8630
|
+
type: "stage",
|
|
8631
|
+
label: "Stage",
|
|
8632
|
+
description: "A stage within a pipeline. Must be parented under a schema:pipeline content node.",
|
|
8633
|
+
payloadSchema: StagePayloadSchema,
|
|
8634
|
+
parentTypes: ["schema:pipeline"]
|
|
8635
|
+
});
|
|
8636
|
+
var TemplatePayloadSchema = z.object({
|
|
8637
|
+
/**
|
|
8638
|
+
* Optional description surfaced in the KB describe view and tooling.
|
|
8639
|
+
*/
|
|
8640
|
+
description: z.string().trim().min(1).max(2e3).optional().meta({ label: "Description", hint: "What this template is used for" })
|
|
8641
|
+
});
|
|
8642
|
+
var templateKind = defineContentType({
|
|
8643
|
+
kind: "schema",
|
|
8644
|
+
type: "template",
|
|
8645
|
+
label: "Template",
|
|
8646
|
+
description: "A named build template (e.g. a prospecting pipeline sequence).",
|
|
8647
|
+
payloadSchema: TemplatePayloadSchema,
|
|
8648
|
+
parentTypes: []
|
|
8649
|
+
});
|
|
8650
|
+
var TemplateStepPayloadSchema = z.object({
|
|
8651
|
+
/**
|
|
8652
|
+
* Which entity type this step primarily operates on.
|
|
8653
|
+
*/
|
|
8654
|
+
primaryEntity: z.enum(["company", "contact"]).meta({ label: "Primary entity", hint: "Entity type this step processes", color: "blue" }),
|
|
8655
|
+
/**
|
|
8656
|
+
* Action key identifying the workflow action executed by this step.
|
|
8657
|
+
* `.meta({ ref: 'action' })` enables SchemaDrivenFieldList to render a
|
|
8658
|
+
* clickable graph link.
|
|
8659
|
+
*/
|
|
8660
|
+
actionKey: z.string().trim().min(1).max(200).meta({ label: "Action", ref: "action", hint: "Workflow action executed by this step" }),
|
|
8661
|
+
/**
|
|
8662
|
+
* IDs of sibling step local NodeIds this step depends on.
|
|
8663
|
+
*/
|
|
8664
|
+
dependsOn: z.array(z.string().trim().min(1).max(200)).optional().meta({ label: "Depends on", hint: "Local NodeIds of prerequisite steps" })
|
|
8665
|
+
});
|
|
8666
|
+
var templateStepKind = defineContentType({
|
|
8667
|
+
kind: "schema",
|
|
8668
|
+
type: "template-step",
|
|
8669
|
+
label: "Template Step",
|
|
8670
|
+
description: "A step within a build template. Must be parented under a schema:template content node.",
|
|
8671
|
+
payloadSchema: TemplateStepPayloadSchema,
|
|
8672
|
+
parentTypes: ["schema:template"]
|
|
8673
|
+
});
|
|
8674
|
+
var StatusFlowPayloadSchema = z.object({
|
|
8675
|
+
/**
|
|
8676
|
+
* Which entity scope this status flow governs.
|
|
8677
|
+
*/
|
|
8678
|
+
appliesTo: z.enum(["project", "milestone", "task"]).meta({ label: "Applies to", hint: "Entity scope governed by this status flow", color: "blue" })
|
|
8679
|
+
});
|
|
8680
|
+
var statusFlowKind = defineContentType({
|
|
8681
|
+
kind: "schema",
|
|
8682
|
+
type: "status-flow",
|
|
8683
|
+
label: "Status Flow",
|
|
8684
|
+
description: "A named set of statuses governing a project, milestone, or task entity.",
|
|
8685
|
+
payloadSchema: StatusFlowPayloadSchema,
|
|
8686
|
+
parentTypes: []
|
|
8687
|
+
});
|
|
8688
|
+
var StatusPayloadSchema = z.object({
|
|
8689
|
+
/**
|
|
8690
|
+
* Semantic classification string for this status.
|
|
8691
|
+
* Free-form to allow tenant-defined classifications (e.g. 'active', 'blocked',
|
|
8692
|
+
* 'completed'). Used by UI to apply color and icon fallbacks.
|
|
8693
|
+
* Optional — status nodes may omit this when the label is self-descriptive.
|
|
8694
|
+
*/
|
|
8695
|
+
semanticClass: z.string().trim().min(1).max(100).optional().meta({ label: "Semantic class", hint: "Semantic meaning of this status (e.g. active, blocked, completed)" }),
|
|
8696
|
+
/**
|
|
8697
|
+
* Optional UI color token override for this status.
|
|
8698
|
+
*/
|
|
8699
|
+
color: z.string().trim().min(1).max(40).optional().meta({ label: "Color", hint: "UI color token" })
|
|
8700
|
+
});
|
|
8701
|
+
var statusKind = defineContentType({
|
|
8702
|
+
kind: "schema",
|
|
8703
|
+
type: "status",
|
|
8704
|
+
label: "Status",
|
|
8705
|
+
description: "A single status within a status flow. Must be parented under a schema:status-flow content node.",
|
|
8706
|
+
payloadSchema: StatusPayloadSchema,
|
|
8707
|
+
parentTypes: ["schema:status-flow"]
|
|
8708
|
+
});
|
|
8709
|
+
var ConfigKvPayloadSchema = z.object({
|
|
8710
|
+
/**
|
|
8711
|
+
* Flat key-value entries. Values are JSON primitives.
|
|
8712
|
+
* Keys are short identifiers (e.g. 'maxBatchSize', 'featureEnabled').
|
|
8713
|
+
*/
|
|
8714
|
+
entries: z.record(z.string().trim().min(1).max(200), z.union([z.string(), z.number(), z.boolean(), z.null()])).meta({ label: "Entries", hint: "Key-value configuration entries (string, number, boolean, or null values)" })
|
|
8715
|
+
});
|
|
8716
|
+
var configKvKind = defineContentType({
|
|
8717
|
+
kind: "config",
|
|
8718
|
+
type: "kv",
|
|
8719
|
+
label: "Key-Value Config",
|
|
8720
|
+
description: "A flat key-value configuration store co-located with a system. Values are JSON primitives.",
|
|
8721
|
+
payloadSchema: ConfigKvPayloadSchema,
|
|
8722
|
+
parentTypes: []
|
|
8723
|
+
});
|
|
8724
|
+
|
|
8725
|
+
// ../core/src/organization-model/content-kinds/index.ts
|
|
8726
|
+
var CONTENT_KIND_REGISTRY = {
|
|
8727
|
+
"schema:pipeline": pipelineKind,
|
|
8728
|
+
"schema:stage": stageKind,
|
|
8729
|
+
"schema:template": templateKind,
|
|
8730
|
+
"schema:template-step": templateStepKind,
|
|
8731
|
+
"schema:status-flow": statusFlowKind,
|
|
8732
|
+
"schema:status": statusKind,
|
|
8733
|
+
"config:kv": configKvKind
|
|
8734
|
+
};
|
|
8735
|
+
function lookupContentType(kind, type3) {
|
|
8736
|
+
const key = `${kind}:${type3}`;
|
|
8737
|
+
return CONTENT_KIND_REGISTRY[key];
|
|
8738
|
+
}
|
|
8739
|
+
var SurfaceTypeSchema = z.enum(["page", "dashboard", "graph", "detail", "list", "settings"]).meta({ label: "Surface type", color: "blue" });
|
|
8740
|
+
z.object({
|
|
8741
|
+
id: ModelIdSchema,
|
|
8742
|
+
label: LabelSchema,
|
|
8743
|
+
path: PathSchema,
|
|
8744
|
+
surfaceType: SurfaceTypeSchema,
|
|
8745
|
+
description: DescriptionSchema.optional(),
|
|
8746
|
+
enabled: z.boolean().default(true),
|
|
8747
|
+
devOnly: z.boolean().optional(),
|
|
8748
|
+
icon: IconNameSchema.optional(),
|
|
8749
|
+
systemIds: z.array(ModelIdSchema.meta({ ref: "system" })).default([]),
|
|
8750
|
+
entityIds: z.array(ModelIdSchema.meta({ ref: "entity" })).default([]),
|
|
8751
|
+
resourceIds: z.array(ModelIdSchema.meta({ ref: "resource" })).default([]),
|
|
8752
|
+
actionIds: z.array(ModelIdSchema.meta({ ref: "action" })).default([]),
|
|
8753
|
+
parentId: ModelIdSchema.meta({ ref: "surface" }).optional()
|
|
8754
|
+
});
|
|
8755
|
+
var SidebarSurfaceTargetsSchema = z.object({
|
|
8756
|
+
systems: z.array(ModelIdSchema.meta({ ref: "system" })).default([]).optional(),
|
|
8757
|
+
entities: z.array(ModelIdSchema.meta({ ref: "entity" })).default([]).optional(),
|
|
8758
|
+
resources: z.array(ModelIdSchema.meta({ ref: "resource" })).default([]).optional(),
|
|
8759
|
+
actions: z.array(ModelIdSchema.meta({ ref: "action" })).default([]).optional()
|
|
8760
|
+
}).default({});
|
|
8761
|
+
var SidebarNodeSchema = z.lazy(
|
|
8762
|
+
() => z.discriminatedUnion("type", [
|
|
8763
|
+
z.object({
|
|
8764
|
+
type: z.literal("group"),
|
|
8765
|
+
label: LabelSchema,
|
|
8766
|
+
description: DescriptionSchema.optional(),
|
|
8767
|
+
icon: IconNameSchema.optional(),
|
|
8768
|
+
order: z.number().int().optional(),
|
|
8769
|
+
children: z.record(z.string(), SidebarNodeSchema).default({})
|
|
8770
|
+
}),
|
|
8771
|
+
z.object({
|
|
8772
|
+
type: z.literal("surface"),
|
|
8773
|
+
label: LabelSchema,
|
|
8774
|
+
path: PathSchema,
|
|
8775
|
+
surfaceType: SurfaceTypeSchema,
|
|
8776
|
+
description: DescriptionSchema.optional(),
|
|
8777
|
+
icon: IconNameSchema.optional(),
|
|
8778
|
+
order: z.number().int().optional(),
|
|
8779
|
+
targets: SidebarSurfaceTargetsSchema.optional(),
|
|
8780
|
+
devOnly: z.boolean().optional(),
|
|
8781
|
+
requiresAdmin: z.boolean().optional()
|
|
8782
|
+
})
|
|
8783
|
+
])
|
|
8784
|
+
);
|
|
8785
|
+
var SidebarSectionSchema = z.record(z.string(), SidebarNodeSchema).default({});
|
|
8786
|
+
var SidebarNavigationSchema = z.object({
|
|
8787
|
+
primary: SidebarSectionSchema,
|
|
8788
|
+
bottom: SidebarSectionSchema
|
|
8789
|
+
}).default({ primary: {}, bottom: {} });
|
|
8790
|
+
var OrganizationModelNavigationSchema = z.object({
|
|
8791
|
+
sidebar: SidebarNavigationSchema
|
|
8792
|
+
}).default({ sidebar: { primary: {}, bottom: {} } });
|
|
8793
|
+
z.object({
|
|
8794
|
+
id: ModelIdSchema,
|
|
8795
|
+
label: LabelSchema,
|
|
8796
|
+
placement: z.string().trim().min(1).max(50),
|
|
8797
|
+
surfaceIds: z.array(ModelIdSchema.meta({ ref: "surface" })).default([])
|
|
8798
|
+
});
|
|
8799
|
+
var KnowledgeTargetKindSchema = z.enum([
|
|
8800
|
+
"system",
|
|
8801
|
+
"resource",
|
|
8802
|
+
"knowledge",
|
|
8803
|
+
"stage",
|
|
8804
|
+
"action",
|
|
8805
|
+
"role",
|
|
8806
|
+
"goal",
|
|
8807
|
+
"customer-segment",
|
|
8808
|
+
"offering",
|
|
8809
|
+
"ontology",
|
|
8810
|
+
// D4: content nodes are a valid knowledge target after compound-domain data moved into system.content
|
|
8811
|
+
"content-node"
|
|
8812
|
+
]).meta({ label: "Target kind" });
|
|
8813
|
+
var KnowledgeTargetRefSchema = z.object({
|
|
8814
|
+
kind: KnowledgeTargetKindSchema,
|
|
8815
|
+
// D4: content-node targets use a qualified id format '<system-path>:<local-content-id>'.
|
|
8816
|
+
// Ontology targets use the canonical '<scope>:<kind>/<local-id>' ontology id format.
|
|
8817
|
+
// Business-logic validation of target existence is done in OrganizationModelSchema.superRefine.
|
|
8818
|
+
id: z.string().trim().min(1).max(300)
|
|
8819
|
+
}).superRefine((target, ctx) => {
|
|
8820
|
+
if (target.kind !== "ontology") return;
|
|
8821
|
+
const result = OntologyIdSchema.safeParse(target.id);
|
|
8822
|
+
if (!result.success) {
|
|
8823
|
+
ctx.addIssue({
|
|
8824
|
+
code: z.ZodIssueCode.custom,
|
|
8825
|
+
path: ["id"],
|
|
8826
|
+
message: "Ontology knowledge targets must use <system-path>:<kind>/<local-id> or global:<kind>/<local-id>"
|
|
8827
|
+
});
|
|
8828
|
+
}
|
|
8829
|
+
});
|
|
8830
|
+
var LegacyKnowledgeLinkSchema = z.object({
|
|
8831
|
+
nodeId: z.union([NodeIdStringSchema, z.templateLiteral(["ontology:", OntologyIdSchema])])
|
|
8832
|
+
});
|
|
8833
|
+
var CanonicalKnowledgeLinkSchema = z.object({
|
|
8834
|
+
target: KnowledgeTargetRefSchema
|
|
8835
|
+
});
|
|
8836
|
+
function nodeIdFromTarget(target) {
|
|
8837
|
+
return `${target.kind}:${target.id}`;
|
|
8838
|
+
}
|
|
8839
|
+
function targetFromNodeId(nodeId) {
|
|
8840
|
+
const [kind, ...idParts] = nodeId.split(":");
|
|
8841
|
+
return {
|
|
8842
|
+
kind: KnowledgeTargetKindSchema.parse(kind),
|
|
8843
|
+
id: idParts.join(":")
|
|
8844
|
+
};
|
|
8845
|
+
}
|
|
8846
|
+
var KnowledgeLinkSchema = z.union([CanonicalKnowledgeLinkSchema, LegacyKnowledgeLinkSchema]).transform((link) => {
|
|
8847
|
+
const target = "target" in link ? link.target : targetFromNodeId(link.nodeId);
|
|
8848
|
+
return {
|
|
8849
|
+
target,
|
|
8850
|
+
nodeId: nodeIdFromTarget(target)
|
|
8851
|
+
};
|
|
8852
|
+
});
|
|
8853
|
+
var OrgKnowledgeKindSchema = z.enum(["playbook", "strategy", "reference"]).meta({ label: "Knowledge kind", color: "grape" });
|
|
8854
|
+
var OrgKnowledgeNodeSchema = z.object({
|
|
8855
|
+
id: ModelIdSchema,
|
|
8856
|
+
kind: OrgKnowledgeKindSchema,
|
|
8857
|
+
title: z.string().trim().min(1).max(200),
|
|
8858
|
+
summary: z.string().trim().min(1).max(1e3),
|
|
8859
|
+
icon: IconNameSchema.optional(),
|
|
8860
|
+
/** Canonical documentation URL when body content is a local summary. */
|
|
8861
|
+
externalUrl: z.string().trim().url().max(500).optional(),
|
|
8862
|
+
/** Optional generated source file path for local MDX-backed knowledge nodes. */
|
|
8863
|
+
sourceFilePath: z.string().trim().min(1).max(500).optional(),
|
|
8864
|
+
/** Raw MDX string. Phase 2 will introduce a structured block format. */
|
|
8865
|
+
body: z.string().trim().min(1),
|
|
8866
|
+
/**
|
|
8867
|
+
* Graph links to other OM nodes this knowledge node governs.
|
|
8868
|
+
* Each link emits a `governs` edge: knowledge-node -> target node.
|
|
8869
|
+
*/
|
|
8870
|
+
links: z.array(KnowledgeLinkSchema).default([]),
|
|
8871
|
+
/** Role identifiers that own this knowledge node. */
|
|
8872
|
+
ownerIds: z.array(RoleIdSchema.meta({ ref: "role" })).default([]),
|
|
8873
|
+
/** ISO date string (YYYY-MM-DD or full ISO 8601) of last meaningful update. */
|
|
8874
|
+
updatedAt: z.string().trim().min(1).max(50)
|
|
8875
|
+
});
|
|
8876
|
+
var KnowledgeDomainSchema = z.record(ModelIdSchema, OrgKnowledgeNodeSchema).default({});
|
|
8877
|
+
|
|
8878
|
+
// ../core/src/organization-model/schema.ts
|
|
8879
|
+
z.enum([
|
|
8880
|
+
"branding",
|
|
8881
|
+
"identity",
|
|
8882
|
+
"customers",
|
|
8883
|
+
"offerings",
|
|
8884
|
+
"roles",
|
|
8885
|
+
"goals",
|
|
8886
|
+
"systems",
|
|
8887
|
+
"ontology",
|
|
8888
|
+
"resources",
|
|
8889
|
+
"actions",
|
|
8890
|
+
"entities",
|
|
8891
|
+
"policies",
|
|
8892
|
+
"knowledge"
|
|
8893
|
+
]);
|
|
8894
|
+
var OrganizationModelDomainMetadataSchema = z.object({
|
|
8895
|
+
version: z.literal(1).default(1),
|
|
8896
|
+
lastModified: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "lastModified must be an ISO date string (YYYY-MM-DD)")
|
|
8897
|
+
});
|
|
8898
|
+
var DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA = {
|
|
8899
|
+
branding: { version: 1, lastModified: "2026-05-10" },
|
|
8900
|
+
identity: { version: 1, lastModified: "2026-05-10" },
|
|
8901
|
+
customers: { version: 1, lastModified: "2026-05-10" },
|
|
8902
|
+
offerings: { version: 1, lastModified: "2026-05-10" },
|
|
8903
|
+
roles: { version: 1, lastModified: "2026-05-10" },
|
|
8904
|
+
goals: { version: 1, lastModified: "2026-05-10" },
|
|
8905
|
+
systems: { version: 1, lastModified: "2026-05-10" },
|
|
8906
|
+
ontology: { version: 1, lastModified: "2026-05-14" },
|
|
8907
|
+
resources: { version: 1, lastModified: "2026-05-10" },
|
|
8908
|
+
actions: { version: 1, lastModified: "2026-05-10" },
|
|
8909
|
+
entities: { version: 1, lastModified: "2026-05-10" },
|
|
8910
|
+
policies: { version: 1, lastModified: "2026-05-10" },
|
|
8911
|
+
knowledge: { version: 1, lastModified: "2026-05-10" }
|
|
8912
|
+
};
|
|
8913
|
+
var OrganizationModelDomainMetadataByDomainSchema = z.object({
|
|
8914
|
+
branding: OrganizationModelDomainMetadataSchema,
|
|
8915
|
+
identity: OrganizationModelDomainMetadataSchema,
|
|
8916
|
+
customers: OrganizationModelDomainMetadataSchema,
|
|
8917
|
+
offerings: OrganizationModelDomainMetadataSchema,
|
|
8918
|
+
roles: OrganizationModelDomainMetadataSchema,
|
|
8919
|
+
goals: OrganizationModelDomainMetadataSchema,
|
|
8920
|
+
systems: OrganizationModelDomainMetadataSchema,
|
|
8921
|
+
ontology: OrganizationModelDomainMetadataSchema,
|
|
8922
|
+
resources: OrganizationModelDomainMetadataSchema,
|
|
8923
|
+
actions: OrganizationModelDomainMetadataSchema,
|
|
8924
|
+
entities: OrganizationModelDomainMetadataSchema,
|
|
8925
|
+
policies: OrganizationModelDomainMetadataSchema,
|
|
8926
|
+
knowledge: OrganizationModelDomainMetadataSchema
|
|
8927
|
+
}).partial().default(DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA).transform((metadata) => ({ ...DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA, ...metadata }));
|
|
8928
|
+
var OrganizationModelSchemaBase = z.object({
|
|
8929
|
+
version: z.literal(1).default(1),
|
|
8930
|
+
domainMetadata: OrganizationModelDomainMetadataByDomainSchema,
|
|
8931
|
+
branding: OrganizationModelBrandingSchema,
|
|
8932
|
+
navigation: OrganizationModelNavigationSchema,
|
|
8933
|
+
identity: IdentityDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_IDENTITY),
|
|
8934
|
+
customers: CustomersDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_CUSTOMERS),
|
|
8935
|
+
offerings: OfferingsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_OFFERINGS),
|
|
8936
|
+
roles: RolesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ROLES),
|
|
8937
|
+
goals: GoalsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_GOALS),
|
|
8938
|
+
systems: SystemsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_SYSTEMS),
|
|
8939
|
+
ontology: OntologyScopeSchema.default(DEFAULT_ONTOLOGY_SCOPE),
|
|
8940
|
+
resources: ResourcesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_RESOURCES),
|
|
8941
|
+
actions: ActionsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ACTIONS),
|
|
8942
|
+
entities: EntitiesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ENTITIES),
|
|
8943
|
+
policies: PoliciesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_POLICIES),
|
|
8944
|
+
// D3: flat Record<id, OrgKnowledgeNode> — no wrapper object
|
|
8945
|
+
knowledge: KnowledgeDomainSchema.default({})
|
|
8946
|
+
});
|
|
8947
|
+
function addIssue(ctx, path, message) {
|
|
8948
|
+
ctx.addIssue({
|
|
8949
|
+
code: z.ZodIssueCode.custom,
|
|
8950
|
+
path,
|
|
8951
|
+
message
|
|
8952
|
+
});
|
|
8953
|
+
}
|
|
8954
|
+
function isLifecycleEnabled(lifecycle, enabled) {
|
|
8955
|
+
if (enabled === false) return false;
|
|
8956
|
+
return lifecycle !== "deprecated" && lifecycle !== "archived";
|
|
8957
|
+
}
|
|
8958
|
+
function defaultSystemPathFor(id) {
|
|
8959
|
+
return `/${id.replaceAll(".", "/")}`;
|
|
8960
|
+
}
|
|
8961
|
+
function asRoleHolderArray(heldBy) {
|
|
8962
|
+
return Array.isArray(heldBy) ? heldBy : [heldBy];
|
|
8963
|
+
}
|
|
8964
|
+
function isKnowledgeKindCompatibleWithTarget(knowledgeKind, targetKind) {
|
|
8965
|
+
if (knowledgeKind === "reference") return true;
|
|
8966
|
+
if (knowledgeKind === "playbook") {
|
|
8967
|
+
return ["system", "resource", "stage", "action", "ontology"].includes(targetKind);
|
|
8968
|
+
}
|
|
8969
|
+
if (knowledgeKind === "strategy") {
|
|
8970
|
+
return ["system", "goal", "offering", "customer-segment", "ontology"].includes(targetKind);
|
|
8971
|
+
}
|
|
8972
|
+
return false;
|
|
8973
|
+
}
|
|
8974
|
+
function isRecord(value) {
|
|
8975
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8976
|
+
}
|
|
8977
|
+
OrganizationModelSchemaBase.superRefine((model, ctx) => {
|
|
8978
|
+
function collectAllSystems(systems, prefix = "", schemaPath = ["systems"]) {
|
|
8979
|
+
const result = [];
|
|
8980
|
+
for (const [key, system] of Object.entries(systems)) {
|
|
8981
|
+
const path = prefix ? `${prefix}.${key}` : key;
|
|
8982
|
+
const currentSchemaPath = [...schemaPath, key];
|
|
8983
|
+
result.push({ path, schemaPath: currentSchemaPath, system });
|
|
8984
|
+
const childSystems = system.systems ?? system.subsystems;
|
|
8985
|
+
if (childSystems !== void 0) {
|
|
8986
|
+
result.push(
|
|
8987
|
+
...collectAllSystems(childSystems, path, [...currentSchemaPath, system.systems !== void 0 ? "systems" : "subsystems"])
|
|
8988
|
+
);
|
|
8989
|
+
}
|
|
8990
|
+
}
|
|
8991
|
+
return result;
|
|
8992
|
+
}
|
|
8993
|
+
const allSystems = collectAllSystems(model.systems);
|
|
8994
|
+
const systemsById = /* @__PURE__ */ new Map();
|
|
8995
|
+
for (const { path, system } of allSystems) {
|
|
8996
|
+
systemsById.set(path, system);
|
|
8997
|
+
systemsById.set(system.id, system);
|
|
8998
|
+
}
|
|
8999
|
+
const systemIdsByEffectivePath = /* @__PURE__ */ new Map();
|
|
9000
|
+
allSystems.forEach(({ path, schemaPath, system }) => {
|
|
9001
|
+
if (system.parentSystemId !== void 0 && !systemsById.has(system.parentSystemId)) {
|
|
9002
|
+
addIssue(
|
|
9003
|
+
ctx,
|
|
9004
|
+
[...schemaPath, "parentSystemId"],
|
|
9005
|
+
`System "${system.id}" references unknown parent "${system.parentSystemId}"`
|
|
9006
|
+
);
|
|
9007
|
+
}
|
|
9008
|
+
const hasChildren = Object.keys(system.systems ?? system.subsystems ?? {}).length > 0 || allSystems.some((candidate) => candidate.path.startsWith(`${path}.`) && !candidate.path.slice(path.length + 1).includes("."));
|
|
9009
|
+
const contributesRoutePath = system.ui?.path !== void 0 || system.path !== void 0 || !hasChildren;
|
|
9010
|
+
if (contributesRoutePath) {
|
|
9011
|
+
const effectivePath = system.ui?.path ?? system.path ?? defaultSystemPathFor(path);
|
|
9012
|
+
const existingSystemId = systemIdsByEffectivePath.get(effectivePath);
|
|
9013
|
+
if (existingSystemId !== void 0) {
|
|
9014
|
+
addIssue(
|
|
9015
|
+
ctx,
|
|
9016
|
+
[...schemaPath, system.ui?.path !== void 0 ? "ui" : "path"],
|
|
9017
|
+
`System "${path}" effective path "${effectivePath}" duplicates system "${existingSystemId}"`
|
|
9018
|
+
);
|
|
9019
|
+
} else {
|
|
9020
|
+
systemIdsByEffectivePath.set(effectivePath, path);
|
|
9021
|
+
}
|
|
9022
|
+
}
|
|
9023
|
+
if (hasChildren && isLifecycleEnabled(system.lifecycle, system.enabled)) {
|
|
9024
|
+
const hasEnabledDescendant = Object.values(system.systems ?? system.subsystems ?? {}).some(
|
|
9025
|
+
(candidate) => isLifecycleEnabled(candidate.lifecycle, candidate.enabled)
|
|
9026
|
+
) || allSystems.some(
|
|
9027
|
+
(candidate) => candidate.path.startsWith(`${path}.`) && !candidate.path.slice(path.length + 1).includes(".") && isLifecycleEnabled(candidate.system.lifecycle, candidate.system.enabled)
|
|
9028
|
+
);
|
|
9029
|
+
if (!hasEnabledDescendant) {
|
|
9030
|
+
addIssue(
|
|
9031
|
+
ctx,
|
|
9032
|
+
[...schemaPath, "lifecycle"],
|
|
9033
|
+
`System "${path}" is active but has no active descendants`
|
|
9034
|
+
);
|
|
9035
|
+
}
|
|
9036
|
+
}
|
|
9037
|
+
});
|
|
9038
|
+
allSystems.forEach(({ schemaPath, system }) => {
|
|
9039
|
+
const visited = /* @__PURE__ */ new Set();
|
|
9040
|
+
let currentParentId = system.parentSystemId;
|
|
9041
|
+
while (currentParentId !== void 0) {
|
|
9042
|
+
if (currentParentId === system.id || visited.has(currentParentId)) {
|
|
9043
|
+
addIssue(ctx, [...schemaPath, "parentSystemId"], `System "${system.id}" has a parent cycle`);
|
|
9044
|
+
return;
|
|
9045
|
+
}
|
|
9046
|
+
visited.add(currentParentId);
|
|
9047
|
+
currentParentId = systemsById.get(currentParentId)?.parentSystemId;
|
|
9048
|
+
}
|
|
9049
|
+
});
|
|
9050
|
+
function normalizeRoutePath(path) {
|
|
9051
|
+
return path.length > 1 ? path.replace(/\/+$/, "") : path;
|
|
9052
|
+
}
|
|
9053
|
+
const sidebarNodeIds = /* @__PURE__ */ new Map();
|
|
9054
|
+
const sidebarSurfacePaths = /* @__PURE__ */ new Map();
|
|
9055
|
+
const sidebarSurfaces = [];
|
|
9056
|
+
function collectSidebarNodes(nodes, schemaPath) {
|
|
9057
|
+
Object.entries(nodes).forEach(([nodeId, node]) => {
|
|
9058
|
+
const nodePath = [...schemaPath, nodeId];
|
|
9059
|
+
const existingNodePath = sidebarNodeIds.get(nodeId);
|
|
9060
|
+
if (existingNodePath !== void 0) {
|
|
9061
|
+
addIssue(ctx, nodePath, `Sidebar node id "${nodeId}" duplicates another sidebar node`);
|
|
9062
|
+
} else {
|
|
9063
|
+
sidebarNodeIds.set(nodeId, nodePath);
|
|
9064
|
+
}
|
|
9065
|
+
if (node.type === "group") {
|
|
9066
|
+
collectSidebarNodes(node.children, [...nodePath, "children"]);
|
|
9067
|
+
return;
|
|
9068
|
+
}
|
|
9069
|
+
sidebarSurfaces.push({ id: nodeId, node, path: nodePath });
|
|
9070
|
+
const normalizedPath = normalizeRoutePath(node.path);
|
|
9071
|
+
const existingSurfaceId = sidebarSurfacePaths.get(normalizedPath);
|
|
9072
|
+
if (existingSurfaceId !== void 0) {
|
|
9073
|
+
addIssue(
|
|
9074
|
+
ctx,
|
|
9075
|
+
[...nodePath, "path"],
|
|
9076
|
+
`Sidebar surface path "${node.path}" duplicates surface "${existingSurfaceId}"`
|
|
9077
|
+
);
|
|
9078
|
+
} else {
|
|
9079
|
+
sidebarSurfacePaths.set(normalizedPath, nodeId);
|
|
9080
|
+
}
|
|
9081
|
+
node.targets?.systems?.forEach((systemId, systemIndex) => {
|
|
9082
|
+
if (!systemsById.has(systemId)) {
|
|
9083
|
+
addIssue(
|
|
9084
|
+
ctx,
|
|
9085
|
+
[...nodePath, "targets", "systems", systemIndex],
|
|
9086
|
+
`Sidebar surface "${nodeId}" references unknown system "${systemId}"`
|
|
9087
|
+
);
|
|
9088
|
+
}
|
|
9089
|
+
});
|
|
9090
|
+
});
|
|
9091
|
+
}
|
|
9092
|
+
collectSidebarNodes(model.navigation.sidebar.primary, ["navigation", "sidebar", "primary"]);
|
|
9093
|
+
collectSidebarNodes(model.navigation.sidebar.bottom, ["navigation", "sidebar", "bottom"]);
|
|
9094
|
+
const segmentsById = new Map(Object.entries(model.customers));
|
|
9095
|
+
Object.values(model.offerings).forEach((product) => {
|
|
9096
|
+
product.targetSegmentIds.forEach((segmentId, segmentIndex) => {
|
|
9097
|
+
if (!segmentsById.has(segmentId)) {
|
|
9098
|
+
addIssue(
|
|
9099
|
+
ctx,
|
|
9100
|
+
["offerings", product.id, "targetSegmentIds", segmentIndex],
|
|
9101
|
+
`Product "${product.id}" references unknown customer segment "${segmentId}"`
|
|
9102
|
+
);
|
|
9103
|
+
}
|
|
9104
|
+
});
|
|
9105
|
+
if (product.deliveryFeatureId !== void 0 && !systemsById.has(product.deliveryFeatureId)) {
|
|
9106
|
+
addIssue(
|
|
9107
|
+
ctx,
|
|
9108
|
+
["offerings", product.id, "deliveryFeatureId"],
|
|
9109
|
+
`Product "${product.id}" references unknown delivery system "${product.deliveryFeatureId}"`
|
|
9110
|
+
);
|
|
9111
|
+
}
|
|
9112
|
+
});
|
|
9113
|
+
Object.values(model.goals).forEach((objective) => {
|
|
9114
|
+
if (objective.periodEnd <= objective.periodStart) {
|
|
9115
|
+
addIssue(
|
|
9116
|
+
ctx,
|
|
9117
|
+
["goals", objective.id, "periodEnd"],
|
|
9118
|
+
`Goal "${objective.id}" has periodEnd "${objective.periodEnd}" which must be strictly after periodStart "${objective.periodStart}"`
|
|
9119
|
+
);
|
|
9120
|
+
}
|
|
9121
|
+
});
|
|
9122
|
+
const goalsById = new Map(Object.entries(model.goals));
|
|
9123
|
+
const knowledgeById = new Map(Object.entries(model.knowledge));
|
|
9124
|
+
const actionsById = new Map(Object.entries(model.actions));
|
|
9125
|
+
const entitiesById = new Map(Object.entries(model.entities));
|
|
9126
|
+
const policiesById = new Map(Object.entries(model.policies));
|
|
9127
|
+
sidebarSurfaces.forEach(({ id, node, path }) => {
|
|
9128
|
+
node.targets?.entities?.forEach((entityId, entityIndex) => {
|
|
9129
|
+
if (!entitiesById.has(entityId)) {
|
|
9130
|
+
addIssue(
|
|
9131
|
+
ctx,
|
|
9132
|
+
[...path, "targets", "entities", entityIndex],
|
|
9133
|
+
`Sidebar surface "${id}" references unknown entity "${entityId}"`
|
|
9134
|
+
);
|
|
9135
|
+
}
|
|
9136
|
+
});
|
|
9137
|
+
node.targets?.actions?.forEach((actionId, actionIndex) => {
|
|
9138
|
+
if (!actionsById.has(actionId)) {
|
|
9139
|
+
addIssue(
|
|
9140
|
+
ctx,
|
|
9141
|
+
[...path, "targets", "actions", actionIndex],
|
|
9142
|
+
`Sidebar surface "${id}" references unknown action "${actionId}"`
|
|
9143
|
+
);
|
|
9144
|
+
}
|
|
9145
|
+
});
|
|
9146
|
+
});
|
|
9147
|
+
Object.values(model.entities).forEach((entity) => {
|
|
9148
|
+
if (!systemsById.has(entity.ownedBySystemId)) {
|
|
9149
|
+
addIssue(
|
|
9150
|
+
ctx,
|
|
9151
|
+
["entities", entity.id, "ownedBySystemId"],
|
|
9152
|
+
`Entity "${entity.id}" references unknown ownedBySystemId "${entity.ownedBySystemId}"`
|
|
9153
|
+
);
|
|
9154
|
+
}
|
|
9155
|
+
entity.links?.forEach((link, linkIndex) => {
|
|
9156
|
+
if (!entitiesById.has(link.toEntity)) {
|
|
9157
|
+
addIssue(
|
|
9158
|
+
ctx,
|
|
9159
|
+
["entities", entity.id, "links", linkIndex, "toEntity"],
|
|
9160
|
+
`Entity "${entity.id}" links to unknown entity "${link.toEntity}"`
|
|
9161
|
+
);
|
|
9162
|
+
}
|
|
9163
|
+
});
|
|
9164
|
+
});
|
|
9165
|
+
const rolesById = new Map(Object.entries(model.roles));
|
|
9166
|
+
Object.values(model.roles).forEach((role) => {
|
|
9167
|
+
if (role.reportsToId !== void 0 && !rolesById.has(role.reportsToId)) {
|
|
9168
|
+
addIssue(
|
|
9169
|
+
ctx,
|
|
9170
|
+
["roles", role.id, "reportsToId"],
|
|
9171
|
+
`Role "${role.id}" references unknown reportsToId "${role.reportsToId}"`
|
|
9172
|
+
);
|
|
9173
|
+
}
|
|
9174
|
+
});
|
|
9175
|
+
Object.values(model.roles).forEach((role) => {
|
|
9176
|
+
const visited = /* @__PURE__ */ new Set();
|
|
9177
|
+
let currentReportsToId = role.reportsToId;
|
|
9178
|
+
while (currentReportsToId !== void 0) {
|
|
9179
|
+
if (currentReportsToId === role.id || visited.has(currentReportsToId)) {
|
|
9180
|
+
addIssue(ctx, ["roles", role.id, "reportsToId"], `Role "${role.id}" has a reportsToId cycle`);
|
|
9181
|
+
return;
|
|
9182
|
+
}
|
|
9183
|
+
visited.add(currentReportsToId);
|
|
9184
|
+
currentReportsToId = rolesById.get(currentReportsToId)?.reportsToId;
|
|
9185
|
+
}
|
|
9186
|
+
});
|
|
9187
|
+
Object.values(model.roles).forEach((role) => {
|
|
9188
|
+
role.responsibleFor?.forEach((systemId, systemIndex) => {
|
|
9189
|
+
if (!systemsById.has(systemId)) {
|
|
9190
|
+
addIssue(
|
|
9191
|
+
ctx,
|
|
9192
|
+
["roles", role.id, "responsibleFor", systemIndex],
|
|
9193
|
+
`Role "${role.id}" references unknown responsibleFor system "${systemId}"`
|
|
9194
|
+
);
|
|
9195
|
+
}
|
|
9196
|
+
});
|
|
9197
|
+
});
|
|
9198
|
+
allSystems.forEach(({ schemaPath, system }) => {
|
|
9199
|
+
if (system.responsibleRoleId !== void 0 && !rolesById.has(system.responsibleRoleId)) {
|
|
9200
|
+
addIssue(
|
|
9201
|
+
ctx,
|
|
9202
|
+
[...schemaPath, "responsibleRoleId"],
|
|
9203
|
+
`System "${system.id}" references unknown responsibleRoleId "${system.responsibleRoleId}"`
|
|
9204
|
+
);
|
|
9205
|
+
}
|
|
9206
|
+
system.governedByKnowledge?.forEach((nodeId, nodeIndex) => {
|
|
9207
|
+
if (!knowledgeById.has(nodeId)) {
|
|
9208
|
+
addIssue(
|
|
9209
|
+
ctx,
|
|
9210
|
+
[...schemaPath, "governedByKnowledge", nodeIndex],
|
|
9211
|
+
`System "${system.id}" references unknown knowledge node "${nodeId}"`
|
|
9212
|
+
);
|
|
9213
|
+
}
|
|
9214
|
+
});
|
|
9215
|
+
system.drivesGoals?.forEach((goalId, goalIndex) => {
|
|
9216
|
+
if (!goalsById.has(goalId)) {
|
|
9217
|
+
addIssue(
|
|
9218
|
+
ctx,
|
|
9219
|
+
[...schemaPath, "drivesGoals", goalIndex],
|
|
9220
|
+
`System "${system.id}" references unknown goal "${goalId}"`
|
|
9221
|
+
);
|
|
9222
|
+
}
|
|
9223
|
+
});
|
|
9224
|
+
system.actions?.forEach((actionRef, actionIndex) => {
|
|
9225
|
+
if (!actionsById.has(actionRef.actionId)) {
|
|
9226
|
+
addIssue(
|
|
9227
|
+
ctx,
|
|
9228
|
+
[...schemaPath, "actions", actionIndex, "actionId"],
|
|
9229
|
+
`System "${system.id}" references unknown action "${actionRef.actionId}"`
|
|
9230
|
+
);
|
|
9231
|
+
}
|
|
9232
|
+
});
|
|
9233
|
+
system.policies?.forEach((policyId, policyIndex) => {
|
|
9234
|
+
if (!policiesById.has(policyId)) {
|
|
9235
|
+
addIssue(
|
|
9236
|
+
ctx,
|
|
9237
|
+
[...schemaPath, "policies", policyIndex],
|
|
9238
|
+
`System "${system.id}" references unknown policy "${policyId}"`
|
|
9239
|
+
);
|
|
9240
|
+
}
|
|
9241
|
+
});
|
|
9242
|
+
});
|
|
9243
|
+
Object.values(model.actions).forEach((action) => {
|
|
9244
|
+
action.affects?.forEach((entityId, entityIndex) => {
|
|
9245
|
+
if (!entitiesById.has(entityId)) {
|
|
9246
|
+
addIssue(
|
|
9247
|
+
ctx,
|
|
9248
|
+
["actions", action.id, "affects", entityIndex],
|
|
9249
|
+
`Action "${action.id}" affects unknown entity "${entityId}"`
|
|
9250
|
+
);
|
|
9251
|
+
}
|
|
9252
|
+
});
|
|
9253
|
+
});
|
|
9254
|
+
const resourcesById = new Map(Object.entries(model.resources));
|
|
9255
|
+
sidebarSurfaces.forEach(({ id, node, path }) => {
|
|
9256
|
+
node.targets?.resources?.forEach((resourceId, resourceIndex) => {
|
|
9257
|
+
if (!resourcesById.has(resourceId)) {
|
|
9258
|
+
addIssue(
|
|
9259
|
+
ctx,
|
|
9260
|
+
[...path, "targets", "resources", resourceIndex],
|
|
9261
|
+
`Sidebar surface "${id}" references unknown resource "${resourceId}"`
|
|
9262
|
+
);
|
|
9263
|
+
}
|
|
9264
|
+
});
|
|
9265
|
+
});
|
|
9266
|
+
const stageIds = /* @__PURE__ */ new Set();
|
|
9267
|
+
const actionIds = new Set(Object.keys(model.actions));
|
|
9268
|
+
const offeringsById = new Map(Object.entries(model.offerings));
|
|
9269
|
+
const ontologyCompilation = compileOrganizationOntology(model);
|
|
9270
|
+
const ontologyIndexByKind = {
|
|
9271
|
+
object: ontologyCompilation.ontology.objectTypes,
|
|
9272
|
+
link: ontologyCompilation.ontology.linkTypes,
|
|
9273
|
+
action: ontologyCompilation.ontology.actionTypes,
|
|
9274
|
+
catalog: ontologyCompilation.ontology.catalogTypes,
|
|
9275
|
+
event: ontologyCompilation.ontology.eventTypes,
|
|
9276
|
+
interface: ontologyCompilation.ontology.interfaceTypes,
|
|
9277
|
+
"value-type": ontologyCompilation.ontology.valueTypes,
|
|
9278
|
+
property: ontologyCompilation.ontology.sharedProperties,
|
|
9279
|
+
group: ontologyCompilation.ontology.groups,
|
|
9280
|
+
surface: ontologyCompilation.ontology.surfaces
|
|
9281
|
+
};
|
|
9282
|
+
const ontologyIds = new Set(Object.values(ontologyIndexByKind).flatMap((index2) => Object.keys(index2)));
|
|
9283
|
+
const ontologyReferenceKeyKinds = {
|
|
9284
|
+
valueType: "value-type",
|
|
9285
|
+
catalogType: "catalog",
|
|
9286
|
+
objectType: "object",
|
|
9287
|
+
eventType: "event",
|
|
9288
|
+
actionType: "action",
|
|
9289
|
+
linkType: "link",
|
|
9290
|
+
interfaceType: "interface",
|
|
9291
|
+
propertyType: "property",
|
|
9292
|
+
groupType: "group",
|
|
9293
|
+
surfaceType: "surface",
|
|
9294
|
+
stepCatalog: "catalog"
|
|
9295
|
+
};
|
|
9296
|
+
function validateKnownOntologyReferences(ownerId, value, path, seen = /* @__PURE__ */ new WeakSet()) {
|
|
9297
|
+
if (Array.isArray(value)) {
|
|
9298
|
+
value.forEach((entry, index2) => validateKnownOntologyReferences(ownerId, entry, [...path, index2], seen));
|
|
9299
|
+
return;
|
|
9300
|
+
}
|
|
9301
|
+
if (!isRecord(value)) return;
|
|
9302
|
+
if (seen.has(value)) return;
|
|
9303
|
+
seen.add(value);
|
|
9304
|
+
Object.entries(value).forEach(([key, entry]) => {
|
|
9305
|
+
const expectedKind = ontologyReferenceKeyKinds[key];
|
|
9306
|
+
if (expectedKind !== void 0) {
|
|
9307
|
+
if (typeof entry !== "string") {
|
|
9308
|
+
addIssue(ctx, [...path, key], `Ontology record "${ownerId}" ${key} must be an ontology ID string`);
|
|
9309
|
+
} else if (ontologyIndexByKind[expectedKind][entry] === void 0) {
|
|
9310
|
+
addIssue(
|
|
9311
|
+
ctx,
|
|
9312
|
+
[...path, key],
|
|
9313
|
+
`Ontology record "${ownerId}" ${key} references unknown ${expectedKind} ontology ID "${entry}"`
|
|
9314
|
+
);
|
|
9315
|
+
}
|
|
9316
|
+
}
|
|
9317
|
+
validateKnownOntologyReferences(ownerId, entry, [...path, key], seen);
|
|
9318
|
+
});
|
|
9319
|
+
}
|
|
9320
|
+
for (const { id, record } of listResolvedOntologyRecords(ontologyCompilation.ontology)) {
|
|
9321
|
+
validateKnownOntologyReferences(id, record, record.origin.path);
|
|
9322
|
+
}
|
|
9323
|
+
Object.values(model.policies).forEach((policy) => {
|
|
9324
|
+
policy.appliesTo.systemIds.forEach((systemId, systemIndex) => {
|
|
9325
|
+
if (!systemsById.has(systemId)) {
|
|
9326
|
+
addIssue(
|
|
9327
|
+
ctx,
|
|
9328
|
+
["policies", policy.id, "appliesTo", "systemIds", systemIndex],
|
|
9329
|
+
`Policy "${policy.id}" applies to unknown system "${systemId}"`
|
|
9330
|
+
);
|
|
9331
|
+
}
|
|
9332
|
+
});
|
|
9333
|
+
policy.appliesTo.actionIds.forEach((actionId, actionIndex) => {
|
|
9334
|
+
if (!actionsById.has(actionId)) {
|
|
9335
|
+
addIssue(
|
|
9336
|
+
ctx,
|
|
9337
|
+
["policies", policy.id, "appliesTo", "actionIds", actionIndex],
|
|
9338
|
+
`Policy "${policy.id}" applies to unknown action "${actionId}"`
|
|
9339
|
+
);
|
|
9340
|
+
}
|
|
9341
|
+
});
|
|
9342
|
+
policy.actions.forEach((action, actionIndex) => {
|
|
9343
|
+
if (action.kind === "invoke-action" && !actionsById.has(action.actionId)) {
|
|
9344
|
+
addIssue(
|
|
9345
|
+
ctx,
|
|
9346
|
+
["policies", policy.id, "actions", actionIndex, "actionId"],
|
|
9347
|
+
`Policy "${policy.id}" invokes unknown action "${action.actionId}"`
|
|
9348
|
+
);
|
|
9349
|
+
}
|
|
9350
|
+
if ((action.kind === "notify-role" || action.kind === "require-approval") && action.roleId !== void 0 && !rolesById.has(action.roleId)) {
|
|
9351
|
+
addIssue(
|
|
9352
|
+
ctx,
|
|
9353
|
+
["policies", policy.id, "actions", actionIndex, "roleId"],
|
|
9354
|
+
`Policy "${policy.id}" references unknown role "${action.roleId}"`
|
|
9355
|
+
);
|
|
9356
|
+
}
|
|
9357
|
+
});
|
|
9358
|
+
if (policy.trigger.kind === "action-invocation" && !actionsById.has(policy.trigger.actionId)) {
|
|
9359
|
+
addIssue(
|
|
9360
|
+
ctx,
|
|
9361
|
+
["policies", policy.id, "trigger", "actionId"],
|
|
9362
|
+
`Policy "${policy.id}" references unknown trigger action "${policy.trigger.actionId}"`
|
|
9363
|
+
);
|
|
9364
|
+
}
|
|
9365
|
+
});
|
|
9366
|
+
function knowledgeTargetExists(kind, id) {
|
|
9367
|
+
if (kind === "system") return systemsById.has(id);
|
|
9368
|
+
if (kind === "resource") return resourcesById.has(id);
|
|
9369
|
+
if (kind === "knowledge") return knowledgeById.has(id);
|
|
9370
|
+
if (kind === "stage") return stageIds.has(id);
|
|
9371
|
+
if (kind === "action") return actionIds.has(id);
|
|
9372
|
+
if (kind === "role") return rolesById.has(id);
|
|
9373
|
+
if (kind === "goal") return goalsById.has(id);
|
|
9374
|
+
if (kind === "customer-segment") return segmentsById.has(id);
|
|
9375
|
+
if (kind === "offering") return offeringsById.has(id);
|
|
9376
|
+
if (kind === "ontology") return ontologyIds.has(id);
|
|
9377
|
+
return false;
|
|
9378
|
+
}
|
|
9379
|
+
Object.entries(model.knowledge).forEach(([nodeId, node]) => {
|
|
9380
|
+
node.links.forEach((link, linkIndex) => {
|
|
9381
|
+
if (!knowledgeTargetExists(link.target.kind, link.target.id)) {
|
|
9382
|
+
addIssue(
|
|
9383
|
+
ctx,
|
|
9384
|
+
["knowledge", nodeId, "links", linkIndex, "target"],
|
|
9385
|
+
`Knowledge node "${node.id}" references unknown ${link.target.kind} target "${link.target.id}"`
|
|
9386
|
+
);
|
|
9387
|
+
}
|
|
9388
|
+
if (!isKnowledgeKindCompatibleWithTarget(node.kind, link.target.kind)) {
|
|
9389
|
+
addIssue(
|
|
9390
|
+
ctx,
|
|
9391
|
+
["knowledge", nodeId, "links", linkIndex, "target", "kind"],
|
|
9392
|
+
`Knowledge node "${node.id}" kind "${node.kind}" cannot govern ${link.target.kind} targets`
|
|
9393
|
+
);
|
|
9394
|
+
}
|
|
9395
|
+
});
|
|
9396
|
+
});
|
|
9397
|
+
Object.values(model.resources).forEach((resource) => {
|
|
9398
|
+
if (!systemsById.has(resource.systemPath)) {
|
|
9399
|
+
addIssue(
|
|
9400
|
+
ctx,
|
|
9401
|
+
["resources", resource.id, "systemPath"],
|
|
9402
|
+
`Resource "${resource.id}" references unknown system path "${resource.systemPath}"`
|
|
9403
|
+
);
|
|
9404
|
+
}
|
|
9405
|
+
if (resource.ownerRoleId !== void 0 && !rolesById.has(resource.ownerRoleId)) {
|
|
9406
|
+
addIssue(
|
|
9407
|
+
ctx,
|
|
9408
|
+
["resources", resource.id, "ownerRoleId"],
|
|
9409
|
+
`Resource "${resource.id}" references unknown ownerRoleId "${resource.ownerRoleId}"`
|
|
9410
|
+
);
|
|
9411
|
+
}
|
|
9412
|
+
if (resource.kind === "agent" && resource.actsAsRoleId !== void 0 && !rolesById.has(resource.actsAsRoleId)) {
|
|
9413
|
+
addIssue(
|
|
9414
|
+
ctx,
|
|
9415
|
+
["resources", resource.id, "actsAsRoleId"],
|
|
9416
|
+
`Agent resource "${resource.id}" references unknown actsAsRoleId "${resource.actsAsRoleId}"`
|
|
9417
|
+
);
|
|
9418
|
+
}
|
|
9419
|
+
});
|
|
9420
|
+
function validateResourceOntologyBinding(resourceId, bindingKey, expectedKind, ids) {
|
|
9421
|
+
ids?.forEach((ontologyId, ontologyIndex) => {
|
|
9422
|
+
if (ontologyIndexByKind[expectedKind][ontologyId] === void 0) {
|
|
9423
|
+
addIssue(
|
|
9424
|
+
ctx,
|
|
9425
|
+
["resources", resourceId, "ontology", bindingKey, ontologyIndex],
|
|
9426
|
+
`Resource "${resourceId}" ontology binding "${bindingKey}" references unknown ${expectedKind} ontology ID "${ontologyId}"`
|
|
9427
|
+
);
|
|
9428
|
+
}
|
|
9429
|
+
});
|
|
9430
|
+
}
|
|
9431
|
+
Object.values(model.resources).forEach((resource) => {
|
|
9432
|
+
const binding = resource.ontology;
|
|
9433
|
+
if (binding === void 0) return;
|
|
9434
|
+
validateResourceOntologyBinding(resource.id, "implements", "action", binding.implements);
|
|
9435
|
+
validateResourceOntologyBinding(resource.id, "reads", "object", binding.reads);
|
|
9436
|
+
validateResourceOntologyBinding(resource.id, "writes", "object", binding.writes);
|
|
9437
|
+
validateResourceOntologyBinding(resource.id, "usesCatalogs", "catalog", binding.usesCatalogs);
|
|
9438
|
+
validateResourceOntologyBinding(resource.id, "emits", "event", binding.emits);
|
|
9439
|
+
});
|
|
9440
|
+
Object.values(model.roles).forEach((role) => {
|
|
9441
|
+
if (role.heldBy === void 0) return;
|
|
9442
|
+
asRoleHolderArray(role.heldBy).forEach((holder, holderIndex) => {
|
|
9443
|
+
if (holder.kind !== "agent") return;
|
|
9444
|
+
const resource = resourcesById.get(holder.agentId);
|
|
9445
|
+
if (resource === void 0) {
|
|
9446
|
+
addIssue(
|
|
9447
|
+
ctx,
|
|
9448
|
+
["roles", role.id, "heldBy", Array.isArray(role.heldBy) ? holderIndex : "agentId"],
|
|
9449
|
+
`Role "${role.id}" references unknown agent holder resource "${holder.agentId}"`
|
|
9450
|
+
);
|
|
9451
|
+
return;
|
|
9452
|
+
}
|
|
9453
|
+
if (resource.kind !== "agent") {
|
|
9454
|
+
addIssue(
|
|
9455
|
+
ctx,
|
|
9456
|
+
["roles", role.id, "heldBy", Array.isArray(role.heldBy) ? holderIndex : "agentId"],
|
|
9457
|
+
`Role "${role.id}" agent holder "${holder.agentId}" must reference an agent resource`
|
|
9458
|
+
);
|
|
9459
|
+
}
|
|
9460
|
+
});
|
|
9461
|
+
});
|
|
9462
|
+
Object.entries(model.knowledge).forEach(([nodeId, node]) => {
|
|
9463
|
+
node.ownerIds.forEach((roleId, ownerIndex) => {
|
|
9464
|
+
if (!rolesById.has(roleId)) {
|
|
9465
|
+
addIssue(
|
|
9466
|
+
ctx,
|
|
9467
|
+
["knowledge", nodeId, "ownerIds", ownerIndex],
|
|
9468
|
+
`Knowledge node "${node.id}" references unknown owner role "${roleId}"`
|
|
9469
|
+
);
|
|
9470
|
+
}
|
|
9471
|
+
});
|
|
9472
|
+
});
|
|
9473
|
+
function validateSystemContent(system, systemPath) {
|
|
9474
|
+
const childSystems = system.systems ?? system.subsystems;
|
|
9475
|
+
const childKey = system.systems !== void 0 ? "systems" : "subsystems";
|
|
9476
|
+
const content = system.content;
|
|
9477
|
+
if (content === void 0 || Object.keys(content).length === 0) {
|
|
9478
|
+
if (childSystems !== void 0) {
|
|
9479
|
+
Object.entries(childSystems).forEach(([childLocalId, child]) => {
|
|
9480
|
+
validateSystemContent(child, [...systemPath, childKey, childLocalId]);
|
|
9481
|
+
});
|
|
9482
|
+
}
|
|
9483
|
+
return;
|
|
9484
|
+
}
|
|
9485
|
+
Object.entries(content).forEach(([localId, node]) => {
|
|
9486
|
+
if (node.parentContentId !== void 0 && !(node.parentContentId in content)) {
|
|
9487
|
+
addIssue(
|
|
9488
|
+
ctx,
|
|
9489
|
+
[...systemPath, "content", localId, "parentContentId"],
|
|
9490
|
+
`Content node "${localId}" parentContentId "${node.parentContentId}" does not resolve within the same system`
|
|
9491
|
+
);
|
|
9492
|
+
}
|
|
9493
|
+
});
|
|
9494
|
+
Object.entries(content).forEach(([localId, node]) => {
|
|
9495
|
+
const visited = /* @__PURE__ */ new Set();
|
|
9496
|
+
let currentId = node.parentContentId;
|
|
9497
|
+
while (currentId !== void 0) {
|
|
9498
|
+
if (currentId === localId || visited.has(currentId)) {
|
|
9499
|
+
addIssue(
|
|
9500
|
+
ctx,
|
|
9501
|
+
[...systemPath, "content", localId, "parentContentId"],
|
|
9502
|
+
`Content node "${localId}" has a parentContentId cycle`
|
|
9503
|
+
);
|
|
9504
|
+
break;
|
|
9505
|
+
}
|
|
9506
|
+
visited.add(currentId);
|
|
9507
|
+
currentId = content[currentId]?.parentContentId;
|
|
9508
|
+
}
|
|
9509
|
+
});
|
|
9510
|
+
Object.entries(content).forEach(([localId, node]) => {
|
|
9511
|
+
const childDef = lookupContentType(node.kind, node.type);
|
|
9512
|
+
if (childDef !== void 0 && node.data !== void 0) {
|
|
9513
|
+
const result = childDef.payloadSchema.safeParse(node.data);
|
|
9514
|
+
if (!result.success) {
|
|
9515
|
+
addIssue(
|
|
9516
|
+
ctx,
|
|
9517
|
+
[...systemPath, "content", localId, "data"],
|
|
9518
|
+
`Content node "${localId}" (${node.kind}:${node.type}) data failed payload validation: ${result.error.message}`
|
|
9519
|
+
);
|
|
9520
|
+
}
|
|
9521
|
+
}
|
|
9522
|
+
if (node.parentContentId !== void 0 && childDef !== void 0) {
|
|
9523
|
+
const parentNode = content[node.parentContentId];
|
|
9524
|
+
if (parentNode !== void 0) {
|
|
9525
|
+
const parentDef = lookupContentType(parentNode.kind, parentNode.type);
|
|
9526
|
+
if (parentDef !== void 0 && childDef.kind !== parentDef.kind) {
|
|
9527
|
+
addIssue(
|
|
9528
|
+
ctx,
|
|
9529
|
+
[...systemPath, "content", localId, "parentContentId"],
|
|
9530
|
+
`Content node "${localId}" kind "${childDef.kind}" cannot parent under "${node.parentContentId}" kind "${parentDef.kind}": parentContentId must be same-meta-kind (per L19)`
|
|
9531
|
+
);
|
|
9532
|
+
}
|
|
9533
|
+
}
|
|
9534
|
+
}
|
|
9535
|
+
});
|
|
9536
|
+
if (childSystems !== void 0) {
|
|
9537
|
+
Object.entries(childSystems).forEach(([childLocalId, child]) => {
|
|
9538
|
+
validateSystemContent(child, [...systemPath, childKey, childLocalId]);
|
|
9539
|
+
});
|
|
9540
|
+
}
|
|
9541
|
+
}
|
|
9542
|
+
Object.entries(model.systems).forEach(([systemKey, system]) => {
|
|
9543
|
+
validateSystemContent(system, ["systems", systemKey]);
|
|
9544
|
+
});
|
|
9545
|
+
for (const diagnostic of ontologyCompilation.diagnostics) {
|
|
9546
|
+
addIssue(ctx, diagnostic.path, diagnostic.message);
|
|
9547
|
+
}
|
|
9548
|
+
});
|
|
9549
|
+
|
|
9550
|
+
// ../core/src/organization-model/defaults.ts
|
|
9551
|
+
var DEFAULT_ORGANIZATION_MODEL_KNOWLEDGE = {};
|
|
9552
|
+
var DEFAULT_ORGANIZATION_MODEL_ENTITIES2 = DEFAULT_ORGANIZATION_MODEL_ENTITIES;
|
|
9553
|
+
var DEFAULT_ORGANIZATION_MODEL_NAVIGATION = {
|
|
9554
|
+
sidebar: {
|
|
9555
|
+
primary: {
|
|
9556
|
+
dashboard: {
|
|
9557
|
+
type: "surface",
|
|
9558
|
+
label: "Dashboard",
|
|
9559
|
+
path: "/",
|
|
9560
|
+
surfaceType: "dashboard",
|
|
9561
|
+
icon: "dashboard",
|
|
9562
|
+
order: 10,
|
|
9563
|
+
targets: { systems: ["dashboard"] }
|
|
9564
|
+
},
|
|
9565
|
+
business: {
|
|
9566
|
+
type: "group",
|
|
9567
|
+
label: "Business",
|
|
9568
|
+
icon: "business",
|
|
9569
|
+
order: 20,
|
|
9570
|
+
children: {
|
|
9571
|
+
sales: {
|
|
9572
|
+
type: "surface",
|
|
9573
|
+
label: "Sales",
|
|
9574
|
+
path: "/sales",
|
|
9575
|
+
surfaceType: "page",
|
|
9576
|
+
icon: "sales",
|
|
9577
|
+
order: 10,
|
|
9578
|
+
targets: { systems: ["sales"] }
|
|
9579
|
+
},
|
|
9580
|
+
clients: {
|
|
9581
|
+
type: "surface",
|
|
9582
|
+
label: "Clients",
|
|
9583
|
+
path: "/clients",
|
|
9584
|
+
surfaceType: "list",
|
|
9585
|
+
icon: "projects",
|
|
9586
|
+
order: 20,
|
|
9587
|
+
targets: { systems: ["clients"] }
|
|
9588
|
+
},
|
|
9589
|
+
projects: {
|
|
9590
|
+
type: "surface",
|
|
9591
|
+
label: "Projects",
|
|
9592
|
+
path: "/projects",
|
|
9593
|
+
surfaceType: "page",
|
|
9594
|
+
icon: "projects",
|
|
9595
|
+
order: 30,
|
|
9596
|
+
targets: { systems: ["projects"] }
|
|
9597
|
+
}
|
|
9598
|
+
}
|
|
9599
|
+
},
|
|
9600
|
+
operations: {
|
|
9601
|
+
type: "group",
|
|
9602
|
+
label: "Operations",
|
|
9603
|
+
icon: "operations",
|
|
9604
|
+
order: 30,
|
|
9605
|
+
children: {
|
|
9606
|
+
"operations-overview": {
|
|
9607
|
+
type: "surface",
|
|
9608
|
+
label: "Overview",
|
|
9609
|
+
path: "/operations",
|
|
9610
|
+
surfaceType: "page",
|
|
9611
|
+
order: 10,
|
|
9612
|
+
targets: { systems: ["operations.overview"] }
|
|
9613
|
+
},
|
|
9614
|
+
"operations-systems": {
|
|
9615
|
+
type: "surface",
|
|
9616
|
+
label: "Systems",
|
|
9617
|
+
path: "/operations/systems",
|
|
9618
|
+
surfaceType: "page",
|
|
9619
|
+
order: 20,
|
|
9620
|
+
targets: { systems: ["operations"] }
|
|
9621
|
+
},
|
|
9622
|
+
"operations-resources": {
|
|
9623
|
+
type: "surface",
|
|
9624
|
+
label: "Resources",
|
|
9625
|
+
path: "/operations/resources",
|
|
9626
|
+
surfaceType: "list",
|
|
9627
|
+
order: 30,
|
|
9628
|
+
targets: { systems: ["operations.resources"] }
|
|
9629
|
+
},
|
|
9630
|
+
"operations-command-queue": {
|
|
9631
|
+
type: "surface",
|
|
9632
|
+
label: "Command Queue",
|
|
9633
|
+
path: "/operations/command-queue",
|
|
9634
|
+
surfaceType: "list",
|
|
9635
|
+
order: 40,
|
|
9636
|
+
targets: { systems: ["operations.command-queue"] }
|
|
9637
|
+
},
|
|
9638
|
+
"operations-task-scheduler": {
|
|
9639
|
+
type: "surface",
|
|
9640
|
+
label: "Task Scheduler",
|
|
9641
|
+
path: "/operations/task-scheduler",
|
|
9642
|
+
surfaceType: "list",
|
|
9643
|
+
order: 50,
|
|
9644
|
+
targets: { systems: ["operations.task-scheduler"] }
|
|
9645
|
+
}
|
|
9646
|
+
}
|
|
9647
|
+
},
|
|
9648
|
+
monitoring: {
|
|
9649
|
+
type: "group",
|
|
9650
|
+
label: "Monitoring",
|
|
9651
|
+
icon: "monitoring",
|
|
9652
|
+
order: 40,
|
|
9653
|
+
children: {
|
|
9654
|
+
"monitoring-overview": {
|
|
9655
|
+
type: "surface",
|
|
9656
|
+
label: "Overview",
|
|
9657
|
+
path: "/monitoring",
|
|
9658
|
+
surfaceType: "page",
|
|
9659
|
+
order: 10,
|
|
9660
|
+
targets: { systems: ["monitoring"] }
|
|
9661
|
+
},
|
|
9662
|
+
"monitoring-calendar": {
|
|
9663
|
+
type: "surface",
|
|
9664
|
+
label: "Calendar",
|
|
9665
|
+
path: "/monitoring/calendar",
|
|
9666
|
+
surfaceType: "page",
|
|
9667
|
+
order: 20,
|
|
9668
|
+
targets: { systems: ["monitoring.calendar"] }
|
|
9669
|
+
},
|
|
9670
|
+
"monitoring-activity-log": {
|
|
9671
|
+
type: "surface",
|
|
9672
|
+
label: "Activity Log",
|
|
9673
|
+
path: "/monitoring/activity-log",
|
|
9674
|
+
surfaceType: "list",
|
|
9675
|
+
order: 30,
|
|
9676
|
+
targets: { systems: ["monitoring.activity-log"] }
|
|
9677
|
+
},
|
|
9678
|
+
"monitoring-execution-logs": {
|
|
9679
|
+
type: "surface",
|
|
9680
|
+
label: "Execution Logs",
|
|
9681
|
+
path: "/monitoring/execution-logs",
|
|
9682
|
+
surfaceType: "list",
|
|
9683
|
+
order: 40,
|
|
9684
|
+
targets: { systems: ["monitoring.execution-logs"] }
|
|
9685
|
+
},
|
|
9686
|
+
"monitoring-execution-health": {
|
|
9687
|
+
type: "surface",
|
|
9688
|
+
label: "Execution Health",
|
|
9689
|
+
path: "/monitoring/execution-health",
|
|
9690
|
+
surfaceType: "dashboard",
|
|
9691
|
+
order: 50,
|
|
9692
|
+
targets: { systems: ["monitoring.execution-health"] }
|
|
9693
|
+
},
|
|
9694
|
+
"monitoring-notifications": {
|
|
9695
|
+
type: "surface",
|
|
9696
|
+
label: "Notifications",
|
|
9697
|
+
path: "/monitoring/notifications",
|
|
9698
|
+
surfaceType: "list",
|
|
9699
|
+
order: 60,
|
|
9700
|
+
targets: { systems: ["monitoring.notifications"] }
|
|
9701
|
+
},
|
|
9702
|
+
"monitoring-requests": {
|
|
9703
|
+
type: "surface",
|
|
9704
|
+
label: "Requests",
|
|
9705
|
+
path: "/monitoring/requests",
|
|
9706
|
+
surfaceType: "list",
|
|
9707
|
+
order: 70,
|
|
9708
|
+
targets: { systems: ["monitoring.submitted-requests"] }
|
|
9709
|
+
}
|
|
9710
|
+
}
|
|
9711
|
+
},
|
|
9712
|
+
knowledge: {
|
|
9713
|
+
type: "surface",
|
|
9714
|
+
label: "Knowledge Base",
|
|
9715
|
+
path: "/knowledge",
|
|
9716
|
+
surfaceType: "page",
|
|
9717
|
+
icon: "knowledge",
|
|
9718
|
+
order: 50
|
|
9719
|
+
}
|
|
9720
|
+
},
|
|
9721
|
+
bottom: {
|
|
9722
|
+
settings: {
|
|
9723
|
+
type: "group",
|
|
9724
|
+
label: "Settings",
|
|
9725
|
+
icon: "settings",
|
|
9726
|
+
order: 10,
|
|
9727
|
+
children: {
|
|
9728
|
+
"settings-account": {
|
|
9729
|
+
type: "surface",
|
|
9730
|
+
label: "Account",
|
|
9731
|
+
path: "/settings/account",
|
|
9732
|
+
surfaceType: "settings",
|
|
9733
|
+
order: 10,
|
|
9734
|
+
targets: { systems: ["settings.account"] }
|
|
9735
|
+
},
|
|
9736
|
+
"settings-appearance": {
|
|
9737
|
+
type: "surface",
|
|
9738
|
+
label: "Appearance",
|
|
9739
|
+
path: "/settings/appearance",
|
|
9740
|
+
surfaceType: "settings",
|
|
9741
|
+
order: 20,
|
|
9742
|
+
targets: { systems: ["settings.appearance"] }
|
|
9743
|
+
},
|
|
9744
|
+
"settings-roles": {
|
|
9745
|
+
type: "surface",
|
|
9746
|
+
label: "My Roles",
|
|
9747
|
+
path: "/settings/roles",
|
|
9748
|
+
surfaceType: "settings",
|
|
9749
|
+
order: 30,
|
|
9750
|
+
targets: { systems: ["settings.roles"] }
|
|
9751
|
+
},
|
|
9752
|
+
"settings-organization": {
|
|
9753
|
+
type: "surface",
|
|
9754
|
+
label: "Organization",
|
|
9755
|
+
path: "/settings/organization",
|
|
9756
|
+
surfaceType: "settings",
|
|
9757
|
+
order: 40,
|
|
9758
|
+
targets: { systems: ["settings.organization"] }
|
|
9759
|
+
},
|
|
9760
|
+
"settings-credentials": {
|
|
9761
|
+
type: "surface",
|
|
9762
|
+
label: "Credentials",
|
|
9763
|
+
path: "/settings/credentials",
|
|
9764
|
+
surfaceType: "settings",
|
|
9765
|
+
order: 50,
|
|
9766
|
+
targets: { systems: ["settings.credentials"] }
|
|
9767
|
+
},
|
|
9768
|
+
"settings-api-keys": {
|
|
9769
|
+
type: "surface",
|
|
9770
|
+
label: "API Keys",
|
|
9771
|
+
path: "/settings/api-keys",
|
|
9772
|
+
surfaceType: "settings",
|
|
9773
|
+
order: 60,
|
|
9774
|
+
targets: { systems: ["settings.api-keys"] }
|
|
9775
|
+
},
|
|
9776
|
+
"settings-webhooks": {
|
|
9777
|
+
type: "surface",
|
|
9778
|
+
label: "Webhooks",
|
|
9779
|
+
path: "/settings/webhooks",
|
|
9780
|
+
surfaceType: "settings",
|
|
9781
|
+
order: 70,
|
|
9782
|
+
targets: { systems: ["settings.webhooks"] }
|
|
9783
|
+
},
|
|
9784
|
+
"settings-deployments": {
|
|
9785
|
+
type: "surface",
|
|
9786
|
+
label: "Deployments",
|
|
9787
|
+
path: "/settings/deployments",
|
|
9788
|
+
surfaceType: "settings",
|
|
9789
|
+
order: 80,
|
|
9790
|
+
targets: { systems: ["settings.deployments"] }
|
|
9791
|
+
}
|
|
9792
|
+
}
|
|
9793
|
+
},
|
|
9794
|
+
admin: {
|
|
9795
|
+
type: "group",
|
|
9796
|
+
label: "Admin",
|
|
9797
|
+
icon: "admin",
|
|
9798
|
+
order: 20,
|
|
9799
|
+
children: {
|
|
9800
|
+
"admin-dashboard": {
|
|
9801
|
+
type: "surface",
|
|
9802
|
+
label: "Dashboard",
|
|
9803
|
+
path: "/admin/dashboard",
|
|
9804
|
+
surfaceType: "dashboard",
|
|
9805
|
+
order: 10,
|
|
9806
|
+
targets: { systems: ["admin"] },
|
|
9807
|
+
requiresAdmin: true
|
|
9808
|
+
},
|
|
9809
|
+
"admin-system-health": {
|
|
9810
|
+
type: "surface",
|
|
9811
|
+
label: "System Health",
|
|
9812
|
+
path: "/admin/system-health",
|
|
9813
|
+
surfaceType: "dashboard",
|
|
9814
|
+
order: 20,
|
|
9815
|
+
targets: { systems: ["admin.system-health"] },
|
|
9816
|
+
requiresAdmin: true
|
|
9817
|
+
},
|
|
9818
|
+
"admin-organizations": {
|
|
9819
|
+
type: "surface",
|
|
9820
|
+
label: "Organizations",
|
|
9821
|
+
path: "/admin/organizations",
|
|
9822
|
+
surfaceType: "list",
|
|
9823
|
+
order: 30,
|
|
9824
|
+
targets: { systems: ["admin.organizations"] },
|
|
9825
|
+
requiresAdmin: true
|
|
9826
|
+
},
|
|
9827
|
+
"admin-users": {
|
|
9828
|
+
type: "surface",
|
|
9829
|
+
label: "Users",
|
|
9830
|
+
path: "/admin/users",
|
|
9831
|
+
surfaceType: "list",
|
|
9832
|
+
order: 40,
|
|
9833
|
+
targets: { systems: ["admin.users"] },
|
|
9834
|
+
requiresAdmin: true
|
|
9835
|
+
},
|
|
9836
|
+
"admin-design-showcase": {
|
|
9837
|
+
type: "surface",
|
|
9838
|
+
label: "Design Showcase",
|
|
9839
|
+
path: "/admin/design-showcase",
|
|
9840
|
+
surfaceType: "page",
|
|
9841
|
+
order: 50,
|
|
9842
|
+
targets: { systems: ["admin.design-showcase"] },
|
|
9843
|
+
requiresAdmin: true
|
|
9844
|
+
},
|
|
9845
|
+
"admin-debug": {
|
|
9846
|
+
type: "surface",
|
|
9847
|
+
label: "Debug",
|
|
9848
|
+
path: "/admin/debug",
|
|
9849
|
+
surfaceType: "page",
|
|
9850
|
+
order: 60,
|
|
9851
|
+
targets: { systems: ["admin.debug"] },
|
|
9852
|
+
requiresAdmin: true
|
|
9853
|
+
}
|
|
9854
|
+
}
|
|
9855
|
+
}
|
|
9856
|
+
}
|
|
9857
|
+
}
|
|
9858
|
+
};
|
|
9859
|
+
var DEFAULT_ORGANIZATION_MODEL = {
|
|
9860
|
+
version: 1,
|
|
9861
|
+
domainMetadata: DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA,
|
|
9862
|
+
branding: DEFAULT_ORGANIZATION_MODEL_BRANDING,
|
|
9863
|
+
navigation: DEFAULT_ORGANIZATION_MODEL_NAVIGATION,
|
|
9864
|
+
identity: DEFAULT_ORGANIZATION_MODEL_IDENTITY,
|
|
9865
|
+
customers: DEFAULT_ORGANIZATION_MODEL_CUSTOMERS,
|
|
9866
|
+
offerings: DEFAULT_ORGANIZATION_MODEL_OFFERINGS,
|
|
9867
|
+
roles: DEFAULT_ORGANIZATION_MODEL_ROLES,
|
|
9868
|
+
goals: DEFAULT_ORGANIZATION_MODEL_GOALS,
|
|
9869
|
+
systems: {
|
|
9870
|
+
dashboard: {
|
|
9871
|
+
id: "dashboard",
|
|
9872
|
+
order: 10,
|
|
9873
|
+
label: "Dashboard",
|
|
9874
|
+
enabled: true,
|
|
9875
|
+
lifecycle: "active",
|
|
9876
|
+
path: "/",
|
|
9877
|
+
icon: "dashboard"
|
|
9878
|
+
},
|
|
9879
|
+
platform: {
|
|
9880
|
+
id: "platform",
|
|
9881
|
+
order: 30,
|
|
9882
|
+
label: "Platform",
|
|
9883
|
+
description: "Elevasis platform architecture, capabilities, and implementation patterns",
|
|
9884
|
+
enabled: true,
|
|
9885
|
+
lifecycle: "active",
|
|
9886
|
+
color: "cyan",
|
|
9887
|
+
icon: "platform"
|
|
9888
|
+
},
|
|
9889
|
+
finance: {
|
|
9890
|
+
id: "finance",
|
|
9891
|
+
order: 40,
|
|
9892
|
+
label: "Finance",
|
|
9893
|
+
description: "Finance operations, accounting, billing, reconciliation, and tax prep",
|
|
9894
|
+
enabled: true,
|
|
9895
|
+
lifecycle: "active",
|
|
9896
|
+
color: "green",
|
|
9897
|
+
icon: "finance"
|
|
9898
|
+
},
|
|
9899
|
+
sales: {
|
|
9900
|
+
id: "sales",
|
|
9901
|
+
order: 60,
|
|
9902
|
+
label: "Sales",
|
|
9903
|
+
description: "Revenue workflows and customer acquisition",
|
|
9904
|
+
enabled: true,
|
|
9905
|
+
lifecycle: "active",
|
|
9906
|
+
color: "blue",
|
|
9907
|
+
icon: "sales",
|
|
9908
|
+
path: "/sales"
|
|
9909
|
+
},
|
|
9910
|
+
"sales.crm": {
|
|
9911
|
+
id: "sales.crm",
|
|
9912
|
+
order: 70,
|
|
9913
|
+
label: "CRM",
|
|
9914
|
+
description: "Relationship pipeline and deal management",
|
|
9915
|
+
enabled: true,
|
|
9916
|
+
lifecycle: "active",
|
|
9917
|
+
actions: Object.values(CRM_ACTION_ENTRIES).map((action) => ({
|
|
9918
|
+
actionId: action.id,
|
|
9919
|
+
intent: "exposes"
|
|
9920
|
+
})),
|
|
9921
|
+
color: "blue",
|
|
9922
|
+
icon: "crm",
|
|
9923
|
+
path: "/crm"
|
|
9924
|
+
},
|
|
9925
|
+
"sales.lead-gen": {
|
|
9926
|
+
id: "sales.lead-gen",
|
|
9927
|
+
order: 80,
|
|
9928
|
+
label: "Lead Gen",
|
|
9929
|
+
description: "Prospecting, qualification, and outreach preparation",
|
|
9930
|
+
enabled: true,
|
|
9931
|
+
lifecycle: "active",
|
|
9932
|
+
actions: Object.values(LEAD_GEN_ACTION_ENTRIES).map((action) => ({
|
|
9933
|
+
actionId: action.id,
|
|
9934
|
+
intent: "exposes"
|
|
9935
|
+
})),
|
|
9936
|
+
color: "cyan",
|
|
9937
|
+
icon: "lead-gen",
|
|
9938
|
+
path: "/lead-gen"
|
|
9939
|
+
},
|
|
9940
|
+
projects: {
|
|
9941
|
+
id: "projects",
|
|
9942
|
+
order: 90,
|
|
9943
|
+
label: "Projects",
|
|
9944
|
+
description: "Projects, milestones, and client work execution",
|
|
9945
|
+
enabled: true,
|
|
9946
|
+
lifecycle: "active",
|
|
9947
|
+
color: "orange",
|
|
9948
|
+
icon: "projects",
|
|
9949
|
+
path: "/projects"
|
|
9950
|
+
},
|
|
9951
|
+
clients: {
|
|
9952
|
+
id: "clients",
|
|
9953
|
+
order: 100,
|
|
9954
|
+
label: "Clients",
|
|
9955
|
+
description: "Client relationships, accounts, and business context",
|
|
9956
|
+
enabled: true,
|
|
9957
|
+
lifecycle: "active",
|
|
9958
|
+
color: "orange",
|
|
9959
|
+
icon: "projects",
|
|
9960
|
+
path: "/clients"
|
|
9961
|
+
},
|
|
9962
|
+
operations: {
|
|
9963
|
+
id: "operations",
|
|
9964
|
+
order: 110,
|
|
9965
|
+
label: "Operations",
|
|
9966
|
+
description: "Operational resources, topology, and orchestration visibility",
|
|
9967
|
+
enabled: true,
|
|
9968
|
+
lifecycle: "active",
|
|
9969
|
+
color: "violet",
|
|
9970
|
+
icon: "operations"
|
|
9971
|
+
},
|
|
9972
|
+
"knowledge.command-view": {
|
|
9973
|
+
id: "knowledge.command-view",
|
|
9974
|
+
order: 120,
|
|
9975
|
+
label: "Command View",
|
|
9976
|
+
enabled: true,
|
|
9977
|
+
lifecycle: "active",
|
|
9978
|
+
path: "/knowledge/command-view",
|
|
9979
|
+
devOnly: true
|
|
9980
|
+
},
|
|
9981
|
+
"operations.overview": {
|
|
9982
|
+
id: "operations.overview",
|
|
9983
|
+
order: 130,
|
|
9984
|
+
label: "Overview",
|
|
9985
|
+
enabled: true,
|
|
9986
|
+
lifecycle: "active",
|
|
9987
|
+
path: "/operations"
|
|
9988
|
+
},
|
|
9989
|
+
"operations.resources": {
|
|
9990
|
+
id: "operations.resources",
|
|
9991
|
+
order: 140,
|
|
9992
|
+
label: "Resources",
|
|
9993
|
+
enabled: true,
|
|
9994
|
+
lifecycle: "active",
|
|
9995
|
+
path: "/operations/resources"
|
|
9996
|
+
},
|
|
9997
|
+
"operations.command-queue": {
|
|
9998
|
+
id: "operations.command-queue",
|
|
9999
|
+
order: 150,
|
|
10000
|
+
label: "Command Queue",
|
|
10001
|
+
enabled: true,
|
|
10002
|
+
lifecycle: "active",
|
|
10003
|
+
path: "/operations/command-queue"
|
|
10004
|
+
},
|
|
10005
|
+
"operations.sessions": {
|
|
10006
|
+
id: "operations.sessions",
|
|
10007
|
+
order: 160,
|
|
10008
|
+
label: "Sessions",
|
|
10009
|
+
enabled: false,
|
|
10010
|
+
lifecycle: "deprecated",
|
|
10011
|
+
path: "/operations/sessions"
|
|
10012
|
+
},
|
|
10013
|
+
"operations.task-scheduler": {
|
|
10014
|
+
id: "operations.task-scheduler",
|
|
10015
|
+
order: 170,
|
|
10016
|
+
label: "Task Scheduler",
|
|
10017
|
+
enabled: true,
|
|
10018
|
+
lifecycle: "active",
|
|
10019
|
+
path: "/operations/task-scheduler"
|
|
10020
|
+
},
|
|
10021
|
+
monitoring: {
|
|
10022
|
+
id: "monitoring",
|
|
10023
|
+
order: 180,
|
|
10024
|
+
label: "Monitoring",
|
|
10025
|
+
enabled: true,
|
|
10026
|
+
lifecycle: "active"
|
|
10027
|
+
},
|
|
10028
|
+
"monitoring.calendar": {
|
|
10029
|
+
id: "monitoring.calendar",
|
|
10030
|
+
order: 190,
|
|
10031
|
+
label: "Calendar",
|
|
10032
|
+
description: "Google Calendar events and agenda views",
|
|
10033
|
+
enabled: true,
|
|
10034
|
+
lifecycle: "active",
|
|
10035
|
+
path: "/monitoring/calendar",
|
|
10036
|
+
icon: "calendar"
|
|
10037
|
+
},
|
|
10038
|
+
"monitoring.activity-log": {
|
|
10039
|
+
id: "monitoring.activity-log",
|
|
10040
|
+
order: 200,
|
|
10041
|
+
label: "Activity Log",
|
|
10042
|
+
enabled: true,
|
|
10043
|
+
lifecycle: "active",
|
|
10044
|
+
path: "/monitoring/activity-log"
|
|
10045
|
+
},
|
|
10046
|
+
"monitoring.execution-logs": {
|
|
10047
|
+
id: "monitoring.execution-logs",
|
|
10048
|
+
order: 210,
|
|
10049
|
+
label: "Execution Logs",
|
|
10050
|
+
enabled: true,
|
|
10051
|
+
lifecycle: "active",
|
|
10052
|
+
path: "/monitoring/execution-logs"
|
|
10053
|
+
},
|
|
10054
|
+
"monitoring.execution-health": {
|
|
10055
|
+
id: "monitoring.execution-health",
|
|
10056
|
+
order: 220,
|
|
10057
|
+
label: "Execution Health",
|
|
10058
|
+
enabled: true,
|
|
10059
|
+
lifecycle: "active",
|
|
10060
|
+
path: "/monitoring/execution-health"
|
|
10061
|
+
},
|
|
10062
|
+
"monitoring.cost-analytics": {
|
|
10063
|
+
id: "monitoring.cost-analytics",
|
|
10064
|
+
order: 230,
|
|
10065
|
+
label: "Cost Analytics",
|
|
10066
|
+
enabled: false,
|
|
10067
|
+
lifecycle: "deprecated",
|
|
10068
|
+
path: "/monitoring/cost-analytics"
|
|
10069
|
+
},
|
|
10070
|
+
"monitoring.notifications": {
|
|
10071
|
+
id: "monitoring.notifications",
|
|
10072
|
+
order: 240,
|
|
10073
|
+
label: "Notifications",
|
|
10074
|
+
enabled: true,
|
|
10075
|
+
lifecycle: "active",
|
|
10076
|
+
path: "/monitoring/notifications"
|
|
10077
|
+
},
|
|
10078
|
+
"monitoring.submitted-requests": {
|
|
10079
|
+
id: "monitoring.submitted-requests",
|
|
10080
|
+
order: 250,
|
|
10081
|
+
label: "Submitted Requests",
|
|
10082
|
+
enabled: true,
|
|
10083
|
+
lifecycle: "active",
|
|
10084
|
+
path: "/monitoring/requests"
|
|
10085
|
+
},
|
|
10086
|
+
settings: {
|
|
10087
|
+
id: "settings",
|
|
10088
|
+
order: 260,
|
|
10089
|
+
label: "Settings",
|
|
10090
|
+
enabled: true,
|
|
10091
|
+
lifecycle: "active",
|
|
10092
|
+
icon: "settings"
|
|
10093
|
+
},
|
|
10094
|
+
"settings.account": {
|
|
10095
|
+
id: "settings.account",
|
|
10096
|
+
order: 270,
|
|
10097
|
+
label: "Account",
|
|
10098
|
+
enabled: true,
|
|
10099
|
+
lifecycle: "active",
|
|
10100
|
+
path: "/settings/account"
|
|
10101
|
+
},
|
|
10102
|
+
"settings.appearance": {
|
|
10103
|
+
id: "settings.appearance",
|
|
10104
|
+
order: 280,
|
|
10105
|
+
label: "Appearance",
|
|
10106
|
+
enabled: true,
|
|
10107
|
+
lifecycle: "active",
|
|
10108
|
+
path: "/settings/appearance"
|
|
10109
|
+
},
|
|
10110
|
+
"settings.roles": {
|
|
10111
|
+
id: "settings.roles",
|
|
10112
|
+
order: 290,
|
|
10113
|
+
label: "My Roles",
|
|
10114
|
+
enabled: true,
|
|
10115
|
+
lifecycle: "active",
|
|
10116
|
+
path: "/settings/roles"
|
|
10117
|
+
},
|
|
10118
|
+
"settings.organization": {
|
|
10119
|
+
id: "settings.organization",
|
|
10120
|
+
order: 300,
|
|
10121
|
+
label: "Organization",
|
|
10122
|
+
enabled: true,
|
|
10123
|
+
lifecycle: "active",
|
|
10124
|
+
path: "/settings/organization"
|
|
10125
|
+
},
|
|
10126
|
+
"settings.credentials": {
|
|
10127
|
+
id: "settings.credentials",
|
|
10128
|
+
order: 310,
|
|
10129
|
+
label: "Credentials",
|
|
10130
|
+
enabled: true,
|
|
10131
|
+
lifecycle: "active",
|
|
10132
|
+
path: "/settings/credentials"
|
|
7023
10133
|
},
|
|
7024
|
-
|
|
7025
|
-
id: "
|
|
7026
|
-
|
|
7027
|
-
|
|
7028
|
-
|
|
7029
|
-
|
|
7030
|
-
|
|
7031
|
-
dependencyMode: "per-record-eligibility",
|
|
7032
|
-
capabilityKey: "lead-gen.company.qualify",
|
|
7033
|
-
defaultBatchSize: 100,
|
|
7034
|
-
maxBatchSize: 250
|
|
10134
|
+
"settings.api-keys": {
|
|
10135
|
+
id: "settings.api-keys",
|
|
10136
|
+
order: 320,
|
|
10137
|
+
label: "API Keys",
|
|
10138
|
+
enabled: true,
|
|
10139
|
+
lifecycle: "active",
|
|
10140
|
+
path: "/settings/api-keys"
|
|
7035
10141
|
},
|
|
7036
|
-
|
|
7037
|
-
id: "
|
|
7038
|
-
|
|
7039
|
-
|
|
7040
|
-
|
|
7041
|
-
|
|
7042
|
-
|
|
7043
|
-
dependencyMode: "per-record-eligibility",
|
|
7044
|
-
capabilityKey: "lead-gen.contact.discover",
|
|
7045
|
-
defaultBatchSize: 50,
|
|
7046
|
-
maxBatchSize: 100
|
|
10142
|
+
"settings.webhooks": {
|
|
10143
|
+
id: "settings.webhooks",
|
|
10144
|
+
order: 330,
|
|
10145
|
+
label: "Webhooks",
|
|
10146
|
+
enabled: true,
|
|
10147
|
+
lifecycle: "active",
|
|
10148
|
+
path: "/settings/webhooks"
|
|
7047
10149
|
},
|
|
7048
|
-
|
|
7049
|
-
id: "
|
|
7050
|
-
|
|
7051
|
-
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
dependencyMode: "per-record-eligibility",
|
|
7056
|
-
capabilityKey: "lead-gen.contact.verify-email",
|
|
7057
|
-
defaultBatchSize: 100,
|
|
7058
|
-
maxBatchSize: 500
|
|
10150
|
+
"settings.deployments": {
|
|
10151
|
+
id: "settings.deployments",
|
|
10152
|
+
order: 340,
|
|
10153
|
+
label: "Deployments",
|
|
10154
|
+
enabled: true,
|
|
10155
|
+
lifecycle: "active",
|
|
10156
|
+
path: "/settings/deployments"
|
|
7059
10157
|
},
|
|
7060
|
-
|
|
7061
|
-
id: "
|
|
7062
|
-
|
|
7063
|
-
|
|
7064
|
-
|
|
7065
|
-
|
|
7066
|
-
|
|
7067
|
-
|
|
7068
|
-
|
|
7069
|
-
defaultBatchSize: 25,
|
|
7070
|
-
maxBatchSize: 100
|
|
10158
|
+
admin: {
|
|
10159
|
+
id: "admin",
|
|
10160
|
+
order: 350,
|
|
10161
|
+
label: "Admin",
|
|
10162
|
+
enabled: true,
|
|
10163
|
+
lifecycle: "active",
|
|
10164
|
+
path: "/admin",
|
|
10165
|
+
icon: "admin",
|
|
10166
|
+
requiresAdmin: true
|
|
7071
10167
|
},
|
|
7072
|
-
|
|
7073
|
-
id: "
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
dependencyMode: "per-record-eligibility",
|
|
7080
|
-
capabilityKey: "lead-gen.review.outreach-ready",
|
|
7081
|
-
defaultBatchSize: 25,
|
|
7082
|
-
maxBatchSize: 100
|
|
7083
|
-
}
|
|
7084
|
-
},
|
|
7085
|
-
dtcApolloClickup: {
|
|
7086
|
-
importApolloSearch: {
|
|
7087
|
-
id: "import-apollo-search",
|
|
7088
|
-
label: "Companies found",
|
|
7089
|
-
description: "Pull companies and seed contact data from a predefined Apollo search or list.",
|
|
7090
|
-
primaryEntity: "company",
|
|
7091
|
-
outputs: ["company", "contact"],
|
|
7092
|
-
stageKey: "populated",
|
|
7093
|
-
dependencyMode: "per-record-eligibility",
|
|
7094
|
-
capabilityKey: "lead-gen.company.apollo-import",
|
|
7095
|
-
defaultBatchSize: 250,
|
|
7096
|
-
maxBatchSize: 1e3,
|
|
7097
|
-
recordColumns: DTC_RECORD_COLUMNS.populated,
|
|
7098
|
-
credentialRequirements: [
|
|
7099
|
-
{
|
|
7100
|
-
key: "apollo",
|
|
7101
|
-
provider: "apollo",
|
|
7102
|
-
credentialType: "api-key-secret",
|
|
7103
|
-
label: "Apollo API key",
|
|
7104
|
-
required: true,
|
|
7105
|
-
selectionMode: "single",
|
|
7106
|
-
inputPath: "credential"
|
|
7107
|
-
}
|
|
7108
|
-
]
|
|
10168
|
+
"admin.system-health": {
|
|
10169
|
+
id: "admin.system-health",
|
|
10170
|
+
order: 360,
|
|
10171
|
+
label: "System Health",
|
|
10172
|
+
enabled: true,
|
|
10173
|
+
lifecycle: "active",
|
|
10174
|
+
path: "/admin/system-health"
|
|
7109
10175
|
},
|
|
7110
|
-
|
|
7111
|
-
id: "
|
|
7112
|
-
|
|
7113
|
-
|
|
7114
|
-
|
|
7115
|
-
|
|
7116
|
-
|
|
7117
|
-
dependsOn: ["import-apollo-search"],
|
|
7118
|
-
dependencyMode: "per-record-eligibility",
|
|
7119
|
-
capabilityKey: "lead-gen.company.apify-crawl",
|
|
7120
|
-
defaultBatchSize: 50,
|
|
7121
|
-
maxBatchSize: 100,
|
|
7122
|
-
recordColumns: DTC_RECORD_COLUMNS.crawled,
|
|
7123
|
-
credentialRequirements: [
|
|
7124
|
-
{
|
|
7125
|
-
key: "apify",
|
|
7126
|
-
provider: "apify",
|
|
7127
|
-
credentialType: "api-key-secret",
|
|
7128
|
-
label: "Apify API token",
|
|
7129
|
-
required: true,
|
|
7130
|
-
selectionMode: "single",
|
|
7131
|
-
inputPath: "credential",
|
|
7132
|
-
verifyOnRun: true
|
|
7133
|
-
}
|
|
7134
|
-
]
|
|
10176
|
+
"admin.organizations": {
|
|
10177
|
+
id: "admin.organizations",
|
|
10178
|
+
order: 370,
|
|
10179
|
+
label: "Organizations",
|
|
10180
|
+
enabled: true,
|
|
10181
|
+
lifecycle: "active",
|
|
10182
|
+
path: "/admin/organizations"
|
|
7135
10183
|
},
|
|
7136
|
-
|
|
7137
|
-
id: "
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
dependsOn: ["apify-crawl"],
|
|
7144
|
-
dependencyMode: "per-record-eligibility",
|
|
7145
|
-
capabilityKey: "lead-gen.company.website-extract",
|
|
7146
|
-
defaultBatchSize: 50,
|
|
7147
|
-
maxBatchSize: 100,
|
|
7148
|
-
recordColumns: DTC_RECORD_COLUMNS.extracted
|
|
10184
|
+
"admin.users": {
|
|
10185
|
+
id: "admin.users",
|
|
10186
|
+
order: 380,
|
|
10187
|
+
label: "Users",
|
|
10188
|
+
enabled: true,
|
|
10189
|
+
lifecycle: "active",
|
|
10190
|
+
path: "/admin/users"
|
|
7149
10191
|
},
|
|
7150
|
-
|
|
7151
|
-
id: "
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
dependsOn: ["analyze-websites"],
|
|
7158
|
-
dependencyMode: "per-record-eligibility",
|
|
7159
|
-
capabilityKey: "lead-gen.company.dtc-subscription-qualify",
|
|
7160
|
-
defaultBatchSize: 100,
|
|
7161
|
-
maxBatchSize: 250,
|
|
7162
|
-
recordColumns: DTC_RECORD_COLUMNS.qualified
|
|
10192
|
+
"admin.design-showcase": {
|
|
10193
|
+
id: "admin.design-showcase",
|
|
10194
|
+
order: 390,
|
|
10195
|
+
label: "Design Showcase",
|
|
10196
|
+
enabled: true,
|
|
10197
|
+
lifecycle: "active",
|
|
10198
|
+
path: "/admin/design-showcase"
|
|
7163
10199
|
},
|
|
7164
|
-
|
|
7165
|
-
id: "
|
|
7166
|
-
|
|
7167
|
-
|
|
7168
|
-
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
|
|
7177
|
-
|
|
7178
|
-
|
|
10200
|
+
"admin.debug": {
|
|
10201
|
+
id: "admin.debug",
|
|
10202
|
+
order: 400,
|
|
10203
|
+
label: "Debug",
|
|
10204
|
+
enabled: true,
|
|
10205
|
+
lifecycle: "active",
|
|
10206
|
+
path: "/admin/debug"
|
|
10207
|
+
},
|
|
10208
|
+
archive: {
|
|
10209
|
+
id: "archive",
|
|
10210
|
+
order: 410,
|
|
10211
|
+
label: "Archive",
|
|
10212
|
+
enabled: true,
|
|
10213
|
+
lifecycle: "active",
|
|
10214
|
+
path: "/archive",
|
|
10215
|
+
icon: "archive",
|
|
10216
|
+
devOnly: true
|
|
10217
|
+
},
|
|
10218
|
+
"archive.agent-chat": {
|
|
10219
|
+
id: "archive.agent-chat",
|
|
10220
|
+
order: 420,
|
|
10221
|
+
label: "Agent Chat",
|
|
10222
|
+
enabled: true,
|
|
10223
|
+
lifecycle: "active",
|
|
10224
|
+
path: "/archive/agent-chat"
|
|
10225
|
+
},
|
|
10226
|
+
"archive.execution-runner": {
|
|
10227
|
+
id: "archive.execution-runner",
|
|
10228
|
+
order: 430,
|
|
10229
|
+
label: "Execution Runner",
|
|
10230
|
+
enabled: true,
|
|
10231
|
+
lifecycle: "active",
|
|
10232
|
+
path: "/archive/execution-runner"
|
|
10233
|
+
},
|
|
10234
|
+
seo: {
|
|
10235
|
+
id: "seo",
|
|
10236
|
+
order: 440,
|
|
10237
|
+
label: "SEO",
|
|
10238
|
+
enabled: false,
|
|
10239
|
+
lifecycle: "deprecated",
|
|
10240
|
+
path: "/seo"
|
|
10241
|
+
},
|
|
10242
|
+
knowledge: {
|
|
10243
|
+
id: "knowledge",
|
|
10244
|
+
order: 450,
|
|
10245
|
+
label: "Knowledge",
|
|
10246
|
+
description: "Operational knowledge, playbooks, and strategy docs",
|
|
10247
|
+
enabled: true,
|
|
10248
|
+
lifecycle: "active",
|
|
10249
|
+
color: "teal",
|
|
10250
|
+
icon: "knowledge"
|
|
10251
|
+
},
|
|
10252
|
+
"knowledge.base": {
|
|
10253
|
+
id: "knowledge.base",
|
|
10254
|
+
order: 460,
|
|
10255
|
+
label: "Knowledge Base",
|
|
10256
|
+
enabled: true,
|
|
10257
|
+
lifecycle: "active",
|
|
10258
|
+
path: "/knowledge"
|
|
10259
|
+
}
|
|
10260
|
+
},
|
|
10261
|
+
ontology: DEFAULT_ONTOLOGY_SCOPE,
|
|
10262
|
+
resources: DEFAULT_ORGANIZATION_MODEL_RESOURCES,
|
|
10263
|
+
actions: DEFAULT_ORGANIZATION_MODEL_ACTIONS,
|
|
10264
|
+
entities: DEFAULT_ORGANIZATION_MODEL_ENTITIES2,
|
|
10265
|
+
policies: DEFAULT_ORGANIZATION_MODEL_POLICIES,
|
|
10266
|
+
// Phase 4 (D1): statuses top-level field removed; bridge status mirrors may
|
|
10267
|
+
// still project from System.content, but primary authoring belongs in ontology.
|
|
10268
|
+
knowledge: DEFAULT_ORGANIZATION_MODEL_KNOWLEDGE
|
|
10269
|
+
};
|
|
10270
|
+
|
|
10271
|
+
// ../core/src/business/acquisition/ontology-validation.ts
|
|
10272
|
+
var CRM_PIPELINE_CATALOG_ONTOLOGY_ID = formatOntologyId({
|
|
10273
|
+
scope: "sales.crm",
|
|
10274
|
+
kind: "catalog",
|
|
10275
|
+
localId: "crm.pipeline"
|
|
10276
|
+
});
|
|
10277
|
+
var LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID = formatOntologyId({
|
|
10278
|
+
scope: "sales.lead-gen",
|
|
10279
|
+
kind: "catalog",
|
|
10280
|
+
localId: "lead-gen.stage-catalog"
|
|
10281
|
+
});
|
|
10282
|
+
var CRM_DEAL_OBJECT_ONTOLOGY_ID = formatOntologyId({
|
|
10283
|
+
scope: "sales.crm",
|
|
10284
|
+
kind: "object",
|
|
10285
|
+
localId: "crm.deal"
|
|
10286
|
+
});
|
|
10287
|
+
function createCrmPipelineCatalog() {
|
|
10288
|
+
return {
|
|
10289
|
+
id: CRM_PIPELINE_CATALOG_ONTOLOGY_ID,
|
|
10290
|
+
label: CRM_PIPELINE_DEFINITION.label,
|
|
10291
|
+
ownerSystemId: "sales.crm",
|
|
10292
|
+
kind: "pipeline",
|
|
10293
|
+
appliesTo: CRM_DEAL_OBJECT_ONTOLOGY_ID,
|
|
10294
|
+
entries: Object.fromEntries(
|
|
10295
|
+
CRM_PIPELINE_DEFINITION.stages.map((stage, index2) => [
|
|
10296
|
+
stage.stageKey,
|
|
7179
10297
|
{
|
|
7180
|
-
key:
|
|
7181
|
-
|
|
7182
|
-
|
|
7183
|
-
|
|
7184
|
-
|
|
7185
|
-
selectionMode: "single",
|
|
7186
|
-
inputPath: "credential"
|
|
10298
|
+
key: stage.stageKey,
|
|
10299
|
+
label: stage.label,
|
|
10300
|
+
order: (index2 + 1) * 10,
|
|
10301
|
+
...stage.color !== void 0 ? { color: stage.color } : {},
|
|
10302
|
+
states: stage.states.map((state) => ({ ...state }))
|
|
7187
10303
|
}
|
|
7188
|
-
]
|
|
7189
|
-
|
|
7190
|
-
|
|
7191
|
-
|
|
7192
|
-
|
|
7193
|
-
|
|
7194
|
-
|
|
7195
|
-
|
|
7196
|
-
|
|
7197
|
-
|
|
7198
|
-
|
|
7199
|
-
|
|
7200
|
-
|
|
7201
|
-
|
|
7202
|
-
|
|
7203
|
-
maxBatchSize: 250,
|
|
7204
|
-
recordColumns: DTC_RECORD_COLUMNS.uploaded,
|
|
7205
|
-
credentialRequirements: [
|
|
10304
|
+
])
|
|
10305
|
+
),
|
|
10306
|
+
legacyPipelineKey: CRM_PIPELINE_DEFINITION.pipelineKey,
|
|
10307
|
+
legacyEntityKey: CRM_PIPELINE_DEFINITION.entityKey
|
|
10308
|
+
};
|
|
10309
|
+
}
|
|
10310
|
+
function createLeadGenStageCatalog() {
|
|
10311
|
+
return {
|
|
10312
|
+
id: LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID,
|
|
10313
|
+
label: "Lead Gen Processing Stages",
|
|
10314
|
+
ownerSystemId: "sales.lead-gen",
|
|
10315
|
+
kind: "processing-stage-catalog",
|
|
10316
|
+
entries: Object.fromEntries(
|
|
10317
|
+
Object.entries(LEAD_GEN_STAGE_CATALOG).map(([key, entry]) => [
|
|
10318
|
+
key,
|
|
7206
10319
|
{
|
|
7207
|
-
|
|
7208
|
-
provider: "clickup",
|
|
7209
|
-
credentialType: "api-key-secret",
|
|
7210
|
-
label: "ClickUp API token",
|
|
7211
|
-
required: true,
|
|
7212
|
-
selectionMode: "single",
|
|
7213
|
-
inputPath: "clickupCredential",
|
|
7214
|
-
verifyOnRun: true
|
|
10320
|
+
...entry
|
|
7215
10321
|
}
|
|
7216
|
-
]
|
|
7217
|
-
|
|
10322
|
+
])
|
|
10323
|
+
),
|
|
10324
|
+
legacyCatalogKey: "LEAD_GEN_STAGE_CATALOG"
|
|
10325
|
+
};
|
|
10326
|
+
}
|
|
10327
|
+
function isPlainRecord(value) {
|
|
10328
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
10329
|
+
}
|
|
10330
|
+
function mergeBridgeCatalogs(model) {
|
|
10331
|
+
const baseCatalogTypes = model.ontology?.catalogTypes ?? {};
|
|
10332
|
+
const bridgeCatalogTypes = {};
|
|
10333
|
+
if (baseCatalogTypes[CRM_PIPELINE_CATALOG_ONTOLOGY_ID] === void 0) {
|
|
10334
|
+
bridgeCatalogTypes[CRM_PIPELINE_CATALOG_ONTOLOGY_ID] = createCrmPipelineCatalog();
|
|
7218
10335
|
}
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
contactEntityId: ModelIdSchema,
|
|
7224
|
-
description: DescriptionSchema.optional(),
|
|
7225
|
-
companyStages: z.array(ProspectingLifecycleStageSchema).min(1),
|
|
7226
|
-
contactStages: z.array(ProspectingLifecycleStageSchema).min(1),
|
|
7227
|
-
defaultBuildTemplateId: ModelIdSchema,
|
|
7228
|
-
buildTemplates: z.array(ProspectingBuildTemplateSchema).min(1)
|
|
7229
|
-
});
|
|
7230
|
-
function toProspectingLifecycleStage(stage) {
|
|
10336
|
+
if (baseCatalogTypes[LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID] === void 0) {
|
|
10337
|
+
bridgeCatalogTypes[LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID] = createLeadGenStageCatalog();
|
|
10338
|
+
}
|
|
10339
|
+
if (Object.keys(bridgeCatalogTypes).length === 0) return model;
|
|
7231
10340
|
return {
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
|
|
10341
|
+
...model,
|
|
10342
|
+
ontology: {
|
|
10343
|
+
...model.ontology ?? {},
|
|
10344
|
+
catalogTypes: {
|
|
10345
|
+
...baseCatalogTypes,
|
|
10346
|
+
...bridgeCatalogTypes
|
|
10347
|
+
}
|
|
10348
|
+
}
|
|
7235
10349
|
};
|
|
7236
10350
|
}
|
|
7237
|
-
function
|
|
7238
|
-
|
|
10351
|
+
function compileBusinessOntologyValidationIndex(model = DEFAULT_ORGANIZATION_MODEL) {
|
|
10352
|
+
const compilation = compileOrganizationOntology(mergeBridgeCatalogs(model));
|
|
10353
|
+
if (compilation.diagnostics.length > 0) {
|
|
10354
|
+
const summary = compilation.diagnostics.map((diagnostic) => diagnostic.message).join("; ");
|
|
10355
|
+
throw new Error(`Business ontology validation index failed to compile: ${summary}`);
|
|
10356
|
+
}
|
|
10357
|
+
const crmPipelineCatalog = compilation.ontology.catalogTypes[CRM_PIPELINE_CATALOG_ONTOLOGY_ID];
|
|
10358
|
+
const leadGenStageCatalog = compilation.ontology.catalogTypes[LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID];
|
|
10359
|
+
if (crmPipelineCatalog === void 0 || leadGenStageCatalog === void 0) {
|
|
10360
|
+
throw new Error("Business ontology validation index is missing CRM or lead-gen catalog bridge records");
|
|
10361
|
+
}
|
|
10362
|
+
return {
|
|
10363
|
+
ontology: compilation.ontology,
|
|
10364
|
+
crmPipelineCatalog,
|
|
10365
|
+
leadGenStageCatalog,
|
|
10366
|
+
actionTypesByLegacyId: indexActionTypesByLegacyId(compilation.ontology.actionTypes)
|
|
10367
|
+
};
|
|
7239
10368
|
}
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
{
|
|
7245
|
-
|
|
7246
|
-
label: "Local Services Prospecting",
|
|
7247
|
-
description: "Curated local-services list build using company sourcing, website analysis, qualification, contact discovery, verification, personalization, and review.",
|
|
7248
|
-
steps: [
|
|
7249
|
-
PROSPECTING_STEPS.localServices.sourceCompanies,
|
|
7250
|
-
PROSPECTING_STEPS.localServices.analyzeWebsites,
|
|
7251
|
-
PROSPECTING_STEPS.localServices.qualifyCompanies,
|
|
7252
|
-
PROSPECTING_STEPS.localServices.findContacts,
|
|
7253
|
-
PROSPECTING_STEPS.localServices.verifyEmails,
|
|
7254
|
-
PROSPECTING_STEPS.localServices.personalize,
|
|
7255
|
-
PROSPECTING_STEPS.localServices.review
|
|
7256
|
-
]
|
|
7257
|
-
},
|
|
7258
|
-
{
|
|
7259
|
-
id: "dtc-subscription-apollo-clickup",
|
|
7260
|
-
label: "DTC Subscription Apollo Export",
|
|
7261
|
-
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.",
|
|
7262
|
-
steps: [
|
|
7263
|
-
PROSPECTING_STEPS.dtcApolloClickup.importApolloSearch,
|
|
7264
|
-
PROSPECTING_STEPS.dtcApolloClickup.apifyCrawl,
|
|
7265
|
-
PROSPECTING_STEPS.dtcApolloClickup.analyzeWebsites,
|
|
7266
|
-
PROSPECTING_STEPS.dtcApolloClickup.scoreDtcFit,
|
|
7267
|
-
PROSPECTING_STEPS.dtcApolloClickup.enrichDecisionMakers,
|
|
7268
|
-
PROSPECTING_STEPS.dtcApolloClickup.reviewAndExport
|
|
7269
|
-
]
|
|
10369
|
+
function indexActionTypesByLegacyId(actionTypes) {
|
|
10370
|
+
const byLegacyId = {};
|
|
10371
|
+
for (const actionType of Object.values(actionTypes)) {
|
|
10372
|
+
const legacyActionId = actionType["legacyActionId"];
|
|
10373
|
+
if (typeof legacyActionId === "string") {
|
|
10374
|
+
byLegacyId[legacyActionId] = actionType;
|
|
7270
10375
|
}
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
|
|
7276
|
-
(
|
|
7277
|
-
|
|
10376
|
+
}
|
|
10377
|
+
return byLegacyId;
|
|
10378
|
+
}
|
|
10379
|
+
var BUSINESS_ONTOLOGY_VALIDATION_INDEX = compileBusinessOntologyValidationIndex();
|
|
10380
|
+
function getCatalogEntries(catalog) {
|
|
10381
|
+
return isPlainRecord(catalog.entries) ? catalog.entries : {};
|
|
10382
|
+
}
|
|
10383
|
+
function asCrmStageEntry(key, value) {
|
|
10384
|
+
const record = isPlainRecord(value) ? value : {};
|
|
10385
|
+
const label = typeof record.label === "string" ? record.label : key;
|
|
10386
|
+
const order = typeof record.order === "number" ? record.order : 0;
|
|
10387
|
+
const color = typeof record.color === "string" ? record.color : void 0;
|
|
10388
|
+
const rawStates = Array.isArray(record.states) ? record.states : [];
|
|
10389
|
+
const states = rawStates.flatMap((state) => {
|
|
10390
|
+
if (!isPlainRecord(state) || typeof state.stateKey !== "string") return [];
|
|
10391
|
+
return [
|
|
10392
|
+
{
|
|
10393
|
+
stateKey: state.stateKey,
|
|
10394
|
+
label: typeof state.label === "string" ? state.label : state.stateKey
|
|
10395
|
+
}
|
|
10396
|
+
];
|
|
10397
|
+
});
|
|
10398
|
+
return {
|
|
10399
|
+
key,
|
|
7278
10400
|
label,
|
|
7279
|
-
|
|
7280
|
-
|
|
10401
|
+
order,
|
|
10402
|
+
...color !== void 0 ? { color } : {},
|
|
10403
|
+
states
|
|
10404
|
+
};
|
|
10405
|
+
}
|
|
10406
|
+
function asLeadGenStageEntry(key, value) {
|
|
10407
|
+
const record = isPlainRecord(value) ? value : {};
|
|
10408
|
+
const entity = record.entity === "contact" ? "contact" : "company";
|
|
10409
|
+
const additionalEntities = Array.isArray(record.additionalEntities) ? record.additionalEntities.filter(
|
|
10410
|
+
(item) => item === "company" || item === "contact"
|
|
10411
|
+
) : void 0;
|
|
10412
|
+
const recordEntity = record.recordEntity === "company" || record.recordEntity === "contact" ? record.recordEntity : void 0;
|
|
10413
|
+
const recordStageKey = typeof record.recordStageKey === "string" ? record.recordStageKey : void 0;
|
|
10414
|
+
return {
|
|
10415
|
+
key: typeof record.key === "string" ? record.key : key,
|
|
10416
|
+
label: typeof record.label === "string" ? record.label : key,
|
|
10417
|
+
description: typeof record.description === "string" ? record.description : "",
|
|
10418
|
+
order: typeof record.order === "number" ? record.order : 0,
|
|
10419
|
+
entity,
|
|
10420
|
+
...additionalEntities !== void 0 ? { additionalEntities } : {},
|
|
10421
|
+
...recordEntity !== void 0 ? { recordEntity } : {},
|
|
10422
|
+
...recordStageKey !== void 0 ? { recordStageKey } : {}
|
|
10423
|
+
};
|
|
10424
|
+
}
|
|
10425
|
+
var CRM_STAGE_KEYS_FROM_ONTOLOGY = Object.keys(
|
|
10426
|
+
getCatalogEntries(BUSINESS_ONTOLOGY_VALIDATION_INDEX.crmPipelineCatalog)
|
|
7281
10427
|
);
|
|
7282
|
-
|
|
7283
|
-
|
|
10428
|
+
var CRM_STATE_KEYS_FROM_ONTOLOGY = Object.values(
|
|
10429
|
+
getCatalogEntries(BUSINESS_ONTOLOGY_VALIDATION_INDEX.crmPipelineCatalog)
|
|
10430
|
+
).flatMap((entry, index2) => {
|
|
10431
|
+
const stageKey = CRM_STAGE_KEYS_FROM_ONTOLOGY[index2];
|
|
10432
|
+
if (stageKey === void 0) return [];
|
|
10433
|
+
return asCrmStageEntry(stageKey, entry).states.map((state) => state.stateKey);
|
|
10434
|
+
});
|
|
10435
|
+
Object.keys(
|
|
10436
|
+
getCatalogEntries(BUSINESS_ONTOLOGY_VALIDATION_INDEX.leadGenStageCatalog)
|
|
10437
|
+
);
|
|
10438
|
+
function getLeadGenStageCatalogFromOntology() {
|
|
10439
|
+
return Object.fromEntries(
|
|
10440
|
+
Object.entries(getCatalogEntries(BUSINESS_ONTOLOGY_VALIDATION_INDEX.leadGenStageCatalog)).map(([key, value]) => [
|
|
10441
|
+
key,
|
|
10442
|
+
asLeadGenStageEntry(key, value)
|
|
10443
|
+
])
|
|
10444
|
+
);
|
|
10445
|
+
}
|
|
10446
|
+
function getLeadGenStageEntry(stageKey) {
|
|
10447
|
+
return getLeadGenStageCatalogFromOntology()[stageKey];
|
|
10448
|
+
}
|
|
10449
|
+
function isLeadGenStageKey(stageKey) {
|
|
10450
|
+
return getLeadGenStageEntry(stageKey) !== void 0;
|
|
10451
|
+
}
|
|
10452
|
+
function isLeadGenRecordStageValidForEntity(stageKey, entity) {
|
|
10453
|
+
const stage = getLeadGenStageEntry(stageKey);
|
|
10454
|
+
return stage !== void 0 && (stage.entity === entity || stage.additionalEntities?.includes(entity) === true || stage.recordEntity === entity);
|
|
10455
|
+
}
|
|
10456
|
+
function isLeadGenActionKey(actionKey) {
|
|
10457
|
+
return actionKey.startsWith("lead-gen.") && BUSINESS_ONTOLOGY_VALIDATION_INDEX.actionTypesByLegacyId[actionKey] !== void 0;
|
|
7284
10458
|
}
|
|
10459
|
+
|
|
10460
|
+
// ../core/src/business/acquisition/api-schemas.ts
|
|
7285
10461
|
var ProcessingStageStatusSchema = z.enum(["success", "no_result", "skipped", "error"]);
|
|
7286
|
-
var LeadGenStageKeySchema = z.string().refine((value) =>
|
|
10462
|
+
var LeadGenStageKeySchema = z.string().refine((value) => isLeadGenStageKey(value), {
|
|
7287
10463
|
message: "processing state key must match LEAD_GEN_STAGE_CATALOG"
|
|
7288
10464
|
});
|
|
7289
|
-
var
|
|
7290
|
-
message: "
|
|
10465
|
+
var LeadGenActionKeySchema = z.string().refine((value) => isLeadGenActionKey(value), {
|
|
10466
|
+
message: "actionKey must match ACTION_REGISTRY"
|
|
7291
10467
|
});
|
|
7292
|
-
var crmStageKeys =
|
|
7293
|
-
var crmStateKeys =
|
|
10468
|
+
var crmStageKeys = CRM_STAGE_KEYS_FROM_ONTOLOGY;
|
|
10469
|
+
var crmStateKeys = CRM_STATE_KEYS_FROM_ONTOLOGY;
|
|
7294
10470
|
var CrmStageKeySchema = z.enum(crmStageKeys);
|
|
7295
10471
|
var CrmStateKeySchema = z.enum(crmStateKeys);
|
|
7296
10472
|
var ProcessingStateEntrySchema = z.object({
|
|
@@ -7545,7 +10721,7 @@ var IcpRubricSchema = z.object({
|
|
|
7545
10721
|
customRules: z.string().optional()
|
|
7546
10722
|
});
|
|
7547
10723
|
var PipelineStageSchema = z.object({
|
|
7548
|
-
key: z.string().refine((value) =>
|
|
10724
|
+
key: z.string().refine((value) => isLeadGenStageKey(value), {
|
|
7549
10725
|
message: "pipeline stage key must match LEAD_GEN_STAGE_CATALOG"
|
|
7550
10726
|
}),
|
|
7551
10727
|
label: z.string().optional(),
|
|
@@ -7567,7 +10743,7 @@ var BuildPlanSnapshotStepSchema = z.object({
|
|
|
7567
10743
|
recordSourceStageKey: LeadGenStageKeySchema.optional(),
|
|
7568
10744
|
dependsOn: z.array(z.string().trim().min(1).max(100)).optional(),
|
|
7569
10745
|
dependencyMode: z.literal("per-record-eligibility"),
|
|
7570
|
-
|
|
10746
|
+
actionKey: LeadGenActionKeySchema,
|
|
7571
10747
|
defaultBatchSize: z.number().int().positive(),
|
|
7572
10748
|
maxBatchSize: z.number().int().positive(),
|
|
7573
10749
|
recordColumns: z.object({
|
|
@@ -8017,9 +11193,7 @@ z.object({
|
|
|
8017
11193
|
offset: z.coerce.number().int().min(0).default(0)
|
|
8018
11194
|
}).strict().superRefine((query, ctx) => {
|
|
8019
11195
|
if (!query.stage) return;
|
|
8020
|
-
|
|
8021
|
-
const validEntity = stage?.entity === query.entity || stage?.additionalEntities?.includes(query.entity) || stage?.recordEntity === query.entity;
|
|
8022
|
-
if (!validEntity) {
|
|
11196
|
+
if (!isLeadGenRecordStageValidForEntity(query.stage, query.entity)) {
|
|
8023
11197
|
ctx.addIssue({
|
|
8024
11198
|
code: z.ZodIssueCode.custom,
|
|
8025
11199
|
message: `stage "${query.stage}" is not valid for ${query.entity} records`,
|
|
@@ -8484,6 +11658,26 @@ createAdapter("execution", ["trigger", "triggerAsync"]);
|
|
|
8484
11658
|
// src/worker/adapters/email.ts
|
|
8485
11659
|
createAdapter("email", ["send"]);
|
|
8486
11660
|
|
|
11661
|
+
// ../core/src/organization-model/helpers.ts
|
|
11662
|
+
function childSystemsOf2(system) {
|
|
11663
|
+
return system.systems ?? system.subsystems ?? {};
|
|
11664
|
+
}
|
|
11665
|
+
function listAllSystems(model) {
|
|
11666
|
+
const results = [];
|
|
11667
|
+
function walk(map2, prefix) {
|
|
11668
|
+
for (const [localId, system] of Object.entries(map2)) {
|
|
11669
|
+
const fullPath = prefix ? `${prefix}.${localId}` : localId;
|
|
11670
|
+
results.push({ path: fullPath, system });
|
|
11671
|
+
const childSystems = childSystemsOf2(system);
|
|
11672
|
+
if (Object.keys(childSystems).length > 0) {
|
|
11673
|
+
walk(childSystems, fullPath);
|
|
11674
|
+
}
|
|
11675
|
+
}
|
|
11676
|
+
}
|
|
11677
|
+
walk(model.systems, "");
|
|
11678
|
+
return results;
|
|
11679
|
+
}
|
|
11680
|
+
|
|
8487
11681
|
// ../core/src/platform/registry/validation.ts
|
|
8488
11682
|
var RegistryValidationError = class extends Error {
|
|
8489
11683
|
constructor(orgName, resourceId, field, message) {
|
|
@@ -8539,25 +11733,27 @@ function getRuntimeResources(resources) {
|
|
|
8539
11733
|
}
|
|
8540
11734
|
function validateResourceGovernance(orgName, deployment, organizationModel = deployment.organizationModel, options = {}) {
|
|
8541
11735
|
const mode = getResourceValidatorMode(options.mode);
|
|
8542
|
-
const
|
|
8543
|
-
const
|
|
11736
|
+
const omResourcesMap = organizationModel?.resources;
|
|
11737
|
+
const omSystemsMap = organizationModel?.systems;
|
|
8544
11738
|
const issues = [];
|
|
8545
|
-
if (!
|
|
11739
|
+
if (!omResourcesMap || !omSystemsMap) {
|
|
8546
11740
|
return { valid: true, mode, issues };
|
|
8547
11741
|
}
|
|
8548
|
-
const systemsById = new Map(
|
|
8549
|
-
|
|
11742
|
+
const systemsById = new Map(
|
|
11743
|
+
listAllSystems({ systems: omSystemsMap }).map(({ path, system }) => [path, system])
|
|
11744
|
+
);
|
|
11745
|
+
const activeOmResources = Object.values(omResourcesMap).filter((resource) => resource.status === "active");
|
|
8550
11746
|
const omResourcesById = new Map(activeOmResources.map((resource) => [resource.id, resource]));
|
|
8551
11747
|
const runtimeResources = getRuntimeResources(deployment);
|
|
8552
11748
|
const runtimeResourcesById = new Map(runtimeResources.map((resource) => [resource.resourceId, resource]));
|
|
8553
11749
|
for (const resource of activeOmResources) {
|
|
8554
|
-
if (!systemsById.has(resource.
|
|
11750
|
+
if (!systemsById.has(resource.systemPath)) {
|
|
8555
11751
|
addGovernanceIssue(
|
|
8556
11752
|
issues,
|
|
8557
11753
|
"missing-om-system",
|
|
8558
11754
|
orgName,
|
|
8559
11755
|
resource.id,
|
|
8560
|
-
`[${orgName}] OM resource '${resource.id}' references missing
|
|
11756
|
+
`[${orgName}] OM resource '${resource.id}' references missing system path '${resource.systemPath}'.`
|
|
8561
11757
|
);
|
|
8562
11758
|
}
|
|
8563
11759
|
const runtimeResource = runtimeResourcesById.get(resource.id);
|
|
@@ -8580,13 +11776,13 @@ function validateResourceGovernance(orgName, deployment, organizationModel = dep
|
|
|
8580
11776
|
`[${orgName}] Resource '${resource.id}' type mismatch: code has '${runtimeResource.type}', OM has '${resource.kind}'.`
|
|
8581
11777
|
);
|
|
8582
11778
|
}
|
|
8583
|
-
if (runtimeResource.descriptor && runtimeResource.descriptor.
|
|
11779
|
+
if (runtimeResource.descriptor && runtimeResource.descriptor.systemPath !== resource.systemPath) {
|
|
8584
11780
|
addGovernanceIssue(
|
|
8585
11781
|
issues,
|
|
8586
11782
|
"system-mismatch",
|
|
8587
11783
|
orgName,
|
|
8588
11784
|
resource.id,
|
|
8589
|
-
`[${orgName}] Resource '${resource.id}' system mismatch: code descriptor has '${runtimeResource.descriptor.
|
|
11785
|
+
`[${orgName}] Resource '${resource.id}' system mismatch: code descriptor has '${runtimeResource.descriptor.systemPath}', OM has '${resource.systemPath}'.`
|
|
8590
11786
|
);
|
|
8591
11787
|
}
|
|
8592
11788
|
}
|