@seamapi/react 5.2.4 → 5.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/ecosystem.js +11 -10
- package/dist/ecosystem.js.map +1 -1
- package/dist/elements.js +12339 -11523
- package/dist/elements.js.map +1 -1
- package/dist/index.css +996 -162
- package/dist/index.css.map +1 -1
- package/dist/index.min.css +1 -1
- package/dist/index.min.css.map +1 -1
- package/lib/seam/components/SupportedDevices/AccessoryCatalog.d.ts +9 -0
- package/lib/seam/components/SupportedDevices/AccessoryCatalog.js +40 -0
- package/lib/seam/components/SupportedDevices/AccessoryCatalog.js.map +1 -0
- package/lib/seam/components/SupportedDevices/BrandMark.d.ts +7 -0
- package/lib/seam/components/SupportedDevices/BrandMark.js +23 -0
- package/lib/seam/components/SupportedDevices/BrandMark.js.map +1 -0
- package/lib/seam/components/SupportedDevices/CapabilityFilter.d.ts +7 -0
- package/lib/seam/components/SupportedDevices/CapabilityFilter.js +58 -0
- package/lib/seam/components/SupportedDevices/CapabilityFilter.js.map +1 -0
- package/lib/seam/components/SupportedDevices/DeviceRow.d.ts +6 -0
- package/lib/seam/components/SupportedDevices/DeviceRow.js +20 -0
- package/lib/seam/components/SupportedDevices/DeviceRow.js.map +1 -0
- package/lib/seam/components/SupportedDevices/HardwareGallery.d.ts +6 -0
- package/lib/seam/components/SupportedDevices/HardwareGallery.js +108 -0
- package/lib/seam/components/SupportedDevices/HardwareGallery.js.map +1 -0
- package/lib/seam/components/SupportedDevices/HardwareInformation.d.ts +5 -0
- package/lib/seam/components/SupportedDevices/HardwareInformation.js +50 -0
- package/lib/seam/components/SupportedDevices/HardwareInformation.js.map +1 -0
- package/lib/seam/components/SupportedDevices/ManufacturerSection.d.ts +3 -3
- package/lib/seam/components/SupportedDevices/ManufacturerSection.js +10 -13
- package/lib/seam/components/SupportedDevices/ManufacturerSection.js.map +1 -1
- package/lib/seam/components/SupportedDevices/ProviderRequirements.d.ts +5 -0
- package/lib/seam/components/SupportedDevices/ProviderRequirements.js +20 -0
- package/lib/seam/components/SupportedDevices/ProviderRequirements.js.map +1 -0
- package/lib/seam/components/SupportedDevices/RequirementIcon.js +1 -1
- package/lib/seam/components/SupportedDevices/RequirementIcon.js.map +1 -1
- package/lib/seam/components/SupportedDevices/StatusMarks.d.ts +3 -0
- package/lib/seam/components/SupportedDevices/StatusMarks.js +8 -0
- package/lib/seam/components/SupportedDevices/StatusMarks.js.map +1 -0
- package/lib/seam/components/SupportedDevices/SupportedDevices.d.ts +2 -2
- package/lib/seam/components/SupportedDevices/SupportedDevices.js +53 -30
- package/lib/seam/components/SupportedDevices/SupportedDevices.js.map +1 -1
- package/lib/seam/components/SupportedDevices/presentation.d.ts +34 -0
- package/lib/seam/components/SupportedDevices/presentation.js +142 -0
- package/lib/seam/components/SupportedDevices/presentation.js.map +1 -0
- package/lib/seam/ecosystem/types.d.ts +5 -1
- package/lib/seam/ecosystem/use-ecosystem-device-model-summaries.d.ts +5 -2
- package/lib/seam/ecosystem/use-ecosystem-device-model-summaries.js +4 -1
- package/lib/seam/ecosystem/use-ecosystem-device-model-summaries.js.map +1 -1
- package/lib/seam/ecosystem/use-ecosystem-provider-requirements.d.ts +1 -1
- package/lib/seam/ecosystem/use-ecosystem-provider-requirements.js +1 -1
- package/lib/seam/ecosystem/use-ecosystem-provider-requirements.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/src/lib/seam/components/SupportedDevices/AccessoryCatalog.tsx +138 -0
- package/src/lib/seam/components/SupportedDevices/BrandMark.tsx +61 -0
- package/src/lib/seam/components/SupportedDevices/CapabilityFilter.tsx +142 -0
- package/src/lib/seam/components/SupportedDevices/DeviceRow.tsx +163 -0
- package/src/lib/seam/components/SupportedDevices/HardwareGallery.tsx +284 -0
- package/src/lib/seam/components/SupportedDevices/HardwareInformation.tsx +103 -0
- package/src/lib/seam/components/SupportedDevices/ManufacturerSection.tsx +22 -32
- package/src/lib/seam/components/SupportedDevices/ProviderRequirements.tsx +127 -0
- package/src/lib/seam/components/SupportedDevices/RequirementIcon.tsx +8 -1
- package/src/lib/seam/components/SupportedDevices/StatusMarks.tsx +32 -0
- package/src/lib/seam/components/SupportedDevices/SupportedDevices.tsx +120 -91
- package/src/lib/seam/components/SupportedDevices/presentation.ts +234 -0
- package/src/lib/seam/ecosystem/types.ts +5 -1
- package/src/lib/seam/ecosystem/use-ecosystem-device-model-summaries.ts +8 -1
- package/src/lib/seam/ecosystem/use-ecosystem-provider-requirements.ts +1 -1
- package/src/lib/version.ts +1 -1
- package/src/styles/_supported-devices.scss +1183 -174
- package/lib/seam/components/SupportedDevices/DeviceModelRow.d.ts +0 -8
- package/lib/seam/components/SupportedDevices/DeviceModelRow.js +0 -49
- package/lib/seam/components/SupportedDevices/DeviceModelRow.js.map +0 -1
- package/src/lib/seam/components/SupportedDevices/DeviceModelRow.tsx +0 -197
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import classNames from 'classnames'
|
|
2
2
|
import { useDeferredValue, useMemo, useState } from 'react'
|
|
3
3
|
|
|
4
|
-
import { CheckIcon } from 'lib/icons/Check.js'
|
|
5
|
-
import { TriangleWarningOutlineIcon } from 'lib/icons/TriangleWarningOutline.js'
|
|
6
4
|
import {
|
|
7
5
|
applyEmbedExclusions,
|
|
8
6
|
capabilityLabels,
|
|
@@ -35,13 +33,18 @@ import {
|
|
|
35
33
|
getEcosystemThemeClassName,
|
|
36
34
|
} from 'lib/ui/ecosystem/theme.js'
|
|
37
35
|
|
|
36
|
+
import { AccessoryCatalog } from './AccessoryCatalog.js'
|
|
37
|
+
import { CapabilityFilter } from './CapabilityFilter.js'
|
|
38
|
+
import { CapabilityLegend } from './DeviceRow.js'
|
|
39
|
+
import { presentDevice } from './presentation.js'
|
|
40
|
+
|
|
38
41
|
export interface SupportedDevicesProps {
|
|
39
42
|
/**
|
|
40
43
|
* DeviceDB manufacturer slug, e.g., `schlage`.
|
|
41
44
|
* Defaults to the manufacturer of a manufacturer embed key.
|
|
42
45
|
*/
|
|
43
46
|
manufacturer?: string | undefined
|
|
44
|
-
/** Ecosystem provider slug, e.g., `oracode`. Scopes models and capability
|
|
47
|
+
/** Ecosystem provider slug, e.g., `oracode`. Scopes models and capability summaries. */
|
|
45
48
|
provider?: string | undefined
|
|
46
49
|
/** DeviceDB device type slug, e.g., `smartlock` or `thermostat`. */
|
|
47
50
|
deviceType?: string | undefined
|
|
@@ -57,7 +60,7 @@ export interface SupportedDevicesProps {
|
|
|
57
60
|
|
|
58
61
|
/**
|
|
59
62
|
* Device models that work with Seam, grouped by manufacturer,
|
|
60
|
-
* with
|
|
63
|
+
* with capability checks and expandable hardware and provider requirements.
|
|
61
64
|
*/
|
|
62
65
|
export function SupportedDevices({
|
|
63
66
|
manufacturer,
|
|
@@ -103,23 +106,71 @@ export function SupportedDevices({
|
|
|
103
106
|
enabled: (explicitManufacturer != null || isResolved) && !isResolutionError,
|
|
104
107
|
})
|
|
105
108
|
|
|
106
|
-
const
|
|
107
|
-
() =>
|
|
108
|
-
|
|
109
|
-
applyEmbedExclusions(deviceModels ?? [], embedResolution?.exclusions),
|
|
110
|
-
fixedProvider
|
|
111
|
-
),
|
|
112
|
-
[deviceModels, embedResolution, fixedProvider]
|
|
109
|
+
const allowedDeviceModels = useMemo(
|
|
110
|
+
() => applyEmbedExclusions(deviceModels ?? [], embedResolution?.exclusions),
|
|
111
|
+
[deviceModels, embedResolution]
|
|
113
112
|
)
|
|
114
113
|
|
|
115
114
|
const missingProviderSlugs = useMemo(
|
|
116
|
-
() => getProvidersWithMissingRequirements(
|
|
117
|
-
[
|
|
115
|
+
() => getProvidersWithMissingRequirements(allowedDeviceModels),
|
|
116
|
+
[allowedDeviceModels]
|
|
117
|
+
)
|
|
118
|
+
const providerSlugs = useMemo(
|
|
119
|
+
() =>
|
|
120
|
+
allowedDeviceModels.flatMap((model) =>
|
|
121
|
+
model.providers.map((provider) => provider.slug)
|
|
122
|
+
),
|
|
123
|
+
[allowedDeviceModels]
|
|
124
|
+
)
|
|
125
|
+
const {
|
|
126
|
+
providers,
|
|
127
|
+
isError: isProvidersError,
|
|
128
|
+
error: providersError,
|
|
129
|
+
refetch: refetchProviders,
|
|
130
|
+
} = useEcosystemProviderRequirements(providerSlugs)
|
|
131
|
+
const resolvedDeviceModels = useMemo(
|
|
132
|
+
() => resolveProviderRequirements(allowedDeviceModels, providers ?? []),
|
|
133
|
+
[allowedDeviceModels, providers]
|
|
118
134
|
)
|
|
119
|
-
const { providers } = useEcosystemProviderRequirements(missingProviderSlugs)
|
|
120
135
|
const availableDeviceModels = useMemo(
|
|
121
|
-
() =>
|
|
122
|
-
[
|
|
136
|
+
() => scopeDeviceModelsToProvider(resolvedDeviceModels, fixedProvider),
|
|
137
|
+
[resolvedDeviceModels, fixedProvider]
|
|
138
|
+
)
|
|
139
|
+
const presentedDevices = useMemo(() => {
|
|
140
|
+
const allProvidersById = new Map(
|
|
141
|
+
resolvedDeviceModels.map((model) => [model.device_model_id, model])
|
|
142
|
+
)
|
|
143
|
+
return availableDeviceModels.map((source) =>
|
|
144
|
+
presentDevice(
|
|
145
|
+
source,
|
|
146
|
+
providers ?? [],
|
|
147
|
+
allProvidersById.get(source.device_model_id),
|
|
148
|
+
fixedProvider ?? undefined
|
|
149
|
+
)
|
|
150
|
+
)
|
|
151
|
+
}, [availableDeviceModels, resolvedDeviceModels, providers, fixedProvider])
|
|
152
|
+
const presentedDevicesById = useMemo(
|
|
153
|
+
() =>
|
|
154
|
+
new Map(
|
|
155
|
+
presentedDevices.map((device) => [
|
|
156
|
+
device.source.device_model_id,
|
|
157
|
+
device,
|
|
158
|
+
])
|
|
159
|
+
),
|
|
160
|
+
[presentedDevices]
|
|
161
|
+
)
|
|
162
|
+
const accessorySlugs = useMemo(
|
|
163
|
+
() =>
|
|
164
|
+
presentedDevices.flatMap((device) =>
|
|
165
|
+
device.providers
|
|
166
|
+
.filter((provider) => provider.integrationStatus !== 'unsupported')
|
|
167
|
+
.flatMap((provider) =>
|
|
168
|
+
provider.requirements.flatMap(
|
|
169
|
+
(requirement) => requirement.deviceSlugs ?? []
|
|
170
|
+
)
|
|
171
|
+
)
|
|
172
|
+
),
|
|
173
|
+
[presentedDevices]
|
|
123
174
|
)
|
|
124
175
|
|
|
125
176
|
const manufacturerSlugs = useMemo(
|
|
@@ -150,19 +201,21 @@ export function SupportedDevices({
|
|
|
150
201
|
const [selectedDeviceType, setSelectedDeviceType] = useState<string | null>(
|
|
151
202
|
null
|
|
152
203
|
)
|
|
153
|
-
const [
|
|
154
|
-
null
|
|
155
|
-
)
|
|
204
|
+
const [selectedCapabilities, setSelectedCapabilities] = useState<string[]>([])
|
|
156
205
|
const search = useDeferredValue(searchValue)
|
|
157
206
|
|
|
158
207
|
const filteredDeviceModels = useMemo(
|
|
159
208
|
() =>
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
209
|
+
selectedCapabilities.reduce(
|
|
210
|
+
(models, selected) =>
|
|
211
|
+
filterDeviceModels(models, { capability: selected }),
|
|
212
|
+
filterDeviceModels(availableDeviceModels, {
|
|
213
|
+
manufacturer: scopeManufacturer ?? selectedManufacturer,
|
|
214
|
+
deviceType: fixedDeviceType ?? selectedDeviceType,
|
|
215
|
+
capability: fixedCapability,
|
|
216
|
+
search,
|
|
217
|
+
})
|
|
218
|
+
),
|
|
166
219
|
[
|
|
167
220
|
availableDeviceModels,
|
|
168
221
|
scopeManufacturer,
|
|
@@ -170,7 +223,7 @@ export function SupportedDevices({
|
|
|
170
223
|
fixedDeviceType,
|
|
171
224
|
selectedDeviceType,
|
|
172
225
|
fixedCapability,
|
|
173
|
-
|
|
226
|
+
selectedCapabilities,
|
|
174
227
|
search,
|
|
175
228
|
]
|
|
176
229
|
)
|
|
@@ -204,17 +257,25 @@ export function SupportedDevices({
|
|
|
204
257
|
searchValue.trim().length > 0 ||
|
|
205
258
|
selectedManufacturer != null ||
|
|
206
259
|
selectedDeviceType != null ||
|
|
207
|
-
|
|
260
|
+
selectedCapabilities.length > 0
|
|
208
261
|
|
|
209
262
|
const resetFilters = (): void => {
|
|
210
263
|
setSearchValue('')
|
|
211
264
|
setSelectedManufacturer(null)
|
|
212
265
|
setSelectedDeviceType(null)
|
|
213
|
-
|
|
266
|
+
setSelectedCapabilities([])
|
|
214
267
|
}
|
|
215
268
|
|
|
216
|
-
const
|
|
217
|
-
const
|
|
269
|
+
const areRequirementsMissing = missingProviderSlugs.length > 0
|
|
270
|
+
const isError =
|
|
271
|
+
isResolutionError ||
|
|
272
|
+
isDeviceModelsError ||
|
|
273
|
+
(areRequirementsMissing && isProvidersError)
|
|
274
|
+
const isLoading =
|
|
275
|
+
!isError &&
|
|
276
|
+
(!isResolved ||
|
|
277
|
+
deviceModels == null ||
|
|
278
|
+
(areRequirementsMissing && providers == null))
|
|
218
279
|
|
|
219
280
|
const scopedManufacturerName =
|
|
220
281
|
scopeManufacturer == null
|
|
@@ -233,7 +294,11 @@ export function SupportedDevices({
|
|
|
233
294
|
const content = (() => {
|
|
234
295
|
if (isError) {
|
|
235
296
|
const { message, canRetry } = getEcosystemErrorMessage(
|
|
236
|
-
isResolutionError
|
|
297
|
+
isResolutionError
|
|
298
|
+
? resolutionError
|
|
299
|
+
: isDeviceModelsError
|
|
300
|
+
? deviceModelsError
|
|
301
|
+
: providersError,
|
|
237
302
|
t.error
|
|
238
303
|
)
|
|
239
304
|
return (
|
|
@@ -245,6 +310,7 @@ export function SupportedDevices({
|
|
|
245
310
|
onAction: () => {
|
|
246
311
|
if (isResolutionError) void refetchResolution()
|
|
247
312
|
if (isDeviceModelsError) void refetchDeviceModels()
|
|
313
|
+
if (isProvidersError) void refetchProviders()
|
|
248
314
|
},
|
|
249
315
|
}
|
|
250
316
|
: {})}
|
|
@@ -277,7 +343,10 @@ export function SupportedDevices({
|
|
|
277
343
|
{groups.map((group) => (
|
|
278
344
|
<ManufacturerSection
|
|
279
345
|
key={group.key}
|
|
280
|
-
|
|
346
|
+
devices={group.deviceModels.flatMap((model) => {
|
|
347
|
+
const device = presentedDevicesById.get(model.device_model_id)
|
|
348
|
+
return device == null ? [] : [device]
|
|
349
|
+
})}
|
|
281
350
|
manufacturer={manufacturersBySlug.get(group.key) ?? null}
|
|
282
351
|
collapsible={groups.length > 1}
|
|
283
352
|
/>
|
|
@@ -303,7 +372,15 @@ export function SupportedDevices({
|
|
|
303
372
|
{(!hideTitle || !hideSearch || showFilters) && (
|
|
304
373
|
<div className='seam-ecosystem-header'>
|
|
305
374
|
{!hideTitle && <h2 className='seam-ecosystem-title'>{title}</h2>}
|
|
306
|
-
<div className='seam-ecosystem-controls'>
|
|
375
|
+
<div className='seam-ecosystem-controls seam-supported-device-filters'>
|
|
376
|
+
{!hideSearch && (
|
|
377
|
+
<SearchField
|
|
378
|
+
label={t.search}
|
|
379
|
+
value={searchValue}
|
|
380
|
+
onChange={setSearchValue}
|
|
381
|
+
disabled={controlsDisabled}
|
|
382
|
+
/>
|
|
383
|
+
)}
|
|
307
384
|
{showFilters && showManufacturerFilter && (
|
|
308
385
|
<FilterSelect
|
|
309
386
|
label={t.manufacturer}
|
|
@@ -325,20 +402,10 @@ export function SupportedDevices({
|
|
|
325
402
|
/>
|
|
326
403
|
)}
|
|
327
404
|
{showFilters && showCapabilityFilter && (
|
|
328
|
-
<
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
value={selectedCapability}
|
|
333
|
-
onChange={setSelectedCapability}
|
|
334
|
-
disabled={controlsDisabled}
|
|
335
|
-
/>
|
|
336
|
-
)}
|
|
337
|
-
{!hideSearch && (
|
|
338
|
-
<SearchField
|
|
339
|
-
label={t.search}
|
|
340
|
-
value={searchValue}
|
|
341
|
-
onChange={setSearchValue}
|
|
405
|
+
<CapabilityFilter
|
|
406
|
+
capabilities={capabilityOptions.map((option) => option.value)}
|
|
407
|
+
selected={selectedCapabilities}
|
|
408
|
+
onChange={setSelectedCapabilities}
|
|
342
409
|
disabled={controlsDisabled}
|
|
343
410
|
/>
|
|
344
411
|
)}
|
|
@@ -346,53 +413,20 @@ export function SupportedDevices({
|
|
|
346
413
|
</div>
|
|
347
414
|
)}
|
|
348
415
|
{!isLoading && !isError && availableDeviceModels.length > 0 && (
|
|
349
|
-
<
|
|
350
|
-
className='seam-supported-devices-legend'
|
|
351
|
-
aria-label={t.featureStatus}
|
|
352
|
-
>
|
|
353
|
-
<span>
|
|
354
|
-
<CheckIcon aria-hidden />
|
|
355
|
-
{t.supported}
|
|
356
|
-
</span>
|
|
357
|
-
<span>
|
|
358
|
-
<TriangleWarningOutlineIcon aria-hidden />
|
|
359
|
-
{t.requiresSetup}
|
|
360
|
-
</span>
|
|
361
|
-
</div>
|
|
416
|
+
<CapabilityLegend />
|
|
362
417
|
)}
|
|
363
|
-
{content}
|
|
418
|
+
<AccessoryCatalog slugs={accessorySlugs}>{content}</AccessoryCatalog>
|
|
364
419
|
</div>
|
|
365
420
|
)
|
|
366
421
|
}
|
|
367
422
|
|
|
368
423
|
function LoadingRows(): JSX.Element {
|
|
369
|
-
return
|
|
370
|
-
<div className='seam-supported-devices-sections' aria-busy='true'>
|
|
371
|
-
<section className='seam-supported-devices-section'>
|
|
372
|
-
<div className='seam-supported-devices-section-header'>
|
|
373
|
-
<div className='seam-ecosystem-skeleton seam-supported-devices-logo' />
|
|
374
|
-
<div className='seam-ecosystem-skeleton seam-ecosystem-skeleton-line-short' />
|
|
375
|
-
</div>
|
|
376
|
-
<ul className='seam-supported-devices-rows'>
|
|
377
|
-
{Array.from({ length: 3 }, (_, index) => (
|
|
378
|
-
<li key={index} className='seam-supported-devices-row'>
|
|
379
|
-
<div className='seam-ecosystem-skeleton seam-supported-devices-image' />
|
|
380
|
-
<div className='seam-supported-devices-info'>
|
|
381
|
-
<div className='seam-ecosystem-skeleton seam-ecosystem-skeleton-line' />
|
|
382
|
-
<div className='seam-ecosystem-skeleton seam-ecosystem-skeleton-line-short' />
|
|
383
|
-
</div>
|
|
384
|
-
</li>
|
|
385
|
-
))}
|
|
386
|
-
</ul>
|
|
387
|
-
</section>
|
|
388
|
-
</div>
|
|
389
|
-
)
|
|
424
|
+
return <StateMessage role='status'>Loading supported devices…</StateMessage>
|
|
390
425
|
}
|
|
391
426
|
|
|
392
|
-
const normalizeSlug = (
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
return slug
|
|
427
|
+
const normalizeSlug = (slug: string | undefined): string | null => {
|
|
428
|
+
const value = slug?.trim()
|
|
429
|
+
return value == null || value.length === 0 ? null : value
|
|
396
430
|
}
|
|
397
431
|
|
|
398
432
|
const getScopedManufacturerName = (
|
|
@@ -412,11 +446,6 @@ const t = {
|
|
|
412
446
|
allManufacturers: 'All manufacturers',
|
|
413
447
|
deviceType: 'Device type',
|
|
414
448
|
allDeviceTypes: 'All device types',
|
|
415
|
-
capability: 'Feature',
|
|
416
|
-
allCapabilities: 'All features',
|
|
417
|
-
featureStatus: 'Feature status',
|
|
418
|
-
supported: 'Supported',
|
|
419
|
-
requiresSetup: 'Requires setup · expand details',
|
|
420
449
|
error: 'An error occurred while loading supported devices.',
|
|
421
450
|
retry: 'Retry',
|
|
422
451
|
noDevices: 'No supported devices found.',
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getCapabilityLabel,
|
|
3
|
+
getCapabilityRequirementMessages,
|
|
4
|
+
getDeviceModelName,
|
|
5
|
+
getSupportedCapabilities,
|
|
6
|
+
} from 'lib/seam/components/SupportedDevices/device-models.js'
|
|
7
|
+
import type {
|
|
8
|
+
CapabilitySummary,
|
|
9
|
+
DeviceAsset,
|
|
10
|
+
DeviceModelSummary,
|
|
11
|
+
IntegrationSupportLevel,
|
|
12
|
+
ProviderRef,
|
|
13
|
+
ProviderRequirements,
|
|
14
|
+
} from 'lib/seam/ecosystem/types.js'
|
|
15
|
+
|
|
16
|
+
export interface Capability {
|
|
17
|
+
name: string
|
|
18
|
+
label: string
|
|
19
|
+
messages: string[]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface PresentedDevice {
|
|
23
|
+
source: DeviceModelSummary
|
|
24
|
+
name: string
|
|
25
|
+
capabilities: Capability[]
|
|
26
|
+
requirements: Array<{
|
|
27
|
+
message: string
|
|
28
|
+
capabilities: string[]
|
|
29
|
+
deviceSlugs?: string[]
|
|
30
|
+
}>
|
|
31
|
+
providers: PresentedProvider[]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface PresentedProvider extends ProviderRef {
|
|
35
|
+
logos?: DeviceAsset[]
|
|
36
|
+
primary: boolean
|
|
37
|
+
integrationStatus: 'supported' | 'unsupported' | 'unknown'
|
|
38
|
+
capabilities: Capability[]
|
|
39
|
+
requirements: PresentedDevice['requirements']
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type RequirementKind =
|
|
43
|
+
| 'subscription'
|
|
44
|
+
| 'bridge'
|
|
45
|
+
| 'keypad'
|
|
46
|
+
| 'legal'
|
|
47
|
+
| 'other'
|
|
48
|
+
|
|
49
|
+
/** UI aliases for source prose, which can describe more than one prerequisite. */
|
|
50
|
+
export function getRequirementKinds(message: string): RequirementKind[] {
|
|
51
|
+
const known: Record<string, RequirementKind> = {
|
|
52
|
+
'A compatible bridge is required.': 'bridge',
|
|
53
|
+
'An external keypad is required.': 'keypad',
|
|
54
|
+
'A paying Nuki SmartHosting subscription is required.': 'subscription',
|
|
55
|
+
}
|
|
56
|
+
const kinds: RequirementKind[] = []
|
|
57
|
+
const knownKind = known[message.trim()]
|
|
58
|
+
if (knownKind != null) kinds.push(knownKind)
|
|
59
|
+
if (/\b(?:eula|waiver|end[- ]user licen[cs]e agreement)\b/i.test(message))
|
|
60
|
+
kinds.push('legal')
|
|
61
|
+
if (/\binstall\s+(?:a\s+)?seam\s+bridge\b/i.test(message))
|
|
62
|
+
kinds.push('bridge')
|
|
63
|
+
return kinds.length === 0 ? ['other'] : [...new Set(kinds)]
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function presentDevice(
|
|
67
|
+
source: DeviceModelSummary,
|
|
68
|
+
providers: ProviderRequirements[] = [],
|
|
69
|
+
allProvidersSource: DeviceModelSummary = source,
|
|
70
|
+
primaryProvider?: string
|
|
71
|
+
): PresentedDevice {
|
|
72
|
+
const capabilities = reviewCapabilities(source)
|
|
73
|
+
const primarySlug = primaryProvider
|
|
74
|
+
return {
|
|
75
|
+
source,
|
|
76
|
+
name: getDeviceModelName(source),
|
|
77
|
+
capabilities,
|
|
78
|
+
requirements: reviewRequirements(capabilities, source),
|
|
79
|
+
providers: allProvidersSource.providers
|
|
80
|
+
.map((provider) => {
|
|
81
|
+
const details = providers.find((entry) => entry.slug === provider.slug)
|
|
82
|
+
const providerCapabilities =
|
|
83
|
+
allProvidersSource.capabilities_by_provider.filter(
|
|
84
|
+
(entry) => entry.provider.slug === provider.slug
|
|
85
|
+
)
|
|
86
|
+
const providerSource = {
|
|
87
|
+
...allProvidersSource,
|
|
88
|
+
capabilities_by_provider: providerCapabilities,
|
|
89
|
+
}
|
|
90
|
+
const capabilities = reviewCapabilities(providerSource)
|
|
91
|
+
// Provider metadata distinguishes a missing integration from missing
|
|
92
|
+
// device capabilities. Connectivity alone does not imply Seam support.
|
|
93
|
+
const levels =
|
|
94
|
+
details?.integrations != null && details.integrations.length > 0
|
|
95
|
+
? details.integrations.map(
|
|
96
|
+
(entry) => entry.integration_support_level
|
|
97
|
+
)
|
|
98
|
+
: allProvidersSource.capabilities_stale
|
|
99
|
+
? []
|
|
100
|
+
: providerCapabilities.flatMap((entry) =>
|
|
101
|
+
entry.capabilities
|
|
102
|
+
.filter(
|
|
103
|
+
(capability) => capability.name !== 'device_connectivity'
|
|
104
|
+
)
|
|
105
|
+
.map((capability) => capability.integration_support_level)
|
|
106
|
+
)
|
|
107
|
+
return {
|
|
108
|
+
...provider,
|
|
109
|
+
display_name: details?.display_name ?? provider.display_name,
|
|
110
|
+
logos: details?.logos,
|
|
111
|
+
primary: provider.slug === primarySlug,
|
|
112
|
+
integrationStatus: getIntegrationStatus(levels),
|
|
113
|
+
capabilities,
|
|
114
|
+
requirements: reviewRequirements(capabilities, providerSource),
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
.sort((a, b) => {
|
|
118
|
+
const unsupported =
|
|
119
|
+
Number(a.integrationStatus === 'unsupported') -
|
|
120
|
+
Number(b.integrationStatus === 'unsupported')
|
|
121
|
+
if (unsupported !== 0) return unsupported
|
|
122
|
+
if (a.primary !== b.primary) return a.primary ? -1 : 1
|
|
123
|
+
return (a.display_name ?? a.slug).localeCompare(
|
|
124
|
+
b.display_name ?? b.slug
|
|
125
|
+
)
|
|
126
|
+
}),
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function getIntegrationStatus(
|
|
131
|
+
levels: Array<IntegrationSupportLevel | null>
|
|
132
|
+
): PresentedProvider['integrationStatus'] {
|
|
133
|
+
if (levels.some((level) => level === 'stable' || level === 'beta'))
|
|
134
|
+
return 'supported'
|
|
135
|
+
if (levels.length === 0 || levels.some((level) => level == null))
|
|
136
|
+
return 'unknown'
|
|
137
|
+
return 'unsupported'
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function reviewCapabilities(source: DeviceModelSummary): Capability[] {
|
|
141
|
+
return getSupportedCapabilities(source)
|
|
142
|
+
.filter((capability) => capability.name !== 'device_connectivity')
|
|
143
|
+
.map((capability) => ({
|
|
144
|
+
name: capability.name,
|
|
145
|
+
label: `${getCapabilityLabel(capability.name)}${capability.integrationSupportLevel === 'beta' ? ' (beta)' : ''}`,
|
|
146
|
+
messages: getCapabilityRequirementMessages(capability),
|
|
147
|
+
}))
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function reviewRequirements(
|
|
151
|
+
capabilities: Capability[],
|
|
152
|
+
source: DeviceModelSummary
|
|
153
|
+
): PresentedDevice['requirements'] {
|
|
154
|
+
const requirements = new Map<string, string[]>()
|
|
155
|
+
for (const capability of capabilities)
|
|
156
|
+
for (const message of capability.messages)
|
|
157
|
+
requirements.set(message, [
|
|
158
|
+
...(requirements.get(message) ?? []),
|
|
159
|
+
capability.label,
|
|
160
|
+
])
|
|
161
|
+
return [...requirements].map(([message, labels]) => ({
|
|
162
|
+
message,
|
|
163
|
+
capabilities: labels,
|
|
164
|
+
deviceSlugs: [
|
|
165
|
+
...new Set(
|
|
166
|
+
source.capabilities_by_provider.flatMap(
|
|
167
|
+
({ capabilities: rawCapabilities }) =>
|
|
168
|
+
rawCapabilities
|
|
169
|
+
.filter((capability) =>
|
|
170
|
+
capabilities.some(
|
|
171
|
+
(supported) =>
|
|
172
|
+
supported.name === capability.name &&
|
|
173
|
+
supported.messages.includes(message)
|
|
174
|
+
)
|
|
175
|
+
)
|
|
176
|
+
.flatMap((capability) =>
|
|
177
|
+
getRequirementDeviceSlugs(capability, rawCapabilities, message)
|
|
178
|
+
)
|
|
179
|
+
)
|
|
180
|
+
),
|
|
181
|
+
],
|
|
182
|
+
}))
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Follow capability dependencies within the same model/provider only. */
|
|
186
|
+
function getRequirementDeviceSlugs(
|
|
187
|
+
capability: CapabilitySummary,
|
|
188
|
+
capabilities: CapabilitySummary[],
|
|
189
|
+
message: string,
|
|
190
|
+
visited = new Set<string>()
|
|
191
|
+
): string[] {
|
|
192
|
+
if (visited.has(capability.name)) return []
|
|
193
|
+
visited.add(capability.name)
|
|
194
|
+
const slugs = Object.values(capability.report?.requirements ?? {})
|
|
195
|
+
.filter((requirement) => requirement.message === message)
|
|
196
|
+
.flatMap((requirement) => requirement.device_slugs ?? [])
|
|
197
|
+
for (const name of capability.report?.dependencies ?? []) {
|
|
198
|
+
const dependency = capabilities.find((entry) => entry.name === name)
|
|
199
|
+
if (dependency != null)
|
|
200
|
+
slugs.push(
|
|
201
|
+
...getRequirementDeviceSlugs(dependency, capabilities, message, visited)
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
return slugs
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** Presentation aliases for known requirements; unfamiliar source copy stays explicit. */
|
|
208
|
+
export function getRequirementPills(
|
|
209
|
+
device: Pick<PresentedDevice, 'requirements'>
|
|
210
|
+
): Array<{ label: string; messages: string[] }> {
|
|
211
|
+
const labels: Record<RequirementKind, string> = {
|
|
212
|
+
bridge: 'Accessories Required',
|
|
213
|
+
keypad: 'Accessories Required',
|
|
214
|
+
subscription: 'Subscription Required',
|
|
215
|
+
legal: 'Legal Requirements',
|
|
216
|
+
other: 'Other Requirements',
|
|
217
|
+
}
|
|
218
|
+
const groups = new Map<string, string[]>()
|
|
219
|
+
for (const { message } of device.requirements) {
|
|
220
|
+
for (const kind of getRequirementKinds(message)) {
|
|
221
|
+
const label = labels[kind]
|
|
222
|
+
groups.set(label, [...(groups.get(label) ?? []), message])
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return [
|
|
226
|
+
'Accessories Required',
|
|
227
|
+
'Subscription Required',
|
|
228
|
+
'Legal Requirements',
|
|
229
|
+
'Other Requirements',
|
|
230
|
+
].flatMap((label) => {
|
|
231
|
+
const messages = groups.get(label)
|
|
232
|
+
return messages == null ? [] : [{ label, messages }]
|
|
233
|
+
})
|
|
234
|
+
}
|
|
@@ -182,10 +182,14 @@ export interface ProviderRef {
|
|
|
182
182
|
display_name: string | null
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
/** Fields used from
|
|
185
|
+
/** Fields used from public `providers/list` for branding, support, and report text. */
|
|
186
186
|
export interface ProviderRequirements extends ProviderRef {
|
|
187
187
|
has_requirements: boolean | null
|
|
188
188
|
requirements_md: string | null
|
|
189
|
+
logos?: DeviceAsset[]
|
|
190
|
+
integrations?: Array<{
|
|
191
|
+
integration_support_level: IntegrationSupportLevel | null
|
|
192
|
+
}>
|
|
189
193
|
}
|
|
190
194
|
|
|
191
195
|
export type CapabilityName =
|
|
@@ -13,7 +13,10 @@ import {
|
|
|
13
13
|
} from 'lib/seam/ecosystem/use-ecosystem-query-result.js'
|
|
14
14
|
|
|
15
15
|
export type UseEcosystemDeviceModelSummariesParams =
|
|
16
|
-
UseEcosystemDeviceModelsParams
|
|
16
|
+
UseEcosystemDeviceModelsParams & {
|
|
17
|
+
/** Fetch specific models, including accessories from other manufacturers. */
|
|
18
|
+
slugs?: string[] | undefined
|
|
19
|
+
}
|
|
17
20
|
|
|
18
21
|
export type UseEcosystemDeviceModelSummariesData = DeviceModelSummary[]
|
|
19
22
|
|
|
@@ -30,6 +33,7 @@ export function useEcosystemDeviceModelSummaries({
|
|
|
30
33
|
deviceType = '',
|
|
31
34
|
provider = '',
|
|
32
35
|
capability = '',
|
|
36
|
+
slugs = [],
|
|
33
37
|
enabled = true,
|
|
34
38
|
}: UseEcosystemDeviceModelSummariesParams = {}): UseEcosystemQueryResult<
|
|
35
39
|
'deviceModels',
|
|
@@ -42,6 +46,9 @@ export function useEcosystemDeviceModelSummaries({
|
|
|
42
46
|
device_type: deviceType.trim(),
|
|
43
47
|
provider: provider.trim(),
|
|
44
48
|
capability: capability.trim(),
|
|
49
|
+
slugs: [
|
|
50
|
+
...new Set(slugs.map((slug) => slug.trim()).filter(Boolean)),
|
|
51
|
+
].sort(),
|
|
45
52
|
}
|
|
46
53
|
|
|
47
54
|
const { data, ...rest } = useQuery<
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
type UseEcosystemQueryResult,
|
|
12
12
|
} from 'lib/seam/ecosystem/use-ecosystem-query-result.js'
|
|
13
13
|
|
|
14
|
-
/**
|
|
14
|
+
/** Fetch provider branding, integration status, and legacy free-text requirements. */
|
|
15
15
|
export function useEcosystemProviderRequirements(
|
|
16
16
|
slugs: string[]
|
|
17
17
|
): UseEcosystemQueryResult<'providers', ProviderRequirements[]> {
|
package/src/lib/version.ts
CHANGED