@escapenavigator/utils 2.1.22 → 2.1.24

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.
@@ -0,0 +1,7 @@
1
+ /** Комиссия эквайринга CloudPayments: 2,7%. */
2
+ export declare const BALANCE_CARD_COMMISSION_PER_MILLE = 27;
3
+ /**
4
+ * Возвращает сумму списания, при которой после удержания 2,7% останется
5
+ * указанная сумма пополнения. Все значения передаются в копейках.
6
+ */
7
+ export declare const balanceCardChargeKopecks: (balanceKopecks: number) => number;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.balanceCardChargeKopecks = exports.BALANCE_CARD_COMMISSION_PER_MILLE = void 0;
4
+ /** Комиссия эквайринга CloudPayments: 2,7%. */
5
+ exports.BALANCE_CARD_COMMISSION_PER_MILLE = 27;
6
+ const NET_PER_MILLE = 1000 - exports.BALANCE_CARD_COMMISSION_PER_MILLE;
7
+ /**
8
+ * Возвращает сумму списания, при которой после удержания 2,7% останется
9
+ * указанная сумма пополнения. Все значения передаются в копейках.
10
+ */
11
+ const balanceCardChargeKopecks = (balanceKopecks) => Math.round((balanceKopecks * 1000) / NET_PER_MILLE);
12
+ exports.balanceCardChargeKopecks = balanceCardChargeKopecks;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const balance_card_commission_1 = require("./balance-card-commission");
4
+ describe('balance card commission', () => {
5
+ it('grosses up the balance amount so the acquiring fee is paid by the payer', () => {
6
+ expect(balance_card_commission_1.BALANCE_CARD_COMMISSION_PER_MILLE).toBe(27);
7
+ expect((0, balance_card_commission_1.balanceCardChargeKopecks)(1_000_000)).toBe(1_027_749);
8
+ });
9
+ it('rounds the charge to whole kopecks', () => {
10
+ expect((0, balance_card_commission_1.balanceCardChargeKopecks)(100)).toBe(103);
11
+ expect((0, balance_card_commission_1.balanceCardChargeKopecks)(12_345)).toBe(12_688);
12
+ });
13
+ });
package/dist/index.d.ts CHANGED
@@ -24,6 +24,7 @@ export * from './is-axios-error';
24
24
  export * from './is-network-error';
25
25
  export * from './is-stale-chunk-error';
26
26
  export * from './is-valid-pt-nif';
27
+ export * from './personal-data-consent';
27
28
  export * from './phone';
28
29
  export * from './pick';
29
30
  export * from './promocode-error-codes';
package/dist/index.js CHANGED
@@ -40,6 +40,7 @@ __exportStar(require("./is-axios-error"), exports);
40
40
  __exportStar(require("./is-network-error"), exports);
41
41
  __exportStar(require("./is-stale-chunk-error"), exports);
42
42
  __exportStar(require("./is-valid-pt-nif"), exports);
43
+ __exportStar(require("./personal-data-consent"), exports);
43
44
  __exportStar(require("./phone"), exports);
44
45
  __exportStar(require("./pick"), exports);
45
46
  __exportStar(require("./promocode-error-codes"), exports);
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Отдельное согласие на обработку ПДн спрашиваем только у клиентов площадок
3
+ * из России: после поправок 01.09.2025 РКН ждёт его отдельной галочкой, и
4
+ * площадка должна уметь доказать, что оно было (ч. 3 ст. 9 152-ФЗ). Бэкенд
5
+ * не принимает заявки, сертификаты и первое сообщение чата без него — тогда
6
+ * сама запись в базе и есть доказательство.
7
+ *
8
+ * В ЕС основание — договор или преддоговорный запрос (GDPR 6(1)(b)), согласие
9
+ * там не нужно: достаточно ссылки на политику площадки у формы (ст. 13).
10
+ */
11
+ export declare const requiresPersonalDataConsent: (country?: string | null) => boolean;
12
+ export declare const PERSONAL_DATA_CONSENT_REQUIRED = "Personal data consent is required";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PERSONAL_DATA_CONSENT_REQUIRED = exports.requiresPersonalDataConsent = void 0;
4
+ const countries_enum_1 = require("@escapenavigator/types/dist/shared/enum/countries.enum");
5
+ /**
6
+ * Отдельное согласие на обработку ПДн спрашиваем только у клиентов площадок
7
+ * из России: после поправок 01.09.2025 РКН ждёт его отдельной галочкой, и
8
+ * площадка должна уметь доказать, что оно было (ч. 3 ст. 9 152-ФЗ). Бэкенд
9
+ * не принимает заявки, сертификаты и первое сообщение чата без него — тогда
10
+ * сама запись в базе и есть доказательство.
11
+ *
12
+ * В ЕС основание — договор или преддоговорный запрос (GDPR 6(1)(b)), согласие
13
+ * там не нужно: достаточно ссылки на политику площадки у формы (ст. 13).
14
+ */
15
+ const requiresPersonalDataConsent = (country) => country === countries_enum_1.CountriesEnum.RUSSIA;
16
+ exports.requiresPersonalDataConsent = requiresPersonalDataConsent;
17
+ exports.PERSONAL_DATA_CONSENT_REQUIRED = 'Personal data consent is required';
@@ -0,0 +1,7 @@
1
+ import { RoleRO } from '@escapenavigator/types/dist/role/role.ro';
2
+ export type RoleClientDeletePermissions = Pick<RoleRO, 'totalAccess' | 'canDeleteClients'>;
3
+ /**
4
+ * Анонимизировать клиента может владелец профиля или сотрудник, которому
5
+ * владелец явно выдал это право.
6
+ */
7
+ export declare const canDeleteClients: (role?: RoleClientDeletePermissions | null) => boolean;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.canDeleteClients = void 0;
4
+ /**
5
+ * Анонимизировать клиента может владелец профиля или сотрудник, которому
6
+ * владелец явно выдал это право.
7
+ */
8
+ const canDeleteClients = (role) => !!role?.totalAccess || !!role?.canDeleteClients;
9
+ exports.canDeleteClients = canDeleteClients;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const role_client_delete_permissions_1 = require("./role-client-delete-permissions");
4
+ describe('canDeleteClients', () => {
5
+ it('denies access without a role or an explicit permission', () => {
6
+ expect((0, role_client_delete_permissions_1.canDeleteClients)()).toBe(false);
7
+ expect((0, role_client_delete_permissions_1.canDeleteClients)(null)).toBe(false);
8
+ expect((0, role_client_delete_permissions_1.canDeleteClients)({ totalAccess: false, canDeleteClients: false })).toBe(false);
9
+ });
10
+ it('allows a role with the explicit permission', () => {
11
+ expect((0, role_client_delete_permissions_1.canDeleteClients)({ totalAccess: false, canDeleteClients: true })).toBe(true);
12
+ });
13
+ it('always allows the owner role', () => {
14
+ expect((0, role_client_delete_permissions_1.canDeleteClients)({ totalAccess: true, canDeleteClients: false })).toBe(true);
15
+ });
16
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@escapenavigator/utils",
3
- "version": "2.1.22",
3
+ "version": "2.1.24",
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.22",
17
+ "@escapenavigator/types": "^2.1.24",
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": "a4d5c142ffa0a99936093b991f5ee87cf8359d7e"
32
+ "gitHead": "153992d51e958b46acefa16ab49c9a0c1f727150"
33
33
  }