@seamapi/react 5.2.1 → 5.2.3

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.
Files changed (37) hide show
  1. package/README.md +13 -5
  2. package/dist/ecosystem.js +10 -11
  3. package/dist/ecosystem.js.map +1 -1
  4. package/dist/elements.js +8547 -8365
  5. package/dist/elements.js.map +1 -1
  6. package/dist/index.css +121 -23
  7. package/dist/index.css.map +1 -1
  8. package/dist/index.min.css +1 -1
  9. package/dist/index.min.css.map +1 -1
  10. package/lib/seam/components/SupportedDevices/DeviceModelRow.js +33 -31
  11. package/lib/seam/components/SupportedDevices/DeviceModelRow.js.map +1 -1
  12. package/lib/seam/components/SupportedDevices/ManufacturerSection.js +2 -7
  13. package/lib/seam/components/SupportedDevices/ManufacturerSection.js.map +1 -1
  14. package/lib/seam/components/SupportedDevices/RequirementIcon.d.ts +5 -0
  15. package/lib/seam/components/SupportedDevices/RequirementIcon.js +6 -0
  16. package/lib/seam/components/SupportedDevices/RequirementIcon.js.map +1 -0
  17. package/lib/seam/components/SupportedDevices/SupportedDevices.js +14 -5
  18. package/lib/seam/components/SupportedDevices/SupportedDevices.js.map +1 -1
  19. package/lib/seam/components/SupportedDevices/device-models.d.ts +6 -1
  20. package/lib/seam/components/SupportedDevices/device-models.js +70 -2
  21. package/lib/seam/components/SupportedDevices/device-models.js.map +1 -1
  22. package/lib/seam/ecosystem/types.d.ts +9 -0
  23. package/lib/seam/ecosystem/use-ecosystem-provider-requirements.d.ts +4 -0
  24. package/lib/seam/ecosystem/use-ecosystem-provider-requirements.js +49 -0
  25. package/lib/seam/ecosystem/use-ecosystem-provider-requirements.js.map +1 -0
  26. package/lib/version.d.ts +1 -1
  27. package/lib/version.js +1 -1
  28. package/package.json +1 -1
  29. package/src/lib/seam/components/SupportedDevices/DeviceModelRow.tsx +120 -65
  30. package/src/lib/seam/components/SupportedDevices/ManufacturerSection.tsx +1 -25
  31. package/src/lib/seam/components/SupportedDevices/RequirementIcon.tsx +39 -0
  32. package/src/lib/seam/components/SupportedDevices/SupportedDevices.tsx +36 -3
  33. package/src/lib/seam/components/SupportedDevices/device-models.ts +109 -4
  34. package/src/lib/seam/ecosystem/types.ts +11 -0
  35. package/src/lib/seam/ecosystem/use-ecosystem-provider-requirements.ts +62 -0
  36. package/src/lib/version.ts +1 -1
  37. package/src/styles/_supported-devices.scss +141 -22
@@ -1,11 +1,15 @@
1
- import classNames from 'classnames'
1
+ import { useId, useState } from 'react'
2
2
 
3
+ import { CheckIcon } from 'lib/icons/Check.js'
4
+ import { TriangleWarningOutlineIcon } from 'lib/icons/TriangleWarningOutline.js'
3
5
  import {
4
6
  getCapabilityLabel,
7
+ getCapabilityRequirementMessages,
5
8
  getDeviceModelImageUrl,
6
9
  getDeviceModelName,
7
10
  getSupportedCapabilities,
8
11
  } from 'lib/seam/components/SupportedDevices/device-models.js'
