Runtime API Reference¶
Runtime library API for USL-generated applications.
Storage API¶
Load¶
Load an entity by ID.
Store¶
Save an entity to storage.
Delete¶
Delete an entity.
LoadAll¶
Load all entities of a type.
Context API¶
Current User¶
Get the authenticated user from request context.
Request Context¶
interface RequestContext {
user: User;
timestamp: Date;
ipAddress: string;
headers: Record<string, string>;
}
function getContext(): RequestContext
Policy API¶
Check Authorization¶
Check if a policy rule allows an action.
Enforce¶
Enforce a policy rule, throwing if denied.
Event API¶
Emit¶
Emit a domain event.
Subscribe¶
function subscribe<T extends Event>(
eventType: EventType<T>,
handler: (event: T) => Promise<void>
): Unsubscribe
Subscribe to domain events.
Validation API¶
Validate¶
Validate entity invariants.