@open-norantec/utilities 2.1.1 → 2.1.3

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.
@@ -1,50 +1,47 @@
1
- import { UUIDUtil } from './uuid-util.class';
2
- var StringUtil = (function () {
3
- function StringUtil() {
4
- }
5
- StringUtil.isFalsyString = function (value, connector) {
6
- if (connector === void 0) { connector = 'AND'; }
7
- var stringList = Array.isArray(value) ? value : [value];
8
- var checkResultList = stringList.map(function (stringValue) { return typeof stringValue === 'string' && stringValue.length > 0; });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StringUtil = void 0;
4
+ const uuid_util_class_1 = require("./uuid-util.class");
5
+ class StringUtil {
6
+ static isFalsyString(value, connector = 'AND') {
7
+ const stringList = Array.isArray(value) ? value : [value];
8
+ const checkResultList = stringList.map((stringValue) => typeof stringValue === 'string' && stringValue.length > 0);
9
9
  if (connector === 'AND') {
10
- return checkResultList.some(function (result) { return !result; });
10
+ return checkResultList.some((result) => !result);
11
11
  }
12
12
  if (connector === 'OR') {
13
- return checkResultList.every(function (result) { return !result; });
13
+ return checkResultList.every((result) => !result);
14
14
  }
15
15
  return true;
16
- };
17
- StringUtil.generateRandomText = function (length, extraCharacters) {
18
- if (length === void 0) { length = 32; }
19
- if (extraCharacters === void 0) { extraCharacters = ''; }
20
- var seed = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.concat(extraCharacters);
21
- var result = '';
16
+ }
17
+ static generateRandomText(length = 32, extraCharacters = '') {
18
+ const seed = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.concat(extraCharacters);
19
+ let result = '';
22
20
  while (result.length < length) {
23
21
  result += seed.charAt(Math.floor(Math.random() * seed.length));
24
22
  }
25
23
  return result;
26
- };
27
- StringUtil.generateTempId = function () {
28
- var tempIds = [];
24
+ }
25
+ static generateTempId() {
26
+ const tempIds = [];
29
27
  while (true) {
30
- var currentTempId = UUIDUtil.generateV4();
28
+ const currentTempId = uuid_util_class_1.UUIDUtil.generateV4();
31
29
  if (tempIds.indexOf(currentTempId) === -1) {
32
30
  tempIds.push(currentTempId);
33
- return "temp$:".concat(currentTempId);
31
+ return `temp$:${currentTempId}`;
34
32
  }
35
33
  }
36
- };
37
- StringUtil.extractTempId = function (idOrTempId) {
34
+ }
35
+ static extractTempId(idOrTempId) {
38
36
  var _a;
39
37
  if (!idOrTempId) {
40
38
  return null;
41
39
  }
42
- var regex = /^temp\$:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
40
+ const regex = /^temp\$:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
43
41
  if (!regex.test(idOrTempId)) {
44
42
  return;
45
43
  }
46
44
  return ((_a = /^temp\$:(.*)$/g.exec(idOrTempId)) === null || _a === void 0 ? void 0 : _a[1]) || null;
47
- };
48
- return StringUtil;
49
- }());
50
- export { StringUtil };
45
+ }
46
+ }
47
+ exports.StringUtil = StringUtil;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -7,92 +8,35 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
9
  });
