uploadFile
Registers a new file metadata record in the file model and links it to the currently logged-in user via the uploader relation. The file model backs avatars, purchase-order attachments, and tender documents, so this is the act you call whenever a user uploads something. It is open to every authenticated role (everyone can upload).
getFile
Fetches a single file document by its _id. Use it when you have a file id (from a user's avatar, a PO attachment, or a getFiles list) and want the full metadata โ and optionally the uploader snapshot. Open to all authenticated roles.
getFiles
Lists file documents, newest first, with an optional filter on the uploader. Every authenticated role can list files โ it's how the UI renders an uploader's library or a global attachment index.
removeFile
Deletes a file document by its _id. Restricted to Manager and Admin โ regular uploaders can create files but not remove them. Deleting a file that is still referenced (e.g. a purchase-order attachment) is blocked by the ODM's relation guard.
addTag
Creates a tag โ a lightweight { name, color } label used to classify products. Only Manager and Admin can create tags. The model enforces a unique index on name, so you can't create two tags with the same label.
getTags
Lists all tags, newest first. Open to every authenticated role โ tags are shared reference data, so anyone can read them. No filter fields; it's a flat list that feeds tag dropdowns and product filters.
updateTag
Edits a tag's name and/or color by _id. Only Manager and Admin. Fields are optional here (unlike addTag), so you send exactly what you want to change. The unique name index still applies.
removeTag
Deletes a tag by its _id. Only Manager and Admin. Deleting a tag that is still referenced by products is blocked by the ODM's relation guard โ you must un-tag those products first.
addOrganization
Creates an organization โ the top-level tenant (hospital, clinic, chain). Organizations can optionally nest under a parent, building a tree. Only Manager and Admin can create one. The model enforces a unique index on code.
getOrganizations
Lists organizations, optionally filtered by a case-insensitive name match, sorted alphabetically by name. Open to every authenticated role โ organizations are the tenant boundary, so most pages need to enumerate them.
updateOrganizationRelations
Reparents an organization โ sets (or replaces) its parent and keeps the parent's children back-reference in sync. Roles allowed no pure fields are touched.
addUnit
Creates a unit (department or warehouse) that belongs to exactly one organization, with optional head (user) and parentUnit (tree) relations. Roles allowed: Manager, Admin, OrgHead. Units are the scope object for step-approvals and inventory ownership, so this act is called early in the setup of any tenant.
getUnits
Lists units, optionally filtered by their owning organizationId, sorted alphabetically by name. Open to every authenticated role. This is the workhorse read for anything scoped to a department or warehouse.
removeUnit
Deletes a unit by its _id. Restricted to Manager and Admin. The ODM's relation guard protects against deleting a unit that still has referencing documents (stores, users, step approvals, purchase orders, process steps).
updateUnitRelations
Moves a unit Manager, Admin, OrgHead. This is the biggest of the "update relations" acts because a unit has three relations.
addProduct
Creates a product (a purchasable good), optionally nested under a parent product (category tree) and/or tagged with existing tags. Only Manager and Admin. The model enforces a unique index on code.
getProduct
Fetches a single product by its _id, with the full depth-2 projection available (parent, tags). Open to every authenticated role. This is the detail view behind a product listing.
getProducts
Lists products with two optional filters: a free-text search (case-insensitive match on name or code) and a tagId (products carrying that tag). Sorted alphabetically by name. Open to every authenticated role.
removeProduct
Deletes a product by its _id. Only Manager and Admin. The ODM's relation guard refuses to delete a product that is still referenced โ by purchase orders, inventory records, or its own child products.
updateProductRelations
Re-assigns a product's relations only true pattern for both single and array relations.
addStore
Creates a store โ a physical location (warehouse/shelf) where inventory is kept โ optionally owned by a unit. Roles allowed: Manager, Admin, OrgHead. The model enforces a unique index on code.
getStores
Lists stores, optionally filtered by their owning unitId, sorted alphabetically by name. Open to every authenticated role. This is the store picker used by the inventory acts.