diff --git a/database-model.ts b/database-model.ts new file mode 100644 index 0000000..d91c67d --- /dev/null +++ b/database-model.ts @@ -0,0 +1,78 @@ +// +// Prelude +// + +type Natural = number +type Integer = number +type Rational = [number, number] +type Real = number + +type Datetime = string +type Time = string + +type Maybe = { present: false } | { present: true; value: T } + +// +// PostiDM +// + +type UserPermission = 'basic' | 'helper' | 'moderator' | 'admin' + +type PostiDM = { + users: Map + rooms: Map + seats: Map + slots: Map +} + +type UserID = string +type User = { + id: UserID + permissions: Set + bookings: Booking[] +} + +type BookingID = string +type Booking = { + id: BookingID + timestamp: Datetime + slotID: SlotID +} + +type SlotID = string +type Slot = { + id: SlotID + seatID: SeatID + range: { + from: Datetime + to: Datetime + } +} + +type SeatID = string +type Seat = { + id: SeatID + roomID: RoomID + diagram: { + x: Natural + y: Natural + width: Natural + height: Natural + } + + // non mi piace questo nome + getCurrentOccupant(): Maybe +} + +type RoomID = string +type Room = { + id: RoomID + seatIDs: SeatID[] + diagram: { + gridRows: Natural + gridCols: Natural + } + + getTotalSeatCount(): Natural + getOccupiedSeatCount(): Natural +}