@clxmedia/xperience-rights-client 1.0.8 → 1.0.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,6 +1,24 @@
1
- import { XperienceAbility, XperienceRightsData, XperienceScopes } from '@clxmedia/types/core/auth';
1
+ import { CLiQUserLocator, XperienceAbility, XperienceRightsData, XperienceScopes } from '@clxmedia/types/core/auth';
2
+ export type OdooRole = {
3
+ id: number;
4
+ slug: string;
5
+ name: string;
6
+ };
7
+ export declare const ODOO_ROLES: {
8
+ [x: string]: OdooRole;
9
+ };
10
+ export declare const CLIQ_GROUPS: {
11
+ [x: string]: string;
12
+ };
13
+ export declare const CLIQ_ROLES: {
14
+ [x: string]: string;
15
+ };
16
+ export declare const FRIENDLY_SCOPE_NAMES: {
17
+ [key in XperienceScopes]: string;
18
+ };
2
19
  export declare class XperienceRightsClient {
3
20
  static findAbility(data: XperienceRightsData, scope: XperienceScopes, qualifier?: number): XperienceAbility;
21
+ static cliqLocatorDescription(locator: CLiQUserLocator | null, long?: boolean): string | null;
4
22
  static isGroupMember(data: XperienceRightsData, group: string, qualifier?: number): boolean;
5
23
  static abilityValue(ability: XperienceAbility): number;
6
24
  static compareAbilities(a: XperienceAbility, b: XperienceAbility, comparison?: 'enough' | 'better'): boolean;
package/dist/client.js CHANGED
@@ -1,6 +1,68 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.XperienceRightsClient = void 0;
3
+ exports.XperienceRightsClient = exports.FRIENDLY_SCOPE_NAMES = exports.CLIQ_ROLES = exports.CLIQ_GROUPS = exports.ODOO_ROLES = void 0;
4
+ exports.ODOO_ROLES = {
5
+ '2-Proofing Contact': { id: 2, name: 'Proofing Contact', slug: '2-Proofing Contact' },
6
+ '3-Reporting Contact': { id: 3, name: 'Reporting Contact', slug: '3-Reporting Contact' },
7
+ '4-Billing Contact': { id: 4, name: 'Billing Contact', slug: '4-Billing Contact' },
8
+ '5-Marketing Contact': { id: 5, name: 'Marketing Contact', slug: '5-Marketing Contact' },
9
+ '8-Video Producer': { id: 8, name: 'Video Producer', slug: '8-Video Producer' },
10
+ '9-Regional Contact': { id: 9, name: 'Regional Contact', slug: '9-Regional Contact' },
11
+ '16-Accounts Payable': { id: 16, name: 'Accounts Payable', slug: '16-Accounts Payable' },
12
+ '17-Main': { id: 17, name: 'Main', slug: '17-Main' },
13
+ '18-Website Contact': { id: 18, name: 'Website Contact', slug: '18-Website Contact' },
14
+ '19-GTM Contact': { id: 19, name: 'GTM Contact', slug: '19-GTM Contact' },
15
+ '20-GA Contact': { id: 20, name: 'GA Contact', slug: '20-GA Contact' },
16
+ '21-GBP Contact': { id: 21, name: 'GBP Contact', slug: '21-GBP Contact' },
17
+ '22-FB Contact': { id: 22, name: 'FB Contact', slug: '22-FB Contact' },
18
+ '23-CRM Contact': { id: 23, name: 'CRM Contact', slug: '23-CRM Contact' },
19
+ '24-TCC/Chat Contact': { id: 24, name: 'TCC/Chat Contact', slug: '24-TCC/Chat Contact' },
20
+ '25-Leasing/Community Manager': { id: 25, name: 'Leasing/Community Manager', slug: '25-Leasing/Community Manager' },
21
+ '27-Pausing Notifications Contact': {
22
+ id: 27,
23
+ name: 'Pausing Notifications Contact',
24
+ slug: '27-Pausing Notifications Contact',
25
+ },
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
+ };
30
+ exports.CLIQ_GROUPS = {
31
+ ad_reviewer: 'Property Ad Reviewers',
32
+ company_billing: 'Property Billing Admins',
33
+ company_user: 'Property Users',
34
+ accounting: 'Conversion Logix Accounting',
35
+ cs_group: 'CS Group',
36
+ superuser: 'Superusers',
37
+ account_manager: 'Account Managers',
38
+ clx_staff: 'Conversion Logix Staff',
39
+ implementation_group: 'Implementation Group',
40
+ };
41
+ exports.CLIQ_ROLES = {
42
+ client_service_analyst: 'Client Service Analyst',
43
+ implementation_specialist: 'Implementation Specialist',
44
+ account_manager: 'Account Manager',
45
+ };
46
+ exports.FRIENDLY_SCOPE_NAMES = {
47
+ company: 'Property',
48
+ tasks: 'Tasks',
49
+ displayreview: 'Display Review',
50
+ platform: 'Platform',
51
+ users: 'Users',
52
+ forms: 'Forms',
53
+ gbpreview: 'GBP Review',
54
+ gbpa: 'GBPA',
55
+ insights: 'Insights',
56
+ mac: 'Meta',
57
+ macreview: 'MAC Review',
58
+ billing: 'Billing',
59
+ mediahub: 'Media Hub',
60
+ onboarding: 'Onboarding',
61
+ adrequests: 'Ad Requests',
62
+ dashboard: 'Dashboard',
63
+ videoreview: 'Video Review',
64
+ tcc: 'The Conversion Cloud',
65
+ };
4
66
  class XperienceRightsClient {
5
67
  static findAbility(data, scope, qualifier) {
6
68
  if (!data || !data.rights) {
@@ -29,6 +91,28 @@ class XperienceRightsClient {
29
91
  return best;
30
92
  }, 'none');
31
93
  }
94
+ static cliqLocatorDescription(locator, long = false) {
95
+ if (!locator || !locator.type) {
96
+ return null;
97
+ }
98
+ if (locator.type === 'user') {
99
+ return locator.value;
100
+ }
101
+ if (locator.type === 'group') {
102
+ return `${long ? 'any user in the group: ' : ''}${exports.CLIQ_GROUPS[locator.value] || locator.value}`;
103
+ }
104
+ if (locator.type === 'role') {
105
+ return `${exports.CLIQ_ROLES[locator.value] || locator.value}`;
106
+ }
107
+ if (locator.type === 'right') {
108
+ const [scope, ability] = locator.value.split('@');
109
+ return long ? `any ${locator.constraint ? `${locator.constraint} ` : ''}user with the ${exports.FRIENDLY_SCOPE_NAMES[scope]} ${ability} rights` : `${exports.FRIENDLY_SCOPE_NAMES[scope]} ${ability}${locator.constraint ? ` (${locator.constraint})` : ''}`;
110
+ }
111
+ if (locator.type === 'odoo_role') {
112
+ return `${long ? 'any user with the Odoo role: ' : ''}${exports.ODOO_ROLES[locator.value] ? exports.ODOO_ROLES[locator.value].name : locator.value}`;
113
+ }
114
+ }
115
+ ;
32
116
  static isGroupMember(data, group, qualifier) {
33
117
  if (!data || !data.groups || !data.groups[group]) {
34
118
  return false;
@@ -66,46 +150,7 @@ class XperienceRightsClient {
66
150
  }, 'none');
67
151
  }
68
152
  static xperienceScopeName(scope) {
69
- switch (scope) {
70
- case 'company':
71
- return 'Company';
72
- case 'displayreview':
73
- return 'Display Review';
74
- case 'tasks':
75
- return 'Tasks';
76
- case 'platform':
77
- return 'Xperience Platform';
78
- case 'users':
79
- return 'Users';
80
- case 'forms':
81
- return 'Forms';
82
- case 'gbpreview':
83
- return 'GBP Review';
84
- case 'gbpa':
85
- return 'GBPA';
86
- case 'insights':
87
- return 'Insights';
88
- case 'mac':
89
- return 'MAC';
90
- case 'macreview':
91
- return 'MAC Review';
92
- case 'mediahub':
93
- return 'Media Hub';
94
- case 'onboarding':
95
- return 'Onboarding';
96
- case 'dashboard':
97
- return 'Dashboard';
98
- case 'billing':
99
- return 'Billing';
100
- case 'adrequests':
101
- return 'Ad Requests';
102
- case 'videoreview':
103
- return 'Video Review';
104
- case 'tcc':
105
- return 'The Conversion Cloud';
106
- default:
107
- return 'Unknown';
108
- }
153
+ return exports.FRIENDLY_SCOPE_NAMES[scope] || 'Unknown';
109
154
  }
110
155
  }
111
156
  exports.XperienceRightsClient = XperienceRightsClient;
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { XperienceRightsClient } from './client';
1
+ export { XperienceRightsClient, CLIQ_GROUPS, CLIQ_ROLES, FRIENDLY_SCOPE_NAMES, ODOO_ROLES, OdooRole, } from './client';
package/dist/index.js CHANGED
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.XperienceRightsClient = void 0;
3
+ exports.ODOO_ROLES = exports.FRIENDLY_SCOPE_NAMES = exports.CLIQ_ROLES = exports.CLIQ_GROUPS = exports.XperienceRightsClient = void 0;
4
4
  var client_1 = require("./client");
5
5
  Object.defineProperty(exports, "XperienceRightsClient", { enumerable: true, get: function () { return client_1.XperienceRightsClient; } });
6
+ Object.defineProperty(exports, "CLIQ_GROUPS", { enumerable: true, get: function () { return client_1.CLIQ_GROUPS; } });
7
+ Object.defineProperty(exports, "CLIQ_ROLES", { enumerable: true, get: function () { return client_1.CLIQ_ROLES; } });
8
+ Object.defineProperty(exports, "FRIENDLY_SCOPE_NAMES", { enumerable: true, get: function () { return client_1.FRIENDLY_SCOPE_NAMES; } });
9
+ Object.defineProperty(exports, "ODOO_ROLES", { enumerable: true, get: function () { return client_1.ODOO_ROLES; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clxmedia/xperience-rights-client",
3
- "version": "1.0.8",
3
+ "version": "1.0.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.122"
35
+ "@clxmedia/types": "1.0.153"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/jest": "29.5.11",