@elevasis/core 0.21.0 → 0.23.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/index.d.ts +2518 -2169
- package/dist/index.js +2495 -1095
- package/dist/knowledge/index.d.ts +706 -1044
- package/dist/knowledge/index.js +9 -9
- package/dist/organization-model/index.d.ts +2518 -2169
- package/dist/organization-model/index.js +2495 -1095
- package/dist/test-utils/index.d.ts +826 -1014
- package/dist/test-utils/index.js +1894 -1032
- package/package.json +3 -3
- package/src/__tests__/template-core-compatibility.test.ts +11 -79
- package/src/_gen/__tests__/__snapshots__/contracts.md.snap +852 -397
- package/src/auth/multi-tenancy/permissions.ts +20 -8
- package/src/business/README.md +2 -2
- package/src/business/acquisition/api-schemas.test.ts +175 -2
- package/src/business/acquisition/api-schemas.ts +132 -16
- package/src/business/acquisition/build-templates.test.ts +4 -4
- package/src/business/acquisition/build-templates.ts +72 -30
- package/src/business/acquisition/crm-state-actions.test.ts +13 -11
- package/src/business/acquisition/index.ts +12 -0
- package/src/business/acquisition/types.ts +7 -3
- package/src/business/clients/api-schemas.test.ts +115 -0
- package/src/business/clients/api-schemas.ts +158 -0
- package/src/business/clients/index.ts +1 -0
- package/src/business/deals/api-schemas.ts +8 -0
- package/src/business/index.ts +5 -2
- package/src/business/projects/types.ts +19 -0
- package/src/execution/engine/__tests__/fixtures/test-agents.ts +10 -8
- package/src/execution/engine/agent/core/__tests__/agent.test.ts +16 -12
- package/src/execution/engine/agent/core/__tests__/error-passthrough.test.ts +4 -3
- package/src/execution/engine/agent/core/types.ts +25 -15
- package/src/execution/engine/agent/index.ts +6 -4
- package/src/execution/engine/agent/reasoning/__tests__/request-builder.test.ts +24 -18
- package/src/execution/engine/index.ts +3 -0
- package/src/execution/engine/workflow/types.ts +9 -2
- package/src/knowledge/README.md +8 -7
- package/src/knowledge/__tests__/queries.test.ts +74 -73
- package/src/knowledge/format.ts +10 -9
- package/src/knowledge/index.ts +1 -1
- package/src/knowledge/published.ts +1 -1
- package/src/knowledge/queries.ts +26 -25
- package/src/organization-model/README.md +73 -26
- package/src/organization-model/__tests__/content-kinds-registry.test.ts +210 -0
- package/src/organization-model/__tests__/defaults.test.ts +76 -96
- package/src/organization-model/__tests__/domains/actions.test.ts +56 -0
- package/src/organization-model/__tests__/domains/customers.test.ts +299 -295
- package/src/organization-model/__tests__/domains/entities.test.ts +56 -0
- package/src/organization-model/__tests__/domains/goals.test.ts +493 -479
- package/src/organization-model/__tests__/domains/identity.test.ts +280 -279
- package/src/organization-model/__tests__/domains/navigation.test.ts +268 -212
- package/src/organization-model/__tests__/domains/offerings.test.ts +414 -419
- package/src/organization-model/__tests__/domains/policies.test.ts +323 -0
- package/src/organization-model/__tests__/domains/resource-mappings.test.ts +271 -271
- package/src/organization-model/__tests__/domains/resources.test.ts +310 -0
- package/src/organization-model/__tests__/domains/roles.test.ts +463 -347
- package/src/organization-model/__tests__/domains/statuses.test.ts +246 -243
- package/src/organization-model/__tests__/domains/systems.test.ts +209 -0
- package/src/organization-model/__tests__/flatten-additive-merge.test.ts +361 -0
- package/src/organization-model/__tests__/foundation.test.ts +74 -102
- package/src/organization-model/__tests__/get-resources-for-system.test.ts +144 -0
- package/src/organization-model/__tests__/graph.test.ts +899 -71
- package/src/organization-model/__tests__/knowledge.test.ts +209 -49
- package/src/organization-model/__tests__/lookup-helpers.test.ts +438 -0
- package/src/organization-model/__tests__/migration-helpers.test.ts +591 -0
- package/src/organization-model/__tests__/prospecting-ssot.test.ts +36 -27
- package/src/organization-model/__tests__/recursive-system-schema.test.ts +520 -0
- package/src/organization-model/__tests__/resolve.test.ts +174 -23
- package/src/organization-model/__tests__/schema.test.ts +291 -114
- package/src/organization-model/__tests__/surface-projection.test.ts +207 -97
- package/src/organization-model/catalogs/lead-gen.ts +144 -0
- package/src/organization-model/content-kinds/config.ts +36 -0
- package/src/organization-model/content-kinds/index.ts +74 -0
- package/src/organization-model/content-kinds/pipeline.ts +68 -0
- package/src/organization-model/content-kinds/registry.ts +44 -0
- package/src/organization-model/content-kinds/status.ts +71 -0
- package/src/organization-model/content-kinds/template.ts +83 -0
- package/src/organization-model/content-kinds/types.ts +117 -0
- package/src/organization-model/contracts.ts +13 -3
- package/src/organization-model/defaults.ts +499 -86
- package/src/organization-model/domains/actions.ts +239 -0
- package/src/organization-model/domains/customers.ts +78 -75
- package/src/organization-model/domains/entities.ts +144 -0
- package/src/organization-model/domains/goals.ts +83 -80
- package/src/organization-model/domains/knowledge.ts +76 -17
- package/src/organization-model/domains/navigation.ts +107 -384
- package/src/organization-model/domains/offerings.ts +71 -66
- package/src/organization-model/domains/policies.ts +102 -0
- package/src/organization-model/domains/projects.ts +14 -48
- package/src/organization-model/domains/prospecting.ts +62 -181
- package/src/organization-model/domains/resources.ts +145 -0
- package/src/organization-model/domains/roles.ts +96 -55
- package/src/organization-model/domains/sales.ts +10 -219
- package/src/organization-model/domains/shared.ts +57 -57
- package/src/organization-model/domains/statuses.ts +339 -130
- package/src/organization-model/domains/systems.ts +203 -0
- package/src/organization-model/foundation.ts +54 -67
- package/src/organization-model/graph/build.ts +682 -54
- package/src/organization-model/graph/link.ts +1 -1
- package/src/organization-model/graph/schema.ts +24 -9
- package/src/organization-model/graph/types.ts +20 -7
- package/src/organization-model/helpers.ts +231 -26
- package/src/organization-model/icons.ts +1 -0
- package/src/organization-model/index.ts +118 -5
- package/src/organization-model/migration-helpers.ts +249 -0
- package/src/organization-model/organization-graph.mdx +16 -15
- package/src/organization-model/organization-model.mdx +111 -44
- package/src/organization-model/published.ts +172 -19
- package/src/organization-model/resolve.ts +117 -54
- package/src/organization-model/schema.ts +654 -112
- package/src/organization-model/surface-projection.ts +116 -122
- package/src/organization-model/types.ts +146 -20
- package/src/platform/api/types.ts +38 -35
- package/src/platform/constants/versions.ts +1 -1
- package/src/platform/registry/__tests__/command-view.test.ts +6 -8
- package/src/platform/registry/__tests__/resource-link.test.ts +13 -8
- package/src/platform/registry/__tests__/resource-registry.integration.test.ts +16 -31
- package/src/platform/registry/__tests__/resource-registry.nested-systems.test.ts +245 -0
- package/src/platform/registry/__tests__/resource-registry.test.ts +2053 -2005
- package/src/platform/registry/__tests__/validation.test.ts +1347 -1086
- package/src/platform/registry/index.ts +14 -0
- package/src/platform/registry/resource-registry.ts +52 -2
- package/src/platform/registry/serialization.ts +241 -202
- package/src/platform/registry/serialized-types.ts +1 -0
- package/src/platform/registry/types.ts +411 -361
- package/src/platform/registry/validation.ts +745 -513
- package/src/projects/api-schemas.ts +290 -267
- package/src/reference/_generated/contracts.md +853 -397
- package/src/reference/glossary.md +23 -18
- package/src/supabase/database.types.ts +181 -0
- package/src/test-utils/test-utils.test.ts +1 -6
- package/src/organization-model/__tests__/domains/operations.test.ts +0 -203
- package/src/organization-model/domains/features.ts +0 -31
- package/src/organization-model/domains/operations.ts +0 -85
|
@@ -4,23 +4,37 @@ import { OrganizationModelSchema } from '../schema'
|
|
|
4
4
|
|
|
5
5
|
export const OrganizationGraphNodeKindSchema = z.enum([
|
|
6
6
|
'organization',
|
|
7
|
-
'
|
|
8
|
-
'
|
|
7
|
+
'system',
|
|
8
|
+
'role',
|
|
9
|
+
'action',
|
|
9
10
|
'entity',
|
|
10
|
-
'
|
|
11
|
+
'event',
|
|
12
|
+
'policy',
|
|
11
13
|
'stage',
|
|
12
14
|
'resource',
|
|
13
|
-
'knowledge'
|
|
15
|
+
'knowledge',
|
|
16
|
+
'customer-segment',
|
|
17
|
+
'offering',
|
|
18
|
+
'goal',
|
|
19
|
+
'surface',
|
|
20
|
+
'navigation-group',
|
|
21
|
+
// Phase 3 preview — Phase 4 populates via graph projection of system.content entries.
|
|
22
|
+
'content-node'
|
|
14
23
|
])
|
|
15
24
|
|
|
16
25
|
export const OrganizationGraphEdgeKindSchema = z.enum([
|
|
17
26
|
'contains',
|
|
18
27
|
'references',
|
|
19
|
-
'exposes',
|
|
20
28
|
'maps_to',
|
|
21
|
-
'operates-on',
|
|
22
29
|
'uses',
|
|
23
|
-
'governs'
|
|
30
|
+
'governs',
|
|
31
|
+
'links',
|
|
32
|
+
'affects',
|
|
33
|
+
'emits',
|
|
34
|
+
'originates_from',
|
|
35
|
+
'triggers',
|
|
36
|
+
'applies_to',
|
|
37
|
+
'effects'
|
|
24
38
|
])
|
|
25
39
|
|
|
26
40
|
export const OrganizationGraphNodeSchema = z.object({
|
|
@@ -31,8 +45,9 @@ export const OrganizationGraphNodeSchema = z.object({
|
|
|
31
45
|
description: DescriptionSchema.optional(),
|
|
32
46
|
icon: IconNameSchema.optional(),
|
|
33
47
|
enabled: z.boolean().optional(),
|
|
34
|
-
|
|
35
|
-
|
|
48
|
+
resourceType: z
|
|
49
|
+
.enum(['workflow', 'agent', 'trigger', 'integration', 'external', 'human_checkpoint', 'script'])
|
|
50
|
+
.optional()
|
|
36
51
|
})
|
|
37
52
|
|
|
38
53
|
export const OrganizationGraphEdgeSchema = z.object({
|
|
@@ -5,22 +5,36 @@ import type { OrganizationModelIconToken } from '../icons'
|
|
|
5
5
|
|
|
6
6
|
export type OrganizationGraphNodeKind =
|
|
7
7
|
| 'organization'
|
|
8
|
-
| '
|
|
9
|
-
| '
|
|
8
|
+
| 'system'
|
|
9
|
+
| 'role'
|
|
10
|
+
| 'action'
|
|
10
11
|
| 'entity'
|
|
11
|
-
| '
|
|
12
|
+
| 'event'
|
|
13
|
+
| 'policy'
|
|
12
14
|
| 'stage'
|
|
13
15
|
| 'resource'
|
|
14
16
|
| 'knowledge'
|
|
17
|
+
| 'customer-segment'
|
|
18
|
+
| 'offering'
|
|
19
|
+
| 'goal'
|
|
20
|
+
| 'surface'
|
|
21
|
+
| 'navigation-group'
|
|
22
|
+
/** Phase 3 preview — Phase 4 populates this kind via graph projection of system.content entries. */
|
|
23
|
+
| 'content-node'
|
|
15
24
|
|
|
16
25
|
export type OrganizationGraphEdgeKind =
|
|
17
26
|
| 'contains'
|
|
18
27
|
| 'references'
|
|
19
|
-
| 'exposes'
|
|
20
28
|
| 'maps_to'
|
|
21
|
-
| 'operates-on'
|
|
22
29
|
| 'uses'
|
|
23
30
|
| 'governs'
|
|
31
|
+
| 'links'
|
|
32
|
+
| 'affects'
|
|
33
|
+
| 'emits'
|
|
34
|
+
| 'originates_from'
|
|
35
|
+
| 'triggers'
|
|
36
|
+
| 'applies_to'
|
|
37
|
+
| 'effects'
|
|
24
38
|
export type { Link } from './link'
|
|
25
39
|
|
|
26
40
|
export interface OrganizationGraphNode {
|
|
@@ -31,8 +45,7 @@ export interface OrganizationGraphNode {
|
|
|
31
45
|
description?: string
|
|
32
46
|
icon?: OrganizationModelIconToken
|
|
33
47
|
enabled?: boolean
|
|
34
|
-
|
|
35
|
-
resourceType?: 'workflow' | 'agent' | 'trigger' | 'integration' | 'external' | 'human_checkpoint'
|
|
48
|
+
resourceType?: 'workflow' | 'agent' | 'trigger' | 'integration' | 'external' | 'human_checkpoint' | 'script'
|
|
36
49
|
}
|
|
37
50
|
|
|
38
51
|
export interface OrganizationGraphEdge {
|
|
@@ -1,4 +1,20 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OrganizationModel, OrganizationModelSystemEntry } from './types'
|
|
2
|
+
import type { ContentNode } from './content-kinds/types'
|
|
3
|
+
import type { ResourceEntry } from './domains/resources'
|
|
4
|
+
|
|
5
|
+
// W1A has landed: ContentNode and SystemEntry (with content + subsystems) are now
|
|
6
|
+
// defined in their canonical locations.
|
|
7
|
+
// Phase 4: removed locally-scoped inferred types for deleted compound-domain schemas
|
|
8
|
+
// (SalesPipeline, ProspectingBuildTemplate, etc.). migration-helpers.ts imports them directly.
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* SystemEntry extended with the recursive tree slots (`content`, `subsystems`).
|
|
12
|
+
* `OrganizationModelSystemEntry` is inferred from `SystemEntrySchema: ZodType<SystemEntry>`
|
|
13
|
+
* so it already carries these fields; this alias re-exports it under the tree-walker name
|
|
14
|
+
* for clarity at call sites.
|
|
15
|
+
*/
|
|
16
|
+
export type { ContentNode }
|
|
17
|
+
export type SystemEntryWithTree = OrganizationModelSystemEntry
|
|
2
18
|
|
|
3
19
|
export function defaultPathFor(id: string): string {
|
|
4
20
|
return `/${id.replaceAll('.', '/')}`
|
|
@@ -9,66 +25,255 @@ export function parentIdOf(id: string): string | undefined {
|
|
|
9
25
|
return index === -1 ? undefined : id.slice(0, index)
|
|
10
26
|
}
|
|
11
27
|
|
|
12
|
-
|
|
13
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Return all entries of an OM domain map sorted by their declared `order` field.
|
|
30
|
+
* Use this whenever iteration order matters for UI or deterministic output.
|
|
31
|
+
*/
|
|
32
|
+
export function listDomain<T extends { id: string; order: number }>(record: Record<string, T>): T[] {
|
|
33
|
+
return Object.values(record).sort((a, b) => a.order - b.order)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function findById(
|
|
37
|
+
systems: Record<string, OrganizationModelSystemEntry>,
|
|
38
|
+
id: string
|
|
39
|
+
): OrganizationModelSystemEntry | undefined {
|
|
40
|
+
return systems[id]
|
|
14
41
|
}
|
|
15
42
|
|
|
16
43
|
export function findByPath(
|
|
17
|
-
|
|
44
|
+
systems: Record<string, OrganizationModelSystemEntry>,
|
|
18
45
|
path: string
|
|
19
|
-
):
|
|
20
|
-
return
|
|
46
|
+
): OrganizationModelSystemEntry | undefined {
|
|
47
|
+
return Object.values(systems).find((system) => (system.path ?? system.ui?.path ?? defaultPathFor(system.id)) === path)
|
|
21
48
|
}
|
|
22
49
|
|
|
23
50
|
export function childrenOf(
|
|
24
|
-
|
|
51
|
+
systems: Record<string, OrganizationModelSystemEntry>,
|
|
25
52
|
id: string
|
|
26
|
-
):
|
|
53
|
+
): OrganizationModelSystemEntry[] {
|
|
27
54
|
const prefix = `${id}.`
|
|
28
|
-
return
|
|
55
|
+
return Object.values(systems).filter(
|
|
56
|
+
(system) => system.id.startsWith(prefix) && !system.id.slice(prefix.length).includes('.')
|
|
57
|
+
)
|
|
29
58
|
}
|
|
30
59
|
|
|
31
|
-
export function topLevel(
|
|
32
|
-
return
|
|
60
|
+
export function topLevel(systems: Record<string, OrganizationModelSystemEntry>): OrganizationModelSystemEntry[] {
|
|
61
|
+
return Object.values(systems).filter((system) => !system.id.includes('.'))
|
|
33
62
|
}
|
|
34
63
|
|
|
35
64
|
export function ancestorsOf(
|
|
36
|
-
|
|
65
|
+
systems: Record<string, OrganizationModelSystemEntry>,
|
|
37
66
|
id: string
|
|
38
|
-
):
|
|
67
|
+
): OrganizationModelSystemEntry[] {
|
|
39
68
|
const segments = id.split('.')
|
|
40
69
|
const ids = segments.map((_, index) => segments.slice(0, index + 1).join('.'))
|
|
41
|
-
return ids
|
|
70
|
+
return ids
|
|
71
|
+
.map((ancestorId) => findById(systems, ancestorId))
|
|
72
|
+
.filter((system): system is OrganizationModelSystemEntry => Boolean(system))
|
|
42
73
|
}
|
|
43
74
|
|
|
44
75
|
export function parentOf(
|
|
45
|
-
|
|
76
|
+
systems: Record<string, OrganizationModelSystemEntry>,
|
|
46
77
|
id: string
|
|
47
|
-
):
|
|
78
|
+
): OrganizationModelSystemEntry | undefined {
|
|
48
79
|
const parentId = parentIdOf(id)
|
|
49
|
-
return parentId ? findById(
|
|
80
|
+
return parentId ? findById(systems, parentId) : undefined
|
|
50
81
|
}
|
|
51
82
|
|
|
52
83
|
function inheritedValue<T>(
|
|
53
|
-
|
|
84
|
+
systems: Record<string, OrganizationModelSystemEntry>,
|
|
54
85
|
id: string,
|
|
55
|
-
getValue: (
|
|
86
|
+
getValue: (system: OrganizationModelSystemEntry) => T | undefined
|
|
56
87
|
): T | undefined {
|
|
57
|
-
return ancestorsOf(
|
|
88
|
+
return ancestorsOf(systems, id)
|
|
58
89
|
.slice()
|
|
59
90
|
.reverse()
|
|
60
91
|
.map(getValue)
|
|
61
92
|
.find((value): value is T => value !== undefined)
|
|
62
93
|
}
|
|
63
94
|
|
|
64
|
-
export function uiPositionFor(
|
|
65
|
-
return inheritedValue(
|
|
95
|
+
export function uiPositionFor(systems: Record<string, OrganizationModelSystemEntry>, id: string) {
|
|
96
|
+
return inheritedValue(systems, id, (system) => system.uiPosition)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function requiresAdminFor(systems: Record<string, OrganizationModelSystemEntry>, id: string): boolean {
|
|
100
|
+
return inheritedValue(systems, id, (system) => system.requiresAdmin) ?? false
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function devOnlyFor(systems: Record<string, OrganizationModelSystemEntry>, id: string): boolean {
|
|
104
|
+
return inheritedValue(systems, id, (system) => system.devOnly || system.lifecycle === 'beta' || undefined) ?? false
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// ---------------------------------------------------------------------------
|
|
108
|
+
// Recursive system-tree helpers (Wave 1B)
|
|
109
|
+
// These operate on the NEW recursive System shape introduced by W1A, where
|
|
110
|
+
// `model.systems` is `Record<LocalId, SystemEntry>` (nested via `subsystems`).
|
|
111
|
+
// `SystemEntry` here is the extended interface defined at the top of this file.
|
|
112
|
+
// ---------------------------------------------------------------------------
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Resolve a system by its dot-separated path string.
|
|
116
|
+
*
|
|
117
|
+
* `getSystem(model, 'sales.crm.dispositions')` walks:
|
|
118
|
+
* `model.systems['sales'] → .subsystems['crm'] → .subsystems['dispositions']`
|
|
119
|
+
*
|
|
120
|
+
* Returns `undefined` if any segment is missing.
|
|
121
|
+
*/
|
|
122
|
+
export function getSystem(model: OrganizationModel, path: string): SystemEntryWithTree | undefined {
|
|
123
|
+
const segments = path.split('.')
|
|
124
|
+
// model.systems is typed as Record<string, OrganizationModelSystemEntry>; cast
|
|
125
|
+
// to SystemEntryWithTree (which extends it with optional content + subsystems).
|
|
126
|
+
let current: Record<string, SystemEntryWithTree> = model.systems as Record<string, SystemEntryWithTree>
|
|
127
|
+
let node: SystemEntryWithTree | undefined
|
|
128
|
+
for (const seg of segments) {
|
|
129
|
+
node = current[seg]
|
|
130
|
+
if (node === undefined) return undefined
|
|
131
|
+
current = node.subsystems ?? {}
|
|
132
|
+
}
|
|
133
|
+
return node
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Return the root-first ancestor chain for a system path, including the system
|
|
138
|
+
* itself as the last element.
|
|
139
|
+
*
|
|
140
|
+
* `getSystemAncestors(model, 'sales.crm')` → `[salesEntry, crmEntry]`
|
|
141
|
+
*
|
|
142
|
+
* Returns an empty array if the path cannot be resolved.
|
|
143
|
+
*/
|
|
144
|
+
export function getSystemAncestors(model: OrganizationModel, path: string): SystemEntryWithTree[] {
|
|
145
|
+
const segments = path.split('.')
|
|
146
|
+
const result: SystemEntryWithTree[] = []
|
|
147
|
+
let current: Record<string, SystemEntryWithTree> = model.systems as Record<string, SystemEntryWithTree>
|
|
148
|
+
for (const seg of segments) {
|
|
149
|
+
const node = current[seg]
|
|
150
|
+
if (node === undefined) return []
|
|
151
|
+
result.push(node)
|
|
152
|
+
current = node.subsystems ?? {}
|
|
153
|
+
}
|
|
154
|
+
return result
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Flat depth-first enumeration of every system in the model tree.
|
|
159
|
+
* Each entry carries the computed full path and the system node.
|
|
160
|
+
* Order: parent before children (pre-order DFS).
|
|
161
|
+
*
|
|
162
|
+
* Example result paths: `'sales'`, `'sales.crm'`, `'sales.crm.dispositions'`
|
|
163
|
+
*/
|
|
164
|
+
export function listAllSystems(model: OrganizationModel): Array<{ path: string; system: SystemEntryWithTree }> {
|
|
165
|
+
const results: Array<{ path: string; system: SystemEntryWithTree }> = []
|
|
166
|
+
|
|
167
|
+
function walk(map: Record<string, SystemEntryWithTree>, prefix: string): void {
|
|
168
|
+
for (const [localId, system] of Object.entries(map)) {
|
|
169
|
+
const fullPath = prefix ? `${prefix}.${localId}` : localId
|
|
170
|
+
results.push({ path: fullPath, system })
|
|
171
|
+
if (system.subsystems) {
|
|
172
|
+
walk(system.subsystems, fullPath)
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
walk(model.systems as Record<string, SystemEntryWithTree>, '')
|
|
178
|
+
return results
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Resolve a content node by its qualified id (`<system-path>:<local-content-id>`).
|
|
183
|
+
*
|
|
184
|
+
* `getContent(model, 'sales.crm:default-pipeline')` resolves the `sales.crm`
|
|
185
|
+
* system and then looks up `system.content['default-pipeline']`.
|
|
186
|
+
*
|
|
187
|
+
* Returns `undefined` if the system or local id is not found, or if the
|
|
188
|
+
* qualified id does not contain exactly one `:` separator.
|
|
189
|
+
*/
|
|
190
|
+
export function getContent(model: OrganizationModel, qualifiedId: string): ContentNode | undefined {
|
|
191
|
+
const colonIndex = qualifiedId.indexOf(':')
|
|
192
|
+
if (colonIndex === -1) return undefined
|
|
193
|
+
const systemPath = qualifiedId.slice(0, colonIndex)
|
|
194
|
+
const localId = qualifiedId.slice(colonIndex + 1)
|
|
195
|
+
if (!systemPath || !localId) return undefined
|
|
196
|
+
const system = getSystem(model, systemPath)
|
|
197
|
+
return system?.content?.[localId]
|
|
66
198
|
}
|
|
67
199
|
|
|
68
|
-
|
|
69
|
-
|
|
200
|
+
/**
|
|
201
|
+
* Resolve the layered content view for a system.
|
|
202
|
+
*
|
|
203
|
+
* Returns:
|
|
204
|
+
* - `own`: the system's direct `content` map (empty record if none).
|
|
205
|
+
* - `inherited`: ancestor content nodes that are NOT shadowed by `own` or by a
|
|
206
|
+
* closer ancestor (depth-wins cascade, same as CSS specificity).
|
|
207
|
+
*
|
|
208
|
+
* Shadow rule: if two ancestors both declare `content['x']`, the deeper one
|
|
209
|
+
* wins. If the system itself declares `content['x']`, neither ancestor entry
|
|
210
|
+
* for `'x'` appears in `inherited`.
|
|
211
|
+
*
|
|
212
|
+
* `resolveSystemContent(model, 'sales.crm')` with both `sales.content['x']`
|
|
213
|
+
* and `sales.crm.content['x']` defined → `own` contains `'x'`, `inherited`
|
|
214
|
+
* contains NO entry for `'x'` from `sales`.
|
|
215
|
+
*/
|
|
216
|
+
export function resolveSystemContent(
|
|
217
|
+
model: OrganizationModel,
|
|
218
|
+
path: string
|
|
219
|
+
): { own: Record<string, ContentNode>; inherited: Array<{ fromPath: string; node: ContentNode; localId: string }> } {
|
|
220
|
+
const ancestors = getSystemAncestors(model, path)
|
|
221
|
+
if (ancestors.length === 0) return { own: {}, inherited: [] }
|
|
222
|
+
|
|
223
|
+
const system = ancestors[ancestors.length - 1]
|
|
224
|
+
const own: Record<string, ContentNode> = { ...(system.content ?? {}) }
|
|
225
|
+
|
|
226
|
+
// Collect ancestor entries depth-first (deepest ancestor first, excluding self).
|
|
227
|
+
// We reconstruct paths for each ancestor by slicing the path segments.
|
|
228
|
+
const segments = path.split('.')
|
|
229
|
+
const shadowedIds = new Set(Object.keys(own))
|
|
230
|
+
const inherited: Array<{ fromPath: string; node: ContentNode; localId: string }> = []
|
|
231
|
+
|
|
232
|
+
// Iterate ancestors from deepest-parent to root so deeper wins.
|
|
233
|
+
for (let i = ancestors.length - 2; i >= 0; i--) {
|
|
234
|
+
const ancestor = ancestors[i]
|
|
235
|
+
const ancestorPath = segments.slice(0, i + 1).join('.')
|
|
236
|
+
const contentMap = ancestor.content ?? {}
|
|
237
|
+
for (const [localId, node] of Object.entries(contentMap)) {
|
|
238
|
+
if (!shadowedIds.has(localId)) {
|
|
239
|
+
shadowedIds.add(localId)
|
|
240
|
+
inherited.push({ fromPath: ancestorPath, node, localId })
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Re-order inherited so shallower ancestors come first (root-first display order).
|
|
246
|
+
inherited.reverse()
|
|
247
|
+
|
|
248
|
+
return { own, inherited }
|
|
70
249
|
}
|
|
71
250
|
|
|
72
|
-
|
|
73
|
-
|
|
251
|
+
/**
|
|
252
|
+
* Return all resources whose `systemPath` belongs to the given system.
|
|
253
|
+
*
|
|
254
|
+
* When `includeDescendants` is false (default), only resources whose
|
|
255
|
+
* `systemPath` exactly matches `systemPath` are returned.
|
|
256
|
+
*
|
|
257
|
+
* When `includeDescendants` is true, resources attached to any descendant
|
|
258
|
+
* system are also included. Descendant matching is segment-aware: the path
|
|
259
|
+
* `'sales'` does NOT match `'salesforce.foo'` because segment boundaries are
|
|
260
|
+
* enforced by splitting on `'.'`.
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* getResourcesForSystem(model, 'sales')
|
|
264
|
+
* // → resources where systemPath === 'sales'
|
|
265
|
+
*
|
|
266
|
+
* getResourcesForSystem(model, 'sales', { includeDescendants: true })
|
|
267
|
+
* // → resources where systemPath === 'sales' OR systemPath starts with 'sales.'
|
|
268
|
+
*/
|
|
269
|
+
export function getResourcesForSystem(
|
|
270
|
+
model: OrganizationModel,
|
|
271
|
+
systemPath: string,
|
|
272
|
+
options: { includeDescendants?: boolean } = {}
|
|
273
|
+
): ResourceEntry[] {
|
|
274
|
+
const { includeDescendants = false } = options
|
|
275
|
+
const prefix = systemPath + '.'
|
|
276
|
+
return Object.values(model.resources ?? {}).filter(
|
|
277
|
+
(r) => r.systemPath === systemPath || (includeDescendants && r.systemPath.startsWith(prefix))
|
|
278
|
+
)
|
|
74
279
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './content-kinds/index'
|
|
1
2
|
export * from './schema'
|
|
2
3
|
export * from './types'
|
|
3
4
|
export * from './contracts'
|
|
@@ -9,10 +10,122 @@ export {
|
|
|
9
10
|
export * from './defaults'
|
|
10
11
|
export * from './resolve'
|
|
11
12
|
export * from './foundation'
|
|
13
|
+
export * from './surface-projection'
|
|
12
14
|
export * from './helpers'
|
|
15
|
+
export * from './migration-helpers'
|
|
13
16
|
export * from './graph'
|
|
14
|
-
export * from './
|
|
15
|
-
export * from './domains/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
export * from './catalogs/lead-gen'
|
|
18
|
+
export * from './domains/branding'
|
|
19
|
+
// Phase 4: OrganizationModelSalesSchema, OrganizationModelProspectingSchema,
|
|
20
|
+
// OrganizationModelProjectsSchema removed. Business-logic exports (StatefulPipelineDefinition,
|
|
21
|
+
// CRM_PIPELINE_DEFINITION, ProspectingBuildTemplateSchema, etc.) still re-exported below.
|
|
22
|
+
export {
|
|
23
|
+
SalesStageSemanticClassSchema,
|
|
24
|
+
SalesStageSchema,
|
|
25
|
+
SalesPipelineSchema,
|
|
26
|
+
CRM_DISCOVERY_REPLIED_STATE,
|
|
27
|
+
CRM_DISCOVERY_LINK_SENT_STATE,
|
|
28
|
+
CRM_DISCOVERY_NUDGING_STATE,
|
|
29
|
+
CRM_DISCOVERY_BOOKING_CANCELLED_STATE,
|
|
30
|
+
CRM_REPLY_SENT_STATE,
|
|
31
|
+
CRM_FOLLOWUP_1_SENT_STATE,
|
|
32
|
+
CRM_FOLLOWUP_2_SENT_STATE,
|
|
33
|
+
CRM_FOLLOWUP_3_SENT_STATE,
|
|
34
|
+
CRM_PIPELINE_DEFINITION,
|
|
35
|
+
CRM_PRIORITY_BUCKETS,
|
|
36
|
+
DEFAULT_CRM_PRIORITY_RULE_CONFIG,
|
|
37
|
+
DEFAULT_CRM_NEXT_ACTION_RULE_CONFIG,
|
|
38
|
+
ACQ_LIST_MEMBERS_LEAD_GEN_PIPELINE,
|
|
39
|
+
ACQ_LIST_COMPANIES_LEAD_GEN_PIPELINE,
|
|
40
|
+
LEAD_GEN_PIPELINE_DEFINITIONS,
|
|
41
|
+
findPipeline,
|
|
42
|
+
getValidStatesForStage,
|
|
43
|
+
LEAD_GEN_STAGE_CATALOG
|
|
44
|
+
} from './domains/sales'
|
|
45
|
+
export type {
|
|
46
|
+
StatefulStateDefinition,
|
|
47
|
+
StatefulStageDefinition,
|
|
48
|
+
StatefulPipelineDefinition,
|
|
49
|
+
CrmPriorityBucketKey,
|
|
50
|
+
CrmPriorityBucketDefinition,
|
|
51
|
+
CrmPriorityRuleConfig,
|
|
52
|
+
CrmNextActionMapping,
|
|
53
|
+
CrmNextActionRuleConfig
|
|
54
|
+
} from './domains/sales'
|
|
55
|
+
export {
|
|
56
|
+
ProspectingLifecycleStageSchema,
|
|
57
|
+
RecordColumnConfigSchema,
|
|
58
|
+
RecordColumnsConfigSchema,
|
|
59
|
+
CredentialRequirementSchema,
|
|
60
|
+
ProspectingBuildTemplateStepSchema,
|
|
61
|
+
ProspectingBuildTemplateSchema,
|
|
62
|
+
PROSPECTING_STEPS,
|
|
63
|
+
ACTION_REGISTRY,
|
|
64
|
+
findActionById
|
|
65
|
+
} from './domains/prospecting'
|
|
66
|
+
export type {
|
|
67
|
+
ListBuilderStep,
|
|
68
|
+
RecordColumnConfig,
|
|
69
|
+
CredentialRequirement,
|
|
70
|
+
TemplateName,
|
|
71
|
+
StepName,
|
|
72
|
+
ActionRegistry
|
|
73
|
+
} from './domains/prospecting'
|
|
74
|
+
export { ProjectsDomainStateSchema } from './domains/projects'
|
|
75
|
+
export * from './domains/systems'
|
|
76
|
+
export * from './domains/resources'
|
|
77
|
+
export {
|
|
78
|
+
DEFAULT_ORGANIZATION_MODEL_NAVIGATION,
|
|
79
|
+
getSortedSidebarEntries,
|
|
80
|
+
NavigationGroupSchema,
|
|
81
|
+
OrganizationModelNavigationSchema,
|
|
82
|
+
SidebarNavigationSchema,
|
|
83
|
+
SidebarNodeSchema,
|
|
84
|
+
SidebarSectionSchema,
|
|
85
|
+
SidebarSurfaceTargetsSchema,
|
|
86
|
+
SurfaceDefinitionSchema,
|
|
87
|
+
SurfaceTypeSchema
|
|
88
|
+
} from './domains/navigation'
|
|
89
|
+
export {
|
|
90
|
+
EntitiesDomainSchema,
|
|
91
|
+
EntityIdSchema,
|
|
92
|
+
EntityLinkKindSchema,
|
|
93
|
+
EntityLinkSchema,
|
|
94
|
+
EntitySchema
|
|
95
|
+
} from './domains/entities'
|
|
96
|
+
export {
|
|
97
|
+
KnowledgeDomainSchema,
|
|
98
|
+
KnowledgeLinkSchema,
|
|
99
|
+
KnowledgeTargetKindSchema,
|
|
100
|
+
KnowledgeTargetRefSchema,
|
|
101
|
+
OrgKnowledgeKindSchema,
|
|
102
|
+
OrgKnowledgeNodeSchema
|
|
103
|
+
} from './domains/knowledge'
|
|
104
|
+
export * from './domains/roles'
|
|
105
|
+
export * from './domains/identity'
|
|
106
|
+
export * from './domains/policies'
|
|
107
|
+
export {
|
|
108
|
+
ActionsDomainSchema,
|
|
109
|
+
ActionIdSchema,
|
|
110
|
+
ActionInvocationKindSchema,
|
|
111
|
+
ActionInvocationSchema,
|
|
112
|
+
ActionRefSchema,
|
|
113
|
+
ActionSchema,
|
|
114
|
+
ActionScopeSchema,
|
|
115
|
+
ApiEndpointInvocationSchema,
|
|
116
|
+
DEFAULT_ORGANIZATION_MODEL_ACTIONS,
|
|
117
|
+
findOrganizationActionById,
|
|
118
|
+
LEAD_GEN_ACTION_ENTRIES,
|
|
119
|
+
McpToolInvocationSchema,
|
|
120
|
+
ScriptExecutionInvocationSchema,
|
|
121
|
+
SlashCommandInvocationSchema
|
|
122
|
+
} from './domains/actions'
|
|
123
|
+
export type {
|
|
124
|
+
ActionsDomain,
|
|
125
|
+
Action as OrganizationAction,
|
|
126
|
+
ActionId,
|
|
127
|
+
ActionInvocation,
|
|
128
|
+
ActionInvocationKind,
|
|
129
|
+
ActionRef,
|
|
130
|
+
ActionScope
|
|
131
|
+
} from './domains/actions'
|