@envive-ai/react-hooks 0.3.32 → 0.3.33
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/commerce-api.d.cts +1 -1
- package/dist/application/commerce-api.d.ts +1 -1
- package/dist/atoms/app/index.d.cts +9 -9
- package/dist/atoms/app/index.d.ts +9 -9
- package/dist/atoms/app/variant.d.cts +8 -8
- package/dist/atoms/app/variant.d.ts +8 -8
- package/dist/atoms/chat/chatState.d.cts +20 -20
- package/dist/atoms/chat/chatState.d.ts +20 -20
- package/dist/atoms/chat/form.d.cts +2 -2
- package/dist/atoms/chat/form.d.ts +2 -2
- package/dist/atoms/chat/index.cjs +1 -1
- package/dist/atoms/chat/index.d.cts +3 -3
- package/dist/atoms/chat/index.d.ts +2 -2
- package/dist/atoms/chat/index.js +1 -1
- package/dist/atoms/chat/lastMessage.d.ts +2 -2
- package/dist/atoms/chat/messageQueue.d.cts +6 -6
- package/dist/atoms/chat/messageQueue.d.ts +6 -6
- package/dist/atoms/chat/performanceMetrics.d.ts +6 -6
- package/dist/atoms/chat/renderedWidgetRefs.d.cts +2 -2
- package/dist/atoms/chat/renderedWidgetRefs.d.ts +3 -3
- package/dist/atoms/chat/replies.d.ts +3 -3
- package/dist/atoms/chat/suggestions.d.cts +2 -2
- package/dist/atoms/chat/suggestions.d.ts +2 -2
- package/dist/atoms/envive/enviveConfig.d.cts +13 -13
- package/dist/atoms/envive/enviveConfig.d.ts +13 -13
- package/dist/atoms/globalSearch/globalSearch.d.cts +5 -5
- package/dist/atoms/globalSearch/globalSearch.d.ts +6 -6
- 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 +5 -5
- package/dist/atoms/org/graphqlConfig.d.ts +5 -5
- package/dist/atoms/org/index.cjs +2 -3
- package/dist/atoms/org/index.d.cts +2 -2
- package/dist/atoms/org/index.d.ts +2 -2
- package/dist/atoms/org/index.js +3 -3
- package/dist/atoms/org/newOrgConfigAtom.d.cts +2 -2
- package/dist/atoms/org/newOrgConfigAtom.d.ts +2 -2
- package/dist/atoms/org/orgAnalyticsConfig.cjs +1 -3
- package/dist/atoms/org/orgAnalyticsConfig.d.cts +7 -8
- package/dist/atoms/org/orgAnalyticsConfig.d.ts +7 -8
- package/dist/atoms/org/orgAnalyticsConfig.js +2 -3
- package/dist/atoms/search/chatSearch.cjs +1 -1
- package/dist/atoms/search/chatSearch.d.cts +17 -17
- package/dist/atoms/search/chatSearch.d.ts +17 -17
- package/dist/atoms/search/chatSearch.js +1 -1
- package/dist/atoms/search/searchAPI.cjs +1 -1
- package/dist/atoms/search/searchAPI.d.cts +13 -13
- package/dist/atoms/search/searchAPI.d.ts +13 -13
- package/dist/atoms/search/searchAPI.js +1 -1
- package/dist/atoms/widget/chatPreviewLoading.d.ts +2 -2
- package/dist/contexts/amplitudeContext/amplitudeContext.cjs +1 -5
- package/dist/contexts/amplitudeContext/amplitudeContext.js +1 -5
- package/dist/contexts/enviveConfigContext/enviveConfigContext.cjs +18 -23
- package/dist/contexts/enviveConfigContext/enviveConfigContext.d.cts +10 -12
- package/dist/contexts/enviveConfigContext/enviveConfigContext.d.ts +10 -12
- package/dist/contexts/enviveConfigContext/enviveConfigContext.js +18 -23
- package/dist/contexts/enviveContext/enviveContext.cjs +41 -74
- package/dist/contexts/enviveContext/enviveContext.d.cts +15 -32
- package/dist/contexts/enviveContext/enviveContext.d.ts +15 -32
- package/dist/contexts/enviveContext/enviveContext.js +41 -74
- package/dist/contexts/enviveContext/index.d.cts +2 -2
- package/dist/contexts/enviveContext/index.d.ts +2 -2
- package/dist/contexts/enviveCssContext/enviveCssContext.cjs +31 -16
- package/dist/contexts/enviveCssContext/enviveCssContext.js +31 -16
- package/dist/contexts/graphqlContext/graphqlContext.cjs +3 -212
- package/dist/contexts/graphqlContext/graphqlContext.d.cts +2 -10
- package/dist/contexts/graphqlContext/graphqlContext.d.ts +2 -10
- package/dist/contexts/graphqlContext/graphqlContext.js +3 -212
- package/dist/contexts/graphqlContext/mockV3Config.cjs +31 -16
- package/dist/contexts/graphqlContext/mockV3Config.js +31 -16
- package/dist/contexts/hardcopyContext/hardcopyContext.cjs +9 -238
- package/dist/contexts/hardcopyContext/hardcopyContext.d.cts +5 -17
- package/dist/contexts/hardcopyContext/hardcopyContext.d.ts +5 -17
- package/dist/contexts/hardcopyContext/hardcopyContext.js +9 -238
- package/dist/contexts/hardcopyContext/index.d.cts +3 -2
- package/dist/contexts/hardcopyContext/index.d.ts +3 -2
- package/dist/contexts/newOrgConfigContext/newOrgConfigContext.cjs +10 -32
- package/dist/contexts/newOrgConfigContext/newOrgConfigContext.d.cts +2 -2
- package/dist/contexts/newOrgConfigContext/newOrgConfigContext.d.ts +2 -2
- package/dist/contexts/newOrgConfigContext/newOrgConfigContext.js +12 -34
- package/dist/contexts/pageContext/mapping.d.cts +1 -1
- package/dist/contexts/pageContext/mapping.d.ts +1 -1
- package/dist/contexts/pageContext/types.d.cts +1 -1
- package/dist/contexts/salesAgentContext/chatAPI.cjs +2 -2
- package/dist/contexts/salesAgentContext/chatAPI.js +2 -2
- package/dist/contexts/salesAgentContext/salesAgentService.cjs +1 -1
- package/dist/contexts/salesAgentContext/salesAgentService.js +1 -1
- package/dist/contexts/searchContext/searchContext.cjs +1 -1
- package/dist/contexts/searchContext/searchContext.js +1 -1
- package/dist/contexts/systemSettingsContext/systemSettingsContext.d.cts +2 -2
- package/dist/contexts/types.d.cts +2 -2
- package/dist/contexts/types.d.ts +2 -2
- package/dist/contexts/typesV3.cjs +31 -16
- package/dist/contexts/typesV3.d.cts +62 -31
- package/dist/contexts/typesV3.d.ts +62 -31
- package/dist/contexts/typesV3.js +31 -16
- package/dist/contexts/userIdentityContext/userIdentityContext.cjs +1 -1
- package/dist/contexts/userIdentityContext/userIdentityContext.d.cts +3 -3
- package/dist/contexts/userIdentityContext/userIdentityContext.d.ts +3 -3
- package/dist/contexts/userIdentityContext/userIdentityContext.js +1 -1
- package/dist/hooks/ChatToggle/useChatToggle.cjs +1 -1
- package/dist/hooks/ChatToggle/useChatToggle.js +1 -1
- package/dist/hooks/GrabAndScroll/useGrabAndScroll.d.cts +2 -2
- package/dist/hooks/GraphQLConfig/index.cjs +0 -1
- package/dist/hooks/GraphQLConfig/index.d.cts +2 -2
- package/dist/hooks/GraphQLConfig/index.d.ts +2 -2
- package/dist/hooks/GraphQLConfig/index.js +2 -2
- package/dist/hooks/GraphQLConfig/useGraphQLConfig.cjs +7 -66
- package/dist/hooks/GraphQLConfig/useGraphQLConfig.d.cts +5 -13
- package/dist/hooks/GraphQLConfig/useGraphQLConfig.d.ts +5 -13
- package/dist/hooks/GraphQLConfig/useGraphQLConfig.js +8 -66
- package/dist/hooks/Search/useSearch.cjs +3 -3
- package/dist/hooks/Search/useSearch.js +3 -3
- package/dist/services/amplitudeService/amplitudeService.cjs +4 -3
- package/dist/services/amplitudeService/amplitudeService.d.cts +1 -2
- package/dist/services/amplitudeService/amplitudeService.d.ts +1 -2
- package/dist/services/amplitudeService/amplitudeService.js +4 -3
- package/dist/services/enviveConfigService/enviveConfigService.cjs +25 -5
- package/dist/services/enviveConfigService/enviveConfigService.d.cts +24 -5
- package/dist/services/enviveConfigService/enviveConfigService.d.ts +24 -5
- package/dist/services/enviveConfigService/enviveConfigService.js +25 -6
- package/dist/services/enviveConfigService/fetchGraphQLConfig.cjs +181 -0
- package/dist/services/enviveConfigService/fetchGraphQLConfig.js +180 -0
- package/dist/services/enviveConfigService/index.cjs +2 -1
- package/dist/services/enviveConfigService/index.d.cts +2 -2
- package/dist/services/enviveConfigService/index.d.ts +2 -2
- package/dist/services/enviveConfigService/index.js +2 -2
- package/dist/services/hardcopyService/hardcopyService.cjs +232 -0
- package/dist/services/hardcopyService/hardcopyService.d.cts +39 -0
- package/dist/services/hardcopyService/hardcopyService.d.ts +39 -0
- package/dist/services/hardcopyService/hardcopyService.js +229 -0
- package/dist/services/hardcopyService/index.cjs +5 -0
- package/dist/services/hardcopyService/index.d.cts +2 -0
- package/dist/services/hardcopyService/index.d.ts +2 -0
- package/dist/services/hardcopyService/index.js +3 -0
- package/dist/services/userIdentityService/index.cjs +1 -0
- package/dist/services/userIdentityService/index.d.cts +2 -2
- package/dist/services/userIdentityService/index.d.ts +2 -2
- package/dist/services/userIdentityService/index.js +2 -2
- package/dist/services/userIdentityService/userIdentityService.cjs +13 -1
- package/dist/services/userIdentityService/userIdentityService.d.cts +12 -2
- package/dist/services/userIdentityService/userIdentityService.d.ts +12 -2
- package/dist/services/userIdentityService/userIdentityService.js +13 -2
- package/dist/types/enviveConfig.d.cts +1 -1
- package/dist/types/enviveConfig.d.ts +1 -1
- package/package.json +5 -1
- package/src/atoms/org/orgAnalyticsConfig.ts +0 -5
- package/src/contexts/amplitudeContext/amplitudeContext.tsx +0 -4
- package/src/contexts/enviveConfigContext/enviveConfigContext.tsx +37 -49
- package/src/contexts/enviveContext/enviveContext.tsx +72 -134
- package/src/contexts/enviveCssContext/enviveCssContext.tsx +32 -17
- package/src/contexts/graphqlContext/__tests__/graphqlContext.test.tsx +3 -36
- package/src/contexts/graphqlContext/graphqlContext.tsx +4 -304
- package/src/contexts/graphqlContext/mockV3Config.ts +30 -15
- package/src/contexts/hardcopyContext/hardcopyContext.tsx +12 -270
- package/src/contexts/newOrgConfigContext/__tests__/newOrgConfigContext.test.tsx +54 -478
- package/src/contexts/newOrgConfigContext/newOrgConfigContext.tsx +9 -26
- package/src/contexts/typesV3.ts +61 -30
- package/src/contexts/userIdentityContext/userIdentityContext.tsx +2 -2
- package/src/hooks/GraphQLConfig/useGraphQLConfig.ts +2 -62
- package/src/hooks/Search/__tests__/useSearch.test.tsx +2 -2
- package/src/services/amplitudeService/__tests__/amplitudeService.test.ts +3 -5
- package/src/services/amplitudeService/amplitudeService.ts +5 -3
- package/src/services/enviveConfigService/__tests__/fetchGraphQLConfig.test.ts +425 -0
- package/src/services/enviveConfigService/enviveConfigService.ts +41 -13
- package/src/services/enviveConfigService/fetchGraphQLConfig.ts +225 -0
- package/src/services/hardcopyService/__tests__/hardcopyService.test.ts +367 -0
- package/src/services/hardcopyService/hardcopyService.ts +271 -0
- package/src/services/hardcopyService/index.ts +1 -0
- package/src/services/userIdentityService/userIdentityService.ts +18 -0
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
|
|
3
|
-
import { OrgConfigFeatureGate } from 'src/application/models/api/orgConfigResults';
|
|
4
|
-
import { EnviveConfigService, EnviveServiceConfig } from 'src/services/enviveConfigService';
|
|
5
3
|
import { AmplitudeService } from 'src/services/amplitudeService/amplitudeService';
|
|
4
|
+
import { EnviveServiceConfig, IEnviveConfigService } from 'src/services/enviveConfigService';
|
|
5
|
+
import { IHardcopyService } from 'src/services/hardcopyService';
|
|
6
|
+
import { IUserIdentityService } from 'src/services/userIdentityService';
|
|
6
7
|
import Logger from 'src/application/logging/logger';
|
|
7
|
-
import { UserIdentityService } from 'src/services/userIdentityService';
|
|
8
8
|
import { AmplitudeProvider } from '../amplitudeContext';
|
|
9
9
|
import { EnviveConfigProvider } from '../enviveConfigContext';
|
|
10
10
|
import { EnviveCssProvider } from '../enviveCssContext';
|
|
11
11
|
import { FeatureFlagService, FeatureFlagServiceProvider } from '../featureFlagServiceContext';
|
|
12
|
-
import { GraphQLProvider, GraphQlConfigValues } from '../graphqlContext';
|
|
13
12
|
import { LocalStorageProvider } from '../localStorageContext';
|
|
14
13
|
import { NewOrgConfigProvider } from '../newOrgConfigContext';
|
|
15
14
|
import { UserIdentityProvider } from '../userIdentityContext';
|
|
@@ -17,8 +16,7 @@ import { EnviveAgent } from './types';
|
|
|
17
16
|
import { SearchProvider } from '../searchContext';
|
|
18
17
|
import { SalesAgentProvider } from '../salesAgentContext/salesAgentContext';
|
|
19
18
|
import { SystemSettingsContextProvider } from '../systemSettingsContext';
|
|
20
|
-
import { HardcopyProvider
|
|
21
|
-
import { WidgetTypeV3 } from '../typesV3';
|
|
19
|
+
import { HardcopyProvider } from '../hardcopyContext';
|
|
22
20
|
import { WidgetConfigProvider } from '../widgetConfigContext';
|
|
23
21
|
import { PageProvider } from '../pageContext';
|
|
24
22
|
import { WindowChatToggleBinder } from './WindowChatToggleBinder';
|
|
@@ -36,35 +34,23 @@ export interface ExtensionStatusCallbacks {
|
|
|
36
34
|
onInjectionError?: (error: Error) => Promise<unknown> | void;
|
|
37
35
|
}
|
|
38
36
|
|
|
37
|
+
export interface EnviveServices {
|
|
38
|
+
enviveConfigService: IEnviveConfigService;
|
|
39
|
+
amplitudeService: AmplitudeService;
|
|
40
|
+
userIdentityService: IUserIdentityService;
|
|
41
|
+
hardcopyService: IHardcopyService;
|
|
42
|
+
extensionService?: ExtensionStatusCallbacks;
|
|
43
|
+
}
|
|
44
|
+
|
|
39
45
|
interface EnviveProviderProps extends AgentWrapperProps {
|
|
40
|
-
amplitudeApiKey?: string;
|
|
41
|
-
dataResidency?: string;
|
|
42
|
-
env?: string;
|
|
43
|
-
baseUrl?: string;
|
|
44
|
-
reactAppName?: string;
|
|
45
|
-
cdnUrl?: string;
|
|
46
|
-
contextSource?: string;
|
|
47
|
-
orgLevelApiKey?: string;
|
|
48
|
-
orgShortName?: string;
|
|
49
46
|
identifyingPrefix: string;
|
|
50
|
-
|
|
51
|
-
variantUrlOverride?: string;
|
|
52
|
-
variantInfoOverride?: any;
|
|
47
|
+
services: EnviveServices;
|
|
53
48
|
show?: boolean;
|
|
54
49
|
enviveOn?: boolean;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
featureFlagService?: FeatureFlagService;
|
|
58
|
-
enviveConfigService?: EnviveConfigService;
|
|
59
|
-
amplitudeService?: AmplitudeService;
|
|
60
|
-
mockV3ConfigToDeprecatedConfig?: boolean;
|
|
61
|
-
requestV3Config?: boolean;
|
|
62
|
-
userIdentityService?: UserIdentityService;
|
|
50
|
+
cdnUrl?: string;
|
|
51
|
+
reactAppName?: string;
|
|
63
52
|
previewMode?: boolean;
|
|
64
|
-
overrideConfig?: GraphQlConfigValues;
|
|
65
53
|
mockSalesAgentData?: any;
|
|
66
|
-
hardcopyOverride?: Partial<Record<WidgetTypeV3, HardcopyResponse>>;
|
|
67
|
-
extensionService?: ExtensionStatusCallbacks;
|
|
68
54
|
}
|
|
69
55
|
|
|
70
56
|
const SearchAgentWrapper: React.FC<AgentWrapperProps> = ({ children, enabledAgents }) => {
|
|
@@ -105,27 +91,23 @@ const SalesAgentWrapper: React.FC<SalesAgentWrapperProps> = ({
|
|
|
105
91
|
export const EnviveProvider: React.FC<EnviveProviderProps> = ({
|
|
106
92
|
children,
|
|
107
93
|
previewMode = false,
|
|
108
|
-
overrideConfig,
|
|
109
94
|
enabledAgents,
|
|
110
|
-
|
|
111
|
-
featureFlagService: inputFeatureFlagService,
|
|
112
|
-
amplitudeService: inputAmplitudeService,
|
|
113
|
-
userIdentityService: inputUserIdentityService,
|
|
114
|
-
mockV3ConfigToDeprecatedConfig = false,
|
|
115
|
-
requestV3Config = false,
|
|
95
|
+
services,
|
|
116
96
|
mockSalesAgentData,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
97
|
+
show,
|
|
98
|
+
enviveOn,
|
|
99
|
+
cdnUrl,
|
|
100
|
+
reactAppName,
|
|
101
|
+
identifyingPrefix,
|
|
120
102
|
}) => {
|
|
121
|
-
const
|
|
103
|
+
const { extensionService } = services;
|
|
104
|
+
const [enviveServiceConfig, setEnviveServiceConfig] = useState<EnviveServiceConfig | null>(null);
|
|
122
105
|
const didReportSuccessRef = useRef(false);
|
|
123
106
|
|
|
124
107
|
const invokeExtensionCallback = useCallback((callback?: () => Promise<unknown> | void) => {
|
|
125
108
|
if (!callback) {
|
|
126
109
|
return;
|
|
127
110
|
}
|
|
128
|
-
|
|
129
111
|
Promise.resolve(callback()).catch(error => {
|
|
130
112
|
logger.logDebug('Extension status callback failed', error);
|
|
131
113
|
});
|
|
@@ -136,7 +118,6 @@ export const EnviveProvider: React.FC<EnviveProviderProps> = ({
|
|
|
136
118
|
if (!extensionService?.onInjectionError) {
|
|
137
119
|
return;
|
|
138
120
|
}
|
|
139
|
-
|
|
140
121
|
Promise.resolve(extensionService.onInjectionError(error)).catch(callbackError => {
|
|
141
122
|
logger.logDebug('Extension error callback failed', callbackError);
|
|
142
123
|
});
|
|
@@ -144,44 +125,13 @@ export const EnviveProvider: React.FC<EnviveProviderProps> = ({
|
|
|
144
125
|
[extensionService],
|
|
145
126
|
);
|
|
146
127
|
|
|
147
|
-
const userIdService = useMemo(
|
|
148
|
-
() =>
|
|
149
|
-
inputUserIdentityService ??
|
|
150
|
-
new UserIdentityService({ apiKey: config?.amplitudeApiKey || '' }),
|
|
151
|
-
[config?.amplitudeApiKey, inputUserIdentityService],
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
useEffect(() => {
|
|
155
|
-
const fetchUserId = async () => {
|
|
156
|
-
const id = await userIdService.getUserIdOrDefault();
|
|
157
|
-
setUserId(id);
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
fetchUserId();
|
|
161
|
-
}, [config.amplitudeApiKey, inputUserIdentityService, userIdService]);
|
|
162
|
-
|
|
163
|
-
const namespace = 'spiffy-react-components'; // TODO: Should this be different from the current namespace?
|
|
164
|
-
const source = 'app'; // TODO: Make this dependent upon the "spiffy_on" query param
|
|
165
|
-
const [enviveServiceConfig, setEnviveServiceConfig] = useState<EnviveServiceConfig | null>(null);
|
|
166
|
-
|
|
167
128
|
useEffect(() => {
|
|
168
129
|
invokeExtensionCallback(extensionService?.onInjectionLoading);
|
|
169
130
|
|
|
170
|
-
// Really not happy with this approach, but I'm seeing 429 errors in the tests
|
|
171
|
-
// because of the rate limiting on the API.
|
|
172
|
-
const enviveConfigService =
|
|
173
|
-
inputEnviveConfigService ??
|
|
174
|
-
new EnviveConfigService({
|
|
175
|
-
baseUrl: config?.baseUrl || '',
|
|
176
|
-
apiKey: config?.orgLevelApiKey || '',
|
|
177
|
-
userId,
|
|
178
|
-
namespace: namespace || '',
|
|
179
|
-
source: source || '',
|
|
180
|
-
});
|
|
181
131
|
const fetchEnviveConfig = async () => {
|
|
182
132
|
try {
|
|
183
|
-
const
|
|
184
|
-
setEnviveServiceConfig(
|
|
133
|
+
const config = await services.enviveConfigService.getEnviveConfig();
|
|
134
|
+
setEnviveServiceConfig(config);
|
|
185
135
|
} catch (error) {
|
|
186
136
|
const resolvedError =
|
|
187
137
|
error instanceof Error ? error : new Error('Failed to load envive config');
|
|
@@ -192,11 +142,7 @@ export const EnviveProvider: React.FC<EnviveProviderProps> = ({
|
|
|
192
142
|
|
|
193
143
|
fetchEnviveConfig();
|
|
194
144
|
}, [
|
|
195
|
-
|
|
196
|
-
userId,
|
|
197
|
-
namespace,
|
|
198
|
-
source,
|
|
199
|
-
inputEnviveConfigService,
|
|
145
|
+
services.enviveConfigService,
|
|
200
146
|
extensionService,
|
|
201
147
|
invokeExtensionCallback,
|
|
202
148
|
invokeExtensionErrorCallback,
|
|
@@ -206,71 +152,63 @@ export const EnviveProvider: React.FC<EnviveProviderProps> = ({
|
|
|
206
152
|
if (!enviveServiceConfig || didReportSuccessRef.current) {
|
|
207
153
|
return;
|
|
208
154
|
}
|
|
209
|
-
|
|
210
155
|
didReportSuccessRef.current = true;
|
|
211
156
|
invokeExtensionCallback(extensionService?.onInjectionSuccess);
|
|
212
157
|
}, [enviveServiceConfig, extensionService, invokeExtensionCallback]);
|
|
213
158
|
|
|
214
|
-
const enviveConfig = useMemo(
|
|
215
|
-
() => ({
|
|
216
|
-
...config,
|
|
217
|
-
featureGates: enviveServiceConfig?.gates || [],
|
|
218
|
-
orgShortName: enviveServiceConfig?.org?.org?.short_name || '',
|
|
219
|
-
orgId: enviveServiceConfig?.org?.org?.id || '',
|
|
220
|
-
}),
|
|
221
|
-
[config, enviveServiceConfig],
|
|
222
|
-
);
|
|
223
|
-
logger.logDebug('enviveContext: enviveServiceConfig', enviveServiceConfig, config);
|
|
224
|
-
logger.logDebug('enviveContext: enviveConfig', enviveConfig);
|
|
225
|
-
|
|
226
159
|
const featureFlagService = useMemo(
|
|
227
|
-
() =>
|
|
228
|
-
[
|
|
160
|
+
() => new FeatureFlagService(enviveServiceConfig?.gates ?? []),
|
|
161
|
+
[enviveServiceConfig?.gates],
|
|
229
162
|
);
|
|
230
163
|
|
|
231
|
-
if (enviveServiceConfig === null
|
|
164
|
+
if (enviveServiceConfig === null) {
|
|
232
165
|
return null;
|
|
233
166
|
}
|
|
234
167
|
|
|
235
168
|
return (
|
|
236
|
-
<EnviveConfigProvider
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
169
|
+
<EnviveConfigProvider
|
|
170
|
+
identifyingPrefix={identifyingPrefix}
|
|
171
|
+
baseUrl={services.enviveConfigService.baseUrl}
|
|
172
|
+
orgLevelApiKey={services.enviveConfigService.apiKey}
|
|
173
|
+
orgShortName={enviveServiceConfig.org.org.short_name}
|
|
174
|
+
orgId={enviveServiceConfig.org.org.id}
|
|
175
|
+
show={show}
|
|
176
|
+
enviveOn={enviveOn}
|
|
177
|
+
cdnUrl={cdnUrl}
|
|
178
|
+
reactAppName={reactAppName}
|
|
179
|
+
>
|
|
180
|
+
<NewOrgConfigProvider config={enviveServiceConfig.orgConfig ?? {}}>
|
|
181
|
+
<LocalStorageProvider>
|
|
182
|
+
<FeatureFlagServiceProvider featureFlagService={featureFlagService}>
|
|
183
|
+
<UserIdentityProvider userIdService={services.userIdentityService}>
|
|
184
|
+
<AmplitudeProvider externalAmplitudeService={services.amplitudeService}>
|
|
185
|
+
<PageProvider
|
|
186
|
+
previewMode={previewMode}
|
|
187
|
+
onUrlResolverNotReady={extensionService?.onInjectionError}
|
|
188
|
+
>
|
|
189
|
+
<WidgetConfigProvider>
|
|
190
|
+
<HardcopyProvider hardcopyService={services.hardcopyService}>
|
|
191
|
+
<EnviveCssProvider>
|
|
192
|
+
<SearchAgentWrapper enabledAgents={enabledAgents}>
|
|
193
|
+
<WindowChatToggleBinder />
|
|
194
|
+
<SalesAgentWrapper
|
|
195
|
+
enabledAgents={enabledAgents}
|
|
196
|
+
showDebugBar={enviveOn || false}
|
|
197
|
+
previewMode={previewMode}
|
|
198
|
+
mockSalesAgentData={mockSalesAgentData}
|
|
199
|
+
>
|
|
200
|
+
{children}
|
|
201
|
+
</SalesAgentWrapper>
|
|
202
|
+
</SearchAgentWrapper>
|
|
203
|
+
</EnviveCssProvider>
|
|
204
|
+
</HardcopyProvider>
|
|
205
|
+
</WidgetConfigProvider>
|
|
206
|
+
</PageProvider>
|
|
207
|
+
</AmplitudeProvider>
|
|
208
|
+
</UserIdentityProvider>
|
|
209
|
+
</FeatureFlagServiceProvider>
|
|
210
|
+
</LocalStorageProvider>
|
|
211
|
+
</NewOrgConfigProvider>
|
|
274
212
|
</EnviveConfigProvider>
|
|
275
213
|
);
|
|
276
214
|
};
|
|
@@ -93,23 +93,38 @@ export const EnviveCssProvider: React.FC<EnviveCssProviderProps> = ({ children }
|
|
|
93
93
|
--${FontSizeCSSVar.L1}: ${configV3.uiConfigs?.lookAndFeel?.typography?.fontSize?.l1};
|
|
94
94
|
--${FontSizeCSSVar.L2}: ${configV3.uiConfigs?.lookAndFeel?.typography?.fontSize?.l2};
|
|
95
95
|
|
|
96
|
-
--${FontWeightCSSVar.
|
|
97
|
-
--${FontWeightCSSVar.
|
|
98
|
-
--${FontWeightCSSVar.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
--${LetterSpacingCSSVar.
|
|
102
|
-
|
|
103
|
-
--${
|
|
104
|
-
--${
|
|
105
|
-
--${
|
|
106
|
-
--${
|
|
107
|
-
--${
|
|
108
|
-
--${
|
|
109
|
-
--${
|
|
110
|
-
--${
|
|
111
|
-
--${
|
|
112
|
-
--${
|
|
96
|
+
--${FontWeightCSSVar.Title}: ${configV3.uiConfigs?.lookAndFeel?.typography?.fontWeight?.title};
|
|
97
|
+
--${FontWeightCSSVar.Header}: ${configV3.uiConfigs?.lookAndFeel?.typography?.fontWeight?.header};
|
|
98
|
+
--${FontWeightCSSVar.BodyEmphasis}: ${configV3.uiConfigs?.lookAndFeel?.typography?.fontWeight?.bodyEmphasis};
|
|
99
|
+
--${FontWeightCSSVar.BodyStandard}: ${configV3.uiConfigs?.lookAndFeel?.typography?.fontWeight?.bodyStandard};
|
|
100
|
+
|
|
101
|
+
--${LetterSpacingCSSVar.T1}: ${configV3.uiConfigs?.lookAndFeel?.typography?.letterSpacing?.t1};
|
|
102
|
+
--${LetterSpacingCSSVar.T2}: ${configV3.uiConfigs?.lookAndFeel?.typography?.letterSpacing?.t2};
|
|
103
|
+
--${LetterSpacingCSSVar.T3}: ${configV3.uiConfigs?.lookAndFeel?.typography?.letterSpacing?.t3};
|
|
104
|
+
--${LetterSpacingCSSVar.H1}: ${configV3.uiConfigs?.lookAndFeel?.typography?.letterSpacing?.h1};
|
|
105
|
+
--${LetterSpacingCSSVar.H2}: ${configV3.uiConfigs?.lookAndFeel?.typography?.letterSpacing?.h2};
|
|
106
|
+
--${LetterSpacingCSSVar.H3}: ${configV3.uiConfigs?.lookAndFeel?.typography?.letterSpacing?.h3};
|
|
107
|
+
--${LetterSpacingCSSVar.B1}: ${configV3.uiConfigs?.lookAndFeel?.typography?.letterSpacing?.b1};
|
|
108
|
+
--${LetterSpacingCSSVar.B2}: ${configV3.uiConfigs?.lookAndFeel?.typography?.letterSpacing?.b2};
|
|
109
|
+
--${LetterSpacingCSSVar.B3}: ${configV3.uiConfigs?.lookAndFeel?.typography?.letterSpacing?.b3};
|
|
110
|
+
--${LetterSpacingCSSVar.B4}: ${configV3.uiConfigs?.lookAndFeel?.typography?.letterSpacing?.b4};
|
|
111
|
+
--${LetterSpacingCSSVar.B5}: ${configV3.uiConfigs?.lookAndFeel?.typography?.letterSpacing?.b5};
|
|
112
|
+
--${LetterSpacingCSSVar.L1}: ${configV3.uiConfigs?.lookAndFeel?.typography?.letterSpacing?.l1};
|
|
113
|
+
--${LetterSpacingCSSVar.L2}: ${configV3.uiConfigs?.lookAndFeel?.typography?.letterSpacing?.l2};
|
|
114
|
+
|
|
115
|
+
--${LineHeightCSSVar.T1}: ${configV3.uiConfigs?.lookAndFeel?.typography?.lineHeight?.t1};
|
|
116
|
+
--${LineHeightCSSVar.T2}: ${configV3.uiConfigs?.lookAndFeel?.typography?.lineHeight?.t2};
|
|
117
|
+
--${LineHeightCSSVar.T3}: ${configV3.uiConfigs?.lookAndFeel?.typography?.lineHeight?.t3};
|
|
118
|
+
--${LineHeightCSSVar.H1}: ${configV3.uiConfigs?.lookAndFeel?.typography?.lineHeight?.h1};
|
|
119
|
+
--${LineHeightCSSVar.H2}: ${configV3.uiConfigs?.lookAndFeel?.typography?.lineHeight?.h2};
|
|
120
|
+
--${LineHeightCSSVar.H3}: ${configV3.uiConfigs?.lookAndFeel?.typography?.lineHeight?.h3};
|
|
121
|
+
--${LineHeightCSSVar.B1}: ${configV3.uiConfigs?.lookAndFeel?.typography?.lineHeight?.b1};
|
|
122
|
+
--${LineHeightCSSVar.B2}: ${configV3.uiConfigs?.lookAndFeel?.typography?.lineHeight?.b2};
|
|
123
|
+
--${LineHeightCSSVar.B3}: ${configV3.uiConfigs?.lookAndFeel?.typography?.lineHeight?.b3};
|
|
124
|
+
--${LineHeightCSSVar.B4}: ${configV3.uiConfigs?.lookAndFeel?.typography?.lineHeight?.b4};
|
|
125
|
+
--${LineHeightCSSVar.B5}: ${configV3.uiConfigs?.lookAndFeel?.typography?.lineHeight?.b5};
|
|
126
|
+
--${LineHeightCSSVar.L1}: ${configV3.uiConfigs?.lookAndFeel?.typography?.lineHeight?.l1};
|
|
127
|
+
--${LineHeightCSSVar.L2}: ${configV3.uiConfigs?.lookAndFeel?.typography?.lineHeight?.l2};
|
|
113
128
|
|
|
114
129
|
--${ThemeCSSVar.GlobalCustom}: ${configV3.uiConfigs?.lookAndFeel?.theme};
|
|
115
130
|
|
|
@@ -36,34 +36,6 @@ const MockGraphQLComponent: React.FC = () => {
|
|
|
36
36
|
>
|
|
37
37
|
Execute Query
|
|
38
38
|
</button>
|
|
39
|
-
<button
|
|
40
|
-
data-testid="get-org-id-btn"
|
|
41
|
-
type="button"
|
|
42
|
-
onClick={async () => {
|
|
43
|
-
try {
|
|
44
|
-
const orgId = await client.getOrgId();
|
|
45
|
-
(window as any).lastOrgId = orgId;
|
|
46
|
-
} catch (error) {
|
|
47
|
-
(window as any).lastOrgIdError = error;
|
|
48
|
-
}
|
|
49
|
-
}}
|
|
50
|
-
>
|
|
51
|
-
Get Org ID
|
|
52
|
-
</button>
|
|
53
|
-
<button
|
|
54
|
-
data-testid="get-config-btn"
|
|
55
|
-
type="button"
|
|
56
|
-
onClick={async () => {
|
|
57
|
-
try {
|
|
58
|
-
const config = await client.getColorsAndFrontendConfig();
|
|
59
|
-
(window as any).lastConfig = config;
|
|
60
|
-
} catch (error) {
|
|
61
|
-
(window as any).lastConfigError = error;
|
|
62
|
-
}
|
|
63
|
-
}}
|
|
64
|
-
>
|
|
65
|
-
Get Config
|
|
66
|
-
</button>
|
|
67
39
|
</div>
|
|
68
40
|
);
|
|
69
41
|
};
|
|
@@ -104,13 +76,8 @@ describe('GraphQLProvider', () => {
|
|
|
104
76
|
beforeEach(() => {
|
|
105
77
|
vi.clearAllMocks();
|
|
106
78
|
(global.fetch as any).mockClear();
|
|
107
|
-
// Clear any stored results
|
|
108
79
|
delete (window as any).lastQueryResult;
|
|
109
80
|
delete (window as any).lastQueryError;
|
|
110
|
-
delete (window as any).lastOrgId;
|
|
111
|
-
delete (window as any).lastOrgIdError;
|
|
112
|
-
delete (window as any).lastConfig;
|
|
113
|
-
delete (window as any).lastConfigError;
|
|
114
81
|
});
|
|
115
82
|
|
|
116
83
|
describe('Provider Integration with Jotai Store', () => {
|
|
@@ -403,7 +370,7 @@ describe('GraphQLProvider', () => {
|
|
|
403
370
|
});
|
|
404
371
|
});
|
|
405
372
|
|
|
406
|
-
describe('getOrgId', () => {
|
|
373
|
+
describe.skip('getOrgId', () => {
|
|
407
374
|
it('should fetch and return org ID successfully', async () => {
|
|
408
375
|
const mockOrgId = 'org-123';
|
|
409
376
|
const mockResponse = {
|
|
@@ -528,7 +495,7 @@ describe('GraphQLProvider', () => {
|
|
|
528
495
|
});
|
|
529
496
|
});
|
|
530
497
|
|
|
531
|
-
describe('getColorsAndFrontendConfig', () => {
|
|
498
|
+
describe.skip('getColorsAndFrontendConfig', () => {
|
|
532
499
|
it('should fetch and return colors and frontend config successfully', async () => {
|
|
533
500
|
const mockColorsConfig = {
|
|
534
501
|
accent_primary: '#FF0000',
|
|
@@ -694,7 +661,7 @@ describe('GraphQLProvider', () => {
|
|
|
694
661
|
|
|
695
662
|
React.useEffect(() => {
|
|
696
663
|
if (client.isReady) {
|
|
697
|
-
client.getColorsAndFrontendConfig().then(setConfig);
|
|
664
|
+
(client as any).getColorsAndFrontendConfig().then(setConfig);
|
|
698
665
|
}
|
|
699
666
|
}, [client]);
|
|
700
667
|
|