@escapenavigator/utils 2.1.0 → 2.1.1

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.
@@ -5,3 +5,10 @@ export type RoleLeadPermissions = Pick<RoleRO, 'totalAccess' | 'accessToLeadsSec
5
5
  * включён. Раздел новый, поэтому у старых ролей флага нет и доступа тоже.
6
6
  */
7
7
  export declare const canAccessLeads: (role?: RoleLeadPermissions | null) => boolean;
8
+ export type RoleIncomingLeadCardsPermissions = Partial<Pick<RoleRO, 'canSeeIncomingLeadCards'>>;
9
+ /**
10
+ * Всплывающие карточки входящих звонков и заявок.
11
+ * Намеренно без `totalAccess`: владелец настраивает это отдельно,
12
+ * иначе собственник получал бы каждую карточку вместе с полным доступом.
13
+ */
14
+ export declare const canSeeIncomingLeadCards: (role?: RoleIncomingLeadCardsPermissions | null) => boolean;
@@ -1,9 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.canAccessLeads = void 0;
3
+ exports.canSeeIncomingLeadCards = exports.canAccessLeads = void 0;
4
4
  /**
5
5
  * Доступ к разделу «Заявки». Владелец (`totalAccess`) — как будто флаг
6
6
  * включён. Раздел новый, поэтому у старых ролей флага нет и доступа тоже.
7
7
  */
8
8
  const canAccessLeads = (role) => !!role?.totalAccess || !!role?.accessToLeadsSection;
9
9
  exports.canAccessLeads = canAccessLeads;
10
+ /**
11
+ * Всплывающие карточки входящих звонков и заявок.
12
+ * Намеренно без `totalAccess`: владелец настраивает это отдельно,
13
+ * иначе собственник получал бы каждую карточку вместе с полным доступом.
14
+ */
15
+ const canSeeIncomingLeadCards = (role) => {
16
+ if (!role)
17
+ return false;
18
+ // Нет поля (старый API / роль до колонки) — как сейчас: карточки видны.
19
+ // Явный `false` — единственный способ скрыть, в том числе у owner.
20
+ return role.canSeeIncomingLeadCards !== false;
21
+ };
22
+ exports.canSeeIncomingLeadCards = canSeeIncomingLeadCards;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const role_lead_permissions_1 = require("./role-lead-permissions");
4
+ describe('canAccessLeads', () => {
5
+ it('is false without role or flag', () => {
6
+ expect((0, role_lead_permissions_1.canAccessLeads)()).toBe(false);
7
+ expect((0, role_lead_permissions_1.canAccessLeads)(null)).toBe(false);
8
+ expect((0, role_lead_permissions_1.canAccessLeads)({ totalAccess: false, accessToLeadsSection: false })).toBe(false);
9
+ });
10
+ it('is true when flag is on', () => {
11
+ expect((0, role_lead_permissions_1.canAccessLeads)({ totalAccess: false, accessToLeadsSection: true })).toBe(true);
12
+ });
13
+ it('is true for totalAccess even when flag is off', () => {
14
+ expect((0, role_lead_permissions_1.canAccessLeads)({ totalAccess: true, accessToLeadsSection: false })).toBe(true);
15
+ });
16
+ });
17
+ describe('canSeeIncomingLeadCards', () => {
18
+ it('is false without a role', () => {
19
+ expect((0, role_lead_permissions_1.canSeeIncomingLeadCards)()).toBe(false);
20
+ expect((0, role_lead_permissions_1.canSeeIncomingLeadCards)(null)).toBe(false);
21
+ });
22
+ it('is true when the flag is on or missing', () => {
23
+ expect((0, role_lead_permissions_1.canSeeIncomingLeadCards)({ canSeeIncomingLeadCards: true })).toBe(true);
24
+ expect((0, role_lead_permissions_1.canSeeIncomingLeadCards)({})).toBe(true);
25
+ });
26
+ it('is false only when the flag is explicitly off', () => {
27
+ expect((0, role_lead_permissions_1.canSeeIncomingLeadCards)({ canSeeIncomingLeadCards: false })).toBe(false);
28
+ });
29
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@escapenavigator/utils",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -14,7 +14,7 @@
14
14
  "test": "jest"
15
15
  },
16
16
  "dependencies": {
17
- "@escapenavigator/types": "^2.1.0",
17
+ "@escapenavigator/types": "^2.1.1",
18
18
  "axios": "^0.21.4",
19
19
  "class-transformer": "^0.5.1",
20
20
  "class-validator": "^0.13.2",
@@ -29,5 +29,5 @@
29
29
  "ts-jest": "^29.1.1",
30
30
  "typescript": "^5.6"
31
31
  },
32
- "gitHead": "6566478707369811402ca08e2193bf0ead7a1172"
32
+ "gitHead": "a12ec3a77f18fd9acd233aa2d15696c279b4137f"
33
33
  }