Skip to main content

Generate Room/Den and Room/LivingRoom STI models

Commit Message

Generate Room/Den and Room/LivingRoom STI models

```console
pnpm psy g:sti-child --help
pnpm psy g:sti-child --model-name=Den Room/Den extends Room
pnpm psy g:sti-child --model-name=LivingRoom Room/LivingRoom extends Room
pnpm psy sync
```

Changes

diff --git a/api/spec/factories/Room/DenFactory.ts b/api/spec/factories/Room/DenFactory.ts
new file mode 100644
index 0000000..1a26df8
--- /dev/null
+++ b/api/spec/factories/Room/DenFactory.ts
@@ -0,0 +1,8 @@
+import { UpdateableProperties } from '@rvoh/dream/types'
+import Den from '@models/Room/Den.js'
+
+export default async function createDen(attrs: UpdateableProperties<Den> = {}) {
+ return await Den.create({
+ ...attrs,
+ })
+}
diff --git a/api/spec/factories/Room/LivingRoomFactory.ts b/api/spec/factories/Room/LivingRoomFactory.ts
new file mode 100644
index 0000000..acca82d
--- /dev/null
+++ b/api/spec/factories/Room/LivingRoomFactory.ts
@@ -0,0 +1,8 @@
+import { UpdateableProperties } from '@rvoh/dream/types'
+import LivingRoom from '@models/Room/LivingRoom.js'
+
+export default async function createLivingRoom(attrs: UpdateableProperties<LivingRoom> = {}) {
+ return await LivingRoom.create({
+ ...attrs,
+ })
+}
diff --git a/api/spec/unit/models/Room/Den.spec.ts b/api/spec/unit/models/Room/Den.spec.ts
new file mode 100644
index 0000000..f1e12ce
--- /dev/null
+++ b/api/spec/unit/models/Room/Den.spec.ts
@@ -0,0 +1,3 @@
+describe('Room/Den', () => {
+ it.todo('add a test here to get started building Room/Den')
+})
diff --git a/api/spec/unit/models/Room/LivingRoom.spec.ts b/api/spec/unit/models/Room/LivingRoom.spec.ts
new file mode 100644
index 0000000..6e4aa50
--- /dev/null
+++ b/api/spec/unit/models/Room/LivingRoom.spec.ts
@@ -0,0 +1,3 @@
+describe('Room/LivingRoom', () => {
+ it.todo('add a test here to get started building Room/LivingRoom')
+})
diff --git a/api/src/app/models/Room/Den.ts b/api/src/app/models/Room/Den.ts
new file mode 100644
index 0000000..2c0a986
--- /dev/null
+++ b/api/src/app/models/Room/Den.ts
@@ -0,0 +1,18 @@
+import { STI } from '@rvoh/dream'
+import { DreamColumn, DreamSerializers } from '@rvoh/dream/types'
+import Room from '@models/Room.js'
+
+// Uncomment when adding decorators (@deco.BelongsTo, @deco.Validates, etc.):
+// import { Decorators } from '@rvoh/dream'
+// const deco = new Decorators<typeof Den>()
+
+@STI(Room)
+export default class Den extends Room {
+ public override get serializers(): DreamSerializers<Den> {
+ return {
+ default: 'Room/DenSerializer',
+ summary: 'Room/DenSummarySerializer',
+ }
+ }
+
+}
diff --git a/api/src/app/models/Room/LivingRoom.ts b/api/src/app/models/Room/LivingRoom.ts
new file mode 100644
index 0000000..1069ae8
--- /dev/null
+++ b/api/src/app/models/Room/LivingRoom.ts
@@ -0,0 +1,18 @@
+import { STI } from '@rvoh/dream'
+import { DreamColumn, DreamSerializers } from '@rvoh/dream/types'
+import Room from '@models/Room.js'
+
+// Uncomment when adding decorators (@deco.BelongsTo, @deco.Validates, etc.):
+// import { Decorators } from '@rvoh/dream'
+// const deco = new Decorators<typeof LivingRoom>()
+
+@STI(Room)
+export default class LivingRoom extends Room {
+ public override get serializers(): DreamSerializers<LivingRoom> {
+ return {
+ default: 'Room/LivingRoomSerializer',
+ summary: 'Room/LivingRoomSummarySerializer',
+ }
+ }
+
+}
diff --git a/api/src/app/serializers/Room/DenSerializer.ts b/api/src/app/serializers/Room/DenSerializer.ts
new file mode 100644
index 0000000..5d4db09
--- /dev/null
+++ b/api/src/app/serializers/Room/DenSerializer.ts
@@ -0,0 +1,8 @@
+import { RoomSerializer, RoomSummarySerializer } from '@serializers/RoomSerializer.js'
+import Den from '@models/Room/Den.js'
+
+export const RoomDenSummarySerializer = (den: Den) =>
+ RoomSummarySerializer(Den, den)
+
+export const RoomDenSerializer = (den: Den) =>
+ RoomSerializer(Den, den)
diff --git a/api/src/app/serializers/Room/LivingRoomSerializer.ts b/api/src/app/serializers/Room/LivingRoomSerializer.ts
new file mode 100644
index 0000000..473d39b
--- /dev/null
+++ b/api/src/app/serializers/Room/LivingRoomSerializer.ts
@@ -0,0 +1,8 @@
+import { RoomSerializer, RoomSummarySerializer } from '@serializers/RoomSerializer.js'
+import LivingRoom from '@models/Room/LivingRoom.js'
+
+export const RoomLivingRoomSummarySerializer = (livingRoom: LivingRoom) =>
+ RoomSummarySerializer(LivingRoom, livingRoom)
+
+export const RoomLivingRoomSerializer = (livingRoom: LivingRoom) =>
+ RoomSerializer(LivingRoom, livingRoom)
diff --git a/api/src/openapi/mobile.openapi.json b/api/src/openapi/mobile.openapi.json
index cf4d2d1..ca09d72 100644
--- a/api/src/openapi/mobile.openapi.json
+++ b/api/src/openapi/mobile.openapi.json
@@ -350,8 +350,14 @@
{
"$ref": "#/components/schemas/RoomBedroomSummary"
},
+ {
+ "$ref": "#/components/schemas/RoomDenSummary"
+ },
{
"$ref": "#/components/schemas/RoomKitchenSummary"
+ },
+ {
+ "$ref": "#/components/schemas/RoomLivingRoomSummary"
}
]
}
@@ -419,8 +425,14 @@
{
"$ref": "#/components/schemas/RoomBedroom"
},
+ {
+ "$ref": "#/components/schemas/RoomDen"
+ },
{
"$ref": "#/components/schemas/RoomKitchen"
+ },
+ {
+ "$ref": "#/components/schemas/RoomLivingRoom"
}
]
}
@@ -488,8 +500,14 @@
{
"$ref": "#/components/schemas/RoomBedroom"
},
+ {
+ "$ref": "#/components/schemas/RoomDen"
+ },
{
"$ref": "#/components/schemas/RoomKitchen"
+ },
+ {
+ "$ref": "#/components/schemas/RoomLivingRoom"
}
]
}
@@ -785,6 +803,40 @@
}
}
},
+ "RoomDen": {
+ "type": "object",
+ "required": [
+ "id",
+ "position",
+ "type"
+ ],
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "position": {
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "type": {
+ "type": "string",
+ "description": "The following values will be allowed:\n Den"
+ }
+ }
+ },
+ "RoomDenSummary": {
+ "type": "object",
+ "required": [
+ "id"
+ ],
+ "properties": {
+ "id": {
+ "type": "string"
+ }
+ }
+ },
"RoomKitchen": {
"type": "object",
"required": [
@@ -827,6 +879,40 @@
}
}
},
+ "RoomLivingRoom": {
+ "type": "object",
+ "required": [
+ "id",
+ "position",
+ "type"
+ ],
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "position": {
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "type": {
+ "type": "string",
+ "description": "The following values will be allowed:\n LivingRoom"
+ }
+ }
+ },
+ "RoomLivingRoomSummary": {
+ "type": "object",
+ "required": [
+ "id"
+ ],
+ "properties": {
+ "id": {
+ "type": "string"
+ }
+ }
+ },
"ValidationErrors": {
"type": "object",
"required": [
diff --git a/api/src/openapi/openapi.json b/api/src/openapi/openapi.json
index d09bfd5..9a96900 100644
--- a/api/src/openapi/openapi.json
+++ b/api/src/openapi/openapi.json
@@ -350,8 +350,14 @@
{
"$ref": "#/components/schemas/RoomBedroomSummary"
},
+ {
+ "$ref": "#/components/schemas/RoomDenSummary"
+ },
{
"$ref": "#/components/schemas/RoomKitchenSummary"
+ },
+ {
+ "$ref": "#/components/schemas/RoomLivingRoomSummary"
}
]
}
@@ -419,8 +425,14 @@
{
"$ref": "#/components/schemas/RoomBedroom"
},
+ {
+ "$ref": "#/components/schemas/RoomDen"
+ },
{
"$ref": "#/components/schemas/RoomKitchen"
+ },
+ {
+ "$ref": "#/components/schemas/RoomLivingRoom"
}
]
}
@@ -488,8 +500,14 @@
{
"$ref": "#/components/schemas/RoomBedroom"
},
+ {
+ "$ref": "#/components/schemas/RoomDen"
+ },
{
"$ref": "#/components/schemas/RoomKitchen"
+ },
+ {
+ "$ref": "#/components/schemas/RoomLivingRoom"
}
]
}
@@ -810,6 +828,42 @@
}
}
},
+ "RoomDen": {
+ "type": "object",
+ "required": [
+ "id",
+ "position",
+ "type"
+ ],
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "position": {
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "type": {
+ "type": "string",
+ "enum": [
+ "Den"
+ ]
+ }
+ }
+ },
+ "RoomDenSummary": {
+ "type": "object",
+ "required": [
+ "id"
+ ],
+ "properties": {
+ "id": {
+ "type": "string"
+ }
+ }
+ },
"RoomKitchen": {
"type": "object",
"required": [
@@ -859,6 +913,42 @@
}
}
},
+ "RoomLivingRoom": {
+ "type": "object",
+ "required": [
+ "id",
+ "position",
+ "type"
+ ],
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "position": {
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "type": {
+ "type": "string",
+ "enum": [
+ "LivingRoom"
+ ]
+ }
+ }
+ },
+ "RoomLivingRoomSummary": {
+ "type": "object",
+ "required": [
+ "id"
+ ],
+ "properties": {
+ "id": {
+ "type": "string"
+ }
+ }
+ },
"ValidationErrors": {
"type": "object",
"required": [
diff --git a/api/src/openapi/tests.openapi.json b/api/src/openapi/tests.openapi.json
index 7d02636..a6dd096 100644
--- a/api/src/openapi/tests.openapi.json
+++ b/api/src/openapi/tests.openapi.json
@@ -350,8 +350,14 @@
{
"$ref": "#/components/schemas/RoomBedroomSummary"
},
+ {
+ "$ref": "#/components/schemas/RoomDenSummary"
+ },
{
"$ref": "#/components/schemas/RoomKitchenSummary"
+ },
+ {
+ "$ref": "#/components/schemas/RoomLivingRoomSummary"
}
]
}
@@ -419,8 +425,14 @@
{
"$ref": "#/components/schemas/RoomBedroom"
},
+ {
+ "$ref": "#/components/schemas/RoomDen"
+ },
{
"$ref": "#/components/schemas/RoomKitchen"
+ },
+ {
+ "$ref": "#/components/schemas/RoomLivingRoom"
}
]
}
@@ -488,8 +500,14 @@
{
"$ref": "#/components/schemas/RoomBedroom"
},
+ {
+ "$ref": "#/components/schemas/RoomDen"
+ },
{
"$ref": "#/components/schemas/RoomKitchen"
+ },
+ {
+ "$ref": "#/components/schemas/RoomLivingRoom"
}
]
}
@@ -810,6 +828,42 @@
}
}
},
+ "RoomDen": {
+ "type": "object",
+ "required": [
+ "id",
+ "position",
+ "type"
+ ],
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "position": {
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "type": {
+ "type": "string",
+ "enum": [
+ "Den"
+ ]
+ }
+ }
+ },
+ "RoomDenSummary": {
+ "type": "object",
+ "required": [
+ "id"
+ ],
+ "properties": {
+ "id": {
+ "type": "string"
+ }
+ }
+ },
"RoomKitchen": {
"type": "object",
"required": [
@@ -859,6 +913,42 @@
}
}
},
+ "RoomLivingRoom": {
+ "type": "object",
+ "required": [
+ "id",
+ "position",
+ "type"
+ ],
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "position": {
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "type": {
+ "type": "string",
+ "enum": [
+ "LivingRoom"
+ ]
+ }
+ }
+ },
+ "RoomLivingRoomSummary": {
+ "type": "object",
+ "required": [
+ "id"
+ ],
+ "properties": {
+ "id": {
+ "type": "string"
+ }
+ }
+ },
"ValidationErrors": {
"type": "object",
"required": [
diff --git a/api/src/types/dream.globals.ts b/api/src/types/dream.globals.ts
index a014277..b6e5538 100644
--- a/api/src/types/dream.globals.ts
+++ b/api/src/types/dream.globals.ts
@@ -68,8 +68,12 @@ export const globalTypeConfig = {
'Room/BathroomSummarySerializer',
'Room/BedroomSerializer',
'Room/BedroomSummarySerializer',
+ 'Room/DenSerializer',
+ 'Room/DenSummarySerializer',
'Room/KitchenSerializer',
'Room/KitchenSummarySerializer',
+ 'Room/LivingRoomSerializer',
+ 'Room/LivingRoomSummarySerializer',
'RoomSerializer',
'RoomSummarySerializer',
],
diff --git a/api/src/types/dream.ts b/api/src/types/dream.ts
index 5c8ea9a..facc6e2 100644
--- a/api/src/types/dream.ts
+++ b/api/src/types/dream.ts
@@ -651,7 +651,9 @@ export const connectionTypeConfig = {
Room: 'rooms',
'Room/Bathroom': 'rooms',
'Room/Bedroom': 'rooms',
+ 'Room/Den': 'rooms',
'Room/Kitchen': 'rooms',
+ 'Room/LivingRoom': 'rooms',
User: 'users',
},
},
diff --git a/api/src/types/openapi/tests.openapi.d.ts b/api/src/types/openapi/tests.openapi.d.ts
index 1066893..a34709d 100644
--- a/api/src/types/openapi/tests.openapi.d.ts
+++ b/api/src/types/openapi/tests.openapi.d.ts
@@ -225,7 +225,7 @@ export interface paths {
content: {
"application/json": {
cursor: string | null;
- results: (components["schemas"]["RoomBathroomSummary"] | components["schemas"]["RoomBedroomSummary"] | components["schemas"]["RoomKitchenSummary"])[];
+ results: (components["schemas"]["RoomBathroomSummary"] | components["schemas"]["RoomBedroomSummary"] | components["schemas"]["RoomDenSummary"] | components["schemas"]["RoomKitchenSummary"] | components["schemas"]["RoomLivingRoomSummary"])[];
};
};
};
@@ -266,7 +266,7 @@ export interface paths {
[name: string]: unknown;
};
content: {
- "application/json": components["schemas"]["RoomBathroom"] | components["schemas"]["RoomBedroom"] | components["schemas"]["RoomKitchen"];
+ "application/json": components["schemas"]["RoomBathroom"] | components["schemas"]["RoomBedroom"] | components["schemas"]["RoomDen"] | components["schemas"]["RoomKitchen"] | components["schemas"]["RoomLivingRoom"];
};
};
400: components["responses"]["BadRequest"];
@@ -313,7 +313,7 @@ export interface paths {
[name: string]: unknown;
};
content: {
- "application/json": components["schemas"]["RoomBathroom"] | components["schemas"]["RoomBedroom"] | components["schemas"]["RoomKitchen"];
+ "application/json": components["schemas"]["RoomBathroom"] | components["schemas"]["RoomBedroom"] | components["schemas"]["RoomDen"] | components["schemas"]["RoomKitchen"] | components["schemas"]["RoomLivingRoom"];
};
};
400: components["responses"]["BadRequest"];
@@ -434,6 +434,15 @@ export interface components {
RoomBedroomSummary: {
id: string;
};
+ RoomDen: {
+ id: string;
+ position: number | null;
+ /** @enum {string} */
+ type: "Den";
+ };
+ RoomDenSummary: {
+ id: string;
+ };
RoomKitchen: {
appliances: ("dishwasher" | "microwave" | "oven" | "stove")[];
id: string;
@@ -444,6 +453,15 @@ export interface components {
RoomKitchenSummary: {
id: string;
};
+ RoomLivingRoom: {
+ id: string;
+ position: number | null;
+ /** @enum {string} */
+ type: "LivingRoom";
+ };
+ RoomLivingRoomSummary: {
+ id: string;
+ };
ValidationErrors: {
/** @enum {string} */
type: "validation";