@clxmedia/xperience-rights-client 1.0.10 → 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 +68 -26
- package/package.json +2 -2
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',
|
|
@@ -61,6 +93,7 @@ exports.FRIENDLY_SCOPE_NAMES = {
|
|
|
61
93
|
adrequests: 'Ad Requests',
|
|
62
94
|
dashboard: 'Dashboard',
|
|
63
95
|
videoreview: 'Video Review',
|
|
96
|
+
video: 'Video',
|
|
64
97
|
tcc: 'The Conversion Cloud',
|
|
65
98
|
};
|
|
66
99
|
class XperienceRightsClient {
|
|
@@ -106,13 +139,16 @@ class XperienceRightsClient {
|
|
|
106
139
|
}
|
|
107
140
|
if (locator.type === 'right') {
|
|
108
141
|
const [scope, ability] = locator.value.split('@');
|
|
109
|
-
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})` : ''}`;
|
|
110
145
|
}
|
|
111
146
|
if (locator.type === 'odoo_role') {
|
|
112
|
-
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}`;
|
|
113
150
|
}
|
|
114
151
|
}
|
|
115
|
-
;
|
|
116
152
|
static isGroupMember(data, group, qualifier) {
|
|
117
153
|
if (!data || !data.groups || !data.groups[group]) {
|
|
118
154
|
return false;
|
|
@@ -120,7 +156,11 @@ class XperienceRightsClient {
|
|
|
120
156
|
if (!qualifier) {
|
|
121
157
|
qualifier = 0;
|
|
122
158
|
}
|
|
123
|
-
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))));
|
|
124
164
|
}
|
|
125
165
|
static abilityValue(ability) {
|
|
126
166
|
switch (ability) {
|
|
@@ -146,7 +186,9 @@ class XperienceRightsClient {
|
|
|
146
186
|
}
|
|
147
187
|
static bestAbility(...abilities) {
|
|
148
188
|
return abilities.reduce((best, current) => {
|
|
149
|
-
return XperienceRightsClient.compareAbilities(current, best, 'better')
|
|
189
|
+
return XperienceRightsClient.compareAbilities(current, best, 'better')
|
|
190
|
+
? current
|
|
191
|
+
: best;
|
|
150
192
|
}, 'none');
|
|
151
193
|
}
|
|
152
194
|
static xperienceScopeName(scope) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clxmedia/xperience-rights-client",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "CLXperience Rights Client",
|
|
5
5
|
"author": "Brandon Thompson <brandont@clxmedia.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"bugs": "https://github.com/adsupnow/xperience-library/xperience-rights-client",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@clxmedia/types": "1.0.
|
|
35
|
+
"@clxmedia/types": "1.0.155"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/jest": "29.5.11",
|