@gzl10/ts-helpers 4.2.1
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/CHANGELOG.md +320 -0
- package/README.md +233 -0
- package/USAGE-GUIDE.md +800 -0
- package/dist/browser/async.js +15 -0
- package/dist/browser/async.js.map +1 -0
- package/dist/browser/chunk-4O7ZPIJN.js +383 -0
- package/dist/browser/chunk-4O7ZPIJN.js.map +1 -0
- package/dist/browser/chunk-75XNTC34.js +60 -0
- package/dist/browser/chunk-75XNTC34.js.map +1 -0
- package/dist/browser/chunk-C3D7YZVE.js +299 -0
- package/dist/browser/chunk-C3D7YZVE.js.map +1 -0
- package/dist/browser/chunk-CZL6C2EI.js +452 -0
- package/dist/browser/chunk-CZL6C2EI.js.map +1 -0
- package/dist/browser/chunk-D4FZFIVA.js +240 -0
- package/dist/browser/chunk-D4FZFIVA.js.map +1 -0
- package/dist/browser/chunk-IL7NG7IC.js +72 -0
- package/dist/browser/chunk-IL7NG7IC.js.map +1 -0
- package/dist/browser/chunk-NSBPE2FW.js +17 -0
- package/dist/browser/chunk-NSBPE2FW.js.map +1 -0
- package/dist/browser/chunk-SLQVNPTH.js +27 -0
- package/dist/browser/chunk-SLQVNPTH.js.map +1 -0
- package/dist/browser/chunk-WG7ILCUB.js +195 -0
- package/dist/browser/chunk-WG7ILCUB.js.map +1 -0
- package/dist/browser/chunk-WJA4JDMZ.js +278 -0
- package/dist/browser/chunk-WJA4JDMZ.js.map +1 -0
- package/dist/browser/chunk-ZFVYLUTT.js +65 -0
- package/dist/browser/chunk-ZFVYLUTT.js.map +1 -0
- package/dist/browser/chunk-ZYTSVMTI.js +263 -0
- package/dist/browser/chunk-ZYTSVMTI.js.map +1 -0
- package/dist/browser/dates.js +78 -0
- package/dist/browser/dates.js.map +1 -0
- package/dist/browser/environment-detection.js +21 -0
- package/dist/browser/environment-detection.js.map +1 -0
- package/dist/browser/environment.js +34 -0
- package/dist/browser/environment.js.map +1 -0
- package/dist/browser/errors.js +18 -0
- package/dist/browser/errors.js.map +1 -0
- package/dist/browser/index.js +412 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/math.js +51 -0
- package/dist/browser/math.js.map +1 -0
- package/dist/browser/number.js +10 -0
- package/dist/browser/number.js.map +1 -0
- package/dist/browser/objects.js +31 -0
- package/dist/browser/objects.js.map +1 -0
- package/dist/browser/strings.js +80 -0
- package/dist/browser/strings.js.map +1 -0
- package/dist/browser/validation-core.js +54 -0
- package/dist/browser/validation-core.js.map +1 -0
- package/dist/browser/validation-crypto.js +28 -0
- package/dist/browser/validation-crypto.js.map +1 -0
- package/dist/browser/validators.js +98 -0
- package/dist/browser/validators.js.map +1 -0
- package/dist/cjs/async.js +86 -0
- package/dist/cjs/async.js.map +1 -0
- package/dist/cjs/dates.js +285 -0
- package/dist/cjs/dates.js.map +1 -0
- package/dist/cjs/environment-detection.js +84 -0
- package/dist/cjs/environment-detection.js.map +1 -0
- package/dist/cjs/environment.js +261 -0
- package/dist/cjs/environment.js.map +1 -0
- package/dist/cjs/errors.js +80 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/index.js +2035 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/math.js +388 -0
- package/dist/cjs/math.js.map +1 -0
- package/dist/cjs/number.js +37 -0
- package/dist/cjs/number.js.map +1 -0
- package/dist/cjs/objects.js +249 -0
- package/dist/cjs/objects.js.map +1 -0
- package/dist/cjs/strings.js +253 -0
- package/dist/cjs/strings.js.map +1 -0
- package/dist/cjs/validation.js +450 -0
- package/dist/cjs/validation.js.map +1 -0
- package/dist/esm/async.js +15 -0
- package/dist/esm/async.js.map +1 -0
- package/dist/esm/chunk-4O7ZPIJN.js +383 -0
- package/dist/esm/chunk-4O7ZPIJN.js.map +1 -0
- package/dist/esm/chunk-75XNTC34.js +60 -0
- package/dist/esm/chunk-75XNTC34.js.map +1 -0
- package/dist/esm/chunk-BDOBKBKA.js +72 -0
- package/dist/esm/chunk-BDOBKBKA.js.map +1 -0
- package/dist/esm/chunk-C3D7YZVE.js +299 -0
- package/dist/esm/chunk-C3D7YZVE.js.map +1 -0
- package/dist/esm/chunk-CZL6C2EI.js +452 -0
- package/dist/esm/chunk-CZL6C2EI.js.map +1 -0
- package/dist/esm/chunk-EBLSTOEC.js +263 -0
- package/dist/esm/chunk-EBLSTOEC.js.map +1 -0
- package/dist/esm/chunk-NSBPE2FW.js +17 -0
- package/dist/esm/chunk-NSBPE2FW.js.map +1 -0
- package/dist/esm/chunk-SLQVNPTH.js +27 -0
- package/dist/esm/chunk-SLQVNPTH.js.map +1 -0
- package/dist/esm/chunk-WG7ILCUB.js +195 -0
- package/dist/esm/chunk-WG7ILCUB.js.map +1 -0
- package/dist/esm/chunk-WJA4JDMZ.js +278 -0
- package/dist/esm/chunk-WJA4JDMZ.js.map +1 -0
- package/dist/esm/chunk-ZFVYLUTT.js +65 -0
- package/dist/esm/chunk-ZFVYLUTT.js.map +1 -0
- package/dist/esm/dates.js +78 -0
- package/dist/esm/dates.js.map +1 -0
- package/dist/esm/environment-detection.js +21 -0
- package/dist/esm/environment-detection.js.map +1 -0
- package/dist/esm/environment.js +34 -0
- package/dist/esm/environment.js.map +1 -0
- package/dist/esm/errors.js +18 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/index.js +380 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/math.js +51 -0
- package/dist/esm/math.js.map +1 -0
- package/dist/esm/number.js +10 -0
- package/dist/esm/number.js.map +1 -0
- package/dist/esm/objects.js +31 -0
- package/dist/esm/objects.js.map +1 -0
- package/dist/esm/strings.js +80 -0
- package/dist/esm/strings.js.map +1 -0
- package/dist/esm/validation.js +54 -0
- package/dist/esm/validation.js.map +1 -0
- package/dist/node/async.js +93 -0
- package/dist/node/async.js.map +1 -0
- package/dist/node/csv.js +102 -0
- package/dist/node/csv.js.map +1 -0
- package/dist/node/data.js +880 -0
- package/dist/node/data.js.map +1 -0
- package/dist/node/dates.js +324 -0
- package/dist/node/dates.js.map +1 -0
- package/dist/node/environment.js +278 -0
- package/dist/node/environment.js.map +1 -0
- package/dist/node/errors.js +89 -0
- package/dist/node/errors.js.map +1 -0
- package/dist/node/index.js +3151 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/json.js +107 -0
- package/dist/node/json.js.map +1 -0
- package/dist/node/math.js +413 -0
- package/dist/node/math.js.map +1 -0
- package/dist/node/number.js +42 -0
- package/dist/node/number.js.map +1 -0
- package/dist/node/objects.js +264 -0
- package/dist/node/objects.js.map +1 -0
- package/dist/node/strings.js +293 -0
- package/dist/node/strings.js.map +1 -0
- package/dist/node/tree.js +89 -0
- package/dist/node/tree.js.map +1 -0
- package/dist/node/validation-core.js +477 -0
- package/dist/node/validation-core.js.map +1 -0
- package/dist/node/validation-crypto.js +179 -0
- package/dist/node/validation-crypto.js.map +1 -0
- package/dist/node/validation.js +677 -0
- package/dist/node/validation.js.map +1 -0
- package/dist/node/validators.js +123 -0
- package/dist/node/validators.js.map +1 -0
- package/dist/node-esm/async.js +15 -0
- package/dist/node-esm/async.js.map +1 -0
- package/dist/node-esm/chunk-3YOF7NPT.js +299 -0
- package/dist/node-esm/chunk-3YOF7NPT.js.map +1 -0
- package/dist/node-esm/chunk-64TBXJQS.js +263 -0
- package/dist/node-esm/chunk-64TBXJQS.js.map +1 -0
- package/dist/node-esm/chunk-75XNTC34.js +60 -0
- package/dist/node-esm/chunk-75XNTC34.js.map +1 -0
- package/dist/node-esm/chunk-C4PKXIPB.js +278 -0
- package/dist/node-esm/chunk-C4PKXIPB.js.map +1 -0
- package/dist/node-esm/chunk-CMDFZME3.js +452 -0
- package/dist/node-esm/chunk-CMDFZME3.js.map +1 -0
- package/dist/node-esm/chunk-DZZPUYMP.js +74 -0
- package/dist/node-esm/chunk-DZZPUYMP.js.map +1 -0
- package/dist/node-esm/chunk-HTSEHRHI.js +195 -0
- package/dist/node-esm/chunk-HTSEHRHI.js.map +1 -0
- package/dist/node-esm/chunk-JCAUVOPH.js +27 -0
- package/dist/node-esm/chunk-JCAUVOPH.js.map +1 -0
- package/dist/node-esm/chunk-KBHE3K2F.js +505 -0
- package/dist/node-esm/chunk-KBHE3K2F.js.map +1 -0
- package/dist/node-esm/chunk-LYTET5NX.js +65 -0
- package/dist/node-esm/chunk-LYTET5NX.js.map +1 -0
- package/dist/node-esm/chunk-PZ5AY32C.js +10 -0
- package/dist/node-esm/chunk-PZ5AY32C.js.map +1 -0
- package/dist/node-esm/chunk-UKGXL2QO.js +383 -0
- package/dist/node-esm/chunk-UKGXL2QO.js.map +1 -0
- package/dist/node-esm/chunk-XAEYT23H.js +164 -0
- package/dist/node-esm/chunk-XAEYT23H.js.map +1 -0
- package/dist/node-esm/csv.js +63 -0
- package/dist/node-esm/csv.js.map +1 -0
- package/dist/node-esm/data.js +32 -0
- package/dist/node-esm/data.js.map +1 -0
- package/dist/node-esm/dates.js +78 -0
- package/dist/node-esm/dates.js.map +1 -0
- package/dist/node-esm/environment.js +34 -0
- package/dist/node-esm/environment.js.map +1 -0
- package/dist/node-esm/errors.js +18 -0
- package/dist/node-esm/errors.js.map +1 -0
- package/dist/node-esm/index.js +426 -0
- package/dist/node-esm/index.js.map +1 -0
- package/dist/node-esm/json.js +68 -0
- package/dist/node-esm/json.js.map +1 -0
- package/dist/node-esm/math.js +51 -0
- package/dist/node-esm/math.js.map +1 -0
- package/dist/node-esm/number.js +10 -0
- package/dist/node-esm/number.js.map +1 -0
- package/dist/node-esm/objects.js +31 -0
- package/dist/node-esm/objects.js.map +1 -0
- package/dist/node-esm/strings.js +80 -0
- package/dist/node-esm/strings.js.map +1 -0
- package/dist/node-esm/tree.js +8 -0
- package/dist/node-esm/tree.js.map +1 -0
- package/dist/node-esm/validation-core.js +54 -0
- package/dist/node-esm/validation-core.js.map +1 -0
- package/dist/node-esm/validation-crypto.js +26 -0
- package/dist/node-esm/validation-crypto.js.map +1 -0
- package/dist/node-esm/validation.js +606 -0
- package/dist/node-esm/validation.js.map +1 -0
- package/dist/node-esm/validators.js +98 -0
- package/dist/node-esm/validators.js.map +1 -0
- package/dist/types/async-C8gvbSG-.d.ts +453 -0
- package/dist/types/async.d.ts +1 -0
- package/dist/types/csv.d.ts +226 -0
- package/dist/types/data.d.ts +1561 -0
- package/dist/types/dates-hTiE0Z11.d.ts +298 -0
- package/dist/types/dates.d.ts +1 -0
- package/dist/types/environment-B8eLS7KT.d.ts +420 -0
- package/dist/types/environment-detection.d.ts +102 -0
- package/dist/types/environment.d.ts +1 -0
- package/dist/types/errors.d.ts +147 -0
- package/dist/types/index.d.ts +211 -0
- package/dist/types/json.d.ts +284 -0
- package/dist/types/math-BQ9Lwdp7.d.ts +2060 -0
- package/dist/types/math.d.ts +1 -0
- package/dist/types/number-CYnQfLWj.d.ts +44 -0
- package/dist/types/number.d.ts +1 -0
- package/dist/types/objects-BohS8GCS.d.ts +1185 -0
- package/dist/types/objects.d.ts +1 -0
- package/dist/types/strings-CiqRPYLL.d.ts +1349 -0
- package/dist/types/strings.d.ts +1 -0
- package/dist/types/tree.d.ts +284 -0
- package/dist/types/validation-core-DfHF8rCG.d.ts +238 -0
- package/dist/types/validation-crypto-browser.d.ts +56 -0
- package/dist/types/validation-crypto-node.d.ts +31 -0
- package/dist/types/validation.d.ts +1 -0
- package/dist/types/validators.d.ts +216 -0
- package/package.json +253 -0
|
@@ -0,0 +1,3151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// src/environment.ts
|
|
34
|
+
var environment_exports = {};
|
|
35
|
+
__export(environment_exports, {
|
|
36
|
+
detectHostname: () => detectHostname,
|
|
37
|
+
detectProtocol: () => detectProtocol,
|
|
38
|
+
getEnvironmentInfo: () => getEnvironmentInfo,
|
|
39
|
+
isBrowser: () => isBrowser,
|
|
40
|
+
isBrowserEnvironment: () => isBrowserEnvironment,
|
|
41
|
+
isDevelopment: () => isDevelopment,
|
|
42
|
+
isLocalhost: () => isLocalhost,
|
|
43
|
+
isNode: () => isNode,
|
|
44
|
+
isNodeEnvironment: () => isNodeEnvironment,
|
|
45
|
+
isNonProduction: () => isNonProduction,
|
|
46
|
+
isPrivateIP: () => isPrivateIP,
|
|
47
|
+
isProduction: () => isProduction,
|
|
48
|
+
isTest: () => isTest,
|
|
49
|
+
parseEnvValue: () => parseEnvValue
|
|
50
|
+
});
|
|
51
|
+
function isNodeEnvironment() {
|
|
52
|
+
return typeof window === "undefined" && typeof process !== "undefined" && !!process.versions?.node;
|
|
53
|
+
}
|
|
54
|
+
function isBrowserEnvironment() {
|
|
55
|
+
const win = typeof window !== "undefined" ? window : global.window;
|
|
56
|
+
const doc = typeof document !== "undefined" ? document : global.document;
|
|
57
|
+
return typeof win !== "undefined" && win !== null && typeof doc !== "undefined" && doc !== null;
|
|
58
|
+
}
|
|
59
|
+
function isDevelopment(req) {
|
|
60
|
+
if (isNodeEnvironment()) {
|
|
61
|
+
if (process.env.NODE_ENV === "production") {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
if (process.env.NODE_ENV === "development") {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
if (req) {
|
|
68
|
+
const protocol = detectProtocol(req);
|
|
69
|
+
const hostname = detectHostname(req);
|
|
70
|
+
return protocol === "http" || isLocalhost(hostname) || isPrivateIP(hostname);
|
|
71
|
+
}
|
|
72
|
+
return !process.env.NODE_ENV || process.env.NODE_ENV === "development";
|
|
73
|
+
}
|
|
74
|
+
if (isBrowserEnvironment()) {
|
|
75
|
+
if (typeof globalThis.__DEV__ !== "undefined" && globalThis.__DEV__ === true) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
if (typeof window !== "undefined" && window.__VUE_DEVTOOLS_GLOBAL_HOOK__ && typeof location !== "undefined" && isLocalhost(location.hostname)) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
if (typeof location === "undefined") {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
const hostname = location.hostname || "";
|
|
85
|
+
const port = parseInt(location.port || "80");
|
|
86
|
+
const isDevelopmentPort = port >= 3e3 && port <= 9999;
|
|
87
|
+
const isHttpDevelopment = location.protocol === "http:" && (isLocalhost(hostname) || isPrivateIP(hostname));
|
|
88
|
+
return isLocalhost(hostname) || isPrivateIP(hostname) || isDevelopmentPort || isHttpDevelopment;
|
|
89
|
+
}
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
function isProduction() {
|
|
93
|
+
if (isNodeEnvironment()) {
|
|
94
|
+
return process.env.NODE_ENV === "production";
|
|
95
|
+
}
|
|
96
|
+
return !isDevelopment();
|
|
97
|
+
}
|
|
98
|
+
function isTest() {
|
|
99
|
+
if (isNodeEnvironment()) {
|
|
100
|
+
return process.env.NODE_ENV === "test";
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
function isNonProduction() {
|
|
105
|
+
if (isNodeEnvironment()) {
|
|
106
|
+
return process.env.NODE_ENV !== "production";
|
|
107
|
+
}
|
|
108
|
+
return !isProduction();
|
|
109
|
+
}
|
|
110
|
+
function detectProtocol(req) {
|
|
111
|
+
if (isBrowserEnvironment()) {
|
|
112
|
+
if (typeof location !== "undefined") {
|
|
113
|
+
return location.protocol === "https:" ? "https" : "http";
|
|
114
|
+
}
|
|
115
|
+
return "https";
|
|
116
|
+
}
|
|
117
|
+
if (req) {
|
|
118
|
+
const forwardedProto = req.get?.("X-Forwarded-Proto") || req.headers?.["x-forwarded-proto"];
|
|
119
|
+
const forwardedProtocol = req.get?.("X-Forwarded-Protocol") || req.headers?.["x-forwarded-protocol"];
|
|
120
|
+
const urlScheme = req.get?.("X-Url-Scheme") || req.headers?.["x-url-scheme"];
|
|
121
|
+
const frontEndHttps = req.get?.("Front-End-Https") || req.headers?.["front-end-https"];
|
|
122
|
+
const cloudflareVisitor = req.get?.("CF-Visitor") || req.headers?.["cf-visitor"];
|
|
123
|
+
if (forwardedProto) {
|
|
124
|
+
return forwardedProto.split(",")[0].trim().toLowerCase();
|
|
125
|
+
}
|
|
126
|
+
if (forwardedProtocol) {
|
|
127
|
+
return forwardedProtocol.toLowerCase();
|
|
128
|
+
}
|
|
129
|
+
if (urlScheme) {
|
|
130
|
+
return urlScheme.toLowerCase();
|
|
131
|
+
}
|
|
132
|
+
if (frontEndHttps === "on") {
|
|
133
|
+
return "https";
|
|
134
|
+
}
|
|
135
|
+
if (cloudflareVisitor) {
|
|
136
|
+
try {
|
|
137
|
+
const visitor = JSON.parse(cloudflareVisitor);
|
|
138
|
+
if (visitor.scheme) {
|
|
139
|
+
return visitor.scheme.toLowerCase();
|
|
140
|
+
}
|
|
141
|
+
} catch (_e) {
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (req.protocol) return req.protocol;
|
|
145
|
+
if (req.secure) return "https";
|
|
146
|
+
}
|
|
147
|
+
return "http";
|
|
148
|
+
}
|
|
149
|
+
function detectHostname(req) {
|
|
150
|
+
if (isBrowserEnvironment()) {
|
|
151
|
+
if (typeof location !== "undefined") {
|
|
152
|
+
return location.hostname;
|
|
153
|
+
}
|
|
154
|
+
return "localhost";
|
|
155
|
+
}
|
|
156
|
+
if (req) {
|
|
157
|
+
const forwardedHost = req.get?.("X-Forwarded-Host") || req.headers?.["x-forwarded-host"];
|
|
158
|
+
const originalHost = req.get?.("X-Original-Host") || req.headers?.["x-original-host"];
|
|
159
|
+
const host = req.get?.("Host") || req.headers?.["host"];
|
|
160
|
+
if (forwardedHost) {
|
|
161
|
+
return forwardedHost.split(",")[0].trim().split(":")[0];
|
|
162
|
+
}
|
|
163
|
+
if (originalHost) {
|
|
164
|
+
return originalHost.split(":")[0];
|
|
165
|
+
}
|
|
166
|
+
if (host) {
|
|
167
|
+
return host.split(":")[0];
|
|
168
|
+
}
|
|
169
|
+
if (req.hostname) return req.hostname;
|
|
170
|
+
}
|
|
171
|
+
return "localhost";
|
|
172
|
+
}
|
|
173
|
+
function isLocalhost(hostname) {
|
|
174
|
+
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname.endsWith(".localhost") || hostname.endsWith(".local");
|
|
175
|
+
}
|
|
176
|
+
function isPrivateIP(hostname) {
|
|
177
|
+
const ipv4Patterns = [
|
|
178
|
+
/^10\./,
|
|
179
|
+
// 10.0.0.0/8
|
|
180
|
+
/^172\.(1[6-9]|2[0-9]|3[0-1])\./,
|
|
181
|
+
// 172.16.0.0/12
|
|
182
|
+
/^192\.168\./,
|
|
183
|
+
// 192.168.0.0/16
|
|
184
|
+
/^127\./
|
|
185
|
+
// 127.0.0.0/8 (loopback)
|
|
186
|
+
];
|
|
187
|
+
const ipv6Patterns = [
|
|
188
|
+
/^::1$/,
|
|
189
|
+
// IPv6 loopback
|
|
190
|
+
/^fc[0-9a-f]{2}:/i,
|
|
191
|
+
// Unique local addresses
|
|
192
|
+
/^fd[0-9a-f]{2}:/i,
|
|
193
|
+
// Unique local addresses
|
|
194
|
+
/^fe80:/i
|
|
195
|
+
// Link-local addresses
|
|
196
|
+
];
|
|
197
|
+
return ipv4Patterns.some((pattern) => pattern.test(hostname)) || ipv6Patterns.some((pattern) => pattern.test(hostname)) || isLocalhost(hostname);
|
|
198
|
+
}
|
|
199
|
+
function getEnvironmentInfo(req) {
|
|
200
|
+
const platform = isNodeEnvironment() ? "node" : isBrowserEnvironment() ? "browser" : "unknown";
|
|
201
|
+
let environment = "production";
|
|
202
|
+
if (isNodeEnvironment()) {
|
|
203
|
+
const nodeEnv = process.env.NODE_ENV;
|
|
204
|
+
if (nodeEnv === "development" || nodeEnv === "test") {
|
|
205
|
+
environment = nodeEnv;
|
|
206
|
+
}
|
|
207
|
+
} else if (isDevelopment()) {
|
|
208
|
+
environment = "development";
|
|
209
|
+
}
|
|
210
|
+
const protocol = detectProtocol(req);
|
|
211
|
+
const hostname = detectHostname(req);
|
|
212
|
+
const info = {
|
|
213
|
+
platform,
|
|
214
|
+
environment,
|
|
215
|
+
protocol,
|
|
216
|
+
hostname
|
|
217
|
+
};
|
|
218
|
+
if (isBrowserEnvironment() && typeof navigator !== "undefined") {
|
|
219
|
+
info.userAgent = navigator.userAgent;
|
|
220
|
+
}
|
|
221
|
+
const criteria = {
|
|
222
|
+
isLocalhost: isLocalhost(hostname),
|
|
223
|
+
isPrivateIP: isPrivateIP(hostname),
|
|
224
|
+
isDevelopmentPort: false,
|
|
225
|
+
hasDevtools: false
|
|
226
|
+
};
|
|
227
|
+
if (isBrowserEnvironment() && typeof location !== "undefined") {
|
|
228
|
+
const port = parseInt(location.port || "80");
|
|
229
|
+
criteria.isDevelopmentPort = port >= 3e3 && port <= 9999;
|
|
230
|
+
criteria.hasDevtools = !!(typeof window !== "undefined" && window.__VUE_DEVTOOLS_GLOBAL_HOOK__);
|
|
231
|
+
}
|
|
232
|
+
if (isNodeEnvironment()) {
|
|
233
|
+
criteria.nodeEnv = process.env.NODE_ENV || "undefined";
|
|
234
|
+
}
|
|
235
|
+
info.criteria = criteria;
|
|
236
|
+
return info;
|
|
237
|
+
}
|
|
238
|
+
function parseEnvValue(value) {
|
|
239
|
+
if (value === void 0 || value === null || value === "") {
|
|
240
|
+
return void 0;
|
|
241
|
+
}
|
|
242
|
+
const trimmed = value.trim();
|
|
243
|
+
if (trimmed === "null") return null;
|
|
244
|
+
if (trimmed === "undefined") return void 0;
|
|
245
|
+
const lowerValue = trimmed.toLowerCase();
|
|
246
|
+
if (lowerValue === "true" || lowerValue === "yes") return true;
|
|
247
|
+
if (lowerValue === "false" || lowerValue === "no") return false;
|
|
248
|
+
if (trimmed === "1") return true;
|
|
249
|
+
if (trimmed === "0") return false;
|
|
250
|
+
if (/^-?\d+\.?\d*$/.test(trimmed)) {
|
|
251
|
+
if (trimmed.length > 1 && trimmed[0] === "0" && trimmed[1] !== ".") {
|
|
252
|
+
return trimmed;
|
|
253
|
+
}
|
|
254
|
+
const num = Number(trimmed);
|
|
255
|
+
if (!isNaN(num)) return num;
|
|
256
|
+
}
|
|
257
|
+
if (trimmed.startsWith("[") && trimmed.endsWith("]") || trimmed.startsWith("{") && trimmed.endsWith("}")) {
|
|
258
|
+
try {
|
|
259
|
+
return JSON.parse(trimmed);
|
|
260
|
+
} catch {
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (trimmed.includes(",")) {
|
|
264
|
+
const parts = trimmed.split(",").map((s) => s.trim());
|
|
265
|
+
if (parts.every((p) => p.length > 0)) {
|
|
266
|
+
return parts;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return trimmed;
|
|
270
|
+
}
|
|
271
|
+
var isNode, isBrowser;
|
|
272
|
+
var init_environment = __esm({
|
|
273
|
+
"src/environment.ts"() {
|
|
274
|
+
"use strict";
|
|
275
|
+
isNode = isNodeEnvironment;
|
|
276
|
+
isBrowser = isBrowserEnvironment;
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
// src/tree.ts
|
|
281
|
+
var tree_exports = {};
|
|
282
|
+
__export(tree_exports, {
|
|
283
|
+
renderTreeAsText: () => renderTreeAsText
|
|
284
|
+
});
|
|
285
|
+
function renderTreeAsText(data, options) {
|
|
286
|
+
if (!data || !Array.isArray(data)) {
|
|
287
|
+
return "";
|
|
288
|
+
}
|
|
289
|
+
if (data.length === 0) {
|
|
290
|
+
return "";
|
|
291
|
+
}
|
|
292
|
+
const {
|
|
293
|
+
labelField = "name",
|
|
294
|
+
verticalLine = "\u2502 ",
|
|
295
|
+
middleBranch = "\u251C\u2500\u2500 ",
|
|
296
|
+
lastBranch = "\u2514\u2500\u2500 ",
|
|
297
|
+
emptySpace = " ",
|
|
298
|
+
labelFunction
|
|
299
|
+
} = options || {};
|
|
300
|
+
const visited = /* @__PURE__ */ new WeakSet();
|
|
301
|
+
const getLabel = (node) => {
|
|
302
|
+
try {
|
|
303
|
+
if (labelFunction) return String(labelFunction(node));
|
|
304
|
+
if (node == null) return "[null]";
|
|
305
|
+
if (typeof node !== "object") return String(node);
|
|
306
|
+
return node[labelField] != null ? String(node[labelField]) : String(node);
|
|
307
|
+
} catch (_error) {
|
|
308
|
+
return "[error]";
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
const renderNode = (node, prefix = "", isLast = true, depth = 0) => {
|
|
312
|
+
if (node == null) {
|
|
313
|
+
return "";
|
|
314
|
+
}
|
|
315
|
+
if (typeof node === "object" && visited.has(node)) {
|
|
316
|
+
return `${prefix + (isLast ? lastBranch : middleBranch)}[circular reference]`;
|
|
317
|
+
}
|
|
318
|
+
if (depth > 100) {
|
|
319
|
+
return `${prefix + (isLast ? lastBranch : middleBranch)}[max depth exceeded]`;
|
|
320
|
+
}
|
|
321
|
+
if (typeof node === "object") {
|
|
322
|
+
visited.add(node);
|
|
323
|
+
}
|
|
324
|
+
const lines = [];
|
|
325
|
+
const currentPrefix = isLast ? lastBranch : middleBranch;
|
|
326
|
+
lines.push(prefix + currentPrefix + getLabel(node));
|
|
327
|
+
const children = Array.isArray(node.children) ? node.children.filter((child) => child != null) : [];
|
|
328
|
+
const nextPrefix = prefix + (isLast ? emptySpace : verticalLine);
|
|
329
|
+
children.forEach((child, index) => {
|
|
330
|
+
const isLastChild = index === children.length - 1;
|
|
331
|
+
const childOutput = renderNode(child, nextPrefix, isLastChild, depth + 1);
|
|
332
|
+
if (childOutput) {
|
|
333
|
+
lines.push(childOutput);
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
return lines.join("\n");
|
|
337
|
+
};
|
|
338
|
+
const validRoots = data.filter((root) => root != null);
|
|
339
|
+
if (validRoots.length === 0) {
|
|
340
|
+
return "";
|
|
341
|
+
}
|
|
342
|
+
return validRoots.map((root, index) => renderNode(root, "", index === validRoots.length - 1)).join("\n");
|
|
343
|
+
}
|
|
344
|
+
var init_tree = __esm({
|
|
345
|
+
"src/tree.ts"() {
|
|
346
|
+
"use strict";
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
// src/validators.ts
|
|
351
|
+
var validators_exports = {};
|
|
352
|
+
__export(validators_exports, {
|
|
353
|
+
isValidFilePath: () => isValidFilePath,
|
|
354
|
+
isValidFileSize: () => isValidFileSize,
|
|
355
|
+
isValidTextContent: () => isValidTextContent
|
|
356
|
+
});
|
|
357
|
+
function isValidFilePath(filePath) {
|
|
358
|
+
if (!filePath || typeof filePath !== "string") return false;
|
|
359
|
+
if (typeof filePath === "object") return false;
|
|
360
|
+
if (filePath.length === 0 || filePath.length > 1e3) return false;
|
|
361
|
+
if (filePath.includes("../") || filePath.includes("..\\")) return false;
|
|
362
|
+
const suspiciousPatterns = ["//", "\\\\", "//\\", "\\//", "/./", "\\.\\"];
|
|
363
|
+
if (suspiciousPatterns.some((pattern) => filePath.includes(pattern))) return false;
|
|
364
|
+
const encodedPatterns = [
|
|
365
|
+
"%2e%2e%2f",
|
|
366
|
+
// ../
|
|
367
|
+
"%2e%2e/",
|
|
368
|
+
// ../
|
|
369
|
+
"%2e%2e%5c",
|
|
370
|
+
// ..\
|
|
371
|
+
"%252e"
|
|
372
|
+
// double-encoded
|
|
373
|
+
];
|
|
374
|
+
if (encodedPatterns.some((pattern) => filePath.toLowerCase().includes(pattern))) return false;
|
|
375
|
+
if (filePath.includes("\0")) return false;
|
|
376
|
+
const commandChars = [";", "&", "|", "`", "$", "(", ")", "{", "}"];
|
|
377
|
+
if (commandChars.some((char) => filePath.includes(char))) return false;
|
|
378
|
+
const sqlPatterns = ["'", '"', "--", "/*", "*/", "DROP", "DELETE", "UNION", "SELECT"];
|
|
379
|
+
const lowerPath = filePath.toLowerCase();
|
|
380
|
+
if (sqlPatterns.some(
|
|
381
|
+
(pattern) => lowerPath.includes(pattern.toLowerCase()) && (pattern === "'" || pattern === '"' || lowerPath.includes(` ${pattern.toLowerCase()}`))
|
|
382
|
+
))
|
|
383
|
+
return false;
|
|
384
|
+
const dangerousUnicode = [
|
|
385
|
+
"\u202E",
|
|
386
|
+
// Right-to-left override
|
|
387
|
+
"\u200B",
|
|
388
|
+
// Zero-width space
|
|
389
|
+
"\u200C",
|
|
390
|
+
// Zero-width non-joiner
|
|
391
|
+
"\u200D",
|
|
392
|
+
// Zero-width joiner
|
|
393
|
+
"\uFEFF"
|
|
394
|
+
// Zero-width no-break space
|
|
395
|
+
];
|
|
396
|
+
if (dangerousUnicode.some((char) => filePath.includes(char))) return false;
|
|
397
|
+
if (/^[A-Za-z]:\\.*\\\.\./.test(filePath)) return false;
|
|
398
|
+
return true;
|
|
399
|
+
}
|
|
400
|
+
function isValidFileSize(size2, maxSize) {
|
|
401
|
+
return typeof size2 === "number" && size2 >= 0 && size2 <= maxSize;
|
|
402
|
+
}
|
|
403
|
+
function isValidTextContent(content, options = {}) {
|
|
404
|
+
const { maxLength = 1e6 } = options;
|
|
405
|
+
if (typeof content !== "string") return false;
|
|
406
|
+
if (content.length > maxLength) return false;
|
|
407
|
+
const lowerContent = content.toLowerCase();
|
|
408
|
+
const scriptPatterns = ["<script", "</script", "<scr<script>ipt", "<scr\0ipt"];
|
|
409
|
+
if (scriptPatterns.some((pattern) => lowerContent.includes(pattern))) return false;
|
|
410
|
+
const eventHandlers = [
|
|
411
|
+
"onerror",
|
|
412
|
+
"onload",
|
|
413
|
+
"onclick",
|
|
414
|
+
"onmouseover",
|
|
415
|
+
"onfocus",
|
|
416
|
+
"onblur",
|
|
417
|
+
"oninput"
|
|
418
|
+
];
|
|
419
|
+
if (eventHandlers.some((handler) => lowerContent.includes(handler))) return false;
|
|
420
|
+
const protocolPatterns = [
|
|
421
|
+
"javascript:",
|
|
422
|
+
"data:text/html",
|
|
423
|
+
"data:text/javascript",
|
|
424
|
+
"data:application",
|
|
425
|
+
"vbscript:",
|
|
426
|
+
"file:///",
|
|
427
|
+
"steam://",
|
|
428
|
+
"slack://"
|
|
429
|
+
];
|
|
430
|
+
if (protocolPatterns.some((pattern) => lowerContent.includes(pattern))) return false;
|
|
431
|
+
const encodedPatterns = [
|
|
432
|
+
"<script",
|
|
433
|
+
// < = <
|
|
434
|
+
"%3cscript",
|
|
435
|
+
// %3c = <
|
|
436
|
+
"\\x3cscript",
|
|
437
|
+
// \x3c = <
|
|
438
|
+
"\\u003cscript"
|
|
439
|
+
// \u003c = <
|
|
440
|
+
];
|
|
441
|
+
if (encodedPatterns.some((pattern) => lowerContent.includes(pattern))) return false;
|
|
442
|
+
if (lowerContent.includes("<svg") && lowerContent.includes("onload")) return false;
|
|
443
|
+
if (lowerContent.includes("<iframe")) return false;
|
|
444
|
+
return true;
|
|
445
|
+
}
|
|
446
|
+
var init_validators = __esm({
|
|
447
|
+
"src/validators.ts"() {
|
|
448
|
+
"use strict";
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
// src/csv.ts
|
|
453
|
+
var csv_exports = {};
|
|
454
|
+
__export(csv_exports, {
|
|
455
|
+
exportCSV: () => exportCSV,
|
|
456
|
+
importCSV: () => importCSV
|
|
457
|
+
});
|
|
458
|
+
async function exportCSV(data, filePath, options) {
|
|
459
|
+
if (data == null) {
|
|
460
|
+
throw new TypeError("Data cannot be null or undefined");
|
|
461
|
+
}
|
|
462
|
+
if (!Array.isArray(data)) {
|
|
463
|
+
throw new TypeError("Data must be an array");
|
|
464
|
+
}
|
|
465
|
+
if (data.length === 0) {
|
|
466
|
+
throw new Error("Data array cannot be empty");
|
|
467
|
+
}
|
|
468
|
+
if (!filePath || typeof filePath !== "string" || filePath.trim() === "") {
|
|
469
|
+
throw new TypeError("File path must be a non-empty string");
|
|
470
|
+
}
|
|
471
|
+
const csvText = import_papaparse.default.unparse(data, {
|
|
472
|
+
delimiter: ";",
|
|
473
|
+
header: true,
|
|
474
|
+
...options
|
|
475
|
+
});
|
|
476
|
+
if (isNode()) {
|
|
477
|
+
const fs = await import("fs/promises");
|
|
478
|
+
await fs.writeFile(filePath, `\uFEFF${csvText}`, { encoding: "utf-8" });
|
|
479
|
+
} else {
|
|
480
|
+
const blob = new Blob([`\uFEFF${csvText}`], { type: "text/csv;charset=utf-8" });
|
|
481
|
+
const url = URL.createObjectURL(blob);
|
|
482
|
+
const link = document.createElement("a");
|
|
483
|
+
link.href = url;
|
|
484
|
+
link.download = filePath.split("/").pop() || "data.csv";
|
|
485
|
+
document.body.appendChild(link);
|
|
486
|
+
link.click();
|
|
487
|
+
document.body.removeChild(link);
|
|
488
|
+
URL.revokeObjectURL(url);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
async function importCSV(filePath, options) {
|
|
492
|
+
if (!filePath || typeof filePath !== "string" || filePath.trim() === "") {
|
|
493
|
+
throw new TypeError("File path must be a non-empty string");
|
|
494
|
+
}
|
|
495
|
+
if (isNode()) {
|
|
496
|
+
const fs = await import("fs/promises");
|
|
497
|
+
const content = await fs.readFile(filePath, { encoding: "utf-8" });
|
|
498
|
+
const parseResult = import_papaparse.default.parse(content, {
|
|
499
|
+
header: true,
|
|
500
|
+
delimiter: ";",
|
|
501
|
+
skipEmptyLines: true,
|
|
502
|
+
...options
|
|
503
|
+
});
|
|
504
|
+
return parseResult.data || [];
|
|
505
|
+
} else {
|
|
506
|
+
throw new Error("CSV import not supported in browser. Use readFileAsText() with a File object.");
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
var import_papaparse;
|
|
510
|
+
var init_csv = __esm({
|
|
511
|
+
"src/csv.ts"() {
|
|
512
|
+
"use strict";
|
|
513
|
+
import_papaparse = __toESM(require("papaparse"));
|
|
514
|
+
init_environment();
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
// src/json.ts
|
|
519
|
+
var json_exports = {};
|
|
520
|
+
__export(json_exports, {
|
|
521
|
+
exportJSON: () => exportJSON,
|
|
522
|
+
importJSON: () => importJSON
|
|
523
|
+
});
|
|
524
|
+
async function exportJSON(data, filePath, options) {
|
|
525
|
+
if (data === null || data === void 0) {
|
|
526
|
+
throw new TypeError("Data cannot be null or undefined");
|
|
527
|
+
}
|
|
528
|
+
if (!filePath || typeof filePath !== "string" || filePath.trim() === "") {
|
|
529
|
+
throw new TypeError("File path must be a non-empty string");
|
|
530
|
+
}
|
|
531
|
+
const { indent = 2 } = options || {};
|
|
532
|
+
let jsonText;
|
|
533
|
+
try {
|
|
534
|
+
jsonText = JSON.stringify(data, null, indent);
|
|
535
|
+
} catch (error) {
|
|
536
|
+
if (error instanceof TypeError && error.message.includes("circular")) {
|
|
537
|
+
throw new TypeError("Cannot serialize data with circular references");
|
|
538
|
+
}
|
|
539
|
+
throw error;
|
|
540
|
+
}
|
|
541
|
+
if (isNode()) {
|
|
542
|
+
const fs = await import("fs/promises");
|
|
543
|
+
await fs.writeFile(filePath, jsonText, { encoding: "utf-8" });
|
|
544
|
+
} else {
|
|
545
|
+
const blob = new Blob([jsonText], { type: "application/json;charset=utf-8" });
|
|
546
|
+
const url = URL.createObjectURL(blob);
|
|
547
|
+
const link = document.createElement("a");
|
|
548
|
+
link.href = url;
|
|
549
|
+
link.download = filePath.split("/").pop() || "data.json";
|
|
550
|
+
document.body.appendChild(link);
|
|
551
|
+
link.click();
|
|
552
|
+
document.body.removeChild(link);
|
|
553
|
+
URL.revokeObjectURL(url);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
async function importJSON(filePath, _options) {
|
|
557
|
+
if (!filePath || typeof filePath !== "string" || filePath.trim() === "") {
|
|
558
|
+
throw new TypeError("File path must be a non-empty string");
|
|
559
|
+
}
|
|
560
|
+
if (isNode()) {
|
|
561
|
+
const fs = await import("fs/promises");
|
|
562
|
+
const content = await fs.readFile(filePath, { encoding: "utf-8" });
|
|
563
|
+
const trimmed = content.trim();
|
|
564
|
+
if (trimmed === "") {
|
|
565
|
+
throw new SyntaxError("JSON file is empty");
|
|
566
|
+
}
|
|
567
|
+
try {
|
|
568
|
+
return JSON.parse(content);
|
|
569
|
+
} catch (error) {
|
|
570
|
+
if (error instanceof SyntaxError) {
|
|
571
|
+
throw new SyntaxError(`Invalid JSON in file ${filePath}: ${error.message}`);
|
|
572
|
+
}
|
|
573
|
+
throw error;
|
|
574
|
+
}
|
|
575
|
+
} else {
|
|
576
|
+
throw new Error(
|
|
577
|
+
"JSON import not supported in browser. Use readFileAsText() with a File object."
|
|
578
|
+
);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
var init_json = __esm({
|
|
582
|
+
"src/json.ts"() {
|
|
583
|
+
"use strict";
|
|
584
|
+
init_environment();
|
|
585
|
+
}
|
|
586
|
+
});
|
|
587
|
+
|
|
588
|
+
// src/node/index.ts
|
|
589
|
+
var node_exports = {};
|
|
590
|
+
__export(node_exports, {
|
|
591
|
+
addDays: () => addDays,
|
|
592
|
+
addMonths: () => addMonths,
|
|
593
|
+
addNowDays: () => addNowDays,
|
|
594
|
+
addNowMonths: () => addNowMonths,
|
|
595
|
+
addNowSeconds: () => addNowSeconds,
|
|
596
|
+
addNowYears: () => addNowYears,
|
|
597
|
+
addSeconds: () => addSeconds,
|
|
598
|
+
addYears: () => addYears,
|
|
599
|
+
areDatesEqualWithTolerance: () => areDatesEqualWithTolerance,
|
|
600
|
+
async: () => async_exports,
|
|
601
|
+
calculateAggregations: () => calculateAggregations,
|
|
602
|
+
calculateAnnuityPayment: () => calculateAnnuityPayment,
|
|
603
|
+
calculateCorrelation: () => calculateCorrelation,
|
|
604
|
+
calculateDifferences: () => calculateDifferences,
|
|
605
|
+
calculateEuclideanDistance: () => calculateEuclideanDistance,
|
|
606
|
+
calculateFutureValue: () => calculateFutureValue,
|
|
607
|
+
calculateHistogram: () => calculateHistogram,
|
|
608
|
+
calculateIQR: () => calculateIQR,
|
|
609
|
+
calculateIRR: () => calculateIRR,
|
|
610
|
+
calculateManhattanDistance: () => calculateManhattanDistance,
|
|
611
|
+
calculateMedian: () => calculateMedian,
|
|
612
|
+
calculateMode: () => calculateMode,
|
|
613
|
+
calculateNPV: () => calculateNPV,
|
|
614
|
+
calculatePercentile: () => calculatePercentile,
|
|
615
|
+
calculatePresentValue: () => calculatePresentValue,
|
|
616
|
+
calculateQuartiles: () => calculateQuartiles,
|
|
617
|
+
calculateStandardDeviation: () => calculateStandardDeviation,
|
|
618
|
+
calculateTrendSlope: () => calculateTrendSlope,
|
|
619
|
+
calculateVariance: () => calculateVariance,
|
|
620
|
+
capitalizeEachWord: () => capitalizeEachWord,
|
|
621
|
+
capitalizeFirst: () => capitalizeFirst,
|
|
622
|
+
cleanJsonChars: () => cleanJsonChars,
|
|
623
|
+
comparator: () => comparator,
|
|
624
|
+
contains: () => contains,
|
|
625
|
+
countOccurrences: () => countOccurrences,
|
|
626
|
+
data: () => data_exports,
|
|
627
|
+
dates: () => dates_exports,
|
|
628
|
+
dayOfWeek: () => dayOfWeek,
|
|
629
|
+
deepEqual: () => deepEqual,
|
|
630
|
+
default: () => node_default,
|
|
631
|
+
deleteArrayElementsBy: () => deleteArrayElementsBy,
|
|
632
|
+
detectFileExtension: () => detectFileExtension,
|
|
633
|
+
detectFormatFromFilename: () => detectFormatFromFilename,
|
|
634
|
+
detectHostname: () => detectHostname,
|
|
635
|
+
detectOutliers: () => detectOutliers,
|
|
636
|
+
detectProtocol: () => detectProtocol,
|
|
637
|
+
detectUniversalFormat: () => detectUniversalFormat,
|
|
638
|
+
diffBusinessDays: () => diffBusinessDays,
|
|
639
|
+
diffDays: () => diffDays,
|
|
640
|
+
diffMilliSeconds: () => diffMilliSeconds,
|
|
641
|
+
diffMonths: () => diffMonths,
|
|
642
|
+
diffYears: () => diffYears,
|
|
643
|
+
endsWith: () => endsWith,
|
|
644
|
+
ensureEndsWith: () => ensureEndsWith,
|
|
645
|
+
ensureStartsWith: () => ensureStartsWith,
|
|
646
|
+
envKeyToPath: () => envKeyToPath,
|
|
647
|
+
environment: () => environment_exports,
|
|
648
|
+
escapeHtmlChars: () => escapeHtmlChars,
|
|
649
|
+
escapeShellCommand: () => escapeShellCommand,
|
|
650
|
+
excelToDate: () => excelToDate,
|
|
651
|
+
exportData: () => exportData,
|
|
652
|
+
exportTree: () => exportTree,
|
|
653
|
+
exportTxt: () => exportTxt,
|
|
654
|
+
format: () => format,
|
|
655
|
+
formatForMysql: () => formatForMysql,
|
|
656
|
+
formatNow: () => formatNow,
|
|
657
|
+
formatToReadableString: () => formatToReadableString,
|
|
658
|
+
fromNow: () => fromNow,
|
|
659
|
+
generateAlphaNumericString: () => generateAlphaNumericString,
|
|
660
|
+
generateAlphaString: () => generateAlphaString,
|
|
661
|
+
generateComplexString: () => generateComplexString,
|
|
662
|
+
generateCrcHash: () => generateCrcHash,
|
|
663
|
+
generateEmail: () => generateEmail,
|
|
664
|
+
generateHexColor: () => generateHexColor,
|
|
665
|
+
generateNonce: () => generateNonce,
|
|
666
|
+
generatePassword: () => generatePassword,
|
|
667
|
+
generateRandomInteger: () => generateRandomInteger,
|
|
668
|
+
generateSecureToken: () => generateSecureToken,
|
|
669
|
+
generateSpanishCIF: () => generateSpanishCIF,
|
|
670
|
+
generateSpanishIBAN: () => generateSpanishIBAN,
|
|
671
|
+
generateSpanishNIE: () => generateSpanishNIE,
|
|
672
|
+
generateSpanishNIF: () => generateSpanishNIF,
|
|
673
|
+
generateSpanishPostalCode: () => generateSpanishPostalCode,
|
|
674
|
+
generateUsername: () => generateUsername,
|
|
675
|
+
generateUsernameFromEmail: () => generateUsernameFromEmail,
|
|
676
|
+
getDeepValue: () => getDeepValue,
|
|
677
|
+
getEnvironmentInfo: () => getEnvironmentInfo,
|
|
678
|
+
getFirstDayOfYear: () => getFirstDayOfYear,
|
|
679
|
+
getFirstWorkdayAfterMonths: () => getFirstWorkdayAfterMonths,
|
|
680
|
+
getFirstWorkdayOfMonth: () => getFirstWorkdayOfMonth,
|
|
681
|
+
getLastDayOfYear: () => getLastDayOfYear,
|
|
682
|
+
getLastWorkdayOfMonth: () => getLastWorkdayOfMonth,
|
|
683
|
+
getShallowProperties: () => getShallowProperties,
|
|
684
|
+
handleOperation: () => handleOperation,
|
|
685
|
+
hasSameType: () => hasSameType,
|
|
686
|
+
hashString: () => hashString,
|
|
687
|
+
importData: () => importData,
|
|
688
|
+
importTree: () => importTree,
|
|
689
|
+
importTxt: () => importTxt,
|
|
690
|
+
isBrowser: () => isBrowser,
|
|
691
|
+
isBrowserEnvironment: () => isBrowserEnvironment,
|
|
692
|
+
isDateTime: () => isDateTime,
|
|
693
|
+
isDevelopment: () => isDevelopment,
|
|
694
|
+
isEmail: () => isEmail,
|
|
695
|
+
isEmpty: () => isEmpty,
|
|
696
|
+
isEqualsDateTimeByDay: () => isEqualsDateTimeByDay,
|
|
697
|
+
isExpired: () => isExpired,
|
|
698
|
+
isLocalhost: () => isLocalhost,
|
|
699
|
+
isNew: () => isNew,
|
|
700
|
+
isNode: () => isNode,
|
|
701
|
+
isNodeEnvironment: () => isNodeEnvironment,
|
|
702
|
+
isNonProduction: () => isNonProduction,
|
|
703
|
+
isNumericValue: () => isNumericValue,
|
|
704
|
+
isPrivateIP: () => isPrivateIP,
|
|
705
|
+
isProduction: () => isProduction,
|
|
706
|
+
isSecureUrl: () => isSecureUrl,
|
|
707
|
+
isTest: () => isTest,
|
|
708
|
+
isValidBase64: () => isValidBase64,
|
|
709
|
+
isValidCIF: () => isValidCIF,
|
|
710
|
+
isValidEmail: () => isValidEmail,
|
|
711
|
+
isValidJSON: () => isValidJSON,
|
|
712
|
+
isValidJWTFormat: () => isValidJWTFormat,
|
|
713
|
+
isValidNIE: () => isValidNIE,
|
|
714
|
+
isValidNIF: () => isValidNIF,
|
|
715
|
+
isValidSpanishIBAN: () => isValidSpanishIBAN,
|
|
716
|
+
isValidSpanishPhone: () => isValidSpanishPhone,
|
|
717
|
+
isValidSpanishPostalCode: () => isValidSpanishPostalCode,
|
|
718
|
+
isValidURL: () => isValidURL,
|
|
719
|
+
isWeekday: () => isWeekday,
|
|
720
|
+
longString: () => longString,
|
|
721
|
+
matchPathPattern: () => matchPathPattern,
|
|
722
|
+
math: () => math_exports,
|
|
723
|
+
normalizeToRange: () => normalizeToRange,
|
|
724
|
+
now: () => now,
|
|
725
|
+
number: () => number_exports,
|
|
726
|
+
objects: () => objects_exports,
|
|
727
|
+
padEnd: () => padEnd,
|
|
728
|
+
padStart: () => padStart,
|
|
729
|
+
parseEnvValue: () => parseEnvValue,
|
|
730
|
+
pathToEnvKey: () => pathToEnvKey,
|
|
731
|
+
readFileAsText: () => readFileAsText,
|
|
732
|
+
removeAccents: () => removeAccents,
|
|
733
|
+
removeDangerousChars: () => removeDangerousChars,
|
|
734
|
+
renderTreeAsText: () => renderTreeAsText,
|
|
735
|
+
repeatString: () => repeatString,
|
|
736
|
+
replaceAllOccurrences: () => replaceAllOccurrences,
|
|
737
|
+
reverseString: () => reverseString,
|
|
738
|
+
roundToDecimals: () => roundToDecimals,
|
|
739
|
+
runBatch: () => runBatch,
|
|
740
|
+
sanitizeHtml: () => sanitizeHtml,
|
|
741
|
+
sanitizeString: () => sanitizeString,
|
|
742
|
+
scaleToRange: () => scaleToRange,
|
|
743
|
+
setDeepValue: () => setDeepValue,
|
|
744
|
+
simpleKMeans: () => simpleKMeans,
|
|
745
|
+
sleep: () => sleep,
|
|
746
|
+
startsWith: () => startsWith,
|
|
747
|
+
strings: () => strings_exports,
|
|
748
|
+
stripFromEnd: () => stripFromEnd,
|
|
749
|
+
stripFromStart: () => stripFromStart,
|
|
750
|
+
toCamelCase: () => toCamelCase,
|
|
751
|
+
toDate: () => toDate,
|
|
752
|
+
toDateFromString: () => toDateFromString,
|
|
753
|
+
toISO: () => toISO,
|
|
754
|
+
toKebabCase: () => toKebabCase,
|
|
755
|
+
toLowerCase: () => toLowerCase,
|
|
756
|
+
toPascalCase: () => toPascalCase,
|
|
757
|
+
toSnakeCase: () => toSnakeCase,
|
|
758
|
+
toUpperCase: () => toUpperCase,
|
|
759
|
+
toUrlSlug: () => toUrlSlug,
|
|
760
|
+
tree: () => tree_exports,
|
|
761
|
+
trim: () => trim,
|
|
762
|
+
trimEnd: () => trimEnd,
|
|
763
|
+
trimStart: () => trimStart,
|
|
764
|
+
truncateString: () => truncateString,
|
|
765
|
+
unescapeHtmlChars: () => unescapeHtmlChars,
|
|
766
|
+
unescapeUnicode: () => unescapeUnicode,
|
|
767
|
+
updateArrayElementById: () => updateArrayElementById,
|
|
768
|
+
updateArrayElementsBy: () => updateArrayElementsBy,
|
|
769
|
+
validateCSVData: () => validateCSVData,
|
|
770
|
+
validateExportData: () => validateExportData,
|
|
771
|
+
validateNIF: () => validateNIF,
|
|
772
|
+
validatePassword: () => validatePassword,
|
|
773
|
+
validation: () => validationFunctions,
|
|
774
|
+
wait: () => wait,
|
|
775
|
+
weekOfYear: () => weekOfYear
|
|
776
|
+
});
|
|
777
|
+
module.exports = __toCommonJS(node_exports);
|
|
778
|
+
|
|
779
|
+
// src/universal/validation-core.ts
|
|
780
|
+
var validation_core_exports = {};
|
|
781
|
+
__export(validation_core_exports, {
|
|
782
|
+
generateAlphaNumericString: () => generateAlphaNumericString,
|
|
783
|
+
generateAlphaString: () => generateAlphaString,
|
|
784
|
+
generateComplexString: () => generateComplexString,
|
|
785
|
+
generateEmail: () => generateEmail,
|
|
786
|
+
generateHexColor: () => generateHexColor,
|
|
787
|
+
generatePassword: () => generatePassword,
|
|
788
|
+
generateRandomInteger: () => generateRandomInteger,
|
|
789
|
+
generateSpanishCIF: () => generateSpanishCIF,
|
|
790
|
+
generateSpanishIBAN: () => generateSpanishIBAN,
|
|
791
|
+
generateSpanishNIE: () => generateSpanishNIE,
|
|
792
|
+
generateSpanishNIF: () => generateSpanishNIF,
|
|
793
|
+
generateSpanishPostalCode: () => generateSpanishPostalCode,
|
|
794
|
+
generateUsername: () => generateUsername,
|
|
795
|
+
generateUsernameFromEmail: () => generateUsernameFromEmail,
|
|
796
|
+
isValidCIF: () => isValidCIF,
|
|
797
|
+
isValidEmail: () => isValidEmail,
|
|
798
|
+
isValidJSON: () => isValidJSON,
|
|
799
|
+
isValidNIE: () => isValidNIE,
|
|
800
|
+
isValidNIF: () => isValidNIF,
|
|
801
|
+
isValidSpanishIBAN: () => isValidSpanishIBAN,
|
|
802
|
+
isValidSpanishPhone: () => isValidSpanishPhone,
|
|
803
|
+
isValidSpanishPostalCode: () => isValidSpanishPostalCode,
|
|
804
|
+
isValidURL: () => isValidURL,
|
|
805
|
+
validateNIF: () => validateNIF
|
|
806
|
+
});
|
|
807
|
+
var import_validator = __toESM(require("validator"));
|
|
808
|
+
var randomInteger = (min, max) => {
|
|
809
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
810
|
+
};
|
|
811
|
+
var randomString = (length, pool) => {
|
|
812
|
+
const chars = pool || "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
813
|
+
let result = "";
|
|
814
|
+
for (let i = 0; i < length; i++) {
|
|
815
|
+
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
816
|
+
}
|
|
817
|
+
return result;
|
|
818
|
+
};
|
|
819
|
+
var randomAlphaString = (length, casing) => {
|
|
820
|
+
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
821
|
+
let result = randomString(length, chars);
|
|
822
|
+
if (casing === "upper") result = result.toUpperCase();
|
|
823
|
+
if (casing === "lower") result = result.toLowerCase();
|
|
824
|
+
return result;
|
|
825
|
+
};
|
|
826
|
+
var randomAlphaNumericString = (length, casing) => {
|
|
827
|
+
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
828
|
+
let result = randomString(length, chars);
|
|
829
|
+
if (casing === "upper") result = result.toUpperCase();
|
|
830
|
+
if (casing === "lower") result = result.toLowerCase();
|
|
831
|
+
return result;
|
|
832
|
+
};
|
|
833
|
+
var pickone = (array) => {
|
|
834
|
+
return array[Math.floor(Math.random() * array.length)];
|
|
835
|
+
};
|
|
836
|
+
var randomBool = (likelihood = 50) => {
|
|
837
|
+
return Math.random() * 100 < likelihood;
|
|
838
|
+
};
|
|
839
|
+
var generateRandomInteger = (min = 0, max = 100) => {
|
|
840
|
+
return randomInteger(min, max);
|
|
841
|
+
};
|
|
842
|
+
var generateAlphaString = (options = {}) => {
|
|
843
|
+
const { length = 10, casing = void 0 } = options;
|
|
844
|
+
return randomAlphaString(length, casing);
|
|
845
|
+
};
|
|
846
|
+
var generateAlphaNumericString = (options = {}) => {
|
|
847
|
+
const { length = 10, casing = void 0 } = options;
|
|
848
|
+
return randomAlphaNumericString(length, casing);
|
|
849
|
+
};
|
|
850
|
+
var generateComplexString = (options = {}) => {
|
|
851
|
+
const { length = 10, casing: _casing = void 0 } = options;
|
|
852
|
+
return randomString(length);
|
|
853
|
+
};
|
|
854
|
+
var generateUsernameFromEmail = (email, randomDigits = 1) => {
|
|
855
|
+
if (!email || !email.includes("@"))
|
|
856
|
+
return `user${Math.floor(Math.random() * Math.pow(10, randomDigits))}`;
|
|
857
|
+
const localPart = email.split("@")[0];
|
|
858
|
+
const username = localPart.toLowerCase().replace(/[^a-z0-9]/g, "").substring(0, 12);
|
|
859
|
+
const randomSuffix = Math.floor(Math.random() * Math.pow(10, randomDigits));
|
|
860
|
+
return username + randomSuffix;
|
|
861
|
+
};
|
|
862
|
+
var generateUsername = (separator = "", randomDigits = 1, length = 8) => {
|
|
863
|
+
const adjectives = [
|
|
864
|
+
"cool",
|
|
865
|
+
"happy",
|
|
866
|
+
"smart",
|
|
867
|
+
"fast",
|
|
868
|
+
"nice",
|
|
869
|
+
"wild",
|
|
870
|
+
"free",
|
|
871
|
+
"bold",
|
|
872
|
+
"calm",
|
|
873
|
+
"brave"
|
|
874
|
+
];
|
|
875
|
+
const nouns = ["cat", "dog", "bird", "fish", "lion", "bear", "wolf", "tiger", "eagle", "shark"];
|
|
876
|
+
const adjective = adjectives[Math.floor(Math.random() * adjectives.length)];
|
|
877
|
+
const noun = nouns[Math.floor(Math.random() * nouns.length)];
|
|
878
|
+
const randomSuffix = Math.floor(Math.random() * Math.pow(10, randomDigits));
|
|
879
|
+
const username = adjective + separator + noun + randomSuffix;
|
|
880
|
+
return username.length > length ? username.substring(0, length) : username;
|
|
881
|
+
};
|
|
882
|
+
var generateSpanishNIF = () => {
|
|
883
|
+
const number = randomInteger(1e7, 99999999);
|
|
884
|
+
const letters = "TRWAGMYFPDXBNJZSQVHLCKE";
|
|
885
|
+
const letter = letters[number % 23];
|
|
886
|
+
return `${number}${letter}`;
|
|
887
|
+
};
|
|
888
|
+
var generateSpanishNIE = () => {
|
|
889
|
+
const prefixes = ["X", "Y", "Z"];
|
|
890
|
+
const selectedPrefix = pickone(prefixes);
|
|
891
|
+
const prefixValue = selectedPrefix === "X" ? 0 : selectedPrefix === "Y" ? 1 : 2;
|
|
892
|
+
const number = randomInteger(1e6, 9999999);
|
|
893
|
+
const letters = "TRWAGMYFPDXBNJZSQVHLCKE";
|
|
894
|
+
const calculationNumber = prefixValue * 1e7 + number;
|
|
895
|
+
const letter = letters[calculationNumber % 23];
|
|
896
|
+
return `${selectedPrefix}${number}${letter}`;
|
|
897
|
+
};
|
|
898
|
+
var generateSpanishCIF = () => {
|
|
899
|
+
const organizationTypes = [
|
|
900
|
+
"A",
|
|
901
|
+
"B",
|
|
902
|
+
"C",
|
|
903
|
+
"D",
|
|
904
|
+
"E",
|
|
905
|
+
"F",
|
|
906
|
+
"G",
|
|
907
|
+
"H",
|
|
908
|
+
"J",
|
|
909
|
+
"N",
|
|
910
|
+
"P",
|
|
911
|
+
"Q",
|
|
912
|
+
"R",
|
|
913
|
+
"S",
|
|
914
|
+
"U",
|
|
915
|
+
"V",
|
|
916
|
+
"W"
|
|
917
|
+
];
|
|
918
|
+
const organizationType = pickone(organizationTypes);
|
|
919
|
+
const number = randomInteger(1e6, 9999999).toString().padStart(7, "0");
|
|
920
|
+
let sum2 = 0;
|
|
921
|
+
for (let i = 0; i < 7; i++) {
|
|
922
|
+
let digit = parseInt(number[i]);
|
|
923
|
+
if (i % 2 === 0) {
|
|
924
|
+
digit *= 2;
|
|
925
|
+
if (digit > 9) digit = Math.floor(digit / 10) + digit % 10;
|
|
926
|
+
}
|
|
927
|
+
sum2 += digit;
|
|
928
|
+
}
|
|
929
|
+
const controlDigit = (10 - sum2 % 10) % 10;
|
|
930
|
+
const controlLetter = "JABCDEFGHI"[controlDigit];
|
|
931
|
+
const control = ["N", "P", "Q", "R", "S", "W"].includes(organizationType) ? controlLetter : randomBool() ? controlDigit.toString() : controlLetter;
|
|
932
|
+
return `${organizationType}${number}${control}`;
|
|
933
|
+
};
|
|
934
|
+
var generateSpanishPostalCode = () => {
|
|
935
|
+
const validPrefixes = [
|
|
936
|
+
"01",
|
|
937
|
+
"02",
|
|
938
|
+
"03",
|
|
939
|
+
"04",
|
|
940
|
+
"05",
|
|
941
|
+
"06",
|
|
942
|
+
"07",
|
|
943
|
+
"08",
|
|
944
|
+
"09",
|
|
945
|
+
"10",
|
|
946
|
+
"11",
|
|
947
|
+
"12",
|
|
948
|
+
"13",
|
|
949
|
+
"14",
|
|
950
|
+
"15",
|
|
951
|
+
"16",
|
|
952
|
+
"17",
|
|
953
|
+
"18",
|
|
954
|
+
"19",
|
|
955
|
+
"20",
|
|
956
|
+
"21",
|
|
957
|
+
"22",
|
|
958
|
+
"23",
|
|
959
|
+
"24",
|
|
960
|
+
"25",
|
|
961
|
+
"26",
|
|
962
|
+
"27",
|
|
963
|
+
"28",
|
|
964
|
+
"29",
|
|
965
|
+
"30",
|
|
966
|
+
"31",
|
|
967
|
+
"32",
|
|
968
|
+
"33",
|
|
969
|
+
"34",
|
|
970
|
+
"35",
|
|
971
|
+
"36",
|
|
972
|
+
"37",
|
|
973
|
+
"38",
|
|
974
|
+
"39",
|
|
975
|
+
"40",
|
|
976
|
+
"41",
|
|
977
|
+
"42",
|
|
978
|
+
"43",
|
|
979
|
+
"44",
|
|
980
|
+
"45",
|
|
981
|
+
"46",
|
|
982
|
+
"47",
|
|
983
|
+
"48",
|
|
984
|
+
"49",
|
|
985
|
+
"50",
|
|
986
|
+
"51",
|
|
987
|
+
"52"
|
|
988
|
+
];
|
|
989
|
+
const firstDigit = pickone(validPrefixes);
|
|
990
|
+
const remainingDigits = randomString(3, "0123456789");
|
|
991
|
+
return `${firstDigit}${remainingDigits}`;
|
|
992
|
+
};
|
|
993
|
+
var generateSpanishIBAN = () => {
|
|
994
|
+
const bankCode = randomString(4, "0123456789");
|
|
995
|
+
const branchCode = randomString(4, "0123456789");
|
|
996
|
+
const controlDigits = randomString(2, "0123456789");
|
|
997
|
+
const accountNumber = randomString(10, "0123456789");
|
|
998
|
+
const accountPart = `${bankCode}${branchCode}${controlDigits}${accountNumber}`;
|
|
999
|
+
const rearranged = `${accountPart}142800`;
|
|
1000
|
+
const checkDigits = String(98n - BigInt(rearranged) % 97n).padStart(2, "0");
|
|
1001
|
+
return `ES${checkDigits}${bankCode}${branchCode}${controlDigits}${accountNumber}`;
|
|
1002
|
+
};
|
|
1003
|
+
var generateEmail = (domain) => {
|
|
1004
|
+
const firstNames = [
|
|
1005
|
+
"Ana",
|
|
1006
|
+
"Carlos",
|
|
1007
|
+
"Mar\xEDa",
|
|
1008
|
+
"Jos\xE9",
|
|
1009
|
+
"Laura",
|
|
1010
|
+
"David",
|
|
1011
|
+
"Carmen",
|
|
1012
|
+
"Antonio",
|
|
1013
|
+
"Isabel",
|
|
1014
|
+
"Manuel"
|
|
1015
|
+
];
|
|
1016
|
+
const lastNames = [
|
|
1017
|
+
"Garc\xEDa",
|
|
1018
|
+
"Gonz\xE1lez",
|
|
1019
|
+
"L\xF3pez",
|
|
1020
|
+
"Mart\xEDnez",
|
|
1021
|
+
"S\xE1nchez",
|
|
1022
|
+
"P\xE9rez",
|
|
1023
|
+
"G\xF3mez",
|
|
1024
|
+
"Mart\xEDn",
|
|
1025
|
+
"Jim\xE9nez",
|
|
1026
|
+
"Ruiz"
|
|
1027
|
+
];
|
|
1028
|
+
const domains = ["gmail.com", "hotmail.com", "yahoo.es", "outlook.com", "test.com"];
|
|
1029
|
+
const firstName = pickone(firstNames);
|
|
1030
|
+
const lastName = pickone(lastNames);
|
|
1031
|
+
const emailDomain = domain || pickone(domains);
|
|
1032
|
+
const formats = [
|
|
1033
|
+
`${firstName.toLowerCase()}.${lastName.toLowerCase()}@${emailDomain}`,
|
|
1034
|
+
`${firstName.toLowerCase()}${randomInteger(1, 99)}@${emailDomain}`,
|
|
1035
|
+
`${firstName.toLowerCase()}.${lastName.toLowerCase()}${randomInteger(1, 9)}@${emailDomain}`,
|
|
1036
|
+
`${firstName.toLowerCase()}${lastName.toLowerCase()}@${emailDomain}`
|
|
1037
|
+
];
|
|
1038
|
+
const username = pickone(formats);
|
|
1039
|
+
return username.toLowerCase();
|
|
1040
|
+
};
|
|
1041
|
+
var generatePassword = (options = {}) => {
|
|
1042
|
+
const {
|
|
1043
|
+
length = 12,
|
|
1044
|
+
includeUppercase = true,
|
|
1045
|
+
includeLowercase = true,
|
|
1046
|
+
includeNumbers = true,
|
|
1047
|
+
includeSymbols = true
|
|
1048
|
+
} = options;
|
|
1049
|
+
const minLength = 4;
|
|
1050
|
+
const maxLength = 30;
|
|
1051
|
+
const targetLength = length || randomInteger(minLength, maxLength);
|
|
1052
|
+
const upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
1053
|
+
const lowerChars = "abcdefghijklmnopqrstuvwxyz";
|
|
1054
|
+
const numberChars = "0123456789";
|
|
1055
|
+
const symbolChars = "!@#$%^&*()_+-=[]{}|;:,.<>?";
|
|
1056
|
+
let charset = "";
|
|
1057
|
+
let requiredChars = "";
|
|
1058
|
+
if (includeUppercase) {
|
|
1059
|
+
charset += upperChars;
|
|
1060
|
+
requiredChars += upperChars.charAt(Math.floor(Math.random() * upperChars.length));
|
|
1061
|
+
}
|
|
1062
|
+
if (includeLowercase) {
|
|
1063
|
+
charset += lowerChars;
|
|
1064
|
+
requiredChars += lowerChars.charAt(Math.floor(Math.random() * lowerChars.length));
|
|
1065
|
+
}
|
|
1066
|
+
if (includeNumbers) {
|
|
1067
|
+
charset += numberChars;
|
|
1068
|
+
requiredChars += numberChars.charAt(Math.floor(Math.random() * numberChars.length));
|
|
1069
|
+
}
|
|
1070
|
+
if (includeSymbols) {
|
|
1071
|
+
charset += symbolChars;
|
|
1072
|
+
requiredChars += symbolChars.charAt(Math.floor(Math.random() * symbolChars.length));
|
|
1073
|
+
}
|
|
1074
|
+
if (!charset) charset = "abcdefghijklmnopqrstuvwxyz";
|
|
1075
|
+
let password = requiredChars;
|
|
1076
|
+
const remainingLength = targetLength - requiredChars.length;
|
|
1077
|
+
for (let i = 0; i < remainingLength; i++) {
|
|
1078
|
+
password += charset.charAt(Math.floor(Math.random() * charset.length));
|
|
1079
|
+
}
|
|
1080
|
+
return password.split("").sort(() => Math.random() - 0.5).join("");
|
|
1081
|
+
};
|
|
1082
|
+
var generateHexColor = (shortFormat) => {
|
|
1083
|
+
const hexChars = "0123456789ABCDEF";
|
|
1084
|
+
const useShortFormat = shortFormat !== void 0 ? shortFormat : randomBool();
|
|
1085
|
+
if (useShortFormat) {
|
|
1086
|
+
const r = pickone(hexChars.split(""));
|
|
1087
|
+
const g2 = pickone(hexChars.split(""));
|
|
1088
|
+
const b = pickone(hexChars.split(""));
|
|
1089
|
+
return `#${r}${g2}${b}`;
|
|
1090
|
+
} else {
|
|
1091
|
+
const color = randomString(6, hexChars);
|
|
1092
|
+
return `#${color}`;
|
|
1093
|
+
}
|
|
1094
|
+
};
|
|
1095
|
+
var isValidNIF = (nif) => {
|
|
1096
|
+
if (!nif || typeof nif !== "string") return false;
|
|
1097
|
+
const cleanNif = nif.trim().toUpperCase();
|
|
1098
|
+
const nifRegex = /^[0-9]{8}[TRWAGMYFPDXBNJZSQVHLCKE]$/;
|
|
1099
|
+
if (!nifRegex.test(cleanNif)) return false;
|
|
1100
|
+
const number = parseInt(cleanNif.substring(0, 8));
|
|
1101
|
+
const letter = cleanNif.charAt(8);
|
|
1102
|
+
const letters = "TRWAGMYFPDXBNJZSQVHLCKE";
|
|
1103
|
+
const expectedLetter = letters[number % 23];
|
|
1104
|
+
return letter === expectedLetter;
|
|
1105
|
+
};
|
|
1106
|
+
var validateNIF = isValidNIF;
|
|
1107
|
+
var isValidNIE = (nie) => {
|
|
1108
|
+
if (!nie || typeof nie !== "string") return false;
|
|
1109
|
+
const cleanNie = nie.trim().toUpperCase();
|
|
1110
|
+
const nieRegex = /^[XYZ][0-9]{7}[TRWAGMYFPDXBNJZSQVHLCKE]$/;
|
|
1111
|
+
if (!nieRegex.test(cleanNie)) return false;
|
|
1112
|
+
const prefix = cleanNie.charAt(0);
|
|
1113
|
+
const number = parseInt(cleanNie.substring(1, 8));
|
|
1114
|
+
const letter = cleanNie.charAt(8);
|
|
1115
|
+
const prefixValue = prefix === "X" ? 0 : prefix === "Y" ? 1 : 2;
|
|
1116
|
+
const calculationNumber = prefixValue * 1e7 + number;
|
|
1117
|
+
const letters = "TRWAGMYFPDXBNJZSQVHLCKE";
|
|
1118
|
+
const expectedLetter = letters[calculationNumber % 23];
|
|
1119
|
+
return letter === expectedLetter;
|
|
1120
|
+
};
|
|
1121
|
+
var isValidCIF = (cif) => {
|
|
1122
|
+
if (!cif || typeof cif !== "string") return false;
|
|
1123
|
+
const cleanCif = cif.trim().toUpperCase();
|
|
1124
|
+
const cifRegex = /^[ABCDEFGHJNPQRSUVW][0-9]{7}[0-9A-J]$/;
|
|
1125
|
+
if (!cifRegex.test(cleanCif)) return false;
|
|
1126
|
+
const organizationType = cleanCif.charAt(0);
|
|
1127
|
+
const number = cleanCif.substring(1, 8);
|
|
1128
|
+
const control = cleanCif.charAt(8);
|
|
1129
|
+
let sum2 = 0;
|
|
1130
|
+
for (let i = 0; i < 7; i++) {
|
|
1131
|
+
let digit = parseInt(number[i]);
|
|
1132
|
+
if (i % 2 === 0) {
|
|
1133
|
+
digit *= 2;
|
|
1134
|
+
if (digit > 9) digit = Math.floor(digit / 10) + digit % 10;
|
|
1135
|
+
}
|
|
1136
|
+
sum2 += digit;
|
|
1137
|
+
}
|
|
1138
|
+
const controlDigit = (10 - sum2 % 10) % 10;
|
|
1139
|
+
const controlLetter = "JABCDEFGHI"[controlDigit];
|
|
1140
|
+
if (["N", "P", "Q", "R", "S", "W"].includes(organizationType)) {
|
|
1141
|
+
return control === controlLetter;
|
|
1142
|
+
} else {
|
|
1143
|
+
return control === controlDigit.toString() || control === controlLetter;
|
|
1144
|
+
}
|
|
1145
|
+
};
|
|
1146
|
+
var isValidSpanishPostalCode = (postalCode) => {
|
|
1147
|
+
if (!postalCode || typeof postalCode !== "string") return false;
|
|
1148
|
+
const cleanCode = postalCode.trim();
|
|
1149
|
+
const postalCodeRegex = /^(0[1-9]|[1-4][0-9]|5[0-2])[0-9]{3}$/;
|
|
1150
|
+
return postalCodeRegex.test(cleanCode);
|
|
1151
|
+
};
|
|
1152
|
+
var isValidSpanishPhone = (phone) => {
|
|
1153
|
+
if (!phone || typeof phone !== "string") return false;
|
|
1154
|
+
const cleanPhone = phone.replace(/[\s\-()]/g, "");
|
|
1155
|
+
const phoneRegex = /^(?:\+34|0034|34)?([679][0-9]{8})$/;
|
|
1156
|
+
return phoneRegex.test(cleanPhone);
|
|
1157
|
+
};
|
|
1158
|
+
var isValidEmail = (email) => {
|
|
1159
|
+
if (!email || typeof email !== "string") return false;
|
|
1160
|
+
return import_validator.default.isEmail(email);
|
|
1161
|
+
};
|
|
1162
|
+
var isValidURL = (url) => {
|
|
1163
|
+
if (!url || typeof url !== "string") return false;
|
|
1164
|
+
if (import_validator.default.isURL(url, { require_protocol: true })) {
|
|
1165
|
+
return true;
|
|
1166
|
+
}
|
|
1167
|
+
try {
|
|
1168
|
+
const urlObj = new URL(url);
|
|
1169
|
+
return urlObj.hostname === "localhost" || urlObj.hostname === "127.0.0.1";
|
|
1170
|
+
} catch {
|
|
1171
|
+
return false;
|
|
1172
|
+
}
|
|
1173
|
+
};
|
|
1174
|
+
var isValidJSON = (str) => {
|
|
1175
|
+
if (!str || typeof str !== "string") return false;
|
|
1176
|
+
try {
|
|
1177
|
+
JSON.parse(str);
|
|
1178
|
+
return true;
|
|
1179
|
+
} catch {
|
|
1180
|
+
return false;
|
|
1181
|
+
}
|
|
1182
|
+
};
|
|
1183
|
+
var isValidSpanishIBAN = (iban) => {
|
|
1184
|
+
if (!iban || typeof iban !== "string") return false;
|
|
1185
|
+
const cleanIban = iban.replace(/\s/g, "").toUpperCase();
|
|
1186
|
+
const ibanRegex = /^ES[0-9]{22}$/;
|
|
1187
|
+
if (!ibanRegex.test(cleanIban)) return false;
|
|
1188
|
+
const rearranged = cleanIban.substring(4) + cleanIban.substring(0, 4);
|
|
1189
|
+
const numericString = rearranged.replace(/[A-Z]/g, (letter) => {
|
|
1190
|
+
return (letter.charCodeAt(0) - 55).toString();
|
|
1191
|
+
});
|
|
1192
|
+
let remainder = 0;
|
|
1193
|
+
for (let i = 0; i < numericString.length; i++) {
|
|
1194
|
+
remainder = (remainder * 10 + parseInt(numericString[i])) % 97;
|
|
1195
|
+
}
|
|
1196
|
+
return remainder === 1;
|
|
1197
|
+
};
|
|
1198
|
+
|
|
1199
|
+
// src/strings.ts
|
|
1200
|
+
var strings_exports = {};
|
|
1201
|
+
__export(strings_exports, {
|
|
1202
|
+
capitalizeEachWord: () => capitalizeEachWord,
|
|
1203
|
+
capitalizeFirst: () => capitalizeFirst,
|
|
1204
|
+
cleanJsonChars: () => cleanJsonChars,
|
|
1205
|
+
contains: () => contains,
|
|
1206
|
+
countOccurrences: () => countOccurrences,
|
|
1207
|
+
endsWith: () => endsWith,
|
|
1208
|
+
ensureEndsWith: () => ensureEndsWith,
|
|
1209
|
+
ensureStartsWith: () => ensureStartsWith,
|
|
1210
|
+
envKeyToPath: () => envKeyToPath,
|
|
1211
|
+
escapeHtmlChars: () => escapeHtmlChars,
|
|
1212
|
+
isEmail: () => isEmail,
|
|
1213
|
+
isEmpty: () => isEmpty,
|
|
1214
|
+
matchPathPattern: () => matchPathPattern,
|
|
1215
|
+
padEnd: () => padEnd,
|
|
1216
|
+
padStart: () => padStart,
|
|
1217
|
+
pathToEnvKey: () => pathToEnvKey,
|
|
1218
|
+
removeAccents: () => removeAccents,
|
|
1219
|
+
repeatString: () => repeatString,
|
|
1220
|
+
replaceAllOccurrences: () => replaceAllOccurrences,
|
|
1221
|
+
reverseString: () => reverseString,
|
|
1222
|
+
sanitizeString: () => sanitizeString,
|
|
1223
|
+
startsWith: () => startsWith,
|
|
1224
|
+
stripFromEnd: () => stripFromEnd,
|
|
1225
|
+
stripFromStart: () => stripFromStart,
|
|
1226
|
+
toCamelCase: () => toCamelCase,
|
|
1227
|
+
toKebabCase: () => toKebabCase,
|
|
1228
|
+
toLowerCase: () => toLowerCase,
|
|
1229
|
+
toPascalCase: () => toPascalCase,
|
|
1230
|
+
toSnakeCase: () => toSnakeCase,
|
|
1231
|
+
toUpperCase: () => toUpperCase,
|
|
1232
|
+
toUrlSlug: () => toUrlSlug,
|
|
1233
|
+
trim: () => trim,
|
|
1234
|
+
trimEnd: () => trimEnd,
|
|
1235
|
+
trimStart: () => trimStart,
|
|
1236
|
+
truncateString: () => truncateString,
|
|
1237
|
+
unescapeHtmlChars: () => unescapeHtmlChars,
|
|
1238
|
+
unescapeUnicode: () => unescapeUnicode
|
|
1239
|
+
});
|
|
1240
|
+
var sanitizeString = (instr) => {
|
|
1241
|
+
if (!instr) return "";
|
|
1242
|
+
return addDash(instr.replace(/[^a-zA-Z0-9 ]/g, "")).toLowerCase();
|
|
1243
|
+
};
|
|
1244
|
+
function addDash(str) {
|
|
1245
|
+
const str2 = str.replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>{}[\]\\/]/gi, "");
|
|
1246
|
+
return str2.replace(/ /g, "-");
|
|
1247
|
+
}
|
|
1248
|
+
var cleanJsonChars = (texto) => {
|
|
1249
|
+
if (!texto) return "";
|
|
1250
|
+
return texto.replace(/({|}|&|amp;|gt;)/g, "");
|
|
1251
|
+
};
|
|
1252
|
+
var truncateString = (str, maxlength = 80, suffix = "...") => {
|
|
1253
|
+
if (!str) return "";
|
|
1254
|
+
return str.length > maxlength ? str.substring(0, maxlength) + suffix : str;
|
|
1255
|
+
};
|
|
1256
|
+
var unescapeUnicode = (input) => {
|
|
1257
|
+
return JSON.stringify(JSON.parse(`"${input}"`)).replace(/^"(.*)"$/, "$1");
|
|
1258
|
+
};
|
|
1259
|
+
var ensureEndsWith = (str, trailing) => {
|
|
1260
|
+
return str.endsWith(trailing) ? str : `${str}${trailing}`;
|
|
1261
|
+
};
|
|
1262
|
+
var stripFromEnd = (str, trailing) => {
|
|
1263
|
+
return str.endsWith(trailing) ? str.slice(0, -1 * trailing.length) : str;
|
|
1264
|
+
};
|
|
1265
|
+
var ensureStartsWith = (str, leading) => {
|
|
1266
|
+
return str.startsWith(leading) ? str : `${leading}${str}`;
|
|
1267
|
+
};
|
|
1268
|
+
var stripFromStart = (str, leading) => {
|
|
1269
|
+
return str.startsWith(leading) ? str.slice(leading.length) : str;
|
|
1270
|
+
};
|
|
1271
|
+
var toLowerCase = (str) => {
|
|
1272
|
+
return str.toLowerCase();
|
|
1273
|
+
};
|
|
1274
|
+
var toUpperCase = (str) => {
|
|
1275
|
+
return str.toUpperCase();
|
|
1276
|
+
};
|
|
1277
|
+
var capitalizeFirst = (str) => {
|
|
1278
|
+
if (!str) return "";
|
|
1279
|
+
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
1280
|
+
};
|
|
1281
|
+
var capitalizeEachWord = (str) => {
|
|
1282
|
+
if (!str) return "";
|
|
1283
|
+
return str.split(" ").map((word) => capitalizeFirst(word)).join(" ");
|
|
1284
|
+
};
|
|
1285
|
+
var toCamelCase = (str) => {
|
|
1286
|
+
if (!str) return "";
|
|
1287
|
+
const words = str.replace(/([a-z])([A-Z])/g, "$1 $2").split(/[-_\s]+/).filter((word) => word.length > 0).map((word) => word.toLowerCase());
|
|
1288
|
+
if (words.length === 0) return "";
|
|
1289
|
+
return words[0] + words.slice(1).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
|
|
1290
|
+
};
|
|
1291
|
+
var toSnakeCase = (str) => {
|
|
1292
|
+
if (!str) return "";
|
|
1293
|
+
return str.replace(/\W+/g, " ").split(/ |\B(?=[A-Z])/).map((word) => word.toLowerCase()).join("_");
|
|
1294
|
+
};
|
|
1295
|
+
var toKebabCase = (str) => {
|
|
1296
|
+
if (!str) return "";
|
|
1297
|
+
return str.replace(/[_\s]+/g, "-").replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
1298
|
+
};
|
|
1299
|
+
var toPascalCase = (str) => {
|
|
1300
|
+
if (!str) return "";
|
|
1301
|
+
return str.replace(/[-_\s]+(.)?/g, (_, char) => char ? char.toUpperCase() : "").replace(/^./, (char) => char.toUpperCase());
|
|
1302
|
+
};
|
|
1303
|
+
var contains = (str, searchStr, caseSensitive = false) => {
|
|
1304
|
+
if (caseSensitive) {
|
|
1305
|
+
return str.includes(searchStr);
|
|
1306
|
+
}
|
|
1307
|
+
return str.toLowerCase().includes(searchStr.toLowerCase());
|
|
1308
|
+
};
|
|
1309
|
+
var startsWith = (str, searchStr, caseSensitive = false) => {
|
|
1310
|
+
if (caseSensitive) {
|
|
1311
|
+
return str.startsWith(searchStr);
|
|
1312
|
+
}
|
|
1313
|
+
return str.toLowerCase().startsWith(searchStr.toLowerCase());
|
|
1314
|
+
};
|
|
1315
|
+
var endsWith = (str, searchStr, caseSensitive = false) => {
|
|
1316
|
+
if (caseSensitive) {
|
|
1317
|
+
return str.endsWith(searchStr);
|
|
1318
|
+
}
|
|
1319
|
+
return str.toLowerCase().endsWith(searchStr.toLowerCase());
|
|
1320
|
+
};
|
|
1321
|
+
var padStart = (str, length, padChar = " ") => {
|
|
1322
|
+
return str.padStart(length, padChar);
|
|
1323
|
+
};
|
|
1324
|
+
var padEnd = (str, length, padChar = " ") => {
|
|
1325
|
+
if (str.length >= length) return str;
|
|
1326
|
+
return str + padChar.repeat(length - str.length);
|
|
1327
|
+
};
|
|
1328
|
+
var trim = (str) => {
|
|
1329
|
+
return str.trim();
|
|
1330
|
+
};
|
|
1331
|
+
var trimStart = (str) => {
|
|
1332
|
+
return str.trimStart();
|
|
1333
|
+
};
|
|
1334
|
+
var trimEnd = (str) => {
|
|
1335
|
+
return str.trimEnd();
|
|
1336
|
+
};
|
|
1337
|
+
var reverseString = (str) => {
|
|
1338
|
+
return str.split("").reverse().join("");
|
|
1339
|
+
};
|
|
1340
|
+
var repeatString = (str, times) => {
|
|
1341
|
+
return str.repeat(times);
|
|
1342
|
+
};
|
|
1343
|
+
var replaceAllOccurrences = (str, searchStr, replaceStr) => {
|
|
1344
|
+
return str.split(searchStr).join(replaceStr);
|
|
1345
|
+
};
|
|
1346
|
+
var countOccurrences = (str, searchStr) => {
|
|
1347
|
+
if (!searchStr) return 0;
|
|
1348
|
+
let count = 0;
|
|
1349
|
+
let position = 0;
|
|
1350
|
+
while ((position = str.indexOf(searchStr, position)) !== -1) {
|
|
1351
|
+
count++;
|
|
1352
|
+
position += 1;
|
|
1353
|
+
}
|
|
1354
|
+
return count;
|
|
1355
|
+
};
|
|
1356
|
+
var isEmpty = (str) => {
|
|
1357
|
+
return !str || str.trim().length === 0;
|
|
1358
|
+
};
|
|
1359
|
+
var isEmail = (str) => {
|
|
1360
|
+
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
1361
|
+
return re.test(str.toLowerCase());
|
|
1362
|
+
};
|
|
1363
|
+
var toUrlSlug = (str) => {
|
|
1364
|
+
return str.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
1365
|
+
};
|
|
1366
|
+
var removeAccents = (str) => {
|
|
1367
|
+
return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
|
1368
|
+
};
|
|
1369
|
+
var escapeHtmlChars = (str) => {
|
|
1370
|
+
const htmlEscapes = {
|
|
1371
|
+
"&": "&",
|
|
1372
|
+
"<": "<",
|
|
1373
|
+
">": ">",
|
|
1374
|
+
'"': """,
|
|
1375
|
+
"'": "'"
|
|
1376
|
+
};
|
|
1377
|
+
return str.replace(/[&<>"']/g, (match) => htmlEscapes[match]);
|
|
1378
|
+
};
|
|
1379
|
+
var unescapeHtmlChars = (str) => {
|
|
1380
|
+
const htmlUnescapes = {
|
|
1381
|
+
"&": "&",
|
|
1382
|
+
"<": "<",
|
|
1383
|
+
">": ">",
|
|
1384
|
+
""": '"',
|
|
1385
|
+
"'": "'"
|
|
1386
|
+
};
|
|
1387
|
+
return str.replace(/&|<|>|"|'/g, (match) => htmlUnescapes[match]);
|
|
1388
|
+
};
|
|
1389
|
+
function matchPathPattern(path, pattern) {
|
|
1390
|
+
if (!path || typeof path !== "string" || !pattern || typeof pattern !== "string") {
|
|
1391
|
+
return false;
|
|
1392
|
+
}
|
|
1393
|
+
if (path === pattern) {
|
|
1394
|
+
return true;
|
|
1395
|
+
}
|
|
1396
|
+
if (!pattern.includes("*")) {
|
|
1397
|
+
return path === pattern;
|
|
1398
|
+
}
|
|
1399
|
+
const regexPattern = pattern.split(".").map((segment) => {
|
|
1400
|
+
if (segment === "*") {
|
|
1401
|
+
return "[^.]+";
|
|
1402
|
+
}
|
|
1403
|
+
return segment.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1404
|
+
}).join("\\.");
|
|
1405
|
+
const regex = new RegExp(`^${regexPattern}$`);
|
|
1406
|
+
return regex.test(path);
|
|
1407
|
+
}
|
|
1408
|
+
function envKeyToPath(envKey, prefix = "NX") {
|
|
1409
|
+
if (!envKey || typeof envKey !== "string") {
|
|
1410
|
+
return "";
|
|
1411
|
+
}
|
|
1412
|
+
let key = envKey.trim();
|
|
1413
|
+
if (prefix && key.startsWith(`${prefix}_`)) {
|
|
1414
|
+
key = key.substring(prefix.length + 1);
|
|
1415
|
+
}
|
|
1416
|
+
return key.toLowerCase().replace(/_/g, ".");
|
|
1417
|
+
}
|
|
1418
|
+
function pathToEnvKey(path, prefix = "NX") {
|
|
1419
|
+
if (!path || typeof path !== "string") {
|
|
1420
|
+
return "";
|
|
1421
|
+
}
|
|
1422
|
+
const key = path.trim().toUpperCase().replace(/\./g, "_");
|
|
1423
|
+
if (key.length === 0) {
|
|
1424
|
+
return "";
|
|
1425
|
+
}
|
|
1426
|
+
if (prefix && prefix.length > 0) {
|
|
1427
|
+
return `${prefix.toUpperCase()}_${key}`;
|
|
1428
|
+
}
|
|
1429
|
+
return key;
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
// src/objects.ts
|
|
1433
|
+
var objects_exports = {};
|
|
1434
|
+
__export(objects_exports, {
|
|
1435
|
+
calculateDifferences: () => calculateDifferences,
|
|
1436
|
+
comparator: () => comparator,
|
|
1437
|
+
deepEqual: () => deepEqual,
|
|
1438
|
+
deleteArrayElementsBy: () => deleteArrayElementsBy,
|
|
1439
|
+
formatToReadableString: () => formatToReadableString,
|
|
1440
|
+
generateCrcHash: () => generateCrcHash,
|
|
1441
|
+
getDeepValue: () => getDeepValue,
|
|
1442
|
+
getShallowProperties: () => getShallowProperties,
|
|
1443
|
+
hasSameType: () => hasSameType,
|
|
1444
|
+
setDeepValue: () => setDeepValue,
|
|
1445
|
+
updateArrayElementById: () => updateArrayElementById,
|
|
1446
|
+
updateArrayElementsBy: () => updateArrayElementsBy
|
|
1447
|
+
});
|
|
1448
|
+
var import_crc32 = __toESM(require("crc/crc32"));
|
|
1449
|
+
var lodash = __toESM(require("lodash"));
|
|
1450
|
+
var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
|
|
1451
|
+
|
|
1452
|
+
// src/dates.ts
|
|
1453
|
+
var dates_exports = {};
|
|
1454
|
+
__export(dates_exports, {
|
|
1455
|
+
addDays: () => addDays,
|
|
1456
|
+
addMonths: () => addMonths,
|
|
1457
|
+
addNowDays: () => addNowDays,
|
|
1458
|
+
addNowMonths: () => addNowMonths,
|
|
1459
|
+
addNowSeconds: () => addNowSeconds,
|
|
1460
|
+
addNowYears: () => addNowYears,
|
|
1461
|
+
addSeconds: () => addSeconds,
|
|
1462
|
+
addYears: () => addYears,
|
|
1463
|
+
areDatesEqualWithTolerance: () => areDatesEqualWithTolerance,
|
|
1464
|
+
dayOfWeek: () => dayOfWeek,
|
|
1465
|
+
diffBusinessDays: () => diffBusinessDays,
|
|
1466
|
+
diffDays: () => diffDays,
|
|
1467
|
+
diffMilliSeconds: () => diffMilliSeconds,
|
|
1468
|
+
diffMonths: () => diffMonths,
|
|
1469
|
+
diffYears: () => diffYears,
|
|
1470
|
+
excelToDate: () => excelToDate,
|
|
1471
|
+
format: () => format,
|
|
1472
|
+
formatForMysql: () => formatForMysql,
|
|
1473
|
+
formatNow: () => formatNow,
|
|
1474
|
+
fromNow: () => fromNow,
|
|
1475
|
+
getFirstDayOfYear: () => getFirstDayOfYear,
|
|
1476
|
+
getFirstWorkdayAfterMonths: () => getFirstWorkdayAfterMonths,
|
|
1477
|
+
getFirstWorkdayOfMonth: () => getFirstWorkdayOfMonth,
|
|
1478
|
+
getLastDayOfYear: () => getLastDayOfYear,
|
|
1479
|
+
getLastWorkdayOfMonth: () => getLastWorkdayOfMonth,
|
|
1480
|
+
isDateTime: () => isDateTime,
|
|
1481
|
+
isEqualsDateTimeByDay: () => isEqualsDateTimeByDay,
|
|
1482
|
+
isExpired: () => isExpired,
|
|
1483
|
+
isNew: () => isNew,
|
|
1484
|
+
isWeekday: () => isWeekday,
|
|
1485
|
+
longString: () => longString,
|
|
1486
|
+
now: () => now,
|
|
1487
|
+
toDate: () => toDate,
|
|
1488
|
+
toDateFromString: () => toDateFromString,
|
|
1489
|
+
toISO: () => toISO,
|
|
1490
|
+
weekOfYear: () => weekOfYear
|
|
1491
|
+
});
|
|
1492
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
1493
|
+
var import_utc = __toESM(require("dayjs/plugin/utc.js"));
|
|
1494
|
+
var import_relativeTime = __toESM(require("dayjs/plugin/relativeTime.js"));
|
|
1495
|
+
var import_weekOfYear = __toESM(require("dayjs/plugin/weekOfYear.js"));
|
|
1496
|
+
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat.js"));
|
|
1497
|
+
var import_isSameOrAfter = __toESM(require("dayjs/plugin/isSameOrAfter.js"));
|
|
1498
|
+
var import_isSameOrBefore = __toESM(require("dayjs/plugin/isSameOrBefore.js"));
|
|
1499
|
+
var import_weekday = __toESM(require("dayjs/plugin/weekday.js"));
|
|
1500
|
+
var import_localeData = __toESM(require("dayjs/plugin/localeData.js"));
|
|
1501
|
+
var import_localizedFormat = __toESM(require("dayjs/plugin/localizedFormat.js"));
|
|
1502
|
+
var import_es = require("dayjs/locale/es.js");
|
|
1503
|
+
var dateValidator = __toESM(require("iso-datestring-validator"));
|
|
1504
|
+
var { isValidDate, isValidISODateString } = dateValidator;
|
|
1505
|
+
import_dayjs.default.extend(import_utc.default);
|
|
1506
|
+
import_dayjs.default.extend(import_relativeTime.default);
|
|
1507
|
+
import_dayjs.default.extend(import_weekOfYear.default);
|
|
1508
|
+
import_dayjs.default.extend(import_customParseFormat.default);
|
|
1509
|
+
import_dayjs.default.extend(import_isSameOrAfter.default);
|
|
1510
|
+
import_dayjs.default.extend(import_isSameOrBefore.default);
|
|
1511
|
+
import_dayjs.default.extend(import_weekday.default);
|
|
1512
|
+
import_dayjs.default.extend(import_localeData.default);
|
|
1513
|
+
import_dayjs.default.extend(import_localizedFormat.default);
|
|
1514
|
+
import_dayjs.default.locale("es");
|
|
1515
|
+
var formatNow = (formatStr = "DD/MM/YYYY") => (0, import_dayjs.default)().format(formatStr);
|
|
1516
|
+
var format = (value, formatStr = "DD/MM/YYYY") => {
|
|
1517
|
+
if (!value) return "";
|
|
1518
|
+
if (formatStr.toLowerCase() === "gg") return weekOfYear(value);
|
|
1519
|
+
else if (formatStr.toLowerCase() === "gggg") return (0, import_dayjs.default)(value).format("YY") + weekOfYear(value);
|
|
1520
|
+
return (0, import_dayjs.default)(value).format(formatStr);
|
|
1521
|
+
};
|
|
1522
|
+
var longString = (value = null) => {
|
|
1523
|
+
if (!value) return "";
|
|
1524
|
+
return (0, import_dayjs.default)(value).format("LL");
|
|
1525
|
+
};
|
|
1526
|
+
var toDate = (value, isUtc) => {
|
|
1527
|
+
if (isUtc === void 0) return (0, import_dayjs.default)(value).toDate();
|
|
1528
|
+
return isUtc ? import_dayjs.default.utc(value).toDate() : (0, import_dayjs.default)(value).toDate();
|
|
1529
|
+
};
|
|
1530
|
+
var toDateFromString = (dateString, format2) => {
|
|
1531
|
+
const formatRegex = {
|
|
1532
|
+
"DD/MM/YYYY": /^(\d{2})\/(\d{2})\/(\d{4})$/,
|
|
1533
|
+
"YYYY-MM-DD": /^(\d{4})-(\d{2})-(\d{2})$/,
|
|
1534
|
+
"MM/DD/YYYY": /^(\d{2})\/(\d{2})\/(\d{4})$/,
|
|
1535
|
+
"YYYY/MM/DD": /^(\d{4})\/(\d{2})\/(\d{2})$/,
|
|
1536
|
+
"DD-MM-YYYY": /^(\d{2})-(\d{2})-(\d{4})$/,
|
|
1537
|
+
"MM-DD-YYYY": /^(\d{2})-(\d{2})-(\d{4})$/,
|
|
1538
|
+
YYYYMMDD: /^(\d{4})(\d{2})(\d{2})$/,
|
|
1539
|
+
DDMMYYYY: /^(\d{2})(\d{2})(\d{4})$/,
|
|
1540
|
+
MMDDYYYY: /^(\d{2})(\d{2})(\d{4})$/,
|
|
1541
|
+
"YYYY.MM.DD": /^(\d{4})\.(\d{2})\.(\d{2})$/,
|
|
1542
|
+
"DD.MM.YYYY": /^(\d{2})\.(\d{2})\.(\d{4})$/,
|
|
1543
|
+
"MM.DD.YYYY": /^(\d{2})\.(\d{2})\.(\d{4})$/
|
|
1544
|
+
};
|
|
1545
|
+
const regex = formatRegex[format2];
|
|
1546
|
+
if (!regex) return null;
|
|
1547
|
+
const match = dateString.match(regex);
|
|
1548
|
+
if (match) {
|
|
1549
|
+
let year, month, day;
|
|
1550
|
+
if (format2.startsWith("YYYY")) {
|
|
1551
|
+
year = parseInt(match[1], 10);
|
|
1552
|
+
month = parseInt(match[2], 10) - 1;
|
|
1553
|
+
day = parseInt(match[3], 10);
|
|
1554
|
+
} else if (format2.startsWith("DD")) {
|
|
1555
|
+
day = parseInt(match[1], 10);
|
|
1556
|
+
month = parseInt(match[2], 10) - 1;
|
|
1557
|
+
year = parseInt(match[3], 10);
|
|
1558
|
+
} else if (format2.startsWith("MM")) {
|
|
1559
|
+
month = parseInt(match[1], 10) - 1;
|
|
1560
|
+
day = parseInt(match[2], 10);
|
|
1561
|
+
year = parseInt(match[3], 10);
|
|
1562
|
+
} else {
|
|
1563
|
+
return null;
|
|
1564
|
+
}
|
|
1565
|
+
return new Date(year, month, day);
|
|
1566
|
+
}
|
|
1567
|
+
return null;
|
|
1568
|
+
};
|
|
1569
|
+
var now = () => (0, import_dayjs.default)().toDate();
|
|
1570
|
+
var isNew = (value, daysnew = 1) => (0, import_dayjs.default)().isSameOrBefore((0, import_dayjs.default)(value).add(daysnew, "days"));
|
|
1571
|
+
var toISO = (value = null, isUtc = false) => {
|
|
1572
|
+
if (!value) return (0, import_dayjs.default)().toISOString();
|
|
1573
|
+
return isUtc ? import_dayjs.default.utc(value).toISOString() : (0, import_dayjs.default)(value).toISOString();
|
|
1574
|
+
};
|
|
1575
|
+
var fromNow = (value) => (0, import_dayjs.default)(value).fromNow();
|
|
1576
|
+
var dayOfWeek = (value = null) => {
|
|
1577
|
+
if (!value) return (0, import_dayjs.default)().format("d");
|
|
1578
|
+
return (0, import_dayjs.default)(value).format("d");
|
|
1579
|
+
};
|
|
1580
|
+
var weekOfYear = (value = null) => {
|
|
1581
|
+
if (!value) return (0, import_dayjs.default)().locale("es").week().toString().padStart(2, "0");
|
|
1582
|
+
return (0, import_dayjs.default)(value).locale("es").week().toString().padStart(2, "0");
|
|
1583
|
+
};
|
|
1584
|
+
var diffDays = (start, end = null, precise = false) => {
|
|
1585
|
+
const v2 = !end ? (0, import_dayjs.default)() : (0, import_dayjs.default)(end);
|
|
1586
|
+
return (0, import_dayjs.default)(start).diff(v2, "days", precise);
|
|
1587
|
+
};
|
|
1588
|
+
var diffBusinessDays = (start, end = null, precise = false) => {
|
|
1589
|
+
let startDate = (0, import_dayjs.default)(start).startOf("day");
|
|
1590
|
+
let endDate = end ? (0, import_dayjs.default)(end).startOf("day") : (0, import_dayjs.default)().startOf("day");
|
|
1591
|
+
if (startDate.isAfter(endDate)) {
|
|
1592
|
+
;
|
|
1593
|
+
[startDate, endDate] = [endDate, startDate];
|
|
1594
|
+
}
|
|
1595
|
+
let businessDays = 0;
|
|
1596
|
+
let currentDate = startDate;
|
|
1597
|
+
while (currentDate.isBefore(endDate)) {
|
|
1598
|
+
if (isWeekday(currentDate)) {
|
|
1599
|
+
businessDays++;
|
|
1600
|
+
}
|
|
1601
|
+
currentDate = currentDate.add(1, "day");
|
|
1602
|
+
}
|
|
1603
|
+
if (precise) {
|
|
1604
|
+
const fractionalDay = endDate.diff(currentDate, "hours") / 24;
|
|
1605
|
+
businessDays += fractionalDay;
|
|
1606
|
+
}
|
|
1607
|
+
return businessDays;
|
|
1608
|
+
};
|
|
1609
|
+
var diffMonths = (value, valueRefOrNow = null, precise = false) => {
|
|
1610
|
+
const v2 = !valueRefOrNow ? (0, import_dayjs.default)() : (0, import_dayjs.default)(valueRefOrNow);
|
|
1611
|
+
return (0, import_dayjs.default)(value).diff(v2, "months", precise);
|
|
1612
|
+
};
|
|
1613
|
+
var diffYears = (value, valueRefOrNow = null, precise = false) => {
|
|
1614
|
+
const v2 = !valueRefOrNow ? (0, import_dayjs.default)() : (0, import_dayjs.default)(valueRefOrNow);
|
|
1615
|
+
return (0, import_dayjs.default)(value).diff(v2, "years", precise);
|
|
1616
|
+
};
|
|
1617
|
+
var diffMilliSeconds = (value, valueRefOrNow = null) => {
|
|
1618
|
+
const v2 = !valueRefOrNow ? (0, import_dayjs.default)() : (0, import_dayjs.default)(valueRefOrNow);
|
|
1619
|
+
return (0, import_dayjs.default)(value).diff(v2, "milliseconds", true);
|
|
1620
|
+
};
|
|
1621
|
+
var addDays = (value, nDays = 1) => (0, import_dayjs.default)(value).add(nDays, "days").toDate();
|
|
1622
|
+
var addSeconds = (value, nSeconds = 1) => (0, import_dayjs.default)(value).add(nSeconds, "seconds").toDate();
|
|
1623
|
+
var areDatesEqualWithTolerance = (date1, date2) => {
|
|
1624
|
+
const tolerance = 2 * 1e3;
|
|
1625
|
+
return Math.abs((0, import_dayjs.default)(date1).diff((0, import_dayjs.default)(date2))) <= tolerance;
|
|
1626
|
+
};
|
|
1627
|
+
var addNowDays = (nDays = 1) => (0, import_dayjs.default)().add(nDays, "days").toDate();
|
|
1628
|
+
var addNowSeconds = (nSeconds = 60) => (0, import_dayjs.default)().add(nSeconds, "seconds").toDate();
|
|
1629
|
+
var addMonths = (value, nMonths = 1) => (0, import_dayjs.default)(value).add(nMonths, "months").toDate();
|
|
1630
|
+
var addNowMonths = (nMonths = 1) => (0, import_dayjs.default)().add(nMonths, "months").toDate();
|
|
1631
|
+
var addYears = (value, nYears = 1) => (0, import_dayjs.default)(value).add(nYears, "years").toDate();
|
|
1632
|
+
var addNowYears = (nYears = 1) => (0, import_dayjs.default)().add(nYears, "years").toDate();
|
|
1633
|
+
var excelToDate = (value) => {
|
|
1634
|
+
try {
|
|
1635
|
+
const d = Number(value);
|
|
1636
|
+
if (d >= 18e3 && d <= 3e5) return new Date(Math.round((d - 25569) * 86400 * 1e3));
|
|
1637
|
+
return null;
|
|
1638
|
+
} catch (_err) {
|
|
1639
|
+
return null;
|
|
1640
|
+
}
|
|
1641
|
+
};
|
|
1642
|
+
var isDateTime = (value) => {
|
|
1643
|
+
try {
|
|
1644
|
+
if (!value) return false;
|
|
1645
|
+
if (typeof value === "number") return false;
|
|
1646
|
+
else if (typeof value === "boolean") return false;
|
|
1647
|
+
else if (typeof value === "string" && !isValidISODateString(value) && !isValidDate(value) && !isValidDate(value, ""))
|
|
1648
|
+
return false;
|
|
1649
|
+
else if (typeof value === "object" && !(value instanceof Date) && !import_dayjs.default.isDayjs(value))
|
|
1650
|
+
return false;
|
|
1651
|
+
return (0, import_dayjs.default)(value).isValid();
|
|
1652
|
+
} catch (_err) {
|
|
1653
|
+
return false;
|
|
1654
|
+
}
|
|
1655
|
+
};
|
|
1656
|
+
var isEqualsDateTimeByDay = (value1, value2) => {
|
|
1657
|
+
if (!isDateTime(value1)) return false;
|
|
1658
|
+
if (!isDateTime(value2)) return false;
|
|
1659
|
+
return (0, import_dayjs.default)(value1).isSame((0, import_dayjs.default)(value2), "day");
|
|
1660
|
+
};
|
|
1661
|
+
var isExpired = (value, valueRefOrNow = null) => {
|
|
1662
|
+
const v2 = !valueRefOrNow ? (0, import_dayjs.default)() : (0, import_dayjs.default)(valueRefOrNow);
|
|
1663
|
+
if (isDateTime(value)) {
|
|
1664
|
+
return v2.isAfter(value);
|
|
1665
|
+
}
|
|
1666
|
+
return true;
|
|
1667
|
+
};
|
|
1668
|
+
var formatForMysql = (fecha) => {
|
|
1669
|
+
if (!fecha) return null;
|
|
1670
|
+
fecha.setMinutes(fecha.getMinutes() - fecha.getTimezoneOffset());
|
|
1671
|
+
return fecha.toISOString().slice(0, 19).replace("T", " ");
|
|
1672
|
+
};
|
|
1673
|
+
var getFirstWorkdayOfMonth = (month) => {
|
|
1674
|
+
const monthToUse = month === void 0 ? (0, import_dayjs.default)().month() : month;
|
|
1675
|
+
let firstDay = (0, import_dayjs.default)().month(monthToUse).startOf("month");
|
|
1676
|
+
while (firstDay.day() === 0 || firstDay.day() === 6) {
|
|
1677
|
+
firstDay = firstDay.add(1, "day");
|
|
1678
|
+
}
|
|
1679
|
+
return firstDay.toDate();
|
|
1680
|
+
};
|
|
1681
|
+
var getLastWorkdayOfMonth = (month) => {
|
|
1682
|
+
const monthToUse = month === void 0 ? (0, import_dayjs.default)().month() : month;
|
|
1683
|
+
let lastDay = (0, import_dayjs.default)().month(monthToUse).endOf("month");
|
|
1684
|
+
while (lastDay.day() === 0 || lastDay.day() === 6) {
|
|
1685
|
+
lastDay = lastDay.subtract(1, "day");
|
|
1686
|
+
}
|
|
1687
|
+
return lastDay.toDate();
|
|
1688
|
+
};
|
|
1689
|
+
var getFirstWorkdayAfterMonths = (initialDate, n) => {
|
|
1690
|
+
const startDate = (0, import_dayjs.default)(initialDate);
|
|
1691
|
+
const monthsToAdd = n;
|
|
1692
|
+
const targetDate = startDate.add(monthsToAdd, "months");
|
|
1693
|
+
let firstWorkday = targetDate.startOf("month");
|
|
1694
|
+
while (firstWorkday.day() === 0 || firstWorkday.day() === 6) {
|
|
1695
|
+
firstWorkday = firstWorkday.add(1, "day");
|
|
1696
|
+
}
|
|
1697
|
+
return firstWorkday.toDate();
|
|
1698
|
+
};
|
|
1699
|
+
var getFirstDayOfYear = () => (0, import_dayjs.default)().startOf("year").toDate();
|
|
1700
|
+
var getLastDayOfYear = () => (0, import_dayjs.default)().endOf("year").toDate();
|
|
1701
|
+
var isWeekday = (date) => {
|
|
1702
|
+
const d = (0, import_dayjs.default)(date);
|
|
1703
|
+
const dayOfWeek2 = d.day();
|
|
1704
|
+
return dayOfWeek2 !== 0 && dayOfWeek2 !== 6;
|
|
1705
|
+
};
|
|
1706
|
+
|
|
1707
|
+
// src/objects.ts
|
|
1708
|
+
var {
|
|
1709
|
+
isArray,
|
|
1710
|
+
isArrayBuffer,
|
|
1711
|
+
isBoolean,
|
|
1712
|
+
isBuffer,
|
|
1713
|
+
isEqual,
|
|
1714
|
+
isNil,
|
|
1715
|
+
isNumber,
|
|
1716
|
+
isObject,
|
|
1717
|
+
isPlainObject,
|
|
1718
|
+
isString,
|
|
1719
|
+
isTypedArray,
|
|
1720
|
+
transform
|
|
1721
|
+
} = lodash;
|
|
1722
|
+
var nativeFilter = (array, predicate) => {
|
|
1723
|
+
return array.filter((item) => {
|
|
1724
|
+
return Object.keys(predicate).every((key) => item[key] === predicate[key]);
|
|
1725
|
+
});
|
|
1726
|
+
};
|
|
1727
|
+
var nativeAssign = (target, source) => {
|
|
1728
|
+
return Object.assign(target, source);
|
|
1729
|
+
};
|
|
1730
|
+
var nativePick = (object, keys) => {
|
|
1731
|
+
const result = {};
|
|
1732
|
+
keys.forEach((key) => {
|
|
1733
|
+
if (key in object) {
|
|
1734
|
+
result[key] = object[key];
|
|
1735
|
+
}
|
|
1736
|
+
});
|
|
1737
|
+
return result;
|
|
1738
|
+
};
|
|
1739
|
+
var nativeRemove = (array, predicate) => {
|
|
1740
|
+
const removed = [];
|
|
1741
|
+
for (let i = array.length - 1; i >= 0; i--) {
|
|
1742
|
+
if (predicate(array[i])) {
|
|
1743
|
+
removed.unshift(array.splice(i, 1)[0]);
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
return removed;
|
|
1747
|
+
};
|
|
1748
|
+
var comparator = (data1, data2) => isEqual(data1, data2);
|
|
1749
|
+
var deepEqual = (data1, data2) => (0, import_fast_deep_equal.default)(data1, data2);
|
|
1750
|
+
var formatToReadableString = (data) => JSON.stringify(data).replace(/[{}"]/g, "").replace(/,/g, ", ");
|
|
1751
|
+
var getShallowProperties = (obj) => {
|
|
1752
|
+
if (!obj) return {};
|
|
1753
|
+
const topLevelProps = {};
|
|
1754
|
+
for (const prop in obj) {
|
|
1755
|
+
if (Object.hasOwnProperty.call(obj, prop)) {
|
|
1756
|
+
const value = obj[prop];
|
|
1757
|
+
const type = typeof value;
|
|
1758
|
+
if (type !== "object" && type !== "function" || value === null) {
|
|
1759
|
+
topLevelProps[prop] = value;
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
return topLevelProps;
|
|
1764
|
+
};
|
|
1765
|
+
var calculateDifferences = (oldObj, newObj) => {
|
|
1766
|
+
return transform(
|
|
1767
|
+
newObj,
|
|
1768
|
+
(result, value, key) => {
|
|
1769
|
+
const oldValue = oldObj[key];
|
|
1770
|
+
if (isDateTime(value) && isDateTime(oldValue)) {
|
|
1771
|
+
if (!areDatesEqualWithTolerance(toDate(value), toDate(oldValue))) {
|
|
1772
|
+
result[key] = value;
|
|
1773
|
+
}
|
|
1774
|
+
} else if (!isEqual(value, oldValue)) {
|
|
1775
|
+
result[key] = value;
|
|
1776
|
+
}
|
|
1777
|
+
},
|
|
1778
|
+
{}
|
|
1779
|
+
);
|
|
1780
|
+
};
|
|
1781
|
+
var generateCrcHash = (str) => {
|
|
1782
|
+
if (isNil(str)) return (0, import_crc32.default)("-").toString(16);
|
|
1783
|
+
if (isString(str)) return (0, import_crc32.default)(str).toString(16);
|
|
1784
|
+
if (isBuffer(str)) return (0, import_crc32.default)(str).toString(16);
|
|
1785
|
+
if (isArrayBuffer(str)) return (0, import_crc32.default)(str).toString(16);
|
|
1786
|
+
if (isBoolean(str)) return (0, import_crc32.default)(str ? "true" : "false").toString(16);
|
|
1787
|
+
if (isNumber(str)) return (0, import_crc32.default)(str.toString()).toString(16);
|
|
1788
|
+
if (isArray(str) || isObject(str)) return generateCrcHash(JSON.stringify(str));
|
|
1789
|
+
return (0, import_crc32.default)(str || "").toString(16);
|
|
1790
|
+
};
|
|
1791
|
+
var hasSameType = (sourceTarget, destinationTarget) => {
|
|
1792
|
+
if (isArray(sourceTarget) && isArray(destinationTarget)) return true;
|
|
1793
|
+
if (isArray(sourceTarget) !== isArray(destinationTarget)) return false;
|
|
1794
|
+
if (isTypedArray(sourceTarget) && isTypedArray(destinationTarget)) {
|
|
1795
|
+
if (Object.prototype.toString.call(sourceTarget) === Object.prototype.toString.call(destinationTarget))
|
|
1796
|
+
return true;
|
|
1797
|
+
else return false;
|
|
1798
|
+
}
|
|
1799
|
+
if (isTypedArray(sourceTarget) !== isTypedArray(destinationTarget)) return false;
|
|
1800
|
+
if (isPlainObject(sourceTarget) && isPlainObject(destinationTarget)) return true;
|
|
1801
|
+
if (isPlainObject(sourceTarget) !== isPlainObject(destinationTarget)) return false;
|
|
1802
|
+
return typeof sourceTarget === typeof destinationTarget;
|
|
1803
|
+
};
|
|
1804
|
+
var updateArrayElementsBy = (data, objUpd, objSearch) => {
|
|
1805
|
+
nativeFilter(data, objSearch).forEach((element) => nativeAssign(element, objUpd));
|
|
1806
|
+
return data;
|
|
1807
|
+
};
|
|
1808
|
+
var updateArrayElementById = (data, objUpd, idField) => {
|
|
1809
|
+
const index = data.findIndex((x) => x[idField] === objUpd[idField]);
|
|
1810
|
+
if (index !== -1) data.splice(index, 1, objUpd);
|
|
1811
|
+
};
|
|
1812
|
+
var deleteArrayElementsBy = (data, objSearch) => {
|
|
1813
|
+
nativeRemove(data, (x) => deepEqual(nativePick(x, Object.keys(objSearch)), objSearch));
|
|
1814
|
+
return data;
|
|
1815
|
+
};
|
|
1816
|
+
function setDeepValue(obj, path, value) {
|
|
1817
|
+
if (!obj || typeof obj !== "object") {
|
|
1818
|
+
throw new TypeError("setDeepValue: target must be an object");
|
|
1819
|
+
}
|
|
1820
|
+
if (!path || typeof path !== "string") {
|
|
1821
|
+
throw new TypeError("setDeepValue: path must be a non-empty string");
|
|
1822
|
+
}
|
|
1823
|
+
const keys = path.split(".");
|
|
1824
|
+
let current = obj;
|
|
1825
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
1826
|
+
const key = keys[i];
|
|
1827
|
+
const nextKey = keys[i + 1];
|
|
1828
|
+
const isNextArray = /^\d+$/.test(nextKey);
|
|
1829
|
+
if (!(key in current) || typeof current[key] !== "object") {
|
|
1830
|
+
current[key] = isNextArray ? [] : {};
|
|
1831
|
+
}
|
|
1832
|
+
current = current[key];
|
|
1833
|
+
}
|
|
1834
|
+
const lastKey = keys[keys.length - 1];
|
|
1835
|
+
current[lastKey] = value;
|
|
1836
|
+
return obj;
|
|
1837
|
+
}
|
|
1838
|
+
function getDeepValue(obj, path, defaultValue) {
|
|
1839
|
+
if (!obj || typeof obj !== "object") {
|
|
1840
|
+
return defaultValue;
|
|
1841
|
+
}
|
|
1842
|
+
if (!path || typeof path !== "string") {
|
|
1843
|
+
return defaultValue;
|
|
1844
|
+
}
|
|
1845
|
+
const keys = path.split(".");
|
|
1846
|
+
let current = obj;
|
|
1847
|
+
for (const key of keys) {
|
|
1848
|
+
if (current === null || current === void 0 || typeof current !== "object") {
|
|
1849
|
+
return defaultValue;
|
|
1850
|
+
}
|
|
1851
|
+
if (!(key in current)) {
|
|
1852
|
+
return defaultValue;
|
|
1853
|
+
}
|
|
1854
|
+
current = current[key];
|
|
1855
|
+
}
|
|
1856
|
+
return current !== void 0 ? current : defaultValue;
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
// src/math.ts
|
|
1860
|
+
var math_exports = {};
|
|
1861
|
+
__export(math_exports, {
|
|
1862
|
+
calculateAggregations: () => calculateAggregations,
|
|
1863
|
+
calculateAnnuityPayment: () => calculateAnnuityPayment,
|
|
1864
|
+
calculateCorrelation: () => calculateCorrelation,
|
|
1865
|
+
calculateEuclideanDistance: () => calculateEuclideanDistance,
|
|
1866
|
+
calculateFutureValue: () => calculateFutureValue,
|
|
1867
|
+
calculateHistogram: () => calculateHistogram,
|
|
1868
|
+
calculateIQR: () => calculateIQR,
|
|
1869
|
+
calculateIRR: () => calculateIRR,
|
|
1870
|
+
calculateManhattanDistance: () => calculateManhattanDistance,
|
|
1871
|
+
calculateMedian: () => calculateMedian,
|
|
1872
|
+
calculateMode: () => calculateMode,
|
|
1873
|
+
calculateNPV: () => calculateNPV,
|
|
1874
|
+
calculatePercentile: () => calculatePercentile,
|
|
1875
|
+
calculatePresentValue: () => calculatePresentValue,
|
|
1876
|
+
calculateQuartiles: () => calculateQuartiles,
|
|
1877
|
+
calculateStandardDeviation: () => calculateStandardDeviation,
|
|
1878
|
+
calculateTrendSlope: () => calculateTrendSlope,
|
|
1879
|
+
calculateVariance: () => calculateVariance,
|
|
1880
|
+
detectOutliers: () => detectOutliers,
|
|
1881
|
+
normalizeToRange: () => normalizeToRange,
|
|
1882
|
+
scaleToRange: () => scaleToRange,
|
|
1883
|
+
simpleKMeans: () => simpleKMeans
|
|
1884
|
+
});
|
|
1885
|
+
var lodash2 = __toESM(require("lodash"));
|
|
1886
|
+
|
|
1887
|
+
// src/number.ts
|
|
1888
|
+
var number_exports = {};
|
|
1889
|
+
__export(number_exports, {
|
|
1890
|
+
isNumericValue: () => isNumericValue,
|
|
1891
|
+
roundToDecimals: () => roundToDecimals
|
|
1892
|
+
});
|
|
1893
|
+
function isNumericValue(value) {
|
|
1894
|
+
if (value === null || value === void 0) return false;
|
|
1895
|
+
if (typeof value === "number") return !isNaN(value) && isFinite(value);
|
|
1896
|
+
if (typeof value === "string") return value.trim() !== "" && !isNaN(Number(value));
|
|
1897
|
+
return false;
|
|
1898
|
+
}
|
|
1899
|
+
function roundToDecimals(num, decimals = 2) {
|
|
1900
|
+
const factor = Math.pow(10, decimals);
|
|
1901
|
+
return num >= 0 ? Math.round(num * factor) / factor : -Math.round(Math.abs(num) * factor) / factor;
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
// src/math.ts
|
|
1905
|
+
var { map, round, sumBy, get, meanBy, maxBy, some, minBy, uniq, size, sum, zipObject, groupBy } = lodash2;
|
|
1906
|
+
var calculateAggregations = (operations, pgroupBy, inData, appendOperationToField = true) => {
|
|
1907
|
+
let data = [];
|
|
1908
|
+
if (pgroupBy?.length) {
|
|
1909
|
+
const groupedData = groupBy(
|
|
1910
|
+
inData,
|
|
1911
|
+
(item) => pgroupBy.map((field) => get(item, field)).join("$|marca|@")
|
|
1912
|
+
);
|
|
1913
|
+
data = map(groupedData, (items, groupKey) => {
|
|
1914
|
+
const obj = zipObject(pgroupBy, groupKey.split("$|marca|@"));
|
|
1915
|
+
for (const operation in operations) {
|
|
1916
|
+
const fields = operations[operation];
|
|
1917
|
+
fields.forEach((field) => {
|
|
1918
|
+
const resultField = appendOperationToField ? field + operation : field;
|
|
1919
|
+
switch (operation) {
|
|
1920
|
+
case "$count":
|
|
1921
|
+
obj[resultField] = items.length;
|
|
1922
|
+
break;
|
|
1923
|
+
case "$sum":
|
|
1924
|
+
obj[resultField] = sumBy(items, (item) => get(item, field));
|
|
1925
|
+
break;
|
|
1926
|
+
case "$avg":
|
|
1927
|
+
obj[resultField] = round(
|
|
1928
|
+
meanBy(items, (item) => get(item, field)),
|
|
1929
|
+
1
|
|
1930
|
+
);
|
|
1931
|
+
break;
|
|
1932
|
+
case "$max": {
|
|
1933
|
+
const maxItem = maxBy(items, (item) => get(item, field));
|
|
1934
|
+
obj[resultField] = maxItem ? get(maxItem, field) : void 0;
|
|
1935
|
+
break;
|
|
1936
|
+
}
|
|
1937
|
+
case "$min": {
|
|
1938
|
+
const minItem = minBy(items, (item) => get(item, field));
|
|
1939
|
+
obj[resultField] = minItem ? get(minItem, field) : void 0;
|
|
1940
|
+
break;
|
|
1941
|
+
}
|
|
1942
|
+
case "$exist":
|
|
1943
|
+
obj[resultField] = some(items, (item) => get(item, field)) ? 1 : 0;
|
|
1944
|
+
break;
|
|
1945
|
+
case "$trend":
|
|
1946
|
+
obj[resultField] = calculateTrendSlope(
|
|
1947
|
+
items.map((item) => get(item, field)),
|
|
1948
|
+
items.map((_item, index) => index + 1)
|
|
1949
|
+
);
|
|
1950
|
+
break;
|
|
1951
|
+
case "$countUniq":
|
|
1952
|
+
obj[resultField] = uniq(items.map((item) => get(item, field))).length;
|
|
1953
|
+
break;
|
|
1954
|
+
}
|
|
1955
|
+
});
|
|
1956
|
+
}
|
|
1957
|
+
return obj;
|
|
1958
|
+
});
|
|
1959
|
+
} else {
|
|
1960
|
+
const results = {};
|
|
1961
|
+
for (const operation in operations) {
|
|
1962
|
+
const fields = operations[operation];
|
|
1963
|
+
fields.forEach((field) => {
|
|
1964
|
+
const resultField = appendOperationToField ? field + operation : field;
|
|
1965
|
+
switch (operation) {
|
|
1966
|
+
case "$count":
|
|
1967
|
+
results[resultField] = inData.length;
|
|
1968
|
+
break;
|
|
1969
|
+
case "$sum":
|
|
1970
|
+
results[resultField] = sumBy(inData, field);
|
|
1971
|
+
break;
|
|
1972
|
+
case "$avg":
|
|
1973
|
+
results[resultField] = round(meanBy(inData, field), 1);
|
|
1974
|
+
break;
|
|
1975
|
+
case "$max":
|
|
1976
|
+
if (Array.isArray(inData)) {
|
|
1977
|
+
const maxItem = maxBy(inData, field);
|
|
1978
|
+
results[resultField] = maxItem ? maxItem[field] : void 0;
|
|
1979
|
+
}
|
|
1980
|
+
break;
|
|
1981
|
+
case "$min":
|
|
1982
|
+
if (Array.isArray(inData)) {
|
|
1983
|
+
const minItem = minBy(inData, field);
|
|
1984
|
+
results[resultField] = minItem ? minItem[field] : void 0;
|
|
1985
|
+
}
|
|
1986
|
+
break;
|
|
1987
|
+
case "$exist":
|
|
1988
|
+
results[resultField] = some(inData, { [field]: true }) ? 1 : 0;
|
|
1989
|
+
break;
|
|
1990
|
+
case "$trend":
|
|
1991
|
+
results[resultField] = calculateTrendSlope(
|
|
1992
|
+
inData.map((item) => get(item, field)),
|
|
1993
|
+
inData.map((_item, index) => index + 1)
|
|
1994
|
+
);
|
|
1995
|
+
break;
|
|
1996
|
+
case "$countUniq":
|
|
1997
|
+
results[resultField] = uniq(inData.map((item) => get(item, field))).length;
|
|
1998
|
+
break;
|
|
1999
|
+
}
|
|
2000
|
+
});
|
|
2001
|
+
}
|
|
2002
|
+
data = results;
|
|
2003
|
+
}
|
|
2004
|
+
return data;
|
|
2005
|
+
};
|
|
2006
|
+
function calculateTrendSlope(y, x) {
|
|
2007
|
+
const n = size(y);
|
|
2008
|
+
const sum_x = sum(x);
|
|
2009
|
+
const sum_y = sum(y);
|
|
2010
|
+
const sum_x2 = sum(map(x, (val) => val * val));
|
|
2011
|
+
const sum_xy = sum(map(x, (val, i) => val * y[i]));
|
|
2012
|
+
const denominator = n * sum_x2 - sum_x * sum_x;
|
|
2013
|
+
if (denominator === 0) {
|
|
2014
|
+
return 0;
|
|
2015
|
+
}
|
|
2016
|
+
const slope = (n * sum_xy - sum_x * sum_y) / denominator;
|
|
2017
|
+
return roundToDecimals(slope, 1);
|
|
2018
|
+
}
|
|
2019
|
+
var calculateMedian = (values) => {
|
|
2020
|
+
if (!values.length) return 0;
|
|
2021
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
2022
|
+
const middle = Math.floor(sorted.length / 2);
|
|
2023
|
+
if (sorted.length % 2 === 0) {
|
|
2024
|
+
return (sorted[middle - 1] + sorted[middle]) / 2;
|
|
2025
|
+
}
|
|
2026
|
+
return sorted[middle];
|
|
2027
|
+
};
|
|
2028
|
+
var calculateMode = (values) => {
|
|
2029
|
+
if (!values.length) return null;
|
|
2030
|
+
const frequency = {};
|
|
2031
|
+
let maxFreq = 0;
|
|
2032
|
+
let mode = null;
|
|
2033
|
+
let hasMultipleModes = false;
|
|
2034
|
+
for (const value of values) {
|
|
2035
|
+
frequency[value] = (frequency[value] || 0) + 1;
|
|
2036
|
+
if (frequency[value] > maxFreq) {
|
|
2037
|
+
maxFreq = frequency[value];
|
|
2038
|
+
mode = value;
|
|
2039
|
+
hasMultipleModes = false;
|
|
2040
|
+
} else if (frequency[value] === maxFreq && value !== mode) {
|
|
2041
|
+
hasMultipleModes = true;
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
return hasMultipleModes ? null : mode;
|
|
2045
|
+
};
|
|
2046
|
+
var calculateStandardDeviation = (values, sample = false) => {
|
|
2047
|
+
if (!values.length) return 0;
|
|
2048
|
+
const mean = values.reduce((sum2, val) => sum2 + val, 0) / values.length;
|
|
2049
|
+
const squaredDiffs = values.map((val) => Math.pow(val - mean, 2));
|
|
2050
|
+
const variance = squaredDiffs.reduce((sum2, val) => sum2 + val, 0) / (sample ? values.length - 1 : values.length);
|
|
2051
|
+
return Math.sqrt(variance);
|
|
2052
|
+
};
|
|
2053
|
+
var calculateVariance = (values, sample = false) => {
|
|
2054
|
+
if (!values.length) return 0;
|
|
2055
|
+
const mean = values.reduce((sum2, val) => sum2 + val, 0) / values.length;
|
|
2056
|
+
const squaredDiffs = values.map((val) => Math.pow(val - mean, 2));
|
|
2057
|
+
return squaredDiffs.reduce((sum2, val) => sum2 + val, 0) / (sample ? values.length - 1 : values.length);
|
|
2058
|
+
};
|
|
2059
|
+
var calculatePercentile = (values, percentile) => {
|
|
2060
|
+
if (!values.length) return 0;
|
|
2061
|
+
if (percentile < 0 || percentile > 100) throw new Error("Percentile must be between 0 and 100");
|
|
2062
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
2063
|
+
const index = percentile / 100 * (sorted.length - 1);
|
|
2064
|
+
if (Math.floor(index) === index) {
|
|
2065
|
+
return sorted[index];
|
|
2066
|
+
}
|
|
2067
|
+
const lower = sorted[Math.floor(index)];
|
|
2068
|
+
const upper = sorted[Math.ceil(index)];
|
|
2069
|
+
const weight = index - Math.floor(index);
|
|
2070
|
+
return lower * (1 - weight) + upper * weight;
|
|
2071
|
+
};
|
|
2072
|
+
var calculateQuartiles = (values) => {
|
|
2073
|
+
return {
|
|
2074
|
+
Q1: calculatePercentile(values, 25),
|
|
2075
|
+
Q2: calculatePercentile(values, 50),
|
|
2076
|
+
// median
|
|
2077
|
+
Q3: calculatePercentile(values, 75)
|
|
2078
|
+
};
|
|
2079
|
+
};
|
|
2080
|
+
var calculateIQR = (values) => {
|
|
2081
|
+
const quartiles = calculateQuartiles(values);
|
|
2082
|
+
return quartiles.Q3 - quartiles.Q1;
|
|
2083
|
+
};
|
|
2084
|
+
var detectOutliers = (values, multiplier = 1.5) => {
|
|
2085
|
+
const quartiles = calculateQuartiles(values);
|
|
2086
|
+
const iqr = quartiles.Q3 - quartiles.Q1;
|
|
2087
|
+
const lowerBound = quartiles.Q1 - multiplier * iqr;
|
|
2088
|
+
const upperBound = quartiles.Q3 + multiplier * iqr;
|
|
2089
|
+
return values.filter((value) => value < lowerBound || value > upperBound);
|
|
2090
|
+
};
|
|
2091
|
+
var calculateCorrelation = (x, y) => {
|
|
2092
|
+
if (x.length !== y.length || x.length === 0) return 0;
|
|
2093
|
+
const n = x.length;
|
|
2094
|
+
const sumX = sum(x);
|
|
2095
|
+
const sumY = sum(y);
|
|
2096
|
+
const sumXY = sum(map(x, (val, i) => val * y[i]));
|
|
2097
|
+
const sumX2 = sum(map(x, (val) => val * val));
|
|
2098
|
+
const sumY2 = sum(map(y, (val) => val * val));
|
|
2099
|
+
const numerator = n * sumXY - sumX * sumY;
|
|
2100
|
+
const denominator = Math.sqrt((n * sumX2 - sumX * sumX) * (n * sumY2 - sumY * sumY));
|
|
2101
|
+
if (denominator === 0) return 0;
|
|
2102
|
+
return numerator / denominator;
|
|
2103
|
+
};
|
|
2104
|
+
var calculateNPV = (cashFlows, discountRate) => {
|
|
2105
|
+
return cashFlows.reduce((npv, cashFlow, index) => {
|
|
2106
|
+
const discountFactor = index === 0 ? 1 : Math.pow(1 + discountRate, index);
|
|
2107
|
+
return npv + cashFlow / discountFactor;
|
|
2108
|
+
}, 0);
|
|
2109
|
+
};
|
|
2110
|
+
var calculateIRR = (cashFlows, initialGuess = 0.1, maxIterations = 100, tolerance = 1e-6) => {
|
|
2111
|
+
let rate = initialGuess;
|
|
2112
|
+
for (let i = 0; i < maxIterations; i++) {
|
|
2113
|
+
const npv = calculateNPV(cashFlows, rate);
|
|
2114
|
+
const npvDerivative = cashFlows.reduce((sum2, cashFlow, index) => {
|
|
2115
|
+
return sum2 - index * cashFlow / Math.pow(1 + rate, index + 1);
|
|
2116
|
+
}, 0);
|
|
2117
|
+
if (Math.abs(npv) < tolerance) return rate;
|
|
2118
|
+
if (Math.abs(npvDerivative) < tolerance) break;
|
|
2119
|
+
rate = rate - npv / npvDerivative;
|
|
2120
|
+
}
|
|
2121
|
+
return rate;
|
|
2122
|
+
};
|
|
2123
|
+
var calculateFutureValue = (presentValue, interestRate, periods) => {
|
|
2124
|
+
return presentValue * Math.pow(1 + interestRate, periods);
|
|
2125
|
+
};
|
|
2126
|
+
var calculatePresentValue = (futureValue, interestRate, periods) => {
|
|
2127
|
+
return futureValue / Math.pow(1 + interestRate, periods);
|
|
2128
|
+
};
|
|
2129
|
+
var calculateAnnuityPayment = (presentValue, interestRate, periods) => {
|
|
2130
|
+
if (interestRate === 0) return presentValue / periods;
|
|
2131
|
+
return presentValue * (interestRate * Math.pow(1 + interestRate, periods)) / (Math.pow(1 + interestRate, periods) - 1);
|
|
2132
|
+
};
|
|
2133
|
+
var normalizeToRange = (values) => {
|
|
2134
|
+
if (!values.length) return [];
|
|
2135
|
+
const min = Math.min(...values);
|
|
2136
|
+
const max = Math.max(...values);
|
|
2137
|
+
const range = max - min;
|
|
2138
|
+
if (range === 0) return values.map(() => 0);
|
|
2139
|
+
return values.map((value) => (value - min) / range);
|
|
2140
|
+
};
|
|
2141
|
+
var scaleToRange = (values, minRange, maxRange) => {
|
|
2142
|
+
const normalized = normalizeToRange(values);
|
|
2143
|
+
const scale = maxRange - minRange;
|
|
2144
|
+
return normalized.map((value) => minRange + value * scale);
|
|
2145
|
+
};
|
|
2146
|
+
var calculateHistogram = (values, bins) => {
|
|
2147
|
+
if (!values.length || bins <= 0) return [];
|
|
2148
|
+
const min = Math.min(...values);
|
|
2149
|
+
const max = Math.max(...values);
|
|
2150
|
+
const binWidth = (max - min) / bins;
|
|
2151
|
+
const histogram = [];
|
|
2152
|
+
for (let i = 0; i < bins; i++) {
|
|
2153
|
+
const rangeStart = min + i * binWidth;
|
|
2154
|
+
const rangeEnd = i === bins - 1 ? max : rangeStart + binWidth;
|
|
2155
|
+
const count = values.filter(
|
|
2156
|
+
(value) => value >= rangeStart && (i === bins - 1 ? value <= rangeEnd : value < rangeEnd)
|
|
2157
|
+
).length;
|
|
2158
|
+
histogram.push({
|
|
2159
|
+
range: [roundToDecimals(rangeStart, 2), roundToDecimals(rangeEnd, 2)],
|
|
2160
|
+
count
|
|
2161
|
+
});
|
|
2162
|
+
}
|
|
2163
|
+
return histogram;
|
|
2164
|
+
};
|
|
2165
|
+
var calculateEuclideanDistance = (point1, point2) => {
|
|
2166
|
+
if (point1.length !== point2.length) {
|
|
2167
|
+
throw new Error("Points must have the same number of dimensions");
|
|
2168
|
+
}
|
|
2169
|
+
const squaredDiffs = point1.map((val, index) => Math.pow(val - point2[index], 2));
|
|
2170
|
+
return Math.sqrt(sum(squaredDiffs));
|
|
2171
|
+
};
|
|
2172
|
+
var calculateManhattanDistance = (point1, point2) => {
|
|
2173
|
+
if (point1.length !== point2.length) {
|
|
2174
|
+
throw new Error("Points must have the same number of dimensions");
|
|
2175
|
+
}
|
|
2176
|
+
return sum(point1.map((val, index) => Math.abs(val - point2[index])));
|
|
2177
|
+
};
|
|
2178
|
+
var simpleKMeans = (points, k, maxIterations = 100) => {
|
|
2179
|
+
if (points.length === 0 || k <= 0) {
|
|
2180
|
+
return { centroids: [], clusters: [] };
|
|
2181
|
+
}
|
|
2182
|
+
const dimensions = points[0].length;
|
|
2183
|
+
let centroids = [];
|
|
2184
|
+
for (let i = 0; i < k; i++) {
|
|
2185
|
+
const randomPoint = points[Math.floor(Math.random() * points.length)];
|
|
2186
|
+
centroids.push([...randomPoint]);
|
|
2187
|
+
}
|
|
2188
|
+
const clusters = new Array(points.length);
|
|
2189
|
+
for (let iteration = 0; iteration < maxIterations; iteration++) {
|
|
2190
|
+
let hasChanged = false;
|
|
2191
|
+
for (let i = 0; i < points.length; i++) {
|
|
2192
|
+
let minDistance = Infinity;
|
|
2193
|
+
let closestCentroid = 0;
|
|
2194
|
+
for (let j = 0; j < centroids.length; j++) {
|
|
2195
|
+
const distance = calculateEuclideanDistance(points[i], centroids[j]);
|
|
2196
|
+
if (distance < minDistance) {
|
|
2197
|
+
minDistance = distance;
|
|
2198
|
+
closestCentroid = j;
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
if (clusters[i] !== closestCentroid) {
|
|
2202
|
+
hasChanged = true;
|
|
2203
|
+
clusters[i] = closestCentroid;
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
const newCentroids = new Array(k).fill(0).map(() => new Array(dimensions).fill(0));
|
|
2207
|
+
const clusterCounts = new Array(k).fill(0);
|
|
2208
|
+
for (let i = 0; i < points.length; i++) {
|
|
2209
|
+
const cluster = clusters[i];
|
|
2210
|
+
clusterCounts[cluster]++;
|
|
2211
|
+
for (let dim = 0; dim < dimensions; dim++) {
|
|
2212
|
+
newCentroids[cluster][dim] += points[i][dim];
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
for (let i = 0; i < k; i++) {
|
|
2216
|
+
if (clusterCounts[i] > 0) {
|
|
2217
|
+
for (let dim = 0; dim < dimensions; dim++) {
|
|
2218
|
+
newCentroids[i][dim] /= clusterCounts[i];
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
centroids = newCentroids;
|
|
2223
|
+
if (!hasChanged) break;
|
|
2224
|
+
}
|
|
2225
|
+
return { centroids, clusters };
|
|
2226
|
+
};
|
|
2227
|
+
|
|
2228
|
+
// src/async.ts
|
|
2229
|
+
var async_exports = {};
|
|
2230
|
+
__export(async_exports, {
|
|
2231
|
+
handleOperation: () => handleOperation,
|
|
2232
|
+
runBatch: () => runBatch,
|
|
2233
|
+
sleep: () => sleep,
|
|
2234
|
+
wait: () => wait
|
|
2235
|
+
});
|
|
2236
|
+
|
|
2237
|
+
// src/errors.ts
|
|
2238
|
+
var TsHelpersError = class _TsHelpersError extends Error {
|
|
2239
|
+
constructor(message, options = {}) {
|
|
2240
|
+
super(message);
|
|
2241
|
+
this.name = "TsHelpersError";
|
|
2242
|
+
this.code = options.code;
|
|
2243
|
+
this.data = options.data;
|
|
2244
|
+
this.cause = options.cause;
|
|
2245
|
+
if (Error.captureStackTrace) {
|
|
2246
|
+
Error.captureStackTrace(this, _TsHelpersError);
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
};
|
|
2250
|
+
var DataError = class extends TsHelpersError {
|
|
2251
|
+
constructor(message, code, data) {
|
|
2252
|
+
super(message, { code, data });
|
|
2253
|
+
this.name = "DataError";
|
|
2254
|
+
}
|
|
2255
|
+
};
|
|
2256
|
+
function createValidationError(message, field, value) {
|
|
2257
|
+
return new TsHelpersError(`Validation failed: ${message}`, {
|
|
2258
|
+
code: "VALIDATION_FAILED" /* VALIDATION_FAILED */,
|
|
2259
|
+
data: { field, value }
|
|
2260
|
+
});
|
|
2261
|
+
}
|
|
2262
|
+
|
|
2263
|
+
// src/async.ts
|
|
2264
|
+
var sleep = (ms) => {
|
|
2265
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
2266
|
+
};
|
|
2267
|
+
var wait = (ms) => sleep(ms);
|
|
2268
|
+
async function runBatch(jobs, batchSize = 50) {
|
|
2269
|
+
if (batchSize <= 0) {
|
|
2270
|
+
throw new TsHelpersError("Batch size must be greater than 0", {
|
|
2271
|
+
code: "INVALID_OPERATION" /* INVALID_OPERATION */,
|
|
2272
|
+
data: { batchSize }
|
|
2273
|
+
});
|
|
2274
|
+
}
|
|
2275
|
+
const results = [];
|
|
2276
|
+
const batches = Math.ceil(jobs.length / batchSize);
|
|
2277
|
+
for (let i = 0; i < batches; i++) {
|
|
2278
|
+
const batchStart = i * batchSize;
|
|
2279
|
+
const batchEnd = batchStart + batchSize;
|
|
2280
|
+
const batch = jobs.slice(batchStart, batchEnd);
|
|
2281
|
+
const batchResults = await Promise.all(batch.map((job) => job));
|
|
2282
|
+
results.push(...batchResults);
|
|
2283
|
+
}
|
|
2284
|
+
return results;
|
|
2285
|
+
}
|
|
2286
|
+
function handleOperation(target, operation, ...args) {
|
|
2287
|
+
if (operation.includes("/")) {
|
|
2288
|
+
const [parentOp, childOp] = operation.split("/");
|
|
2289
|
+
if (!target[parentOp] || !target[parentOp][childOp]) {
|
|
2290
|
+
throw new TsHelpersError(`Operation [${operation}] does not exist`, {
|
|
2291
|
+
code: "INVALID_OPERATION" /* INVALID_OPERATION */,
|
|
2292
|
+
data: { operation, parentOp, childOp }
|
|
2293
|
+
});
|
|
2294
|
+
}
|
|
2295
|
+
return target[parentOp][childOp](...args);
|
|
2296
|
+
}
|
|
2297
|
+
if (!target[operation]) {
|
|
2298
|
+
throw new TsHelpersError(`Operation [${operation}] does not exist`, {
|
|
2299
|
+
code: "INVALID_OPERATION" /* INVALID_OPERATION */,
|
|
2300
|
+
data: { operation }
|
|
2301
|
+
});
|
|
2302
|
+
}
|
|
2303
|
+
return target[operation](...args);
|
|
2304
|
+
}
|
|
2305
|
+
|
|
2306
|
+
// src/data.ts
|
|
2307
|
+
var data_exports = {};
|
|
2308
|
+
__export(data_exports, {
|
|
2309
|
+
detectFileExtension: () => detectFileExtension,
|
|
2310
|
+
detectFormatFromFilename: () => detectFormatFromFilename,
|
|
2311
|
+
detectUniversalFormat: () => detectUniversalFormat,
|
|
2312
|
+
exportData: () => exportData,
|
|
2313
|
+
exportTree: () => exportTree,
|
|
2314
|
+
exportTxt: () => exportTxt,
|
|
2315
|
+
importData: () => importData,
|
|
2316
|
+
importTree: () => importTree,
|
|
2317
|
+
importTxt: () => importTxt,
|
|
2318
|
+
readFileAsText: () => readFileAsText,
|
|
2319
|
+
validateCSVData: () => validateCSVData,
|
|
2320
|
+
validateExportData: () => validateExportData
|
|
2321
|
+
});
|
|
2322
|
+
init_environment();
|
|
2323
|
+
var readFileAsText = async (fileOrPath, encoding = "utf8") => {
|
|
2324
|
+
if (isNode() && typeof fileOrPath === "string") {
|
|
2325
|
+
const fs = await import("fs/promises");
|
|
2326
|
+
return fs.readFile(fileOrPath, encoding);
|
|
2327
|
+
} else if (isBrowser() && fileOrPath instanceof File) {
|
|
2328
|
+
return new Promise((resolve, reject) => {
|
|
2329
|
+
const reader = new FileReader();
|
|
2330
|
+
reader.onload = (e) => resolve(e.target?.result);
|
|
2331
|
+
reader.onerror = () => reject(new Error("Error reading file"));
|
|
2332
|
+
reader.readAsText(fileOrPath);
|
|
2333
|
+
});
|
|
2334
|
+
} else {
|
|
2335
|
+
throw new DataError(
|
|
2336
|
+
"Invalid parameter for current environment",
|
|
2337
|
+
"ENVIRONMENT_NOT_SUPPORTED" /* ENVIRONMENT_NOT_SUPPORTED */,
|
|
2338
|
+
{
|
|
2339
|
+
data: {
|
|
2340
|
+
isNodeEnv: isNode(),
|
|
2341
|
+
isBrowserEnv: isBrowser(),
|
|
2342
|
+
parameterType: typeof fileOrPath
|
|
2343
|
+
}
|
|
2344
|
+
}
|
|
2345
|
+
);
|
|
2346
|
+
}
|
|
2347
|
+
};
|
|
2348
|
+
function validateExportData(data) {
|
|
2349
|
+
if (!Array.isArray(data)) {
|
|
2350
|
+
throw createValidationError("Data must be an array", "data", typeof data);
|
|
2351
|
+
}
|
|
2352
|
+
if (data.length === 0) {
|
|
2353
|
+
throw createValidationError("Data array cannot be empty", "data.length", data.length);
|
|
2354
|
+
}
|
|
2355
|
+
const firstItem = data[0];
|
|
2356
|
+
const isObjectArray = typeof firstItem === "object" && firstItem !== null && !Array.isArray(firstItem);
|
|
2357
|
+
const isArrayOfArrays = Array.isArray(firstItem);
|
|
2358
|
+
if (!isObjectArray && !isArrayOfArrays) {
|
|
2359
|
+
throw createValidationError(
|
|
2360
|
+
"Data must be an array of objects or an array of arrays",
|
|
2361
|
+
"data[0]",
|
|
2362
|
+
typeof firstItem
|
|
2363
|
+
);
|
|
2364
|
+
}
|
|
2365
|
+
if (isObjectArray) {
|
|
2366
|
+
for (let i = 1; i < data.length; i++) {
|
|
2367
|
+
const item = data[i];
|
|
2368
|
+
if (typeof item !== "object" || item === null || Array.isArray(item)) {
|
|
2369
|
+
throw createValidationError(
|
|
2370
|
+
"All elements must be objects if first one is an object",
|
|
2371
|
+
`data[${i}]`,
|
|
2372
|
+
typeof item
|
|
2373
|
+
);
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
} else if (isArrayOfArrays) {
|
|
2377
|
+
const firstRowLength = firstItem.length;
|
|
2378
|
+
for (let i = 1; i < data.length; i++) {
|
|
2379
|
+
if (!Array.isArray(data[i])) {
|
|
2380
|
+
throw createValidationError(`Row ${i} is not an array`, `data[${i}]`, typeof data[i]);
|
|
2381
|
+
}
|
|
2382
|
+
if (data[i].length !== firstRowLength) {
|
|
2383
|
+
throw createValidationError(
|
|
2384
|
+
`Row ${i} has ${data[i].length} columns, but first has ${firstRowLength}`,
|
|
2385
|
+
`data[${i}].length`,
|
|
2386
|
+
{ expected: firstRowLength, actual: data[i].length }
|
|
2387
|
+
);
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
return true;
|
|
2392
|
+
}
|
|
2393
|
+
var validateCSVData = validateExportData;
|
|
2394
|
+
function detectFormatFromFilename(filename) {
|
|
2395
|
+
const parts = filename.toLowerCase().split(".");
|
|
2396
|
+
const extension = parts.length > 1 ? parts.pop() : void 0;
|
|
2397
|
+
switch (extension) {
|
|
2398
|
+
case "csv":
|
|
2399
|
+
return "csv";
|
|
2400
|
+
case "json":
|
|
2401
|
+
return "json";
|
|
2402
|
+
case "tree":
|
|
2403
|
+
return "tree";
|
|
2404
|
+
case "txt":
|
|
2405
|
+
return "txt";
|
|
2406
|
+
default:
|
|
2407
|
+
if (!extension) {
|
|
2408
|
+
throw new DataError(
|
|
2409
|
+
"Could not detect file format. Must have a valid extension (.csv, .json, .tree, .txt)",
|
|
2410
|
+
"UNSUPPORTED_FORMAT" /* UNSUPPORTED_FORMAT */,
|
|
2411
|
+
{ data: { filename } }
|
|
2412
|
+
);
|
|
2413
|
+
}
|
|
2414
|
+
throw new DataError(
|
|
2415
|
+
`Unsupported file format: .${extension}. Use .csv, .json, .tree or .txt`,
|
|
2416
|
+
"UNSUPPORTED_FORMAT" /* UNSUPPORTED_FORMAT */,
|
|
2417
|
+
{ data: { filename, extension } }
|
|
2418
|
+
);
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
function detectFileExtension(filename) {
|
|
2422
|
+
if (!filename || typeof filename !== "string") {
|
|
2423
|
+
return null;
|
|
2424
|
+
}
|
|
2425
|
+
const parts = filename.trim().split(".");
|
|
2426
|
+
if (parts.length < 2) {
|
|
2427
|
+
return null;
|
|
2428
|
+
}
|
|
2429
|
+
const extension = parts.pop()?.toLowerCase();
|
|
2430
|
+
return extension || null;
|
|
2431
|
+
}
|
|
2432
|
+
function detectUniversalFormat(filename) {
|
|
2433
|
+
const extension = detectFileExtension(filename);
|
|
2434
|
+
if (!extension) {
|
|
2435
|
+
return {
|
|
2436
|
+
extension: null,
|
|
2437
|
+
category: "unknown",
|
|
2438
|
+
isText: false,
|
|
2439
|
+
isBinary: false,
|
|
2440
|
+
mimeType: null
|
|
2441
|
+
};
|
|
2442
|
+
}
|
|
2443
|
+
const formatInfo = {
|
|
2444
|
+
// Data formats
|
|
2445
|
+
json: { category: "data", isText: true, isBinary: false, mimeType: "application/json" },
|
|
2446
|
+
csv: { category: "data", isText: true, isBinary: false, mimeType: "text/csv" },
|
|
2447
|
+
xml: { category: "data", isText: true, isBinary: false, mimeType: "application/xml" },
|
|
2448
|
+
yaml: { category: "data", isText: true, isBinary: false, mimeType: "application/yaml" },
|
|
2449
|
+
yml: { category: "data", isText: true, isBinary: false, mimeType: "application/yaml" },
|
|
2450
|
+
tree: { category: "data", isText: true, isBinary: false, mimeType: "text/plain" },
|
|
2451
|
+
tsv: { category: "data", isText: true, isBinary: false, mimeType: "text/tab-separated-values" },
|
|
2452
|
+
sql: { category: "data", isText: true, isBinary: false, mimeType: "application/sql" },
|
|
2453
|
+
db: { category: "data", isText: false, isBinary: true, mimeType: "application/x-sqlite3" },
|
|
2454
|
+
sqlite: { category: "data", isText: false, isBinary: true, mimeType: "application/x-sqlite3" },
|
|
2455
|
+
// Text and code formats
|
|
2456
|
+
txt: { category: "text", isText: true, isBinary: false, mimeType: "text/plain" },
|
|
2457
|
+
md: { category: "text", isText: true, isBinary: false, mimeType: "text/markdown" },
|
|
2458
|
+
rst: { category: "text", isText: true, isBinary: false, mimeType: "text/x-rst" },
|
|
2459
|
+
rtf: { category: "text", isText: true, isBinary: false, mimeType: "application/rtf" },
|
|
2460
|
+
log: { category: "text", isText: true, isBinary: false, mimeType: "text/plain" },
|
|
2461
|
+
// Web formats
|
|
2462
|
+
html: { category: "web", isText: true, isBinary: false, mimeType: "text/html" },
|
|
2463
|
+
htm: { category: "web", isText: true, isBinary: false, mimeType: "text/html" },
|
|
2464
|
+
css: { category: "web", isText: true, isBinary: false, mimeType: "text/css" },
|
|
2465
|
+
scss: { category: "web", isText: true, isBinary: false, mimeType: "text/x-scss" },
|
|
2466
|
+
sass: { category: "web", isText: true, isBinary: false, mimeType: "text/x-sass" },
|
|
2467
|
+
less: { category: "web", isText: true, isBinary: false, mimeType: "text/x-less" },
|
|
2468
|
+
// Programming languages
|
|
2469
|
+
js: { category: "code", isText: true, isBinary: false, mimeType: "application/javascript" },
|
|
2470
|
+
mjs: { category: "code", isText: true, isBinary: false, mimeType: "application/javascript" },
|
|
2471
|
+
jsx: { category: "code", isText: true, isBinary: false, mimeType: "text/jsx" },
|
|
2472
|
+
ts: { category: "code", isText: true, isBinary: false, mimeType: "application/typescript" },
|
|
2473
|
+
tsx: { category: "code", isText: true, isBinary: false, mimeType: "text/tsx" },
|
|
2474
|
+
py: { category: "code", isText: true, isBinary: false, mimeType: "text/x-python" },
|
|
2475
|
+
java: { category: "code", isText: true, isBinary: false, mimeType: "text/x-java-source" },
|
|
2476
|
+
php: { category: "code", isText: true, isBinary: false, mimeType: "application/x-httpd-php" },
|
|
2477
|
+
rb: { category: "code", isText: true, isBinary: false, mimeType: "text/x-ruby" },
|
|
2478
|
+
go: { category: "code", isText: true, isBinary: false, mimeType: "text/x-go" },
|
|
2479
|
+
rs: { category: "code", isText: true, isBinary: false, mimeType: "text/x-rust" },
|
|
2480
|
+
c: { category: "code", isText: true, isBinary: false, mimeType: "text/x-c" },
|
|
2481
|
+
cpp: { category: "code", isText: true, isBinary: false, mimeType: "text/x-c++" },
|
|
2482
|
+
cc: { category: "code", isText: true, isBinary: false, mimeType: "text/x-c++" },
|
|
2483
|
+
h: { category: "code", isText: true, isBinary: false, mimeType: "text/x-c" },
|
|
2484
|
+
cs: { category: "code", isText: true, isBinary: false, mimeType: "text/x-csharp" },
|
|
2485
|
+
sh: { category: "code", isText: true, isBinary: false, mimeType: "application/x-sh" },
|
|
2486
|
+
bash: { category: "code", isText: true, isBinary: false, mimeType: "application/x-sh" },
|
|
2487
|
+
ps1: { category: "code", isText: true, isBinary: false, mimeType: "application/x-powershell" },
|
|
2488
|
+
// Microsoft Office documents
|
|
2489
|
+
doc: { category: "document", isText: false, isBinary: true, mimeType: "application/msword" },
|
|
2490
|
+
docx: {
|
|
2491
|
+
category: "document",
|
|
2492
|
+
isText: false,
|
|
2493
|
+
isBinary: true,
|
|
2494
|
+
mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
|
2495
|
+
},
|
|
2496
|
+
xls: {
|
|
2497
|
+
category: "spreadsheet",
|
|
2498
|
+
isText: false,
|
|
2499
|
+
isBinary: true,
|
|
2500
|
+
mimeType: "application/vnd.ms-excel"
|
|
2501
|
+
},
|
|
2502
|
+
xlsx: {
|
|
2503
|
+
category: "spreadsheet",
|
|
2504
|
+
isText: false,
|
|
2505
|
+
isBinary: true,
|
|
2506
|
+
mimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
2507
|
+
},
|
|
2508
|
+
ppt: {
|
|
2509
|
+
category: "presentation",
|
|
2510
|
+
isText: false,
|
|
2511
|
+
isBinary: true,
|
|
2512
|
+
mimeType: "application/vnd.ms-powerpoint"
|
|
2513
|
+
},
|
|
2514
|
+
pptx: {
|
|
2515
|
+
category: "presentation",
|
|
2516
|
+
isText: false,
|
|
2517
|
+
isBinary: true,
|
|
2518
|
+
mimeType: "application/vnd.openxmlformats-officedocument.presentationml.presentation"
|
|
2519
|
+
},
|
|
2520
|
+
// LibreOffice/OpenOffice
|
|
2521
|
+
odt: {
|
|
2522
|
+
category: "document",
|
|
2523
|
+
isText: false,
|
|
2524
|
+
isBinary: true,
|
|
2525
|
+
mimeType: "application/vnd.oasis.opendocument.text"
|
|
2526
|
+
},
|
|
2527
|
+
ods: {
|
|
2528
|
+
category: "spreadsheet",
|
|
2529
|
+
isText: false,
|
|
2530
|
+
isBinary: true,
|
|
2531
|
+
mimeType: "application/vnd.oasis.opendocument.spreadsheet"
|
|
2532
|
+
},
|
|
2533
|
+
odp: {
|
|
2534
|
+
category: "presentation",
|
|
2535
|
+
isText: false,
|
|
2536
|
+
isBinary: true,
|
|
2537
|
+
mimeType: "application/vnd.oasis.opendocument.presentation"
|
|
2538
|
+
},
|
|
2539
|
+
// Other document formats
|
|
2540
|
+
pdf: { category: "document", isText: false, isBinary: true, mimeType: "application/pdf" },
|
|
2541
|
+
epub: { category: "document", isText: false, isBinary: true, mimeType: "application/epub+zip" },
|
|
2542
|
+
mobi: {
|
|
2543
|
+
category: "document",
|
|
2544
|
+
isText: false,
|
|
2545
|
+
isBinary: true,
|
|
2546
|
+
mimeType: "application/x-mobipocket-ebook"
|
|
2547
|
+
},
|
|
2548
|
+
// Image formats
|
|
2549
|
+
jpg: { category: "image", isText: false, isBinary: true, mimeType: "image/jpeg" },
|
|
2550
|
+
jpeg: { category: "image", isText: false, isBinary: true, mimeType: "image/jpeg" },
|
|
2551
|
+
png: { category: "image", isText: false, isBinary: true, mimeType: "image/png" },
|
|
2552
|
+
gif: { category: "image", isText: false, isBinary: true, mimeType: "image/gif" },
|
|
2553
|
+
svg: { category: "image", isText: true, isBinary: false, mimeType: "image/svg+xml" },
|
|
2554
|
+
webp: { category: "image", isText: false, isBinary: true, mimeType: "image/webp" },
|
|
2555
|
+
avif: { category: "image", isText: false, isBinary: true, mimeType: "image/avif" },
|
|
2556
|
+
bmp: { category: "image", isText: false, isBinary: true, mimeType: "image/bmp" },
|
|
2557
|
+
tiff: { category: "image", isText: false, isBinary: true, mimeType: "image/tiff" },
|
|
2558
|
+
tif: { category: "image", isText: false, isBinary: true, mimeType: "image/tiff" },
|
|
2559
|
+
ico: { category: "image", isText: false, isBinary: true, mimeType: "image/x-icon" },
|
|
2560
|
+
psd: {
|
|
2561
|
+
category: "image",
|
|
2562
|
+
isText: false,
|
|
2563
|
+
isBinary: true,
|
|
2564
|
+
mimeType: "image/vnd.adobe.photoshop"
|
|
2565
|
+
},
|
|
2566
|
+
// Audio formats
|
|
2567
|
+
mp3: { category: "audio", isText: false, isBinary: true, mimeType: "audio/mpeg" },
|
|
2568
|
+
wav: { category: "audio", isText: false, isBinary: true, mimeType: "audio/wav" },
|
|
2569
|
+
flac: { category: "audio", isText: false, isBinary: true, mimeType: "audio/flac" },
|
|
2570
|
+
ogg: { category: "audio", isText: false, isBinary: true, mimeType: "audio/ogg" },
|
|
2571
|
+
aac: { category: "audio", isText: false, isBinary: true, mimeType: "audio/aac" },
|
|
2572
|
+
m4a: { category: "audio", isText: false, isBinary: true, mimeType: "audio/m4a" },
|
|
2573
|
+
wma: { category: "audio", isText: false, isBinary: true, mimeType: "audio/x-ms-wma" },
|
|
2574
|
+
// Video formats
|
|
2575
|
+
mp4: { category: "video", isText: false, isBinary: true, mimeType: "video/mp4" },
|
|
2576
|
+
avi: { category: "video", isText: false, isBinary: true, mimeType: "video/x-msvideo" },
|
|
2577
|
+
mov: { category: "video", isText: false, isBinary: true, mimeType: "video/quicktime" },
|
|
2578
|
+
wmv: { category: "video", isText: false, isBinary: true, mimeType: "video/x-ms-wmv" },
|
|
2579
|
+
flv: { category: "video", isText: false, isBinary: true, mimeType: "video/x-flv" },
|
|
2580
|
+
webm: { category: "video", isText: false, isBinary: true, mimeType: "video/webm" },
|
|
2581
|
+
mkv: { category: "video", isText: false, isBinary: true, mimeType: "video/x-matroska" },
|
|
2582
|
+
"3gp": { category: "video", isText: false, isBinary: true, mimeType: "video/3gpp" },
|
|
2583
|
+
// Archive formats
|
|
2584
|
+
zip: { category: "archive", isText: false, isBinary: true, mimeType: "application/zip" },
|
|
2585
|
+
rar: {
|
|
2586
|
+
category: "archive",
|
|
2587
|
+
isText: false,
|
|
2588
|
+
isBinary: true,
|
|
2589
|
+
mimeType: "application/x-rar-compressed"
|
|
2590
|
+
},
|
|
2591
|
+
"7z": {
|
|
2592
|
+
category: "archive",
|
|
2593
|
+
isText: false,
|
|
2594
|
+
isBinary: true,
|
|
2595
|
+
mimeType: "application/x-7z-compressed"
|
|
2596
|
+
},
|
|
2597
|
+
tar: { category: "archive", isText: false, isBinary: true, mimeType: "application/x-tar" },
|
|
2598
|
+
gz: { category: "archive", isText: false, isBinary: true, mimeType: "application/gzip" },
|
|
2599
|
+
bz2: { category: "archive", isText: false, isBinary: true, mimeType: "application/x-bzip2" },
|
|
2600
|
+
xz: { category: "archive", isText: false, isBinary: true, mimeType: "application/x-xz" },
|
|
2601
|
+
// Configuration files
|
|
2602
|
+
ini: { category: "config", isText: true, isBinary: false, mimeType: "text/plain" },
|
|
2603
|
+
cfg: { category: "config", isText: true, isBinary: false, mimeType: "text/plain" },
|
|
2604
|
+
conf: { category: "config", isText: true, isBinary: false, mimeType: "text/plain" },
|
|
2605
|
+
toml: { category: "config", isText: true, isBinary: false, mimeType: "application/toml" },
|
|
2606
|
+
env: { category: "config", isText: true, isBinary: false, mimeType: "text/plain" },
|
|
2607
|
+
// Font formats
|
|
2608
|
+
ttf: { category: "font", isText: false, isBinary: true, mimeType: "font/ttf" },
|
|
2609
|
+
otf: { category: "font", isText: false, isBinary: true, mimeType: "font/otf" },
|
|
2610
|
+
woff: { category: "font", isText: false, isBinary: true, mimeType: "font/woff" },
|
|
2611
|
+
woff2: { category: "font", isText: false, isBinary: true, mimeType: "font/woff2" },
|
|
2612
|
+
eot: {
|
|
2613
|
+
category: "font",
|
|
2614
|
+
isText: false,
|
|
2615
|
+
isBinary: true,
|
|
2616
|
+
mimeType: "application/vnd.ms-fontobject"
|
|
2617
|
+
}
|
|
2618
|
+
};
|
|
2619
|
+
const info = formatInfo[extension] || {
|
|
2620
|
+
category: "unknown",
|
|
2621
|
+
isText: false,
|
|
2622
|
+
isBinary: false,
|
|
2623
|
+
mimeType: null
|
|
2624
|
+
};
|
|
2625
|
+
return {
|
|
2626
|
+
extension,
|
|
2627
|
+
...info
|
|
2628
|
+
};
|
|
2629
|
+
}
|
|
2630
|
+
async function exportTree(data, filePath, options) {
|
|
2631
|
+
if (!Array.isArray(data)) {
|
|
2632
|
+
throw createValidationError(
|
|
2633
|
+
"Data for tree format must be an array of nodes",
|
|
2634
|
+
"data",
|
|
2635
|
+
typeof data
|
|
2636
|
+
);
|
|
2637
|
+
}
|
|
2638
|
+
const { renderTreeAsText: renderTreeAsText2 } = await Promise.resolve().then(() => (init_tree(), tree_exports));
|
|
2639
|
+
const treeText = renderTreeAsText2(data, options);
|
|
2640
|
+
if (isNode()) {
|
|
2641
|
+
const fs = await import("fs/promises");
|
|
2642
|
+
await fs.writeFile(filePath, treeText, { encoding: "utf-8" });
|
|
2643
|
+
} else {
|
|
2644
|
+
const blob = new Blob([treeText], { type: "text/plain;charset=utf-8" });
|
|
2645
|
+
const url = URL.createObjectURL(blob);
|
|
2646
|
+
const link = document.createElement("a");
|
|
2647
|
+
link.href = url;
|
|
2648
|
+
link.download = filePath.split("/").pop() || "tree.tree";
|
|
2649
|
+
document.body.appendChild(link);
|
|
2650
|
+
link.click();
|
|
2651
|
+
document.body.removeChild(link);
|
|
2652
|
+
URL.revokeObjectURL(url);
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
async function importTree(filePath, _options) {
|
|
2656
|
+
if (isNode()) {
|
|
2657
|
+
const fs = await import("fs/promises");
|
|
2658
|
+
return fs.readFile(filePath, { encoding: "utf-8" });
|
|
2659
|
+
} else {
|
|
2660
|
+
throw new DataError(
|
|
2661
|
+
".tree file import is not supported in browser. Use readFileAsText() with a File object.",
|
|
2662
|
+
"ENVIRONMENT_NOT_SUPPORTED" /* ENVIRONMENT_NOT_SUPPORTED */,
|
|
2663
|
+
{ data: { environment: "browser", operation: "importTree" } }
|
|
2664
|
+
);
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
async function exportTxt(data, filePath, options) {
|
|
2668
|
+
const { separator = "\n", stringify, indent = 2 } = options || {};
|
|
2669
|
+
let textContent;
|
|
2670
|
+
if (stringify) {
|
|
2671
|
+
textContent = stringify(data);
|
|
2672
|
+
} else if (typeof data === "string") {
|
|
2673
|
+
textContent = data;
|
|
2674
|
+
} else if (Array.isArray(data)) {
|
|
2675
|
+
textContent = data.map((item) => typeof item === "string" ? item : JSON.stringify(item, null, indent)).join(separator);
|
|
2676
|
+
} else if (typeof data === "object" && data !== null) {
|
|
2677
|
+
textContent = JSON.stringify(data, null, indent);
|
|
2678
|
+
} else {
|
|
2679
|
+
textContent = String(data);
|
|
2680
|
+
}
|
|
2681
|
+
if (isNode()) {
|
|
2682
|
+
const fs = await import("fs/promises");
|
|
2683
|
+
await fs.writeFile(filePath, textContent, { encoding: "utf-8" });
|
|
2684
|
+
} else {
|
|
2685
|
+
const blob = new Blob([textContent], { type: "text/plain;charset=utf-8" });
|
|
2686
|
+
const url = URL.createObjectURL(blob);
|
|
2687
|
+
const link = document.createElement("a");
|
|
2688
|
+
link.href = url;
|
|
2689
|
+
link.download = filePath.split("/").pop() || "file.txt";
|
|
2690
|
+
document.body.appendChild(link);
|
|
2691
|
+
link.click();
|
|
2692
|
+
document.body.removeChild(link);
|
|
2693
|
+
URL.revokeObjectURL(url);
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
function sanitizeTextContent(content) {
|
|
2697
|
+
return content.replace(/\r\n|\r/g, "\n").replace(/[\x00-\x08\x0E-\x1F\x7F]/g, "").replace(/\n{4,}/g, "\n\n\n").replace(/[ \t]+$/gm, "");
|
|
2698
|
+
}
|
|
2699
|
+
async function importTxt(filePath, options = {}) {
|
|
2700
|
+
const {
|
|
2701
|
+
maxFileSize = 10 * 1024 * 1024,
|
|
2702
|
+
// 10MB default
|
|
2703
|
+
maxLength = 1e6,
|
|
2704
|
+
// 1M characters default
|
|
2705
|
+
validateSecurity = true,
|
|
2706
|
+
sanitize = true
|
|
2707
|
+
} = options;
|
|
2708
|
+
if (isNode()) {
|
|
2709
|
+
const fs = await import("fs/promises");
|
|
2710
|
+
const path = await import("path");
|
|
2711
|
+
const { isValidFilePath: isValidFilePath2, isValidFileSize: isValidFileSize2, isValidTextContent: isValidTextContent2 } = await Promise.resolve().then(() => (init_validators(), validators_exports));
|
|
2712
|
+
if (!isValidFilePath2(filePath)) {
|
|
2713
|
+
throw new Error("Invalid or unsafe file path");
|
|
2714
|
+
}
|
|
2715
|
+
const resolvedPath = path.resolve(filePath);
|
|
2716
|
+
try {
|
|
2717
|
+
const stats = await fs.stat(resolvedPath);
|
|
2718
|
+
if (!isValidFileSize2(stats.size, maxFileSize)) {
|
|
2719
|
+
throw new Error(`File too large: ${stats.size} bytes (max: ${maxFileSize})`);
|
|
2720
|
+
}
|
|
2721
|
+
} catch (error) {
|
|
2722
|
+
if (error.code === "ENOENT") {
|
|
2723
|
+
throw new Error(`File not found: ${filePath}`);
|
|
2724
|
+
}
|
|
2725
|
+
throw error;
|
|
2726
|
+
}
|
|
2727
|
+
const content = await fs.readFile(resolvedPath, { encoding: "utf-8" });
|
|
2728
|
+
if (validateSecurity && !isValidTextContent2(content, { maxLength })) {
|
|
2729
|
+
throw new Error("File contains potentially dangerous content or exceeds security limits");
|
|
2730
|
+
}
|
|
2731
|
+
return sanitize ? sanitizeTextContent(content) : content;
|
|
2732
|
+
} else {
|
|
2733
|
+
throw new Error(
|
|
2734
|
+
".txt file import is not supported in browser. Use readFileAsText() with a File object."
|
|
2735
|
+
);
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
async function exportData(data, filePath, options) {
|
|
2739
|
+
const format2 = detectFormatFromFilename(filePath);
|
|
2740
|
+
if (format2 === "csv") {
|
|
2741
|
+
validateExportData(data);
|
|
2742
|
+
}
|
|
2743
|
+
switch (format2) {
|
|
2744
|
+
case "csv": {
|
|
2745
|
+
const { exportCSV: exportCSV2 } = await Promise.resolve().then(() => (init_csv(), csv_exports));
|
|
2746
|
+
return exportCSV2(data, filePath, options);
|
|
2747
|
+
}
|
|
2748
|
+
case "json": {
|
|
2749
|
+
const { exportJSON: exportJSON2 } = await Promise.resolve().then(() => (init_json(), json_exports));
|
|
2750
|
+
return exportJSON2(data, filePath, options);
|
|
2751
|
+
}
|
|
2752
|
+
case "tree": {
|
|
2753
|
+
return exportTree(data, filePath, options);
|
|
2754
|
+
}
|
|
2755
|
+
case "txt": {
|
|
2756
|
+
return exportTxt(data, filePath, options);
|
|
2757
|
+
}
|
|
2758
|
+
default:
|
|
2759
|
+
throw new Error(`Unsupported format: ${format2}`);
|
|
2760
|
+
}
|
|
2761
|
+
}
|
|
2762
|
+
async function importData(filePath, options) {
|
|
2763
|
+
const format2 = detectFormatFromFilename(filePath);
|
|
2764
|
+
switch (format2) {
|
|
2765
|
+
case "csv": {
|
|
2766
|
+
const { importCSV: importCSV2 } = await Promise.resolve().then(() => (init_csv(), csv_exports));
|
|
2767
|
+
return importCSV2(filePath, options);
|
|
2768
|
+
}
|
|
2769
|
+
case "json": {
|
|
2770
|
+
const { importJSON: importJSON2 } = await Promise.resolve().then(() => (init_json(), json_exports));
|
|
2771
|
+
return importJSON2(filePath, options);
|
|
2772
|
+
}
|
|
2773
|
+
case "tree": {
|
|
2774
|
+
return importTree(filePath, options);
|
|
2775
|
+
}
|
|
2776
|
+
case "txt": {
|
|
2777
|
+
return importTxt(filePath, options);
|
|
2778
|
+
}
|
|
2779
|
+
default:
|
|
2780
|
+
throw new Error(`Unsupported format: ${format2}`);
|
|
2781
|
+
}
|
|
2782
|
+
}
|
|
2783
|
+
|
|
2784
|
+
// src/node/index.ts
|
|
2785
|
+
init_environment();
|
|
2786
|
+
init_tree();
|
|
2787
|
+
|
|
2788
|
+
// src/node/validation-crypto.ts
|
|
2789
|
+
var validation_crypto_exports = {};
|
|
2790
|
+
__export(validation_crypto_exports, {
|
|
2791
|
+
escapeShellCommand: () => escapeShellCommand,
|
|
2792
|
+
generateNonce: () => generateNonce,
|
|
2793
|
+
generateSecureToken: () => generateSecureToken,
|
|
2794
|
+
hashString: () => hashString,
|
|
2795
|
+
isSecureUrl: () => isSecureUrl,
|
|
2796
|
+
isValidBase64: () => isValidBase64,
|
|
2797
|
+
isValidJWTFormat: () => isValidJWTFormat,
|
|
2798
|
+
removeDangerousChars: () => removeDangerousChars,
|
|
2799
|
+
sanitizeHtml: () => sanitizeHtml,
|
|
2800
|
+
validatePassword: () => validatePassword
|
|
2801
|
+
});
|
|
2802
|
+
var import_crypto = require("crypto");
|
|
2803
|
+
var validatePassword = (password, criteria = {}) => {
|
|
2804
|
+
const {
|
|
2805
|
+
minLength = 8,
|
|
2806
|
+
requireUppercase = true,
|
|
2807
|
+
requireLowercase = true,
|
|
2808
|
+
requireNumbers = true,
|
|
2809
|
+
requireSpecialChars = true,
|
|
2810
|
+
maxLength = 128,
|
|
2811
|
+
forbiddenPatterns = []
|
|
2812
|
+
} = criteria;
|
|
2813
|
+
const errors = [];
|
|
2814
|
+
let score = 0;
|
|
2815
|
+
if (password.length < minLength) {
|
|
2816
|
+
errors.push(`La contrase\xF1a debe tener al menos ${minLength} caracteres`);
|
|
2817
|
+
} else {
|
|
2818
|
+
score += 20;
|
|
2819
|
+
}
|
|
2820
|
+
if (password.length > maxLength) {
|
|
2821
|
+
errors.push(`La contrase\xF1a no puede tener m\xE1s de ${maxLength} caracteres`);
|
|
2822
|
+
}
|
|
2823
|
+
if (requireUppercase && !/[A-Z]/.test(password)) {
|
|
2824
|
+
errors.push("La contrase\xF1a debe contener al menos una letra may\xFAscula");
|
|
2825
|
+
} else if (/[A-Z]/.test(password)) {
|
|
2826
|
+
score += 15;
|
|
2827
|
+
}
|
|
2828
|
+
if (requireLowercase && !/[a-z]/.test(password)) {
|
|
2829
|
+
errors.push("La contrase\xF1a debe contener al menos una letra min\xFAscula");
|
|
2830
|
+
} else if (/[a-z]/.test(password)) {
|
|
2831
|
+
score += 15;
|
|
2832
|
+
}
|
|
2833
|
+
if (requireNumbers && !/\d/.test(password)) {
|
|
2834
|
+
errors.push("La contrase\xF1a debe contener al menos un n\xFAmero");
|
|
2835
|
+
} else if (/\d/.test(password)) {
|
|
2836
|
+
score += 15;
|
|
2837
|
+
}
|
|
2838
|
+
if (requireSpecialChars && !/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/.test(password)) {
|
|
2839
|
+
errors.push("La contrase\xF1a debe contener al menos un caracter especial");
|
|
2840
|
+
} else if (/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/.test(password)) {
|
|
2841
|
+
score += 15;
|
|
2842
|
+
}
|
|
2843
|
+
for (const pattern of forbiddenPatterns) {
|
|
2844
|
+
if (password.toLowerCase().includes(pattern.toLowerCase())) {
|
|
2845
|
+
errors.push(`La contrase\xF1a no puede contener: ${pattern}`);
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
if (password.length >= 12) score += 10;
|
|
2849
|
+
if (password.length >= 16) score += 10;
|
|
2850
|
+
if (/(.)\\1{2,}/.test(password)) score -= 10;
|
|
2851
|
+
if (/123|abc|qwe/i.test(password)) score -= 15;
|
|
2852
|
+
score = Math.max(0, Math.min(100, score));
|
|
2853
|
+
let strength;
|
|
2854
|
+
if (score < 30) strength = "weak";
|
|
2855
|
+
else if (score < 60) strength = "fair";
|
|
2856
|
+
else if (score < 80) strength = "good";
|
|
2857
|
+
else strength = "strong";
|
|
2858
|
+
return {
|
|
2859
|
+
isValid: errors.length === 0,
|
|
2860
|
+
errors,
|
|
2861
|
+
strength,
|
|
2862
|
+
score
|
|
2863
|
+
};
|
|
2864
|
+
};
|
|
2865
|
+
var sanitizeHtml = (html) => {
|
|
2866
|
+
if (!html) return "";
|
|
2867
|
+
let sanitized = html.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").replace(/<style\b[^<]*(?:(?!<\/style>)<[^<]*)*<\/style>/gi, "");
|
|
2868
|
+
sanitized = sanitized.replace(/ on\w+="[^"]*"/gi, "");
|
|
2869
|
+
sanitized = sanitized.replace(/ on\w+='[^']*'/gi, "");
|
|
2870
|
+
sanitized = sanitized.replace(/javascript:/gi, "");
|
|
2871
|
+
sanitized = sanitized.replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi, "");
|
|
2872
|
+
sanitized = sanitized.replace(/<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi, "");
|
|
2873
|
+
sanitized = sanitized.replace(/<embed\b[^>]*>/gi, "");
|
|
2874
|
+
return sanitized.trim();
|
|
2875
|
+
};
|
|
2876
|
+
var isValidJWTFormat = (token) => {
|
|
2877
|
+
if (!token || typeof token !== "string") return false;
|
|
2878
|
+
const parts = token.split(".");
|
|
2879
|
+
if (parts.length !== 3) return false;
|
|
2880
|
+
try {
|
|
2881
|
+
for (const part of parts) {
|
|
2882
|
+
if (!part || !/^[A-Za-z0-9_-]+$/.test(part)) return false;
|
|
2883
|
+
atob(part.replace(/-/g, "+").replace(/_/g, "/"));
|
|
2884
|
+
}
|
|
2885
|
+
return true;
|
|
2886
|
+
} catch {
|
|
2887
|
+
return false;
|
|
2888
|
+
}
|
|
2889
|
+
};
|
|
2890
|
+
var hashString = (input, salt = "") => {
|
|
2891
|
+
return (0, import_crypto.createHash)("sha256").update(input + salt).digest("hex");
|
|
2892
|
+
};
|
|
2893
|
+
var generateSecureToken = (length = 32) => {
|
|
2894
|
+
return (0, import_crypto.randomBytes)(length).toString("hex");
|
|
2895
|
+
};
|
|
2896
|
+
var isValidBase64 = (input) => {
|
|
2897
|
+
if (!input || typeof input !== "string") return false;
|
|
2898
|
+
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(input)) return false;
|
|
2899
|
+
try {
|
|
2900
|
+
const decoded = atob(input);
|
|
2901
|
+
const reencoded = btoa(decoded);
|
|
2902
|
+
return reencoded === input;
|
|
2903
|
+
} catch {
|
|
2904
|
+
return false;
|
|
2905
|
+
}
|
|
2906
|
+
};
|
|
2907
|
+
var escapeShellCommand = (input) => {
|
|
2908
|
+
if (!input) return "";
|
|
2909
|
+
return input.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/"/g, '\\"').replace(/;/g, "\\;").replace(/&/g, "\\&").replace(/\|/g, "\\|").replace(/`/g, "\\`").replace(/\$/g, "\\$").replace(/\(/g, "\\(").replace(/\)/g, "\\)").replace(/</g, "\\\\<").replace(/>/g, "\\\\>");
|
|
2910
|
+
};
|
|
2911
|
+
var isSecureUrl = (url) => {
|
|
2912
|
+
if (!url || typeof url !== "string") return false;
|
|
2913
|
+
try {
|
|
2914
|
+
const parsed = new URL(url);
|
|
2915
|
+
return parsed.protocol === "https:" || parsed.protocol === "http:" && (parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1");
|
|
2916
|
+
} catch {
|
|
2917
|
+
return false;
|
|
2918
|
+
}
|
|
2919
|
+
};
|
|
2920
|
+
var removeDangerousChars = (input, replacement = "") => {
|
|
2921
|
+
if (!input) return "";
|
|
2922
|
+
return input.replace(/[<>]/g, replacement).replace(/['"]/g, replacement).replace(/[&]/g, replacement).replace(/[\\x00-\\x1f\\x7f]/g, replacement);
|
|
2923
|
+
};
|
|
2924
|
+
var generateNonce = (length = 32) => {
|
|
2925
|
+
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
2926
|
+
let result = "";
|
|
2927
|
+
const bytes = (0, import_crypto.randomBytes)(length);
|
|
2928
|
+
for (let i = 0; i < length; i++) {
|
|
2929
|
+
result += chars[bytes[i] % chars.length];
|
|
2930
|
+
}
|
|
2931
|
+
return result;
|
|
2932
|
+
};
|
|
2933
|
+
|
|
2934
|
+
// src/node/index.ts
|
|
2935
|
+
init_environment();
|
|
2936
|
+
init_tree();
|
|
2937
|
+
var validationFunctions = {
|
|
2938
|
+
...validation_core_exports,
|
|
2939
|
+
...validation_crypto_exports
|
|
2940
|
+
};
|
|
2941
|
+
var g = {
|
|
2942
|
+
// Full validation functions (core + crypto)
|
|
2943
|
+
...validationFunctions,
|
|
2944
|
+
// String functions
|
|
2945
|
+
...strings_exports,
|
|
2946
|
+
// Object/Array functions
|
|
2947
|
+
...objects_exports,
|
|
2948
|
+
// Date functions
|
|
2949
|
+
...dates_exports,
|
|
2950
|
+
// Math functions
|
|
2951
|
+
...math_exports,
|
|
2952
|
+
// Async functions
|
|
2953
|
+
...async_exports,
|
|
2954
|
+
// Data functions
|
|
2955
|
+
...data_exports,
|
|
2956
|
+
// Number utilities
|
|
2957
|
+
...number_exports,
|
|
2958
|
+
// Tree utilities
|
|
2959
|
+
...tree_exports,
|
|
2960
|
+
// Environment utilities
|
|
2961
|
+
...environment_exports
|
|
2962
|
+
};
|
|
2963
|
+
var node_default = g;
|
|
2964
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2965
|
+
0 && (module.exports = {
|
|
2966
|
+
addDays,
|
|
2967
|
+
addMonths,
|
|
2968
|
+
addNowDays,
|
|
2969
|
+
addNowMonths,
|
|
2970
|
+
addNowSeconds,
|
|
2971
|
+
addNowYears,
|
|
2972
|
+
addSeconds,
|
|
2973
|
+
addYears,
|
|
2974
|
+
areDatesEqualWithTolerance,
|
|
2975
|
+
async,
|
|
2976
|
+
calculateAggregations,
|
|
2977
|
+
calculateAnnuityPayment,
|
|
2978
|
+
calculateCorrelation,
|
|
2979
|
+
calculateDifferences,
|
|
2980
|
+
calculateEuclideanDistance,
|
|
2981
|
+
calculateFutureValue,
|
|
2982
|
+
calculateHistogram,
|
|
2983
|
+
calculateIQR,
|
|
2984
|
+
calculateIRR,
|
|
2985
|
+
calculateManhattanDistance,
|
|
2986
|
+
calculateMedian,
|
|
2987
|
+
calculateMode,
|
|
2988
|
+
calculateNPV,
|
|
2989
|
+
calculatePercentile,
|
|
2990
|
+
calculatePresentValue,
|
|
2991
|
+
calculateQuartiles,
|
|
2992
|
+
calculateStandardDeviation,
|
|
2993
|
+
calculateTrendSlope,
|
|
2994
|
+
calculateVariance,
|
|
2995
|
+
capitalizeEachWord,
|
|
2996
|
+
capitalizeFirst,
|
|
2997
|
+
cleanJsonChars,
|
|
2998
|
+
comparator,
|
|
2999
|
+
contains,
|
|
3000
|
+
countOccurrences,
|
|
3001
|
+
data,
|
|
3002
|
+
dates,
|
|
3003
|
+
dayOfWeek,
|
|
3004
|
+
deepEqual,
|
|
3005
|
+
deleteArrayElementsBy,
|
|
3006
|
+
detectFileExtension,
|
|
3007
|
+
detectFormatFromFilename,
|
|
3008
|
+
detectHostname,
|
|
3009
|
+
detectOutliers,
|
|
3010
|
+
detectProtocol,
|
|
3011
|
+
detectUniversalFormat,
|
|
3012
|
+
diffBusinessDays,
|
|
3013
|
+
diffDays,
|
|
3014
|
+
diffMilliSeconds,
|
|
3015
|
+
diffMonths,
|
|
3016
|
+
diffYears,
|
|
3017
|
+
endsWith,
|
|
3018
|
+
ensureEndsWith,
|
|
3019
|
+
ensureStartsWith,
|
|
3020
|
+
envKeyToPath,
|
|
3021
|
+
environment,
|
|
3022
|
+
escapeHtmlChars,
|
|
3023
|
+
escapeShellCommand,
|
|
3024
|
+
excelToDate,
|
|
3025
|
+
exportData,
|
|
3026
|
+
exportTree,
|
|
3027
|
+
exportTxt,
|
|
3028
|
+
format,
|
|
3029
|
+
formatForMysql,
|
|
3030
|
+
formatNow,
|
|
3031
|
+
formatToReadableString,
|
|
3032
|
+
fromNow,
|
|
3033
|
+
generateAlphaNumericString,
|
|
3034
|
+
generateAlphaString,
|
|
3035
|
+
generateComplexString,
|
|
3036
|
+
generateCrcHash,
|
|
3037
|
+
generateEmail,
|
|
3038
|
+
generateHexColor,
|
|
3039
|
+
generateNonce,
|
|
3040
|
+
generatePassword,
|
|
3041
|
+
generateRandomInteger,
|
|
3042
|
+
generateSecureToken,
|
|
3043
|
+
generateSpanishCIF,
|
|
3044
|
+
generateSpanishIBAN,
|
|
3045
|
+
generateSpanishNIE,
|
|
3046
|
+
generateSpanishNIF,
|
|
3047
|
+
generateSpanishPostalCode,
|
|
3048
|
+
generateUsername,
|
|
3049
|
+
generateUsernameFromEmail,
|
|
3050
|
+
getDeepValue,
|
|
3051
|
+
getEnvironmentInfo,
|
|
3052
|
+
getFirstDayOfYear,
|
|
3053
|
+
getFirstWorkdayAfterMonths,
|
|
3054
|
+
getFirstWorkdayOfMonth,
|
|
3055
|
+
getLastDayOfYear,
|
|
3056
|
+
getLastWorkdayOfMonth,
|
|
3057
|
+
getShallowProperties,
|
|
3058
|
+
handleOperation,
|
|
3059
|
+
hasSameType,
|
|
3060
|
+
hashString,
|
|
3061
|
+
importData,
|
|
3062
|
+
importTree,
|
|
3063
|
+
importTxt,
|
|
3064
|
+
isBrowser,
|
|
3065
|
+
isBrowserEnvironment,
|
|
3066
|
+
isDateTime,
|
|
3067
|
+
isDevelopment,
|
|
3068
|
+
isEmail,
|
|
3069
|
+
isEmpty,
|
|
3070
|
+
isEqualsDateTimeByDay,
|
|
3071
|
+
isExpired,
|
|
3072
|
+
isLocalhost,
|
|
3073
|
+
isNew,
|
|
3074
|
+
isNode,
|
|
3075
|
+
isNodeEnvironment,
|
|
3076
|
+
isNonProduction,
|
|
3077
|
+
isNumericValue,
|
|
3078
|
+
isPrivateIP,
|
|
3079
|
+
isProduction,
|
|
3080
|
+
isSecureUrl,
|
|
3081
|
+
isTest,
|
|
3082
|
+
isValidBase64,
|
|
3083
|
+
isValidCIF,
|
|
3084
|
+
isValidEmail,
|
|
3085
|
+
isValidJSON,
|
|
3086
|
+
isValidJWTFormat,
|
|
3087
|
+
isValidNIE,
|
|
3088
|
+
isValidNIF,
|
|
3089
|
+
isValidSpanishIBAN,
|
|
3090
|
+
isValidSpanishPhone,
|
|
3091
|
+
isValidSpanishPostalCode,
|
|
3092
|
+
isValidURL,
|
|
3093
|
+
isWeekday,
|
|
3094
|
+
longString,
|
|
3095
|
+
matchPathPattern,
|
|
3096
|
+
math,
|
|
3097
|
+
normalizeToRange,
|
|
3098
|
+
now,
|
|
3099
|
+
number,
|
|
3100
|
+
objects,
|
|
3101
|
+
padEnd,
|
|
3102
|
+
padStart,
|
|
3103
|
+
parseEnvValue,
|
|
3104
|
+
pathToEnvKey,
|
|
3105
|
+
readFileAsText,
|
|
3106
|
+
removeAccents,
|
|
3107
|
+
removeDangerousChars,
|
|
3108
|
+
renderTreeAsText,
|
|
3109
|
+
repeatString,
|
|
3110
|
+
replaceAllOccurrences,
|
|
3111
|
+
reverseString,
|
|
3112
|
+
roundToDecimals,
|
|
3113
|
+
runBatch,
|
|
3114
|
+
sanitizeHtml,
|
|
3115
|
+
sanitizeString,
|
|
3116
|
+
scaleToRange,
|
|
3117
|
+
setDeepValue,
|
|
3118
|
+
simpleKMeans,
|
|
3119
|
+
sleep,
|
|
3120
|
+
startsWith,
|
|
3121
|
+
strings,
|
|
3122
|
+
stripFromEnd,
|
|
3123
|
+
stripFromStart,
|
|
3124
|
+
toCamelCase,
|
|
3125
|
+
toDate,
|
|
3126
|
+
toDateFromString,
|
|
3127
|
+
toISO,
|
|
3128
|
+
toKebabCase,
|
|
3129
|
+
toLowerCase,
|
|
3130
|
+
toPascalCase,
|
|
3131
|
+
toSnakeCase,
|
|
3132
|
+
toUpperCase,
|
|
3133
|
+
toUrlSlug,
|
|
3134
|
+
tree,
|
|
3135
|
+
trim,
|
|
3136
|
+
trimEnd,
|
|
3137
|
+
trimStart,
|
|
3138
|
+
truncateString,
|
|
3139
|
+
unescapeHtmlChars,
|
|
3140
|
+
unescapeUnicode,
|
|
3141
|
+
updateArrayElementById,
|
|
3142
|
+
updateArrayElementsBy,
|
|
3143
|
+
validateCSVData,
|
|
3144
|
+
validateExportData,
|
|
3145
|
+
validateNIF,
|
|
3146
|
+
validatePassword,
|
|
3147
|
+
validation,
|
|
3148
|
+
wait,
|
|
3149
|
+
weekOfYear
|
|
3150
|
+
});
|
|
3151
|
+
//# sourceMappingURL=index.js.map
|