@elevasis/sdk 1.10.0 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +22 -142
- package/dist/index.d.ts +127 -154
- package/dist/index.js +15 -139
- package/dist/test-utils/index.d.ts +59 -62
- package/dist/worker/index.js +4 -2
- package/package.json +2 -2
- package/reference/deployment/provided-features.mdx +40 -267
- package/reference/examples/organization-model.ts +96 -564
- package/reference/packages/core/src/organization-model/README.md +101 -97
- package/reference/resources/types.mdx +72 -163
- package/reference/scaffold/core/organization-graph.mdx +89 -272
- package/reference/scaffold/core/organization-model.mdx +149 -320
- package/reference/scaffold/recipes/add-a-feature.md +102 -158
- package/reference/scaffold/recipes/add-a-resource.md +85 -158
- package/reference/scaffold/recipes/customize-organization-model.md +141 -400
- package/reference/scaffold/recipes/gate-by-feature-or-admin.md +114 -158
- package/reference/scaffold/reference/contracts.md +62 -148
- package/reference/scaffold/reference/feature-registry.md +8 -8
- package/reference/scaffold/reference/glossary.md +71 -105
- package/reference/scaffold/ui/feature-flags-and-gating.md +27 -232
- package/reference/scaffold/ui/feature-shell.mdx +50 -219
- package/reference/scaffold/ui/recipes.md +62 -397
|
@@ -1,97 +1,101 @@
|
|
|
1
|
-
# Organization Model
|
|
2
|
-
|
|
3
|
-
The organization model is the published semantic contract that maps a tenant's product shape to
|
|
4
|
-
|
|
5
|
-
Use this module when
|
|
6
|
-
|
|
7
|
-
## Published Exports
|
|
8
|
-
|
|
9
|
-
The public entry point exposes:
|
|
10
|
-
|
|
11
|
-
- `OrganizationModelSchema`
|
|
12
|
-
- `
|
|
13
|
-
- `
|
|
14
|
-
- `
|
|
15
|
-
- `
|
|
16
|
-
- `
|
|
17
|
-
-
|
|
18
|
-
- `OrganizationModel` and
|
|
19
|
-
|
|
20
|
-
Import it from the published subpath:
|
|
21
|
-
|
|
22
|
-
```ts
|
|
23
|
-
import {
|
|
24
|
-
DEFAULT_ORGANIZATION_MODEL,
|
|
25
|
-
|
|
26
|
-
defineOrganizationModel,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
- `
|
|
41
|
-
- `
|
|
42
|
-
- `
|
|
43
|
-
- `
|
|
44
|
-
- `
|
|
45
|
-
- `
|
|
46
|
-
- `
|
|
47
|
-
- `
|
|
48
|
-
- `
|
|
49
|
-
- `
|
|
50
|
-
- `
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
- `
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
-
|
|
82
|
-
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
- Feature
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
1
|
+
# Organization Model
|
|
2
|
+
|
|
3
|
+
The organization model is the published semantic contract that maps a tenant's product shape to flat feature hierarchy, shell navigation, business semantics, and graph bindings.
|
|
4
|
+
|
|
5
|
+
Use this module when resolving or validating an organization's contract before wiring UI shells, routing, feature gates, or domain-specific capability checks.
|
|
6
|
+
|
|
7
|
+
## Published Exports
|
|
8
|
+
|
|
9
|
+
The public entry point exposes:
|
|
10
|
+
|
|
11
|
+
- `OrganizationModelSchema`
|
|
12
|
+
- `FeatureSchema`
|
|
13
|
+
- `DEFAULT_ORGANIZATION_MODEL`
|
|
14
|
+
- `defineOrganizationModel`
|
|
15
|
+
- `resolveOrganizationModel`
|
|
16
|
+
- `createFoundationOrganizationModel`
|
|
17
|
+
- node ID and feature helper types
|
|
18
|
+
- `OrganizationModel` and supporting domain types
|
|
19
|
+
|
|
20
|
+
Import it from the published subpath:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import {
|
|
24
|
+
DEFAULT_ORGANIZATION_MODEL,
|
|
25
|
+
createFoundationOrganizationModel,
|
|
26
|
+
defineOrganizationModel,
|
|
27
|
+
resolveOrganizationModel,
|
|
28
|
+
type OrganizationModel
|
|
29
|
+
} from '@elevasis/core/organization-model'
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Contract Shape
|
|
33
|
+
|
|
34
|
+
The model is versioned and currently validates against `version: 1`.
|
|
35
|
+
|
|
36
|
+
Top-level fields:
|
|
37
|
+
|
|
38
|
+
- `version`
|
|
39
|
+
- `branding`
|
|
40
|
+
- `features`
|
|
41
|
+
- `navigation`
|
|
42
|
+
- `sales`
|
|
43
|
+
- `prospecting`
|
|
44
|
+
- `projects`
|
|
45
|
+
- `identity`
|
|
46
|
+
- `customers`
|
|
47
|
+
- `offerings`
|
|
48
|
+
- `roles`
|
|
49
|
+
- `goals`
|
|
50
|
+
- `statuses`
|
|
51
|
+
- `operations`
|
|
52
|
+
|
|
53
|
+
Resources bind to the graph from deployment metadata through `links` and `category`.
|
|
54
|
+
|
|
55
|
+
## Feature Set
|
|
56
|
+
|
|
57
|
+
Feature hierarchy is authored as a flat array. Dotted IDs define parent/child relationships:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
features: [
|
|
61
|
+
{ id: 'dashboard', label: 'Dashboard', enabled: true, path: '/', uiPosition: 'sidebar-primary' },
|
|
62
|
+
{ id: 'sales', label: 'Sales', enabled: true, uiPosition: 'sidebar-primary' },
|
|
63
|
+
{ id: 'sales.crm', label: 'CRM', enabled: true, path: '/crm' },
|
|
64
|
+
{ id: 'operations.resources', label: 'Resources', enabled: true, path: '/operations/resources' }
|
|
65
|
+
]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Containers omit `path`; leaves provide `path`. `uiPosition`, `requiresAdmin`, and `devOnly` inherit from ancestors.
|
|
69
|
+
|
|
70
|
+
## Graph IDs
|
|
71
|
+
|
|
72
|
+
Cross-collection links use kind-prefixed IDs:
|
|
73
|
+
|
|
74
|
+
- `feature:sales.crm`
|
|
75
|
+
- `integration:instantly`
|
|
76
|
+
- `resource:lead-import`
|
|
77
|
+
- `capability:operations.queue.review`
|
|
78
|
+
|
|
79
|
+
## Resolution Semantics
|
|
80
|
+
|
|
81
|
+
- `defineOrganizationModel()` is a typed helper.
|
|
82
|
+
- `resolveOrganizationModel()` deep-merges a partial override into the default model, then validates it.
|
|
83
|
+
- `createFoundationOrganizationModel()` resolves the canonical model and returns UI-facing helper outputs.
|
|
84
|
+
- Plain objects merge recursively.
|
|
85
|
+
- Arrays replace the default value.
|
|
86
|
+
- Missing fields fall back to `DEFAULT_ORGANIZATION_MODEL`.
|
|
87
|
+
|
|
88
|
+
## Referential Integrity
|
|
89
|
+
|
|
90
|
+
- Feature IDs must be unique.
|
|
91
|
+
- Child feature IDs require ancestor feature nodes.
|
|
92
|
+
- Container features omit `path`.
|
|
93
|
+
- Leaf features provide `path`.
|
|
94
|
+
- Resource links are validated against graph node IDs during registry registration.
|
|
95
|
+
|
|
96
|
+
## Practical Guidance
|
|
97
|
+
|
|
98
|
+
- Use `resolveOrganizationModel()` when you need a runtime-safe model.
|
|
99
|
+
- Use `defineOrganizationModel()` when authoring static overrides.
|
|
100
|
+
- Keep feature IDs stable because shell routing, gating, breadcrumbs, and docs depend on them.
|
|
101
|
+
- Put semantic resource relationships on resource metadata, not on feature nodes.
|
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: SDK Types
|
|
3
|
-
description:
|
|
3
|
+
description: Type reference for @elevasis/sdk package exports, resource metadata, platform types, ElevasConfig, StepHandler context, and runtime values.
|
|
4
4
|
loadWhen: "Looking up type signatures or SDK exports"
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
`@elevasis/sdk`
|
|
7
|
+
`@elevasis/sdk` bundles platform types into a self-contained package for external projects.
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
pnpm add @elevasis/sdk zod
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Zod is a peer dependency
|
|
14
|
-
|
|
15
|
-
---
|
|
13
|
+
Zod is a peer dependency.
|
|
16
14
|
|
|
17
15
|
## Package Exports
|
|
18
16
|
|
|
19
|
-
The package exposes two subpaths:
|
|
20
|
-
|
|
21
17
|
```json
|
|
22
18
|
{
|
|
23
19
|
"exports": {
|
|
@@ -27,181 +23,94 @@ The package exposes two subpaths:
|
|
|
27
23
|
}
|
|
28
24
|
```
|
|
29
25
|
|
|
30
|
-
- `@elevasis/sdk` --
|
|
31
|
-
- `@elevasis/sdk/worker` -- worker runtime module
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
| `
|
|
44
|
-
| `
|
|
45
|
-
| `
|
|
46
|
-
| `
|
|
47
|
-
| `
|
|
48
|
-
| `
|
|
49
|
-
| `
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
| `StepHandler` | Function type: `(input: unknown, context: StepContext) => Promise<unknown>` |
|
|
65
|
-
| `NextConfig` | Union of `LinearNext` and `ConditionalNext` |
|
|
66
|
-
| `LinearNext` | `{ type: 'linear', target: string }` -- fixed next step |
|
|
67
|
-
| `ConditionalNext` | `{ type: 'conditional', routes: Route[], default: string }` -- branching routing |
|
|
68
|
-
| `StepType` | Runtime enum: `LINEAR | CONDITIONAL` (also a runtime value -- see below) |
|
|
69
|
-
| `AgentDefinition` | Complete agent definition including config, agentConfig, tools |
|
|
70
|
-
| `AgentConfig` | Agent metadata: name, description, status |
|
|
71
|
-
| `AgentConstraints` | Execution limits for agents |
|
|
72
|
-
| `Tool` | Tool definition for agent use |
|
|
73
|
-
| `ToolExecutionOptions` | Options passed when a tool executes |
|
|
74
|
-
| `ToolingErrorType` | Enum of tool error categories |
|
|
75
|
-
| `ToolingError` | Error class for tool execution failures (also a runtime value -- see below) |
|
|
76
|
-
| `ExecutionError` | Error class for execution-level failures (also a runtime value -- see below) |
|
|
77
|
-
| `Contract` | Input/output Zod schema pair |
|
|
78
|
-
| `ExecutionContext` | Runtime context passed to step handlers |
|
|
79
|
-
| `ExecutionMetadata` | Metadata about a running execution |
|
|
80
|
-
| `LLMModel` | Model identifier: provider + model name |
|
|
81
|
-
| `ModelConfig` | Full model configuration including temperature and token limits |
|
|
82
|
-
| `ExecutionInterface` | Interface for triggering and inspecting executions |
|
|
83
|
-
|
|
84
|
-
### Form and Metrics Types
|
|
85
|
-
|
|
86
|
-
| Type | Description |
|
|
87
|
-
| ----------------------- | ------------------------------------------ |
|
|
88
|
-
| `FormField` | Individual form field definition |
|
|
89
|
-
| `FormSchema` | Collection of form fields |
|
|
90
|
-
| `FormFieldType` | Enum of supported field types |
|
|
91
|
-
| `ResourceMetricsConfig` | Observability configuration for a resource |
|
|
26
|
+
- `@elevasis/sdk` -- resource, workflow, agent, trigger, deployment, and execution types plus runtime errors.
|
|
27
|
+
- `@elevasis/sdk/worker` -- worker runtime module, platform adapters, and worker helpers.
|
|
28
|
+
|
|
29
|
+
## Platform Types
|
|
30
|
+
|
|
31
|
+
| Type | Description |
|
|
32
|
+
| --- | --- |
|
|
33
|
+
| `ResourceDefinition` | Base interface for resource definitions |
|
|
34
|
+
| `ResourceType` | Resource kind such as `workflow`, `agent`, `trigger`, `integration`, `external`, or `human_checkpoint` |
|
|
35
|
+
| `ResourceStatus` | Resource lifecycle status such as `dev` or `prod` |
|
|
36
|
+
| `ResourceLink` | Graph link `{ nodeId, kind }` binding a resource to an Organization Model node |
|
|
37
|
+
| `ResourceCategory` | Operational category: `production`, `diagnostic`, `internal`, or `testing` |
|
|
38
|
+
| `DeploymentSpec` | Top-level export shape: `{ workflows, agents, triggers, integrations, humanCheckpoints, externalResources, relationships }` |
|
|
39
|
+
| `TriggerDefinition` | Base for trigger configuration |
|
|
40
|
+
| `IntegrationDefinition` | Integration configuration structure |
|
|
41
|
+
| `WebhookProviderType` | Supported webhook providers |
|
|
42
|
+
| `WebhookTriggerConfig` | Webhook trigger configuration |
|
|
43
|
+
| `ScheduleTriggerConfig` | Cron/schedule trigger configuration |
|
|
44
|
+
| `EventTriggerConfig` | Internal event trigger configuration |
|
|
45
|
+
| `TriggerConfig` | Union of all trigger config types |
|
|
46
|
+
|
|
47
|
+
Resource metadata uses graph links:
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
config: {
|
|
51
|
+
resourceId: 'lead-import',
|
|
52
|
+
name: 'Lead Import',
|
|
53
|
+
type: 'workflow',
|
|
54
|
+
version: '1.0.0',
|
|
55
|
+
status: 'prod',
|
|
56
|
+
links: [{ nodeId: 'feature:sales.lead-gen', kind: 'operates-on' }],
|
|
57
|
+
category: 'production'
|
|
58
|
+
}
|
|
59
|
+
```
|
|
92
60
|
|
|
93
|
-
|
|
61
|
+
## Execution Types
|
|
62
|
+
|
|
63
|
+
| Type | Description |
|
|
64
|
+
| --- | --- |
|
|
65
|
+
| `WorkflowDefinition` | Complete workflow definition including config, contract, steps, and entryPoint |
|
|
66
|
+
| `WorkflowStep` | Individual step definition with type, handler, and next routing |
|
|
67
|
+
| `WorkflowConfig` | Metadata block: name, description, status, links, category |
|
|
68
|
+
| `StepHandler` | Function type: `(input: unknown, context: StepContext) => Promise<unknown>` |
|
|
69
|
+
| `NextConfig` | Union of `LinearNext` and `ConditionalNext` |
|
|
70
|
+
| `LinearNext` | Fixed next step routing |
|
|
71
|
+
| `ConditionalNext` | Branching step routing |
|
|
72
|
+
| `StepType` | Runtime enum for step routing |
|
|
73
|
+
| `AgentDefinition` | Complete agent definition including config, agentConfig, and tools |
|
|
74
|
+
| `ExecutionContext` | Runtime context passed to step handlers |
|
|
75
|
+
| `ExecutionMetadata` | Metadata about a running execution |
|
|
76
|
+
| `ExecutionInterface` | Interface for triggering and inspecting executions |
|
|
94
77
|
|
|
95
78
|
## ElevasConfig
|
|
96
79
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
```typescript
|
|
80
|
+
```ts
|
|
100
81
|
export interface ElevasConfig {
|
|
101
82
|
defaultStatus?: ResourceStatus
|
|
102
83
|
dev?: { port?: number }
|
|
103
84
|
}
|
|
104
85
|
```
|
|
105
86
|
|
|
106
|
-
| Field
|
|
107
|
-
|
|
|
108
|
-
| `defaultStatus` | `'dev' | 'prod'` | `'prod'` | Default status applied
|
|
109
|
-
| `dev.port`
|
|
110
|
-
|
|
111
|
-
Usage:
|
|
112
|
-
|
|
113
|
-
```typescript
|
|
114
|
-
import type { ElevasConfig } from '@elevasis/sdk';
|
|
115
|
-
|
|
116
|
-
const config: ElevasConfig = {
|
|
117
|
-
defaultStatus: 'dev',
|
|
118
|
-
dev: { port: 3002 },
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
export default config;
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
---
|
|
87
|
+
| Field | Type | Default | Description |
|
|
88
|
+
| --- | --- | --- | --- |
|
|
89
|
+
| `defaultStatus` | `'dev' | 'prod'` | `'prod'` | Default status applied when resources do not set `config.status` |
|
|
90
|
+
| `dev.port` | `number` | `3001` | Local worker development port |
|
|
125
91
|
|
|
126
92
|
## StepHandler Context
|
|
127
93
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
```typescript
|
|
131
|
-
import type { StepHandler, ExecutionContext } from '@elevasis/sdk';
|
|
94
|
+
```ts
|
|
95
|
+
import type { StepHandler, ExecutionContext } from '@elevasis/sdk'
|
|
132
96
|
|
|
133
97
|
const handler: StepHandler = async (input, context: ExecutionContext) => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
await store.set('checkpoint', JSON.stringify({ step: 'started' }));
|
|
139
|
-
|
|
140
|
-
return { done: true };
|
|
141
|
-
};
|
|
142
|
-
```
|
|
98
|
+
context.logger.info('Processing', {
|
|
99
|
+
executionId: context.executionId,
|
|
100
|
+
resourceId: context.resourceId
|
|
101
|
+
})
|
|
143
102
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
| Field | Type | Description |
|
|
147
|
-
| ---------------- | -------- | ----------------------------------------------------------------------------------------------------------------- |
|
|
148
|
-
| `executionId` | `string` | Unique identifier for this execution run |
|
|
149
|
-
| `organizationId` | `string` | Your organization identifier |
|
|
150
|
-
| `resourceId` | `string` | Identifier of the executing workflow or agent |
|
|
151
|
-
| `logger` | `Logger` | Structured logger -- messages appear in the Elevasis dashboard under the execution |
|
|
152
|
-
| `store` | `Store` | Key-value store scoped to the current execution. Useful for passing data between steps or checkpointing progress. |
|
|
153
|
-
|
|
154
|
-
---
|
|
155
|
-
|
|
156
|
-
## Runtime Values
|
|
157
|
-
|
|
158
|
-
Three runtime values are exported from `@elevasis/sdk` as JavaScript values (not just types). They are defined directly in the SDK package to avoid pulling in the full platform execution engine.
|
|
159
|
-
|
|
160
|
-
### StepType
|
|
161
|
-
|
|
162
|
-
An enum used to configure step routing in multi-step workflows.
|
|
163
|
-
|
|
164
|
-
```typescript
|
|
165
|
-
import { StepType } from '@elevasis/sdk';
|
|
166
|
-
|
|
167
|
-
// StepType.LINEAR -- fixed next step via { target: 'stepName' }
|
|
168
|
-
// StepType.CONDITIONAL -- branching via { type: 'conditional', routes: [...], default: 'stepName' }
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
### ToolingError
|
|
172
|
-
|
|
173
|
-
Thrown by platform tool calls when a tool fails. Use this class to distinguish tool failures from general errors in `try/catch` blocks.
|
|
174
|
-
|
|
175
|
-
```typescript
|
|
176
|
-
import { ToolingError } from '@elevasis/sdk';
|
|
177
|
-
|
|
178
|
-
try {
|
|
179
|
-
const result = await platform.call({ ... });
|
|
180
|
-
} catch (err) {
|
|
181
|
-
if (err instanceof ToolingError) {
|
|
182
|
-
// tool-specific failure -- check err.type for category
|
|
183
|
-
console.error('Tool failed:', err.type, err.message);
|
|
184
|
-
} else {
|
|
185
|
-
throw err; // re-throw unexpected errors
|
|
186
|
-
}
|
|
103
|
+
await context.store.set('checkpoint', JSON.stringify({ step: 'started' }))
|
|
104
|
+
return { done: true }
|
|
187
105
|
}
|
|
188
106
|
```
|
|
189
107
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
Represents a failure at the execution level (distinct from a tool-level failure). Throw this from a step handler to signal that the execution should be marked as failed with a structured error message.
|
|
108
|
+
## Runtime Values
|
|
193
109
|
|
|
194
|
-
|
|
195
|
-
import { ExecutionError } from '@elevasis/sdk';
|
|
110
|
+
Runtime exports include:
|
|
196
111
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
return { result: 'ok' };
|
|
202
|
-
};
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
---
|
|
112
|
+
- `StepType`
|
|
113
|
+
- `ToolingError`
|
|
114
|
+
- `ExecutionError`
|
|
206
115
|
|
|
207
|
-
|
|
116
|
+
Use `ToolingError` for platform adapter failures and `ExecutionError` for execution-level failures that should be surfaced in run history.
|