@intelact/bright 0.9.177 → 0.9.179
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/author/author.model.d.ts +1 -1
- package/lib/author/author.model.js +4 -4
- package/lib/boost/boost.model.d.ts +1 -1
- package/lib/boost/boost.model.js +16 -16
- package/lib/brand/brand.model.d.ts +4 -0
- package/lib/brand/brand.model.js +21 -0
- package/lib/brand/brand.model.js.map +1 -1
- package/lib/category/category.model.d.ts +1 -1
- package/lib/category/category.model.js +4 -4
- package/lib/collection/collection.model.d.ts +1 -1
- package/lib/collection/collection.model.js +4 -4
- package/lib/feedback/feedback-item.model.d.ts +1 -1
- package/lib/feedback/feedback-item.model.js +8 -8
- package/lib/feedback/feedback.model.d.ts +1 -1
- package/lib/feedback/feedback.model.js +6 -6
- package/lib/post/post.model.d.ts +1 -1
- package/lib/post/post.model.js +48 -48
- package/lib/promotion/promotion.model.d.ts +1 -1
- package/lib/promotion/promotion.model.js +17 -17
- package/lib/publisher/publisher.model.d.ts +1 -1
- package/lib/publisher/publisher.model.js +19 -19
- package/lib/question/comment.model.d.ts +1 -1
- package/lib/question/comment.model.js +8 -8
- package/lib/question/question.model.d.ts +1 -1
- package/lib/question/question.model.js +10 -10
- package/lib/quote/quote.model.d.ts +1 -1
- package/lib/quote/quote.model.js +4 -4
- package/lib/survey/survey.model.d.ts +1 -1
- package/lib/survey/survey.model.js +18 -18
- package/lib/topic/topic.model.d.ts +1 -1
- package/lib/topic/topic.model.js +4 -4
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/user/user.model.d.ts +1 -1
- package/lib/user/user.model.js +17 -17
- package/package.json +1 -1
@@ -39,7 +39,7 @@ class Promotion {
|
|
39
39
|
statusChangedOn;
|
40
40
|
publishedBy;
|
41
41
|
publishedOn;
|
42
|
-
|
42
|
+
authorization = {
|
43
43
|
edit: false,
|
44
44
|
publish: false,
|
45
45
|
unpublish: false,
|
@@ -61,11 +61,11 @@ class Promotion {
|
|
61
61
|
return this?.metrics?.find(i => i.event === user_1.UserEvent.Click);
|
62
62
|
}
|
63
63
|
authorize(user) {
|
64
|
-
this.
|
65
|
-
this.
|
66
|
-
this.
|
67
|
-
this.
|
68
|
-
this.
|
64
|
+
this.authorization.edit = false;
|
65
|
+
this.authorization.delete = false;
|
66
|
+
this.authorization.publish = false;
|
67
|
+
this.authorization.unpublish = false;
|
68
|
+
this.authorization.end = false;
|
69
69
|
if (!user?.isBrandUser()) {
|
70
70
|
return;
|
71
71
|
}
|
@@ -79,15 +79,15 @@ class Promotion {
|
|
79
79
|
const isPublished = this.status === status_type_1.StatusType.Published;
|
80
80
|
const isLive = this.label === status_label_1.StatusLabel.Live;
|
81
81
|
if (isDraft) {
|
82
|
-
this.
|
83
|
-
this.
|
84
|
-
this.
|
82
|
+
this.authorization.edit = !isEnded && canManage;
|
83
|
+
this.authorization.delete = !isEnded && canManage;
|
84
|
+
this.authorization.publish = !isExpired && !isEnded && canPublish;
|
85
85
|
}
|
86
86
|
if (isPublished && isUpcoming) {
|
87
|
-
this.
|
87
|
+
this.authorization.unpublish = canPublish;
|
88
88
|
}
|
89
89
|
if (isPublished && isLive) {
|
90
|
-
this.
|
90
|
+
this.authorization.end = canPublish;
|
91
91
|
}
|
92
92
|
}
|
93
93
|
setValidators() {
|
@@ -127,26 +127,26 @@ class Promotion {
|
|
127
127
|
return i;
|
128
128
|
});
|
129
129
|
let validator;
|
130
|
-
this.
|
130
|
+
this.authorization.isValid = true;
|
131
131
|
if (!this.title || this.title.trim().length === 0) {
|
132
132
|
validator = this.validators?.find(i => i.name === 'title');
|
133
133
|
validator.value = false;
|
134
|
-
this.
|
134
|
+
this.authorization.isValid = false;
|
135
135
|
}
|
136
136
|
if (!this.startDate || !this.endDate) {
|
137
137
|
validator = this.validators?.find(i => i.name === 'period');
|
138
138
|
validator.value = false;
|
139
|
-
this.
|
139
|
+
this.authorization.isValid = false;
|
140
140
|
}
|
141
141
|
if (!this.imageUrl || this.imageUrl.trim().length === 0) {
|
142
142
|
validator = this.validators?.find(i => i.name === 'image');
|
143
143
|
validator.value = false;
|
144
|
-
this.
|
144
|
+
this.authorization.isValid = false;
|
145
145
|
}
|
146
146
|
if (!this.feedUrl || this.feedUrl.trim().length === 0) {
|
147
147
|
validator = this.validators?.find(i => i.name === 'feed');
|
148
148
|
validator.value = false;
|
149
|
-
this.
|
149
|
+
this.authorization.isValid = false;
|
150
150
|
}
|
151
151
|
}
|
152
152
|
setLabel() {
|
@@ -277,7 +277,7 @@ __decorate([
|
|
277
277
|
__decorate([
|
278
278
|
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
279
279
|
__metadata("design:type", Object)
|
280
|
-
], Promotion.prototype, "
|
280
|
+
], Promotion.prototype, "authorization", void 0);
|
281
281
|
__decorate([
|
282
282
|
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
283
283
|
(0, class_transformer_1.Type)(() => item_1.Item),
|
@@ -39,7 +39,7 @@ class Publisher {
|
|
39
39
|
statusChangedOn;
|
40
40
|
invitedBy;
|
41
41
|
invitedOn;
|
42
|
-
|
42
|
+
authorization = {
|
43
43
|
edit: false,
|
44
44
|
activate: false,
|
45
45
|
deactivate: false,
|
@@ -87,19 +87,19 @@ class Publisher {
|
|
87
87
|
return data ? (0, class_transformer_1.plainToInstance)(Publisher, data, { groups: groups || [] }) : [];
|
88
88
|
}
|
89
89
|
authorize(user) {
|
90
|
-
this.
|
91
|
-
this.
|
92
|
-
this.
|
93
|
-
this.
|
94
|
-
this.
|
95
|
-
this.
|
96
|
-
this.
|
90
|
+
this.authorization.edit = false;
|
91
|
+
this.authorization.activate = false;
|
92
|
+
this.authorization.deactivate = false;
|
93
|
+
this.authorization.suspend = false;
|
94
|
+
this.authorization.delete = false;
|
95
|
+
this.authorization.close = false;
|
96
|
+
this.authorization.cancel = false;
|
97
97
|
if (user?.isPublisherUser()) {
|
98
98
|
const canManage = user.hasPermission(security_1.Permission.PublisherAccountManage);
|
99
99
|
const canClose = user.hasPermission(security_1.Permission.PublisherAccountClose);
|
100
100
|
if (this.status === account_status_1.AccountStatus.Active) {
|
101
|
-
this.
|
102
|
-
this.
|
101
|
+
this.authorization.edit = canManage;
|
102
|
+
this.authorization.close = canClose;
|
103
103
|
}
|
104
104
|
return;
|
105
105
|
}
|
@@ -110,20 +110,20 @@ class Publisher {
|
|
110
110
|
const canInvite = user?.hasPermission(security_1.Permission.BrandPublisherInvite);
|
111
111
|
switch (this.status) {
|
112
112
|
case account_status_1.AccountStatus.Active:
|
113
|
-
this.
|
114
|
-
this.
|
113
|
+
this.authorization.suspend = canSuspend;
|
114
|
+
this.authorization.deactivate = canDeactivate;
|
115
115
|
break;
|
116
116
|
case account_status_1.AccountStatus.Suspended:
|
117
|
-
this.
|
118
|
-
this.
|
119
|
-
this.
|
117
|
+
this.authorization.activate = canActivate;
|
118
|
+
this.authorization.deactivate = canDeactivate;
|
119
|
+
this.authorization.delete = canDelete;
|
120
120
|
break;
|
121
121
|
case account_status_1.AccountStatus.Disabled:
|
122
|
-
this.
|
123
|
-
this.
|
122
|
+
this.authorization.activate = canActivate;
|
123
|
+
this.authorization.delete = canDelete;
|
124
124
|
break;
|
125
125
|
case account_status_1.AccountStatus.Invited:
|
126
|
-
this.
|
126
|
+
this.authorization.cancel = canInvite;
|
127
127
|
break;
|
128
128
|
}
|
129
129
|
}
|
@@ -228,7 +228,7 @@ __decorate([
|
|
228
228
|
__decorate([
|
229
229
|
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
230
230
|
__metadata("design:type", Object)
|
231
|
-
], Publisher.prototype, "
|
231
|
+
], Publisher.prototype, "authorization", void 0);
|
232
232
|
__decorate([
|
233
233
|
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
234
234
|
__metadata("design:type", Function),
|
@@ -30,7 +30,7 @@ class QuestionComment {
|
|
30
30
|
statusChangedOn;
|
31
31
|
publishedBy;
|
32
32
|
publishedOn;
|
33
|
-
|
33
|
+
authorization = {
|
34
34
|
manage: false,
|
35
35
|
publish: false,
|
36
36
|
unpublish: false,
|
@@ -45,18 +45,18 @@ class QuestionComment {
|
|
45
45
|
return data ? (0, class_transformer_1.plainToInstance)(QuestionComment, data, { groups: groups || [] }) : [];
|
46
46
|
}
|
47
47
|
authorize(user) {
|
48
|
-
this.
|
49
|
-
this.
|
50
|
-
this.
|
48
|
+
this.authorization.manage = false;
|
49
|
+
this.authorization.publish = false;
|
50
|
+
this.authorization.unpublish = false;
|
51
51
|
if (!user?.isBrandUser()) {
|
52
52
|
return;
|
53
53
|
}
|
54
54
|
const canManage = user.hasPermission(security_1.Permission.QuestionManage);
|
55
55
|
const canPublish = user.hasPermission(security_1.Permission.QuestionPublish);
|
56
56
|
const isPublished = this.status === status_type_1.StatusType.Published;
|
57
|
-
this.
|
58
|
-
this.
|
59
|
-
this.
|
57
|
+
this.authorization.manage = canManage && !isPublished;
|
58
|
+
this.authorization.publish = canPublish && !isPublished;
|
59
|
+
this.authorization.unpublish = canPublish && isPublished;
|
60
60
|
}
|
61
61
|
}
|
62
62
|
exports.QuestionComment = QuestionComment;
|
@@ -125,7 +125,7 @@ __decorate([
|
|
125
125
|
__decorate([
|
126
126
|
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
127
127
|
__metadata("design:type", Object)
|
128
|
-
], QuestionComment.prototype, "
|
128
|
+
], QuestionComment.prototype, "authorization", void 0);
|
129
129
|
__decorate([
|
130
130
|
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
131
131
|
__metadata("design:type", Function),
|
@@ -45,7 +45,7 @@ class Question {
|
|
45
45
|
user;
|
46
46
|
comments;
|
47
47
|
categories;
|
48
|
-
|
48
|
+
authorization = {
|
49
49
|
manage: false,
|
50
50
|
close: false,
|
51
51
|
publish: false,
|
@@ -76,17 +76,17 @@ class Question {
|
|
76
76
|
return data ? (0, class_transformer_1.plainToInstance)(Question, data, { groups: groups || [] }) : [];
|
77
77
|
}
|
78
78
|
authorize(user) {
|
79
|
-
this.
|
80
|
-
this.
|
81
|
-
this.
|
82
|
-
this.
|
79
|
+
this.authorization.manage = false;
|
80
|
+
this.authorization.publish = false;
|
81
|
+
this.authorization.close = false;
|
82
|
+
this.authorization.attention = false;
|
83
83
|
if (!user?.isBrandUser()) {
|
84
84
|
return;
|
85
85
|
}
|
86
|
-
this.
|
87
|
-
this.
|
88
|
-
this.
|
89
|
-
this.
|
86
|
+
this.authorization.manage = user?.hasPermission(security_1.Permission.QuestionManage);
|
87
|
+
this.authorization.publish = user?.hasPermission(security_1.Permission.QuestionPublish);
|
88
|
+
this.authorization.close = !this.closed;
|
89
|
+
this.authorization.attention = !this.attentionOn;
|
90
90
|
if (this.comments?.length) {
|
91
91
|
for (const comment of this.comments) {
|
92
92
|
comment.authorize(user);
|
@@ -216,7 +216,7 @@ __decorate([
|
|
216
216
|
__decorate([
|
217
217
|
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
218
218
|
__metadata("design:type", Object)
|
219
|
-
], Question.prototype, "
|
219
|
+
], Question.prototype, "authorization", void 0);
|
220
220
|
__decorate([
|
221
221
|
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
222
222
|
__metadata("design:type", Function),
|
package/lib/quote/quote.model.js
CHANGED
@@ -20,18 +20,18 @@ class Quote {
|
|
20
20
|
publisher;
|
21
21
|
imageUrl;
|
22
22
|
post;
|
23
|
-
|
23
|
+
authorization = {
|
24
24
|
manage: false
|
25
25
|
};
|
26
26
|
constructor(props) {
|
27
27
|
Object.assign(this, props);
|
28
28
|
}
|
29
29
|
authorize(user, publisher) {
|
30
|
-
this.
|
30
|
+
this.authorization.manage = false;
|
31
31
|
if (!user?.isPublisherUser() || publisher?.status !== security_1.AccountStatus.Active) {
|
32
32
|
return;
|
33
33
|
}
|
34
|
-
this.
|
34
|
+
this.authorization.manage = user?.hasPermission(security_1.Permission.QuoteManage);
|
35
35
|
}
|
36
36
|
}
|
37
37
|
exports.Quote = Quote;
|
@@ -57,7 +57,7 @@ __decorate([
|
|
57
57
|
__decorate([
|
58
58
|
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
59
59
|
__metadata("design:type", Object)
|
60
|
-
], Quote.prototype, "
|
60
|
+
], Quote.prototype, "authorization", void 0);
|
61
61
|
__decorate([
|
62
62
|
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
63
63
|
__metadata("design:type", Function),
|
@@ -43,7 +43,7 @@ class Survey {
|
|
43
43
|
statusChangedOn;
|
44
44
|
publishedBy;
|
45
45
|
publishedOn;
|
46
|
-
|
46
|
+
authorization = {
|
47
47
|
edit: false,
|
48
48
|
publish: false,
|
49
49
|
unpublish: false,
|
@@ -68,11 +68,11 @@ class Survey {
|
|
68
68
|
return this?.metrics?.find(i => i.event === metric_1.MetricType.Items);
|
69
69
|
}
|
70
70
|
authorize(user) {
|
71
|
-
this.
|
72
|
-
this.
|
73
|
-
this.
|
74
|
-
this.
|
75
|
-
this.
|
71
|
+
this.authorization.edit = false;
|
72
|
+
this.authorization.delete = false;
|
73
|
+
this.authorization.publish = false;
|
74
|
+
this.authorization.unpublish = false;
|
75
|
+
this.authorization.end = false;
|
76
76
|
this.setLabel();
|
77
77
|
if (!user?.isBrandUser()) {
|
78
78
|
return;
|
@@ -86,15 +86,15 @@ class Survey {
|
|
86
86
|
const isPublished = this.status === status_type_1.StatusType.Published;
|
87
87
|
const isLive = this.label === status_label_1.StatusLabel.Live;
|
88
88
|
if (isDraft) {
|
89
|
-
this.
|
90
|
-
this.
|
91
|
-
this.
|
89
|
+
this.authorization.edit = !isEnded && canManage;
|
90
|
+
this.authorization.delete = !isEnded && canManage;
|
91
|
+
this.authorization.publish = !isExpired && !isEnded && canPublish;
|
92
92
|
}
|
93
93
|
if (isPublished && isUpcoming) {
|
94
|
-
this.
|
94
|
+
this.authorization.unpublish = canPublish;
|
95
95
|
}
|
96
96
|
if (isPublished && isLive) {
|
97
|
-
this.
|
97
|
+
this.authorization.end = canPublish;
|
98
98
|
}
|
99
99
|
}
|
100
100
|
setValidators() {
|
@@ -136,7 +136,7 @@ class Survey {
|
|
136
136
|
this.setValidators();
|
137
137
|
}
|
138
138
|
let validator;
|
139
|
-
this.
|
139
|
+
this.authorization.isValid = true;
|
140
140
|
this.validators = this.validators.map(i => {
|
141
141
|
i.value = true;
|
142
142
|
return i;
|
@@ -144,27 +144,27 @@ class Survey {
|
|
144
144
|
if (!this.name || this.name.trim().length === 0) {
|
145
145
|
validator = this.validators?.find(i => i.name === 'name');
|
146
146
|
validator.value = false;
|
147
|
-
this.
|
147
|
+
this.authorization.isValid = false;
|
148
148
|
}
|
149
149
|
if (!this.description || this.description.trim().length === 0) {
|
150
150
|
validator = this.validators?.find(i => i.name === 'description');
|
151
151
|
validator.value = false;
|
152
|
-
this.
|
152
|
+
this.authorization.isValid = false;
|
153
153
|
}
|
154
154
|
if (!this.startDate || !this.endDate) {
|
155
155
|
validator = this.validators?.find(i => i.name === 'period');
|
156
156
|
validator.value = false;
|
157
|
-
this.
|
157
|
+
this.authorization.isValid = false;
|
158
158
|
}
|
159
159
|
if (!this.imageUrl || this.imageUrl.trim().length === 0) {
|
160
160
|
validator = this.validators?.find(i => i.name === 'image');
|
161
161
|
validator.value = false;
|
162
|
-
this.
|
162
|
+
this.authorization.isValid = false;
|
163
163
|
}
|
164
164
|
if (!this.items || this.items.length === 0) {
|
165
165
|
validator = this.validators?.find(i => i.name === 'items');
|
166
166
|
validator.value = false;
|
167
|
-
this.
|
167
|
+
this.authorization.isValid = false;
|
168
168
|
}
|
169
169
|
}
|
170
170
|
setLabel() {
|
@@ -305,7 +305,7 @@ __decorate([
|
|
305
305
|
__decorate([
|
306
306
|
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
307
307
|
__metadata("design:type", Object)
|
308
|
-
], Survey.prototype, "
|
308
|
+
], Survey.prototype, "authorization", void 0);
|
309
309
|
__decorate([
|
310
310
|
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
311
311
|
(0, class_transformer_1.Type)(() => item_1.Item),
|
package/lib/topic/topic.model.js
CHANGED
@@ -31,7 +31,7 @@ class Topic {
|
|
31
31
|
createdOn;
|
32
32
|
updatedBy;
|
33
33
|
updatedOn;
|
34
|
-
|
34
|
+
authorization = {
|
35
35
|
manage: false
|
36
36
|
};
|
37
37
|
constructor(props) {
|
@@ -70,11 +70,11 @@ class Topic {
|
|
70
70
|
return data ? (0, class_transformer_1.plainToInstance)(Topic, data, { groups: groups || [] }) : [];
|
71
71
|
}
|
72
72
|
authorize(user) {
|
73
|
-
this.
|
73
|
+
this.authorization.manage = false;
|
74
74
|
if (!user?.isBrandUser()) {
|
75
75
|
return;
|
76
76
|
}
|
77
|
-
this.
|
77
|
+
this.authorization.manage = user?.hasPermission(security_1.Permission.TopicManage);
|
78
78
|
}
|
79
79
|
}
|
80
80
|
exports.Topic = Topic;
|
@@ -139,7 +139,7 @@ __decorate([
|
|
139
139
|
__decorate([
|
140
140
|
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
141
141
|
__metadata("design:type", Object)
|
142
|
-
], Topic.prototype, "
|
142
|
+
], Topic.prototype, "authorization", void 0);
|
143
143
|
__decorate([
|
144
144
|
(0, class_transformer_1.Expose)({ groups: ['admin'] }),
|
145
145
|
__metadata("design:type", Function),
|