@elevasis/sdk 1.21.0 → 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 +951 -171
- package/dist/index.d.ts +632 -341
- package/dist/index.js +3102 -142
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +19 -1
- package/dist/test-utils/index.d.ts +313 -4
- package/dist/test-utils/index.js +3246 -281
- package/dist/worker/index.js +3041 -80
- package/package.json +3 -3
- 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 -277
- 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 +110 -84
- 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 -235
- 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 +314 -299
- 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 -159
- package/reference/claude-config/skills/knowledge/operations/customers.md +109 -109
- package/reference/claude-config/skills/knowledge/operations/features.md +76 -76
- 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 -94
- 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 -1303
- 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 -30
- 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 -808
- 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 -107
- package/reference/deployment/ui-execution.mdx +250 -250
- package/reference/examples/organization-model.ts +146 -83
- 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 +32 -32
- package/reference/packages/core/src/organization-model/README.md +149 -149
- 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 -90
- package/reference/scaffold/core/organization-model.mdx +226 -219
- package/reference/scaffold/index.mdx +67 -67
- package/reference/scaffold/operations/propagation-pipeline.md +77 -77
- package/reference/scaffold/operations/scaffold-maintenance.md +12 -12
- package/reference/scaffold/operations/workflow-recipes.md +138 -138
- package/reference/scaffold/recipes/add-a-feature.md +308 -88
- package/reference/scaffold/recipes/add-a-resource.md +134 -110
- package/reference/scaffold/recipes/customize-knowledge-browser.md +5 -5
- package/reference/scaffold/recipes/customize-organization-model.md +273 -138
- package/reference/scaffold/recipes/extend-a-base-entity.md +8 -8
- package/reference/scaffold/recipes/extend-crm.md +3 -3
- package/reference/scaffold/recipes/extend-lead-gen.md +400 -400
- package/reference/scaffold/recipes/gate-by-feature-or-admin.md +118 -118
- package/reference/scaffold/recipes/index.md +46 -46
- package/reference/scaffold/recipes/query-the-knowledge-graph.md +197 -170
- package/reference/scaffold/reference/contracts.md +2101 -2096
- 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 -214
- 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,
|
|
@@ -6651,7 +6656,7 @@ var EntitySchema = z.object({
|
|
|
6651
6656
|
stateCatalogId: ModelIdSchema.optional(),
|
|
6652
6657
|
links: z.array(EntityLinkSchema).optional()
|
|
6653
6658
|
});
|
|
6654
|
-
z.record(z.string(), EntitySchema).refine((record) => Object.entries(record).every(([key, entry]) => entry.id === key), {
|
|
6659
|
+
var EntitiesDomainSchema = z.record(z.string(), EntitySchema).refine((record) => Object.entries(record).every(([key, entry]) => entry.id === key), {
|
|
6655
6660
|
message: "Each entity entry id must match its map key"
|
|
6656
6661
|
}).default({});
|
|
6657
6662
|
var ENTITY_ENTRY_INPUTS = [
|
|
@@ -6749,7 +6754,7 @@ var ENTITY_ENTRY_INPUTS = [
|
|
|
6749
6754
|
]
|
|
6750
6755
|
}
|
|
6751
6756
|
];
|
|
6752
|
-
Object.fromEntries(
|
|
6757
|
+
var DEFAULT_ORGANIZATION_MODEL_ENTITIES = Object.fromEntries(
|
|
6753
6758
|
ENTITY_ENTRY_INPUTS.map((entity) => {
|
|
6754
6759
|
const parsed = EntitySchema.parse(entity);
|
|
6755
6760
|
return [parsed.id, parsed];
|
|
@@ -6766,7 +6771,7 @@ var ActionScopeSchema = z.union([
|
|
|
6766
6771
|
domain: ModelIdSchema
|
|
6767
6772
|
})
|
|
6768
6773
|
]);
|
|
6769
|
-
z.object({
|
|
6774
|
+
var ActionRefSchema = z.object({
|
|
6770
6775
|
actionId: ActionIdSchema.meta({ ref: "action" }),
|
|
6771
6776
|
intent: z.enum(["exposes", "consumes"]).meta({ label: "Intent" })
|
|
6772
6777
|
});
|
|
@@ -6810,7 +6815,7 @@ var ActionSchema = z.object({
|
|
|
6810
6815
|
knowledge: z.array(ModelIdSchema.meta({ ref: "knowledge" })).default([]).optional(),
|
|
6811
6816
|
lifecycle: z.enum(["draft", "beta", "active", "deprecated", "archived"]).meta({ label: "Lifecycle", color: "teal" }).default("active")
|
|
6812
6817
|
});
|
|
6813
|
-
z.record(z.string(), ActionSchema).refine((record) => Object.entries(record).every(([key, entry]) => entry.id === key), {
|
|
6818
|
+
var ActionsDomainSchema = z.record(z.string(), ActionSchema).refine((record) => Object.entries(record).every(([key, entry]) => entry.id === key), {
|
|
6814
6819
|
message: "Each action entry id must match its map key"
|
|
6815
6820
|
}).default({});
|
|
6816
6821
|
var LEAD_GEN_ACTION_ENTRY_INPUTS = [
|
|
@@ -6940,6 +6945,99 @@ var LEAD_GEN_ACTION_ENTRIES = Object.fromEntries(
|
|
|
6940
6945
|
return [parsed.id, parsed];
|
|
6941
6946
|
})
|
|
6942
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"]
|
|
7029
|
+
}
|
|
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
|
+
};
|
|
6943
7041
|
|
|
6944
7042
|
// ../core/src/organization-model/domains/prospecting.ts
|
|
6945
7043
|
DisplayMetadataSchema.extend({
|
|
@@ -7078,7 +7176,7 @@ var DTC_RECORD_COLUMNS = {
|
|
|
7078
7176
|
]
|
|
7079
7177
|
}
|
|
7080
7178
|
};
|
|
7081
|
-
|
|
7179
|
+
Object.values(LEAD_GEN_ACTION_ENTRIES);
|
|
7082
7180
|
var PROSPECTING_STEPS = {
|
|
7083
7181
|
localServices: {
|
|
7084
7182
|
sourceCompanies: {
|
|
@@ -7287,223 +7385,3088 @@ var PROSPECTING_STEPS = {
|
|
|
7287
7385
|
recordColumns: DTC_RECORD_COLUMNS.uploaded,
|
|
7288
7386
|
credentialRequirements: [
|
|
7289
7387
|
{
|
|
7290
|
-
key: "clickup",
|
|
7291
|
-
provider: "clickup",
|
|
7292
|
-
credentialType: "api-key-secret",
|
|
7293
|
-
label: "ClickUp API token",
|
|
7294
|
-
required: true,
|
|
7295
|
-
selectionMode: "single",
|
|
7296
|
-
inputPath: "clickupCredential",
|
|
7297
|
-
verifyOnRun: true
|
|
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"
|
|
10133
|
+
},
|
|
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"
|
|
10141
|
+
},
|
|
10142
|
+
"settings.webhooks": {
|
|
10143
|
+
id: "settings.webhooks",
|
|
10144
|
+
order: 330,
|
|
10145
|
+
label: "Webhooks",
|
|
10146
|
+
enabled: true,
|
|
10147
|
+
lifecycle: "active",
|
|
10148
|
+
path: "/settings/webhooks"
|
|
10149
|
+
},
|
|
10150
|
+
"settings.deployments": {
|
|
10151
|
+
id: "settings.deployments",
|
|
10152
|
+
order: 340,
|
|
10153
|
+
label: "Deployments",
|
|
10154
|
+
enabled: true,
|
|
10155
|
+
lifecycle: "active",
|
|
10156
|
+
path: "/settings/deployments"
|
|
10157
|
+
},
|
|
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
|
|
10167
|
+
},
|
|
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"
|
|
10175
|
+
},
|
|
10176
|
+
"admin.organizations": {
|
|
10177
|
+
id: "admin.organizations",
|
|
10178
|
+
order: 370,
|
|
10179
|
+
label: "Organizations",
|
|
10180
|
+
enabled: true,
|
|
10181
|
+
lifecycle: "active",
|
|
10182
|
+
path: "/admin/organizations"
|
|
10183
|
+
},
|
|
10184
|
+
"admin.users": {
|
|
10185
|
+
id: "admin.users",
|
|
10186
|
+
order: 380,
|
|
10187
|
+
label: "Users",
|
|
10188
|
+
enabled: true,
|
|
10189
|
+
lifecycle: "active",
|
|
10190
|
+
path: "/admin/users"
|
|
10191
|
+
},
|
|
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"
|
|
10199
|
+
},
|
|
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,
|
|
10297
|
+
{
|
|
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 }))
|
|
7298
10303
|
}
|
|
7299
|
-
]
|
|
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,
|
|
10319
|
+
{
|
|
10320
|
+
...entry
|
|
10321
|
+
}
|
|
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();
|
|
10335
|
+
}
|
|
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;
|
|
10340
|
+
return {
|
|
10341
|
+
...model,
|
|
10342
|
+
ontology: {
|
|
10343
|
+
...model.ontology ?? {},
|
|
10344
|
+
catalogTypes: {
|
|
10345
|
+
...baseCatalogTypes,
|
|
10346
|
+
...bridgeCatalogTypes
|
|
10347
|
+
}
|
|
7300
10348
|
}
|
|
10349
|
+
};
|
|
10350
|
+
}
|
|
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}`);
|
|
7301
10356
|
}
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
{
|
|
7307
|
-
id: "local-services",
|
|
7308
|
-
label: "Local Services",
|
|
7309
|
-
description: "Source, analyze, qualify, and personalize local service businesses for outreach.",
|
|
7310
|
-
steps: Object.values(PROSPECTING_STEPS.localServices)
|
|
7311
|
-
},
|
|
7312
|
-
{
|
|
7313
|
-
id: "dtc-subscription-apollo-clickup",
|
|
7314
|
-
label: "DTC Subscription (Apollo + ClickUp)",
|
|
7315
|
-
description: "Import DTC brand leads from Apollo, crawl their websites, score fit, enrich contacts, and export via ClickUp.",
|
|
7316
|
-
steps: Object.values(PROSPECTING_STEPS.dtcApolloClickup)
|
|
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");
|
|
7317
10361
|
}
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
}
|
|
7324
|
-
function isProspectingBuildTemplateId(value) {
|
|
7325
|
-
return PROSPECTING_BUILD_TEMPLATE_OPTIONS.some((template) => template.id === value);
|
|
10362
|
+
return {
|
|
10363
|
+
ontology: compilation.ontology,
|
|
10364
|
+
crmPipelineCatalog,
|
|
10365
|
+
leadGenStageCatalog,
|
|
10366
|
+
actionTypesByLegacyId: indexActionTypesByLegacyId(compilation.ontology.actionTypes)
|
|
10367
|
+
};
|
|
7326
10368
|
}
|
|
7327
|
-
|
|
7328
|
-
|
|
7329
|
-
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
description: "Company was scraped from a source directory (Apify actor run).",
|
|
7335
|
-
order: 1,
|
|
7336
|
-
entity: "company"
|
|
7337
|
-
},
|
|
7338
|
-
populated: {
|
|
7339
|
-
key: "populated",
|
|
7340
|
-
label: "Companies found",
|
|
7341
|
-
description: "Companies have been found and added to the lead-gen list.",
|
|
7342
|
-
order: 2,
|
|
7343
|
-
entity: "company"
|
|
7344
|
-
},
|
|
7345
|
-
crawled: {
|
|
7346
|
-
key: "crawled",
|
|
7347
|
-
label: "Websites crawled",
|
|
7348
|
-
description: "Company websites have been crawled (e.g. via Apify) and raw page content stored for downstream LLM analysis.",
|
|
7349
|
-
order: 2.5,
|
|
7350
|
-
entity: "company"
|
|
7351
|
-
},
|
|
7352
|
-
extracted: {
|
|
7353
|
-
key: "extracted",
|
|
7354
|
-
label: "Websites analyzed",
|
|
7355
|
-
description: "Company websites have been analyzed for business signals.",
|
|
7356
|
-
order: 3,
|
|
7357
|
-
entity: "company"
|
|
7358
|
-
},
|
|
7359
|
-
enriched: {
|
|
7360
|
-
key: "enriched",
|
|
7361
|
-
label: "Enriched",
|
|
7362
|
-
description: "Company or contact enriched with third-party data (e.g. Tomba, Anymailfinder).",
|
|
7363
|
-
order: 4,
|
|
7364
|
-
entity: "company"
|
|
7365
|
-
},
|
|
7366
|
-
"decision-makers-enriched": {
|
|
7367
|
-
key: "decision-makers-enriched",
|
|
7368
|
-
label: "Decision-makers found",
|
|
7369
|
-
description: "Decision-maker contacts discovered and attached to a qualified company.",
|
|
7370
|
-
order: 6,
|
|
7371
|
-
entity: "company",
|
|
7372
|
-
recordEntity: "contact",
|
|
7373
|
-
recordStageKey: "discovered"
|
|
7374
|
-
},
|
|
7375
|
-
// Prospecting - contact discovery
|
|
7376
|
-
discovered: {
|
|
7377
|
-
key: "discovered",
|
|
7378
|
-
label: "Decision-makers found",
|
|
7379
|
-
description: "Decision-maker contact details have been found.",
|
|
7380
|
-
order: 5,
|
|
7381
|
-
entity: "contact"
|
|
7382
|
-
},
|
|
7383
|
-
verified: {
|
|
7384
|
-
key: "verified",
|
|
7385
|
-
label: "Emails verified",
|
|
7386
|
-
description: "Contact email addresses have been checked for deliverability.",
|
|
7387
|
-
order: 7,
|
|
7388
|
-
entity: "contact"
|
|
7389
|
-
},
|
|
7390
|
-
// Qualification
|
|
7391
|
-
qualified: {
|
|
7392
|
-
key: "qualified",
|
|
7393
|
-
label: "Companies qualified",
|
|
7394
|
-
description: "Companies have been scored against the qualification criteria.",
|
|
7395
|
-
order: 8,
|
|
7396
|
-
entity: "company"
|
|
7397
|
-
},
|
|
7398
|
-
// Outreach
|
|
7399
|
-
personalized: {
|
|
7400
|
-
key: "personalized",
|
|
7401
|
-
label: "Personalized",
|
|
7402
|
-
description: "Outreach message personalized for the contact (Instantly personalization workflow).",
|
|
7403
|
-
order: 9,
|
|
7404
|
-
entity: "contact"
|
|
7405
|
-
},
|
|
7406
|
-
uploaded: {
|
|
7407
|
-
key: "uploaded",
|
|
7408
|
-
label: "Reviewed and exported",
|
|
7409
|
-
description: "Approved records have been reviewed and exported for handoff.",
|
|
7410
|
-
order: 10,
|
|
7411
|
-
entity: "company",
|
|
7412
|
-
additionalEntities: ["contact"]
|
|
7413
|
-
},
|
|
7414
|
-
interested: {
|
|
7415
|
-
key: "interested",
|
|
7416
|
-
label: "Interested",
|
|
7417
|
-
description: "Contact replied with a positive signal (Instantly reply-handler transition).",
|
|
7418
|
-
order: 11,
|
|
7419
|
-
entity: "contact"
|
|
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;
|
|
10375
|
+
}
|
|
7420
10376
|
}
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
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,
|
|
10400
|
+
label,
|
|
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)
|
|
10427
|
+
);
|
|
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);
|
|
7438
10434
|
});
|
|
7439
|
-
|
|
7440
|
-
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
|
|
7445
|
-
|
|
7446
|
-
|
|
7447
|
-
|
|
7448
|
-
|
|
7449
|
-
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
|
|
7459
|
-
|
|
7460
|
-
|
|
7461
|
-
|
|
7462
|
-
}
|
|
7463
|
-
var CRM_FOLLOWUP_2_SENT_STATE = {
|
|
7464
|
-
stateKey: "followup_2_sent",
|
|
7465
|
-
label: "Follow-up 2 Sent"
|
|
7466
|
-
};
|
|
7467
|
-
var CRM_FOLLOWUP_3_SENT_STATE = {
|
|
7468
|
-
stateKey: "followup_3_sent",
|
|
7469
|
-
label: "Follow-up 3 Sent"
|
|
7470
|
-
};
|
|
7471
|
-
var CRM_PIPELINE_DEFINITION = {
|
|
7472
|
-
pipelineKey: "crm",
|
|
7473
|
-
stages: [
|
|
7474
|
-
{
|
|
7475
|
-
stageKey: "interested",
|
|
7476
|
-
label: "Interested",
|
|
7477
|
-
color: "blue",
|
|
7478
|
-
states: [
|
|
7479
|
-
CRM_DISCOVERY_REPLIED_STATE,
|
|
7480
|
-
CRM_DISCOVERY_LINK_SENT_STATE,
|
|
7481
|
-
CRM_DISCOVERY_NUDGING_STATE,
|
|
7482
|
-
CRM_DISCOVERY_BOOKING_CANCELLED_STATE,
|
|
7483
|
-
CRM_REPLY_SENT_STATE,
|
|
7484
|
-
CRM_FOLLOWUP_1_SENT_STATE,
|
|
7485
|
-
CRM_FOLLOWUP_2_SENT_STATE,
|
|
7486
|
-
CRM_FOLLOWUP_3_SENT_STATE
|
|
7487
|
-
]
|
|
7488
|
-
},
|
|
7489
|
-
{ stageKey: "proposal", label: "Proposal", color: "yellow", states: [] },
|
|
7490
|
-
{ stageKey: "closing", label: "Closing", color: "orange", states: [] },
|
|
7491
|
-
{ stageKey: "closed_won", label: "Closed Won", color: "green", states: [] },
|
|
7492
|
-
{ stageKey: "closed_lost", label: "Closed Lost", color: "red", states: [] },
|
|
7493
|
-
{ stageKey: "nurturing", label: "Nurturing", color: "grape", states: [] }
|
|
7494
|
-
]
|
|
7495
|
-
};
|
|
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;
|
|
10458
|
+
}
|
|
7496
10459
|
|
|
7497
10460
|
// ../core/src/business/acquisition/api-schemas.ts
|
|
7498
10461
|
var ProcessingStageStatusSchema = z.enum(["success", "no_result", "skipped", "error"]);
|
|
7499
|
-
var LeadGenStageKeySchema = z.string().refine((value) =>
|
|
10462
|
+
var LeadGenStageKeySchema = z.string().refine((value) => isLeadGenStageKey(value), {
|
|
7500
10463
|
message: "processing state key must match LEAD_GEN_STAGE_CATALOG"
|
|
7501
10464
|
});
|
|
7502
|
-
var LeadGenActionKeySchema = z.string().refine((value) =>
|
|
10465
|
+
var LeadGenActionKeySchema = z.string().refine((value) => isLeadGenActionKey(value), {
|
|
7503
10466
|
message: "actionKey must match ACTION_REGISTRY"
|
|
7504
10467
|
});
|
|
7505
|
-
var crmStageKeys =
|
|
7506
|
-
var crmStateKeys =
|
|
10468
|
+
var crmStageKeys = CRM_STAGE_KEYS_FROM_ONTOLOGY;
|
|
10469
|
+
var crmStateKeys = CRM_STATE_KEYS_FROM_ONTOLOGY;
|
|
7507
10470
|
var CrmStageKeySchema = z.enum(crmStageKeys);
|
|
7508
10471
|
var CrmStateKeySchema = z.enum(crmStateKeys);
|
|
7509
10472
|
var ProcessingStateEntrySchema = z.object({
|
|
@@ -7758,7 +10721,7 @@ var IcpRubricSchema = z.object({
|
|
|
7758
10721
|
customRules: z.string().optional()
|
|
7759
10722
|
});
|
|
7760
10723
|
var PipelineStageSchema = z.object({
|
|
7761
|
-
key: z.string().refine((value) =>
|
|
10724
|
+
key: z.string().refine((value) => isLeadGenStageKey(value), {
|
|
7762
10725
|
message: "pipeline stage key must match LEAD_GEN_STAGE_CATALOG"
|
|
7763
10726
|
}),
|
|
7764
10727
|
label: z.string().optional(),
|
|
@@ -8230,9 +11193,7 @@ z.object({
|
|
|
8230
11193
|
offset: z.coerce.number().int().min(0).default(0)
|
|
8231
11194
|
}).strict().superRefine((query, ctx) => {
|
|
8232
11195
|
if (!query.stage) return;
|
|
8233
|
-
|
|
8234
|
-
const validEntity = stage?.entity === query.entity || stage?.additionalEntities?.includes(query.entity) || stage?.recordEntity === query.entity;
|
|
8235
|
-
if (!validEntity) {
|
|
11196
|
+
if (!isLeadGenRecordStageValidForEntity(query.stage, query.entity)) {
|
|
8236
11197
|
ctx.addIssue({
|
|
8237
11198
|
code: z.ZodIssueCode.custom,
|
|
8238
11199
|
message: `stage "${query.stage}" is not valid for ${query.entity} records`,
|
|
@@ -8698,14 +11659,18 @@ createAdapter("execution", ["trigger", "triggerAsync"]);
|
|
|
8698
11659
|
createAdapter("email", ["send"]);
|
|
8699
11660
|
|
|
8700
11661
|
// ../core/src/organization-model/helpers.ts
|
|
11662
|
+
function childSystemsOf2(system) {
|
|
11663
|
+
return system.systems ?? system.subsystems ?? {};
|
|
11664
|
+
}
|
|
8701
11665
|
function listAllSystems(model) {
|
|
8702
11666
|
const results = [];
|
|
8703
11667
|
function walk(map2, prefix) {
|
|
8704
11668
|
for (const [localId, system] of Object.entries(map2)) {
|
|
8705
11669
|
const fullPath = prefix ? `${prefix}.${localId}` : localId;
|
|
8706
11670
|
results.push({ path: fullPath, system });
|
|
8707
|
-
|
|
8708
|
-
|
|
11671
|
+
const childSystems = childSystemsOf2(system);
|
|
11672
|
+
if (Object.keys(childSystems).length > 0) {
|
|
11673
|
+
walk(childSystems, fullPath);
|
|
8709
11674
|
}
|
|
8710
11675
|
}
|
|
8711
11676
|
}
|