PriorityService
Configure and resolve booking priority tiers
Overview
PriorityService manages priority tiers that determine booking precedence during conflict resolution. Each tier has a name and a numeric weight. Higher weights take priority over lower weights.
import { PriorityService } from '@roomkit/nestjs';Methods
getAll
List all configured priority tiers.
async getAll(): Promise<PriorityTier[]>const tiers = await priorityService.getAll();
for (const tier of tiers) {
console.log(`${tier.name}: weight ${tier.weight}`);
}resolve
Look up the priority weight for a given purpose type. Matching is case-insensitive. Falls back to 25 (the OPEN tier weight) if no matching tier is found.
async resolve(purposeType: string): Promise<number>| Parameter | Type | Description |
|---|---|---|
purposeType | string | The purpose type to look up (e.g., 'LECTURE', 'seminar') |
const weight = await priorityService.resolve('LECTURE');
// 100
const fallback = await priorityService.resolve('unknown_type');
// 25 (default fallback)upsert
Create a new priority tier or update an existing one.
async upsert(tier: { name: string; weight: number }): Promise<PriorityTier>| Parameter | Type | Description |
|---|---|---|
tier | { name: string; weight: number } | Tier name and numeric weight |
const tier = await priorityService.upsert({ name: 'WORKSHOP', weight: 60 });seedDefaults
Seed the default priority tiers if they do not already exist. This method is safe to call multiple times -- it will not overwrite existing tiers.
async seedDefaults(): Promise<void>Seeds the following default tiers:
| Name | Weight |
|---|---|
LECTURE | 100 |
SEMINAR | 75 |
STUDY_GROUP | 50 |
OPEN | 25 |
await priorityService.seedDefaults();Default Tiers
The default priority tiers provide a standard booking hierarchy:
| Tier | Weight | Description |
|---|---|---|
LECTURE | 100 | Highest priority, formal lectures |
SEMINAR | 75 | Seminars and structured classes |
STUDY_GROUP | 50 | Student study groups |
OPEN | 25 | Open bookings, lowest priority |
When resolve cannot find a matching tier, it returns 25 (the OPEN weight) as the fallback value.