@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.
- package/README.md +66 -3
- package/dist/ecosystem.js +14 -14
- package/dist/ecosystem.js.map +1 -1
- package/dist/elements.js +21042 -19731
- package/dist/elements.js.map +1 -1
- package/ecosystem-react.d.ts +3 -0
- package/ecosystem-react.js +7 -0
- package/ecosystem-react.js.map +1 -0
- package/lib/seam/components/SupportedDevices/SupportedDevices.js +2 -4
- package/lib/seam/components/SupportedDevices/SupportedDevices.js.map +1 -1
- package/lib/seam/components/SupportedDevices/presentation.d.ts +1 -0
- package/lib/seam/components/SupportedDevices/presentation.js +3 -0
- package/lib/seam/components/SupportedDevices/presentation.js.map +1 -1
- package/lib/seam/ecosystem/EcosystemProvider.d.ts +4 -2
- package/lib/seam/ecosystem/EcosystemProvider.js +9 -6
- package/lib/seam/ecosystem/EcosystemProvider.js.map +1 -1
- package/lib/seam/ecosystem/client.d.ts +5 -1
- package/lib/seam/ecosystem/client.js +4 -2
- package/lib/seam/ecosystem/client.js.map +1 -1
- package/lib/seam/ecosystem/embed-resolution.d.ts +7 -0
- package/lib/seam/ecosystem/embed-resolution.js +18 -0
- package/lib/seam/ecosystem/embed-resolution.js.map +1 -0
- package/lib/seam/ecosystem/options.d.ts +6 -0
- package/lib/seam/ecosystem/options.js +13 -0
- package/lib/seam/ecosystem/options.js.map +1 -0
- package/lib/seam/ecosystem/prefetch-supported-devices.d.ts +14 -0
- package/lib/seam/ecosystem/prefetch-supported-devices.js +79 -0
- package/lib/seam/ecosystem/prefetch-supported-devices.js.map +1 -0
- package/lib/seam/ecosystem/queries.d.ts +17 -0
- package/lib/seam/ecosystem/queries.js +144 -0
- package/lib/seam/ecosystem/queries.js.map +1 -0
- package/lib/seam/ecosystem/use-ecosystem-device-model-summaries.d.ts +5 -9
- package/lib/seam/ecosystem/use-ecosystem-device-model-summaries.js +7 -59
- package/lib/seam/ecosystem/use-ecosystem-device-model-summaries.js.map +1 -1
- package/lib/seam/ecosystem/use-ecosystem-manufacturers.d.ts +3 -3
- package/lib/seam/ecosystem/use-ecosystem-manufacturers.js +7 -41
- package/lib/seam/ecosystem/use-ecosystem-manufacturers.js.map +1 -1
- package/lib/seam/ecosystem/use-ecosystem-provider-requirements.d.ts +2 -2
- package/lib/seam/ecosystem/use-ecosystem-provider-requirements.js +6 -40
- package/lib/seam/ecosystem/use-ecosystem-provider-requirements.js.map +1 -1
- package/lib/seam/ecosystem/use-embed-key-resolution.d.ts +4 -14
- package/lib/seam/ecosystem/use-embed-key-resolution.js +8 -43
- package/lib/seam/ecosystem/use-embed-key-resolution.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +23 -10
- package/server.d.ts +2 -0
- package/server.js +3 -0
- package/server.js.map +1 -0
- package/src/ecosystem-react.ts +17 -0
- package/src/lib/ecosystem-element.tsx +4 -1
- package/src/lib/seam/components/SupportedDevices/SupportedDevices.tsx +2 -11
- package/src/lib/seam/components/SupportedDevices/presentation.ts +11 -0
- package/src/lib/seam/ecosystem/EcosystemProvider.tsx +17 -7
- package/src/lib/seam/ecosystem/client.ts +14 -2
- package/src/lib/seam/ecosystem/embed-resolution.ts +20 -0
- package/src/lib/seam/ecosystem/options.ts +21 -0
- package/src/lib/seam/ecosystem/prefetch-supported-devices.ts +150 -0
- package/src/lib/seam/ecosystem/queries.ts +204 -0
- package/src/lib/seam/ecosystem/use-ecosystem-device-model-summaries.ts +10 -79
- package/src/lib/seam/ecosystem/use-ecosystem-manufacturers.ts +9 -60
- package/src/lib/seam/ecosystem/use-ecosystem-provider-requirements.ts +10 -50
- package/src/lib/seam/ecosystem/use-embed-key-resolution.ts +11 -57
- package/src/lib/version.ts +1 -1
- package/src/server.ts +5 -0
|
@@ -1,62 +1,22 @@
|
|
|
1
1
|
import { useQuery } from '@tanstack/react-query'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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 '
|
|
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
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
5
|
-
|
|
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 '
|
|
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
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
}
|
package/src/lib/version.ts
CHANGED