@selfcommunity/react-core 0.4.50-alpha.1 → 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.
@@ -104,17 +104,17 @@ function SCUserProvider({ children }) {
104
104
  * and document is in foreground refresh the cache
105
105
  */
106
106
  (0, react_1.useEffect)(() => {
107
- typeof window !== 'undefined' && window.document.addEventListener('visibilitychange', handleVisibilityChange);
107
+ window.document.addEventListener('visibilitychange', handleVisibilityChange);
108
108
  return () => {
109
- typeof window !== 'undefined' && window.document.removeEventListener('visibilitychange', handleVisibilityChange);
109
+ window.document.removeEventListener('visibilitychange', handleVisibilityChange);
110
110
  };
111
- });
111
+ }, []);
112
112
  /**
113
113
  * handler handleVisibilityChange for this provider
114
114
  * Refresh followed categories, users, etc..
115
115
  */
116
116
  function handleVisibilityChange() {
117
- if ((0, utils_1.isClientSideRendering)() && !window.document.hidden && state.user) {
117
+ if (!window.document.hidden && state.user) {
118
118
  settingsManager.refresh && settingsManager.refresh();
119
119
  refreshCounters();
120
120
  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,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_INTEGRATIONS_OPTION = exports.INTEGRATIONS_OPENAI_SECRETKEY_OPTION = exports.INTEGRATIONS_OPENAI_OPTION = exports.INTEGRATIONS_OPTION = void 0;
4
+ // integrations
5
+ exports.INTEGRATIONS_OPTION = 'integrations';
6
+ exports.INTEGRATIONS_OPENAI_OPTION = 'openai';
7
+ exports.INTEGRATIONS_OPENAI_SECRETKEY_OPTION = 'secretKey';
8
+ exports.DEFAULT_INTEGRATIONS_OPTION = {
9
+ [exports.INTEGRATIONS_OPENAI_OPTION]: {
10
+ [exports.INTEGRATIONS_OPENAI_SECRETKEY_OPTION]: null,
11
+ },
12
+ };
@@ -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
  };
@@ -49,6 +49,9 @@ ValidationError.ERROR_INVALID_PREFERENCES_FEATURES = 5002;
49
49
  ValidationError.ERROR_INVALID_VOTE = 6000;
50
50
  ValidationError.ERROR_INVALID_VOTE_REACTIONS = 6001;
51
51
  ValidationError.ERROR_INVALID_VOTE_REACTIONS_STRUCTURE = 6002;
52
+ ValidationError.ERROR_INVALID_INTEGRATIONS = 6100;
53
+ ValidationError.ERROR_INVALID_INTEGRATIONS_OPENAI = 6101;
54
+ ValidationError.ERROR_INVALID_INTEGRATIONS_OPENAI_SECRETKEY = 6102;
52
55
  ValidationError.defaultErrorMessageMap = {
53
56
  [ValidationError.ERROR_INVALID_CONF]: 'Invalid or missing library configuration. Check the configuration that is passed to the SCContextProvider.',
54
57
  [ValidationError.ERROR_INVALID_SESSION]: 'Invalid session format.',
@@ -79,6 +82,9 @@ ValidationError.defaultErrorMessageMap = {
79
82
  [ValidationError.ERROR_INVALID_VOTE]: 'Invalid vote option.',
80
83
  [ValidationError.ERROR_INVALID_VOTE_REACTIONS]: "Invalid vote option. 'reactions' must be a valid array of reaction objects.",
81
84
  [ValidationError.ERROR_INVALID_VOTE_REACTIONS_STRUCTURE]: "Invalid vote option. 'reactions' must be a valid array of reaction with attributes (id, label, sentiment, image, active).",
85
+ [ValidationError.ERROR_INVALID_INTEGRATIONS]: 'Invalid integrations conf.',
86
+ [ValidationError.ERROR_INVALID_INTEGRATIONS_OPENAI]: 'Invalid integrations (openai) option.',
87
+ [ValidationError.ERROR_INVALID_INTEGRATIONS_OPENAI_SECRETKEY]: 'Invalid integrations openai conf: secretKey must be a string value.',
82
88
  };
83
89
  /**
84
90
  * Manage Validation Warnings
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const react_1 = require("react");
4
+ const utils_1 = require("@selfcommunity/utils");
4
5
  // Ensure that the SSR uses React.useEffect instead of React.useLayoutEffect
5
6
  // because document is undefined on the server-side.
6
- const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? react_1.useLayoutEffect : react_1.useEffect;
7
+ const useIsomorphicLayoutEffect = (0, utils_1.isClientSideRendering)() ? react_1.useLayoutEffect : react_1.useEffect;
7
8
  exports.default = useIsomorphicLayoutEffect;
@@ -7,7 +7,7 @@ const utils_1 = require("@selfcommunity/utils");
7
7
  * Check if mobile native push notification is enabled
8
8
  */
9
9
  function isMobileNativeNotificationEnabled() {
10
- return ((typeof window !== 'undefined' && window[Device_1.PLATFORM_KEY] && window[Device_1.PLATFORM_KEY] in Device_1.PLATFORM) ||
10
+ return (((0, utils_1.isClientSideRendering)() && window[Device_1.PLATFORM_KEY] && window[Device_1.PLATFORM_KEY] in Device_1.PLATFORM) ||
11
11
  (utils_1.LocalStorageDB.checkifSupport() && utils_1.LocalStorageDB.get(Device_1.PLATFORM_KEY) && Device_1.PLATFORMS.includes(utils_1.LocalStorageDB.get(Device_1.PLATFORM_KEY))));
12
12
  }
13
13
  exports.isMobileNativeNotificationEnabled = isMobileNativeNotificationEnabled;
@@ -1,9 +1,9 @@
1
- import { SCNotificationsMobileNativePushMessagingType, SCNotificationsType, SCNotificationsWebPushMessagingType, SCNotificationsWebSocketType, SCSettingsType } from '../types/context';
1
+ import { SCIntegrationsOpenAIType, SCIntegrationsType, SCNotificationsMobileNativePushMessagingType, SCNotificationsType, SCNotificationsWebPushMessagingType, SCNotificationsWebSocketType, SCSettingsType } from '../types/context';
2
2
  import { ValidationResult } from './errors';
3
3
  import { SCLocaleType } from '../types';
4
4
  /**
5
5
  * Validate session option
6
- * @param session
6
+ * @param v
7
7
  * @return {}
8
8
  */
9
9
  export declare function validateSession(v: Record<string, any>): {
@@ -14,6 +14,7 @@ export declare function validateSession(v: Record<string, any>): {
14
14
  /**
15
15
  * Validate session type
16
16
  * @param value
17
+ * @param session
17
18
  * @return {}
18
19
  */
19
20
  export declare const validateSessionType: (value: any, session: any) => {
@@ -24,6 +25,7 @@ export declare const validateSessionType: (value: any, session: any) => {
24
25
  /**
25
26
  * Validate session client id
26
27
  * @param value
28
+ * @param session
27
29
  * @return {}
28
30
  */
29
31
  export declare const validateSessionClientId: (value: any, session: any) => {
@@ -34,6 +36,7 @@ export declare const validateSessionClientId: (value: any, session: any) => {
34
36
  /**
35
37
  * Validate session auth token
36
38
  * @param value
39
+ * @param session
37
40
  * @return {}
38
41
  */
39
42
  export declare const validateSessionAuthTokenOption: (value: any, session: any) => {
@@ -55,6 +58,7 @@ export declare const validateHandleRefreshToken: (value: any, session: any) => {
55
58
  /**
56
59
  * Validate handleLogout option
57
60
  * @param value
61
+ * @param session
58
62
  * @return {}
59
63
  */
60
64
  export declare const validateHandleLogout: (value: any, session: any) => {
@@ -64,7 +68,7 @@ export declare const validateHandleLogout: (value: any, session: any) => {
64
68
  };
65
69
  /**
66
70
  * Validate notifications option
67
- * @param notifications
71
+ * @param v
68
72
  * @return {}
69
73
  */
70
74
  export declare function validateNotifications(v: SCNotificationsType): {
@@ -74,8 +78,7 @@ export declare function validateNotifications(v: SCNotificationsType): {
74
78
  };
75
79
  /**
76
80
  * Validate webSocket
77
- * @param value
78
- * @param {}
81
+ * @param v
79
82
  */
80
83
  export declare const validateWebSocket: (v: any) => {
81
84
  errors: any[];
@@ -91,9 +94,8 @@ export declare const validateWebSocket: (v: any) => {
91
94
  /**
92
95
  * Validate default disableToastMessage (webSocket)
93
96
  * @param value
94
- * @param {}
95
97
  */
96
- export declare const validateWebSocketDisableToastMessage: (value: any, notifications: any) => {
98
+ export declare const validateWebSocketDisableToastMessage: (value: any) => {
97
99
  errors: any[];
98
100
  warnings: any[];
99
101
  value: any;
@@ -101,17 +103,15 @@ export declare const validateWebSocketDisableToastMessage: (value: any, notifica
101
103
  /**
102
104
  * Validate default secure (webSocket)
103
105
  * @param value
104
- * @param {}
105
106
  */
106
- export declare const validateWebSocketSecure: (value: any, notifications: any) => {
107
+ export declare const validateWebSocketSecure: (value: any) => {
107
108
  errors: any[];
108
109
  warnings: any[];
109
110
  value: any;
110
111
  };
111
112
  /**
112
113
  * Validate webPushMessaging
113
- * @param value
114
- * @param {}
114
+ * @param v
115
115
  */
116
116
  export declare const validateWebPushMessaging: (v: any) => {
117
117
  errors: any[];
@@ -127,9 +127,8 @@ export declare const validateWebPushMessaging: (v: any) => {
127
127
  /**
128
128
  * Validate default disableToastMessage (webPushMessaging)
129
129
  * @param value
130
- * @param {}
131
130
  */
132
- export declare const validateWebPushMessagingDisableToastMessage: (value: any, notifications: any) => {
131
+ export declare const validateWebPushMessagingDisableToastMessage: (value: any) => {
133
132
  errors: any[];
134
133
  warnings: any[];
135
134
  value: any;
@@ -137,17 +136,15 @@ export declare const validateWebPushMessagingDisableToastMessage: (value: any, n
137
136
  /**
138
137
  * Validate default applicationServerKey (webPushMessaging)
139
138
  * @param value
140
- * @param {}
141
139
  */
142
- export declare const validateWebPushMessagingApplicationServerKey: (value: any, notifications: any) => {
140
+ export declare const validateWebPushMessagingApplicationServerKey: (value: any) => {
143
141
  errors: any[];
144
142
  warnings: any[];
145
143
  value: any;
146
144
  };
147
145
  /**
148
146
  * Validate mobile native
149
- * @param value
150
- * @param {}
147
+ * @param v
151
148
  */
152
149
  export declare const validateMobileNativePushMessaging: (v: any) => {
153
150
  errors: any[];
@@ -163,16 +160,15 @@ export declare const validateMobileNativePushMessaging: (v: any) => {
163
160
  /**
164
161
  * Validate default disable (mobileNativePushMessaging)
165
162
  * @param value
166
- * @param {}
167
163
  */
168
- export declare const validateMobileNativePushMessagingDisable: (value: any, notifications: any) => {
164
+ export declare const validateMobileNativePushMessagingDisable: (value: any) => {
169
165
  errors: any[];
170
166
  warnings: any[];
171
167
  value: any;
172
168
  };
173
169
  /**
174
170
  * Validate portal option
175
- * @param portal
171
+ * @param value
176
172
  * @return {}
177
173
  */
178
174
  export declare const validatePortal: (value: any) => {
@@ -183,7 +179,7 @@ export declare const validatePortal: (value: any) => {
183
179
  /**
184
180
  * Validate default locale
185
181
  * @param value
186
- * @param {}
182
+ * @param locale
187
183
  */
188
184
  export declare const validateLocaleDefault: (value: any, locale: any) => {
189
185
  errors: any[];
@@ -193,7 +189,6 @@ export declare const validateLocaleDefault: (value: any, locale: any) => {
193
189
  /**
194
190
  * Validate default locale
195
191
  * @param value
196
- * @param {}
197
192
  */
198
193
  export declare const validateLocaleMessages: (value: any) => {
199
194
  errors: any[];
@@ -202,7 +197,7 @@ export declare const validateLocaleMessages: (value: any) => {
202
197
  };
203
198
  /**
204
199
  * Validate locale option
205
- * @param locale
200
+ * @param v
206
201
  * @return {}
207
202
  */
208
203
  export declare const validateLocale: (v: any) => {
@@ -218,7 +213,7 @@ export declare const validateLocale: (v: any) => {
218
213
  };
219
214
  /**
220
215
  * Validate router option
221
- * @param router
216
+ * @param value
222
217
  * @return {}
223
218
  */
224
219
  export declare const validateRouter: (value: any) => {
@@ -228,7 +223,7 @@ export declare const validateRouter: (value: any) => {
228
223
  };
229
224
  /**
230
225
  * Validate theme option
231
- * @param theme
226
+ * @param value
232
227
  * @return {}
233
228
  */
234
229
  export declare const validateTheme: (value: any) => {
@@ -238,7 +233,7 @@ export declare const validateTheme: (value: any) => {
238
233
  };
239
234
  /**
240
235
  * Validate handleAnonymousAction option
241
- * @param handleAnonymousAction
236
+ * @param v
242
237
  * @return {}
243
238
  */
244
239
  export declare const validateHandleAnonymousAction: (v: any) => {
@@ -248,7 +243,7 @@ export declare const validateHandleAnonymousAction: (v: any) => {
248
243
  };
249
244
  /**
250
245
  * Validate contextProviders option
251
- * @param contextProviders
246
+ * @param value
252
247
  * @return [...contextProviders]
253
248
  */
254
249
  export declare const validateContextProviders: (value: any) => {
@@ -304,6 +299,45 @@ export declare function validateVote(v: Record<string, any>): {
304
299
  warnings: any[];
305
300
  value: Record<string, any>;
306
301
  };
302
+ /**
303
+ * Validate integrations option
304
+ * @param v
305
+ * @return {}
306
+ */
307
+ export declare function validateIntegrations(v: SCIntegrationsType): {
308
+ errors: any[];
309
+ warnings: any[];
310
+ value: {
311
+ openai: {
312
+ secretKey: any;
313
+ };
314
+ };
315
+ };
316
+ /**
317
+ * Validate OpenAI Option
318
+ * @param v
319
+ */
320
+ export declare const validateOpenAI: (v: any) => {
321
+ errors: any[];
322
+ warnings: any[];
323
+ v: any;
324
+ value?: undefined;
325
+ } | {
326
+ errors: any[];
327
+ warnings: any[];
328
+ value: SCIntegrationsOpenAIType;
329
+ v?: undefined;
330
+ };
331
+ /**
332
+ * Validate OpenAI secret key option
333
+ * @param value
334
+ * @return {}
335
+ */
336
+ export declare const validateOpenAISecretKey: (value: any) => {
337
+ errors: any[];
338
+ warnings: any[];
339
+ value: any;
340
+ };
307
341
  /**
308
342
  * Valid options
309
343
  * @type {{}}
@@ -317,12 +351,15 @@ export declare const notificationsWebPushMessagingOptions: Record<string, any>;
317
351
  export declare const notificationsMobileNativePushMessagingOptions: Record<string, any>;
318
352
  export declare const preferencesOptions: Record<string, any>;
319
353
  export declare const voteOptions: Record<string, any>;
354
+ export declare const integrationsOptions: Record<string, any>;
355
+ export declare const integrationsOpenAIOptions: Record<string, any>;
320
356
  export declare const validOptions: {
321
357
  [x: string]: any;
322
358
  };
323
359
  /**
324
360
  * Validate all options by type
325
- * @param options
361
+ * @param values
362
+ * @param schemaOptions
326
363
  * @return {options hydrated}
327
364
  */
328
365
  export declare const validateOptions: (values: SCSettingsType, schemaOptions: Record<string, any>) => {