@selfcommunity/react-core 0.4.50-alpha.0 → 0.4.50-event.30
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/lib/cjs/components/provider/SCUserProvider/index.js +4 -4
- package/lib/cjs/constants/Cache.d.ts +3 -0
- package/lib/cjs/constants/Cache.js +6 -2
- package/lib/cjs/constants/Integrations.d.ts +13 -0
- package/lib/cjs/constants/Integrations.js +17 -0
- package/lib/cjs/constants/Notifications.d.ts +2 -1
- package/lib/cjs/constants/Notifications.js +4 -3
- package/lib/cjs/constants/Preferences.d.ts +3 -0
- package/lib/cjs/constants/Preferences.js +8 -2
- package/lib/cjs/constants/Routes.d.ts +4 -0
- package/lib/cjs/constants/Routes.js +9 -1
- package/lib/cjs/hooks/useSCFetchEvent.d.ts +20 -0
- package/lib/cjs/hooks/useSCFetchEvent.js +74 -0
- package/lib/cjs/index.d.ts +2 -1
- package/lib/cjs/index.js +3 -1
- package/lib/cjs/types/context.d.ts +37 -0
- package/lib/cjs/utils/errors.d.ts +6 -0
- package/lib/cjs/utils/errors.js +12 -0
- package/lib/cjs/utils/hooks/useIsomorphicLayoutEffect.js +2 -1
- package/lib/cjs/utils/notification.js +1 -1
- package/lib/cjs/utils/validator.d.ts +103 -28
- package/lib/cjs/utils/validator.js +178 -31
- package/lib/esm/components/provider/SCUserProvider/index.js +5 -5
- package/lib/esm/constants/Cache.d.ts +3 -0
- package/lib/esm/constants/Cache.js +3 -0
- package/lib/esm/constants/Integrations.d.ts +13 -0
- package/lib/esm/constants/Integrations.js +14 -0
- package/lib/esm/constants/Notifications.d.ts +2 -1
- package/lib/esm/constants/Notifications.js +3 -2
- package/lib/esm/constants/Preferences.d.ts +3 -0
- package/lib/esm/constants/Preferences.js +6 -0
- package/lib/esm/constants/Routes.d.ts +4 -0
- package/lib/esm/constants/Routes.js +8 -0
- package/lib/esm/hooks/useSCFetchEvent.d.ts +20 -0
- package/lib/esm/hooks/useSCFetchEvent.js +71 -0
- package/lib/esm/index.d.ts +2 -1
- package/lib/esm/index.js +2 -1
- package/lib/esm/types/context.d.ts +37 -0
- package/lib/esm/utils/errors.d.ts +6 -0
- package/lib/esm/utils/errors.js +12 -0
- package/lib/esm/utils/hooks/useIsomorphicLayoutEffect.js +2 -1
- package/lib/esm/utils/notification.js +2 -2
- package/lib/esm/utils/validator.d.ts +103 -28
- package/lib/esm/utils/validator.js +171 -30
- package/lib/umd/react-core.js +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { SCOPE_SC_CORE } from '../constants/Errors';
|
|
3
|
+
import { Endpoints, http } from '@selfcommunity/api-services';
|
|
4
|
+
import { CacheStrategies, Logger, LRUCache, objectWithoutProperties } from '@selfcommunity/utils';
|
|
5
|
+
import { getEventObjectCacheKey } from '../constants/Cache';
|
|
6
|
+
import { useDeepCompareEffectNoCheck } from 'use-deep-compare-effect';
|
|
7
|
+
import { useSCUser } from '../components/provider/SCUserProvider';
|
|
8
|
+
/**
|
|
9
|
+
:::info
|
|
10
|
+
This custom hook is used to fetch an event object.
|
|
11
|
+
:::
|
|
12
|
+
* @param object
|
|
13
|
+
* @param object.id
|
|
14
|
+
* @param object.event
|
|
15
|
+
* @param object.cacheStrategy
|
|
16
|
+
*/
|
|
17
|
+
export default function useSCFetchEvent({ id = null, event = null, cacheStrategy = CacheStrategies.CACHE_FIRST, }) {
|
|
18
|
+
const __eventId = event ? event.id : id;
|
|
19
|
+
// CONTEXT
|
|
20
|
+
const scUserContext = useSCUser();
|
|
21
|
+
const authUserId = scUserContext.user ? scUserContext.user.id : null;
|
|
22
|
+
// CACHE
|
|
23
|
+
const __eventCacheKey = getEventObjectCacheKey(__eventId);
|
|
24
|
+
const __event = authUserId ? event : objectWithoutProperties(event, ['subscription_status']);
|
|
25
|
+
const [scEvent, setScEvent] = useState(cacheStrategy !== CacheStrategies.NETWORK_ONLY ? LRUCache.get(__eventCacheKey, __event) : null);
|
|
26
|
+
const [error, setError] = useState(null);
|
|
27
|
+
const setSCEvent = (event) => {
|
|
28
|
+
const _e = authUserId ? event : objectWithoutProperties(event, ['subscription_status']);
|
|
29
|
+
setScEvent(_e);
|
|
30
|
+
LRUCache.set(__eventCacheKey, _e);
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Memoized fetchTag
|
|
34
|
+
*/
|
|
35
|
+
const fetchEvent = useMemo(() => () => {
|
|
36
|
+
return http
|
|
37
|
+
.request({
|
|
38
|
+
url: Endpoints.GetEventInfo.url({ id: __eventId }),
|
|
39
|
+
method: Endpoints.GetEventInfo.method,
|
|
40
|
+
})
|
|
41
|
+
.then((res) => {
|
|
42
|
+
if (res.status >= 300) {
|
|
43
|
+
return Promise.reject(res);
|
|
44
|
+
}
|
|
45
|
+
return Promise.resolve(res.data);
|
|
46
|
+
});
|
|
47
|
+
}, [__eventId]);
|
|
48
|
+
/**
|
|
49
|
+
* If id attempt to get the event by id
|
|
50
|
+
*/
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (__eventId && (!scEvent || (scEvent && __eventId !== scEvent.id))) {
|
|
53
|
+
fetchEvent()
|
|
54
|
+
.then((obj) => {
|
|
55
|
+
setSCEvent(obj);
|
|
56
|
+
})
|
|
57
|
+
.catch((err) => {
|
|
58
|
+
LRUCache.delete(__eventCacheKey);
|
|
59
|
+
setError(`Event with id ${id} not found`);
|
|
60
|
+
Logger.error(SCOPE_SC_CORE, `Event with id ${id} not found`);
|
|
61
|
+
Logger.error(SCOPE_SC_CORE, err.message);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}, [__eventId, authUserId]);
|
|
65
|
+
useDeepCompareEffectNoCheck(() => {
|
|
66
|
+
if (event) {
|
|
67
|
+
setSCEvent(event);
|
|
68
|
+
}
|
|
69
|
+
}, [event, authUserId]);
|
|
70
|
+
return { scEvent, setSCEvent, error };
|
|
71
|
+
}
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -62,6 +62,7 @@ import useSCFetchUserBlockedBy from './hooks/useSCFetchUserBlockedBy';
|
|
|
62
62
|
import useSCUserIsBlocked from './hooks/useSCUserIsBlocked';
|
|
63
63
|
import useSCFetchGroup from './hooks/useSCFetchGroup';
|
|
64
64
|
import useSCFetchGroups from './hooks/useSCFetchGroups';
|
|
65
|
+
import useSCFetchEvent from './hooks/useSCFetchEvent';
|
|
65
66
|
/**
|
|
66
67
|
* Routing component
|
|
67
68
|
*/
|
|
@@ -81,4 +82,4 @@ import * as Locale from './constants/Locale';
|
|
|
81
82
|
/**
|
|
82
83
|
* List all exports
|
|
83
84
|
*/
|
|
84
|
-
export { SCUserContextType, SCFollowedCategoriesManagerType, SCContextProviderType, SCContextType, SCSettingsType, SCSessionType, SCSettingsManagerType, SCFollowedManagerType, SCFollowersManagerType, SCConnectionsManagerType, SCSubscribedIncubatorsManagerType, SCLocaleType, SCNotificationContextType, SCPreferencesContextType, SCThemeContextType, SCRoutingContextType, SCLocaleContextType, SCAlertMessagesContextType, SCThemeAvatarVariableType, SCThemeCategoryIconVariableType, SCThemeCategoryVariableType, SCThemeVariablesType, SCThemeType, SCSubscribedGroupsManagerType, SCContext, SCUserContext, SCThemeContext, SCRoutingContext, SCLocaleContext, SCPreferencesContext, useSCContext, SCContextProvider, SCUserProvider, useSCUser, useSCPreferences, SCThemeProvider, useSCTheme, withSCTheme, SCRoutingProvider, useSCRouting, SCLocaleProvider, useSCLocale, withSCLocale, SCPreferencesProvider, SCPreferences, SCFeatures, SCNotification, SCNotificationProvider, SCNotificationContext, useSCNotification, SCAlertMessagesProvider, SCAlertMessagesContext, useSCAlertMessages, Link, SCRoutes, SCCache, UserUtils, Locale, useSCFetchUser, useSCFetchUserProviders, useSCFetchVote, useSCFetchFeedObject, useSCFetchCommentObject, useSCFetchCommentObjects, useSCFetchCustomAdv, useSCFetchTag, useSCFetchAddressingTagList, useSCFetchCategory, useSCFetchCategories, useSCFetchIncubator, useSCMediaClick, useSCFetchContributors, useSCFetchFeed, useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, useSCFetchPrivateMessageSnippets, useSCFetchBroadcastMessages, useSCFetchUserBlockedBy, useSCUserIsBlocked, useSCFetchGroup, useSCFetchGroups, };
|
|
85
|
+
export { SCUserContextType, SCFollowedCategoriesManagerType, SCContextProviderType, SCContextType, SCSettingsType, SCSessionType, SCSettingsManagerType, SCFollowedManagerType, SCFollowersManagerType, SCConnectionsManagerType, SCSubscribedIncubatorsManagerType, SCLocaleType, SCNotificationContextType, SCPreferencesContextType, SCThemeContextType, SCRoutingContextType, SCLocaleContextType, SCAlertMessagesContextType, SCThemeAvatarVariableType, SCThemeCategoryIconVariableType, SCThemeCategoryVariableType, SCThemeVariablesType, SCThemeType, SCSubscribedGroupsManagerType, SCContext, SCUserContext, SCThemeContext, SCRoutingContext, SCLocaleContext, SCPreferencesContext, useSCContext, SCContextProvider, SCUserProvider, useSCUser, useSCPreferences, SCThemeProvider, useSCTheme, withSCTheme, SCRoutingProvider, useSCRouting, SCLocaleProvider, useSCLocale, withSCLocale, SCPreferencesProvider, SCPreferences, SCFeatures, SCNotification, SCNotificationProvider, SCNotificationContext, useSCNotification, SCAlertMessagesProvider, SCAlertMessagesContext, useSCAlertMessages, Link, SCRoutes, SCCache, UserUtils, Locale, useSCFetchUser, useSCFetchUserProviders, useSCFetchVote, useSCFetchFeedObject, useSCFetchCommentObject, useSCFetchCommentObjects, useSCFetchCustomAdv, useSCFetchTag, useSCFetchAddressingTagList, useSCFetchCategory, useSCFetchCategories, useSCFetchIncubator, useSCMediaClick, useSCFetchContributors, useSCFetchFeed, useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, useSCFetchPrivateMessageSnippets, useSCFetchBroadcastMessages, useSCFetchUserBlockedBy, useSCUserIsBlocked, useSCFetchGroup, useSCFetchGroups, useSCFetchEvent };
|
package/lib/esm/index.js
CHANGED
|
@@ -58,6 +58,7 @@ import useSCFetchUserBlockedBy from './hooks/useSCFetchUserBlockedBy';
|
|
|
58
58
|
import useSCUserIsBlocked from './hooks/useSCUserIsBlocked';
|
|
59
59
|
import useSCFetchGroup from './hooks/useSCFetchGroup';
|
|
60
60
|
import useSCFetchGroups from './hooks/useSCFetchGroups';
|
|
61
|
+
import useSCFetchEvent from './hooks/useSCFetchEvent';
|
|
61
62
|
/**
|
|
62
63
|
* Routing component
|
|
63
64
|
*/
|
|
@@ -77,4 +78,4 @@ import * as Locale from './constants/Locale';
|
|
|
77
78
|
/**
|
|
78
79
|
* List all exports
|
|
79
80
|
*/
|
|
80
|
-
export { SCContext, SCUserContext, SCThemeContext, SCRoutingContext, SCLocaleContext, SCPreferencesContext, useSCContext, SCContextProvider, SCUserProvider, useSCUser, useSCPreferences, SCThemeProvider, useSCTheme, withSCTheme, SCRoutingProvider, useSCRouting, SCLocaleProvider, useSCLocale, withSCLocale, SCPreferencesProvider, SCPreferences, SCFeatures, SCNotification, SCNotificationProvider, SCNotificationContext, useSCNotification, SCAlertMessagesProvider, SCAlertMessagesContext, useSCAlertMessages, Link, SCRoutes, SCCache, UserUtils, Locale, useSCFetchUser, useSCFetchUserProviders, useSCFetchVote, useSCFetchFeedObject, useSCFetchCommentObject, useSCFetchCommentObjects, useSCFetchCustomAdv, useSCFetchTag, useSCFetchAddressingTagList, useSCFetchCategory, useSCFetchCategories, useSCFetchIncubator, useSCMediaClick, useSCFetchContributors, useSCFetchFeed, useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, useSCFetchPrivateMessageSnippets, useSCFetchBroadcastMessages, useSCFetchUserBlockedBy, useSCUserIsBlocked, useSCFetchGroup, useSCFetchGroups, };
|
|
81
|
+
export { SCContext, SCUserContext, SCThemeContext, SCRoutingContext, SCLocaleContext, SCPreferencesContext, useSCContext, SCContextProvider, SCUserProvider, useSCUser, useSCPreferences, SCThemeProvider, useSCTheme, withSCTheme, SCRoutingProvider, useSCRouting, SCLocaleProvider, useSCLocale, withSCLocale, SCPreferencesProvider, SCPreferences, SCFeatures, SCNotification, SCNotificationProvider, SCNotificationContext, useSCNotification, SCAlertMessagesProvider, SCAlertMessagesContext, useSCAlertMessages, Link, SCRoutes, SCCache, UserUtils, Locale, useSCFetchUser, useSCFetchUserProviders, useSCFetchVote, useSCFetchFeedObject, useSCFetchCommentObject, useSCFetchCommentObjects, useSCFetchCustomAdv, useSCFetchTag, useSCFetchAddressingTagList, useSCFetchCategory, useSCFetchCategories, useSCFetchIncubator, useSCMediaClick, useSCFetchContributors, useSCFetchFeed, useIsComponentMountedRef, usePreviousValue, useIsomorphicLayoutEffect, useEffectOnce, useNoInitialEffect, useSCFetchPrivateMessageSnippets, useSCFetchBroadcastMessages, useSCFetchUserBlockedBy, useSCUserIsBlocked, useSCFetchGroup, useSCFetchGroups, useSCFetchEvent };
|
|
@@ -37,6 +37,10 @@ export interface SCSettingsType {
|
|
|
37
37
|
* Object conf of notification.
|
|
38
38
|
*/
|
|
39
39
|
notifications?: SCNotificationsType;
|
|
40
|
+
/**
|
|
41
|
+
* Integrations conf
|
|
42
|
+
*/
|
|
43
|
+
integrations?: SCIntegrationsType;
|
|
40
44
|
/**
|
|
41
45
|
* Callback to handle anonymous action
|
|
42
46
|
* Ex. an anonymous user attempt to post a comment
|
|
@@ -620,3 +624,36 @@ export interface SCAlertMessagesContextType {
|
|
|
620
624
|
*/
|
|
621
625
|
setOptions: (options: any) => void;
|
|
622
626
|
}
|
|
627
|
+
/**
|
|
628
|
+
* Interface SCIntegrationsType
|
|
629
|
+
*/
|
|
630
|
+
export interface SCIntegrationsType {
|
|
631
|
+
/**
|
|
632
|
+
* OpenAI
|
|
633
|
+
*/
|
|
634
|
+
openai?: SCIntegrationsOpenAIType;
|
|
635
|
+
/**
|
|
636
|
+
* Geocoding
|
|
637
|
+
*/
|
|
638
|
+
geocoding?: SCGeocodingType;
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Interface SCIntegrationsOpenAIType
|
|
642
|
+
*/
|
|
643
|
+
export interface SCIntegrationsOpenAIType {
|
|
644
|
+
/**
|
|
645
|
+
* Set secretKey OpenAI
|
|
646
|
+
* Default: null
|
|
647
|
+
*/
|
|
648
|
+
secretKey: string | null;
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Interface SCGeocodingType
|
|
652
|
+
*/
|
|
653
|
+
export interface SCGeocodingType {
|
|
654
|
+
/**
|
|
655
|
+
* Set secretKey geocoding service
|
|
656
|
+
* Default: null
|
|
657
|
+
*/
|
|
658
|
+
apiKey: string | null;
|
|
659
|
+
}
|
|
@@ -21,6 +21,7 @@ export declare class ValidationError {
|
|
|
21
21
|
static ERROR_INVALID_NOTIFICATIONS_WEBSOCKET: number;
|
|
22
22
|
static ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_DISABLE_TOAST_MESSAGE: number;
|
|
23
23
|
static ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_SECURE: number;
|
|
24
|
+
static ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_PREFIX_PATH: number;
|
|
24
25
|
static ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING: number;
|
|
25
26
|
static ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING_DISABLE_TOAST_MESSAGE: number;
|
|
26
27
|
static ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING_APPLICATION_SERVER_KEY: number;
|
|
@@ -32,6 +33,11 @@ export declare class ValidationError {
|
|
|
32
33
|
static ERROR_INVALID_VOTE: number;
|
|
33
34
|
static ERROR_INVALID_VOTE_REACTIONS: number;
|
|
34
35
|
static ERROR_INVALID_VOTE_REACTIONS_STRUCTURE: number;
|
|
36
|
+
static ERROR_INVALID_INTEGRATIONS: number;
|
|
37
|
+
static ERROR_INVALID_INTEGRATIONS_OPENAI: number;
|
|
38
|
+
static ERROR_INVALID_INTEGRATIONS_OPENAI_SECRETKEY: number;
|
|
39
|
+
static ERROR_INVALID_INTEGRATIONS_GEOCODING: number;
|
|
40
|
+
static ERROR_INVALID_INTEGRATIONS_GEOCODING_APIKEY: number;
|
|
35
41
|
static defaultErrorMessageMap: {
|
|
36
42
|
[x: number]: string;
|
|
37
43
|
};
|
package/lib/esm/utils/errors.js
CHANGED
|
@@ -33,6 +33,7 @@ ValidationError.ERROR_INVALID_NOTIFICATIONS = 4900;
|
|
|
33
33
|
ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET = 4901;
|
|
34
34
|
ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_DISABLE_TOAST_MESSAGE = 4902;
|
|
35
35
|
ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_SECURE = 4903;
|
|
36
|
+
ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_PREFIX_PATH = 4904;
|
|
36
37
|
ValidationError.ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING = 4921;
|
|
37
38
|
ValidationError.ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING_DISABLE_TOAST_MESSAGE = 4922;
|
|
38
39
|
ValidationError.ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING_APPLICATION_SERVER_KEY = 4923;
|
|
@@ -44,6 +45,11 @@ ValidationError.ERROR_INVALID_PREFERENCES_FEATURES = 5002;
|
|
|
44
45
|
ValidationError.ERROR_INVALID_VOTE = 6000;
|
|
45
46
|
ValidationError.ERROR_INVALID_VOTE_REACTIONS = 6001;
|
|
46
47
|
ValidationError.ERROR_INVALID_VOTE_REACTIONS_STRUCTURE = 6002;
|
|
48
|
+
ValidationError.ERROR_INVALID_INTEGRATIONS = 6100;
|
|
49
|
+
ValidationError.ERROR_INVALID_INTEGRATIONS_OPENAI = 6101;
|
|
50
|
+
ValidationError.ERROR_INVALID_INTEGRATIONS_OPENAI_SECRETKEY = 6102;
|
|
51
|
+
ValidationError.ERROR_INVALID_INTEGRATIONS_GEOCODING = 6103;
|
|
52
|
+
ValidationError.ERROR_INVALID_INTEGRATIONS_GEOCODING_APIKEY = 6104;
|
|
47
53
|
ValidationError.defaultErrorMessageMap = {
|
|
48
54
|
[ValidationError.ERROR_INVALID_CONF]: 'Invalid or missing library configuration. Check the configuration that is passed to the SCContextProvider.',
|
|
49
55
|
[ValidationError.ERROR_INVALID_SESSION]: 'Invalid session format.',
|
|
@@ -63,6 +69,7 @@ ValidationError.defaultErrorMessageMap = {
|
|
|
63
69
|
[ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET]: 'Invalid notifications (websocket) option.',
|
|
64
70
|
[ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_DISABLE_TOAST_MESSAGE]: 'Invalid notifications websocket conf: disableToastMessage must be a boolean value.',
|
|
65
71
|
[ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_SECURE]: 'Invalid notifications websocket conf: secure must be a boolean value.',
|
|
72
|
+
[ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_PREFIX_PATH]: 'Invalid notifications websocket conf: prefixPath must be a string value.',
|
|
66
73
|
[ValidationError.ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING]: 'Invalid notifications (web push messaging) option.',
|
|
67
74
|
[ValidationError.ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING_DISABLE_TOAST_MESSAGE]: "Invalid notifications web push messaging option. 'disableToastMessage' must be a boolean value.",
|
|
68
75
|
[ValidationError.ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING_APPLICATION_SERVER_KEY]: "Invalid notifications web push messaging option. 'applicationServerKey' must be a string value.",
|
|
@@ -74,6 +81,11 @@ ValidationError.defaultErrorMessageMap = {
|
|
|
74
81
|
[ValidationError.ERROR_INVALID_VOTE]: 'Invalid vote option.',
|
|
75
82
|
[ValidationError.ERROR_INVALID_VOTE_REACTIONS]: "Invalid vote option. 'reactions' must be a valid array of reaction objects.",
|
|
76
83
|
[ValidationError.ERROR_INVALID_VOTE_REACTIONS_STRUCTURE]: "Invalid vote option. 'reactions' must be a valid array of reaction with attributes (id, label, sentiment, image, active).",
|
|
84
|
+
[ValidationError.ERROR_INVALID_INTEGRATIONS]: 'Invalid integrations conf.',
|
|
85
|
+
[ValidationError.ERROR_INVALID_INTEGRATIONS_OPENAI]: 'Invalid integrations (openai) option.',
|
|
86
|
+
[ValidationError.ERROR_INVALID_INTEGRATIONS_OPENAI_SECRETKEY]: 'Invalid integrations openai conf: secretKey must be a string value.',
|
|
87
|
+
[ValidationError.ERROR_INVALID_INTEGRATIONS_GEOCODING]: 'Invalid integrations (geocoding) option.',
|
|
88
|
+
[ValidationError.ERROR_INVALID_INTEGRATIONS_GEOCODING_APIKEY]: 'Invalid integrations geocoding conf: apiKey must be a string value.',
|
|
77
89
|
};
|
|
78
90
|
/**
|
|
79
91
|
* Manage Validation Warnings
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useEffect, useLayoutEffect } from 'react';
|
|
2
|
+
import { isClientSideRendering } from '@selfcommunity/utils';
|
|
2
3
|
// Ensure that the SSR uses React.useEffect instead of React.useLayoutEffect
|
|
3
4
|
// because document is undefined on the server-side.
|
|
4
|
-
const useIsomorphicLayoutEffect =
|
|
5
|
+
const useIsomorphicLayoutEffect = isClientSideRendering() ? useLayoutEffect : useEffect;
|
|
5
6
|
export default useIsomorphicLayoutEffect;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PLATFORM, PLATFORM_KEY, PLATFORMS } from '../constants/Device';
|
|
2
|
-
import { LocalStorageDB } from '@selfcommunity/utils';
|
|
2
|
+
import { isClientSideRendering, LocalStorageDB } from '@selfcommunity/utils';
|
|
3
3
|
/**
|
|
4
4
|
* Check if mobile native push notification is enabled
|
|
5
5
|
*/
|
|
6
6
|
export function isMobileNativeNotificationEnabled() {
|
|
7
|
-
return ((
|
|
7
|
+
return ((isClientSideRendering() && window[PLATFORM_KEY] && window[PLATFORM_KEY] in PLATFORM) ||
|
|
8
8
|
(LocalStorageDB.checkifSupport() && LocalStorageDB.get(PLATFORM_KEY) && PLATFORMS.includes(LocalStorageDB.get(PLATFORM_KEY))));
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { SCNotificationsMobileNativePushMessagingType, SCNotificationsType, SCNotificationsWebPushMessagingType, SCNotificationsWebSocketType, SCSettingsType } from '../types/context';
|
|
1
|
+
import { SCGeocodingType, SCIntegrationsOpenAIType, SCIntegrationsType, SCNotificationsMobileNativePushMessagingType, SCNotificationsType, SCNotificationsWebPushMessagingType, SCNotificationsWebSocketType, SCSettingsType } from '../types/context';
|
|
2
2
|
import { ValidationResult } from './errors';
|
|
3
3
|
import { SCLocaleType } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* Validate session option
|
|
6
|
-
* @param
|
|
6
|
+
* @param v
|
|
7
7
|
* @return {}
|
|
8
8
|
*/
|
|
9
9
|
export declare function validateSession(v: Record<string, any>): {
|
|
@@ -14,6 +14,7 @@ export declare function validateSession(v: Record<string, any>): {
|
|
|
14
14
|
/**
|
|
15
15
|
* Validate session type
|
|
16
16
|
* @param value
|
|
17
|
+
* @param session
|
|
17
18
|
* @return {}
|
|
18
19
|
*/
|
|
19
20
|
export declare const validateSessionType: (value: any, session: any) => {
|
|
@@ -24,6 +25,7 @@ export declare const validateSessionType: (value: any, session: any) => {
|
|
|
24
25
|
/**
|
|
25
26
|
* Validate session client id
|
|
26
27
|
* @param value
|
|
28
|
+
* @param session
|
|
27
29
|
* @return {}
|
|
28
30
|
*/
|
|
29
31
|
export declare const validateSessionClientId: (value: any, session: any) => {
|
|
@@ -34,6 +36,7 @@ export declare const validateSessionClientId: (value: any, session: any) => {
|
|
|
34
36
|
/**
|
|
35
37
|
* Validate session auth token
|
|
36
38
|
* @param value
|
|
39
|
+
* @param session
|
|
37
40
|
* @return {}
|
|
38
41
|
*/
|
|
39
42
|
export declare const validateSessionAuthTokenOption: (value: any, session: any) => {
|
|
@@ -55,6 +58,7 @@ export declare const validateHandleRefreshToken: (value: any, session: any) => {
|
|
|
55
58
|
/**
|
|
56
59
|
* Validate handleLogout option
|
|
57
60
|
* @param value
|
|
61
|
+
* @param session
|
|
58
62
|
* @return {}
|
|
59
63
|
*/
|
|
60
64
|
export declare const validateHandleLogout: (value: any, session: any) => {
|
|
@@ -64,7 +68,7 @@ export declare const validateHandleLogout: (value: any, session: any) => {
|
|
|
64
68
|
};
|
|
65
69
|
/**
|
|
66
70
|
* Validate notifications option
|
|
67
|
-
* @param
|
|
71
|
+
* @param v
|
|
68
72
|
* @return {}
|
|
69
73
|
*/
|
|
70
74
|
export declare function validateNotifications(v: SCNotificationsType): {
|
|
@@ -74,8 +78,7 @@ export declare function validateNotifications(v: SCNotificationsType): {
|
|
|
74
78
|
};
|
|
75
79
|
/**
|
|
76
80
|
* Validate webSocket
|
|
77
|
-
* @param
|
|
78
|
-
* @param {}
|
|
81
|
+
* @param v
|
|
79
82
|
*/
|
|
80
83
|
export declare const validateWebSocket: (v: any) => {
|
|
81
84
|
errors: any[];
|
|
@@ -91,9 +94,8 @@ export declare const validateWebSocket: (v: any) => {
|
|
|
91
94
|
/**
|
|
92
95
|
* Validate default disableToastMessage (webSocket)
|
|
93
96
|
* @param value
|
|
94
|
-
* @param {}
|
|
95
97
|
*/
|
|
96
|
-
export declare const validateWebSocketDisableToastMessage: (value: any
|
|
98
|
+
export declare const validateWebSocketDisableToastMessage: (value: any) => {
|
|
97
99
|
errors: any[];
|
|
98
100
|
warnings: any[];
|
|
99
101
|
value: any;
|
|
@@ -101,17 +103,24 @@ export declare const validateWebSocketDisableToastMessage: (value: any, notifica
|
|
|
101
103
|
/**
|
|
102
104
|
* Validate default secure (webSocket)
|
|
103
105
|
* @param value
|
|
104
|
-
* @param {}
|
|
105
106
|
*/
|
|
106
|
-
export declare const validateWebSocketSecure: (value: any
|
|
107
|
+
export declare const validateWebSocketSecure: (value: any) => {
|
|
107
108
|
errors: any[];
|
|
108
109
|
warnings: any[];
|
|
109
110
|
value: any;
|
|
110
111
|
};
|
|
111
112
|
/**
|
|
112
|
-
* Validate
|
|
113
|
+
* Validate prefixPath (webSocket)
|
|
113
114
|
* @param value
|
|
114
|
-
|
|
115
|
+
*/
|
|
116
|
+
export declare const validateWebSocketPrefixPath: (value: any) => {
|
|
117
|
+
errors: any[];
|
|
118
|
+
warnings: any[];
|
|
119
|
+
value: any;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Validate webPushMessaging
|
|
123
|
+
* @param v
|
|
115
124
|
*/
|
|
116
125
|
export declare const validateWebPushMessaging: (v: any) => {
|
|
117
126
|
errors: any[];
|
|
@@ -127,9 +136,8 @@ export declare const validateWebPushMessaging: (v: any) => {
|
|
|
127
136
|
/**
|
|
128
137
|
* Validate default disableToastMessage (webPushMessaging)
|
|
129
138
|
* @param value
|
|
130
|
-
* @param {}
|
|
131
139
|
*/
|
|
132
|
-
export declare const validateWebPushMessagingDisableToastMessage: (value: any
|
|
140
|
+
export declare const validateWebPushMessagingDisableToastMessage: (value: any) => {
|
|
133
141
|
errors: any[];
|
|
134
142
|
warnings: any[];
|
|
135
143
|
value: any;
|
|
@@ -137,17 +145,15 @@ export declare const validateWebPushMessagingDisableToastMessage: (value: any, n
|
|
|
137
145
|
/**
|
|
138
146
|
* Validate default applicationServerKey (webPushMessaging)
|
|
139
147
|
* @param value
|
|
140
|
-
* @param {}
|
|
141
148
|
*/
|
|
142
|
-
export declare const validateWebPushMessagingApplicationServerKey: (value: any
|
|
149
|
+
export declare const validateWebPushMessagingApplicationServerKey: (value: any) => {
|
|
143
150
|
errors: any[];
|
|
144
151
|
warnings: any[];
|
|
145
152
|
value: any;
|
|
146
153
|
};
|
|
147
154
|
/**
|
|
148
155
|
* Validate mobile native
|
|
149
|
-
* @param
|
|
150
|
-
* @param {}
|
|
156
|
+
* @param v
|
|
151
157
|
*/
|
|
152
158
|
export declare const validateMobileNativePushMessaging: (v: any) => {
|
|
153
159
|
errors: any[];
|
|
@@ -163,16 +169,15 @@ export declare const validateMobileNativePushMessaging: (v: any) => {
|
|
|
163
169
|
/**
|
|
164
170
|
* Validate default disable (mobileNativePushMessaging)
|
|
165
171
|
* @param value
|
|
166
|
-
* @param {}
|
|
167
172
|
*/
|
|
168
|
-
export declare const validateMobileNativePushMessagingDisable: (value: any
|
|
173
|
+
export declare const validateMobileNativePushMessagingDisable: (value: any) => {
|
|
169
174
|
errors: any[];
|
|
170
175
|
warnings: any[];
|
|
171
176
|
value: any;
|
|
172
177
|
};
|
|
173
178
|
/**
|
|
174
179
|
* Validate portal option
|
|
175
|
-
* @param
|
|
180
|
+
* @param value
|
|
176
181
|
* @return {}
|
|
177
182
|
*/
|
|
178
183
|
export declare const validatePortal: (value: any) => {
|
|
@@ -183,7 +188,7 @@ export declare const validatePortal: (value: any) => {
|
|
|
183
188
|
/**
|
|
184
189
|
* Validate default locale
|
|
185
190
|
* @param value
|
|
186
|
-
* @param
|
|
191
|
+
* @param locale
|
|
187
192
|
*/
|
|
188
193
|
export declare const validateLocaleDefault: (value: any, locale: any) => {
|
|
189
194
|
errors: any[];
|
|
@@ -193,7 +198,6 @@ export declare const validateLocaleDefault: (value: any, locale: any) => {
|
|
|
193
198
|
/**
|
|
194
199
|
* Validate default locale
|
|
195
200
|
* @param value
|
|
196
|
-
* @param {}
|
|
197
201
|
*/
|
|
198
202
|
export declare const validateLocaleMessages: (value: any) => {
|
|
199
203
|
errors: any[];
|
|
@@ -202,7 +206,7 @@ export declare const validateLocaleMessages: (value: any) => {
|
|
|
202
206
|
};
|
|
203
207
|
/**
|
|
204
208
|
* Validate locale option
|
|
205
|
-
* @param
|
|
209
|
+
* @param v
|
|
206
210
|
* @return {}
|
|
207
211
|
*/
|
|
208
212
|
export declare const validateLocale: (v: any) => {
|
|
@@ -218,7 +222,7 @@ export declare const validateLocale: (v: any) => {
|
|
|
218
222
|
};
|
|
219
223
|
/**
|
|
220
224
|
* Validate router option
|
|
221
|
-
* @param
|
|
225
|
+
* @param value
|
|
222
226
|
* @return {}
|
|
223
227
|
*/
|
|
224
228
|
export declare const validateRouter: (value: any) => {
|
|
@@ -228,7 +232,7 @@ export declare const validateRouter: (value: any) => {
|
|
|
228
232
|
};
|
|
229
233
|
/**
|
|
230
234
|
* Validate theme option
|
|
231
|
-
* @param
|
|
235
|
+
* @param value
|
|
232
236
|
* @return {}
|
|
233
237
|
*/
|
|
234
238
|
export declare const validateTheme: (value: any) => {
|
|
@@ -238,7 +242,7 @@ export declare const validateTheme: (value: any) => {
|
|
|
238
242
|
};
|
|
239
243
|
/**
|
|
240
244
|
* Validate handleAnonymousAction option
|
|
241
|
-
* @param
|
|
245
|
+
* @param v
|
|
242
246
|
* @return {}
|
|
243
247
|
*/
|
|
244
248
|
export declare const validateHandleAnonymousAction: (v: any) => {
|
|
@@ -248,7 +252,7 @@ export declare const validateHandleAnonymousAction: (v: any) => {
|
|
|
248
252
|
};
|
|
249
253
|
/**
|
|
250
254
|
* Validate contextProviders option
|
|
251
|
-
* @param
|
|
255
|
+
* @param value
|
|
252
256
|
* @return [...contextProviders]
|
|
253
257
|
*/
|
|
254
258
|
export declare const validateContextProviders: (value: any) => {
|
|
@@ -304,6 +308,73 @@ export declare function validateVote(v: Record<string, any>): {
|
|
|
304
308
|
warnings: any[];
|
|
305
309
|
value: Record<string, any>;
|
|
306
310
|
};
|
|
311
|
+
/**
|
|
312
|
+
* Validate integrations option
|
|
313
|
+
* @param v
|
|
314
|
+
* @return {}
|
|
315
|
+
*/
|
|
316
|
+
export declare function validateIntegrations(v: SCIntegrationsType): {
|
|
317
|
+
errors: any[];
|
|
318
|
+
warnings: any[];
|
|
319
|
+
value: {
|
|
320
|
+
openai: {
|
|
321
|
+
secretKey: any;
|
|
322
|
+
};
|
|
323
|
+
geocoding: {
|
|
324
|
+
apiKey: any;
|
|
325
|
+
};
|
|
326
|
+
};
|
|
327
|
+
};
|
|
328
|
+
/**
|
|
329
|
+
* Validate OpenAI Option
|
|
330
|
+
* @param v
|
|
331
|
+
*/
|
|
332
|
+
export declare const validateOpenAI: (v: any) => {
|
|
333
|
+
errors: any[];
|
|
334
|
+
warnings: any[];
|
|
335
|
+
v: any;
|
|
336
|
+
value?: undefined;
|
|
337
|
+
} | {
|
|
338
|
+
errors: any[];
|
|
339
|
+
warnings: any[];
|
|
340
|
+
value: SCIntegrationsOpenAIType;
|
|
341
|
+
v?: undefined;
|
|
342
|
+
};
|
|
343
|
+
/**
|
|
344
|
+
* Validate Geocoding Option
|
|
345
|
+
* @param v
|
|
346
|
+
*/
|
|
347
|
+
export declare const validateGeocoding: (v: any) => {
|
|
348
|
+
errors: any[];
|
|
349
|
+
warnings: any[];
|
|
350
|
+
v: any;
|
|
351
|
+
value?: undefined;
|
|
352
|
+
} | {
|
|
353
|
+
errors: any[];
|
|
354
|
+
warnings: any[];
|
|
355
|
+
value: SCGeocodingType;
|
|
356
|
+
v?: undefined;
|
|
357
|
+
};
|
|
358
|
+
/**
|
|
359
|
+
* Validate OpenAI secret key option
|
|
360
|
+
* @param value
|
|
361
|
+
* @return {}
|
|
362
|
+
*/
|
|
363
|
+
export declare const validateOpenAISecretKey: (value: any) => {
|
|
364
|
+
errors: any[];
|
|
365
|
+
warnings: any[];
|
|
366
|
+
value: any;
|
|
367
|
+
};
|
|
368
|
+
/**
|
|
369
|
+
* Validate Geocoding api key option
|
|
370
|
+
* @param value
|
|
371
|
+
* @return {}
|
|
372
|
+
*/
|
|
373
|
+
export declare const validateGeocodingApiKey: (value: any) => {
|
|
374
|
+
errors: any[];
|
|
375
|
+
warnings: any[];
|
|
376
|
+
value: any;
|
|
377
|
+
};
|
|
307
378
|
/**
|
|
308
379
|
* Valid options
|
|
309
380
|
* @type {{}}
|
|
@@ -317,12 +388,16 @@ export declare const notificationsWebPushMessagingOptions: Record<string, any>;
|
|
|
317
388
|
export declare const notificationsMobileNativePushMessagingOptions: Record<string, any>;
|
|
318
389
|
export declare const preferencesOptions: Record<string, any>;
|
|
319
390
|
export declare const voteOptions: Record<string, any>;
|
|
391
|
+
export declare const integrationsOptions: Record<string, any>;
|
|
392
|
+
export declare const integrationsOpenAIOptions: Record<string, any>;
|
|
393
|
+
export declare const integrationsGeocodingOptions: Record<string, any>;
|
|
320
394
|
export declare const validOptions: {
|
|
321
395
|
[x: string]: any;
|
|
322
396
|
};
|
|
323
397
|
/**
|
|
324
398
|
* Validate all options by type
|
|
325
|
-
* @param
|
|
399
|
+
* @param values
|
|
400
|
+
* @param schemaOptions
|
|
326
401
|
* @return {options hydrated}
|
|
327
402
|
*/
|
|
328
403
|
export declare const validateOptions: (values: SCSettingsType, schemaOptions: Record<string, any>) => {
|