oxify-model 0.1.0

Data models and types for OxiFY workflows, execution, and configuration
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
//! TypeScript type definitions generator for OxiFY Model
//!
//! This module provides TypeScript type definitions for use with JavaScript/TypeScript
//! applications. It generates `.d.ts` files that provide type safety when working with
//! OxiFY workflows in TypeScript projects.
//!
//! # Features
//!
//! - Generate TypeScript interfaces from Rust types
//! - Full type coverage for workflows, nodes, edges, and execution types
//! - Compatible with the WASM bindings
//!
//! # Usage
//!
//! ```
//! use oxify_model::typescript::generate_typescript_definitions;
//!
//! let definitions = generate_typescript_definitions();
//! assert!(definitions.contains("interface Workflow"));
//! assert!(definitions.contains("interface Node"));
//! assert!(definitions.contains("interface Edge"));
//! // In production, save to file:
//! // std::fs::write("oxify-model.d.ts", definitions).unwrap();
//! ```

/// Generate complete TypeScript type definitions for OxiFY Model
///
/// Returns a string containing all TypeScript interface and type definitions
/// that can be saved to a `.d.ts` file.
pub fn generate_typescript_definitions() -> String {
    let mut output = String::new();

    output.push_str(HEADER);
    output.push_str(WORKFLOW_TYPES);
    output.push_str(NODE_TYPES);
    output.push_str(EDGE_TYPES);
    output.push_str(EXECUTION_TYPES);
    output.push_str(CONFIG_TYPES);
    output.push_str(UTILITY_TYPES);
    output.push_str(WASM_BINDINGS);

    output
}

const HEADER: &str = r#"/**
 * OxiFY Model - TypeScript Type Definitions
 *
 * Auto-generated TypeScript definitions for OxiFY workflow models.
 * These types are compatible with the WASM bindings provided by oxify-model.
 *
 * @version 0.1.0
 * @generated
 */

"#;

const WORKFLOW_TYPES: &str = r#"// ============================================================================
// Workflow Types
// ============================================================================

/** UUID string type for unique identifiers */
export type UUID = string;

/** ISO 8601 date-time string */
export type DateTime = string;

/** Unique identifier for a workflow */
export type WorkflowId = UUID;

/** Unique identifier for a node */
export type NodeId = UUID;

/** Unique identifier for an edge */
export type EdgeId = UUID;

/** Metadata about a workflow */
export interface WorkflowMetadata {
  /** Unique workflow identifier */
  id: WorkflowId;
  /** Display name */
  name: string;
  /** Description of what this workflow does */
  description?: string;
  /** Version string (semantic versioning) */
  version: string;
  /** When the workflow was created */
  created_at: DateTime;
  /** When the workflow was last modified */
  updated_at: DateTime;
  /** Tags for categorization */
  tags: string[];
  /** Parent workflow ID (for versioning) */
  parent_id?: WorkflowId;
  /** Change description for this version */
  change_description?: string;
  /** Scheduling configuration */
  schedule?: WorkflowSchedule;
}

/** Workflow scheduling configuration */
export interface WorkflowSchedule {
  /** Cron expression for scheduling */
  cron: string;
  /** Timezone (e.g., "UTC", "America/New_York") */
  timezone?: string;
  /** Whether the schedule is enabled */
  enabled: boolean;
}

/** Version bump type */
export type VersionBump = "major" | "minor" | "patch";

/** Complete workflow definition */
export interface Workflow {
  /** Workflow metadata */
  metadata: WorkflowMetadata;
  /** Nodes in the workflow DAG */
  nodes: Node[];
  /** Edges connecting nodes */
  edges: Edge[];
}

"#;

const NODE_TYPES: &str = r#"// ============================================================================
// Node Types
// ============================================================================

/** Node in the workflow DAG */
export interface Node {
  /** Unique node identifier */
  id: NodeId;
  /** Display name of the node */
  name: string;
  /** Type and configuration of the node */
  kind: NodeKind;
  /** Position in the visual editor */
  position?: [number, number];
  /** Retry configuration */
  retry_config?: RetryConfig;
  /** Timeout configuration */
  timeout_config?: TimeoutConfig;
}

/** Retry configuration for nodes */
export interface RetryConfig {
  /** Maximum number of retry attempts */
  max_retries: number;
  /** Initial delay before first retry in milliseconds */
  initial_delay_ms: number;
  /** Backoff multiplier for exponential backoff */
  backoff_multiplier: number;
  /** Maximum delay between retries in milliseconds */
  max_delay_ms: number;
}

