@vendit-dev/thirdparty-adapters 0.7.5 → 0.7.6-beta.2

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.
@@ -15,5 +15,6 @@ export declare class AmanoThirdParty implements ParkingThirdParty {
15
15
  deregisterParkingDiscount(command: DeregisterParkingDiscountCommand): Promise<boolean>;
16
16
  registerParkingPass(command: RegisterParkingPassCommand): Promise<boolean>;
17
17
  deregisterParkingPass(command: DeregisterParkingPassCommand): Promise<boolean>;
18
+ getRegisteredVehicles(criteria: any): Promise<any[]>;
18
19
  }
19
20
  export {};
@@ -20,6 +20,9 @@ var AmanoThirdParty = /** @class */ (function () {
20
20
  AmanoThirdParty.prototype.deregisterParkingPass = function (command) {
21
21
  throw new Error('Method not implemented in Amano yet.');
22
22
  };
23
+ AmanoThirdParty.prototype.getRegisteredVehicles = function (criteria) {
24
+ throw new Error('Method not implemented in Amano yet.');
25
+ };
23
26
  return AmanoThirdParty;
24
27
  }());
25
28
  exports.AmanoThirdParty = AmanoThirdParty;
@@ -1,4 +1,4 @@
1
- import { DeregisterParkingDiscountCommand, DeregisterParkingPassCommand, ParkingThirdParty, RegisterParkingDiscountCommand, RegisterParkingPassCommand, SearchVehiclesByNumberCriteria, SearchVehiclesByNumberResult } from './parkingThirdParty.type';
1
+ import { DeregisterParkingDiscountCommand, DeregisterParkingPassCommand, GetRegisteredVehiclesCriteria, ParkingThirdParty, RegisteredVehicleResult, RegisterParkingDiscountCommand, RegisterParkingPassCommand, SearchVehiclesByNumberCriteria, SearchVehiclesByNumberResult } from './parkingThirdParty.type';
2
2
  export interface NiceParkingConfig {
3
3
  dbHost: string;
4
4
  dbPort: string;
@@ -19,4 +19,5 @@ export declare class NiceParkThirdParty implements ParkingThirdParty {
19
19
  deregisterParkingDiscount(command: DeregisterParkingDiscountCommand): Promise<boolean>;
20
20
  registerParkingPass(command: RegisterParkingPassCommand): Promise<boolean>;
21
21
  deregisterParkingPass(command: DeregisterParkingPassCommand): Promise<boolean>;
22
+ getRegisteredVehicles(criteria: GetRegisteredVehiclesCriteria): Promise<RegisteredVehicleResult[]>;
22
23
  }
@@ -165,6 +165,37 @@ var NiceParkThirdParty = /** @class */ (function () {
165
165
  NiceParkThirdParty.prototype.deregisterParkingPass = function (command) {
166
166
  throw new Error('Method not implemented in NicePark yet.');
167
167
  };
168
+ NiceParkThirdParty.prototype.getRegisteredVehicles = function (criteria) {
169
+ return __awaiter(this, void 0, void 0, function () {
170
+ var startDate, endDate, startDateString, endDateString, result, refinedResult, err_4;
171
+ return __generator(this, function (_a) {
172
+ switch (_a.label) {
173
+ case 0:
174
+ startDate = criteria.startDate, endDate = criteria.endDate;
175
+ startDateString = (0, moment_1.default)(startDate).format('YYYYMMDD');
176
+ endDateString = (0, moment_1.default)(endDate).format('YYYYMMDD');
177
+ _a.label = 1;
178
+ case 1:
179
+ _a.trys.push([1, 3, , 4]);
180
+ return [4 /*yield*/, this.sequelize.query("select regularTkCarNo as vehicleNumber, regularTkStartDt as startDate, regularTkEndDt as endDate from View_RegRegularList_CODEIN where rgTkGrpCd = '".concat(this.configuration.groupCode, "' and regularTkStartDt >= '").concat(startDateString, "' and regularTkEndDt <= '").concat(endDateString, "' ").concat(criteria.vehicleNumber ? "and regularTkCarNo like '%".concat(criteria.vehicleNumber, "%'") : ''))];
181
+ case 2:
182
+ result = _a.sent();
183
+ refinedResult = result[0].map(function (item) { return ({
184
+ vehicleNumber: item.vehicleNumber,
185
+ startDate: new Date(item.startDate),
186
+ endDate: new Date(item.endDate),
187
+ }); });
188
+ console.log('NiceParkThirdParty#getRegisteredVehicles result: ', refinedResult);
189
+ return [2 /*return*/, refinedResult];
190
+ case 3:
191
+ err_4 = _a.sent();
192
+ console.error('NiceParkThirdParty#getRegisteredVehicles failed error: ', err_4);
193
+ return [3 /*break*/, 4];
194
+ case 4: return [2 /*return*/, []];
195
+ }
196
+ });
197
+ });
198
+ };
168
199
  return NiceParkThirdParty;
169
200
  }());
170
201
  exports.NiceParkThirdParty = NiceParkThirdParty;
@@ -27,10 +27,21 @@ export interface SearchVehiclesByNumberResult {
27
27
  vehicleNumber: string;
28
28
  enteredAt?: Date;
29
29
  }
30
+ export interface RegisteredVehicleResult {
31
+ vehicleNumber: string;
32
+ startDate: Date;
33
+ endDate: Date;
34
+ }
35
+ export interface GetRegisteredVehiclesCriteria {
36
+ startDate: Date;
37
+ endDate: Date;
38
+ vehicleNumber?: string;
39
+ }
30
40
  export declare abstract class ParkingThirdParty {
31
41
  abstract searchVehiclesByNumber(criteria: SearchVehiclesByNumberCriteria): Promise<SearchVehiclesByNumberResult[]>;
32
42
  abstract registerParkingDiscount(command: RegisterParkingDiscountCommand): Promise<boolean>;
33
43
  abstract deregisterParkingDiscount(command: DeregisterParkingDiscountCommand): Promise<boolean>;
34
44
  abstract registerParkingPass(command: RegisterParkingPassCommand): Promise<boolean>;
35
45
  abstract deregisterParkingPass(command: DeregisterParkingPassCommand): Promise<boolean>;
46
+ abstract getRegisteredVehicles(criteria: GetRegisteredVehiclesCriteria): Promise<RegisteredVehicleResult[]>;
36
47
  }
@@ -9,4 +9,5 @@ export default class ParkingThirdPartyCaller implements BaseParkingThirdPartyCal
9
9
  deregisterParkingDiscount(command: DeregisterParkingDiscountCommand): Promise<boolean>;
10
10
  registerParkingPass(command: RegisterParkingPassCommand): Promise<boolean>;
11
11
  deregisterParkingPass(command: DeregisterParkingPassCommand): Promise<boolean>;
12
+ getRegisteredVehicles(criteria: any): Promise<any[]>;
12
13
  }
