6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
9
- import { analytics , experimental , json , logging } from '@angular-devkit/core' ;
9
+ import { analytics , json , logging } from '@angular-devkit/core' ;
10
10
import { Observable , from , merge , of , onErrorResumeNext } from 'rxjs' ;
11
11
import {
12
12
concatMap ,
@@ -28,6 +28,20 @@ import {
28
28
targetStringFromTarget ,
29
29
} from './api' ;
30
30
import { ArchitectHost , BuilderDescription , BuilderJobHandler } from './internal' ;
31
+ import {
32
+ FallbackRegistry ,
33
+ JobHandler ,
34
+ JobHandlerContext ,
35
+ JobInboundMessage ,
36
+ JobInboundMessageKind ,
37
+ JobName ,
38
+ JobOutboundMessageKind ,
39
+ Registry ,
40
+ Scheduler ,
41
+ SimpleJobRegistry ,
42
+ SimpleScheduler ,
43
+ createJobHandler ,
44
+ } from './jobs' ;
31
45
import { scheduleByName , scheduleByTarget } from './schedule-by-name' ;
32
46
33
47
const inputSchema = require ( './input-schema.json' ) ;
@@ -48,11 +62,11 @@ function _createJobHandlerFromBuilderInfo(
48
62
info,
49
63
} ;
50
64
51
- function handler ( argument : json . JsonObject , context : experimental . jobs . JobHandlerContext ) {
65
+ function handler ( argument : json . JsonObject , context : JobHandlerContext ) {
52
66
// Add input validation to the inbound bus.
53
67
const inboundBusWithInputValidation = context . inboundBus . pipe (
54
68
concatMap ( ( message ) => {
55
- if ( message . kind === experimental . jobs . JobInboundMessageKind . Input ) {
69
+ if ( message . kind === JobInboundMessageKind . Input ) {
56
70
const v = message . value as BuilderInput ;
57
71
const options = {
58
72
...baseOptions ,
@@ -73,7 +87,7 @@ function _createJobHandlerFromBuilderInfo(
73
87
map ( ( value ) => ( { ...message , value } ) ) ,
74
88
) ;
75
89
} else {
76
- return of ( message as experimental . jobs . JobInboundMessage < BuilderInput > ) ;
90
+ return of ( message as JobInboundMessage < BuilderInput > ) ;
77
91
}
78
92
} ) ,
79
93
// Using a share replay because the job might be synchronously sending input, but
@@ -93,7 +107,7 @@ function _createJobHandlerFromBuilderInfo(
93
107
94
108
return builder . handler ( argument , { ...context , inboundBus } ) . pipe (
95
109
map ( ( output ) => {
96
- if ( output . kind === experimental . jobs . JobOutboundMessageKind . Output ) {
110
+ if ( output . kind === JobOutboundMessageKind . Output ) {
97
111
// Add target to it.
98
112
return {
99
113
...output ,
@@ -198,7 +212,7 @@ class ArchitectBuilderJobRegistry implements BuilderRegistry {
198
212
199
213
get < A extends json . JsonObject , I extends BuilderInput , O extends BuilderOutput > (
200
214
name : string ,
201
- ) : Observable < experimental . jobs . JobHandler < A , I , O > | null > {
215
+ ) : Observable < JobHandler < A , I , O > | null > {
202
216
const m = name . match ( / ^ ( [ ^ : ] + ) : ( [ ^ : ] + ) $ / i) ;
203
217
if ( ! m ) {
204
218
return of ( null ) ;
@@ -207,7 +221,7 @@ class ArchitectBuilderJobRegistry implements BuilderRegistry {
207
221
return from ( this . _resolveBuilder ( name ) ) . pipe (
208
222
concatMap ( ( builderInfo ) => ( builderInfo ? this . _createBuilder ( builderInfo ) : of ( null ) ) ) ,
209
223
first ( null , null ) ,
210
- ) as Observable < experimental . jobs . JobHandler < A , I , O > | null > ;
224
+ ) as Observable < JobHandler < A , I , O > | null > ;
211
225
}
212
226
}
213
227
@@ -217,7 +231,7 @@ class ArchitectBuilderJobRegistry implements BuilderRegistry {
217
231
class ArchitectTargetJobRegistry extends ArchitectBuilderJobRegistry {
218
232
override get < A extends json . JsonObject , I extends BuilderInput , O extends BuilderOutput > (
219
233
name : string ,
220
- ) : Observable < experimental . jobs . JobHandler < A , I , O > | null > {
234
+ ) : Observable < JobHandler < A , I , O > | null > {
221
235
const m = name . match ( / ^ { ( [ ^ : ] + ) : ( [ ^ : ] + ) (?: : ( [ ^ : ] * ) ) ? } $ / i) ;
222
236
if ( ! m ) {
223
237
return of ( null ) ;
@@ -251,12 +265,12 @@ class ArchitectTargetJobRegistry extends ArchitectBuilderJobRegistry {
251
265
) ;
252
266
} ) ,
253
267
first ( null , null ) ,
254
- ) as Observable < experimental . jobs . JobHandler < A , I , O > | null > ;
268
+ ) as Observable < JobHandler < A , I , O > | null > ;
255
269
}
256
270
}
257
271
258
272
function _getTargetOptionsFactory ( host : ArchitectHost ) {
259
- return experimental . jobs . createJobHandler < Target , json . JsonValue , json . JsonObject > (
273
+ return createJobHandler < Target , json . JsonValue , json . JsonObject > (
260
274
( target ) => {
261
275
return host . getOptionsForTarget ( target ) . then ( ( options ) => {
262
276
if ( options === null ) {
@@ -275,7 +289,7 @@ function _getTargetOptionsFactory(host: ArchitectHost) {
275
289
}
276
290
277
291
function _getProjectMetadataFactory ( host : ArchitectHost ) {
278
- return experimental . jobs . createJobHandler < Target , json . JsonValue , json . JsonObject > (
292
+ return createJobHandler < Target , json . JsonValue , json . JsonObject > (
279
293
( target ) => {
280
294
return host . getProjectMetadata ( target ) . then ( ( options ) => {
281
295
if ( options === null ) {
@@ -296,7 +310,7 @@ function _getProjectMetadataFactory(host: ArchitectHost) {
296
310
}
297
311
298
312
function _getBuilderNameForTargetFactory ( host : ArchitectHost ) {
299
- return experimental . jobs . createJobHandler < Target , never , string > (
313
+ return createJobHandler < Target , never , string > (
300
314
async ( target ) => {
301
315
const builderName = await host . getBuilderNameForTarget ( target ) ;
302
316
if ( ! builderName ) {
@@ -314,7 +328,7 @@ function _getBuilderNameForTargetFactory(host: ArchitectHost) {
314
328
}
315
329
316
330
function _validateOptionsFactory ( host : ArchitectHost , registry : json . schema . SchemaRegistry ) {
317
- return experimental . jobs . createJobHandler < [ string , json . JsonObject ] , never , json . JsonObject > (
331
+ return createJobHandler < [ string , json . JsonObject ] , never , json . JsonObject > (
318
332
async ( [ builderName , options ] ) => {
319
333
// Get option schema from the host.
320
334
const builderInfo = await host . resolveBuilder ( builderName ) ;
@@ -348,33 +362,33 @@ function _validateOptionsFactory(host: ArchitectHost, registry: json.schema.Sche
348
362
}
349
363
350
364
export class Architect {
351
- private readonly _scheduler : experimental . jobs . Scheduler ;
365
+ private readonly _scheduler : Scheduler ;
352
366
private readonly _jobCache = new Map < string , Observable < BuilderJobHandler > > ( ) ;
353
367
private readonly _infoCache = new Map < string , Observable < BuilderInfo > > ( ) ;
354
368
355
369
constructor (
356
370
private _host : ArchitectHost ,
357
371
registry : json . schema . SchemaRegistry = new json . schema . CoreSchemaRegistry ( ) ,
358
- additionalJobRegistry ?: experimental . jobs . Registry ,
372
+ additionalJobRegistry ?: Registry ,
359
373
) {
360
- const privateArchitectJobRegistry = new experimental . jobs . SimpleJobRegistry ( ) ;
374
+ const privateArchitectJobRegistry = new SimpleJobRegistry ( ) ;
361
375
// Create private jobs.
362
376
privateArchitectJobRegistry . register ( _getTargetOptionsFactory ( _host ) ) ;
363
377
privateArchitectJobRegistry . register ( _getBuilderNameForTargetFactory ( _host ) ) ;
364
378
privateArchitectJobRegistry . register ( _validateOptionsFactory ( _host , registry ) ) ;
365
379
privateArchitectJobRegistry . register ( _getProjectMetadataFactory ( _host ) ) ;
366
380
367
- const jobRegistry = new experimental . jobs . FallbackRegistry ( [
381
+ const jobRegistry = new FallbackRegistry ( [
368
382
new ArchitectTargetJobRegistry ( _host , registry , this . _jobCache , this . _infoCache ) ,
369
383
new ArchitectBuilderJobRegistry ( _host , registry , this . _jobCache , this . _infoCache ) ,
370
384
privateArchitectJobRegistry ,
371
385
...( additionalJobRegistry ? [ additionalJobRegistry ] : [ ] ) ,
372
- ] as experimental . jobs . Registry [ ] ) ;
386
+ ] as Registry [ ] ) ;
373
387
374
- this . _scheduler = new experimental . jobs . SimpleScheduler ( jobRegistry , registry ) ;
388
+ this . _scheduler = new SimpleScheduler ( jobRegistry , registry ) ;
375
389
}
376
390
377
- has ( name : experimental . jobs . JobName ) {
391
+ has ( name : JobName ) {
378
392
return this . _scheduler . has ( name ) ;
379
393
}
380
394
0 commit comments