@rzl-zone/utils-js 3.1.0-beta.2 → 3.1.2-beta.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 (136) hide show
  1. package/README.md +2 -2
  2. package/dist/NumberRangeUnion-DC-C3_Kq.d.ts +23 -23
  3. package/dist/any-BmdI8UbK.d.ts +56 -56
  4. package/dist/arrays-normalize-recursive-CnjYJ9xg.d.ts +66 -66
  5. package/dist/assertions/index.cjs +1 -1
  6. package/dist/assertions/index.d.ts +396 -396
  7. package/dist/assertions/index.js +1 -1
  8. package/dist/chunk-26W3VZIK.cjs +1 -0
  9. package/dist/chunk-2KRCHXFG.cjs +2 -0
  10. package/dist/{chunk-TQMZ2LPI.js → chunk-33ZLH266.js} +1 -1
  11. package/dist/{chunk-VQLAPEL3.js → chunk-4L4EJTNZ.js} +1 -1
  12. package/dist/{chunk-CK3BZGEU.js → chunk-5Q37AP7P.js} +1 -1
  13. package/dist/chunk-7CHFAMS2.js +1 -0
  14. package/dist/{chunk-REFMEB4A.js → chunk-7MMJZ6HS.js} +1 -1
  15. package/dist/chunk-7TC6DE3J.cjs +1 -0
  16. package/dist/{chunk-K4PLGD7C.js → chunk-7VX33E3V.js} +1 -1
  17. package/dist/chunk-BEZPD44N.cjs +1 -0
  18. package/dist/{chunk-2AUUPGMN.js → chunk-BI263OHW.js} +1 -1
  19. package/dist/{chunk-LVUSFXQS.cjs → chunk-CII6WWLO.cjs} +1 -1
  20. package/dist/{chunk-OX6RLS2F.cjs → chunk-D5TYPCWU.cjs} +1 -1
  21. package/dist/{chunk-MWLEM7ED.js → chunk-EEQY5QUG.js} +1 -1
  22. package/dist/chunk-ESJYBIYH.js +1 -0
  23. package/dist/{chunk-MJAW5RAK.js → chunk-EWYPSKKM.js} +1 -1
  24. package/dist/chunk-EXCOQLWX.cjs +1 -0
  25. package/dist/chunk-FWQVTMYA.cjs +1 -0
  26. package/dist/{chunk-25G6B35W.js → chunk-G4EWCRKS.js} +1 -1
  27. package/dist/{chunk-PFLNHD4B.cjs → chunk-G7R5XZRM.cjs} +1 -1
  28. package/dist/{chunk-EXXLUO7L.cjs → chunk-GGEV7LXX.cjs} +1 -1
  29. package/dist/{chunk-VTR75UID.cjs → chunk-HJOZOENU.cjs} +1 -1
  30. package/dist/{chunk-HXTACM3O.cjs → chunk-IRDZVLNZ.cjs} +1 -1
  31. package/dist/chunk-IW73G523.cjs +1 -0
  32. package/dist/chunk-IY5OZAB3.cjs +1 -0
  33. package/dist/{chunk-467VEMJH.js → chunk-J4NCYYGS.js} +1 -1
  34. package/dist/{chunk-RHIBYOFQ.js → chunk-J7JAZAJD.js} +1 -1
  35. package/dist/{chunk-JQZUWBIX.js → chunk-JYNSO7ZY.js} +1 -1
  36. package/dist/{chunk-UUMKL74S.js → chunk-K3UVKYEU.js} +1 -1
  37. package/dist/{chunk-ME5OV5HN.js → chunk-LQ76EDZG.js} +1 -1
  38. package/dist/chunk-MROH35V3.cjs +1 -0
  39. package/dist/chunk-NJSAV73S.js +1 -0
  40. package/dist/{chunk-HXST7RJB.js → chunk-NR44SNYE.js} +1 -1
  41. package/dist/{chunk-BLCANGFS.js → chunk-NXMTWY77.js} +1 -1
  42. package/dist/chunk-OZCQZO2V.cjs +4 -0
  43. package/dist/chunk-Q3NTKN5I.cjs +1 -0
  44. package/dist/{chunk-NSVLG7NY.js → chunk-QDNSC57Z.js} +1 -1
  45. package/dist/{chunk-NUVGETPD.js → chunk-QGXTL5ZH.js} +1 -1
  46. package/dist/{chunk-D43GV6EF.cjs → chunk-QSQDP7L2.cjs} +1 -1
  47. package/dist/{chunk-U4TZO7WV.js → chunk-S5M33A4O.js} +1 -1
  48. package/dist/{chunk-S7GMG4TB.js → chunk-SGTHOQQ2.js} +1 -1
  49. package/dist/chunk-SL3RQOWA.js +1 -0
  50. package/dist/{chunk-NUHOOAUN.cjs → chunk-SZPWZZYG.cjs} +1 -1
  51. package/dist/{chunk-RHE3M2NJ.cjs → chunk-UA4B7JBO.cjs} +1 -1
  52. package/dist/chunk-UQDJF5RR.cjs +1 -0
  53. package/dist/chunk-UTQUYABU.cjs +1 -0
  54. package/dist/{chunk-G72VSVGO.js → chunk-VPW3DRV5.js} +1 -1
  55. package/dist/{chunk-PSWITZK5.js → chunk-W32WALNU.js} +1 -1
  56. package/dist/chunk-XGZ6K753.cjs +1 -0
  57. package/dist/chunk-YFTR64N5.cjs +1 -0
  58. package/dist/chunk-ZFDS7W6B.cjs +1 -0
  59. package/dist/chunk-ZQOLZE6Z.cjs +1 -0
  60. package/dist/conversions/index.cjs +1 -1
  61. package/dist/conversions/index.d.ts +1285 -1285
  62. package/dist/conversions/index.js +1 -1
  63. package/dist/env/index.d.ts +14 -14
  64. package/dist/events/index.cjs +1 -1
  65. package/dist/events/index.d.ts +109 -109
  66. package/dist/events/index.js +1 -1
  67. package/dist/extends-Bk_SBGdT.d.ts +330 -330
  68. package/dist/formatting/index.cjs +1 -1
  69. package/dist/formatting/index.d.ts +855 -855
  70. package/dist/formatting/index.js +1 -1
  71. package/dist/generator/index.cjs +1 -1
  72. package/dist/generator/index.d.ts +155 -155
  73. package/dist/generator/index.js +1 -1
  74. package/dist/if-CvT4R7Kh.d.ts +16 -16
  75. package/dist/is-array--YjXV-Wx.d.ts +1084 -1084
  76. package/dist/isPlainObject-BVhBAPHX.d.ts +154 -154
  77. package/dist/never-BfayMBF9.d.ts +64 -64
  78. package/dist/next/index.cjs +5 -5
  79. package/dist/next/index.d.ts +183 -183
  80. package/dist/next/index.js +1 -1
  81. package/dist/next/server/index.cjs +1 -1
  82. package/dist/next/server/index.d.ts +25 -25
  83. package/dist/next/server/index.js +1 -1
  84. package/dist/nils-DMz3kU7M.d.ts +155 -155
  85. package/dist/omit-VvmIsZmX.d.ts +25 -25
  86. package/dist/operations/index.cjs +1 -1
  87. package/dist/operations/index.d.ts +120 -120
  88. package/dist/operations/index.js +1 -1
  89. package/dist/parsers/index.cjs +1 -1
  90. package/dist/parsers/index.d.ts +34 -34
  91. package/dist/parsers/index.js +1 -1
  92. package/dist/predicates/index.cjs +1 -1
  93. package/dist/predicates/index.d.ts +1674 -1674
  94. package/dist/predicates/index.js +1 -1
  95. package/dist/prettify-C4xLcYOP.d.ts +328 -328
  96. package/dist/promise/index.cjs +1 -1
  97. package/dist/promise/index.d.ts +29 -29
  98. package/dist/promise/index.js +1 -1
  99. package/dist/rzl-utils.global.js +1 -1
  100. package/dist/string-XA-til3C.d.ts +318 -318
  101. package/dist/strings/index.cjs +1 -1
  102. package/dist/strings/index.d.ts +690 -690
  103. package/dist/strings/index.js +1 -1
  104. package/dist/stylings/index.cjs +1 -1
  105. package/dist/stylings/index.d.ts +35 -35
  106. package/dist/stylings/index.js +1 -1
  107. package/dist/type-data-DDs-u2kq.d.ts +241 -241
  108. package/dist/types/index.d.ts +3264 -3264
  109. package/dist/urls/index.cjs +1 -1
  110. package/dist/urls/index.d.ts +373 -373
  111. package/dist/urls/index.js +1 -1
  112. package/package.json +3 -15
  113. package/dist/chunk-2JQQQ625.js +0 -1
  114. package/dist/chunk-445TAVT4.cjs +0 -1
  115. package/dist/chunk-6Q4I2RPC.cjs +0 -1
  116. package/dist/chunk-6SMJMZ7G.cjs +0 -1
  117. package/dist/chunk-DFSTVQFI.cjs +0 -1
  118. package/dist/chunk-DYRDBYPF.cjs +0 -1
  119. package/dist/chunk-GAJTFCUA.js +0 -1
  120. package/dist/chunk-GOJNH55O.cjs +0 -1
  121. package/dist/chunk-IJTZWWRJ.cjs +0 -1
  122. package/dist/chunk-ISJ33O2J.cjs +0 -1
  123. package/dist/chunk-JISH2VGG.js +0 -1
  124. package/dist/chunk-KZQB7H4E.cjs +0 -1
  125. package/dist/chunk-LUVV5KSD.cjs +0 -2
  126. package/dist/chunk-MF5Y5K4N.cjs +0 -1
  127. package/dist/chunk-O5VXBNUQ.cjs +0 -4
  128. package/dist/chunk-O7SJR4CY.cjs +0 -1
  129. package/dist/chunk-PYUVKHUF.cjs +0 -1
  130. package/dist/chunk-XFCJDSB2.cjs +0 -1
  131. package/dist/chunk-XOYX4PLZ.cjs +0 -1
  132. package/dist/chunk-Z6FLCEN6.js +0 -1
  133. package/dist/chunk-ZO5364A6.cjs +0 -1
  134. package/dist/index.cjs +0 -1
  135. package/dist/index.d.ts +0 -1
  136. package/dist/index.js +0 -1
