@clxmedia/xperience-rights-client 1.1.9 → 1.1.11

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,109 +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',
100
- pmaxreview: 'PMax 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",
101
106
  };
102
107
  class XperienceRightsClient {
103
108
  static findAbility(data, scope, qualifier) {
104
109
  if (!data || !data.rights) {
105
- return 'none';
110
+ return "none";
106
111
  }
107
112
  const abilities = data.rights[scope];
108
113
  if (!abilities) {
109
- return 'none';
114
+ return "none";
110
115
  }
111
116
  if (!qualifier) {
112
117
  qualifier = 0;
@@ -125,29 +130,29 @@ class XperienceRightsClient {
125
130
  return XperienceRightsClient.bestAbility(ability, best);
126
131
  }
127
132
  return best;
128
- }, 'none');
133
+ }, "none");
129
134
  }
130
135
  static cliqLocatorDescription(locator, long = false) {
131
136
  if (!locator || !locator.type) {
132
137
  return null;
133
138
  }
134
- if (locator.type === 'user') {
139
+ if (locator.type === "user") {
135
140
  return locator.value;
136
141
  }
137
- if (locator.type === 'group') {
138
- 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}`;
139
144
  }
140
- if (locator.type === 'role') {
145
+ if (locator.type === "role") {
141
146
  return `${exports.CLIQ_ROLES[locator.value] || locator.value}`;
142
147
  }
143
- if (locator.type === 'right') {
144
- const [scope, ability] = locator.value.split('@');
148
+ if (locator.type === "right") {
149
+ const [scope, ability] = locator.value.split("@");
145
150
  return long
146
- ? `any ${locator.constraint ? `${locator.constraint} ` : ''}user with the ${exports.FRIENDLY_SCOPE_NAMES[scope]} ${ability} rights`
147
- : `${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})` : ""}`;
148
153
  }
149
- if (locator.type === 'odoo_role') {
150
- 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]
151
156
  ? exports.ODOO_ROLES[locator.value].name
152
157
  : locator.value}`;
153
158
  }
@@ -164,20 +169,20 @@ class XperienceRightsClient {
164
169
  if (!strategy.enabled) {
165
170
  return false;
166
171
  }
167
- if (strategy.type === 'group') {
172
+ if (strategy.type === "group") {
168
173
  return (_a = strategy.groups) === null || _a === void 0 ? void 0 : _a.some((group) => XperienceRightsClient.isGroupMember(data, group, qualifier));
169
174
  }
170
- if (strategy.type === 'user') {
175
+ if (strategy.type === "user") {
171
176
  return ((_b = strategy.users) === null || _b === void 0 ? void 0 : _b.includes(data.email)) || false;
172
177
  }
173
- if (strategy.type === 'company') {
178
+ if (strategy.type === "company") {
174
179
  return ((_c = strategy.master_ids) === null || _c === void 0 ? void 0 : _c.includes(qualifier)) || false;
175
180
  }
176
- if (strategy.type === 'company_user') {
181
+ if (strategy.type === "company_user") {
177
182
  return (((_d = strategy.master_ids) === null || _d === void 0 ? void 0 : _d.includes(qualifier)) &&
178
183
  ((_e = strategy.users) === null || _e === void 0 ? void 0 : _e.includes(data.email)));
179
184
  }
180
- if (strategy.type === 'company_group') {
185
+ if (strategy.type === "company_group") {
181
186
  return (((_f = strategy.master_ids) === null || _f === void 0 ? void 0 : _f.includes(qualifier)) &&
182
187
  ((_g = strategy.groups) === null || _g === void 0 ? void 0 : _g.some((group) => XperienceRightsClient.isGroupMember(data, group, qualifier))));
183
188
  }
@@ -199,35 +204,35 @@ class XperienceRightsClient {
199
204
  }
200
205
  static abilityValue(ability) {
201
206
  switch (ability) {
202
- case 'none':
207
+ case "none":
203
208
  return 0;
204
- case 'view':
209
+ case "view":
205
210
  return 1;
206
- case 'edit':
211
+ case "edit":
207
212
  return 2;
208
- case 'admin':
213
+ case "admin":
209
214
  return 3;
210
215
  default:
211
216
  return 0;
212
217
  }
213
218
  }
214
- static compareAbilities(a, b, comparison = 'enough') {
219
+ static compareAbilities(a, b, comparison = "enough") {
215
220
  const aValue = XperienceRightsClient.abilityValue(a);
216
221
  const bValue = XperienceRightsClient.abilityValue(b);
217
- if (comparison === 'enough') {
222
+ if (comparison === "enough") {
218
223
  return aValue >= bValue;
219
224
  }
220
225
  return aValue > bValue;
221
226
  }
222
227
  static bestAbility(...abilities) {
223
228
  return abilities.reduce((best, current) => {
224
- return XperienceRightsClient.compareAbilities(current, best, 'better')
229
+ return XperienceRightsClient.compareAbilities(current, best, "better")
225
230
  ? current
226
231
  : best;
227
- }, 'none');
232
+ }, "none");
228
233
  }
229
234
  static xperienceScopeName(scope) {
230
- return exports.FRIENDLY_SCOPE_NAMES[scope] || 'Unknown';
235
+ return exports.FRIENDLY_SCOPE_NAMES[scope] || "Unknown";
231
236
  }
232
237
  }
233
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.9",
3
+ "version": "1.1.11",
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.187"
35
+ "@clxmedia/types": "1.2.0"
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
+ }