@elevasis/core 0.10.0 → 0.11.1

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 (58) hide show
  1. package/dist/index.d.ts +69 -159
  2. package/dist/index.js +324 -613
  3. package/dist/organization-model/index.d.ts +69 -159
  4. package/dist/organization-model/index.js +324 -613
  5. package/dist/test-utils/index.d.ts +192 -45
  6. package/dist/test-utils/index.js +260 -600
  7. package/package.json +1 -1
  8. package/src/__tests__/template-core-compatibility.test.ts +73 -91
  9. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +94 -182
  10. package/src/auth/multi-tenancy/index.ts +20 -17
  11. package/src/auth/multi-tenancy/memberships/api-schemas.ts +142 -126
  12. package/src/auth/multi-tenancy/memberships/index.ts +26 -22
  13. package/src/auth/multi-tenancy/permissions.test.ts +42 -0
  14. package/src/auth/multi-tenancy/permissions.ts +104 -0
  15. package/src/organization-model/README.md +102 -97
  16. package/src/organization-model/__tests__/defaults.test.ts +19 -6
  17. package/src/organization-model/__tests__/domains/resource-mappings.test.ts +24 -93
  18. package/src/organization-model/__tests__/graph.test.ts +82 -894
  19. package/src/organization-model/__tests__/resolve.test.ts +59 -690
  20. package/src/organization-model/__tests__/schema.test.ts +83 -407
  21. package/src/organization-model/contracts.ts +4 -3
  22. package/src/organization-model/defaults.ts +277 -141
  23. package/src/organization-model/domains/features.ts +31 -22
  24. package/src/organization-model/domains/navigation.ts +27 -20
  25. package/src/organization-model/foundation.ts +42 -54
  26. package/src/organization-model/graph/build.ts +42 -217
  27. package/src/organization-model/graph/index.ts +4 -4
  28. package/src/organization-model/graph/link.ts +10 -0
  29. package/src/organization-model/graph/schema.ts +21 -16
  30. package/src/organization-model/graph/types.ts +10 -10
  31. package/src/organization-model/helpers.ts +74 -0
  32. package/src/organization-model/index.ts +7 -7
  33. package/src/organization-model/organization-graph.mdx +89 -272
  34. package/src/organization-model/organization-model.mdx +152 -320
  35. package/src/organization-model/published.ts +20 -19
  36. package/src/organization-model/resolve.ts +8 -33
  37. package/src/organization-model/schema.ts +63 -205
  38. package/src/organization-model/types.ts +12 -11
  39. package/src/platform/constants/versions.ts +3 -3
  40. package/src/platform/registry/__tests__/command-view.test.ts +6 -5
  41. package/src/platform/registry/__tests__/resource-link.test.ts +30 -0
  42. package/src/platform/registry/__tests__/resource-registry.integration.test.ts +15 -15
  43. package/src/platform/registry/command-view.ts +10 -12
  44. package/src/platform/registry/index.ts +93 -93
  45. package/src/platform/registry/resource-link.ts +32 -0
  46. package/src/platform/registry/resource-registry.ts +917 -876
  47. package/src/platform/registry/serialization.ts +56 -73
  48. package/src/platform/registry/serialized-types.ts +17 -12
  49. package/src/platform/registry/types.ts +14 -43
  50. package/src/reference/_generated/contracts.md +94 -182
  51. package/src/reference/glossary.md +71 -105
  52. package/src/scaffold-registry/__tests__/index.test.ts +125 -1
  53. package/src/scaffold-registry/__tests__/schema.test.ts +48 -20
  54. package/src/scaffold-registry/index.ts +236 -188
  55. package/src/scaffold-registry/schema.ts +47 -22
  56. package/src/supabase/database.types.ts +2880 -2719
  57. package/src/test-utils/fixtures/memberships.ts +82 -80
  58. package/src/platform/registry/domains.ts +0 -165
@@ -7,17 +7,15 @@
7
7
 
8
8
  import type { DeploymentSpec } from './resource-registry'
9
9
  import type { ResourceDefinition } from './types'
10
- import type {
11
- SerializedOrganizationData,
12
- SerializedAgentDefinition,
13
- SerializedWorkflowDefinition,
14
- CommandViewAgent,
10
+ import type {
11
+ SerializedOrganizationData,
12
+ SerializedAgentDefinition,
13
+ SerializedWorkflowDefinition,
14
+ CommandViewAgent,
15
15
  CommandViewWorkflow,
16
16
  CommandViewEdge
17
- } from './serialized-types'
18
- import { serializeDefinition } from '../../execution/engine/base/serialization'
19
- import { DOMAIN_MAP, type ResourceDomain } from './domains'
20
- import type { DomainDefinition } from './types'
17
+ } from './serialized-types'
18
+ import { serializeDefinition } from '../../execution/engine/base/serialization'
21
19
 
