Skip to content

Commit 7481eba

Browse files
committed
Third try to fix conflicts and... build!
1 parent 483f98a commit 7481eba

File tree

3 files changed

+64
-153
lines changed

3 files changed

+64
-153
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const StateAttribute = require("./StateAttribute");
2+
3+
class OperationModeStateAttribute extends StateAttribute {
4+
/**
5+
* @param {object} options
6+
* @param {OperationModeAttributeValue} options.value
7+
* @param {object} [options.metaData]
8+
*/
9+
constructor(options) {
10+
super(options);
11+
12+
this.value = options.value;
13+
}
14+
15+
/**
16+
*
17+
* @param {OperationModeStateAttribute} otherAttribute
18+
* @return {boolean}
19+
*/
20+
equals(otherAttribute) {
21+
return this.__class === otherAttribute.__class &&
22+
this.type === otherAttribute.type &&
23+
this.subType === otherAttribute.subType &&
24+
this.value === otherAttribute.value;
25+
}
26+
}
27+
28+
/**
29+
* @typedef {string} OperationModeAttributeValue
30+
* @enum {string}
31+
*
32+
*/
33+
OperationModeStateAttribute.VALUE = Object.freeze({
34+
VACUUM: "vacuum",
35+
MOP: "mop",
36+
VACUUM_AND_MOP: "vacuum_and_mop"
37+
});
38+
39+
40+
module.exports = OperationModeStateAttribute;

backend/lib/entities/state/attributes/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module.exports = {
33
BatteryStateAttribute: require("./BatteryStateAttribute"),
44
ConsumableStateAttribute: require("./ConsumableStateAttribute"),
55
DockStatusStateAttribute: require("./DockStatusStateAttribute"),
6+
OperationModeStateAttribute: require("./OperationModeStateAttribute"),
67
PresetSelectionStateAttribute: require("./PresetSelectionStateAttribute"),
78
StatusStateAttribute: require("./StatusStateAttribute")
89
};

util/build_openapi_schema.mjs

Lines changed: 23 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import * as path from "path";
66
const __dirname = path.resolve();
77

88
process.on("uncaughtException", function (err) {
9-
// eslint-disable-next-line no-console
10-
console.log(err);
11-
process.exit(1);
9+
// eslint-disable-next-line no-console
10+
console.log(err);
11+
process.exit(1);
1212
});
1313

