@glissandoo/lib 1.9.2 → 1.10.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.
@@ -1,5 +1,6 @@
1
1
  import { EventoFbFunctionsTypes } from '../functions/event';
2
2
  import { NotificationActions } from '../models/Notification/types';
3
+ import { UserNotificationSettings } from '../models/User/types';
3
4
  import { BadgesTypes } from './badges';
4
5
  export declare const notificationActionsBadges: Record<BadgesTypes, {
5
6
  firstLevel: NotificationActions;
@@ -32,8 +33,5 @@ declare type RelationActionNotification = Record<NotificationEventActions, Notif
32
33
  export declare const notificationPerformance: RelationActionNotification;
33
34
  export declare const notificationSinglePractice: RelationActionNotification;
34
35
  export declare const notificationMultiplePractice: RelationActionNotification;
35
- export declare const disabledNotificationsByUserConfig: {
36
- eventAssistanceConfirm: NotificationActions[];
37
- eventAssistanceDecline: NotificationActions[];
38
- };
36
+ export declare const userNotificationSettings: Record<UserNotificationSettings, NotificationActions[]>;
39
37
  export {};
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.disabledNotificationsByUserConfig = exports.notificationMultiplePractice = exports.notificationSinglePractice = exports.notificationPerformance = exports.editScopeToAction = exports.NotificationEventActions = exports.notificationActionsBadges = void 0;
3
+ exports.userNotificationSettings = exports.notificationMultiplePractice = exports.notificationSinglePractice = exports.notificationPerformance = exports.editScopeToAction = exports.NotificationEventActions = exports.notificationActionsBadges = void 0;
4
4
  const types_1 = require("../models/Notification/types");
5
+ const types_2 = require("../models/User/types");
5
6
  const badges_1 = require("./badges");
6
7
  exports.notificationActionsBadges = {
7
8
  [badges_1.BadgesTypes.AccPerformances]: {
@@ -113,12 +114,12 @@ exports.notificationMultiplePractice = {
113
114
  reminderMorningPending: types_1.NotificationActions.PracticeMorningReminderPending,
114
115
  reminderRollcall: types_1.NotificationActions.PracticeRollCallReminder,
115
116
  };
116
- exports.disabledNotificationsByUserConfig = {
117
- eventAssistanceConfirm: [
117
+ exports.userNotificationSettings = {
118
+ [types_2.UserNotificationSettings.AttendanceConfirmed]: [
118
119
  types_1.NotificationActions.PerformanceAssistanceConfirm,
119
120
  types_1.NotificationActions.PracticeAssistanceConfirm,
120
121
  ],
121
- eventAssistanceDecline: [
122
+ [types_2.UserNotificationSettings.AttendanceDeclined]: [
122
123
  types_1.NotificationActions.PerformanceAssistanceDecline,
123
124
  types_1.NotificationActions.PracticeAssistanceDecline,
124
125
  ],
@@ -1,6 +1,6 @@
1
1
  import { DocumentSnapshot } from '@google-cloud/firestore';
2
2
  import UserBasic from './basic';
3
- import { UserAppConfig, UserData, UserRole } from './types';
3
+ import { UserAppConfig, UserData, UserNotificationSettings, UserRole } from './types';
4
4
  export default class User extends UserBasic<UserData> {
5
5
  constructor(doc: DocumentSnapshot);
6
6
  get name(): string;
@@ -25,18 +25,8 @@ export default class User extends UserBasic<UserData> {
25
25
  get groupsAdmin(): string[];
26
26
  get isAdmin(): boolean;
27
27
  get birthDate(): FirebaseFirestore.Timestamp | null;
28
+ get notificationSettings(): Record<UserNotificationSettings, boolean>;
28
29
  /** @deprecated */
29
- private get devices();
30
- /** @deprecated */
31
- get devicesList(): (import("./types").DeviceInfo & {
32
- id: string;
33
- })[];
34
- /** @deprecated */
35
- get hasDevices(): boolean;
36
- /** @deprecated */
37
- get device(): (import("./types").DeviceInfo & {
38
- id: string;
39
- }) | null;
40
30
  get disabledNotifications(): Record<string, boolean>;
41
31
  get activeDisabledNotifications(): string[];
42
32
  get isActive(): boolean;
@@ -47,6 +37,7 @@ export default class User extends UserBasic<UserData> {
47
37
  default_events_filter: import("./types").UserEventsFilter;
48
38
  };
49
39
  getAppConfig(value: UserAppConfig): string | import("./types").UserEventsFilter | null;
40
+ getNotificationSetting(key: UserNotificationSettings): boolean;
50
41
  get registerVia(): import("./types").UserRegisterVia;
51
42
  get lastAppLoginAt(): FirebaseFirestore.Timestamp | null;
52
43
  }
@@ -4,7 +4,6 @@ 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 orderBy_1 = __importDefault(require("lodash/orderBy"));
8
7
  const lang_1 = require("../../lang");
9
8
  const basic_1 = __importDefault(require("./basic"));
10
9
  const types_1 = require("./types");
@@ -78,26 +77,10 @@ class User extends basic_1.default {
78
77
  get birthDate() {
79
78
  return this.data.birthDate;
80
79
  }
81
- /** @deprecated */
82
- get devices() {
83
- return this.data.devices || {};
84
- }
85
- /** @deprecated */
86
- get devicesList() {
87
- const list = Object.keys(this.devices).map((id) => Object.assign(this.devices[id], { id }));
88
- return orderBy_1.default(list, (device) => device.last_seen_at.toDate(), ['desc']);
80
+ get notificationSettings() {
81
+ return this.data.notificationSettings || {};
89
82
  }
90
83
  /** @deprecated */
91
- get hasDevices() {
92
- return this.devicesList.length > 0;
93
- }
94
- /** @deprecated */
95
- get device() {
96
- if (this.hasDevices) {
97
- return this.devicesList[0];
98
- }
99
- return null;
100
- }
101
84
  get disabledNotifications() {
102
85
  return this.data.disabledNotifications || {};
103
86
  }
@@ -119,6 +102,9 @@ class User extends basic_1.default {
119
102
  getAppConfig(value) {
120
103
  return this.data.appConfig[value];
121
104
  }
105
+ getNotificationSetting(key) {
106
+ return this.data.notificationSettings[key] || false;
107
+ }
122
108
  get registerVia() {
123
109
  return this.data.registerVia || null;
124
110
  }
@@ -12,6 +12,10 @@ export declare enum UserAppConfig {
12
12
  DefaultGroupId = "default_group_id",
13
13
  DefaultEventsFilter = "default_events_filter"
14
14
  }
15
+ export declare enum UserNotificationSettings {
16
+ AttendanceConfirmed = "enabled_attendance_confirmed",
17
+ AttendanceDeclined = "enabled_attendance_declined"
18
+ }
15
19
  export declare enum UserEventsFilter {
16
20
  Month = 1,
17
21
  Trimonth = 3,
@@ -58,6 +62,8 @@ export interface UserData extends UserBasicData {
58
62
  birthDate: Timestamp | null;
59
63
  /** @deprecated */
60
64
  devices: Record<string, DeviceInfo> | null;
65
+ notificationSettings: Record<UserNotificationSettings, boolean>;
66
+ /** @deprecated */
61
67
  disabledNotifications: Record<string, boolean> | null;
62
68
  appConfig: {
63
69
  [UserAppConfig.DefaultGroupId]: string | null;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UserEventsFilter = exports.UserAppConfig = exports.UserRegisterVia = exports.UserRole = void 0;
3
+ exports.UserEventsFilter = exports.UserNotificationSettings = exports.UserAppConfig = exports.UserRegisterVia = exports.UserRole = void 0;
4
4
  var UserRole;
5
5
  (function (UserRole) {
6
6
  UserRole["SuperAdmin"] = "admin";
@@ -16,6 +16,11 @@ var UserAppConfig;
16
16
  UserAppConfig["DefaultGroupId"] = "default_group_id";
17
17
  UserAppConfig["DefaultEventsFilter"] = "default_events_filter";
18
18
  })(UserAppConfig = exports.UserAppConfig || (exports.UserAppConfig = {}));
19
+ var UserNotificationSettings;
20
+ (function (UserNotificationSettings) {
21
+ UserNotificationSettings["AttendanceConfirmed"] = "enabled_attendance_confirmed";
22
+ UserNotificationSettings["AttendanceDeclined"] = "enabled_attendance_declined";
23
+ })(UserNotificationSettings = exports.UserNotificationSettings || (exports.UserNotificationSettings = {}));
19
24
  var UserEventsFilter;
20
25
  (function (UserEventsFilter) {
21
26
  UserEventsFilter[UserEventsFilter["Month"] = 1] = "Month";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glissandoo/lib",
3
- "version": "1.9.2",
3
+ "version": "1.10.0",
4
4
  "description": "Glissandoo library js",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",