@@ -1,204 +1,204 @@
1
1
  import{I as IsAny}from'../any-BmdI8UbK.js';import'../if-CvT4R7Kh.js';
2
2
  /** ---------------------------------------------------------
3
- * * ***Extracts dynamic route parameters from a given route string.***
4
- * ---------------------------------------------------------
5
- * **This utility type recursively searches for dynamic segments within a route,
6
- * extracting each parameter and constructing an object where each key represents
7
- * a dynamic segment and its value is of type `string`.**
8
- * - ***⚠️ Warning:***
9
- * - ***This types only support when using ***[`NextJS`](https://nextjs.org/)***.***
10
- * @template T - The route string containing potential dynamic segments.
11
- * @example
12
- * ```ts
13
- * type Params1 = ExtractRouteParams<"/user/[id]">;
14
- * // ➔ { id: string }
15
- * type Params2 = ExtractRouteParams<"/post/[slug]/comment/[commentId]">;
16
- * // ➔ { slug: string; commentId: string }
17
- * type Params3 = ExtractRouteParams<"/dashboard">;
18
- * // ➔ {} (no dynamic parameters)
19
- * ```
20
- */
3
+ * * ***Extracts dynamic route parameters from a given route string.***
4
+ * ---------------------------------------------------------
5
+ * **This utility type recursively searches for dynamic segments within a route,
6
+ * extracting each parameter and constructing an object where each key represents
7
+ * a dynamic segment and its value is of type `string`.**
8
+ * - ***⚠️ Warning:***
9
+ * - ***This types only support when using ***[`NextJS`](https://nextjs.org/)***.***
10
+ * @template T - The route string containing potential dynamic segments.
11
+ * @example
12
+ * ```ts
13
+ * type Params1 = ExtractRouteParams<"/user/[id]">;
14
+ * // ➔ { id: string }
15
+ * type Params2 = ExtractRouteParams<"/post/[slug]/comment/[commentId]">;
16
+ * // ➔ { slug: string; commentId: string }
17
+ * type Params3 = ExtractRouteParams<"/dashboard">;
18
+ * // ➔ {} (no dynamic parameters)
19
+ * ```
20
+ */
21
21
  type ExtractRouteParams<T>=T extends string?HasDynamicSegments<T>extends true?T extends`${infer _Start}[${infer Param}]${infer Rest}`?{[K in Param|keyof ExtractRouteParams<Rest>]:string;}:unknown:unknown:unknown;
22
22
  /** ---------------------------------------------------------
23
- * * ***Determines whether a given route contains dynamic segments.***
24
- * ---------------------------------------------------------
25
- * **This type checks if the route includes at least one `[param]` pattern.
26
- * If it does, the result is `true`, otherwise `false`.**
27
- * - ***⚠️ Warning:***
28
- * - ***This types only support when using ***[`NextJS`](https://nextjs.org/)***.***
29
- * @template T - The route string to be evaluated.
30
- * @example
31
- * ```ts
32
- * type HasParams1 = HasDynamicSegments<"/user/[id]">;
33
- * // ➔ true
34
- * type HasParams2 = HasDynamicSegments<"/settings/profile">;
35
- * // ➔ false
36
- * type HasParams3 = HasDynamicSegments<"/blog/[category]/[slug]">;
37
- * // ➔ true
38
- * ```
39
- */
23
+ * * ***Determines whether a given route contains dynamic segments.***
24
+ * ---------------------------------------------------------
25
+ * **This type checks if the route includes at least one `[param]` pattern.
26
+ * If it does, the result is `true`, otherwise `false`.**
27
+ * - ***⚠️ Warning:***
28
+ * - ***This types only support when using ***[`NextJS`](https://nextjs.org/)***.***
29
+ * @template T - The route string to be evaluated.
30
+ * @example
31
+ * ```ts
32
+ * type HasParams1 = HasDynamicSegments<"/user/[id]">;
33
+ * // ➔ true
34
+ * type HasParams2 = HasDynamicSegments<"/settings/profile">;
35
+ * // ➔ false
36
+ * type HasParams3 = HasDynamicSegments<"/blog/[category]/[slug]">;
37
+ * // ➔ true
38
+ * ```
39
+ */
40
40
  type HasDynamicSegments<T>=T extends`${string}[${string}]${string}`?true:false;type GenerateRouteResult<T>=true extends IsAny<T>?unknown:T extends string?string:unknown;
41
41
  /** ---------------------------------
42
- * * ***Generates a URL by replacing dynamic route parameters with provided values.***
43
- * ---------------------------------
44
- * - ***⚠️ Warning:***
45
- * - ***This function only support when using ***[`NextJS`](https://nextjs.org/)***.***
46
- * @template T - The route string containing dynamic segments in the format `[param]`.
47
- * @param {T} route - The route string containing dynamic segments.
48
- * @param {ExtractRouteParams<T>} [params] - An object containing key-value pairs that match the dynamic segments in the route.
49
- * @returns {string} The formatted URL with all dynamic segments replaced.
50
- * @throws {Error} If the route contains dynamic segments but no parameters object is provided.
51
- * @throws {Error} If a required parameter is missing from the `params` object.
52
- * @throws {Error} If a parameter value is an empty string.
53
- * @throws {Error} If any parameter contains invalid characters like `?`, `&`, `=`, `#`, `/`, spaces, `'`, `"`, `(`, `)`, `+`, `;`, `%`, `@`, or `:`, which can cause URL issues.
54
- * @example
55
- * // Basic usage
56
- * generateRoute("/user/[id]", { id: "123" });
57
- * // ➔ "/user/123"
58
- *
59
- * // No dynamic segments, returns as-is
60
- * generateRoute("/dashboard");
61
- * // ➔ "/dashboard"
62
- *
63
- * // Throws an error due to missing parameters object
64
- * generateRoute("/profile/[username]");
65
- * // ➔ ❌ Error: ❌ Missing parameters object for route: "/profile/[username]"
66
- *
67
- * // Throws an error due to an empty parameter value
68
- * generateRoute("/post/[category]/[slug]", { category: "tech", slug: "" });
69
- * // ➔ ❌ Error: ❌ Parameter "slug" cannot be empty in route: "/post/[category]/[slug]"
70
- *
71
- * // Throws an error due to parameter containing invalid characters
72
- * generateRoute("/search/[query]", { query: "how to?learn" });
73
- * // ➔ ❌ Error: ❌ Parameter "query" contains invalid character "?" in route: "/search/[query]"
74
- *
75
- * // Handles leading/trailing slashes correctly
76
- * generateRoute("/blog/[category]/[slug]", { category: "/news/", slug: "/latest-update/" });
77
- * // ➔ ❌ Error: ❌ Parameter "category" and "slug" contains slashes "/" which is not allowed.
78
- */
42
+ * * ***Generates a URL by replacing dynamic route parameters with provided values.***
43
+ * ---------------------------------
44
+ * - ***⚠️ Warning:***
45
+ * - ***This function only support when using ***[`NextJS`](https://nextjs.org/)***.***
46
+ * @template T - The route string containing dynamic segments in the format `[param]`.
47
+ * @param {T} route - The route string containing dynamic segments.
48
+ * @param {ExtractRouteParams<T>} [params] - An object containing key-value pairs that match the dynamic segments in the route.
49
+ * @returns {string} The formatted URL with all dynamic segments replaced.
50
+ * @throws {Error} If the route contains dynamic segments but no parameters object is provided.
51
+ * @throws {Error} If a required parameter is missing from the `params` object.
52
+ * @throws {Error} If a parameter value is an empty string.
53
+ * @throws {Error} If any parameter contains invalid characters like `?`, `&`, `=`, `#`, `/`, spaces, `'`, `"`, `(`, `)`, `+`, `;`, `%`, `@`, or `:`, which can cause URL issues.
54
+ * @example
55
+ * // Basic usage
56
+ * generateRoute("/user/[id]", { id: "123" });
57
+ * // ➔ "/user/123"
58
+ *
59
+ * // No dynamic segments, returns as-is
60
+ * generateRoute("/dashboard");
61
+ * // ➔ "/dashboard"
62
+ *
63
+ * // Throws an error due to missing parameters object
64
+ * generateRoute("/profile/[username]");
65
+ * // ➔ ❌ Error: ❌ Missing parameters object for route: "/profile/[username]"
66
+ *
67
+ * // Throws an error due to an empty parameter value
68
+ * generateRoute("/post/[category]/[slug]", { category: "tech", slug: "" });
69
+ * // ➔ ❌ Error: ❌ Parameter "slug" cannot be empty in route: "/post/[category]/[slug]"
70
+ *
71
+ * // Throws an error due to parameter containing invalid characters
72
+ * generateRoute("/search/[query]", { query: "how to?learn" });
73
+ * // ➔ ❌ Error: ❌ Parameter "query" contains invalid character "?" in route: "/search/[query]"
74
+ *
75
+ * // Handles leading/trailing slashes correctly
76
+ * generateRoute("/blog/[category]/[slug]", { category: "/news/", slug: "/latest-update/" });
77
+ * // ➔ ❌ Error: ❌ Parameter "category" and "slug" contains slashes "/" which is not allowed.
78
+ */
79
79
  declare function generateRoute<T extends string>(route:T extends string?(HasDynamicSegments<T>extends true?T:never):never,params:T extends string?ExtractRouteParams<T>:undefined):GenerateRouteResult<T>;declare function generateRoute<T extends string>(route:T extends string?T:never,params?:Extract<ExtractRouteParams<T>,Record<string,unknown>>):GenerateRouteResult<T>;declare function generateRoute<T=unknown>(route:T extends string?(HasDynamicSegments<T>extends true?T:unknown):unknown,params?:T extends string?ExtractRouteParams<T>:undefined):unknown;type OptionsCreateBeApiUrl={
80
80
  /** * The prefix pathname api url, e.g:`"http://localhost.com/your-target-prefix-entri-point-api-is-here"`, default: `"/api"`.
81
- *
82
- * @default "/api" */
81
+ *
82
+ * @default "/api" */
83
83
  prefix?:string;
84
84
  /** * Option to getting `prefix` and `pathname` of api url only `(removing origin base api url)`, default: `true`.
85
- *
86
- * @default true */
85
+ *
86
+ * @default true */
87
87
  withOrigin?:boolean;};
88
88
  /** ---------------------------------
89
- * * ***Constructs a backend API URL by appending a given pathname to the base API URL.***
90
- * ---------------------------------
91
- * This function builds on top of `getBeApiUrl()`.
92
- * - **Determines the base API URL from:**
93
- * - `NEXT_PUBLIC_BACKEND_API_URL` environment variable (or defaults to `"http://localhost:8000"`).
94
- * - Automatically appends `NEXT_PUBLIC_PORT_BE` if the base URL does not already include a port.
95
- * - **Features of this function:**
96
- * - Allows customizing the API path with an optional `prefix` (defaults to `"/api"`).
97
- * - Can include or exclude the origin (protocol + host) via `withOrigin`.
98
- * - Normalizes paths to avoid duplicate slashes.
99
- * - ***⚠️ Warning:***
100
- * - ***This function only support when using ***[`NextJS`](https://nextjs.org/)***.***
101
- * @param {string|null|undefined} pathname - The API endpoint path (e.g., `/users` or `/v1/posts`), defaultValue: `""`.
102
- * @param {OptionsCreateBeApiUrl} [options] - Configuration options.
103
- * @param {OptionsCreateBeApiUrl["prefix"]} [options.prefix="/api"] - The prefix for the API path (default is `"/api"`).
104
- * @param {OptionsCreateBeApiUrl["withOrigin"]} [options.withOrigin=true] - Whether to include the full base URL or return only the API path.
105
- * @returns {string} The formatted API URL.
106
- * @throws {TypeError} If `withOrigin` is not a boolean.
107
- * @throws {TypeError} If `prefix` and `pathname` is not a string.
108
- * @throws {Error} If constructing the API URL fails due to an invalid base URL.
109
- * @example
110
- * createBeApiUrl("/users")
111
- * // ➔ "http://localhost:8000/api/users"
112
- * createBeApiUrl("/api/users")
113
- * // ➔ "http://localhost:8000/api/users"
114
- * createBeApiUrl("/v1", { prefix: "/v1" })
115
- * // ➔ "http://localhost:8000/v1"
116
- * createBeApiUrl("/v1/users")
117
- * // ➔ "http://localhost:8000/api/v1/users"
118
- * createBeApiUrl("/v1/users", { prefix: "/v1" })
119
- * // ➔ "http://localhost:8000/v1/users"
120
- * createBeApiUrl("/users", { withOrigin: false })
121
- * // ➔ "/api/users"
122
- * createBeApiUrl(null, { withOrigin: false })
123
- * // ➔ "/api"
124
- * createBeApiUrl(undefined, { withOrigin: false })
125
- * // ➔ "/api"
126
- */
89
+ * * ***Constructs a backend API URL by appending a given pathname to the base API URL.***
90
+ * ---------------------------------
91
+ * This function builds on top of `getBeApiUrl()`.
92
+ * - **Determines the base API URL from:**
93
+ * - `NEXT_PUBLIC_BACKEND_API_URL` environment variable (or defaults to `"http://localhost:8000"`).
94
+ * - Automatically appends `NEXT_PUBLIC_PORT_BE` if the base URL does not already include a port.
95
+ * - **Features of this function:**
96
+ * - Allows customizing the API path with an optional `prefix` (defaults to `"/api"`).
97
+ * - Can include or exclude the origin (protocol + host) via `withOrigin`.
98
+ * - Normalizes paths to avoid duplicate slashes.
99
+ * - ***⚠️ Warning:***
100
+ * - ***This function only support when using ***[`NextJS`](https://nextjs.org/)***.***
101
+ * @param {string|null|undefined} pathname - The API endpoint path (e.g., `/users` or `/v1/posts`), defaultValue: `""`.
102
+ * @param {OptionsCreateBeApiUrl} [options] - Configuration options.
103
+ * @param {OptionsCreateBeApiUrl["prefix"]} [options.prefix="/api"] - The prefix for the API path (default is `"/api"`).
104
+ * @param {OptionsCreateBeApiUrl["withOrigin"]} [options.withOrigin=true] - Whether to include the full base URL or return only the API path.
105
+ * @returns {string} The formatted API URL.
106
+ * @throws {TypeError} If `withOrigin` is not a boolean.
107
+ * @throws {TypeError} If `prefix` and `pathname` is not a string.
108
+ * @throws {Error} If constructing the API URL fails due to an invalid base URL.
109
+ * @example
110
+ * createBeApiUrl("/users")
111
+ * // ➔ "http://localhost:8000/api/users"
112
+ * createBeApiUrl("/api/users")
113
+ * // ➔ "http://localhost:8000/api/users"
114
+ * createBeApiUrl("/v1", { prefix: "/v1" })
115
+ * // ➔ "http://localhost:8000/v1"
116
+ * createBeApiUrl("/v1/users")
117
+ * // ➔ "http://localhost:8000/api/v1/users"
118
+ * createBeApiUrl("/v1/users", { prefix: "/v1" })
119
+ * // ➔ "http://localhost:8000/v1/users"
120
+ * createBeApiUrl("/users", { withOrigin: false })
121
+ * // ➔ "/api/users"
122
+ * createBeApiUrl(null, { withOrigin: false })
123
+ * // ➔ "/api"
124
+ * createBeApiUrl(undefined, { withOrigin: false })
125
+ * // ➔ "/api"
126
+ */
127
127
  declare const createBeApiUrl:(
128
128
  /** * The pathname api url, e.g:`"http://localhost.com/your-target-prefix-entri-point-api-is-here/your-target-pathname-is-here"`.
129
- *
130
- * @default ""
131
- */
129
+ *
130
+ * @default ""
131
+ */
132
132
  pathname:string|null|undefined,options?:OptionsCreateBeApiUrl)=>string;type OptionsGetBeApiUrl={
133
133
  /** * The Suffix origin base api url, e.g:`http://localhost.com/api`, default: `"/"`.
134
- *
135
- * @default "/" */
134
+ *
135
+ * @default "/" */
136
136
  suffix?:string;};
137
137
  /** ---------------------------------------------------
138
- * * ***Retrieves the base API URL of the backend.***
139
- * ---------------------------------------------------
140
- * **This function determines the backend API base URL from the `NEXT_PUBLIC_BACKEND_API_URL` environment variable.**
141
- * - **Behavior:**
142
- * - If the variable is not set, it defaults to `"http://localhost:8000"`.
143
- * - It also allows adding an optional suffix to the returned URL.
144
- * - ***⚠️ Warning:***
145
- * - ***This function only support when using ***[`NextJS`](https://nextjs.org/)***.***
146
- * @description
147
- * This function determines the backend API base URL from the `NEXT_PUBLIC_BACKEND_API_URL` environment variable.
148
- * - If `NEXT_PUBLIC_BACKEND_API_URL` is not set, it defaults to `"http://localhost:8000"`.
149
- * - If `NEXT_PUBLIC_BACKEND_API_URL` does **not** contain a port, it appends one from `NEXT_PUBLIC_PORT_BE` if available.
150
- * - Supports appending optional suffix (like "/api").
151
- * @param {OptionsGetBeApiUrl|undefined} options - Configuration options.
152
- * @param {OptionsGetBeApiUrl["suffix"]} [options.suffix="/"] - The suffix to append to the base API URL.
153
- * @returns {string} The formatted backend API base URL.
154
- * @throws {TypeError} If `suffix` is not a `string`.
155
- * @throws {Error} If `NEXT_PUBLIC_BACKEND_API_URL` is invalid.
156
- * @example
157
- * // With NEXT_PUBLIC_BACKEND_API_URL set at `*.env` file
158
- * NEXT_PUBLIC_BACKEND_API_URL = "https://api.example.com";
159
- * getBeApiUrl();
160
- * // ➔ "https://api.example.com/"
161
- *
162
- * // With NEXT_PUBLIC_BACKEND_API_URL but no port, using NEXT_PUBLIC_PORT_BE at `*.env` file
163
- * NEXT_PUBLIC_BACKEND_API_URL = "http://localhost";
164
- * NEXT_PUBLIC_PORT_BE = "5000";
165
- * getBeApiUrl({ suffix: "/api" });
166
- * // ➔ "http://localhost:5000/api"
167
- *
168
- * // Without NEXT_PUBLIC_BACKEND_API_URL at `*.env` file (defaults to localhost:8000)
169
- * delete NEXT_PUBLIC_BACKEND_API_URL;
170
- * getBeApiUrl({ suffix: "/v1" });
171
- * // ➔ "http://localhost:8000/v1"
172
- */
138
+ * * ***Retrieves the base API URL of the backend.***
139
+ * ---------------------------------------------------
140
+ * **This function determines the backend API base URL from the `NEXT_PUBLIC_BACKEND_API_URL` environment variable.**
141
+ * - **Behavior:**
142
+ * - If the variable is not set, it defaults to `"http://localhost:8000"`.
143
+ * - It also allows adding an optional suffix to the returned URL.
144
+ * - ***⚠️ Warning:***
145
+ * - ***This function only support when using ***[`NextJS`](https://nextjs.org/)***.***
146
+ * @description
147
+ * This function determines the backend API base URL from the `NEXT_PUBLIC_BACKEND_API_URL` environment variable.
148
+ * - If `NEXT_PUBLIC_BACKEND_API_URL` is not set, it defaults to `"http://localhost:8000"`.
149
+ * - If `NEXT_PUBLIC_BACKEND_API_URL` does **not** contain a port, it appends one from `NEXT_PUBLIC_PORT_BE` if available.
150
+ * - Supports appending optional suffix (like "/api").
151
+ * @param {OptionsGetBeApiUrl|undefined} options - Configuration options.
152
+ * @param {OptionsGetBeApiUrl["suffix"]} [options.suffix="/"] - The suffix to append to the base API URL.
153
+ * @returns {string} The formatted backend API base URL.
154
+ * @throws {TypeError} If `suffix` is not a `string`.
155
+ * @throws {Error} If `NEXT_PUBLIC_BACKEND_API_URL` is invalid.
156
+ * @example
157
+ * // With NEXT_PUBLIC_BACKEND_API_URL set at `*.env` file
158
+ * NEXT_PUBLIC_BACKEND_API_URL = "https://api.example.com";
159
+ * getBeApiUrl();
160
+ * // ➔ "https://api.example.com/"
161
+ *
162
+ * // With NEXT_PUBLIC_BACKEND_API_URL but no port, using NEXT_PUBLIC_PORT_BE at `*.env` file
163
+ * NEXT_PUBLIC_BACKEND_API_URL = "http://localhost";
164
+ * NEXT_PUBLIC_PORT_BE = "5000";
165
+ * getBeApiUrl({ suffix: "/api" });
166
+ * // ➔ "http://localhost:5000/api"
167
+ *
168
+ * // Without NEXT_PUBLIC_BACKEND_API_URL at `*.env` file (defaults to localhost:8000)
169
+ * delete NEXT_PUBLIC_BACKEND_API_URL;
170
+ * getBeApiUrl({ suffix: "/v1" });
171
+ * // ➔ "http://localhost:8000/v1"
172
+ */
173
173
  declare const getBeApiUrl:({suffix}?:OptionsGetBeApiUrl)=>string;
174
174
  /** ---------------------------------------------------
175
- * * ***Retrieves the base URL of the application.***
176
- * ---------------------------------------------------
177
- * **This function is designed to be used within `Next.js` applications.**
178
- * - **Behavior:**
179
- * - It determines the base URL from the `NEXT_PUBLIC_BASE_URL` environment variable.
180
- * - If `NEXT_PUBLIC_BASE_URL` is not set, it defaults to `"http://localhost:3000"`.
181
- * - If `NEXT_PUBLIC_BASE_URL` does **not** contain a port, it appends one from `NEXT_PUBLIC_PORT_FE` if available.
182
- * - Ensures the final URL is valid and normalized (no trailing slashes).
183
- * - ***⚠️ Warning:***
184
- * - ***This function only support when using ***[`NextJS`](https://nextjs.org/)***.***
185
- * @returns {string} The resolved base URL of the application.
186
- * @throws {Error} If the constructed URL is invalid or malformed.
187
- * @example
188
- * // With environment variable set at `*.env` file
189
- * NEXT_PUBLIC_BASE_URL = "https://example.com";
190
- * getBaseUrl();
191
- * // ➔ "https://example.com"
192
- *
193
- * // With custom port via NEXT_PUBLIC_PORT_FE at `*.env` file
194
- * NEXT_PUBLIC_BASE_URL = "http://localhost";
195
- * NEXT_PUBLIC_PORT_FE = "4000";
196
- * getBaseUrl();
197
- * // ➔ "http://localhost:4000"
198
- *
199
- * // Without environment variable at `*.env` file
200
- * delete NEXT_PUBLIC_BASE_URL;
201
- * getBaseUrl();
202
- * // ➔ "http://localhost:3000"
203
- */
175
+ * * ***Retrieves the base URL of the application.***
176
+ * ---------------------------------------------------
177
+ * **This function is designed to be used within `Next.js` applications.**
178
+ * - **Behavior:**
179
+ * - It determines the base URL from the `NEXT_PUBLIC_BASE_URL` environment variable.
180
+ * - If `NEXT_PUBLIC_BASE_URL` is not set, it defaults to `"http://localhost:3000"`.
181
+ * - If `NEXT_PUBLIC_BASE_URL` does **not** contain a port, it appends one from `NEXT_PUBLIC_PORT_FE` if available.
182
+ * - Ensures the final URL is valid and normalized (no trailing slashes).
183
+ * - ***⚠️ Warning:***
184
+ * - ***This function only support when using ***[`NextJS`](https://nextjs.org/)***.***
185
+ * @returns {string} The resolved base URL of the application.
186
+ * @throws {Error} If the constructed URL is invalid or malformed.
187
+ * @example
188
+ * // With environment variable set at `*.env` file
189
+ * NEXT_PUBLIC_BASE_URL = "https://example.com";
190
+ * getBaseUrl();
191
+ * // ➔ "https://example.com"
192
+ *
193
+ * // With custom port via NEXT_PUBLIC_PORT_FE at `*.env` file
194
+ * NEXT_PUBLIC_BASE_URL = "http://localhost";
195
+ * NEXT_PUBLIC_PORT_FE = "4000";
196
+ * getBaseUrl();
197
+ * // ➔ "http://localhost:4000"
198
+ *
199
+ * // Without environment variable at `*.env` file
200
+ * delete NEXT_PUBLIC_BASE_URL;
201
+ * getBaseUrl();
202
+ * // ➔ "http://localhost:3000"
203
+ */
204
204
  declare const getBaseUrl:()=>string;export{type ExtractRouteParams,type HasDynamicSegments,createBeApiUrl,generateRoute,getBaseUrl,getBeApiUrl};
@@ -1,4 +1,4 @@
1
- import {c as c$2,d}from'../chunk-NSVLG7NY.js';import {c as c$3}from'../chunk-HXST7RJB.js';import {a}from'../chunk-Z6FLCEN6.js';import {a as a$1}from'../chunk-JISH2VGG.js';import'../chunk-ELDDNERR.js';import {c}from'../chunk-467VEMJH.js';import'../chunk-5SZUSNGZ.js';import {g,E,j,c as c$1,r,p,f,m,G,C}from'../chunk-MJAW5RAK.js';function N(e,t){if(!g(e)||a(e))throw new TypeError(`\u274C 'generateRoute' Failed:
1
+ import {c as c$2,d}from'../chunk-QDNSC57Z.js';import {c as c$3}from'../chunk-NR44SNYE.js';import {a}from'../chunk-7CHFAMS2.js';import {a as a$1}from'../chunk-NJSAV73S.js';import'../chunk-ELDDNERR.js';import {c}from'../chunk-J4NCYYGS.js';import'../chunk-5SZUSNGZ.js';import {g,E,j,c as c$1,r,p,f,m,G,C}from'../chunk-EWYPSKKM.js';function N(e,t){if(!g(e)||a(e))throw new TypeError(`\u274C 'generateRoute' Failed:
2
2
  - Invalid 'route' value.
3
3
  - Must be of type \`string\` and non-empty string, but received: "${E(e)}": \`${c(e)}\`.`);if(!/[\\[\]]/.test(e))return e;if(j(t,{message:({validType:o})=>`\u274C 'generateRoute' Failed cause in route "${e}":
4
4
  - Missing or invalid parameters \`${o}\` for route: "${e}", must be of type \`${o}\` mapping parameters.`}),c$1(t))throw new TypeError(`\u274C 'generateRoute' Failed cause in route "${e}":
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkLVUSFXQS_cjs=require('../../chunk-LVUSFXQS.cjs');require('server-only');var server=require('next/server');var g=(t,r=true)=>{if(!chunkLVUSFXQS_cjs.b(server.NextRequest))throw new Error("Function `getClientIpOrUrl` is designed to be used in a `NextJS` environment.");if(!(t instanceof server.NextRequest))throw new TypeError("First parameter (`request`) must be an `instance of NextRequest` from `NextJS`.");chunkLVUSFXQS_cjs.G(r,{message:({currentType:a,validType:d})=>`Second parameter (\`includeFullUrl\`) must be of type \`${d}\`, but received: \`${a}\`.`});let e=(t.headers.get("x-forwarded-for")??"127.0.0.1").trim().split(",");(e[0]==="::ffff:127.0.0.1"||e[0]==="::1")&&(e[0]="127.0.0.1");let o=e.length>1?e[e.length-1].trim():e[0];if(!r)return o;let p=t.headers.get("x-forwarded-proto")||"http",f=t.headers.get("x-forwarded-port")||"3000";return `${process.env.NODE_ENV==="production"?p:"http"}://${o}:${f}`};
1
+ 'use strict';var chunkCII6WWLO_cjs=require('../../chunk-CII6WWLO.cjs');require('server-only');var server=require('next/server');var g=(t,r=true)=>{if(!chunkCII6WWLO_cjs.b(server.NextRequest))throw new Error("Function `getClientIpOrUrl` is designed to be used in a `NextJS` environment.");if(!(t instanceof server.NextRequest))throw new TypeError("First parameter (`request`) must be an `instance of NextRequest` from `NextJS`.");chunkCII6WWLO_cjs.G(r,{message:({currentType:a,validType:d})=>`Second parameter (\`includeFullUrl\`) must be of type \`${d}\`, but received: \`${a}\`.`});let e=(t.headers.get("x-forwarded-for")??"127.0.0.1").trim().split(",");(e[0]==="::ffff:127.0.0.1"||e[0]==="::1")&&(e[0]="127.0.0.1");let o=e.length>1?e[e.length-1].trim():e[0];if(!r)return o;let p=t.headers.get("x-forwarded-proto")||"http",f=t.headers.get("x-forwarded-port")||"3000";return `${process.env.NODE_ENV==="production"?p:"http"}://${o}:${f}`};
2
2
  exports.getClientIpOrUrl=g;
@@ -1,28 +1,28 @@
1
1
  import{NextRequest}from'next/server';
2
2
  /** ---------------------------------
3
- * * ***Utility for NextJS Server: `getClientIpOrUrl`.***
4
- * ---------------------------------
5
- * **Retrieves the real client IP address and constructs the full URL using headers like `x-forwarded-for`, `x-forwarded-proto`, and `x-forwarded-port`.**
6
- * - **ℹ️ Note:**
7
- * - Only supported in **Next.js** environments (specifically in `server-only` contexts).
8
- * - Should be used in **middleware** or **server actions** that have access to ***[`NextRequest - NextJS`](https://nextjs.org/docs/app/api-reference/functions/next-request)***.
9
- * @param {NextRequest} request - The incoming ***`NextJS`*** request object.
10
- * @param {boolean|undefined} [includeFullUrl=true] - Whether to return the full URL (`protocol`, `IP`, and `port` like `protocol://ip:port`) or just the IP address, defaultValue: `true`.
11
- * @returns {string} The extracted client IP address or the full constructed URL.
12
- * @throws {Error} If the function is used outside a Next.js server environment.
13
- * @throws {TypeError} If the arguments do not match the expected types.
14
- * @example
15
- * // Basic usage in Next.js middleware
16
- * import { NextRequest } from "next/server";
17
- * import { getClientIpOrUrl } from "@rzl-zone/utils-js/next/server";
18
- *
19
- * export function middleware(request: NextRequest) {
20
- * const clientIp = getClientIpOrUrl(request, false);
21
- * console.log("Client IP:", clientIp);
22
- * }
23
- *
24
- * // Get full URL
25
- * const url = getClientIpOrUrl(request);
26
- * console.log("Client full URL:", url);
27
- */
3
+ * * ***Utility for NextJS Server: `getClientIpOrUrl`.***
4
+ * ---------------------------------
5
+ * **Retrieves the real client IP address and constructs the full URL using headers like `x-forwarded-for`, `x-forwarded-proto`, and `x-forwarded-port`.**
6
+ * - **ℹ️ Note:**
7
+ * - Only supported in **Next.js** environments (specifically in `server-only` contexts).
8
+ * - Should be used in **middleware** or **server actions** that have access to ***[`NextRequest - NextJS`](https://nextjs.org/docs/app/api-reference/functions/next-request)***.
9
+ * @param {NextRequest} request - The incoming ***`NextJS`*** request object.
10
+ * @param {boolean|undefined} [includeFullUrl=true] - Whether to return the full URL (`protocol`, `IP`, and `port` like `protocol://ip:port`) or just the IP address, defaultValue: `true`.
11
+ * @returns {string} The extracted client IP address or the full constructed URL.
12
+ * @throws {Error} If the function is used outside a Next.js server environment.
13
+ * @throws {TypeError} If the arguments do not match the expected types.
14
+ * @example
15
+ * // Basic usage in Next.js middleware
16
+ * import { NextRequest } from "next/server";
17
+ * import { getClientIpOrUrl } from "@rzl-zone/utils-js/next/server";
18
+ *
19
+ * export function middleware(request: NextRequest) {
20
+ * const clientIp = getClientIpOrUrl(request, false);
21
+ * console.log("Client IP:", clientIp);
22
+ * }
23
+ *
24
+ * // Get full URL
25
+ * const url = getClientIpOrUrl(request);
26
+ * console.log("Client full URL:", url);
27
+ */
28
28
  declare const getClientIpOrUrl:(request:NextRequest,includeFullUrl?:boolean)=>string;export{getClientIpOrUrl};
@@ -1,2 +1,2 @@
1
- import {b,G}from'../../chunk-MJAW5RAK.js';import'server-only';import {NextRequest}from'next/server';var g=(t,r=true)=>{if(!b(NextRequest))throw new Error("Function `getClientIpOrUrl` is designed to be used in a `NextJS` environment.");if(!(t instanceof NextRequest))throw new TypeError("First parameter (`request`) must be an `instance of NextRequest` from `NextJS`.");G(r,{message:({currentType:a,validType:d})=>`Second parameter (\`includeFullUrl\`) must be of type \`${d}\`, but received: \`${a}\`.`});let e=(t.headers.get("x-forwarded-for")??"127.0.0.1").trim().split(",");(e[0]==="::ffff:127.0.0.1"||e[0]==="::1")&&(e[0]="127.0.0.1");let o=e.length>1?e[e.length-1].trim():e[0];if(!r)return o;let p=t.headers.get("x-forwarded-proto")||"http",f=t.headers.get("x-forwarded-port")||"3000";return `${process.env.NODE_ENV==="production"?p:"http"}://${o}:${f}`};
1
+ import {b,G}from'../../chunk-EWYPSKKM.js';import'server-only';import {NextRequest}from'next/server';var g=(t,r=true)=>{if(!b(NextRequest))throw new Error("Function `getClientIpOrUrl` is designed to be used in a `NextJS` environment.");if(!(t instanceof NextRequest))throw new TypeError("First parameter (`request`) must be an `instance of NextRequest` from `NextJS`.");G(r,{message:({currentType:a,validType:d})=>`Second parameter (\`includeFullUrl\`) must be of type \`${d}\`, but received: \`${a}\`.`});let e=(t.headers.get("x-forwarded-for")??"127.0.0.1").trim().split(",");(e[0]==="::ffff:127.0.0.1"||e[0]==="::1")&&(e[0]="127.0.0.1");let o=e.length>1?e[e.length-1].trim():e[0];if(!r)return o;let p=t.headers.get("x-forwarded-proto")||"http",f=t.headers.get("x-forwarded-port")||"3000";return `${process.env.NODE_ENV==="production"?p:"http"}://${o}:${f}`};
2
2
  export{g as getClientIpOrUrl};