@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.
Files changed (132) hide show
  1. package/dist/index.d.ts +2518 -2169
  2. package/dist/index.js +2495 -1095
  3. package/dist/knowledge/index.d.ts +706 -1044
  4. package/dist/knowledge/index.js +9 -9
  5. package/dist/organization-model/index.d.ts +2518 -2169
  6. package/dist/organization-model/index.js +2495 -1095
  7. package/dist/test-utils/index.d.ts +826 -1014
  8. package/dist/test-utils/index.js +1894 -1032
  9. package/package.json +3 -3
  10. package/src/__tests__/template-core-compatibility.test.ts +11 -79
  11. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +852 -397
  12. package/src/auth/multi-tenancy/permissions.ts +20 -8
  13. package/src/business/README.md +2 -2
  14. package/src/business/acquisition/api-schemas.test.ts +175 -2
  15. package/src/business/acquisition/api-schemas.ts +132 -16
  16. package/src/business/acquisition/build-templates.test.ts +4 -4
  17. package/src/business/acquisition/build-templates.ts +72 -30
  18. package/src/business/acquisition/crm-state-actions.test.ts +13 -11
  19. package/src/business/acquisition/index.ts +12 -0
  20. package/src/business/acquisition/types.ts +7 -3
  21. package/src/business/clients/api-schemas.test.ts +115 -0
  22. package/src/business/clients/api-schemas.ts +158 -0
  23. package/src/business/clients/index.ts +1 -0
  24. package/src/business/deals/api-schemas.ts +8 -0
  25. package/src/business/index.ts +5 -2
  26. package/src/business/projects/types.ts +19 -0
  27. package/src/execution/engine/__tests__/fixtures/test-agents.ts +10 -8
  28. package/src/execution/engine/agent/core/__tests__/agent.test.ts +16 -12
  29. package/src/execution/engine/agent/core/__tests__/error-passthrough.test.ts +4 -3
  30. package/src/execution/engine/agent/core/types.ts +25 -15
  31. package/src/execution/engine/agent/index.ts +6 -4
  32. package/src/execution/engine/agent/reasoning/__tests__/request-builder.test.ts +24 -18
  33. package/src/execution/engine/index.ts +3 -0
  34. package/src/execution/engine/workflow/types.ts +9 -2
  35. package/src/knowledge/README.md +8 -7
  36. package/src/knowledge/__tests__/queries.test.ts +74 -73
  37. package/src/knowledge/format.ts +10 -9
  38. package/src/knowledge/index.ts +1 -1
  39. package/src/knowledge/published.ts +1 -1
  40. package/src/knowledge/queries.ts +26 -25
  41. package/src/organization-model/README.md +73 -26
  42. package/src/organization-model/__tests__/content-kinds-registry.test.ts +210 -0
  43. package/src/organization-model/__tests__/defaults.test.ts +76 -96
  44. package/src/organization-model/__tests__/domains/actions.test.ts +56 -0
  45. package/src/organization-model/__tests__/domains/customers.test.ts +299 -295
  46. package/src/organization-model/__tests__/domains/entities.test.ts +56 -0
  47. package/src/organization-model/__tests__/domains/goals.test.ts +493 -479
  48. package/src/organization-model/__tests__/domains/identity.test.ts +280 -279
  49. package/src/organization-model/__tests__/domains/navigation.test.ts +268 -212
  50. package/src/organization-model/__tests__/domains/offerings.test.ts +414 -419
  51. package/src/organization-model/__tests__/domains/policies.test.ts +323 -0
  52. package/src/organization-model/__tests__/domains/resource-mappings.test.ts +271 -271
  53. package/src/organization-model/__tests__/domains/resources.test.ts +310 -0
  54. package/src/organization-model/__tests__/domains/roles.test.ts +463 -347
  55. package/src/organization-model/__tests__/domains/statuses.test.ts +246 -243
  56. package/src/organization-model/__tests__/domains/systems.test.ts +209 -0
  57. package/src/organization-model/__tests__/flatten-additive-merge.test.ts +361 -0
  58. package/src/organization-model/__tests__/foundation.test.ts +74 -102
  59. package/src/organization-model/__tests__/get-resources-for-system.test.ts +144 -0
  60. package/src/organization-model/__tests__/graph.test.ts +899 -71
  61. package/src/organization-model/__tests__/knowledge.test.ts +209 -49
  62. package/src/organization-model/__tests__/lookup-helpers.test.ts +438 -0
  63. package/src/organization-model/__tests__/migration-helpers.test.ts +591 -0
  64. package/src/organization-model/__tests__/prospecting-ssot.test.ts +36 -27
  65. package/src/organization-model/__tests__/recursive-system-schema.test.ts +520 -0
  66. package/src/organization-model/__tests__/resolve.test.ts +174 -23
  67. package/src/organization-model/__tests__/schema.test.ts +291 -114
  68. package/src/organization-model/__tests__/surface-projection.test.ts +207 -97
  69. package/src/organization-model/catalogs/lead-gen.ts +144 -0
  70. package/src/organization-model/content-kinds/config.ts +36 -0
  71. package/src/organization-model/content-kinds/index.ts +74 -0
  72. package/src/organization-model/content-kinds/pipeline.ts +68 -0
  73. package/src/organization-model/content-kinds/registry.ts +44 -0
  74. package/src/organization-model/content-kinds/status.ts +71 -0
  75. package/src/organization-model/content-kinds/template.ts +83 -0
  76. package/src/organization-model/content-kinds/types.ts +117 -0
  77. package/src/organization-model/contracts.ts +13 -3
  78. package/src/organization-model/defaults.ts +499 -86
  79. package/src/organization-model/domains/actions.ts +239 -0
  80. package/src/organization-model/domains/customers.ts +78 -75
  81. package/src/organization-model/domains/entities.ts +144 -0
  82. package/src/organization-model/domains/goals.ts +83 -80
  83. package/src/organization-model/domains/knowledge.ts +76 -17
  84. package/src/organization-model/domains/navigation.ts +107 -384
  85. package/src/organization-model/domains/offerings.ts +71 -66
  86. package/src/organization-model/domains/policies.ts +102 -0
  87. package/src/organization-model/domains/projects.ts +14 -48
  88. package/src/organization-model/domains/prospecting.ts +62 -181
  89. package/src/organization-model/domains/resources.ts +145 -0
  90. package/src/organization-model/domains/roles.ts +96 -55
  91. package/src/organization-model/domains/sales.ts +10 -219
  92. package/src/organization-model/domains/shared.ts +57 -57
  93. package/src/organization-model/domains/statuses.ts +339 -130
  94. package/src/organization-model/domains/systems.ts +203 -0
  95. package/src/organization-model/foundation.ts +54 -67
  96. package/src/organization-model/graph/build.ts +682 -54
  97. package/src/organization-model/graph/link.ts +1 -1
  98. package/src/organization-model/graph/schema.ts +24 -9
  99. package/src/organization-model/graph/types.ts +20 -7
  100. package/src/organization-model/helpers.ts +231 -26
  101. package/src/organization-model/icons.ts +1 -0
  102. package/src/organization-model/index.ts +118 -5
  103. package/src/organization-model/migration-helpers.ts +249 -0
  104. package/src/organization-model/organization-graph.mdx +16 -15
  105. package/src/organization-model/organization-model.mdx +111 -44
  106. package/src/organization-model/published.ts +172 -19
  107. package/src/organization-model/resolve.ts +117 -54
  108. package/src/organization-model/schema.ts +654 -112
  109. package/src/organization-model/surface-projection.ts +116 -122
  110. package/src/organization-model/types.ts +146 -20
  111. package/src/platform/api/types.ts +38 -35
  112. package/src/platform/constants/versions.ts +1 -1
  113. package/src/platform/registry/__tests__/command-view.test.ts +6 -8
  114. package/src/platform/registry/__tests__/resource-link.test.ts +13 -8
  115. package/src/platform/registry/__tests__/resource-registry.integration.test.ts +16 -31
  116. package/src/platform/registry/__tests__/resource-registry.nested-systems.test.ts +245 -0
  117. package/src/platform/registry/__tests__/resource-registry.test.ts +2053 -2005
  118. package/src/platform/registry/__tests__/validation.test.ts +1347 -1086
  119. package/src/platform/registry/index.ts +14 -0
  120. package/src/platform/registry/resource-registry.ts +52 -2
  121. package/src/platform/registry/serialization.ts +241 -202
  122. package/src/platform/registry/serialized-types.ts +1 -0
  123. package/src/platform/registry/types.ts +411 -361
  124. package/src/platform/registry/validation.ts +745 -513
  125. package/src/projects/api-schemas.ts +290 -267
  126. package/src/reference/_generated/contracts.md +853 -397
  127. package/src/reference/glossary.md +23 -18
  128. package/src/supabase/database.types.ts +181 -0
  129. package/src/test-utils/test-utils.test.ts +1 -6
  130. package/src/organization-model/__tests__/domains/operations.test.ts +0 -203
  131. package/src/organization-model/domains/features.ts +0 -31
  132. package/src/organization-model/domains/operations.ts +0 -85
