diff --git a/.prettierignore b/.prettierignore
index c891352..00a5bda 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -25,3 +25,4 @@ package-lock.json
api/src/app/serializers/**/*.ts
api/src/db/migrations/*.ts
api/spec/unit/controllers/V1/Host/PlacesController.spec.ts
+api/spec/unit/controllers/V1/Host/Places/RoomsController.spec.ts
diff --git a/api/spec/factories/Room/BathroomFactory.ts b/api/spec/factories/Room/BathroomFactory.ts
index 749ce6b..d9b083e 100644
--- a/api/spec/factories/Room/BathroomFactory.ts
+++ b/api/spec/factories/Room/BathroomFactory.ts
@@ -1,8 +1,10 @@
-import { UpdateableProperties } from '@rvoh/dream/types'
import Bathroom from '@models/Room/Bathroom.js'
+import { UpdateableProperties } from '@rvoh/dream/types'
+import createPlace from '@spec/factories/PlaceFactory.js'
export default async function createBathroom(attrs: UpdateableProperties<Bathroom> = {}) {
return await Bathroom.create({
+ place: attrs.place ? null : await createPlace(),
bathOrShowerStyle: 'bath',
...attrs,
})
diff --git a/api/spec/factories/Room/BedroomFactory.ts b/api/spec/factories/Room/BedroomFactory.ts
index 354c9e9..e482350 100644
--- a/api/spec/factories/Room/BedroomFactory.ts
+++ b/api/spec/factories/Room/BedroomFactory.ts
@@ -1,8 +1,10 @@
-import { UpdateableProperties } from '@rvoh/dream/types'
import Bedroom from '@models/Room/Bedroom.js'
+import { UpdateableProperties } from '@rvoh/dream/types'
+import createPlace from '@spec/factories/PlaceFactory.js'
export default async function createBedroom(attrs: UpdateableProperties<Bedroom> = {}) {
return await Bedroom.create({
+ place: attrs.place ? null : await createPlace(),
bedTypes: ['twin'],
...attrs,
})
diff --git a/api/spec/factories/Room/DenFactory.ts b/api/spec/factories/Room/DenFactory.ts
index 1a26df8..d6d03f7 100644
--- a/api/spec/factories/Room/DenFactory.ts
+++ b/api/spec/factories/Room/DenFactory.ts
@@ -1,8 +1,10 @@
-import { UpdateableProperties } from '@rvoh/dream/types'
import Den from '@models/Room/Den.js'
+import { UpdateableProperties } from '@rvoh/dream/types'
+import createPlace from '@spec/factories/PlaceFactory.js'
export default async function createDen(attrs: UpdateableProperties<Den> = {}) {
return await Den.create({
+ place: attrs.place ? null : await createPlace(),
...attrs,
})
}
diff --git a/api/spec/factories/Room/KitchenFactory.ts b/api/spec/factories/Room/KitchenFactory.ts
index cb6d068..5006d45 100644
--- a/api/spec/factories/Room/KitchenFactory.ts
+++ b/api/spec/factories/Room/KitchenFactory.ts
@@ -1,8 +1,10 @@
-import { UpdateableProperties } from '@rvoh/dream/types'
import Kitchen from '@models/Room/Kitchen.js'
+import { UpdateableProperties } from '@rvoh/dream/types'
+import createPlace from '@spec/factories/PlaceFactory.js'
export default async function createKitchen(attrs: UpdateableProperties<Kitchen> = {}) {
return await Kitchen.create({
+ place: attrs.place ? null : await createPlace(),
appliances: ['stove'],
...attrs,
})
diff --git a/api/spec/factories/Room/LivingRoomFactory.ts b/api/spec/factories/Room/LivingRoomFactory.ts
index acca82d..cb831f8 100644
--- a/api/spec/factories/Room/LivingRoomFactory.ts
+++ b/api/spec/factories/Room/LivingRoomFactory.ts
@@ -1,8 +1,10 @@
-import { UpdateableProperties } from '@rvoh/dream/types'
import LivingRoom from '@models/Room/LivingRoom.js'
+import { UpdateableProperties } from '@rvoh/dream/types'
+import createPlace from '@spec/factories/PlaceFactory.js'
export default async function createLivingRoom(attrs: UpdateableProperties<LivingRoom> = {}) {
return await LivingRoom.create({
+ place: attrs.place ? null : await createPlace(),
...attrs,
})
}
diff --git a/api/spec/factories/RoomFactory.ts b/api/spec/factories/RoomFactory.ts
deleted file mode 100644
index c75d9f4..0000000
--- a/api/spec/factories/RoomFactory.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { UpdateableProperties } from '@rvoh/dream/types'
-import Room from '@models/Room.js'
-import createPlace from '@spec/factories/PlaceFactory.js'
-
-export default async function createRoom(attrs: UpdateableProperties<Room> = {}) {
- return await Room.create({
- place: attrs.place ? null : await createPlace(),
- ...attrs,
- })
-}
diff --git a/api/spec/unit/controllers/V1/Host/Places/RoomsController.spec.ts b/api/spec/unit/controllers/V1/Host/Places/RoomsController.spec.ts
index 88ac684..453300a 100644
--- a/api/spec/unit/controllers/V1/Host/Places/RoomsController.spec.ts
+++ b/api/spec/unit/controllers/V1/Host/Places/RoomsController.spec.ts
@@ -1,9 +1,12 @@
+import Place from '@models/Place.js'
import Room from '@models/Room.js'
+import Kitchen from '@models/Room/Kitchen.js'
import User from '@models/User.js'
-import Place from '@models/Place.js'
-import createRoom from '@spec/factories/RoomFactory.js'
-import createUser from '@spec/factories/UserFactory.js'
+import createHost from '@spec/factories/HostFactory.js'
+import createHostPlace from '@spec/factories/HostPlaceFactory.js'
import createPlace from '@spec/factories/PlaceFactory.js'
+import createKitchen from '@spec/factories/Room/KitchenFactory.js'
+import createUser from '@spec/factories/UserFactory.js'
import { RequestBody, session, SpecRequestType } from '@spec/unit/helpers/authentication.js'
describe('V1/Host/Places/RoomsController', () => {
@@ -13,7 +16,9 @@ describe('V1/Host/Places/RoomsController', () => {
beforeEach(async () => {
user = await createUser()
- place = await createPlace({ user })
+ const host = await createHost({ user })
+ place = await createPlace()
+ await createHostPlace({ host, place })
request = await session(user)
})
@@ -25,7 +30,7 @@ describe('V1/Host/Places/RoomsController', () => {
}
it('returns the index of Rooms', async () => {
- const room = await createRoom({ place })
+ const room = await createKitchen({ place })
const { body } = await index(200)
@@ -38,7 +43,7 @@ describe('V1/Host/Places/RoomsController', () => {
context('Rooms created by another Place', () => {
it('are omitted', async () => {
- await createRoom()
+ await createKitchen()
const { body } = await index(200)
@@ -56,7 +61,7 @@ describe('V1/Host/Places/RoomsController', () => {
}
it('returns the specified Room', async () => {
- const room = await createRoom({ place })
+ const room = await createKitchen({ place })
const { body } = await show(room, 200)
@@ -71,7 +76,7 @@ describe('V1/Host/Places/RoomsController', () => {
context('Room created by another Place', () => {
it('is not found', async () => {
- const otherPlaceRoom = await createRoom()
+ const otherPlaceRoom = await createKitchen()
await show(otherPlaceRoom, 404)
})
@@ -91,17 +96,19 @@ describe('V1/Host/Places/RoomsController', () => {
it('creates a Room for this Place', async () => {
const { body } = await create({
- position: 1,
+ type: 'Kitchen',
+ appliances: ['oven', 'stove'],
}, 201)
const room = await place.associationQuery('rooms').firstOrFail()
- expect(room.position).toEqual(1)
+ expect(room.type).toEqual('Kitchen')
+ expect((room as Kitchen).appliances).toEqual(['oven', 'stove'])
expect(body).toEqual(
expect.objectContaining({
id: room.id,
- type: room.type,
- position: room.position,
+ type: 'Kitchen',
+ appliances: ['oven', 'stove'],
}),
)
})
@@ -121,27 +128,26 @@ describe('V1/Host/Places/RoomsController', () => {
}
it('updates the Room', async () => {
- const room = await createRoom({ place })
+ const room = await createKitchen({ place, appliances: ['microwave'] })
await update(room, {
- position: 2,
+ appliances: ['dishwasher'],
}, 204)
await room.reload()
- expect(room.position).toEqual(2)
+ expect(room.appliances).toEqual(['dishwasher'])
})
context('a Room created by another Place', () => {
it('is not updated', async () => {
- const room = await createRoom()
- const originalPosition = room.position
+ const room = await createKitchen({ appliances: ['microwave'] })
await update(room, {
- position: 2,
+ appliances: ['dishwasher'],
}, 404)
await room.reload()
- expect(room.position).toEqual(originalPosition)
+ expect(room.appliances).toEqual(['microwave'])
})
})
})
@@ -155,7 +161,7 @@ describe('V1/Host/Places/RoomsController', () => {
}
it('deletes the Room', async () => {
- const room = await createRoom({ place })
+ const room = await createKitchen({ place })
await destroy(room, 204)
@@ -164,7 +170,7 @@ describe('V1/Host/Places/RoomsController', () => {
context('a Room created by another Place', () => {
it('is not deleted', async () => {
- const room = await createRoom()
+ const room = await createKitchen()
await destroy(room, 404)
diff --git a/api/src/app/controllers/V1/Host/Places/BaseController.ts b/api/src/app/controllers/V1/Host/Places/BaseController.ts
index 475dacc..9da129a 100644
--- a/api/src/app/controllers/V1/Host/Places/BaseController.ts
+++ b/api/src/app/controllers/V1/Host/Places/BaseController.ts
@@ -1,5 +1,14 @@
+import Place from '@models/Place.js'
+import { BeforeAction } from '@rvoh/psychic'
import V1HostBaseController from '../BaseController.js'
export default class V1HostPlacesBaseController extends V1HostBaseController {
+ protected currentPlace: Place
+ @BeforeAction()
+ protected async loadCurrentPlace() {
+ this.currentPlace = await this.currentHost
+ .associationQuery('places')
+ .findOrFail(this.castParam('placeId', 'string'))
+ }
}
diff --git a/api/src/app/controllers/V1/Host/Places/RoomsController.ts b/api/src/app/controllers/V1/Host/Places/RoomsController.ts
index 3fdec77..bf6c9f2 100644
--- a/api/src/app/controllers/V1/Host/Places/RoomsController.ts
+++ b/api/src/app/controllers/V1/Host/Places/RoomsController.ts
@@ -1,6 +1,12 @@
+import Room from '@models/Room.js'
+import Bathroom from '@models/Room/Bathroom.js'
+import Bedroom from '@models/Room/Bedroom.js'
+import Den from '@models/Room/Den.js'
+import Kitchen from '@models/Room/Kitchen.js'
+import LivingRoom from '@models/Room/LivingRoom.js'
import { OpenAPI } from '@rvoh/psychic'
+import { RoomTypesEnumValues } from '@src/types/db.js'
import V1HostPlacesBaseController from './BaseController.js'
-import Room from '@models/Room.js'
const openApiTags = ['rooms']
@@ -14,10 +20,11 @@ export default class V1HostPlacesRoomsController extends V1HostPlacesBaseControl
fastJsonStringify: true,
})
public async index() {
- // const rooms = await this.currentPlace.associationQuery('rooms')
- // .preloadFor('summary')
- // .cursorPaginate({ cursor: this.castParam('cursor', 'string', { allowNull: true }) })
- // this.ok(rooms)
+ const rooms = await this.currentPlace
+ .associationQuery('rooms')
+ .preloadFor('summary')
+ .cursorPaginate({ cursor: this.castParam('cursor', 'string', { allowNull: true }) })
+ this.ok(rooms)
}
@OpenAPI(Room, {
@@ -27,8 +34,8 @@ export default class V1HostPlacesRoomsController extends V1HostPlacesBaseControl
fastJsonStringify: true,
})
public async show() {
- // const room = await this.room()
- // this.ok(room)
+ const room = await this.room()
+ this.ok(room)
}
@OpenAPI(Room, {
@@ -36,11 +43,59 @@ export default class V1HostPlacesRoomsController extends V1HostPlacesBaseControl
tags: openApiTags,
description: 'Create a Room',
fastJsonStringify: true,
+ requestBody: {
+ /**
+ * `type` is normally a protected attribute, but when creating a room, we do want the user
+ * to be able to select room type, we just have to handle it explicitly since it won't be
+ * returned by `paramsFor` (and we don't want it to be since simply setting the type would
+ * not be operating on the correct model, even though the correct model would be hydrated
+ * when loading from the database)
+ */
+ including: ['type'],
+ },
})
public async create() {
- // let room = await this.currentPlace.createAssociation('rooms', this.paramsFor(Room))
- // if (room.isPersisted) room = await room.loadFor('default').execute()
- // this.created(room)
+ let room: Room
+ const roomType = this.castParam('type', 'string', { enum: RoomTypesEnumValues })
+
+ // paramsFor is based on the table (even virtual attributes are associated with
+ // the table at the type level), so passing the STI children to paramsFor
+ // would not alter the results
+ const roomParams = this.paramsFor(Room)
+
+ switch (roomType) {
+ case 'Bathroom':
+ room = await Bathroom.create({ place: this.currentPlace, ...roomParams })
+ break
+
+ case 'Bedroom':
+ room = await Bedroom.create({ place: this.currentPlace, ...roomParams })
+ break
+
+ case 'Den':
+ room = await Den.create({ place: this.currentPlace, ...roomParams })
+ break
+
+ case 'Kitchen':
+ room = await Kitchen.create({ place: this.currentPlace, ...roomParams })
+ break
+
+ case 'LivingRoom':
+ room = await LivingRoom.create({ place: this.currentPlace, ...roomParams })
+ break
+
+ default: {
+ // protection so that if a new RoomTypesEnum is ever added, this will throw a type
+ // error at build time until a case is added to handle that new RoomTypesEnum
+ const _never: never = roomType
+
+ // even though this should never happen due to the type protection, throw an error to satisfy later types
+ throw new Error(`Unhandled RoomTypesEnum: ${_never as string}`)
+ }
+ }
+
+ if (room.isPersisted) room = await room.loadFor('default').execute()
+ this.created(room)
}
@OpenAPI(Room, {
@@ -50,9 +105,9 @@ export default class V1HostPlacesRoomsController extends V1HostPlacesBaseControl
fastJsonStringify: true,
})
public async update() {
- // const room = await this.room()
- // await room.update(this.paramsFor(Room))
- // this.noContent()
+ const room = await this.room()
+ await room.update(this.paramsFor(Room))
+ this.noContent()
}
@OpenAPI({
@@ -62,14 +117,15 @@ export default class V1HostPlacesRoomsController extends V1HostPlacesBaseControl
fastJsonStringify: true,
})
public async destroy() {
- // const room = await this.room()
- // await room.destroy()
- // this.noContent()
+ const room = await this.room()
+ await room.destroy()
+ this.noContent()
}
private async room() {
- // return await this.currentPlace.associationQuery('rooms')
- // .preloadFor('default')
- // .findOrFail(this.castParam('id', 'string'))
+ return await this.currentPlace
+ .associationQuery('rooms')
+ .preloadFor('default')
+ .findOrFail(this.castParam('id', 'string'))
}
}
diff --git a/api/src/app/models/Place.ts b/api/src/app/models/Place.ts
index 9f8b47d..9243aa1 100644
--- a/api/src/app/models/Place.ts
+++ b/api/src/app/models/Place.ts
@@ -1,6 +1,7 @@
import ApplicationModel from '@models/ApplicationModel.js'
import Host from '@models/Host.js'
import HostPlace from '@models/HostPlace.js'
+import Room from '@models/Room.js'
import { Decorators } from '@rvoh/dream'
import { DreamColumn, DreamSerializers } from '@rvoh/dream/types'
@@ -31,4 +32,9 @@ export default class Place extends ApplicationModel {
@deco.HasMany('Host', { through: 'hostPlaces' })
public hosts: Host[]
+
+ @deco.HasMany('Room')
+ // make sure this imports from `import Room from '@models/Room.js'`
+ // not from `import { Room } from 'socket.io-adapter'`
+ public rooms: Room[]
}
diff --git a/api/src/app/models/Room.ts b/api/src/app/models/Room.ts
index 4ea9146..7b34e52 100644
--- a/api/src/app/models/Room.ts
+++ b/api/src/app/models/Room.ts
@@ -1,7 +1,7 @@
-import { Decorators } from '@rvoh/dream'
-import { DreamColumn, DreamSerializers } from '@rvoh/dream/types'
import ApplicationModel from '@models/ApplicationModel.js'
import Place from '@models/Place.js'
+import { Decorators } from '@rvoh/dream'
+import { DreamColumn } from '@rvoh/dream/types'
const deco = new Decorators<typeof Room>()
@@ -10,13 +10,6 @@ export default class Room extends ApplicationModel {
return 'rooms' as const
}
- public get serializers(): DreamSerializers<Room> {
- return {
- default: 'RoomSerializer',
- summary: 'RoomSummarySerializer',
- }
- }
-
public id: DreamColumn<Room, 'id'>
public type: DreamColumn<Room, 'type'>
public position: DreamColumn<Room, 'position'>
diff --git a/api/src/app/models/Room/Bathroom.ts b/api/src/app/models/Room/Bathroom.ts
index 70f5f61..881ead9 100644
--- a/api/src/app/models/Room/Bathroom.ts
+++ b/api/src/app/models/Room/Bathroom.ts
@@ -1,12 +1,12 @@
-import { Decorators, STI } from '@rvoh/dream'
-import { DreamColumn, DreamSerializers } from '@rvoh/dream/types'
import Room from '@models/Room.js'
+import { STI } from '@rvoh/dream'
+import { DreamColumn, DreamSerializers } from '@rvoh/dream/types'
-const deco = new Decorators<typeof Bathroom>()
+// const deco = new Decorators<typeof Bathroom>()
@STI(Room)
export default class Bathroom extends Room {
- public override get serializers(): DreamSerializers<Bathroom> {
+ public get serializers(): DreamSerializers<Bathroom> {
return {
default: 'Room/BathroomSerializer',
summary: 'Room/BathroomSummarySerializer',
diff --git a/api/src/app/models/Room/Bedroom.ts b/api/src/app/models/Room/Bedroom.ts
index b7eabca..2fb83d7 100644
--- a/api/src/app/models/Room/Bedroom.ts
+++ b/api/src/app/models/Room/Bedroom.ts
@@ -1,12 +1,12 @@
-import { Decorators, STI } from '@rvoh/dream'
-import { DreamColumn, DreamSerializers } from '@rvoh/dream/types'
import Room from '@models/Room.js'
+import { STI } from '@rvoh/dream'
+import { DreamColumn, DreamSerializers } from '@rvoh/dream/types'
-const deco = new Decorators<typeof Bedroom>()
+// const deco = new Decorators<typeof Bedroom>()
@STI(Room)
export default class Bedroom extends Room {
- public override get serializers(): DreamSerializers<Bedroom> {
+ public get serializers(): DreamSerializers<Bedroom> {
return {
default: 'Room/BedroomSerializer',
summary: 'Room/BedroomSummarySerializer',
diff --git a/api/src/app/models/Room/Den.ts b/api/src/app/models/Room/Den.ts
index 616ff1e..0f80449 100644
--- a/api/src/app/models/Room/Den.ts
+++ b/api/src/app/models/Room/Den.ts
@@ -1,16 +1,15 @@
-import { Decorators, STI } from '@rvoh/dream'
-import { DreamColumn, DreamSerializers } from '@rvoh/dream/types'
import Room from '@models/Room.js'
+import { STI } from '@rvoh/dream'
+import { DreamSerializers } from '@rvoh/dream/types'
-const deco = new Decorators<typeof Den>()
+// const deco = new Decorators<typeof Den>()
@STI(Room)
export default class Den extends Room {
- public override get serializers(): DreamSerializers<Den> {
+ public get serializers(): DreamSerializers<Den> {
return {
default: 'Room/DenSerializer',
summary: 'Room/DenSummarySerializer',
}
}
-
}
diff --git a/api/src/app/models/Room/Kitchen.ts b/api/src/app/models/Room/Kitchen.ts
index e6e9a80..84eebb2 100644
--- a/api/src/app/models/Room/Kitchen.ts
+++ b/api/src/app/models/Room/Kitchen.ts
@@ -1,12 +1,12 @@
-import { Decorators, STI } from '@rvoh/dream'
-import { DreamColumn, DreamSerializers } from '@rvoh/dream/types'
import Room from '@models/Room.js'
+import { STI } from '@rvoh/dream'
+import { DreamColumn, DreamSerializers } from '@rvoh/dream/types'
-const deco = new Decorators<typeof Kitchen>()
+// const deco = new Decorators<typeof Kitchen>()
@STI(Room)
export default class Kitchen extends Room {
- public override get serializers(): DreamSerializers<Kitchen> {
+ public get serializers(): DreamSerializers<Kitchen> {
return {
default: 'Room/KitchenSerializer',
summary: 'Room/KitchenSummarySerializer',
diff --git a/api/src/app/models/Room/LivingRoom.ts b/api/src/app/models/Room/LivingRoom.ts
index 18781f3..4231e84 100644
--- a/api/src/app/models/Room/LivingRoom.ts
+++ b/api/src/app/models/Room/LivingRoom.ts
@@ -1,16 +1,15 @@
-import { Decorators, STI } from '@rvoh/dream'
-import { DreamColumn, DreamSerializers } from '@rvoh/dream/types'
import Room from '@models/Room.js'
+import { STI } from '@rvoh/dream'
+import { DreamSerializers } from '@rvoh/dream/types'
-const deco = new Decorators<typeof LivingRoom>()
+// const deco = new Decorators<typeof LivingRoom>()
@STI(Room)
export default class LivingRoom extends Room {
- public override get serializers(): DreamSerializers<LivingRoom> {
+ public get serializers(): DreamSerializers<LivingRoom> {
return {
default: 'Room/LivingRoomSerializer',
summary: 'Room/LivingRoomSummarySerializer',
}
}
-
}
diff --git a/api/src/app/serializers/RoomSerializer.ts b/api/src/app/serializers/RoomSerializer.ts
index 79390f9..7a26a36 100644
--- a/api/src/app/serializers/RoomSerializer.ts
+++ b/api/src/app/serializers/RoomSerializer.ts
@@ -1,12 +1,12 @@
-import { DreamSerializer } from '@rvoh/dream'
import Room from '@models/Room.js'
+import { DreamSerializer } from '@rvoh/dream'
export const RoomSummarySerializer = <T extends Room>(StiChildClass: typeof Room, room: T) =>
DreamSerializer(StiChildClass ?? Room, room)
.attribute('id')
+ .attribute('type', { openapi: { type: 'string', enum: [(StiChildClass ?? Room).sanitizedName] } })
+ .attribute('position')
export const RoomSerializer = <T extends Room>(StiChildClass: typeof Room, room: T) =>
RoomSummarySerializer(StiChildClass, room)
- .attribute('type', { openapi: { type: 'string', enum: [(StiChildClass ?? Room).sanitizedName] } })
- .attribute('position')
.attribute('deletedAt')
diff --git a/api/src/openapi/mobile.openapi.json b/api/src/openapi/mobile.openapi.json
index 2c48296..a5705ec 100644
--- a/api/src/openapi/mobile.openapi.json
+++ b/api/src/openapi/mobile.openapi.json
@@ -446,6 +446,16 @@
"integer",
"null"
]
+ },
+ "type": {
+ "type": "string",
+ "enum": [
+ "Bathroom",
+ "Bedroom",
+ "Den",
+ "Kitchen",
+ "LivingRoom"
+ ]
}
}
}
@@ -851,11 +861,23 @@
"type": "object",
"additionalProperties": false,
"required": [
- "id"
+ "id",
+ "position",
+ "type"
],
"properties": {
"id": {
"type": "string"
+ },
+ "position": {
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "type": {
+ "type": "string",
+ "description": "The following values will be allowed:\n Bathroom"
}
}
},
@@ -903,11 +925,23 @@
"type": "object",
"additionalProperties": false,
"required": [
- "id"
+ "id",
+ "position",
+ "type"
],
"properties": {
"id": {
"type": "string"
+ },
+ "position": {
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "type": {
+ "type": "string",
+ "description": "The following values will be allowed:\n Bedroom"
}
}
},
@@ -947,11 +981,23 @@
"type": "object",
"additionalProperties": false,
"required": [
- "id"
+ "id",
+ "position",
+ "type"
],
"properties": {
"id": {
"type": "string"
+ },
+ "position": {
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "type": {
+ "type": "string",
+ "description": "The following values will be allowed:\n Den"
}
}
},
@@ -999,11 +1045,23 @@
"type": "object",
"additionalProperties": false,
"required": [
- "id"
+ "id",
+ "position",
+ "type"
],
"properties": {
"id": {
"type": "string"
+ },
+ "position": {
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "type": {
+ "type": "string",
+ "description": "The following values will be allowed:\n Kitchen"
}
}
},
@@ -1043,11 +1101,23 @@
"type": "object",
"additionalProperties": false,
"required": [
- "id"
+ "id",
+ "position",
+ "type"
],
"properties": {
"id": {
"type": "string"
+ },
+ "position": {
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "type": {
+ "type": "string",
+ "description": "The following values will be allowed:\n LivingRoom"
}
}
},
diff --git a/api/src/openapi/openapi.json b/api/src/openapi/openapi.json
index 6616d1e..e4a969f 100644
--- a/api/src/openapi/openapi.json
+++ b/api/src/openapi/openapi.json
@@ -446,6 +446,16 @@
"integer",
"null"
]
+ },
+ "type": {
+ "type": "string",
+ "enum": [
+ "Bathroom",
+ "Bedroom",
+ "Den",
+ "Kitchen",
+ "LivingRoom"
+ ]
}
}
}
@@ -867,11 +877,25 @@
"type": "object",
"additionalProperties": false,
"required": [
- "id"
+ "id",
+ "position",
+ "type"
],
"properties": {
"id": {
"type": "string"
+ },
+ "position": {
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "type": {
+ "type": "string",
+ "enum": [
+ "Bathroom"
+ ]
}
}
},
@@ -928,11 +952,25 @@
"type": "object",
"additionalProperties": false,
"required": [
- "id"
+ "id",
+ "position",
+ "type"
],
"properties": {
"id": {
"type": "string"
+ },
+ "position": {
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "type": {
+ "type": "string",
+ "enum": [
+ "Bedroom"
+ ]
}
}
},
@@ -974,11 +1012,25 @@
"type": "object",
"additionalProperties": false,
"required": [
- "id"
+ "id",
+ "position",
+ "type"
],
"properties": {
"id": {
"type": "string"
+ },
+ "position": {
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "type": {
+ "type": "string",
+ "enum": [
+ "Den"
+ ]
}
}
},
@@ -1033,11 +1085,25 @@
"type": "object",
"additionalProperties": false,
"required": [
- "id"
+ "id",
+ "position",
+ "type"
],
"properties": {
"id": {
"type": "string"
+ },
+ "position": {
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "type": {
+ "type": "string",
+ "enum": [
+ "Kitchen"
+ ]
}
}
},
@@ -1079,11 +1145,25 @@
"type": "object",
"additionalProperties": false,
"required": [
- "id"
+ "id",
+ "position",
+ "type"
],
"properties": {
"id": {
"type": "string"
+ },
+ "position": {
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "type": {
+ "type": "string",
+ "enum": [
+ "LivingRoom"
+ ]
}
}
},
diff --git a/api/src/openapi/tests.openapi.json b/api/src/openapi/tests.openapi.json
index e34f706..fcc24fe 100644
--- a/api/src/openapi/tests.openapi.json
+++ b/api/src/openapi/tests.openapi.json
@@ -446,6 +446,16 @@
"integer",
"null"
]
+ },
+ "type": {
+ "type": "string",
+ "enum": [
+ "Bathroom",
+ "Bedroom",
+ "Den",
+ "Kitchen",
+ "LivingRoom"
+ ]
}
}
}
@@ -867,11 +877,25 @@
"type": "object",
"additionalProperties": false,
"required": [
- "id"
+ "id",
+ "position",
+ "type"
],
"properties": {
"id": {
"type": "string"
+ },
+ "position": {
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "type": {
+ "type": "string",
+ "enum": [
+ "Bathroom"
+ ]
}
}
},
@@ -928,11 +952,25 @@
"type": "object",
"additionalProperties": false,
"required": [
- "id"
+ "id",
+ "position",
+ "type"
],
"properties": {
"id": {
"type": "string"
+ },
+ "position": {
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "type": {
+ "type": "string",
+ "enum": [
+ "Bedroom"
+ ]
}
}
},
@@ -974,11 +1012,25 @@
"type": "object",
"additionalProperties": false,
"required": [
- "id"
+ "id",
+ "position",
+ "type"
],
"properties": {
"id": {
"type": "string"
+ },
+ "position": {
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "type": {
+ "type": "string",
+ "enum": [
+ "Den"
+ ]
}
}
},
@@ -1033,11 +1085,25 @@
"type": "object",
"additionalProperties": false,
"required": [
- "id"
+ "id",
+ "position",
+ "type"
],
"properties": {
"id": {
"type": "string"
+ },
+ "position": {
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "type": {
+ "type": "string",
+ "enum": [
+ "Kitchen"
+ ]
}
}
},
@@ -1079,11 +1145,25 @@
"type": "object",
"additionalProperties": false,
"required": [
- "id"
+ "id",
+ "position",
+ "type"
],
"properties": {
"id": {
"type": "string"
+ },
+ "position": {
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "type": {
+ "type": "string",
+ "enum": [
+ "LivingRoom"
+ ]
}
}
},
diff --git a/api/src/types/dream.ts b/api/src/types/dream.ts
index a45e34d..9e6360b 100644
--- a/api/src/types/dream.ts
+++ b/api/src/types/dream.ts
@@ -402,6 +402,15 @@ export const schema = {
requiredAndClauses: null,
passthroughAndClauses: null,
},
+ rooms: {
+ type: 'HasMany',
+ foreignKey: 'placeId',
+ foreignKeyTypeColumn: null,
+ tables: ['rooms'],
+ optional: null,
+ requiredAndClauses: null,
+ passthroughAndClauses: null,
+ },
},
},
rooms: {
diff --git a/api/src/types/openapi/tests.openapi.d.ts b/api/src/types/openapi/tests.openapi.d.ts
index 0ff0366..8135272 100644
--- a/api/src/types/openapi/tests.openapi.d.ts
+++ b/api/src/types/openapi/tests.openapi.d.ts
@@ -260,6 +260,8 @@ export interface paths {
bathOrShowerStyle?: "bath" | "bath_and_shower" | "none" | "shower" | null;
bedTypes?: ("bunk" | "cot" | "king" | "queen" | "sofabed" | "twin")[];
position?: number | null;
+ /** @enum {string} */
+ type?: "Bathroom" | "Bedroom" | "Den" | "Kitchen" | "LivingRoom";
};
};
};
@@ -435,6 +437,9 @@ export interface components {
};
RoomBathroomSummary: {
id: string;
+ position: number | null;
+ /** @enum {string} */
+ type: "Bathroom";
};
RoomBedroom: {
bedTypes: ("bunk" | "cot" | "king" | "queen" | "sofabed" | "twin")[];
@@ -447,6 +452,9 @@ export interface components {
};
RoomBedroomSummary: {
id: string;
+ position: number | null;
+ /** @enum {string} */
+ type: "Bedroom";
};
RoomDen: {
/** Format: date-time */
@@ -458,6 +466,9 @@ export interface components {
};
RoomDenSummary: {
id: string;
+ position: number | null;
+ /** @enum {string} */
+ type: "Den";
};
RoomKitchen: {
appliances: ("dishwasher" | "microwave" | "oven" | "stove")[];
@@ -470,6 +481,9 @@ export interface components {
};
RoomKitchenSummary: {
id: string;
+ position: number | null;
+ /** @enum {string} */
+ type: "Kitchen";
};
RoomLivingRoom: {
/** Format: date-time */
@@ -481,6 +495,9 @@ export interface components {
};
RoomLivingRoomSummary: {
id: string;
+ position: number | null;
+ /** @enum {string} */
+ type: "LivingRoom";
};
ValidationErrors: {
/** @enum {string} */