1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
10 | exports.FallbackEngineHost = void 0;
|
11 | const rxjs_1 = require("rxjs");
|
12 | const operators_1 = require("rxjs/operators");
|
13 | const src_1 = require("../src");
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | class FallbackEngineHost {
|
19 | constructor() {
|
20 | this._hosts = [];
|
21 | }
|
22 | addHost(host) {
|
23 | this._hosts.push(host);
|
24 | }
|
25 | createCollectionDescription(name, requester) {
|
26 | for (const host of this._hosts) {
|
27 | try {
|
28 | const description = host.createCollectionDescription(name, requester);
|
29 | return { name, host, description };
|
30 | }
|
31 | catch (_) { }
|
32 | }
|
33 | throw new src_1.UnknownCollectionException(name);
|
34 | }
|
35 | createSchematicDescription(name, collection) {
|
36 | const description = collection.host.createSchematicDescription(name, collection.description);
|
37 | if (!description) {
|
38 | return null;
|
39 | }
|
40 | return { name, collection, description };
|
41 | }
|
42 | getSchematicRuleFactory(schematic, collection) {
|
43 | return collection.host.getSchematicRuleFactory(schematic.description, collection.description);
|
44 | }
|
45 | createSourceFromUrl(url, context) {
|
46 | return context.schematic.collection.description.host.createSourceFromUrl(url, context);
|
47 | }
|
48 | transformOptions(schematic, options, context) {
|
49 |
|
50 | return (0, rxjs_1.of)(options).pipe(...this._hosts.map((host) => (0, operators_1.mergeMap)((opt) => host.transformOptions(schematic, opt, context))));
|
51 | }
|
52 | transformContext(context) {
|
53 | let result = context;
|
54 | this._hosts.forEach((host) => {
|
55 | result = (host.transformContext(result) || result);
|
56 | });
|
57 | return result;
|
58 | }
|
59 | listSchematicNames(collection, includeHidden) {
|
60 | const allNames = new Set();
|
61 | this._hosts.forEach((host) => {
|
62 | try {
|
63 | host
|
64 | .listSchematicNames(collection.description, includeHidden)
|
65 | .forEach((name) => allNames.add(name));
|
66 | }
|
67 | catch (_) { }
|
68 | });
|
69 | return [...allNames];
|
70 | }
|
71 | createTaskExecutor(name) {
|
72 | for (const host of this._hosts) {
|
73 | if (host.hasTaskExecutor(name)) {
|
74 | return host.createTaskExecutor(name);
|
75 | }
|
76 | }
|
77 | return (0, rxjs_1.throwError)(new src_1.UnregisteredTaskException(name));
|
78 | }
|
79 | hasTaskExecutor(name) {
|
80 | for (const host of this._hosts) {
|
81 | if (host.hasTaskExecutor(name)) {
|
82 | return true;
|
83 | }
|
84 | }
|
85 | return false;
|
86 | }
|
87 | }
|
88 | exports.FallbackEngineHost = FallbackEngineHost;
|