@seamapi/react 5.1.0 → 5.1.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.
@@ -2,7 +2,7 @@
2
2
  * Response types for the public Seam Ecosystem API (PartnerDB and DeviceDB).
3
3
  *
4
4
  * Hand-copied from the zod schemas in `seamapi/ecosystem` `public-types/`
5
- * (origin/main 733edf3, 2026-10-16) to avoid a zod runtime dependency.
5
+ * (origin/main 055335c, 2026-10-17) to avoid a zod runtime dependency.
6
6
  * Fields stored verbatim from the source as JSON are typed as `unknown`.
7
7
  * Keep in sync with Ecosystem until it publishes its types as a package.
8
8
  */
@@ -112,18 +112,16 @@ export interface EmbedExclusions {
112
112
  capability_exclusions: EmbedCapabilityExclusion[]
113
113
  }
114
114
 
115
- /**
116
- * Manufacturer context for manufacturer-owned keys.
117
- * Not returned by Ecosystem yet (DEVDB-439); read when present.
118
- */
115
+ /** The manufacturer a manufacturer-owned key scopes DeviceDB widgets to (DEVDB-439). */
119
116
  export interface EmbedManufacturerContext {
120
117
  manufacturer_slug: string
121
118
  }
122
119
 
123
120
  export interface EmbedResolution {
124
121
  embed_key: EmbedKey
125
- exclusions: EmbedExclusions
122
+ /** Set for manufacturer-owned keys; null for partner and Seam keys. */
126
123
  manufacturer_context?: EmbedManufacturerContext | null
124
+ exclusions: EmbedExclusions
127
125
  }
128
126
 
129
127
  // Devices (DeviceDB)
@@ -273,6 +271,71 @@ export interface DeviceModel {
273
271
  updated_at: string
274
272
  }
275
273
 
