@glissandoo/lib 1.37.0 → 1.37.2
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/helpers/utils.d.ts +1 -0
- package/helpers/utils.js +8 -1
- package/models/User/index.d.ts +2 -4
- package/models/User/index.js +4 -7
- package/models/User/types.d.ts +4 -4
- package/models/User/types.js +5 -1
- package/package.json +1 -1
- package/types/messagebirdChatWidget.d.ts +1 -3
- package/types/messagebirdChatWidget.ts +6 -3
package/helpers/utils.d.ts
CHANGED
|
@@ -5,3 +5,4 @@ export declare const replaceVarsBrackets: (string: string, values: MetaNotificat
|
|
|
5
5
|
export declare const replaceKeysNotification: (text: string, values: MetaNotificationData, lang: LanguagesTypes) => string;
|
|
6
6
|
export declare const serializeSlateBlock: (nodes: Descendant[]) => string;
|
|
7
7
|
export declare const orderByMatch: <T>(list: T[], field: keyof T, order: string[]) => T[];
|
|
8
|
+
export declare const enumToObj: <T extends Record<string, string | number | boolean>>(enumObject: Record<string, string>, defaultValue: string | number | boolean) => T;
|
package/helpers/utils.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.orderByMatch = exports.serializeSlateBlock = exports.replaceKeysNotification = exports.replaceVarsBrackets = void 0;
|
|
6
|
+
exports.enumToObj = exports.orderByMatch = exports.serializeSlateBlock = exports.replaceKeysNotification = exports.replaceVarsBrackets = void 0;
|
|
7
7
|
const date_fns_1 = require("date-fns");
|
|
8
8
|
const date_fns_tz_1 = require("date-fns-tz");
|
|
9
9
|
const lodash_1 = require("lodash");
|
|
@@ -101,3 +101,10 @@ const orderByMatch = (list, field, order) => {
|
|
|
101
101
|
return [...sortedmatch, ...sortedNoMatch];
|
|
102
102
|
};
|
|
103
103
|
exports.orderByMatch = orderByMatch;
|
|
104
|
+
const enumToObj = (enumObject, defaultValue) => {
|
|
105
|
+
return Object.values(enumObject).reduce((acc, key) => ({
|
|
106
|
+
...acc,
|
|
107
|
+
[key]: defaultValue,
|
|
108
|
+
}), {});
|
|
109
|
+
};
|
|
110
|
+
exports.enumToObj = enumToObj;
|
package/models/User/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LanguagesTypes } from '../../lang';
|
|
2
2
|
import { DocumentSnapshot } from '../../types/firestore';
|
|
3
3
|
import UserBasic from './basic';
|
|
4
|
-
import { UserAppConfig, UserData, UserNotificationSettings, UserRole } from './types';
|
|
4
|
+
import { UserAppConfig, UserData, UserEmailSettings, UserNotificationSettings, UserRole } from './types';
|
|
5
5
|
export default class User extends UserBasic<UserData> {
|
|
6
6
|
constructor(doc: DocumentSnapshot);
|
|
7
7
|
get name(): string;
|
|
@@ -28,9 +28,7 @@ export default class User extends UserBasic<UserData> {
|
|
|
28
28
|
get isAdmin(): boolean;
|
|
29
29
|
get birthDate(): import("../../types/firestore").Timestamp | null;
|
|
30
30
|
get notificationSettings(): Record<UserNotificationSettings, boolean>;
|
|
31
|
-
|
|
32
|
-
get disabledNotifications(): Record<string, boolean>;
|
|
33
|
-
get activeDisabledNotifications(): string[];
|
|
31
|
+
get emailSettings(): Record<UserEmailSettings, boolean>;
|
|
34
32
|
get isActive(): boolean;
|
|
35
33
|
get deletedAt(): import("../../types/firestore").Timestamp | null;
|
|
36
34
|
get isDeleted(): boolean;
|
package/models/User/index.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const lodash_1 = require("lodash");
|
|
7
|
+
const utils_1 = require("../../helpers/utils");
|
|
7
8
|
const lang_1 = require("../../lang");
|
|
8
9
|
const basic_1 = __importDefault(require("./basic"));
|
|
9
10
|
const types_1 = require("./types");
|
|
@@ -81,14 +82,10 @@ class User extends basic_1.default {
|
|
|
81
82
|
return this.data.birthDate;
|
|
82
83
|
}
|
|
83
84
|
get notificationSettings() {
|
|
84
|
-
return this.data.notificationSettings ||
|
|
85
|
+
return this.data.notificationSettings || (0, utils_1.enumToObj)(types_1.UserNotificationSettings, true);
|
|
85
86
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return this.data.disabledNotifications || {};
|
|
89
|
-
}
|
|
90
|
-
get activeDisabledNotifications() {
|
|
91
|
-
return Object.keys(this.disabledNotifications).filter((key) => this.disabledNotifications[key] === true);
|
|
87
|
+
get emailSettings() {
|
|
88
|
+
return this.data.emailSettings || (0, utils_1.enumToObj)(types_1.UserEmailSettings, true);
|
|
92
89
|
}
|
|
93
90
|
get isActive() {
|
|
94
91
|
return !this.isDeleted && this.hasRegistrationComplete;
|
package/models/User/types.d.ts
CHANGED
|
@@ -16,6 +16,9 @@ export declare enum UserNotificationSettings {
|
|
|
16
16
|
AttendanceConfirmed = "enabled_attendance_confirmed",
|
|
17
17
|
AttendanceDeclined = "enabled_attendance_declined"
|
|
18
18
|
}
|
|
19
|
+
export declare enum UserEmailSettings {
|
|
20
|
+
ReminderBiweeklyEvents = "enabled_reminder_biweekly_events"
|
|
21
|
+
}
|
|
19
22
|
export declare enum UserEventsFilter {
|
|
20
23
|
Month = 1,
|
|
21
24
|
Trimonth = 3,
|
|
@@ -61,11 +64,8 @@ export interface UserData extends UserBasicData {
|
|
|
61
64
|
groups: string[];
|
|
62
65
|
groups_admin: string[];
|
|
63
66
|
birthDate: Timestamp | null;
|
|
64
|
-
/** @deprecated */
|
|
65
|
-
devices: Record<string, DeviceInfo> | null;
|
|
66
67
|
notificationSettings: Record<UserNotificationSettings, boolean>;
|
|
67
|
-
|
|
68
|
-
disabledNotifications: Record<string, boolean> | null;
|
|
68
|
+
emailSettings: Record<UserEmailSettings, boolean>;
|
|
69
69
|
appConfig: {
|
|
70
70
|
[UserAppConfig.DefaultGroupId]: string | null;
|
|
71
71
|
[UserAppConfig.DefaultEventsFilter]: UserEventsFilter;
|
package/models/User/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UserEventsFilter = exports.UserNotificationSettings = exports.UserAppConfig = exports.UserRegisterVia = exports.UserRole = void 0;
|
|
3
|
+
exports.UserEventsFilter = exports.UserEmailSettings = exports.UserNotificationSettings = exports.UserAppConfig = exports.UserRegisterVia = exports.UserRole = void 0;
|
|
4
4
|
var UserRole;
|
|
5
5
|
(function (UserRole) {
|
|
6
6
|
UserRole["SuperAdmin"] = "admin";
|
|
@@ -21,6 +21,10 @@ var UserNotificationSettings;
|
|
|
21
21
|
UserNotificationSettings["AttendanceConfirmed"] = "enabled_attendance_confirmed";
|
|
22
22
|
UserNotificationSettings["AttendanceDeclined"] = "enabled_attendance_declined";
|
|
23
23
|
})(UserNotificationSettings = exports.UserNotificationSettings || (exports.UserNotificationSettings = {}));
|
|
24
|
+
var UserEmailSettings;
|
|
25
|
+
(function (UserEmailSettings) {
|
|
26
|
+
UserEmailSettings["ReminderBiweeklyEvents"] = "enabled_reminder_biweekly_events";
|
|
27
|
+
})(UserEmailSettings = exports.UserEmailSettings || (exports.UserEmailSettings = {}));
|
|
24
28
|
var UserEventsFilter;
|
|
25
29
|
(function (UserEventsFilter) {
|
|
26
30
|
UserEventsFilter[UserEventsFilter["Month"] = 1] = "Month";
|
package/package.json
CHANGED
|
@@ -11,7 +11,5 @@ export default interface MessageBirdChatWidget {
|
|
|
11
11
|
shutdown(): Promise<void>;
|
|
12
12
|
startConversation(text: string): void;
|
|
13
13
|
setLanguage(language: string): void;
|
|
14
|
-
on(event: 'ready', callback: () =>
|
|
15
|
-
on(event: 'visitorCreated', callback: (id: string) => void): void;
|
|
16
|
-
on(event: 'toggle', callback: (isOpen: boolean) => void): void;
|
|
14
|
+
on(...args: [event: 'ready', callback: () => unknown] | [event: 'visitorCreated', callback: (id: string) => unknown] | [event: 'toggle', callback: (isOpen: boolean) => unknown]): void;
|
|
17
15
|
}
|
|
@@ -11,7 +11,10 @@ export default interface MessageBirdChatWidget {
|
|
|
11
11
|
shutdown(): Promise<void>;
|
|
12
12
|
startConversation(text: string): void;
|
|
13
13
|
setLanguage(language: string): void;
|
|
14
|
-
on(
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
on(
|
|
15
|
+
...args:
|
|
16
|
+
| [event: 'ready', callback: () => unknown]
|
|
17
|
+
| [event: 'visitorCreated', callback: (id: string) => unknown]
|
|
18
|
+
| [event: 'toggle', callback: (isOpen: boolean) => unknown]
|
|
19
|
+
): void;
|
|
17
20
|
}
|