My App
RoomKitBackend

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>
ParameterTypeDescription
purposeTypestringThe 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>
ParameterTypeDescription
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:

NameWeight
LECTURE100
SEMINAR75
STUDY_GROUP50
OPEN25
await priorityService.seedDefaults();

Default Tiers

The default priority tiers provide a standard booking hierarchy:

TierWeightDescription
LECTURE100Highest priority, formal lectures
SEMINAR75Seminars and structured classes
STUDY_GROUP50Student study groups
OPEN25Open bookings, lowest priority

When resolve cannot find a matching tier, it returns 25 (the OPEN weight) as the fallback value.

On this page