mts-booking-library 3.0.13 → 3.1.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/README.md +32 -4
- package/lib/booking/journeyBooking.js +8 -5
- package/lib/booking/serviceBooking.js +8 -5
- package/lib/booking/subscriptionBooking.js +8 -5
- package/lib/booking/tplBooking.js +8 -5
- package/lib/index.d.ts +1 -0
- package/lib/types/common/Cart.d.ts +16 -0
- package/lib/types/common/ChangeInformation.d.ts +54 -0
- package/lib/types/common/ChangeInformation.js +13 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,9 +1,37 @@
|
|
|
1
1
|
# Publish
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
To publish a new version of the library, first create a new version with the `npm version` command,
|
|
4
|
+
specifying the semver increment (`patch`, `minor` or `major`, e.g. `npm version patch`).
|
|
5
|
+
|
|
6
|
+
The library will be published to npm by the pipelines every time a new version is detected on the
|
|
7
|
+
`main` branch.
|
|
8
|
+
|
|
9
|
+
For that to work, the `NPM_TOKEN` secret must be kept up-to-date, as it expires **every 90 days**
|
|
10
|
+
and has to be rotated manually.
|
|
11
|
+
|
|
12
|
+
**LAST UPDATE: 2026-05-07**
|
|
13
|
+
|
|
14
|
+
### How to update the npm token
|
|
15
|
+
|
|
16
|
+
1. Go to https://www.npmjs.com/login
|
|
17
|
+
1. Login with the `sviluppatoriinfos` username, and its password
|
|
18
|
+
1. 2FA will be required, ask Jacopo Gargano (jacopo.gargano@infos.it)
|
|
19
|
+
1. Once logged in, navigate to https://www.npmjs.com/settings/sviluppatoriinfos/tokens
|
|
20
|
+
1. On that page, delete the outdated token
|
|
21
|
+
1. Click on "Generate New Token" (may require a second 2FA code)
|
|
22
|
+
1. Use the following settings:
|
|
23
|
+
- Token name: `mts-booking-library publishing`
|
|
24
|
+
- Bypass two-factor authentication (2FA): true
|
|
25
|
+
- Packages and scopes
|
|
26
|
+
- Permissions: Read and write
|
|
27
|
+
- Select packages > Only select packages and scopes: `mts-booking-library`
|
|
28
|
+
- Expiration > Expiration Date: 90 days
|
|
29
|
+
1. Click on "Generate token", and copy the token
|
|
30
|
+
1. Go to the edit pipeline page in Azure:
|
|
31
|
+
https://dev.azure.com/infoservicesrl/MyTicketSolution%202.0/_apps/hub/ms.vss-build-web.ci-designer-hub?pipelineId=88&branch=main
|
|
32
|
+
1. Click on Variables > `NPM_TOKEN`
|
|
33
|
+
1. Paste the new value, then Save > Save
|
|
34
|
+
1. Update the date above
|
|
7
35
|
|
|
8
36
|
# Test
|
|
9
37
|
|
|
@@ -134,17 +134,20 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
|
134
134
|
};
|
|
135
135
|
JourneyBooking.prototype.fetchAndSetCart = function (cartGuid, options) {
|
|
136
136
|
return __awaiter(this, void 0, void 0, function () {
|
|
137
|
-
var cart;
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
var cart, isDeadCart;
|
|
138
|
+
var _a, _b;
|
|
139
|
+
return __generator(this, function (_c) {
|
|
140
|
+
switch (_c.label) {
|
|
140
141
|
case 0: return [4 /*yield*/, this.fetchCart(cartGuid, options)];
|
|
141
142
|
case 1:
|
|
142
|
-
cart =
|
|
143
|
+
cart = _c.sent();
|
|
143
144
|
if (!cart)
|
|
144
145
|
return [2 /*return*/];
|
|
146
|
+
isDeadCart = cart.hasCanceledTickets === true && ((_b = (_a = cart.bookings) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) === 0;
|
|
145
147
|
if (cart.bookingDueDateTime &&
|
|
146
148
|
new Date(cart.bookingDueDateTime.dateTime) > new Date() &&
|
|
147
|
-
!cart.hasIssuedTickets
|
|
149
|
+
!cart.hasIssuedTickets &&
|
|
150
|
+
!isDeadCart) {
|
|
148
151
|
this.cart = cart;
|
|
149
152
|
this.cartGuid = cart.guid;
|
|
150
153
|
this.bookingDueDateTime = cart.bookingDueDateTime; // See Booking class
|
|
@@ -134,17 +134,20 @@ var ServiceBooking = /** @class */ (function (_super) {
|
|
|
134
134
|
};
|
|
135
135
|
ServiceBooking.prototype.fetchAndSetCart = function (cartGuid, options) {
|
|
136
136
|
return __awaiter(this, void 0, void 0, function () {
|
|
137
|
-
var cart;
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
var cart, isDeadCart;
|
|
138
|
+
var _a, _b;
|
|
139
|
+
return __generator(this, function (_c) {
|
|
140
|
+
switch (_c.label) {
|
|
140
141
|
case 0: return [4 /*yield*/, this.fetchCart(cartGuid, options)];
|
|
141
142
|
case 1:
|
|
142
|
-
cart =
|
|
143
|
+
cart = _c.sent();
|
|
143
144
|
if (!cart)
|
|
144
145
|
return [2 /*return*/];
|
|
146
|
+
isDeadCart = cart.hasCanceledTickets === true && ((_b = (_a = cart.bookings) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) === 0;
|
|
145
147
|
if (cart.bookingDueDateTime &&
|
|
146
148
|
new Date(cart.bookingDueDateTime.dateTime) > new Date() &&
|
|
147
|
-
!cart.hasIssuedTickets
|
|
149
|
+
!cart.hasIssuedTickets &&
|
|
150
|
+
!isDeadCart) {
|
|
148
151
|
this.cart = cart;
|
|
149
152
|
this.cartGuid = cart.guid;
|
|
150
153
|
this.bookingDueDateTime = cart.bookingDueDateTime; // See Booking class
|
|
@@ -134,17 +134,20 @@ var SubscriptionBooking = /** @class */ (function (_super) {
|
|
|
134
134
|
};
|
|
135
135
|
SubscriptionBooking.prototype.fetchAndSetCart = function (cartGuid, options) {
|
|
136
136
|
return __awaiter(this, void 0, void 0, function () {
|
|
137
|
-
var cart;
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
var cart, isDeadCart;
|
|
138
|
+
var _a, _b;
|
|
139
|
+
return __generator(this, function (_c) {
|
|
140
|
+
switch (_c.label) {
|
|
140
141
|
case 0: return [4 /*yield*/, this.fetchCart(cartGuid, options)];
|
|
141
142
|
case 1:
|
|
142
|
-
cart =
|
|
143
|
+
cart = _c.sent();
|
|
143
144
|
if (!cart)
|
|
144
145
|
return [2 /*return*/];
|
|
146
|
+
isDeadCart = cart.hasCanceledTickets === true && ((_b = (_a = cart.bookings) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) === 0;
|
|
145
147
|
if (cart.bookingDueDateTime &&
|
|
146
148
|
new Date(cart.bookingDueDateTime.dateTime) > new Date() &&
|
|
147
|
-
!cart.hasIssuedTickets
|
|
149
|
+
!cart.hasIssuedTickets &&
|
|
150
|
+
!isDeadCart) {
|
|
148
151
|
this.cart = cart;
|
|
149
152
|
this.cartGuid = cart.guid;
|
|
150
153
|
this.bookingDueDateTime = cart.bookingDueDateTime; // See Booking class
|
|
@@ -141,17 +141,20 @@ var TplBooking = /** @class */ (function (_super) {
|
|
|
141
141
|
};
|
|
142
142
|
TplBooking.prototype.fetchAndSetCart = function (cartGuid, options) {
|
|
143
143
|
return __awaiter(this, void 0, void 0, function () {
|
|
144
|
-
var cart;
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
var cart, isDeadCart;
|
|
145
|
+
var _a, _b;
|
|
146
|
+
return __generator(this, function (_c) {
|
|
147
|
+
switch (_c.label) {
|
|
147
148
|
case 0: return [4 /*yield*/, this.fetchCart(cartGuid, options)];
|
|
148
149
|
case 1:
|
|
149
|
-
cart =
|
|
150
|
+
cart = _c.sent();
|
|
150
151
|
if (!cart)
|
|
151
152
|
return [2 /*return*/];
|
|
153
|
+
isDeadCart = cart.hasCanceledTickets === true && ((_b = (_a = cart.bookings) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) === 0;
|
|
152
154
|
if (cart.bookingDueDateTime &&
|
|
153
155
|
new Date(cart.bookingDueDateTime.dateTime) > new Date() &&
|
|
154
|
-
!cart.hasIssuedTickets
|
|
156
|
+
!cart.hasIssuedTickets &&
|
|
157
|
+
!isDeadCart) {
|
|
155
158
|
this.cart = cart;
|
|
156
159
|
this.cartGuid = cart.guid;
|
|
157
160
|
this.bookingDueDateTime = cart.bookingDueDateTime; // See Booking class
|
package/lib/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export { Person, DEFAULT_PERSON, initializePerson } from "./types/common/Person"
|
|
|
10
10
|
export { GetBuyerPassengersDetailsResponse, GetPersonRequest, GetPassenger, EditPassengerRequestType, EditPassengersDetailsRequest } from "./types/common/Person";
|
|
11
11
|
export { Tariff, TariffsMatrix, TariffSummary, TariffType, TermsType, PassengerTariff, ExtraTariff } from "./types/common/Tariffs";
|
|
12
12
|
export { ReductionType, Reduction, AddReductionRequest } from "./types/common/Reduction";
|
|
13
|
+
export { GetChangeInformationRequest, GetChangeInformationResponse, ChangeTicketInformation } from "./types/common/ChangeInformation";
|
|
13
14
|
export { Gateway, GetSellerGatewaysResponse, GetPaymentInformationFromGatewayResponse, IssueCartResponse, GatewayTypes, PaymentMethods } from "./types/common/Payment";
|
|
14
15
|
export { ErrorResponse, objectIsMTSErrorResponse } from "./types/ErrorResponse";
|
|
15
16
|
export { City } from "./types/common/City";
|
|
@@ -70,6 +70,14 @@ export type Cart = {
|
|
|
70
70
|
* cart. It is expressed in the currency of the cart.
|
|
71
71
|
*/
|
|
72
72
|
totalCreditFromChange: number;
|
|
73
|
+
/**
|
|
74
|
+
* Sum of penalty (penale) amounts levied on the original tickets being replaced
|
|
75
|
+
* by this change cart. Positive number, in the same currency as
|
|
76
|
+
* {@link Cart.currency}. Zero when no change is in progress or no penalty rule
|
|
77
|
+
* applies to the changed tickets. Surfaced so the booking summary can render a
|
|
78
|
+
* "Penale cambio" line alongside {@link Cart.totalCreditFromChange}.
|
|
79
|
+
*/
|
|
80
|
+
totalChangePenalty: number;
|
|
73
81
|
/** The total amount to pay by buyer */
|
|
74
82
|
totalAmountToPayByBuyer: number;
|
|
75
83
|
/**
|
|
@@ -105,6 +113,14 @@ export type Cart = {
|
|
|
105
113
|
* possible to add tickets to an issued cart. Thus, all data should be reset.
|
|
106
114
|
*/
|
|
107
115
|
hasIssuedTickets: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* True when at least one ticket attached to the cart has been canceled (e.g. all
|
|
118
|
+
* gateway transactions expired before capture and the parent service transaction
|
|
119
|
+
* also expired, auto-canceling the ticket). Combined with an empty `bookings`
|
|
120
|
+
* list this flags a dead cart that the library will drop from persisted state.
|
|
121
|
+
* Optional for forward compatibility against backends that pre-date the field.
|
|
122
|
+
*/
|
|
123
|
+
hasCanceledTickets?: boolean;
|
|
108
124
|
/** The booking due date as ISO string */
|
|
109
125
|
bookingDueDateTime: DateWithTimeZone;
|
|
110
126
|
/** The ids of the tickets in the cart */
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the BE preview endpoint `GET /v3_tickets/change/info`.
|
|
3
|
+
*
|
|
4
|
+
* Fetches the change-penalty (PENALE) for a set of tickets WITHOUT creating a
|
|
5
|
+
* change cart, so the FE can render a confirmation pop-up before the user
|
|
6
|
+
* commits to the change:
|
|
7
|
+
*
|
|
8
|
+
* "Il costo del cambio è di euro xx
|
|
9
|
+
* Vuoi procedere?
|
|
10
|
+
* [si] [indietro]"
|
|
11
|
+
*/
|
|
12
|
+
export type GetChangeInformationRequest = {
|
|
13
|
+
/**
|
|
14
|
+
* Convenience single-PNR alternative to {@link ticketsToChange}. Either this
|
|
15
|
+
* or `ticketsToChange` must be set.
|
|
16
|
+
*/
|
|
17
|
+
pnr?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The PNRs / ticket codes to preview the change penalty for. Pass when the
|
|
20
|
+
* user is changing more than one ticket at once.
|
|
21
|
+
*/
|
|
22
|
+
ticketsToChange?: string[];
|
|
23
|
+
};
|
|
24
|
+
export type GetChangeInformationResponse = {
|
|
25
|
+
/** Per-ticket breakdown of the penalty preview. */
|
|
26
|
+
ticketsToChange: ChangeTicketInformation[];
|
|
27
|
+
/**
|
|
28
|
+
* Sum of {@link ChangeTicketInformation.penalty} across all tickets in the
|
|
29
|
+
* request. Positive value, in {@link GetChangeInformationResponse.currency}.
|
|
30
|
+
* Surfaced so the FE can render a single "Il costo del cambio è di euro xx"
|
|
31
|
+
* line in the pop-up.
|
|
32
|
+
*/
|
|
33
|
+
totalChangePenalty: number;
|
|
34
|
+
/**
|
|
35
|
+
* Currency of {@link totalChangePenalty}. Sourced from the first ticket in
|
|
36
|
+
* the request — if the caller passes tickets with different currencies, only
|
|
37
|
+
* the first is reflected here. Mixed-currency requests are unsupported; use
|
|
38
|
+
* the per-ticket {@link ChangeTicketInformation.currency} for authoritative
|
|
39
|
+
* per-ticket display.
|
|
40
|
+
*/
|
|
41
|
+
currency: string;
|
|
42
|
+
};
|
|
43
|
+
export type ChangeTicketInformation = {
|
|
44
|
+
pnr: string;
|
|
45
|
+
/**
|
|
46
|
+
* Penalty owed to the seller for changing this ticket. Computed via the
|
|
47
|
+
* tariff's value-date rule, capped at the ticket's actual value to the
|
|
48
|
+
* buyer. Zero when no rule applies.
|
|
49
|
+
*/
|
|
50
|
+
penalty: number;
|
|
51
|
+
/** True when the ticket is changeable per its terms-type configuration. */
|
|
52
|
+
isChangeable: boolean;
|
|
53
|
+
currency: string;
|
|
54
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Types for the BE preview endpoint `GET /v3_tickets/change/info`.
|
|
4
|
+
*
|
|
5
|
+
* Fetches the change-penalty (PENALE) for a set of tickets WITHOUT creating a
|
|
6
|
+
* change cart, so the FE can render a confirmation pop-up before the user
|
|
7
|
+
* commits to the change:
|
|
8
|
+
*
|
|
9
|
+
* "Il costo del cambio è di euro xx
|
|
10
|
+
* Vuoi procedere?
|
|
11
|
+
* [si] [indietro]"
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|