// // 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 UserID = string type BookingID = string type SlotID = string type SeatID = string type RoomID = string type UserPermission = 'basic' | 'helper' | 'moderator' | 'admin' type PostiDM = { users: Map rooms: Map seats: Map slots: Map getCurrentWeekSlots(): Slot[] bookings: Map } // TODO: Tutte le funzioni "getCurrentSomething()" in realtà sono da pensare meglio in modo da poter passare un range temporale o qualcosa del genere /** * Un utente loggato con credenziali di ateneo */ type User = { id: UserID permissions: Set getBookings(): Booking[] getCurrentSeat(): Maybe } /** * Una prenotazione di un utente per un certo slot orario */ type Booking = { id: BookingID timestamp: Datetime slotID: SlotID userID: UserID // cioè ok c'è User.bookings però pensando in SQL è sempre meglio avere comunque un id qui (forse) getSlot(): Slot // giusto per comodità per parlare direttamente dell'oggetto "Slot" relativo ad un "Booking" getSeat(): Seat // ".getSlot().getSeat()" } /** * Slot rappresenta uno slot orario prenotabile per un certo posto */ type Slot = { id: SlotID seatID: SeatID // Magari invece di eliminare uno slot, in quanto ricrearlo potrebbe essere complicato e forse è meglio che i moderatori semplicemente disabilitino uno slot se vogliono non renderlo prenotabile (?) // disabled: boolean range: { from: Datetime to: Datetime } getCurrentBooking(): Maybe } /** * Seat rappresenta un posto in dipartimento in una certa stanza */ type Seat = { id: SeatID diagram: { x: Natural y: Natural width: Natural height: Natural } // TODO: Forse per ora è meglio fare che più utenti possono prenotare lo stesso posto così inizialmente possiamo fare che in ogni stanza c'è solo un posto e la gente può prenotarsi solo "alla stanza" e non al posto specifico, altrimenti facciamo "getCurrentBookedUser(): Maybe" getCurrentlyBookedUsers(): User[] getRoom(): Room } /** * Room rappresenta una stanza in dipartimento e contiene dei posti */ type Room = { id: RoomID name: string diagram: { gridRows: Natural gridCols: Natural } getSeats(): Seat[] getTotalSeatCount(): Natural // ".seatIDs.length" getCurrentBookedSeatCount(): Natural }