@selfcommunity/react-core 0.4.50 → 0.4.51-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/lib/cjs/components/provider/SCUserProvider/index.js +4 -4
- package/lib/cjs/constants/Integrations.d.ts +8 -0
- package/lib/cjs/constants/Integrations.js +12 -0
- package/lib/cjs/types/context.d.ts +19 -0
- package/lib/cjs/utils/errors.d.ts +3 -0
- package/lib/cjs/utils/errors.js +6 -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 +65 -28
- package/lib/cjs/utils/validator.js +108 -29
- package/lib/esm/components/provider/SCUserProvider/index.js +5 -5
- package/lib/esm/constants/Integrations.d.ts +8 -0
- package/lib/esm/constants/Integrations.js +9 -0
- package/lib/esm/types/context.d.ts +19 -0
- package/lib/esm/utils/errors.d.ts +3 -0
- package/lib/esm/utils/errors.js +6 -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 +65 -28
- package/lib/esm/utils/validator.js +104 -28
- package/lib/umd/react-core.js +1 -1
- 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.integrationsOpenAIOptions = exports.integrationsOptions = exports.voteOptions = exports.preferencesOptions = exports.notificationsMobileNativePushMessagingOptions = exports.notificationsWebPushMessagingOptions = exports.notificationsWebSocketOptions = exports.notificationsOptions = exports.localeOptions = exports.sessionOptions = exports.settingsOptions = exports.validateOpenAISecretKey = 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.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
|
|
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
|
|
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),
|
|
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
|
|
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
|
|
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
|
|
206
|
+
const validateWebSocketSecure = (value) => {
|
|
205
207
|
const errors = [];
|
|
206
208
|
const warnings = [];
|
|
207
209
|
if (value) {
|
|
@@ -221,8 +223,7 @@ const validateWebSocketSecure = (value, notifications) => {
|
|
|
221
223
|
exports.validateWebSocketSecure = validateWebSocketSecure;
|
|
222
224
|
/**
|
|
223
225
|
* Validate webPushMessaging
|
|
224
|
-
* @param
|
|
225
|
-
* @param {}
|
|
226
|
+
* @param v
|
|
226
227
|
*/
|
|
227
228
|
const validateWebPushMessaging = (v) => {
|
|
228
229
|
const errors = [];
|
|
@@ -247,9 +248,8 @@ exports.validateWebPushMessaging = validateWebPushMessaging;
|
|
|
247
248
|
/**
|
|
248
249
|
* Validate default disableToastMessage (webPushMessaging)
|
|
249
250
|
* @param value
|
|
250
|
-
* @param {}
|
|
251
251
|
*/
|
|
252
|
-
const validateWebPushMessagingDisableToastMessage = (value
|
|
252
|
+
const validateWebPushMessagingDisableToastMessage = (value) => {
|
|
253
253
|
const errors = [];
|
|
254
254
|
const warnings = [];
|
|
255
255
|
if (value !== undefined) {
|
|
@@ -270,9 +270,8 @@ exports.validateWebPushMessagingDisableToastMessage = validateWebPushMessagingDi
|
|
|
270
270
|
/**
|
|
271
271
|
* Validate default applicationServerKey (webPushMessaging)
|
|
272
272
|
* @param value
|
|
273
|
-
* @param {}
|
|
274
273
|
*/
|
|
275
|
-
const validateWebPushMessagingApplicationServerKey = (value
|
|
274
|
+
const validateWebPushMessagingApplicationServerKey = (value) => {
|
|
276
275
|
const errors = [];
|
|
277
276
|
const warnings = [];
|
|
278
277
|
if (value) {
|
|
@@ -285,8 +284,7 @@ const validateWebPushMessagingApplicationServerKey = (value, notifications) => {
|
|
|
285
284
|
exports.validateWebPushMessagingApplicationServerKey = validateWebPushMessagingApplicationServerKey;
|
|
286
285
|
/**
|
|
287
286
|
* Validate mobile native
|
|
288
|
-
* @param
|
|
289
|
-
* @param {}
|
|
287
|
+
* @param v
|
|
290
288
|
*/
|
|
291
289
|
const validateMobileNativePushMessaging = (v) => {
|
|
292
290
|
const errors = [];
|
|
@@ -311,9 +309,8 @@ exports.validateMobileNativePushMessaging = validateMobileNativePushMessaging;
|
|
|
311
309
|
/**
|
|
312
310
|
* Validate default disable (mobileNativePushMessaging)
|
|
313
311
|
* @param value
|
|
314
|
-
* @param {}
|
|
315
312
|
*/
|
|
316
|
-
const validateMobileNativePushMessagingDisable = (value
|
|
313
|
+
const validateMobileNativePushMessagingDisable = (value) => {
|
|
317
314
|
const errors = [];
|
|
318
315
|
const warnings = [];
|
|
319
316
|
if (value !== undefined) {
|
|
@@ -333,7 +330,7 @@ const validateMobileNativePushMessagingDisable = (value, notifications) => {
|
|
|
333
330
|
exports.validateMobileNativePushMessagingDisable = validateMobileNativePushMessagingDisable;
|
|
334
331
|
/**
|
|
335
332
|
* Validate portal option
|
|
336
|
-
* @param
|
|
333
|
+
* @param value
|
|
337
334
|
* @return {}
|
|
338
335
|
*/
|
|
339
336
|
const validatePortal = (value) => {
|
|
@@ -348,7 +345,7 @@ exports.validatePortal = validatePortal;
|
|
|
348
345
|
/**
|
|
349
346
|
* Validate default locale
|
|
350
347
|
* @param value
|
|
351
|
-
* @param
|
|
348
|
+
* @param locale
|
|
352
349
|
*/
|
|
353
350
|
const validateLocaleDefault = (value, locale) => {
|
|
354
351
|
const errors = [];
|
|
@@ -367,7 +364,6 @@ exports.validateLocaleDefault = validateLocaleDefault;
|
|
|
367
364
|
/**
|
|
368
365
|
* Validate default locale
|
|
369
366
|
* @param value
|
|
370
|
-
* @param {}
|
|
371
367
|
*/
|
|
372
368
|
const validateLocaleMessages = (value) => {
|
|
373
369
|
const errors = [];
|
|
@@ -380,7 +376,7 @@ const validateLocaleMessages = (value) => {
|
|
|
380
376
|
exports.validateLocaleMessages = validateLocaleMessages;
|
|
381
377
|
/**
|
|
382
378
|
* Validate locale option
|
|
383
|
-
* @param
|
|
379
|
+
* @param v
|
|
384
380
|
* @return {}
|
|
385
381
|
*/
|
|
386
382
|
const validateLocale = (v) => {
|
|
@@ -405,7 +401,7 @@ const validateLocale = (v) => {
|
|
|
405
401
|
exports.validateLocale = validateLocale;
|
|
406
402
|
/**
|
|
407
403
|
* Validate router option
|
|
408
|
-
* @param
|
|
404
|
+
* @param value
|
|
409
405
|
* @return {}
|
|
410
406
|
*/
|
|
411
407
|
const validateRouter = (value) => {
|
|
@@ -429,7 +425,7 @@ const validateRouter = (value) => {
|
|
|
429
425
|
exports.validateRouter = validateRouter;
|
|
430
426
|
/**
|
|
431
427
|
* Validate theme option
|
|
432
|
-
* @param
|
|
428
|
+
* @param value
|
|
433
429
|
* @return {}
|
|
434
430
|
*/
|
|
435
431
|
const validateTheme = (value) => {
|
|
@@ -443,7 +439,7 @@ const validateTheme = (value) => {
|
|
|
443
439
|
exports.validateTheme = validateTheme;
|
|
444
440
|
/**
|
|
445
441
|
* Validate handleAnonymousAction option
|
|
446
|
-
* @param
|
|
442
|
+
* @param v
|
|
447
443
|
* @return {}
|
|
448
444
|
*/
|
|
449
445
|
const validateHandleAnonymousAction = (v) => {
|
|
@@ -469,7 +465,7 @@ const validateHandleAnonymousAction = (v) => {
|
|
|
469
465
|
exports.validateHandleAnonymousAction = validateHandleAnonymousAction;
|
|
470
466
|
/**
|
|
471
467
|
* Validate contextProviders option
|
|
472
|
-
* @param
|
|
468
|
+
* @param value
|
|
473
469
|
* @return [...contextProviders]
|
|
474
470
|
*/
|
|
475
471
|
const validateContextProviders = (value) => {
|
|
@@ -617,6 +613,69 @@ function validateVote(v) {
|
|
|
617
613
|
return { errors, warnings, value: defaultValue };
|
|
618
614
|
}
|
|
619
615
|
exports.validateVote = validateVote;
|
|
616
|
+
/**
|
|
617
|
+
* Validate integrations option
|
|
618
|
+
* @param v
|
|
619
|
+
* @return {}
|
|
620
|
+
*/
|
|
621
|
+
function validateIntegrations(v) {
|
|
622
|
+
const errors = [];
|
|
623
|
+
const warnings = [];
|
|
624
|
+
if (!v || !(0, utils_1.isObject)(v)) {
|
|
625
|
+
return { errors, warnings, value: Integrations.DEFAULT_INTEGRATIONS_OPTION };
|
|
626
|
+
}
|
|
627
|
+
const _options = Object.keys(exports.integrationsOptions);
|
|
628
|
+
const value = Object.keys(v)
|
|
629
|
+
.filter((key) => _options.includes(key))
|
|
630
|
+
.reduce((obj, key) => {
|
|
631
|
+
const res = exports.integrationsOptions[key].validator(v[key], v);
|
|
632
|
+
res.errors.map((error) => errors.push(error));
|
|
633
|
+
res.warnings.map((warning) => warnings.push(warning));
|
|
634
|
+
obj[key] = res.value;
|
|
635
|
+
return obj;
|
|
636
|
+
}, {});
|
|
637
|
+
return { errors, warnings, value: Object.assign(Object.assign({}, Integrations.DEFAULT_INTEGRATIONS_OPTION), value) };
|
|
638
|
+
}
|
|
639
|
+
exports.validateIntegrations = validateIntegrations;
|
|
640
|
+
/**
|
|
641
|
+
* Validate OpenAI Option
|
|
642
|
+
* @param v
|
|
643
|
+
*/
|
|
644
|
+
const validateOpenAI = (v) => {
|
|
645
|
+
console.log(v);
|
|
646
|
+
const errors = [];
|
|
647
|
+
const warnings = [];
|
|
648
|
+
if (v && !(0, utils_1.isObject)(v)) {
|
|
649
|
+
errors.push(errors_1.ValidationError.ERROR_INVALID_INTEGRATIONS_OPENAI);
|
|
650
|
+
return { errors, warnings, v };
|
|
651
|
+
}
|
|
652
|
+
const _options = Object.keys(exports.integrationsOpenAIOptions);
|
|
653
|
+
const value = Object.keys(v)
|
|
654
|
+
.filter((key) => _options.includes(key))
|
|
655
|
+
.reduce((obj, key) => {
|
|
656
|
+
const res = exports.integrationsOpenAIOptions[key].validator(v[key], v);
|
|
657
|
+
res.errors.map((error) => errors.push(error));
|
|
658
|
+
res.warnings.map((warning) => warnings.push(warning));
|
|
659
|
+
obj[key] = res.value;
|
|
660
|
+
return obj;
|
|
661
|
+
}, {});
|
|
662
|
+
return { errors, warnings, value };
|
|
663
|
+
};
|
|
664
|
+
exports.validateOpenAI = validateOpenAI;
|
|
665
|
+
/**
|
|
666
|
+
* Validate OpenAI secret key option
|
|
667
|
+
* @param value
|
|
668
|
+
* @return {}
|
|
669
|
+
*/
|
|
670
|
+
const validateOpenAISecretKey = (value) => {
|
|
671
|
+
const errors = [];
|
|
672
|
+
const warnings = [];
|
|
673
|
+
if (!value || !(0, utils_1.isString)(value)) {
|
|
674
|
+
errors.push(errors_1.ValidationError.ERROR_INVALID_INTEGRATIONS_OPENAI_SECRETKEY);
|
|
675
|
+
}
|
|
676
|
+
return { errors, warnings, value };
|
|
677
|
+
};
|
|
678
|
+
exports.validateOpenAISecretKey = validateOpenAISecretKey;
|
|
620
679
|
/**
|
|
621
680
|
* Components Widget
|
|
622
681
|
*/
|
|
@@ -660,6 +719,10 @@ const VoteOption = {
|
|
|
660
719
|
name: Vote.VOTE_OPTION,
|
|
661
720
|
validator: validateVote,
|
|
662
721
|
};
|
|
722
|
+
const IntegrationsOption = {
|
|
723
|
+
name: Integrations.INTEGRATIONS_OPTION,
|
|
724
|
+
validator: validateIntegrations,
|
|
725
|
+
};
|
|
663
726
|
/**
|
|
664
727
|
* Session options
|
|
665
728
|
*/
|
|
@@ -735,6 +798,14 @@ const ReactionsOption = {
|
|
|
735
798
|
name: Vote.VOTE_REACTIONS_OPTION,
|
|
736
799
|
validator: exports.validateReactions,
|
|
737
800
|
};
|
|
801
|
+
const IntegrationOpenAIOption = {
|
|
802
|
+
name: Integrations.INTEGRATIONS_OPENAI_OPTION,
|
|
803
|
+
validator: exports.validateOpenAI,
|
|
804
|
+
};
|
|
805
|
+
const IntegrationOpenAISecretKeyOption = {
|
|
806
|
+
name: Integrations.INTEGRATIONS_OPENAI_SECRETKEY_OPTION,
|
|
807
|
+
validator: exports.validateOpenAISecretKey,
|
|
808
|
+
};
|
|
738
809
|
/**
|
|
739
810
|
* Valid options
|
|
740
811
|
* @type {{}}
|
|
@@ -750,6 +821,7 @@ exports.settingsOptions = {
|
|
|
750
821
|
[ContextProvidersOption.name]: ContextProvidersOption,
|
|
751
822
|
[PreferencesOption.name]: PreferencesOption,
|
|
752
823
|
[VoteOption.name]: VoteOption,
|
|
824
|
+
[IntegrationsOption.name]: IntegrationsOption,
|
|
753
825
|
};
|
|
754
826
|
exports.sessionOptions = {
|
|
755
827
|
[SessionTypeOption.name]: SessionTypeOption,
|
|
@@ -785,10 +857,17 @@ exports.preferencesOptions = {
|
|
|
785
857
|
exports.voteOptions = {
|
|
786
858
|
[ReactionsOption.name]: ReactionsOption,
|
|
787
859
|
};
|
|
860
|
+
exports.integrationsOptions = {
|
|
861
|
+
[IntegrationOpenAIOption.name]: IntegrationOpenAIOption,
|
|
862
|
+
};
|
|
863
|
+
exports.integrationsOpenAIOptions = {
|
|
864
|
+
[IntegrationOpenAISecretKeyOption.name]: IntegrationOpenAISecretKeyOption,
|
|
865
|
+
};
|
|
788
866
|
exports.validOptions = Object.assign({}, exports.settingsOptions);
|
|
789
867
|
/**
|
|
790
868
|
* Validate all options by type
|
|
791
|
-
* @param
|
|
869
|
+
* @param values
|
|
870
|
+
* @param schemaOptions
|
|
792
871
|
* @return {options hydrated}
|
|
793
872
|
*/
|
|
794
873
|
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 {
|
|
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
|
-
|
|
103
|
+
window.document.addEventListener('visibilitychange', handleVisibilityChange);
|
|
104
104
|
return () => {
|
|
105
|
-
|
|
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 (
|
|
113
|
+
if (!window.document.hidden && state.user) {
|
|
114
114
|
settingsManager.refresh && settingsManager.refresh();
|
|
115
115
|
refreshCounters();
|
|
116
116
|
categoriesManager.refresh && categoriesManager.refresh();
|
|
@@ -0,0 +1,8 @@
|
|
|
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 DEFAULT_INTEGRATIONS_OPTION: {
|
|
5
|
+
openai: {
|
|
6
|
+
secretKey: any;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
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 DEFAULT_INTEGRATIONS_OPTION = {
|
|
6
|
+
[INTEGRATIONS_OPENAI_OPTION]: {
|
|
7
|
+
[INTEGRATIONS_OPENAI_SECRETKEY_OPTION]: null,
|
|
8
|
+
},
|
|
9
|
+
};
|
|
@@ -620,3 +620,22 @@ export interface SCAlertMessagesContextType {
|
|
|
620
620
|
*/
|
|
621
621
|
setOptions: (options: any) => void;
|
|
622
622
|
}
|
|
623
|
+
/**
|
|
624
|
+
* Interface SCIntegrationsType
|
|
625
|
+
*/
|
|
626
|
+
export interface SCIntegrationsType {
|
|
627
|
+
/**
|
|
628
|
+
* OpenAI
|
|
629
|
+
*/
|
|
630
|
+
openai?: SCIntegrationsOpenAIType;
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* Interface SCNotificationsWebSocketType
|
|
634
|
+
*/
|
|
635
|
+
export interface SCIntegrationsOpenAIType {
|
|
636
|
+
/**
|
|
637
|
+
* Set secretKey OpenAI
|
|
638
|
+
* Default: null
|
|
639
|
+
*/
|
|
640
|
+
secretKey: string | null;
|
|
641
|
+
}
|
|
@@ -32,6 +32,9 @@ export declare class ValidationError {
|
|
|
32
32
|
static ERROR_INVALID_VOTE: number;
|
|
33
33
|
static ERROR_INVALID_VOTE_REACTIONS: number;
|
|
34
34
|
static ERROR_INVALID_VOTE_REACTIONS_STRUCTURE: number;
|
|
35
|
+
static ERROR_INVALID_INTEGRATIONS: number;
|
|
36
|
+
static ERROR_INVALID_INTEGRATIONS_OPENAI: number;
|
|
37
|
+
static ERROR_INVALID_INTEGRATIONS_OPENAI_SECRETKEY: number;
|
|
35
38
|
static defaultErrorMessageMap: {
|
|
36
39
|
[x: number]: string;
|
|
37
40
|
};
|
package/lib/esm/utils/errors.js
CHANGED
|
@@ -44,6 +44,9 @@ ValidationError.ERROR_INVALID_PREFERENCES_FEATURES = 5002;
|
|
|
44
44
|
ValidationError.ERROR_INVALID_VOTE = 6000;
|
|
45
45
|
ValidationError.ERROR_INVALID_VOTE_REACTIONS = 6001;
|
|
46
46
|
ValidationError.ERROR_INVALID_VOTE_REACTIONS_STRUCTURE = 6002;
|
|
47
|
+
ValidationError.ERROR_INVALID_INTEGRATIONS = 6100;
|
|
48
|
+
ValidationError.ERROR_INVALID_INTEGRATIONS_OPENAI = 6101;
|
|
49
|
+
ValidationError.ERROR_INVALID_INTEGRATIONS_OPENAI_SECRETKEY = 6102;
|
|
47
50
|
ValidationError.defaultErrorMessageMap = {
|
|
48
51
|
[ValidationError.ERROR_INVALID_CONF]: 'Invalid or missing library configuration. Check the configuration that is passed to the SCContextProvider.',
|
|
49
52
|
[ValidationError.ERROR_INVALID_SESSION]: 'Invalid session format.',
|
|
@@ -74,6 +77,9 @@ ValidationError.defaultErrorMessageMap = {
|
|
|
74
77
|
[ValidationError.ERROR_INVALID_VOTE]: 'Invalid vote option.',
|
|
75
78
|
[ValidationError.ERROR_INVALID_VOTE_REACTIONS]: "Invalid vote option. 'reactions' must be a valid array of reaction objects.",
|
|
76
79
|
[ValidationError.ERROR_INVALID_VOTE_REACTIONS_STRUCTURE]: "Invalid vote option. 'reactions' must be a valid array of reaction with attributes (id, label, sentiment, image, active).",
|
|
80
|
+
[ValidationError.ERROR_INVALID_INTEGRATIONS]: 'Invalid integrations conf.',
|
|
81
|
+
[ValidationError.ERROR_INVALID_INTEGRATIONS_OPENAI]: 'Invalid integrations (openai) option.',
|
|
82
|
+
[ValidationError.ERROR_INVALID_INTEGRATIONS_OPENAI_SECRETKEY]: 'Invalid integrations openai conf: secretKey must be a string value.',
|
|
77
83
|
};
|
|
78
84
|
/**
|
|
79
85
|
* 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
|
/**
|