Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sdmGoal.uniqueName, sdmGoal.fulfillment.method, sdmGoal.fulfillment.name);
return Success;
} else if (sdmGoal.fulfillment.method === SdmGoalFulfillmentMethod.Other) {
// fail goal with neither Sdm nor SideEffect fulfillment
await updateGoal(
ctx,
sdmGoal,
{
state: SdmGoalState.failure,
description: `No fulfillment for ${sdmGoal.uniqueName}`,
});
return Success;
}
const id = this.configuration.sdm.repoRefResolver.repoRefFromSdmGoal(sdmGoal);
const credentials = await resolveCredentialsPromise(this.configuration.sdm.credentialsResolver.eventHandlerCredentials(ctx, id));
const addressChannels = addressChannelsFor(sdmGoal.push.repo, ctx);
const preferences = this.configuration.sdm.preferenceStoreFactory(ctx);
const implementation = this.implementationMapper.findImplementationBySdmGoal(sdmGoal);
const { goal } = implementation;
const progressLog = new WriteToAllProgressLog(
sdmGoal.name,
new LoggingProgressLog(sdmGoal.name, "debug"),
await this.configuration.sdm.logFactory(ctx, sdmGoal));
const goalInvocation: GoalInvocation = {
configuration: this.configuration,
sdmGoal,
goalEvent: sdmGoal,
goal,
public async handle(event: EventFired,
context: HandlerContext): Promise {
const repo = event.data.Repo[0];
const id = this.repoRefResolver.toRemoteRepoRef(repo, {});
const credentials = await resolveCredentialsPromise(this.credentialsFactory.eventHandlerCredentials(context, id));
const preferences = this.preferenceStoreFactory(context);
const invocation: RepoCreationListenerInvocation = {
addressChannels: AddressNoChannels,
preferences,
configuration: this.configuration,
id,
context,
repo,
credentials,
};
await Promise.all(this.newRepoActions.map(a => a(invocation)));
return Success;
}
}
public async handle(event: EventFired,
context: HandlerContext): Promise {
const push: OnPushToAnyBranch.Push = event.data.Push[0];
const id: RemoteRepoRef = this.repoRefResolver.toRemoteRepoRef(push.repo, {});
const credentials = await resolveCredentialsPromise(this.credentialsFactory.eventHandlerCredentials(context, id));
await chooseAndSetGoals({
projectLoader: this.projectLoader,
repoRefResolver: this.repoRefResolver,
goalsListeners: this.goalsListeners,
goalSetter: this.goalSetter,
implementationMapping: this.implementationMapping,
preferencesFactory: this.preferenceStoreFactory,
enrichGoal: this.enrichGoal,
tagGoalSet: this.tagGoalSet,
}, {
context,
credentials,
push,
});
return Success;
public async handle(event: EventFired,
context: HandlerContext): Promise {
const joinEvent = event.data.UserJoinedChannel[0];
const repos = joinEvent.channel.repos.map(
repo => this.repoRefResolver.toRemoteRepoRef(repo, {}));
const credentials = await resolveCredentialsPromise(this.credentialsFactory.eventHandlerCredentials(context, repos[0]));
const addressChannels = (msg, opts) => context.messageClient.addressChannels(msg, joinEvent.channel.name, opts);
const preferences = this.preferenceStoreFactory(context);
const invocation: UserJoiningChannelListenerInvocation = {
addressChannels,
preferences,
configuration: this.configuration,
context,
credentials,
joinEvent,
repos,
};
await Promise.all(this.listeners
.map(l => l(invocation)),
);
.filter(f => !!f.name) as FingerprintValue[];
const newValues: FingerprintValue[] = newFingerprints
.filter(f => !!f.name) as FingerprintValue[];
const allNames = _.uniq(oldValues.map(f => f.name)
.concat(newValues.map(f => f.name)));
const diffs: FingerprintDifference[] =
allNames
.map(name => ({
oldValue: oldValues.find(f => f.name === name),
newValue: newValues.find(f => f.name === name),
}))
.filter(fv => _.get(fv, "oldValue.sha") !== _.get(fv, "newValue.sha"));
const credentials = await resolveCredentialsPromise(this.credentialsFactory.eventHandlerCredentials(context, id));
const preferences = this.preferencesStoreFactory(context);
const inv: FingerprintDifferenceListenerInvocation = {
id,
context,
credentials,
addressChannels: addressChannelsFor(after.repo, context),
configuration: this.configuration,
preferences,
diffs,
};
await Promise.all(this.differenceListeners.map(dh => dh(inv)));
return Success;
}
}
public async handle(event: EventFired,
context: HandlerContext): Promise {
const issue = event.data.Issue[0];
const id = this.repoRefResolver.toRemoteRepoRef(issue.repo, {});
const credentials = await resolveCredentialsPromise(this.credentialsFactory.eventHandlerCredentials(context, id));
const preferences = this.preferenceStoreFactory(context);
const addressChannels = addressChannelsFor(issue.repo, context);
const inv: ClosedIssueListenerInvocation = {
id,
addressChannels,
preferences,
configuration: this.configuration,
context,
issue,
credentials,
};
await Promise.all(this.closedIssueListeners
.map(l => l(inv)));
return Success;
}
public async handle(event: EventFired,
context: HandlerContext): Promise {
const issue = event.data.Issue[0];
const addressChannels = addressChannelsFor(issue.repo, context);
const id = this.repoRefResolver.toRemoteRepoRef(issue.repo, {});
if (issue.updatedAt !== issue.createdAt) {
logger.debug("Issue updated, not created: %s on %j", issue.number, id);
return Success;
}
const credentials = await resolveCredentialsPromise(this.credentialsFactory.eventHandlerCredentials(context, id));
const preferences = this.preferenceStoreFactory(context);
const inv: NewIssueListenerInvocation = {
id,
addressChannels,
preferences,
configuration: this.configuration,
context,
issue,
credentials,
};
await Promise.all(this.newIssueListeners
.map(l => l(inv)));
return Success;
}
}
if (!shouldHandle(sdmGoal)) {
logger.debug(`Goal ${sdmGoal.uniqueName} skipped because not managed by this SDM`);
return Success;
}
await verifyGoal(sdmGoal, this.configuration.sdm.goalSigning, context);
const id = this.repoRefResolver.repoRefFromPush(sdmGoal.push);
const goals = fetchGoalsFromPush(sdmGoal);
const gsi: GoalCompletionListenerInvocation = {
id,
context,
credentials: await resolveCredentialsPromise(this.credentialsFactory.eventHandlerCredentials(context, id)),
addressChannels: addressChannelsFor(sdmGoal.push.repo, context),
configuration: this.configuration,
preferences: this.preferenceStoreFactory(context),
allGoals: goals,
completedGoal: sdmGoal,
};
try {
await Promise.all(this.goalCompletionListeners.map(l => l(gsi)));
} catch (e) {
logger.warn(`Error occurred while running goal completion listener: ${stringify(e)}`);
}
return Success;
}
}
public async handle(event: EventFired,
context: HandlerContext): Promise {
const sdmGoal = event.data.SdmGoal[0] as SdmGoalEvent;
if (!shouldHandle(sdmGoal)) {
logger.debug(`Goal ${sdmGoal.name} skipped because not managed by this SDM`);
return Success;
}
await verifyGoal(sdmGoal, this.configuration.sdm.goalSigning, context);
const id = this.repoRefResolver.repoRefFromPush(sdmGoal.push);
const credentials = await resolveCredentialsPromise(this.credentialsFactory.eventHandlerCredentials(context, id));
const preferences = this.preferenceStoreFactory(context);
const garvi: GoalApprovalRequestVoterInvocation = {
id,
context,
credentials,
addressChannels: addressChannelsFor(sdmGoal.push.repo, context),
configuration: this.configuration,
preferences,
goal: sdmGoal,
};
const votes = await Promise.all(this.voters.map(v => v(garvi)));
const decision = this.decisionManager(...votes);
const goal = this.implementationMapper.findGoalBySdmGoal(sdmGoal);
public async handle(event: EventFired,
context: HandlerContext): Promise {
const sdmGoal = event.data.SdmGoal[0] as SdmGoalEvent;
if (!isGoalRelevant(sdmGoal)) {
logger.debug(`Goal ${sdmGoal.uniqueName} skipped because not relevant for this SDM`);
return Success;
}
await verifyGoal(sdmGoal, this.configuration.sdm.goalSigning, context);
const id = this.repoRefResolver.repoRefFromPush(sdmGoal.push);
const credentials = await resolveCredentialsPromise(this.credentialsResolver.eventHandlerCredentials(context, id));
const preferences = this.preferenceStoreFactory(context);
const goals = fetchGoalsFromPush(sdmGoal);
const goalsToRequest = goals.filter(g => isDirectlyDependentOn(sdmGoal, g))
.filter(g => expectToBeFulfilledAfterRequest(g, this.name))
.filter(shouldBePlannedOrSkipped)
.filter(g => preconditionsAreMet(g, { goalsForCommit: goals }));
if (goalsToRequest.length > 0) {
logger.info("because %s is successful, these goals are now ready: %s", goalKeyString(sdmGoal),
goalsToRequest.map(goalKeyString).join(", "));
}
await Promise.all(goalsToRequest.map(async sdmG => {
delete sdmG.data;