Automations
An automation is trigger code plus the configuration binding it to an entity. Both deploy together as configuration.
Layout
Section titled “Layout”automations/ Issue/ ApplyDefaults.ts GuardClosed.ts Component/ SyncOwner.tsThe directory name is the entity. Every class inside runs on that entity’s changes, according to the interfaces it implements.
Ordering
Section titled “Ordering”Several automations on one entity all run. Do not depend on the order between them — if step B needs step A’s output, put both in one class where the sequence is explicit.
Auditing
Section titled “Auditing”Runs are recorded, so you can see what fired and when. A trigger that throws
fails the operation that triggered it: a failing beforeInsert blocks the
insert. That is deliberate — silent partial success on a validation rule is
worse than a visible error.
Choosing a home for logic
Section titled “Choosing a home for logic”| Situation | Put it in |
|---|---|
| Must happen with the write, atomically | Trigger |
| Must reject bad input | before* trigger |
| Slow, or calls a model | Scheduled job |
| Serves a custom UI | Controller |
Triggers run inside the user’s save. Anything slow there makes saving slow, and an AI call in a trigger is felt on every record.
Deploying
Section titled “Deploying”polymesa deploy ./config --dry-runpolymesa deploy ./config