@@ -143,6 +143,26 @@ var ParkingThirdPartyCaller = /** @class */ (function () {
143
143
  });
144
144
  });
145
145
  };
146
+ ParkingThirdPartyCaller.prototype.getRegisteredVehicles = function (criteria) {
147
+ return __awaiter(this, void 0, void 0, function () {
148
+ var result, err_6;
149
+ return __generator(this, function (_a) {
150
+ switch (_a.label) {
151
+ case 0:
152
+ _a.trys.push([0, 2, , 3]);
153
+ return [4 /*yield*/, this.parkingThirdParty.getRegisteredVehicles(criteria)];
154
+ case 1:
155
+ result = _a.sent();
156
+ return [2 /*return*/, result];
157
+ case 2:
158
+ err_6 = _a.sent();
159
+ console.error("getRegisteredVehicles failed: ".concat(err_6));
160
+ return [2 /*return*/, []];
161
+ case 3: return [2 /*return*/];
162
+ }
163
+ });
164
+ });
165
+ };
146
166
  return ParkingThirdPartyCaller;
147
167
  }());
148
168
  exports.default = ParkingThirdPartyCaller;
@@ -73,21 +73,26 @@ export default class SmartAccessAdapter {
73
73
  lockList: SmartAccessRoomKey[];
74
74
  }>;
75
75
  getRoomsWithDevices: (accommodationId: string) => Promise<SmartAccessRoom[]>;
