Skip to content

Commit 72a9841

Browse files
authored
Merge pull request #533 from seamapi/ver/2
Version 2 features and breaking changes
2 parents 2edc24a + bf94be8 commit 72a9841

25 files changed

+2128
-2114
lines changed

.storybook/devicedb-seed.json

Lines changed: 1770 additions & 1784 deletions
Large diffs are not rendered by default.

api/fake-seam-connect.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ export default async (
5353
fakeDevicedb.database.vercel_protection_bypass_secret,
5454
})
5555

56-
await fake.startServer()
56+
const { host } = req.headers
57+
if (host == null) throw new Error('Missing Host header')
58+
await fake.startServer({ baseUrl: `https://${host}/api` })
5759

5860
const requestBuffer = await getRawBody(req)
5961

@@ -70,6 +72,7 @@ export default async (
7072
timeout: 10_000,
7173
validateStatus: () => true,
7274
maxRedirects: 0,
75+
responseType: 'arraybuffer',
7376
})
7477

7578
res.status(status)
@@ -78,11 +81,7 @@ export default async (
7881
if (!unproxiedHeaders.has(key)) res.setHeader(key, value)
7982
}
8083

81-
if (typeof data === 'string') {
82-
res.end(data)
83-
} else {
84-
res.json(data)
85-
}
84+
res.end(Buffer.from(data))
8685

