@freshpointcz/fresh-core 0.0.17 → 0.0.18

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.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 crypto3 = __require("crypto");
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 = crypto3.createDecipheriv("aes-256-gcm", key, nonce);
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) {
@@ -772,46 +772,53 @@ import { Entity } from "typeorm";
772
772
  // src/database/entities/fresh-entity.ts
773
773
  import { BaseEntity, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index, Column } from "typeorm";
774
774
 
775
- // ../../node_modules/uuid/dist/esm-node/rng.js
776
- import crypto from "crypto";
775
+ // ../../node_modules/uuid/dist/esm/stringify.js
776
+ var byteToHex = [];
777
+ for (let i = 0; i < 256; ++i) {
778
+ byteToHex.push((i + 256).toString(16).slice(1));
779
+ }
780
+ function unsafeStringify(arr, offset = 0) {
781
+ 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();
782
+ }
783
+ __name(unsafeStringify, "unsafeStringify");
784
+
785
+ // ../../node_modules/uuid/dist/esm/rng.js
786
+ import { randomFillSync } from "crypto";
777
787
  var rnds8Pool = new Uint8Array(256);
778
788
  var poolPtr = rnds8Pool.length;
779
789
  function rng() {
780
790
  if (poolPtr > rnds8Pool.length - 16) {
781
- crypto.randomFillSync(rnds8Pool);
791
+ randomFillSync(rnds8Pool);
782
792
  poolPtr = 0;
783
793
  }
784
794
  return rnds8Pool.slice(poolPtr, poolPtr += 16);
785
795
  }
786
796
  __name(rng, "rng");
787
797
 
788
- // ../../node_modules/uuid/dist/esm-node/stringify.js
789
- var byteToHex = [];
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";
798
+ // ../../node_modules/uuid/dist/esm/native.js
799
+ import { randomUUID } from "crypto";
800
800
  var native_default = {
801
- randomUUID: crypto2.randomUUID
801
+ randomUUID
802
802
  };
803
803
 
804
- // ../../node_modules/uuid/dist/esm-node/v4.js
804
+ // ../../node_modules/uuid/dist/esm/v4.js
805
805
  function v4(options, buf, offset) {
806
+ var _a, _b, _c;
806
807
  if (native_default.randomUUID && !buf && !options) {
807
808
  return native_default.randomUUID();
808
809
  }
809
810
  options = options || {};
810
- const rnds = options.random || (options.rng || rng)();
811
+ const rnds = (_c = (_b = options.random) != null ? _b : (_a = options.rng) == null ? void 0 : _a.call(options)) != null ? _c : rng();
812
+ if (rnds.length < 16) {
813
+ throw new Error("Random bytes length must be >= 16");
814
+ }
811
815
  rnds[6] = rnds[6] & 15 | 64;
812
816
  rnds[8] = rnds[8] & 63 | 128;
813
817
  if (buf) {
814
818
  offset = offset || 0;
819
+ if (offset < 0 || offset + 16 > buf.length) {
820
+ throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
821
+ }
815
822
  for (let i = 0; i < 16; ++i) {
816
823
  buf[offset + i] = rnds[i];
817
824
  }
@@ -1324,6 +1331,40 @@ function isNumberInRange(v, min, max, options) {
1324
1331
  return true;
1325
1332
  }
1326
1333
  __name(isNumberInRange, "isNumberInRange");
1334
+ var TO_BINARY_FLAG = /* @__PURE__ */ __name((v) => v === 1 || v === true ? 1 : 0, "TO_BINARY_FLAG");
1335
+
1336
+ // src/common/utils/async.utils.ts
1337
+ async function runWithConcurrency(items, concurrency, worker) {
1338
+ const queue = [
1339
+ ...items
1340
+ ];
1341
+ const runNext = /* @__PURE__ */ __name(async () => {
1342
+ const item = queue.shift();
1343
+ if (!item) {
1344
+ return;
1345
+ }
1346
+ await worker(item);
1347
+ await runNext();
1348
+ }, "runNext");
1349
+ await Promise.all(Array.from({
1350
+ length: Math.min(concurrency, items.length)
1351
+ }, runNext));
1352
+ }
1353
+ __name(runWithConcurrency, "runWithConcurrency");
1354
+
1355
+ // src/common/utils/patch.utils.ts
1356
+ function buildPatch(data, keys, transforms) {
1357
+ const patch = {};
1358
+ for (const k of keys) {
1359
+ const value = data[k];
1360
+ if (value === void 0) {
1361
+ continue;
1362
+ }
1363
+ patch[k] = (transforms == null ? void 0 : transforms[k]) ? transforms[k](value) : value;
1364
+ }
1365
+ return patch;
1366
+ }
1367
+ __name(buildPatch, "buildPatch");
1327
1368
 
1328
1369
  // src/core/data-helper.ts
1329
1370
  var _DataHelper = class _DataHelper {
@@ -1498,6 +1539,18 @@ var _ApiError = class _ApiError extends Error {
1498
1539
  __name(_ApiError, "ApiError");
1499
1540
  var ApiError = _ApiError;
1500
1541
 
1542
+ // src/core/errors/business-warning.ts
1543
+ var _BusinessWarning = class _BusinessWarning extends Error {
1544
+ constructor(code, message) {
1545
+ super(message);
1546
+ __publicField(this, "code");
1547
+ this.code = code;
1548
+ this.name = "BusinessWarning";
1549
+ }
1550
+ };
1551
+ __name(_BusinessWarning, "BusinessWarning");
1552
+ var BusinessWarning = _BusinessWarning;
1553
+
1501
1554
  // src/types/maybe-type.ts
1502
1555
  function isMaybe(v, inner) {
1503
1556
  return v === null || inner(v);
@@ -1691,6 +1744,7 @@ export {
1691
1744
  ActionCommandCode,
1692
1745
  ApiError,
1693
1746
  BaseEntityChangeSubscriber,
1747
+ BusinessWarning,
1694
1748
  Category,
1695
1749
  DataHelper,
1696
1750
  DateUtils,
@@ -1711,8 +1765,10 @@ export {
1711
1765
  Singleton,
1712
1766
  StatusDto,
1713
1767
  Subcategory,
1768
+ TO_BINARY_FLAG,
1714
1769
  TimestampColumn,
1715
1770
  TransactionType,
1771
+ buildPatch,
1716
1772
  createDeferred,
1717
1773
  eslint_config_default as freshEslintConfig,
1718
1774
  hasOwn,
@@ -1723,6 +1779,7 @@ export {
1723
1779
  isNumberInRange,
1724
1780
  isObject,
1725
1781
  isString,
1726
- isValidCron
1782
+ isValidCron,
1783
+ runWithConcurrency
1727
1784
  };
1728
1785
  //# sourceMappingURL=index.mjs.map