@clxmedia/xperience-rights-client 1.0.11 → 1.1.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.
- package/dist/client.js +67 -26
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -2,30 +2,62 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.XperienceRightsClient = exports.FRIENDLY_SCOPE_NAMES = exports.CLIQ_ROLES = exports.CLIQ_GROUPS = exports.ODOO_ROLES = void 0;
|
|
4
4
|
exports.ODOO_ROLES = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
'
|
|
5
|
+
proofing_contact: {
|
|
6
|
+
id: 2,
|
|
7
|
+
name: 'Proofing Contact',
|
|
8
|
+
slug: 'proofing_contact',
|
|
9
|
+
},
|
|
10
|
+
reporting_contact: {
|
|
11
|
+
id: 3,
|
|
12
|
+
name: 'Reporting Contact',
|
|
13
|
+
slug: 'reporting_contact',
|
|
14
|
+
},
|
|
15
|
+
billing_contact: { id: 4, name: 'Billing Contact', slug: 'billing_contact' },
|
|
16
|
+
marketing_contact: {
|
|
17
|
+
id: 5,
|
|
18
|
+
name: 'Marketing Contact',
|
|
19
|
+
slug: 'marketing_contact',
|
|
20
|
+
},
|
|
21
|
+
video_producer: { id: 8, name: 'Video Producer', slug: 'video_producer' },
|
|
22
|
+
regional_contact: {
|
|
23
|
+
id: 9,
|
|
24
|
+
name: 'Regional Contact',
|
|
25
|
+
slug: 'regional_contact',
|
|
26
|
+
},
|
|
27
|
+
accounts_payable: {
|
|
28
|
+
id: 16,
|
|
29
|
+
name: 'Accounts Payable',
|
|
30
|
+
slug: 'accounts_payable',
|
|
31
|
+
},
|
|
32
|
+
main: { id: 17, name: 'Main', slug: 'main' },
|
|
33
|
+
website_contact: { id: 18, name: 'Website Contact', slug: 'website_contact' },
|
|
34
|
+
gtm_contact: { id: 19, name: 'GTM Contact', slug: 'gtm_contact' },
|
|
35
|
+
ga_contact: { id: 20, name: 'GA Contact', slug: 'ga_contact' },
|
|
36
|
+
gbp_contact: { id: 21, name: 'GBP Contact', slug: 'gbp_contact' },
|
|
37
|
+
fb_contact: { id: 22, name: 'FB Contact', slug: 'fb_contact' },
|
|
38
|
+
crm_contact: { id: 23, name: 'CRM Contact', slug: 'crm_contact' },
|
|
39
|
+
tcc_chat_contact: {
|
|
40
|
+
id: 24,
|
|
41
|
+
name: 'TCC/Chat Contact',
|
|
42
|
+
slug: 'tcc_chat_contact',
|
|
43
|
+
},
|
|
44
|
+
leasing_community_manager: {
|
|
45
|
+
id: 25,
|
|
46
|
+
name: 'Leasing/Community Manager',
|
|
47
|
+
slug: 'leasing_community_manager',
|
|
48
|
+
},
|
|
49
|
+
pausing_notifications_contact: {
|
|
22
50
|
id: 27,
|
|
23
51
|
name: 'Pausing Notifications Contact',
|
|
24
|
-
slug: '
|
|
52
|
+
slug: 'pausing_notifications_contact',
|
|
53
|
+
},
|
|
54
|
+
bov_contact: { id: 28, name: 'BOV Contact', slug: 'bov_contact' },
|
|
55
|
+
contract_signee: { id: 29, name: 'Contract Signee', slug: 'contract_signee' },
|
|
56
|
+
onboarding_contact: {
|
|
57
|
+
id: 30,
|
|
58
|
+
name: 'Onboarding Contact',
|
|
59
|
+
slug: 'onboarding_contact',
|
|
25
60
|
},
|
|
26
|
-
'28-BOV Contact': { id: 28, name: 'BOV Contact', slug: '28-BOV Contact' },
|
|
27
|
-
'29-Contract Signee': { id: 29, name: 'Contract Signee', slug: '29-Contract Signee' },
|
|
28
|
-
'30-Onboarding Contact': { id: 30, name: 'Onboarding Contact', slug: '30-Onboarding Contact' },
|
|
29
61
|
};
|
|
30
62
|
exports.CLIQ_GROUPS = {
|
|
31
63
|
ad_reviewer: 'Property Ad Reviewers',
|
|
@@ -107,13 +139,16 @@ class XperienceRightsClient {
|
|
|
107
139
|
}
|
|
108
140
|
if (locator.type === 'right') {
|
|
109
141
|
const [scope, ability] = locator.value.split('@');
|
|
110
|
-
return long
|
|
142
|
+
return long
|
|
143
|
+
? `any ${locator.constraint ? `${locator.constraint} ` : ''}user with the ${exports.FRIENDLY_SCOPE_NAMES[scope]} ${ability} rights`
|
|
144
|
+
: `${exports.FRIENDLY_SCOPE_NAMES[scope]} ${ability}${locator.constraint ? ` (${locator.constraint})` : ''}`;
|
|
111
145
|
}
|
|
112
146
|
if (locator.type === 'odoo_role') {
|
|
113
|
-
return `${long ? 'any user with the Odoo role: ' : ''}${exports.ODOO_ROLES[locator.value]
|
|
147
|
+
return `${long ? 'any user with the Odoo role: ' : ''}${exports.ODOO_ROLES[locator.value]
|
|
148
|
+
? exports.ODOO_ROLES[locator.value].name
|
|
149
|
+
: locator.value}`;
|
|
114
150
|
}
|
|
115
151
|
}
|
|
116
|
-
;
|
|
117
152
|
static isGroupMember(data, group, qualifier) {
|
|
118
153
|
if (!data || !data.groups || !data.groups[group]) {
|
|
119
154
|
return false;
|
|
@@ -121,7 +156,11 @@ class XperienceRightsClient {
|
|
|
121
156
|
if (!qualifier) {
|
|
122
157
|
qualifier = 0;
|
|
123
158
|
}
|
|
124
|
-
return data.groups[group].qualifiers.includes(0) ||
|
|
159
|
+
return (data.groups[group].qualifiers.includes(0) ||
|
|
160
|
+
data.groups[group].qualifiers.includes(qualifier) ||
|
|
161
|
+
(data.groups[group].common &&
|
|
162
|
+
(data.commonQualifiers.includes(qualifier) ||
|
|
163
|
+
data.commonQualifiers.includes(0))));
|
|
125
164
|
}
|
|
126
165
|
static abilityValue(ability) {
|
|
127
166
|
switch (ability) {
|
|
@@ -147,7 +186,9 @@ class XperienceRightsClient {
|
|
|
147
186
|
}
|
|
148
187
|
static bestAbility(...abilities) {
|
|
149
188
|
return abilities.reduce((best, current) => {
|
|
150
|
-
return XperienceRightsClient.compareAbilities(current, best, 'better')
|
|
189
|
+
return XperienceRightsClient.compareAbilities(current, best, 'better')
|
|
190
|
+
? current
|
|
191
|
+
: best;
|
|
151
192
|
}, 'none');
|
|
152
193
|
}
|
|
153
194
|
static xperienceScopeName(scope) {
|