@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.
Files changed (46) hide show
  1. package/lib/cjs/components/provider/SCUserProvider/index.js +4 -4
  2. package/lib/cjs/constants/Cache.d.ts +3 -0
  3. package/lib/cjs/constants/Cache.js +6 -2
  4. package/lib/cjs/constants/Integrations.d.ts +13 -0
  5. package/lib/cjs/constants/Integrations.js +17 -0
  6. package/lib/cjs/constants/Notifications.d.ts +2 -1
  7. package/lib/cjs/constants/Notifications.js +4 -3
  8. package/lib/cjs/constants/Preferences.d.ts +3 -0
  9. package/lib/cjs/constants/Preferences.js +8 -2
  10. package/lib/cjs/constants/Routes.d.ts +4 -0
  11. package/lib/cjs/constants/Routes.js +9 -1
  12. package/lib/cjs/hooks/useSCFetchEvent.d.ts +20 -0
  13. package/lib/cjs/hooks/useSCFetchEvent.js +74 -0
  14. package/lib/cjs/index.d.ts +2 -1
  15. package/lib/cjs/index.js +3 -1
  16. package/lib/cjs/types/context.d.ts +37 -0
  17. package/lib/cjs/utils/errors.d.ts +6 -0
  18. package/lib/cjs/utils/errors.js +12 -0
  19. package/lib/cjs/utils/hooks/useIsomorphicLayoutEffect.js +2 -1
  20. package/lib/cjs/utils/notification.js +1 -1
  21. package/lib/cjs/utils/validator.d.ts +103 -28
  22. package/lib/cjs/utils/validator.js +178 -31
  23. package/lib/esm/components/provider/SCUserProvider/index.js +5 -5
  24. package/lib/esm/constants/Cache.d.ts +3 -0
  25. package/lib/esm/constants/Cache.js +3 -0
  26. package/lib/esm/constants/Integrations.d.ts +13 -0
  27. package/lib/esm/constants/Integrations.js +14 -0
  28. package/lib/esm/constants/Notifications.d.ts +2 -1
  29. package/lib/esm/constants/Notifications.js +3 -2
  30. package/lib/esm/constants/Preferences.d.ts +3 -0
  31. package/lib/esm/constants/Preferences.js +6 -0
  32. package/lib/esm/constants/Routes.d.ts +4 -0
  33. package/lib/esm/constants/Routes.js +8 -0
  34. package/lib/esm/hooks/useSCFetchEvent.d.ts +20 -0
  35. package/lib/esm/hooks/useSCFetchEvent.js +71 -0
  36. package/lib/esm/index.d.ts +2 -1
  37. package/lib/esm/index.js +2 -1
  38. package/lib/esm/types/context.d.ts +37 -0
  39. package/lib/esm/utils/errors.d.ts +6 -0
  40. package/lib/esm/utils/errors.js +12 -0
  41. package/lib/esm/utils/hooks/useIsomorphicLayoutEffect.js +2 -1
  42. package/lib/esm/utils/notification.js +2 -2
  43. package/lib/esm/utils/validator.d.ts +103 -28
  44. package/lib/esm/utils/validator.js +171 -30
  45. package/lib/umd/react-core.js +1 -1
  46. package/package.json +6 -6
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateOptions = exports.validOptions = exports.voteOptions = exports.preferencesOptions = exports.notificationsMobileNativePushMessagingOptions = exports.notificationsWebPushMessagingOptions = exports.notificationsWebSocketOptions = exports.notificationsOptions = exports.localeOptions = exports.sessionOptions = exports.settingsOptions = exports.validateVote = exports.validateReactions = exports.validatePreferences = exports.validateFeatures = exports.validateGlobalPreferences = exports.validateContextProviders = exports.validateHandleAnonymousAction = exports.validateTheme = exports.validateRouter = exports.validateLocale = exports.validateLocaleMessages = exports.validateLocaleDefault = exports.validatePortal = exports.validateMobileNativePushMessagingDisable = exports.validateMobileNativePushMessaging = exports.validateWebPushMessagingApplicationServerKey = exports.validateWebPushMessagingDisableToastMessage = exports.validateWebPushMessaging = exports.validateWebSocketSecure = exports.validateWebSocketDisableToastMessage = exports.validateWebSocket = exports.validateNotifications = exports.validateHandleLogout = exports.validateHandleRefreshToken = exports.validateSessionAuthTokenOption = exports.validateSessionClientId = exports.validateSessionType = exports.validateSession = void 0;
3
+ exports.validateOptions = exports.validOptions = exports.integrationsGeocodingOptions = exports.integrationsOpenAIOptions = exports.integrationsOptions = exports.voteOptions = exports.preferencesOptions = exports.notificationsMobileNativePushMessagingOptions = exports.notificationsWebPushMessagingOptions = exports.notificationsWebSocketOptions = exports.notificationsOptions = exports.localeOptions = exports.sessionOptions = exports.settingsOptions = exports.validateGeocodingApiKey = exports.validateOpenAISecretKey = exports.validateGeocoding = exports.validateOpenAI = exports.validateIntegrations = exports.validateVote = exports.validateReactions = exports.validatePreferences = exports.validateFeatures = exports.validateGlobalPreferences = exports.validateContextProviders = exports.validateHandleAnonymousAction = exports.validateTheme = exports.validateRouter = exports.validateLocale = exports.validateLocaleMessages = exports.validateLocaleDefault = exports.validatePortal = exports.validateMobileNativePushMessagingDisable = exports.validateMobileNativePushMessaging = exports.validateWebPushMessagingApplicationServerKey = exports.validateWebPushMessagingDisableToastMessage = exports.validateWebPushMessaging = exports.validateWebSocketPrefixPath = exports.validateWebSocketSecure = exports.validateWebSocketDisableToastMessage = exports.validateWebSocket = exports.validateNotifications = exports.validateHandleLogout = exports.validateHandleRefreshToken = exports.validateSessionAuthTokenOption = exports.validateSessionClientId = exports.validateSessionType = exports.validateSession = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const Locale = tslib_1.__importStar(require("../constants/Locale"));
6
6
  const utils_1 = require("@selfcommunity/utils");
