@nanas-home/hub-common 0.3.214 → 0.3.222

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.
@@ -1190,6 +1190,163 @@ var stopPropagation = (event) => {
1190
1190
  return event;
1191
1191
  };
1192
1192
 
1193
+ // src/assets/meta.json
1194
+ var meta_default = {
1195
+ packageVersion: "0.3.0",
1196
+ date: "2025-07-08",
1197
+ gitCommitHash: "08dc089a9686047cbe11d862cb3e406eaf2eed65"
1198
+ };
1199
+
1200
+ // src/assets/packagesUsed.json
1201
+ var packagesUsed_default = {
1202
+ generatedDate: "2025-07-08T05:57:56.062Z",
1203
+ generatedDateFormat: "2025-07-08",
1204
+ list: [
1205
+ {
1206
+ name: "@chromatic-com/storybook",
1207
+ version: "4.0.1",
1208
+ licenseType: "MIT",
1209
+ repoUrl: "https://github.com/chromaui/addon-visual-tests.git",
1210
+ licenceUrl: "https://github.com/chromaui/addon-visual-tests/blob/master/LICENSE"
1211
+ },
1212
+ {
1213
+ name: "@kachurun/storybook-solid-vite",
1214
+ version: "9.0.11",
1215
+ licenseType: "MIT",
1216
+ repoUrl: "https://github.com/solidjs-community/storybook.git",
1217
+ licenceUrl: "https://github.com/solidjs-community/storybook/blob/master/LICENSE"
1218
+ },
1219
+ {
1220
+ name: "@storybook/addon-a11y",
1221
+ version: "9.0.15",
1222
+ licenseType: "MIT",
1223
+ repoUrl: "https://github.com/storybookjs/storybook.git",
1224
+ licenceUrl: "https://github.com/storybookjs/storybook/blob/master/LICENSE.md"
1225
+ },
1226
+ {
1227
+ name: "@storybook/addon-docs",
1228
+ version: "9.0.15",
1229
+ licenseType: "MIT",
1230
+ repoUrl: "https://github.com/storybookjs/storybook.git",
1231
+ licenceUrl: "https://github.com/storybookjs/storybook/blob/master/LICENSE.md"
1232
+ },
1233
+ {
1234
+ name: "@storybook/addon-links",
1235
+ version: "9.0.15",
1236
+ licenseType: "MIT",
1237
+ repoUrl: "https://github.com/storybookjs/storybook.git",
1238
+ licenceUrl: "https://github.com/storybookjs/storybook/blob/master/LICENSE.md"
1239
+ },
1240
+ {
1241
+ name: "@storybook/addon-onboarding",
1242
+ version: "9.0.15",
1243
+ licenseType: "MIT",
1244
+ repoUrl: "https://github.com/storybookjs/storybook.git",
1245
+ licenceUrl: "https://github.com/storybookjs/storybook/blob/master/LICENSE.md"
1246
+ },
1247
+ {
1248
+ name: "@storybook/addon-vitest",
1249
+ version: "9.0.15",
1250
+ licenseType: "MIT",
1251
+ repoUrl: "https://github.com/storybookjs/storybook.git",
1252
+ licenceUrl: "https://github.com/storybookjs/storybook/blob/master/LICENSE.md"
1253
+ },
1254
+ {
1255
+ name: "@types/node",
1256
+ version: "24.0.10",
1257
+ licenseType: "MIT",
1258
+ repoUrl: "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
1259
+ licenceUrl: "https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/LICENSE"
1260
+ },
1261
+ {
1262
+ name: "@vitest/browser",
1263
+ version: "3.2.4",
1264
+ licenseType: "MIT",
1265
+ repoUrl: "https://github.com/vitest-dev/vitest.git",
1266
+ licenceUrl: "https://github.com/vitest-dev/vitest/blob/master/LICENSE"
1267
+ },
1268
+ {
1269
+ name: "@vitest/coverage-v8",
1270
+ version: "3.2.4",
1271
+ licenseType: "MIT",
1272
+ repoUrl: "https://github.com/vitest-dev/vitest.git",
1273
+ licenceUrl: "https://github.com/vitest-dev/vitest/blob/master/LICENSE"
1274
+ },
1275
+ {
1276
+ name: "@vitest/ui",
1277
+ version: "3.2.4",
1278
+ licenseType: "MIT",
1279
+ repoUrl: "https://github.com/vitest-dev/vitest.git",
1280
+ licenceUrl: "https://github.com/vitest-dev/vitest/blob/master/LICENSE"
1281
+ },
1282
+ {
1283
+ name: "dotenv-cli",
1284
+ version: "8.0.0",
1285
+ licenseType: "MIT"
1286
+ },
1287
+ {
1288
+ name: "sass",
1289
+ version: "1.89.2",
1290
+ licenseType: "MIT",
1291
+ repoUrl: "https://github.com/sass/dart-sass",
1292
+ licenceUrl: "https://github.com/sass/dart-sass/blob/master/LICENSE"
1293
+ },
1294
+ {
1295
+ name: "storybook",
1296
+ version: "9.0.15",
1297
+ licenseType: "MIT",
1298
+ repoUrl: "https://github.com/storybookjs/storybook.git",
1299
+ licenceUrl: "https://github.com/storybookjs/storybook/blob/master/LICENSE.md"
1300
+ },
1301
+ {
1302
+ name: "tsup",
1303
+ version: "8.5.0",
1304
+ licenseType: "MIT",
1305
+ repoUrl: "https://github.com/egoist/tsup.git",
1306
+ licenceUrl: "https://github.com/egoist/tsup/blob/master/LICENSE"
1307
+ },
1308
+ {
1309
+ name: "tsup-preset-solid",
1310
+ version: "2.2.0",
1311
+ licenseType: "MIT",
1312
+ repoUrl: "https://github.com/solidjs-community/tsup-preset-solid.git",
1313
+ licenceUrl: "https://github.com/solidjs-community/tsup-preset-solid/blob/master/LICENSE"
1314
+ },
1315
+ {
1316
+ name: "typescript",
1317
+ version: "5.8.3",
1318
+ licenseType: "Apache-2.0",
1319
+ repoUrl: "https://github.com/microsoft/TypeScript.git",
1320
+ licenceUrl: "https://github.com/microsoft/TypeScript/blob/master/LICENSE.md"
1321
+ },
1322
+ {
1323
+ name: "vite",
1324
+ version: "7.0.2",
1325
+ licenseType: "MIT",
1326
+ repoUrl: "https://github.com/vitejs/vite.git",
1327
+ licenceUrl: "https://github.com/vitejs/vite/blob/master/LICENSE.md"
1328
+ },
1329
+ {
1330
+ name: "vite-plugin-solid",
1331
+ version: "2.11.7",
1332
+ licenseType: "MIT",
1333
+ repoUrl: "https://github.com/solidjs/vite-plugin-solid.git",
1334
+ licenceUrl: "https://github.com/solidjs/vite-plugin-solid/blob/master/LICENSE.md"
1335
+ },
1336
+ {
1337
+ name: "vitest",
1338
+ version: "3.2.4",
1339
+ licenseType: "MIT",
1340
+ repoUrl: "https://github.com/vitest-dev/vitest.git",
1341
+ licenceUrl: "https://github.com/vitest-dev/vitest/blob/master/LICENSE.md"
1342
+ }
1343
+ ]
1344
+ };
1345
+
1346
+ // src/helpers/metaHelper.ts
1347
+ var getMeta = () => meta_default;
1348
+ var getPackagesUsed = () => packagesUsed_default;
1349
+
1193
1350
  // src/helpers/randomHelper.ts
