{
 "$schema": "../../lib/umlimator.schema.json",
 "schemaVersion": 2,
 "title": "State machine diagram",
 "root": "order-life",
 "nodes": [
  { "id": "created", "type": "uml.Pseudostate", "props": { "kind": "initial" } },
  { "id": "placed", "type": "uml.State", "label": "Placed",
   "props": { "entry": "reserve the books", "do": "poll the payment provider", "exit": "log the payment result" },
   "members": [
    { "id": "placed.address", "type": "uml.InternalTransition", "props": { "trigger": "address changed", "effect": "update the delivery address" } }
   ] },
  { "id": "payment-outcome", "type": "uml.Pseudostate", "props": { "kind": "choice" } },
  { "id": "prepaid", "type": "uml.Pseudostate", "props": { "kind": "fork" } },
  { "id": "fulfilling", "type": "uml.State", "label": "Fulfilling",
   "members": [
    { "id": "fulfilling.parcel", "type": "uml.Region", "label": "Parcel" },
    { "id": "fulfilling.payment", "type": "uml.Region", "label": "Payment" }
   ] },
  { "id": "parcel-start", "type": "uml.Pseudostate", "parent": "fulfilling.parcel", "props": { "kind": "initial" } },
  { "id": "picking", "type": "uml.State", "label": "Picking", "parent": "fulfilling.parcel", "props": { "do": "collect the books from the shelves" } },
  { "id": "packed", "type": "uml.State", "label": "Packed", "parent": "fulfilling.parcel", "props": { "entry": "print the address label" } },
  { "id": "parcel-history", "type": "uml.Pseudostate", "parent": "fulfilling.parcel", "props": { "kind": "deepHistory" } },
  { "id": "payment-start", "type": "uml.Pseudostate", "parent": "fulfilling.payment", "props": { "kind": "initial" } },
  { "id": "capturing", "type": "uml.State", "label": "Capturing payment", "parent": "fulfilling.payment", "props": { "entry": "ask the payment provider to capture" } },
  { "id": "captured", "type": "uml.State", "label": "Payment captured", "parent": "fulfilling.payment" },
  { "id": "on-hold", "type": "uml.State", "label": "On hold", "props": { "entry": "tell the warehouse to stop" } },
  { "id": "ready", "type": "uml.Pseudostate", "props": { "kind": "join" } },
  { "id": "delivery", "type": "uml.State", "label": "In delivery" },
  { "id": "delivery-start", "type": "uml.Pseudostate", "parent": "delivery", "props": { "kind": "initial" } },
  { "id": "in-transit", "type": "uml.State", "label": "In transit", "parent": "delivery", "props": { "do": "follow the carrier's tracking" } },
  { "id": "out-for-delivery", "type": "uml.State", "label": "Out for delivery", "parent": "delivery", "props": { "entry": "text the shopper a delivery window" } },
  { "id": "delivery-history", "type": "uml.Pseudostate", "parent": "delivery", "props": { "kind": "shallowHistory" } },
  { "id": "enquiry", "type": "uml.State", "label": "Under enquiry" },
  { "id": "enquiry-start", "type": "uml.Pseudostate", "parent": "enquiry", "props": { "kind": "initial" } },
  { "id": "waiting-carrier", "type": "uml.State", "label": "Waiting for the carrier", "parent": "enquiry" },
  { "id": "investigating", "type": "uml.State", "label": "Investigating", "parent": "enquiry" },
  { "id": "returned", "type": "uml.Pseudostate", "props": { "kind": "junction" } },
  { "id": "cancelled", "type": "uml.State", "label": "Cancelled",
   "props": { "entry": "release the reserved books", "exit": "close the order" },
   "members": [
    { "id": "cancelled.refund-failed", "type": "uml.InternalTransition", "props": { "trigger": "refund failed", "effect": "retry the refund" } },
    { "id": "cancelled.asked", "type": "uml.InternalTransition", "props": { "trigger": "shopper asks", "effect": "resend the email" } }
   ] },
  { "id": "erased", "type": "uml.Pseudostate", "props": { "kind": "terminate" } },
  { "id": "delivered", "type": "uml.FinalState" },
  { "id": "hold-note", "type": "uml.Comment", "label": "H* resumes picking or packing where the hold stopped it" }
 ],
 "edges": [
  { "id": "t-created", "type": "uml.Transition", "from": "created", "to": "placed" },
  { "id": "t-payment-result", "type": "uml.Transition", "from": "placed", "to": "payment-outcome", "props": { "trigger": "payment result" } },
  { "id": "t-authorised", "type": "uml.Transition", "from": "payment-outcome", "to": "fulfilling", "props": { "guard": "card authorised" } },
  { "id": "t-prepaid", "type": "uml.Transition", "from": "payment-outcome", "to": "prepaid", "props": { "guard": "paid by gift card" } },
  { "id": "t-declined", "type": "uml.Transition", "from": "payment-outcome", "to": "cancelled", "props": { "guard": "else", "effect": "email the shopper" } },
  { "id": "t-prepaid-picking", "type": "uml.Transition", "from": "prepaid", "to": "picking" },
  { "id": "t-prepaid-captured", "type": "uml.Transition", "from": "prepaid", "to": "captured" },
  { "id": "t-parcel-start", "type": "uml.Transition", "from": "parcel-start", "to": "picking" },
  { "id": "t-picked", "type": "uml.Transition", "from": "picking", "to": "packed", "props": { "trigger": "all books picked" } },
  { "id": "t-payment-start", "type": "uml.Transition", "from": "payment-start", "to": "capturing" },
  { "id": "t-capture-retry", "type": "uml.Transition", "from": "capturing", "to": "capturing",
   "props": { "trigger": "capture failed", "guard": "attempts < 3", "effect": "count the attempt" } },
  { "id": "t-captured", "type": "uml.Transition", "from": "capturing", "to": "captured", "props": { "trigger": "capture confirmed" } },
  { "id": "t-hold", "type": "uml.Transition", "from": "fulfilling", "to": "on-hold", "props": { "trigger": "hold requested" } },
  { "id": "t-unhold", "type": "uml.Transition", "from": "on-hold", "to": "parcel-history", "props": { "trigger": "hold lifted" } },
  { "id": "t-packed-ready", "type": "uml.Transition", "from": "packed", "to": "ready" },
  { "id": "t-captured-ready", "type": "uml.Transition", "from": "captured", "to": "ready" },
  { "id": "t-handed-over", "type": "uml.Transition", "from": "ready", "to": "delivery", "props": { "effect": "hand the parcel to the carrier" } },
  { "id": "t-delivery-start", "type": "uml.Transition", "from": "delivery-start", "to": "in-transit" },
  { "id": "t-at-depot", "type": "uml.Transition", "from": "in-transit", "to": "out-for-delivery", "props": { "trigger": "reached the local depot" } },
  { "id": "t-delivered", "type": "uml.Transition", "from": "out-for-delivery", "to": "delivered", "props": { "trigger": "parcel signed for", "effect": "email the receipt" } },
  { "id": "t-problem", "type": "uml.Transition", "from": "delivery", "to": "enquiry", "props": { "trigger": "problem reported" } },
  { "id": "t-enquiry-start", "type": "uml.Transition", "from": "enquiry-start", "to": "waiting-carrier" },
  { "id": "t-carrier-answered", "type": "uml.Transition", "from": "waiting-carrier", "to": "investigating", "props": { "trigger": "carrier answered" } },
  { "id": "t-resolved", "type": "uml.Transition", "from": "enquiry", "to": "delivery-history", "props": { "trigger": "problem resolved" } },
  { "id": "t-refused", "type": "uml.Transition", "from": "out-for-delivery", "to": "returned", "props": { "trigger": "refused at the door" } },
  { "id": "t-lost", "type": "uml.Transition", "from": "enquiry", "to": "returned", "props": { "trigger": "parcel lost" } },
  { "id": "t-returned", "type": "uml.Transition", "from": "returned", "to": "cancelled", "props": { "effect": "refund the payment" } },
  { "id": "t-cancel", "type": "uml.Transition", "from": "fulfilling", "to": "cancelled", "props": { "trigger": "cancel requested", "effect": "refund the payment" } },
  { "id": "t-erase", "type": "uml.Transition", "from": "cancelled", "to": "erased", "props": { "trigger": "after 30 days", "effect": "erase the shopper's details" } },
  { "id": "hold-note-link", "type": "uml.CommentLink", "from": "hold-note", "to": "parcel-history" }
 ],
 "views": [
  { "id": "order-life", "diagram": "uml.state-machine", "title": "An order's life", "parent": null,
   "layout": { "on-hold": [3, 0], "hold-note": [2, 1] },
   "nodeIds": ["created", "placed", "payment-outcome", "prepaid", "fulfilling", "parcel-start", "picking", "packed", "parcel-history", "payment-start", "capturing", "captured",
    "on-hold", "ready", "delivery", "delivery-start", "in-transit", "out-for-delivery", "delivery-history", "enquiry", "returned", "cancelled", "erased", "delivered", "hold-note"],
   "present": { "cancelled": { "rows": 2 }, "out-for-delivery": { "collapsed": ["activities"] } } }
 ]
}
