@nanas-home/hub-common 0.60.1336 → 0.61.1366
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/chunk/{KEYIZIIS.js → L6A6KIRK.js} +156 -5
- package/dist/index.css +1 -1
- package/dist/node-utils/index.d.ts +2 -9
- package/dist/node-utils/index.js +3 -47
- package/dist/{textValidation-YmUdzikm.d.ts → textValidation-CDAetMyD.d.ts} +255 -32
- package/dist/web/index.d.ts +15 -5
- package/dist/web/index.js +110 -41
- package/dist/web/index.jsx +345 -122
- package/package.json +14 -15
|
@@ -364,6 +364,7 @@ var apiRoute = {
|
|
|
364
364
|
create: "",
|
|
365
365
|
update: "",
|
|
366
366
|
delete: `/${apiRouteParam.bookingUuid}`,
|
|
367
|
+
pricePrediction: "/price",
|
|
367
368
|
swagger: { name: "Bookings", description: "Endpoints for User to manage their Bookings" }
|
|
368
369
|
},
|
|
369
370
|
bookingAddon: {
|
|
@@ -450,6 +451,7 @@ var ActivityType = /* @__PURE__ */ ((ActivityType2) => {
|
|
|
450
451
|
ActivityType2[ActivityType2["Read"] = 2] = "Read";
|
|
451
452
|
ActivityType2[ActivityType2["Update"] = 3] = "Update";
|
|
452
453
|
ActivityType2[ActivityType2["Delete"] = 4] = "Delete";
|
|
454
|
+
ActivityType2[ActivityType2["System"] = 5] = "System";
|
|
453
455
|
return ActivityType2;
|
|
454
456
|
})(ActivityType || {});
|
|
455
457
|
|
|
@@ -903,6 +905,15 @@ var UuidRestriction = {
|
|
|
903
905
|
minLength: 36,
|
|
904
906
|
maxLength: 36
|
|
905
907
|
};
|
|
908
|
+
var CaptchaTokenRestriction = {
|
|
909
|
+
minLength: 10,
|
|
910
|
+
maxLength: 2048
|
|
911
|
+
};
|
|
912
|
+
var DateObjectRestriction = {
|
|
913
|
+
day: { min: 0, max: 31 },
|
|
914
|
+
month: { min: 0, max: 12 },
|
|
915
|
+
year: { min: 2e3, max: 2050 }
|
|
916
|
+
};
|
|
906
917
|
|
|
907
918
|
// src/contracts/generated/restrictions/drivingRouteRestriction.ts
|
|
908
919
|
var DrivingRouteRestriction = {
|
|
@@ -1007,9 +1018,21 @@ var searchColumns = {
|
|
|
1007
1018
|
upload: [{ "property": "linkUuid", "type": 2 }, { "property": "linkType", "type": 2 }, { "property": "type", "type": 2 }, { "property": "fileName", "type": 2 }, { "property": "blobType", "type": 2 }, { "property": "sizeInKb", "type": 2 }, { "property": "dateCreated", "type": 5 }],
|
|
1008
1019
|
booking: [{ "property": "code", "type": 3 }, { "property": "startDate", "type": 5 }, { "property": "endDate", "type": 5 }, { "property": "status", "type": 1 }, { "property": "dateCreated", "type": 5 }, { "property": "notes", "type": 2 }],
|
|
1009
1020
|
bugReport: [{ "property": "status", "type": 0 }, { "property": "comment", "type": 2 }, { "property": "metadata", "type": 2 }, { "property": "logs", "type": 2 }, { "property": "dateCreated", "type": 5 }],
|
|
1010
|
-
question: [{ "property": "forTypes", "type": 1 }, { "property": "transKey", "type": 2 }, { "property": "fallback", "type": 2 }, { "property": "category", "type": 2 }, { "property": "type", "type": 0 }, { "property": "sortOrder", "type": 3 }, { "property": "visible", "type": 4 }, { "property": "notes", "type": 2 }]
|
|
1021
|
+
question: [{ "property": "forTypes", "type": 1 }, { "property": "transKey", "type": 2 }, { "property": "fallback", "type": 2 }, { "property": "category", "type": 2 }, { "property": "type", "type": 0 }, { "property": "sortOrder", "type": 3 }, { "property": "visible", "type": 4 }, { "property": "notes", "type": 2 }],
|
|
1022
|
+
tempLink: [{ "property": "linkType", "type": 1 }, { "property": "dateCreated", "type": 5 }, { "property": "dateModified", "type": 5 }]
|
|
1011
1023
|
};
|
|
1012
1024
|
|
|
1025
|
+
// src/contracts/register.ts
|
|
1026
|
+
var ClientRegisterStep = /* @__PURE__ */ ((ClientRegisterStep2) => {
|
|
1027
|
+
ClientRegisterStep2[ClientRegisterStep2["User"] = 0] = "User";
|
|
1028
|
+
ClientRegisterStep2[ClientRegisterStep2["Address"] = 1] = "Address";
|
|
1029
|
+
ClientRegisterStep2[ClientRegisterStep2["Pets"] = 2] = "Pets";
|
|
1030
|
+
ClientRegisterStep2[ClientRegisterStep2["Questions"] = 3] = "Questions";
|
|
1031
|
+
ClientRegisterStep2[ClientRegisterStep2["TermsConditions"] = 4] = "TermsConditions";
|
|
1032
|
+
ClientRegisterStep2[ClientRegisterStep2["Finish"] = 5] = "Finish";
|
|
1033
|
+
return ClientRegisterStep2;
|
|
1034
|
+
})(ClientRegisterStep || {});
|
|
1035
|
+
|
|
1013
1036
|
// src/helpers/arrayHelper.ts
|
|
1014
1037
|
var makeArrayOrDefault = (propsVal, defaultValue = []) => {
|
|
1015
1038
|
if (propsVal == null) return defaultValue;
|
|
@@ -1043,10 +1066,10 @@ var CommonConfigService = class {
|
|
|
1043
1066
|
getHubDocsUrl = () => this.get("VITE_HUB_DOCS_URL");
|
|
1044
1067
|
getHubStorybookUrl = () => this.get("VITE_HUB_STORYBOOK_URL");
|
|
1045
1068
|
getFakeApiRequestDelay = () => this.getNumber("VITE_FAKE_API_REQUEST_DELAY");
|
|
1046
|
-
//
|
|
1069
|
+
// Captcha
|
|
1047
1070
|
getCaptchaEnabled = () => this.getBool("VITE_ENABLE_CAPTCHA");
|
|
1048
|
-
|
|
1049
|
-
|
|
1071
|
+
getCaptchaSecret = () => this.get("CAPTCHA_SECRET");
|
|
1072
|
+
getCaptchaSiteKey = () => this.get("VITE_CAPTCHA_SITE_KEY");
|
|
1050
1073
|
// Tolgee
|
|
1051
1074
|
getTolgeeApiKey = () => this.get("VITE_TOLGEE_API_KEY");
|
|
1052
1075
|
getTolgeeApiUrl = () => this.get("VITE_TOLGEE_API_URL");
|
|
@@ -1599,6 +1622,61 @@ var getUsersName = (details) => {
|
|
|
1599
1622
|
return names.filter((n) => n != null).join(" ");
|
|
1600
1623
|
};
|
|
1601
1624
|
|
|
1625
|
+
// src/helpers/dateDtoHelper.ts
|
|
1626
|
+
var numberOfDaysPerMonth = {
|
|
1627
|
+
defaultYear: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
|
|
1628
|
+
leapYear: [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
|
|
1629
|
+
};
|
|
1630
|
+
var dateDtoToDateColumn = (dateObj) => `${dateObj.year}-${dateObj.month.toString().padStart(2, "0")}-${dateObj.day.toString().padStart(2, "0")}`;
|
|
1631
|
+
var dateColumnToDateDto = (dateStr) => {
|
|
1632
|
+
const segments = dateStr.split("-");
|
|
1633
|
+
if (segments.length != 3) return { day: 1, month: 1, year: 2e3 };
|
|
1634
|
+
const year = Number(segments[0]);
|
|
1635
|
+
const month = Math.min(12, Number(segments[1]));
|
|
1636
|
+
const daysInMonthItem = getNumberOfDaysInAMonth(year, month);
|
|
1637
|
+
const day = Math.min(daysInMonthItem, Number(segments[2]));
|
|
1638
|
+
return { year, month, day };
|
|
1639
|
+
};
|
|
1640
|
+
var dateToDateDto = (date) => ({
|
|
1641
|
+
year: date.getFullYear(),
|
|
1642
|
+
month: date.getMonth() + 1,
|
|
1643
|
+
day: date.getDate()
|
|
1644
|
+
});
|
|
1645
|
+
var isLeapYear = (year) => year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
1646
|
+
var getNumberOfDaysInAMonth = (year, month) => {
|
|
1647
|
+
const daysInMonth = isLeapYear(year) ? numberOfDaysPerMonth.leapYear : numberOfDaysPerMonth.defaultYear;
|
|
1648
|
+
const daysInMonthItem = daysInMonth[month - 1];
|
|
1649
|
+
if (daysInMonthItem == null) {
|
|
1650
|
+
throw "Invalid date";
|
|
1651
|
+
}
|
|
1652
|
+
return daysInMonthItem;
|
|
1653
|
+
};
|
|
1654
|
+
var getNextDayOfDateDto = (d) => {
|
|
1655
|
+
let { day, month, year } = d;
|
|
1656
|
+
const daysInMonthItem = getNumberOfDaysInAMonth(year, month);
|
|
1657
|
+
day++;
|
|
1658
|
+
if (day > daysInMonthItem) {
|
|
1659
|
+
day = 1;
|
|
1660
|
+
month++;
|
|
1661
|
+
if (month > 12) {
|
|
1662
|
+
month = 1;
|
|
1663
|
+
year++;
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
return { day, month, year };
|
|
1667
|
+
};
|
|
1668
|
+
var dateDtoCompare = (a, b) => {
|
|
1669
|
+
if (a.year !== b.year) return a.year - b.year;
|
|
1670
|
+
if (a.month !== b.month) return a.month - b.month;
|
|
1671
|
+
return a.day - b.day;
|
|
1672
|
+
};
|
|
1673
|
+
var dateDtoIsBefore = (a, b) => {
|
|
1674
|
+
const compareResult = dateDtoCompare(a, b);
|
|
1675
|
+
if (compareResult == 0) return false;
|
|
1676
|
+
if (compareResult > 0) return false;
|
|
1677
|
+
return true;
|
|
1678
|
+
};
|
|
1679
|
+
|
|
1602
1680
|
// src/helpers/debounceHelper.ts
|
|
1603
1681
|
function debounceLeading(fn, ms) {
|
|
1604
1682
|
let timer;
|
|
@@ -1865,6 +1943,51 @@ var getActiveUserMembership = (userMemberships) => {
|
|
|
1865
1943
|
});
|
|
1866
1944
|
};
|
|
1867
1945
|
|
|
1946
|
+
// src/services/external/captcha/captchaNodeService.ts
|
|
1947
|
+
var CaptchaNodeService = class {
|
|
1948
|
+
constructor(log, _config) {
|
|
1949
|
+
this._config = _config;
|
|
1950
|
+
this._logger = log.getLogger("CaptchaNodeService");
|
|
1951
|
+
}
|
|
1952
|
+
_logger;
|
|
1953
|
+
async verifyToken(token, options) {
|
|
1954
|
+
const appType = getAppType();
|
|
1955
|
+
if (isWebApp(appType)) {
|
|
1956
|
+
const message = `verifyToken is not supported on this app type (${appType})`;
|
|
1957
|
+
this._logger.e(message);
|
|
1958
|
+
return { isSuccess: false, errorMessage: message };
|
|
1959
|
+
}
|
|
1960
|
+
let formData = new FormData();
|
|
1961
|
+
formData.append("response", token);
|
|
1962
|
+
formData.append("secret", this._config.getCaptchaSecret());
|
|
1963
|
+
if (options?.idempotencyKey != null) formData.append("idempotency_key", options.idempotencyKey);
|
|
1964
|
+
this._logger.i("verify captcha token");
|
|
1965
|
+
try {
|
|
1966
|
+
const apiResult = await fetch("https://challenges.cloudflare.com/turnstile/v0/siteverify", {
|
|
1967
|
+
method: "POST",
|
|
1968
|
+
body: formData
|
|
1969
|
+
});
|
|
1970
|
+
const response = await apiResult.json();
|
|
1971
|
+
if (response == null || response.success === false) {
|
|
1972
|
+
return {
|
|
1973
|
+
isSuccess: false,
|
|
1974
|
+
errorMessage: "Failed to verify captcha token"
|
|
1975
|
+
};
|
|
1976
|
+
}
|
|
1977
|
+
return {
|
|
1978
|
+
isSuccess: true
|
|
1979
|
+
};
|
|
1980
|
+
} catch (ex) {
|
|
1981
|
+
const errMsg = `Failed to verify captcha token: ${ex?.toString?.()}`;
|
|
1982
|
+
this._logger.e(errMsg);
|
|
1983
|
+
return {
|
|
1984
|
+
isSuccess: false,
|
|
1985
|
+
errorMessage: errMsg
|
|
1986
|
+
};
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
};
|
|
1990
|
+
|
|
1868
1991
|
// src/services/internal/config/colour.config.ts
|
|
1869
1992
|
var colourPalette = {
|
|
1870
1993
|
nanasBackyard: "#97A571",
|
|
@@ -2026,6 +2149,34 @@ var contactNumberValid = (value) => {
|
|
|
2026
2149
|
return { isValid: true };
|
|
2027
2150
|
};
|
|
2028
2151
|
|
|
2152
|
+
// src/validation/dateDtoValidation.ts
|
|
2153
|
+
var minDateDto = (minDate2) => (value) => {
|
|
2154
|
+
if (minDate2 != null && value != null) {
|
|
2155
|
+
if (dateDtoIsBefore(minDate2, value)) {
|
|
2156
|
+
return { isValid: true };
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
return {
|
|
2160
|
+
isValid: false,
|
|
2161
|
+
errorMessageTransKey: "min_date_validator",
|
|
2162
|
+
errorMessageParams: { date: dateDtoToDateColumn(minDate2) },
|
|
2163
|
+
errorMessage: "Minimum date is {date}"
|
|
2164
|
+
};
|
|
2165
|
+
};
|
|
2166
|
+
var maxDateDto = (maxDate2) => (value) => {
|
|
2167
|
+
if (maxDate2 != null && value != null) {
|
|
2168
|
+
if (dateDtoIsBefore(value, maxDate2)) {
|
|
2169
|
+
return { isValid: true };
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
return {
|
|
2173
|
+
isValid: false,
|
|
2174
|
+
errorMessageTransKey: "max_date_validator",
|
|
2175
|
+
errorMessageParams: { date: dateDtoToDateColumn(maxDate2) },
|
|
2176
|
+
errorMessage: "Maximum date is {date}"
|
|
2177
|
+
};
|
|
2178
|
+
};
|
|
2179
|
+
|
|
2029
2180
|
// src/validation/dateValidation.ts
|
|
2030
2181
|
var minDate = (minDate2) => (value) => {
|
|
2031
2182
|
if (isBefore(minDate2, value)) {
|
|
@@ -2205,4 +2356,4 @@ var shouldBeYoutubeUrl = (value) => {
|
|
|
2205
2356
|
};
|
|
2206
2357
|
};
|
|
2207
2358
|
|
|
2208
|
-
export { APP_TYPE_TOKEN, ActivityRestriction, ActivityType, AddressLinkType, AddressRestriction, AnswerLinkType, AnswerRestriction, AppType, AuthRegisterRestriction, BOOKING_OVERVIEW_STATUSES, BOT_PATH_TOKEN, BookingAddonRestriction, BookingAddonType, BookingRestriction, BookingStatusType, BugReportRestriction, BugReportStatusType, CdnAppImage, CommentLinkType, CommentRestriction, CommonConfigService, DependencyInjectionContainer, DrivingRouteRestriction, InvoiceRestriction, InvoiceStatusType, LogService, MembershipBillingCycleType, MembershipRestriction, MembershipStatus, MembershipType, MouseButton, NANAS_PALLETTE, NetworkState, OrderDirectionType, PermissionRestriction, PermissionType, PetRestriction, PetSexType, PetStatusType, PetType, QuestionForType, QuestionRestriction, QuestionType, SITE_CONFIG_TOKEN, SearchableColumnType, SentEmailLinkType, SentEmailRestriction, SentEmailSentStatus, StripeRestriction, SupportedLanguageArray, TempLinkType, TempRegistrationStatus, UnavailabilityRestriction, UploadLinkType, UploadRestriction, UploadType, UserAccountFlagType, UserRestriction, UserType, UuidRestriction, activityShortCode, addDays, addMinutes, addMonths, addSeconds, addSpacesForEnum, addToParallelTasks, allowedNonNumericalValuesInContactNumber, anyObject, apiRoute, apiRouteParam, arrayContains, arrayOfNLength, capitalizeFirstLetter, changeMonth, colourPalette, commonEmailLinks, computeBookingNightCount, computeBookingStatusCounts, contactNumberCharValid, contactNumberValid, convertToDate, convertToFullDateSelection, createToken, cyrb53, dateDiffInDays, debounceLeading, defaultSiteColour, emailValid, fakePromise, filterBookingsByOverviewStatus, formatBookingCalendarLabel, formatBookingNightsTooltip, formatDate, formatFileSize, formatForBookingDate, formatForDateDropdown, formatForDateLocal, formatForDateLocalDetailed, formatForDateOfBirth, formatForDateWithTime, formatPetTypesLabel, getActiveUserMembership, getAgeInYears, getAllPetQuestionForType, getAppType, getArrFromEnum, getBookingStatusLabelForAdmin, getBotPath, getCalendarDropdownDisplayValue, getCalendarDropdownForDateOfBirthDisplayValue, getCommonConfig, getDayClassObject, getDayElements, getDayHeadingElements, getImageParams, getLog, getMembershipTypeLabel, getMimeTypeFromExtension, getPayloadFromJwt, getPerformanceTimer, getPetAvatarUrl, getPetTypeLabel, getQuestionGroups, getSiteColour, getSiteConfig, getUserAvatarUrl, getUsersName, getWeekNumber, hasRequiredPermissions, hubspotQuestionsExport, isBefore, isDateAfterStart, isDateBeforeEnd, isDateDisabledByDisabledDays, isDateEnabledByEnabledDays, isNumber, isSameDay, isWebApp, lowercaseFirstLetter, makeArrayOrDefault, maxDate, maxItems, maxLength, maxValue, mimeTypeLookup, minDate, minItems, minLength, minUrlLength, minValue, monthTranslationKeyOrder, multiValidation, nameof, nanasFonts, noValidation, notNull, onlyUnique, parseBookingOverviewStatuses, passwordValid, portalGlyphLength, postCodeValid, promiseFromValue, randomIntFromRange, randomItemFromArray, rootContainer, rootDependencyInjectionSetup, searchColumns, selectedItemsExist, selectedOptionIsInEnum, separateValidation, serializeBookingOverviewStatuses, setContainerToken, setContainerTokenLazy, setSiteConfig, shouldBeUrl, shouldBeYoutubeUrl, showSecondCalendar, socialLinks, timeout, tryParseNumber, uploadsThatNeedEncryption, urlAddQueryParam, urlRef, userMustChangePassword, uuidv4, validUuidChars, validateForEach, webAppTypes, weekdayTranslationKeyOrder };
|
|
2359
|
+
export { APP_TYPE_TOKEN, ActivityRestriction, ActivityType, AddressLinkType, AddressRestriction, AnswerLinkType, AnswerRestriction, AppType, AuthRegisterRestriction, BOOKING_OVERVIEW_STATUSES, BOT_PATH_TOKEN, BookingAddonRestriction, BookingAddonType, BookingRestriction, BookingStatusType, BugReportRestriction, BugReportStatusType, CaptchaNodeService, CaptchaTokenRestriction, CdnAppImage, ClientRegisterStep, CommentLinkType, CommentRestriction, CommonConfigService, DateObjectRestriction, DependencyInjectionContainer, DrivingRouteRestriction, InvoiceRestriction, InvoiceStatusType, LogService, MembershipBillingCycleType, MembershipRestriction, MembershipStatus, MembershipType, MouseButton, NANAS_PALLETTE, NetworkState, OrderDirectionType, PermissionRestriction, PermissionType, PetRestriction, PetSexType, PetStatusType, PetType, QuestionForType, QuestionRestriction, QuestionType, SITE_CONFIG_TOKEN, SearchableColumnType, SentEmailLinkType, SentEmailRestriction, SentEmailSentStatus, StripeRestriction, SupportedLanguageArray, TempLinkType, TempRegistrationStatus, UnavailabilityRestriction, UploadLinkType, UploadRestriction, UploadType, UserAccountFlagType, UserRestriction, UserType, UuidRestriction, activityShortCode, addDays, addMinutes, addMonths, addSeconds, addSpacesForEnum, addToParallelTasks, allowedNonNumericalValuesInContactNumber, anyObject, apiRoute, apiRouteParam, arrayContains, arrayOfNLength, capitalizeFirstLetter, changeMonth, colourPalette, commonEmailLinks, computeBookingNightCount, computeBookingStatusCounts, contactNumberCharValid, contactNumberValid, convertToDate, convertToFullDateSelection, createToken, cyrb53, dateColumnToDateDto, dateDiffInDays, dateDtoCompare, dateDtoIsBefore, dateDtoToDateColumn, dateToDateDto, debounceLeading, defaultSiteColour, emailValid, fakePromise, filterBookingsByOverviewStatus, formatBookingCalendarLabel, formatBookingNightsTooltip, formatDate, formatFileSize, formatForBookingDate, formatForDateDropdown, formatForDateLocal, formatForDateLocalDetailed, formatForDateOfBirth, formatForDateWithTime, formatPetTypesLabel, getActiveUserMembership, getAgeInYears, getAllPetQuestionForType, getAppType, getArrFromEnum, getBookingStatusLabelForAdmin, getBotPath, getCalendarDropdownDisplayValue, getCalendarDropdownForDateOfBirthDisplayValue, getCommonConfig, getDayClassObject, getDayElements, getDayHeadingElements, getImageParams, getLog, getMembershipTypeLabel, getMimeTypeFromExtension, getNextDayOfDateDto, getNumberOfDaysInAMonth, getPayloadFromJwt, getPerformanceTimer, getPetAvatarUrl, getPetTypeLabel, getQuestionGroups, getSiteColour, getSiteConfig, getUserAvatarUrl, getUsersName, getWeekNumber, hasRequiredPermissions, hubspotQuestionsExport, isBefore, isDateAfterStart, isDateBeforeEnd, isDateDisabledByDisabledDays, isDateEnabledByEnabledDays, isLeapYear, isNumber, isSameDay, isWebApp, lowercaseFirstLetter, makeArrayOrDefault, maxDate, maxDateDto, maxItems, maxLength, maxValue, mimeTypeLookup, minDate, minDateDto, minItems, minLength, minUrlLength, minValue, monthTranslationKeyOrder, multiValidation, nameof, nanasFonts, noValidation, notNull, numberOfDaysPerMonth, onlyUnique, parseBookingOverviewStatuses, passwordValid, portalGlyphLength, postCodeValid, promiseFromValue, randomIntFromRange, randomItemFromArray, rootContainer, rootDependencyInjectionSetup, searchColumns, selectedItemsExist, selectedOptionIsInEnum, separateValidation, serializeBookingOverviewStatuses, setContainerToken, setContainerTokenLazy, setSiteConfig, shouldBeUrl, shouldBeYoutubeUrl, showSecondCalendar, socialLinks, timeout, tryParseNumber, uploadsThatNeedEncryption, urlAddQueryParam, urlRef, userMustChangePassword, uuidv4, validUuidChars, validateForEach, webAppTypes, weekdayTranslationKeyOrder };
|