@vendit-dev/thirdparty-adapters 0.7.19 → 0.7.20

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.
@@ -107,7 +107,7 @@ export type VenditPaymentInfoInput = {
107
107
  };
108
108
  export declare abstract class ExternalChannelManager {
109
109
  abstract getRoomTypes(): Promise<ExternalRoomType[]>;
110
- abstract getReservations(input?: unknown): Promise<ExternalReservation[] | undefined>;
110
+ abstract getReservations(input?: unknown, options?: Record<string, unknown>): Promise<ExternalReservation[] | undefined>;
111
111
  abstract updateStocks(input?: unknown): Promise<boolean>;
112
112
  abstract updatePricePlans(input?: unknown): Promise<boolean>;
113
113
  }
@@ -5,11 +5,14 @@ export declare class TlLincoln implements ExternalChannelManager {
5
5
  private readonly systemId;
6
6
  private readonly pmsUserId;
7
7
  private readonly pmsPassword;
8
- constructor({ credentials, apiHost }: {
8
+ constructor({ credentials, apiHost, }: {
9
9
  credentials: TlLincolnCredentials;
10
10
  apiHost?: string;
11
11
  });
12
- getReservations(input?: TlLincolnReservationRequestInput, mergedReservations?: ExternalReservation[]): Promise<ExternalReservation[] | undefined>;
12
+ getReservations(input?: TlLincolnReservationRequestInput, options?: {
13
+ mergedReservations?: ExternalReservation[];
14
+ isDevelopment?: boolean;
15
+ }): Promise<ExternalReservation[] | undefined>;
13
16
  getRoomTypes(): Promise<ExternalRoomType[]>;
14
17
  updatePricePlans<TRequest>(): Promise<boolean>;
15
18
  updateStocks(input: ExternalChannelManagerUpdateStockRequest[]): Promise<boolean>;
@@ -180,7 +180,7 @@ var formattedPaxCountText = function (roomInformation, genderDivision) {
180
180
  exports.formattedPaxCountText = formattedPaxCountText;
181
181
  function formatPhoneNumber(text) {
182
182
  var onlyNumberText = text === null || text === void 0 ? void 0 : text.replace(/[^0-9]/g, '');
183
- var safeNumberRegex = /^050{1}[0-9]{9}$/;
183
+ var safeNumberRegex = /^0?50[0-9]{8,9}$/;
184
184
  // +로 시작하는 경우 처리
185
185
  if (text === null || text === void 0 ? void 0 : text.startsWith('+')) {
186
186
  // +82로 시작하는 경우
@@ -191,6 +191,9 @@ function formatPhoneNumber(text) {
191
191
  return text.replace(/[+\s]/g, '');
192
192
  }
193
193
  if (safeNumberRegex.test(onlyNumberText || '')) {
194
+ if (onlyNumberText === null || onlyNumberText === void 0 ? void 0 : onlyNumberText.startsWith('50')) {
195
+ return "0".concat(onlyNumberText);
196
+ }
194
197
  return onlyNumberText;
195
198
  }
196
199
  return onlyNumberText ? "010".concat(onlyNumberText.slice(-8)) : '';
@@ -77,22 +77,23 @@ var TlLincoln = /** @class */ (function () {
77
77
  this.pmsUserId = credentials.pmsUserId;
78
78
  this.pmsPassword = credentials.pmsPassword;
79
79
  }
80
- TlLincoln.prototype.getReservations = function (input, mergedReservations) {
81
- if (mergedReservations === void 0) { mergedReservations = []; }
80
+ TlLincoln.prototype.getReservations = function (input, options) {
81
+ var _a;
82
82
  return __awaiter(this, void 0, void 0, function () {
83
- var continueFetching, result, reservations, _a, isSuccess, errorDescription, failureReason, _b, bookingInfoList, configurationSettings, refinedArrayReservationList;
84
- return __generator(this, function (_c) {
85
- switch (_c.label) {
83
+ var continueFetching, result, reservations, _b, isSuccess, errorDescription, failureReason, _c, bookingInfoList, configurationSettings, refinedArrayReservationList;
84
+ return __generator(this, function (_d) {
85
+ switch (_d.label) {
86
86
  case 0:
87
87
  continueFetching = true;
88
- result = __spreadArray([], mergedReservations, true);
89
- _c.label = 1;
88
+ result = __spreadArray([], ((_a = options === null || options === void 0 ? void 0 : options.mergedReservations) !== null && _a !== void 0 ? _a : []), true);
89
+ _d.label = 1;
90
90
  case 1:
91
- if (!continueFetching) return [3 /*break*/, 4];
91
+ if (!continueFetching) return [3 /*break*/, 5];
92
92
  return [4 /*yield*/, this.bookingInfoOutputService(input)];
93
93
  case 2:
94
- reservations = _c.sent();
95
- _a = reservations['S:Envelope']['S:Body']['ns2:executeResponse'].return.commonResponse, isSuccess = _a.isSuccess, errorDescription = _a.errorDescription, failureReason = _a.failureReason;
94
+ reservations = _d.sent();
95
+ _b = reservations['S:Envelope']['S:Body']['ns2:executeResponse'].return
96
+ .commonResponse, isSuccess = _b.isSuccess, errorDescription = _b.errorDescription, failureReason = _b.failureReason;
96
97
  if (!isSuccess) {
97
98
  throw new externalChannelManager_type_1.ExternalChannelManagerError({
98
99
  message: "Failed to load Reservations - ".concat(errorDescription, ": ").concat(failureReason),
@@ -100,18 +101,21 @@ var TlLincoln = /** @class */ (function () {
100
101
  description: errorDescription,
101
102
  });
102
103
  }
103
- _b = reservations['S:Envelope']['S:Body']['ns2:executeResponse'].return, bookingInfoList = _b.bookingInfoList, configurationSettings = _b.configurationSettings;
104
+ _c = reservations['S:Envelope']['S:Body']['ns2:executeResponse'].return, bookingInfoList = _c.bookingInfoList, configurationSettings = _c.configurationSettings;
104
105
  refinedArrayReservationList = (0, tl_lincoln_types_1.makeArray)(bookingInfoList);
105
- if (!(configurationSettings === null || configurationSettings === void 0 ? void 0 : configurationSettings.outputId)) {
106
+ if (!(options === null || options === void 0 ? void 0 : options.isDevelopment) && !(configurationSettings === null || configurationSettings === void 0 ? void 0 : configurationSettings.outputId)) {
106
107
  throw new externalChannelManager_type_1.ExternalChannelManagerError({
107
108
  message: 'Failed to load Reservations - outputId is not found',
108
109
  code: 'outputId is not found',
109
110
  description: 'outputId is not found',
110
111
  });
111
112
  }
113
+ if (!(!(options === null || options === void 0 ? void 0 : options.isDevelopment) && (configurationSettings === null || configurationSettings === void 0 ? void 0 : configurationSettings.outputId))) return [3 /*break*/, 4];
112
114
  return [4 /*yield*/, this.outputCompleteService(configurationSettings === null || configurationSettings === void 0 ? void 0 : configurationSettings.outputId)];
113
115
  case 3:
114
- _c.sent();
116
+ _d.sent();
117
+ _d.label = 4;
118
+ case 4:
115
119
  result = refinedArrayReservationList.reduce(function (acc, reservation) {
116
120
  if (reservation === null || reservation === void 0 ? void 0 : reservation.infoTravelXML) {
117
121
  var refinedData = (0, tl_lincoln_helper_1.refineReservationData)((0, tl_lincoln_helper_1.xmlToJson)(reservation.infoTravelXML));
@@ -122,7 +126,7 @@ var TlLincoln = /** @class */ (function () {
122
126
  // 다음 페이지가 있는지 여부 확인: 100개면 추가 호출이 필요하다고 가정
123
127
  continueFetching = refinedArrayReservationList.length === 100;
124
128
  return [3 /*break*/, 1];
125
- case 4: return [2 /*return*/, result];
129
+ case 5: return [2 /*return*/, result];
126
130
  }
127
131
  });
128
132
  });
@@ -135,8 +139,10 @@ var TlLincoln = /** @class */ (function () {
135
139
  case 0: return [4 /*yield*/, this.netRoomTypeMasterSearchService()];
136
140
  case 1:
137
141
  result = _c.sent();
138
- if (!result['S:Envelope']['S:Body']['ns2:executeResponse'].return.commonResponse.isSuccess) {
139
- _a = result['S:Envelope']['S:Body']['ns2:executeResponse'].return.commonResponse, errorDescription = _a.errorDescription, failureReason = _a.failureReason;
142
+ if (!result['S:Envelope']['S:Body']['ns2:executeResponse'].return
143
+ .commonResponse.isSuccess) {
144
+ _a = result['S:Envelope']['S:Body']['ns2:executeResponse'].return
145
+ .commonResponse, errorDescription = _a.errorDescription, failureReason = _a.failureReason;
140
146
  throw new externalChannelManager_type_1.ExternalChannelManagerError({
141
147
  message: "Failed to load RoomTypes - ".concat(errorDescription, ": ").concat(failureReason),
142
148
  code: failureReason,
@@ -145,7 +151,9 @@ var TlLincoln = /** @class */ (function () {
145
151
  }
146
152
  _b = result['S:Envelope']['S:Body']['ns2:executeResponse'].return, rmTypeList = _b.rmTypeList, netRmTypeGroupList = _b.netRmTypeGroupList, netAgtRmTypeList = _b.netAgtRmTypeList;
147
153
  aggregateRoomTypeGroups = function (rmTypeCode) {
148
- var groups = (0, tl_lincoln_types_1.isArray)(netRmTypeGroupList) ? netRmTypeGroupList.filter(function (group) { return group.rmTypeCode === rmTypeCode; }) : [netRmTypeGroupList];
154
+ var groups = (0, tl_lincoln_types_1.isArray)(netRmTypeGroupList)
155
+ ? netRmTypeGroupList.filter(function (group) { return group.rmTypeCode === rmTypeCode; })
156
+ : [netRmTypeGroupList];
149
157
  return groups.map(function (group) { return ({
150
158
  groupCode: group.netRmTypeGroupCode,
151
159
  groupName: group.netRmTypeGroupName,
@@ -153,7 +161,9 @@ var TlLincoln = /** @class */ (function () {
153
161
  }); });
154
162
  };
155
163
  aggregateAgentRoomTypeGroups = function (rmTypeCode) {
156
- var groups = (0, tl_lincoln_types_1.isArray)(netAgtRmTypeList) ? netAgtRmTypeList.filter(function (group) { return group.rmTypeCode === rmTypeCode; }) : [netAgtRmTypeList];
164
+ var groups = (0, tl_lincoln_types_1.isArray)(netAgtRmTypeList)
165
+ ? netAgtRmTypeList.filter(function (group) { return group.rmTypeCode === rmTypeCode; })
166
+ : [netAgtRmTypeList];
157
167
  return groups.map(function (group) { return ({
158
168
  agentRoomTypeCode: group.netAgtRmTypeCode,
159
169
  agentRoomTypeName: group.netAgtRmTypeName,
@@ -161,17 +171,21 @@ var TlLincoln = /** @class */ (function () {
161
171
  rmTypeCode: group.rmTypeCode,
162
172
  }); });
163
173
  };
164
- return [2 /*return*/, (0, tl_lincoln_types_1.isArray)(rmTypeList) ? rmTypeList.map(function (roomType) { return ({
165
- roomTypeCode: roomType.rmTypeCode,
166
- roomTypeName: roomType.rmTypeName,
167
- groups: aggregateRoomTypeGroups(roomType.rmTypeCode),
168
- agentRoomTypes: aggregateAgentRoomTypeGroups(roomType.rmTypeCode),
169
- }); }) : [{
170
- roomTypeCode: rmTypeList.rmTypeCode,
171
- roomTypeName: rmTypeList.rmTypeName,
172
- groups: aggregateRoomTypeGroups(rmTypeList.rmTypeCode),
173
- agentRoomTypes: aggregateAgentRoomTypeGroups(rmTypeList.rmTypeCode),
174
- }]];
174
+ return [2 /*return*/, (0, tl_lincoln_types_1.isArray)(rmTypeList)
175
+ ? rmTypeList.map(function (roomType) { return ({
176
+ roomTypeCode: roomType.rmTypeCode,
177
+ roomTypeName: roomType.rmTypeName,
178
+ groups: aggregateRoomTypeGroups(roomType.rmTypeCode),
179
+ agentRoomTypes: aggregateAgentRoomTypeGroups(roomType.rmTypeCode),
180
+ }); })
181
+ : [
182
+ {
183
+ roomTypeCode: rmTypeList.rmTypeCode,
184
+ roomTypeName: rmTypeList.rmTypeName,
185
+ groups: aggregateRoomTypeGroups(rmTypeList.rmTypeCode),
186
+ agentRoomTypes: aggregateAgentRoomTypeGroups(rmTypeList.rmTypeCode),
187
+ },
188
+ ]];
175
189
  }
176
190
  });
177
191
  });
@@ -195,8 +209,10 @@ var TlLincoln = /** @class */ (function () {
195
209
  return [4 /*yield*/, this.netStockAdjustmentService(refinedData)];
196
210
  case 2:
197
211
  result = _b.sent();
198
- if (!result['S:Envelope']['S:Body']['ns2:executeResponse'].return.commonResponse.isSuccess) {
199
- _a = result['S:Envelope']['S:Body']['ns2:executeResponse'].return.commonResponse, errorDescription = _a.errorDescription, failureReason = _a.failureReason;
212
+ if (!result['S:Envelope']['S:Body']['ns2:executeResponse'].return
213
+ .commonResponse.isSuccess) {
214
+ _a = result['S:Envelope']['S:Body']['ns2:executeResponse'].return
215
+ .commonResponse, errorDescription = _a.errorDescription, failureReason = _a.failureReason;
200
216
  throw new externalChannelManager_type_1.ExternalChannelManagerError({
201
217
  message: "Failed to update RoomType stocks - ".concat(errorDescription, ": ").concat(failureReason),
202
218
  code: failureReason,
@@ -221,7 +237,9 @@ var TlLincoln = /** @class */ (function () {
221
237
  netRmTypeGroupCode: input.roomTypeCode,
222
238
  adjustmentProcedureCode: tl_lincoln_types_1.AdjustmentProcedureCode.NET_ROOM_TYPE_GROUP_CODE,
223
239
  // stock이 0이 아니더라도 salesStatus를 START 하지 않을 수도 있음
224
- salesStatus: stock.stock === 0 ? tl_lincoln_types_1.AdjustmentSaleStatus.STOP : tl_lincoln_types_1.AdjustmentSaleStatus.START,
240
+ salesStatus: stock.stock === 0
241
+ ? tl_lincoln_types_1.AdjustmentSaleStatus.STOP
242
+ : tl_lincoln_types_1.AdjustmentSaleStatus.START,
225
243
  remainingCount: "".concat(stock.stock),
226
244
  requestId: _this.generateEightByteId(),
227
245
  }); });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vendit-dev/thirdparty-adapters",
3
- "version": "0.7.19",
3
+ "version": "0.7.20",
4
4
  "description": "Third party adapters between v-cloud and other PMS/CMS providers.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {