@elevasis/core 0.36.0 → 0.38.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 (31) hide show
  1. package/dist/auth/index.d.ts +84 -1
  2. package/dist/index.d.ts +359 -5
  3. package/dist/index.js +41 -8
  4. package/dist/knowledge/index.d.ts +86 -1
  5. package/dist/organization-model/index.d.ts +359 -5
  6. package/dist/organization-model/index.js +41 -8
  7. package/dist/test-utils/index.d.ts +84 -1
  8. package/dist/test-utils/index.js +38 -6
  9. package/package.json +1 -1
  10. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +423 -338
  11. package/src/_gen/__tests__/__snapshots__/system-interface-capabilities.md.snap +47 -0
  12. package/src/_gen/__tests__/scaffold-contracts.test.ts +47 -8
  13. package/src/business/acquisition/api-schemas.test.ts +13 -1
  14. package/src/business/acquisition/ontology-validation.ts +13 -22
  15. package/src/organization-model/__tests__/domains/navigation-topbar.test.ts +282 -0
  16. package/src/organization-model/__tests__/domains/systems.test.ts +34 -1
  17. package/src/organization-model/__tests__/schema.test.ts +47 -0
  18. package/src/organization-model/defaults.ts +2 -1
  19. package/src/organization-model/domains/navigation.ts +176 -139
  20. package/src/organization-model/domains/systems.ts +22 -9
  21. package/src/organization-model/icons.ts +1 -0
  22. package/src/organization-model/published.ts +8 -6
  23. package/src/organization-model/types.ts +5 -1
  24. package/src/platform/constants/versions.ts +1 -1
  25. package/src/platform/registry/__tests__/validation.test.ts +1404 -1318
  26. package/src/platform/registry/index.ts +90 -88
  27. package/src/platform/registry/types.ts +443 -425
  28. package/src/platform/registry/validation.ts +60 -1
  29. package/src/reference/_generated/contracts.md +423 -338
  30. package/src/reference/_generated/system-interface-capabilities.md +47 -0
  31. package/src/reference/glossary.md +14 -2
@@ -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.
@@ -65,15 +65,28 @@ export const SystemInterfaceKeySchema = ModelIdSchema
65
65
  export const SystemInterfaceLifecycleSchema = z
66
66
  .enum(['draft', 'active', 'disabled', 'deprecated', 'archived'])
67
67
  .meta({ label: 'System interface lifecycle', color: 'teal' })
68
- export const SystemInterfaceReadinessProfileSchema = z
69
- .string()
70
- .trim()
71
- .min(1)
72
- .max(200)
73
- .regex(
74
- /^[a-z0-9][a-z0-9-]*(?:\.[a-z0-9][a-z0-9-]*)*(?:\.[a-z0-9][a-z0-9-]*)?$/,
75
- 'Readiness profiles must use dotted lowercase identifiers (e.g. "sales.lead-gen.api")'
76
- )
68
+ export const SYSTEM_INTERFACE_PROFILES = [
69
+ {
70
+ systemPath: 'sales.lead-gen',
71
+ interfaceKey: 'api',
72
+ readinessProfile: 'sales.lead-gen.api'
73
+ },
74
+ {
75
+ systemPath: 'sales.crm',
76
+ interfaceKey: 'api',
77
+ readinessProfile: 'sales.crm.api'
78
+ },
79
+ {
80
+ systemPath: 'sales.lead-gen',
81
+ interfaceKey: 'crm-handoff',
82
+ readinessProfile: 'sales.lead-gen.crm-handoff'
83
+ }
84
+ ] as const
85
+ type SystemInterfaceReadinessProfileValue = (typeof SYSTEM_INTERFACE_PROFILES)[number]['readinessProfile']
86
+ export const SYSTEM_INTERFACE_READINESS_PROFILES = SYSTEM_INTERFACE_PROFILES.map(
87
+ (profile) => profile.readinessProfile
88
+ ) as [SystemInterfaceReadinessProfileValue, ...SystemInterfaceReadinessProfileValue[]]
89
+ export const SystemInterfaceReadinessProfileSchema = z.enum(SYSTEM_INTERFACE_READINESS_PROFILES)
77
90
  export const SystemInterfaceResourceScopeSchema = z
78
91
  .array(ModelIdSchema)
79
92
  .default([])
@@ -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 {
@@ -113,6 +109,8 @@ export {
113
109
  } from './domains/goals'
114
110
  export {
115
111
  DEFAULT_ORGANIZATION_MODEL_SYSTEMS,
112
+ SYSTEM_INTERFACE_PROFILES,
113
+ SYSTEM_INTERFACE_READINESS_PROFILES,
116
114
  defineSystem,
117
115
  defineSystems,
118
116
  SystemEntrySchema,
@@ -221,7 +219,9 @@ export {
221
219
  SidebarSectionSchema,
222
220
  SidebarSurfaceTargetsSchema,
223
221
  SurfaceDefinitionSchema,
224
- SurfaceTypeSchema
222
+ SurfaceTypeSchema,
223
+ TopbarActionNodeSchema,
224
+ TopbarSectionSchema
225
225
  } from './domains/navigation'
226
226
  export {
227
227
  defineKnowledgeNode,
@@ -299,6 +299,8 @@ export type {
299
299
  OrganizationModelSidebarSection,
300
300
  OrganizationModelSidebarSurfaceNode,
301
301
  OrganizationModelSidebarSurfaceTargets,
302
+ OrganizationModelTopbarActionNode,
303
+ OrganizationModelTopbarSection,
302
304
  OrganizationModelKeyResult,
303
305
  OrganizationModelObjective,
304
306
  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.14'
3
3
  }