orbitx-core-models 11.103.0 → 11.112.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/index.d.ts +14 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -1
- package/dist/interfaces/agent.interface.d.ts +6 -1
- package/dist/interfaces/agent.interface.d.ts.map +1 -1
- package/dist/interfaces/callSession.interface.d.ts +6 -0
- package/dist/interfaces/callSession.interface.d.ts.map +1 -1
- package/dist/interfaces/request.interface.d.ts +33 -0
- package/dist/interfaces/request.interface.d.ts.map +1 -0
- package/dist/interfaces/request.interface.js +2 -0
- package/dist/interfaces/role.interface.d.ts +12 -0
- package/dist/interfaces/role.interface.d.ts.map +1 -0
- package/dist/interfaces/role.interface.js +2 -0
- package/dist/interfaces/user.interface.d.ts +5 -0
- package/dist/interfaces/user.interface.d.ts.map +1 -1
- package/dist/models/agent.model.d.ts.map +1 -1
- package/dist/models/agent.model.js +21 -2
- package/dist/models/callSession.model.d.ts.map +1 -1
- package/dist/models/callSession.model.js +12 -0
- package/dist/models/request.model.d.ts +9 -0
- package/dist/models/request.model.d.ts.map +1 -0
- package/dist/models/request.model.js +150 -0
- package/dist/models/role.model.d.ts +8 -0
- package/dist/models/role.model.d.ts.map +1 -0
- package/dist/models/role.model.js +72 -0
- package/dist/models/user.model.d.ts.map +1 -1
- package/dist/models/user.model.js +21 -0
- package/dist/permissions/resolve.d.ts +50 -0
- package/dist/permissions/resolve.d.ts.map +1 -0
- package/dist/permissions/resolve.js +68 -0
- package/dist/permissions/seeds/roles.seed.d.ts +19 -0
- package/dist/permissions/seeds/roles.seed.d.ts.map +1 -0
- package/dist/permissions/seeds/roles.seed.js +169 -0
- package/dist/permissions/treeUtils.d.ts +9 -0
- package/dist/permissions/treeUtils.d.ts.map +1 -0
- package/dist/permissions/treeUtils.js +46 -0
- package/dist/permissions/trees/client.tree.d.ts +3 -0
- package/dist/permissions/trees/client.tree.d.ts.map +1 -0
- package/dist/permissions/trees/client.tree.js +99 -0
- package/dist/permissions/trees/employee.tree.d.ts +3 -0
- package/dist/permissions/trees/employee.tree.d.ts.map +1 -0
- package/dist/permissions/trees/employee.tree.js +35 -0
- package/dist/permissions/trees/ops.tree.d.ts +3 -0
- package/dist/permissions/trees/ops.tree.d.ts.map +1 -0
- package/dist/permissions/trees/ops.tree.js +173 -0
- package/dist/permissions/trees/partner.tree.d.ts +3 -0
- package/dist/permissions/trees/partner.tree.d.ts.map +1 -0
- package/dist/permissions/trees/partner.tree.js +71 -0
- package/dist/permissions/types.d.ts +9 -0
- package/dist/permissions/types.d.ts.map +1 -0
- package/dist/permissions/types.js +4 -0
- package/package.json +1 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Dashboard } from "./types";
|
|
2
|
+
export interface PermissionSource {
|
|
3
|
+
permissionMode?: "role" | "custom";
|
|
4
|
+
permissionKeys?: string[];
|
|
5
|
+
/**
|
|
6
|
+
* Individually-granted extras on top of a named role -- e.g. a
|
|
7
|
+
* global-admin-adjacent role that also needs one extra node nobody else on
|
|
8
|
+
* that role gets. Only applies in "role" mode; ignored in "custom" mode
|
|
9
|
+
* since permissionKeys is already the fully authoritative set there.
|
|
10
|
+
*/
|
|
11
|
+
extraPermissionKeys?: string[];
|
|
12
|
+
/**
|
|
13
|
+
* Must be populated (a Role document with `grantedKeys`) for "role" mode to
|
|
14
|
+
* resolve to anything — pass the raw ObjectId and this returns an empty set.
|
|
15
|
+
*/
|
|
16
|
+
roleId?: {
|
|
17
|
+
grantedKeys?: string[];
|
|
18
|
+
} | unknown;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Single source of truth for "what can this user/agent actually do", used
|
|
22
|
+
* identically by every backend's requirePermission middleware and by each
|
|
23
|
+
* frontend's usePermissions() hook (via the effectivePermissions the login/
|
|
24
|
+
* `GET /me` response should expose). Does not hit the DB — the caller is
|
|
25
|
+
* responsible for populating `roleId` beforehand when in "role" mode.
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolveEffectivePermissions(source: PermissionSource): Set<string>;
|
|
28
|
+
export declare function hasPermission(source: PermissionSource, key: string): boolean;
|
|
29
|
+
export interface ValidationResult {
|
|
30
|
+
valid: boolean;
|
|
31
|
+
errors: string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Enforces the parent-gates-children rule server-side: a submitted set is
|
|
35
|
+
* only valid if every key exists in that dashboard's tree AND every key's
|
|
36
|
+
* full ancestor chain is also present in the set. Run this on every write
|
|
37
|
+
* path that accepts a custom permission set or a new Role's grantedKeys —
|
|
38
|
+
* never trust client-side tree-editor state alone.
|
|
39
|
+
*/
|
|
40
|
+
export declare function validateGrantedKeys(dashboard: Dashboard, keys: string[]): ValidationResult;
|
|
41
|
+
/** Every key in a dashboard's tree, granted at once -- for "full access" roles. */
|
|
42
|
+
export declare function getFullAccessKeys(dashboard: Dashboard): string[];
|
|
43
|
+
/**
|
|
44
|
+
* Validates a role's extraPermissionKeys against the UNION of the role's own
|
|
45
|
+
* grantedKeys and the extras -- an extra key's parent may already be covered
|
|
46
|
+
* by the role itself, so it doesn't need to be duplicated into the extras
|
|
47
|
+
* list. Call this on every write path that accepts extraPermissionKeys.
|
|
48
|
+
*/
|
|
49
|
+
export declare function validateExtraKeys(dashboard: Dashboard, roleGrantedKeys: string[], extraKeys: string[]): ValidationResult;
|
|
50
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/permissions/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC,MAAM,WAAW,gBAAgB;IAC/B,cAAc,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IACnC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B;;;OAGG;IACH,MAAM,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC;CAC/C;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,gBAAgB,GAAG,GAAG,CAAC,MAAM,CAAC,CAYjF;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAE5E;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAkB1F;AAED,mFAAmF;AACnF,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,EAAE,CAEhE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,MAAM,EAAE,EACzB,SAAS,EAAE,MAAM,EAAE,GAClB,gBAAgB,CAElB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveEffectivePermissions = resolveEffectivePermissions;
|
|
4
|
+
exports.hasPermission = hasPermission;
|
|
5
|
+
exports.validateGrantedKeys = validateGrantedKeys;
|
|
6
|
+
exports.getFullAccessKeys = getFullAccessKeys;
|
|
7
|
+
exports.validateExtraKeys = validateExtraKeys;
|
|
8
|
+
const treeUtils_1 = require("./treeUtils");
|
|
9
|
+
/**
|
|
10
|
+
* Single source of truth for "what can this user/agent actually do", used
|
|
11
|
+
* identically by every backend's requirePermission middleware and by each
|
|
12
|
+
* frontend's usePermissions() hook (via the effectivePermissions the login/
|
|
13
|
+
* `GET /me` response should expose). Does not hit the DB — the caller is
|
|
14
|
+
* responsible for populating `roleId` beforehand when in "role" mode.
|
|
15
|
+
*/
|
|
16
|
+
function resolveEffectivePermissions(source) {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
if (source.permissionMode === "custom") {
|
|
19
|
+
return new Set((_a = source.permissionKeys) !== null && _a !== void 0 ? _a : []);
|
|
20
|
+
}
|
|
21
|
+
const role = source.roleId;
|
|
22
|
+
const keys = new Set();
|
|
23
|
+
if (role && Array.isArray(role.grantedKeys)) {
|
|
24
|
+
role.grantedKeys.forEach((k) => keys.add(k));
|
|
25
|
+
}
|
|
26
|
+
((_b = source.extraPermissionKeys) !== null && _b !== void 0 ? _b : []).forEach((k) => keys.add(k));
|
|
27
|
+
return keys;
|
|
28
|
+
}
|
|
29
|
+
function hasPermission(source, key) {
|
|
30
|
+
return resolveEffectivePermissions(source).has(key);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Enforces the parent-gates-children rule server-side: a submitted set is
|
|
34
|
+
* only valid if every key exists in that dashboard's tree AND every key's
|
|
35
|
+
* full ancestor chain is also present in the set. Run this on every write
|
|
36
|
+
* path that accepts a custom permission set or a new Role's grantedKeys —
|
|
37
|
+
* never trust client-side tree-editor state alone.
|
|
38
|
+
*/
|
|
39
|
+
function validateGrantedKeys(dashboard, keys) {
|
|
40
|
+
const errors = [];
|
|
41
|
+
const validKeys = new Set((0, treeUtils_1.getAllKeys)(dashboard));
|
|
42
|
+
const keySet = new Set(keys);
|
|
43
|
+
for (const key of keys) {
|
|
44
|
+
if (!validKeys.has(key)) {
|
|
45
|
+
errors.push(`Unknown permission key "${key}" for dashboard "${dashboard}"`);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
for (const ancestor of (0, treeUtils_1.getAncestorKeys)(key)) {
|
|
49
|
+
if (!keySet.has(ancestor)) {
|
|
50
|
+
errors.push(`"${key}" is granted but its required parent "${ancestor}" is not`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return { valid: errors.length === 0, errors };
|
|
55
|
+
}
|
|
56
|
+
/** Every key in a dashboard's tree, granted at once -- for "full access" roles. */
|
|
57
|
+
function getFullAccessKeys(dashboard) {
|
|
58
|
+
return (0, treeUtils_1.getAllKeys)(dashboard);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Validates a role's extraPermissionKeys against the UNION of the role's own
|
|
62
|
+
* grantedKeys and the extras -- an extra key's parent may already be covered
|
|
63
|
+
* by the role itself, so it doesn't need to be duplicated into the extras
|
|
64
|
+
* list. Call this on every write path that accepts extraPermissionKeys.
|
|
65
|
+
*/
|
|
66
|
+
function validateExtraKeys(dashboard, roleGrantedKeys, extraKeys) {
|
|
67
|
+
return validateGrantedKeys(dashboard, [...roleGrantedKeys, ...extraKeys]);
|
|
68
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Dashboard } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* DRAFT SEED DATA -- transcribed by hand from the client's "Role & Access" PDF.
|
|
4
|
+
* This is the highest content-accuracy-risk piece of the whole RBAC build: a
|
|
5
|
+
* wrong key here silently over- or under-grants real production access.
|
|
6
|
+
*
|
|
7
|
+
* DO NOT run this against production until a human has reviewed the
|
|
8
|
+
* `grantedKeys` list for every role below against the original spec and
|
|
9
|
+
* signed off. Treat this file as a reviewable table, not settled code.
|
|
10
|
+
*/
|
|
11
|
+
export interface RoleSeed {
|
|
12
|
+
dashboard: Dashboard;
|
|
13
|
+
key: string;
|
|
14
|
+
label: string;
|
|
15
|
+
isSystemRole: true;
|
|
16
|
+
grantedKeys: string[];
|
|
17
|
+
}
|
|
18
|
+
export declare const roleSeeds: RoleSeed[];
|
|
19
|
+
//# sourceMappingURL=roles.seed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roles.seed.d.ts","sourceRoot":"","sources":["../../../src/permissions/seeds/roles.seed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC;;;;;;;;GAQG;AACH,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,SAAS,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,IAAI,CAAC;IACnB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,eAAO,MAAM,SAAS,EAAE,QAAQ,EAuK/B,CAAC"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.roleSeeds = void 0;
|
|
4
|
+
const resolve_1 = require("../resolve");
|
|
5
|
+
exports.roleSeeds = [
|
|
6
|
+
// ── Operations Dashboard ──────────────────────────────────────────────
|
|
7
|
+
{
|
|
8
|
+
dashboard: "ops",
|
|
9
|
+
key: "global-admin",
|
|
10
|
+
label: "Global Admin",
|
|
11
|
+
isSystemRole: true,
|
|
12
|
+
// Near-full access per spec -- modeled as literally every node in the
|
|
13
|
+
// Ops tree, since the spec's global-admin list covers every top-level
|
|
14
|
+
// section that exists.
|
|
15
|
+
grantedKeys: (0, resolve_1.getFullAccessKeys)("ops"),
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
dashboard: "ops",
|
|
19
|
+
key: "team-lead-chat",
|
|
20
|
+
label: "Team Lead (Chat)",
|
|
21
|
+
isSystemRole: true,
|
|
22
|
+
grantedKeys: [
|
|
23
|
+
"profile",
|
|
24
|
+
"profile.editPersonalInformation",
|
|
25
|
+
"profile.updatePassword",
|
|
26
|
+
"profile.twoFactorAuthentication",
|
|
27
|
+
"profile.viewSessions",
|
|
28
|
+
"status",
|
|
29
|
+
"dashboard",
|
|
30
|
+
"dashboard.liveChat",
|
|
31
|
+
"employees",
|
|
32
|
+
"logs",
|
|
33
|
+
"logs.detailedLogView",
|
|
34
|
+
"inbox",
|
|
35
|
+
"leads",
|
|
36
|
+
"leads.forward",
|
|
37
|
+
"leads.viewScript",
|
|
38
|
+
"leads.viewConversation",
|
|
39
|
+
"leads.company",
|
|
40
|
+
"leads.chatHistory",
|
|
41
|
+
"conversations",
|
|
42
|
+
"conversations.viewLead",
|
|
43
|
+
"chatFlux",
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
dashboard: "ops",
|
|
48
|
+
key: "acc-manager-client",
|
|
49
|
+
label: "Account Manager (Client)",
|
|
50
|
+
isSystemRole: true,
|
|
51
|
+
grantedKeys: [
|
|
52
|
+
"profile",
|
|
53
|
+
"profile.editPersonalInformation",
|
|
54
|
+
"profile.updatePassword",
|
|
55
|
+
"profile.twoFactorAuthentication",
|
|
56
|
+
"profile.viewSessions",
|
|
57
|
+
"status",
|
|
58
|
+
"companies",
|
|
59
|
+
"companies.createCompany",
|
|
60
|
+
"companies.account",
|
|
61
|
+
"companies.account.basicInformation",
|
|
62
|
+
"companies.account.contactInformation",
|
|
63
|
+
"companies.account.hoursCallConnect",
|
|
64
|
+
"companies.account.leadForm",
|
|
65
|
+
"companies.account.users",
|
|
66
|
+
"companies.account.script",
|
|
67
|
+
"companies.account.appointmentScheduling",
|
|
68
|
+
"companies.account.retainerScheduling",
|
|
69
|
+
"companies.branding",
|
|
70
|
+
"companies.branding.widget",
|
|
71
|
+
"companies.branding.aliases",
|
|
72
|
+
"companies.branding.exitPopUp",
|
|
73
|
+
"companies.branding.appearance",
|
|
74
|
+
"companies.plansAddOns",
|
|
75
|
+
"companies.plansAddOns.chatX",
|
|
76
|
+
"companies.plansAddOns.addOns",
|
|
77
|
+
"companies.integrations",
|
|
78
|
+
"tickets",
|
|
79
|
+
"tickets.updateTicket",
|
|
80
|
+
"requests",
|
|
81
|
+
"requests.updateRequest",
|
|
82
|
+
"scripts",
|
|
83
|
+
"scripts.createVertical",
|
|
84
|
+
"scripts.updateVertical",
|
|
85
|
+
"scripts.deleteVertical",
|
|
86
|
+
"billing",
|
|
87
|
+
"billing.invoices",
|
|
88
|
+
"billing.paymentMethod",
|
|
89
|
+
"billing.adjustBillingCycle",
|
|
90
|
+
"invoices",
|
|
91
|
+
"invoices.createNewInvoice",
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
dashboard: "ops",
|
|
96
|
+
key: "acc-manager-partner",
|
|
97
|
+
label: "Account Manager (Partner)",
|
|
98
|
+
isSystemRole: true,
|
|
99
|
+
grantedKeys: [
|
|
100
|
+
"profile",
|
|
101
|
+
"profile.editPersonalInformation",
|
|
102
|
+
"profile.updatePassword",
|
|
103
|
+
"profile.twoFactorAuthentication",
|
|
104
|
+
"profile.viewSessions",
|
|
105
|
+
"status",
|
|
106
|
+
"partners",
|
|
107
|
+
"partners.createPartner",
|
|
108
|
+
"partners.account",
|
|
109
|
+
"partners.account.basicInformation",
|
|
110
|
+
"partners.account.contactInformation",
|
|
111
|
+
"partners.account.users",
|
|
112
|
+
"partners.account.bankInformation",
|
|
113
|
+
"partners.payouts",
|
|
114
|
+
"partners.payouts.transfers",
|
|
115
|
+
"partners.payouts.withdrawals",
|
|
116
|
+
"partners.payouts.processPayout",
|
|
117
|
+
"tickets",
|
|
118
|
+
"tickets.updateTicket",
|
|
119
|
+
"requests",
|
|
120
|
+
"requests.updateRequest",
|
|
121
|
+
"reviews",
|
|
122
|
+
"reviews.updateReview",
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
// ── Employee Dashboard (created from Ops per the spec's own note) ──────
|
|
126
|
+
{
|
|
127
|
+
dashboard: "employee",
|
|
128
|
+
key: "associate-agent",
|
|
129
|
+
label: "Associate Agent",
|
|
130
|
+
isSystemRole: true,
|
|
131
|
+
grantedKeys: [
|
|
132
|
+
"profile",
|
|
133
|
+
"dashboard",
|
|
134
|
+
"inbox",
|
|
135
|
+
"inbox.searchLiveChatsOnly",
|
|
136
|
+
"leads",
|
|
137
|
+
"leads.viewScript",
|
|
138
|
+
"leads.viewConversations",
|
|
139
|
+
"conversations",
|
|
140
|
+
"conversations.viewLead",
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
dashboard: "employee",
|
|
145
|
+
key: "executive-agent",
|
|
146
|
+
label: "Executive Agent",
|
|
147
|
+
isSystemRole: true,
|
|
148
|
+
// Strict superset of associate-agent per spec -- every node checked.
|
|
149
|
+
grantedKeys: (0, resolve_1.getFullAccessKeys)("employee"),
|
|
150
|
+
},
|
|
151
|
+
// ── Partner Dashboard ───────────────────────────────────────────────────
|
|
152
|
+
{
|
|
153
|
+
dashboard: "partner",
|
|
154
|
+
key: "partner-admin",
|
|
155
|
+
label: "Admin",
|
|
156
|
+
isSystemRole: true,
|
|
157
|
+
// Full tree per spec. Assignable to the account owner AND, per the
|
|
158
|
+
// client's explicit confirmation, to additional team members later.
|
|
159
|
+
grantedKeys: (0, resolve_1.getFullAccessKeys)("partner"),
|
|
160
|
+
},
|
|
161
|
+
// ── Client Dashboard ────────────────────────────────────────────────────
|
|
162
|
+
{
|
|
163
|
+
dashboard: "client",
|
|
164
|
+
key: "client-admin",
|
|
165
|
+
label: "Admin",
|
|
166
|
+
isSystemRole: true,
|
|
167
|
+
grantedKeys: (0, resolve_1.getFullAccessKeys)("client"),
|
|
168
|
+
},
|
|
169
|
+
];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Dashboard, PermissionNode } from "./types";
|
|
2
|
+
export declare function getTree(dashboard: Dashboard): PermissionNode[];
|
|
3
|
+
/** Every valid key in a dashboard's tree, parents and leaves alike. */
|
|
4
|
+
export declare function getAllKeys(dashboard: Dashboard): string[];
|
|
5
|
+
/** "companies.account.leadForm" -> "companies.account" (or null for a top-level key). */
|
|
6
|
+
export declare function getParentKey(key: string): string | null;
|
|
7
|
+
/** A key's full ancestor chain, nearest-parent-last excluded... actually root-first. */
|
|
8
|
+
export declare function getAncestorKeys(key: string): string[];
|
|
9
|
+
//# sourceMappingURL=treeUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"treeUtils.d.ts","sourceRoot":"","sources":["../../src/permissions/treeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAapD,wBAAgB,OAAO,CAAC,SAAS,EAAE,SAAS,GAAG,cAAc,EAAE,CAE9D;AAED,uEAAuE;AACvE,wBAAgB,UAAU,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,EAAE,CAUzD;AAED,yFAAyF;AACzF,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGvD;AAED,wFAAwF;AACxF,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAOrD"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTree = getTree;
|
|
4
|
+
exports.getAllKeys = getAllKeys;
|
|
5
|
+
exports.getParentKey = getParentKey;
|
|
6
|
+
exports.getAncestorKeys = getAncestorKeys;
|
|
7
|
+
const ops_tree_1 = require("./trees/ops.tree");
|
|
8
|
+
const employee_tree_1 = require("./trees/employee.tree");
|
|
9
|
+
const partner_tree_1 = require("./trees/partner.tree");
|
|
10
|
+
const client_tree_1 = require("./trees/client.tree");
|
|
11
|
+
const TREES = {
|
|
12
|
+
ops: ops_tree_1.opsTree,
|
|
13
|
+
employee: employee_tree_1.employeeTree,
|
|
14
|
+
partner: partner_tree_1.partnerTree,
|
|
15
|
+
client: client_tree_1.clientTree,
|
|
16
|
+
};
|
|
17
|
+
function getTree(dashboard) {
|
|
18
|
+
return TREES[dashboard];
|
|
19
|
+
}
|
|
20
|
+
/** Every valid key in a dashboard's tree, parents and leaves alike. */
|
|
21
|
+
function getAllKeys(dashboard) {
|
|
22
|
+
const keys = [];
|
|
23
|
+
const walk = (nodes) => {
|
|
24
|
+
for (const node of nodes) {
|
|
25
|
+
keys.push(node.key);
|
|
26
|
+
if (node.children)
|
|
27
|
+
walk(node.children);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
walk(TREES[dashboard]);
|
|
31
|
+
return keys;
|
|
32
|
+
}
|
|
33
|
+
/** "companies.account.leadForm" -> "companies.account" (or null for a top-level key). */
|
|
34
|
+
function getParentKey(key) {
|
|
35
|
+
const idx = key.lastIndexOf(".");
|
|
36
|
+
return idx === -1 ? null : key.slice(0, idx);
|
|
37
|
+
}
|
|
38
|
+
/** A key's full ancestor chain, nearest-parent-last excluded... actually root-first. */
|
|
39
|
+
function getAncestorKeys(key) {
|
|
40
|
+
const parts = key.split(".");
|
|
41
|
+
const ancestors = [];
|
|
42
|
+
for (let i = 1; i < parts.length; i++) {
|
|
43
|
+
ancestors.push(parts.slice(0, i).join("."));
|
|
44
|
+
}
|
|
45
|
+
return ancestors;
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.tree.d.ts","sourceRoot":"","sources":["../../../src/permissions/trees/client.tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAM1C,eAAO,MAAM,UAAU,EAAE,cAAc,EA2FtC,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clientTree = void 0;
|
|
4
|
+
// Transcribed from the client's "Role & Access" spec (Client Dashboard section).
|
|
5
|
+
// Only one predefined role exists here ("admin", full tree) -- same note as Partner:
|
|
6
|
+
// "An admin can control custom access from the above tree of a new or old user,
|
|
7
|
+
// there are no more pre-made roles for client dashboard."
|
|
8
|
+
exports.clientTree = [
|
|
9
|
+
{
|
|
10
|
+
key: "profile",
|
|
11
|
+
label: "Profile",
|
|
12
|
+
children: [
|
|
13
|
+
{ key: "profile.editPersonalInformation", label: "Edit Personal Information" },
|
|
14
|
+
{ key: "profile.updatePassword", label: "Update Password" },
|
|
15
|
+
{ key: "profile.twoFactorAuthentication", label: "Two Factor Authentication" },
|
|
16
|
+
{ key: "profile.viewSessions", label: "View Sessions" },
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
key: "dashboard",
|
|
21
|
+
label: "Dashboard",
|
|
22
|
+
children: [
|
|
23
|
+
{ key: "dashboard.liveChat", label: "Live Chat" },
|
|
24
|
+
{ key: "dashboard.website", label: "Website" },
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
key: "company",
|
|
29
|
+
label: "Company",
|
|
30
|
+
children: [
|
|
31
|
+
{
|
|
32
|
+
key: "company.account",
|
|
33
|
+
label: "Account",
|
|
34
|
+
children: [
|
|
35
|
+
{ key: "company.account.basicInformation", label: "Basic Information" },
|
|
36
|
+
{ key: "company.account.contactInformation", label: "Contact Information" },
|
|
37
|
+
{ key: "company.account.hoursCallConnect", label: "Hours/Call Connect" },
|
|
38
|
+
{ key: "company.account.leadForm", label: "Lead Form" },
|
|
39
|
+
{ key: "company.account.users", label: "Users" },
|
|
40
|
+
{ key: "company.account.script", label: "Script" },
|
|
41
|
+
{ key: "company.account.appointment", label: "Appointment Scheduling" },
|
|
42
|
+
{ key: "company.account.retainerSigning", label: "Retainer Signing" },
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
key: "company.branding",
|
|
47
|
+
label: "Branding",
|
|
48
|
+
children: [
|
|
49
|
+
{ key: "company.branding.widget", label: "Widget" },
|
|
50
|
+
{ key: "company.branding.aliases", label: "Aliases" },
|
|
51
|
+
{ key: "company.branding.exitPopUp", label: "Exit Pop Up" },
|
|
52
|
+
{ key: "company.branding.appearance", label: "Appearance" },
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
key: "company.plansAddOns",
|
|
57
|
+
label: "Plans & Add Ons",
|
|
58
|
+
children: [
|
|
59
|
+
{ key: "company.plansAddOns.chatX", label: "CHAT-X" },
|
|
60
|
+
{ key: "company.plansAddOns.addOns", label: "Add Ons" },
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
{ key: "company.integrations", label: "Integrations" },
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
key: "leads",
|
|
68
|
+
label: "Leads",
|
|
69
|
+
children: [
|
|
70
|
+
{ key: "leads.viewConversations", label: "View Conversations" },
|
|
71
|
+
{ key: "leads.forward", label: "Forward" },
|
|
72
|
+
{ key: "leads.dispute", label: "Dispute" },
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
key: "requests",
|
|
77
|
+
label: "Requests",
|
|
78
|
+
children: [
|
|
79
|
+
{ key: "requests.createRequest", label: "Create Request" },
|
|
80
|
+
{ key: "requests.viewRequest", label: "View Request" },
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
key: "tickets",
|
|
85
|
+
label: "Tickets",
|
|
86
|
+
children: [
|
|
87
|
+
{ key: "tickets.createTicket", label: "Create Ticket" },
|
|
88
|
+
{ key: "tickets.viewTicket", label: "View Ticket" },
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
key: "billing",
|
|
93
|
+
label: "Billing",
|
|
94
|
+
children: [
|
|
95
|
+
{ key: "billing.addRemovePaymentMethod", label: "Add / Remove Payment Method" },
|
|
96
|
+
{ key: "billing.invoices", label: "Invoices" },
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"employee.tree.d.ts","sourceRoot":"","sources":["../../../src/permissions/trees/employee.tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAM1C,eAAO,MAAM,YAAY,EAAE,cAAc,EA2BxC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.employeeTree = void 0;
|
|
4
|
+
// Transcribed from the client's "Role & Access" spec (Employee Dashboard section).
|
|
5
|
+
// Note: the spec shows "Leads" nested under a "Portal" heading, but Portal has no
|
|
6
|
+
// checkbox of its own and no other children — modeled here as a pure nav grouping
|
|
7
|
+
// label, not a permission node, matching how "Leads" is a top-level node elsewhere.
|
|
8
|
+
exports.employeeTree = [
|
|
9
|
+
{ key: "profile", label: "Profile" },
|
|
10
|
+
{ key: "dashboard", label: "Dashboard" },
|
|
11
|
+
{
|
|
12
|
+
key: "inbox",
|
|
13
|
+
label: "Inbox",
|
|
14
|
+
children: [
|
|
15
|
+
{ key: "inbox.searchLiveChatsOnly", label: "Search [Live Chats Only]" },
|
|
16
|
+
{ key: "inbox.searchEndedShelvedChats", label: "Search [Ended / Shelved Chats]" },
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
key: "leads",
|
|
21
|
+
label: "Leads",
|
|
22
|
+
children: [
|
|
23
|
+
{ key: "leads.forward", label: "Forward" },
|
|
24
|
+
{ key: "leads.viewScript", label: "View Script" },
|
|
25
|
+
{ key: "leads.viewConversations", label: "View Conversations" },
|
|
26
|
+
{ key: "leads.viewCompany", label: "View Company" },
|
|
27
|
+
{ key: "leads.chatHistory", label: "Chat History" },
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
key: "conversations",
|
|
32
|
+
label: "Conversations",
|
|
33
|
+
children: [{ key: "conversations.viewLead", label: "View Lead" }],
|
|
34
|
+
},
|
|
35
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ops.tree.d.ts","sourceRoot":"","sources":["../../../src/permissions/trees/ops.tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAQ1C,eAAO,MAAM,OAAO,EAAE,cAAc,EAmKnC,CAAC"}
|