@seamapi/react 5.3.2 → 5.4.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.
Files changed (65) hide show
  1. package/README.md +66 -3
  2. package/dist/ecosystem.js +14 -14
  3. package/dist/ecosystem.js.map +1 -1
  4. package/dist/elements.js +21042 -19731
  5. package/dist/elements.js.map +1 -1
  6. package/ecosystem-react.d.ts +3 -0
  7. package/ecosystem-react.js +7 -0
  8. package/ecosystem-react.js.map +1 -0
  9. package/lib/seam/components/SupportedDevices/SupportedDevices.js +2 -4
  10. package/lib/seam/components/SupportedDevices/SupportedDevices.js.map +1 -1
  11. package/lib/seam/components/SupportedDevices/presentation.d.ts +1 -0
  12. package/lib/seam/components/SupportedDevices/presentation.js +3 -0
  13. package/lib/seam/components/SupportedDevices/presentation.js.map +1 -1
  14. package/lib/seam/ecosystem/EcosystemProvider.d.ts +4 -2
  15. package/lib/seam/ecosystem/EcosystemProvider.js +9 -6
  16. package/lib/seam/ecosystem/EcosystemProvider.js.map +1 -1
  17. package/lib/seam/ecosystem/client.d.ts +5 -1
  18. package/lib/seam/ecosystem/client.js +4 -2
  19. package/lib/seam/ecosystem/client.js.map +1 -1
  20. package/lib/seam/ecosystem/embed-resolution.d.ts +7 -0
  21. package/lib/seam/ecosystem/embed-resolution.js +18 -0
  22. package/lib/seam/ecosystem/embed-resolution.js.map +1 -0
  23. package/lib/seam/ecosystem/options.d.ts +6 -0
  24. package/lib/seam/ecosystem/options.js +13 -0
  25. package/lib/seam/ecosystem/options.js.map +1 -0
  26. package/lib/seam/ecosystem/prefetch-supported-devices.d.ts +14 -0
  27. package/lib/seam/ecosystem/prefetch-supported-devices.js +79 -0
  28. package/lib/seam/ecosystem/prefetch-supported-devices.js.map +1 -0
  29. package/lib/seam/ecosystem/queries.d.ts +17 -0
  30. package/lib/seam/ecosystem/queries.js +144 -0
  31. package/lib/seam/ecosystem/queries.js.map +1 -0
  32. package/lib/seam/ecosystem/use-ecosystem-device-model-summaries.d.ts +5 -9
  33. package/lib/seam/ecosystem/use-ecosystem-device-model-summaries.js +7 -59
  34. package/lib/seam/ecosystem/use-ecosystem-device-model-summaries.js.map +1 -1
  35. package/lib/seam/ecosystem/use-ecosystem-manufacturers.d.ts +3 -3
  36. package/lib/seam/ecosystem/use-ecosystem-manufacturers.js +7 -41
  37. package/lib/seam/ecosystem/use-ecosystem-manufacturers.js.map +1 -1
  38. package/lib/seam/ecosystem/use-ecosystem-provider-requirements.d.ts +2 -2
  39. package/lib/seam/ecosystem/use-ecosystem-provider-requirements.js +6 -40
  40. package/lib/seam/ecosystem/use-ecosystem-provider-requirements.js.map +1 -1
  41. package/lib/seam/ecosystem/use-embed-key-resolution.d.ts +4 -14
  42. package/lib/seam/ecosystem/use-embed-key-resolution.js +8 -43
  43. package/lib/seam/ecosystem/use-embed-key-resolution.js.map +1 -1
  44. package/lib/version.d.ts +1 -1
  45. package/lib/version.js +1 -1
  46. package/package.json +23 -10
  47. package/server.d.ts +2 -0
  48. package/server.js +3 -0
  49. package/server.js.map +1 -0
  50. package/src/ecosystem-react.ts +17 -0
  51. package/src/lib/ecosystem-element.tsx +4 -1
  52. package/src/lib/seam/components/SupportedDevices/SupportedDevices.tsx +2 -11
  53. package/src/lib/seam/components/SupportedDevices/presentation.ts +11 -0
  54. package/src/lib/seam/ecosystem/EcosystemProvider.tsx +17 -7
  55. package/src/lib/seam/ecosystem/client.ts +14 -2
  56. package/src/lib/seam/ecosystem/embed-resolution.ts +20 -0
  57. package/src/lib/seam/ecosystem/options.ts +21 -0
  58. package/src/lib/seam/ecosystem/prefetch-supported-devices.ts +150 -0
  59. package/src/lib/seam/ecosystem/queries.ts +204 -0
  60. package/src/lib/seam/ecosystem/use-ecosystem-device-model-summaries.ts +10 -79
  61. package/src/lib/seam/ecosystem/use-ecosystem-manufacturers.ts +9 -60
  62. package/src/lib/seam/ecosystem/use-ecosystem-provider-requirements.ts +10 -50
  63. package/src/lib/seam/ecosystem/use-embed-key-resolution.ts +11 -57
  64. package/src/lib/version.ts +1 -1
  65. package/src/server.ts +5 -0
@@ -1,62 +1,22 @@
1
1
  import { useQuery } from '@tanstack/react-query'