1194
1351
  var randomIntFromRange = (min, max) => {
1195
1352
  return Math.floor(Math.random() * (max - min) + min);
@@ -1235,6 +1392,24 @@ var cyrb53 = (input, seed = 0) => {
1235
1392
  var anyObject = () => ({});
1236
1393
  var fakePromise = () => new Promise((res) => res({}));
1237
1394
 
1395
+ // src/helpers/debounceHelper.ts
1396
+ var debounceLeading = (func, wait = 300, immediate) => {
1397
+ let timeout2;
1398
+ const funcToReturn = function() {
1399
+ let context = this;
1400
+ let args = arguments;
1401
+ let later = function() {
1402
+ timeout2 = null;
1403
+ if (!immediate) func.apply(context, args);
1404
+ };
1405
+ let callNow = immediate && !timeout2;
1406
+ clearTimeout(timeout2);
1407
+ timeout2 = setTimeout(later, wait);
1408
+ if (callNow) func.apply(context, args);
1409
+ };
1410
+ return funcToReturn;
1411
+ };
1412
+
1238
1413
  // src/helpers/stringHelper.ts
1239
1414
  var capitalizeAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
1240
1415
  var capitalizeFirstLetter = (orig) => {
@@ -1321,6 +1496,80 @@ var getPayloadFromJwt = (token) => {
1321
1496
  };
1322
1497
  }
1323
1498
  };
1499
+
1500
+ // src/helpers/commonHelper.ts
1501
+ var getUsersName = (details) => `${details?.firstName} ${details?.lastName}`;
1502
+ var LocalStorageService = class {
1503
+ _logger;
1504
+ constructor(log) {
1505
+ this._logger = log.getLogger("LocalStorageService");
1506
+ }
1507
+ get = (key) => {
1508
+ const dataStr = localStorage.getItem(key);
1509
+ if (dataStr == null) return null;
1510
+ try {
1511
+ const obj = JSON.parse(dataStr || "{}");
1512
+ return obj;
1513
+ } catch (err) {
1514
+ this._logger.e("get", err);
1515
+ return null;
1516
+ }
1517
+ };
1518
+ set = (key, value) => {
1519
+ try {
1520
+ const valueStr = JSON.stringify(value);
1521
+ localStorage.setItem(key, valueStr);
1522
+ } catch (err) {
1523
+ this._logger.e("set", err);
1524
+ }
1525
+ };
1526
+ removeAllTrackedKeys = (allKeys) => {
1527
+ for (const key in localStorage) {
1528
+ if (allKeys.includes(key)) {
1529
+ localStorage.removeItem(key);
1530
+ }
1531
+ }
1532
+ };
1533
+ };
1534
+ LocalStorageService = __decorateClass([
1535
+ Service({ scope: "singleton" }, [LogService])
1536
+ ], LocalStorageService);
1537
+ var getLocalStorage = () => Container.get(LocalStorageService);
1538
+ var CommonStateService = class {
1539
+ _localStorageKey = "nanas-home-common";
1540
+ _internalState = {
1541
+ language: "en",
1542
+ theme: "dark",
1543
+ isSideBarOpen: true,
1544
+ auth: void 0
1545
+ };
1546
+ constructor(local) {
1547
+ const localInitialState = local.get(this._localStorageKey);
1548
+ if (localInitialState != null) {
1549
+ this._internalState = {
1550
+ ...localInitialState
1551
+ };
1552
+ }
1553
+ }
1554
+ saveToLocalStorage = debounceLeading((newState) => {
1555
+ getLocalStorage().set(this._localStorageKey, newState);
1556
+ }, 250);
1557
+ getStateProp = (propName) => this._internalState?.[propName];
1558
+ setStateProp(prop) {
1559
+ this._internalState = {
1560
+ ...this._internalState,
1561
+ [prop.name]: prop.value
1562
+ };
1563
+ this.saveToLocalStorage(this._internalState);
1564
+ }
1565
+ getPermissions = () => this._internalState.auth?.permissions ?? [];
1566
+ getIsSidebarOpen = () => this._internalState?.isSideBarOpen ?? true;
1567
+ getTheme = () => this._internalState.theme;
1568
+ };
1569
+ CommonStateService = __decorateClass([
1570
+ Service([LocalStorageService])
1571
+ ], CommonStateService);
1572
+ var getCommonStateService = () => Container.get(CommonStateService);
1324
1573
  var DocumentService = class {
1325
1574
  constructor(_config, _siteConfig) {
1326
1575
  this._config = _config;
@@ -1572,6 +1821,83 @@ ${errorJson.message}`
1572
1821
  }
1573
1822
  }
1574
1823
  };
1824
+
1825
+ // src/services/api/baseCrudService.ts
1826
+ var BaseCrudService = class extends BaseApiService {
1827
+ constructor(_prefix, logger, config) {
1828
+ const apiUrl = config.getHubApiUrl();
1829
+ super(apiUrl, logger);
1830
+ this._prefix = _prefix;
1831
+ }
1832
+ create = (item) => this.post(this._prefix, item, addAccessTokenToHeaders);
1833
+ read = (uuid) => this.get(`${this._prefix}/${uuid}`, addAccessTokenToHeaders);
1834
+ readPage(pagination) {
1835
+ return this.get(`${this._prefix}?${getPaginationQueryParams(pagination)}`, addAccessTokenToHeaders);
1836
+ }
1837
+ search(pagination, searchObj) {
1838
+ return this.post(
1839
+ `${this._prefix}/search?${getPaginationQueryParams(pagination)}`,
1840
+ searchObj,
1841
+ addAccessTokenToHeaders
1842
+ );
1843
+ }
1844
+ update = (item) => this.put(`${this._prefix}/${item.uuid}`, item, addAccessTokenToHeaders);
1845
+ del = (item) => this.delete(`${this._prefix}/${item.uuid}`, addAccessTokenToHeaders);
1846
+ };
1847
+ var addAccessTokenToHeaders = () => {
1848
+ const authObj = getCommonStateService().getStateProp("auth");
1849
+ return { authorization: `Bearer ${authObj?.auth}` };
1850
+ };
1851
+ var formDataWithAccessTokenHeaders = () => {
1852
+ const onlyAccessToken = addAccessTokenToHeaders();
1853
+ return {
1854
+ ...onlyAccessToken,
1855
+ headers: {
1856
+ ...onlyAccessToken,
1857
+ "Content-Type": "multipart/form-data"
1858
+ }
1859
+ };
1860
+ };
1861
+ var getPaginationQueryParams = (pagination) => {
1862
+ const searchProps = [
1863
+ `page=${pagination.page}`,
1864
+ `pageSize=${pagination.pageSize}`,
1865
+ `orderColumnName=${pagination.orderColumnName ?? ""}`,
1866
+ `orderDirection=${pagination.orderDirection ?? ""}`
1867
+ ];
1868
+ return `${searchProps.join("&")}`;
1869
+ };
1870
+ var UserApiService = class extends BaseCrudService {
1871
+ constructor(log, config) {
1872
+ super(
1873
+ apiRoute.routes.user.prefix,
1874
+ //
1875
+ log.getLogger("UserApiService"),
1876
+ config
1877
+ );
1878
+ }
1879
+ };
1880
+ UserApiService = __decorateClass([
1881
+ Service([LogService, CommonConfigService])
1882
+ ], UserApiService);
1883
+ var getUserApiService = () => Container.get(UserApiService);
1884
+ var ProfileApiService = class extends BaseApiService {
1885
+ prefix = apiRoute.routes.user.prefix;
1886
+ constructor(log, config) {
1887
+ const apiUrl = config.getHubApiUrl();
1888
+ super(apiUrl, log.getLogger("ProfileApiService"));
1889
+ }
1890
+ load = () => this.get(`${this.prefix}${apiRoute.routes.user.profile.prefix}`, addAccessTokenToHeaders);
1891
+ getQuestionsAndAnswers = (payload) => async () => this.post(
1892
+ `${this.prefix}${apiRoute.routes.user.profile.answers}`,
1893
+ payload,
1894
+ addAccessTokenToHeaders
1895
+ );
1896
+ };
1897
+ ProfileApiService = __decorateClass([
1898
+ Service([LogService, CommonConfigService, CommonStateService])
1899
+ ], ProfileApiService);
1900
+ var getProfileApiService = () => Container.get(ProfileApiService);
1575
1901
  var AuthApiService = class extends BaseApiService {
1576
1902
  prefix = apiRoute.routes.auth.prefix;
1577
1903
  constructor(log, config) {
@@ -1687,4 +2013,4 @@ var validUuidChars = [
1687
2013
  "F"
1688
2014
  ];
1689
2015
 
1690
- export { APP_TYPE, ActivityRestriction, ActivityType, AddressCreateDtoMeta, AddressRestriction, AnswerRestriction, AppType, AuthApiService, AuthLoginDtoMeta, AuthSignupDtoMeta, BOT_PATH, BaseApiService, BookingAddonRestriction, BookingAddonType, BookingCreateDtoMeta, BookingRestriction, BookingStatusType, CaptchaService, CommentRestriction, CommonConfigService, DocumentService, DrivingRouteRestriction, LogService, MembershipRestriction, MembershipStatus, NetworkState, OrderDirectionType, PermissionRestriction, PermissionType, PetCreateDtoMeta, PetRestriction, PetSexType, PetStatusType, PetType, QuestionCreateDtoMeta, QuestionForType, QuestionRestriction, QuestionType, SiteConfigService, UnavailabilityRestriction, UploadCreateDtoMeta, UploadLinkType, UploadRestriction, UploadType, UserAccountFlagType, UserCreateDtoMeta, UserDtoMeta, UserRestriction, UserType, __decorateClass, addDays, addMinutes, addSeconds, addSpacesForEnum, addToParallelTasks, anyObject, apiParams, apiRoute, arrayContains, arrayOfNLength, capitalizeFirstLetter, cyrb53, dateDiffInDays, fakePromise, formatDate, formatFileSize, formatForBookingDate, formatForDateDropdown, formatForDateLocal, formatForDateLocalDetailed, formatForDateOfBirth, formatForDateWithTime, getAgeInYears, getAppType, getArrFromEnum, getAuthApiService, getBotPath, getCaptchaService, getCommonConfig, getDefaultDtoMeta, getDocumentServ, getImageParams, getLog, getMimeTypeFromExtension, getPayloadFromJwt, getPerformanceTimer, getSiteConfig, getWeekNumber, isBefore, isNumber, isSameDay, isWebApp, lowercaseFirstLetter, makeArrayOrDefault, maxDate, maxItems, maxLength, mimeTypeLookup, minDate, minItems, minLength, minUrlLength, multiValidation, nameof, noValidation, notNull, onTargetFiles, onTargetValue, onlyUnique, portalGlyphLength, preventDefault, randomIntFromRange, randomItemFromArray, selectedItemsExist, separateValidation, setContainerToken, shouldBeUrl, shouldBeYoutubeUrl, stopPropagation, timeout, uploadsThatNeedEncryption, uuidv4, validUuidChars, validateForEach, webAppTypes };
2016
+ export { APP_TYPE, ActivityRestriction, ActivityType, AddressCreateDtoMeta, AddressRestriction, AnswerRestriction, AppType, AuthApiService, AuthLoginDtoMeta, AuthSignupDtoMeta, BOT_PATH, BaseApiService, BaseCrudService, BookingAddonRestriction, BookingAddonType, BookingCreateDtoMeta, BookingRestriction, BookingStatusType, CaptchaService, CommentRestriction, CommonConfigService, CommonStateService, DocumentService, DrivingRouteRestriction, LocalStorageService, LogService, MembershipRestriction, MembershipStatus, NetworkState, OrderDirectionType, PermissionRestriction, PermissionType, PetCreateDtoMeta, PetRestriction, PetSexType, PetStatusType, PetType, ProfileApiService, QuestionCreateDtoMeta, QuestionForType, QuestionRestriction, QuestionType, SiteConfigService, UnavailabilityRestriction, UploadCreateDtoMeta, UploadLinkType, UploadRestriction, UploadType, UserAccountFlagType, UserApiService, UserCreateDtoMeta, UserDtoMeta, UserRestriction, UserType, __decorateClass, addAccessTokenToHeaders, addDays, addMinutes, addSeconds, addSpacesForEnum, addToParallelTasks, anyObject, apiParams, apiRoute, arrayContains, arrayOfNLength, capitalizeFirstLetter, cyrb53, dateDiffInDays, debounceLeading, fakePromise, formDataWithAccessTokenHeaders, formatDate, formatFileSize, formatForBookingDate, formatForDateDropdown, formatForDateLocal, formatForDateLocalDetailed, formatForDateOfBirth, formatForDateWithTime, getAgeInYears, getAppType, getArrFromEnum, getAuthApiService, getBotPath, getCaptchaService, getCommonConfig, getCommonStateService, getDefaultDtoMeta, getDocumentServ, getImageParams, getLocalStorage, getLog, getMeta, getMimeTypeFromExtension, getPackagesUsed, getPaginationQueryParams, getPayloadFromJwt, getPerformanceTimer, getProfileApiService, getSiteConfig, getUserApiService, getUsersName, getWeekNumber, isBefore, isNumber, isSameDay, isWebApp, lowercaseFirstLetter, makeArrayOrDefault, maxDate, maxItems, maxLength, mimeTypeLookup, minDate, minItems, minLength, minUrlLength, multiValidation, nameof, noValidation, notNull, onTargetFiles, onTargetValue, onlyUnique, portalGlyphLength, preventDefault, randomIntFromRange, randomItemFromArray, selectedItemsExist, separateValidation, setContainerToken, shouldBeUrl, shouldBeYoutubeUrl, stopPropagation, timeout, uploadsThatNeedEncryption, uuidv4, validUuidChars, validateForEach, webAppTypes };