Let prettier change a load of things because new prettier has new rules :(

This commit is contained in:
Julian Stirling 2025-11-02 18:15:02 +00:00
parent a05156407b
commit 1601bdd123
44 changed files with 218 additions and 262 deletions

View file

@ -28,12 +28,7 @@ export const wotStoreModule = {
// Deduplication should be done elsewhere.
let response = await axios.get(uri);
let td = response.data;
let thing_name =
name |
uri
.replace(/\/$/, "")
.split("/")
.pop();
let thing_name = name | uri.replace(/\/$/, "").split("/").pop();
commit("addThingDescription", {
thingName: thing_name,
thingDescription: td,
@ -53,38 +48,40 @@ export const wotStoreModule = {
},
},
getters: {
thingDescriptions: state => {
thingDescriptions: (state) => {
return state.thingDescriptions;
},
thingDescription: state => thingName => {
thingDescription: (state) => (thingName) => {
return state.thingDescriptions[thingName];
},
thingAvailable: state => thingName => {
thingAvailable: (state) => (thingName) => {
return thingName in state.thingDescriptions;
},
thingFormUrl: state => (thing, affordanceType, affordance, op, allowUndefined = true) => {
// Find the URL for a particular operation
let td = state.thingDescriptions[thing];
if (!td) {
if (allowUndefined) return undefined;
throw `Could not find form for ${affordanceType} ${thing}/${affordance} with op ${op}`;
}
let affordances = td[affordanceType];
let href = findFormHref(affordances[affordance], op);
if (href == undefined) {
if (allowUndefined) return undefined;
throw `Could not find form for ${affordanceType} ${thing}/${affordance} with op ${op}`;
}
// If we've found an href, prepend the `base` URL if appropriate
if (href.startsWith("http")) return href;
if ("base" in td) {
let base = td.base;
if (href.startsWith("/")) href = href.slice(1);
if (!base.endsWith("/")) base += "/";
return base + href;
}
return href;
},
thingFormUrl:
(state) =>
(thing, affordanceType, affordance, op, allowUndefined = true) => {
// Find the URL for a particular operation
let td = state.thingDescriptions[thing];
if (!td) {
if (allowUndefined) return undefined;
throw `Could not find form for ${affordanceType} ${thing}/${affordance} with op ${op}`;
}
let affordances = td[affordanceType];
let href = findFormHref(affordances[affordance], op);
if (href == undefined) {
if (allowUndefined) return undefined;
throw `Could not find form for ${affordanceType} ${thing}/${affordance} with op ${op}`;
}
// If we've found an href, prepend the `base` URL if appropriate
if (href.startsWith("http")) return href;
if ("base" in td) {
let base = td.base;
if (href.startsWith("/")) href = href.slice(1);
if (!base.endsWith("/")) base += "/";
return base + href;
}
return href;
},
thingPropertyUrl: (_state, getters) => (thing, property, op, allowUndefined) => {
// Find the URL for a particular property
return getters.thingFormUrl(thing, "properties", property, op, allowUndefined);
@ -100,7 +97,7 @@ export function findFormHref(affordance, op) {
// Find the form in the affordance that matches the given operation type
if (affordance == undefined) return undefined;
let forms = affordance.forms;
let matchingForm = forms.find(f => f.op == op || f.op.includes(op));
let matchingForm = forms.find((f) => f.op == op || f.op.includes(op));
if (matchingForm == undefined) return undefined;
return matchingForm.href;
}