2
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'
3
+ import { useEcosystemContext } from './EcosystemProvider.js'
4
+ import { providerRequirementsQuery } from './queries.js'
5
+ import type { ProviderRequirements } from './types.js'
9
6
  import {
10
7
  retryEcosystemQuery,
11
8
  type UseEcosystemQueryResult,
12
- } from 'lib/seam/ecosystem/use-ecosystem-query-result.js'
9
+ } from './use-ecosystem-query-result.js'
13
10
 
14
11
  /** Fetch provider branding, integration status, and legacy free-text requirements. */
15
12
  export function useEcosystemProviderRequirements(
16
13
  slugs: string[]
17
14
  ): 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
- )
15
+ const context = useEcosystemContext()
16
+ const { data, ...rest } = useQuery({
17
+ ...providerRequirementsQuery(context, slugs),
18
+ enabled: slugs.length > 0,
19
+ retry: retryEcosystemQuery,
20
+ })
61
21
  return { ...rest, providers: data }
62
22
  }
@@ -1,15 +1,14 @@
1
1
  import { useQuery } from '@tanstack/react-query'
2
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 { EmbedResolution } from 'lib/seam/ecosystem/types.js'
3
+ import { useEcosystemContext } from './EcosystemProvider.js'
4
+ import { embedResolutionQuery } from './queries.js'
5
+ import type { EmbedResolution } from './types.js'
9
6
  import {
10
7
  retryEcosystemQuery,
11
8
  type UseEcosystemQueryResult,
12
- } from 'lib/seam/ecosystem/use-ecosystem-query-result.js'
9
+ } from './use-ecosystem-query-result.js'
10
+
11
+ export { getEmbedKeyManufacturer } from './embed-resolution.js'
13
12
 
14
13
  export interface UseEmbedKeyResolutionParams {
15
14
  /** Resolve the partner's capability exclusions for this capability. */
@@ -18,63 +17,18 @@ export interface UseEmbedKeyResolutionParams {
18
17
 
19
18
  export type UseEmbedKeyResolutionData = EmbedResolution
20
19
 
21
- /**
22
- * Validates the provider's embed key against the page origin with
23
- * Ecosystem `GET /v1/embed/resolve` and returns the key's public record
24
- * and, for partner keys, what the partner's widgets must not show.
25
- * Disabled when there is no embed key.
26
- */
20
+ /** Validates the embed key and resolves its manufacturer scope and exclusions. */
27
21
  export function useEmbedKeyResolution({
28
22
  capability = '',
29
23
  }: UseEmbedKeyResolutionParams = {}): UseEcosystemQueryResult<
30
24
  'embedResolution',
31
25
  UseEmbedKeyResolutionData
32
26
  > {
33
- const { embedKey, endpoint } = useEcosystemContext()
34
-
35
- const params = { capability: capability.trim() }
36
-
37
- const { data, ...rest } = useQuery<
38
- UseEmbedKeyResolutionData,
39
- EcosystemApiError
40
- >({
41
- enabled: embedKey != null,
42
- queryKey: [
43
- 'ecosystem',
44
- endpoint,
45
- embedKey ?? null,
46
- 'embed',
47
- 'resolve',
48
- params,
49
- ],
50
- queryFn: async ({ signal }) =>
51
- await fetchEcosystem<EmbedResolution>('embed/resolve', {
52
- endpoint,
53
- embedKey,
54
- params,
55
- signal,
56
- }),
27
+ const context = useEcosystemContext()
28
+ const { data, ...rest } = useQuery({
29
+ ...embedResolutionQuery(context, capability),
30
+ enabled: context.embedKey != null,
57
31
  retry: retryEcosystemQuery,
58
32
  })
59
-
60
33
  return { ...rest, embedResolution: data }
61
34
  }
62
-
63
- /**
64
- * The manufacturer an embed key is scoped to, if any.
65
- * Prefers the `manufacturer_context` Ecosystem returns for manufacturer keys (DEVDB-439),
66
- * and falls back to the key's own `manufacturer_slug`.
67
- */
68
- export const getEmbedKeyManufacturer = (
69
- resolution: EmbedResolution | null | undefined
70
- ): string | null => {
71
- if (resolution == null) return null
72
- const contextSlug = resolution.manufacturer_context?.manufacturer_slug
73
- if (contextSlug != null && contextSlug.length > 0) return contextSlug
74
- const { owner_kind: ownerKind, manufacturer_slug: slug } =
75
- resolution.embed_key
76
- if (ownerKind === 'manufacturer' && slug != null && slug.length > 0) {
77
- return slug
78
- }
79
- return null
80
- }
@@ -1,3 +1,3 @@
1
- const seamapiReactVersion = '5.3.2'
1
+ const seamapiReactVersion = '5.4.1'
2
2
 
3
3
  export default seamapiReactVersion
package/src/server.ts ADDED
@@ -0,0 +1,5 @@
1
+ export { EcosystemApiError } from './lib/seam/ecosystem/client.js'
2
+ export {
3
+ prefetchSupportedDevices,
4
+ type PrefetchSupportedDevicesOptions,
5
+ } from './lib/seam/ecosystem/prefetch-supported-devices.js'