@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.
Files changed (132) hide show
  1. package/README.md +94 -45
  2. package/dist/assertions/index.cjs +34 -1
  3. package/dist/assertions/index.d.ts +2 -2
  4. package/dist/assertions/index.js +5 -1
  5. package/dist/chunk-2CQX5CBG.js +247 -1
  6. package/dist/chunk-2IOOEY45.cjs +20 -1
  7. package/dist/chunk-2WA36TC5.cjs +176 -0
  8. package/dist/chunk-3IBQ5MOM.js +6 -1
  9. package/dist/chunk-3VA554KW.js +23 -1
  10. package/dist/chunk-5757UBXJ.cjs +144 -1
  11. package/dist/chunk-5IGC6PBH.js +22 -1
  12. package/dist/chunk-5KJFVIQT.cjs +55 -1
  13. package/dist/chunk-6JFCSH7J.js +24 -1
  14. package/dist/chunk-6JFZL7YE.cjs +14 -1
  15. package/dist/chunk-7ODAAXX5.cjs +361 -1
  16. package/dist/chunk-BAV5T2E3.cjs +5 -1
  17. package/dist/chunk-CAH33WOQ.cjs +25 -1
  18. package/dist/chunk-CDCERIZ2.js +164 -0
  19. package/dist/chunk-CKTLUNWX.js +12 -1
  20. package/dist/chunk-CMW2TBOQ.js +522 -1
  21. package/dist/chunk-D3ENH7H6.cjs +87 -1
  22. package/dist/chunk-DEZZUYE2.js +139 -1
  23. package/dist/chunk-DVMHRLKP.cjs +6 -1
  24. package/dist/chunk-DWF2R5GD.cjs +212 -1
  25. package/dist/chunk-E55EQK2U.cjs +8 -1
  26. package/dist/chunk-E74U6CYP.cjs +8 -1
  27. package/dist/chunk-EL6A35UR.cjs +51 -1
  28. package/dist/chunk-F6IPNNSJ.cjs +531 -1
  29. package/dist/chunk-FJZGG54N.cjs +252 -1
  30. package/dist/chunk-FWCKOJZM.js +519 -1
  31. package/dist/chunk-FWHNWL2P.cjs +409 -1
  32. package/dist/chunk-GGEADHZO.js +78 -1
  33. package/dist/chunk-GQR4R5WY.js +21 -1
  34. package/dist/chunk-H66AC7GK.cjs +81 -1
  35. package/dist/chunk-HQWOFR56.cjs +23 -1
  36. package/dist/chunk-HYRQMTRH.cjs +14 -1
  37. package/dist/chunk-IRFL4MAX.js +53 -1
  38. package/dist/chunk-IVL7CKVH.cjs +26 -1
  39. package/dist/chunk-IZPBKKPO.js +6 -1
  40. package/dist/chunk-JBQMXC5I.cjs +93 -1
  41. package/dist/chunk-JEQEF5WD.js +81 -1
  42. package/dist/chunk-JMJQCN74.js +334 -1
  43. package/dist/chunk-KHO2SBNA.cjs +6 -1
  44. package/dist/chunk-KVAL5PAG.cjs +16 -1
  45. package/dist/chunk-L5RDAVVH.js +5 -1
  46. package/dist/chunk-LS6U7FAY.cjs +98 -1
  47. package/dist/chunk-NBZWMBO6.js +88 -1
  48. package/dist/chunk-NRF6LWBC.cjs +45 -1
  49. package/dist/chunk-OI5XKNZO.js +42 -1
  50. package/dist/chunk-ONZFBJVW.js +5 -1
  51. package/dist/chunk-OYTYSY7G.js +94 -1
  52. package/dist/chunk-PET42Z7W.js +107 -1
  53. package/dist/chunk-PZQ6I4JJ.cjs +559 -1
  54. package/dist/chunk-QBKAEVYG.js +102 -1
  55. package/dist/chunk-QNKGP5DY.js +5 -1
  56. package/dist/chunk-RIPKY4RU.js +407 -1
  57. package/dist/chunk-RZW35UN5.cjs +105 -1
  58. package/dist/chunk-SBFNXGTJ.js +207 -1
  59. package/dist/chunk-SBKGWRS5.js +12 -1
  60. package/dist/chunk-SIM77PU4.js +46 -1
  61. package/dist/chunk-T2T7K3KR.js +18 -1
  62. package/dist/chunk-T7PU2V7X.cjs +111 -1
  63. package/dist/chunk-UDA26MCU.cjs +6 -1
  64. package/dist/chunk-V45XJKHW.cjs +8 -1
  65. package/dist/chunk-VJDDGRIK.cjs +6 -1
  66. package/dist/chunk-W2WNBUDE.js +6 -1
  67. package/dist/chunk-WVSPXFTY.js +5 -1
  68. package/dist/chunk-XABCB3Y7.cjs +563 -1
  69. package/dist/chunk-XEDXFSGI.js +14 -1
  70. package/dist/chunk-YKPSRP5G.js +552 -1
  71. package/dist/chunk-YWHHVDT4.js +4 -1
  72. package/dist/chunk-ZETAZZLD.cjs +27 -1
  73. package/dist/conversions/index.cjs +97 -1
  74. package/dist/conversions/index.d.ts +2 -2
  75. package/dist/conversions/index.js +16 -1
  76. package/dist/events/index.cjs +25 -1
  77. package/dist/events/index.d.ts +1 -1
  78. package/dist/events/index.js +4 -1
  79. package/dist/formatters/index.cjs +55 -1
  80. package/dist/formatters/index.d.ts +2 -2
  81. package/dist/formatters/index.js +10 -1
  82. package/dist/generators/index.cjs +31 -1
  83. package/dist/generators/index.d.ts +2 -2
  84. package/dist/generators/index.js +6 -1
  85. package/dist/index.d.ts +1 -1
  86. package/dist/{isPlainObject-DGJkcFYw.d.ts → isPlainObject-FWmcJF6k.d.ts} +5 -5
  87. package/dist/next/index.cjs +205 -1
  88. package/dist/next/index.d.ts +2 -2
  89. package/dist/next/index.js +200 -1
  90. package/dist/next/server/index.cjs +34 -1
  91. package/dist/next/server/index.d.ts +1 -1
  92. package/dist/next/server/index.js +32 -1
  93. package/dist/operations/index.cjs +26 -1
  94. package/dist/operations/index.d.ts +2 -2
  95. package/dist/operations/index.js +9 -1
  96. package/dist/parsers/index.cjs +11 -1
  97. package/dist/parsers/index.d.ts +1 -1
  98. package/dist/parsers/index.js +2 -1
  99. package/dist/predicates/index.cjs +292 -1
  100. package/dist/predicates/index.d.ts +4 -4
  101. package/dist/predicates/index.js +15 -1
  102. package/dist/promises/index.cjs +18 -1
  103. package/dist/promises/index.d.ts +2 -2
  104. package/dist/promises/index.js +5 -1
  105. package/dist/rzl-utils.global.js +16 -1
  106. package/dist/strings/index.cjs +75 -1
  107. package/dist/strings/index.d.ts +2 -2
  108. package/dist/strings/index.js +6 -1
  109. package/dist/tailwind/index.cjs +36 -1
  110. package/dist/tailwind/index.d.ts +1 -1
  111. package/dist/tailwind/index.js +3 -1
  112. package/dist/urls/index.cjs +44 -1
  113. package/dist/urls/index.d.ts +1 -1
  114. package/dist/urls/index.js +15 -1
  115. package/package.json +16 -24
  116. package/dist/NumberRangeUnion-B6bhM2s7.d.ts +0 -33
  117. package/dist/any-v4TsK9ES.d.ts +0 -66
  118. package/dist/arrays-normalize-recursive-BqmVuFlD.d.ts +0 -72
  119. package/dist/chunk-JYQTCICM.js +0 -1
  120. package/dist/chunk-YLA3DURS.cjs +0 -1
  121. package/dist/extends-DtdRjDyU.d.ts +0 -343
  122. package/dist/if-ChM35c_q.d.ts +0 -19
  123. package/dist/is-array-BJeHxPM3.d.ts +0 -952
  124. package/dist/never-D89PbPh5.d.ts +0 -66
  125. package/dist/nils-CO8zLHSB.d.ts +0 -151
  126. package/dist/or-C6qzKt2I.d.ts +0 -82
  127. package/dist/override-CL2olHE5.d.ts +0 -59
  128. package/dist/pick-BSMX6Xe2.d.ts +0 -15
  129. package/dist/prettify-3o8_Kw6b.d.ts +0 -564
  130. package/dist/promises-LU7K00H0.d.ts +0 -72
  131. package/dist/string-B1jlOnws.d.ts +0 -312
  132. package/dist/types/index.d.ts +0 -3345
@@ -1 +1,200 @@
1
- import{normalizePathname as e,formatEnvPort as r}from"../chunk-GGEADHZO.js";import{removeSpaces as t}from"../chunk-XEDXFSGI.js";import{isEmptyString as o}from"../chunk-W2WNBUDE.js";import{assertIsString as n}from"../chunk-SBKGWRS5.js";import{safeStableStringify as s}from"../chunk-PET42Z7W.js";import"../chunk-QNKGP5DY.js";import{isString as a,getPreciseType as i,assertIsPlainObject as p,isNil as c,isNonEmptyArray as u,isNonEmptyString as l,isPlainObject as m,isUndefined as f,assertIsBoolean as h,isError as $,hasOwnProp as d}from"../chunk-CMW2TBOQ.js";function g(e,r){if(!a(e)||o(e))throw new TypeError(`❌ 'generateRoute' Failed:\n- Invalid 'route' value.\n- Must be of type \`string\` and non-empty string, but received: "${i(e)}": \`${s(e)}\`.`);if(!/[\\[\]]/.test(e))return e;if(p(r,{message:({validType:r})=>`❌ 'generateRoute' Failed cause in route "${e}":\n- Missing or invalid parameters \`${r}\` for route: "${e}", must be of type \`${r}\` mapping parameters.`}),c(r))throw new TypeError(`❌ 'generateRoute' Failed cause in route "${e}":\n- Missing parameters \`plain-object\` for route: "${e}".`);const t=["?","&","#","=","/","'",'"',"(",")","+",";","%","@",":"],n=[],m=Array.from(e.matchAll(/\[(\w+)\]/g)).map(e=>e[1]);for(const e of m){const s=r[e];if(!a(s)){n.push(`- Invalid parameter: "${e}" must be of type \`string\`, but received: \`${i(s)}\`.`);continue}if(o(s)){n.push(`- Parameter "${e}" cannot be empty string.`);continue}const p=t.filter(e=>s.includes(e));if(/\s/.test(s)&&p.push("white-space(s)"),p.length>0){const r=p.map(e=>"`"===e?"backtick - (`)":`\`${e}\``);t.includes("white-space(s)")||t.push("white-space(s)");const o=t.map(e=>"`"===e?"backtick - (`)":`\`${e}\``);n.push(`- Parameter "${e}" contains invalid characters (${r.join(", ")}). These characters are not allowed because they could cause issues in URL structure. The following characters are forbidden in route parameters: (${o.join(", ")}).`)}}if(u(n))throw new Error(`❌ 'generateRoute' Failed cause in route "${e}":\n${n.join("\n")}.`);return e.replace(/\[(\w+)\]/g,(e,t)=>(l(r[t])?r[t]:"").trim().replace(/^\/+|\/+$/g,"")).replace(/\/+/g,"/")}var E=(r,t={})=>{try{let o=function(e,r){return`${e.replace(/\/+$/,"")}/${r.replace(/^\/+/,"")}`};n(c(r)?"":r,{message:({currentType:e,validType:r})=>`First parameter (\`pathname\`) must be of type \`${r}\`, but received: \`${e}\`.`}),m(t)||(t={});let{prefix:s="/api",withOrigin:p=!0}=t;if(!f(s)&&!a(s))throw new TypeError(`Parameter \`prefix\` property of the \`options\` (second parameter) must be of type \`string\`, but received: \`${i(s)}\`.`);h(p,{message:({currentType:e,validType:r})=>`Parameter \`withOrigin\` property of the \`options\` (second parameter) must be of type \`${r}\`, but received: \`${e}\`.`}),r=e(r),s=e(s);const u=s.endsWith("/")?s:s+"/";(r===s||r===s+"/"||r.startsWith(u))&&(r=r.slice(s.length),r=e(r));const l=w({suffix:s});return o(p?l:new URL(l).pathname,r).replace(/\/+$/,"")}catch(e){throw $(e)?e:new Error("Failed to generate backend API URL in `createBeApiUrl()`, Error: "+new Error(String(e)).message.trim())}},w=(e={})=>{m(e)||(e={});let o=d(e,"suffix")?e.suffix:"/";n(o,{message:({currentType:e,validType:r})=>`Parameter \`suffix\` property of the first parameter must be of type \`${r}\`, but received: \`${e}\`.`});try{let e=process.env.NEXT_PUBLIC_BACKEND_API_URL?.trim();if(e){e=t(e);const o=new URL(e);!!!o.port&&process.env.NEXT_PUBLIC_PORT_BE&&(e=o.origin+r(process.env.NEXT_PUBLIC_PORT_BE,{prefixColon:!0}))}else e="http://localhost"+r(process.env.NEXT_PUBLIC_PORT_BE||"8000",{prefixColon:!0});o=t(o).length?t(o):"/";const n=new URL(e.replace(/\/+$/,"")).origin;return`${n}${"/"===o?"/":`${o.startsWith("/")?"":"/"}${o.replace(/\/+$/,"")}`}`}catch(e){throw new Error("Invalid `NEXT_PUBLIC_BACKEND_API_URL`, failed to generate from `getBeApiUrl()`, Error:"+e)}},y=()=>{try{const e=process.env.NEXT_PUBLIC_BASE_URL?.trim(),o=process.env.NEXT_PUBLIC_PORT_FE?.trim();let n=e||"http://localhost";n=t(n).replace(/\/+$/,"");const s=/:\/\/[^/]+:\d+/.test(n);!s&&o?n+=r(o,{prefixColon:!0}):s||e||(n+=":3000");const a=new URL(n);return`${a.protocol}//${a.hostname}${a.port?`:${a.port}`:""}`}catch(e){throw new Error("Invalid `NEXT_PUBLIC_BASE_URL`, failed to generate from `getBaseUrl()`, Error:"+e)}};export{E as createBeApiUrl,g as generateRoute,y as getBaseUrl,w as getBeApiUrl};
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
- "use strict";var e=require("../../chunk-PZQ6I4JJ.cjs");require("server-only");var r=require("next/server");exports.getClientIpOrUrl=(t,n=!0)=>{if(!e.isFunction(r.NextRequest))throw new Error("Function `getClientIpOrUrl` is designed to be used in a `NextJS` environment.");if(!(t instanceof r.NextRequest))throw new TypeError("First parameter (`request`) must be an `instance of NextRequest` from `NextJS`.");e.assertIsBoolean(n,{message:({currentType:e,validType:r})=>`Second parameter (\`includeFullUrl\`) must be of type \`${r}\`, but received: \`${e}\`.`});const s=(t.headers.get("x-forwarded-for")??"127.0.0.1").trim().split(",");"::ffff:127.0.0.1"!==s[0]&&"::1"!==s[0]||(s[0]="127.0.0.1");const o=s.length>1?s[s.length-1].trim():s[0];if(!n)return o;const i=t.headers.get("x-forwarded-proto")||"http",u=t.headers.get("x-forwarded-port")||"3000";return`${"production"===process.env.NODE_ENV?i:"http"}://${o}:${u}`};
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 as e,assertIsBoolean as r}from"../../chunk-CMW2TBOQ.js";import"server-only";import{NextRequest as t}from"next/server";var o=(o,n=!0)=>{if(!e(t))throw new Error("Function `getClientIpOrUrl` is designed to be used in a `NextJS` environment.");if(!(o instanceof t))throw new TypeError("First parameter (`request`) must be an `instance of NextRequest` from `NextJS`.");r(n,{message:({currentType:e,validType:r})=>`Second parameter (\`includeFullUrl\`) must be of type \`${r}\`, but received: \`${e}\`.`});const s=(o.headers.get("x-forwarded-for")??"127.0.0.1").trim().split(",");"::ffff:127.0.0.1"!==s[0]&&"::1"!==s[0]||(s[0]="127.0.0.1");const i=s.length>1?s[s.length-1].trim():s[0];if(!n)return i;const p=o.headers.get("x-forwarded-proto")||"http",a=o.headers.get("x-forwarded-port")||"3000";return`${"production"===process.env.NODE_ENV?p:"http"}://${i}:${a}`};export{o as getClientIpOrUrl};
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
- "use strict";var e=require("../chunk-LS6U7FAY.cjs");require("../chunk-FJZGG54N.cjs"),require("../chunk-JBQMXC5I.cjs"),require("../chunk-ZETAZZLD.cjs"),require("../chunk-6JFZL7YE.cjs"),require("../chunk-BAV5T2E3.cjs"),require("../chunk-T7PU2V7X.cjs"),require("../chunk-UDA26MCU.cjs"),require("../chunk-PZQ6I4JJ.cjs"),Object.defineProperty(exports,"findDuplicates",{enumerable:!0,get:function(){return e.findDuplicates}}),Object.defineProperty(exports,"omitKeys",{enumerable:!0,get:function(){return e.omitKeys}}),Object.defineProperty(exports,"omitKeysDeep",{enumerable:!0,get:function(){return e.omitKeysDeep}});
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{N as NumberRangeUnion}from'../NumberRangeUnion-B6bhM2s7.js';
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};
@@ -1 +1,9 @@
1
- export{findDuplicates,omitKeys,omitKeysDeep}from"../chunk-OYTYSY7G.js";import"../chunk-2CQX5CBG.js";import"../chunk-NBZWMBO6.js";import"../chunk-6JFCSH7J.js";import"../chunk-CKTLUNWX.js";import"../chunk-YWHHVDT4.js";import"../chunk-PET42Z7W.js";import"../chunk-QNKGP5DY.js";import"../chunk-CMW2TBOQ.js";
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';
@@ -1 +1,11 @@
1
- "use strict";var e=require("../chunk-FWHNWL2P.cjs");require("../chunk-PZQ6I4JJ.cjs"),Object.defineProperty(exports,"extractFileName",{enumerable:!0,get:function(){return e.extractFileName}});
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
+ });
@@ -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};
@@ -1 +1,2 @@
1
- export{extractFileName}from"../chunk-RIPKY4RU.js";import"../chunk-CMW2TBOQ.js";
1
+ export { extractFileName } from '../chunk-RIPKY4RU.js';
2
+ import '../chunk-CMW2TBOQ.js';