Reference
Decorators
Decorators add metadata that cannot be inferred safely from field defaults: interfaces, relationships, tenant scope, sensitive fields, reports, and other package behavior.
@smrt()
Marks a model for scanning and declares which actions appear in REST, MCP, WebMCP definitions, and CLI. Use include, exclude, and writable lists instead of exposing every method by accident.
- A public method routes as a custom action by default only when every parameter is JSON-shaped. @method({ expose }) overrides that heuristic in both directions: expose: true routes the method anyway, and expose: false withholds it.
- previousQualifiedNames lists the deprecated qualified names (@package/name:ClassName) a moved or renamed class used to carry. Keep tableName explicit so the class keeps its table. Lookups by an old name resolve to the current class, and smrt db:migrate-qualified-names rewrites stored names when you ask it to.
Relationships
Use foreignKey for a same-package relationship and crossPackageRef when the target comes from another package. The manifest records the target and the collection can batch-load named relationships.
Tenant scope
TenantScoped selects required, optional, or global behavior. The tenantId field decorator records the storage field used by automatic query interceptors.
- allowSuperAdminBypass, on @TenantScoped or on tenantScoped inside @smrt(), lets withSuperAdminBypass lift tenant enforcement for that class. It defaults to false, so every other tenant-scoped class stays scoped to the caller tenant under the bypass.
Recipes are declared beside the models
SmrtRecipe is a base class rather than a decorator: abstract, never persisted, and not marked with @smrt(). A recipe is a subclass with static id, label, models, nav, requires, and options, declared in the package that owns its models. The scanner reads those statics structurally and collects them into the manifest and knowledge recipes list. A cookbook, an application shell, or an agent can then add one named unit of functionality without every model in the package.
Report fields
smrt-reports adds group, time bucket, and measure decorators so aggregate specifications remain beside the report model.