@@ -15,9 +15,10 @@ const Actions = tslib_1.__importStar(require("../constants/Actions"));
15
15
  const Preferences = tslib_1.__importStar(require("../constants/Preferences"));
16
16
  const Features = tslib_1.__importStar(require("../constants/Features"));
17
17
  const Vote = tslib_1.__importStar(require("../constants/Vote"));
18
+ const Integrations = tslib_1.__importStar(require("../constants/Integrations"));
18
19
  /**
19
20
  * Validate session option
20
- * @param session
21
+ * @param v
21
22
  * @return {}
22
23
  */
23
24
  function validateSession(v) {
@@ -43,6 +44,7 @@ exports.validateSession = validateSession;
43
44
  /**
44
45
  * Validate session type
45
46
  * @param value
47
+ * @param session
46
48
  * @return {}
47
49
  */
48
50
  const validateSessionType = (value, session) => {
@@ -57,6 +59,7 @@ exports.validateSessionType = validateSessionType;
57
59
  /**
58
60
  * Validate session client id
59
61
  * @param value
62
+ * @param session
60
63
  * @return {}
61
64
  */
62
65
  const validateSessionClientId = (value, session) => {
@@ -75,6 +78,7 @@ exports.validateSessionClientId = validateSessionClientId;
75
78
  /**
76
79
  * Validate session auth token
77
80
  * @param value
81
+ * @param session
78
82
  * @return {}
79
83
  */
80
84
  const validateSessionAuthTokenOption = (value, session) => {
@@ -113,6 +117,7 @@ exports.validateHandleRefreshToken = validateHandleRefreshToken;
113
117
  /**
114
118
  * Validate handleLogout option
115
119
  * @param value
120
+ * @param session
116
121
  * @return {}
117
122
  */
118
123
  const validateHandleLogout = (value, session) => {
@@ -126,7 +131,7 @@ const validateHandleLogout = (value, session) => {
126
131
  exports.validateHandleLogout = validateHandleLogout;
127
132
  /**
128
133
  * Validate notifications option
129
- * @param notifications
134
+ * @param v
130
135
  * @return {}
131
136
  */
132
137
  function validateNotifications(v) {
@@ -145,13 +150,12 @@ function validateNotifications(v) {
145
150
  obj[key] = res.value;
146
151
  return obj;
147
152
  }, {});
148
- return { errors, warnings, value: Object.assign(Object.assign({}, Notifications.DEFAULT_NOTIFICATIONS), v) };
153
+ return { errors, warnings, value: Object.assign(Object.assign({}, Notifications.DEFAULT_NOTIFICATIONS), value) };
149
154
  }
150
155
  exports.validateNotifications = validateNotifications;
151
156
  /**
152
157
  * Validate webSocket
153
- * @param value
154
- * @param {}
158
+ * @param v
155
159
  */
156
160
  const validateWebSocket = (v) => {
157
161
  const errors = [];
@@ -176,9 +180,8 @@ exports.validateWebSocket = validateWebSocket;
176
180
  /**
177
181
  * Validate default disableToastMessage (webSocket)
178
182
  * @param value
179
- * @param {}
180
183
  */
181
- const validateWebSocketDisableToastMessage = (value, notifications) => {
184
+ const validateWebSocketDisableToastMessage = (value) => {
182
185
  const errors = [];
183
186
  const warnings = [];
184
187
  if (value) {
@@ -199,9 +202,8 @@ exports.validateWebSocketDisableToastMessage = validateWebSocketDisableToastMess
199
202
  /**
200
203
  * Validate default secure (webSocket)
201
204
  * @param value
202
- * @param {}
203
205
  */
204
- const validateWebSocketSecure = (value, notifications) => {
206
+ const validateWebSocketSecure = (value) => {
205
207
  const errors = [];
206
208
  const warnings = [];
207
209
  if (value) {
@@ -213,16 +215,28 @@ const validateWebSocketSecure = (value, notifications) => {
213
215
  return {
214
216
  errors,
215
217
  warnings,
216
- value: Notifications.DEFAULT_NOTIFICATIONS[Notifications.NOTIFICATIONS_WEB_SOCKET_OPTION][Notifications.NOTIFICATIONS_SECURE_OPTION],
218
+ value: Notifications.DEFAULT_NOTIFICATIONS[Notifications.NOTIFICATIONS_WEB_SOCKET_OPTION][Notifications.NOTIFICATIONS_WEBSOCKET_SECURE_OPTION],
217
219
  };
218
220
  }
219
221
  return { errors, warnings, value };
220
222
  };
221
223
  exports.validateWebSocketSecure = validateWebSocketSecure;
222
224
  /**
223
- * Validate webPushMessaging
225
+ * Validate prefixPath (webSocket)
224
226
  * @param value
225
- * @param {}
227
+ */
228
+ const validateWebSocketPrefixPath = (value) => {
229
+ const errors = [];
230
+ const warnings = [];
231
+ if (!value || !(0, utils_1.isString)(value)) {
232
+ errors.push(errors_1.ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_PREFIX_PATH);
233
+ }
234
+ return { errors, warnings, value };
235
+ };
236
+ exports.validateWebSocketPrefixPath = validateWebSocketPrefixPath;
237
+ /**
238
+ * Validate webPushMessaging
239
+ * @param v
226
240
  */
227
241
  const validateWebPushMessaging = (v) => {
228
242
  const errors = [];
@@ -247,9 +261,8 @@ exports.validateWebPushMessaging = validateWebPushMessaging;
247
261
  /**
248
262
  * Validate default disableToastMessage (webPushMessaging)
249
263
  * @param value
250
- * @param {}
251
264
  */
252
- const validateWebPushMessagingDisableToastMessage = (value, notifications) => {
265
+ const validateWebPushMessagingDisableToastMessage = (value) => {
253
266
  const errors = [];
254
267
  const warnings = [];
255
268
  if (value !== undefined) {
@@ -270,9 +283,8 @@ exports.validateWebPushMessagingDisableToastMessage = validateWebPushMessagingDi
270
283
  /**
271
284
  * Validate default applicationServerKey (webPushMessaging)
272
285
  * @param value
273
- * @param {}
274
286
  */
275
- const validateWebPushMessagingApplicationServerKey = (value, notifications) => {
287
+ const validateWebPushMessagingApplicationServerKey = (value) => {
276
288
  const errors = [];
277
289
  const warnings = [];
278
290
  if (value) {
@@ -285,8 +297,7 @@ const validateWebPushMessagingApplicationServerKey = (value, notifications) => {
285
297
  exports.validateWebPushMessagingApplicationServerKey = validateWebPushMessagingApplicationServerKey;
286
298
  /**
287
299
  * Validate mobile native
288
- * @param value
289
- * @param {}
300
+ * @param v
290
301
  */
291
302
  const validateMobileNativePushMessaging = (v) => {
292
303
  const errors = [];
@@ -311,9 +322,8 @@ exports.validateMobileNativePushMessaging = validateMobileNativePushMessaging;
311
322
  /**
312
323
  * Validate default disable (mobileNativePushMessaging)
313
324
  * @param value
314
- * @param {}
315
325
  */
316
- const validateMobileNativePushMessagingDisable = (value, notifications) => {
326
+ const validateMobileNativePushMessagingDisable = (value) => {
317
327
  const errors = [];
318
328
  const warnings = [];
319
329
  if (value !== undefined) {
@@ -333,7 +343,7 @@ const validateMobileNativePushMessagingDisable = (value, notifications) => {
333
343
  exports.validateMobileNativePushMessagingDisable = validateMobileNativePushMessagingDisable;
334
344
  /**
335
345
  * Validate portal option
336
- * @param portal
346
+ * @param value
337
347
  * @return {}
338
348
  */
339
349
  const validatePortal = (value) => {
@@ -348,7 +358,7 @@ exports.validatePortal = validatePortal;
348
358
  /**
349
359
  * Validate default locale
350
360
  * @param value
351
- * @param {}
361
+ * @param locale
352
362
  */
353
363
  const validateLocaleDefault = (value, locale) => {
354
364
  const errors = [];
@@ -367,7 +377,6 @@ exports.validateLocaleDefault = validateLocaleDefault;
367
377
  /**
368
378
  * Validate default locale
369
379
  * @param value
370
- * @param {}
371
380
  */
372
381
  const validateLocaleMessages = (value) => {
373
382
  const errors = [];
@@ -380,7 +389,7 @@ const validateLocaleMessages = (value) => {
380
389
  exports.validateLocaleMessages = validateLocaleMessages;
381
390
  /**
382
391
  * Validate locale option
383
- * @param locale
392
+ * @param v
384
393
  * @return {}
385
394
  */
386
395
  const validateLocale = (v) => {
@@ -405,7 +414,7 @@ const validateLocale = (v) => {
405
414
  exports.validateLocale = validateLocale;
406
415
  /**
407
416
  * Validate router option
408
- * @param router
417
+ * @param value
409
418
  * @return {}
410
419
  */
411
420
  const validateRouter = (value) => {
@@ -429,7 +438,7 @@ const validateRouter = (value) => {
429
438
  exports.validateRouter = validateRouter;
430
439
  /**
431
440
  * Validate theme option
432
- * @param theme
441
+ * @param value
433
442
  * @return {}
434
443
  */
435
444
  const validateTheme = (value) => {
@@ -443,7 +452,7 @@ const validateTheme = (value) => {
443
452
  exports.validateTheme = validateTheme;
444
453
  /**
445
454
  * Validate handleAnonymousAction option
446
- * @param handleAnonymousAction
455
+ * @param v
447
456
  * @return {}
448
457
  */
449
458
  const validateHandleAnonymousAction = (v) => {
@@ -469,7 +478,7 @@ const validateHandleAnonymousAction = (v) => {
469
478
  exports.validateHandleAnonymousAction = validateHandleAnonymousAction;
470
479
  /**
471
480
  * Validate contextProviders option
472
- * @param contextProviders
481
+ * @param value
473
482
  * @return [...contextProviders]
474
483
  */
475
484
  const validateContextProviders = (value) => {
@@ -617,6 +626,107 @@ function validateVote(v) {
617
626
  return { errors, warnings, value: defaultValue };
618
627
  }
619
628
  exports.validateVote = validateVote;
629
+ /**
630
+ * Validate integrations option
631
+ * @param v
632
+ * @return {}
633
+ */
634
+ function validateIntegrations(v) {
635
+ const errors = [];
636
+ const warnings = [];
637
+ if (!v || !(0, utils_1.isObject)(v)) {
638
+ return { errors, warnings, value: Integrations.DEFAULT_INTEGRATIONS_OPTION };
639
+ }
640
+ const _options = Object.keys(exports.integrationsOptions);
641
+ const value = Object.keys(v)
642
+ .filter((key) => _options.includes(key))
643
+ .reduce((obj, key) => {
644
+ const res = exports.integrationsOptions[key].validator(v[key], v);
645
+ res.errors.map((error) => errors.push(error));
646
+ res.warnings.map((warning) => warnings.push(warning));
647
+ obj[key] = res.value;
648
+ return obj;
649
+ }, {});
650
+ return { errors, warnings, value: Object.assign(Object.assign({}, Integrations.DEFAULT_INTEGRATIONS_OPTION), value) };
651
+ }
652
+ exports.validateIntegrations = validateIntegrations;
653
+ /**
654
+ * Validate OpenAI Option
655
+ * @param v
656
+ */
657
+ const validateOpenAI = (v) => {
658
+ const errors = [];
659
+ const warnings = [];
660
+ if (v && !(0, utils_1.isObject)(v)) {
661
+ errors.push(errors_1.ValidationError.ERROR_INVALID_INTEGRATIONS_OPENAI);
662
+ return { errors, warnings, v };
663
+ }
664
+ const _options = Object.keys(exports.integrationsOpenAIOptions);
665
+ const value = Object.keys(v)
666
+ .filter((key) => _options.includes(key))
667
+ .reduce((obj, key) => {
668
+ const res = exports.integrationsOpenAIOptions[key].validator(v[key], v);
669
+ res.errors.map((error) => errors.push(error));
670
+ res.warnings.map((warning) => warnings.push(warning));
671
+ obj[key] = res.value;
672
+ return obj;
673
+ }, {});
674
+ return { errors, warnings, value };
675
+ };
676
+ exports.validateOpenAI = validateOpenAI;
677
+ /**
678
+ * Validate Geocoding Option
679
+ * @param v
680
+ */
681
+ const validateGeocoding = (v) => {
682
+ //console.log(v);
683
+ const errors = [];
684
+ const warnings = [];
685
+ if (v && !(0, utils_1.isObject)(v)) {
686
+ errors.push(errors_1.ValidationError.ERROR_INVALID_INTEGRATIONS_GEOCODING);
687
+ return { errors, warnings, v };
688
+ }
689
+ const _options = Object.keys(exports.integrationsGeocodingOptions);
690
+ const value = Object.keys(v)
691
+ .filter((key) => _options.includes(key))
692
+ .reduce((obj, key) => {
693
+ const res = exports.integrationsGeocodingOptions[key].validator(v[key], v);
694
+ res.errors.map((error) => errors.push(error));
695
+ res.warnings.map((warning) => warnings.push(warning));
696
+ obj[key] = res.value;
697
+ return obj;
698
+ }, {});
699
+ return { errors, warnings, value };
700
+ };
701
+ exports.validateGeocoding = validateGeocoding;
702
+ /**
703
+ * Validate OpenAI secret key option
704
+ * @param value
705
+ * @return {}
706
+ */
707
+ const validateOpenAISecretKey = (value) => {
708
+ const errors = [];
709
+ const warnings = [];
710
+ if (!value || !(0, utils_1.isString)(value)) {
711
+ errors.push(errors_1.ValidationError.ERROR_INVALID_INTEGRATIONS_OPENAI_SECRETKEY);
712
+ }
713
+ return { errors, warnings, value };
714
+ };
715
+ exports.validateOpenAISecretKey = validateOpenAISecretKey;
716
+ /**
717
+ * Validate Geocoding api key option
718
+ * @param value
719
+ * @return {}
720
+ */
721
+ const validateGeocodingApiKey = (value) => {
722
+ const errors = [];
723
+ const warnings = [];
724
+ if (!value || !(0, utils_1.isString)(value)) {
725
+ errors.push(errors_1.ValidationError.ERROR_INVALID_INTEGRATIONS_GEOCODING_APIKEY);
726
+ }
727
+ return { errors, warnings, value };
728
+ };
729
+ exports.validateGeocodingApiKey = validateGeocodingApiKey;
620
730
  /**
621
731
  * Components Widget
622
732
  */
@@ -660,6 +770,10 @@ const VoteOption = {
660
770
  name: Vote.VOTE_OPTION,
661
771
  validator: validateVote,
662
772
  };
773
+ const IntegrationsOption = {
774
+ name: Integrations.INTEGRATIONS_OPTION,
775
+ validator: validateIntegrations,
776
+ };
663
777
  /**
664
778
  * Session options
665
779
  */
@@ -716,9 +830,13 @@ const NotificationsWebSocketDisableToastMessageOption = {
716
830
  validator: exports.validateWebSocketDisableToastMessage,
717
831
  };
718
832
  const NotificationsWebSocketSecureOption = {
719
- name: Notifications.NOTIFICATIONS_SECURE_OPTION,
833
+ name: Notifications.NOTIFICATIONS_WEBSOCKET_SECURE_OPTION,
720
834
  validator: exports.validateWebSocketSecure,
721
835
  };
836
+ const NotificationsWebSocketPrefixPathOption = {
837
+ name: Notifications.NOTIFICATIONS_WEBSOCKET_PREFIX_PATH_OPTION,
838
+ validator: exports.validateWebSocketPrefixPath,
839
+ };
722
840
  const NotificationsWebPushMessagingDisableToastMessageOption = {
723
841
  name: Notifications.NOTIFICATIONS_DISABLE_TOAST_MESSAGE_OPTION,
724
842
  validator: exports.validateWebPushMessagingDisableToastMessage,
@@ -735,6 +853,22 @@ const ReactionsOption = {
735
853
  name: Vote.VOTE_REACTIONS_OPTION,
736
854
  validator: exports.validateReactions,
737
855
  };
856
+ const IntegrationOpenAIOption = {
857
+ name: Integrations.INTEGRATIONS_OPENAI_OPTION,
858
+ validator: exports.validateOpenAI,
859
+ };
860
+ const IntegrationOpenAISecretKeyOption = {
861
+ name: Integrations.INTEGRATIONS_OPENAI_SECRETKEY_OPTION,
862
+ validator: exports.validateOpenAISecretKey,
863
+ };
864
+ const IntegrationGeocodingOption = {
865
+ name: Integrations.INTEGRATIONS_GEOCODING_OPTION,
866
+ validator: exports.validateGeocoding,
867
+ };
868
+ const IntegrationGeocodingApiKeyOption = {
869
+ name: Integrations.INTEGRATIONS_GEOCODING_APIKEY_OPTION,
870
+ validator: exports.validateGeocodingApiKey,
871
+ };
738
872
  /**
739
873
  * Valid options
740
874
  * @type {{}}
@@ -750,6 +884,7 @@ exports.settingsOptions = {
750
884
  [ContextProvidersOption.name]: ContextProvidersOption,
751
885
  [PreferencesOption.name]: PreferencesOption,
752
886
  [VoteOption.name]: VoteOption,
887
+ [IntegrationsOption.name]: IntegrationsOption,
753
888
  };
754
889
  exports.sessionOptions = {
755
890
  [SessionTypeOption.name]: SessionTypeOption,
@@ -770,6 +905,7 @@ exports.notificationsOptions = {
770
905
  exports.notificationsWebSocketOptions = {
771
906
  [NotificationsWebSocketDisableToastMessageOption.name]: NotificationsWebSocketDisableToastMessageOption,
772
907
  [NotificationsWebSocketSecureOption.name]: NotificationsWebSocketSecureOption,
908
+ [NotificationsWebSocketPrefixPathOption.name]: NotificationsWebSocketPrefixPathOption,
773
909
  };
774
910
  exports.notificationsWebPushMessagingOptions = {
775
911
  [NotificationsWebPushMessagingDisableToastMessageOption.name]: NotificationsWebPushMessagingDisableToastMessageOption,
@@ -785,10 +921,21 @@ exports.preferencesOptions = {
785
921
  exports.voteOptions = {
786
922
  [ReactionsOption.name]: ReactionsOption,
787
923
  };
924
+ exports.integrationsOptions = {
925
+ [IntegrationOpenAIOption.name]: IntegrationOpenAIOption,
926
+ [IntegrationGeocodingOption.name]: IntegrationGeocodingOption,
927
+ };
928
+ exports.integrationsOpenAIOptions = {
929
+ [IntegrationOpenAISecretKeyOption.name]: IntegrationOpenAISecretKeyOption,
930
+ };
931
+ exports.integrationsGeocodingOptions = {
932
+ [IntegrationGeocodingApiKeyOption.name]: IntegrationGeocodingApiKeyOption,
933
+ };
788
934
  exports.validOptions = Object.assign({}, exports.settingsOptions);
789
935
  /**
790
936
  * Validate all options by type
791
- * @param options
937
+ * @param values
938
+ * @param schemaOptions
792
939
  * @return {options hydrated}
793
940
  */
794
941
  const validateOptions = (values, schemaOptions) => {
@@ -2,7 +2,7 @@ import React, { createContext, useContext, useEffect, useMemo, useRef } from 're
2
2
  import { UserService } from '@selfcommunity/api-services';
3
3
  import { SCContext } from '../SCContextProvider';
4
4
  import useSCAuth, { userActionTypes } from '../../../hooks/useSCAuth';
5
- import { isClientSideRendering, Logger } from '@selfcommunity/utils';
5
+ import { Logger } from '@selfcommunity/utils';
6
6
  import PubSub from 'pubsub-js';
7
7
  import { SCOPE_SC_CORE } from '../../../constants/Errors';
8
8
  import { useDeepCompareEffectNoCheck } from 'use-deep-compare-effect';
@@ -100,17 +100,17 @@ export default function SCUserProvider({ children }) {
100
100
  * and document is in foreground refresh the cache
101
101
  */
102
102
  useEffect(() => {
103
- typeof window !== 'undefined' && window.document.addEventListener('visibilitychange', handleVisibilityChange);
103
+ window.document.addEventListener('visibilitychange', handleVisibilityChange);
104
104
  return () => {
105
- typeof window !== 'undefined' && window.document.removeEventListener('visibilitychange', handleVisibilityChange);
105
+ window.document.removeEventListener('visibilitychange', handleVisibilityChange);
106
106
  };
107
- });
107
+ }, []);
108
108
  /**
109
109
  * handler handleVisibilityChange for this provider
110
110
  * Refresh followed categories, users, etc..
111
111
  */
112
112
  function handleVisibilityChange() {
113
- if (isClientSideRendering() && !window.document.hidden && state.user) {
113
+ if (!window.document.hidden && state.user) {
114
114
  settingsManager.refresh && settingsManager.refresh();
115
115
  refreshCounters();
116
116
  categoriesManager.refresh && categoriesManager.refresh();
@@ -17,6 +17,9 @@ export declare const getCategoriesObjectCacheKey: () => string;
17
17
  /** CATEGORY OBJECT **/
18
18
  export declare const CATEGORY_OBJECT_CACHE_PREFIX_KEY = "_ca_";
19
19
  export declare const getCategoryObjectCacheKey: (id: any) => string;
20
+ /** EVENT OBJECT **/
21
+ export declare const EVENT_OBJECT_CACHE_PREFIX_KEY = "_evt_";
22
+ export declare const getEventObjectCacheKey: (id: any) => string;
20
23
  /** GROUP OBJECT **/
21
24
  export declare const GROUP_OBJECT_CACHE_PREFIX_KEY = "_grp_";
22
25
  export declare const getGroupObjectCacheKey: (id: any) => string;
@@ -17,6 +17,9 @@ export const getCategoriesObjectCacheKey = () => `${CATEGORIES_OBJECT_CACHE_PREF
17
17
  /** CATEGORY OBJECT **/
18
18
  export const CATEGORY_OBJECT_CACHE_PREFIX_KEY = '_ca_';
19
19
  export const getCategoryObjectCacheKey = (id) => `${CATEGORY_OBJECT_CACHE_PREFIX_KEY}${id}`;
20
+ /** EVENT OBJECT **/
21
+ export const EVENT_OBJECT_CACHE_PREFIX_KEY = '_evt_';
22
+ export const getEventObjectCacheKey = (id) => `${EVENT_OBJECT_CACHE_PREFIX_KEY}${id}`;
20
23
  /** GROUP OBJECT **/
21
24
  export const GROUP_OBJECT_CACHE_PREFIX_KEY = '_grp_';
22
25
  export const getGroupObjectCacheKey = (id) => `${GROUP_OBJECT_CACHE_PREFIX_KEY}${id}`;
@@ -0,0 +1,13 @@
1
+ export declare const INTEGRATIONS_OPTION = "integrations";
2
+ export declare const INTEGRATIONS_OPENAI_OPTION = "openai";
3
+ export declare const INTEGRATIONS_OPENAI_SECRETKEY_OPTION = "secretKey";
4
+ export declare const INTEGRATIONS_GEOCODING_OPTION = "geocoding";
5
+ export declare const INTEGRATIONS_GEOCODING_APIKEY_OPTION = "apiKey";
6
+ export declare const DEFAULT_INTEGRATIONS_OPTION: {
7
+ openai: {
8
+ secretKey: any;
9
+ };
10
+ geocoding: {
11
+ apiKey: any;
12
+ };
13
+ };
@@ -0,0 +1,14 @@
1
+ // integrations
2
+ export const INTEGRATIONS_OPTION = 'integrations';
3
+ export const INTEGRATIONS_OPENAI_OPTION = 'openai';
4
+ export const INTEGRATIONS_OPENAI_SECRETKEY_OPTION = 'secretKey';
5
+ export const INTEGRATIONS_GEOCODING_OPTION = 'geocoding';
6
+ export const INTEGRATIONS_GEOCODING_APIKEY_OPTION = 'apiKey';
7
+ export const DEFAULT_INTEGRATIONS_OPTION = {
8
+ [INTEGRATIONS_OPENAI_OPTION]: {
9
+ [INTEGRATIONS_OPENAI_SECRETKEY_OPTION]: null,
10
+ },
11
+ [INTEGRATIONS_GEOCODING_OPTION]: {
12
+ [INTEGRATIONS_GEOCODING_APIKEY_OPTION]: null,
13
+ },
14
+ };
@@ -9,6 +9,7 @@ export declare const NOTIFICATIONS_MOBILE_NATIVE_PUSH_MESSAGING_OPTION = "mobile
9
9
  export declare const NOTIFICATIONS_WEB_PUSH_MESSAGING_DIALOG_COOKIE = "wpnDialogDisabled";
10
10
  export declare const NOTIFICATIONS_DISABLE_TOAST_MESSAGE_OPTION = "disableToastMessage";
11
11
  export declare const NOTIFICATIONS_MOBILE_NATIVE_DISABLE_OPTION = "disable";
12
- export declare const NOTIFICATIONS_SECURE_OPTION = "secure";
12
+ export declare const NOTIFICATIONS_WEBSOCKET_SECURE_OPTION = "secure";
13
+ export declare const NOTIFICATIONS_WEBSOCKET_PREFIX_PATH_OPTION = "prefixPath";
13
14
  export declare const NOTIFICATIONS_APPLICATION_SERVER_KEY_OPTION = "applicationServerKey";
14
15
  export declare const DEFAULT_NOTIFICATIONS: SCNotificationsType;
@@ -5,12 +5,13 @@ export const NOTIFICATIONS_MOBILE_NATIVE_PUSH_MESSAGING_OPTION = 'mobileNativePu
5
5
  export const NOTIFICATIONS_WEB_PUSH_MESSAGING_DIALOG_COOKIE = 'wpnDialogDisabled';
6
6
  export const NOTIFICATIONS_DISABLE_TOAST_MESSAGE_OPTION = 'disableToastMessage';
7
7
  export const NOTIFICATIONS_MOBILE_NATIVE_DISABLE_OPTION = 'disable';
8
- export const NOTIFICATIONS_SECURE_OPTION = 'secure';
8
+ export const NOTIFICATIONS_WEBSOCKET_SECURE_OPTION = 'secure';
9
+ export const NOTIFICATIONS_WEBSOCKET_PREFIX_PATH_OPTION = 'prefixPath';
9
10
  export const NOTIFICATIONS_APPLICATION_SERVER_KEY_OPTION = 'applicationServerKey';
10
11
  export const DEFAULT_NOTIFICATIONS = {
11
12
  [NOTIFICATIONS_WEB_SOCKET_OPTION]: {
12
13
  [NOTIFICATIONS_DISABLE_TOAST_MESSAGE_OPTION]: false,
13
- [NOTIFICATIONS_SECURE_OPTION]: true,
14
+ [NOTIFICATIONS_WEBSOCKET_SECURE_OPTION]: true,
14
15
  },
15
16
  [NOTIFICATIONS_WEB_PUSH_MESSAGING_OPTION]: {
16
17
  [NOTIFICATIONS_DISABLE_TOAST_MESSAGE_OPTION]: true,
@@ -129,6 +129,9 @@ export declare const CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_IMAGE: string;
129
129
  export declare const CONFIGURATIONS_GROUPS_ONLY_STAFF_ENABLED: string;
130
130
  export declare const CONFIGURATIONS_GROUPS_VISIBILITY_ENABLED: string;
131
131
  export declare const CONFIGURATIONS_GROUPS_PRIVATE_ENABLED: string;
132
+ export declare const CONFIGURATIONS_EVENTS_ONLY_STAFF_ENABLED: string;
133
+ export declare const CONFIGURATIONS_EVENTS_VISIBILITY_ENABLED: string;
134
+ export declare const CONFIGURATIONS_EVENTS_PRIVATE_ENABLED: string;
132
135
  /**
133
136
  * PROVIDERS
134
137
  */
@@ -130,6 +130,9 @@ export const CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_IMAGE = `${SCPreferenceSection.CO
130
130
  export const CONFIGURATIONS_GROUPS_ONLY_STAFF_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.GROUPS_ONLY_STAFF_ENABLED}`;
131
131
  export const CONFIGURATIONS_GROUPS_VISIBILITY_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.GROUPS_VISIBILITY_ENABLED}`;
132
132
  export const CONFIGURATIONS_GROUPS_PRIVATE_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.GROUPS_PRIVATE_ENABLED}`;
133
+ export const CONFIGURATIONS_EVENTS_ONLY_STAFF_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.EVENTS_ONLY_STAFF_ENABLED}`;
134
+ export const CONFIGURATIONS_EVENTS_VISIBILITY_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.EVENTS_VISIBILITY_ENABLED}`;
135
+ export const CONFIGURATIONS_EVENTS_PRIVATE_ENABLED = `${SCPreferenceSection.CONFIGURATIONS}.${SCPreferenceName.EVENTS_PRIVATE_ENABLED}`;
133
136
  /**
134
137
  * PROVIDERS
135
138
  */
@@ -266,6 +269,9 @@ export const DATA_TYPES = {
266
269
  [CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_TEXT]: stringType,
267
270
  [CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_URL]: stringType,
268
271
  [CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_IMAGE]: stringType,
272
+ [CONFIGURATIONS_EVENTS_ONLY_STAFF_ENABLED]: booleanType,
273
+ [CONFIGURATIONS_EVENTS_VISIBILITY_ENABLED]: booleanType,
274
+ [CONFIGURATIONS_EVENTS_PRIVATE_ENABLED]: booleanType,
269
275
  [CONFIGURATIONS_GROUPS_ONLY_STAFF_ENABLED]: booleanType,
270
276
  [CONFIGURATIONS_GROUPS_VISIBILITY_ENABLED]: booleanType,
271
277
  [CONFIGURATIONS_GROUPS_PRIVATE_ENABLED]: booleanType,
@@ -36,6 +36,10 @@ export declare const GROUP_MEMBERS_ROUTE_NAME = "group_members";
36
36
  export declare const GROUP_MESSAGES_ROUTE_NAME = "group_messages";
37
37
  export declare const GROUPS_ROUTE_NAME = "groups";
38
38
  export declare const GROUPS_SUBSCRIBED_ROUTE_NAME = "groups_subscribed";
39
+ export declare const EVENT_ROUTE_NAME = "event";
40
+ export declare const EVENTS_ROUTE_NAME = "events";
41
+ export declare const EVENTS_SUBSCRIBED_ROUTE_NAME = "events_subscribed";
42
+ export declare const EVENTS_HIGHLIGHT_ROUTE_NAME = "events_highlight";
39
43
  /**
40
44
  * Default Routes
41
45
  * @type {{[p: string]: string, '[POST_ROUTE_NAME]': string, '[INCUBATOR_ROUTE_NAME]': string, '[LOYALTY_ROUTE_NAME]': string, '[USER_NOTIFICATION_ROUTE_NAME]': string, '[USER_PRIVATE_MESSAGES_ROUTE_NAME]': string, '[COMMENT_ROUTE_NAME]': string, '[DISCUSSION_ROUTE_NAME]': string, '[CATEGORIES_ROUTE_NAME]': string, '[USER_PROFILE_ROUTE_NAME]': string, '[CATEGORY_ROUTE_NAME]': string, '[USER_PROFILE_SETTINGS_ROUTE_NAME]': string, '[STATUS_ROUTE_NAME]': string}}
@@ -36,6 +36,10 @@ export const GROUP_MEMBERS_ROUTE_NAME = 'group_members';
36
36
  export const GROUP_MESSAGES_ROUTE_NAME = 'group_messages';
37
37
  export const GROUPS_ROUTE_NAME = 'groups';
38
38
  export const GROUPS_SUBSCRIBED_ROUTE_NAME = 'groups_subscribed';
39
+ export const EVENT_ROUTE_NAME = 'event';
40
+ export const EVENTS_ROUTE_NAME = 'events';
41
+ export const EVENTS_SUBSCRIBED_ROUTE_NAME = 'events_subscribed';
42
+ export const EVENTS_HIGHLIGHT_ROUTE_NAME = 'events_highlight';
39
43
  /**
40
44
  * Default Routes
41
45
  * @type {{[p: string]: string, '[POST_ROUTE_NAME]': string, '[INCUBATOR_ROUTE_NAME]': string, '[LOYALTY_ROUTE_NAME]': string, '[USER_NOTIFICATION_ROUTE_NAME]': string, '[USER_PRIVATE_MESSAGES_ROUTE_NAME]': string, '[COMMENT_ROUTE_NAME]': string, '[DISCUSSION_ROUTE_NAME]': string, '[CATEGORIES_ROUTE_NAME]': string, '[USER_PROFILE_ROUTE_NAME]': string, '[CATEGORY_ROUTE_NAME]': string, '[USER_PROFILE_SETTINGS_ROUTE_NAME]': string, '[STATUS_ROUTE_NAME]': string}}
@@ -74,4 +78,8 @@ export const defaultRoutes = {
74
78
  [GROUP_MESSAGES_ROUTE_NAME]: '/group/:id/:slug/messages/',
75
79
  [GROUPS_ROUTE_NAME]: '/groups/',
76
80
  [GROUPS_SUBSCRIBED_ROUTE_NAME]: '/groups/subscribed/',
81
+ [EVENTS_ROUTE_NAME]: '/events/',
82
+ [EVENT_ROUTE_NAME]: '/event/:id/:slug/',
83
+ [EVENTS_SUBSCRIBED_ROUTE_NAME]: '/events/subscribed/',
84
+ [EVENTS_HIGHLIGHT_ROUTE_NAME]: '/events/highlight/',
77
85
  };
@@ -0,0 +1,20 @@
1
+ import { SCEventType } from '@selfcommunity/types';
2
+ import { CacheStrategies } from '@selfcommunity/utils';
3
+ /**
4
+ :::info
5
+ This custom hook is used to fetch an event object.
6
+ :::
7
+ * @param object
8
+ * @param object.id
9
+ * @param object.event
10
+ * @param object.cacheStrategy
11
+ */
12
+ export default function useSCFetchEvent({ id, event, cacheStrategy, }: {
13
+ id?: number | string;
14
+ event?: SCEventType;
15
+ cacheStrategy?: CacheStrategies;
16
+ }): {
17
+ scEvent: SCEventType;
18
+ setSCEvent: (event: SCEventType) => void;
19
+ error: string;
20
+ };