@freshpointcz/fresh-core 0.0.18 → 0.0.20

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/index.js CHANGED
@@ -428,35 +428,81 @@ __export(index_exports, {
428
428
  AMOUNT_UNIT: () => AMOUNT_UNIT,
429
429
  ActionCommandCode: () => ActionCommandCode,
430
430
  ApiError: () => ApiError,
431
+ BadGatewayError: () => BadGatewayError,
432
+ BadRequestError: () => BadRequestError,
431
433
  BaseEntityChangeSubscriber: () => BaseEntityChangeSubscriber,
432
434
  BusinessWarning: () => BusinessWarning,
433
435
  Category: () => Category,
436
+ ConflictError: () => ConflictError,
437
+ DEFAULT_PAGINATION_PARAMS: () => DEFAULT_PAGINATION_PARAMS,
434
438
  DataHelper: () => DataHelper,
435
439
  DateUtils: () => DateUtils,
436
440
  DepotPoolStatus: () => DepotPoolStatus,
437
441
  Device: () => Device,
442
+ ExpectationFailedError: () => ExpectationFailedError,
443
+ FailedDependencyError: () => FailedDependencyError,
444
+ ForbiddenError: () => ForbiddenError,
438
445
  FreshDao: () => FreshDao,
439
446
  FreshEntity: () => FreshEntity,
447
+ FreshError: () => FreshError,
440
448
  FreshHyperEntity: () => FreshHyperEntity,
441
449
  FreshJob: () => FreshJob,
442
450
  FreshTranslationBase: () => FreshTranslationBase,
451
+ GatewayTimeoutError: () => GatewayTimeoutError,
452
+ GoneError: () => GoneError,
443
453
  HttpStatus: () => HttpStatus,
454
+ HttpVersionNotSupportedError: () => HttpVersionNotSupportedError,
455
+ ImATeapotError: () => ImATeapotError,
456
+ InsufficientStorageError: () => InsufficientStorageError,
457
+ InternalServerError: () => InternalServerError,
444
458
  LanguageCode: () => LanguageCode,
459
+ LengthRequiredError: () => LengthRequiredError,
460
+ LockedError: () => LockedError,
461
+ LoopDetectedError: () => LoopDetectedError,
445
462
  Manufacturer: () => Manufacturer,
463
+ MethodNotAllowedError: () => MethodNotAllowedError,
464
+ MisdirectedRequestError: () => MisdirectedRequestError,
465
+ NetworkAuthenticationRequiredError: () => NetworkAuthenticationRequiredError,
466
+ NotAcceptableError: () => NotAcceptableError,
467
+ NotExtendedError: () => NotExtendedError,
468
+ NotFoundError: () => NotFoundError,
469
+ NotImplementedError: () => NotImplementedError,
470
+ PayloadTooLargeError: () => PayloadTooLargeError,
446
471
  PaymentMethod: () => PaymentMethod,
472
+ PaymentRequiredError: () => PaymentRequiredError,
447
473
  PgDataSourceOptions: () => datasource_default,
474
+ PreconditionFailedError: () => PreconditionFailedError,
475
+ PreconditionRequiredError: () => PreconditionRequiredError,
448
476
  Product: () => Product,
477
+ ProxyAuthenticationRequiredError: () => ProxyAuthenticationRequiredError,
478
+ RangeNotSatisfiableError: () => RangeNotSatisfiableError,
479
+ RequestHeaderFieldsTooLargeError: () => RequestHeaderFieldsTooLargeError,
480
+ RequestTimeoutError: () => RequestTimeoutError,
481
+ ServiceUnavailableError: () => ServiceUnavailableError,
449
482
  SinglePromiseWaiter: () => SinglePromiseWaiter,
450
483
  Singleton: () => Singleton,
451
484
  StatusDto: () => StatusDto,
452
485
  Subcategory: () => Subcategory,
453
486
  TO_BINARY_FLAG: () => TO_BINARY_FLAG,
454
487
  TimestampColumn: () => TimestampColumn,
488
+ TooEarlyError: () => TooEarlyError,
489
+ TooManyRequestsError: () => TooManyRequestsError,
455
490
  TransactionType: () => TransactionType,
491
+ UnauthorizedError: () => UnauthorizedError,
492
+ UnavailableForLegalReasonsError: () => UnavailableForLegalReasonsError,
493
+ UnprocessableEntityError: () => UnprocessableEntityError,
494
+ UnsupportedMediaTypeError: () => UnsupportedMediaTypeError,
495
+ UpgradeRequiredError: () => UpgradeRequiredError,
496
+ UriTooLongError: () => UriTooLongError,
497
+ VariantAlsoNegotiatesError: () => VariantAlsoNegotiatesError,
456
498
  buildPatch: () => buildPatch,
499
+ constructTypeormPagination: () => constructTypeormPagination,
457
500
  createDeferred: () => createDeferred,
458
501
  freshEslintConfig: () => eslint_config_default,
502
+ getPaginationMeta: () => getPaginationMeta,
503
+ getPaginationParams: () => getPaginationParams,
459
504
  hasOwn: () => hasOwn,
505
+ isDecimal: () => isDecimal,
460
506
  isEnumValue: () => isEnumValue,
461
507
  isFlag01: () => isFlag01,
462
508
  isMaybe: () => isMaybe,
@@ -465,10 +511,46 @@ __export(index_exports, {
465
511
  isObject: () => isObject,
466
512
  isString: () => isString,
467
513
  isValidCron: () => isValidCron,
468
- runWithConcurrency: () => runWithConcurrency
514
+ listAll: () => listAll,
515
+ parsePaginationFromURL: () => parsePaginationFromURL,
516
+ resolvePathParameterId: () => resolvePathParameterId,
517
+ runWithConcurrency: () => runWithConcurrency,
518
+ toDecimal: () => toDecimal
469
519
  });
470
520
  module.exports = __toCommonJS(index_exports);
471
521
 
522
+ // src/common/constants/amount-unit.ts
523
+ var AMOUNT_UNIT = {
524
+ 1: {
525
+ symbol: "g",
526
+ translations: {
527
+ en: "gram",
528
+ cs: "gram"
529
+ }
530
+ },
531
+ 2: {
532
+ symbol: "kg",
533
+ translations: {
534
+ en: "kilogram",
535
+ cs: "kilogram"
536
+ }
537
+ },
538
+ 3: {
539
+ symbol: "ml",
540
+ translations: {
541
+ en: "milliliter",
542
+ cs: "mililitr"
543
+ }
544
+ },
545
+ 4: {
546
+ symbol: "l",
547
+ translations: {
548
+ en: "liter",
549
+ cs: "litr"
550
+ }
551
+ }
552
+ };
553
+
472
554
  // src/common/date-utils.ts
473
555
  var import_dayjs = __toESM(require("dayjs"));
474
556
  var import_utc = __toESM(require("dayjs/plugin/utc"));
@@ -649,62 +731,94 @@ __publicField(_DateUtils, "HOLIDAYS", _DateUtils.HOLIDAYS_STR.map((h) => {
649
731
  }));
650
732
  var DateUtils = _DateUtils;
651
733
 
652
- // src/common/promise-magic/deferred.ts
653
- function createDeferred() {
654
- let resolve;
655
- let reject;
656
- const promise = new Promise((res, rej) => {
657
- resolve = res;
658
- reject = rej;
659
- });
734
+ // src/common/dto/status-dto.ts
735
+ var _StatusDto = class _StatusDto {
736
+ constructor(status, details, timestamp) {
737
+ /**
738
+ * Call result status
739
+ */
740
+ __publicField(this, "status");
741
+ /**
742
+ * UTC Timestamp
743
+ * @example "2021-12-01T13:23:39.305Z"
744
+ */
745
+ __publicField(this, "timestamp");
746
+ /**
747
+ * Details (optional)
748
+ */
749
+ __publicField(this, "details");
750
+ this.status = status;
751
+ this.details = details;
752
+ this.timestamp = timestamp != null ? timestamp : DateUtils.getNowCzech().toISOString();
753
+ }
754
+ };
755
+ __name(_StatusDto, "StatusDto");
756
+ var StatusDto = _StatusDto;
757
+
758
+ // src/common/pagination/constructors.ts
759
+ function constructTypeormPagination(params) {
660
760
  return {
661
- promise,
662
- resolve,
663
- reject
761
+ take: params.limit,
762
+ skip: params.skip
664
763
  };
665
764
  }
666
- __name(createDeferred, "createDeferred");
765
+ __name(constructTypeormPagination, "constructTypeormPagination");
766
+ function parsePaginationFromURL(searchParams) {
767
+ var _a, _b;
768
+ const page = Math.max(1, parseInt((_a = searchParams.get("page")) != null ? _a : "1", 10));
769
+ const limit = Math.min(100, Math.max(1, parseInt((_b = searchParams.get("limit")) != null ? _b : "20", 10)));
770
+ return {
771
+ page,
772
+ limit,
773
+ skip: (page - 1) * limit
774
+ };
775
+ }
776
+ __name(parsePaginationFromURL, "parsePaginationFromURL");
667
777
 
668
- // src/common/promise-magic/single-promise-waiter.ts
669
- var _SinglePromiseWaiter = class _SinglePromiseWaiter {
670
- constructor() {
671
- __publicField(this, "_promise", null);
672
- }
673
- static getInstance() {
674
- if (!_SinglePromiseWaiter._instance) {
675
- _SinglePromiseWaiter._instance = new _SinglePromiseWaiter();
676
- }
677
- return _SinglePromiseWaiter._instance;
678
- }
679
- get promise() {
680
- return this._promise;
681
- }
682
- set promise(promise) {
683
- if (promise !== null) {
684
- this._promise = promise;
685
- this._promise.finally(() => {
686
- this._promise = null;
687
- });
688
- }
689
- }
690
- get hasPromise() {
691
- return this._promise !== null;
692
- }
778
+ // src/common/pagination/pagination-meta.ts
779
+ function getPaginationMeta(total, page, limit) {
780
+ return {
781
+ total,
782
+ page,
783
+ limit,
784
+ totalPages: Math.ceil(total / limit)
785
+ };
786
+ }
787
+ __name(getPaginationMeta, "getPaginationMeta");
788
+
789
+ // src/common/pagination/pagination-params.ts
790
+ function getPaginationParams(params) {
791
+ return {
792
+ ...DEFAULT_PAGINATION_PARAMS,
793
+ ...params
794
+ };
795
+ }
796
+ __name(getPaginationParams, "getPaginationParams");
797
+ var DEFAULT_PAGINATION_PARAMS = {
798
+ page: 1,
799
+ limit: 1e3,
800
+ skip: 0
693
801
  };
694
- __name(_SinglePromiseWaiter, "SinglePromiseWaiter");
695
- __publicField(_SinglePromiseWaiter, "_instance");
696
- var SinglePromiseWaiter = _SinglePromiseWaiter;
697
802
 
698
- // src/common/utils/is-cron-valid.ts
699
- function isValidCron(expr) {
700
- const parts = expr.trim().split(/\s+/);
701
- if (parts.length < 5 || parts.length > 6) {
702
- return false;
803
+ // src/common/pagination/scrapper.ts
804
+ async function listAll(fetchPage, batchSize = 1e3) {
805
+ const results = [];
806
+ let page = 1;
807
+ while (true) {
808
+ const { data, meta } = await fetchPage({
809
+ page,
810
+ limit: batchSize,
811
+ skip: (page - 1) * batchSize
812
+ });
813
+ results.push(...data);
814
+ if (page >= meta.totalPages) {
815
+ break;
816
+ }
817
+ page++;
703
818
  }
704
- const cronPart = /^(\*|\d+|\d+\-\d+|\d+\/\d+|\*\/\d+)(,\d+)*$/;
705
- return parts.every((part) => cronPart.test(part));
819
+ return results;
706
820
  }
707
- __name(isValidCron, "isValidCron");
821
+ __name(listAll, "listAll");
708
822
 
709
823
  // src/common/patterns/singleton.ts
710
824
  var _Singleton = class _Singleton {
@@ -757,61 +871,51 @@ __name(_Singleton, "Singleton");
757
871
  __publicField(_Singleton, "instances", /* @__PURE__ */ new Map());
758
872
  var Singleton = _Singleton;
759
873
 
760
- // src/common/dto/status-dto.ts
761
- var _StatusDto = class _StatusDto {
762
- constructor(status, details, timestamp) {
763
- /**
764
- * Call result status
765
- */
766
- __publicField(this, "status");
767
- /**
768
- * UTC Timestamp
769
- * @example "2021-12-01T13:23:39.305Z"
770
- */
771
- __publicField(this, "timestamp");
772
- /**
773
- * Details (optional)
774
- */
775
- __publicField(this, "details");
776
- this.status = status;
777
- this.details = details;
778
- this.timestamp = timestamp != null ? timestamp : DateUtils.getNowCzech().toISOString();
779
- }
780
- };
781
- __name(_StatusDto, "StatusDto");
782
- var StatusDto = _StatusDto;
874
+ // src/common/promise-magic/deferred.ts
875
+ function createDeferred() {
876
+ let resolve;
877
+ let reject;
878
+ const promise = new Promise((res, rej) => {
879
+ resolve = res;
880
+ reject = rej;
881
+ });
882
+ return {
883
+ promise,
884
+ resolve,
885
+ reject
886
+ };
887
+ }
888
+ __name(createDeferred, "createDeferred");
783
889
 
784
- // src/common/constants/amount-unit.ts
785
- var AMOUNT_UNIT = {
786
- 1: {
787
- symbol: "g",
788
- translations: {
789
- en: "gram",
790
- cs: "gram"
791
- }
792
- },
793
- 2: {
794
- symbol: "kg",
795
- translations: {
796
- en: "kilogram",
797
- cs: "kilogram"
798
- }
799
- },
800
- 3: {
801
- symbol: "ml",
802
- translations: {
803
- en: "milliliter",
804
- cs: "mililitr"
890
+ // src/common/promise-magic/single-promise-waiter.ts
891
+ var _SinglePromiseWaiter = class _SinglePromiseWaiter {
892
+ constructor() {
893
+ __publicField(this, "_promise", null);
894
+ }
895
+ static getInstance() {
896
+ if (!_SinglePromiseWaiter._instance) {
897
+ _SinglePromiseWaiter._instance = new _SinglePromiseWaiter();
805
898
  }
806
- },
807
- 4: {
808
- symbol: "l",
809
- translations: {
810
- en: "liter",
811
- cs: "litr"
899
+ return _SinglePromiseWaiter._instance;
900
+ }
901
+ get promise() {
902
+ return this._promise;
903
+ }
904
+ set promise(promise) {
905
+ if (promise !== null) {
906
+ this._promise = promise;
907
+ this._promise.finally(() => {
908
+ this._promise = null;
909
+ });
812
910
  }
813
911
  }
912
+ get hasPromise() {
913
+ return this._promise !== null;
914
+ }
814
915
  };
916
+ __name(_SinglePromiseWaiter, "SinglePromiseWaiter");
917
+ __publicField(_SinglePromiseWaiter, "_instance");
918
+ var SinglePromiseWaiter = _SinglePromiseWaiter;
815
919
 
816
920
  // src/common/schema/entities/category.entity.ts
817
921
  var import_typeorm5 = require("typeorm");
@@ -1329,6 +1433,57 @@ Subcategory = _ts_decorate8([
1329
1433
  (0, import_typeorm9.Entity)()
1330
1434
  ], Subcategory);
1331
1435
 
1436
+ // src/common/typeguards/decimal.ts
1437
+ function toDecimal(num, precision = 9, scale = 2) {
1438
+ const limit = Math.pow(10, precision - scale);
1439
+ if (Math.abs(num) >= limit) {
1440
+ throw new Error(`Value ${num} exceeds the allowed precision of ${precision} and scale of ${scale}.`);
1441
+ }
1442
+ return num.toFixed(scale);
1443
+ }
1444
+ __name(toDecimal, "toDecimal");
1445
+ function isDecimal(v, options) {
1446
+ var _a, _b, _c;
1447
+ const type = typeof v;
1448
+ if ((options == null ? void 0 : options.allowedType) !== void 0 && type !== options.allowedType) {
1449
+ return false;
1450
+ }
1451
+ if (type !== "number" && type !== "string") {
1452
+ return false;
1453
+ }
1454
+ const sep = (_a = options == null ? void 0 : options.decimalPoint) != null ? _a : ".";
1455
+ let intPart;
1456
+ let fracPart;
1457
+ if (type === "number") {
1458
+ const n = v;
1459
+ if (!Number.isFinite(n)) {
1460
+ return false;
1461
+ }
1462
+ const str = n.toString();
1463
+ if (str.includes("e") || str.includes("E")) {
1464
+ return false;
1465
+ }
1466
+ const parts = str.replace("-", "").split(".");
1467
+ intPart = parts[0];
1468
+ fracPart = (_b = parts[1]) != null ? _b : "";
1469
+ } else {
1470
+ const s = v;
1471
+ const escapedSep = sep === "." ? "\\." : ",";
1472
+ const pattern = new RegExp(`^-?\\d+(?:${escapedSep}\\d+)?$`);
1473
+ if (!pattern.test(s)) {
1474
+ return false;
1475
+ }
1476
+ const parts = s.replace("-", "").split(sep);
1477
+ intPart = parts[0];
1478
+ fracPart = (_c = parts[1]) != null ? _c : "";
1479
+ }
1480
+ if ((options == null ? void 0 : options.scale) !== void 0 && fracPart.length > options.scale) {
1481
+ return false;
1482
+ }
1483
+ return (options == null ? void 0 : options.precision) === void 0 || intPart.length + fracPart.length <= options.precision;
1484
+ }
1485
+ __name(isDecimal, "isDecimal");
1486
+
1332
1487
  // src/common/typeguards/enums.ts
1333
1488
  function isEnumValue(enumObj, v) {
1334
1489
  if (!enumObj) {
@@ -1399,6 +1554,23 @@ async function runWithConcurrency(items, concurrency, worker) {
1399
1554
  }
1400
1555
  __name(runWithConcurrency, "runWithConcurrency");
1401
1556
 
1557
+ // src/common/utils/id-path-param-resolver.utils.ts
1558
+ function resolvePathParameterId(id) {
1559
+ return /^\d+$/.test(id) ? parseInt(id, 10) : id;
1560
+ }
1561
+ __name(resolvePathParameterId, "resolvePathParameterId");
1562
+
1563
+ // src/common/utils/is-cron-valid.ts
1564
+ function isValidCron(expr) {
1565
+ const parts = expr.trim().split(/\s+/);
1566
+ if (parts.length < 5 || parts.length > 6) {
1567
+ return false;
1568
+ }
1569
+ const cronPart = /^(\*|\d+|\d+\-\d+|\d+\/\d+|\*\/\d+)(,\d+)*$/;
1570
+ return parts.every((part) => cronPart.test(part));
1571
+ }
1572
+ __name(isValidCron, "isValidCron");
1573
+
1402
1574
  // src/common/utils/patch.utils.ts
1403
1575
  function buildPatch(data, keys, transforms) {
1404
1576
  const patch = {};
@@ -1413,43 +1585,6 @@ function buildPatch(data, keys, transforms) {
1413
1585
  }
1414
1586
  __name(buildPatch, "buildPatch");
1415
1587
 
1416
- // src/core/data-helper.ts
1417
- var _DataHelper = class _DataHelper {
1418
- constructor(startDataRetrieve = true, deviceIds) {
1419
- __publicField(this, "_data");
1420
- __publicField(this, "_dataPromise", null);
1421
- __publicField(this, "deviceIds");
1422
- this.deviceIds = deviceIds;
1423
- if (startDataRetrieve) {
1424
- this._dataPromise = this.startDataRetrieval();
1425
- }
1426
- }
1427
- get data() {
1428
- return this._data;
1429
- }
1430
- set data(value) {
1431
- this._data = value;
1432
- }
1433
- get dataPromise() {
1434
- return this._dataPromise;
1435
- }
1436
- set dataPromise(value) {
1437
- this._dataPromise = value;
1438
- }
1439
- async getData() {
1440
- if (this._dataPromise) {
1441
- return await this._dataPromise;
1442
- }
1443
- if (this._data === void 0) {
1444
- this._dataPromise = this.startDataRetrieval();
1445
- return this._dataPromise;
1446
- }
1447
- return this._data;
1448
- }
1449
- };
1450
- __name(_DataHelper, "DataHelper");
1451
- var DataHelper = _DataHelper;
1452
-
1453
1588
  // src/core/class/fresh-job.ts
1454
1589
  var import_node_schedule = require("node-schedule");
1455
1590
  var _FreshJob = class _FreshJob extends Singleton {
@@ -1598,6 +1733,346 @@ var _BusinessWarning = class _BusinessWarning extends Error {
1598
1733
  __name(_BusinessWarning, "BusinessWarning");
1599
1734
  var BusinessWarning = _BusinessWarning;
1600
1735
 
1736
+ // src/core/errors/fresh-error.ts
1737
+ var _FreshError = class _FreshError extends Error {
1738
+ constructor(statusCode, status, detail, options) {
1739
+ super(detail != null ? detail : status);
1740
+ /** HTTP status code sent in the response. */
1741
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1742
+ __publicField(this, "statusCode");
1743
+ /** Structured response body describing the error. */
1744
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1745
+ __publicField(this, "statusDto");
1746
+ this.name = this.constructor.name;
1747
+ if ((options == null ? void 0 : options.cause) !== void 0) {
1748
+ this.cause = options.cause;
1749
+ }
1750
+ this.statusCode = statusCode;
1751
+ this.statusDto = new StatusDto(status, detail);
1752
+ }
1753
+ };
1754
+ __name(_FreshError, "FreshError");
1755
+ var FreshError = _FreshError;
1756
+
1757
+ // src/core/errors/errors.ts
1758
+ var _BadRequestError = class _BadRequestError extends FreshError {
1759
+ constructor(detail, options) {
1760
+ super(HttpStatus.BAD_REQUEST, "validation-error", detail, options);
1761
+ }
1762
+ };
1763
+ __name(_BadRequestError, "BadRequestError");
1764
+ var BadRequestError = _BadRequestError;
1765
+ var _UnauthorizedError = class _UnauthorizedError extends FreshError {
1766
+ constructor(detail, options) {
1767
+ super(HttpStatus.UNAUTHORIZED, "not-authenticated", detail, options);
1768
+ }
1769
+ };
1770
+ __name(_UnauthorizedError, "UnauthorizedError");
1771
+ var UnauthorizedError = _UnauthorizedError;
1772
+ var _PaymentRequiredError = class _PaymentRequiredError extends FreshError {
1773
+ constructor(detail, options) {
1774
+ super(HttpStatus.PAYMENT_REQUIRED, "error", detail, options);
1775
+ }
1776
+ };
1777
+ __name(_PaymentRequiredError, "PaymentRequiredError");
1778
+ var PaymentRequiredError = _PaymentRequiredError;
1779
+ var _ForbiddenError = class _ForbiddenError extends FreshError {
1780
+ constructor(detail, options) {
1781
+ super(HttpStatus.FORBIDDEN, "not-authorized", detail, options);
1782
+ }
1783
+ };
1784
+ __name(_ForbiddenError, "ForbiddenError");
1785
+ var ForbiddenError = _ForbiddenError;
1786
+ var _NotFoundError = class _NotFoundError extends FreshError {
1787
+ constructor(detail, options) {
1788
+ super(HttpStatus.NOT_FOUND, "error", detail, options);
1789
+ }
1790
+ };
1791
+ __name(_NotFoundError, "NotFoundError");
1792
+ var NotFoundError = _NotFoundError;
1793
+ var _MethodNotAllowedError = class _MethodNotAllowedError extends FreshError {
1794
+ constructor(detail, options) {
1795
+ super(HttpStatus.METHOD_NOT_ALLOWED, "error", detail, options);
1796
+ }
1797
+ };
1798
+ __name(_MethodNotAllowedError, "MethodNotAllowedError");
1799
+ var MethodNotAllowedError = _MethodNotAllowedError;
1800
+ var _NotAcceptableError = class _NotAcceptableError extends FreshError {
1801
+ constructor(detail, options) {
1802
+ super(HttpStatus.NOT_ACCEPTABLE, "error", detail, options);
1803
+ }
1804
+ };
1805
+ __name(_NotAcceptableError, "NotAcceptableError");
1806
+ var NotAcceptableError = _NotAcceptableError;
1807
+ var _ProxyAuthenticationRequiredError = class _ProxyAuthenticationRequiredError extends FreshError {
1808
+ constructor(detail, options) {
1809
+ super(HttpStatus.PROXY_AUTHENTICATION_REQUIRED, "not-authenticated", detail, options);
1810
+ }
1811
+ };
1812
+ __name(_ProxyAuthenticationRequiredError, "ProxyAuthenticationRequiredError");
1813
+ var ProxyAuthenticationRequiredError = _ProxyAuthenticationRequiredError;
1814
+ var _RequestTimeoutError = class _RequestTimeoutError extends FreshError {
1815
+ constructor(detail, options) {
1816
+ super(HttpStatus.REQUEST_TIMEOUT, "error", detail, options);
1817
+ }
1818
+ };
1819
+ __name(_RequestTimeoutError, "RequestTimeoutError");
1820
+ var RequestTimeoutError = _RequestTimeoutError;
1821
+ var _ConflictError = class _ConflictError extends FreshError {
1822
+ constructor(detail, options) {
1823
+ super(HttpStatus.CONFLICT, "error", detail, options);
1824
+ }
1825
+ };
1826
+ __name(_ConflictError, "ConflictError");
1827
+ var ConflictError = _ConflictError;
1828
+ var _GoneError = class _GoneError extends FreshError {
1829
+ constructor(detail, options) {
1830
+ super(HttpStatus.GONE, "error", detail, options);
1831
+ }
1832
+ };
1833
+ __name(_GoneError, "GoneError");
1834
+ var GoneError = _GoneError;
1835
+ var _LengthRequiredError = class _LengthRequiredError extends FreshError {
1836
+ constructor(detail, options) {
1837
+ super(HttpStatus.LENGTH_REQUIRED, "error", detail, options);
1838
+ }
1839
+ };
1840
+ __name(_LengthRequiredError, "LengthRequiredError");
1841
+ var LengthRequiredError = _LengthRequiredError;
1842
+ var _PreconditionFailedError = class _PreconditionFailedError extends FreshError {
1843
+ constructor(detail, options) {
1844
+ super(HttpStatus.PRECONDITION_FAILED, "error", detail, options);
1845
+ }
1846
+ };
1847
+ __name(_PreconditionFailedError, "PreconditionFailedError");
1848
+ var PreconditionFailedError = _PreconditionFailedError;
1849
+ var _PayloadTooLargeError = class _PayloadTooLargeError extends FreshError {
1850
+ constructor(detail, options) {
1851
+ super(HttpStatus.PAYLOAD_TOO_LARGE, "error", detail, options);
1852
+ }
1853
+ };
1854
+ __name(_PayloadTooLargeError, "PayloadTooLargeError");
1855
+ var PayloadTooLargeError = _PayloadTooLargeError;
1856
+ var _UriTooLongError = class _UriTooLongError extends FreshError {
1857
+ constructor(detail, options) {
1858
+ super(HttpStatus.URI_TOO_LONG, "error", detail, options);
1859
+ }
1860
+ };
1861
+ __name(_UriTooLongError, "UriTooLongError");
1862
+ var UriTooLongError = _UriTooLongError;
1863
+ var _UnsupportedMediaTypeError = class _UnsupportedMediaTypeError extends FreshError {
1864
+ constructor(detail, options) {
1865
+ super(HttpStatus.UNSUPPORTED_MEDIA_TYPE, "error", detail, options);
1866
+ }
1867
+ };
1868
+ __name(_UnsupportedMediaTypeError, "UnsupportedMediaTypeError");
1869
+ var UnsupportedMediaTypeError = _UnsupportedMediaTypeError;
1870
+ var _RangeNotSatisfiableError = class _RangeNotSatisfiableError extends FreshError {
1871
+ constructor(detail, options) {
1872
+ super(HttpStatus.RANGE_NOT_SATISFIABLE, "error", detail, options);
1873
+ }
1874
+ };
1875
+ __name(_RangeNotSatisfiableError, "RangeNotSatisfiableError");
1876
+ var RangeNotSatisfiableError = _RangeNotSatisfiableError;
1877
+ var _ExpectationFailedError = class _ExpectationFailedError extends FreshError {
1878
+ constructor(detail, options) {
1879
+ super(HttpStatus.EXPECTATION_FAILED, "error", detail, options);
1880
+ }
1881
+ };
1882
+ __name(_ExpectationFailedError, "ExpectationFailedError");
1883
+ var ExpectationFailedError = _ExpectationFailedError;
1884
+ var _ImATeapotError = class _ImATeapotError extends FreshError {
1885
+ constructor(detail, options) {
1886
+ super(HttpStatus.IM_A_TEAPOT, "error", detail, options);
1887
+ }
1888
+ };
1889
+ __name(_ImATeapotError, "ImATeapotError");
1890
+ var ImATeapotError = _ImATeapotError;
1891
+ var _MisdirectedRequestError = class _MisdirectedRequestError extends FreshError {
1892
+ constructor(detail, options) {
1893
+ super(HttpStatus.MISDIRECTED_REQUEST, "error", detail, options);
1894
+ }
1895
+ };
1896
+ __name(_MisdirectedRequestError, "MisdirectedRequestError");
1897
+ var MisdirectedRequestError = _MisdirectedRequestError;
1898
+ var _UnprocessableEntityError = class _UnprocessableEntityError extends FreshError {
1899
+ constructor(detail, options) {
1900
+ super(HttpStatus.UNPROCESSABLE_ENTITY, "validation-error", detail, options);
1901
+ }
1902
+ };
1903
+ __name(_UnprocessableEntityError, "UnprocessableEntityError");
1904
+ var UnprocessableEntityError = _UnprocessableEntityError;
1905
+ var _LockedError = class _LockedError extends FreshError {
1906
+ constructor(detail, options) {
1907
+ super(HttpStatus.LOCKED, "error", detail, options);
1908
+ }
1909
+ };
1910
+ __name(_LockedError, "LockedError");
1911
+ var LockedError = _LockedError;
1912
+ var _FailedDependencyError = class _FailedDependencyError extends FreshError {
1913
+ constructor(detail, options) {
1914
+ super(HttpStatus.FAILED_DEPENDENCY, "error", detail, options);
1915
+ }
1916
+ };
1917
+ __name(_FailedDependencyError, "FailedDependencyError");
1918
+ var FailedDependencyError = _FailedDependencyError;
1919
+ var _TooEarlyError = class _TooEarlyError extends FreshError {
1920
+ constructor(detail, options) {
1921
+ super(HttpStatus.TOO_EARLY, "error", detail, options);
1922
+ }
1923
+ };
1924
+ __name(_TooEarlyError, "TooEarlyError");
1925
+ var TooEarlyError = _TooEarlyError;
1926
+ var _UpgradeRequiredError = class _UpgradeRequiredError extends FreshError {
1927
+ constructor(detail, options) {
1928
+ super(HttpStatus.UPGRADE_REQUIRED, "error", detail, options);
1929
+ }
1930
+ };
1931
+ __name(_UpgradeRequiredError, "UpgradeRequiredError");
1932
+ var UpgradeRequiredError = _UpgradeRequiredError;
1933
+ var _PreconditionRequiredError = class _PreconditionRequiredError extends FreshError {
1934
+ constructor(detail, options) {
1935
+ super(HttpStatus.PRECONDITION_REQUIRED, "error", detail, options);
1936
+ }
1937
+ };
1938
+ __name(_PreconditionRequiredError, "PreconditionRequiredError");
1939
+ var PreconditionRequiredError = _PreconditionRequiredError;
1940
+ var _TooManyRequestsError = class _TooManyRequestsError extends FreshError {
1941
+ constructor(detail, options) {
1942
+ super(HttpStatus.TOO_MANY_REQUESTS, "error", detail, options);
1943
+ }
1944
+ };
1945
+ __name(_TooManyRequestsError, "TooManyRequestsError");
1946
+ var TooManyRequestsError = _TooManyRequestsError;
1947
+ var _RequestHeaderFieldsTooLargeError = class _RequestHeaderFieldsTooLargeError extends FreshError {
1948
+ constructor(detail, options) {
1949
+ super(HttpStatus.REQUEST_HEADER_FIELDS_TOO_LARGE, "error", detail, options);
1950
+ }
1951
+ };
1952
+ __name(_RequestHeaderFieldsTooLargeError, "RequestHeaderFieldsTooLargeError");
1953
+ var RequestHeaderFieldsTooLargeError = _RequestHeaderFieldsTooLargeError;
1954
+ var _UnavailableForLegalReasonsError = class _UnavailableForLegalReasonsError extends FreshError {
1955
+ constructor(detail, options) {
1956
+ super(HttpStatus.UNAVAILABLE_FOR_LEGAL_REASONS, "error", detail, options);
1957
+ }
1958
+ };
1959
+ __name(_UnavailableForLegalReasonsError, "UnavailableForLegalReasonsError");
1960
+ var UnavailableForLegalReasonsError = _UnavailableForLegalReasonsError;
1961
+ var _InternalServerError = class _InternalServerError extends FreshError {
1962
+ constructor(detail, options) {
1963
+ super(HttpStatus.INTERNAL_SERVER_ERROR, "internal-server-error", detail, options);
1964
+ }
1965
+ };
1966
+ __name(_InternalServerError, "InternalServerError");
1967
+ var InternalServerError = _InternalServerError;
1968
+ var _NotImplementedError = class _NotImplementedError extends FreshError {
1969
+ constructor(detail, options) {
1970
+ super(HttpStatus.NOT_IMPLEMENTED, "internal-server-error", detail, options);
1971
+ }
1972
+ };
1973
+ __name(_NotImplementedError, "NotImplementedError");
1974
+ var NotImplementedError = _NotImplementedError;
1975
+ var _BadGatewayError = class _BadGatewayError extends FreshError {
1976
+ constructor(detail, options) {
1977
+ super(HttpStatus.BAD_GATEWAY, "internal-server-error", detail, options);
1978
+ }
1979
+ };
1980
+ __name(_BadGatewayError, "BadGatewayError");
1981
+ var BadGatewayError = _BadGatewayError;
1982
+ var _ServiceUnavailableError = class _ServiceUnavailableError extends FreshError {
1983
+ constructor(detail, options) {
1984
+ super(HttpStatus.SERVICE_UNAVAILABLE, "internal-server-error", detail, options);
1985
+ }
1986
+ };
1987
+ __name(_ServiceUnavailableError, "ServiceUnavailableError");
1988
+ var ServiceUnavailableError = _ServiceUnavailableError;
1989
+ var _GatewayTimeoutError = class _GatewayTimeoutError extends FreshError {
1990
+ constructor(detail, options) {
1991
+ super(HttpStatus.GATEWAY_TIMEOUT, "internal-server-error", detail, options);
1992
+ }
1993
+ };
1994
+ __name(_GatewayTimeoutError, "GatewayTimeoutError");
1995
+ var GatewayTimeoutError = _GatewayTimeoutError;
1996
+ var _HttpVersionNotSupportedError = class _HttpVersionNotSupportedError extends FreshError {
1997
+ constructor(detail, options) {
1998
+ super(HttpStatus.HTTP_VERSION_NOT_SUPPORTED, "internal-server-error", detail, options);
1999
+ }
2000
+ };
2001
+ __name(_HttpVersionNotSupportedError, "HttpVersionNotSupportedError");
2002
+ var HttpVersionNotSupportedError = _HttpVersionNotSupportedError;
2003
+ var _VariantAlsoNegotiatesError = class _VariantAlsoNegotiatesError extends FreshError {
2004
+ constructor(detail, options) {
2005
+ super(HttpStatus.VARIANT_ALSO_NEGOTIATES, "internal-server-error", detail, options);
2006
+ }
2007
+ };
2008
+ __name(_VariantAlsoNegotiatesError, "VariantAlsoNegotiatesError");
2009
+ var VariantAlsoNegotiatesError = _VariantAlsoNegotiatesError;
2010
+ var _InsufficientStorageError = class _InsufficientStorageError extends FreshError {
2011
+ constructor(detail, options) {
2012
+ super(HttpStatus.INSUFFICIENT_STORAGE, "internal-server-error", detail, options);
2013
+ }
2014
+ };
2015
+ __name(_InsufficientStorageError, "InsufficientStorageError");
2016
+ var InsufficientStorageError = _InsufficientStorageError;
2017
+ var _LoopDetectedError = class _LoopDetectedError extends FreshError {
2018
+ constructor(detail, options) {
2019
+ super(HttpStatus.LOOP_DETECTED, "internal-server-error", detail, options);
2020
+ }
2021
+ };
2022
+ __name(_LoopDetectedError, "LoopDetectedError");
2023
+ var LoopDetectedError = _LoopDetectedError;
2024
+ var _NotExtendedError = class _NotExtendedError extends FreshError {
2025
+ constructor(detail, options) {
2026
+ super(HttpStatus.NOT_EXTENDED, "internal-server-error", detail, options);
2027
+ }
2028
+ };
2029
+ __name(_NotExtendedError, "NotExtendedError");
2030
+ var NotExtendedError = _NotExtendedError;
2031
+ var _NetworkAuthenticationRequiredError = class _NetworkAuthenticationRequiredError extends FreshError {
2032
+ constructor(detail, options) {
2033
+ super(HttpStatus.NETWORK_AUTHENTICATION_REQUIRED, "internal-server-error", detail, options);
2034
+ }
2035
+ };
2036
+ __name(_NetworkAuthenticationRequiredError, "NetworkAuthenticationRequiredError");
2037
+ var NetworkAuthenticationRequiredError = _NetworkAuthenticationRequiredError;
2038
+
2039
+ // src/core/data-helper.ts
2040
+ var _DataHelper = class _DataHelper {
2041
+ constructor(startDataRetrieve = true, deviceIds) {
2042
+ __publicField(this, "_data");
2043
+ __publicField(this, "_dataPromise", null);
2044
+ __publicField(this, "deviceIds");
2045
+ this.deviceIds = deviceIds;
2046
+ if (startDataRetrieve) {
2047
+ this._dataPromise = this.startDataRetrieval();
2048
+ }
2049
+ }
2050
+ get data() {
2051
+ return this._data;
2052
+ }
2053
+ set data(value) {
2054
+ this._data = value;
2055
+ }
2056
+ get dataPromise() {
2057
+ return this._dataPromise;
2058
+ }
2059
+ set dataPromise(value) {
2060
+ this._dataPromise = value;
2061
+ }
2062
+ async getData() {
2063
+ if (this._dataPromise) {
2064
+ return await this._dataPromise;
2065
+ }
2066
+ if (this._data === void 0) {
2067
+ this._dataPromise = this.startDataRetrieval();
2068
+ return this._dataPromise;
2069
+ }
2070
+ return this._data;
2071
+ }
2072
+ };
2073
+ __name(_DataHelper, "DataHelper");
2074
+ var DataHelper = _DataHelper;
2075
+
1601
2076
  // src/types/maybe-type.ts
1602
2077
  function isMaybe(v, inner) {
1603
2078
  return v === null || inner(v);
@@ -1791,35 +2266,81 @@ var datasource_default = PG_DATA_SOURCE_OPTIONS;
1791
2266
  AMOUNT_UNIT,
1792
2267
  ActionCommandCode,
1793
2268
  ApiError,
2269
+ BadGatewayError,
2270
+ BadRequestError,
1794
2271
  BaseEntityChangeSubscriber,
1795
2272
  BusinessWarning,
1796
2273
  Category,
2274
+ ConflictError,
2275
+ DEFAULT_PAGINATION_PARAMS,
1797
2276
  DataHelper,
1798
2277
  DateUtils,
1799
2278
  DepotPoolStatus,
1800
2279
  Device,
2280
+ ExpectationFailedError,
2281
+ FailedDependencyError,
2282
+ ForbiddenError,
1801
2283
  FreshDao,
1802
2284
  FreshEntity,
2285
+ FreshError,
1803
2286
  FreshHyperEntity,
1804
2287
  FreshJob,
1805
2288
  FreshTranslationBase,
2289
+ GatewayTimeoutError,
2290
+ GoneError,
1806
2291
  HttpStatus,
2292
+ HttpVersionNotSupportedError,
2293
+ ImATeapotError,
2294
+ InsufficientStorageError,
2295
+ InternalServerError,
1807
2296
  LanguageCode,
2297
+ LengthRequiredError,
2298
+ LockedError,
2299
+ LoopDetectedError,
1808
2300
  Manufacturer,
2301
+ MethodNotAllowedError,
2302
+ MisdirectedRequestError,
2303
+ NetworkAuthenticationRequiredError,
2304
+ NotAcceptableError,
2305
+ NotExtendedError,
2306
+ NotFoundError,
2307
+ NotImplementedError,
2308
+ PayloadTooLargeError,
1809
2309
  PaymentMethod,
2310
+ PaymentRequiredError,
1810
2311
  PgDataSourceOptions,
2312
+ PreconditionFailedError,
2313
+ PreconditionRequiredError,
1811
2314
  Product,
2315
+ ProxyAuthenticationRequiredError,
2316
+ RangeNotSatisfiableError,
2317
+ RequestHeaderFieldsTooLargeError,
2318
+ RequestTimeoutError,
2319
+ ServiceUnavailableError,
1812
2320
  SinglePromiseWaiter,
1813
2321
  Singleton,
1814
2322
  StatusDto,
1815
2323
  Subcategory,
1816
2324
  TO_BINARY_FLAG,
1817
2325
  TimestampColumn,
2326
+ TooEarlyError,
2327
+ TooManyRequestsError,
1818
2328
  TransactionType,
2329
+ UnauthorizedError,
2330
+ UnavailableForLegalReasonsError,
2331
+ UnprocessableEntityError,
2332
+ UnsupportedMediaTypeError,
2333
+ UpgradeRequiredError,
2334
+ UriTooLongError,
2335
+ VariantAlsoNegotiatesError,
1819
2336
  buildPatch,
2337
+ constructTypeormPagination,
1820
2338
  createDeferred,
1821
2339
  freshEslintConfig,
2340
+ getPaginationMeta,
2341
+ getPaginationParams,
1822
2342
  hasOwn,
2343
+ isDecimal,
1823
2344
  isEnumValue,
1824
2345
  isFlag01,
1825
2346
  isMaybe,
@@ -1828,6 +2349,10 @@ var datasource_default = PG_DATA_SOURCE_OPTIONS;
1828
2349
  isObject,
1829
2350
  isString,
1830
2351
  isValidCron,
1831
- runWithConcurrency
2352
+ listAll,
2353
+ parsePaginationFromURL,
2354
+ resolvePathParameterId,
2355
+ runWithConcurrency,
2356
+ toDecimal
1832
2357
  });
1833
2358
  //# sourceMappingURL=index.js.map