UNPKG

2.21 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.dev/license
7 */
8import { schema, virtualFs } from '@angular-devkit/core';
9import { Observable, Subject } from 'rxjs';
10import { Engine, EngineHost } from '../engine';
11import { DryRunEvent } from '../sink/dryrun';
12import { Sink } from '../sink/sink';
13import { LifeCycleEvent, RequiredWorkflowExecutionContext, Workflow, WorkflowExecutionContext } from './interface';
14export interface BaseWorkflowOptions {
15 host: virtualFs.Host;
16 engineHost: EngineHost<{}, {}>;
17 registry?: schema.CoreSchemaRegistry;
18 force?: boolean;
19 dryRun?: boolean;
20}
21/**
22 * Base class for workflows. Even without abstract methods, this class should not be used without
23 * surrounding some initialization for the registry and host. This class only adds life cycle and
24 * dryrun/force support. You need to provide any registry and task executors that you need to
25 * support.
26 * See {@see NodeWorkflow} implementation for how to make a specialized subclass of this.
27 * TODO: add default set of CoreSchemaRegistry transforms. Once the job refactor is done, use that
28 * as the support for tasks.
29 *
30 * @public
31 */
32export declare abstract class BaseWorkflow implements Workflow {
33 protected _engine: Engine<{}, {}>;
34 protected _engineHost: EngineHost<{}, {}>;
35 protected _registry: schema.CoreSchemaRegistry;
36 protected _host: virtualFs.Host;
37 protected _reporter: Subject<DryRunEvent>;
38 protected _lifeCycle: Subject<LifeCycleEvent>;
39 protected _context: WorkflowExecutionContext[];
40 protected _force: boolean;
41 protected _dryRun: boolean;
42 constructor(options: BaseWorkflowOptions);
43 get context(): Readonly<WorkflowExecutionContext>;
44 get engine(): Engine<{}, {}>;
45 get engineHost(): EngineHost<{}, {}>;
46 get registry(): schema.SchemaRegistry;
47 get reporter(): Observable<DryRunEvent>;
48 get lifeCycle(): Observable<LifeCycleEvent>;
49 protected _createSinks(): Sink[];
50 execute(options: Partial<WorkflowExecutionContext> & RequiredWorkflowExecutionContext): Observable<void>;
51}