/** Timeout configuration for nodes */
export interface TimeoutConfig {
  /** Maximum execution time in milliseconds */
  execution_timeout_ms: number;
  /** Idle timeout in milliseconds */
  idle_timeout_ms?: number;
  /** Action to take on timeout */
  timeout_action: TimeoutAction;
}

/** Action to take when a timeout occurs */
export type TimeoutAction = "Fail" | "Skip" | "UseDefault";

/** Node kind discriminated union */
export type NodeKind =
  | { Start: {} }
  | { End: {} }
  | { LlmCall: LlmConfig }
  | { Retriever: VectorConfig }
  | { CodeExecution: ScriptConfig }
  | { IfElse: Condition }
  | { Switch: SwitchConfig }
  | { Tool: McpConfig }
  | { Loop: LoopConfig }
  | { TryCatch: TryCatchConfig }
  | { SubWorkflow: SubWorkflowConfig }
  | { Parallel: ParallelConfig }
  | { Approval: ApprovalConfig }
  | { Form: FormConfig };

/** LLM call configuration */
export interface LlmConfig {
  /** LLM provider (e.g., "openai", "anthropic", "ollama") */
  provider: string;
  /** Model name (e.g., "gpt-4", "claude-3-opus") */
  model: string;
  /** System prompt template */
  system_prompt?: string;
  /** User prompt template with {{variable}} placeholders */
  prompt_template: string;
  /** Temperature for sampling (0.0 - 2.0) */
  temperature?: number;
  /** Maximum tokens to generate */
  max_tokens?: number;
  /** Stop sequences */
  stop_sequences?: string[];
  /** Response format (json, text) */
  response_format?: string;
}

/** Vector database configuration */
export interface VectorConfig {
  /** Database type (e.g., "qdrant", "pgvector") */
  db_type: string;
  /** Collection name */
  collection: string;
  /** Query template */
  query: string;
  /** Number of results to return */
  top_k: number;
  /** Minimum similarity score threshold */
  score_threshold?: number;
  /** Embedding model to use */
  embedding_model?: string;
}

/** Script execution configuration */
export interface ScriptConfig {
  /** Runtime environment */
  runtime: "rhai" | "wasm";
  /** Script code */
  code: string;
  /** Input variable mappings */
  input_mapping?: Record<string, string>;
  /** Output variable name */
  output_variable?: string;
}

/** Conditional node configuration */
export interface Condition {
  /** Boolean expression to evaluate */
  expression: string;
  /** Node ID for true branch */
  true_branch: NodeId;
  /** Node ID for false branch */
  false_branch: NodeId;
}

/** Switch/case configuration */
export interface SwitchConfig {
  /** Expression to switch on */
  switch_on: string;
  /** Case definitions */
  cases: SwitchCase[];
  /** Default case action */
  default_case?: string;
}

/** Single switch case */
export interface SwitchCase {
  /** Value to match */
  match_value: string;
  /** Action expression or node to execute */
  action: string;
}

/** MCP tool configuration */
export interface McpConfig {
  /** MCP server ID */
  server_id: string;
  /** Tool name */
  tool_name: string;
  /** Tool arguments template */
  arguments_template?: string;
}

/** Loop configuration */
export interface LoopConfig {
  /** Type of loop */
  loop_type: LoopType;
  /** Maximum iterations (safety limit) */
  max_iterations: number;
  /** Body expression to execute */
  body: string;
}

/** Loop type variants */
export type LoopType =
  | { ForEach: ForEachLoop }
  | { While: WhileLoop }
  | { Repeat: RepeatLoop };

/** ForEach loop configuration */
export interface ForEachLoop {
  /** Path to collection to iterate over */
  collection_path: string;
  /** Variable name for current item */
  item_variable: string;
  /** Variable name for current index */
  index_variable?: string;
  /** Body expression */
  body_expression: string;
  /** Enable parallel execution of loop iterations */
  parallel: boolean;
  /** Maximum number of concurrent iterations (only used when parallel=true) */
  max_concurrency?: number;
}

/** While loop configuration */
export interface WhileLoop {
  /** Condition expression */
  condition: string;
  /** Body expression */
  body_expression: string;
}

/** Repeat loop configuration */
export interface RepeatLoop {
  /** Number of times to repeat */
  count: number;
  /** Body expression */
  body_expression: string;
}

