@nanas-home/hub-common 0.41.937 → 0.43.982

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.
@@ -143,6 +143,9 @@ var apiRoute = {
143
143
  booking: {
144
144
  prefix: "/admin/booking",
145
145
  byUser: "/user",
146
+ withRelationships: `/with-relationships/${apiRouteParam.bookingUuid}`,
147
+ assignHost: `/assign-host/${apiRouteParam.bookingUuid}/${apiRouteParam.userUuid}`,
148
+ removeHost: `/remove-host/${apiRouteParam.bookingUuid}`,
146
149
  swagger: { name: "Bookings", description: "Endpoints for managing bookings" }
147
150
  },
148
151
  invoice: {
@@ -667,7 +670,7 @@ var searchColumns = {
667
670
  address: [{ "property": "name", "type": 2 }, { "property": "street", "type": 2 }, { "property": "city", "type": 2 }, { "property": "postalCode", "type": 2 }, { "property": "country", "type": 2 }],
668
671
  pet: [{ "property": "type", "type": 1 }, { "property": "sex", "type": 2 }, { "property": "breed", "type": 2 }, { "property": "neutered", "type": 2 }, { "property": "name", "type": 2 }, { "property": "notes", "type": 2 }, { "property": "dateOfBirth", "type": 5 }],
669
672
  invoice: [{ "property": "userUuid", "type": 2 }, { "property": "bookingUuid", "type": 2 }, { "property": "bookingAddonUuid", "type": 2 }, { "property": "status", "type": 2 }, { "property": "stripeInvoiceId", "type": 2 }, { "property": "dueDate", "type": 5 }, { "property": "notes", "type": 2 }],
670
- userMembership: [{ "property": "status", "type": 1 }, { "property": "startDate", "type": 5 }, { "property": "endDate", "type": 5 }],
673
+ userMembership: [{ "property": "status", "type": 1, "subType": "MembershipStatus" }, { "property": "billingCycle", "type": 1, "subType": "MembershipBillingCycleType" }, { "property": "stripeSubscriptionId", "type": 2 }, { "property": "startDate", "type": 5 }, { "property": "endDate", "type": 5 }],
671
674
  user: [{ "property": "types", "type": 1 }, { "property": "firstName", "type": 2 }, { "property": "lastName", "type": 2 }, { "property": "email", "type": 2 }, { "property": "hubspotId", "type": 2 }, { "property": "flags", "type": 1 }, { "property": "dateCreated", "type": 5 }],
672
675
  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 }],
673
676
  booking: [{ "property": "startDate", "type": 5 }, { "property": "endDate", "type": 5 }, { "property": "status", "type": 2 }, { "property": "notes", "type": 2 }],
@@ -692,6 +695,55 @@ var arrayContains = (arr, items, method = "AND") => {
692
695
  }
693
696
  return true;
694
697
  };
