@elevasis/core 0.36.0 → 0.37.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.
@@ -1,139 +1,176 @@
1
- import { z, type ZodType } from 'zod'
2
- import { DescriptionSchema, IconNameSchema, LabelSchema, ModelIdSchema, PathSchema } from './shared'
3
-
4
- export const SurfaceTypeSchema = z
5
- .enum(['page', 'dashboard', 'graph', 'detail', 'list', 'settings'])
6
- .meta({ label: 'Surface type', color: 'blue' })
7
-
8
- export const SurfaceDefinitionSchema = z.object({
9
- id: ModelIdSchema,
10
- label: LabelSchema,
11
- path: PathSchema,
12
- surfaceType: SurfaceTypeSchema,
13
- description: DescriptionSchema.optional(),
14
- enabled: z.boolean().default(true),
15
- devOnly: z.boolean().optional(),
16
- icon: IconNameSchema.optional(),
17
- systemIds: z.array(ModelIdSchema.meta({ ref: 'system' })).default([]),
18
- entityIds: z.array(ModelIdSchema.meta({ ref: 'entity' })).default([]),
19
- resourceIds: z.array(ModelIdSchema.meta({ ref: 'resource' })).default([]),
20
- actionIds: z.array(ModelIdSchema.meta({ ref: 'action' })).default([]),
21
- parentId: ModelIdSchema.meta({ ref: 'surface' }).optional()
22
- })
23
-
24
- export const SidebarSurfaceTargetsSchema = z
25
- .object({
26
- systems: z.array(ModelIdSchema.meta({ ref: 'system' })).default([]).optional(),
27
- entities: z.array(ModelIdSchema.meta({ ref: 'entity' })).default([]).optional(),
28
- resources: z.array(ModelIdSchema.meta({ ref: 'resource' })).default([]).optional(),
29
- actions: z.array(ModelIdSchema.meta({ ref: 'action' })).default([]).optional()
30
- })
31
- .default({})
32
-
33
- export interface SidebarSurfaceNode {
34
- type: 'surface'
35
- label: string
36
- path: string
37
- surfaceType: z.infer<typeof SurfaceTypeSchema>
38
- description?: string
39
- icon?: string
40
- order?: number
41
- targets?: {
42
- systems?: string[]
43
- entities?: string[]
44
- resources?: string[]
45
- actions?: string[]
46
- }
47
- devOnly?: boolean
48
- requiresAdmin?: boolean
49
- }
50
-
51
- export interface SidebarGroupNode {
52
- type: 'group'
53
- label: string
54
- description?: string
55
- icon?: string
56
- order?: number
57
- children: Record<string, SidebarNode>
58
- }
59
-
60
- export type SidebarNode = SidebarSurfaceNode | SidebarGroupNode
61
-
62
- export const SidebarNodeSchema: ZodType<SidebarNode> = z.lazy(() =>
63
- z.discriminatedUnion('type', [
64
- z.object({
65
- type: z.literal('group'),
66
- label: LabelSchema,
67
- description: DescriptionSchema.optional(),
68
- icon: IconNameSchema.optional(),
69
- order: z.number().int().optional(),
70
- children: z.record(z.string(), SidebarNodeSchema).default({})
71
- }),
72
- z.object({
73
- type: z.literal('surface'),
74
- label: LabelSchema,
75
- path: PathSchema,
76
- surfaceType: SurfaceTypeSchema,
77
- description: DescriptionSchema.optional(),
78
- icon: IconNameSchema.optional(),
79
- order: z.number().int().optional(),
80
- targets: SidebarSurfaceTargetsSchema.optional(),
81
- devOnly: z.boolean().optional(),
82
- requiresAdmin: z.boolean().optional()
83
- })
84
- ])
85
- )
86
-
87
- export const SidebarSectionSchema = z.record(z.string(), SidebarNodeSchema).default({})
88
-
89
- export const SidebarNavigationSchema = z
90
- .object({
91
- primary: SidebarSectionSchema,
92
- bottom: SidebarSectionSchema
93
- })
94
- .default({ primary: {}, bottom: {} })
95
-
96
- export const OrganizationModelNavigationSchema = z
97
- .object({
98
- sidebar: SidebarNavigationSchema
99
- })
100
- .default({ sidebar: { primary: {}, bottom: {} } })
101
-
102
- export const DEFAULT_ORGANIZATION_MODEL_NAVIGATION: z.infer<typeof OrganizationModelNavigationSchema> = {
103
- sidebar: {
104
- primary: {},
105
- bottom: {}
106
- }
107
- }
108
-
109
- export function getSortedSidebarEntries<TNode extends SidebarNode>(
110
- nodes: Record<string, TNode>
111
- ): Array<[string, TNode]> {
112
- return Object.entries(nodes).sort(([leftId, left], [rightId, right]) => {
113
- const orderDelta = (left.order ?? Number.MAX_SAFE_INTEGER) - (right.order ?? Number.MAX_SAFE_INTEGER)
114
- return orderDelta === 0 ? leftId.localeCompare(rightId) : orderDelta
115
- })
116
- }
117
-
118
- /**
119
- * Core placement values: 'primary' | 'secondary' | 'bottom'.
120
- *
121
- * `placement` is intentionally open (`z.string()`) so that per-project adapters can
122
- * introduce additional placement IDs (e.g. 'pinned', 'spotlight', 'contextual') without
123
- * forking core. Extension pattern: add the new string literal to the project's
124
- * `foundations/config/organization-model.ts` adapter — no changes to this file required.
125
- *
126
- * `surfaceType` and `resourceType` remain closed enums (UI/runtime invariants).
127
- */
128
- export const CORE_PLACEMENT_VALUES = ['primary', 'secondary', 'bottom'] as const
129
- export type CorePlacement = (typeof CORE_PLACEMENT_VALUES)[number]
130
-
131
- export const NavigationGroupSchema = z.object({
132
- id: ModelIdSchema,
133
- label: LabelSchema,
134
- placement: z.string().trim().min(1).max(50),
135
- surfaceIds: z.array(ModelIdSchema.meta({ ref: 'surface' })).default([])
136
- })
137
-
138
- // SurfaceDefinitionSchema and NavigationGroupSchema remain for derived DTOs and
139
- // transitional call sites. They are not authored top-level OrganizationModel fields.
1
+ import { z, type ZodType } from 'zod'
2
+ import { DescriptionSchema, IconNameSchema, LabelSchema, ModelIdSchema, PathSchema } from './shared'
3
+
4
+ export const SurfaceTypeSchema = z
5
+ .enum(['page', 'dashboard', 'graph', 'detail', 'list', 'settings'])
6
+ .meta({ label: 'Surface type', color: 'blue' })
7
+
8
+ export const SurfaceDefinitionSchema = z.object({
9
+ id: ModelIdSchema,
10
+ label: LabelSchema,
11
+ path: PathSchema,
12
+ surfaceType: SurfaceTypeSchema,
13
+ description: DescriptionSchema.optional(),
14
+ enabled: z.boolean().default(true),
15
+ devOnly: z.boolean().optional(),
16
+ icon: IconNameSchema.optional(),
17
+ systemIds: z.array(ModelIdSchema.meta({ ref: 'system' })).default([]),
18
+ entityIds: z.array(ModelIdSchema.meta({ ref: 'entity' })).default([]),
19
+ resourceIds: z.array(ModelIdSchema.meta({ ref: 'resource' })).default([]),
20
+ actionIds: z.array(ModelIdSchema.meta({ ref: 'action' })).default([]),
21
+ parentId: ModelIdSchema.meta({ ref: 'surface' }).optional()
22
+ })
23
+
24
+ export const SidebarSurfaceTargetsSchema = z
25
+ .object({
26
+ systems: z
27
+ .array(ModelIdSchema.meta({ ref: 'system' }))
28
+ .default([])
29
+ .optional(),
30
+ entities: z
31
+ .array(ModelIdSchema.meta({ ref: 'entity' }))
32
+ .default([])
33
+ .optional(),
34
+ resources: z
35
+ .array(ModelIdSchema.meta({ ref: 'resource' }))
36
+ .default([])
37
+ .optional(),
38
+ actions: z
39
+ .array(ModelIdSchema.meta({ ref: 'action' }))
40
+ .default([])
41
+ .optional()
42
+ })
43
+ .default({})
44
+
45
+ export interface SidebarSurfaceNode {
46
+ type: 'surface'
47
+ label: string
48
+ path: string
49
+ surfaceType: z.infer<typeof SurfaceTypeSchema>
50
+ description?: string
51
+ icon?: string
52
+ order?: number
53
+ targets?: {
54
+ systems?: string[]
55
+ entities?: string[]
56
+ resources?: string[]
57
+ actions?: string[]
58
+ }
59
+ devOnly?: boolean
60
+ requiresAdmin?: boolean
61
+ }
62
+
63
+ export interface SidebarGroupNode {
64
+ type: 'group'
65
+ label: string
66
+ description?: string
67
+ icon?: string
68
+ order?: number
69
+ children: Record<string, SidebarNode>
70
+ }
71
+
72
+ export type SidebarNode = SidebarSurfaceNode | SidebarGroupNode
73
+
74
+ export const SidebarNodeSchema: ZodType<SidebarNode> = z.lazy(() =>
75
+ z.discriminatedUnion('type', [
76
+ z.object({
77
+ type: z.literal('group'),
78
+ label: LabelSchema,
79
+ description: DescriptionSchema.optional(),
80
+ icon: IconNameSchema.optional(),
81
+ order: z.number().int().optional(),
82
+ children: z.record(z.string(), SidebarNodeSchema).default({})
83
+ }),
84
+ z.object({
85
+ type: z.literal('surface'),
86
+ label: LabelSchema,
87
+ path: PathSchema,
88
+ surfaceType: SurfaceTypeSchema,
89
+ description: DescriptionSchema.optional(),
90
+ icon: IconNameSchema.optional(),
91
+ order: z.number().int().optional(),
92
+ targets: SidebarSurfaceTargetsSchema.optional(),
93
+ devOnly: z.boolean().optional(),
94
+ requiresAdmin: z.boolean().optional()
95
+ })
96
+ ])
97
+ )
98
+
99
+ export const SidebarSectionSchema = z.record(z.string(), SidebarNodeSchema).default({})
100
+
101
+ export const SidebarNavigationSchema = z
102
+ .object({
103
+ primary: SidebarSectionSchema,
104
+ bottom: SidebarSectionSchema
105
+ })
106
+ .default({ primary: {}, bottom: {} })
107
+
108
+ /**
109
+ * A leaf node in `navigation.topbar`. Has no `path`, `surfaceType`, or nesting —
110
+ * topbar actions trigger behavior (open a modal, open docs, etc.) rather than navigate to a route.
111
+ * Behavior is bound by a UI registry (`TopbarActionModule`) that matches on `id`.
112
+ */
113
+ export const TopbarActionNodeSchema = z.object({
114
+ id: ModelIdSchema,
115
+ label: LabelSchema,
116
+ tooltip: DescriptionSchema.optional(),
117
+ icon: IconNameSchema.optional(),
118
+ order: z.number().int().optional(),
119
+ enabled: z.boolean().default(true),
120
+ devOnly: z.boolean().optional(),
121
+ requiresAdmin: z.boolean().optional(),
122
+ targets: SidebarSurfaceTargetsSchema.optional()
123
+ })
124
+
125
+ /**
126
+ * A flat map of topbar action nodes, keyed by action id.
127
+ * Defaults to an empty record (no topbar actions declared).
128
+ */
129
+ export const TopbarSectionSchema = z.record(z.string(), TopbarActionNodeSchema).default({})
130
+
131
+ export const OrganizationModelNavigationSchema = z
132
+ .object({
133
+ sidebar: SidebarNavigationSchema,
134
+ topbar: TopbarSectionSchema
135
+ })
136
+ .default({ sidebar: { primary: {}, bottom: {} }, topbar: {} })
137
+
138
+ export const DEFAULT_ORGANIZATION_MODEL_NAVIGATION: z.infer<typeof OrganizationModelNavigationSchema> = {
139
+ sidebar: {
140
+ primary: {},
141
+ bottom: {}
142
+ },
143
+ topbar: {}
144
+ }
145
+
146
+ export function getSortedSidebarEntries<TNode extends SidebarNode>(
147
+ nodes: Record<string, TNode>
148
+ ): Array<[string, TNode]> {
149
+ return Object.entries(nodes).sort(([leftId, left], [rightId, right]) => {
150
+ const orderDelta = (left.order ?? Number.MAX_SAFE_INTEGER) - (right.order ?? Number.MAX_SAFE_INTEGER)
151
+ return orderDelta === 0 ? leftId.localeCompare(rightId) : orderDelta
152
+ })
153
+ }
154
+
155
+ /**
156
+ * Core placement values: 'primary' | 'secondary' | 'bottom'.
157
+ *
158
+ * `placement` is intentionally open (`z.string()`) so that per-project adapters can
159
+ * introduce additional placement IDs (e.g. 'pinned', 'spotlight', 'contextual') without
160
+ * forking core. Extension pattern: add the new string literal to the project's
161
+ * `foundations/config/organization-model.ts` adapter — no changes to this file required.
162
+ *
163
+ * `surfaceType` and `resourceType` remain closed enums (UI/runtime invariants).
164
+ */
165
+ export const CORE_PLACEMENT_VALUES = ['primary', 'secondary', 'bottom'] as const
166
+ export type CorePlacement = (typeof CORE_PLACEMENT_VALUES)[number]
167
+
168
+ export const NavigationGroupSchema = z.object({
169
+ id: ModelIdSchema,
170
+ label: LabelSchema,
171
+ placement: z.string().trim().min(1).max(50),
172
+ surfaceIds: z.array(ModelIdSchema.meta({ ref: 'surface' })).default([])
173
+ })
174
+
175
+ // SurfaceDefinitionSchema and NavigationGroupSchema remain for derived DTOs and
176
+ // transitional call sites. They are not authored top-level OrganizationModel fields.
@@ -54,6 +54,7 @@ export const ORGANIZATION_MODEL_ICON_TOKENS = [
54
54
  'view',
55
55
  'launch',
56
56
  'message',
57
+ 'message-plus',
57
58
  'escalate',
58
59
  'promote',
59
60
  'submit',
@@ -29,11 +29,7 @@ export {
29
29
  OrganizationModelDomainMetadataSchema,
30
30
  OrganizationModelSchema
31
31
  } from './schema'
32
- export {
33
- NodeIdPathSchema,
34
- NodeIdStringSchema,
35
- UiPositionSchema
36
- } from './domains/systems'
32
+ export { NodeIdPathSchema, NodeIdStringSchema, UiPositionSchema } from './domains/systems'
37
33
  export { LinkSchema } from './graph/link'
38
34
  export { IconNameSchema, TechStackEntrySchema } from './domains/shared'
39
35
  export {
@@ -221,7 +217,9 @@ export {
221
217
  SidebarSectionSchema,
222
218
  SidebarSurfaceTargetsSchema,
223
219
  SurfaceDefinitionSchema,
224
- SurfaceTypeSchema
220
+ SurfaceTypeSchema,
221
+ TopbarActionNodeSchema,
222
+ TopbarSectionSchema
225
223
  } from './domains/navigation'
226
224
  export {
227
225
  defineKnowledgeNode,
@@ -299,6 +297,8 @@ export type {
299
297
  OrganizationModelSidebarSection,
300
298
  OrganizationModelSidebarSurfaceNode,
301
299
  OrganizationModelSidebarSurfaceTargets,
300
+ OrganizationModelTopbarActionNode,
301
+ OrganizationModelTopbarSection,
302
302
  OrganizationModelKeyResult,
303
303
  OrganizationModelObjective,
304
304
  OrganizationModelSystemEntry,
@@ -11,7 +11,9 @@ import {
11
11
  SidebarNodeSchema,
12
12
  SidebarSectionSchema,
13
13
  SidebarSurfaceTargetsSchema,
14
- SurfaceDefinitionSchema
14
+ SurfaceDefinitionSchema,
15
+ TopbarActionNodeSchema,
16
+ TopbarSectionSchema
15
17
  } from './domains/navigation'
16
18
  import { TechStackEntrySchema } from './domains/shared'
17
19
  import { StatusesDomainSchema, StatusEntrySchema, StatusSemanticClassSchema } from './domains/statuses'
@@ -135,6 +137,8 @@ export type OrganizationModelSidebarNode = z.infer<typeof SidebarNodeSchema>
135
137
  export type OrganizationModelSidebarSurfaceTargets = z.infer<typeof SidebarSurfaceTargetsSchema>
136
138
  export type OrganizationModelSidebarSurfaceNode = Extract<OrganizationModelSidebarNode, { type: 'surface' }>
137
139
  export type OrganizationModelSidebarGroupNode = Extract<OrganizationModelSidebarNode, { type: 'group' }>
140
+ export type OrganizationModelTopbarActionNode = z.infer<typeof TopbarActionNodeSchema>
141
+ export type OrganizationModelTopbarSection = z.infer<typeof TopbarSectionSchema>
138
142
  export type OrganizationModelTechStackEntry = z.infer<typeof TechStackEntrySchema>
139
143
  export type OrganizationModelStatuses = z.infer<typeof StatusesDomainSchema>
140
144
  export type OrganizationModelStatusEntry = z.infer<typeof StatusEntrySchema>
@@ -1,3 +1,3 @@
1
1
  export const VERSION = {
2
- CURRENT: '1.12.12'
2
+ CURRENT: '1.12.13'
3
3
  }
@@ -135,6 +135,18 @@ export type OrganizationModelSidebarSurfaceNode = Extract<OrganizationModelSideb
135
135
  export type OrganizationModelSidebarGroupNode = Extract<OrganizationModelSidebarNode, { type: 'group' }>
136
136
  ```
137
137
 
138
+ ### `OrganizationModelTopbarActionNode`
139
+
140
+ ```typescript
141
+ export type OrganizationModelTopbarActionNode = z.infer<typeof TopbarActionNodeSchema>
142
+ ```
143
+
144
+ ### `OrganizationModelTopbarSection`
145
+
146
+ ```typescript
147
+ export type OrganizationModelTopbarSection = z.infer<typeof TopbarSectionSchema>
148
+ ```
149
+
138
150
  ### `OrganizationModelTechStackEntry`
139
151
 
140
152
  ```typescript
@@ -845,6 +857,57 @@ export interface ShellRuntime {
845
857
  }
846
858
  ```
847
859
 
860
+ ### `ResolvedTopbarAction`
861
+
862
+ ```typescript
863
+ /**
864
+ * A resolved topbar action — the OM node after gating/filtering, with icon resolved
865
+ * from the semantic icon registry. Passed to `TopbarActionModule.render`.
866
+ */
867
+ export interface ResolvedTopbarAction {
868
+ id: string
869
+ label: string
870
+ tooltip?: string
871
+ icon: TablerIconComponent
872
+ order: number
873
+ }
874
+ ```
875
+
876
+ ### `TopbarActionModule`
877
+
878
+ ```typescript
879
+ /**
880
+ * A topbar action module — binds a registry key to UI behavior (a render callback).
881
+ * The key must match `navigation.topbar[id]`. The OM supplies data + visibility;
882
+ * the module supplies behavior.
883
+ */
884
+ export interface TopbarActionModule {
885
+ /** Stable key that matches the `id` of a `navigation.topbar` node. */
886
+ key: string
887
+ /** Render the topbar action. Receives the resolved OM node (icon pre-resolved). */
888
+ render: (ctx: { node: ResolvedTopbarAction }) => ReactNode
889
+ }
890
+ ```
891
+
892
+ ### `ResolvedTopbarActionEntry`
893
+
894
+ ```typescript
895
+ /** A joined entry emitted by `getTopbarActions`: resolved OM node + module behavior. */
896
+ export interface ResolvedTopbarActionEntry {
897
+ node: ResolvedTopbarAction
898
+ render: TopbarActionModule['render']
899
+ }
900
+ ```
901
+
902
+ ### `TopbarActionsProjectionOptions`
903
+
904
+ ```typescript
905
+ export interface TopbarActionsProjectionOptions {
906
+ isPlatformAdmin?: boolean
907
+ isDev?: boolean
908
+ }
909
+ ```
910
+
848
911
  ### `OrganizationGraphSystemBridge`
849
912
 
850
913
  ```typescript
@@ -868,6 +931,8 @@ export interface OrganizationGraphContextValue {
868
931
  ```typescript
869
932
  export interface ElevasisSystemsProviderProps {
870
933
  systems?: SystemModule[]
934
+ /** Registered topbar action modules. OM node presence controls visibility; module supplies behavior. */
935
+ topbarActions?: TopbarActionModule[]
871
936
  organizationModel?: ElevasisOrganizationModel
872
937
  timeRange?: TimeRange
873
938
  operationsApiUrl?: string
@@ -886,6 +951,8 @@ export interface ElevasisSystemsContextValue {
886
951
  shellModel: ResolvedShellModel
887
952
  shellRuntime: ShellRuntime
888
953
  getSidebarLinks: (options?: ShellSidebarProjectionOptions) => ShellSidebarLinkGroup[]
954
+ /** Returns the list of topbar actions visible to the current user, in order. */
955
+ getTopbarActions: (options?: TopbarActionsProjectionOptions) => ResolvedTopbarActionEntry[]
889
956
  enabledResolvedSystems: ResolvedSystemModule[]
890
957
  resolvedSystems: ResolvedSystemModule[]
891
958
  organizationGraph: OrganizationGraphContextValue