@freshpointcz/fresh-core 0.0.17 → 0.0.19
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.d.mts +414 -1
- package/dist/index.d.ts +414 -1
- package/dist/index.js +215 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +202 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -108,7 +108,7 @@ var require_main = __commonJS({
|
|
|
108
108
|
var fs = __require("fs");
|
|
109
109
|
var path2 = __require("path");
|
|
110
110
|
var os = __require("os");
|
|
111
|
-
var
|
|
111
|
+
var crypto = __require("crypto");
|
|
112
112
|
var packageJson = require_package();
|
|
113
113
|
var version = packageJson.version;
|
|
114
114
|
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
@@ -355,7 +355,7 @@ var require_main = __commonJS({
|
|
|
355
355
|
const authTag = ciphertext.subarray(-16);
|
|
356
356
|
ciphertext = ciphertext.subarray(12, -16);
|
|
357
357
|
try {
|
|
358
|
-
const aesgcm =
|
|
358
|
+
const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
|
|
359
359
|
aesgcm.setAuthTag(authTag);
|
|
360
360
|
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
361
361
|
} catch (error) {
|
|
@@ -734,6 +734,71 @@ var _StatusDto = class _StatusDto {
|
|
|
734
734
|
__name(_StatusDto, "StatusDto");
|
|
735
735
|
var StatusDto = _StatusDto;
|
|
736
736
|
|
|
737
|
+
// src/common/pagination/constructors.ts
|
|
738
|
+
function constructTypeormPagination(params) {
|
|
739
|
+
return {
|
|
740
|
+
take: params.limit,
|
|
741
|
+
skip: params.skip
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
__name(constructTypeormPagination, "constructTypeormPagination");
|
|
745
|
+
function parsePaginationFromURL(searchParams) {
|
|
746
|
+
var _a, _b;
|
|
747
|
+
const page = Math.max(1, parseInt((_a = searchParams.get("page")) != null ? _a : "1", 10));
|
|
748
|
+
const limit = Math.min(100, Math.max(1, parseInt((_b = searchParams.get("limit")) != null ? _b : "20", 10)));
|
|
749
|
+
return {
|
|
750
|
+
page,
|
|
751
|
+
limit,
|
|
752
|
+
skip: (page - 1) * limit
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
__name(parsePaginationFromURL, "parsePaginationFromURL");
|
|
756
|
+
|
|
757
|
+
// src/common/pagination/pagination-meta.ts
|
|
758
|
+
function getPaginationMeta(total, page, limit) {
|
|
759
|
+
return {
|
|
760
|
+
total,
|
|
761
|
+
page,
|
|
762
|
+
limit,
|
|
763
|
+
totalPages: Math.ceil(total / limit)
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
__name(getPaginationMeta, "getPaginationMeta");
|
|
767
|
+
|
|
768
|
+
// src/common/pagination/pagination-params.ts
|
|
769
|
+
function getPaginationParams(params) {
|
|
770
|
+
return {
|
|
771
|
+
...DEFAULT_PAGINATION_PARAMS,
|
|
772
|
+
...params
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
__name(getPaginationParams, "getPaginationParams");
|
|
776
|
+
var DEFAULT_PAGINATION_PARAMS = {
|
|
777
|
+
page: 1,
|
|
778
|
+
limit: 1e3,
|
|
779
|
+
skip: 0
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
// src/common/pagination/scrapper.ts
|
|
783
|
+
async function listAll(fetchPage, batchSize = 1e3) {
|
|
784
|
+
const results = [];
|
|
785
|
+
let page = 1;
|
|
786
|
+
while (true) {
|
|
787
|
+
const { data, meta } = await fetchPage({
|
|
788
|
+
page,
|
|
789
|
+
limit: batchSize,
|
|
790
|
+
skip: (page - 1) * batchSize
|
|
791
|
+
});
|
|
792
|
+
results.push(...data);
|
|
793
|
+
if (page >= meta.totalPages) {
|
|
794
|
+
break;
|
|
795
|
+
}
|
|
796
|
+
page++;
|
|
797
|
+
}
|
|
798
|
+
return results;
|
|
799
|
+
}
|
|
800
|
+
__name(listAll, "listAll");
|
|
801
|
+
|
|
737
802
|
// src/common/constants/amount-unit.ts
|
|
738
803
|
var AMOUNT_UNIT = {
|
|
739
804
|
1: {
|
|
@@ -772,46 +837,53 @@ import { Entity } from "typeorm";
|
|
|
772
837
|
// src/database/entities/fresh-entity.ts
|
|
773
838
|
import { BaseEntity, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index, Column } from "typeorm";
|
|
774
839
|
|
|
775
|
-
// ../../node_modules/uuid/dist/esm
|
|
776
|
-
|
|
840
|
+
// ../../node_modules/uuid/dist/esm/stringify.js
|
|
841
|
+
var byteToHex = [];
|
|
842
|
+
for (let i = 0; i < 256; ++i) {
|
|
843
|
+
byteToHex.push((i + 256).toString(16).slice(1));
|
|
844
|
+
}
|
|
845
|
+
function unsafeStringify(arr, offset = 0) {
|
|
846
|
+
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
847
|
+
}
|
|
848
|
+
__name(unsafeStringify, "unsafeStringify");
|
|
849
|
+
|
|
850
|
+
// ../../node_modules/uuid/dist/esm/rng.js
|
|
851
|
+
import { randomFillSync } from "crypto";
|
|
777
852
|
var rnds8Pool = new Uint8Array(256);
|
|
778
853
|
var poolPtr = rnds8Pool.length;
|
|
779
854
|
function rng() {
|
|
780
855
|
if (poolPtr > rnds8Pool.length - 16) {
|
|
781
|
-
|
|
856
|
+
randomFillSync(rnds8Pool);
|
|
782
857
|
poolPtr = 0;
|
|
783
858
|
}
|
|
784
859
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
785
860
|
}
|
|
786
861
|
__name(rng, "rng");
|
|
787
862
|
|
|
788
|
-
// ../../node_modules/uuid/dist/esm
|
|
789
|
-
|
|
790
|
-
for (let i = 0; i < 256; ++i) {
|
|
791
|
-
byteToHex.push((i + 256).toString(16).slice(1));
|
|
792
|
-
}
|
|
793
|
-
function unsafeStringify(arr, offset = 0) {
|
|
794
|
-
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
|
795
|
-
}
|
|
796
|
-
__name(unsafeStringify, "unsafeStringify");
|
|
797
|
-
|
|
798
|
-
// ../../node_modules/uuid/dist/esm-node/native.js
|
|
799
|
-
import crypto2 from "crypto";
|
|
863
|
+
// ../../node_modules/uuid/dist/esm/native.js
|
|
864
|
+
import { randomUUID } from "crypto";
|
|
800
865
|
var native_default = {
|
|
801
|
-
randomUUID
|
|
866
|
+
randomUUID
|
|
802
867
|
};
|
|
803
868
|
|
|
804
|
-
// ../../node_modules/uuid/dist/esm
|
|
869
|
+
// ../../node_modules/uuid/dist/esm/v4.js
|
|
805
870
|
function v4(options, buf, offset) {
|
|
871
|
+
var _a, _b, _c;
|
|
806
872
|
if (native_default.randomUUID && !buf && !options) {
|
|
807
873
|
return native_default.randomUUID();
|
|
808
874
|
}
|
|
809
875
|
options = options || {};
|
|
810
|
-
const rnds = options.random
|
|
876
|
+
const rnds = (_c = (_b = options.random) != null ? _b : (_a = options.rng) == null ? void 0 : _a.call(options)) != null ? _c : rng();
|
|
877
|
+
if (rnds.length < 16) {
|
|
878
|
+
throw new Error("Random bytes length must be >= 16");
|
|
879
|
+
}
|
|
811
880
|
rnds[6] = rnds[6] & 15 | 64;
|
|
812
881
|
rnds[8] = rnds[8] & 63 | 128;
|
|
813
882
|
if (buf) {
|
|
814
883
|
offset = offset || 0;
|
|
884
|
+
if (offset < 0 || offset + 16 > buf.length) {
|
|
885
|
+
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
886
|
+
}
|
|
815
887
|
for (let i = 0; i < 16; ++i) {
|
|
816
888
|
buf[offset + i] = rnds[i];
|
|
817
889
|
}
|
|
@@ -1275,6 +1347,57 @@ Subcategory = _ts_decorate8([
|
|
|
1275
1347
|
Entity5()
|
|
1276
1348
|
], Subcategory);
|
|
1277
1349
|
|
|
1350
|
+
// src/common/typeguards/decimal.ts
|
|
1351
|
+
function toDecimal(num, precision = 9, scale = 2) {
|
|
1352
|
+
const limit = Math.pow(10, precision - scale);
|
|
1353
|
+
if (Math.abs(num) >= limit) {
|
|
1354
|
+
throw new Error(`Value ${num} exceeds the allowed precision of ${precision} and scale of ${scale}.`);
|
|
1355
|
+
}
|
|
1356
|
+
return num.toFixed(scale);
|
|
1357
|
+
}
|
|
1358
|
+
__name(toDecimal, "toDecimal");
|
|
1359
|
+
function isDecimal(v, options) {
|
|
1360
|
+
var _a, _b, _c;
|
|
1361
|
+
const type = typeof v;
|
|
1362
|
+
if ((options == null ? void 0 : options.allowedType) !== void 0 && type !== options.allowedType) {
|
|
1363
|
+
return false;
|
|
1364
|
+
}
|
|
1365
|
+
if (type !== "number" && type !== "string") {
|
|
1366
|
+
return false;
|
|
1367
|
+
}
|
|
1368
|
+
const sep = (_a = options == null ? void 0 : options.decimalPoint) != null ? _a : ".";
|
|
1369
|
+
let intPart;
|
|
1370
|
+
let fracPart;
|
|
1371
|
+
if (type === "number") {
|
|
1372
|
+
const n = v;
|
|
1373
|
+
if (!Number.isFinite(n)) {
|
|
1374
|
+
return false;
|
|
1375
|
+
}
|
|
1376
|
+
const str = n.toString();
|
|
1377
|
+
if (str.includes("e") || str.includes("E")) {
|
|
1378
|
+
return false;
|
|
1379
|
+
}
|
|
1380
|
+
const parts = str.replace("-", "").split(".");
|
|
1381
|
+
intPart = parts[0];
|
|
1382
|
+
fracPart = (_b = parts[1]) != null ? _b : "";
|
|
1383
|
+
} else {
|
|
1384
|
+
const s = v;
|
|
1385
|
+
const escapedSep = sep === "." ? "\\." : ",";
|
|
1386
|
+
const pattern = new RegExp(`^-?\\d+(?:${escapedSep}\\d+)?$`);
|
|
1387
|
+
if (!pattern.test(s)) {
|
|
1388
|
+
return false;
|
|
1389
|
+
}
|
|
1390
|
+
const parts = s.replace("-", "").split(sep);
|
|
1391
|
+
intPart = parts[0];
|
|
1392
|
+
fracPart = (_c = parts[1]) != null ? _c : "";
|
|
1393
|
+
}
|
|
1394
|
+
if ((options == null ? void 0 : options.scale) !== void 0 && fracPart.length > options.scale) {
|
|
1395
|
+
return false;
|
|
1396
|
+
}
|
|
1397
|
+
return (options == null ? void 0 : options.precision) === void 0 || intPart.length + fracPart.length <= options.precision;
|
|
1398
|
+
}
|
|
1399
|
+
__name(isDecimal, "isDecimal");
|
|
1400
|
+
|
|
1278
1401
|
// src/common/typeguards/enums.ts
|
|
1279
1402
|
function isEnumValue(enumObj, v) {
|
|
1280
1403
|
if (!enumObj) {
|
|
@@ -1324,6 +1447,40 @@ function isNumberInRange(v, min, max, options) {
|
|
|
1324
1447
|
return true;
|
|
1325
1448
|
}
|
|
1326
1449
|
__name(isNumberInRange, "isNumberInRange");
|
|
1450
|
+
var TO_BINARY_FLAG = /* @__PURE__ */ __name((v) => v === 1 || v === true ? 1 : 0, "TO_BINARY_FLAG");
|
|
1451
|
+
|
|
1452
|
+
// src/common/utils/async.utils.ts
|
|
1453
|
+
async function runWithConcurrency(items, concurrency, worker) {
|
|
1454
|
+
const queue = [
|
|
1455
|
+
...items
|
|
1456
|
+
];
|
|
1457
|
+
const runNext = /* @__PURE__ */ __name(async () => {
|
|
1458
|
+
const item = queue.shift();
|
|
1459
|
+
if (!item) {
|
|
1460
|
+
return;
|
|
1461
|
+
}
|
|
1462
|
+
await worker(item);
|
|
1463
|
+
await runNext();
|
|
1464
|
+
}, "runNext");
|
|
1465
|
+
await Promise.all(Array.from({
|
|
1466
|
+
length: Math.min(concurrency, items.length)
|
|
1467
|
+
}, runNext));
|
|
1468
|
+
}
|
|
1469
|
+
__name(runWithConcurrency, "runWithConcurrency");
|
|
1470
|
+
|
|
1471
|
+
// src/common/utils/patch.utils.ts
|
|
1472
|
+
function buildPatch(data, keys, transforms) {
|
|
1473
|
+
const patch = {};
|
|
1474
|
+
for (const k of keys) {
|
|
1475
|
+
const value = data[k];
|
|
1476
|
+
if (value === void 0) {
|
|
1477
|
+
continue;
|
|
1478
|
+
}
|
|
1479
|
+
patch[k] = (transforms == null ? void 0 : transforms[k]) ? transforms[k](value) : value;
|
|
1480
|
+
}
|
|
1481
|
+
return patch;
|
|
1482
|
+
}
|
|
1483
|
+
__name(buildPatch, "buildPatch");
|
|
1327
1484
|
|
|
1328
1485
|
// src/core/data-helper.ts
|
|
1329
1486
|
var _DataHelper = class _DataHelper {
|
|
@@ -1498,6 +1655,18 @@ var _ApiError = class _ApiError extends Error {
|
|
|
1498
1655
|
__name(_ApiError, "ApiError");
|
|
1499
1656
|
var ApiError = _ApiError;
|
|
1500
1657
|
|
|
1658
|
+
// src/core/errors/business-warning.ts
|
|
1659
|
+
var _BusinessWarning = class _BusinessWarning extends Error {
|
|
1660
|
+
constructor(code, message) {
|
|
1661
|
+
super(message);
|
|
1662
|
+
__publicField(this, "code");
|
|
1663
|
+
this.code = code;
|
|
1664
|
+
this.name = "BusinessWarning";
|
|
1665
|
+
}
|
|
1666
|
+
};
|
|
1667
|
+
__name(_BusinessWarning, "BusinessWarning");
|
|
1668
|
+
var BusinessWarning = _BusinessWarning;
|
|
1669
|
+
|
|
1501
1670
|
// src/types/maybe-type.ts
|
|
1502
1671
|
function isMaybe(v, inner) {
|
|
1503
1672
|
return v === null || inner(v);
|
|
@@ -1691,7 +1860,9 @@ export {
|
|
|
1691
1860
|
ActionCommandCode,
|
|
1692
1861
|
ApiError,
|
|
1693
1862
|
BaseEntityChangeSubscriber,
|
|
1863
|
+
BusinessWarning,
|
|
1694
1864
|
Category,
|
|
1865
|
+
DEFAULT_PAGINATION_PARAMS,
|
|
1695
1866
|
DataHelper,
|
|
1696
1867
|
DateUtils,
|
|
1697
1868
|
DepotPoolStatus,
|
|
@@ -1711,11 +1882,17 @@ export {
|
|
|
1711
1882
|
Singleton,
|
|
1712
1883
|
StatusDto,
|
|
1713
1884
|
Subcategory,
|
|
1885
|
+
TO_BINARY_FLAG,
|
|
1714
1886
|
TimestampColumn,
|
|
1715
1887
|
TransactionType,
|
|
1888
|
+
buildPatch,
|
|
1889
|
+
constructTypeormPagination,
|
|
1716
1890
|
createDeferred,
|
|
1717
1891
|
eslint_config_default as freshEslintConfig,
|
|
1892
|
+
getPaginationMeta,
|
|
1893
|
+
getPaginationParams,
|
|
1718
1894
|
hasOwn,
|
|
1895
|
+
isDecimal,
|
|
1719
1896
|
isEnumValue,
|
|
1720
1897
|
isFlag01,
|
|
1721
1898
|
isMaybe,
|
|
@@ -1723,6 +1900,10 @@ export {
|
|
|
1723
1900
|
isNumberInRange,
|
|
1724
1901
|
isObject,
|
|
1725
1902
|
isString,
|
|
1726
|
-
isValidCron
|
|
1903
|
+
isValidCron,
|
|
1904
|
+
listAll,
|
|
1905
|
+
parsePaginationFromURL,
|
|
1906
|
+
runWithConcurrency,
|
|
1907
|
+
toDecimal
|
|
1727
1908
|
};
|
|
1728
1909
|
//# sourceMappingURL=index.mjs.map
|