@freshpointcz/fresh-core 0.0.14 → 0.0.16
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 +96 -5
- package/dist/index.d.ts +96 -5
- package/dist/index.js +97 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +89 -28
- 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 crypto3 = __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 = crypto3.createDecipheriv("aes-256-gcm", key, nonce);
|
|
359
359
|
aesgcm.setAuthTag(authTag);
|
|
360
360
|
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
361
361
|
} catch (error) {
|
|
@@ -822,53 +822,46 @@ import { Entity } from "typeorm";
|
|
|
822
822
|
// src/database/entities/fresh-entity.ts
|
|
823
823
|
import { BaseEntity, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index, Column } from "typeorm";
|
|
824
824
|
|
|
825
|
-
// ../../node_modules/uuid/dist/esm/
|
|
826
|
-
|
|
827
|
-
for (let i = 0; i < 256; ++i) {
|
|
828
|
-
byteToHex.push((i + 256).toString(16).slice(1));
|
|
829
|
-
}
|
|
830
|
-
function unsafeStringify(arr, offset = 0) {
|
|
831
|
-
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();
|
|
832
|
-
}
|
|
833
|
-
__name(unsafeStringify, "unsafeStringify");
|
|
834
|
-
|
|
835
|
-
// ../../node_modules/uuid/dist/esm/rng.js
|
|
836
|
-
import { randomFillSync } from "crypto";
|
|
825
|
+
// ../../node_modules/uuid/dist/esm-node/rng.js
|
|
826
|
+
import crypto from "crypto";
|
|
837
827
|
var rnds8Pool = new Uint8Array(256);
|
|
838
828
|
var poolPtr = rnds8Pool.length;
|
|
839
829
|
function rng() {
|
|
840
830
|
if (poolPtr > rnds8Pool.length - 16) {
|
|
841
|
-
randomFillSync(rnds8Pool);
|
|
831
|
+
crypto.randomFillSync(rnds8Pool);
|
|
842
832
|
poolPtr = 0;
|
|
843
833
|
}
|
|
844
834
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
845
835
|
}
|
|
846
836
|
__name(rng, "rng");
|
|
847
837
|
|
|
848
|
-
// ../../node_modules/uuid/dist/esm/
|
|
849
|
-
|
|
838
|
+
// ../../node_modules/uuid/dist/esm-node/stringify.js
|
|
839
|
+
var byteToHex = [];
|
|
840
|
+
for (let i = 0; i < 256; ++i) {
|
|
841
|
+
byteToHex.push((i + 256).toString(16).slice(1));
|
|
842
|
+
}
|
|
843
|
+
function unsafeStringify(arr, offset = 0) {
|
|
844
|
+
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]];
|
|
845
|
+
}
|
|
846
|
+
__name(unsafeStringify, "unsafeStringify");
|
|
847
|
+
|
|
848
|
+
// ../../node_modules/uuid/dist/esm-node/native.js
|
|
849
|
+
import crypto2 from "crypto";
|
|
850
850
|
var native_default = {
|
|
851
|
-
randomUUID
|
|
851
|
+
randomUUID: crypto2.randomUUID
|
|
852
852
|
};
|
|
853
853
|
|
|
854
|
-
// ../../node_modules/uuid/dist/esm/v4.js
|
|
854
|
+
// ../../node_modules/uuid/dist/esm-node/v4.js
|
|
855
855
|
function v4(options, buf, offset) {
|
|
856
|
-
var _a, _b, _c;
|
|
857
856
|
if (native_default.randomUUID && !buf && !options) {
|
|
858
857
|
return native_default.randomUUID();
|
|
859
858
|
}
|
|
860
859
|
options = options || {};
|
|
861
|
-
const rnds =
|
|
862
|
-
if (rnds.length < 16) {
|
|
863
|
-
throw new Error("Random bytes length must be >= 16");
|
|
864
|
-
}
|
|
860
|
+
const rnds = options.random || (options.rng || rng)();
|
|
865
861
|
rnds[6] = rnds[6] & 15 | 64;
|
|
866
862
|
rnds[8] = rnds[8] & 63 | 128;
|
|
867
863
|
if (buf) {
|
|
868
864
|
offset = offset || 0;
|
|
869
|
-
if (offset < 0 || offset + 16 > buf.length) {
|
|
870
|
-
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
871
|
-
}
|
|
872
865
|
for (let i = 0; i < 16; ++i) {
|
|
873
866
|
buf[offset + i] = rnds[i];
|
|
874
867
|
}
|
|
@@ -921,7 +914,7 @@ _ts_decorate([
|
|
|
921
914
|
}),
|
|
922
915
|
Column({
|
|
923
916
|
type: "uuid",
|
|
924
|
-
default: /* @__PURE__ */ __name(() => "
|
|
917
|
+
default: /* @__PURE__ */ __name(() => "gen_random_uuid()", "default")
|
|
925
918
|
}),
|
|
926
919
|
_ts_metadata("design:type", String)
|
|
927
920
|
], FreshEntity.prototype, "uuid", void 0);
|
|
@@ -1105,6 +1098,7 @@ var PaymentMethod = /* @__PURE__ */ (function(PaymentMethod2) {
|
|
|
1105
1098
|
PaymentMethod2[PaymentMethod2["CODE"] = 0] = "CODE";
|
|
1106
1099
|
PaymentMethod2[PaymentMethod2["CARD"] = 1] = "CARD";
|
|
1107
1100
|
PaymentMethod2[PaymentMethod2["NONE"] = 2] = "NONE";
|
|
1101
|
+
PaymentMethod2[PaymentMethod2["CREDIT"] = 3] = "CREDIT";
|
|
1108
1102
|
return PaymentMethod2;
|
|
1109
1103
|
})({});
|
|
1110
1104
|
|
|
@@ -1163,6 +1157,9 @@ _ts_decorate3([
|
|
|
1163
1157
|
|
|
1164
1158
|
// src/database/dao/fresh-dao.ts
|
|
1165
1159
|
var _FreshDao = class _FreshDao {
|
|
1160
|
+
getRepo(manager, entity = this.entity) {
|
|
1161
|
+
return manager ? manager.getRepository(entity) : this.repo;
|
|
1162
|
+
}
|
|
1166
1163
|
};
|
|
1167
1164
|
__name(_FreshDao, "FreshDao");
|
|
1168
1165
|
var FreshDao = _FreshDao;
|
|
@@ -1251,6 +1248,56 @@ Subcategory = _ts_decorate8([
|
|
|
1251
1248
|
Entity5()
|
|
1252
1249
|
], Subcategory);
|
|
1253
1250
|
|
|
1251
|
+
// src/common/typeguards/enums.ts
|
|
1252
|
+
function isEnumValue(enumObj, v) {
|
|
1253
|
+
if (!enumObj) {
|
|
1254
|
+
return typeof v === "string" || typeof v === "number";
|
|
1255
|
+
}
|
|
1256
|
+
const values = new Set(Object.values(enumObj));
|
|
1257
|
+
return (typeof v === "string" || typeof v === "number") && values.has(v);
|
|
1258
|
+
}
|
|
1259
|
+
__name(isEnumValue, "isEnumValue");
|
|
1260
|
+
|
|
1261
|
+
// src/common/typeguards/objects.ts
|
|
1262
|
+
function isObject(v) {
|
|
1263
|
+
return typeof v === "object" && v !== null;
|
|
1264
|
+
}
|
|
1265
|
+
__name(isObject, "isObject");
|
|
1266
|
+
function hasOwn(obj, key) {
|
|
1267
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
1268
|
+
}
|
|
1269
|
+
__name(hasOwn, "hasOwn");
|
|
1270
|
+
|
|
1271
|
+
// src/common/typeguards/primitives.ts
|
|
1272
|
+
function isNumber(v) {
|
|
1273
|
+
return typeof v === "number" && Number.isFinite(v);
|
|
1274
|
+
}
|
|
1275
|
+
__name(isNumber, "isNumber");
|
|
1276
|
+
function isString(v) {
|
|
1277
|
+
return typeof v === "string";
|
|
1278
|
+
}
|
|
1279
|
+
__name(isString, "isString");
|
|
1280
|
+
function isFlag01(v) {
|
|
1281
|
+
return v === 0 || v === 1;
|
|
1282
|
+
}
|
|
1283
|
+
__name(isFlag01, "isFlag01");
|
|
1284
|
+
function isNumberInRange(v, min, max, options) {
|
|
1285
|
+
var _a, _b;
|
|
1286
|
+
if (!isNumber(v)) {
|
|
1287
|
+
return false;
|
|
1288
|
+
}
|
|
1289
|
+
const includeMin = (_a = options == null ? void 0 : options.includeMin) != null ? _a : true;
|
|
1290
|
+
const includeMax = (_b = options == null ? void 0 : options.includeMax) != null ? _b : true;
|
|
1291
|
+
if (includeMin ? v < min : v <= min) {
|
|
1292
|
+
return false;
|
|
1293
|
+
}
|
|
1294
|
+
if (includeMax ? v > max : v >= max) {
|
|
1295
|
+
return false;
|
|
1296
|
+
}
|
|
1297
|
+
return true;
|
|
1298
|
+
}
|
|
1299
|
+
__name(isNumberInRange, "isNumberInRange");
|
|
1300
|
+
|
|
1254
1301
|
// src/core/data-helper.ts
|
|
1255
1302
|
var _DataHelper = class _DataHelper {
|
|
1256
1303
|
constructor(startDataRetrieve = true, deviceIds) {
|
|
@@ -1424,6 +1471,12 @@ var _ApiError = class _ApiError extends Error {
|
|
|
1424
1471
|
__name(_ApiError, "ApiError");
|
|
1425
1472
|
var ApiError = _ApiError;
|
|
1426
1473
|
|
|
1474
|
+
// src/types/maybe-type.ts
|
|
1475
|
+
function isMaybe(v, inner) {
|
|
1476
|
+
return v === null || inner(v);
|
|
1477
|
+
}
|
|
1478
|
+
__name(isMaybe, "isMaybe");
|
|
1479
|
+
|
|
1427
1480
|
// src/config/eslint-config.ts
|
|
1428
1481
|
import tseslint from "typescript-eslint";
|
|
1429
1482
|
import eslintPluginPrettier from "eslint-plugin-prettier";
|
|
@@ -1634,6 +1687,14 @@ export {
|
|
|
1634
1687
|
TransactionType,
|
|
1635
1688
|
createDeferred,
|
|
1636
1689
|
eslint_config_default as freshEslintConfig,
|
|
1690
|
+
hasOwn,
|
|
1691
|
+
isEnumValue,
|
|
1692
|
+
isFlag01,
|
|
1693
|
+
isMaybe,
|
|
1694
|
+
isNumber,
|
|
1695
|
+
isNumberInRange,
|
|
1696
|
+
isObject,
|
|
1697
|
+
isString,
|
|
1637
1698
|
isValidCron,
|
|
1638
1699
|
logger
|
|
1639
1700
|
};
|