@nanas-home/hub-common 0.41.937 → 0.42.947

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.
@@ -692,6 +692,55 @@ var arrayContains = (arr, items, method = "AND") => {
692
692
  }
693
693
  return true;
694
694
  };
695
+
696
+ // src/services/internal/config/commonConfigService.ts
697
+ var CommonConfigService = class {
698
+ _internalIsProd;
699
+ getHubApiUrl = () => this.get("VITE_HUB_API_URL");
700
+ getHubLandingUrl = () => this.get("VITE_HUB_LANDING_URL");
701
+ getHubClientUrl = () => this.get("VITE_HUB_CLIENT_URL");
702
+ getHubAdminUrl = () => this.get("VITE_HUB_ADMIN_URL");
703
+ getHubCoverageUrl = () => this.get("VITE_HUB_COVERAGE_URL");
704
+ getHubDocsUrl = () => this.get("VITE_HUB_DOCS_URL");
705
+ getHubStorybookUrl = () => this.get("VITE_HUB_STORYBOOK_URL");
706
+ getFakeApiRequestDelay = () => this.getNumber("VITE_FAKE_API_REQUEST_DELAY");
707
+ // HCaptcha
708
+ getCaptchaEnabled = () => this.getBool("VITE_ENABLE_CAPTCHA");
709
+ getHCaptchaSecret = () => this.get("HCAPTCHA_SECRET");
710
+ getHCaptchaSiteKey = () => this.get("VITE_HCAPTCHA_SITE_KEY");
711
+ // Tolgee
712
+ getTolgeeApiKey = () => this.get("VITE_TOLGEE_API_KEY");
713
+ getTolgeeApiUrl = () => this.get("VITE_TOLGEE_API_URL");
714
+ getTolgeeProjectId = () => this.getNumber("VITE_TOLGEE_PROJECT_ID");
715
+ /* Special case, available on UI & API */
716
+ isProd = () => {
717
+ if (this._internalIsProd == null) {
718
+ this._internalIsProd = this.get("NODE_ENV").toLocaleLowerCase() === "production" || this.get("MODE").toLocaleLowerCase() === "production";
719
+ }
720
+ return this._internalIsProd;
721
+ };
722
+ packageVersion = () => this.getWithFallback("npm_package_version", "PACKAGE_VERSION");
723
+ getConsoleLogLevels = () => {
724
+ const envVar = this.get("VITE_CONSOLE_LOGGING");
725
+ if (envVar?.length < 1) return ["trace", "log", "info", "debug", "warn", "error"];
726
+ return envVar.split(",").map((l) => l);
727
+ };
728
+ get(property, defaultValue) {
729
+ let value = void 0;
730
+ value = import.meta.env?.[property];
731
+ if (defaultValue != null) {
732
+ return value ?? defaultValue;
733
+ }
734
+ return value ?? "";
735
+ }
736
+ getWithFallback = (property, fallbackProperty, defaultValue) => {
737
+ const orig = this.get(property);
738
+ if (orig != null) return orig;
739
+ return this.get(fallbackProperty, defaultValue);
740
+ };
741
+ getBool = (property, defaultValue) => this.get(property, defaultValue).toLowerCase() == "true";
742
+ getNumber = (property, defaultValue) => Number(this.get(property, defaultValue?.toString?.()));
743
+ };
695
744
  var formatDate = (date, format = "DD MMM YYYY HH:mm") => {
696
745
  const dateStr = dayjs(date).format(format);
697
746
  if (dateStr.includes("Invalid")) return "";
@@ -743,55 +792,6 @@ var showSecondCalendar = (startDateStr, endDateStr) => {
743
792
  return true;
744
793
  };
745
794
 
746
- // src/services/internal/config/commonConfigService.ts
747
- var CommonConfigService = class {
748
- _internalIsProd;
749
- getHubApiUrl = () => this.get("VITE_HUB_API_URL");
750
- getHubLandingUrl = () => this.get("VITE_HUB_LANDING_URL");
751
- getHubClientUrl = () => this.get("VITE_HUB_CLIENT_URL");
752
- getHubAdminUrl = () => this.get("VITE_HUB_ADMIN_URL");
753
- getHubCoverageUrl = () => this.get("VITE_HUB_COVERAGE_URL");
754
- getHubDocsUrl = () => this.get("VITE_HUB_DOCS_URL");
755
- getHubStorybookUrl = () => this.get("VITE_HUB_STORYBOOK_URL");
756
- getFakeApiRequestDelay = () => this.getNumber("VITE_FAKE_API_REQUEST_DELAY");
757
- // HCaptcha
758
- getCaptchaEnabled = () => this.getBool("VITE_ENABLE_CAPTCHA");
759
- getHCaptchaSecret = () => this.get("HCAPTCHA_SECRET");
760
- getHCaptchaSiteKey = () => this.get("VITE_HCAPTCHA_SITE_KEY");
761
- // Tolgee
762
- getTolgeeApiKey = () => this.get("VITE_TOLGEE_API_KEY");
763
- getTolgeeApiUrl = () => this.get("VITE_TOLGEE_API_URL");
764
- getTolgeeProjectId = () => this.getNumber("VITE_TOLGEE_PROJECT_ID");
765
- /* Special case, available on UI & API */
766
- isProd = () => {
767
- if (this._internalIsProd == null) {
768
- this._internalIsProd = this.get("NODE_ENV").toLocaleLowerCase() === "production" || this.get("MODE").toLocaleLowerCase() === "production";
769
- }
770
- return this._internalIsProd;
771
- };
772
- packageVersion = () => this.getWithFallback("npm_package_version", "PACKAGE_VERSION");
773
- getConsoleLogLevels = () => {
774
- const envVar = this.get("VITE_CONSOLE_LOGGING");
775
- if (envVar?.length < 1) return ["trace", "log", "info", "debug", "warn", "error"];
776
- return envVar.split(",").map((l) => l);
777
- };
778
- get(property, defaultValue) {
779
- let value = void 0;
780
- value = import.meta.env?.[property];
781
- if (defaultValue != null) {
782
- return value ?? defaultValue;
783
- }
784
- return value ?? "";
785
- }
786
- getWithFallback = (property, fallbackProperty, defaultValue) => {
787
- const orig = this.get(property);
788
- if (orig != null) return orig;
789
- return this.get(fallbackProperty, defaultValue);
790
- };
791
- getBool = (property, defaultValue) => this.get(property, defaultValue).toLowerCase() == "true";
792
- getNumber = (property, defaultValue) => Number(this.get(property, defaultValue?.toString?.()));
793
- };
794
-
795
795
  // src/services/internal/log/logService.ts
796
796
  var LogService = class {
797
797
  constructor(config, _logToConsole = true, _onLogMessage, _numDaysToKeep = 100) {
@@ -1369,6 +1369,24 @@ var urlRef = (url) => {
1369
1369
  return url + `?ref=${ref}`;
1370
1370
  };
1371
1371
 
1372
+ // src/helpers/userMembershipHelper.ts
1373
+ var getActiveUserMembership = (userMemberships) => {
1374
+ const now = /* @__PURE__ */ new Date();
1375
+ return userMemberships.find((m) => {
1376
+ if (isBefore(now, m.startDate)) return false;
1377
+ if (m.endDate != null) {
1378
+ if (isBefore(m.endDate, now)) return false;
1379
+ }
1380
+ const badStatuses = [
1381
+ 0 /* Unknown */,
1382
+ 20 /* Cancelled */,
1383
+ 23 /* PastDue */,
1384
+ 12 /* Unpaid */
1385
+ ];
1386
+ return badStatuses.includes(m.status) == false;
1387
+ });
1388
+ };
1389
+
1372
1390
  // src/services/internal/config/colour.config.ts
1373
1391
  var colourPalette = {
1374
1392
  nanasBackyard: "#97A571",
@@ -1387,6 +1405,24 @@ var defaultSiteColour = {
1387
1405
  primary: "#97A571",
1388
1406
  secondary: "#97A571"
1389
1407
  };
1408
+
1409
+ // src/services/internal/debug/debugService.ts
1410
+ var DebugService = class {
1411
+ _setDebug(e) {
1412
+ if (e.code == "ControlLeft") {
1413
+ document.body.classList.add("debug");
1414
+ }
1415
+ }
1416
+ _removeDebug(e) {
1417
+ if (e.code == "ControlLeft") {
1418
+ document.body.classList.remove("debug");
1419
+ }
1420
+ }
1421
+ setupGlobalDebugKey = () => {
1422
+ document.addEventListener("keydown", this._setDebug);
1423
+ document.addEventListener("keyup", this._removeDebug);
1424
+ };
1425
+ };
1390
1426
  var TranslationService = class {
1391
1427
  constructor(log, _config) {
1392
1428
  this._config = _config;
@@ -1639,4 +1675,4 @@ var shouldBeYoutubeUrl = (value) => {
1639
1675
  };
1640
1676
  };
1641
1677
 
1642
- export { APP_TYPE_TOKEN, ActivityRestriction, ActivityType, AddressLinkType, AddressRestriction, AnswerLinkType, AnswerRestriction, AppType, BOT_PATH_TOKEN, BookingAddonRestriction, BookingAddonType, BookingRestriction, BookingStatusType, CommentLinkType, CommentRestriction, CommonConfigService, DependencyInjectionContainer, DrivingRouteRestriction, InvoiceRestriction, InvoiceStatusType, LogService, MembershipBillingCycleType, MembershipRestriction, MembershipStatus, MembershipType, MouseButton, NetworkState, OrderDirectionType, PermissionRestriction, PermissionType, PetRestriction, PetSexType, PetStatusType, PetType, QuestionForType, QuestionRestriction, QuestionType, SITE_CONFIG_TOKEN, SearchableColumnType, StripeRestriction, TranslationService, UnavailabilityRestriction, UploadLinkType, UploadRestriction, UploadType, UserAccountFlagType, UserRestriction, UserType, addDays, addMinutes, addMonths, addSeconds, addSpacesForEnum, addToParallelTasks, anyObject, apiRoute, apiRouteParam, arrayContains, arrayOfNLength, capitalizeFirstLetter, changeMonth, colourPalette, convertToDate, convertToFullDateSelection, createToken, cyrb53, dateDiffInDays, debounceLeading, defaultSiteColour, fakePromise, formatDate, formatFileSize, formatForBookingDate, formatForDateDropdown, formatForDateLocal, formatForDateLocalDetailed, formatForDateOfBirth, formatForDateWithTime, getAgeInYears, getAllPetQuestionForType, getAppType, getArrFromEnum, getBotPath, getCalendarDropdownDisplayValue, getCalendarDropdownForDateOfBirthDisplayValue, getCommonConfig, getDayClassObject, getDayElements, getDayHeadingElements, getImageParams, getLog, getMimeTypeFromExtension, getPayloadFromJwt, getPerformanceTimer, getPetAvatarUrl, getSiteColour, getSiteConfig, getUserAvatarUrl, getUsersName, getWeekNumber, hasRequiredPermissions, 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, portalGlyphLength, promiseFromValue, randomIntFromRange, randomItemFromArray, rootContainer, rootDependencyInjectionSetup, searchColumns, selectedItemsExist, selectedOptionIsInEnum, separateValidation, setContainerToken, setContainerTokenLazy, setSiteConfig, shouldBeUrl, shouldBeYoutubeUrl, showSecondCalendar, socialLinks, timeout, tryParseNumber, uploadsThatNeedEncryption, urlRef, uuidv4, validUuidChars, validateForEach, webAppTypes, weekdayTranslationKeyOrder };
1678
+ export { APP_TYPE_TOKEN, ActivityRestriction, ActivityType, AddressLinkType, AddressRestriction, AnswerLinkType, AnswerRestriction, AppType, BOT_PATH_TOKEN, BookingAddonRestriction, BookingAddonType, BookingRestriction, BookingStatusType, CommentLinkType, CommentRestriction, CommonConfigService, DebugService, DependencyInjectionContainer, DrivingRouteRestriction, InvoiceRestriction, InvoiceStatusType, LogService, MembershipBillingCycleType, MembershipRestriction, MembershipStatus, MembershipType, MouseButton, NetworkState, OrderDirectionType, PermissionRestriction, PermissionType, PetRestriction, PetSexType, PetStatusType, PetType, QuestionForType, QuestionRestriction, QuestionType, SITE_CONFIG_TOKEN, SearchableColumnType, StripeRestriction, TranslationService, UnavailabilityRestriction, UploadLinkType, UploadRestriction, UploadType, UserAccountFlagType, UserRestriction, UserType, addDays, addMinutes, addMonths, addSeconds, addSpacesForEnum, addToParallelTasks, anyObject, apiRoute, apiRouteParam, arrayContains, arrayOfNLength, capitalizeFirstLetter, changeMonth, colourPalette, convertToDate, convertToFullDateSelection, createToken, cyrb53, dateDiffInDays, debounceLeading, defaultSiteColour, fakePromise, formatDate, formatFileSize, formatForBookingDate, formatForDateDropdown, formatForDateLocal, formatForDateLocalDetailed, formatForDateOfBirth, formatForDateWithTime, getActiveUserMembership, getAgeInYears, getAllPetQuestionForType, getAppType, getArrFromEnum, getBotPath, getCalendarDropdownDisplayValue, getCalendarDropdownForDateOfBirthDisplayValue, getCommonConfig, getDayClassObject, getDayElements, getDayHeadingElements, getImageParams, getLog, getMimeTypeFromExtension, getPayloadFromJwt, getPerformanceTimer, getPetAvatarUrl, getSiteColour, getSiteConfig, getUserAvatarUrl, getUsersName, getWeekNumber, hasRequiredPermissions, 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, portalGlyphLength, promiseFromValue, randomIntFromRange, randomItemFromArray, rootContainer, rootDependencyInjectionSetup, searchColumns, selectedItemsExist, selectedOptionIsInEnum, separateValidation, setContainerToken, setContainerTokenLazy, setSiteConfig, shouldBeUrl, shouldBeYoutubeUrl, showSecondCalendar, socialLinks, timeout, tryParseNumber, uploadsThatNeedEncryption, urlRef, uuidv4, validUuidChars, validateForEach, webAppTypes, weekdayTranslationKeyOrder };
@@ -0,0 +1,7 @@
1
+ import requireDebugMarker from './rules/require-debug-marker.js';
2
+
3
+ export default {
4
+ rules: {
5
+ 'require-debug-marker': requireDebugMarker,
6
+ },
7
+ };
@@ -0,0 +1,37 @@
1
+ export default {
2
+ meta: {
3
+ type: 'problem',
4
+ docs: {
5
+ description: 'Require at least one data-debug attribute or <DebugNode> component in TSX files',
6
+ },
7
+ schema: [],
8
+ },
9
+
10
+ create(context) {
11
+ const filename = context.filename;
12
+ if (filename.endsWith('.ts')) return {};
13
+ if (filename.endsWith('.meta.tsx')) return {};
14
+
15
+ let found = false;
16
+
17
+ return {
18
+ JSXAttribute(node) {
19
+ if (node.name?.name === 'data-debug') found = true;
20
+ if (node.name?.name === 'debug') found = true;
21
+ },
22
+ JSXOpeningElement(node) {
23
+ if (node.name?.type === 'JSXIdentifier' && node.name.name === 'DebugNode') {
24
+ found = true;
25
+ }
26
+ },
27
+ 'Program:exit'() {
28
+ if (!found) {
29
+ context.report({
30
+ loc: { line: 1, column: 0 },
31
+ message: 'TSX file must contain at least one `data-debug` attribute or `<DebugNode>` component.',
32
+ });
33
+ }
34
+ },
35
+ };
36
+ },
37
+ };