274
+ // Device model summaries (`device_models/summaries/list`, DEVDB-437):
275
+ // the same models in a slim shape, without storage internals or commerce data.
276
+
277
+ export interface DeviceImageFormat {
278
+ url: string
279
+ width: number | null
280
+ height: number | null
281
+ }
282
+
283
+ export interface DeviceImage {
284
+ url: string
285
+ mime: string | null
286
+ width: number | null
287
+ height: number | null
288
+ formats: Partial<Record<MediaFormatName, DeviceImageFormat>>
289
+ }
290
+
291
+ export interface CapabilitySummary {
292
+ name: CapabilityName
293
+ supported: CapabilitySupported
294
+ integration_support_level: IntegrationSupportLevel | null
295
+ report: CapabilityReport | null
296
+ }
297
+
298
+ export interface DeviceModelSummaryVariant {
299
+ device_model_variant_id: string
300
+ color_name: string | null
301
+ style_name: string | null
302
+ primary_color_hex: string | null
303
+ manufacturer_model_id: string | null
304
+ images: DeviceImage[]
305
+ /** Only with `include=commerce`. */
306
+ asin?: string | null
307
+ /** Only with `include=commerce`. */
308
+ gtins?: unknown
309
+ /** Only with `include=commerce`. */
310
+ marketplace_listings?: unknown
311
+ }
312
+
313
+ export interface DeviceModelSummary {
314
+ device_model_id: string
315
+ slug: string
316
+ display_name: string | null
317
+ description_md: string | null
318
+ product_url: string | null
319
+ no_longer_sold: boolean | null
320
+ is_forbidden_to_3dparty: boolean | null
321
+ manufacturer: ManufacturerRef | null
322
+ device_type: DeviceTypeRef | null
323
+ device_type_properties: unknown
324
+ featured_image: DeviceImage | null
325
+ variants: DeviceModelSummaryVariant[]
326
+ providers: ProviderRef[]
327
+ capabilities_by_provider: Array<{
328
+ provider: ProviderRef
329
+ capabilities: CapabilitySummary[]
330
+ }>
331
+ capabilities_stale: boolean
332
+ /** Only with `include=commerce`. */
333
+ shop_listings?: unknown
334
+ /** Only with `include=commerce`. */
335
+ last_commerce_search_at?: string | null
336
+ updated_at: string
337
+ }
338
+
276
339
  export interface ManufacturerDefaultDeviceImage {
277
340
  device_type: DeviceTypeRef
278
341
  asset: DeviceAsset
@@ -318,6 +381,11 @@ export interface DeviceModelsListResponse {
318
381
  pagination: Pagination
319
382
  }
320
383
 
384
+ export interface DeviceModelSummariesListResponse {
385
+ device_models: DeviceModelSummary[]
386
+ pagination: Pagination
387
+ }
388
+
321
389
  export interface ManufacturersListResponse {
322
390
  manufacturers: Manufacturer[]
323
391
  pagination: Pagination
@@ -0,0 +1,89 @@
1
+ import { useQuery } from '@tanstack/react-query'
2
+
3
+ import {
4
+ type EcosystemApiError,
5
+ fetchEcosystem,
6
+ } from 'lib/seam/ecosystem/client.js'
7
+ import { useEcosystemContext } from 'lib/seam/ecosystem/EcosystemProvider.js'
8
+ import type {
9
+ DeviceModelSummariesListResponse,
10
+ DeviceModelSummary,
11
+ } from 'lib/seam/ecosystem/types.js'
12
+ import type { UseEcosystemDeviceModelsParams } from 'lib/seam/ecosystem/use-ecosystem-device-models.js'
13
+ import {
14
+ retryEcosystemQuery,
15
+ type UseEcosystemQueryResult,
16
+ } from 'lib/seam/ecosystem/use-ecosystem-query-result.js'
17
+
18
+ export type UseEcosystemDeviceModelSummariesParams =
19
+ UseEcosystemDeviceModelsParams
20
+
21
+ export type UseEcosystemDeviceModelSummariesData = DeviceModelSummary[]
22
+
23
+ const pageSize = 500
24
+ const maxPages = 20
25
+
26
+ /**
27
+ * Published device models in the slim summary shape from Ecosystem
28
+ * `GET /v1/device_models/summaries/list` (no commerce data),
29
+ * following pagination to return every matching model.
30
+ */
31
+ export function useEcosystemDeviceModelSummaries({
32
+ manufacturer = '',
33
+ deviceType = '',
34
+ provider = '',
35
+ capability = '',
36
+ enabled = true,
37
+ }: UseEcosystemDeviceModelSummariesParams = {}): UseEcosystemQueryResult<
38
+ 'deviceModels',
39
+ UseEcosystemDeviceModelSummariesData
40
+ > {
41
+ const { embedKey, endpoint } = useEcosystemContext()
42
+
43
+ const params = {
44
+ manufacturer: manufacturer.trim(),
45
+ device_type: deviceType.trim(),
46
+ provider: provider.trim(),
47
+ capability: capability.trim(),
48
+ }
49
+
50
+ const { data, ...rest } = useQuery<
51
+ UseEcosystemDeviceModelSummariesData,
52
+ EcosystemApiError
53
+ >({
54
+ enabled,
55
+ queryKey: [
56
+ 'ecosystem',
57
+ endpoint,
58
+ embedKey ?? null,
59
+ 'device_models',
60
+ 'summaries',
61
+ 'list',
62
+ params,
63
+ ],
64
+ queryFn: async ({ signal }) => {
65
+ const deviceModels: DeviceModelSummary[] = []
66
+ let pageCursor: string | undefined
67
+ for (let page = 0; page < maxPages; page++) {
68
+ const res = await fetchEcosystem<DeviceModelSummariesListResponse>(
69
+ 'device_models/summaries/list',
70
+ {
71
+ endpoint,
72
+ embedKey,
73
+ params: { ...params, limit: pageSize, page_cursor: pageCursor },
74
+ signal,
75
+ }
76
+ )
77
+ deviceModels.push(...res.device_models)
78
+ const { has_next_page: hasNextPage, next_page_cursor: nextPageCursor } =
79
+ res.pagination
80
+ if (!hasNextPage || nextPageCursor == null) break
81
+ pageCursor = nextPageCursor
82
+ }
83
+ return deviceModels
84
+ },
85
+ retry: retryEcosystemQuery,
86
+ })
87
+
88
+ return { ...rest, deviceModels: data }
89
+ }
@@ -1,3 +1,3 @@
1
- const seamapiReactVersion = '5.1.0'
1
+ const seamapiReactVersion = '5.1.1'
2
2
 
3
3
  export default seamapiReactVersion