Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions project/server/src/api/endpoint/derived/device/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Schema } from "effect";
import type { PickDeep } from "type-fest";

import integrations from "../../../../categorized-integrations.json";
import { logger } from "../../../../logger";
import {
DeviceCategoryIdValue,
DeviceConnectivityValue,
Expand Down Expand Up @@ -142,13 +143,19 @@ export const getDerivedDevices = (
? integrations[item.integration as Integration]
: undefined;

if (typeof integration === "undefined") {
logger.warn(
`integration definition missing for <${item.integration}>`,
{ integration: item.integration },
);

continue;
}

const independent = {
id: item.id,
integration: {
name:
typeof integration !== "undefined"
? integration.title
: undefined,
name: integration.title,
domain: item.integration,
},
manufacturer: item.manufacturer,
Expand Down Expand Up @@ -238,10 +245,21 @@ export const getDerivedDevice = (
? integrations[result.integration as Integration]
: undefined;

if (typeof integration === "undefined") {
logger.warn(
`integration definition missing for <${result.integration}>`,
{ integration: result.integration },
);

return {
code: 404,
body: "not found",
} as const;
}

const independent = {
integration: {
name:
typeof integration !== "undefined" ? integration.title : undefined,
name: integration.title,
domain: result.integration,
},
manufacturer: result.manufacturer,
Expand Down
1 change: 1 addition & 0 deletions schema/spec/derived/device.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ DerivedDeviceMono:
type: object
required:
- domain
- name
properties:
name:
type: string
Expand Down