Skip to content

Commit

Permalink
provide a results callback hook
Browse files Browse the repository at this point in the history
  • Loading branch information
eyadmba committed Dec 15, 2023
1 parent 19bbe6a commit 8ec344a
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,14 @@ export interface ExecuteIntegrationOptions {
enableSchemaValidation?: boolean;
graphObjectStore?: GraphObjectStore;
createStepGraphObjectDataUploader?: CreateStepGraphObjectDataUploaderFunction;
resultsCallback?: (results: IntegrationStepResult[]) => Promise<void>;
pretty?: boolean;
}

export interface ExecuteWithContextOptions {
graphObjectStore?: GraphObjectStore;
createStepGraphObjectDataUploader?: CreateStepGraphObjectDataUploaderFunction;
}
type ExecuteWithContextOptions = Pick<
ExecuteIntegrationOptions,
'graphObjectStore' | 'resultsCallback' | 'createStepGraphObjectDataUploader'
>;

const THIRTY_SECONDS_STORAGE_INTERVAL_MS = 60000 / 2;

Expand Down Expand Up @@ -251,6 +252,7 @@ export async function executeWithContext<
const {
graphObjectStore = new FileSystemGraphObjectStore(),
createStepGraphObjectDataUploader,
resultsCallback,
} = options;

const integrationStepResults = await executeSteps({
Expand Down Expand Up @@ -288,6 +290,17 @@ export async function executeWithContext<
data: summary,
});

if (resultsCallback != null) {
try {
await resultsCallback(integrationStepResults);
} catch (err) {
context.logger.warn(
err,
'Unable to run results callback for integration job',
);
}
}

processDeclaredTypesDiff(summary, (step, undeclaredTypes) => {
if (
step.status === StepResultStatus.SUCCESS &&
Expand Down

0 comments on commit 8ec344a

Please sign in to comment.