@selfcommunity/react-core 0.1.2-alpha.0
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/LICENSE.md +21 -0
- package/README.md +13 -0
- package/lib/cjs/components/provider/SCAlertMessagesProvider/index.js +67 -0
- package/lib/cjs/components/provider/SCContextProvider/index.js +117 -0
- package/lib/cjs/components/provider/SCLocaleProvider/index.js +158 -0
- package/lib/cjs/components/provider/SCNotificationProvider/index.js +73 -0
- package/lib/cjs/components/provider/SCPreferencesProvider/index.js +93 -0
- package/lib/cjs/components/provider/SCRoutingProvider/index.js +146 -0
- package/lib/cjs/components/provider/SCThemeProvider/index.js +123 -0
- package/lib/cjs/components/provider/SCUserProvider/index.js +310 -0
- package/lib/cjs/components/router/index.js +91 -0
- package/lib/cjs/constants/Actions.js +6 -0
- package/lib/cjs/constants/ContextProviders.js +29 -0
- package/lib/cjs/constants/Device.js +11 -0
- package/lib/cjs/constants/Errors.js +10 -0
- package/lib/cjs/constants/Features.js +84 -0
- package/lib/cjs/constants/Locale.js +19 -0
- package/lib/cjs/constants/Notification.js +67 -0
- package/lib/cjs/constants/Notifications.js +27 -0
- package/lib/cjs/constants/Preferences.js +344 -0
- package/lib/cjs/constants/Routes.js +68 -0
- package/lib/cjs/constants/Session.js +22 -0
- package/lib/cjs/constants/Theme.js +6 -0
- package/lib/cjs/constants/WebSocket.js +10 -0
- package/lib/cjs/hooks/useSCAuth.js +340 -0
- package/lib/cjs/hooks/useSCCachingManager.js +58 -0
- package/lib/cjs/hooks/useSCConnectionsManager.js +285 -0
- package/lib/cjs/hooks/useSCFetchCategories.js +71 -0
- package/lib/cjs/hooks/useSCFetchCategory.js +68 -0
- package/lib/cjs/hooks/useSCFetchCommentObject.js +68 -0
- package/lib/cjs/hooks/useSCFetchCommentObjects.js +296 -0
- package/lib/cjs/hooks/useSCFetchCustomAdv.js +84 -0
- package/lib/cjs/hooks/useSCFetchFeedObject.js +79 -0
- package/lib/cjs/hooks/useSCFetchIncubator.js +68 -0
- package/lib/cjs/hooks/useSCFetchTag.js +68 -0
- package/lib/cjs/hooks/useSCFetchUser.js +68 -0
- package/lib/cjs/hooks/useSCFollowedCategoriesManager.js +162 -0
- package/lib/cjs/hooks/useSCFollowersManager.js +232 -0
- package/lib/cjs/hooks/useSCMediaClick.js +27 -0
- package/lib/cjs/hooks/useSCSubscribedIncubatorsManager.js +165 -0
- package/lib/cjs/hooks/useSCWebPushMessaging.js +286 -0
- package/lib/cjs/hooks/useSCWebSocket.js +120 -0
- package/lib/cjs/index.js +169 -0
- package/lib/cjs/scss/styles.scss +1 -0
- package/lib/cjs/themes/theme.js +165 -0
- package/lib/cjs/types/context.js +3 -0
- package/lib/cjs/types/index.js +22 -0
- package/lib/cjs/utils/errors.js +196 -0
- package/lib/cjs/utils/locale.js +56 -0
- package/lib/cjs/utils/logger.js +32 -0
- package/lib/cjs/utils/object.js +44 -0
- package/lib/cjs/utils/session.js +17 -0
- package/lib/cjs/utils/string.js +57 -0
- package/lib/cjs/utils/url.js +70 -0
- package/lib/cjs/utils/user.js +83 -0
- package/lib/cjs/utils/validator.js +771 -0
- package/lib/cjs/utils/webPushMessaging.js +110 -0
- package/lib/cjs/utils/websocket.js +307 -0
- package/lib/esm/api-services/src/client/index.d.ts +115 -0
- package/lib/esm/api-services/src/client/index.d.ts.map +1 -0
- package/lib/esm/api-services/src/constants/Endpoints.d.ts +10 -0
- package/lib/esm/api-services/src/constants/Endpoints.d.ts.map +1 -0
- package/lib/esm/api-services/src/index.d.ts +24 -0
- package/lib/esm/api-services/src/index.d.ts.map +1 -0
- package/lib/esm/api-services/src/services/category/index.d.ts +13 -0
- package/lib/esm/api-services/src/services/category/index.d.ts.map +1 -0
- package/lib/esm/api-services/src/services/feature/index.d.ts +10 -0
- package/lib/esm/api-services/src/services/feature/index.d.ts.map +1 -0
- package/lib/esm/api-services/src/services/preference/index.d.ts +16 -0
- package/lib/esm/api-services/src/services/preference/index.d.ts.map +1 -0
- package/lib/esm/api-services/src/services/user/index.d.ts +16 -0
- package/lib/esm/api-services/src/services/user/index.d.ts.map +1 -0
- package/lib/esm/api-services/src/utils/http.d.ts +6 -0
- package/lib/esm/api-services/src/utils/http.d.ts.map +1 -0
- package/lib/esm/api-services/src/utils/token.d.ts +16 -0
- package/lib/esm/api-services/src/utils/token.d.ts.map +1 -0
- package/lib/esm/components/provider/SCAlertMessagesProvider/index.js +67 -0
- package/lib/esm/components/provider/SCContextProvider/index.js +117 -0
- package/lib/esm/components/provider/SCLocaleProvider/index.js +158 -0
- package/lib/esm/components/provider/SCNotificationProvider/index.js +73 -0
- package/lib/esm/components/provider/SCPreferencesProvider/index.js +93 -0
- package/lib/esm/components/provider/SCRoutingProvider/index.js +146 -0
- package/lib/esm/components/provider/SCThemeProvider/index.js +123 -0
- package/lib/esm/components/provider/SCUserProvider/index.js +310 -0
- package/lib/esm/components/router/index.js +91 -0
- package/lib/esm/constants/Actions.js +6 -0
- package/lib/esm/constants/ContextProviders.js +29 -0
- package/lib/esm/constants/Device.js +11 -0
- package/lib/esm/constants/Errors.js +10 -0
- package/lib/esm/constants/Features.js +84 -0
- package/lib/esm/constants/Locale.js +19 -0
- package/lib/esm/constants/Notification.js +67 -0
- package/lib/esm/constants/Notifications.js +27 -0
- package/lib/esm/constants/Preferences.js +344 -0
- package/lib/esm/constants/Routes.js +68 -0
- package/lib/esm/constants/Session.js +22 -0
- package/lib/esm/constants/Theme.js +6 -0
- package/lib/esm/constants/WebSocket.js +10 -0
- package/lib/esm/hooks/useSCAuth.js +340 -0
- package/lib/esm/hooks/useSCCachingManager.js +58 -0
- package/lib/esm/hooks/useSCConnectionsManager.js +285 -0
- package/lib/esm/hooks/useSCFetchCategories.js +71 -0
- package/lib/esm/hooks/useSCFetchCategory.js +68 -0
- package/lib/esm/hooks/useSCFetchCommentObject.js +68 -0
- package/lib/esm/hooks/useSCFetchCommentObjects.js +296 -0
- package/lib/esm/hooks/useSCFetchCustomAdv.js +84 -0
- package/lib/esm/hooks/useSCFetchFeedObject.js +79 -0
- package/lib/esm/hooks/useSCFetchIncubator.js +68 -0
- package/lib/esm/hooks/useSCFetchTag.js +68 -0
- package/lib/esm/hooks/useSCFetchUser.js +68 -0
- package/lib/esm/hooks/useSCFollowedCategoriesManager.js +162 -0
- package/lib/esm/hooks/useSCFollowersManager.js +232 -0
- package/lib/esm/hooks/useSCMediaClick.js +27 -0
- package/lib/esm/hooks/useSCSubscribedIncubatorsManager.js +165 -0
- package/lib/esm/hooks/useSCWebPushMessaging.js +286 -0
- package/lib/esm/hooks/useSCWebSocket.js +120 -0
- package/lib/esm/index.js +169 -0
- package/lib/esm/react-core/src/components/provider/SCAlertMessagesProvider/index.d.ts +37 -0
- package/lib/esm/react-core/src/components/provider/SCAlertMessagesProvider/index.d.ts.map +1 -0
- package/lib/esm/react-core/src/components/provider/SCContextProvider/index.d.ts +35 -0
- package/lib/esm/react-core/src/components/provider/SCContextProvider/index.d.ts.map +1 -0
- package/lib/esm/react-core/src/components/provider/SCLocaleProvider/index.d.ts +42 -0
- package/lib/esm/react-core/src/components/provider/SCLocaleProvider/index.d.ts.map +1 -0
- package/lib/esm/react-core/src/components/provider/SCNotificationProvider/index.d.ts +37 -0
- package/lib/esm/react-core/src/components/provider/SCNotificationProvider/index.d.ts.map +1 -0
- package/lib/esm/react-core/src/components/provider/SCPreferencesProvider/index.d.ts +38 -0
- package/lib/esm/react-core/src/components/provider/SCPreferencesProvider/index.d.ts.map +1 -0
- package/lib/esm/react-core/src/components/provider/SCRoutingProvider/index.d.ts +39 -0
- package/lib/esm/react-core/src/components/provider/SCRoutingProvider/index.d.ts.map +1 -0
- package/lib/esm/react-core/src/components/provider/SCThemeProvider/index.d.ts +49 -0
- package/lib/esm/react-core/src/components/provider/SCThemeProvider/index.d.ts.map +1 -0
- package/lib/esm/react-core/src/components/provider/SCUserProvider/index.d.ts +38 -0
- package/lib/esm/react-core/src/components/provider/SCUserProvider/index.d.ts.map +1 -0
- package/lib/esm/react-core/src/components/router/index.d.ts +34 -0
- package/lib/esm/react-core/src/components/router/index.d.ts.map +1 -0
- package/lib/esm/react-core/src/constants/Actions.d.ts +2 -0
- package/lib/esm/react-core/src/constants/Actions.d.ts.map +1 -0
- package/lib/esm/react-core/src/constants/ContextProviders.d.ts +6 -0
- package/lib/esm/react-core/src/constants/ContextProviders.d.ts.map +1 -0
- package/lib/esm/react-core/src/constants/Device.d.ts +6 -0
- package/lib/esm/react-core/src/constants/Device.d.ts.map +1 -0
- package/lib/esm/react-core/src/constants/Errors.d.ts +5 -0
- package/lib/esm/react-core/src/constants/Errors.d.ts.map +1 -0
- package/lib/esm/react-core/src/constants/Features.d.ts +41 -0
- package/lib/esm/react-core/src/constants/Features.d.ts.map +1 -0
- package/lib/esm/react-core/src/constants/Locale.d.ts +8 -0
- package/lib/esm/react-core/src/constants/Locale.d.ts.map +1 -0
- package/lib/esm/react-core/src/constants/Notification.d.ts +55 -0
- package/lib/esm/react-core/src/constants/Notification.d.ts.map +1 -0
- package/lib/esm/react-core/src/constants/Notifications.d.ts +11 -0
- package/lib/esm/react-core/src/constants/Notifications.d.ts.map +1 -0
- package/lib/esm/react-core/src/constants/Routes.d.ts +29 -0
- package/lib/esm/react-core/src/constants/Routes.d.ts.map +1 -0
- package/lib/esm/react-core/src/constants/Session.d.ts +10 -0
- package/lib/esm/react-core/src/constants/Session.d.ts.map +1 -0
- package/lib/esm/react-core/src/constants/Theme.d.ts +2 -0
- package/lib/esm/react-core/src/constants/Theme.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCAuth.d.ts +56 -0
- package/lib/esm/react-core/src/hooks/useSCAuth.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCCachingManager.d.ts +19 -0
- package/lib/esm/react-core/src/hooks/useSCCachingManager.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCConnectionsManager.d.ts +40 -0
- package/lib/esm/react-core/src/hooks/useSCConnectionsManager.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCFetchCategories.d.ts +17 -0
- package/lib/esm/react-core/src/hooks/useSCFetchCategories.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCFetchCategory.d.ts +19 -0
- package/lib/esm/react-core/src/hooks/useSCFetchCategory.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCFetchCommentObject.d.ts +19 -0
- package/lib/esm/react-core/src/hooks/useSCFetchCommentObject.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCFetchCommentObjects.d.ts +54 -0
- package/lib/esm/react-core/src/hooks/useSCFetchCommentObjects.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCFetchCustomAdv.d.ts +19 -0
- package/lib/esm/react-core/src/hooks/useSCFetchCustomAdv.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCFetchFeedObject.d.ts +21 -0
- package/lib/esm/react-core/src/hooks/useSCFetchFeedObject.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCFetchIncubator.d.ts +19 -0
- package/lib/esm/react-core/src/hooks/useSCFetchIncubator.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCFetchTag.d.ts +19 -0
- package/lib/esm/react-core/src/hooks/useSCFetchTag.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCFetchUser.d.ts +19 -0
- package/lib/esm/react-core/src/hooks/useSCFetchUser.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCFollowedCategoriesManager.d.ts +37 -0
- package/lib/esm/react-core/src/hooks/useSCFollowedCategoriesManager.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCFollowersManager.d.ts +37 -0
- package/lib/esm/react-core/src/hooks/useSCFollowersManager.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCMediaClick.d.ts +4 -0
- package/lib/esm/react-core/src/hooks/useSCMediaClick.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCSubscribedIncubatorsManager.d.ts +27 -0
- package/lib/esm/react-core/src/hooks/useSCSubscribedIncubatorsManager.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCWebPushMessaging.d.ts +9 -0
- package/lib/esm/react-core/src/hooks/useSCWebPushMessaging.d.ts.map +1 -0
- package/lib/esm/react-core/src/hooks/useSCWebSocket.d.ts +12 -0
- package/lib/esm/react-core/src/hooks/useSCWebSocket.d.ts.map +1 -0
- package/lib/esm/react-core/src/index.d.ts +77 -0
- package/lib/esm/react-core/src/index.d.ts.map +1 -0
- package/lib/esm/react-core/src/types/context.d.ts +428 -0
- package/lib/esm/react-core/src/types/context.d.ts.map +1 -0
- package/lib/esm/react-core/src/types/index.d.ts +3 -0
- package/lib/esm/react-core/src/types/index.d.ts.map +1 -0
- package/lib/esm/react-core/src/utils/errors.d.ts +98 -0
- package/lib/esm/react-core/src/utils/errors.d.ts.map +1 -0
- package/lib/esm/react-core/src/utils/locale.d.ts +10 -0
- package/lib/esm/react-core/src/utils/locale.d.ts.map +1 -0
- package/lib/esm/react-core/src/utils/logger.d.ts +11 -0
- package/lib/esm/react-core/src/utils/logger.d.ts.map +1 -0
- package/lib/esm/react-core/src/utils/object.d.ts +13 -0
- package/lib/esm/react-core/src/utils/object.d.ts.map +1 -0
- package/lib/esm/react-core/src/utils/session.d.ts +6 -0
- package/lib/esm/react-core/src/utils/session.d.ts.map +1 -0
- package/lib/esm/react-core/src/utils/string.d.ts +21 -0
- package/lib/esm/react-core/src/utils/string.d.ts.map +1 -0
- package/lib/esm/react-core/src/utils/url.d.ts +22 -0
- package/lib/esm/react-core/src/utils/url.d.ts.map +1 -0
- package/lib/esm/react-core/src/utils/user.d.ts +41 -0
- package/lib/esm/react-core/src/utils/user.d.ts.map +1 -0
- package/lib/esm/react-core/src/utils/validator.d.ts +239 -0
- package/lib/esm/react-core/src/utils/validator.d.ts.map +1 -0
- package/lib/esm/react-core/src/utils/webPushMessaging.d.ts +14 -0
- package/lib/esm/react-core/src/utils/webPushMessaging.d.ts.map +1 -0
- package/lib/esm/react-core/src/utils/websocket.d.ts +177 -0
- package/lib/esm/react-core/src/utils/websocket.d.ts.map +1 -0
- package/lib/esm/react-i18n/src/index.d.ts +815 -0
- package/lib/esm/react-i18n/src/index.d.ts.map +1 -0
- package/lib/esm/scss/styles.scss +1 -0
- package/lib/esm/themes/theme.js +165 -0
- package/lib/esm/types/context.js +3 -0
- package/lib/esm/types/index.js +22 -0
- package/lib/esm/types/src/index.d.ts +9 -0
- package/lib/esm/types/src/index.d.ts.map +1 -0
- package/lib/esm/types/src/types/auth.d.ts +26 -0
- package/lib/esm/types/src/types/auth.d.ts.map +1 -0
- package/lib/esm/types/src/types/broadcastMessage.d.ts +73 -0
- package/lib/esm/types/src/types/broadcastMessage.d.ts.map +1 -0
- package/lib/esm/types/src/types/category.d.ts +100 -0
- package/lib/esm/types/src/types/category.d.ts.map +1 -0
- package/lib/esm/types/src/types/comment.d.ts +97 -0
- package/lib/esm/types/src/types/comment.d.ts.map +1 -0
- package/lib/esm/types/src/types/customAdv.d.ts +53 -0
- package/lib/esm/types/src/types/customAdv.d.ts.map +1 -0
- package/lib/esm/types/src/types/customNotification.d.ts +28 -0
- package/lib/esm/types/src/types/customNotification.d.ts.map +1 -0
- package/lib/esm/types/src/types/embed.d.ts +33 -0
- package/lib/esm/types/src/types/embed.d.ts.map +1 -0
- package/lib/esm/types/src/types/feed.d.ts +208 -0
- package/lib/esm/types/src/types/feed.d.ts.map +1 -0
- package/lib/esm/types/src/types/incubator.d.ts +53 -0
- package/lib/esm/types/src/types/incubator.d.ts.map +1 -0
- package/lib/esm/types/src/types/index.d.ts +22 -0
- package/lib/esm/types/src/types/index.d.ts.map +1 -0
- package/lib/esm/types/src/types/location.d.ts +61 -0
- package/lib/esm/types/src/types/location.d.ts.map +1 -0
- package/lib/esm/types/src/types/media.d.ts +52 -0
- package/lib/esm/types/src/types/media.d.ts.map +1 -0
- package/lib/esm/types/src/types/notification.d.ts +416 -0
- package/lib/esm/types/src/types/notification.d.ts.map +1 -0
- package/lib/esm/types/src/types/poll.d.ts +77 -0
- package/lib/esm/types/src/types/poll.d.ts.map +1 -0
- package/lib/esm/types/src/types/privateMessage.d.ts +109 -0
- package/lib/esm/types/src/types/privateMessage.d.ts.map +1 -0
- package/lib/esm/types/src/types/prize.d.ts +48 -0
- package/lib/esm/types/src/types/prize.d.ts.map +1 -0
- package/lib/esm/types/src/types/tag.d.ts +47 -0
- package/lib/esm/types/src/types/tag.d.ts.map +1 -0
- package/lib/esm/types/src/types/user.d.ts +227 -0
- package/lib/esm/types/src/types/user.d.ts.map +1 -0
- package/lib/esm/utils/errors.js +196 -0
- package/lib/esm/utils/locale.js +56 -0
- package/lib/esm/utils/logger.js +32 -0
- package/lib/esm/utils/object.js +44 -0
- package/lib/esm/utils/session.js +17 -0
- package/lib/esm/utils/src/index.d.ts +7 -0
- package/lib/esm/utils/src/index.d.ts.map +1 -0
- package/lib/esm/utils/src/utils/string.d.ts +21 -0
- package/lib/esm/utils/src/utils/string.d.ts.map +1 -0
- package/lib/esm/utils/src/utils/url.d.ts +22 -0
- package/lib/esm/utils/src/utils/url.d.ts.map +1 -0
- package/lib/esm/utils/string.js +57 -0
- package/lib/esm/utils/url.js +70 -0
- package/lib/esm/utils/user.js +83 -0
- package/lib/esm/utils/validator.js +771 -0
- package/lib/esm/utils/webPushMessaging.js +110 -0
- package/lib/esm/utils/websocket.js +307 -0
- package/lib/umd/react-core.js +2 -0
- package/lib/umd/react-core.js.LICENSE.txt +1 -0
- package/package.json +128 -0
|
@@ -0,0 +1,771 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.validateLocaleMessages = exports.validateLocaleDefault = exports.validateLocale = exports.validateHandleRefreshToken = exports.validateHandleAnonymousAction = exports.validateContextProviders = exports.validOptions = exports.settingsOptions = exports.sessionOptions = exports.notificationsWebSocketOptions = exports.notificationsWebSPushMessagingOptions = exports.notificationsOptions = exports.localeOptions = void 0;
|
|
5
|
+
exports.validateNotifications = validateNotifications;
|
|
6
|
+
exports.validateRouter = exports.validatePortal = exports.validateOptions = void 0;
|
|
7
|
+
exports.validateSession = validateSession;
|
|
8
|
+
exports.validateWebSocketDisableToastMessage = exports.validateWebSocket = exports.validateWebPushMessagingDisableToastMessage = exports.validateWebPushMessagingApplicationServerKey = exports.validateWebPushMessaging = exports.validateTheme = exports.validateSessionType = exports.validateSessionClientId = exports.validateSessionAuthTokenOption = void 0;
|
|
9
|
+
|
|
10
|
+
var Locale = _interopRequireWildcard(require("../constants/Locale"));
|
|
11
|
+
|
|
12
|
+
var _url = require("./url");
|
|
13
|
+
|
|
14
|
+
var Session = _interopRequireWildcard(require("../constants/Session"));
|
|
15
|
+
|
|
16
|
+
var _Errors = require("../constants/Errors");
|
|
17
|
+
|
|
18
|
+
var _errors = require("./errors");
|
|
19
|
+
|
|
20
|
+
var _object = require("./object");
|
|
21
|
+
|
|
22
|
+
var _string = require("./string");
|
|
23
|
+
|
|
24
|
+
var _ContextProviders = require("../constants/ContextProviders");
|
|
25
|
+
|
|
26
|
+
var _logger = require("./logger");
|
|
27
|
+
|
|
28
|
+
var Notifications = _interopRequireWildcard(require("../constants/Notifications"));
|
|
29
|
+
|
|
30
|
+
var Theme = _interopRequireWildcard(require("../constants/Theme"));
|
|
31
|
+
|
|
32
|
+
var _Routes = require("../constants/Routes");
|
|
33
|
+
|
|
34
|
+
var Actions = _interopRequireWildcard(require("../constants/Actions"));
|
|
35
|
+
|
|
36
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
37
|
+
|
|
38
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Validate session option
|
|
42
|
+
* @param session
|
|
43
|
+
* @return {}
|
|
44
|
+
*/
|
|
45
|
+
function validateSession(v) {
|
|
46
|
+
const errors = [];
|
|
47
|
+
const warnings = [];
|
|
48
|
+
|
|
49
|
+
if (!v || !(0, _object.isObject)(v)) {
|
|
50
|
+
errors.push(_errors.ValidationError.ERROR_INVALID_SESSION);
|
|
51
|
+
return {
|
|
52
|
+
errors,
|
|
53
|
+
warnings,
|
|
54
|
+
value: v
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const _options = Object.keys(sessionOptions);
|
|
59
|
+
|
|
60
|
+
const value = Object.keys(v).filter(key => _options.includes(key)).reduce((obj, key) => {
|
|
61
|
+
const res = sessionOptions[key].validator(v[key], v);
|
|
62
|
+
res.errors.map(error => errors.push(error));
|
|
63
|
+
res.warnings.map(warning => warnings.push(warning));
|
|
64
|
+
obj[key] = res.value;
|
|
65
|
+
return obj;
|
|
66
|
+
}, {});
|
|
67
|
+
return {
|
|
68
|
+
errors,
|
|
69
|
+
warnings,
|
|
70
|
+
value
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Validate session type
|
|
75
|
+
* @param value
|
|
76
|
+
* @return {}
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
const validateSessionType = (value, session) => {
|
|
81
|
+
const errors = [];
|
|
82
|
+
const warnings = [];
|
|
83
|
+
|
|
84
|
+
if (!session[Session.SESSION_TYPE_OPTION] || !Session.sessionTypes.includes(session[Session.SESSION_TYPE_OPTION])) {
|
|
85
|
+
errors.push(_errors.ValidationError.ERROR_INVALID_SESSION_TYPE);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
errors,
|
|
90
|
+
warnings,
|
|
91
|
+
value
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Validate session client id
|
|
96
|
+
* @param value
|
|
97
|
+
* @return {}
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
exports.validateSessionType = validateSessionType;
|
|
102
|
+
|
|
103
|
+
const validateSessionClientId = (value, session) => {
|
|
104
|
+
const errors = [];
|
|
105
|
+
const warnings = [];
|
|
106
|
+
|
|
107
|
+
if (session[Session.SESSION_TYPE_OPTION] && (session[Session.SESSION_TYPE_OPTION] === Session.OAUTH_SESSION || session[Session.SESSION_TYPE_OPTION] === Session.OAUTH_SESSION)) {
|
|
108
|
+
if (session[Session.SESSION_TYPE_OPTION] === Session.OAUTH_SESSION && (!session[Session.SESSION_CLIENT_ID_OPTION] || !(0, _string.isString)(session[Session.SESSION_CLIENT_ID_OPTION]))) {
|
|
109
|
+
errors.push(_errors.ValidationError.ERROR_INVALID_SESSION_CLIENT_ID);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return {
|
|
114
|
+
errors,
|
|
115
|
+
warnings,
|
|
116
|
+
value
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Validate session auth token
|
|
121
|
+
* @param value
|
|
122
|
+
* @return {}
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
exports.validateSessionClientId = validateSessionClientId;
|
|
127
|
+
|
|
128
|
+
const validateSessionAuthTokenOption = (value, session) => {
|
|
129
|
+
const errors = [];
|
|
130
|
+
const warnings = [];
|
|
131
|
+
|
|
132
|
+
if (session[Session.SESSION_TYPE_OPTION] && (session[Session.SESSION_TYPE_OPTION] === Session.OAUTH_SESSION || session[Session.SESSION_TYPE_OPTION] === Session.JWT_SESSION)) {
|
|
133
|
+
if (session[Session.SESSION_AUTH_TOKEN_OPTION] && !(0, _object.isObject)(session[Session.SESSION_AUTH_TOKEN_OPTION])) {
|
|
134
|
+
errors.push(_errors.ValidationError.ERROR_INVALID_SESSION_AUTH_TOKEN);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return {
|
|
139
|
+
errors,
|
|
140
|
+
warnings,
|
|
141
|
+
value
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Validate handleRefreshToken option
|
|
146
|
+
* @param value
|
|
147
|
+
* @return {}
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
exports.validateSessionAuthTokenOption = validateSessionAuthTokenOption;
|
|
152
|
+
|
|
153
|
+
const validateHandleRefreshToken = (value, session) => {
|
|
154
|
+
const errors = [];
|
|
155
|
+
const warnings = [];
|
|
156
|
+
|
|
157
|
+
if (session[Session.SESSION_TYPE_OPTION] && (session[Session.SESSION_TYPE_OPTION] === Session.OAUTH_SESSION || session[Session.SESSION_TYPE_OPTION] === Session.JWT_SESSION)) {
|
|
158
|
+
if (session.authToken && !session.handleRefreshToken) {
|
|
159
|
+
warnings.push(_errors.ValidationWarnings.WARNING_SESSION_REFRESH_TOKEN_CALLBACK_NOT_FOUND);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (session.handleRefreshToken && !(0, _errors.isFunc)(session.handleRefreshToken)) {
|
|
163
|
+
errors.push(_errors.ValidationError.ERROR_INVALID_SESSION_REFRESH_TOKEN_CALLBACK);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return {
|
|
168
|
+
errors,
|
|
169
|
+
warnings,
|
|
170
|
+
value
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* Validate notifications option
|
|
175
|
+
* @param notifications
|
|
176
|
+
* @return {}
|
|
177
|
+
*/
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
exports.validateHandleRefreshToken = validateHandleRefreshToken;
|
|
181
|
+
|
|
182
|
+
function validateNotifications(v) {
|
|
183
|
+
const errors = [];
|
|
184
|
+
const warnings = [];
|
|
185
|
+
|
|
186
|
+
if (!v || !(0, _object.isObject)(v)) {
|
|
187
|
+
return {
|
|
188
|
+
errors,
|
|
189
|
+
warnings,
|
|
190
|
+
value: Notifications.DEFAULT_NOTIFICATIONS
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const _options = Object.keys(notificationsOptions);
|
|
195
|
+
|
|
196
|
+
const value = Object.keys(v).filter(key => _options.includes(key)).reduce((obj, key) => {
|
|
197
|
+
const res = notificationsOptions[key].validator(v[key], v);
|
|
198
|
+
res.errors.map(error => errors.push(error));
|
|
199
|
+
res.warnings.map(warning => warnings.push(warning));
|
|
200
|
+
obj[key] = res.value;
|
|
201
|
+
return obj;
|
|
202
|
+
}, {});
|
|
203
|
+
return {
|
|
204
|
+
errors,
|
|
205
|
+
warnings,
|
|
206
|
+
value: Object.assign({}, Notifications.DEFAULT_NOTIFICATIONS, v)
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Validate webSocket
|
|
211
|
+
* @param value
|
|
212
|
+
* @param {}
|
|
213
|
+
*/
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
const validateWebSocket = v => {
|
|
217
|
+
const errors = [];
|
|
218
|
+
const warnings = [];
|
|
219
|
+
|
|
220
|
+
if (v && !(0, _object.isObject)(v)) {
|
|
221
|
+
errors.push(_errors.ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET);
|
|
222
|
+
return {
|
|
223
|
+
errors,
|
|
224
|
+
warnings,
|
|
225
|
+
v
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const _options = Object.keys(notificationsWebSocketOptions);
|
|
230
|
+
|
|
231
|
+
const value = Object.keys(v).filter(key => _options.includes(key)).reduce((obj, key) => {
|
|
232
|
+
const res = notificationsWebSocketOptions[key].validator(v[key], v);
|
|
233
|
+
res.errors.map(error => errors.push(error));
|
|
234
|
+
res.warnings.map(warning => warnings.push(warning));
|
|
235
|
+
obj[key] = res.value;
|
|
236
|
+
return obj;
|
|
237
|
+
}, {});
|
|
238
|
+
return {
|
|
239
|
+
errors,
|
|
240
|
+
warnings,
|
|
241
|
+
value
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* Validate default disableToastMessage (webSocket)
|
|
246
|
+
* @param value
|
|
247
|
+
* @param {}
|
|
248
|
+
*/
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
exports.validateWebSocket = validateWebSocket;
|
|
252
|
+
|
|
253
|
+
const validateWebSocketDisableToastMessage = (value, notifications) => {
|
|
254
|
+
const errors = [];
|
|
255
|
+
const warnings = [];
|
|
256
|
+
|
|
257
|
+
if (value) {
|
|
258
|
+
if (!(typeof value === 'boolean')) {
|
|
259
|
+
errors.push(_errors.ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_DISABLE_TOAST_MESSAGE);
|
|
260
|
+
}
|
|
261
|
+
} else {
|
|
262
|
+
return {
|
|
263
|
+
errors,
|
|
264
|
+
warnings,
|
|
265
|
+
value: Notifications.DEFAULT_NOTIFICATIONS[Notifications.NOTIFICATIONS_WEB_SOCKET_OPTION][Notifications.NOTIFICATIONS_DISABLE_TOAST_MESSAGE_OPTION]
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return {
|
|
270
|
+
errors,
|
|
271
|
+
warnings,
|
|
272
|
+
value
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* Validate webPushMessaging
|
|
277
|
+
* @param value
|
|
278
|
+
* @param {}
|
|
279
|
+
*/
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
exports.validateWebSocketDisableToastMessage = validateWebSocketDisableToastMessage;
|
|
283
|
+
|
|
284
|
+
const validateWebPushMessaging = v => {
|
|
285
|
+
const errors = [];
|
|
286
|
+
const warnings = [];
|
|
287
|
+
|
|
288
|
+
if (v && !(0, _object.isObject)(v)) {
|
|
289
|
+
errors.push(_errors.ValidationError.ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING);
|
|
290
|
+
return {
|
|
291
|
+
errors,
|
|
292
|
+
warnings,
|
|
293
|
+
v
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const _options = Object.keys(notificationsWebSPushMessagingOptions);
|
|
298
|
+
|
|
299
|
+
const value = Object.keys(v).filter(key => _options.includes(key)).reduce((obj, key) => {
|
|
300
|
+
const res = notificationsWebSPushMessagingOptions[key].validator(v[key], v);
|
|
301
|
+
res.errors.map(error => errors.push(error));
|
|
302
|
+
res.warnings.map(warning => warnings.push(warning));
|
|
303
|
+
obj[key] = res.value;
|
|
304
|
+
return obj;
|
|
305
|
+
}, {});
|
|
306
|
+
return {
|
|
307
|
+
errors,
|
|
308
|
+
warnings,
|
|
309
|
+
value
|
|
310
|
+
};
|
|
311
|
+
};
|
|
312
|
+
/**
|
|
313
|
+
* Validate default disableToastMessage (webPushMessaging)
|
|
314
|
+
* @param value
|
|
315
|
+
* @param {}
|
|
316
|
+
*/
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
exports.validateWebPushMessaging = validateWebPushMessaging;
|
|
320
|
+
|
|
321
|
+
const validateWebPushMessagingDisableToastMessage = (value, notifications) => {
|
|
322
|
+
const errors = [];
|
|
323
|
+
const warnings = [];
|
|
324
|
+
|
|
325
|
+
if (value !== undefined) {
|
|
326
|
+
if (!(typeof value === 'boolean')) {
|
|
327
|
+
errors.push(_errors.ValidationError.ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING_DISABLE_TOAST_MESSAGE);
|
|
328
|
+
}
|
|
329
|
+
} else {
|
|
330
|
+
return {
|
|
331
|
+
errors,
|
|
332
|
+
warnings,
|
|
333
|
+
value: Notifications.DEFAULT_NOTIFICATIONS[Notifications.NOTIFICATIONS_WEB_PUSH_MESSAGING_OPTION][Notifications.NOTIFICATIONS_DISABLE_TOAST_MESSAGE_OPTION]
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
return {
|
|
338
|
+
errors,
|
|
339
|
+
warnings,
|
|
340
|
+
value
|
|
341
|
+
};
|
|
342
|
+
};
|
|
343
|
+
/**
|
|
344
|
+
* Validate default applicationServerKey (webPushMessaging)
|
|
345
|
+
* @param value
|
|
346
|
+
* @param {}
|
|
347
|
+
*/
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
exports.validateWebPushMessagingDisableToastMessage = validateWebPushMessagingDisableToastMessage;
|
|
351
|
+
|
|
352
|
+
const validateWebPushMessagingApplicationServerKey = (value, notifications) => {
|
|
353
|
+
const errors = [];
|
|
354
|
+
const warnings = [];
|
|
355
|
+
|
|
356
|
+
if (value) {
|
|
357
|
+
if (!(0, _string.isString)(value)) {
|
|
358
|
+
errors.push(_errors.ValidationError.ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING_APPLICATION_SERVER_KEY);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
return {
|
|
363
|
+
errors,
|
|
364
|
+
warnings,
|
|
365
|
+
value
|
|
366
|
+
};
|
|
367
|
+
};
|
|
368
|
+
/**
|
|
369
|
+
* Validate portal option
|
|
370
|
+
* @param portal
|
|
371
|
+
* @return {}
|
|
372
|
+
*/
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
exports.validateWebPushMessagingApplicationServerKey = validateWebPushMessagingApplicationServerKey;
|
|
376
|
+
|
|
377
|
+
const validatePortal = value => {
|
|
378
|
+
const errors = [];
|
|
379
|
+
const warnings = [];
|
|
380
|
+
|
|
381
|
+
if (!value || !(0, _string.isString)(value) || !(0, _url.isValidUrl)(value)) {
|
|
382
|
+
errors.push(_errors.ValidationError.ERROR_INVALID_PORTAL);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
return {
|
|
386
|
+
errors,
|
|
387
|
+
warnings,
|
|
388
|
+
value
|
|
389
|
+
};
|
|
390
|
+
};
|
|
391
|
+
/**
|
|
392
|
+
* Validate default locale
|
|
393
|
+
* @param value
|
|
394
|
+
* @param {}
|
|
395
|
+
*/
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
exports.validatePortal = validatePortal;
|
|
399
|
+
|
|
400
|
+
const validateLocaleDefault = (value, locale) => {
|
|
401
|
+
const errors = [];
|
|
402
|
+
const warnings = [];
|
|
403
|
+
|
|
404
|
+
if (locale.default) {
|
|
405
|
+
if (!(0, _string.isString)(value) || !locale[Locale.LOCALE_MESSAGES_OPTION] && !Locale.LOCALES.includes(value)) {
|
|
406
|
+
errors.push(_errors.ValidationError.ERROR_INVALID_LOCALE);
|
|
407
|
+
}
|
|
408
|
+
} else {
|
|
409
|
+
warnings.push(_errors.ValidationWarnings.WARNING_LOCALE_FALLBACK);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
return {
|
|
413
|
+
errors,
|
|
414
|
+
warnings,
|
|
415
|
+
value
|
|
416
|
+
};
|
|
417
|
+
};
|
|
418
|
+
/**
|
|
419
|
+
* Validate default locale
|
|
420
|
+
* @param value
|
|
421
|
+
* @param {}
|
|
422
|
+
*/
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
exports.validateLocaleDefault = validateLocaleDefault;
|
|
426
|
+
|
|
427
|
+
const validateLocaleMessages = value => {
|
|
428
|
+
const errors = [];
|
|
429
|
+
const warnings = [];
|
|
430
|
+
|
|
431
|
+
if (value.messages && !(0, _object.isObject)(value.messages)) {
|
|
432
|
+
errors.push(_errors.ValidationError.ERROR_INVALID_TRANSLATIONS);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
return {
|
|
436
|
+
errors,
|
|
437
|
+
warnings,
|
|
438
|
+
value
|
|
439
|
+
};
|
|
440
|
+
};
|
|
441
|
+
/**
|
|
442
|
+
* Validate locale option
|
|
443
|
+
* @param locale
|
|
444
|
+
* @return {}
|
|
445
|
+
*/
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
exports.validateLocaleMessages = validateLocaleMessages;
|
|
449
|
+
|
|
450
|
+
const validateLocale = v => {
|
|
451
|
+
const errors = [];
|
|
452
|
+
const warnings = [];
|
|
453
|
+
|
|
454
|
+
if (!v || !(0, _object.isObject)(v) || (0, _object.isObject)(v) && !v.messages && !v.default) {
|
|
455
|
+
warnings.push(_errors.ValidationWarnings.WARNING_LOCALE_FALLBACK);
|
|
456
|
+
return {
|
|
457
|
+
errors,
|
|
458
|
+
warnings,
|
|
459
|
+
v
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
const _options = Object.keys(localeOptions);
|
|
464
|
+
|
|
465
|
+
const value = Object.keys(v).filter(key => _options.includes(key)).reduce((obj, key) => {
|
|
466
|
+
const res = localeOptions[key].validator(v[key], v);
|
|
467
|
+
res.errors.map(error => errors.push(error));
|
|
468
|
+
res.warnings.map(warning => warnings.push(warning));
|
|
469
|
+
obj[key] = res.value;
|
|
470
|
+
return obj;
|
|
471
|
+
}, {});
|
|
472
|
+
return {
|
|
473
|
+
errors,
|
|
474
|
+
warnings,
|
|
475
|
+
value
|
|
476
|
+
};
|
|
477
|
+
};
|
|
478
|
+
/**
|
|
479
|
+
* Validate router option
|
|
480
|
+
* @param router
|
|
481
|
+
* @return {}
|
|
482
|
+
*/
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
exports.validateLocale = validateLocale;
|
|
486
|
+
|
|
487
|
+
const validateRouter = value => {
|
|
488
|
+
const errors = [];
|
|
489
|
+
const warnings = [];
|
|
490
|
+
|
|
491
|
+
if (value) {
|
|
492
|
+
if (!(0, _object.isObject)(value)) {
|
|
493
|
+
errors.push(_errors.ValidationError.ERROR_INVALID_ROUTER);
|
|
494
|
+
} else {
|
|
495
|
+
if (value.routes && !(0, _object.isObject)(value.routes) || value.handleRoute && !(0, _errors.isFunc)(value.handleRoute)) {
|
|
496
|
+
errors.push(_errors.ValidationError.ERROR_INVALID_ROUTER);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
} else {
|
|
500
|
+
warnings.push(_errors.ValidationWarnings.WARNING_ROUTER_FALLBACK);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
return {
|
|
504
|
+
errors,
|
|
505
|
+
warnings,
|
|
506
|
+
value
|
|
507
|
+
};
|
|
508
|
+
};
|
|
509
|
+
/**
|
|
510
|
+
* Validate theme option
|
|
511
|
+
* @param theme
|
|
512
|
+
* @return {}
|
|
513
|
+
*/
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
exports.validateRouter = validateRouter;
|
|
517
|
+
|
|
518
|
+
const validateTheme = value => {
|
|
519
|
+
const errors = [];
|
|
520
|
+
const warnings = [];
|
|
521
|
+
|
|
522
|
+
if (value && !(0, _object.isObject)(value)) {
|
|
523
|
+
errors.push(_errors.ValidationError.ERROR_INVALID_THEME);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
return {
|
|
527
|
+
errors,
|
|
528
|
+
warnings,
|
|
529
|
+
value
|
|
530
|
+
};
|
|
531
|
+
};
|
|
532
|
+
/**
|
|
533
|
+
* Validate handleAnonymousAction option
|
|
534
|
+
* @param handleAnonymousAction
|
|
535
|
+
* @return {}
|
|
536
|
+
*/
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
exports.validateTheme = validateTheme;
|
|
540
|
+
|
|
541
|
+
const validateHandleAnonymousAction = v => {
|
|
542
|
+
const errors = [];
|
|
543
|
+
const warnings = [];
|
|
544
|
+
|
|
545
|
+
if (v) {
|
|
546
|
+
if (!(0, _errors.isFunc)(v)) {
|
|
547
|
+
errors.push(_errors.ValidationError.ERROR_INVALID_HANDLE_ANONYMOUS_ACTION);
|
|
548
|
+
}
|
|
549
|
+
} else {
|
|
550
|
+
warnings.push(_errors.ValidationWarnings.WARNING_HANDLE_ANONYMOUS_ACTION_FALLBACK);
|
|
551
|
+
return {
|
|
552
|
+
errors,
|
|
553
|
+
warnings,
|
|
554
|
+
value: () => {
|
|
555
|
+
_logger.Logger.info(_Errors.SCOPE_SC_CORE, 'Attempting to perform an action that requires a logged user.');
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
return {
|
|
561
|
+
errors,
|
|
562
|
+
warnings,
|
|
563
|
+
value: v
|
|
564
|
+
};
|
|
565
|
+
};
|
|
566
|
+
/**
|
|
567
|
+
* Validate contextProviders option
|
|
568
|
+
* @param contextProviders
|
|
569
|
+
* @return [...contextProviders]
|
|
570
|
+
*/
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
exports.validateHandleAnonymousAction = validateHandleAnonymousAction;
|
|
574
|
+
|
|
575
|
+
const validateContextProviders = value => {
|
|
576
|
+
const errors = [];
|
|
577
|
+
const warnings = [];
|
|
578
|
+
|
|
579
|
+
if (value) {
|
|
580
|
+
if (!Array.isArray(value)) {
|
|
581
|
+
errors.push(_errors.ValidationError.ERROR_INVALID_PROVIDERS);
|
|
582
|
+
} else {
|
|
583
|
+
const _providers = value.filter(c => !_ContextProviders.DEFAULT_CONTEXT_PROVIDERS.includes(c));
|
|
584
|
+
|
|
585
|
+
if (_providers.length > 0) {
|
|
586
|
+
errors.push(_errors.ValidationError.ERROR_INVALID_PROVIDERS);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
} else {
|
|
590
|
+
return {
|
|
591
|
+
errors,
|
|
592
|
+
warnings,
|
|
593
|
+
value: _ContextProviders.DEFAULT_CONTEXT_PROVIDERS
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
return {
|
|
598
|
+
errors,
|
|
599
|
+
warnings,
|
|
600
|
+
value
|
|
601
|
+
};
|
|
602
|
+
};
|
|
603
|
+
/**
|
|
604
|
+
* Components Widget
|
|
605
|
+
*/
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
exports.validateContextProviders = validateContextProviders;
|
|
609
|
+
const PortalOption = {
|
|
610
|
+
name: _Routes.PORTAL_OPTION,
|
|
611
|
+
validator: validatePortal
|
|
612
|
+
};
|
|
613
|
+
const LocaleOption = {
|
|
614
|
+
name: Locale.LOCALE_OPTION,
|
|
615
|
+
validator: validateLocale
|
|
616
|
+
};
|
|
617
|
+
const ThemeOption = {
|
|
618
|
+
name: Theme.THEME_OPTION,
|
|
619
|
+
validator: validateTheme
|
|
620
|
+
};
|
|
621
|
+
const RouterOption = {
|
|
622
|
+
name: _Routes.ROUTER_OPTION,
|
|
623
|
+
validator: validateRouter
|
|
624
|
+
};
|
|
625
|
+
const NotificationsOption = {
|
|
626
|
+
name: Notifications.NOTIFICATIONS_OPTION,
|
|
627
|
+
validator: validateNotifications
|
|
628
|
+
};
|
|
629
|
+
const SessionOption = {
|
|
630
|
+
name: Session.SESSION_OPTION,
|
|
631
|
+
validator: validateSession
|
|
632
|
+
};
|
|
633
|
+
const HandleAnonymousActionOption = {
|
|
634
|
+
name: Actions.HANDLE_ANONYMOUS_ACTION_OPTION,
|
|
635
|
+
validator: validateHandleAnonymousAction
|
|
636
|
+
};
|
|
637
|
+
const ContextProvidersOption = {
|
|
638
|
+
name: _ContextProviders.CONTEXT_PROVIDERS_OPTION,
|
|
639
|
+
validator: validateContextProviders
|
|
640
|
+
};
|
|
641
|
+
/**
|
|
642
|
+
* Session options
|
|
643
|
+
*/
|
|
644
|
+
|
|
645
|
+
const SessionTypeOption = {
|
|
646
|
+
name: Session.SESSION_TYPE_OPTION,
|
|
647
|
+
validator: validateSessionType
|
|
648
|
+
};
|
|
649
|
+
const SessionClientIdOption = {
|
|
650
|
+
name: Session.SESSION_CLIENT_ID_OPTION,
|
|
651
|
+
validator: validateSessionClientId
|
|
652
|
+
};
|
|
653
|
+
const SessionAuthTokenOption = {
|
|
654
|
+
name: Session.SESSION_AUTH_TOKEN_OPTION,
|
|
655
|
+
validator: validateSessionAuthTokenOption
|
|
656
|
+
};
|
|
657
|
+
const SessionHandleRefreshTokenOption = {
|
|
658
|
+
name: Session.SESSION_HANDLE_REFRESH_TOKEN_OPTION,
|
|
659
|
+
validator: validateHandleRefreshToken
|
|
660
|
+
};
|
|
661
|
+
const LocaleDefaultOption = {
|
|
662
|
+
name: Locale.LOCALE_DEFAULT_OPTION,
|
|
663
|
+
validator: validateLocaleDefault
|
|
664
|
+
};
|
|
665
|
+
const LocaleMessagesOption = {
|
|
666
|
+
name: Locale.LOCALE_MESSAGES_OPTION,
|
|
667
|
+
validator: validateLocaleMessages
|
|
668
|
+
};
|
|
669
|
+
const NotificationsWebSocketOption = {
|
|
670
|
+
name: Notifications.NOTIFICATIONS_WEB_SOCKET_OPTION,
|
|
671
|
+
validator: validateWebSocket
|
|
672
|
+
};
|
|
673
|
+
const NotificationsWebPushMessagingOption = {
|
|
674
|
+
name: Notifications.NOTIFICATIONS_WEB_PUSH_MESSAGING_OPTION,
|
|
675
|
+
validator: validateWebPushMessaging
|
|
676
|
+
};
|
|
677
|
+
const NotificationsWebSocketDisableToastMessageOption = {
|
|
678
|
+
name: Notifications.NOTIFICATIONS_DISABLE_TOAST_MESSAGE_OPTION,
|
|
679
|
+
validator: validateWebSocketDisableToastMessage
|
|
680
|
+
};
|
|
681
|
+
const NotificationsWebPushMessagingDisableToastMessageOption = {
|
|
682
|
+
name: Notifications.NOTIFICATIONS_DISABLE_TOAST_MESSAGE_OPTION,
|
|
683
|
+
validator: validateWebPushMessagingDisableToastMessage
|
|
684
|
+
};
|
|
685
|
+
const NotificationsWebPushMessagingApplicationServerKeyOption = {
|
|
686
|
+
name: Notifications.NOTIFICATIONS_APPLICATION_SERVER_KEY_OPTION,
|
|
687
|
+
validator: validateWebPushMessagingApplicationServerKey
|
|
688
|
+
};
|
|
689
|
+
/**
|
|
690
|
+
* Valid options
|
|
691
|
+
* @type {{}}
|
|
692
|
+
*/
|
|
693
|
+
|
|
694
|
+
const settingsOptions = {
|
|
695
|
+
[PortalOption.name]: PortalOption,
|
|
696
|
+
[LocaleOption.name]: LocaleOption,
|
|
697
|
+
[ThemeOption.name]: ThemeOption,
|
|
698
|
+
[NotificationsOption.name]: NotificationsOption,
|
|
699
|
+
[RouterOption.name]: RouterOption,
|
|
700
|
+
[SessionOption.name]: SessionOption,
|
|
701
|
+
[HandleAnonymousActionOption.name]: HandleAnonymousActionOption,
|
|
702
|
+
[ContextProvidersOption.name]: ContextProvidersOption
|
|
703
|
+
};
|
|
704
|
+
exports.settingsOptions = settingsOptions;
|
|
705
|
+
const sessionOptions = {
|
|
706
|
+
[SessionTypeOption.name]: SessionTypeOption,
|
|
707
|
+
[SessionClientIdOption.name]: SessionClientIdOption,
|
|
708
|
+
[SessionAuthTokenOption.name]: SessionAuthTokenOption,
|
|
709
|
+
[SessionHandleRefreshTokenOption.name]: SessionHandleRefreshTokenOption
|
|
710
|
+
};
|
|
711
|
+
exports.sessionOptions = sessionOptions;
|
|
712
|
+
const localeOptions = {
|
|
713
|
+
[LocaleDefaultOption.name]: LocaleDefaultOption,
|
|
714
|
+
[LocaleMessagesOption.name]: LocaleMessagesOption
|
|
715
|
+
};
|
|
716
|
+
exports.localeOptions = localeOptions;
|
|
717
|
+
const notificationsOptions = {
|
|
718
|
+
[NotificationsWebSocketOption.name]: NotificationsWebSocketOption,
|
|
719
|
+
[NotificationsWebPushMessagingOption.name]: NotificationsWebPushMessagingOption
|
|
720
|
+
};
|
|
721
|
+
exports.notificationsOptions = notificationsOptions;
|
|
722
|
+
const notificationsWebSocketOptions = {
|
|
723
|
+
[NotificationsWebSocketDisableToastMessageOption.name]: NotificationsWebSocketDisableToastMessageOption
|
|
724
|
+
};
|
|
725
|
+
exports.notificationsWebSocketOptions = notificationsWebSocketOptions;
|
|
726
|
+
const notificationsWebSPushMessagingOptions = {
|
|
727
|
+
[NotificationsWebPushMessagingDisableToastMessageOption.name]: NotificationsWebPushMessagingDisableToastMessageOption,
|
|
728
|
+
[NotificationsWebPushMessagingApplicationServerKeyOption.name]: NotificationsWebPushMessagingApplicationServerKeyOption
|
|
729
|
+
};
|
|
730
|
+
exports.notificationsWebSPushMessagingOptions = notificationsWebSPushMessagingOptions;
|
|
731
|
+
const validOptions = Object.assign({}, settingsOptions);
|
|
732
|
+
/**
|
|
733
|
+
* Validate all options by type
|
|
734
|
+
* @param options
|
|
735
|
+
* @return {options hydrated}
|
|
736
|
+
*/
|
|
737
|
+
|
|
738
|
+
exports.validOptions = validOptions;
|
|
739
|
+
|
|
740
|
+
const validateOptions = (values, schemaOptions) => {
|
|
741
|
+
const validationResult = new _errors.ValidationResult(_Errors.SCOPE_SC_CORE);
|
|
742
|
+
|
|
743
|
+
if (!values) {
|
|
744
|
+
validationResult.addError(_errors.ValidationError.ERROR_INVALID_CONF, values);
|
|
745
|
+
return {
|
|
746
|
+
validationResult,
|
|
747
|
+
values
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
const _options = Object.keys(schemaOptions);
|
|
752
|
+
|
|
753
|
+
const _data = Object.assign({}, values, Object.keys(schemaOptions).reduce((obj, key) => {
|
|
754
|
+
obj[key] = null;
|
|
755
|
+
return obj;
|
|
756
|
+
}, {}));
|
|
757
|
+
|
|
758
|
+
const settings = Object.keys(_data).filter(key => _options.includes(key)).reduce((obj, key) => {
|
|
759
|
+
const res = schemaOptions[key].validator(values[key]);
|
|
760
|
+
res.errors.map(error => validationResult.addError(error, res.value));
|
|
761
|
+
res.warnings.map(warning => validationResult.addWarnings(warning, res.value));
|
|
762
|
+
obj[key] = res.value;
|
|
763
|
+
return obj;
|
|
764
|
+
}, {});
|
|
765
|
+
return {
|
|
766
|
+
validationResult,
|
|
767
|
+
settings
|
|
768
|
+
};
|
|
769
|
+
};
|
|
770
|
+
|
|
771
|
+
exports.validateOptions = validateOptions;
|