@escapenavigator/utils 1.10.105 → 1.10.107
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/get-full-name.d.ts +3 -2
- package/dist/get-full-name.js +4 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/serialize-slot.d.ts +25 -4
- package/dist/serialize-slot.js +103 -29
- package/package.json +3 -3
package/dist/get-full-name.d.ts
CHANGED
package/dist/get-full-name.js
CHANGED
|
@@ -4,9 +4,10 @@ exports.getFullName = void 0;
|
|
|
4
4
|
const getFullName = (row) => {
|
|
5
5
|
if (!row)
|
|
6
6
|
return 'Deleted';
|
|
7
|
-
const { name, surname, id } = row;
|
|
8
|
-
if (name || surname)
|
|
9
|
-
return `${name || ''} ${surname || ''}`.trim();
|
|
7
|
+
const { name, patronymic, surname, id, } = row;
|
|
8
|
+
if (name || patronymic || surname) {
|
|
9
|
+
return `${name || ''} ${patronymic || ''} ${surname || ''}`.replace(/\s+/g, ' ').trim();
|
|
10
|
+
}
|
|
10
11
|
return `Client №${id}`;
|
|
11
12
|
};
|
|
12
13
|
exports.getFullName = getFullName;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -29,3 +29,4 @@ __exportStar(require("./tz-date"), exports);
|
|
|
29
29
|
__exportStar(require("./validate-by-dto"), exports);
|
|
30
30
|
__exportStar(require("./convert-hhmm-to-minutes"), exports);
|
|
31
31
|
__exportStar(require("./convert-minutes-to-hhmm"), exports);
|
|
32
|
+
__exportStar(require("./get-full-name"), exports);
|
package/dist/serialize-slot.d.ts
CHANGED
|
@@ -2,10 +2,31 @@ import { OrderRO } from '@escapenavigator/types/dist/order/order.ro';
|
|
|
2
2
|
import { SlotRO } from '@escapenavigator/types/dist/slot/slot.ro';
|
|
3
3
|
type Props = {
|
|
4
4
|
slot: any;
|
|
5
|
-
|
|
5
|
+
orders?: Array<OrderRO & {
|
|
6
6
|
workers: any[];
|
|
7
|
-
}
|
|
7
|
+
}>;
|
|
8
8
|
};
|
|
9
|
-
export declare const serializeSlotOrderData: (order:
|
|
10
|
-
|
|
9
|
+
export declare const serializeSlotOrderData: (order: OrderRO & {
|
|
10
|
+
workers: any[];
|
|
11
|
+
}) => SlotRO['orders'][number];
|
|
12
|
+
/**
|
|
13
|
+
* Serializes the internal slot model into the public `SlotRO`.
|
|
14
|
+
*
|
|
15
|
+
* The list response no longer carries `durations` or `variations`. For flex
|
|
16
|
+
* slots top-level fields (status/end/tariff/availability) reflect the minimum
|
|
17
|
+
* duration, which is what the slot service has already pre-computed via
|
|
18
|
+
* `groupSlotsWithDurationsAndVariations`.
|
|
19
|
+
*
|
|
20
|
+
* Consumers that need the full duration/variation set should call the
|
|
21
|
+
* `/openapi/slots/details` endpoint on demand.
|
|
22
|
+
*/
|
|
23
|
+
export declare const serializeSlot: ({ slot, orders }: Props) => SlotRO;
|
|
24
|
+
/**
|
|
25
|
+
* Legacy serializer that emits the old `variations[]` + `variationKind` shape.
|
|
26
|
+
*
|
|
27
|
+
* Kept only for legacy aggregator endpoints where the public response contract
|
|
28
|
+
* cannot be changed (now-escape, ru aggregators). Prefer `serializeSlot` for
|
|
29
|
+
* everything else.
|
|
30
|
+
*/
|
|
31
|
+
export declare const serializeSlotLegacy: ({ slot, orders }: Props) => any;
|
|
11
32
|
export {};
|
package/dist/serialize-slot.js
CHANGED
|
@@ -1,17 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.serializeSlot = exports.serializeSlotOrderData = void 0;
|
|
3
|
+
exports.serializeSlotLegacy = exports.serializeSlot = exports.serializeSlotOrderData = void 0;
|
|
4
4
|
const defailt_rule_1 = require("@escapenavigator/types/dist/slot-rule/defailt-rule");
|
|
5
5
|
const get_full_name_1 = require("./get-full-name");
|
|
6
|
+
const buildRuleSummary = (rule) => {
|
|
7
|
+
const { prepayment, prepaymentType, title, minHoursForBooking, minHoursForFreeCanceling, cancelationRule, tax, minHoursForFullFine, cancelationAmount, } = rule || defailt_rule_1.defaultRule;
|
|
8
|
+
return {
|
|
9
|
+
prepayment,
|
|
10
|
+
tax,
|
|
11
|
+
minHoursForFullFine,
|
|
12
|
+
cancelationAmount,
|
|
13
|
+
prepaymentType,
|
|
14
|
+
title,
|
|
15
|
+
minHoursForBooking,
|
|
16
|
+
minHoursForFreeCanceling,
|
|
17
|
+
cancelationRule,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
const computeDurationMinutes = (start, end, fallback) => {
|
|
21
|
+
if (typeof fallback === 'number')
|
|
22
|
+
return fallback;
|
|
23
|
+
if (!start || !end)
|
|
24
|
+
return 0;
|
|
25
|
+
return (Math.max(0, new Date(`1970-01-01T${end}`).getTime() - new Date(`1970-01-01T${start}`).getTime()) / 60000);
|
|
26
|
+
};
|
|
6
27
|
const serializeSlotOrderData = (order) => order && {
|
|
7
28
|
id: order.id,
|
|
8
29
|
players: order.players,
|
|
9
30
|
children: order.children,
|
|
10
|
-
hasDiscounts: !!order.discounts?.length,
|
|
11
|
-
hasComments: !!order.messages?.length || !!order.comment,
|
|
12
|
-
hasCertificateApplies: !!order.certificates?.length,
|
|
13
|
-
hasPenalties: !!order.penalties?.length,
|
|
14
|
-
hasUpsellings: !!order.upsellings?.length,
|
|
15
31
|
utcDate: order.utcDate,
|
|
16
32
|
moderatorId: order.moderatorId,
|
|
17
33
|
confirmed: order.confirmed,
|
|
@@ -21,36 +37,94 @@ const serializeSlotOrderData = (order) => order && {
|
|
|
21
37
|
otherParticipantsIds: order.workers?.map(({ userId }) => userId) || [],
|
|
22
38
|
code: order.code,
|
|
23
39
|
clientName: (0, get_full_name_1.getFullName)(order.client),
|
|
40
|
+
hold: order.hold,
|
|
41
|
+
expiration: order.expiration,
|
|
24
42
|
};
|
|
25
43
|
exports.serializeSlotOrderData = serializeSlotOrderData;
|
|
26
|
-
|
|
27
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Serializes the internal slot model into the public `SlotRO`.
|
|
46
|
+
*
|
|
47
|
+
* The list response no longer carries `durations` or `variations`. For flex
|
|
48
|
+
* slots top-level fields (status/end/tariff/availability) reflect the minimum
|
|
49
|
+
* duration, which is what the slot service has already pre-computed via
|
|
50
|
+
* `groupSlotsWithDurationsAndVariations`.
|
|
51
|
+
*
|
|
52
|
+
* Consumers that need the full duration/variation set should call the
|
|
53
|
+
* `/openapi/slots/details` endpoint on demand.
|
|
54
|
+
*/
|
|
55
|
+
const serializeSlot = ({ slot, orders = [] }) => ({
|
|
56
|
+
id: slot.id,
|
|
57
|
+
questroomId: slot.questroomId,
|
|
58
|
+
old: slot.old,
|
|
59
|
+
date: slot.date,
|
|
60
|
+
start: slot.start,
|
|
61
|
+
tariffId: slot.tariffId,
|
|
62
|
+
ruleId: slot.ruleId,
|
|
63
|
+
end: slot.end,
|
|
64
|
+
tariff: slot.tariff?.price || slot.tariff || {},
|
|
65
|
+
status: slot.status,
|
|
66
|
+
discount: slot.discount ?? 0,
|
|
67
|
+
onlyPhone: slot.onlyPhone ?? false,
|
|
68
|
+
forceOnlineBooking: slot.forceOnlineBooking ?? false,
|
|
69
|
+
breakReason: slot.breakReason ?? null,
|
|
70
|
+
availableTeams: slot.availableTeams ?? null,
|
|
71
|
+
numSeatsAvailable: slot.numSeatsAvailable ?? slot.availablePlayers ?? 0,
|
|
72
|
+
rule: slot.rule ? buildRuleSummary(slot.rule) : undefined,
|
|
73
|
+
orders: orders.map((order) => (0, exports.serializeSlotOrderData)(order)),
|
|
74
|
+
});
|
|
75
|
+
exports.serializeSlot = serializeSlot;
|
|
76
|
+
/**
|
|
77
|
+
* Legacy serializer that emits the old `variations[]` + `variationKind` shape.
|
|
78
|
+
*
|
|
79
|
+
* Kept only for legacy aggregator endpoints where the public response contract
|
|
80
|
+
* cannot be changed (now-escape, ru aggregators). Prefer `serializeSlot` for
|
|
81
|
+
* everything else.
|
|
82
|
+
*/
|
|
83
|
+
const serializeSlotLegacy = ({ slot, orders = [] }) => {
|
|
84
|
+
const baseVariation = slot.variations?.[0] || slot;
|
|
85
|
+
const normalizedVariations = (slot.variations || [baseVariation]).map((variation) => {
|
|
86
|
+
const duration = computeDurationMinutes(slot.start, variation.end, variation.duration);
|
|
87
|
+
return {
|
|
88
|
+
id: variation.id,
|
|
89
|
+
tariffId: variation.tariffId,
|
|
90
|
+
ruleId: variation.ruleId,
|
|
91
|
+
variationKind: variation.variationKind,
|
|
92
|
+
end: variation.end,
|
|
93
|
+
duration,
|
|
94
|
+
tariff: variation.tariff?.price || variation.tariff || {},
|
|
95
|
+
status: variation.status,
|
|
96
|
+
discount: variation.discount || 0,
|
|
97
|
+
onlyPhone: !!variation.onlyPhone,
|
|
98
|
+
breakReason: variation.breakReason || null,
|
|
99
|
+
forceOnlineBooking: !!variation.forceOnlineBooking,
|
|
100
|
+
availableTeams: variation.availableTeams ?? null,
|
|
101
|
+
numSeatsAvailable: variation.availablePlayers ?? variation.numSeatsAvailable ?? 0,
|
|
102
|
+
rule: buildRuleSummary(variation.rule || slot.rule),
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
const primaryVariation = normalizedVariations.find((variation) => variation.status === 'free')
|
|
106
|
+
|| normalizedVariations.find((variation) => variation.status === 'call')
|
|
107
|
+
|| normalizedVariations[0];
|
|
28
108
|
return {
|
|
29
109
|
id: slot.id,
|
|
30
110
|
questroomId: slot.questroomId,
|
|
31
|
-
hold: slot.hold,
|
|
32
111
|
old: slot.old,
|
|
33
112
|
date: slot.date,
|
|
34
|
-
discount: slot.discount,
|
|
35
|
-
onlyPhone: slot.onlyPhone,
|
|
36
|
-
status: slot.status,
|
|
37
113
|
start: slot.start,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
},
|
|
53
|
-
order: (0, exports.serializeSlotOrderData)(order),
|
|
114
|
+
defaultVariationId: slot.defaultVariationId ?? slot.tariffId,
|
|
115
|
+
variationIds: slot.variationIds || (slot.tariffId != null ? [slot.tariffId] : []),
|
|
116
|
+
variations: normalizedVariations,
|
|
117
|
+
end: slot.end || primaryVariation?.end,
|
|
118
|
+
tariff: primaryVariation?.tariff,
|
|
119
|
+
status: primaryVariation?.status,
|
|
120
|
+
discount: primaryVariation?.discount,
|
|
121
|
+
onlyPhone: primaryVariation?.onlyPhone,
|
|
122
|
+
forceOnlineBooking: primaryVariation?.forceOnlineBooking,
|
|
123
|
+
breakReason: primaryVariation?.breakReason,
|
|
124
|
+
availableTeams: primaryVariation?.availableTeams,
|
|
125
|
+
numSeatsAvailable: primaryVariation?.numSeatsAvailable,
|
|
126
|
+
rule: primaryVariation?.rule,
|
|
127
|
+
orders: orders.map((order) => (0, exports.serializeSlotOrderData)(order)),
|
|
54
128
|
};
|
|
55
129
|
};
|
|
56
|
-
exports.
|
|
130
|
+
exports.serializeSlotLegacy = serializeSlotLegacy;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@escapenavigator/utils",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.107",
|
|
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": "^1.10.
|
|
17
|
+
"@escapenavigator/types": "^1.10.103",
|
|
18
18
|
"axios": "^0.21.4",
|
|
19
19
|
"class-transformer": "^0.5.1",
|
|
20
20
|
"class-validator": "^0.13.2",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"utility-types": "^3.10.0",
|
|
48
48
|
"uuid": "^8.3.2"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "0e41f6e541edd14685f9dd242e17207d1b8f6660"
|
|
51
51
|
}
|