76
- createPinCodeForRoom: ({ roomId, accommodationId, userType, keyType, startDate, endDate, }: {
76
+ createPinCodeForRoom: ({ roomId, accommodationId, userType, keyType, startDate, endDate, pinCode, }: {
77
77
  roomId: string;
78
78
  accommodationId: string;
79
79
  userType: 'GUEST' | 'EMPLOYEE';
80
80
  keyType: 'SCHEDULE' | 'ONETIME';
81
81
  startDate: Date;
82
82
  endDate: Date;
83
+ /**
84
+ * @description 4~12자리 출입 비밀번호, 미입력 시 시스템에서 6자리 랜덤 키 발급(권장)
85
+ */
86
+ pinCode?: string | null | undefined;
83
87
  }) => Promise<any>;
84
- modifyPinCodeByKeyId: ({ keyId, accommodationId, userType, keyType, startDate, endDate, }: {
88
+ modifyPinCodeByKeyId: ({ keyId, accommodationId, userType, keyType, startDate, endDate, pinCode, }: {
85
89
  keyId: string;
86
90
  accommodationId: string;
87
91
  userType: 'GUEST' | 'EMPLOYEE';
88
92
  keyType: 'SCHEDULE' | 'ONETIME';
89
93
  startDate: Date;
90
94
  endDate: Date;
95
+ pinCode?: string | undefined;
91
96
  }) => Promise<any>;
92
97
  deletePinCodeByKeyId: ({ keyId, accommodationId, }: {
93
98
  keyId: string;
@@ -293,12 +293,12 @@ var SmartAccessAdapter = /** @class */ (function () {
293
293
  });
294
294
  }); };
295
295
  this.createPinCodeForRoom = function (_a) {
296
- var roomId = _a.roomId, accommodationId = _a.accommodationId, userType = _a.userType, keyType = _a.keyType, startDate = _a.startDate, endDate = _a.endDate;
296
+ var roomId = _a.roomId, accommodationId = _a.accommodationId, userType = _a.userType, keyType = _a.keyType, startDate = _a.startDate, endDate = _a.endDate, _b = _a.pinCode, pinCode = _b === void 0 ? null : _b;
297
297
  return __awaiter(_this, void 0, void 0, function () {
298
298
  var foundProperty, data, parsedProperty, parsedData, pinCodeResult, keyId, pinCodeQuery, lockInfo;
299
- var _b;
300
- return __generator(this, function (_c) {
301
- switch (_c.label) {
299
+ var _c;
300
+ return __generator(this, function (_d) {
301
+ switch (_d.label) {
302
302
  case 0: return [4 /*yield*/, this.authenticator.getThirdPartyPropertyByRelatedId({
303
303
  accommodationId: accommodationId,
304
304
  provider: this.PROVIDER_KEY,
@@ -306,7 +306,7 @@ var SmartAccessAdapter = /** @class */ (function () {
306
306
  type: 'room',
307
307
  })];
308
308
  case 1:
309
- foundProperty = _c.sent();
309
+ foundProperty = _d.sent();
310
310
  if (!(foundProperty === null || foundProperty === void 0 ? void 0 : foundProperty.result)) return [3 /*break*/, 4];
311
311
  data = foundProperty.data;
312
312
  parsedProperty = JSON.parse(data);
@@ -317,7 +317,7 @@ var SmartAccessAdapter = /** @class */ (function () {
317
317
  params: {
318
318
  userType: userType,
319
319
  keyType: keyType,
320
- pinCode: null,
320
+ pinCode: pinCode,
321
321
  roomId: parsedProperty.thirdPartyId,
322
322
  accessStartDate: (0, moment_1.default)(startDate)
323
323
  .add(9, 'hours')
@@ -326,7 +326,7 @@ var SmartAccessAdapter = /** @class */ (function () {
326
326
  },
327
327
  })];
328
328
  case 2:
329
- pinCodeResult = _c.sent();
329
+ pinCodeResult = _d.sent();
330
330
  keyId = pinCodeResult.keyId;
331
331
  return [4 /*yield*/, this.callSmartAccessApi({
332
332
  accommodationId: accommodationId,
@@ -334,43 +334,44 @@ var SmartAccessAdapter = /** @class */ (function () {
334
334
  route: "v1/key/".concat(keyId, "/pincode"),
335
335
  })];
336
336
  case 3:
337
- pinCodeQuery = _c.sent();
338
- lockInfo = ((_b = pinCodeQuery === null || pinCodeQuery === void 0 ? void 0 : pinCodeQuery.lockList) === null || _b === void 0 ? void 0 : _b[0]) || {};
337
+ pinCodeQuery = _d.sent();
338
+ lockInfo = ((_c = pinCodeQuery === null || pinCodeQuery === void 0 ? void 0 : pinCodeQuery.lockList) === null || _c === void 0 ? void 0 : _c[0]) || {};
339
339
  return [2 /*return*/, __assign(__assign({}, lockInfo), { pinCode: (lockInfo === null || lockInfo === void 0 ? void 0 : lockInfo.pinCode) || (parsedData === null || parsedData === void 0 ? void 0 : parsedData.masterPinCode), keyId: keyId, pinCodeResult: pinCodeResult })];
340
- case 4: return [2 /*return*/];
340
+ case 4: return [2 /*return*/, {
341
+ error: 'THIRDPARTY_PROPERTY_NOT_FOUND',
342
+ }];
341
343
  }
342
344
  });
343
345
  });
344
346
  };
345
347
  this.modifyPinCodeByKeyId = function (_a) {
346
- var keyId = _a.keyId, accommodationId = _a.accommodationId, userType = _a.userType, keyType = _a.keyType, startDate = _a.startDate, endDate = _a.endDate;
348
+ var keyId = _a.keyId, accommodationId = _a.accommodationId, userType = _a.userType, keyType = _a.keyType, startDate = _a.startDate, endDate = _a.endDate, pinCode = _a.pinCode;
347
349
  return __awaiter(_this, void 0, void 0, function () {
348
- var pinCodeResult, pinCodeQuery;
349
- return __generator(this, function (_b) {
350
- switch (_b.label) {
350
+ var pinCodeResult, newKeyId, pinCodeQuery;
351
+ var _b;
352
+ return __generator(this, function (_c) {
353
+ switch (_c.label) {
351
354
  case 0: return [4 /*yield*/, this.callSmartAccessApi({
352
355
  accommodationId: accommodationId,
353
356
  method: 'put',
354
357
  route: "v1/key/".concat(keyId, "/pincode"),
355
- params: {
356
- userType: userType,
357
- keyType: keyType,
358
- accessStartDate: (0, moment_1.default)(startDate)
358
+ params: __assign({ userType: userType, keyType: keyType, accessStartDate: (0, moment_1.default)(startDate)
359
359
  .add(9, 'hours')
360
- .format('YYYYMMDDHHmm'),
361
- accessEndDate: (0, moment_1.default)(endDate).add(9, 'hours').format('YYYYMMDDHHmm'),
362
- },
360
+ .format('YYYYMMDDHHmm'), accessEndDate: (0, moment_1.default)(endDate).add(9, 'hours').format('YYYYMMDDHHmm') }, (pinCode && {
361
+ pinCode: pinCode,
362
+ })),
363
363
  })];
364
364
  case 1:
365
- pinCodeResult = _b.sent();
365
+ pinCodeResult = _c.sent();
366
+ newKeyId = pinCodeResult.keyId;
366
367
  return [4 /*yield*/, this.callSmartAccessApi({
367
368
  accommodationId: accommodationId,
368
369
  method: 'get',
369
- route: "v1/key/".concat(keyId, "/pincode"),
370
+ route: "v1/key/".concat(newKeyId || keyId, "/pincode"),
370
371
  })];
371
372
  case 2:
372
- pinCodeQuery = _b.sent();
373
- return [2 /*return*/, __assign(__assign({}, pinCodeQuery.lockList[0]), { keyId: keyId })];
373
+ pinCodeQuery = _c.sent();
374
+ return [2 /*return*/, __assign(__assign({}, (_b = pinCodeQuery.lockList) === null || _b === void 0 ? void 0 : _b[0]), { keyId: newKeyId })];
374
375
  }
375
376
  });
376
377
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vendit-dev/thirdparty-adapters",
3
- "version": "0.7.5",
3
+ "version": "0.7.6-beta.2",
4
4
  "description": "Third party adapters between v-cloud and other PMS/CMS providers.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -1 +0,0 @@
1
- export declare function findMinimumNumbersForSum(target: number, numbers: number[]): number[];
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findMinimumNumbersForSum = void 0;
4
- function findMinimumNumbersForSum(target, numbers) {
5
- // Sort the numbers array in descending order.
6
- numbers.sort(function (a, b) { return b - a; });
7
- var sum = 0;
8
- var result = [];
9
- for (var _i = 0, numbers_1 = numbers; _i < numbers_1.length; _i++) {
10
- var number = numbers_1[_i];
11
- while (sum + number <= target) {
12
- sum += number;
13
- result.push(number);
14
- }
15
- // Early exit if the target is reached or exceeded.
16
- if (sum >= target) {
17
- break;
18
- }
19
- }
20
- // If the sum is not reached, no solution exists with the given numbers.
21
- if (sum < target) {
22
- return [];
23
- }
24
- return result;
25
- }
26
- exports.findMinimumNumbersForSum = findMinimumNumbersForSum;