zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

vf-intro-gql-iface.md (65474B)


      1 # VF Intro
      2 
      3 This document tries to explain how to use Zenflows's implementaton of the
      4 Valueflows vocabulary.  Please read about Valueflows documentation a bit to grasp
      5 some concepts such as *Processes*, *EconomicEvents*, *EconomicResources*, and
      6 *ResourceSpecifications* in order for this document to be more effective.
      7 
      8 
      9 ## Ownership and Quanty Types of Resources
     10 
     11 There are two quantity types in Zenflows:
     12 
     13 * `accountingQuantity`
     14 * `onhandQuantity`
     15 
     16 Their meaning is defined by how they are used by the events.  For example:
     17 
     18 * `produce` and `raise` events increase both quantities
     19 * `consume` and `lower` events decrease both quantities
     20 * `accept` events decrease `onhandQuantity`
     21 * `modify` events increase `onhandQuantity`
     22 * `transferAllRights` events decrease `accountingQuantity` of one resource, and
     23   increase `accountingQuantity` of the other resource
     24 
     25 The ownership types specify who is the owner of the given quantity type.  Those
     26 types are:
     27 
     28 * `primaryAccountable`: the owner of the quantity `accountingQuantity`
     29 * `custodian`: the current owner who has custody over the resource, amounted by
     30   `onhandQuantity`
     31 
     32 
     33 ## ResourceSpecification and ProcessSpecification
     34 
     35 In order to tell what a resource is, we use *ResourceSpecifications*.  If two
     36 resources conform to the same ResourceSpecification, they would be of the same
     37 type.  Each resource has a field named `conformsTo` that points to a
     38 ResourceSpecification.  The field gets set by `resourceConformsTo` of `produce`
     39 and `raise` events.
     40 
     41 But sometimes ResourceSpecification is not enough to differentiate between other
     42 resources.  Sometimes you need to, for example, differentiate between "clean",
     43 "used", "dirty", "donated" gown resources.  You use ProcessSpecifications to
     44 differentiate between those.  Each resource has a field named `stage` that could
     45 point to a ProcessSpecification.  The field gets set by `modify` events.
     46 
     47 
     48 ## Event Side-Effects and Enforcements
     49 
     50 In Zenflows, each event has its own requirements, enforcements, and possible
     51 side-effects.  Even though the GraphQL types allow some fields optionally,
     52 depending on the action, the back-end enforces some fields required by the
     53 events.
     54 
     55 
     56 ### Common Requirements and Enforcements
     57 
     58 Each event requires an Action.  If no Action is provided, the back-end can't
     59 know which fields to enforce and which side-effects to create.  The supported
     60 Actions are:
     61 
     62 * `produce`
     63 * `consume`
     64 * `use`
     65 * `work`
     66 * `cite`
     67 * `deliverService` (alias: `deliver-service`)
     68 * `pickup`
     69 * `dropoff`
     70 * `accept`
     71 * `modify`
     72 * `pack`
     73 * `unpack`
     74 * `transferCustody` (alias: `transfer-custody`)
     75 * `transferAllRights` (alias: `transfer-all-rights`)
     76 * `transfer`
     77 * `move`
     78 * `raise`
     79 * `lower`
     80 
     81 Each event requires a `provider` and a `receiver`.  If any of them is not
     82 provided, the back-end will default to the currently logged-in agent.  This
     83 might be changed in the future, however (the front-ends can default to currently
     84 logged-in agent by themselves).  Also, at the moment, `provider` must be the
     85 same agent as the logged-in agent.
     86 
     87 Each event requires you to provide some sort of time-related data.  These are
     88 provided by the fields `hasPointInTime`, `hasBeginning`, and `hasEnd`.  The
     89 back-end allows only these mutually-exclusive combinations, and if none of these
     90 combinations are met, you'll not be able to create your event:
     91 
     92 * Only `hasPointInTime`
     93 * Only `hasBeginning`
     94 * Only `hasEnd`
     95 * Both `hasBeginning` and `hasEnd`
     96 
     97 Currently, there's no check regarding the date-time fields.  For example,
     98 the back-end do not check if `hasBeginning` is older than `hasEnd`.
     99 
    100 The fields that take a reference (ID) to a record (such as
    101 `resourceInventoriedAs`, `resourceConformsTo`, `atLocation`, and `toLocation`)
    102 checks if the provided record exists.  You can't create an event with invalid
    103 references.
    104 
    105 The quantity fields take only positive amounts at the moment.
    106 
    107 
    108 ### Produce Events
    109 
    110 `produce` events are used for creating stuff.  This does not only mean something
    111 like harvesting crops, making a wood toy; it can also mean separating a resource
    112 that have quantities of five pieces into five individual pieces (in that case,
    113 you'd `consume` the resource that have five pieces, and `produce` five individual
    114 pieces).
    115 
    116 Generally used with `consume`, `work`, `use`, and `cite` events together to
    117 create a meaningful scenario.
    118 
    119 There are two things a `produce` event can do:
    120 
    121 * creating a new resource
    122 * increasing quantities of an existing resource
    123 
    124 The back-end differentiates them by whether the event has
    125 `resourceInventoriedAs` field or not.  If it has, it'll try to increase the
    126 quantities of the resource `resourceInventoriedAs`.
    127 
    128 Whether it creates a new resource or just increases the quantities of an existing
    129 resource, the events will require `outputOf`, `resourceConformsTo`, and
    130 `resourceQuantity` to be provided, and that the `provider` and `receiver` are
    131 the same agents.
    132 
    133 If it creates a new resource, it'll try to get the fields `name`, `note`,
    134 `trackingIdentifier`, `currentLocation`, and `stage` from
    135 `newInventoriedResource` and put them into the newly-created resource.
    136 
    137 If it increases the quantities of an existing resource, it'll just do it, but
    138 these requirements must be met first:
    139 
    140 * The `provider` and `receiver` must be the same agent as the
    141   `primaryAccountable` and `custodian` of the resource `resourceInventoriedAs`.
    142 * The `resourceQuantity.hasUnit` of the event must be the same as
    143   `accountingQuantity.hasUnit` and `onhandQuantity.hasUnit` of the resource
    144   `resourceInventoriedAs`.
    145 * The `resourceConformsTo` must be same as `conformsTo` of the resource
    146   `resourceInventoriedAs`
    147 * The `resourceInventoriedAs` can't be a container or packed resource.
    148 
    149 
    150 ### Raise Events
    151 
    152 `raise` events are pretty much require and have the same side-effects as
    153 `produce` events, but they can't have `outputOf` (or `inputOf`).
    154 
    155 The semantic meaning of `raise`, hower is different than `produce`.
    156 
    157 
    158 ### Consume Events
    159 
    160 `consume` events are used for... consuming stuff.  This does not only mean
    161 something like consuming seeds to plant crops; it can also mean separating a
    162 resource that have quantities of five pieces into five individual pieces (in
    163 that case, you'd `consume` the resource that have five pieces, and `produce` five
    164 individual pieces).
    165 
    166 Generally used with `produce`, `work`, `use`, and `cite` events together to
    167 create a meaningful scenario.
    168 
    169 The events require `inputOf`, `resourceInventoriedAs`, and `resourceQuantity`
    170 to be provided, and that the `provider` and `receiver` are the same agents.
    171 
    172 It'll decrease the quantities of the resource `resourceInventoriedAs`, but these
    173 requirements must be met:
    174 
    175 * The `provider` and `receiver` must be the same agent as the
    176   `primaryAccountable` and `custodian` of the resource `resourceInventoriedAs`.
    177 * The `resourceQuantity.hasUnit` of the event must be the same as
    178   `accountingQuantity.hasUnit` and `onhandQuantity.hasUnit` of the resource
    179   `resourceInventoriedAs`.
    180 * The `resourceInventoriedAs` can't be a container or packed resource.
    181 
    182 
    183 ### Lower Events
    184 
    185 `lower` events are pretty much require and have the same side-effects as
    186 `consume` events, but they can't have `inputOf` (or `outputOf`).
    187 
    188 The semantic meaning of `lower`, hower is different than `consume`.
    189 
    190 
    191 ### Use Events
    192 
    193 `use` events are used for... using stuff.  The stuff you use are either an
    194 actual resource or its specification.
    195 
    196 Generally used with `produce`, `consume`, `work`, and `cite` events together to
    197 create a meaningful scenario.
    198 
    199 The events require `inputOf`, `effortQuantity`, and either
    200 `resourceInventoriedAs` or `resourceConformsTo` (they're mutally-exclusive).
    201 Optionally, you can also provide `resourceQuantity`.
    202 
    203 If you choose to have `resourceInventoriedAs`, these requirements must be met:
    204 
    205 * The `resourceQuantity.hasUnit` of the event must be the same as
    206   `accountingQuantity.hasUnit` and `onhandQuantity.hasUnit` of the resource
    207   `resourceInventoriedAs`
    208 * The `resourceInventoriedAs` can't be a container or packed resource.
    209 
    210 
    211 ### Work Events
    212 
    213 `work` events are used for indicating labor power used in a process.  This can
    214 be the "repairing" in a car repairing scenario, "kneading" in a making a pie
    215 scenario.
    216 
    217 Generally used with `produce`, `consume`, `use`, and `cite` events together to
    218 create a meaningful scenario.
    219 
    220 The events require `inputOf`, `effortQuantity`, and `resourceConformsTo`.
    221 
    222 
    223 ### Cite Events
    224 
    225 `cite` events are used for indicating the usage of instructions, blueprints and
    226 the like.  They are used resourced but not consumed (that is, decreasing
    227 quantities).
    228 
    229 Generally used with `produce`, `consume`, `use`, and `work` events together to
    230 create a meaningful scenario.
    231 
    232 The events require `inputOf`, and `resourceQuantity`, and `resourceConformsTo`
    233 or `resourceInventoriedAs` (they're mutually-exclusive).
    234 
    235 If you choose to have `resourceInventoriedAs`, these requirements must be met:
    236 
    237 * The `resourceQuantity.hasUnit` of the event must be the same as
    238   `accountingQuantity.hasUnit` and `onhandQuantity.hasUnit` of the resource
    239 * The `resourceInventoriedAs` can't be a container or packed resource.
    240 
    241 
    242 ### DeliverService Events
    243 
    244 `deliverService` events are used for indicating delivered services, such as
    245 transportation of apples, painting the walls of the house.
    246 
    247 The events require `inputOf` and/or `outputOf`, and
    248 `resourceConformsTo`.  If both of `inputOf` and `outputOf` are provided, they
    249 must refer to different Processes.
    250 
    251 
    252 ### Pickup and Dropoff Events
    253 
    254 `pickup` and `dropoff` events are used in pairs to transport resources from one
    255 location to another.
    256 
    257 `pickup` and `dropoff` events are paired through the resource
    258 `resourceInventoriedAs`.  If they both refer to the same resource, they are
    259 paired.  That's the definition of "pair" here.
    260 
    261 The `pickup` events require `inputOf`, `resourceQuantity`, and
    262 `resourceInventoriedAs`, and that the `provider` and `receiver` are the same
    263 agents.
    264 
    265 The `pickup` events also require that:
    266 
    267 * The `provider` is the same agent as the `custodian` of the resource
    268   `resourceInventoriedAs`
    269 * The `resourceInventoriedAs` can't be a packed resource
    270 * The `resourceQuantity.hasUnit` of the event must be the same as
    271   `onhandQuantity.hasUnit` of the resource `resourceInventoriedAs`
    272 * The `onhandQuantity.hasNumericalValue` of the resource is positive
    273 * The `resourceQuantity.hasNumericalValue` of the event must be the same as
    274   `onhandQuantity.hasNumericalValue` of the resource `resourceInventoriedAs`
    275 * There is no other `pickup` event that refers to the same resource
    276   `resourceInventoriedAs` in the same process
    277 
    278 The `dropoff` events requires `outputOf`, `resourceQuantity`, and
    279 `resourceInventoriedAs`, and that the `provider` and `receiver` are the same
    280 agents.
    281 
    282 The `dropoff` events also requires that:
    283 
    284 * There is exactly one `pickup` event referring to the same resource
    285   `resourceInventoriedAs` in the same process.  Due to this, most of the
    286   `pickup` events requrimenst apply here out of the box
    287 * The `provider` is the same agent as the `provider` of the paired event
    288 * There is no other `dropoff` events that refer to the same resource
    289   `resourceInventoriedAs` in the same process
    290 * The `resourceQuantity.hasUnit` of the event must be the same as
    291   the paired `pickup` event's `resourceQuantity.hasUnit`
    292 
    293 If `toLocation` is provided, `dropoff` events will set the `currentLocation` of
    294 the resource `resourceInventoriedAs`.  If the resource `resourceInventoriedAs`
    295 is a container, it'll also set the `currentLocation` of all the contained
    296 resources.
    297 
    298 I'm thinking to add another validation logic here: until the resource
    299 `resourceInventoriedAs` is `dropoff`'ed, any other event that are not in the
    300 same process won't be able to affect it (as in `consume`, `cite`, `use`,
    301 `transfer`, and so on).
    302 
    303 
    304 ### Accept and Modify Events
    305 
    306 `accept` and `modify` events are used in pairs and have the follow
    307 functionalities:
    308 
    309 * set a resource's `stage` field
    310 * specify the container resource used for `pack` and `unpack`
    311 
    312 `accept` and `modify` events are paired through the resource
    313 `resourceInventoriedAs`.  If they both refer to the same resource, they are
    314 paired.  That's the definition of "pair" here.
    315 
    316 The `accept` events require `inputOf`, `resourceQuantity`, and
    317 `resourceInventoriedAs`, and that the `provider` and `receiver` are the same
    318 agents.
    319 
    320 The `accept` events also require that:
    321 
    322 * The `provider` is the same agent as the `custodian` of the resource
    323   `resourceInventoriedAs`
    324 * The `resourceInventoriedAs` can't be a packed resource.
    325 * There is no other `accept` event that refers to the same resource
    326   `resourceInventoriedAs` in the same process
    327 * The `resourceQuantity.hasUnit` of the event must be the same as
    328   `onhandQuantity.hasUnit` of the resource `resourceInventoriedAs`
    329 * There is no `pack` or `unpack` events in the same process
    330 * If the resource `resourceInventoriedAs` is a contanier, the
    331   `onhandQuantity.hasNumericalValue` of the resource is positive
    332 * If the resource `resourceInventoriedAs` is a container, the
    333   `resourceQuantity.hasNumericalValue` of the event must be the same as
    334   `onhandQuantity.hasNumericalValue` of the resource
    335 
    336 If these requirements above are met, the `onhandQuantity.hasNumericalValue` of
    337 the resource `resourceInventoriedAs` will be decreased by
    338 `resourceQuantity.hasNumericalValue` of the event.
    339 
    340 The `modify` events require `outputOf`, `resourceQuantity`, and
    341 `resourceInventoriedAs`, and that the `provider` and `receiver` are the same
    342 agents.
    343 
    344 The `modify` events also require that:
    345 
    346 * There is exactly one `accept` event referring to the same resource
    347   `resourceInventoriedAs` in the same process.  Due to this, most of the
    348   `accept` events requrimenst apply here out of the box
    349 * The `provider` is the same agent as the `provider` of the paired event
    350 * The `resourceQuantity.hasUnit` of the event must be the same as
    351   the paired `accept` event's `resourceQuantity.hasUnit`
    352 * There is no other `modify` events that refer to the same resource
    353   `resourceInventoriedAs` in the same process
    354 * The `resourceQuantity.hasNumericalValue` of the event must be the same as
    355   the paired `accept` event's `resourceQuantity.hasNumericalValue`
    356 
    357 If these requirements above are met, the `onhandQuantity.hasNumericalValue` of
    358 the resource `resourceInventoriedAs` will be increased by
    359 `resourceQuantity.hasNumericalValue` of the event, and the resource's `stage`
    360 will be set to the same ProcessesSpecification of the current Process (`basedOn`
    361 field of the Process).  Note that this also includes the `null` value.
    362 
    363 
    364 ### Pack and Unpack Events
    365 
    366 `pack` and `unpack` events are *not* used in pairs, even though it kinda sounds
    367 like that.  `pack` events put a resource into a container resource, `unpack`
    368 events take them out.
    369 
    370 The `pack` events require `inputOf`, and `resourceInventoriedAs`, and that the
    371 `provider` and `receiver` are the same agents.
    372 
    373 The `pack` events also require that:
    374 
    375 * There's exactly one `accept` event in the same process.  It requires it
    376   beforehand so that the back-end can see what container is used with this
    377 * The `provider` is the same agent as the `custodian` of the resource
    378   `resourceInventoriedAs`
    379 * The `resourceInventoriedAs` can't be an already-packed resource
    380 * There is no `unpack` events in the same process
    381 
    382 If these requirements above are met, the `containedIn` of the resource
    383 `resourceInventoriedAs` will be set to `resourceInventoriedAs` of the accept
    384 event in the process.
    385 
    386 The `unpack` events require `outputOf`, and `resourceInventoriedAs`, and that the
    387 `provider` and `receiver` are the same agents.
    388 
    389 The `unpack` events also require that:
    390 
    391 * There's exactly one `accept` event in the same process.  It requires it
    392   beforehand so that the back-end can see what container is used with this
    393 * The `provider` is the same agent as the `custodian` of the resource
    394   `resourceInventoriedAs`
    395 * The resource `resourceInventoriedAs` is actually in the container provided by
    396   the `accept` event
    397 * There is no `pack` events in the same process
    398 
    399 If these requirements above are met, the `containedIn` of the resource
    400 `resourceInventoriedAs` will be set to `null`.
    401 
    402 
    403 ### TransferCustody Events
    404 
    405 `transferCustody` events transfer the custody ownership, that is, `custodian`
    406 and thus, it only affects `onhandQuantity`.
    407 
    408 There are two things a `transferCustody` event can do:
    409 
    410 * when only `resourceInventoriedAs` is provided, it'll create a new resource on
    411   the other end
    412 * when both `resourceInventoriedAs` and `toResourceInventoriedAs` are provided,
    413   it'll increase the `onhandQuantity` of `toResourceInventoriedAs` while
    414   decreasing `resourceInventoriedAs`'s
    415 
    416 In any case, they require `resourceInventoriedAs`, `resourceQuantity` and,
    417 optionally if you want to "transfer into" another resource,
    418 `toResourceInventoriedAs`.
    419 
    420 If only `resourceInventoriedAs` is provided, you need to fulfill these
    421 requirements:
    422 
    423 * The `provider` is the same agent as the `custodian` of the resource
    424   `resourceInventoriedAs`
    425 * The `resourceInventoriedAs` can't be a packed resource
    426 * The `resourceQuantity.hasUnit` of the event must be the same as
    427   `onhandQuantity.hasUnit` of the resource `resourceInventoriedAs`
    428 * If the resource `resourceInventoriedAs` is a container, the
    429   `onhandQuantity.hasNumericalValue` of the resource must be postitive
    430 * If the resource `resourceInventoriedAs` is a container,
    431   `resourceQuantity.hasNumericalValue` of the event must be the same as
    432   `onhandQuantity.hasNumericalValue` of the resource
    433 
    434 If these requirements above are met, it'll create a new resource that will:
    435 
    436 * have `onhandQuantity.hasUnit` and `onhandQuantity.hasNumericalValue` set from
    437   `resourceQuantity` of the event
    438 * have `accountingQuantity.hasNumericalValue` set to `0` and
    439   `accountingQuantity.hasUnit` set to `resourceQuantity.hasUnit` of the event
    440 * have `currentLocation` set to `toLocation` of the event, if it is available
    441 * have all the other fields copied from the resource `resourceInventoriedAs`,
    442   except for `name`, `note`, `trackingIdentifier` if they are provided by
    443   `newInventoriedResource` when creating the event
    444 
    445 It'll also decrease the `onhandQuantity.hasNumericalValue` of the resourece
    446 `resourceInventoriedAs` by `resourceQuantity.hasNumericalValue` of the event.
    447 And if the resource `resourceInventoriedAs` was a container, the packed resources'
    448 `containedIn` will be set to the newly created resource and `custodian` set to
    449 `receiver` of the event.
    450 
    451 If both `resourceInventoriedAs` and `toResourceInventoriedAs` are provided, you
    452 need to fulfill these requirements:
    453 
    454 * The `provider` is the same agent as the `custodian` of the resource
    455   `resourceInventoriedAs`
    456 * The `resourceInventoriedAs` and `toResourceInventoriedAs` can't be a packed
    457   resource
    458 * The `resourceQuantity.hasUnit` of the event must be the same as
    459   `onhandQuantity.hasUnit` of the resource `resourceInventoriedAs` and
    460   `toResourceInventoriedAs`
    461 * The `resourceInventoriedAs.conformsTo` and
    462   `toResourceInventoriedAs.conformsTo` must bethe same
    463 * If the resource `resourceInventoriedAs` is a container, the
    464   `onhandQuantity.hasNumericalValue` of the resource must be postitive
    465 * If the resource `resourceInventoriedAs` is a container,
    466   `resourceQuantity.hasNumericalValue` of the event must be the same as
    467   `onhandQuantity.hasNumericalValue` of the resource
    468 
    469 If these requirements above are met, it'll increase the
    470 `onhandQuantity.hasNumericalValue` of the resource `toResourceInventoriedAs`
    471 while decreasing `onhandQuantity.hasNumericalValue` of `resourceInventoriedAs`
    472 by `resourceQuantity.hasNumericalValue` of the event.  And if the resource
    473 `resourceInventoriedAs` was a container, the packed resources' `containedIn`
    474 will be set to `toResourceInventoriedAs` and `custodian` set to `receiver` of
    475 the event.
    476 
    477 
    478 ### TransferAllRights Events
    479 
    480 `transferAllRight` events transfer the accounting ownership, that is,
    481 `primaryAccountable` and thus, it only affects `accountingQuantity`.
    482 
    483 There are two things a `transferAllRight` event can do:
    484 
    485 * when only `resourceInventoriedAs` is provided, it'll create a new resource on
    486   the other end
    487 * when both `resourceInventoriedAs` and `toResourceInventoriedAs` are provided,
    488   it'll increase the `accountingQuantity` of `toResourceInventoriedAs` while
    489   decreasing `resourceInventoriedAs`'s
    490 
    491 In any case, they require `resourceInventoriedAs`, `resourceQuantity` and,
    492 optionally if you want to "transfer into" another resource,
    493 `toResourceInventoriedAs`.
    494 
    495 If only `resourceInventoriedAs` is provided, you need to fulfill these
    496 requirements:
    497 
    498 * The `provider` is the same agent as the `primaryAccountable` of the resource
    499   `resourceInventoriedAs`
    500 * The `resourceInventoriedAs` can't be a packed resource
    501 * The `resourceQuantity.hasUnit` of the event must be the same as
    502   `accountingQuantity.hasUnit` of the resource `resourceInventoriedAs`
    503 * If the resource `resourceInventoriedAs` is a container, the
    504   `accountingQuantity.hasNumericalValue` of the resource must be postitive
    505 * If the resource `resourceInventoriedAs` is a container,
    506   `resourceQuantity.hasNumericalValue` of the event must be the same as
    507   `accountingQuantity.hasNumericalValue` of the resource
    508 
    509 If these requirements above are met, it'll create a new resource that will:
    510 
    511 * have `accountingQuantity.hasUnit` and `accountingQuantity.hasNumericalValue`
    512   set from `resourceQuantity` of the event
    513 * have `onhandQuantity.hasNumericalValue` set to `0` and
    514   `onhandQuantity.hasUnit` set to `resourceQuantity.hasUnit` of the event
    515 * have all the other fields copied from the resource `resourceInventoriedAs`,
    516   except for `name`, `note`, `trackingIdentifier` if they are provided by
    517   `newInventoriedResource` when creating the event
    518 
    519 It'll also decrease the `accountingQuantity.hasNumericalValue` of the resourece
    520 `resourceInventoriedAs` by `resourceQuantity.hasNumericalValue` of the event.
    521 And if the resource `resourceInventoriedAs` was a container, the packed resources'
    522 `containedIn` will be set to the newly created resource and `primaryAccountable`
    523 set to `receiver` of the event.
    524 
    525 If both `resourceInventoriedAs` and `toResourceInventoriedAs` are provided, you
    526 need to fulfill these requirements:
    527 
    528 * The `provider` is the same agent as the `primaryAccountable` of the resource
    529   `resourceInventoriedAs`
    530 * The `resourceInventoriedAs` and `toResourceInventoriedAs` can't be a packed
    531   resource
    532 * The `resourceQuantity.hasUnit` of the event must be the same as
    533   `accountingQuantity.hasUnit` of the resource `resourceInventoriedAs` and
    534   `toResourceInventoriedAs`
    535 * The `resourceInventoriedAs.conformsTo` and
    536   `toResourceInventoriedAs.conformsTo` must bethe same
    537 * If the resource `resourceInventoriedAs` is a container, the
    538   `accountingQuantity.hasNumericalValue` of the resource must be postitive
    539 * If the resource `resourceInventoriedAs` is a container,
    540   `resourceQuantity.hasNumericalValue` of the event must be the same as
    541   `accountingQuantity.hasNumericalValue` of the resource
    542 
    543 If these requirements above are met, it'll increase the
    544 `accountingQuantity.hasNumericalValue` of the resource `toResourceInventoriedAs`
    545 while decreasing `accountingQuantity.hasNumericalValue` of
    546 `resourceInventoriedAs` by `resourceQuantity.hasNumericalValue` of the event.
    547 And if the resource `resourceInventoriedAs` was a container, the packed
    548 resources' `containedIn` will be set to `toResourceInventoriedAs` and
    549 `primaryAccountable` set to `receiver` of the event.
    550 
    551 
    552 ### Transfer Events
    553 
    554 `transfer` events transfer the both types of ownership, that is,
    555 `primaryAccountable` and `custodian` and thus, it affects both
    556 `accountingQuantity` and `onhandQuantity`.
    557 
    558 There are two things a `transfer` event can do:
    559 
    560 * when only `resourceInventoriedAs` is provided, it'll create a new resource on
    561   the other end
    562 * when both `resourceInventoriedAs` and `toResourceInventoriedAs` are provided,
    563   it'll increase the `accountingQuantity` and `onhandQuantity` of
    564   `toResourceInventoriedAs` while decreasing `resourceInventoriedAs`'s
    565 
    566 In any case, they require `resourceInventoriedAs`, `resourceQuantity` and,
    567 optionally if you want to "transfer into" another resource,
    568 `toResourceInventoriedAs`.
    569 
    570 If only `resourceInventoriedAs` is provided, you need to fulfill these
    571 requirements:
    572 
    573 * The `provider` is the same agent as the `primaryAccountable` and `custodian`
    574   of the resource `resourceInventoriedAs`
    575 * The `resourceInventoriedAs` can't be a packed resource
    576 * The `resourceQuantity.hasUnit` of the event must be the same as
    577   `accountingQuantity` and `onhandQuantity.hasUnit` of the resource
    578   `resourceInventoriedAs`
    579 * If the resource `resourceInventoriedAs` is a container, the
    580   `accountingQuantity.hasNumericalValue` and `onhandQuantity.hasNumericalValue`
    581   of the resource must be postitive
    582 * If the resource `resourceInventoriedAs` is a container,
    583   `resourceQuantity.hasNumericalValue` of the event must be the same as
    584   `accountingQuantity.hasNumericalValue` and `onhandQuantity.hasNumericalValue`
    585   of the resource
    586 
    587 If these requirements above are met, it'll create a new resource that will:
    588 
    589 * have `accountingQuantity.hasUnit`, `accountingQuantity.hasNumericalValue`,
    590   `onhandQuantity.hasUnit`, and `onhandQuantity.hasNumericalValue` set from
    591   `resourceQuantity` of the event
    592 * have all the other fields copied from the resource `resourceInventoriedAs`,
    593   except for `name`, `note`, `trackingIdentifier` if they are provided by
    594   `newInventoriedResource` when creating the event
    595 
    596 It'll also decrease the `accountingQuantity.hasNumericalValue` and
    597 `onhandQuantity.hasNumericalValue` of the resourece `resourceInventoriedAs` by
    598 `resourceQuantity.hasNumericalValue` of the event.
    599 And if the resource `resourceInventoriedAs` was a container, the packed resources'
    600 `containedIn` will be set to the newly created resource, and `primaryAccountable`
    601 and `custodian` set to `receiver` of the event.
    602 
    603 If both `resourceInventoriedAs` and `toResourceInventoriedAs` are provided, you
    604 need to fulfill these requirements:
    605 
    606 * The `provider` is the same agent as the `primaryAccountable` and `custodian`
    607   of the resource `resourceInventoriedAs`
    608 * The `resourceInventoriedAs` and `toResourceInventoriedAs` can't be a packed
    609   resource
    610 * The `resourceQuantity.hasUnit` of the event must be the same as
    611   `accountingQuantity` and `onhandQuantity.hasUnit` of the resource
    612   `resourceInventoriedAs` and `toResourceInventoriedAs`
    613 * The `resourceInventoriedAs.conformsTo` and
    614   `toResourceInventoriedAs.conformsTo` must bethe same
    615 * If the resource `resourceInventoriedAs` is a container, the
    616   `accountingQuantity.hasNumericalValue` and `onhandQuantity.hasNumericalValue`
    617   of the resource must be postitive
    618 * If the resource `resourceInventoriedAs` is a container,
    619   `resourceQuantity.hasNumericalValue` of the event must be the same as
    620   `accountingQuantity.hasNumericalValue` and `onhandQuantity.hasNumericalValue`
    621   of the resource
    622 
    623 If these requirements above are met, it'll increase the
    624 `accountingQuantity.hasNumericalValue` and `onhandQuantity.hasNumericalValue` of
    625 the resource `toResourceInventoriedAs` while decreasing
    626 `accountingQuantity.hasNumericalValue` and `onhandQuantity.hasNumericalValue` of
    627 `resourceInventoriedAs` by `resourceQuantity.hasNumericalValue` of the event.
    628 And if the resource `resourceInventoriedAs` was a container, the packed
    629 resources' `containedIn` will be set to `toResourceInventoriedAs`, and
    630 `primaryAccountable` and `custodian` set to `receiver` of the event.
    631 
    632 
    633 ### Move Events
    634 
    635 `move` events are used for internal dividing and such.  When companed to
    636 `transfer`, it is similar to what `produce` is to `raise` and what `consume` is
    637 to `lower`
    638 
    639 The only differenece between `move` and `transfer` in the back-end is that
    640 `move` requires both the `provider` and `receiver` be the same person.
    641 
    642 
    643 ## Examples
    644 
    645 
    646 ### Produce Examples
    647 Harvesting apples from a tree farm.
    648 
    649 Give:
    650 ```
    651 mutation {
    652   createEconomicEvent(
    653     event: {
    654       action: "produce"
    655       provider: "01FWN12XX7TJX1AFF5KA4WPNN9" # bob
    656       receiver: "01FWN12XX7TJX1AFF5KA4WPNN9" # bob
    657       outputOf: "01FWN136SPDMKWWF23SWQZRM5F" # harvesting apples process
    658       resourceConformsTo: "01FWN136Y4ZZ7K9F314HQ7MKRG" # apple
    659       resourceQuantity: {
    660         hasNumericalValue: 50
    661         hasUnit: "01FWN136S5VPCCR3B3TGYDYEY9" # kilogram
    662       }
    663       atLocation: "01FWN136ZAPQ5ENBF3FZ79935D" # bob's farm
    664       hasPointInTime: "2022-01-02T03:04:05Z"
    665     }
    666     newInventoriedResource: {
    667       name: "bob's apples"
    668       note: "bob's delish apples"
    669       trackingIdentifier: "lot 123"
    670       currentLocation: "01FWN136ZAPQ5ENBF3FZ79935D" # bob's farm
    671       stage: "01FWN136X183DM43CTWXESNWAB" # fresh
    672     }
    673   ) {
    674     economicEvent {
    675       id
    676       action {id}
    677       provider {id}
    678       receiver {id}
    679       outputOf {id}
    680       resourceConformsTo {id}
    681       resourceQuantity {
    682         hasNumericalValue
    683         hasUnit {id}
    684       }
    685       atLocation {id}
    686       hasPointInTime
    687     }
    688     economicResource { # this is the newly-created resource
    689       id
    690       name
    691       note
    692       trackingIdentifier
    693       stage {id}
    694       currentLocation {id}
    695       conformsTo {id}
    696       primaryAccountable {id}
    697       custodian {id}
    698       accountingQuantity {
    699         hasNumericalValue
    700         hasUnit {id}
    701       }
    702       onhandQuantity {
    703         hasNumericalValue
    704         hasUnit {id}
    705       }
    706     }
    707   }
    708 }
    709 ```
    710 
    711 Get:
    712 ```
    713 {
    714   "data": {
    715     "createEconomicEvent": {
    716       "economicEvent": {
    717         "id: "01FWN16MMRPWEWCWHGNNH9TCTK",
    718         "action": {"id": "produce"},
    719         "provider": {"id": "01FWN12XX7TJX1AFF5KA4WPNN9"}, # bob
    720         "receiver": {"id": "01FWN12XX7TJX1AFF5KA4WPNN9"}, # bob
    721         "outputOf": {"id": "01FWN136SPDMKWWF23SWQZRM5F"}, # harvesting apples process
    722         "resourceConformsTo": {"id": "01FWN136Y4ZZ7K9F314HQ7MKRG"}, # apple
    723         "resourceQuantity": {
    724           "hasNumericalValue": 50,
    725           "hasUnit": {"id": "01FWN136S5VPCCR3B3TGYDYEY9"} # kilogram
    726         },
    727         "atLocation": {"id": "01FWN136ZAPQ5ENBF3FZ79935D"}, # bob's farm
    728         "hasPointInTime": "2022-01-02T03:04:05.000000Z"
    729       },
    730       "economicResource": {
    731         "id": "01FWN16MMVVVWEWTMC6Z5PMCM0",
    732         "name": "bob's apples",
    733         "note": "bob's delish apples",
    734         "trackingIdentifier": "lot 123",
    735         "stage": {"id": "01FWN136X183DM43CTWXESNWAB"}, # fresh
    736         "currentLocation": {"id": "01FWN136ZAPQ5ENBF3FZ79935D"}, # bob's farm
    737         "conformsTo": {"id": "01FWN136Y4ZZ7K9F314HQ7MKRG"}, # apple
    738         "primaryAccountable": {"id": "01FWN12XX7TJX1AFF5KA4WPNN9"}, # bob
    739         "custodian": {"id": "01FWN12XX7TJX1AFF5KA4WPNN9"}, # bob
    740         "accountingQuantity": {
    741           "hasNumericalValue": 50,
    742           "hasUnit": {"id": "01FWN136S5VPCCR3B3TGYDYEY9"} # kilogram
    743         },
    744         "onhandQuantity": {
    745           "hasNumericalValue": 50,
    746           "hasUnit": {"id": "01FWN136S5VPCCR3B3TGYDYEY9"} # kilogram
    747         }
    748       }
    749     }
    750   }
    751 }
    752 ```
    753 
    754 Harvesting apples, but using the existing apple resource (created above).
    755 
    756 Give:
    757 ```
    758 mutation {
    759   createEconomicEvent(event: {
    760       action: "produce"
    761       provider: "01FWN12XX7TJX1AFF5KA4WPNN9" # bob
    762       receiver: "01FWN12XX7TJX1AFF5KA4WPNN9" # bob
    763       outputOf: "01FWN136SPDMKWWF23SWQZRM5F" # harvesting apples process
    764       resourceConformsTo: "01FWN136Y4ZZ7K9F314HQ7MKRG" # apple
    765       resourceQuantity: {
    766         hasNumericalValue: 15
    767         hasUnit: "01FWN136S5VPCCR3B3TGYDYEY9" # kilogram
    768       }
    769       resourceInventoriedAs: "01FWN16MMVVVWEWTMC6Z5PMCM0" # resource "bob's apples"
    770       atLocation: "01FWN136ZAPQ5ENBF3FZ79935D" # bob's farm
    771       hasPointInTime: "2022-01-02T03:04:05Z"
    772   }) {
    773     economicEvent {
    774       id
    775       action {id}
    776       provider {id}
    777       receiver {id}
    778       outputOf {id}
    779       resourceConformsTo {id}
    780       resourceQuantity {
    781         hasNumericalValue
    782         hasUnit {id}
    783       }
    784       resourceInventoriedAs { # this is the already-existing resource "bob's apples"
    785         id
    786         name
    787         note
    788         trackingIdentifier
    789         stage {id}
    790         currentLocation {id}
    791         conformsTo {id}
    792         primaryAccountable {id}
    793         custodian {id}
    794         accountingQuantity {
    795           hasNumericalValue
    796           hasUnit {id}
    797         }
    798         onhandQuantity {
    799           hasNumericalValue
    800           hasUnit {id}
    801         }
    802       }
    803       atLocation {id}
    804       hasPointInTime
    805     }
    806   }
    807 }
    808 ```
    809 
    810 Get:
    811 ```
    812 {
    813   "data": {
    814     "createEconomicEvent": {
    815       "economicEvent": {
    816         "id: "01FWN2Z7XNACJBT2K4TR9EM40W",
    817         "action": {"id": "produce"},
    818         "provider": {"id": "01FWN12XX7TJX1AFF5KA4WPNN9"}, # bob
    819         "receiver": {"id": "01FWN12XX7TJX1AFF5KA4WPNN9"}, # bob
    820         "outputOf": {"id": "01FWN136SPDMKWWF23SWQZRM5F"}, # harvesting apples process
    821         "resourceConformsTo": {"id": "01FWN136Y4ZZ7K9F314HQ7MKRG"}, # apple
    822         "resourceQuantity": {
    823           "hasNumericalValue": 15,
    824           "hasUnit": {"id": "01FWN136S5VPCCR3B3TGYDYEY9"} # kilogram
    825         },
    826         "atLocation": {"id": "01FWN136ZAPQ5ENBF3FZ79935D"}, # bob's farm
    827         "hasPointInTime": "2022-01-02T03:04:05.000000Z"
    828       },
    829       "economicResource": {
    830         "id": "01FWN16MMVVVWEWTMC6Z5PMCM0",
    831         "name": "bob's apples",
    832         "note": "bob's delish apples",
    833         "trackingIdentifier": "lot 123",
    834         "stage": {"id": "01FWN136X183DM43CTWXESNWAB"}, # fresh
    835         "currentLocation": {"id": "01FWN136ZAPQ5ENBF3FZ79935D"}, # bob's farm
    836         "conformsTo": {"id": "01FWN136Y4ZZ7K9F314HQ7MKRG"}, # apple
    837         "primaryAccountable": {"id": "01FWN12XX7TJX1AFF5KA4WPNN9"}, # bob
    838         "custodian": {"id": "01FWN12XX7TJX1AFF5KA4WPNN9"}, # bob
    839         "accountingQuantity": {
    840           "hasNumericalValue": 65,
    841           "hasUnit": {"id": "01FWN136S5VPCCR3B3TGYDYEY9"} # kilogram
    842         },
    843         "onhandQuantity": {
    844           "hasNumericalValue": 65,
    845           "hasUnit": {"id": "01FWN136S5VPCCR3B3TGYDYEY9"} # kilogram
    846         }
    847       }
    848     }
    849   }
    850 }
    851 ```
    852 
    853 
    854 ### Raise Examples
    855 Suppose a person joined to the instance at a later time.  But they already have
    856 some resources they want to import.  You can use `raise` events for that.
    857 
    858 Give:
    859 ```
    860 mutation {
    861   createEconomicEvent(
    862     event: {
    863       action: "raise"
    864       provider: "01FWN3QA3Q2G0JNYHBCCBEN76H" # alice
    865       receiver: "01FWN3QA3Q2G0JNYHBCCBEN76H" # alice
    866       resourceConformsTo: "01FWN136Y4ZZ7K9F314HQ7MKRG" # apple
    867       resourceQuantity: {
    868         hasNumericalValue: 30
    869         hasUnit: "01FWN136S5VPCCR3B3TGYDYEY9" # kilogram
    870       }
    871       atLocation: "01FWN3VH3H8T4KHN8XC7FJ32V3" # alice's kitchen
    872       hasPointInTime: "2022-01-02T03:04:05Z"
    873     }
    874     newInventoriedResource: {
    875       name: "alice's apples"
    876       note: "alice's delish apples"
    877       trackingIdentifier: "lot 123"
    878       currentLocation: "01FWN3VH3H8T4KHN8XC7FJ32V3" # alice's kitchen
    879       stage: "01FWN136X183DM43CTWXESNWAB" # fresh
    880     }
    881   ) {
    882     economicEvent {
    883       id
    884       action {id}
    885       provider {id}
    886       receiver {id}
    887       resourceConformsTo {id}
    888       resourceQuantity {
    889         hasNumericalValue
    890         hasUnit {id}
    891       }
    892       atLocation {id}
    893       hasPointInTime
    894     }
    895     economicResource { # this is the newly-created resource
    896       id
    897       name
    898       note
    899       trackingIdentifier
    900       stage {id}
    901       currentLocation {id}
    902       conformsTo {id}
    903       primaryAccountable {id}
    904       custodian {id}
    905       accountingQuantity {
    906         hasNumericalValue
    907         hasUnit {id}
    908       }
    909       onhandQuantity {
    910         hasNumericalValue
    911         hasUnit {id}
    912       }
    913     }
    914   }
    915 }
    916 ```
    917 
    918 Get:
    919 ```
    920 {
    921   "data": {
    922     "createEconomicEvent": {
    923       "economicEvent": {
    924         "id: "01FWN3YAT32CGRFJG827XWTSWY",
    925         "action": {"id": "raise"},
    926         "provider": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
    927         "receiver": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
    928         "resourceConformsTo": {"id": "01FWN136Y4ZZ7K9F314HQ7MKRG"}, # apple
    929         "resourceQuantity": {
    930           "hasNumericalValue": 30,
    931           "hasUnit": {"id": "01FWN136S5VPCCR3B3TGYDYEY9"} # kilogram
    932         },
    933         "atLocation": {"id": "01FWN3VH3H8T4KHN8XC7FJ32V3"}, # alice's kitchen
    934         "hasPointInTime": "2022-01-02T03:04:05.000000Z"
    935       },
    936       "economicResource": {
    937         "id": "01FWN3ZY2Z8ZJ071YXJ315KC2W",
    938         "name": "alice's apples",
    939         "note": "alice's delish apples",
    940         "trackingIdentifier": "lot 123",
    941         "stage": {"id": "01FWN136X183DM43CTWXESNWAB"}, # fresh
    942         "currentLocation": {"id": "01FWN3VH3H8T4KHN8XC7FJ32V3"}, # alice's kitchen
    943         "conformsTo": {"id": "01FWN136Y4ZZ7K9F314HQ7MKRG"}, # apple
    944         "primaryAccountable": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
    945         "custodian": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
    946         "accountingQuantity": {
    947           "hasNumericalValue": 30,
    948           "hasUnit": {"id": "01FWN136S5VPCCR3B3TGYDYEY9"} # kilogram
    949         },
    950         "onhandQuantity": {
    951           "hasNumericalValue": 30,
    952           "hasUnit": {"id": "01FWN136S5VPCCR3B3TGYDYEY9"} # kilogram
    953         }
    954       }
    955     }
    956   }
    957 }
    958 ```
    959 
    960 Found more apples?  Add them to the stack!
    961 
    962 Give:
    963 ```
    964 mutation {
    965   createEconomicEvent(event: {
    966     action: "raise"
    967     provider: "01FWN3QA3Q2G0JNYHBCCBEN76H" # alice
    968     receiver: "01FWN3QA3Q2G0JNYHBCCBEN76H" # alice
    969     resourceConformsTo: "01FWN136Y4ZZ7K9F314HQ7MKRG" # apple
    970     resourceQuantity: {
    971       hasNumericalValue: 15
    972       hasUnit: "01FWN136S5VPCCR3B3TGYDYEY9" # kilogram
    973     }
    974     resourceInventoriedAs: "01FWN3ZY2Z8ZJ071YXJ315KC2W" # resource "alice's apples"
    975     atLocation: "01FWN3VH3H8T4KHN8XC7FJ32V3" # alice's kitchen
    976     hasPointInTime: "2022-01-02T03:04:05Z"
    977   }) {
    978     economicEvent {
    979       id
    980       action {id}
    981       provider {id}
    982       receiver {id}
    983       resourceConformsTo {id}
    984       resourceQuantity {
    985         hasNumericalValue
    986         hasUnit {id}
    987       }
    988       resourceInventoriedAs { # this is the already-existing resource "bob's apples"
    989         id
    990         name
    991         note
    992         trackingIdentifier
    993         stage {id}
    994         currentLocation {id}
    995         conformsTo {id}
    996         primaryAccountable {id}
    997         custodian {id}
    998         accountingQuantity {
    999           hasNumericalValue
   1000           hasUnit {id}
   1001         }
   1002         onhandQuantity {
   1003           hasNumericalValue
   1004           hasUnit {id}
   1005         }
   1006       }
   1007       atLocation {id}
   1008       hasPointInTime
   1009     }
   1010   }
   1011 }
   1012 ```
   1013 
   1014 Get:
   1015 ```
   1016 {
   1017   "data": {
   1018     "createEconomicEvent": {
   1019       "economicEvent": {
   1020         "id: "01FWN3ZY2Z8ZJ071YXJ315KC2W",
   1021         "action": {"id": "raise"},
   1022         "provider": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
   1023         "receiver": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
   1024         "resourceConformsTo": {"id": "01FWN136Y4ZZ7K9F314HQ7MKRG"}, # apple
   1025         "resourceQuantity": {
   1026           "hasNumericalValue": 15,
   1027           "hasUnit": {"id": "01FWN136S5VPCCR3B3TGYDYEY9"} # kilogram
   1028         },
   1029         "resourceInventoriedAs": {
   1030           "id": "01FWN3ZY2Z8ZJ071YXJ315KC2W",
   1031           "name": "alice's apples",
   1032           "note": "alice's delish apples",
   1033           "trackingIdentifier": "lot 123",
   1034           "stage": {"id": "01FWN136X183DM43CTWXESNWAB"}, # fresh
   1035           "currentLocation": {"id": "01FWN3VH3H8T4KHN8XC7FJ32V3"}, # alice's kitchen
   1036           "conformsTo": {"id": "01FWN136Y4ZZ7K9F314HQ7MKRG"}, # apple
   1037           "primaryAccountable": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
   1038           "custodian": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
   1039           "accountingQuantity": {
   1040             "hasNumericalValue": 45,
   1041             "hasUnit": {"id": "01FW15136S5VPCCR3B3TGYDYEY9"} # kilogram
   1042           },
   1043           "onhandQuantity": {
   1044             "hasNumericalValue": 45,
   1045             "hasUnit": {"id": "01FWN136S5VPCCR3B3TGYDYEY9"} # kilogram
   1046           }
   1047         },
   1048         "atLocation": {"id": "01FWN3VH3H8T4KHN8XC7FJ32V3"}, # alice's kitchen
   1049         "hasPointInTime": "2022-01-02T03:04:05.000000Z"
   1050       }
   1051     }
   1052   }
   1053 }
   1054 ```
   1055 
   1056 
   1057 ### Consume Examples
   1058 
   1059 Consume apples for making apple juice.
   1060 
   1061 Give:
   1062 ```
   1063 mutation {
   1064   createEconomicEvent(event: {
   1065     action: "consume"
   1066     provider: "01FWN3QA3Q2G0JNYHBCCBEN76H" # alice
   1067     receiver: "01FWN3QA3Q2G0JNYHBCCBEN76H" # alice
   1068     inputOf: "01FWN5SVCHH662KD10E73M221J" # process "making apple juice"
   1069     resourceInventoriedAs: "01FWN3ZY2Z8ZJ071YXJ315KC2W" # resource "alice's apples" 45kg
   1070     resourceQuantity: {
   1071       hasNumericalValue: 20
   1072       hasUnit: "01FWN136S5VPCCR3B3TGYDYEY9" # kilogram
   1073     }
   1074     atLocation: "01FWN3VH3H8T4KHN8XC7FJ32V3" # alice's kitchen
   1075     hasPointInTime: "2022-01-02T03:04:05Z"
   1076   }) {
   1077     economicEvent {
   1078       id
   1079       action {id}
   1080       provider {id}
   1081       receiver {id}
   1082       inputOf {id}
   1083       resourceInventoriedAs {
   1084         id
   1085         name
   1086         note
   1087         trackingIdentifier
   1088         stage {id}
   1089         currentLocation {id}
   1090         conformsTo {id}
   1091         primaryAccountable {id}
   1092         custodian {id}
   1093         accountingQuantity {
   1094           hasNumericalValue
   1095           hasUnit {id}
   1096         }
   1097         onhandQuantity {
   1098           hasNumericalValue
   1099           hasUnit {id}
   1100         }
   1101       }
   1102       resourceQuantity {
   1103         hasNumericalValue
   1104         hasUnit {id}
   1105       }
   1106       atLocation {id}
   1107       hasPointInTime
   1108     }
   1109   }
   1110 }
   1111 ```
   1112 
   1113 Get:
   1114 ```
   1115 {
   1116   "data": {
   1117     "createEconomicEvent": {
   1118       "economicEvent": {
   1119         "id: "01FWN6ABS0RCKEVC636N8TY58D",
   1120         "action": {"id": "consume"},
   1121         "provider": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
   1122         "receiver": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
   1123         "inputOf": {"id": "01FWN5SVCHH662KD10E73M221J"}, # process "making apple juice"
   1124         "resourceConformsTo": {"id": "01FWN136Y4ZZ7K9F314HQ7MKRG"}, # apple
   1125         "resourceQuantity": {
   1126           "hasNumericalValue": 20,
   1127           "hasUnit": {"id": "01FWN136S5VPCCR3B3TGYDYEY9"} # kilogram
   1128         },
   1129         "resourceInventoriedAs": {
   1130           "id": "01FWN3ZY2Z8ZJ071YXJ315KC2W",
   1131           "name": "alice's apples",
   1132           "note": "alice's delish apples",
   1133           "trackingIdentifier": "lot 123",
   1134           "stage": {"id": "01FWN136X183DM43CTWXESNWAB"}, # fresh
   1135           "currentLocation": {"id": "01FWN3VH3H8T4KHN8XC7FJ32V3"}, # alice's kitchen
   1136           "conformsTo": {"id": "01FWN136Y4ZZ7K9F314HQ7MKRG"}, # apple
   1137           "primaryAccountable": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
   1138           "custodian": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
   1139           "accountingQuantity": {
   1140             "hasNumericalValue": 25, # = 45 - 15
   1141             "hasUnit": {"id": "01FW15136S5VPCCR3B3TGYDYEY9"} # kilogram
   1142           },
   1143           "onhandQuantity": {
   1144             "hasNumericalValue": 25, # = 45 - 15
   1145             "hasUnit": {"id": "01FWN136S5VPCCR3B3TGYDYEY9"} # kilogram
   1146           }
   1147         },
   1148         "atLocation": {"id": "01FWN3VH3H8T4KHN8XC7FJ32V3"}, # alice's kitchen
   1149         "hasPointInTime": "2022-01-02T03:04:05.000000Z"
   1150       }
   1151     }
   1152   }
   1153 }
   1154 ```
   1155 
   1156 ### Lower Examples
   1157 
   1158 Oh, did you import 5kg of apples accidentally?  We can `lower` it!
   1159 
   1160 Give:
   1161 ```
   1162 mutation {
   1163   createEconomicEvent(event: {
   1164     action: "lower"
   1165     provider: "01FWN3QA3Q2G0JNYHBCCBEN76H" # alice
   1166     receiver: "01FWN3QA3Q2G0JNYHBCCBEN76H" # alice
   1167     resourceInventoriedAs: "01FWN3ZY2Z8ZJ071YXJ315KC2W" # resource "alice's apples" 20kg
   1168     resourceQuantity: {
   1169       hasNumericalValue: 5
   1170       hasUnit: "01FWN136S5VPCCR3B3TGYDYEY9" # kilogram
   1171     }
   1172     atLocation: "01FWN3VH3H8T4KHN8XC7FJ32V3" # alice's kitchen
   1173     hasPointInTime: "2022-01-02T03:04:05Z"
   1174   }) {
   1175     economicEvent {
   1176       id
   1177       action {id}
   1178       provider {id}
   1179       receiver {id}
   1180       resourceInventoriedAs {
   1181         id
   1182         name
   1183         note
   1184         trackingIdentifier
   1185         stage {id}
   1186         currentLocation {id}
   1187         conformsTo {id}
   1188         primaryAccountable {id}
   1189         custodian {id}
   1190         accountingQuantity {
   1191           hasNumericalValue
   1192           hasUnit {id}
   1193         }
   1194         onhandQuantity {
   1195           hasNumericalValue
   1196           hasUnit {id}
   1197         }
   1198       }
   1199       resourceQuantity {
   1200         hasNumericalValue
   1201         hasUnit {id}
   1202       }
   1203       atLocation {id}
   1204       hasPointInTime
   1205     }
   1206   }
   1207 }
   1208 ```
   1209 
   1210 Get:
   1211 ```
   1212 {
   1213   "data": {
   1214     "createEconomicEvent": {
   1215       "economicEvent": {
   1216         "id: "01FWN6ABS0RCKEVC636N8TY58D",
   1217         "action": {"id": "lower"},
   1218         "provider": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
   1219         "receiver": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
   1220         "resourceConformsTo": {"id": "01FWN136Y4ZZ7K9F314HQ7MKRG"}, # apple
   1221         "resourceQuantity": {
   1222           "hasNumericalValue": 5,
   1223           "hasUnit": {"id": "01FWN136S5VPCCR3B3TGYDYEY9"} # kilogram
   1224         },
   1225         "resourceInventoriedAs": {
   1226           "id": "01FWN3ZY2Z8ZJ071YXJ315KC2W",
   1227           "name": "alice's apples",
   1228           "note": "alice's delish apples",
   1229           "trackingIdentifier": "lot 123",
   1230           "stage": {"id": "01FWN136X183DM43CTWXESNWAB"}, # fresh
   1231           "currentLocation": {"id": "01FWN3VH3H8T4KHN8XC7FJ32V3"}, # alice's kitchen
   1232           "conformsTo": {"id": "01FWN136Y4ZZ7K9F314HQ7MKRG"}, # apple
   1233           "primaryAccountable": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
   1234           "custodian": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
   1235           "accountingQuantity": {
   1236             "hasNumericalValue": 15, # = 20 - 5
   1237             "hasUnit": {"id": "01FW15136S5VPCCR3B3TGYDYEY9"} # kilogram
   1238           },
   1239           "onhandQuantity": {
   1240             "hasNumericalValue": 15, # = 20 - 5
   1241             "hasUnit": {"id": "01FWN136S5VPCCR3B3TGYDYEY9"} # kilogram
   1242           }
   1243         },
   1244         "atLocation": {"id": "01FWN3VH3H8T4KHN8XC7FJ32V3"}, # alice's kitchen
   1245         "hasPointInTime": "2022-01-02T03:04:05.000000Z"
   1246       }
   1247     }
   1248   }
   1249 }
   1250 ```
   1251 
   1252 
   1253 ### Use Examples
   1254 
   1255 Suppose you want to make some apple juice out of... apples.  You would `consume`
   1256 some apple resources and `produce` some apple juice resources, but this story
   1257 doesn't sound quite right.  If you want to record how you did get the juice, you
   1258 could use a `use` event, specifying that you used a juicer.
   1259 
   1260 The below example demonstates that we used a juicer machine for 2 hours.
   1261 
   1262 Give:
   1263 ```
   1264 mutation {
   1265   createEconomicEvent(event: {
   1266     action: "use"
   1267     provider: "01FWN3QA3Q2G0JNYHBCCBEN76H" # alice
   1268     receiver: "01FWN3QA3Q2G0JNYHBCCBEN76H" # alice
   1269     inputOf: "01FWN9E7MD5JKJE52EMP5MHYT3" # process "making apple juice"
   1270     resourceInventoriedAs: "01FWN9A23V1Y1XRJPZ5CG2BDYW" # the juicer
   1271     resourceQuantity: {
   1272       hasNumericalValue: 1
   1273       hasUnit: "01FWN9828J8M6NB95C0GV0Z324" # one/each/pcs
   1274     }
   1275     effortQuantity: {
   1276       hasNumericalValue: 2
   1277       hasUnit: "01FWN96JV5KG2N91Q3FSZRZZQ3" # hour
   1278     }
   1279     atLocation: "01FWN3VH3H8T4KHN8XC7FJ32V3" # alice's kitchen
   1280     hasPointInTime: "2022-01-02T03:04:05Z"
   1281   }) {
   1282     economicEvent {
   1283       id
   1284       action {id}
   1285       provider {id}
   1286       receiver {id}
   1287       inputOf {id}
   1288       resourceInventoriedAs {
   1289         id
   1290         name
   1291         accountingQuantity {
   1292           hasNumericalValue
   1293           hasUnit {id}
   1294         }
   1295         onhandQuantity {
   1296           hasNumericalValue
   1297           hasUnit {id}
   1298         }
   1299       }
   1300       resourceQuantity {
   1301         hasNumericalValue
   1302         hasUnit {id}
   1303       }
   1304       effortQuantity {
   1305         hasNumericalValue
   1306         hasUnit {id}
   1307       }
   1308       atLocation {id}
   1309       hasPointInTime
   1310     }
   1311   }
   1312 }
   1313 ```
   1314 
   1315 Get:
   1316 ```
   1317 {
   1318   "data": {
   1319     "createEconomicEvent": {
   1320       "economicEvent": {
   1321         "id: "01FWN9W5Y9JY6ZFTZ6518SF6PP",
   1322         "action": {"id": "use"},
   1323         "provider": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
   1324         "receiver": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
   1325         "inputOf": {"id": "01FWN9E7MD5JKJE52EMP5MHYT3"}, # process "making apple juice"
   1326         "resourceInventoriedAs": {
   1327           "id": "01FWN9A23V1Y1XRJPZ5CG2BDYW",
   1328           "name": "the juicer machine",
   1329           "accountingQuantity": {
   1330             "hasNumericalValue": 1,
   1331             "hasUnit": {"id": "01FWN9828J8M6NB95C0GV0Z324"} # one/each/pcs
   1332           },
   1333           "onhandQuantity": {
   1334             "hasNumericalValue": 1,
   1335             "hasUnit": {"id": "01FWN9828J8M6NB95C0GV0Z324"} # one/each/pcs
   1336           }
   1337         },
   1338         "resourceQuantity": {
   1339           "hasNumericalValue": 1,
   1340           "hasUnit": {"id": "01FWN9828J8M6NB95C0GV0Z324"} # one/each/pcs
   1341         },
   1342         "effortQuantity": {
   1343           "hasNumericalValue": 2,
   1344           "hasUnit": {"id": "01FWN96JV5KG2N91Q3FSZRZZQ3"} # hour
   1345         },
   1346         "atLocation": {"id": "01FWN3VH3H8T4KHN8XC7FJ32V3"}, # alice's kitchen
   1347         "hasPointInTime": "2022-01-02T03:04:05.000000Z"
   1348       }
   1349     }
   1350   }
   1351 }
   1352 ```
   1353 
   1354 You can also choose to not use `resourceQuantity` or `resourceInventoriedAs` at
   1355 all.  But if you choose to not use `resourceInventoriedAs`, you must provide a
   1356 ResourceSpecification in the field `resourceConformsTo`.
   1357 
   1358 This would mean that we used a machine for 2 hours, but we didn't want to use an
   1359 actual resource for it and didn't want to provide how many of them we used.
   1360 This is a valid usage of `use` events.
   1361 
   1362 Give:
   1363 ```
   1364 mutation {
   1365   createEconomicEvent(event: {
   1366     action: "use"
   1367     provider: "01FWN3QA3Q2G0JNYHBCCBEN76H" # alice
   1368     receiver: "01FWN3QA3Q2G0JNYHBCCBEN76H" # alice
   1369     inputOf: "01FWN9E7MD5JKJE52EMP5MHYT3" # process "making apple juice"
   1370     resourceConformsTo: "01FWNA5WDM5FPJYPQ3BTGMFTQ5" # resource spec "juicer machine"
   1371     effortQuantity: {
   1372       hasNumericalValue: 2
   1373       hasUnit: "01FWN96JV5KG2N91Q3FSZRZZQ3" # hour
   1374     }
   1375     atLocation: "01FWN3VH3H8T4KHN8XC7FJ32V3" # alice's kitchen
   1376     hasPointInTime: "2022-01-02T03:04:05Z"
   1377   }) {
   1378     economicEvent {
   1379       id
   1380       action {id}
   1381       provider {id}
   1382       receiver {id}
   1383       inputOf {id}
   1384       resourceConformsTo {id}
   1385       effortQuantity {
   1386         hasNumericalValue
   1387         hasUnit {id}
   1388       }
   1389       atLocation {id}
   1390       hasPointInTime
   1391     }
   1392   }
   1393 }
   1394 ```
   1395 
   1396 Get:
   1397 ```
   1398 {
   1399   "data": {
   1400     "createEconomicEvent": {
   1401       "economicEvent": {
   1402         "id: "01FWNA7DETHVJ2C97AQWK55Y8B",
   1403         "action": {"id": "use"},
   1404         "provider": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
   1405         "receiver": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
   1406         "inputOf": {"id": "01FWN9E7MD5JKJE52EMP5MHYT3"}, # process "making apple juice"
   1407         "resourceConformsTo": {"id": "01FWN9A23V1Y1XRJPZ5CG2BDYW"},
   1408         "effortQuantity": {
   1409           "hasNumericalValue": 2,
   1410           "hasUnit": {"id": "01FWN96JV5KG2N91Q3FSZRZZQ3"} # hour
   1411         },
   1412         "atLocation": {"id": "01FWN3VH3H8T4KHN8XC7FJ32V3"}, # alice's kitchen
   1413         "hasPointInTime": "2022-01-02T03:04:05.000000Z"
   1414       }
   1415     }
   1416   }
   1417 }
   1418 ```
   1419 
   1420 
   1421 ### Work Examples
   1422 
   1423 `works` events are used when you want to specify what kind of work you put in a
   1424 process.  Suppose you are making some apple pies, and you are kneading the dough
   1425 for the crust; you'd put "kneading the dough" as a work event to the proccess.
   1426 
   1427 There's a small catch, though: as the term "resource", thus its "specification",
   1428 is broad in the Valueflows vocabulary, you are required to provide what kind of
   1429 work you do to the field `resourceConformsTo`, that is, there's no such field
   1430 as `effortConformsTo` and a type as `EffortSpecification`.  Such work would be
   1431 "kneading" in a "making apple pies" scenario.
   1432 
   1433 Give:
   1434 ```
   1435 mutation {
   1436   createEconomicEvent(event: {
   1437     action: "work"
   1438     provider: "01FWN3QA3Q2G0JNYHBCCBEN76H" # alice
   1439     receiver: "01FWN3QA3Q2G0JNYHBCCBEN76H" # alice
   1440     inputOf: "01FWTXNRFVYPR98WQGPVB69DW8" # process "making apple pies"
   1441     resourceConformsTo: "01FWTWNTZEWYKAT0S45809QMFN" # resource spec "kneading"
   1442     effortQuantity: {
   1443       hasNumericalValue: 2
   1444       hasUnit: "01FWN96JV5KG2N91Q3FSZRZZQ3" # hour
   1445     }
   1446     atLocation: "01FWN3VH3H8T4KHN8XC7FJ32V3" # alice's kitchen
   1447     hasPointInTime: "2022-01-02T03:04:05Z
   1448   }) {
   1449     economicEvent {
   1450       id
   1451       provider {id}
   1452       receiver {id}
   1453       inputOf {id}
   1454       resourceInventoriedAs {id}
   1455       effortQuantity {
   1456         hasNumericalValue
   1457         hasUnit {id}
   1458       }
   1459       atLocation {id}
   1460       hasPointInTime
   1461     }
   1462   }
   1463 }
   1464 ```
   1465 
   1466 Get:
   1467 ```
   1468 {
   1469   "data": {
   1470     "createEconomicEvent": {
   1471       "economicEvent": {
   1472         "id: "01FWTXN8ZY01XXNG9QK47PEKNH",
   1473         "action": {"id": "work"},
   1474         "provider": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
   1475         "receiver": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
   1476         "inputOf": {"id": "01FWTXNRFVYPR98WQGPVB69DW8"}, # process "making apple pies"
   1477         "resourceConformsTo": {"id": "01FWTWNTZEWYKAT0S45809QMFN"}, # resource spec "kneading"
   1478         "effortQuantity": {
   1479           "hasNumericalValue": 2,
   1480           "hasUnit": {"id": "01FWN96JV5KG2N91Q3FSZRZZQ3"}, # hour
   1481         },
   1482         "atLocation": {"id": "01FWN3VH3H8T4KHN8XC7FJ32V3"}, # alice's kitchen
   1483         "hasPointInTime": "2022-01-02T03:04:05.000000Z"
   1484       }
   1485     }
   1486   }
   1487 }
   1488 ```
   1489 
   1490 
   1491 ### Cite Examples
   1492 
   1493 Suppose you are some sort of instruction paper, design files, blueprints (all
   1494 can be digital as well) to produce something.  You record the history of that
   1495 with `cite` events.  They cosume the cited resource.  They're there because they
   1496 help us to create a more meaningful history.
   1497 
   1498 Give:
   1499 ```
   1500 mutation {
   1501   createEconomicEvent(event: {
   1502     action: "cite"
   1503     provider: "01FWN3QA3Q2G0JNYHBCCBEN76H" # alice
   1504     receiver: "01FWN3QA3Q2G0JNYHBCCBEN76H" # alice
   1505     inputOf: "01FWPA0H6YB1NDP2X1HNCXFQN9" # process "creating flags"
   1506     resourceInventoriedAs: "01FWPA7HXMA25AGA3VXXR0540K" # resource "flag design"
   1507     resourceQuantity: {
   1508       hasNumericalValue: 1
   1509       hasUnit: "01FWN9828J8M6NB95C0GV0Z324" # one/each/pcs
   1510     }
   1511     atLocation: "01FWPAG1YVBXXPTQNSCFG48RTY" # alice's workshop
   1512     hasPointInTime: "2022-01-02T03:04:05Z
   1513   }) {
   1514     economicEvent {
   1515       id
   1516       provider {id}
   1517       receiver {id}
   1518       inputOf {id}
   1519       resourceInventoriedAs {id}
   1520       resourceQuantity {
   1521         hasNumericalValue
   1522         hasUnit {id}
   1523       }
   1524       atLocation {id}
   1525       hasPointInTime
   1526     }
   1527   }
   1528 }
   1529 ```
   1530 
   1531 Get:
   1532 ```
   1533 {
   1534   "data": {
   1535     "createEconomicEvent": {
   1536       "economicEvent": {
   1537         "id: "01FWPAE4JC2P039G4B93D0AS4Q",
   1538         "action": {"id": "cite"},
   1539         "provider": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
   1540         "receiver": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
   1541         "inputOf": {"id": "01FWPA0H6YB1NDP2X1HNCXFQN9"}, # process "creating flags"
   1542         "resourceInventoriedAs": {"id": "01FWPA7HXMA25AGA3VXXR0540K"}, # resource "flag design"
   1543         "resourceQuantity": {
   1544           "hasNumericalValue": 1,
   1545           "hasUnit": {"id": "01FWN9828J8M6NB95C0GV0Z324"}, # one/each/pcs
   1546         },
   1547         "atLocation": {"id": "01FWPAG1YVBXXPTQNSCFG48RTY"}, # alice's workshop
   1548         "hasPointInTime": "2022-01-02T03:04:05.000000Z"
   1549       }
   1550     }
   1551   }
   1552 }
   1553 ```
   1554 
   1555 With `cite` events, you may wish to just use a ResourceSpecification instead of
   1556 an Economicresource.  But, you must provide the quantity nonetheless.
   1557 
   1558 Give:
   1559 ```
   1560 mutation {
   1561   createEconomicEvent(event: {
   1562     action: "cite"
   1563     provider: "01FWN3QA3Q2G0JNYHBCCBEN76H" # alice
   1564     receiver: "01FWN3QA3Q2G0JNYHBCCBEN76H" # alice
   1565     inputOf: "01FWPA0H6YB1NDP2X1HNCXFQN9" # process "creating flags"
   1566     resourceConformsTo: "01FWPAN3ST2FE431DSBQTCMBN9" # resource spec "flag design"
   1567     resourceQuantity: {
   1568       hasNumericalValue: 1
   1569       hasUnit: "01FWN9828J8M6NB95C0GV0Z324" # one/each/pcs
   1570     }
   1571     atLocation: "01FWPAG1YVBXXPTQNSCFG48RTY" # alice's workshop
   1572     hasPointInTime: "2022-01-02T03:04:05Z
   1573   }) {
   1574     economicEvent {
   1575       id
   1576       provider {id}
   1577       receiver {id}
   1578       inputOf {id}
   1579       resourceConformsTo {id}
   1580       resourceQuantity {
   1581         hasNumericalValue
   1582         hasUnit {id}
   1583       }
   1584       atLocation {id}
   1585       hasPointInTime
   1586     }
   1587   }
   1588 }
   1589 ```
   1590 
   1591 Get:
   1592 ```
   1593 {
   1594   "data": {
   1595     "createEconomicEvent": {
   1596       "economicEvent": {
   1597         "id: "01FWPAE4JC2P039G4B93D0AS4Q",
   1598         "action": {"id": "cite"},
   1599         "provider": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
   1600         "receiver": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice
   1601         "inputOf": {"id": "01FWPA0H6YB1NDP2X1HNCXFQN9"}, # process "creating flags"
   1602         "resourceConformsTo": {"id": "01FWPAN3ST2FE431DSBQTCMBN9"} # resource spec "flag design"
   1603         "resourceQuantity": {
   1604           "hasNumericalValue": 1,
   1605           "hasUnit": {"id": "01FWN9828J8M6NB95C0GV0Z324"}, # one/each/pcs
   1606         },
   1607         "atLocation": {"id": "01FWPAG1YVBXXPTQNSCFG48RTY"}, # alice's workshop
   1608         "hasPointInTime": "2022-01-02T03:04:05.000000Z"
   1609       }
   1610     }
   1611   }
   1612 }
   1613 ```
   1614 
   1615 
   1616 ### DeliverService Examples
   1617 
   1618 When you want to indicate the services used in a process, you use
   1619 `deliverService` events.
   1620 
   1621 Painting a house, transporting a pizza, and dry-cleaning clothes are examples of
   1622 services.
   1623 
   1624 Similar to `work` events, `resourceConformsTo` refer to the type of service.
   1625 
   1626 Give:
   1627 ```
   1628 mutation {
   1629   createEconomicEvent(event: {
   1630     action: "deliverService"
   1631     provider: "01FWN12XX7TJX1AFF5KA4WPNN9" # bob the painter
   1632     receiver: "01FWN3QA3Q2G0JNYHBCCBEN76H" # alice the house owner
   1633     outputOf: "01FWV0BXSCMRWHRCFCQ82JM2S3" # process "painting alice's house"
   1634     resourceConformsTo: "01FWV0G7X0H03BQKPV0W8Q32EA" # resource spec "painting"
   1635     atLocation: "01FWV0REX2G4VHRRBH5QSWD7N8" # alice's house
   1636     hasPointInTime: "2022-01-02T03:04:05Z"
   1637   }) {
   1638     economicEvent {
   1639       id
   1640       provider {id}
   1641       receiver {id}
   1642       outputOf {id}
   1643       resourceConformsTo {id}
   1644       atLocation {id}
   1645       hasPointInTime
   1646     }
   1647   }
   1648 }
   1649 ```
   1650 
   1651 Get:
   1652 ```
   1653 {
   1654   "data": {
   1655     "createEconomicEvent": {
   1656       "economicEvent": {
   1657         "id: "01FWV0N1FE320H75Q8RYVAFTR4",
   1658         "action": {"id": "deliverService"},
   1659         "provider": {"id": "01FWN12XX7TJX1AFF5KA4WPNN9"}, # bob the painter
   1660         "receiver": {"id": "01FWN3QA3Q2G0JNYHBCCBEN76H"}, # alice the house owner
   1661         "outputOf": {"id": "01FWPA0H6YB1NDP2X1HNCXFQN9"}, # process "painting alice's house"
   1662         "resourceConformsTo": {"id": "01FWV0G7X0H03BQKPV0W8Q32EA"} # resource spec "painting"
   1663         "atLocation": {"id": "01FWV0REX2G4VHRRBH5QSWD7N8"}, # alice's workshop
   1664         "hasPointInTime": "2022-01-02T03:04:05.000000Z"
   1665       }
   1666     }
   1667   }
   1668 }
   1669 ```
   1670 
   1671 # GraphQL Documents
   1672 
   1673 
   1674 ## Economic Events
   1675 
   1676 All the events require `action`, `provider`, `receiver` fields along with one of these datetime combinations (no particular validation regarding the datetime fields is performed, such as wether `hasBeginning` is actually older or equal to than `hasEnd`):
   1677 
   1678 * only `hasPointInTime`
   1679 * only `hasBeginning`
   1680 * only `hasEnd`
   1681 * both `hasBeginning` and `hasEnd`
   1682 
   1683 The rest of the sections will asume you are aware of this information.
   1684 
   1685 
   1686 ### Produce Events
   1687 
   1688 Produce events require `outputOf`, `resourceConformsTo`, `resourceQuantity`,
   1689 and `newInventoriedResource.name`.  You can provide the soon-to-be-created
   1690 resource's `name`, `note`, `trackingIdentifier` through
   1691 `newInventoriedResource`.  Here is an example document that uses variables:
   1692 
   1693 ```
   1694 mutation (
   1695   $outputOf: ID!
   1696   $provider: ID!
   1697   $receiver: ID!
   1698   $resourceConformsTo: ID!
   1699   $resourceQuantity: IMeasure!
   1700   $newInventoriedResource: EconomicResourceCreateParams!
   1701   $hasPointInTime: DateTime
   1702   $hasBeginning: DateTime
   1703   $hasEnd: DateTime
   1704 ) {
   1705   createEconomicEvent(
   1706     event: {
   1707       action: "produce"
   1708       outputOf: $outputOf
   1709       provider: $provider
   1710       receiver: $receiver
   1711       resourceConformsTo: $resourceConformsTo
   1712       resourceQuantity: $resourceQuantity
   1713       hasPointInTime: $hasPointInTime
   1714       hasBeginning: $hasBeginning
   1715       hasEnd: $hasEnd
   1716     }
   1717     newInventoriedResource: $newInventoriedResource
   1718   ) {
   1719     economicEvent {
   1720       id
   1721       action {id}
   1722       outputOf {id}
   1723       provider {id}
   1724       receiver {id}
   1725       resourceConformsTo {id}
   1726       resourceQuantity {
   1727         hasNumericalValue
   1728         hasUnit {id}
   1729       }
   1730       resourceInventoriedAs {
   1731         id
   1732         name
   1733         note
   1734         primaryAccountable {id}
   1735         accountingQuantity {
   1736           hasNumericalValue
   1737           hasUnit {id}
   1738         }
   1739         onhandQuantity {
   1740           hasNumericalValue
   1741           hasUnit {id}
   1742         }
   1743         conformsTo {id}
   1744       }
   1745       hasPointInTime
   1746       hasEnd
   1747       hasBeginning
   1748     }
   1749   }
   1750 }
   1751 ```
   1752 
   1753 and the example variables:
   1754 
   1755 ```
   1756 {
   1757   "outputOf": "01G2Q2AT2PHQD56N9RFX3A240J",
   1758   "provider": "01FZFE8E43ANRY360J1E98PJ0Z",
   1759   "receiver": "01FZFE8E43ANRY360J1E98PJ0Z",
   1760   "resourceConformsTo": "01FTB03K54ZF38FHEKGVHTWGY8",
   1761   "resourceQuantity": {
   1762     "hasNumericalValue": 10.0,
   1763     "hasUnit":  "01FTB06BQ64MSS7XSB3QMSW83R"
   1764   },
   1765   "newInventoriedResource": {
   1766     "name":  "some name",
   1767     "note": "some note"
   1768   },
   1769   "hasEnd": "2022-01-02T03:04:05Z"
   1770 }
   1771 ```
   1772 
   1773 
   1774 ### Consume Events
   1775 
   1776 Consume events require `inputOf`, `resourceInventoriedAs`, and
   1777 `resourceQuantity` fields.  Here is an example document that uses variables:
   1778 
   1779 ```
   1780 mutation (
   1781   $inputOf: ID!
   1782   $provider: ID!
   1783   $receiver: ID!
   1784   $resourceInventoriedAs: ID!
   1785   $resourceQuantity: IMeasure!
   1786   $hasPointInTime: DateTime
   1787   $hasBeginning: DateTime
   1788   $hasEnd: DateTime
   1789 ) {
   1790   createEconomicEvent(event: {
   1791      action: "consume"
   1792      inputOf: $inputOf
   1793      provider: $provider
   1794      receiver: $receiver
   1795      resourceInventoriedAs: $resourceInventoriedAs
   1796      resourceQuantity: $resourceQuantity
   1797      hasPointInTime: $hasPointInTime
   1798      hasBeginning: $hasBeginning
   1799      hasEnd: $hasEnd
   1800   }) {
   1801     economicEvent {
   1802       id
   1803       action {id}
   1804       inputOf {id}
   1805       provider {id}
   1806       receiver {id}
   1807       resourceQuantity {
   1808         hasNumericalValue
   1809         hasUnit {id}
   1810       }
   1811       resourceInventoriedAs {
   1812         id
   1813         name
   1814         note
   1815         primaryAccountable {id}
   1816         accountingQuantity {
   1817           hasNumericalValue
   1818           hasUnit {id}
   1819         }
   1820         onhandQuantity {
   1821           hasNumericalValue
   1822           hasUnit {id}
   1823         }
   1824         conformsTo {id}
   1825       }
   1826       hasPointInTime
   1827       hasEnd
   1828       hasBeginning
   1829     }
   1830   }
   1831 }
   1832 ```
   1833 
   1834 and the example variables:
   1835 
   1836 ```
   1837 {
   1838   "inputOf": "01G2Q2AT2PHQD56N9RFX3A240J",
   1839   "provider": "01FZFE8E43ANRY360J1E98PJ0Z",
   1840   "receiver": "01FZFE8E43ANRY360J1E98PJ0Z",
   1841   "resourceInventoriedAs": "01FTB03K54ZF38FHEKGVHTWGY8",
   1842   "resourceQuantity": {
   1843     "hasNumericalValue": 10.0,
   1844     "hasUnit":  "01FTB06BQ64MSS7XSB3QMSW83R"
   1845   },
   1846   "hasPointInTime": "2022-01-02T03:04:05Z"
   1847 }
   1848 ```
   1849 
   1850 
   1851 ### Raise Events
   1852 
   1853 Raise events are almost identical to produce events, execept for their semantic
   1854 meaning, and the fact that they don't require `outputOf` to be provided (that's
   1855 related to the semantic meaning).  Here is an example document that uses
   1856 variables:
   1857 
   1858 ```
   1859 mutation (
   1860   $provider: ID!
   1861   $receiver: ID!
   1862   $resourceConformsTo: ID!
   1863   $resourceQuantity: IMeasure!
   1864   $newInventoriedResource: EconomicResourceCreateParams!
   1865   $hasPointInTime: DateTime
   1866   $hasBeginning: DateTime
   1867   $hasEnd: DateTime
   1868 ) {
   1869   createEconomicEvent(
   1870     event: {
   1871       action: "raise"
   1872       provider: $provider
   1873       receiver: $receiver
   1874       resourceConformsTo: $resourceConformsTo
   1875       resourceQuantity: $resourceQuantity
   1876       hasPointInTime: $hasPointInTime
   1877       hasBeginning: $hasBeginning
   1878       hasEnd: $hasEnd
   1879     }
   1880     newInventoriedResource: $newInventoriedResource
   1881   ) {
   1882     economicEvent {
   1883       id
   1884       action {id}
   1885       provider {id}
   1886       receiver {id}
   1887       resourceConformsTo {id}
   1888       resourceQuantity {
   1889         hasNumericalValue
   1890         hasUnit {id}
   1891       }
   1892       resourceInventoriedAs {
   1893         id
   1894         name
   1895         note
   1896         primaryAccountable {id}
   1897         accountingQuantity {
   1898           hasNumericalValue
   1899           hasUnit {id}
   1900         }
   1901         onhandQuantity {
   1902           hasNumericalValue
   1903           hasUnit {id}
   1904         }
   1905         conformsTo {id}
   1906       }
   1907       hasPointInTime
   1908       hasEnd
   1909       hasBeginning
   1910     }
   1911   }
   1912 }
   1913 ```
   1914 
   1915 and the example variables:
   1916 
   1917 ```
   1918 {
   1919   "provider": "01FZFE8E43ANRY360J1E98PJ0Z",
   1920   "receiver": "01FZFE8E43ANRY360J1E98PJ0Z",
   1921   "resourceConformsTo": "01FTB03K54ZF38FHEKGVHTWGY8",
   1922   "resourceQuantity": {
   1923     "hasNumericalValue": 10.0,
   1924     "hasUnit":  "01FTB06BQ64MSS7XSB3QMSW83R"
   1925   },
   1926   "newInventoriedResource": {
   1927     "name":  "some name",
   1928     "note": "some note"
   1929   },
   1930   "hasBeginning": "2022-01-02T03:04:05Z"
   1931 }
   1932 ```
   1933 
   1934 
   1935 ### Lower Events
   1936 
   1937 Raise events are almost identical to consume events, execept for their semantic
   1938 meaning, and the fact that they don't require `inputOf` to be provided (that's
   1939 related to the semantic meaning).  Here is an example document that uses
   1940 variables:
   1941 
   1942 ```
   1943 mutation (
   1944   $provider: ID!
   1945   $receiver: ID!
   1946   $resourceInventoriedAs: ID!
   1947   $resourceQuantity: IMeasure!
   1948   $hasPointInTime: DateTime
   1949   $hasBeginning: DateTime
   1950   $hasEnd: DateTime
   1951 ) {
   1952   createEconomicEvent(event: {
   1953      action: "lower"
   1954      provider: $provider
   1955      receiver: $receiver
   1956      resourceInventoriedAs: $resourceInventoriedAs
   1957      resourceQuantity: $resourceQuantity
   1958      hasPointInTime: $hasPointInTime
   1959      hasBeginning: $hasBeginning
   1960      hasEnd: $hasEnd
   1961   }) {
   1962     economicEvent {
   1963       id
   1964       action {id}
   1965       inputOf {id}
   1966       provider {id}
   1967       receiver {id}
   1968       resourceQuantity {
   1969         hasNumericalValue
   1970         hasUnit {id}
   1971       }
   1972       resourceInventoriedAs {
   1973         id
   1974         name
   1975         note
   1976         primaryAccountable {id}
   1977         accountingQuantity {
   1978           hasNumericalValue
   1979           hasUnit {id}
   1980         }
   1981         onhandQuantity {
   1982           hasNumericalValue
   1983           hasUnit {id}
   1984         }
   1985         conformsTo {id}
   1986       }
   1987       hasPointInTime
   1988       hasEnd
   1989       hasBeginning
   1990     }
   1991   }
   1992 }
   1993 ```
   1994 
   1995 and the example variables:
   1996 
   1997 ```
   1998 {
   1999   "provider": "01FZFE8E43ANRY360J1E98PJ0Z",
   2000   "receiver": "01FZFE8E43ANRY360J1E98PJ0Z",
   2001   "resourceInventoriedAs": "01FTB03K54ZF38FHEKGVHTWGY8",
   2002   "resourceQuantity": {
   2003     "hasNumericalValue": 10.0,
   2004     "hasUnit":  "01FTB06BQ64MSS7XSB3QMSW83R"
   2005   },
   2006   "hasBeginning": "2022-01-02T03:04:05Z",
   2007   "hasEnd": "2022-01-02T03:04:05Z"
   2008 }
   2009 ```