1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | const sdm_1 = require("@atomist/sdm");
|
19 | const _ = require("lodash");
|
20 | const ReactToSemanticDiffsOnPushImpact_1 = require("../../handlers/events/delivery/code/ReactToSemanticDiffsOnPushImpact");
|
21 | const FulfillGoalOnRequested_1 = require("../../handlers/events/delivery/goals/FulfillGoalOnRequested");
|
22 | const RequestDownstreamGoalsOnGoalSuccess_1 = require("../../handlers/events/delivery/goals/RequestDownstreamGoalsOnGoalSuccess");
|
23 | const RespondOnGoalCompletion_1 = require("../../handlers/events/delivery/goals/RespondOnGoalCompletion");
|
24 | const SetGoalsOnPush_1 = require("../../handlers/events/delivery/goals/SetGoalsOnPush");
|
25 | const SkipDownstreamGoalsOnGoalFailure_1 = require("../../handlers/events/delivery/goals/SkipDownstreamGoalsOnGoalFailure");
|
26 | const VoteOnGoalApprovalRequest_1 = require("../../handlers/events/delivery/goals/VoteOnGoalApprovalRequest");
|
27 | const ClosedIssueHandler_1 = require("../../handlers/events/issue/ClosedIssueHandler");
|
28 | const NewIssueHandler_1 = require("../../handlers/events/issue/NewIssueHandler");
|
29 | const UpdatedIssueHandler_1 = require("../../handlers/events/issue/UpdatedIssueHandler");
|
30 | const OnChannelLink_1 = require("../../handlers/events/repo/OnChannelLink");
|
31 | const OnFirstPushToRepo_1 = require("../../handlers/events/repo/OnFirstPushToRepo");
|
32 | const OnPullRequest_1 = require("../../handlers/events/repo/OnPullRequest");
|
33 | const OnRepoCreation_1 = require("../../handlers/events/repo/OnRepoCreation");
|
34 | const OnRepoOnboarded_1 = require("../../handlers/events/repo/OnRepoOnboarded");
|
35 | const OnTag_1 = require("../../handlers/events/repo/OnTag");
|
36 | const OnUserJoiningChannel_1 = require("../../handlers/events/repo/OnUserJoiningChannel");
|
37 |
|
38 |
|
39 |
|
40 |
|
41 | class HandlerBasedSoftwareDeliveryMachine extends sdm_1.AbstractSoftwareDeliveryMachine {
|
42 | get onRepoCreation() {
|
43 | return this.repoCreationListeners.length > 0 ?
|
44 | () => new OnRepoCreation_1.OnRepoCreation(this.repoCreationListeners, this.configuration.sdm.repoRefResolver, this.configuration.sdm.credentialsResolver, this.configuration.sdm.preferenceStoreFactory) :
|
45 | undefined;
|
46 | }
|
47 | get onFirstPush() {
|
48 | return this.firstPushListeners.length > 0 ?
|
49 | () => new OnFirstPushToRepo_1.OnFirstPushToRepo(this.firstPushListeners, this.configuration.sdm.repoRefResolver, this.configuration.sdm.credentialsResolver, this.configuration.sdm.preferenceStoreFactory) :
|
50 | undefined;
|
51 | }
|
52 | get semanticDiffReactor() {
|
53 | return this.fingerprintDifferenceListeners.length > 0 ?
|
54 | () => new ReactToSemanticDiffsOnPushImpact_1.ReactToSemanticDiffsOnPushImpact(this.fingerprintDifferenceListeners, this.configuration.sdm.repoRefResolver, this.configuration.sdm.credentialsResolver, this.configuration.sdm.preferenceStoreFactory) :
|
55 | undefined;
|
56 | }
|
57 | get goalSetting() {
|
58 | if (this.pushMapping) {
|
59 | return {
|
60 | eventHandlers: [() => new SetGoalsOnPush_1.SetGoalsOnPush(this.configuration.sdm.projectLoader, this.configuration.sdm.repoRefResolver, this.pushMapping, this.goalsSetListeners, this.goalFulfillmentMapper, this.configuration.sdm.credentialsResolver, this.configuration.sdm.preferenceStoreFactory, this.configuration.sdm.enrichGoal)],
|
61 | commandHandlers: [],
|
62 | ingesters: [],
|
63 | };
|
64 | }
|
65 | else {
|
66 | return {
|
67 | eventHandlers: [],
|
68 | commandHandlers: [],
|
69 | ingesters: [],
|
70 | };
|
71 | }
|
72 | }
|
73 | get goalConsequences() {
|
74 | if (this.pushMapping) {
|
75 | return {
|
76 | eventHandlers: [
|
77 | () => new SkipDownstreamGoalsOnGoalFailure_1.SkipDownstreamGoalsOnGoalFailure(),
|
78 | () => new RequestDownstreamGoalsOnGoalSuccess_1.RequestDownstreamGoalsOnGoalSuccess(this.configuration.name, this.goalFulfillmentMapper, this.configuration.sdm.repoRefResolver, this.configuration.sdm.credentialsResolver, this.configuration.sdm.preferenceStoreFactory),
|
79 | () => new RespondOnGoalCompletion_1.RespondOnGoalCompletion(this.configuration.sdm.repoRefResolver, this.configuration.sdm.credentialsResolver, this.goalCompletionListeners, this.configuration.sdm.preferenceStoreFactory),
|
80 | () => new VoteOnGoalApprovalRequest_1.VoteOnGoalApprovalRequest(this.configuration.sdm.repoRefResolver, this.configuration.sdm.credentialsResolver, this.goalApprovalRequestVoters, this.goalApprovalRequestVoteDecisionManager, this.goalFulfillmentMapper, this.configuration.sdm.preferenceStoreFactory)
|
81 | ],
|
82 | commandHandlers: [],
|
83 | ingesters: [],
|
84 | };
|
85 | }
|
86 | else {
|
87 | return {
|
88 | eventHandlers: [],
|
89 | commandHandlers: [],
|
90 | ingesters: [],
|
91 | };
|
92 | }
|
93 | }
|
94 | get allFunctionalUnits() {
|
95 | return []
|
96 | .concat([
|
97 | this.goalSetting,
|
98 | this.goalConsequences,
|
99 | ]);
|
100 | }
|
101 | get eventHandlers() {
|
102 | return this.registrationManager.eventHandlers
|
103 | .concat(this.pushMapping ? () => new FulfillGoalOnRequested_1.FulfillGoalOnRequested(this.goalFulfillmentMapper, this.goalExecutionListeners) : undefined)
|
104 | .concat(_.flatten(this.allFunctionalUnits.map(fu => fu.eventHandlers)))
|
105 | .concat([
|
106 | this.userJoiningChannelListeners.length > 0 ?
|
107 | () => new OnUserJoiningChannel_1.OnUserJoiningChannel(this.userJoiningChannelListeners, this.configuration.sdm.repoRefResolver, this.configuration.sdm.credentialsResolver, this.configuration.sdm.preferenceStoreFactory) :
|
108 | undefined,
|
109 | this.tagListeners.length > 0 ?
|
110 | () => new OnTag_1.OnTag(this.tagListeners, this.configuration.sdm.repoRefResolver, this.configuration.sdm.credentialsResolver, this.configuration.sdm.preferenceStoreFactory) :
|
111 | undefined,
|
112 | this.newIssueListeners.length > 0 ?
|
113 | () => new NewIssueHandler_1.NewIssueHandler(this.newIssueListeners, this.configuration.sdm.repoRefResolver, this.configuration.sdm.credentialsResolver, this.configuration.sdm.preferenceStoreFactory) :
|
114 | undefined,
|
115 | this.updatedIssueListeners.length > 0 ?
|
116 | () => new UpdatedIssueHandler_1.UpdatedIssueHandler(this.updatedIssueListeners, this.configuration.sdm.repoRefResolver, this.configuration.sdm.credentialsResolver, this.configuration.sdm.preferenceStoreFactory) :
|
117 | undefined,
|
118 | this.closedIssueListeners.length > 0 ?
|
119 | () => new ClosedIssueHandler_1.ClosedIssueHandler(this.closedIssueListeners, this.configuration.sdm.repoRefResolver, this.configuration.sdm.credentialsResolver, this.configuration.sdm.preferenceStoreFactory) :
|
120 | undefined,
|
121 | this.channelLinkListeners.length > 0 ?
|
122 | () => new OnChannelLink_1.OnChannelLink(this.configuration.sdm.projectLoader, this.configuration.sdm.repoRefResolver, this.channelLinkListeners, this.configuration.sdm.credentialsResolver, this.configuration.sdm.preferenceStoreFactory) :
|
123 | undefined,
|
124 | this.pullRequestListeners.length > 0 ?
|
125 | () => new OnPullRequest_1.OnPullRequest(this.configuration.sdm.projectLoader, this.configuration.sdm.repoRefResolver, this.pullRequestListeners, this.configuration.sdm.credentialsResolver, this.configuration.sdm.preferenceStoreFactory) : undefined,
|
126 | this.repoOnboardingListeners.length > 0 ?
|
127 | () => new OnRepoOnboarded_1.OnRepoOnboarded(this.repoOnboardingListeners, this.configuration.sdm.repoRefResolver, this.configuration.sdm.credentialsResolver, this.configuration.sdm.preferenceStoreFactory) :
|
128 | undefined,
|
129 | this.onRepoCreation,
|
130 | this.onFirstPush,
|
131 | this.semanticDiffReactor,
|
132 | ])
|
133 | .filter(m => !!m);
|
134 | }
|
135 | get commandHandlers() {
|
136 | return this.registrationManager.commandHandlers
|
137 | .concat(_.flatten(this.allFunctionalUnits.map(fu => fu.commandHandlers)))
|
138 | .filter(m => !!m);
|
139 | }
|
140 | get ingesters() {
|
141 | return this.registrationManager.ingesters
|
142 | .concat(_.flatten(this.allFunctionalUnits.map(fu => fu.ingesters)))
|
143 | .filter(m => !!m);
|
144 | }
|
145 | |
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 | constructor(name, configuration, goalSetters) {
|
153 | super(name, configuration, goalSetters);
|
154 | }
|
155 | }
|
156 | exports.HandlerBasedSoftwareDeliveryMachine = HandlerBasedSoftwareDeliveryMachine;
|
157 |
|
\ | No newline at end of file |