/** Try-catch configuration */
export interface TryCatchConfig {
  /** Node ID to try */
  try_node: NodeId;
  /** Node ID for catch handler */
  catch_node?: NodeId;
  /** Node ID for finally handler */
  finally_node?: NodeId;
  /** Variable name for error */
  error_variable?: string;
  /** Whether to rethrow after catch */
  rethrow?: boolean;
}

/** Sub-workflow configuration */
export interface SubWorkflowConfig {
  /** Path to sub-workflow file */
  workflow_path: string;
  /** Input variable mappings */
  input_mappings?: Record<string, string>;
  /** Output variable mappings */
  output_mappings?: Record<string, string>;
  /** Whether to inherit parent context */
  inherit_context?: boolean;
}

/** Parallel execution configuration */
export interface ParallelConfig {
  /** Tasks to execute in parallel */
  tasks: ParallelTask[];
  /** Execution strategy */
  strategy: ParallelStrategy;
  /** Timeout in milliseconds */
  timeout_ms?: number;
  /** Maximum concurrent tasks */
  max_concurrency?: number;
}

/** Single parallel task */
export interface ParallelTask {
  /** Task identifier */
  id: string;
  /** Expression to execute */
  expression: string;
}

/** Parallel execution strategy */
export type ParallelStrategy = "WaitAll" | "Race" | "AllSettled";

/** Approval node configuration */
export interface ApprovalConfig {
  /** Message to display for approval */
  message: string;
  /** Detailed description */
  description?: string;
  /** Required approvers (user IDs or roles) */
  required_approvers?: string[];
  /** Timeout in milliseconds */
  timeout_ms?: number;
  /** Context data for approval UI */
  context_data?: Record<string, unknown>;
}

/** Form node configuration */
export interface FormConfig {
  /** Form title */
  title: string;
  /** Form description */
  description?: string;
  /** Form fields */
  fields: FormField[];
  /** Submit button label */
  submit_label?: string;
  /** Allowed submitters */
  allowed_submitters?: string[];
  /** Timeout in milliseconds */
  timeout_ms?: number;
}

/** Form field definition */
export interface FormField {
  /** Field identifier */
  id: string;
  /** Field label */
  label: string;
  /** Field type */
  field_type: FormFieldType;
  /** Whether field is required */
  required: boolean;
  /** Default value */
  default_value?: unknown;
  /** Placeholder text */
  placeholder?: string;
  /** Help text */
  help_text?: string;
  /** Validation pattern (regex) */
  validation_pattern?: string;
  /** Options for select/radio fields */
  options?: string[];
}

/** Form field types */
export type FormFieldType =
  | "Text"
  | "Number"
  | "Email"
  | "Password"
  | "TextArea"
  | "Select"
  | "MultiSelect"
  | "Radio"
  | "Checkbox"
  | "Date"
  | "DateTime";

"#;

const EDGE_TYPES: &str = r#"// ============================================================================
// Edge Types
// ============================================================================

/** Edge connecting two nodes */
export interface Edge {
  /** Unique edge identifier */
  id: EdgeId;
  /** Source node ID */
  from: NodeId;
  /** Target node ID */
  to: NodeId;
  /** Condition for conditional edges */
  condition?: string;
  /** Edge label */
  label?: string;
}

"#;

const EXECUTION_TYPES: &str = r#"// ============================================================================
// Execution Types
// ============================================================================

/** Execution state */
export type ExecutionState =
  | "Pending"
  | "Running"
  | "Completed"
  | "Failed"
  | "Cancelled"
  | "Paused";

/** Unique identifier for an execution */
export type ExecutionId = UUID;

/** Execution context variables */
export type ExecutionContext = Record<string, unknown>;

/** Node execution result */
export interface NodeExecutionResult {
  /** Node ID */
  node_id: NodeId;
  /** Execution state */
  state: ExecutionState;
  /** Output value */
  output?: unknown;
  /** Error message if failed */
  error?: string;
  /** Execution duration in milliseconds */
  duration_ms?: number;
  /** Token usage for LLM nodes */
  token_usage?: TokenUsage;
  /** Number of retry attempts */
  retry_count?: number;
}

/** Token usage for LLM calls */
export interface TokenUsage {
  /** Input tokens */
  input_tokens: number;
  /** Output tokens */
  output_tokens: number;
  /** Total tokens */
  total_tokens: number;
}

/** Complete execution result */
export interface ExecutionResult {
  /** Execution ID */
  id: ExecutionId;
  /** Workflow ID */
  workflow_id: WorkflowId;
  /** Overall state */
  state: ExecutionState;
  /** Started at timestamp */
  started_at: DateTime;
  /** Completed at timestamp */
  completed_at?: DateTime;
  /** Node results */
  node_results: Record<string, NodeExecutionResult>;
  /** Final context */
  context: ExecutionContext;
  /** Total duration in milliseconds */
  duration_ms?: number;
  /** Total cost in USD */
  cost_usd?: number;
}