22
20
  /**
23
21
  * Serialize all organization resources
@@ -33,28 +31,9 @@ export function serializeAllOrganizations(
33
31
  return cache
34
32
  }
35
33
 
36
- /**
37
- * Derive domain definitions from resource domains
38
- * Collects all unique domain IDs used across resources and maps to definitions
39
- */
40
- function deriveDomainDefinitions(resources: DeploymentSpec): DomainDefinition[] {
41
- const domainIds = new Set<ResourceDomain>()
42
-
43
- // Collect from all resource types
44
- resources.workflows?.forEach((w) => w.config.domains?.forEach((d) => domainIds.add(d)))
45
- resources.agents?.forEach((a) => a.config.domains?.forEach((d) => domainIds.add(d)))
46
- resources.triggers?.forEach((t) => t.domains?.forEach((d) => domainIds.add(d)))
47
- resources.integrations?.forEach((i) => i.domains?.forEach((d) => domainIds.add(d)))
48
- resources.externalResources?.forEach((e) => e.domains?.forEach((d) => domainIds.add(d)))
49
- resources.humanCheckpoints?.forEach((h) => h.domains?.forEach((d) => domainIds.add(d)))
50
-
51
- // Look up definitions - guaranteed to exist due to ResourceDomain typing
52
- return Array.from(domainIds).map((id) => DOMAIN_MAP[id])
53
- }
54
-
55
- /**
56
- * Serialize single organization's resources
57
- */
34
+ /**
35
+ * Serialize single organization's resources
36
+ */
58
37
  export function serializeOrganization(resources: DeploymentSpec): SerializedOrganizationData {
59
38
  // Serialize workflows
60
39
  const workflowDefinitions = new Map<string, SerializedWorkflowDefinition>()
@@ -66,26 +45,29 @@ export function serializeOrganization(resources: DeploymentSpec): SerializedOrga
66
45
  const serialized = serializeDefinition(workflow) as SerializedWorkflowDefinition
67
46
  workflowDefinitions.set(resourceId, serialized)
68
47
 
69
- workflowResources.push({
70
- resourceId,
71
- name: workflow.config.name,
72
- description: workflow.config.description,
73
- version: workflow.config.version,
74
- type: 'workflow',
75
- status: workflow.config.status
76
- })
48
+ workflowResources.push({
49
+ resourceId,
50
+ name: workflow.config.name,
51
+ description: workflow.config.description,
52
+ version: workflow.config.version,
53
+ type: 'workflow',
54
+ status: workflow.config.status,
55
+ links: workflow.config.links,
56
+ category: workflow.config.category
57
+ })
77
58
 
78
59
  commandViewWorkflows.push({
79
60
  resourceId,
80
61
  name: workflow.config.name,
81
- description: workflow.config.description,
82
- version: workflow.config.version,
83
- type: 'workflow',
84
- status: workflow.config.status,
85
- domains: workflow.config.domains,
86
- stepCount: Object.keys(workflow.steps).length,
87
- entryPoint: workflow.entryPoint
88
- })
62
+ description: workflow.config.description,
63
+ version: workflow.config.version,
64
+ type: 'workflow',
65
+ status: workflow.config.status,
66
+ links: workflow.config.links,
67
+ category: workflow.config.category,
68
+ stepCount: Object.keys(workflow.steps).length,
69
+ entryPoint: workflow.entryPoint
70
+ })
89
71
  }
90
72
 
91
73
  // Serialize agents
@@ -98,24 +80,27 @@ export function serializeOrganization(resources: DeploymentSpec): SerializedOrga
98
80
  const serialized = serializeDefinition(agent) as SerializedAgentDefinition
99
81
  agentDefinitions.set(resourceId, serialized)
100
82
 
101
- agentResources.push({
102
- resourceId,
103
- name: agent.config.name,
104
- description: agent.config.description,
105
- version: agent.config.version,
106
- type: 'agent',
107
- status: agent.config.status
108
- })
83
+ agentResources.push({
84
+ resourceId,
85
+ name: agent.config.name,
86
+ description: agent.config.description,
87
+ version: agent.config.version,
88
+ type: 'agent',
89
+ status: agent.config.status,
90
+ links: agent.config.links,
91
+ category: agent.config.category
92
+ })
109
93
 
