@rzl-zone/utils-js 3.3.1 → 3.5.0
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/README.md +94 -45
- package/dist/assertions/index.cjs +34 -1
- package/dist/assertions/index.d.ts +2 -2
- package/dist/assertions/index.js +5 -1
- package/dist/chunk-2CQX5CBG.js +247 -1
- package/dist/chunk-2IOOEY45.cjs +20 -1
- package/dist/chunk-2WA36TC5.cjs +176 -0
- package/dist/chunk-3IBQ5MOM.js +6 -1
- package/dist/chunk-3VA554KW.js +23 -1
- package/dist/chunk-5757UBXJ.cjs +144 -1
- package/dist/chunk-5IGC6PBH.js +22 -1
- package/dist/chunk-5KJFVIQT.cjs +55 -1
- package/dist/chunk-6JFCSH7J.js +24 -1
- package/dist/chunk-6JFZL7YE.cjs +14 -1
- package/dist/chunk-7ODAAXX5.cjs +361 -1
- package/dist/chunk-BAV5T2E3.cjs +5 -1
- package/dist/chunk-CAH33WOQ.cjs +25 -1
- package/dist/chunk-CDCERIZ2.js +164 -0
- package/dist/chunk-CKTLUNWX.js +12 -1
- package/dist/chunk-CMW2TBOQ.js +522 -1
- package/dist/chunk-D3ENH7H6.cjs +87 -1
- package/dist/chunk-DEZZUYE2.js +139 -1
- package/dist/chunk-DVMHRLKP.cjs +6 -1
- package/dist/chunk-DWF2R5GD.cjs +212 -1
- package/dist/chunk-E55EQK2U.cjs +8 -1
- package/dist/chunk-E74U6CYP.cjs +8 -1
- package/dist/chunk-EL6A35UR.cjs +51 -1
- package/dist/chunk-F6IPNNSJ.cjs +531 -1
- package/dist/chunk-FJZGG54N.cjs +252 -1
- package/dist/chunk-FWCKOJZM.js +519 -1
- package/dist/chunk-FWHNWL2P.cjs +409 -1
- package/dist/chunk-GGEADHZO.js +78 -1
- package/dist/chunk-GQR4R5WY.js +21 -1
- package/dist/chunk-H66AC7GK.cjs +81 -1
- package/dist/chunk-HQWOFR56.cjs +23 -1
- package/dist/chunk-HYRQMTRH.cjs +14 -1
- package/dist/chunk-IRFL4MAX.js +53 -1
- package/dist/chunk-IVL7CKVH.cjs +26 -1
- package/dist/chunk-IZPBKKPO.js +6 -1
- package/dist/chunk-JBQMXC5I.cjs +93 -1
- package/dist/chunk-JEQEF5WD.js +81 -1
- package/dist/chunk-JMJQCN74.js +334 -1
- package/dist/chunk-KHO2SBNA.cjs +6 -1
- package/dist/chunk-KVAL5PAG.cjs +16 -1
- package/dist/chunk-L5RDAVVH.js +5 -1
- package/dist/chunk-LS6U7FAY.cjs +98 -1
- package/dist/chunk-NBZWMBO6.js +88 -1
- package/dist/chunk-NRF6LWBC.cjs +45 -1
- package/dist/chunk-OI5XKNZO.js +42 -1
- package/dist/chunk-ONZFBJVW.js +5 -1
- package/dist/chunk-OYTYSY7G.js +94 -1
- package/dist/chunk-PET42Z7W.js +107 -1
- package/dist/chunk-PZQ6I4JJ.cjs +559 -1
- package/dist/chunk-QBKAEVYG.js +102 -1
- package/dist/chunk-QNKGP5DY.js +5 -1
- package/dist/chunk-RIPKY4RU.js +407 -1
- package/dist/chunk-RZW35UN5.cjs +105 -1
- package/dist/chunk-SBFNXGTJ.js +207 -1
- package/dist/chunk-SBKGWRS5.js +12 -1
- package/dist/chunk-SIM77PU4.js +46 -1
- package/dist/chunk-T2T7K3KR.js +18 -1
- package/dist/chunk-T7PU2V7X.cjs +111 -1
- package/dist/chunk-UDA26MCU.cjs +6 -1
- package/dist/chunk-V45XJKHW.cjs +8 -1
- package/dist/chunk-VJDDGRIK.cjs +6 -1
- package/dist/chunk-W2WNBUDE.js +6 -1
- package/dist/chunk-WVSPXFTY.js +5 -1
- package/dist/chunk-XABCB3Y7.cjs +563 -1
- package/dist/chunk-XEDXFSGI.js +14 -1
- package/dist/chunk-YKPSRP5G.js +552 -1
- package/dist/chunk-YWHHVDT4.js +4 -1
- package/dist/chunk-ZETAZZLD.cjs +27 -1
- package/dist/conversions/index.cjs +97 -1
- package/dist/conversions/index.d.ts +2 -2
- package/dist/conversions/index.js +16 -1
- package/dist/events/index.cjs +25 -1
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.js +4 -1
- package/dist/formatters/index.cjs +55 -1
- package/dist/formatters/index.d.ts +2 -2
- package/dist/formatters/index.js +10 -1
- package/dist/generators/index.cjs +31 -1
- package/dist/generators/index.d.ts +2 -2
- package/dist/generators/index.js +6 -1
- package/dist/index.d.ts +1 -1
- package/dist/{isPlainObject-DGJkcFYw.d.ts → isPlainObject-FWmcJF6k.d.ts} +5 -5
- package/dist/next/index.cjs +205 -1
- package/dist/next/index.d.ts +2 -2
- package/dist/next/index.js +200 -1
- package/dist/next/server/index.cjs +34 -1
- package/dist/next/server/index.d.ts +1 -1
- package/dist/next/server/index.js +32 -1
- package/dist/operations/index.cjs +26 -1
- package/dist/operations/index.d.ts +2 -2
- package/dist/operations/index.js +9 -1
- package/dist/parsers/index.cjs +11 -1
- package/dist/parsers/index.d.ts +1 -1
- package/dist/parsers/index.js +2 -1
- package/dist/predicates/index.cjs +292 -1
- package/dist/predicates/index.d.ts +4 -4
- package/dist/predicates/index.js +15 -1
- package/dist/promises/index.cjs +18 -1
- package/dist/promises/index.d.ts +2 -2
- package/dist/promises/index.js +5 -1
- package/dist/rzl-utils.global.js +16 -1
- package/dist/strings/index.cjs +75 -1
- package/dist/strings/index.d.ts +2 -2
- package/dist/strings/index.js +6 -1
- package/dist/tailwind/index.cjs +36 -1
- package/dist/tailwind/index.d.ts +1 -1
- package/dist/tailwind/index.js +3 -1
- package/dist/urls/index.cjs +44 -1
- package/dist/urls/index.d.ts +1 -1
- package/dist/urls/index.js +15 -1
- package/package.json +16 -24
- package/dist/NumberRangeUnion-B6bhM2s7.d.ts +0 -33
- package/dist/any-v4TsK9ES.d.ts +0 -66
- package/dist/arrays-normalize-recursive-BqmVuFlD.d.ts +0 -72
- package/dist/chunk-JYQTCICM.js +0 -1
- package/dist/chunk-YLA3DURS.cjs +0 -1
- package/dist/extends-DtdRjDyU.d.ts +0 -343
- package/dist/if-ChM35c_q.d.ts +0 -19
- package/dist/is-array-BJeHxPM3.d.ts +0 -952
- package/dist/never-D89PbPh5.d.ts +0 -66
- package/dist/nils-CO8zLHSB.d.ts +0 -151
- package/dist/or-C6qzKt2I.d.ts +0 -82
- package/dist/override-CL2olHE5.d.ts +0 -59
- package/dist/pick-BSMX6Xe2.d.ts +0 -15
- package/dist/prettify-3o8_Kw6b.d.ts +0 -564
- package/dist/promises-LU7K00H0.d.ts +0 -72
- package/dist/string-B1jlOnws.d.ts +0 -312
- package/dist/types/index.d.ts +0 -3345
package/dist/next/index.js
CHANGED
|
@@ -1 +1,200 @@
|
|
|
1
|
-
import{normalizePathname
|
|
1
|
+
import { normalizePathname, formatEnvPort } from '../chunk-GGEADHZO.js';
|
|
2
|
+
import { removeSpaces } from '../chunk-XEDXFSGI.js';
|
|
3
|
+
import { isEmptyString } from '../chunk-W2WNBUDE.js';
|
|
4
|
+
import { assertIsString } from '../chunk-SBKGWRS5.js';
|
|
5
|
+
import { safeStableStringify } from '../chunk-PET42Z7W.js';
|
|
6
|
+
import '../chunk-QNKGP5DY.js';
|
|
7
|
+
import { isString, getPreciseType, assertIsPlainObject, isNil, isNonEmptyArray, isNonEmptyString, isPlainObject, isUndefined, assertIsBoolean, isError, hasOwnProp } from '../chunk-CMW2TBOQ.js';
|
|
8
|
+
function generateRoute(route, params) {
|
|
9
|
+
if (!isString(route) || isEmptyString(route)) {
|
|
10
|
+
throw new TypeError(
|
|
11
|
+
`\u274C 'generateRoute' Failed:
|
|
12
|
+
- Invalid 'route' value.
|
|
13
|
+
- Must be of type \`string\` and non-empty string, but received: "${getPreciseType(
|
|
14
|
+
route
|
|
15
|
+
)}": \`${safeStableStringify(route)}\`.`
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
if (!/[\\[\]]/.test(route)) {
|
|
19
|
+
return route;
|
|
20
|
+
}
|
|
21
|
+
assertIsPlainObject(params, {
|
|
22
|
+
message: ({ validType }) => `\u274C 'generateRoute' Failed cause in route "${route}":
|
|
23
|
+
- Missing or invalid parameters \`${validType}\` for route: "${route}", must be of type \`${validType}\` mapping parameters.`
|
|
24
|
+
});
|
|
25
|
+
if (isNil(params)) {
|
|
26
|
+
throw new TypeError(
|
|
27
|
+
`\u274C 'generateRoute' Failed cause in route "${route}":
|
|
28
|
+
- Missing parameters \`plain-object\` for route: "${route}".`
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
const invalidChars = [
|
|
32
|
+
"?",
|
|
33
|
+
"&",
|
|
34
|
+
"#",
|
|
35
|
+
"=",
|
|
36
|
+
"/",
|
|
37
|
+
// "`",
|
|
38
|
+
// " ",
|
|
39
|
+
// ".",
|
|
40
|
+
"'",
|
|
41
|
+
'"',
|
|
42
|
+
"(",
|
|
43
|
+
")",
|
|
44
|
+
"+",
|
|
45
|
+
";",
|
|
46
|
+
"%",
|
|
47
|
+
"@",
|
|
48
|
+
":"
|
|
49
|
+
];
|
|
50
|
+
const errors = [];
|
|
51
|
+
const requiredKeys = Array.from(route.matchAll(/\[(\w+)\]/g)).map((m) => m[1]);
|
|
52
|
+
for (const key of requiredKeys) {
|
|
53
|
+
const value = params[key];
|
|
54
|
+
if (!isString(value)) {
|
|
55
|
+
errors.push(
|
|
56
|
+
`- Invalid parameter: "${key}" must be of type \`string\`, but received: \`${getPreciseType(
|
|
57
|
+
value
|
|
58
|
+
)}\`.`
|
|
59
|
+
);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (isEmptyString(value)) {
|
|
63
|
+
errors.push(`- Parameter "${key}" cannot be empty string.`);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const foundInvalidChars = invalidChars.filter((char) => value.includes(char));
|
|
67
|
+
if (/\s/.test(value)) {
|
|
68
|
+
foundInvalidChars.push("white-space(s)");
|
|
69
|
+
}
|
|
70
|
+
if (foundInvalidChars.length > 0) {
|
|
71
|
+
const formattedChars = foundInvalidChars.map(
|
|
72
|
+
(c) => c === "`" ? "backtick - (`)" : `\`${c}\``
|
|
73
|
+
);
|
|
74
|
+
if (!invalidChars.includes("white-space(s)")) invalidChars.push("white-space(s)");
|
|
75
|
+
const formattedInvalidChars = invalidChars.map(
|
|
76
|
+
(c) => c === "`" ? "backtick - (`)" : `\`${c}\``
|
|
77
|
+
);
|
|
78
|
+
errors.push(
|
|
79
|
+
`- Parameter "${key}" contains invalid characters (${formattedChars.join(
|
|
80
|
+
", "
|
|
81
|
+
)}). These characters are not allowed because they could cause issues in URL structure. The following characters are forbidden in route parameters: (${formattedInvalidChars.join(
|
|
82
|
+
", "
|
|
83
|
+
)}).`
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (isNonEmptyArray(errors)) {
|
|
88
|
+
throw new Error(
|
|
89
|
+
`\u274C 'generateRoute' Failed cause in route "${route}":
|
|
90
|
+
${errors.join("\n")}.`
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
return route.replace(/\[(\w+)\]/g, (_, key) => {
|
|
94
|
+
const paramKey = isNonEmptyString(params[key]) ? params[key] : "";
|
|
95
|
+
return paramKey.trim().replace(/^\/+|\/+$/g, "");
|
|
96
|
+
}).replace(/\/+/g, "/");
|
|
97
|
+
}
|
|
98
|
+
var createBeApiUrl = (pathname, options = {}) => {
|
|
99
|
+
try {
|
|
100
|
+
let joinPath2 = function(a, b) {
|
|
101
|
+
return `${a.replace(/\/+$/, "")}/${b.replace(/^\/+/, "")}`;
|
|
102
|
+
};
|
|
103
|
+
var joinPath = joinPath2;
|
|
104
|
+
assertIsString(isNil(pathname) ? "" : pathname, {
|
|
105
|
+
message({ currentType, validType }) {
|
|
106
|
+
return `First parameter (\`pathname\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
if (!isPlainObject(options)) {
|
|
110
|
+
options = {};
|
|
111
|
+
}
|
|
112
|
+
let {
|
|
113
|
+
prefix = "/api",
|
|
114
|
+
withOrigin = true
|
|
115
|
+
} = options;
|
|
116
|
+
if (!isUndefined(prefix) && !isString(prefix)) {
|
|
117
|
+
throw new TypeError(
|
|
118
|
+
`Parameter \`prefix\` property of the \`options\` (second parameter) must be of type \`string\`, but received: \`${getPreciseType(
|
|
119
|
+
prefix
|
|
120
|
+
)}\`.`
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
assertIsBoolean(withOrigin, {
|
|
124
|
+
message: ({ currentType, validType }) => `Parameter \`withOrigin\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
125
|
+
});
|
|
126
|
+
pathname = normalizePathname(pathname);
|
|
127
|
+
prefix = normalizePathname(prefix);
|
|
128
|
+
const normalizedPrefix = prefix.endsWith("/") ? prefix : prefix + "/";
|
|
129
|
+
if (pathname === prefix || pathname === prefix + "/" || pathname.startsWith(normalizedPrefix)) {
|
|
130
|
+
pathname = pathname.slice(prefix.length);
|
|
131
|
+
pathname = normalizePathname(pathname);
|
|
132
|
+
}
|
|
133
|
+
const baseApiUrl = getBeApiUrl({ suffix: prefix });
|
|
134
|
+
const fullPath = withOrigin ? joinPath2(baseApiUrl, pathname) : joinPath2(new URL(baseApiUrl).pathname, pathname);
|
|
135
|
+
return fullPath.replace(/\/+$/, "");
|
|
136
|
+
} catch (err) {
|
|
137
|
+
if (isError(err)) {
|
|
138
|
+
throw err;
|
|
139
|
+
} else
|
|
140
|
+
throw new Error(
|
|
141
|
+
"Failed to generate backend API URL in `createBeApiUrl()`, Error: " + new Error(String(err)).message.trim()
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
var getBeApiUrl = (options = {}) => {
|
|
146
|
+
if (!isPlainObject(options)) options = {};
|
|
147
|
+
let suffix = hasOwnProp(options, "suffix") ? options.suffix : "/";
|
|
148
|
+
assertIsString(suffix, {
|
|
149
|
+
message({ currentType, validType }) {
|
|
150
|
+
return `Parameter \`suffix\` property of the first parameter must be of type \`${validType}\`, but received: \`${currentType}\`.`;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
try {
|
|
154
|
+
let rawBaseUrl = process.env.NEXT_PUBLIC_BACKEND_API_URL?.trim();
|
|
155
|
+
if (rawBaseUrl) {
|
|
156
|
+
rawBaseUrl = removeSpaces(rawBaseUrl);
|
|
157
|
+
const urlObj = new URL(rawBaseUrl);
|
|
158
|
+
const hasPort = !!urlObj.port;
|
|
159
|
+
if (!hasPort && process.env.NEXT_PUBLIC_PORT_BE) {
|
|
160
|
+
rawBaseUrl = urlObj.origin + formatEnvPort(process.env.NEXT_PUBLIC_PORT_BE, {
|
|
161
|
+
prefixColon: true
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
} else {
|
|
165
|
+
rawBaseUrl = "http://localhost" + formatEnvPort(process.env.NEXT_PUBLIC_PORT_BE || "8000", {
|
|
166
|
+
prefixColon: true
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
suffix = removeSpaces(suffix).length ? removeSpaces(suffix) : "/";
|
|
170
|
+
const baseApiUrl = new URL(rawBaseUrl.replace(/\/+$/, "")).origin;
|
|
171
|
+
const finalSuffix = suffix === "/" ? "/" : `${suffix.startsWith("/") ? "" : "/"}${suffix.replace(/\/+$/, "")}`;
|
|
172
|
+
return `${baseApiUrl}${finalSuffix}`;
|
|
173
|
+
} catch (error) {
|
|
174
|
+
throw new Error(
|
|
175
|
+
"Invalid `NEXT_PUBLIC_BACKEND_API_URL`, failed to generate from `getBeApiUrl()`, Error:" + error
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
var getBaseUrl = () => {
|
|
180
|
+
try {
|
|
181
|
+
const baseEnv = process.env.NEXT_PUBLIC_BASE_URL?.trim();
|
|
182
|
+
const portEnv = process.env.NEXT_PUBLIC_PORT_FE?.trim();
|
|
183
|
+
let baseUrl = baseEnv || "http://localhost";
|
|
184
|
+
baseUrl = removeSpaces(baseUrl).replace(/\/+$/, "");
|
|
185
|
+
const hasPort = /:\/\/[^/]+:\d+/.test(baseUrl);
|
|
186
|
+
if (!hasPort && portEnv) {
|
|
187
|
+
baseUrl += formatEnvPort(portEnv, { prefixColon: true });
|
|
188
|
+
} else if (!hasPort && !baseEnv) {
|
|
189
|
+
baseUrl += ":3000";
|
|
190
|
+
}
|
|
191
|
+
const url = new URL(baseUrl);
|
|
192
|
+
return `${url.protocol}//${url.hostname}${url.port ? `:${url.port}` : ""}`;
|
|
193
|
+
} catch (error) {
|
|
194
|
+
throw new Error(
|
|
195
|
+
"Invalid `NEXT_PUBLIC_BASE_URL`, failed to generate from `getBaseUrl()`, Error:" + error
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
export { createBeApiUrl, generateRoute, getBaseUrl, getBeApiUrl };
|
|
@@ -1 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkPZQ6I4JJ_cjs = require('../../chunk-PZQ6I4JJ.cjs');
|
|
4
|
+
require('server-only');
|
|
5
|
+
var server = require('next/server');
|
|
6
|
+
|
|
7
|
+
var getClientIpOrUrl = (request, includeFullUrl = true) => {
|
|
8
|
+
if (!chunkPZQ6I4JJ_cjs.isFunction(server.NextRequest)) {
|
|
9
|
+
throw new Error(
|
|
10
|
+
"Function `getClientIpOrUrl` is designed to be used in a `NextJS` environment."
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
if (!(request instanceof server.NextRequest)) {
|
|
14
|
+
throw new TypeError(
|
|
15
|
+
"First parameter (`request`) must be an `instance of NextRequest` from `NextJS`."
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
chunkPZQ6I4JJ_cjs.assertIsBoolean(includeFullUrl, {
|
|
19
|
+
message: ({ currentType, validType }) => `Second parameter (\`includeFullUrl\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
20
|
+
});
|
|
21
|
+
const forwardedIps = (request.headers.get("x-forwarded-for") ?? "127.0.0.1").trim().split(",");
|
|
22
|
+
if (forwardedIps[0] === "::ffff:127.0.0.1" || forwardedIps[0] === "::1") {
|
|
23
|
+
forwardedIps[0] = "127.0.0.1";
|
|
24
|
+
}
|
|
25
|
+
const clientIp = forwardedIps.length > 1 ? forwardedIps[forwardedIps.length - 1].trim() : forwardedIps[0];
|
|
26
|
+
if (!includeFullUrl) {
|
|
27
|
+
return clientIp;
|
|
28
|
+
}
|
|
29
|
+
const protocol = request.headers.get("x-forwarded-proto") || "http";
|
|
30
|
+
const port = request.headers.get("x-forwarded-port") || "3000";
|
|
31
|
+
return `${process.env.NODE_ENV === "production" ? protocol : "http"}://${clientIp}:${port}`;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.getClientIpOrUrl = getClientIpOrUrl;
|
|
@@ -25,4 +25,4 @@ import{NextRequest}from'next/server';
|
|
|
25
25
|
* const url = getClientIpOrUrl(request);
|
|
26
26
|
* console.log("Client full URL:", url);
|
|
27
27
|
*/
|
|
28
|
-
declare const getClientIpOrUrl:(request:NextRequest,includeFullUrl?:boolean)=>string;export{getClientIpOrUrl};
|
|
28
|
+
declare const getClientIpOrUrl:(request:NextRequest,includeFullUrl?:boolean)=>string;export{getClientIpOrUrl};
|
|
@@ -1 +1,32 @@
|
|
|
1
|
-
import{isFunction
|
|
1
|
+
import { isFunction, assertIsBoolean } from '../../chunk-CMW2TBOQ.js';
|
|
2
|
+
import 'server-only';
|
|
3
|
+
import { NextRequest } from 'next/server';
|
|
4
|
+
|
|
5
|
+
var getClientIpOrUrl = (request, includeFullUrl = true) => {
|
|
6
|
+
if (!isFunction(NextRequest)) {
|
|
7
|
+
throw new Error(
|
|
8
|
+
"Function `getClientIpOrUrl` is designed to be used in a `NextJS` environment."
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
if (!(request instanceof NextRequest)) {
|
|
12
|
+
throw new TypeError(
|
|
13
|
+
"First parameter (`request`) must be an `instance of NextRequest` from `NextJS`."
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
assertIsBoolean(includeFullUrl, {
|
|
17
|
+
message: ({ currentType, validType }) => `Second parameter (\`includeFullUrl\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
18
|
+
});
|
|
19
|
+
const forwardedIps = (request.headers.get("x-forwarded-for") ?? "127.0.0.1").trim().split(",");
|
|
20
|
+
if (forwardedIps[0] === "::ffff:127.0.0.1" || forwardedIps[0] === "::1") {
|
|
21
|
+
forwardedIps[0] = "127.0.0.1";
|
|
22
|
+
}
|
|
23
|
+
const clientIp = forwardedIps.length > 1 ? forwardedIps[forwardedIps.length - 1].trim() : forwardedIps[0];
|
|
24
|
+
if (!includeFullUrl) {
|
|
25
|
+
return clientIp;
|
|
26
|
+
}
|
|
27
|
+
const protocol = request.headers.get("x-forwarded-proto") || "http";
|
|
28
|
+
const port = request.headers.get("x-forwarded-port") || "3000";
|
|
29
|
+
return `${process.env.NODE_ENV === "production" ? protocol : "http"}://${clientIp}:${port}`;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { getClientIpOrUrl };
|
|
@@ -1 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkLS6U7FAY_cjs = require('../chunk-LS6U7FAY.cjs');
|
|
4
|
+
require('../chunk-FJZGG54N.cjs');
|
|
5
|
+
require('../chunk-JBQMXC5I.cjs');
|
|
6
|
+
require('../chunk-ZETAZZLD.cjs');
|
|
7
|
+
require('../chunk-6JFZL7YE.cjs');
|
|
8
|
+
require('../chunk-BAV5T2E3.cjs');
|
|
9
|
+
require('../chunk-T7PU2V7X.cjs');
|
|
10
|
+
require('../chunk-UDA26MCU.cjs');
|
|
11
|
+
require('../chunk-PZQ6I4JJ.cjs');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
Object.defineProperty(exports, "findDuplicates", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkLS6U7FAY_cjs.findDuplicates; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "omitKeys", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkLS6U7FAY_cjs.omitKeys; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "omitKeysDeep", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return chunkLS6U7FAY_cjs.omitKeysDeep; }
|
|
26
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{NumberRangeUnion}from'@rzl-zone/ts-types-plus';
|
|
2
2
|
/** ----------------------------------------------------------------------
|
|
3
3
|
* * ***Utility: `findDuplicates`.***
|
|
4
4
|
* ----------------------------------------------------------------------
|
|
@@ -124,4 +124,4 @@ declare const omitKeys:<I extends Record<string,unknown>,K extends keyof I>(obje
|
|
|
124
124
|
* omitKeysDeep({ mixed: { a: [1, 2, 3], b: { c: 4 } } }, ["mixed.b.c"]);
|
|
125
125
|
* // ➔ { mixed: { a: [1, 2, 3] } }
|
|
126
126
|
*/
|
|
127
|
-
declare const omitKeysDeep:<I extends Record<string,unknown>>(object:I,keysToOmit:DotPath<I>[])=>Partial<I>;export{findDuplicates,omitKeys,omitKeysDeep};
|
|
127
|
+
declare const omitKeysDeep:<I extends Record<string,unknown>>(object:I,keysToOmit:DotPath<I>[])=>Partial<I>;export{findDuplicates,omitKeys,omitKeysDeep};
|
package/dist/operations/index.js
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
export{findDuplicates,omitKeys,omitKeysDeep}from
|
|
1
|
+
export { findDuplicates, omitKeys, omitKeysDeep } from '../chunk-OYTYSY7G.js';
|
|
2
|
+
import '../chunk-2CQX5CBG.js';
|
|
3
|
+
import '../chunk-NBZWMBO6.js';
|
|
4
|
+
import '../chunk-6JFCSH7J.js';
|
|
5
|
+
import '../chunk-CKTLUNWX.js';
|
|
6
|
+
import '../chunk-YWHHVDT4.js';
|
|
7
|
+
import '../chunk-PET42Z7W.js';
|
|
8
|
+
import '../chunk-QNKGP5DY.js';
|
|
9
|
+
import '../chunk-CMW2TBOQ.js';
|
package/dist/parsers/index.cjs
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkFWHNWL2P_cjs = require('../chunk-FWHNWL2P.cjs');
|
|
4
|
+
require('../chunk-PZQ6I4JJ.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "extractFileName", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkFWHNWL2P_cjs.extractFileName; }
|
|
11
|
+
});
|
package/dist/parsers/index.d.ts
CHANGED
|
@@ -33,4 +33,4 @@
|
|
|
33
33
|
* extractFileName(""); // ➔ undefined
|
|
34
34
|
* extractFileName(123); // ➔ undefined
|
|
35
35
|
*/
|
|
36
|
-
declare const extractFileName:(url:string|null|undefined)=>string|undefined;export{extractFileName};
|
|
36
|
+
declare const extractFileName:(url:string|null|undefined)=>string|undefined;export{extractFileName};
|
package/dist/parsers/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export{extractFileName}from
|
|
1
|
+
export { extractFileName } from '../chunk-RIPKY4RU.js';
|
|
2
|
+
import '../chunk-CMW2TBOQ.js';
|