-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added steps order to collection flow config & fixed process tra…
…cker in backoffice
- Loading branch information
1 parent
6ad59bd
commit cfad964
Showing
14 changed files
with
115 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule data-migrations
updated
from 65491e to 995e03
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
services/workflows-service/src/collection-flow/helpers/get-steps-in-order.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { createWorkflow } from '@ballerine/workflow-core'; | ||
import { Prisma, UiDefinition } from '@prisma/client'; | ||
|
||
export const getStepsInOrder = async (uiDefinition: UiDefinition) => { | ||
if (!uiDefinition?.uiSchema) return []; | ||
|
||
const { uiSchema = {}, definition } = uiDefinition as Prisma.JsonObject; | ||
const { elements } = uiSchema as Prisma.JsonObject; | ||
|
||
if (!elements || !definition) return []; | ||
|
||
const stepsInOrder: string[] = []; | ||
|
||
const stateMachine = createWorkflow({ | ||
runtimeId: '', | ||
definition: (definition as Prisma.JsonObject).definition as any, | ||
definitionType: 'statechart-json', | ||
extensions: {}, | ||
workflowContext: {}, | ||
}); | ||
|
||
while (!stateMachine.getSnapshot().done) { | ||
stepsInOrder.push(stateMachine.getSnapshot().value); | ||
await stateMachine.sendEvent({ type: 'NEXT' }); | ||
} | ||
|
||
return stepsInOrder.map((stepName, index) => ({ stateName: stepName, orderNumber: index + 1 })); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters