# Synthetic Avouch example for Avouch Studio: an online shop from order to delivery. # All names and quotes are invented. formatVersion: 1 contexts: Sales: Orders and payments Fulfilment: Shipping and delivery permission_rows_not_commands: [] knownSourceGaps: [] objectTypes: Order: context: Sales datasource: orders doc: 'shop#order' properties: status: class: canonical cite: { doc: 'shop#order', quote: Order status changes only through order commands } Payment: context: Sales datasource: payments doc: 'shop#payment' properties: status: class: canonical cite: { doc: 'shop#payment', quote: A payment is either pending or captured } Shipment: context: Fulfilment datasource: shipments doc: 'shop#shipment' properties: status: class: canonical cite: { doc: 'shop#shipment', quote: A shipment is packed or in transit or delivered } stateMachines: Order: doc: 'shop#order-states' initial: PLACED terminal: [RETURNED] transitions: - { from: PLACED, to: PAID, by: [PAY_ORDER] } - { from: PAID, to: SHIPPED, by: [SHIP_ORDER] } - { from: SHIPPED, to: DELIVERED, by: [CONFIRM_DELIVERY] } - { from: DELIVERED, to: RETURNED, by: [], out_of_scope: Returns are handled by the support team outside this system } linkTypes: - { id: payment_order, from: Payment, to: Order, cardinality: 'N:1', via: order_id, doc: 'shop#payment' } - { id: shipment_order, from: Shipment, to: Order, cardinality: 'N:1', via: order_id, doc: 'shop#shipment' } actionTypes: PAY_ORDER: context: Sales doc: 'shop#pay' doc_term: Pay order permission: keys: ['order:pay'] cite: { doc: 'shop#permissions', quote: Paying an order needs order:pay } submissionCriteria: - id: order_placed reads: [Order.status] cite: { doc: 'shop#pay', quote: Only a placed order can be paid } creates: [Payment] edits: [Order.status] link_effects: payment_order: effect: The new payment points to the paid order cite: { doc: 'shop#pay', quote: The payment records the order it pays } shipment_order: { none: Paying does not create a shipment } emits: [] SHIP_ORDER: context: Fulfilment doc: 'shop#ship' doc_term: Ship order permission: keys: ['order:ship'] cite: { doc: 'shop#permissions', quote: Shipping an order needs order:ship } submissionCriteria: - id: payment_captured reads: - { prop: Payment.status, values: [CAPTURED] } cite: { doc: 'shop#ship', quote: An order ships only after its payment is captured } creates: [Shipment] edits: [Order.status] link_effects: shipment_order: effect: The new shipment points to the shipped order cite: { doc: 'shop#ship', quote: The shipment records the order it carries } payment_order: { none: Shipping does not change the payment link } emits: [] CONFIRM_DELIVERY: context: Fulfilment doc: 'shop#delivery' doc_term: Confirm delivery permission: keys: ['order:deliver'] cite: { doc: 'shop#permissions', quote: Confirming delivery needs order:deliver } submissionCriteria: - id: order_shipped reads: [Order.status] cite: { doc: 'shop#delivery', quote: Only a shipped order can be confirmed as delivered } edits: [Order.status, Shipment.status] link_effects: shipment_order: { none: Delivery does not change the shipment link } payment_order: { none: Delivery does not change the payment link } emits: []