8786
fake.server?.close()
8887
fakeDevicedb.server?.close()

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
"luxon": "^3.3.0",
133133
"queue": "^7.0.0",
134134
"react-hook-form": "^7.46.1",
135-
"seamapi": "^8.13.1",
135+
"seamapi": "^8.13.3",
136136
"uuid": "^9.0.0"
137137
},
138138
"devDependencies": {
@@ -141,7 +141,7 @@
141141
"@mui/material": "^5.12.2",
142142
"@rxfork/r2wc-react-to-web-component": "^2.4.0",
143143
"@seamapi/fake-devicedb": "^1.1.0",
144-
"@seamapi/fake-seam-connect": "^1.32.0",
144+
"@seamapi/fake-seam-connect": "^1.37.1",
145145
"@seamapi/http": "^0.2.1",
146146
"@seamapi/types": "^1.28.0",
147147
"@storybook/addon-designs": "^7.0.1",

src/lib/seam/components/AccessCodeTable/AccessCodeTable.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ export interface AccessCodeTableProps extends CommonProps {
4949
onAccessCodeClick?: (accessCodeId: string) => void
5050
preventDefaultOnAccessCodeClick?: boolean
5151
heading?: string | null
52-
/**
53-
* @deprecated Use heading.
54-
*/
55-
title?: string | null
5652
}
5753

5854
type AccessCode = UseAccessCodesData[number]
@@ -82,7 +78,6 @@ export function AccessCodeTable({
8278
errorFilter = () => true,
8379
warningFilter = () => true,
8480
heading = t.accessCodes,
85-
title = t.accessCodes,
8681
className,
8782
disableCreateAccessCode = false,
8883
disableEditAccessCode = false,
@@ -231,10 +226,9 @@ export function AccessCodeTable({
231226
<ContentHeader onBack={onBack} />
232227
<TableHeader>
233228
<div className='seam-left'>
234-
{title != null ? (
229+
{heading != null ? (
235230
<TableTitle>
236-
{heading ?? title ?? t.accessCodes}{' '}
237-
<Caption>({filteredAccessCodes.length})</Caption>
231+
{heading} <Caption>({filteredAccessCodes.length})</Caption>
238232
</TableTitle>
239233
) : (
240234
<div className='seam-fragment' />

src/lib/seam/components/DeviceDetails/ThermostatDeviceDetails.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export function ThermostatDeviceDetails({
133133
</DetailSection>
134134

135135
<DetailSection label={t.deviceDetails}>
136-
<DetailRow label={t.brand}>
136+
<DetailRow label={t.manufacturer}>
137137
<div className='seam-detail-row-hstack'>
138138
{device.properties.model.manufacturer_display_name}
139139
{device.properties.manufacturer === 'ecobee' && <BeeIcon />}
@@ -175,7 +175,7 @@ const t = {
175175
defaultClimate: 'Default climate',
176176
allowManualOverride: 'Allow manual override',
177177
deviceDetails: 'Device details',
178-
brand: 'Brand',
178+
manufacturer: 'Manufacturer',
179179
linkedAccount: 'Linked account',
180180
deviceId: 'Device ID',
181181
none: 'None',

src/lib/seam/components/DeviceTable/DeviceTable.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ export interface DeviceTableProps extends CommonProps {
4141
onDeviceClick?: (deviceId: string) => void
4242
preventDefaultOnDeviceClick?: boolean
4343
heading?: string | null
44-
/**
45-
* @deprecated Use heading.
46-
*/
47-
title?: string | null
4844
}
4945

5046
export const defaultDeviceFilter = (
@@ -67,7 +63,6 @@ export function DeviceTable({
6763
deviceFilter = defaultDeviceFilter,
6864
deviceComparator = compareByCreatedAtDesc,
6965
heading = t.devices,
70-
title = t.devices,
7166
errorFilter = () => true,
7267
warningFilter = () => true,
7368
disableLockUnlock = false,
@@ -129,10 +124,9 @@ export function DeviceTable({
129124
<div className={classNames('seam-device-table', className)}>
130125
<ContentHeader onBack={onBack} />
131126
<TableHeader>
132-
{title != null ? (
127+
{heading != null ? (
133128
<TableTitle>
134-
{heading ?? title ?? t.devices}{' '}
135-
<Caption>({filteredDevices.length})</Caption>
129+
{heading} <Caption>({filteredDevices.length})</Caption>
136130
</TableTitle>
137131
) : (
138132
<div className='seam-fragment' />

src/lib/seam/components/SupportedDeviceTable/SupportedDeviceContent.tsx

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
import type { DeviceModel } from 'seamapi'
1+
import type { DeviceModelV1 } from '@seamapi/types/devicedb'
22

3-
import { SupportedDeviceBrandSection } from 'lib/seam/components/SupportedDeviceTable/SupportedDeviceBrandSection.js'
43
import { SupportedDeviceFilterResultRow } from 'lib/seam/components/SupportedDeviceTable/SupportedDeviceFilterResultRow.js'
4+
import { SupportedDeviceManufacturerSection } from 'lib/seam/components/SupportedDeviceTable/SupportedDeviceManufacturerSection.js'
5+
import type { UseDeviceModelsData } from 'lib/seam/components/SupportedDeviceTable/use-device-models.js'
56
import {
67
type DeviceModelFilters,
78
useFilteredDeviceModels,
89
} from 'lib/seam/components/SupportedDeviceTable/use-filtered-device-models.js'
9-
import type { UseDeviceModelsData } from 'lib/seam/device-models/use-device-models.js'
1010
import { Button } from 'lib/ui/Button.js'
1111

1212
interface SupportedDeviceContentProps {
1313
filterValue: string
1414
resetFilterValue: () => void
1515
filters: DeviceModelFilters
16-
brands: string[] | null
17-
excludedBrands: string[]
16+
manufacturers: string[] | null
17+
excludedManufacturers: string[]
1818
}
1919

2020
export function SupportedDeviceContent({
2121
resetFilterValue,
2222
filterValue,
2323
filters,
24-
brands,
25-
excludedBrands,
24+
manufacturers,
25+
excludedManufacturers,
2626
}: SupportedDeviceContentProps): JSX.Element | null {
2727
const { deviceModels, isLoading, isError, refetch } = useFilteredDeviceModels(
2828
{
2929
filterValue,
3030
filters,
31-
brands,
32-
excludedBrands,
31+
manufacturers,
32+
excludedManufacturers,
3333
}
3434
)
3535

@@ -74,20 +74,14 @@ export function SupportedDeviceContent({
7474
)
7575
}
7676

77-
const hasFilters = filterValue.trim() !== '' || filters.brand !== null
77+
const hasFilters = filterValue.trim() !== '' || filters.manufacturer !== null
7878

7979
if (hasFilters) {
8080
return (
8181
<div className='seam-supported-device-table-content'>
82-
{deviceModels.map((deviceModel, index) => (
82+
{deviceModels.map((deviceModel) => (
8383
<SupportedDeviceFilterResultRow
84-
key={[
85-
deviceModel.main_category,
86-
deviceModel.brand,
87-
deviceModel.model_name,
88-
deviceModel.manufacturer_model_id,
89-
index,
90-
].join(':')}
84+
key={deviceModel.device_model_id}
9185
deviceModel={deviceModel}
9286
/>
9387
))}
@@ -97,11 +91,11 @@ export function SupportedDeviceContent({
9791

9892
return (
9993
<>
100-
{Object.entries(groupDeviceModelsByBrand(deviceModels)).map(
101-
([brand, models]) => (
102-
<SupportedDeviceBrandSection
103-
key={brand}
104-
brand={brand}
94+
{Object.entries(groupDeviceModelsByManufacturer(deviceModels)).map(
95+
([manufacturerId, models]) => (
96+
<SupportedDeviceManufacturerSection
97+
key={manufacturerId}
98+
manufacturerId={manufacturerId}
10599
deviceModels={models}
106100
/>
107101
)
@@ -142,15 +136,15 @@ function EmptyResult({
142136
)
143137
}
144138

145-
function groupDeviceModelsByBrand(
139+
function groupDeviceModelsByManufacturer(
146140
deviceModels: UseDeviceModelsData
147-
): Record<string, DeviceModel[]> {
148-
const result: Record<string, DeviceModel[]> = {}
141+
): Record<string, DeviceModelV1[]> {
142+
const result: Record<string, DeviceModelV1[]> = {}
149143

150144
for (const model of deviceModels) {
151-
const { brand } = model
152-
const list = result[brand] ?? []
153-
result[brand] = [...list, model]
145+
const { manufacturer } = model
146+
const list = result[manufacturer.manufacturer_id] ?? []
147+
result[manufacturer.manufacturer_id] = [...list, model]
154148
}
155149
return result
156150
}

src/lib/seam/components/SupportedDeviceTable/SupportedDeviceContentRows.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { SupportedDeviceRow } from 'lib/seam/components/SupportedDeviceTable/SupportedDeviceRow.js'
2-
import type { UseDeviceModelsData } from 'lib/seam/device-models/use-device-models.js'
2+
import type { UseDeviceModelsData } from 'lib/seam/components/SupportedDeviceTable/use-device-models.js'
33

44
interface SupportedDeviceContentRowsProps {
55
deviceModels: UseDeviceModelsData
@@ -10,15 +10,9 @@ export function SupportedDeviceContentRows({
1010
}: SupportedDeviceContentRowsProps): JSX.Element | null {
1111
return (
1212
<div className='seam-supported-device-table-content'>
13-
{deviceModels.map((deviceModel, index) => (
13+
{deviceModels.map((deviceModel) => (
1414
<SupportedDeviceRow
15-
key={[
16-
deviceModel.main_category,
17-
deviceModel.brand,
18-
deviceModel.model_name,
19-
deviceModel.manufacturer_model_id,
20-
index,
21-
].join(':')}
15+
key={deviceModel.device_model_id}
2216
deviceModel={deviceModel}
2317
/>
2418
))}

0 commit comments

Comments
 (0)