110
94
  commandViewAgents.push({
111
95
  resourceId,
112
96
  name: agent.config.name,
113
- description: agent.config.description,
114
- version: agent.config.version,
115
- type: 'agent',
116
- status: agent.config.status,
117
- domains: agent.config.domains,
118
- modelProvider: agent.modelConfig.provider,
97
+ description: agent.config.description,
98
+ version: agent.config.version,
99
+ type: 'agent',
100
+ status: agent.config.status,
101
+ links: agent.config.links,
102
+ category: agent.config.category,
103
+ modelProvider: agent.modelConfig.provider,
119
104
  modelId: agent.modelConfig.model,
120
105
  toolCount: agent.tools.length,
121
106
  hasKnowledgeMap: agent.knowledgeMap !== undefined,
@@ -129,12 +114,11 @@ export function serializeOrganization(resources: DeploymentSpec): SerializedOrga
129
114
 
130
115
  // Pass-through manifest data (already JSON-safe)
131
116
  const triggers = resources.triggers ?? []
132
- const integrations = resources.integrations ?? []
133
- const externalResources = resources.externalResources ?? []
134
- const humanCheckpoints = resources.humanCheckpoints ?? []
135
- const domainDefinitions = deriveDomainDefinitions(resources)
136
-
137
- return {
117
+ const integrations = resources.integrations ?? []
118
+ const externalResources = resources.externalResources ?? []
119
+ const humanCheckpoints = resources.humanCheckpoints ?? []
120
+
121
+ return {
138
122
  version: resources.version,
139
123
  resources: {
140
124
  workflows: workflowResources,
@@ -149,12 +133,11 @@ export function serializeOrganization(resources: DeploymentSpec): SerializedOrga
149
133
  workflows: commandViewWorkflows,
150
134
  agents: commandViewAgents,
151
135
  triggers,
152
- integrations,
153
- externalResources,
154
- humanCheckpoints,
155
- edges,
156
- domainDefinitions
157
- },
136
+ integrations,
137
+ externalResources,
138
+ humanCheckpoints,
139
+ edges
140
+ },
158
141
  triggers,
159
142
  integrations,
160
143
  externalResources,
@@ -7,14 +7,15 @@
7
7
 
8
8
  import type { FormFieldType } from '../../forms/types'
9
9
  import { CommandViewData } from './command-view'
10
- import type {
11
- ResourceDefinition,
12
- TriggerDefinition,
13
- IntegrationDefinition,
14
- ResourceRelationships,
15
- ExternalResourceDefinition,
16
- HumanCheckpointDefinition
17
- } from './types'
10
+ import type {
11
+ ResourceDefinition,
12
+ TriggerDefinition,
13
+ IntegrationDefinition,
14
+ ResourceRelationships,
15
+ ExternalResourceDefinition,
16
+ HumanCheckpointDefinition
17
+ } from './types'
18
+ import type { ResourceCategory, ResourceLink } from './resource-link'
18
19
 
19
20
  // ============================================================================
20
21
  // Serialized Interface Types (for Execution Runner UI)
@@ -99,8 +100,10 @@ export interface SerializedAgentDefinition {
99
100
  description: string
100
101
  version: string
101
102
  type: 'agent'
102
- status: 'dev' | 'prod'
103
- /** Whether this resource is archived and should be excluded from registration and deployment */
103
+ status: 'dev' | 'prod'
104
+ links?: ResourceLink[]
105
+ category?: ResourceCategory
106
+ /** Whether this resource is archived and should be excluded from registration and deployment */
104
107
  archived?: boolean
105
108
  systemPrompt: string
106
109
  constraints?: {
@@ -155,8 +158,10 @@ export interface SerializedWorkflowDefinition {
155
158
  description: string
156
159
  version: string
157
160
  type: 'workflow'
158
- status: 'dev' | 'prod'
159
- /** Whether this resource is archived and should be excluded from registration and deployment */
161
+ status: 'dev' | 'prod'
162
+ links?: ResourceLink[]
163
+ category?: ResourceCategory
164
+ /** Whether this resource is archived and should be excluded from registration and deployment */
160
165
  archived?: boolean
161
166
  }
162
167
  entryPoint: string
@@ -2,8 +2,8 @@
2
2
  * Resource Registry type definitions
3
3
  */
4
4
 
5
- import type { IntegrationType } from '../../execution/engine/tools/integration'
6
- import type { ResourceDomain } from './domains'
5
+ import type { IntegrationType } from '../../execution/engine/tools/integration'
6
+ import type { ResourceCategory, ResourceLink } from './resource-link'
7
7
 
8
8
  // ============================================================================
9
9
  // Core Resource Type Definitions
@@ -53,8 +53,11 @@ export interface ResourceDefinition {
53
53
  /** Environment/deployment status */
54
54
  status: ResourceStatus
55
55
 
56
- /** Domain tags for filtering and organization */
57
- domains?: ResourceDomain[]
56
+ /** Graph links to Organization Model nodes */
57
+ links?: ResourceLink[]
58
+
59
+ /** Infrastructure category for filtering */
60
+ category?: ResourceCategory
58
61
 
59
62
  /** Whether the agent supports multi-turn sessions (agents only) */
60
63
  sessionCapable?: boolean
@@ -66,41 +69,9 @@ export interface ResourceDefinition {
66
69
  archived?: boolean
67
70
  }
68
71
 
69
- // ============================================================================
70
- // Domain Definition Types
71
- // ============================================================================
72
-
73
- /**
74
- * Domain definition for Command View filtering
75
- *
76
- * Domains are organizational metadata for UI filtering/grouping.
77
- * No execution impact - purely for visualization.
78
- *
79
- * @example
80
- * {
81
- * id: 'support',
82
- * name: 'Customer Support',
83
- * description: 'Ticket triage, knowledge base, escalations',
84
- * color: 'green',
85
- * icon: 'IconHeadset'
86
- * }
87
- */
88
- export interface DomainDefinition {
89
- /** Unique identifier (e.g., 'support') */
90
- id: string
91
- /** Display name (e.g., 'Customer Support') */
92
- name: string
93
- /** Purpose description */
94
- description: string
95
- /** Optional Mantine color for UI (e.g., 'blue', 'green', 'orange') */
96
- color?: string
97
- /** Optional Tabler icon name (e.g., 'IconHeadset') */
98
- icon?: string
99
- }
100
-
101
- /**
102
- * Resource list for organization
103
- * Returns ResourceDefinition metadata (not full definitions)
72
+ /**
73
+ * Resource list for organization
74
+ * Returns ResourceDefinition metadata (not full definitions)
104
75
  */
105
76
  export interface ResourceList {
106
77
  workflows: ResourceDefinition[]
@@ -163,7 +134,7 @@ export type TriggerConfig = WebhookTriggerConfig | ScheduleTriggerConfig | Event
163
134
  * scheduled cron jobs, platform events, or manual user actions.
164
135
  *
165
136
  * BREAKING CHANGES (2025-11-30):
166
- * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, domains)
137
+ * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, links, category)
167
138
  * - Field renames: `id` -> `resourceId` (inherited), `type` -> `triggerType`
168
139
  * - Relationship rename: `invokes` -> `triggers` (unified vocabulary)
169
140
  * - New required fields: `version` (inherited), `type: 'trigger'` (inherited)
@@ -216,7 +187,7 @@ export interface TriggerDefinition extends ResourceDefinition {
216
187
  * stored here (queried at runtime from credentials table).
217
188
  *
218
189
  * BREAKING CHANGES (2025-11-30):
219
- * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, domains)
190
+ * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, links, category)
220
191
  * - Field renames: `id` -> `resourceId` (inherited)
221
192
  * - New required field: `status` (inherited) - organizations must add status to all integrations
222
193
  * - New required field: `version` (inherited) - organizations must add version to all integrations
@@ -305,7 +276,7 @@ export type ExternalPlatform = 'n8n' | 'make' | 'zapier' | 'other'
305
276
  * no API integration with external platforms, no status syncing.
306
277
  *
307
278
  * BREAKING CHANGES (2025-11-30):
308
- * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, domains)
279
+ * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, links, category)
309
280
  * - Field renames: `id` -> `resourceId` (inherited)
310
281
  * - New required field: `version` (inherited) - organizations must add version to all external resources
311
282
  * - New required field: `type: 'external'` (inherited) - resource type discriminator
@@ -364,7 +335,7 @@ export interface ExternalResourceDefinition extends ResourceDefinition {
364
335
  * Tasks with matching command_queue_group are routed to this checkpoint.
365
336
  *
366
337
  * BREAKING CHANGES (2025-11-30):
367
- * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, domains)
338
+ * - Now extends ResourceDefinition (inherits: resourceId, name, description, version, type, status, links, category)
368
339
  * - Field renames: `id` -> `resourceId` (inherited)
369
340
  * - description is now REQUIRED (was optional) - organizations must add description to all human checkpoints
370
341
  * - New required field: `version` (inherited) - organizations must add version to all human checkpoints