@@ -1,23 +1,30 @@
1
- import type { OrganizationModel, OrganizationModelFeature, OrganizationModelSurface } from './types'
1
+ import type {
2
+ OrganizationModel,
3
+ OrganizationModelSurface,
4
+ OrganizationModelSidebarNode,
5
+ OrganizationModelSidebarSurfaceNode,
6
+ OrganizationModelSystemEntry
7
+ } from './types'
8
+ import { listAllSystems } from './helpers'
9
+ import { getSortedSidebarEntries } from './domains/navigation'
2
10
 
3
11
  export type OrganizationSurfaceProjectionIssueCode =
4
12
  | 'duplicate-surface-id'
5
13
  | 'duplicate-surface-path'
6
- | 'unknown-default-surface'
7
- | 'unknown-group-surface'
8
- | 'unknown-surface-feature'
9
- | 'unknown-surface-feature-reference'
14
+ | 'unknown-surface-system'
10
15
 
11
16
  export interface OrganizationSurfaceProjection {
12
17
  id: string
13
18
  label: string
14
19
  path: string
15
20
  surfaceType: OrganizationModelSurface['surfaceType']
16
- featureId?: string
17
- featureIds: string[]
21
+ description?: string
22
+ icon?: string
23
+ order?: number
24
+ systemIds: string[]
18
25
  entityIds: string[]
19
26
  resourceIds: string[]
20
- capabilityIds: string[]
27
+ actionIds: string[]
21
28
  enabled: boolean
22
29
  devOnly?: boolean
23
30
  requiresAdmin?: boolean
@@ -28,104 +35,129 @@ export interface OrganizationSurfaceProjectionIssue {
28
35
  message: string
29
36
  path: Array<string | number>
30
37
  surfaceId?: string
31
- featureId?: string
32
- groupId?: string
38
+ systemId?: string
33
39
  value?: string
34
40
  }
35
41
 
36
- const LEGACY_FEATURE_ALIASES = new Map<string, string>([
37
- ['crm', 'sales.crm'],
38
- ['lead-gen', 'sales.lead-gen'],
39
- ['submitted-requests', 'monitoring.submitted-requests']
40
- ])
42
+ interface SidebarSurfaceWithId {
43
+ id: string
44
+ surface: OrganizationModelSidebarSurfaceNode
45
+ path: Array<string | number>
46
+ }
41
47
 
42
48
  function normalizePath(path: string): string {
43
49
  return path.length > 1 ? path.replace(/\/+$/, '') : path
44
50
  }
45
51
 
46
- function collectFeaturesById(model: OrganizationModel): Map<string, OrganizationModelFeature> {
47
- return new Map(model.features.map((feature) => [feature.id, feature]))
48
- }
49
-
50
- function resolveFeatureId(featuresById: Map<string, OrganizationModelFeature>, featureId: string): string | undefined {
51
- if (featuresById.has(featureId)) {
52
- return featureId
52
+ function collectSystemsById(model: OrganizationModel): Map<string, OrganizationModelSystemEntry> {
53
+ const systemsById = new Map<string, OrganizationModelSystemEntry>()
54
+ for (const { path, system } of listAllSystems(model)) {
55
+ systemsById.set(path, system)
56
+ systemsById.set(system.id, system)
53
57
  }
54
-
55
- const aliasTarget = LEGACY_FEATURE_ALIASES.get(featureId)
56
- return aliasTarget !== undefined && featuresById.has(aliasTarget) ? aliasTarget : undefined
58
+ return systemsById
57
59
  }
58
60
 
59
- function getFeatureWithAncestors(
60
- featuresById: Map<string, OrganizationModelFeature>,
61
- featureId: string
62
- ): OrganizationModelFeature[] {
63
- const features: OrganizationModelFeature[] = []
64
- const segments = featureId.split('.')
65
-
66
- for (let index = 1; index <= segments.length; index += 1) {
67
- const candidate = featuresById.get(segments.slice(0, index).join('.'))
68
- if (candidate) {
69
- features.push(candidate)
70
- }
61
+ function getSystemWithAncestors(
62
+ systemsById: Map<string, OrganizationModelSystemEntry>,
63
+ systemId: string
64
+ ): OrganizationModelSystemEntry[] {
65
+ const systems: OrganizationModelSystemEntry[] = []
66
+ let current = systemsById.get(systemId)
67
+ while (current !== undefined) {
68
+ systems.unshift(current)
69
+ current = current.parentSystemId ? systemsById.get(current.parentSystemId) : undefined
71
70
  }
72
-
73
- return features
71
+ return systems
74
72
  }
75
73
 
76
74
  function hasInheritedFlag(
77
- featuresById: Map<string, OrganizationModelFeature>,
78
- featureIds: string[],
75
+ systemsById: Map<string, OrganizationModelSystemEntry>,
76
+ systemIds: string[],
79
77
  flag: 'devOnly' | 'requiresAdmin'
80
78
  ): boolean {
81
- return featureIds.some((featureId) =>
82
- getFeatureWithAncestors(featuresById, featureId).some((feature) => feature[flag] === true)
79
+ return systemIds.some((systemId) =>
80
+ getSystemWithAncestors(systemsById, systemId).some((system) => system[flag] === true)
83
81
  )
84
82
  }
85
83
 
86
- function isFeatureEnabled(featuresById: Map<string, OrganizationModelFeature>, featureId: string): boolean {
87
- const featureLineage = getFeatureWithAncestors(featuresById, featureId)
88
- return featureLineage.length > 0 && featureLineage.every((feature) => feature.enabled)
84
+ function isLifecycleEnabled(system: OrganizationModelSystemEntry): boolean {
85
+ if (system.enabled === false) return false
86
+ return system.lifecycle !== 'deprecated' && system.lifecycle !== 'archived'
87
+ }
88
+
89
+ function isLifecycleDevOnly(system: OrganizationModelSystemEntry): boolean {
90
+ return system.devOnly === true || system.lifecycle === 'beta'
91
+ }
92
+
93
+ function isSystemEnabled(systemsById: Map<string, OrganizationModelSystemEntry>, systemId: string): boolean {
94
+ const systemLineage = getSystemWithAncestors(systemsById, systemId)
95
+ return systemLineage.length > 0 && systemLineage.every(isLifecycleEnabled)
89
96
  }
90
97
 
91
98
  function unique(values: string[]): string[] {
92
99
  return [...new Set(values)]
93
100
  }
94
101
 
102
+ function collectSidebarSurfaces(
103
+ nodes: Record<string, OrganizationModelSidebarNode>,
104
+ schemaPath: Array<string | number>,
105
+ surfaces: SidebarSurfaceWithId[] = []
106
+ ): SidebarSurfaceWithId[] {
107
+ getSortedSidebarEntries(nodes).forEach(([id, node]) => {
108
+ const nodePath = [...schemaPath, id]
109
+ if (node.type === 'group') {
110
+ collectSidebarSurfaces(node.children, [...nodePath, 'children'], surfaces)
111
+ return
112
+ }
113
+ surfaces.push({ id, surface: node, path: nodePath })
114
+ })
115
+
116
+ return surfaces
117
+ }
118
+
119
+ function getSidebarSurfaces(model: OrganizationModel): SidebarSurfaceWithId[] {
120
+ return [
121
+ ...collectSidebarSurfaces(model.navigation.sidebar.primary, ['navigation', 'sidebar', 'primary']),
122
+ ...collectSidebarSurfaces(model.navigation.sidebar.bottom, ['navigation', 'sidebar', 'bottom'])
123
+ ]
124
+ }
125
+
95
126
  export function projectOrganizationSurfaces(model: OrganizationModel): OrganizationSurfaceProjection[] {
96
- const featuresById = collectFeaturesById(model)
97
-
98
- return model.navigation.surfaces.map((surface) => {
99
- const featureId = surface.featureId ? resolveFeatureId(featuresById, surface.featureId) : undefined
100
- const featureIds = unique(
101
- [featureId, ...surface.featureIds.map((candidate) => resolveFeatureId(featuresById, candidate))].filter(
102
- (candidate): candidate is string => candidate !== undefined
103
- )
104
- )
105
- const enabled = surface.enabled && featureIds.every((candidate) => isFeatureEnabled(featuresById, candidate))
106
- const devOnly = surface.devOnly === true || hasInheritedFlag(featuresById, featureIds, 'devOnly')
107
- const requiresAdmin = hasInheritedFlag(featuresById, featureId ? [featureId] : featureIds, 'requiresAdmin')
127
+ const systemsById = collectSystemsById(model)
128
+
129
+ return getSidebarSurfaces(model).map(({ id, surface }) => {
130
+ const targets = surface.targets ?? {}
131
+ const systemIds = unique((targets.systems ?? []).filter((systemId: string) => systemsById.has(systemId)))
132
+ const enabled = systemIds.every((candidate) => isSystemEnabled(systemsById, candidate))
133
+ const devOnly =
134
+ surface.devOnly === true ||
135
+ hasInheritedFlag(systemsById, systemIds, 'devOnly') ||
136
+ systemIds.some((candidate) => getSystemWithAncestors(systemsById, candidate).some(isLifecycleDevOnly))
137
+ const requiresAdmin = hasInheritedFlag(systemsById, systemIds, 'requiresAdmin')
108
138
 
109
139
  return {
110
- id: surface.id,
140
+ id,
111
141
  label: surface.label,
112
142
  path: surface.path,
113
143
  surfaceType: surface.surfaceType,
114
- featureId,
115
- featureIds,
116
- entityIds: [...surface.entityIds],
117
- resourceIds: [...surface.resourceIds],
118
- capabilityIds: [...surface.capabilityIds],
144
+ ...(surface.description !== undefined ? { description: surface.description } : {}),
145
+ ...(surface.icon !== undefined ? { icon: surface.icon } : {}),
146
+ ...(surface.order !== undefined ? { order: surface.order } : {}),
147
+ systemIds,
148
+ entityIds: [...(targets.entities ?? [])],
149
+ resourceIds: [...(targets.resources ?? [])],
150
+ actionIds: [...(targets.actions ?? [])],
119
151
  enabled,
120
152
  ...(devOnly ? { devOnly } : {}),
121
- ...(requiresAdmin ? { requiresAdmin } : {})
153
+ ...(surface.requiresAdmin === true || requiresAdmin ? { requiresAdmin: true } : {})
122
154
  }
123
155
  })
124
156
  }
125
157
 
126
158
  export function validateOrganizationSurfaceProjection(model: OrganizationModel): OrganizationSurfaceProjectionIssue[] {
127
159
  const issues: OrganizationSurfaceProjectionIssue[] = []
128
- const featuresById = collectFeaturesById(model)
160
+ const systemsById = collectSystemsById(model)
129
161
  const surfaceIds = new Set<string>()
130
162
  const surfacePaths = new Map<string, string>()
131
163
 
@@ -133,17 +165,17 @@ export function validateOrganizationSurfaceProjection(model: OrganizationModel):
133
165
  issues.push(issue)
134
166
  }
135
167
 
136
- model.navigation.surfaces.forEach((surface, surfaceIndex) => {
137
- if (surfaceIds.has(surface.id)) {
168
+ getSidebarSurfaces(model).forEach(({ id, surface, path }) => {
169
+ if (surfaceIds.has(id)) {
138
170
  addIssue({
139
171
  code: 'duplicate-surface-id',
140
- message: `Surface id "${surface.id}" must be unique`,
141
- path: ['navigation', 'surfaces', surfaceIndex, 'id'],
142
- surfaceId: surface.id,
143
- value: surface.id
172
+ message: `Surface id "${id}" must be unique`,
173
+ path,
174
+ surfaceId: id,
175
+ value: id
144
176
  })
145
177
  } else {
146
- surfaceIds.add(surface.id)
178
+ surfaceIds.add(id)
147
179
  }
148
180
 
149
181
  const normalizedPath = normalizePath(surface.path)
@@ -152,64 +184,26 @@ export function validateOrganizationSurfaceProjection(model: OrganizationModel):
152
184
  addIssue({
153
185
  code: 'duplicate-surface-path',
154
186
  message: `Surface path "${surface.path}" is already used by surface "${existingSurfaceId}"`,
155
- path: ['navigation', 'surfaces', surfaceIndex, 'path'],
156
- surfaceId: surface.id,
187
+ path: [...path, 'path'],
188
+ surfaceId: id,
157
189
  value: surface.path
158
190
  })
159
191
  } else {
160
- surfacePaths.set(normalizedPath, surface.id)
192
+ surfacePaths.set(normalizedPath, id)
161
193
  }
162
194
 
163
- if (surface.featureId !== undefined && resolveFeatureId(featuresById, surface.featureId) === undefined) {
164
- addIssue({
165
- code: 'unknown-surface-feature',
166
- message: `Surface "${surface.id}" references unknown feature "${surface.featureId}"`,
167
- path: ['navigation', 'surfaces', surfaceIndex, 'featureId'],
168
- surfaceId: surface.id,
169
- featureId: surface.featureId,
170
- value: surface.featureId
171
- })
172
- }
173
-
174
- surface.featureIds.forEach((featureId, featureIndex) => {
175
- if (resolveFeatureId(featuresById, featureId) !== undefined) {
176
- return
177
- }
178
-
179
- addIssue({
180
- code: 'unknown-surface-feature-reference',
181
- message: `Surface "${surface.id}" references unknown feature "${featureId}"`,
182
- path: ['navigation', 'surfaces', surfaceIndex, 'featureIds', featureIndex],
183
- surfaceId: surface.id,
184
- featureId,
185
- value: featureId
186
- })
187
- })
188
- })
189
-
190
- if (model.navigation.defaultSurfaceId !== undefined && !surfaceIds.has(model.navigation.defaultSurfaceId)) {
191
- addIssue({
192
- code: 'unknown-default-surface',
193
- message: `Default surface "${model.navigation.defaultSurfaceId}" is not declared in navigation.surfaces`,
194
- path: ['navigation', 'defaultSurfaceId'],
195
- surfaceId: model.navigation.defaultSurfaceId,
196
- value: model.navigation.defaultSurfaceId
197
- })
198
- }
199
-
200
- model.navigation.groups.forEach((group, groupIndex) => {
201
- group.surfaceIds.forEach((surfaceId, surfaceIndex) => {
202
- if (surfaceIds.has(surfaceId)) {
195
+ surface.targets?.systems?.forEach((systemId: string, systemIndex: number) => {
196
+ if (systemsById.has(systemId)) {
203
197
  return
204
198
  }
205
199
 
206
200
  addIssue({
207
- code: 'unknown-group-surface',
208
- message: `Navigation group "${group.id}" references unknown surface "${surfaceId}"`,
209
- path: ['navigation', 'groups', groupIndex, 'surfaceIds', surfaceIndex],
210
- surfaceId,
211
- groupId: group.id,
212
- value: surfaceId
201
+ code: 'unknown-surface-system',
202
+ message: `Surface "${id}" references unknown system "${systemId}"`,
203
+ path: [...path, 'targets', 'systems', systemIndex],
204
+ surfaceId: id,
205
+ systemId,
206
+ value: systemId
213
207
  })
214
208
  })
215
209
  })
@@ -1,44 +1,121 @@
1
1
  import type { z } from 'zod'
2
2
  import { OrganizationModelBrandingSchema } from './domains/branding'
3
- import { OrganizationModelSalesSchema } from './domains/sales'
4
- import { OrganizationModelProjectsSchema } from './domains/projects'
5
- import { FeatureSchema, NodeIdPathSchema, NodeIdStringSchema } from './domains/features'
6
- import { OrganizationModelProspectingSchema } from './domains/prospecting'
7
- import { OrganizationModelNavigationSchema, SurfaceDefinitionSchema } from './domains/navigation'
3
+ import { SalesPipelineSchema, SalesStageSchema } from './domains/sales'
4
+ import { ProjectsDomainStateSchema } from './domains/projects'
5
+ import { NodeIdPathSchema, NodeIdStringSchema } from './domains/systems'
6
+ import { ProspectingBuildTemplateSchema, ProspectingLifecycleStageSchema } from './domains/prospecting'
7
+ import {
8
+ NavigationGroupSchema,
9
+ OrganizationModelNavigationSchema,
10
+ SidebarNavigationSchema,
11
+ SidebarNodeSchema,
12
+ SidebarSectionSchema,
13
+ SidebarSurfaceTargetsSchema,
14
+ SurfaceDefinitionSchema
15
+ } from './domains/navigation'
8
16
  import { TechStackEntrySchema } from './domains/shared'
9
- import { OperationsDomainSchema, OperationEntrySchema, OperationSemanticClassSchema } from './domains/operations'
10
17
  import { StatusesDomainSchema, StatusEntrySchema, StatusSemanticClassSchema } from './domains/statuses'
11
18
  import { CustomersDomainSchema, CustomerSegmentSchema, FirmographicsSchema } from './domains/customers'
12
19
  import { OfferingsDomainSchema, ProductSchema, PricingModelSchema } from './domains/offerings'
13
- import { RolesDomainSchema, RoleSchema } from './domains/roles'
20
+ import {
21
+ AgentRoleHolderSchema,
22
+ HumanRoleHolderSchema,
23
+ RoleHolderSchema,
24
+ RoleIdSchema,
25
+ RolesDomainSchema,
26
+ RoleSchema,
27
+ TeamRoleHolderSchema
28
+ } from './domains/roles'
14
29
  import { GoalsDomainSchema, ObjectiveSchema, KeyResultSchema } from './domains/goals'
15
30
  import {
16
- KnowledgeDomainBindingSchema,
17
31
  KnowledgeDomainSchema,
18
- KnowledgeSkillBindingSchema,
32
+ KnowledgeLinkSchema,
33
+ KnowledgeTargetKindSchema,
34
+ KnowledgeTargetRefSchema,
19
35
  OrgKnowledgeKindSchema,
20
36
  OrgKnowledgeNodeSchema
21
37
  } from './domains/knowledge'
38
+ import {
39
+ SystemEntrySchema,
40
+ SystemIdSchema,
41
+ SystemKindSchema,
42
+ SystemLifecycleSchema,
43
+ SystemPathSchema,
44
+ SystemStatusSchema,
45
+ SystemsDomainSchema
46
+ } from './domains/systems'
47
+ import {
48
+ AgentKindSchema,
49
+ AgentResourceEntrySchema,
50
+ EventDescriptorSchema,
51
+ EventEmissionDescriptorSchema,
52
+ EventIdSchema,
53
+ IntegrationResourceEntrySchema,
54
+ ResourceEntrySchema,
55
+ ResourceGovernanceStatusSchema,
56
+ ResourceIdSchema,
57
+ ResourceKindSchema,
58
+ ResourcesDomainSchema,
59
+ ScriptResourceEntrySchema,
60
+ ScriptResourceLanguageSchema,
61
+ ScriptResourceSourceSchema,
62
+ WorkflowResourceEntrySchema
63
+ } from './domains/resources'
64
+ import {
65
+ ActionsDomainSchema,
66
+ ActionIdSchema,
67
+ ActionInvocationKindSchema,
68
+ ActionInvocationSchema,
69
+ ActionRefSchema,
70
+ ActionSchema,
71
+ ActionScopeSchema
72
+ } from './domains/actions'
73
+ import { EntitiesDomainSchema, EntityIdSchema, EntityLinkSchema, EntitySchema } from './domains/entities'
74
+ import {
75
+ PoliciesDomainSchema,
76
+ PolicyEffectSchema,
77
+ PolicyApplicabilitySchema,
78
+ PolicyIdSchema,
79
+ PolicyPredicateSchema,
80
+ PolicySchema,
81
+ PolicyTriggerSchema
82
+ } from './domains/policies'
22
83
  import { OrganizationModelIconTokenSchema, OrganizationModelBuiltinIconTokenSchema } from './icons'
23
- import { OrganizationModelSchema } from './schema'
84
+ import {
85
+ OrganizationModelDomainKeySchema,
86
+ OrganizationModelDomainMetadataByDomainSchema,
87
+ OrganizationModelDomainMetadataSchema,
88
+ OrganizationModelSchema
89
+ } from './schema'
24
90
 
25
91
  export type OrganizationModel = z.infer<typeof OrganizationModelSchema>
92
+ export type OrganizationModelDomainKey = z.infer<typeof OrganizationModelDomainKeySchema>
93
+ export type OrganizationModelDomainMetadata = z.infer<typeof OrganizationModelDomainMetadataSchema>
94
+ export type OrganizationModelDomainMetadataByDomain = z.infer<typeof OrganizationModelDomainMetadataByDomainSchema>
26
95
  export type OrganizationModelBranding = z.infer<typeof OrganizationModelBrandingSchema>
27
- export type OrganizationModelSales = z.infer<typeof OrganizationModelSalesSchema>
28
- export type OrganizationModelProspecting = z.infer<typeof OrganizationModelProspectingSchema>
29
- export type OrganizationModelProjects = z.infer<typeof OrganizationModelProjectsSchema>
30
- export type OrganizationModelFeature = z.infer<typeof FeatureSchema>
96
+ // Phase 4: OrganizationModelSales, OrganizationModelProspecting, OrganizationModelProjects,
97
+ // OrganizationModelNavigation removed compound domain top-level fields deleted per D8/D1.
98
+ // Retained as local aliases for content-kind payload shapes used in migration-helpers:
99
+ export type SalesPipeline = z.infer<typeof SalesPipelineSchema>
100
+ export type SalesStage = z.infer<typeof SalesStageSchema>
101
+ export type ProspectingBuildTemplate = z.infer<typeof ProspectingBuildTemplateSchema>
102
+ export type ProspectingLifecycleStage = z.infer<typeof ProspectingLifecycleStageSchema>
103
+ export type ProjectsDomainState = z.infer<typeof ProjectsDomainStateSchema>
31
104
  export type NodeIdPath = z.infer<typeof NodeIdPathSchema>
32
105
  export type NodeIdString = z.infer<typeof NodeIdStringSchema>
33
- export type OrganizationModelNavigation = z.infer<typeof OrganizationModelNavigationSchema>
34
106
  export type OrganizationModelSurface = z.infer<typeof SurfaceDefinitionSchema>
107
+ export type OrganizationModelNavigationGroup = z.infer<typeof NavigationGroupSchema>
108
+ export type OrganizationModelNavigation = z.infer<typeof OrganizationModelNavigationSchema>
109
+ export type OrganizationModelSidebar = z.infer<typeof SidebarNavigationSchema>
110
+ export type OrganizationModelSidebarSection = z.infer<typeof SidebarSectionSchema>
111
+ export type OrganizationModelSidebarNode = z.infer<typeof SidebarNodeSchema>
112
+ export type OrganizationModelSidebarSurfaceTargets = z.infer<typeof SidebarSurfaceTargetsSchema>
113
+ export type OrganizationModelSidebarSurfaceNode = Extract<OrganizationModelSidebarNode, { type: 'surface' }>
114
+ export type OrganizationModelSidebarGroupNode = Extract<OrganizationModelSidebarNode, { type: 'group' }>
35
115
  export type OrganizationModelTechStackEntry = z.infer<typeof TechStackEntrySchema>
36
116
  export type OrganizationModelStatuses = z.infer<typeof StatusesDomainSchema>
37
117
  export type OrganizationModelStatusEntry = z.infer<typeof StatusEntrySchema>
38
118
  export type OrganizationModelStatusSemanticClass = z.infer<typeof StatusSemanticClassSchema>
39
- export type OrganizationModelOperations = z.infer<typeof OperationsDomainSchema>
40
- export type OrganizationModelOperationEntry = z.infer<typeof OperationEntrySchema>
41
- export type OrganizationModelOperationSemanticClass = z.infer<typeof OperationSemanticClassSchema>
42
119
  export type OrganizationModelCustomers = z.infer<typeof CustomersDomainSchema>
43
120
  export type OrganizationModelCustomerSegment = z.infer<typeof CustomerSegmentSchema>
44
121
  export type OrganizationModelCustomerFirmographics = z.infer<typeof FirmographicsSchema>
@@ -47,14 +124,63 @@ export type OrganizationModelProduct = z.infer<typeof ProductSchema>
47
124
  export type OrganizationModelPricingModel = z.infer<typeof PricingModelSchema>
48
125
  export type OrganizationModelRoles = z.infer<typeof RolesDomainSchema>
49
126
  export type OrganizationModelRole = z.infer<typeof RoleSchema>
127
+ export type OrganizationModelRoleId = z.infer<typeof RoleIdSchema>
128
+ export type OrganizationModelRoleHolder = z.infer<typeof RoleHolderSchema>
129
+ export type OrganizationModelHumanRoleHolder = z.infer<typeof HumanRoleHolderSchema>
130
+ export type OrganizationModelAgentRoleHolder = z.infer<typeof AgentRoleHolderSchema>
131
+ export type OrganizationModelTeamRoleHolder = z.infer<typeof TeamRoleHolderSchema>
50
132
  export type OrganizationModelGoals = z.infer<typeof GoalsDomainSchema>
51
133
  export type OrganizationModelObjective = z.infer<typeof ObjectiveSchema>
52
134
  export type OrganizationModelKeyResult = z.infer<typeof KeyResultSchema>
135
+ export type OrganizationModelSystems = z.infer<typeof SystemsDomainSchema>
136
+ export type OrganizationModelSystemEntry = z.infer<typeof SystemEntrySchema>
137
+ export type OrganizationModelSystemId = z.infer<typeof SystemIdSchema>
138
+ export type OrganizationModelSystemPath = z.infer<typeof SystemPathSchema>
139
+ export type OrganizationModelSystemKind = z.infer<typeof SystemKindSchema>
140
+ export type OrganizationModelSystemLifecycle = z.infer<typeof SystemLifecycleSchema>
141
+ /** @deprecated Use OrganizationModelSystemLifecycle. Accepted for one publish cycle. */
142
+ export type OrganizationModelSystemStatus = z.infer<typeof SystemStatusSchema>
143
+ export type OrganizationModelResources = z.infer<typeof ResourcesDomainSchema>
144
+ export type OrganizationModelResourceEntry = z.infer<typeof ResourceEntrySchema>
145
+ export type OrganizationModelResourceId = z.infer<typeof ResourceIdSchema>
146
+ export type EventId = z.infer<typeof EventIdSchema>
147
+ export type EventEmissionDescriptor = z.infer<typeof EventEmissionDescriptorSchema>
148
+ export type EventDescriptor = z.infer<typeof EventDescriptorSchema>
149
+ export type OrganizationModelResourceKind = z.infer<typeof ResourceKindSchema>
150
+ export type OrganizationModelResourceGovernanceStatus = z.infer<typeof ResourceGovernanceStatusSchema>
151
+ export type OrganizationModelAgentKind = z.infer<typeof AgentKindSchema>
152
+ export type OrganizationModelScriptResourceLanguage = z.infer<typeof ScriptResourceLanguageSchema>
153
+ export type OrganizationModelScriptResourceSource = z.infer<typeof ScriptResourceSourceSchema>
154
+ export type OrganizationModelWorkflowResourceEntry = z.infer<typeof WorkflowResourceEntrySchema>
155
+ export type OrganizationModelAgentResourceEntry = z.infer<typeof AgentResourceEntrySchema>
156
+ export type OrganizationModelIntegrationResourceEntry = z.infer<typeof IntegrationResourceEntrySchema>
157
+ export type OrganizationModelScriptResourceEntry = z.infer<typeof ScriptResourceEntrySchema>
158
+ export type OrganizationModelActions = z.infer<typeof ActionsDomainSchema>
159
+ export type OrganizationModelAction = z.infer<typeof ActionSchema>
160
+ export type OrganizationModelActionId = z.infer<typeof ActionIdSchema>
161
+ export type OrganizationModelActionScope = z.infer<typeof ActionScopeSchema>
162
+ export type OrganizationModelActionRef = z.infer<typeof ActionRefSchema>
163
+ export type OrganizationModelActionInvocationKind = z.infer<typeof ActionInvocationKindSchema>
164
+ export type OrganizationModelActionInvocation = z.infer<typeof ActionInvocationSchema>
165
+ export type EntityId = z.infer<typeof EntityIdSchema>
166
+ export type EntityLink = z.infer<typeof EntityLinkSchema>
167
+ export type Entity = z.infer<typeof EntitySchema>
168
+ export type OrganizationModelEntity = z.infer<typeof EntitySchema>
169
+ export type OrganizationModelEntities = z.infer<typeof EntitiesDomainSchema>
170
+ export type OrganizationModelPolicies = z.infer<typeof PoliciesDomainSchema>
171
+ export type OrganizationModelPolicy = z.infer<typeof PolicySchema>
172
+ export type OrganizationModelPolicyId = z.infer<typeof PolicyIdSchema>
173
+ export type OrganizationModelPolicyApplicability = z.infer<typeof PolicyApplicabilitySchema>
174
+ export type OrganizationModelPolicyTrigger = z.infer<typeof PolicyTriggerSchema>
175
+ export type OrganizationModelPolicyPredicate = z.infer<typeof PolicyPredicateSchema>
176
+ export type OrganizationModelPolicyEffect = z.infer<typeof PolicyEffectSchema>
53
177
  export type OrganizationModelKnowledge = z.infer<typeof KnowledgeDomainSchema>
54
178
  export type OrgKnowledgeNode = z.infer<typeof OrgKnowledgeNodeSchema>
179
+ export type OrgKnowledgeNodeInput = z.input<typeof OrgKnowledgeNodeSchema>
55
180
  export type OrgKnowledgeKind = z.infer<typeof OrgKnowledgeKindSchema>
56
- export type KnowledgeSkillBinding = z.infer<typeof KnowledgeSkillBindingSchema>
57
- export type KnowledgeDomainBinding = z.infer<typeof KnowledgeDomainBindingSchema>
181
+ export type KnowledgeTargetKind = z.infer<typeof KnowledgeTargetKindSchema>
182
+ export type KnowledgeTargetRef = z.infer<typeof KnowledgeTargetRefSchema>
183
+ export type KnowledgeLink = z.infer<typeof KnowledgeLinkSchema>
58
184
  export type OrganizationModelIconToken = z.infer<typeof OrganizationModelIconTokenSchema>
59
185
  export type OrganizationModelBuiltinIconToken = z.infer<typeof OrganizationModelBuiltinIconTokenSchema>
60
186
 
@@ -1,35 +1,38 @@
1
- /**
2
- * Standard API error response format
3
- * Returned by APIError.toJSON() in apps/api
4
- * Consumed by Command Center UI for type-safe error handling
5
- */
6
- export interface APIErrorResponse {
7
- /** Human-readable error message */
8
- error: string
9
-
10
- /** Machine-readable error code */
11
- code: APIErrorCode
12
-
13
- /** Request ID for debugging (optional) */
14
- requestId?: string
15
-
16
- /** Field-level validation errors (only present for VALIDATION_ERROR code) */
17
- fields?: Record<string, string[]>
18
-
19
- /** Seconds until the rate limit resets (only present for RATE_LIMIT_EXCEEDED code) */
20
- retryAfter?: number
21
- }
22
-
23
- /**
24
- * Type-safe error codes
25
- * MUST match API_ERROR_CODES in apps/api/src/errors/error-codes.ts
26
- */
27
- export type APIErrorCode =
28
- | 'VALIDATION_ERROR'
29
- | 'AUTHENTICATION_FAILED'
30
- | 'FORBIDDEN'
31
- | 'NOT_FOUND'
32
- | 'CONFLICT'
33
- | 'RATE_LIMIT_EXCEEDED'
34
- | 'INTERNAL_SERVER_ERROR'
35
- | 'SERVICE_UNAVAILABLE'
1
+ /**
2
+ * Standard API error response format
3
+ * Returned by APIError.toJSON() in apps/api
4
+ * Consumed by Command Center UI for type-safe error handling
5
+ */
6
+ export interface APIErrorResponse {
7
+ /** Human-readable error message */
8
+ error: string
9
+
10
+ /** Machine-readable error code */
11
+ code: APIErrorCode
12
+
13
+ /** Request ID for debugging (optional) */
14
+ requestId?: string
15
+
16
+ /** Field-level validation errors (only present for VALIDATION_ERROR code) */
17
+ fields?: Record<string, string[]>
18
+
19
+ /** Seconds until the rate limit resets (only present for RATE_LIMIT_EXCEEDED code) */
20
+ retryAfter?: number
21
+
22
+ /** Structured detail payload (e.g. linked-row counts on CONFLICT errors) */
23
+ details?: Record<string, unknown>
24
+ }
25
+
26
+ /**
27
+ * Type-safe error codes
28
+ * MUST match API_ERROR_CODES in apps/api/src/errors/error-codes.ts
29
+ */
30
+ export type APIErrorCode =
31
+ | 'VALIDATION_ERROR'
32
+ | 'AUTHENTICATION_FAILED'
33
+ | 'FORBIDDEN'
34
+ | 'NOT_FOUND'
35
+ | 'CONFLICT'
36
+ | 'RATE_LIMIT_EXCEEDED'
37
+ | 'INTERNAL_SERVER_ERROR'
38
+ | 'SERVICE_UNAVAILABLE'
@@ -1,3 +1,3 @@
1
1
  export const VERSION = {
2
- CURRENT: '1.8.7'
2
+ CURRENT: '1.8.8'
3
3
  }
@@ -36,13 +36,12 @@ const mockAgent: CommandViewAgent = {
36
36
  type: 'agent',
37
37
  status: 'dev',
38
38
  modelProvider: 'anthropic',
39
- modelId: 'claude-sonnet-4-20250514',
39
+ modelId: 'claude-sonnet-4-20250514',
40
40
  toolCount: 5,
41
41
  hasKnowledgeMap: true,
42
42
  hasMemory: false,
43
- links: [{ nodeId: 'feature:sales.crm', kind: 'operates-on' }],
44
43
  category: 'production'
45
- }
44
+ }
46
45
 
47
46
  const mockWorkflow: CommandViewWorkflow = {
48
47
  resourceId: 'test-workflow-456',
@@ -50,11 +49,10 @@ const mockWorkflow: CommandViewWorkflow = {
50
49
  description: 'A test workflow for unit testing',
51
50
  version: '2.1.0',
52
51
  type: 'workflow',
53
- status: 'prod',
54
- stepCount: 3,
55
- entryPoint: 'start',
56
- links: [{ nodeId: 'feature:monitoring.submitted-requests', kind: 'operates-on' }]
57
- }
52
+ status: 'prod',
53
+ stepCount: 3,
54
+ entryPoint: 'start'
55
+ }
58
56
 
59
57
  const mockTrigger: TriggerDefinition = {
60
58
  resourceId: 'test-trigger-789',