Resources
A resource defines one thing your product counts, such as roasted coffee, game credits, or court hours. It sets the unit of measure, the scopes that keep separate balances, and the rules supply and claims follow.
Units
Quantities are integers in the smallest unit that the resource’s unit.precision allows. A resource measured in meters with precision 2 takes 125 for 1.25 meters. Precision runs from 0 to 6.
settings.identity: 'count' counts like units together. settings.identity: 'instance' gives each unit its own ID, such as the ID of a numbered bag or room. A line on that resource sends scope.instanceId and a quantity of 1. The resource uses precision 0 and sets no capacity. It sets settings.supplyExpiry and tracking to none. Keep a best-before date in the unit’s attributes, and retire the unit to take it off sale. A hold or consume that names an unavailable unit answers assignment_infeasible.
At the ResourceShark API root, GET /resources/:id/free-instances lists the units a line could take. Your app picks the unit. A page scans at most 1,000 instances, so follow next even when a page is empty. Bookings covers units with calendars.
Balances and shortages
With settings.time: 'none', a resource keeps a balance for each scope. With settings.time: 'buckets', it keeps a balance for each bucket in that scope. Schedules explains what a bucket holds.
shortage: 'deny'limits a take to the supply available now.shortage: 'backorder'counts expected supply toward what is available.shortage: 'negative'allows a take even if it puts the balance below zero. An individually tracked resource usesdenyorbackorder. A take on backorder can leave the unit’sonHandat-1until its expected supply arrives.
settings.supplyExpiry: 'expiring' keeps balances for individual supply entries. It requires identity: 'count', time: 'none', and shortage: 'deny' or 'negative'. Batch tracking, tracking: 'batch', requires expiring supply and shortage: 'deny'. Owing explains how expiring supply goes below zero.
Changes
Tags and attributes help you find resources and select them for reports. A patch sends the resource’s version in If-Match. The first supply, stock write, claim, schedule save, or exception save locks the resource’s unit code and precision, settings, scope, and tracking, and shortage when its supply expires. Changing a locked field answers settings_locked. Archiving a resource takes it out of the resource list. Its record and movement history stay readable.
Where to act on it
- The ResourceShark quickstart defines a resource that counts grams at a roastery.
- Resources defines and edits resources. Instances records units and lists which ones are free.