@envive-ai/react-hooks 0.3.62 → 0.3.63
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/dist/application/utils/elementObserver.d.cts +2 -2
- package/dist/application/utils/widgetTextRequestToApiRequest.cjs +1 -0
- package/dist/application/utils/widgetTextRequestToApiRequest.js +1 -1
- package/dist/atoms/app/index.d.cts +7 -7
- package/dist/atoms/chat/chatState.d.cts +19 -19
- package/dist/atoms/chat/chatState.d.ts +1 -1
- package/dist/atoms/chat/form.d.cts +2 -2
- package/dist/atoms/chat/index.d.cts +2 -2
- package/dist/atoms/chat/lastMessage.d.cts +2 -2
- package/dist/atoms/chat/messageQueue.d.cts +6 -6
- package/dist/atoms/chat/performanceMetrics.d.cts +6 -6
- package/dist/atoms/chat/renderedWidgetRefs.d.cts +2 -2
- package/dist/atoms/chat/replies.d.cts +3 -3
- package/dist/atoms/chat/replies.d.ts +1 -1
- package/dist/atoms/chat/suggestions.d.cts +2 -2
- package/dist/atoms/envive/enviveConfig.d.cts +14 -14
- package/dist/atoms/envive/enviveConfig.d.ts +1 -1
- package/dist/atoms/globalSearch/globalSearch.d.cts +5 -5
- package/dist/atoms/globalSearch/globalSearch.d.ts +5 -5
- package/dist/atoms/org/customerService.d.cts +6 -6
- package/dist/atoms/org/customerService.d.ts +6 -6
- package/dist/atoms/org/graphqlConfig.d.cts +4 -4
- package/dist/atoms/org/graphqlConfig.d.ts +4 -4
- package/dist/atoms/org/newOrgConfigAtom.d.cts +2 -2
- package/dist/atoms/org/newOrgConfigAtom.d.ts +2 -2
- package/dist/atoms/org/orgAnalyticsConfig.d.cts +4 -4
- package/dist/atoms/org/orgAnalyticsConfig.d.ts +4 -4
- package/dist/atoms/search/chatSearch.d.cts +17 -17
- package/dist/atoms/search/chatSearch.d.ts +17 -17
- package/dist/atoms/search/searchAPI.d.cts +13 -13
- package/dist/atoms/search/types.d.cts +1 -1
- package/dist/atoms/search/utils.d.cts +1 -1
- package/dist/atoms/search/utils.d.ts +1 -1
- package/dist/atoms/widget/chatPreviewLoading.d.cts +2 -2
- package/dist/atoms/widget/chatPreviewLoading.d.ts +2 -2
- package/dist/contexts/systemSettingsContext/systemSettingsContext.d.cts +2 -2
- package/dist/contexts/types.d.cts +1 -1
- package/dist/contexts/types.d.ts +1 -1
- package/dist/contexts/typesV3.d.cts +1 -1
- package/dist/contexts/typesV3.d.ts +1 -1
- package/dist/hooks/utils.d.cts +1 -1
- package/dist/hooks/utils.d.ts +1 -1
- package/dist/services/enviveConfigService/enviveConfigService.cjs +49 -3
- package/dist/services/enviveConfigService/enviveConfigService.d.cts +16 -2
- package/dist/services/enviveConfigService/enviveConfigService.d.ts +16 -2
- package/dist/services/enviveConfigService/enviveConfigService.js +49 -3
- package/dist/services/enviveConfigService/fetchBootstrapConfig.cjs +102 -0
- package/dist/services/enviveConfigService/fetchBootstrapConfig.js +102 -0
- package/dist/services/enviveConfigService/fetchGraphQLConfig.cjs +2 -1
- package/dist/services/enviveConfigService/fetchGraphQLConfig.js +2 -2
- package/dist/services/hardcopyService/hardcopyService.cjs +20 -4
- package/dist/services/hardcopyService/hardcopyService.d.cts +3 -2
- package/dist/services/hardcopyService/hardcopyService.d.ts +3 -2
- package/dist/services/hardcopyService/hardcopyService.js +20 -5
- package/dist/services/hardcopyService/index.cjs +1 -0
- package/dist/services/hardcopyService/index.d.cts +2 -2
- package/dist/services/hardcopyService/index.d.ts +2 -2
- package/dist/services/hardcopyService/index.js +2 -2
- package/dist/services/urlResolverWarmupService/index.cjs +3 -3
- package/dist/services/urlResolverWarmupService/index.d.cts +8 -2
- package/dist/services/urlResolverWarmupService/index.d.ts +8 -2
- package/dist/services/urlResolverWarmupService/index.js +3 -3
- package/package.json +1 -1
- package/src/services/enviveConfigService/__tests__/enviveConfigService.test.ts +226 -0
- package/src/services/enviveConfigService/__tests__/fetchBootstrapConfig.test.ts +271 -0
- package/src/services/enviveConfigService/enviveConfigService.ts +124 -5
- package/src/services/enviveConfigService/fetchBootstrapConfig.ts +276 -0
- package/src/services/enviveConfigService/fetchGraphQLConfig.ts +7 -4
- package/src/services/hardcopyService/__tests__/hardcopyService.test.ts +60 -1
- package/src/services/hardcopyService/hardcopyService.ts +45 -3
- package/src/services/urlResolverWarmupService/__tests__/urlResolverWarmupService.test.ts +55 -0
- package/src/services/urlResolverWarmupService/index.ts +18 -1
|
@@ -4,6 +4,7 @@ import { contextSourceAtom, envAtom, enviveConfigAtom } from 'src/atoms/envive/e
|
|
|
4
4
|
import { featureFlagServiceAtom } from 'src/atoms/org/graphqlConfig';
|
|
5
5
|
import { FeatureFlagService } from 'src/services/featureFlagService';
|
|
6
6
|
import type { EnviveServiceConfig } from 'src/services/enviveConfigService';
|
|
7
|
+
import { type UrlResolverResponse, urlResolverAtom } from 'src/atoms/app/variant';
|
|
7
8
|
import { warmUrlResolver } from '../index';
|
|
8
9
|
|
|
9
10
|
const { mockResolveUrl } = vi.hoisted(() => ({ mockResolveUrl: vi.fn() }));
|
|
@@ -82,4 +83,58 @@ describe('warmUrlResolver', () => {
|
|
|
82
83
|
expect(getAtomStore().get(featureFlagServiceAtom)).toBeUndefined();
|
|
83
84
|
expect(mockResolveUrl).toHaveBeenCalledTimes(1);
|
|
84
85
|
});
|
|
86
|
+
|
|
87
|
+
it('seeds urlResolverAtom from precomputedUrlResolving when its URL matches, skipping resolveUrl', async () => {
|
|
88
|
+
// The bootstrap-consolidated path: /v1/session/bootstrap already resolved
|
|
89
|
+
// the URL, so the warm-up must NOT fire a second /v1/url_resolving.
|
|
90
|
+
const response = {
|
|
91
|
+
variant_type: 'pdp',
|
|
92
|
+
specific_details: {},
|
|
93
|
+
ready: true,
|
|
94
|
+
} as unknown as UrlResolverResponse;
|
|
95
|
+
const cleansedUrl = window.location.href.toLowerCase().trim();
|
|
96
|
+
|
|
97
|
+
await warmUrlResolver({
|
|
98
|
+
...baseParams,
|
|
99
|
+
env: 'prod',
|
|
100
|
+
contextSource: 'app',
|
|
101
|
+
featureFlagService: new FeatureFlagService([]),
|
|
102
|
+
precomputedUrlResolving: { url: cleansedUrl, response },
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
expect(mockResolveUrl).not.toHaveBeenCalled();
|
|
106
|
+
expect(getAtomStore().get(urlResolverAtom)[cleansedUrl]).toEqual(response);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('falls back to resolveUrl when the precomputed URL no longer matches (SPA nav during bootstrap)', async () => {
|
|
110
|
+
// Bootstrap resolved a DIFFERENT URL (a nav happened since) — its result must
|
|
111
|
+
// NOT be cached under the current URL; resolve the current URL instead.
|
|
112
|
+
const staleResponse = {
|
|
113
|
+
variant_type: 'plp',
|
|
114
|
+
specific_details: {},
|
|
115
|
+
ready: true,
|
|
116
|
+
} as unknown as UrlResolverResponse;
|
|
117
|
+
mockResolveUrl.mockResolvedValue({ variant_type: 'pdp', ready: true });
|
|
118
|
+
|
|
119
|
+
await warmUrlResolver({
|
|
120
|
+
...baseParams,
|
|
121
|
+
env: 'prod',
|
|
122
|
+
contextSource: 'app',
|
|
123
|
+
featureFlagService: new FeatureFlagService([]),
|
|
124
|
+
precomputedUrlResolving: { url: 'https://other.example/stale', response: staleResponse },
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
expect(mockResolveUrl).toHaveBeenCalledTimes(1);
|
|
128
|
+
const cleansedUrl = window.location.href.toLowerCase().trim();
|
|
129
|
+
expect(getAtomStore().get(urlResolverAtom)[cleansedUrl]).toEqual({
|
|
130
|
+
variant_type: 'pdp',
|
|
131
|
+
ready: true,
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('falls back to resolveUrl when precomputedUrlResolving is null (getWidgetConfig path)', async () => {
|
|
136
|
+
await warmUrlResolver({ ...baseParams, precomputedUrlResolving: null });
|
|
137
|
+
|
|
138
|
+
expect(mockResolveUrl).toHaveBeenCalledTimes(1);
|
|
139
|
+
});
|
|
85
140
|
});
|
|
@@ -19,6 +19,15 @@ export interface WarmUrlResolverParams {
|
|
|
19
19
|
env?: string;
|
|
20
20
|
contextSource?: string;
|
|
21
21
|
featureFlagService?: FeatureFlagService;
|
|
22
|
+
// The url_resolving result /v1/session/bootstrap already produced (unified-config
|
|
23
|
+
// gate ON), paired with the URL it was resolved for. When set AND that URL still
|
|
24
|
+
// matches the current one, the warm-up seeds urlResolverAtom with it and skips
|
|
25
|
+
// its own /v1/url_resolving call — the third leg of the 3→1 consolidation. If a
|
|
26
|
+
// SPA navigation changed the URL since bootstrap ran, the URLs no longer match
|
|
27
|
+
// and the warm-up falls back to resolveUrl (so a stale variant is never cached
|
|
28
|
+
// under the new URL). The atom-seeding above still runs either way, so
|
|
29
|
+
// PageProvider (and any later navigation resolveUrl) sees the same context.
|
|
30
|
+
precomputedUrlResolving?: { url: string; response: UrlResolverResponse } | null;
|
|
22
31
|
}
|
|
23
32
|
|
|
24
33
|
/**
|
|
@@ -43,6 +52,7 @@ export const warmUrlResolver = async ({
|
|
|
43
52
|
env,
|
|
44
53
|
contextSource,
|
|
45
54
|
featureFlagService,
|
|
55
|
+
precomputedUrlResolving,
|
|
46
56
|
}: WarmUrlResolverParams): Promise<void> => {
|
|
47
57
|
try {
|
|
48
58
|
const store = getAtomStore();
|
|
@@ -79,7 +89,14 @@ export const warmUrlResolver = async ({
|
|
|
79
89
|
store.set(resolvedBaseConfigVersionAtom, baseVersion);
|
|
80
90
|
}
|
|
81
91
|
|
|
82
|
-
|
|
92
|
+
// Bootstrap already resolved a URL in the same round trip as the config —
|
|
93
|
+
// reuse it ONLY when it's still the current URL, so its variant is never
|
|
94
|
+
// cached under a different key after a SPA navigation. Otherwise resolve the
|
|
95
|
+
// current URL ourselves (same as the no-precompute path).
|
|
96
|
+
const response =
|
|
97
|
+
precomputedUrlResolving && precomputedUrlResolving.url === cleansedUrl
|
|
98
|
+
? precomputedUrlResolving.response
|
|
99
|
+
: ((await CommerceApiClient.resolveUrl(cleansedUrl)) as UrlResolverResponse);
|
|
83
100
|
store.set(urlResolverAtom, { url: cleansedUrl, response });
|
|
84
101
|
} catch (err) {
|
|
85
102
|
// Fail open: PageProvider issues its own resolveUrl call when the cache
|