or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

file-system-actions.mdindex.mdnode-tools.mdoutput-sinks.mdrule-system.mdschematic-engine.mdtemplate-engine.mdtree-operations.mdworkflow.md
tile.json

workflow.mddocs/

Workflow System

The workflow system provides high-level orchestration for schematic execution with lifecycle management, error handling, and context propagation. It serves as the primary interface for coordinating complex schematic operations with multiple collections and schematics.

Capabilities

Workflow Interface

Core workflow interface for executing schematics with full lifecycle management.

/**
 * Main workflow interface for orchestrating schematic execution
 */
interface Workflow {
  readonly context: Readonly<WorkflowExecutionContext>;
  
  /** Execute a schematic with the given context */
  execute(
    options: Partial<WorkflowExecutionContext> & RequiredWorkflowExecutionContext
  ): Observable<void>;
}

/**
 * Required execution context for workflow operations
 */
interface RequiredWorkflowExecutionContext {
  collection: string;
  schematic: string;
  options: object;
}

/**
 * Complete execution context with optional fields
 */
interface WorkflowExecutionContext extends RequiredWorkflowExecutionContext {
  debug: boolean;
  logger: logging.Logger;
  parentContext?: Readonly<WorkflowExecutionContext>;
  allowPrivate?: boolean;
}

Base Workflow Implementation

Abstract base class for implementing custom workflows.

/**
 * Configuration options for base workflow
 */
interface BaseWorkflowOptions {
  host: virtualFs.Host;
  engineHost: EngineHost<{}, {}>;
  registry?: schema.CoreSchemaRegistry;
  force?: boolean;
  dryRun?: boolean;
}

/**
 * Abstract base workflow with common functionality
 */
abstract class BaseWorkflow implements Workflow {
  constructor(options: BaseWorkflowOptions);
  
  readonly context: Readonly<WorkflowExecutionContext>;
  readonly engine: Engine<{}, {}>;
  readonly engineHost: EngineHost<{}, {}>;
  readonly registry: schema.SchemaRegistry;
  readonly reporter: Observable<DryRunEvent>;
  readonly lifeCycle: Observable<LifeCycleEvent>;
  
  execute(
    options: Partial<WorkflowExecutionContext> & RequiredWorkflowExecutionContext
  ): Observable<void>;
}

Lifecycle Events

Events emitted during workflow execution for monitoring and debugging.

/**
 * Lifecycle events emitted during workflow execution
 */
interface LifeCycleEvent {
  kind: 'start' | 'end' | 'workflow-start' | 'workflow-end' | 'post-tasks-start' | 'post-tasks-end';
}

Usage Examples:

import { BaseWorkflow, BaseWorkflowOptions } from "@angular-devkit/schematics";
import { virtualFs, logging } from "@angular-devkit/core";

// Create a custom workflow
class CustomWorkflow extends BaseWorkflow {
  constructor(options: BaseWorkflowOptions) {
    super(options);
    
    // Subscribe to lifecycle events
    this.lifeCycle.subscribe(event => {
      console.log(`Workflow event: ${event.kind}`);
    });
  }
}

// Execute a schematic through workflow
const workflow = new CustomWorkflow({
  host: new virtualFs.SimpleMemoryHost(),
  engineHost: new FileSystemEngineHost()
});

workflow.execute({
  collection: '@schematics/angular',
  schematic: 'component',
  options: { name: 'my-component' },
  debug: false,
  logger: new logging.NullLogger()
}).subscribe({
  next: () => console.log('Schematic executed successfully'),
  error: (err) => console.error('Execution failed:', err)
});

Workflow Exceptions

/**
 * Exception thrown when workflow execution fails
 */
class UnsuccessfulWorkflowExecution extends BaseException {
  constructor(message?: string);
}

Types

Context Types

type ExecutionOptions = {
  scope?: string;
  interactive?: boolean;
};