12
+ import { RequirementIcon } from 'lib/seam/components/SupportedDevices/RequirementIcon.js'
9
13
  import type {
10
14
  DeviceModelSummary,
11
15
  Manufacturer,
@@ -20,6 +24,8 @@ export function DeviceModelRow({
20
24
  deviceModel,
21
25
  manufacturer,
22
26
  }: DeviceModelRowProps): JSX.Element {
27
+ const detailsId = useId()
28
+ const [expanded, setExpanded] = useState(false)
23
29
  const name = getDeviceModelName(deviceModel)
24
30
  const imageUrl = getDeviceModelImageUrl(deviceModel, manufacturer)
25
31
  const modelIds = [
@@ -29,28 +35,19 @@ export function DeviceModelRow({
29
35
  .filter((id): id is string => id != null && id.length > 0)
30
36
  ),
31
37
  ]
32
- const providers = deviceModel.providers
33
- .map((p) => p.display_name ?? p.slug)
34
- .join(', ')
38
+ const providers = deviceModel.providers.map((p) => p.display_name ?? p.slug)
35
39
  const capabilities = getSupportedCapabilities(deviceModel).filter(
36
40
  (c) => c.name !== 'device_connectivity'
37
41
  )
38
- const requirements = [
39
- ...new Set(
40
- capabilities.flatMap((capability) => [
41
- ...capability.requirements,
42
- ...(capability.supported === 'conditionally' &&
43
- capability.details != null
44
- ? [capability.details]
45
- : []),
46
- ])
47
- ),
48
- ]
49
-
50
- const meta = [
51
- modelIds.length > 0 ? modelIds.slice(0, 2).join(', ') : null,
52
- providers.length > 0 ? t.via(providers) : null,
53
- ].filter((value): value is string => value != null)
42
+ const requirements = new Map<string, Set<string>>()
43
+ for (const capability of capabilities) {
44
+ const messages = getCapabilityRequirementMessages(capability)
45
+ for (const message of messages) {
46
+ const features = requirements.get(message) ?? new Set<string>()
47
+ features.add(getCapabilityLabel(capability.name))
48
+ requirements.set(message, features)
49
+ }
50
+ }
54
51
 
55
52
  return (
56
53
  <li className='seam-supported-devices-row'>
@@ -74,58 +71,111 @@ export function DeviceModelRow({
74
71
  {name}
75
72
  </a>
76
73
  )}
77
- {meta.length > 0 && (
74
+ {deviceModel.device_type != null && (
78
75
  <span className='seam-supported-devices-meta'>
79
- {meta.join(' · ')}
76
+ {deviceModel.device_type.display_name}
80
77
  </span>
81
78
  )}
82
79
  </div>
83
- <ul className='seam-supported-devices-badges' aria-label={t.badges}>
84
- {deviceModel.device_type != null && (
85
- <li className='seam-ecosystem-badge seam-ecosystem-badge-type'>
86
- {deviceModel.device_type.display_name}
87
- </li>
88
- )}
89
- {capabilities.map((capability) => (
90
- <li
91
- key={capability.name}
92
- className={classNames('seam-ecosystem-badge', {
93
- 'seam-ecosystem-badge-conditional':
94
- capability.supported === 'conditionally',
95
- })}
96
- title={
97
- capability.supported === 'conditionally'
98
- ? [
99
- ...capability.requirements,
100
- capability.details ?? t.conditional,
101
- ].join('\n')
102
- : undefined
103
- }
80
+ {capabilities.length > 0 && (
81
+ <div className='seam-supported-devices-capabilities'>
82
+ <span className='seam-supported-devices-capabilities-label'>
83
+ {t.features}
84
+ </span>
85
+ <ul
86
+ className='seam-supported-devices-features'
87
+ aria-label={t.features}
104
88
  >
105
- {getCapabilityLabel(capability.name)}
106
- {capability.integrationSupportLevel === 'beta' && ' (beta)'}
107
- {capability.supported === 'conditionally' && (
108
- <span className='seam-ecosystem-visually-hidden'>
109
- {` (${t.conditional})`}
110
- </span>
111
- )}
112
- </li>
113
- ))}
114
- </ul>
89
+ {capabilities.map((capability) => (
90
+ <li key={capability.name}>
91
+ {capability.supported === 'conditionally' ? (
92
+ <button
93
+ type='button'
94
+ className='seam-supported-devices-requirement-toggle'
95
+ aria-label={t.toggleRequirements(
96
+ getCapabilityLabel(capability.name),
97
+ name
98
+ )}
99
+ aria-controls={detailsId}
100
+ aria-expanded={expanded}
101
+ onClick={() => {
102
+ setExpanded((open) => !open)
103
+ }}
104
+ >
105
+ <TriangleWarningOutlineIcon
106
+ aria-hidden
107
+ className='seam-supported-devices-conditional-icon'
108
+ />
109
+ </button>
110
+ ) : (
111
+ <CheckIcon aria-hidden />
112
+ )}
113
+ <span>
114
+ {getCapabilityLabel(capability.name)}
115
+ {capability.integrationSupportLevel === 'beta' && ' (beta)'}
116
+ {capability.supported === 'conditionally' && (
117
+ <span className='seam-ecosystem-visually-hidden'>
118
+ {` (${t.requirementsDetails})`}
119
+ </span>
120
+ )}
121
+ </span>
122
+ </li>
123
+ ))}
124
+ </ul>
125
+ </div>
126
+ )}
115
127
  {deviceModel.capabilities_stale ? (
116
128
  <span className='seam-supported-devices-status'>{t.refreshing}</span>
117
129
  ) : capabilities.length === 0 &&
118
130
  deviceModel.device_type?.is_accessory !== true ? (
119
131
  <span className='seam-supported-devices-status'>{t.unconfirmed}</span>
120
132
  ) : null}
121
- {requirements.length > 0 && (
122
- <details className='seam-supported-devices-requirements'>
123
- <summary>{t.requirements}</summary>
124
- <ul>
125
- {requirements.map((requirement) => (
126
- <li key={requirement}>{requirement}</li>
127
- ))}
128
- </ul>
133
+ {(requirements.size > 0 ||
134
+ modelIds.length > 0 ||
135
+ providers.length > 0) && (
136
+ <details
137
+ id={detailsId}
138
+ className='seam-supported-devices-details'
139
+ open={expanded}
140
+ onToggle={(event) => {
141
+ setExpanded(event.currentTarget.open)
142
+ }}
143
+ >
144
+ <summary>{t.modelDetails}</summary>
145
+ {requirements.size > 0 && (
146
+ <ul
147
+ className='seam-supported-devices-requirements'
148
+ aria-label={t.requirements}
149
+ >
150
+ {[...requirements].map(([message, features]) => (
151
+ <li key={message}>
152
+ <RequirementIcon message={message} />
153
+ <div>
154
+ <span>{message}</span>
155
+ <span className='seam-supported-devices-requirement-features'>
156
+ {t.requiredFor([...features].join(', '))}
157
+ </span>
158
+ </div>
159
+ </li>
160
+ ))}
161
+ </ul>
162
+ )}
163
+ {(modelIds.length > 0 || providers.length > 0) && (
164
+ <dl>
165
+ {modelIds.length > 0 && (
166
+ <div>
167
+ <dt>{t.modelNumbers}</dt>
168
+ <dd>{modelIds.join(', ')}</dd>
169
+ </div>
170
+ )}
171
+ {providers.length > 0 && (
172
+ <div>
173
+ <dt>{t.integration}</dt>
174
+ <dd>{providers.join(', ')}</dd>
175
+ </div>
176
+ )}
177
+ </dl>
178
+ )}
129
179
  </details>
130
180
  )}
131
181
  </li>
@@ -133,10 +183,15 @@ export function DeviceModelRow({
133
183
  }
134
184
 
135
185
  const t = {
136
- via: (providers: string) => `via ${providers}`,
137
- badges: 'Device type and capabilities',
138
- conditional: 'conditionally supported',
139
- requirements: 'Requirements and compatibility',
186
+ features: 'Supported capabilities',
187
+ requirements: 'Requirements',
188
+ requirementsDetails: 'expand model and requirements details',
189
+ toggleRequirements: (capability: string, device: string) =>
190
+ `${capability} requirements for ${device}`,
191
+ requiredFor: (features: string) => `For ${features}`,
192
+ modelDetails: 'Model and requirements details',
193
+ modelNumbers: 'Model numbers',
194
+ integration: 'Integration',
140
195
  refreshing: 'Compatibility is being refreshed.',
141
196
  unconfirmed: 'Compatibility not confirmed for this integration.',
142
197
  }
@@ -1,4 +1,3 @@
1
- import classNames from 'classnames'
2
1
  import { useState } from 'react'
3
2
 
4
3
  import {
@@ -40,8 +39,6 @@ export function ManufacturerSection({
40
39
  : t.other
41
40
 
42
41
  const logoUrl = getManufacturerLogoUrl(manufacturer)
43
- const darkLogoUrl = getManufacturerLogoUrl(manufacturer, { mono: true })
44
- const hasDarkLogo = darkLogoUrl != null && darkLogoUrl !== logoUrl
45
42
 
46
43
  return (
47
44
  <section className='seam-supported-devices-section'>
@@ -50,28 +47,7 @@ export function ManufacturerSection({
50
47
  {logoUrl == null ? (
51
48
  <span aria-hidden>{name.slice(0, 1)}</span>
52
49
  ) : (
53
- <>
54
- <img
55
- loading='lazy'
56
- src={logoUrl}
57
- alt=''
58
- width={40}
59
- height={40}
60
- className={classNames({
61
- 'seam-ecosystem-light-only': hasDarkLogo,
62
- })}
63
- />
64
- {hasDarkLogo && (
65
- <img
66
- loading='lazy'
67
- src={darkLogoUrl}
68
- alt=''
69
- width={40}
70
- height={40}
71
- className='seam-ecosystem-dark-only'
72
- />
73
- )}
74
- </>
50
+ <img loading='lazy' src={logoUrl} alt='' width={40} height={40} />
75
51
  )}
76
52
  </div>
77
53
  <h3 className='seam-supported-devices-section-title'>{name}</h3>
@@ -0,0 +1,39 @@
1
+ /** The adjacent text carries the meaning of these contextual illustrations. */
2
+ export function RequirementIcon({ message }: { message: string }): JSX.Element {
3
+ return (
4
+ <svg
5
+ className='seam-supported-devices-requirement-icon'
6
+ aria-hidden
7
+ width='20'
8
+ height='20'
9
+ viewBox='0 0 24 24'
10
+ fill='none'
11
+ stroke='currentColor'
12
+ strokeWidth='1.5'
13
+ strokeLinecap='round'
14
+ strokeLinejoin='round'
15
+ >
16
+ {/subscription|licen[sc]e|paying|paid|fees?/i.test(message) ? (
17
+ <>
18
+ <rect x='2' y='4' width='20' height='16' rx='3' />
19
+ <path d='M2 9h20M6 15h4m4 0h4' />
20
+ </>
21
+ ) : /keypad/i.test(message) ? (
22
+ <>
23
+ <rect x='5' y='2' width='14' height='20' rx='3' />
24
+ <path d='M9 6h6M9 10h.01M12 10h.01M15 10h.01M9 14h.01M12 14h.01M15 14h.01M12 18h.01' />
25
+ </>
26
+ ) : /bridge|hub/i.test(message) ? (
27
+ <>
28
+ <rect x='3' y='12' width='18' height='8' rx='2' />
29
+ <path d='M7 12V8m10 4V8M7 16h.01M11 16h.01M9 5a5 5 0 0 1 6 0M6 2a10 10 0 0 1 12 0' />
30
+ </>
31
+ ) : (
32
+ <>
33
+ <circle cx='12' cy='12' r='9' />
34
+ <path d='M12 11v6m0-10h.01' />
35
+ </>
36
+ )}
37
+ </svg>
38
+ )
39
+ }
@@ -1,6 +1,8 @@
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'
4
6
  import {
5
7
  applyEmbedExclusions,
6
8
  capabilityLabels,
@@ -9,7 +11,9 @@ import {
9
11
  getDeviceTypeOptions,
10
12
  getManufacturerName,
11
13
  getManufacturerOptions,
14
+ getProvidersWithMissingRequirements,
12
15
  groupDeviceModelsByManufacturer,
16
+ resolveProviderRequirements,
13
17
  scopeDeviceModelsToProvider,
14
18
  } from 'lib/seam/components/SupportedDevices/device-models.js'
15
19
  import { FilterSelect } from 'lib/seam/components/SupportedDevices/FilterSelect.js'
@@ -18,6 +22,7 @@ import { useEcosystemContext } from 'lib/seam/ecosystem/EcosystemProvider.js'
18
22
  import type { Manufacturer } from 'lib/seam/ecosystem/types.js'
19
23
  import { useEcosystemDeviceModelSummaries } from 'lib/seam/ecosystem/use-ecosystem-device-model-summaries.js'
20
24
  import { useEcosystemManufacturers } from 'lib/seam/ecosystem/use-ecosystem-manufacturers.js'
25
+ import { useEcosystemProviderRequirements } from 'lib/seam/ecosystem/use-ecosystem-provider-requirements.js'
21
26
  import {
22
27
  getEmbedKeyManufacturer,
23
28
  useEmbedKeyResolution,
@@ -98,7 +103,7 @@ export function SupportedDevices({
98
103
  enabled: (explicitManufacturer != null || isResolved) && !isResolutionError,
99
104
  })
100
105
 
101
- const availableDeviceModels = useMemo(
106
+ const scopedDeviceModels = useMemo(
102
107
  () =>
103
108
  scopeDeviceModelsToProvider(
104
109
  applyEmbedExclusions(deviceModels ?? [], embedResolution?.exclusions),
@@ -107,6 +112,16 @@ export function SupportedDevices({
107
112
  [deviceModels, embedResolution, fixedProvider]
108
113
  )
109
114
 
115
+ const missingProviderSlugs = useMemo(
116
+ () => getProvidersWithMissingRequirements(scopedDeviceModels),
117
+ [scopedDeviceModels]
118
+ )
119
+ const { providers } = useEcosystemProviderRequirements(missingProviderSlugs)
120
+ const availableDeviceModels = useMemo(
121
+ () => resolveProviderRequirements(scopedDeviceModels, providers ?? []),
122
+ [scopedDeviceModels, providers]
123
+ )
124
+
110
125
  const manufacturerSlugs = useMemo(
111
126
  () =>
112
127
  availableDeviceModels
@@ -330,6 +345,21 @@ export function SupportedDevices({
330
345
  </div>
331
346
  </div>
332
347
  )}
348
+ {!isLoading && !isError && availableDeviceModels.length > 0 && (
349
+ <div
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>
362
+ )}
333
363
  {content}
334
364
  </div>
335
365
  )
@@ -382,8 +412,11 @@ const t = {
382
412
  allManufacturers: 'All manufacturers',
383
413
  deviceType: 'Device type',
384
414
  allDeviceTypes: 'All device types',
385
- capability: 'Capability',
386
- allCapabilities: 'All capabilities',
415
+ capability: 'Feature',
416
+ allCapabilities: 'All features',
417
+ featureStatus: 'Feature status',
418
+ supported: 'Supported',
419
+ requiresSetup: 'Requires setup · expand details',
387
420
  error: 'An error occurred while loading supported devices.',
388
421
  retry: 'Retry',
389
422
  noDevices: 'No supported devices found.',
@@ -6,6 +6,7 @@ import type {
6
6
  IntegrationSupportLevel,
7
7
  Manufacturer,
8
8
  ManufacturerRef,
9
+ ProviderRequirements,
9
10
  } from 'lib/seam/ecosystem/types.js'
10
11
 
11
12
  export interface DeviceModelFilters {
@@ -184,6 +185,105 @@ const supportRank = (
184
185
  (level === 'stable' ? 4 : level === 'beta' ? 2 : 0) +
185
186
  (supported === 'yes' ? 1 : 0)
186
187
 
188
+ const genericSupportDetails = new Set([
189
+ 'This feature is supported by this system and can be used through Seam, but please check additional requirements are met.',
190
+ 'Device requires a compatible server bridge',
191
+ ])
192
+
193
+ const isGenericSupportDetail = (details: string): boolean =>
194
+ genericSupportDetails.has(details.trim())
195
+
196
+ const isMissingMessage = (message: unknown): boolean =>
197
+ typeof message !== 'string' ||
198
+ message.trim().length === 0 ||
199
+ message.trim() === 'Requirement message not found' ||
200
+ message.trim() === 'Report details not found'
201
+
202
+ export const getProvidersWithMissingRequirements = (
203
+ models: DeviceModelSummary[]
204
+ ): string[] =>
205
+ [
206
+ ...new Set(
207
+ models.flatMap((model) =>
208
+ model.capabilities_by_provider
209
+ .filter((entry) =>
210
+ entry.capabilities.some(
211
+ (capability) =>
212
+ capability.report?.requirements?.['provider'] != null &&
213
+ isMissingMessage(
214
+ capability.report.requirements['provider'].message
215
+ )
216
+ )
217
+ )
218
+ .map((entry) => entry.provider.slug)
219
+ )
220
+ ),
221
+ ].sort()
222
+
223
+ /** Legacy translation treats provider prose as a dictionary key; the public provider retains the prose. */
224
+ export const resolveProviderRequirements = (
225
+ models: DeviceModelSummary[],
226
+ providers: ProviderRequirements[]
227
+ ): DeviceModelSummary[] => {
228
+ const bySlug = new Map(
229
+ providers.map((provider) => [provider.slug, provider.requirements_md])
230
+ )
231
+ return models.map((model) => ({
232
+ ...model,
233
+ capabilities_by_provider: model.capabilities_by_provider.map((entry) => ({
234
+ ...entry,
235
+ capabilities: entry.capabilities.map((capability) => {
236
+ const report = capability.report
237
+ const requirement = report?.requirements?.['provider']
238
+ if (
239
+ report == null ||
240
+ requirement == null ||
241
+ !isMissingMessage(requirement.message)
242
+ )
243
+ return capability
244
+ const message = bySlug.get(entry.provider.slug)
245
+ return {
246
+ ...capability,
247
+ report: {
248
+ ...report,
249
+ requirements: {
250
+ ...report.requirements,
251
+ provider: {
252
+ ...requirement,
253
+ message:
254
+ typeof message === 'string' && !isMissingMessage(message)
255
+ ? message.trim()
256
+ : 'Additional integration requirements apply. Check with your integration provider.',
257
+ },
258
+ },
259
+ },
260
+ }
261
+ }),
262
+ })),
263
+ }))
264
+ }
265
+
266
+ /** Keep specific constraints; replace boilerplate with an actionable setup note. */
267
+ export const getCapabilityRequirementMessages = (
268
+ capability: SupportedCapability
269
+ ): string[] => {
270
+ const messages = new Set(
271
+ capability.requirements.map((message) =>
272
+ isMissingMessage(message) ? 'Additional setup is required.' : message
273
+ )
274
+ )
275
+ if (capability.supported === 'conditionally') {
276
+ if (
277
+ capability.details != null &&
278
+ !isMissingMessage(capability.details) &&
279
+ !isGenericSupportDetail(capability.details)
280
+ )
281
+ messages.add(capability.details)
282
+ if (messages.size === 0) messages.add('Additional setup is required.')
283
+ }
284
+ return [...messages]
285
+ }
286
+
187
287
  const getCapabilityRequirements = (
188
288
  capability: CapabilitySummary,
189
289
  capabilities: CapabilitySummary[],
@@ -195,14 +295,19 @@ const getCapabilityRequirements = (
195
295
  (requirement) => requirement.message
196
296
  )
197
297
  for (const name of capability.report?.dependencies ?? []) {
298
+ if (visited.has(name)) continue
198
299
  const dependency = capabilities.find((c) => c.name === name)
199
300
  if (dependency == null) continue
200
- if (dependency.supported !== 'yes' && dependency.report?.details != null) {
301
+ const nested = getCapabilityRequirements(dependency, capabilities, visited)
302
+ if (
303
+ dependency.supported !== 'yes' &&
304
+ dependency.report?.details != null &&
305
+ (nested.length === 0 ||
306
+ !isGenericSupportDetail(dependency.report.details))
307
+ ) {
201
308
  requirements.push(dependency.report.details)
202
309
  }
203
- requirements.push(
204
- ...getCapabilityRequirements(dependency, capabilities, visited)
205
- )
310
+ requirements.push(...nested)
206
311
  }
207
312
  return [...new Set(requirements)]
208
313
  }
@@ -182,6 +182,12 @@ export interface ProviderRef {
182
182
  display_name: string | null
183
183
  }
184
184
 
185
+ /** Fields used from the public `providers/list` response to recover legacy report text. */
186
+ export interface ProviderRequirements extends ProviderRef {
187
+ has_requirements: boolean | null
188
+ requirements_md: string | null
189
+ }
190
+
185
191
  export type CapabilityName =
186
192
  | 'device_connectivity'
187
193
  | 'can_program_online_access_codes'
@@ -391,6 +397,11 @@ export interface ManufacturersListResponse {
391
397
  pagination: Pagination
392
398
  }
393
399
 
400
+ export interface ProvidersListResponse {
401
+ providers: ProviderRequirements[]
402
+ pagination: Pagination
403
+ }
404
+
394
405
  export interface EcosystemErrorResponse {
395
406
  ok: false
396
407
  error: {
@@ -0,0 +1,62 @@
1
+ import { useQuery } from '@tanstack/react-query'
2
+
3
+ import { EcosystemApiError, fetchEcosystem } from 'lib/seam/ecosystem/client.js'
4
+ import { useEcosystemContext } from 'lib/seam/ecosystem/EcosystemProvider.js'
5
+ import type {
6
+ ProviderRequirements,
7
+ ProvidersListResponse,
8
+ } from 'lib/seam/ecosystem/types.js'
9
+ import {
10
+ retryEcosystemQuery,
11
+ type UseEcosystemQueryResult,
12
+ } from 'lib/seam/ecosystem/use-ecosystem-query-result.js'
13
+
14
+ /** Only fetch providers whose legacy capability reports lost their free-text requirement. */
15
+ export function useEcosystemProviderRequirements(
16
+ slugs: string[]
17
+ ): UseEcosystemQueryResult<'providers', ProviderRequirements[]> {
18
+ const { endpoint, embedKey } = useEcosystemContext()
19
+ const sortedSlugs = [...new Set(slugs)].sort()
20
+ const { data, ...rest } = useQuery<ProviderRequirements[], EcosystemApiError>(
21
+ {
22
+ enabled: sortedSlugs.length > 0,
23
+ queryKey: [
24
+ 'ecosystem',
25
+ endpoint,
26
+ embedKey ?? null,
27
+ 'providers',
28
+ 'list',
29
+ { slugs: sortedSlugs },
30
+ ],
31
+ queryFn: async ({ signal }) => {
32
+ const providers: ProviderRequirements[] = []
33
+ const seen = new Set<string>()
34
+ let cursor: string | undefined
35
+ for (let page = 0; page < 10; page++) {
36
+ const res = await fetchEcosystem<ProvidersListResponse>(
37
+ 'providers/list',
38
+ {
39
+ endpoint,
40
+ embedKey,
41
+ signal,
42
+ params: { slugs: sortedSlugs, limit: 500, page_cursor: cursor },
43
+ }
44
+ )
45
+ providers.push(...res.providers)
46
+ if (!res.pagination.has_next_page) return providers
47
+ const next = res.pagination.next_page_cursor
48
+ if (next == null || seen.has(next)) break
49
+ seen.add(next)
50
+ cursor = next
51
+ }
52
+ throw new EcosystemApiError({
53
+ status: 502,
54
+ type: 'pagination_incomplete',
55
+ message: 'The provider catalog returned incomplete requirements.',
56
+ })
57
+ },
58
+ retry: retryEcosystemQuery,
59
+ }
60
+ )
61
+ return { ...rest, providers: data }
62
+ }
@@ -1,3 +1,3 @@
1
- const seamapiReactVersion = '5.2.1'
1
+ const seamapiReactVersion = '5.2.3'
2
2
 
3
3
  export default seamapiReactVersion