"#;

const CONFIG_TYPES: &str = r#"// ============================================================================
// Configuration Types
// ============================================================================

/** Cost estimate for a workflow */
export interface CostEstimate {
  /** Total estimated cost in USD */
  total_cost_usd: number;
  /** Cost breakdown by node */
  node_costs: NodeCost[];
  /** Cost breakdown by category */
  category_costs: CategoryCosts;
  /** Token estimates */
  token_estimates: TokenEstimates;
}

/** Cost for a single node */
export interface NodeCost {
  /** Node ID */
  node_id: NodeId;
  /** Node name */
  node_name: string;
  /** Estimated cost in USD */
  cost_usd: number;
  /** Cost components */
  components: CostComponent[];
}

/** Cost component */
export interface CostComponent {
  /** Component name */
  name: string;
  /** Cost in USD */
  cost_usd: number;
  /** Quantity */
  quantity?: number;
  /** Unit */
  unit?: string;
}

/** Costs by category */
export interface CategoryCosts {
  /** LLM costs */
  llm: number;
  /** Vector search costs */
  vector: number;
  /** Tool/API costs */
  tool: number;
  /** Other costs */
  other: number;
}

/** Token estimates */
export interface TokenEstimates {
  /** Estimated input tokens */
  input_tokens: number;
  /** Estimated output tokens */
  output_tokens: number;
  /** Total estimated tokens */
  total_tokens: number;
}

/** Time estimate for a workflow */
export interface TimeEstimate {
  /** Total estimated time in milliseconds */
  total_ms: number;
  /** Time per node */
  node_times: NodeTime[];
  /** Critical path */
  critical_path: NodeId[];
  /** Estimated parallel speedup factor */
  parallel_speedup: number;
}

/** Time estimate for a single node */
export interface NodeTime {
  /** Node ID */
  node_id: NodeId;
  /** Node name */
  node_name: string;
  /** Estimated time in milliseconds */
  estimated_ms: number;
  /** Minimum time in milliseconds */
  min_ms?: number;
  /** Maximum time in milliseconds */
  max_ms?: number;
}

"#;

const UTILITY_TYPES: &str = r#"// ============================================================================
// Utility Types
// ============================================================================

/** Validation error */
export interface ValidationError {
  /** Error code */
  code: string;
  /** Error message */
  message: string;
  /** Related node ID */
  node_id?: NodeId;
  /** Related field */
  field?: string;
}

/** Validation report */
export interface ValidationReport {
  /** Whether validation passed */
  is_valid: boolean;
  /** Validation errors */
  errors: ValidationError[];
  /** Validation warnings */
  warnings: ValidationError[];
  /** Validation statistics */
  stats: ValidationStats;
}

/** Validation statistics */
export interface ValidationStats {
  /** Number of nodes */
  node_count: number;
  /** Number of edges */
  edge_count: number;
  /** Workflow depth */
  max_depth: number;
  /** Has cycles */
  has_cycles: boolean;
}

"#;

const WASM_BINDINGS: &str = r#"// ============================================================================
// WASM Bindings
// ============================================================================

/**
 * WASM-based workflow manipulation.
 * Use with oxify-model compiled with `wasm-pack build --features wasm`
 */
export interface WasmWorkflow {
  /** Get workflow as JSON string */
  to_json(): string;
  /** Get workflow as YAML string */
  to_yaml(): string;
  /** Get workflow ID */
  id(): string;
  /** Get workflow name */
  name(): string;
  /** Get workflow version */
  version(): string;
  /** Get node count */
  node_count(): number;
  /** Get edge count */
  edge_count(): number;
  /** Validate workflow */
  validate(): string;
}

/**
 * Fluent builder for creating workflows.
 */