1414
const options = {
@@ -80,161 +80,31 @@ const options = {
8080
{BasicAuth: []}
8181
],
8282
},
83-
servers: [{ url: "../" }],
84-
tags: [
85-
//Swagger UI respects the order of these
86-
{ name: "Valetudo", description: "Valetudo management API" },
87-
{ name: "ValetudoEvents", description: "Valetudo Events" },
88-
{ name: "Robot", description: "Robot API" },
89-
{ name: "System", description: "System API" },
90-
{ name: "NTP", description: "NTP Client API" },
91-
{ name: "Timers", description: "Timers API" },
92-
{ name: "Updater", description: "Update Valetudo using Valetudo" },
93-
94-
{
95-
name: "BasicControlCapability",
96-
description: "Basic control capability",
97-
},
98-
{
99-
name: "FanSpeedControlCapability",
100-
description: "Fan speed control capability",
101-
},
102-
{
103-
name: "WaterUsageControlCapability",
104-
description: "Water usage control capability",
105-
},
106-
{
107-
name: "WifiConfigurationCapability",
108-
description: "Wi-Fi configuration capability",
109-
},
110-
{ name: "WifiScanCapability", description: "Wi-Fi scan capability" },
111-
{
112-
name: "ZoneCleaningCapability",
113-
description: "Zone cleaning capability",
114-
},
115-
{
116-
name: "MapSegmentationCapability",
117-
description: "Map segment cleaning capability",
118-
},
119-
{
120-
name: "ManualControlCapability",
121-
description: "Manual control capability",
122-
},
123-
{
124-
name: "DoNotDisturbCapability",
125-
description: "Do-not-disturb configuration capability",
126-
},
127-
{
128-
name: "ConsumableMonitoringCapability",
129-
description: "Consumable monitoring capability",
130-
},
131-
{ name: "LocateCapability", description: "Robot locate capability" },
132-
{
133-
name: "GoToLocationCapability",
134-
description: "Go-to location capability",
135-
},
136-
{
137-
name: "CarpetModeControlCapability",
138-
description: "Carpet mode settings capability",
139-
},
140-
{ name: "MapResetCapability", description: "Map reset capability" },
141-
{
142-
name: "MapSegmentEditCapability",
143-
description: "Map segment edit capability",
144-
},
145-
{
146-
name: "MapSegmentRenameCapability",
147-
description: "Map segment rename capability",
148-
},
149-
{
150-
name: "MapSnapshotCapability",
151-
description: "Map snapshots capability",
152-
},
153-
{
154-
name: "PersistentMapControlCapability",
155-
description: "Persistent map control capability",
156-
},
157-
{
158-
name: "SensorCalibrationCapability",
159-
description: "Sensor calibration capability",
160-
},
161-
{ name: "SpeakerTestCapability", description: "Speaker test capability" },
162-
{
163-
name: "SpeakerVolumeControlCapability",
164-
description: "Speaker volume control capability",
165-
},
166-
{
167-
name: "VoicePackManagementCapability",
168-
description: "Voice pack management capability",
169-
},
170-
{
171-
name: "CombinedVirtualRestrictionsCapability",
172-
description: "Combined virtual restrictions capability",
173-
},
174-
{
175-
name: "PendingMapChangeHandlingCapability",
176-
description: "Pending map change handling capability",
177-
},
178-
{ name: "MappingPassCapability", description: "Mapping pass capability" },
179-
{ name: "KeyLockCapability", description: "Key lock capability" },
180-
],
181-
components: {
182-
responses: {
183-
200: { description: "Ok" },
184-
201: { description: "Created" },
185-
202: { description: "Accepted" },
186-
400: { description: "Bad request" },
187-
403: { description: "Forbidden" },
188-
404: { description: "Not found" },
189-
500: { description: "Internal server error" },
190-
},
191-
parameters: {},
192-
securitySchemes: {
193-
BasicAuth: {
194-
type: "http",
195-
scheme: "basic",
196-
},
197-
},
198-
},
199-
security: [{ BasicAuth: [] }],
200-
},
201-
apis: [
202-
path.join(__dirname, "./backend/util/openapi_defs/*.openapi.json"),
203-
path.join(__dirname, "./backend/lib/doc/*.openapi.json"),
204-
path.join(__dirname, "./backend/lib/webserver/doc/*.openapi.json"),
205-
path.join(
206-
__dirname,
207-
"./backend/lib/webserver/capabilityRouters/doc/*.openapi.json"
208-
),
209-
path.join(
210-
__dirname,
211-
"./backend/lib/webserver/middlewares/doc/*.openapi.json"
212-
),
213-
path.join(__dirname, "./backend/lib/entities/doc/*.openapi.json"),
214-
path.join(__dirname, "./backend/lib/entities/map/doc/*.openapi.json"),
215-
path.join(__dirname, "./backend/lib/entities/core/doc/*.openapi.json"),
216-
path.join(
217-
__dirname,
218-
"./backend/lib/entities/core/ntpClient/doc/*.openapi.json"
219-
),
220-
path.join(
221-
__dirname,
222-
"./backend/lib/entities/core/updater/doc/*.openapi.json"
223-
),
224-
path.join(__dirname, "./backend/lib/entities/state/doc/*.openapi.json"),
225-
path.join(
226-
__dirname,
227-
"./backend/lib/entities/state/attributes/doc/*.openapi.json"
228-
),
229-
path.join(__dirname, "./backend/lib/core/capabilities/doc/*.openapi.json"),
230-
],
83+
apis: [
84+
path.join(__dirname, "./backend/util/openapi_defs/*.openapi.json"),
85+
path.join(__dirname, "./backend/lib/doc/*.openapi.json"),
86+
path.join(__dirname, "./backend/lib/webserver/doc/*.openapi.json"),
87+
path.join(__dirname, "./backend/lib/webserver/capabilityRouters/doc/*.openapi.json"),
88+
path.join(__dirname, "./backend/lib/webserver/middlewares/doc/*.openapi.json"),
89+
path.join(__dirname, "./backend/lib/entities/doc/*.openapi.json"),
90+
path.join(__dirname, "./backend/lib/entities/map/doc/*.openapi.json"),
91+
path.join(__dirname, "./backend/lib/entities/core/doc/*.openapi.json"),
92+
path.join(__dirname, "./backend/lib/entities/core/ntpClient/doc/*.openapi.json"),
93+
path.join(__dirname, "./backend/lib/entities/core/updater/doc/*.openapi.json"),
94+
path.join(__dirname, "./backend/lib/entities/state/doc/*.openapi.json"),
95+
path.join(__dirname, "./backend/lib/entities/state/attributes/doc/*.openapi.json"),
96+
path.join(__dirname, "./backend/lib/core/capabilities/doc/*.openapi.json")
97+
]
23198
};
23299

233100
const spec = await swaggerJsdoc(options);
234101

235102
await SwaggerParser.validate(spec);
236103

104+
237105
fs.writeFileSync(
238-
path.join(__dirname, "./backend/lib/res/valetudo.openapi.schema.json"),
239-
JSON.stringify(spec)
106+
path.join(__dirname, "./backend/lib/res/valetudo.openapi.schema.json"),
107+
JSON.stringify(spec)
240108
);
109+
110+

0 commit comments

Comments
 (0)