@contractspec/lib.contracts-spec 2.5.0 → 2.7.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.
@@ -29,8 +29,8 @@
29
29
  * }
30
30
  * ```
31
31
  */
32
- import type { WorkflowState, StepExecution } from './state';
33
- import type { WorkflowSpec, Step } from './spec';
32
+ import type { StepExecution, WorkflowState } from './state';
33
+ import type { Step, WorkflowSpec } from './spec';
34
34
  /**
35
35
  * Error thrown when a workflow operation fails.
36
36
  */
@@ -80,7 +80,7 @@ export interface WorkflowEvent {
80
80
  * Provides a simplified interface over WorkflowRunner for common
81
81
  * workflow operations like state access, transitions, and SLA tracking.
82
82
  */
83
- export interface WorkflowContext<TData = Record<string, unknown>> {
83
+ export interface WorkflowContext<TData extends Record<string, unknown> = Record<string, unknown>> {
84
84
  /** Unique workflow instance identifier. */
85
85
  readonly workflowId: string;
86
86
  /** Workflow spec key. */
@@ -99,13 +99,13 @@ export interface WorkflowContext<TData = Record<string, unknown>> {
99
99
  * Get the current workflow state.
100
100
  * @returns Full workflow state object
101
101
  */
102
- getState(): WorkflowState;
102
+ getState(): WorkflowState<TData>;
103
103
  /**
104
104
  * Get a value from workflow data.
105
105
  * @param key - Data key to retrieve
106
106
  * @returns Value or undefined
107
107
  */
108
- getData<T = unknown>(key: string): T | undefined;
108
+ getData<Key extends keyof TData>(key: Key): TData[Key] | undefined;
109
109
  /**
110
110
  * Check if workflow is in a terminal state.
111
111
  * @returns True if completed, failed, or cancelled
@@ -193,7 +193,7 @@ export interface WorkflowContext<TData = Record<string, unknown>> {
193
193
  * console.log('Available transitions:', ctx.getAvailableTransitions());
194
194
  * ```
195
195
  */
196
- export declare function createWorkflowContext<TData = Record<string, unknown>>(state: WorkflowState, spec: WorkflowSpec): WorkflowContext<TData>;
196
+ export declare function createWorkflowContext<TData extends Record<string, unknown> = Record<string, unknown>>(state: WorkflowState<TData>, spec: WorkflowSpec): WorkflowContext<TData>;
197
197
  /**
198
198
  * Calculate workflow progress as a percentage.
199
199
  *
@@ -8,12 +8,12 @@ export interface StepExecution {
8
8
  output?: unknown;
9
9
  error?: string;
10
10
  }
11
- export interface WorkflowState {
11
+ export interface WorkflowState<Data extends Record<string, unknown> = Record<string, unknown>> {
12
12
  workflowId: string;
13
13
  workflowName: string;
14
14
  workflowVersion: string;
15
15
  currentStep: string;
16
- data: Record<string, unknown>;
16
+ data: Data;
17
17
  retryCounts?: Record<string, number>;
18
18
  history: StepExecution[];
19
19
  status: WorkflowStatus;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contractspec/lib.contracts-spec",
3
- "version": "2.5.0",
3
+ "version": "2.7.0",
4
4
  "description": "Spec definitions and registries for ContractSpec",
5
5
  "keywords": [
6
6
  "contractspec",
@@ -28,8 +28,8 @@
28
28
  "registry:build": "bun run scripts/build-registry.ts"
29
29
  },
30
30
  "dependencies": {
31
- "@blocknote/core": "^0.46.1",
32
- "@contractspec/lib.schema": "2.5.0",
31
+ "@blocknote/core": "^0.47.0",
32
+ "@contractspec/lib.schema": "2.7.0",
33
33
  "compare-versions": "^6.1.1",
34
34
  "turndown": "^7.2.2",
35
35
  "zod": "^4.3.5"
@@ -38,8 +38,8 @@
38
38
  "react": "^19.2.4"
39
39
  },
40
40
  "devDependencies": {
41
- "@contractspec/tool.bun": "2.5.0",
42
- "@contractspec/tool.typescript": "2.5.0",
41
+ "@contractspec/tool.bun": "2.7.0",
42
+ "@contractspec/tool.typescript": "2.7.0",
43
43
  "@types/turndown": "^5.0.6",
44
44
  "typescript": "^5.9.3"
45
45
  },