9
10
  };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- var __read = (this && this.__read) || function (o, n) {
38
- var m = typeof Symbol === "function" && o[Symbol.iterator];
39
- if (!m) return o;
40
- var i = m.call(o), r, ar = [], e;
41
- try {
42
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
43
- }
44
- catch (error) { e = { error: error }; }
45
- finally {
46
- try {
47
- if (r && !r.done && (m = i["return"])) m.call(i);
48
- }
49
- finally { if (e) throw e.error; }
50
- }
51
- return ar;
52
- };
53
- import { CryptoUtil } from './crypto-util.class';
54
- var UrlUtil = (function () {
55
- function UrlUtil() {
56
- }
57
- UrlUtil.normalize = function (urlString) {
58
- var url = new URL(urlString);
59
- var searchParams = new URLSearchParams(url.search);
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.UrlUtil = void 0;
13
+ const crypto_util_class_1 = require("./crypto-util.class");
14
+ class UrlUtil {
15
+ static normalize(urlString) {
16
+ const url = new URL(urlString);
17
+ const searchParams = new URLSearchParams(url.search);
60
18
  url.search = '';
61
- var newSearchParams = new URLSearchParams();
62
- var searchParamsEntries = Array.from(searchParams.entries());
63
- var newSearchParamsEntries = searchParamsEntries
64
- .map(function (_a) {
65
- var _b = __read(_a, 1), key = _b[0];
66
- return key;
67
- })
68
- .sort(function (a, b) { return a.localeCompare(b); })
69
- .map(function (key) { return [key, []]; });
70
- searchParamsEntries.forEach(function (_a) {
71
- var _b = __read(_a, 2), key = _b[0], value = _b[1];
72
- newSearchParamsEntries.find(function (_a) {
73
- var _b = __read(_a, 1), k = _b[0];
74
- return k === key;
75
- })[1].push(value);
19
+ const newSearchParams = new URLSearchParams();
20
+ const searchParamsEntries = Array.from(searchParams.entries());
21
+ const newSearchParamsEntries = searchParamsEntries
22
+ .map(([key]) => key)
23
+ .sort((a, b) => a.localeCompare(b))
24
+ .map((key) => [key, []]);
25
+ searchParamsEntries.forEach(([key, value]) => {
26
+ newSearchParamsEntries.find(([k]) => k === key)[1].push(value);
76
27
  });
77
- newSearchParamsEntries.forEach(function (_a) {
78
- var _b = __read(_a, 2), key = _b[0], values = _b[1];
79
- values.forEach(function (value) {
28
+ newSearchParamsEntries.forEach(([key, values]) => {
29
+ values.forEach((value) => {
80
30
  newSearchParams.append(key, value);
81
31
  });
82
32
  });
83
33
  url.search = newSearchParams.toString();
84
34
  return url.toString();
85
- };
86
- UrlUtil.hash = function (urlString) {
87
- return __awaiter(this, void 0, void 0, function () {
88
- return __generator(this, function (_a) {
89
- switch (_a.label) {
90
- case 0: return [4, CryptoUtil.sha256Hex(UrlUtil.normalize(urlString))];
91
- case 1: return [2, _a.sent()];
92
- }
93
- });
35
+ }
36
+ static hash(urlString) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ return yield crypto_util_class_1.CryptoUtil.sha256Hex(UrlUtil.normalize(urlString));
94
39
  });
95
- };
96
- return UrlUtil;
97
- }());
98
- export { UrlUtil };
40
+ }
41
+ }
42
+ exports.UrlUtil = UrlUtil;
@@ -1,8 +1,9 @@
1
- var UserAgentUtil = (function () {
2
- function UserAgentUtil() {
3
- }
4
- UserAgentUtil.generateRandomUa = function () {
5
- var userAgents = [
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserAgentUtil = void 0;
4
+ class UserAgentUtil {
5
+ static generateRandomUa() {
6
+ const userAgents = [
6
7
  'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.12) Gecko/20070731 Ubuntu/dapper-security Firefox/1.5.0.12',
7
8
  'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Acoo Browser; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506)',
8
9
  'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
@@ -23,9 +24,8 @@ var UserAgentUtil = (function () {
23
24
  'Opera/9.25 (Windows NT 5.1; U; en), Lynx/2.8.5rel.1 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/1.2.9',
24
25
  'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36',
25
26
  ];
26
- var userAgent = userAgents[Math.random() * userAgents.length];
27
+ const userAgent = userAgents[Math.random() * userAgents.length];
27
28
  return userAgent;
28
- };
29
- return UserAgentUtil;
30
- }());
31
- export { UserAgentUtil };
29
+ }
30
+ }
31
+ exports.UserAgentUtil = UserAgentUtil;
@@ -1,7 +1,8 @@
1
- var UUIDUtil = (function () {
2
- function UUIDUtil() {
3
- }
4
- UUIDUtil.generateV4 = function () {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UUIDUtil = void 0;
4
+ class UUIDUtil {
5
+ static generateV4() {
5
6
  var _a, _b;
6
7
  if (typeof window !== 'undefined' && typeof ((_a = window.crypto) === null || _a === void 0 ? void 0 : _a.randomUUID) === 'function') {
7
8
  try {
@@ -15,18 +16,17 @@ var UUIDUtil = (function () {
15
16
  }
16
17
  catch (e) { }
17
18
  }
18
- var hex = [];
19
- var bytes = new Uint8Array(16);
20
- for (var i = 0; i < 16; i++) {
19
+ const hex = [];
20
+ const bytes = new Uint8Array(16);
21
+ for (let i = 0; i < 16; i++) {
21
22
  bytes[i] = Math.floor(Math.random() * 256);
22
23
  }
23
24
  bytes[6] = (bytes[6] & 0x0f) | 0x40;
24
25
  bytes[8] = (bytes[8] & 0x3f) | 0x80;
25
- for (var i = 0; i < 16; i++) {
26
+ for (let i = 0; i < 16; i++) {
26
27
  hex.push(bytes[i].toString(16).padStart(2, '0'));
27
28
  }
28
- return "".concat(hex[0]).concat(hex[1]).concat(hex[2]).concat(hex[3], "-").concat(hex[4]).concat(hex[5], "-").concat(hex[6]).concat(hex[7], "-").concat(hex[8]).concat(hex[9], "-").concat(hex[10]).concat(hex[11]).concat(hex[12]).concat(hex[13]).concat(hex[14]).concat(hex[15]);
29
- };
30
- return UUIDUtil;
31
- }());
32
- export { UUIDUtil };
29
+ return `${hex[0]}${hex[1]}${hex[2]}${hex[3]}-${hex[4]}${hex[5]}-${hex[6]}${hex[7]}-${hex[8]}${hex[9]}-${hex[10]}${hex[11]}${hex[12]}${hex[13]}${hex[14]}${hex[15]}`;
30
+ }
31
+ }
32
+ exports.UUIDUtil = UUIDUtil;
@@ -1,21 +1,48 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- import * as vm from 'node:vm';
13
- var VMUtil = (function () {
14
- function VMUtil() {
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
15
7
  }
16
- VMUtil.runScriptCode = function (code, overrideContext) {
17
- new vm.Script(code).runInContext(vm.createContext(__assign(__assign(__assign({}, global), { __dirname: __dirname, __filename: __filename, process: process, module: module, exports: exports, require: require }), overrideContext)));
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
18
33
  };
19
- return VMUtil;
20
- }());
21
- export { VMUtil };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.VMUtil = void 0;
37
+ const vm = __importStar(require("node:vm"));
38
+ class VMUtil {
39
+ static runScriptCode(code, overrideContext) {
40
+ new vm.Script(code).runInContext(vm.createContext(Object.assign(Object.assign(Object.assign({}, global), { __dirname,
41
+ __filename,
42
+ process,
43
+ module,
44
+ exports,
45
+ require }), overrideContext)));
46
+ }
47
+ }
48
+ exports.VMUtil = VMUtil;
package/dist/zod.js CHANGED
@@ -1 +1,17 @@
1
- export * from 'zod';
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("zod"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-norantec/utilities",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "NoranTec Utilities",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {