turf-common 1.2.1-beta.7 → 1.2.1-beta.71
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/build/@enum.d.ts +2 -0
- package/build/@enum.js +2 -0
- package/build/@model.d.ts +1 -0
- package/build/@model.js +1 -0
- package/build/@type.d.ts +2 -0
- package/build/@type.js +2 -0
- package/build/@utils.d.ts +1 -0
- package/build/@utils.js +1 -0
- package/build/enums/availability-view.enum.d.ts +4 -0
- package/build/enums/availability-view.enum.js +8 -0
- package/build/enums/booking-history-operation-type.enum.d.ts +4 -2
- package/build/enums/booking-history-operation-type.enum.js +4 -2
- package/build/enums/environment.enum.d.ts +5 -0
- package/build/enums/environment.enum.js +9 -0
- package/build/enums/valid-coupon-type.enum.d.ts +3 -1
- package/build/enums/valid-coupon-type.enum.js +2 -0
- package/build/interface/api/create-recurring-slot-booking.interface.d.ts +4 -1
- package/build/interface/api/get-availability-by-turf.interface.d.ts +29 -0
- package/build/interface/api/get-availability-by-turf.interface.js +2 -0
- package/build/interface/api/get-tournament.interface.d.ts +4 -0
- package/build/interface/api/get-tournament.interface.js +2 -0
- package/build/interface/api/index.d.ts +2 -0
- package/build/interface/api/index.js +2 -0
- package/build/interface/api/list-of-coupons.interface.d.ts +6 -0
- package/build/interface/convert-to-midnight-time.interface.d.ts +5 -0
- package/build/interface/convert-to-midnight-time.interface.js +2 -0
- package/build/interface/entity/booking-details-entity.interface.d.ts +2 -0
- package/build/interface/entity/booking-history-entity.interface.d.ts +4 -0
- package/build/interface/get-booking-by-id.interface.d.ts +2 -3
- package/build/interface/model/charge-model.interface.d.ts +1 -0
- package/build/interface/ng-date-structure.interface.d.ts +5 -0
- package/build/interface/ng-date-structure.interface.js +2 -0
- package/build/models/booking-code-model.d.ts +28 -1
- package/build/models/booking-code-model.js +66 -3
- package/build/models/charge-model.d.ts +3 -3
- package/build/models/charge-model.js +74 -28
- package/build/models/entity/booking-details-model.d.ts +2 -0
- package/build/models/entity/subscription-model.js +3 -3
- package/build/models/turf-availability-model.d.ts +57 -0
- package/build/models/turf-availability-model.js +239 -0
- package/build/utils/constant.d.ts +2 -0
- package/build/utils/constant.js +3 -1
- package/build/utils/date-util.d.ts +32 -0
- package/build/utils/date-util.js +76 -1
- package/build/utils/string-utils.d.ts +12 -0
- package/build/utils/string-utils.js +53 -0
- package/package.json +1 -1
- package/build/utils/format-string-with-hyphens.d.ts +0 -1
- package/build/utils/format-string-with-hyphens.js +0 -7
package/build/utils/date-util.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.dateUtilService = exports.DateUtilService = void 0;
|
|
4
4
|
var date_fns_1 = require("date-fns");
|
|
5
|
+
var _model_1 = require("../@model");
|
|
5
6
|
var DateUtilService = /** @class */ (function () {
|
|
6
7
|
function DateUtilService() {
|
|
7
8
|
this.getDateFromDatabaseDate = function (date) { return (0, date_fns_1.parseISO)(date); };
|
|
@@ -10,6 +11,13 @@ var DateUtilService = /** @class */ (function () {
|
|
|
10
11
|
var dayDifference = Math.ceil((date2.getTime() - date1.getTime()) / oneDay);
|
|
11
12
|
return dayDifference - 1; //minus 1 day
|
|
12
13
|
};
|
|
14
|
+
this.convertMonthsToNumber = function (months) {
|
|
15
|
+
var year = months.year.toString().slice(2, 4);
|
|
16
|
+
var month = months.month.toString().padStart(2, "0");
|
|
17
|
+
var day = months.day.toString().padStart(2, "0");
|
|
18
|
+
var dates = year.concat(month).concat(day);
|
|
19
|
+
return "".concat(dates);
|
|
20
|
+
};
|
|
13
21
|
}
|
|
14
22
|
DateUtilService.prototype.getTodayCode = function () {
|
|
15
23
|
return (0, date_fns_1.format)(new Date(), "yyMMdd");
|
|
@@ -24,7 +32,10 @@ var DateUtilService = /** @class */ (function () {
|
|
|
24
32
|
return (0, date_fns_1.add)(date, { days: n });
|
|
25
33
|
};
|
|
26
34
|
DateUtilService.prototype.convertStringToDate = function (dateString, format) {
|
|
27
|
-
|
|
35
|
+
var parsedDate = (0, date_fns_1.parse)(dateString, format, new Date());
|
|
36
|
+
// IST has a fixed offset of UTC+5:30
|
|
37
|
+
var indianDate = new Date(parsedDate.getTime() + 330 * 60 * 1000);
|
|
38
|
+
return indianDate;
|
|
28
39
|
};
|
|
29
40
|
DateUtilService.prototype.isInPast = function (date) {
|
|
30
41
|
return date < new Date();
|
|
@@ -63,6 +74,70 @@ var DateUtilService = /** @class */ (function () {
|
|
|
63
74
|
futureDate.setDate(today.getDate() + n);
|
|
64
75
|
return futureDate;
|
|
65
76
|
};
|
|
77
|
+
DateUtilService.prototype.calculateDateDifference = function (fromDateCode, toDateCode, unit) {
|
|
78
|
+
if (unit === void 0) { unit = "minute"; }
|
|
79
|
+
if (toDateCode.slice(-4, -2) === "24") {
|
|
80
|
+
toDateCode =
|
|
81
|
+
exports.dateUtilService.addNDaysToDateCode(toDateCode.slice(0, -4), 1) +
|
|
82
|
+
"00" +
|
|
83
|
+
toDateCode.slice(-2);
|
|
84
|
+
}
|
|
85
|
+
var fromDate = (0, date_fns_1.parse)(fromDateCode, "yyMMddHHmm", new Date());
|
|
86
|
+
var toDate = (0, date_fns_1.parse)(toDateCode, "yyMMddHHmm", new Date());
|
|
87
|
+
var minutesDifference = (0, date_fns_1.differenceInMinutes)(toDate, fromDate);
|
|
88
|
+
return unit === "minute"
|
|
89
|
+
? minutesDifference
|
|
90
|
+
: parseFloat((minutesDifference / 60).toFixed(1));
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Adds or subtracts a specified number of months from a given date in YYMM format.
|
|
94
|
+
*
|
|
95
|
+
* @param {string} dateCode - A string representing a date in YYMM format.
|
|
96
|
+
* @param {number} N - An integer representing the number of months to add or subtract.
|
|
97
|
+
* Use a positive value to add months and a negative value to subtract months.
|
|
98
|
+
* @returns {string} A string representing the resulting date in YYMM format.
|
|
99
|
+
*/
|
|
100
|
+
DateUtilService.prototype.addNMonth = function (dateCode, N) {
|
|
101
|
+
var date = (0, date_fns_1.parse)("20".concat(dateCode), "yyyyMM", new Date());
|
|
102
|
+
var resultDate = N >= 0 ? (0, date_fns_1.addMonths)(date, N) : (0, date_fns_1.subMonths)(date, Math.abs(N));
|
|
103
|
+
return (0, date_fns_1.format)(resultDate, "yyMM");
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Gets an array of month codes between two specified dates (inclusive).
|
|
107
|
+
* Each month code is represented as a number in the format "yyMM," where "yy" is the two-digit year and "MM" is the two-digit month.
|
|
108
|
+
*
|
|
109
|
+
* @param {string} startDateCode - The starting date code in "yyMMdd" format.
|
|
110
|
+
* @param {string} endDateCode - The ending date code in "yyMMdd" format.
|
|
111
|
+
* @returns {number[]} An array of month codes representing each month between the start and end dates (inclusive).
|
|
112
|
+
* Each element in the array is a number in the "yyMM" format.
|
|
113
|
+
*/
|
|
114
|
+
DateUtilService.prototype.getMonthRangeByDateCodes = function (startDateCode, endDateCode) {
|
|
115
|
+
var startDate = exports.dateUtilService.convertStringToDate(startDateCode, "yyMMdd");
|
|
116
|
+
var endDate = exports.dateUtilService.convertStringToDate(endDateCode, "yyMMdd");
|
|
117
|
+
return _model_1.BookingCode.getMonthCodesRange(startDate, endDate);
|
|
118
|
+
};
|
|
119
|
+
DateUtilService.prototype.convertToMidnight = function (time) {
|
|
120
|
+
if (time.hour === 0 && time.minute === 0)
|
|
121
|
+
return { hour: 24, minute: 0 };
|
|
122
|
+
return time;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Retrieves booking date codes for a specified date range and weekdays.
|
|
126
|
+
*
|
|
127
|
+
* @param startDateCode - The starting date code for the date range.
|
|
128
|
+
* @param endDateCode - The ending date code for the date range.
|
|
129
|
+
* @param weekdays - An array of numbers representing weekdays (1 for Monday through 7 for Sunday).
|
|
130
|
+
* @returns An array of booking date codes based on the provided date range and weekdays.
|
|
131
|
+
*/
|
|
132
|
+
DateUtilService.prototype.getBookingCodeByWeekDaysAndDateRange = function (startDateCode, endDateCode, weekdays) {
|
|
133
|
+
var bookingDateCodes = [];
|
|
134
|
+
weekdays.forEach(function (weekDay) {
|
|
135
|
+
var startDateCodeCopy = Number(startDateCode);
|
|
136
|
+
var endDateCodeCopy = Number(endDateCode);
|
|
137
|
+
bookingDateCodes.push.apply(bookingDateCodes, _model_1.BookingCode.getDateCodesByWeek(startDateCodeCopy, endDateCodeCopy, weekDay));
|
|
138
|
+
});
|
|
139
|
+
return bookingDateCodes.map(Number).sort().map(String);
|
|
140
|
+
};
|
|
66
141
|
return DateUtilService;
|
|
67
142
|
}());
|
|
68
143
|
exports.DateUtilService = DateUtilService;
|
|
@@ -14,6 +14,18 @@ declare class StringUtil {
|
|
|
14
14
|
* @returns {string} - The formatted string with hyphens.
|
|
15
15
|
*/
|
|
16
16
|
formatStringWithHyphens(inputString: string): string;
|
|
17
|
+
generateRandomPassword(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Extracts details from a coupon code.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} couponCode - The coupon code to analyze.
|
|
22
|
+
* @returns {Object} - Object with 'code' (alphabetic part) and 'value' (numeric part) properties.
|
|
23
|
+
* @throws {TypeError} - If the provided 'couponCode' is not a string.
|
|
24
|
+
*/
|
|
25
|
+
getCouponDetails(couponCode: string): {
|
|
26
|
+
code: string;
|
|
27
|
+
value: string;
|
|
28
|
+
};
|
|
17
29
|
}
|
|
18
30
|
export declare const stringUtil: StringUtil;
|
|
19
31
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.stringUtil = void 0;
|
|
4
|
+
var app_badrequest_exception_1 = require("../exceptions/app-badrequest.exception");
|
|
4
5
|
var StringUtil = /** @class */ (function () {
|
|
5
6
|
function StringUtil() {
|
|
6
7
|
}
|
|
@@ -24,6 +25,58 @@ var StringUtil = /** @class */ (function () {
|
|
|
24
25
|
// Convert the input string to lowercase and replace spaces with hyphens
|
|
25
26
|
return inputString.toLowerCase().replace(/\s+/g, "-");
|
|
26
27
|
};
|
|
28
|
+
StringUtil.prototype.generateRandomPassword = function () {
|
|
29
|
+
var _a;
|
|
30
|
+
var alphabets = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
31
|
+
var numbers = "0123456789";
|
|
32
|
+
var specialChars = "!@#$%^&*?+";
|
|
33
|
+
function getRandomCharacter(characters) {
|
|
34
|
+
return characters[Math.floor(Math.random() * characters.length)];
|
|
35
|
+
}
|
|
36
|
+
var randomAlphabet = getRandomCharacter(alphabets);
|
|
37
|
+
var randomNumber = getRandomCharacter(numbers);
|
|
38
|
+
var randomSpecialChar = getRandomCharacter(specialChars);
|
|
39
|
+
var remainingCharacters = alphabets + alphabets.toLowerCase();
|
|
40
|
+
var randomRemainingChars = Array.from({ length: 3 }, function () {
|
|
41
|
+
return getRandomCharacter(remainingCharacters);
|
|
42
|
+
}).join("");
|
|
43
|
+
var passwordArray = [
|
|
44
|
+
randomAlphabet,
|
|
45
|
+
randomNumber,
|
|
46
|
+
randomSpecialChar,
|
|
47
|
+
randomRemainingChars,
|
|
48
|
+
];
|
|
49
|
+
// Shuffle the password array
|
|
50
|
+
for (var i = passwordArray.length - 1; i > 0; i--) {
|
|
51
|
+
var j = Math.floor(Math.random() * (i + 1));
|
|
52
|
+
_a = [
|
|
53
|
+
passwordArray[j],
|
|
54
|
+
passwordArray[i],
|
|
55
|
+
], passwordArray[i] = _a[0], passwordArray[j] = _a[1];
|
|
56
|
+
}
|
|
57
|
+
return passwordArray.join("");
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Extracts details from a coupon code.
|
|
61
|
+
*
|
|
62
|
+
* @param {string} couponCode - The coupon code to analyze.
|
|
63
|
+
* @returns {Object} - Object with 'code' (alphabetic part) and 'value' (numeric part) properties.
|
|
64
|
+
* @throws {TypeError} - If the provided 'couponCode' is not a string.
|
|
65
|
+
*/
|
|
66
|
+
StringUtil.prototype.getCouponDetails = function (couponCode) {
|
|
67
|
+
var code = couponCode.match(/[a-zA-Z]+/g);
|
|
68
|
+
var value = couponCode.match(/\d+/g);
|
|
69
|
+
if (!code || !value) {
|
|
70
|
+
throw new app_badrequest_exception_1.AppBadRequestException({
|
|
71
|
+
key: "couponCode",
|
|
72
|
+
message: ["coupon with code ".concat(couponCode, " is wrong ")],
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
code: code[0],
|
|
77
|
+
value: value[0],
|
|
78
|
+
};
|
|
79
|
+
};
|
|
27
80
|
return StringUtil;
|
|
28
81
|
}());
|
|
29
82
|
exports.stringUtil = new StringUtil();
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function FormatStringWithHyphens(inputString: string): string;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FormatStringWithHyphens = void 0;
|
|
4
|
-
function FormatStringWithHyphens(inputString) {
|
|
5
|
-
return inputString.toLowerCase().replace(/\s+/g, "-");
|
|
6
|
-
}
|
|
7
|
-
exports.FormatStringWithHyphens = FormatStringWithHyphens;
|