export interface WasmWorkflowBuilder {
  /** Set workflow description */
  description(desc: string): WasmWorkflowBuilder;
  /** Set workflow version */
  version(version: string): WasmWorkflowBuilder;
  /** Add a tag */
  tag(tag: string): WasmWorkflowBuilder;
  /** Add start node */
  start_node(name: string): WasmWorkflowBuilder;
  /** Add end node */
  end_node(name: string): WasmWorkflowBuilder;
  /** Add LLM node */
  llm_node(name: string, provider: string, model: string, prompt: string): WasmWorkflowBuilder;
  /** Add code node */
  code_node(name: string, code: string): WasmWorkflowBuilder;
  /** Add retriever node */
  retriever_node(name: string, db_type: string, collection: string, query: string, top_k: number): WasmWorkflowBuilder;
  /** Add if-else node */
  if_else_node(name: string, expression: string, true_branch: string, false_branch: string): WasmWorkflowBuilder;
  /** Add switch node */
  switch_node(name: string, expression: string): WasmWorkflowBuilder;
  /** Add tool node */
  tool_node(name: string, server_id: string, tool_name: string): WasmWorkflowBuilder;
  /** Add foreach loop node */
  foreach_node(name: string, collection_path: string, item_var: string, body: string): WasmWorkflowBuilder;
  /** Add while loop node */
  while_node(name: string, condition: string, body: string, max_iterations: number): WasmWorkflowBuilder;
  /** Add repeat loop node */
  repeat_node(name: string, count: number, body: string): WasmWorkflowBuilder;
  /** Connect two nodes */
  connect(from_name: string, to_name: string): WasmWorkflowBuilder;
  /** Build the workflow */
  build(): WasmWorkflow;
}

/**
 * Utility functions for working with workflows.
 */
export interface WasmWorkflowUtils {
  /** Generate a new UUID */
  generate_uuid(): string;
  /** Convert JSON to YAML */
  json_to_yaml(json: string): string;
  /** Convert YAML to JSON */
  yaml_to_json(yaml: string): string;
}

/** Create a new workflow from JSON */
export function workflow_from_json(json: string): WasmWorkflow;

/** Create a new workflow from YAML */
export function workflow_from_yaml(yaml: string): WasmWorkflow;

/** Create a new workflow builder */
export function new_workflow_builder(name: string): WasmWorkflowBuilder;

/** Get workflow utilities */
export function workflow_utils(): WasmWorkflowUtils;
"#;

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_generate_typescript_definitions() {
        let definitions = generate_typescript_definitions();
        assert!(!definitions.is_empty());
        assert!(definitions.contains("export interface Workflow"));
        assert!(definitions.contains("export interface Node"));
        assert!(definitions.contains("export interface Edge"));
        assert!(definitions.contains("export type NodeKind"));
        assert!(definitions.contains("export interface LlmConfig"));
        assert!(definitions.contains("export interface VectorConfig"));
    }

    #[test]
    fn test_definitions_contain_all_node_types() {
        let definitions = generate_typescript_definitions();
        assert!(definitions.contains("LlmCall"));
        assert!(definitions.contains("Retriever"));
        assert!(definitions.contains("CodeExecution"));
        assert!(definitions.contains("IfElse"));
        assert!(definitions.contains("Switch"));
        assert!(definitions.contains("Loop"));
        assert!(definitions.contains("TryCatch"));
        assert!(definitions.contains("SubWorkflow"));
        assert!(definitions.contains("Parallel"));
        assert!(definitions.contains("Approval"));
        assert!(definitions.contains("Form"));
    }

    #[test]
    fn test_definitions_contain_execution_types() {
        let definitions = generate_typescript_definitions();
        assert!(definitions.contains("ExecutionState"));
        assert!(definitions.contains("ExecutionResult"));
        assert!(definitions.contains("NodeExecutionResult"));
        assert!(definitions.contains("TokenUsage"));
    }

    #[test]
    fn test_definitions_contain_wasm_bindings() {
        let definitions = generate_typescript_definitions();
        assert!(definitions.contains("WasmWorkflow"));
        assert!(definitions.contains("WasmWorkflowBuilder"));
        assert!(definitions.contains("WasmWorkflowUtils"));
        assert!(definitions.contains("workflow_from_json"));
        assert!(definitions.contains("new_workflow_builder"));
    }

    #[test]
    fn test_definitions_contain_config_types() {
        let definitions = generate_typescript_definitions();
        assert!(definitions.contains("CostEstimate"));
        assert!(definitions.contains("TimeEstimate"));
        assert!(definitions.contains("ValidationReport"));
    }

    #[test]
    fn test_definitions_valid_typescript_syntax() {
        let definitions = generate_typescript_definitions();
        // Check for proper TypeScript syntax patterns
        assert!(definitions.contains("export interface"));
        assert!(definitions.contains("export type"));
        assert!(definitions.contains(": string"));
        assert!(definitions.contains(": number"));
        assert!(definitions.contains("?: ")); // Optional fields
        assert!(definitions.contains("Record<")); // Generic types
    }
}