@ironcode/vas-lib 0.0.25 → 0.0.26

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.
@@ -66,7 +66,7 @@ class VasUserModel extends VasBaseModel {
66
66
  }
67
67
 
68
68
  class VasFireUserModel extends VasUserModel {
69
- constructor(id, created = '', serverCreated = '', createdBy = '', modified = '', serverModified = '', modifiedBy = '', email, username, accounts) {
69
+ constructor(id, created = '', serverCreated = '', createdBy = '', modified = '', serverModified = '', modifiedBy = '', email, username, accounts, tokens, topics) {
70
70
  super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, email, username);
71
71
  this.id = id;
72
72
  this.created = created;
@@ -78,12 +78,14 @@ class VasFireUserModel extends VasUserModel {
78
78
  this.email = email;
79
79
  this.username = username;
80
80
  this.accounts = accounts;
81
+ this.tokens = tokens;
82
+ this.topics = topics;
81
83
  }
82
84
  static fromDto(dto) {
83
- return new VasFireUserModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.email || '', dto.username || '', dto.accounts || {});
85
+ return new VasFireUserModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.email || '', dto.username || '', dto.accounts || {}, dto.tokens || [], dto.topics || []);
84
86
  }
85
87
  static newUser(uid, displayName, email) {
86
- return new VasFireUserModel(uid, moment().toISOString(), uid, moment().toISOString(), uid, moment().toISOString(), moment().toISOString(), email, displayName, {});
88
+ return new VasFireUserModel(uid, moment().toISOString(), uid, moment().toISOString(), uid, moment().toISOString(), moment().toISOString(), email, displayName, {}, [], []);
87
89
  }
88
90
  toDto() {
89
91
  return {
@@ -96,9 +98,57 @@ class VasFireUserModel extends VasUserModel {
96
98
  modifiedBy: this.modifiedBy,
97
99
  email: this.email,
98
100
  username: this.username,
99
- accounts: this.accounts
101
+ accounts: this.accounts,
102
+ tokens: this.tokens,
103
+ topics: this.topics
100
104
  };
101
105
  }
106
+ /**
107
+ * Adds token to tokens list if it is not already present
108
+ * @param token the new token
109
+ */
110
+ addToken(token) {
111
+ if (this.tokens.includes(token)) {
112
+ return;
113
+ }
114
+ this.tokens.push(token);
115
+ }
116
+ /**
117
+ * Remove token from tokens list
118
+ * @param token the token to remove
119
+ */
120
+ removeToken(token) {
121
+ this.tokens = this.tokens.filter(t => t !== token);
122
+ }
123
+ /**
124
+ * Resets the tokens list
125
+ */
126
+ resetTokens() {
127
+ this.tokens = [];
128
+ }
129
+ /**
130
+ * Adds topic to topics list if it is not already present
131
+ * @param topic the new token
132
+ */
133
+ addTopic(topic) {
134
+ if (this.topics.includes(topic)) {
135
+ return;
136
+ }
137
+ this.topics.push(topic);
138
+ }
139
+ /**
140
+ * Remove topic from topic list
141
+ * @param topic the topic to remove
142
+ */
143
+ removeTopic(topic) {
144
+ this.topics = this.topics.filter(t => t !== topic);
145
+ }
146
+ /**
147
+ * Resets the topic list
148
+ */
149
+ resetTopics() {
150
+ this.topics = [];
151
+ }
102
152
  }
103
153
 
104
154
  var VasAccountIndexingMode;