Skip to content

Instantly share code, notes, and snippets.

@Pruxis
Last active October 30, 2019 12:56
Show Gist options
  • Save Pruxis/61f77221030ed6dcb77775c505c9c0b7 to your computer and use it in GitHub Desktop.
Save Pruxis/61f77221030ed6dcb77775c505c9c0b7 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id: 'fetch',
initial: 'preprocessing',
context: {
retries: 0,
},
states: {
preprocessing: {
on: {
ERROR: 'manualIntervention',
SUCCESS: 'pageManagement',
},
},
manualIntervention: {
on: {
RESOLVE_INTERVENTION: 'businessRules',
},
},
pageManagement: {
initial: 'checkHasPageManagement',
onDone: 'entityExtraction',
states: {
checkHasPageManagement: {
on: {
HAS_PAGE_MANAGEMENT: 'withPageManagement',
NO_PAGE_MANAGEMENT: 'eachFileIsDocument',
},
},
withPageManagement: {
initial: 'documentTypePredictionPerPage',
onDone: 'success',
states: {
documentTypePredictionPerPage: {
on: {
SUCCESS: 'organizePagesML',
ERROR: 'manualIntervention',
},
},
organizePagesML: {
on: {
ERROR: 'manualIntervention',
SUCCESS: 'success',
},
},
manualIntervention: {
on: {
RESOLVE_INTERVENTION: 'success',
},
},
success: { type: 'final' },
},
},
success: { type: 'final' },
eachFileIsDocument: {
initial: 'createDocuments',
onDone: 'success',
states: {
createDocuments: {
on: {
DONE: 'documentTypePrediction',
},
},
success: { type: 'final' },
documentTypePrediction: {
on: {
ERROR: 'manualIntervention',
SUCCESS: 'success',
},
},
manualIntervention: {
on: {
RESOLVE_INTERVENTION: 'success',
},
},
},
},
},
},
entityExtraction: {
onDone: 'businessRules',
initial: 'extractEntities',
states: {
extractEntities: {
type: 'parallel',
states: {
textEntityExtraction: {},
imageEntityExtraction: {},
},
on: {
SUCCESS: 'success',
ERROR: 'manualIntervention',
},
},
success: { type: 'final' },
manualIntervention: {
on: {
RESOLVE_INTERVENTION: 'success',
},
},
},
},
businessRules: {
initial: 'executeRules',
onDone: 'output',
states: {
executeRules: {
on: {
RULES_FAILED: 'manualIntervention',
SUCCESS: 'success',
},
},
success: { type: 'final' },
manualIntervention: {
on: {
RESOLVE_INTERVENTION: 'success',
},
},
},
},
output: { type: 'final' },
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment