@clxmedia/xperience-rights-client 1.1.8 → 1.1.10

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.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { CLiQUserLocator, XperienceAbility, XperienceRightsData, XperienceScopes } from '@clxmedia/types/core/auth';
2
- import { FeatureFlagStrategyDefinition } from '@clxmedia/types/core/features';
1
+ import { CLiQUserLocator, XperienceAbility, XperienceRightsData, XperienceScopes } from "@clxmedia/types/core/auth";
2
+ import { FeatureFlagStrategyDefinition } from "@clxmedia/types/core/features";
3
3
  export type OdooRole = {
4
4
  id: number;
5
5
  slug: string;
@@ -23,7 +23,7 @@ export declare class XperienceRightsClient {
23
23
  static featureFlagEnabled(data: XperienceRightsData, strategies: FeatureFlagStrategyDefinition[], qualifier?: number): boolean;
24
24
  static isGroupMember(data: XperienceRightsData, group: string, qualifier?: number): boolean;
25
25
  static abilityValue(ability: XperienceAbility): number;
26
- static compareAbilities(a: XperienceAbility, b: XperienceAbility, comparison?: 'enough' | 'better'): boolean;
26
+ static compareAbilities(a: XperienceAbility, b: XperienceAbility, comparison?: "enough" | "better"): boolean;
27
27
  static bestAbility(...abilities: XperienceAbility[]): XperienceAbility;
28
28
  static xperienceScopeName(scope: XperienceScopes): string;
29
29
  }
package/dist/client.js CHANGED
@@ -4,108 +4,114 @@ exports.XperienceRightsClient = exports.FRIENDLY_SCOPE_NAMES = exports.CLIQ_ROLE
4
4
  exports.ODOO_ROLES = {
5
5
  proofing_contact: {
6
6
  id: 2,
7
- name: 'Proofing Contact',
8
- slug: 'proofing_contact',
7
+ name: "Proofing Contact",
8
+ slug: "proofing_contact",
9
9
  },
10
10
  reporting_contact: {
11
11
  id: 3,
12
- name: 'Reporting Contact',
13
- slug: 'reporting_contact',
12
+ name: "Reporting Contact",
13
+ slug: "reporting_contact",
14
14
  },
15
- billing_contact: { id: 4, name: 'Billing Contact', slug: 'billing_contact' },
15
+ billing_contact: { id: 4, name: "Billing Contact", slug: "billing_contact" },
16
16
  marketing_contact: {
17
17
  id: 5,
18
- name: 'Marketing Contact',
19
- slug: 'marketing_contact',
18
+ name: "Marketing Contact",
19
+ slug: "marketing_contact",
20
20
  },
21
- video_producer: { id: 8, name: 'Video Producer', slug: 'video_producer' },
21
+ video_producer: { id: 8, name: "Video Producer", slug: "video_producer" },
22
22
  regional_contact: {
23
23
  id: 9,
24
- name: 'Regional Contact',
25
- slug: 'regional_contact',
24
+ name: "Regional Contact",
25
+ slug: "regional_contact",
26
26
  },
27
27
  accounts_payable: {
28
28
  id: 16,
29
- name: 'Accounts Payable',
30
- slug: 'accounts_payable',
29
+ name: "Accounts Payable",
30
+ slug: "accounts_payable",
31
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' },
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
39
  tcc_chat_contact: {
40
40
  id: 24,
41
- name: 'TCC/Chat Contact',
42
- slug: 'tcc_chat_contact',
41
+ name: "TCC/Chat Contact",
42
+ slug: "tcc_chat_contact",
43
43
  },
44
44
  leasing_community_manager: {
45
45
  id: 25,
46
- name: 'Leasing/Community Manager',
47
- slug: 'leasing_community_manager',
46
+ name: "Leasing/Community Manager",
47
+ slug: "leasing_community_manager",
48
48
  },
49
49
  pausing_notifications_contact: {
50
50
  id: 27,
51
- name: 'Pausing Notifications Contact',
52
- slug: 'pausing_notifications_contact',
51
+ name: "Pausing Notifications Contact",
52
+ slug: "pausing_notifications_contact",
53
53
  },
54
- bov_contact: { id: 28, name: 'BOV Contact', slug: 'bov_contact' },
55
- contract_signee: { id: 29, name: 'Contract Signee', slug: 'contract_signee' },
54
+ bov_contact: { id: 28, name: "BOV Contact", slug: "bov_contact" },
55
+ contract_signee: { id: 29, name: "Contract Signee", slug: "contract_signee" },
56
56
  onboarding_contact: {
57
57
  id: 30,
58
- name: 'Onboarding Contact',
59
- slug: 'onboarding_contact',
58
+ name: "Onboarding Contact",
59
+ slug: "onboarding_contact",
60
60
  },
61
61
  };
62
62
  exports.CLIQ_GROUPS = {
63
- ad_reviewer: 'Property Ad Reviewers',
64
- company_billing: 'Property Billing Admins',
65
- company_user: 'Property Users',
66
- accounting: 'Conversion Logix Accounting',
67
- cs_group: 'CS Group',
68
- superuser: 'Superusers',
69
- account_manager: 'Account Managers',
70
- clx_staff: 'Conversion Logix Staff',
71
- implementation_group: 'Implementation Group',
63
+ account_manager: "Account Managers",
64
+ accounting: "Conversion Logix Accounting",
65
+ ad_reviewer: "Client Ad Approvers",
66
+ ad_viewer: "Client Ad Viewer",
67
+ clx_staff: "Conversion Logix Staff",
68
+ company_billing: "Property Billing Admins",
69
+ company_user: "Property Users",
70
+ cs_group: "CS Group",
71
+ design: "Design",
72
+ engineering: "Engineering",
73
+ implementation_group: "Implementation Group",
74
+ notifications_whitelist: "Notifications Whitelist",
75
+ operations: "Operations",
76
+ superuser: "Superusers",
72
77
  };
73
78
  exports.CLIQ_ROLES = {
74
- client_service_analyst: 'Client Service Analyst',
75
- implementation_specialist: 'Implementation Specialist',
76
- account_manager: 'Account Manager',
79
+ client_service_analyst: "Client Service Analyst",
80
+ implementation_specialist: "Implementation Specialist",
81
+ account_manager: "Account Manager",
77
82
  };
78
83
  exports.FRIENDLY_SCOPE_NAMES = {
79
- company: 'Property',
80
- tasks: 'Tasks',
81
- displayreview: 'Display Review',
82
- platform: 'Platform',
83
- users: 'Users',
84
- forms: 'Forms',
85
- gbpreview: 'GBP Review',
86
- gbpa: 'GBPA',
87
- insights: 'Insights',
88
- mac: 'Meta',
89
- macreview: 'MAC Review',
90
- billing: 'Billing',
91
- mediahub: 'Media Hub',
92
- onboarding: 'Onboarding',
93
- adrequests: 'Ad Requests',
94
- dashboard: 'Dashboard',
95
- videoreview: 'Video Review',
96
- video: 'Video',
97
- tcc: 'The Conversion Cloud',
98
- search: 'Search Builder',
99
- searchreview: 'Search Review',
84
+ company: "Property",
85
+ tasks: "Tasks",
86
+ displayreview: "Display Review",
87
+ platform: "Platform",
88
+ users: "Users",
89
+ forms: "Forms",
90
+ gbpreview: "GBP Review",
91
+ gbpa: "GBPA",
92
+ insights: "Insights",
93
+ mac: "Meta",
94
+ macreview: "MAC Review",
95
+ billing: "Billing",
96
+ mediahub: "Media Hub",
97
+ onboarding: "Onboarding",
98
+ adrequests: "Ad Requests",
99
+ dashboard: "Dashboard",
100
+ videoreview: "Video Review",
101
+ video: "Video",
102
+ tcc: "The Conversion Cloud",
103
+ search: "Search Builder",
104
+ searchreview: "Search Review",
105
+ pmaxreview: "PMax Review",
100
106
  };
101
107
  class XperienceRightsClient {
102
108
  static findAbility(data, scope, qualifier) {
103
109
  if (!data || !data.rights) {
104
- return 'none';
110
+ return "none";
105
111
  }
106
112
  const abilities = data.rights[scope];
107
113
  if (!abilities) {
108
- return 'none';
114
+ return "none";
109
115
  }
110
116
  if (!qualifier) {
111
117
  qualifier = 0;
@@ -124,29 +130,29 @@ class XperienceRightsClient {
124
130
  return XperienceRightsClient.bestAbility(ability, best);
125
131
  }
126
132
  return best;
127
- }, 'none');
133
+ }, "none");
128
134
  }
129
135
  static cliqLocatorDescription(locator, long = false) {
130
136
  if (!locator || !locator.type) {
131
137
  return null;
132
138
  }
133
- if (locator.type === 'user') {
139
+ if (locator.type === "user") {
134
140
  return locator.value;
135
141
  }
136
- if (locator.type === 'group') {
137
- return `${long ? 'any user in the group: ' : ''}${exports.CLIQ_GROUPS[locator.value] || locator.value}`;
142
+ if (locator.type === "group") {
143
+ return `${long ? "any user in the group: " : ""}${exports.CLIQ_GROUPS[locator.value] || locator.value}`;
138
144
  }
139
- if (locator.type === 'role') {
145
+ if (locator.type === "role") {
140
146
  return `${exports.CLIQ_ROLES[locator.value] || locator.value}`;
141
147
  }
142
- if (locator.type === 'right') {
143
- const [scope, ability] = locator.value.split('@');
148
+ if (locator.type === "right") {
149
+ const [scope, ability] = locator.value.split("@");
144
150
  return long
145
- ? `any ${locator.constraint ? `${locator.constraint} ` : ''}user with the ${exports.FRIENDLY_SCOPE_NAMES[scope]} ${ability} rights`
146
- : `${exports.FRIENDLY_SCOPE_NAMES[scope]} ${ability}${locator.constraint ? ` (${locator.constraint})` : ''}`;
151
+ ? `any ${locator.constraint ? `${locator.constraint} ` : ""}user with the ${exports.FRIENDLY_SCOPE_NAMES[scope]} ${ability} rights`
152
+ : `${exports.FRIENDLY_SCOPE_NAMES[scope]} ${ability}${locator.constraint ? ` (${locator.constraint})` : ""}`;
147
153
  }
148
- if (locator.type === 'odoo_role') {
149
- return `${long ? 'any user with the Odoo role: ' : ''}${exports.ODOO_ROLES[locator.value]
154
+ if (locator.type === "odoo_role") {
155
+ return `${long ? "any user with the Odoo role: " : ""}${exports.ODOO_ROLES[locator.value]
150
156
  ? exports.ODOO_ROLES[locator.value].name
151
157
  : locator.value}`;
152
158
  }
@@ -163,20 +169,20 @@ class XperienceRightsClient {
163
169
  if (!strategy.enabled) {
164
170
  return false;
165
171
  }
166
- if (strategy.type === 'group') {
172
+ if (strategy.type === "group") {
167
173
  return (_a = strategy.groups) === null || _a === void 0 ? void 0 : _a.some((group) => XperienceRightsClient.isGroupMember(data, group, qualifier));
168
174
  }
169
- if (strategy.type === 'user') {
175
+ if (strategy.type === "user") {
170
176
  return ((_b = strategy.users) === null || _b === void 0 ? void 0 : _b.includes(data.email)) || false;
171
177
  }
172
- if (strategy.type === 'company') {
178
+ if (strategy.type === "company") {
173
179
  return ((_c = strategy.master_ids) === null || _c === void 0 ? void 0 : _c.includes(qualifier)) || false;
174
180
  }
175
- if (strategy.type === 'company_user') {
181
+ if (strategy.type === "company_user") {
176
182
  return (((_d = strategy.master_ids) === null || _d === void 0 ? void 0 : _d.includes(qualifier)) &&
177
183
  ((_e = strategy.users) === null || _e === void 0 ? void 0 : _e.includes(data.email)));
178
184
  }
179
- if (strategy.type === 'company_group') {
185
+ if (strategy.type === "company_group") {
180
186
  return (((_f = strategy.master_ids) === null || _f === void 0 ? void 0 : _f.includes(qualifier)) &&
181
187
  ((_g = strategy.groups) === null || _g === void 0 ? void 0 : _g.some((group) => XperienceRightsClient.isGroupMember(data, group, qualifier))));
182
188
  }
@@ -198,35 +204,35 @@ class XperienceRightsClient {
198
204
  }
199
205
  static abilityValue(ability) {
200
206
  switch (ability) {
201
- case 'none':
207
+ case "none":
202
208
  return 0;
203
- case 'view':
209
+ case "view":
204
210
  return 1;
205
- case 'edit':
211
+ case "edit":
206
212
  return 2;
207
- case 'admin':
213
+ case "admin":
208
214
  return 3;
209
215
  default:
210
216
  return 0;
211
217
  }
212
218
  }
213
- static compareAbilities(a, b, comparison = 'enough') {
219
+ static compareAbilities(a, b, comparison = "enough") {
214
220
  const aValue = XperienceRightsClient.abilityValue(a);
215
221
  const bValue = XperienceRightsClient.abilityValue(b);
216
- if (comparison === 'enough') {
222
+ if (comparison === "enough") {
217
223
  return aValue >= bValue;
218
224
  }
219
225
  return aValue > bValue;
220
226
  }
221
227
  static bestAbility(...abilities) {
222
228
  return abilities.reduce((best, current) => {
223
- return XperienceRightsClient.compareAbilities(current, best, 'better')
229
+ return XperienceRightsClient.compareAbilities(current, best, "better")
224
230
  ? current
225
231
  : best;
226
- }, 'none');
232
+ }, "none");
227
233
  }
228
234
  static xperienceScopeName(scope) {
229
- return exports.FRIENDLY_SCOPE_NAMES[scope] || 'Unknown';
235
+ return exports.FRIENDLY_SCOPE_NAMES[scope] || "Unknown";
230
236
  }
231
237
  }
232
238
  exports.XperienceRightsClient = XperienceRightsClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clxmedia/xperience-rights-client",
3
- "version": "1.1.8",
3
+ "version": "1.1.10",
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.179"
35
+ "@clxmedia/types": "1.0.195"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/jest": "29.5.11",
@@ -64,4 +64,4 @@
64
64
  "coverageDirectory": "../coverage",
65
65
  "testEnvironment": "node"
66
66
  }
67
- }
67
+ }