698
+
699
+ // src/services/internal/config/commonConfigService.ts
700
+ var CommonConfigService = class {
701
+ _internalIsProd;
702
+ getHubApiUrl = () => this.get("VITE_HUB_API_URL");
703
+ getHubLandingUrl = () => this.get("VITE_HUB_LANDING_URL");
704
+ getHubClientUrl = () => this.get("VITE_HUB_CLIENT_URL");
705
+ getHubAdminUrl = () => this.get("VITE_HUB_ADMIN_URL");
706
+ getHubCoverageUrl = () => this.get("VITE_HUB_COVERAGE_URL");
707
+ getHubDocsUrl = () => this.get("VITE_HUB_DOCS_URL");
708
+ getHubStorybookUrl = () => this.get("VITE_HUB_STORYBOOK_URL");
709
+ getFakeApiRequestDelay = () => this.getNumber("VITE_FAKE_API_REQUEST_DELAY");
710
+ // HCaptcha
711
+ getCaptchaEnabled = () => this.getBool("VITE_ENABLE_CAPTCHA");
712
+ getHCaptchaSecret = () => this.get("HCAPTCHA_SECRET");
713
+ getHCaptchaSiteKey = () => this.get("VITE_HCAPTCHA_SITE_KEY");
714
+ // Tolgee
715
+ getTolgeeApiKey = () => this.get("VITE_TOLGEE_API_KEY");
716
+ getTolgeeApiUrl = () => this.get("VITE_TOLGEE_API_URL");
717
+ getTolgeeProjectId = () => this.getNumber("VITE_TOLGEE_PROJECT_ID");
718
+ /* Special case, available on UI & API */
719
+ isProd = () => {
720
+ if (this._internalIsProd == null) {
721
+ this._internalIsProd = this.get("NODE_ENV").toLocaleLowerCase() === "production" || this.get("MODE").toLocaleLowerCase() === "production";
722
+ }
723
+ return this._internalIsProd;
724
+ };
725
+ packageVersion = () => this.getWithFallback("npm_package_version", "PACKAGE_VERSION");
726
+ getConsoleLogLevels = () => {
727
+ const envVar = this.get("VITE_CONSOLE_LOGGING");
728
+ if (envVar?.length < 1) return ["trace", "log", "info", "debug", "warn", "error"];
729
+ return envVar.split(",").map((l) => l);
730
+ };
731
+ get(property, defaultValue) {
732
+ let value = void 0;
733
+ value = import.meta.env?.[property];
734
+ if (defaultValue != null) {
735
+ return value ?? defaultValue;
736
+ }
737
+ return value ?? "";
738
+ }
739
+ getWithFallback = (property, fallbackProperty, defaultValue) => {
740
+ const orig = this.get(property);
741
+ if (orig != null) return orig;
742
+ return this.get(fallbackProperty, defaultValue);
743
+ };
744
+ getBool = (property, defaultValue) => this.get(property, defaultValue).toLowerCase() == "true";
745
+ getNumber = (property, defaultValue) => Number(this.get(property, defaultValue?.toString?.()));
746
+ };
695
747
  var formatDate = (date, format = "DD MMM YYYY HH:mm") => {
696
748
  const dateStr = dayjs(date).format(format);
697
749
  if (dateStr.includes("Invalid")) return "";
@@ -743,55 +795,6 @@ var showSecondCalendar = (startDateStr, endDateStr) => {
743
795
  return true;
744
796
  };
745
797
 
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
798
  // src/services/internal/log/logService.ts
796
799
  var LogService = class {
797
800
  constructor(config, _logToConsole = true, _onLogMessage, _numDaysToKeep = 100) {
@@ -1273,10 +1276,10 @@ var tryParseNumber = (input, opts) => {
1273
1276
  };
1274
1277
 
1275
1278
  // src/helpers/performanceHelper.ts
1276
- var getPerformanceTimer = () => ({
1277
- start: performance.now(),
1278
- getTimeElapsed: (start) => performance.now() - start
1279
- });
1279
+ var getPerformanceTimer = () => {
1280
+ const start = performance.now();
1281
+ return () => performance.now() - start;
1282
+ };
1280
1283
 
1281
1284
  // src/helpers/permissionHelper.ts
1282
1285
  var hasRequiredPermissions = (props) => {
@@ -1369,6 +1372,24 @@ var urlRef = (url) => {
1369
1372
  return url + `?ref=${ref}`;
1370
1373
  };
1371
1374
 
1375
+ // src/helpers/userMembershipHelper.ts
1376
+ var getActiveUserMembership = (userMemberships) => {
1377
+ const now = /* @__PURE__ */ new Date();
1378
+ return userMemberships.find((m) => {
1379
+ if (isBefore(now, m.startDate)) return false;
1380
+ if (m.endDate != null) {
1381
+ if (isBefore(m.endDate, now)) return false;
1382
+ }
1383
+ const badStatuses = [
1384
+ 0 /* Unknown */,
1385
+ 20 /* Cancelled */,
1386
+ 23 /* PastDue */,
1387
+ 12 /* Unpaid */
1388
+ ];
1389
+ return badStatuses.includes(m.status) == false;
1390
+ });
1391
+ };
1392
+
1372
1393
  // src/services/internal/config/colour.config.ts
1373
1394
  var colourPalette = {
1374
1395
  nanasBackyard: "#97A571",
@@ -1387,6 +1408,24 @@ var defaultSiteColour = {
1387
1408
  primary: "#97A571",
1388
1409
  secondary: "#97A571"
1389
1410
  };
1411
+
1412
+ // src/services/internal/debug/debugService.ts
1413
+ var DebugService = class {
1414
+ _setDebug(e) {
1415
+ if (e.code == "ControlLeft") {
1416
+ document.body.classList.add("debug");
1417
+ }
1418
+ }
1419
+ _removeDebug(e) {
1420
+ if (e.code == "ControlLeft") {
1421
+ document.body.classList.remove("debug");
1422
+ }
1423
+ }
1424
+ setupGlobalDebugKey = () => {
1425
+ document.addEventListener("keydown", this._setDebug);
1426
+ document.addEventListener("keyup", this._removeDebug);
1427
+ };
1428
+ };
1390
1429
  var TranslationService = class {
1391
1430
  constructor(log, _config) {
1392
1431
  this._config = _config;
@@ -1639,4 +1678,4 @@ var shouldBeYoutubeUrl = (value) => {
1639
1678
  };
1640
1679
  };
1641
1680
 
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 };
1681
+ 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
+ };