Skip to content

Commit

Permalink
implement find start procedure
Browse files Browse the repository at this point in the history
  • Loading branch information
WMXPY committed Nov 2, 2023
1 parent 29c6fe5 commit 50c3984
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/orchestration/procedure/find-start-procedure.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* @author WMXPY
* @namespace Orchestration_Procedure
* @description Find Start Procedure
*/

import { Optional } from "@sudoo/optional";
import { PUB_PROCEDURE_TYPE, PubProcedureConfiguration } from "../../procedure/definition/configuration";
import { PubRecordProcedureEnrichRecord } from "../../record/definition/procedure-enrich";
import { PubRecord } from "../../record/record";

export const findStartEnrichedProcedure = (
record: PubRecord,
): Optional<PubRecordProcedureEnrichRecord> => {

const startProcedure: Optional<PubProcedureConfiguration<PUB_PROCEDURE_TYPE>> =
findStartProcedure(record);

if (!startProcedure.exists) {
return Optional.ofEmpty();
}

const startEnrichedProcedure: Optional<PubRecordProcedureEnrichRecord> =
Optional.of(record
.snapshot
.procedureEnriches[startProcedure.getOrThrow().identifier]);

return startEnrichedProcedure;
};

export const findStartProcedure = (
record: PubRecord,
): Optional<PubProcedureConfiguration<PUB_PROCEDURE_TYPE>> => {

return Optional.of(record
.cachedConfiguration
.configuration
.procedures
.find((procedure: PubProcedureConfiguration<PUB_PROCEDURE_TYPE>) => {

return procedure.type === PUB_PROCEDURE_TYPE.START;
}));
};

0 comments on commit 50c3984

Please sign in to comment.