1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | import { analytics, logging } from '@angular-devkit/core';
|
10 | import { Observable } from 'rxjs';
|
11 | import { Url } from 'url';
|
12 | import { FileEntry, MergeStrategy, Tree } from '../tree/interface';
|
13 | import { Workflow } from '../workflow/interface';
|
14 | export interface TaskConfiguration<T = {}> {
|
15 | name: string;
|
16 | dependencies?: Array<TaskId>;
|
17 | options?: T;
|
18 | }
|
19 | export interface TaskConfigurationGenerator<T = {}> {
|
20 | toConfiguration(): TaskConfiguration<T>;
|
21 | }
|
22 | export declare type TaskExecutor<T = {}> = (options: T | undefined, context: SchematicContext) => Promise<void> | Observable<void>;
|
23 | export interface TaskExecutorFactory<T> {
|
24 | readonly name: string;
|
25 | create(options?: T): Promise<TaskExecutor> | Observable<TaskExecutor>;
|
26 | }
|
27 | export interface TaskId {
|
28 | readonly id: number;
|
29 | }
|
30 | export interface TaskInfo {
|
31 | readonly id: number;
|
32 | readonly priority: number;
|
33 | readonly configuration: TaskConfiguration;
|
34 | readonly context: SchematicContext;
|
35 | }
|
36 | export interface ExecutionOptions {
|
37 | scope: string;
|
38 | interactive: boolean;
|
39 | }
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 | export declare type CollectionDescription<CollectionMetadataT extends object> = CollectionMetadataT & {
|
46 | readonly name: string;
|
47 | readonly extends?: string[];
|
48 | };
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 | export declare type SchematicDescription<CollectionMetadataT extends object, SchematicMetadataT extends object> = SchematicMetadataT & {
|
55 | readonly collection: CollectionDescription<CollectionMetadataT>;
|
56 | readonly name: string;
|
57 | readonly private?: boolean;
|
58 | readonly hidden?: boolean;
|
59 | };
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 | export interface EngineHost<CollectionMetadataT extends object, SchematicMetadataT extends object> {
|
66 | createCollectionDescription(name: string, requester?: CollectionDescription<CollectionMetadataT>): CollectionDescription<CollectionMetadataT>;
|
67 | listSchematicNames(collection: CollectionDescription<CollectionMetadataT>): string[];
|
68 | createSchematicDescription(name: string, collection: CollectionDescription<CollectionMetadataT>): SchematicDescription<CollectionMetadataT, SchematicMetadataT> | null;
|
69 | getSchematicRuleFactory<OptionT extends object>(schematic: SchematicDescription<CollectionMetadataT, SchematicMetadataT>, collection: CollectionDescription<CollectionMetadataT>): RuleFactory<OptionT>;
|
70 | createSourceFromUrl(url: Url, context: TypedSchematicContext<CollectionMetadataT, SchematicMetadataT>): Source | null;
|
71 | transformOptions<OptionT extends object, ResultT extends object>(schematic: SchematicDescription<CollectionMetadataT, SchematicMetadataT>, options: OptionT, context?: TypedSchematicContext<CollectionMetadataT, SchematicMetadataT>): Observable<ResultT>;
|
72 | transformContext(context: TypedSchematicContext<CollectionMetadataT, SchematicMetadataT>): TypedSchematicContext<CollectionMetadataT, SchematicMetadataT> | void;
|
73 | createTaskExecutor(name: string): Observable<TaskExecutor>;
|
74 | hasTaskExecutor(name: string): boolean;
|
75 | readonly defaultMergeStrategy?: MergeStrategy;
|
76 | }
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 | export interface Engine<CollectionMetadataT extends object, SchematicMetadataT extends object> {
|
88 | createCollection(name: string, requester?: Collection<CollectionMetadataT, SchematicMetadataT>): Collection<CollectionMetadataT, SchematicMetadataT>;
|
89 | createContext(schematic: Schematic<CollectionMetadataT, SchematicMetadataT>, parent?: Partial<TypedSchematicContext<CollectionMetadataT, SchematicMetadataT>>, executionOptions?: Partial<ExecutionOptions>): TypedSchematicContext<CollectionMetadataT, SchematicMetadataT>;
|
90 | createSchematic(name: string, collection: Collection<CollectionMetadataT, SchematicMetadataT>): Schematic<CollectionMetadataT, SchematicMetadataT>;
|
91 | createSourceFromUrl(url: Url, context: TypedSchematicContext<CollectionMetadataT, SchematicMetadataT>): Source;
|
92 | transformOptions<OptionT extends object, ResultT extends object>(schematic: Schematic<CollectionMetadataT, SchematicMetadataT>, options: OptionT, context?: TypedSchematicContext<CollectionMetadataT, SchematicMetadataT>): Observable<ResultT>;
|
93 | executePostTasks(): Observable<void>;
|
94 | readonly defaultMergeStrategy: MergeStrategy;
|
95 | readonly workflow: Workflow | null;
|
96 | }
|
97 |
|
98 |
|
99 |
|
100 |
|
101 | export interface Collection<CollectionMetadataT extends object, SchematicMetadataT extends object> {
|
102 | readonly description: CollectionDescription<CollectionMetadataT>;
|
103 | readonly baseDescriptions?: Array<CollectionDescription<CollectionMetadataT>>;
|
104 | createSchematic(name: string, allowPrivate?: boolean): Schematic<CollectionMetadataT, SchematicMetadataT>;
|
105 | listSchematicNames(): string[];
|
106 | }
|
107 |
|
108 |
|
109 |
|
110 |
|
111 | export interface Schematic<CollectionMetadataT extends object, SchematicMetadataT extends object> {
|
112 | readonly description: SchematicDescription<CollectionMetadataT, SchematicMetadataT>;
|
113 | readonly collection: Collection<CollectionMetadataT, SchematicMetadataT>;
|
114 | call<OptionT extends object>(options: OptionT, host: Observable<Tree>, parentContext?: Partial<TypedSchematicContext<CollectionMetadataT, SchematicMetadataT>>, executionOptions?: Partial<ExecutionOptions>): Observable<Tree>;
|
115 | }
|
116 |
|
117 |
|
118 |
|
119 |
|
120 | export interface TypedSchematicContext<CollectionMetadataT extends object, SchematicMetadataT extends object> {
|
121 | readonly debug: boolean;
|
122 | readonly engine: Engine<CollectionMetadataT, SchematicMetadataT>;
|
123 | readonly logger: logging.LoggerApi;
|
124 | readonly schematic: Schematic<CollectionMetadataT, SchematicMetadataT>;
|
125 | readonly strategy: MergeStrategy;
|
126 | readonly interactive: boolean;
|
127 | addTask<T>(task: TaskConfigurationGenerator<T>, dependencies?: Array<TaskId>): TaskId;
|
128 |
|
129 | readonly analytics?: analytics.Analytics;
|
130 | }
|
131 |
|
132 |
|
133 |
|
134 |
|
135 | export declare type SchematicContext = TypedSchematicContext<{}, {}>;
|
136 |
|
137 |
|
138 |
|
139 |
|
140 | export declare type RuleFactory<T extends object> = (options: T) => Rule;
|
141 |
|
142 |
|
143 |
|
144 |
|
145 | export declare type FileOperator = (entry: FileEntry) => FileEntry | null;
|
146 | export declare type AsyncFileOperator = (tree: FileEntry) => Observable<FileEntry | null>;
|
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 | export declare type Source = (context: SchematicContext) => Tree | Observable<Tree>;
|
157 | export declare type Rule = (tree: Tree, context: SchematicContext) => Tree | Observable<Tree> | Rule | Promise<void | Rule> | void;
|