@selfcommunity/react-core 0.4.50-alpha.1 → 0.4.50-events.100
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/SCAlertMessagesProvider/index.js +3 -4
- package/lib/cjs/components/provider/SCContextProvider/index.js +6 -5
- package/lib/cjs/components/provider/SCLocaleProvider/index.js +4 -6
- package/lib/cjs/components/provider/SCNotificationProvider/index.js +3 -2
- package/lib/cjs/components/provider/SCPreferencesProvider/index.js +18 -3
- package/lib/cjs/components/provider/SCRoutingProvider/index.js +3 -2
- package/lib/cjs/components/provider/SCThemeProvider/index.js +4 -5
- package/lib/cjs/components/provider/SCUserProvider/index.js +13 -6
- package/lib/cjs/components/provider/SCVoteProvider/index.js +3 -3
- package/lib/cjs/components/router/index.js +3 -2
- package/lib/cjs/constants/Cache.d.ts +11 -0
- package/lib/cjs/constants/Cache.js +15 -2
- package/lib/cjs/constants/Integrations.d.ts +13 -0
- package/lib/cjs/constants/Integrations.js +17 -0
- package/lib/cjs/constants/Notifications.d.ts +2 -1
- package/lib/cjs/constants/Notifications.js +4 -3
- package/lib/cjs/constants/Preferences.d.ts +3 -0
- package/lib/cjs/constants/Preferences.js +8 -2
- package/lib/cjs/constants/Routes.d.ts +5 -0
- package/lib/cjs/constants/Routes.js +11 -1
- package/lib/cjs/hooks/useSCFetchEvent.d.ts +22 -0
- package/lib/cjs/hooks/useSCFetchEvent.js +87 -0
- package/lib/cjs/hooks/useSCFetchEvents.d.ts +22 -0
- package/lib/cjs/hooks/useSCFetchEvents.js +83 -0
- package/lib/cjs/hooks/useSCSubscribedEventsManager.d.ts +38 -0
- package/lib/cjs/hooks/useSCSubscribedEventsManager.js +297 -0
- package/lib/cjs/hooks/useSCWebPushMessaging.js +3 -4
- package/lib/cjs/index.d.ts +8 -3
- package/lib/cjs/index.js +13 -3
- package/lib/cjs/types/context.d.ts +89 -1
- package/lib/cjs/types/index.d.ts +2 -2
- package/lib/cjs/utils/errors.d.ts +6 -0
- package/lib/cjs/utils/errors.js +12 -0
- package/lib/cjs/utils/event.d.ts +8 -0
- package/lib/cjs/utils/event.js +29 -0
- package/lib/cjs/utils/hooks/useIsomorphicLayoutEffect.js +2 -1
- package/lib/cjs/utils/notification.js +1 -1
- package/lib/cjs/utils/user.d.ts +7 -0
- package/lib/cjs/utils/user.js +11 -1
- package/lib/cjs/utils/validator.d.ts +103 -28
- package/lib/cjs/utils/validator.js +178 -31
- package/lib/esm/components/provider/SCAlertMessagesProvider/index.js +3 -3
- package/lib/esm/components/provider/SCContextProvider/index.js +6 -5
- package/lib/esm/components/provider/SCLocaleProvider/index.js +4 -5
- package/lib/esm/components/provider/SCNotificationProvider/index.js +3 -2
- package/lib/esm/components/provider/SCPreferencesProvider/index.js +18 -2
- package/lib/esm/components/provider/SCRoutingProvider/index.js +3 -2
- package/lib/esm/components/provider/SCThemeProvider/index.js +4 -5
- package/lib/esm/components/provider/SCUserProvider/index.js +14 -7
- package/lib/esm/components/provider/SCVoteProvider/index.js +3 -2
- package/lib/esm/components/router/index.js +3 -2
- package/lib/esm/constants/Cache.d.ts +11 -0
- package/lib/esm/constants/Cache.js +11 -0
- package/lib/esm/constants/Integrations.d.ts +13 -0
- package/lib/esm/constants/Integrations.js +14 -0
- package/lib/esm/constants/Notifications.d.ts +2 -1
- package/lib/esm/constants/Notifications.js +3 -2
- package/lib/esm/constants/Preferences.d.ts +3 -0
- package/lib/esm/constants/Preferences.js +6 -0
- package/lib/esm/constants/Routes.d.ts +5 -0
- package/lib/esm/constants/Routes.js +10 -0
- package/lib/esm/hooks/useSCFetchEvent.d.ts +22 -0
- package/lib/esm/hooks/useSCFetchEvent.js +84 -0
- package/lib/esm/hooks/useSCFetchEvents.d.ts +22 -0
- package/lib/esm/hooks/useSCFetchEvents.js +81 -0
- package/lib/esm/hooks/useSCSubscribedEventsManager.d.ts +38 -0
- package/lib/esm/hooks/useSCSubscribedEventsManager.js +293 -0
- package/lib/esm/hooks/useSCWebPushMessaging.js +3 -4
- package/lib/esm/index.d.ts +8 -3
- package/lib/esm/index.js +7 -2
- package/lib/esm/types/context.d.ts +89 -1
- package/lib/esm/types/index.d.ts +2 -2
- package/lib/esm/utils/errors.d.ts +6 -0
- package/lib/esm/utils/errors.js +12 -0
- package/lib/esm/utils/event.d.ts +8 -0
- package/lib/esm/utils/event.js +25 -0
- package/lib/esm/utils/hooks/useIsomorphicLayoutEffect.js +2 -1
- package/lib/esm/utils/notification.js +2 -2
- package/lib/esm/utils/user.d.ts +7 -0
- package/lib/esm/utils/user.js +9 -0
- package/lib/esm/utils/validator.d.ts +103 -28
- package/lib/esm/utils/validator.js +171 -30
- package/lib/umd/react-core.js +1 -1
- package/package.json +6 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
import { SCAuthTokenType, SCIncubatorType, SCCategoryType, SCUserType, SCUserSettingsType, SCReactionType, SCGroupType } from '@selfcommunity/types';
|
|
2
|
+
import { SCAuthTokenType, SCIncubatorType, SCCategoryType, SCUserType, SCUserSettingsType, SCReactionType, SCGroupType, SCEventType } from '@selfcommunity/types';
|
|
3
3
|
import { SCThemeType } from './theme';
|
|
4
4
|
/**
|
|
5
5
|
* Interface SCSettingsType
|
|
@@ -37,6 +37,10 @@ export interface SCSettingsType {
|
|
|
37
37
|
* Object conf of notification.
|
|
38
38
|
*/
|
|
39
39
|
notifications?: SCNotificationsType;
|
|
40
|
+
/**
|
|
41
|
+
* Integrations conf
|
|
42
|
+
*/
|
|
43
|
+
integrations?: SCIntegrationsType;
|
|
40
44
|
/**
|
|
41
45
|
* Callback to handle anonymous action
|
|
42
46
|
* Ex. an anonymous user attempt to post a comment
|
|
@@ -143,6 +147,7 @@ export interface SCUserContextType {
|
|
|
143
147
|
incubators?: SCSubscribedIncubatorsManagerType;
|
|
144
148
|
blockedUsers?: SCBlockedUsersManagerType;
|
|
145
149
|
groups?: SCSubscribedGroupsManagerType;
|
|
150
|
+
events?: SCSubscribedEventsManagerType;
|
|
146
151
|
};
|
|
147
152
|
}
|
|
148
153
|
export interface SCSettingsManagerType {
|
|
@@ -249,6 +254,44 @@ export interface SCFollowedCategoriesManagerType {
|
|
|
249
254
|
*/
|
|
250
255
|
emptyCache?: () => void;
|
|
251
256
|
}
|
|
257
|
+
export interface SCSubscribedEventsManagerType {
|
|
258
|
+
/**
|
|
259
|
+
* List of all events ids followed by the authenticated user
|
|
260
|
+
*/
|
|
261
|
+
events: number[];
|
|
262
|
+
/**
|
|
263
|
+
* List of all events in loading state
|
|
264
|
+
*/
|
|
265
|
+
loading: number[];
|
|
266
|
+
/**
|
|
267
|
+
* List of current events in loading state
|
|
268
|
+
*/
|
|
269
|
+
isLoading: (event: SCEventType) => boolean;
|
|
270
|
+
/**
|
|
271
|
+
* Handle user subscription to an event
|
|
272
|
+
*/
|
|
273
|
+
subscribe?: (event: SCEventType, userId?: number) => Promise<any>;
|
|
274
|
+
/**
|
|
275
|
+
* Handle user going to an event
|
|
276
|
+
*/
|
|
277
|
+
toggleEventAttendance?: (event: SCEventType, userId?: number) => Promise<any>;
|
|
278
|
+
/**
|
|
279
|
+
* Handle user not going to an event
|
|
280
|
+
*/
|
|
281
|
+
toggleEventNonattendance?: (event: SCEventType, userId?: number) => Promise<any>;
|
|
282
|
+
/**
|
|
283
|
+
* Handles a user subscription status to an event, caching data
|
|
284
|
+
*/
|
|
285
|
+
subscriptionStatus?: (event: SCEventType) => string;
|
|
286
|
+
/**
|
|
287
|
+
* Refresh groups
|
|
288
|
+
*/
|
|
289
|
+
refresh?: () => void;
|
|
290
|
+
/**
|
|
291
|
+
* Empty cache to revalidate all groups
|
|
292
|
+
*/
|
|
293
|
+
emptyCache?: () => void;
|
|
294
|
+
}
|
|
252
295
|
export interface SCSubscribedGroupsManagerType {
|
|
253
296
|
/**
|
|
254
297
|
* List of all groups ids followed by the authenticated user
|
|
@@ -444,6 +487,18 @@ export interface SCPreferencesContextType {
|
|
|
444
487
|
* List of all community enabled features
|
|
445
488
|
*/
|
|
446
489
|
features: string[];
|
|
490
|
+
/**
|
|
491
|
+
* Set prefrerences
|
|
492
|
+
*/
|
|
493
|
+
setPreferences: (preferences: Record<string, any>) => void;
|
|
494
|
+
/**
|
|
495
|
+
* Set features
|
|
496
|
+
*/
|
|
497
|
+
setFeatures: (features: string[]) => void;
|
|
498
|
+
/**
|
|
499
|
+
* Force refresh
|
|
500
|
+
*/
|
|
501
|
+
refresh: () => void;
|
|
447
502
|
}
|
|
448
503
|
/**
|
|
449
504
|
* Interface SCVoteContextType
|
|
@@ -620,3 +675,36 @@ export interface SCAlertMessagesContextType {
|
|
|
620
675
|
*/
|
|
621
676
|
setOptions: (options: any) => void;
|
|
622
677
|
}
|
|
678
|
+
/**
|
|
679
|
+
* Interface SCIntegrationsType
|
|
680
|
+
*/
|
|
681
|
+
export interface SCIntegrationsType {
|
|
682
|
+
/**
|
|
683
|
+
* OpenAI
|
|
684
|
+
*/
|
|
685
|
+
openai?: SCIntegrationsOpenAIType;
|
|
686
|
+
/**
|
|
687
|
+
* Geocoding
|
|
688
|
+
*/
|
|
689
|
+
geocoding?: SCGeocodingType;
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* Interface SCIntegrationsOpenAIType
|
|
693
|
+
*/
|
|
694
|
+
export interface SCIntegrationsOpenAIType {
|
|
695
|
+
/**
|
|
696
|
+
* Set secretKey OpenAI
|
|
697
|
+
* Default: null
|
|
698
|
+
*/
|
|
699
|
+
secretKey: string | null;
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Interface SCGeocodingType
|
|
703
|
+
*/
|
|
704
|
+
export interface SCGeocodingType {
|
|
705
|
+
/**
|
|
706
|
+
* Set secretKey geocoding service
|
|
707
|
+
* Default: null
|
|
708
|
+
*/
|
|
709
|
+
apiKey: string | null;
|
|
710
|
+
}
|
package/lib/cjs/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { SCUserContextType, SCFollowedManagerType, SCFollowersManagerType, SCFollowedCategoriesManagerType, SCSettingsManagerType, SCSubscribedIncubatorsManagerType, SCConnectionsManagerType, SCBlockedUsersManagerType, SCContextProviderType, SCContextType, SCSettingsType, SCSessionType, SCPreferencesContextType, SCNotificationContextType, SCLocaleType, SCVoteType, SCVoteContextType, SCThemeContextType, SCRoutingContextType, SCLocaleContextType, SCAlertMessagesContextType, SCSubscribedGroupsManagerType } from './context';
|
|
1
|
+
import { SCUserContextType, SCFollowedManagerType, SCFollowersManagerType, SCFollowedCategoriesManagerType, SCSettingsManagerType, SCSubscribedIncubatorsManagerType, SCConnectionsManagerType, SCBlockedUsersManagerType, SCContextProviderType, SCContextType, SCSettingsType, SCSessionType, SCPreferencesContextType, SCNotificationContextType, SCLocaleType, SCVoteType, SCVoteContextType, SCThemeContextType, SCRoutingContextType, SCLocaleContextType, SCAlertMessagesContextType, SCSubscribedGroupsManagerType, SCSubscribedEventsManagerType } from './context';
|
|
2
2
|
import { SCThemeAvatarVariableType, SCThemeUserVariableType, SCThemeCategoryIconVariableType, SCThemeCategoryVariableType, SCThemeVariablesType, SCThemeType } from './theme';
|
|
3
|
-
export { SCUserContextType, SCFollowedCategoriesManagerType, SCSettingsManagerType, SCContextProviderType, SCContextType, SCSettingsType, SCSessionType, SCFollowedManagerType, SCFollowersManagerType, SCConnectionsManagerType, SCBlockedUsersManagerType, SCSubscribedIncubatorsManagerType, SCLocaleType, SCVoteType, SCVoteContextType, SCNotificationContextType, SCPreferencesContextType, SCThemeContextType, SCRoutingContextType, SCLocaleContextType, SCAlertMessagesContextType, SCThemeAvatarVariableType, SCThemeUserVariableType, SCThemeCategoryIconVariableType, SCThemeCategoryVariableType, SCThemeVariablesType, SCThemeType, SCSubscribedGroupsManagerType, };
|
|
3
|
+
export { SCUserContextType, SCFollowedCategoriesManagerType, SCSettingsManagerType, SCContextProviderType, SCContextType, SCSettingsType, SCSessionType, SCFollowedManagerType, SCFollowersManagerType, SCConnectionsManagerType, SCBlockedUsersManagerType, SCSubscribedIncubatorsManagerType, SCLocaleType, SCVoteType, SCVoteContextType, SCNotificationContextType, SCPreferencesContextType, SCThemeContextType, SCRoutingContextType, SCLocaleContextType, SCAlertMessagesContextType, SCThemeAvatarVariableType, SCThemeUserVariableType, SCThemeCategoryIconVariableType, SCThemeCategoryVariableType, SCThemeVariablesType, SCThemeType, SCSubscribedGroupsManagerType, SCSubscribedEventsManagerType, };
|
|
@@ -21,6 +21,7 @@ export declare class ValidationError {
|
|
|
21
21
|
static ERROR_INVALID_NOTIFICATIONS_WEBSOCKET: number;
|
|
22
22
|
static ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_DISABLE_TOAST_MESSAGE: number;
|
|
23
23
|
static ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_SECURE: number;
|
|
24
|
+
static ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_PREFIX_PATH: number;
|
|
24
25
|
static ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING: number;
|
|
25
26
|
static ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING_DISABLE_TOAST_MESSAGE: number;
|
|
26
27
|
static ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING_APPLICATION_SERVER_KEY: number;
|
|
@@ -32,6 +33,11 @@ export declare class ValidationError {
|
|
|
32
33
|
static ERROR_INVALID_VOTE: number;
|
|
33
34
|
static ERROR_INVALID_VOTE_REACTIONS: number;
|
|
34
35
|
static ERROR_INVALID_VOTE_REACTIONS_STRUCTURE: number;
|
|
36
|
+
static ERROR_INVALID_INTEGRATIONS: number;
|
|
37
|
+
static ERROR_INVALID_INTEGRATIONS_OPENAI: number;
|
|
38
|
+
static ERROR_INVALID_INTEGRATIONS_OPENAI_SECRETKEY: number;
|
|
39
|
+
static ERROR_INVALID_INTEGRATIONS_GEOCODING: number;
|
|
40
|
+
static ERROR_INVALID_INTEGRATIONS_GEOCODING_APIKEY: number;
|
|
35
41
|
static defaultErrorMessageMap: {
|
|
36
42
|
[x: number]: string;
|
|
37
43
|
};
|
package/lib/cjs/utils/errors.js
CHANGED
|
@@ -38,6 +38,7 @@ ValidationError.ERROR_INVALID_NOTIFICATIONS = 4900;
|
|
|
38
38
|
ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET = 4901;
|
|
39
39
|
ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_DISABLE_TOAST_MESSAGE = 4902;
|
|
40
40
|
ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_SECURE = 4903;
|
|
41
|
+
ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_PREFIX_PATH = 4904;
|
|
41
42
|
ValidationError.ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING = 4921;
|
|
42
43
|
ValidationError.ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING_DISABLE_TOAST_MESSAGE = 4922;
|
|
43
44
|
ValidationError.ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING_APPLICATION_SERVER_KEY = 4923;
|
|
@@ -49,6 +50,11 @@ ValidationError.ERROR_INVALID_PREFERENCES_FEATURES = 5002;
|
|
|
49
50
|
ValidationError.ERROR_INVALID_VOTE = 6000;
|
|
50
51
|
ValidationError.ERROR_INVALID_VOTE_REACTIONS = 6001;
|
|
51
52
|
ValidationError.ERROR_INVALID_VOTE_REACTIONS_STRUCTURE = 6002;
|
|
53
|
+
ValidationError.ERROR_INVALID_INTEGRATIONS = 6100;
|
|
54
|
+
ValidationError.ERROR_INVALID_INTEGRATIONS_OPENAI = 6101;
|
|
55
|
+
ValidationError.ERROR_INVALID_INTEGRATIONS_OPENAI_SECRETKEY = 6102;
|
|
56
|
+
ValidationError.ERROR_INVALID_INTEGRATIONS_GEOCODING = 6103;
|
|
57
|
+
ValidationError.ERROR_INVALID_INTEGRATIONS_GEOCODING_APIKEY = 6104;
|
|
52
58
|
ValidationError.defaultErrorMessageMap = {
|
|
53
59
|
[ValidationError.ERROR_INVALID_CONF]: 'Invalid or missing library configuration. Check the configuration that is passed to the SCContextProvider.',
|
|
54
60
|
[ValidationError.ERROR_INVALID_SESSION]: 'Invalid session format.',
|
|
@@ -68,6 +74,7 @@ ValidationError.defaultErrorMessageMap = {
|
|
|
68
74
|
[ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET]: 'Invalid notifications (websocket) option.',
|
|
69
75
|
[ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_DISABLE_TOAST_MESSAGE]: 'Invalid notifications websocket conf: disableToastMessage must be a boolean value.',
|
|
70
76
|
[ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_SECURE]: 'Invalid notifications websocket conf: secure must be a boolean value.',
|
|
77
|
+
[ValidationError.ERROR_INVALID_NOTIFICATIONS_WEBSOCKET_PREFIX_PATH]: 'Invalid notifications websocket conf: prefixPath must be a string value.',
|
|
71
78
|
[ValidationError.ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING]: 'Invalid notifications (web push messaging) option.',
|
|
72
79
|
[ValidationError.ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING_DISABLE_TOAST_MESSAGE]: "Invalid notifications web push messaging option. 'disableToastMessage' must be a boolean value.",
|
|
73
80
|
[ValidationError.ERROR_INVALID_NOTIFICATIONS_WEB_PUSH_MESSAGING_APPLICATION_SERVER_KEY]: "Invalid notifications web push messaging option. 'applicationServerKey' must be a string value.",
|
|
@@ -79,6 +86,11 @@ ValidationError.defaultErrorMessageMap = {
|
|
|
79
86
|
[ValidationError.ERROR_INVALID_VOTE]: 'Invalid vote option.',
|
|
80
87
|
[ValidationError.ERROR_INVALID_VOTE_REACTIONS]: "Invalid vote option. 'reactions' must be a valid array of reaction objects.",
|
|
81
88
|
[ValidationError.ERROR_INVALID_VOTE_REACTIONS_STRUCTURE]: "Invalid vote option. 'reactions' must be a valid array of reaction with attributes (id, label, sentiment, image, active).",
|
|
89
|
+
[ValidationError.ERROR_INVALID_INTEGRATIONS]: 'Invalid integrations conf.',
|
|
90
|
+
[ValidationError.ERROR_INVALID_INTEGRATIONS_OPENAI]: 'Invalid integrations (openai) option.',
|
|
91
|
+
[ValidationError.ERROR_INVALID_INTEGRATIONS_OPENAI_SECRETKEY]: 'Invalid integrations openai conf: secretKey must be a string value.',
|
|
92
|
+
[ValidationError.ERROR_INVALID_INTEGRATIONS_GEOCODING]: 'Invalid integrations (geocoding) option.',
|
|
93
|
+
[ValidationError.ERROR_INVALID_INTEGRATIONS_GEOCODING_APIKEY]: 'Invalid integrations geocoding conf: apiKey must be a string value.',
|
|
82
94
|
};
|
|
83
95
|
/**
|
|
84
96
|
* Manage Validation Warnings
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SCEventSubscriptionStatusType, SCEventType } from '@selfcommunity/types';
|
|
2
|
+
/**
|
|
3
|
+
* Get event status
|
|
4
|
+
* @returns status or null
|
|
5
|
+
* @param event
|
|
6
|
+
* @param going
|
|
7
|
+
*/
|
|
8
|
+
export declare function getEventStatus(event: SCEventType, going: boolean): SCEventSubscriptionStatusType | null;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEventStatus = void 0;
|
|
4
|
+
const types_1 = require("@selfcommunity/types");
|
|
5
|
+
/**
|
|
6
|
+
* Get event status
|
|
7
|
+
* @returns status or null
|
|
8
|
+
* @param event
|
|
9
|
+
* @param going
|
|
10
|
+
*/
|
|
11
|
+
function getEventStatus(event, going) {
|
|
12
|
+
const { subscription_status: status, privacy } = event;
|
|
13
|
+
if (!status) {
|
|
14
|
+
return privacy === types_1.SCEventPrivacyType.PRIVATE ? types_1.SCEventSubscriptionStatusType.REQUESTED : types_1.SCEventSubscriptionStatusType.SUBSCRIBED;
|
|
15
|
+
}
|
|
16
|
+
switch (status) {
|
|
17
|
+
case types_1.SCEventSubscriptionStatusType.INVITED:
|
|
18
|
+
case types_1.SCEventSubscriptionStatusType.GOING:
|
|
19
|
+
case types_1.SCEventSubscriptionStatusType.NOT_GOING:
|
|
20
|
+
return types_1.SCEventSubscriptionStatusType.SUBSCRIBED;
|
|
21
|
+
case types_1.SCEventSubscriptionStatusType.SUBSCRIBED:
|
|
22
|
+
return going ? types_1.SCEventSubscriptionStatusType.GOING : types_1.SCEventSubscriptionStatusType.NOT_GOING;
|
|
23
|
+
case types_1.SCEventSubscriptionStatusType.REQUESTED:
|
|
24
|
+
return privacy === types_1.SCEventPrivacyType.PRIVATE ? null : types_1.SCEventSubscriptionStatusType.SUBSCRIBED;
|
|
25
|
+
default:
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.getEventStatus = getEventStatus;
|
|
@@ -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 =
|
|
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 ((
|
|
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;
|
package/lib/cjs/utils/user.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { SCUserType } from '@selfcommunity/types';
|
|
|
6
6
|
export declare const ADMIN_ROLE = "admin";
|
|
7
7
|
export declare const MODERATOR_ROLE = "moderator";
|
|
8
8
|
export declare const EDITOR_ROLE = "editor";
|
|
9
|
+
export declare const COMMUNITY_CREATOR = 1;
|
|
9
10
|
/**
|
|
10
11
|
* Get user role from roles(set)
|
|
11
12
|
* @param user
|
|
@@ -18,6 +19,12 @@ export declare function getUserRole(user: SCUserType): string | null;
|
|
|
18
19
|
* @returns boolean
|
|
19
20
|
*/
|
|
20
21
|
export declare function isAdmin(user: SCUserType): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Check if user is admin
|
|
24
|
+
* @param user
|
|
25
|
+
* @returns boolean
|
|
26
|
+
*/
|
|
27
|
+
export declare function isCommunityCreator(user: SCUserType): boolean;
|
|
21
28
|
/**
|
|
22
29
|
* Check if user is moderator
|
|
23
30
|
* @param user
|
package/lib/cjs/utils/user.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isBlocked = exports.isStaff = exports.isEditor = exports.isModerator = exports.isAdmin = exports.getUserRole = exports.EDITOR_ROLE = exports.MODERATOR_ROLE = exports.ADMIN_ROLE = void 0;
|
|
3
|
+
exports.isBlocked = exports.isStaff = exports.isEditor = exports.isModerator = exports.isCommunityCreator = exports.isAdmin = exports.getUserRole = exports.COMMUNITY_CREATOR = exports.EDITOR_ROLE = exports.MODERATOR_ROLE = exports.ADMIN_ROLE = void 0;
|
|
4
4
|
const types_1 = require("@selfcommunity/types");
|
|
5
5
|
/**
|
|
6
6
|
* Staff Roles
|
|
@@ -9,6 +9,7 @@ const types_1 = require("@selfcommunity/types");
|
|
|
9
9
|
exports.ADMIN_ROLE = 'admin';
|
|
10
10
|
exports.MODERATOR_ROLE = 'moderator';
|
|
11
11
|
exports.EDITOR_ROLE = 'editor';
|
|
12
|
+
exports.COMMUNITY_CREATOR = 1;
|
|
12
13
|
/**
|
|
13
14
|
* Get user role from roles(set)
|
|
14
15
|
* @param user
|
|
@@ -39,6 +40,15 @@ function isAdmin(user) {
|
|
|
39
40
|
return getUserRole(user) === exports.ADMIN_ROLE;
|
|
40
41
|
}
|
|
41
42
|
exports.isAdmin = isAdmin;
|
|
43
|
+
/**
|
|
44
|
+
* Check if user is admin
|
|
45
|
+
* @param user
|
|
46
|
+
* @returns boolean
|
|
47
|
+
*/
|
|
48
|
+
function isCommunityCreator(user) {
|
|
49
|
+
return user && user.id === exports.COMMUNITY_CREATOR;
|
|
50
|
+
}
|
|
51
|
+
exports.isCommunityCreator = isCommunityCreator;
|
|
42
52
|
/**
|
|
43
53
|
* Check if user is moderator
|
|
44
54
|
* @param user
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { SCNotificationsMobileNativePushMessagingType, SCNotificationsType, SCNotificationsWebPushMessagingType, SCNotificationsWebSocketType, SCSettingsType } from '../types/context';
|
|
1
|
+
import { SCGeocodingType, SCIntegrationsOpenAIType, SCIntegrationsType, SCNotificationsMobileNativePushMessagingType, SCNotificationsType, SCNotificationsWebPushMessagingType, SCNotificationsWebSocketType, SCSettingsType } from '../types/context';
|
|
2
2
|
import { ValidationResult } from './errors';
|
|
3
3
|
import { SCLocaleType } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* Validate session option
|
|
6
|
-
* @param
|
|
6
|
+
* @param v
|
|
7
7
|
* @return {}
|
|
8
8
|
*/
|
|
9
9
|
export declare function validateSession(v: Record<string, any>): {
|
|
@@ -14,6 +14,7 @@ export declare function validateSession(v: Record<string, any>): {
|
|
|
14
14
|
/**
|
|
15
15
|
* Validate session type
|
|
16
16
|
* @param value
|
|
17
|
+
* @param session
|
|
17
18
|
* @return {}
|
|
18
19
|
*/
|
|
19
20
|
export declare const validateSessionType: (value: any, session: any) => {
|
|
@@ -24,6 +25,7 @@ export declare const validateSessionType: (value: any, session: any) => {
|
|
|
24
25
|
/**
|
|
25
26
|
* Validate session client id
|
|
26
27
|
* @param value
|
|
28
|
+
* @param session
|
|
27
29
|
* @return {}
|
|
28
30
|
*/
|
|
29
31
|
export declare const validateSessionClientId: (value: any, session: any) => {
|
|
@@ -34,6 +36,7 @@ export declare const validateSessionClientId: (value: any, session: any) => {
|
|
|
34
36
|
/**
|
|
35
37
|
* Validate session auth token
|
|
36
38
|
* @param value
|
|
39
|
+
* @param session
|
|
37
40
|
* @return {}
|
|
38
41
|
*/
|
|
39
42
|
export declare const validateSessionAuthTokenOption: (value: any, session: any) => {
|
|
@@ -55,6 +58,7 @@ export declare const validateHandleRefreshToken: (value: any, session: any) => {
|
|
|
55
58
|
/**
|
|
56
59
|
* Validate handleLogout option
|
|
57
60
|
* @param value
|
|
61
|
+
* @param session
|
|
58
62
|
* @return {}
|
|
59
63
|
*/
|
|
60
64
|
export declare const validateHandleLogout: (value: any, session: any) => {
|
|
@@ -64,7 +68,7 @@ export declare const validateHandleLogout: (value: any, session: any) => {
|
|
|
64
68
|
};
|
|
65
69
|
/**
|
|
66
70
|
* Validate notifications option
|
|
67
|
-
* @param
|
|
71
|
+
* @param v
|
|
68
72
|
* @return {}
|
|
69
73
|
*/
|
|
70
74
|
export declare function validateNotifications(v: SCNotificationsType): {
|
|
@@ -74,8 +78,7 @@ export declare function validateNotifications(v: SCNotificationsType): {
|
|
|
74
78
|
};
|
|
75
79
|
/**
|
|
76
80
|
* Validate webSocket
|
|
77
|
-
* @param
|
|
78
|
-
* @param {}
|
|
81
|
+
* @param v
|
|
79
82
|
*/
|
|
80
83
|
export declare const validateWebSocket: (v: any) => {
|
|
81
84
|
errors: any[];
|
|
@@ -91,9 +94,8 @@ export declare const validateWebSocket: (v: any) => {
|
|
|
91
94
|
/**
|
|
92
95
|
* Validate default disableToastMessage (webSocket)
|
|
93
96
|
* @param value
|
|
94
|
-
* @param {}
|
|
95
97
|
*/
|
|
96
|
-
export declare const validateWebSocketDisableToastMessage: (value: any
|
|
98
|
+
export declare const validateWebSocketDisableToastMessage: (value: any) => {
|
|
97
99
|
errors: any[];
|
|
98
100
|
warnings: any[];
|
|
99
101
|
value: any;
|
|
@@ -101,17 +103,24 @@ export declare const validateWebSocketDisableToastMessage: (value: any, notifica
|
|
|
101
103
|
/**
|
|
102
104
|
* Validate default secure (webSocket)
|
|
103
105
|
* @param value
|
|
104
|
-
* @param {}
|
|
105
106
|
*/
|
|
106
|
-
export declare const validateWebSocketSecure: (value: any
|
|
107
|
+
export declare const validateWebSocketSecure: (value: any) => {
|
|
107
108
|
errors: any[];
|
|
108
109
|
warnings: any[];
|
|
109
110
|
value: any;
|
|
110
111
|
};
|
|
111
112
|
/**
|
|
112
|
-
* Validate
|
|
113
|
+
* Validate prefixPath (webSocket)
|
|
113
114
|
* @param value
|
|
114
|
-
|
|
115
|
+
*/
|
|
116
|
+
export declare const validateWebSocketPrefixPath: (value: any) => {
|
|
117
|
+
errors: any[];
|
|
118
|
+
warnings: any[];
|
|
119
|
+
value: any;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Validate webPushMessaging
|
|
123
|
+
* @param v
|
|
115
124
|
*/
|
|
116
125
|
export declare const validateWebPushMessaging: (v: any) => {
|
|
117
126
|
errors: any[];
|
|
@@ -127,9 +136,8 @@ export declare const validateWebPushMessaging: (v: any) => {
|
|
|
127
136
|
/**
|
|
128
137
|
* Validate default disableToastMessage (webPushMessaging)
|
|
129
138
|
* @param value
|
|
130
|
-
* @param {}
|
|
131
139
|
*/
|
|
132
|
-
export declare const validateWebPushMessagingDisableToastMessage: (value: any
|
|
140
|
+
export declare const validateWebPushMessagingDisableToastMessage: (value: any) => {
|
|
133
141
|
errors: any[];
|
|
134
142
|
warnings: any[];
|
|
135
143
|
value: any;
|
|
@@ -137,17 +145,15 @@ export declare const validateWebPushMessagingDisableToastMessage: (value: any, n
|
|
|
137
145
|
/**
|
|
138
146
|
* Validate default applicationServerKey (webPushMessaging)
|
|
139
147
|
* @param value
|
|
140
|
-
* @param {}
|
|
141
148
|
*/
|
|
142
|
-
export declare const validateWebPushMessagingApplicationServerKey: (value: any
|
|
149
|
+
export declare const validateWebPushMessagingApplicationServerKey: (value: any) => {
|
|
143
150
|
errors: any[];
|
|
144
151
|
warnings: any[];
|
|
145
152
|
value: any;
|
|
146
153
|
};
|
|
147
154
|
/**
|
|
148
155
|
* Validate mobile native
|
|
149
|
-
* @param
|
|
150
|
-
* @param {}
|
|
156
|
+
* @param v
|
|
151
157
|
*/
|
|
152
158
|
export declare const validateMobileNativePushMessaging: (v: any) => {
|
|
153
159
|
errors: any[];
|
|
@@ -163,16 +169,15 @@ export declare const validateMobileNativePushMessaging: (v: any) => {
|
|
|
163
169
|
/**
|
|
164
170
|
* Validate default disable (mobileNativePushMessaging)
|
|
165
171
|
* @param value
|
|
166
|
-
* @param {}
|
|
167
172
|
*/
|
|
168
|
-
export declare const validateMobileNativePushMessagingDisable: (value: any
|
|
173
|
+
export declare const validateMobileNativePushMessagingDisable: (value: any) => {
|
|
169
174
|
errors: any[];
|
|
170
175
|
warnings: any[];
|
|
171
176
|
value: any;
|
|
172
177
|
};
|
|
173
178
|
/**
|
|
174
179
|
* Validate portal option
|
|
175
|
-
* @param
|
|
180
|
+
* @param value
|
|
176
181
|
* @return {}
|
|
177
182
|
*/
|
|
178
183
|
export declare const validatePortal: (value: any) => {
|
|
@@ -183,7 +188,7 @@ export declare const validatePortal: (value: any) => {
|
|
|
183
188
|
/**
|
|
184
189
|
* Validate default locale
|
|
185
190
|
* @param value
|
|
186
|
-
* @param
|
|
191
|
+
* @param locale
|
|
187
192
|
*/
|
|
188
193
|
export declare const validateLocaleDefault: (value: any, locale: any) => {
|
|
189
194
|
errors: any[];
|
|
@@ -193,7 +198,6 @@ export declare const validateLocaleDefault: (value: any, locale: any) => {
|
|
|
193
198
|
/**
|
|
194
199
|
* Validate default locale
|
|
195
200
|
* @param value
|
|
196
|
-
* @param {}
|
|
197
201
|
*/
|
|
198
202
|
export declare const validateLocaleMessages: (value: any) => {
|
|
199
203
|
errors: any[];
|
|
@@ -202,7 +206,7 @@ export declare const validateLocaleMessages: (value: any) => {
|
|
|
202
206
|
};
|
|
203
207
|
/**
|
|
204
208
|
* Validate locale option
|
|
205
|
-
* @param
|
|
209
|
+
* @param v
|
|
206
210
|
* @return {}
|
|
207
211
|
*/
|
|
208
212
|
export declare const validateLocale: (v: any) => {
|
|
@@ -218,7 +222,7 @@ export declare const validateLocale: (v: any) => {
|
|
|
218
222
|
};
|
|
219
223
|
/**
|
|
220
224
|
* Validate router option
|
|
221
|
-
* @param
|
|
225
|
+
* @param value
|
|
222
226
|
* @return {}
|
|
223
227
|
*/
|
|
224
228
|
export declare const validateRouter: (value: any) => {
|
|
@@ -228,7 +232,7 @@ export declare const validateRouter: (value: any) => {
|
|
|
228
232
|
};
|
|
229
233
|
/**
|
|
230
234
|
* Validate theme option
|
|
231
|
-
* @param
|
|
235
|
+
* @param value
|
|
232
236
|
* @return {}
|
|
233
237
|
*/
|
|
234
238
|
export declare const validateTheme: (value: any) => {
|
|
@@ -238,7 +242,7 @@ export declare const validateTheme: (value: any) => {
|
|
|
238
242
|
};
|
|
239
243
|
/**
|
|
240
244
|
* Validate handleAnonymousAction option
|
|
241
|
-
* @param
|
|
245
|
+
* @param v
|
|
242
246
|
* @return {}
|
|
243
247
|
*/
|
|
244
248
|
export declare const validateHandleAnonymousAction: (v: any) => {
|
|
@@ -248,7 +252,7 @@ export declare const validateHandleAnonymousAction: (v: any) => {
|
|
|
248
252
|
};
|
|
249
253
|
/**
|
|
250
254
|
* Validate contextProviders option
|
|
251
|
-
* @param
|
|
255
|
+
* @param value
|
|
252
256
|
* @return [...contextProviders]
|
|
253
257
|
*/
|
|
254
258
|
export declare const validateContextProviders: (value: any) => {
|
|
@@ -304,6 +308,73 @@ export declare function validateVote(v: Record<string, any>): {
|
|
|
304
308
|
warnings: any[];
|
|
305
309
|
value: Record<string, any>;
|
|
306
310
|
};
|
|
311
|
+
/**
|
|
312
|
+
* Validate integrations option
|
|
313
|
+
* @param v
|
|
314
|
+
* @return {}
|
|
315
|
+
*/
|
|
316
|
+
export declare function validateIntegrations(v: SCIntegrationsType): {
|
|
317
|
+
errors: any[];
|
|
318
|
+
warnings: any[];
|
|
319
|
+
value: {
|
|
320
|
+
openai: {
|
|
321
|
+
secretKey: any;
|
|
322
|
+
};
|
|
323
|
+
geocoding: {
|
|
324
|
+
apiKey: any;
|
|
325
|
+
};
|
|
326
|
+
};
|
|
327
|
+
};
|
|
328
|
+
/**
|
|
329
|
+
* Validate OpenAI Option
|
|
330
|
+
* @param v
|
|
331
|
+
*/
|
|
332
|
+
export declare const validateOpenAI: (v: any) => {
|
|
333
|
+
errors: any[];
|
|
334
|
+
warnings: any[];
|
|
335
|
+
v: any;
|
|
336
|
+
value?: undefined;
|
|
337
|
+
} | {
|
|
338
|
+
errors: any[];
|
|
339
|
+
warnings: any[];
|
|
340
|
+
value: SCIntegrationsOpenAIType;
|
|
341
|
+
v?: undefined;
|
|
342
|
+
};
|
|
343
|
+
/**
|
|
344
|
+
* Validate Geocoding Option
|
|
345
|
+
* @param v
|
|
346
|
+
*/
|
|
347
|
+
export declare const validateGeocoding: (v: any) => {
|
|
348
|
+
errors: any[];
|
|
349
|
+
warnings: any[];
|
|
350
|
+
v: any;
|
|
351
|
+
value?: undefined;
|
|
352
|
+
} | {
|
|
353
|
+
errors: any[];
|
|
354
|
+
warnings: any[];
|
|
355
|
+
value: SCGeocodingType;
|
|
356
|
+
v?: undefined;
|
|
357
|
+
};
|
|
358
|
+
/**
|
|
359
|
+
* Validate OpenAI secret key option
|
|
360
|
+
* @param value
|
|
361
|
+
* @return {}
|
|
362
|
+
*/
|
|
363
|
+
export declare const validateOpenAISecretKey: (value: any) => {
|
|
364
|
+
errors: any[];
|
|
365
|
+
warnings: any[];
|
|
366
|
+
value: any;
|
|
367
|
+
};
|
|
368
|
+
/**
|
|
369
|
+
* Validate Geocoding api key option
|
|
370
|
+
* @param value
|
|
371
|
+
* @return {}
|
|
372
|
+
*/
|
|
373
|
+
export declare const validateGeocodingApiKey: (value: any) => {
|
|
374
|
+
errors: any[];
|
|
375
|
+
warnings: any[];
|
|
376
|
+
value: any;
|
|
377
|
+
};
|
|
307
378
|
/**
|
|
308
379
|
* Valid options
|
|
309
380
|
* @type {{}}
|
|
@@ -317,12 +388,16 @@ export declare const notificationsWebPushMessagingOptions: Record<string, any>;
|
|
|
317
388
|
export declare const notificationsMobileNativePushMessagingOptions: Record<string, any>;
|
|
318
389
|
export declare const preferencesOptions: Record<string, any>;
|
|
319
390
|
export declare const voteOptions: Record<string, any>;
|
|
391
|
+
export declare const integrationsOptions: Record<string, any>;
|
|
392
|
+
export declare const integrationsOpenAIOptions: Record<string, any>;
|
|
393
|
+
export declare const integrationsGeocodingOptions: Record<string, any>;
|
|
320
394
|
export declare const validOptions: {
|
|
321
395
|
[x: string]: any;
|
|
322
396
|
};
|
|
323
397
|
/**
|
|
324
398
|
* Validate all options by type
|
|
325
|
-
* @param
|
|
399
|
+
* @param values
|
|
400
|
+
* @param schemaOptions
|
|
326
401
|
* @return {options hydrated}
|
|
327
402
|
*/
|
|
328
403
|
export declare const validateOptions: (values: SCSettingsType, schemaOptions: Record<string, any>) => {
|