@rzl-zone/utils-js 2.1.0 → 3.0.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 (129) hide show
  1. package/README.md +56 -27
  2. package/dist/NumberRangeUnion-DC-C3_Kq.d.ts +26 -0
  3. package/dist/any-BmdI8UbK.d.ts +67 -0
  4. package/dist/arrays-normalize-recursive-CnjYJ9xg.d.ts +72 -0
  5. package/dist/assertions/index.cjs +1 -0
  6. package/dist/assertions/index.d.ts +408 -0
  7. package/dist/assertions/index.js +1 -0
  8. package/dist/chunk-2HSNUPEO.cjs +1 -0
  9. package/dist/chunk-3YCFMGRB.js +1 -0
  10. package/dist/chunk-4Z75R3IT.cjs +1 -0
  11. package/dist/chunk-5C2SMIGX.cjs +1 -0
  12. package/dist/chunk-5Z2G23WP.js +1 -0
  13. package/dist/chunk-6C3ATUGM.cjs +1 -0
  14. package/dist/chunk-AJ25PWXX.cjs +1 -0
  15. package/dist/chunk-BHIBDDQF.js +1 -0
  16. package/dist/chunk-CE4JI2YB.js +1 -0
  17. package/dist/chunk-CMJ6UYWW.cjs +1 -0
  18. package/dist/chunk-D3VSHABU.cjs +1 -0
  19. package/dist/chunk-DG2GWBTS.cjs +1 -0
  20. package/dist/chunk-DVMHRLKP.cjs +1 -0
  21. package/dist/chunk-ECRNH4FW.js +1 -0
  22. package/dist/chunk-EKS4IZJR.cjs +1 -0
  23. package/dist/chunk-EOZKYR5S.cjs +1 -0
  24. package/dist/chunk-EUANTHVN.js +1 -0
  25. package/dist/chunk-EW3I4O7X.js +1 -0
  26. package/dist/chunk-F3E77L46.js +1 -0
  27. package/dist/chunk-FIAAX3UE.js +1 -0
  28. package/dist/chunk-FV7SEBKD.cjs +1 -0
  29. package/dist/chunk-G5LXIEFO.js +0 -0
  30. package/dist/chunk-GGWPB23G.cjs +1 -0
  31. package/dist/chunk-GVWGQNLF.js +1 -0
  32. package/dist/chunk-H3FXL4DU.cjs +1 -0
  33. package/dist/chunk-HHPDLSX2.cjs +1 -0
  34. package/dist/chunk-IMCLPT5V.cjs +1 -0
  35. package/dist/chunk-IRGE5W7L.js +1 -0
  36. package/dist/chunk-J2RGTPGK.cjs +1 -0
  37. package/dist/chunk-JARPXKBM.cjs +1 -0
  38. package/dist/chunk-JFJUPYDT.cjs +1 -0
  39. package/dist/chunk-JLP56WSM.js +1 -0
  40. package/dist/chunk-K3MV4AIN.cjs +1 -0
  41. package/dist/chunk-KHO2SBNA.cjs +1 -0
  42. package/dist/chunk-KOVO72OM.js +1 -0
  43. package/dist/chunk-LJ4M3VGE.js +1 -0
  44. package/dist/chunk-LJVGJLP4.js +1 -0
  45. package/dist/chunk-M47QIBXI.cjs +1 -0
  46. package/dist/chunk-MC3LXMCQ.js +1 -0
  47. package/dist/chunk-MISCBZJC.js +1 -0
  48. package/dist/chunk-MMSYCIJ2.cjs +1 -0
  49. package/dist/chunk-MTUBDVJ2.js +1 -0
  50. package/dist/chunk-O7UT5AN3.cjs +1 -0
  51. package/dist/chunk-OGPPP2S3.js +1 -0
  52. package/dist/chunk-OLPKAX7F.cjs +1 -0
  53. package/dist/chunk-ONZFBJVW.js +1 -0
  54. package/dist/chunk-ORZFHBEY.js +1 -0
  55. package/dist/chunk-OWV2P376.js +1 -0
  56. package/dist/chunk-QNKGP5DY.js +1 -0
  57. package/dist/chunk-RV2WK5E6.js +1 -0
  58. package/dist/chunk-SBF43G3B.cjs +1 -0
  59. package/dist/chunk-T4CIAKEK.js +1 -0
  60. package/dist/chunk-UDA26MCU.cjs +1 -0
  61. package/dist/chunk-VCFXNV3Q.cjs +1 -0
  62. package/dist/chunk-VHAPTHEA.cjs +1 -0
  63. package/dist/chunk-WVSPXFTY.js +1 -0
  64. package/dist/chunk-X74TUJSE.cjs +1 -0
  65. package/dist/chunk-XC3QHAK2.cjs +1 -0
  66. package/dist/chunk-XLDAIZRK.js +1 -0
  67. package/dist/chunk-XZJ7C4N6.js +1 -0
  68. package/dist/chunk-YV3K2EKJ.js +1 -0
  69. package/dist/chunk-ZHV5ZYVN.cjs +1 -0
  70. package/dist/chunk-ZL7J6GTP.js +1 -0
  71. package/dist/chunk-ZTCLKKMB.js +1 -0
  72. package/dist/conversions/index.cjs +1 -0
  73. package/dist/conversions/index.d.ts +1436 -0
  74. package/dist/conversions/index.js +1 -0
  75. package/dist/env/index.cjs +1 -0
  76. package/dist/env/index.d.ts +16 -0
  77. package/dist/env/index.js +1 -0
  78. package/dist/events/index.cjs +1 -0
  79. package/dist/events/index.d.ts +122 -0
  80. package/dist/events/index.js +1 -0
  81. package/dist/extends-Bk_SBGdT.d.ts +367 -0
  82. package/dist/formatting/index.cjs +1 -0
  83. package/dist/formatting/index.d.ts +950 -0
  84. package/dist/formatting/index.js +1 -0
  85. package/dist/generator/index.cjs +1 -0
  86. package/dist/generator/index.d.ts +186 -0
  87. package/dist/generator/index.js +1 -0
  88. package/dist/if-CvT4R7Kh.d.ts +18 -0
  89. package/dist/is-array--YjXV-Wx.d.ts +1207 -0
  90. package/dist/isPlainObject-BVhBAPHX.d.ts +169 -0
  91. package/dist/never-BfayMBF9.d.ts +75 -0
  92. package/dist/next/index.cjs +1 -1
  93. package/dist/next/index.d.ts +130 -110
  94. package/dist/next/index.js +1 -1
  95. package/dist/next/server/index.cjs +1 -1
  96. package/dist/next/server/index.d.ts +9 -23
  97. package/dist/next/server/index.js +1 -1
  98. package/dist/nils-DMz3kU7M.d.ts +177 -0
  99. package/dist/omit-VvmIsZmX.d.ts +28 -0
  100. package/dist/operations/index.cjs +1 -0
  101. package/dist/operations/index.d.ts +127 -0
  102. package/dist/operations/index.js +1 -0
  103. package/dist/parsers/index.cjs +1 -0
  104. package/dist/parsers/index.d.ts +36 -0
  105. package/dist/parsers/index.js +1 -0
  106. package/dist/predicates/index.cjs +1 -0
  107. package/dist/predicates/index.d.ts +1865 -0
  108. package/dist/predicates/index.js +1 -0
  109. package/dist/prettify-C4xLcYOP.d.ts +353 -0
  110. package/dist/promise/index.cjs +1 -0
  111. package/dist/promise/index.d.ts +31 -0
  112. package/dist/promise/index.js +1 -0
  113. package/dist/rzl-utils.global.js +1 -1
  114. package/dist/string-XA-til3C.d.ts +351 -0
  115. package/dist/strings/index.cjs +1 -0
  116. package/dist/strings/index.d.ts +741 -0
  117. package/dist/strings/index.js +1 -0
  118. package/dist/tailwind/index.cjs +1 -0
  119. package/dist/tailwind/index.d.ts +565 -0
  120. package/dist/tailwind/index.js +1 -0
  121. package/dist/type-data-DDs-u2kq.d.ts +261 -0
  122. package/dist/types/index.d.ts +3054 -1555
  123. package/dist/urls/index.cjs +1 -0
  124. package/dist/urls/index.d.ts +393 -0
  125. package/dist/urls/index.js +1 -0
  126. package/package.json +196 -27
  127. package/dist/index.cjs +0 -1
  128. package/dist/index.d.ts +0 -4334
  129. package/dist/index.js +0 -1
@@ -0,0 +1,169 @@
1
+ import{N as NonPlainObject}from'./type-data-DDs-u2kq.js';
2
+ /** Types for **{@link getPreciseType}**. */
3
+ type GetPreciseTypeOptions={
4
+ /** -------------------------------------------------------
5
+ * * ***Specifies the format in which the returned string type should be transformed.***
6
+ * -------------------------------------------------------
7
+ *
8
+ * ℹ️ For special string literals in `SPECIAL_CASES` (`"-Infinity" | "Infinity" | "NaN"`), which will remain unchanged.
9
+ * @default "toLowerCase"
10
+ *
11
+ * @description
12
+ * Supported formats:
13
+ * - `"toLowerCase"` (default) — converts all letters to lowercase.
14
+ * - ➔ `"result example type"`
15
+ * - `"toDotCase"` — words separated by dots.
16
+ * - ➔ `"result.example.type"`
17
+ * - `"toCamelCase"` — first word lowercase, subsequent words capitalized.
18
+ * - ➔ `"resultExampleType"`
19
+ * - `"toKebabCase"` — words separated by hyphens.
20
+ * - ➔ `"result-example-type"`
21
+ * - `"toSnakeCase"` — words separated by underscores.
22
+ * - ➔ `"result_example_type"`
23
+ * - `"toPascalCase"` — all words capitalized, no spaces.
24
+ * - ➔ `"ResultExampleType"`
25
+ * - `"toPascalCaseSpace"` — all words capitalized with spaces between words.
26
+ * - ➔ `"Result Example Type"`
27
+ * - `"slugify"` — URL-friendly slug (lowercase with hyphens).
28
+ * - ➔ `"result-example-type"`
29
+ *
30
+ * @note
31
+ * ⚠️ If an invalid value is provided, the function will automatically fallback to the default `"toLowerCase"`.
32
+ */
33
+ formatCase?:"toPascalCaseSpace"|"toPascalCase"|"toCamelCase"|"toKebabCase"|"toSnakeCase"|"toDotCase"|"slugify"|"toLowerCase";};
34
+ /** ----------------------------------------------------------
35
+ * * ***Utility-Predicate: `getPreciseType`.***
36
+ * ----------------------------------------------------------
37
+ * **Returns a detailed and normalized type string for the given value.**
38
+ * @description
39
+ * The returned string is human-readable _**toLowerCase**_ with spaces _***(by default)***_ or formatted according to the `options.formatCase` setting.
40
+ * - **Handles:**
41
+ * - Primitives (`string`, `number`, `boolean`, `null`, `undefined`, `symbol`, `bigint`)
42
+ * - Built-in objects (`Array`, `Map`, `Set`, `Error subclasses`, `Typed Arrays`, `etc`)
43
+ * - Objects created with `Object.create(null)`
44
+ * - Generator instances
45
+ * - Node.js `Buffer` instances
46
+ * - Proxy detection (returns `"Proxy"` if detected; detection is not 100% accurate)
47
+ * - Uses cached mapping table (`FIXES`) for known types to provide consistent naming
48
+ * - Falls back to constructor name or `Object.prototype.toString` tag
49
+ * @param {*} value - The value to detect the precise type of
50
+ * @param {GetPreciseTypeOptions} [options] - Optional configuration
51
+ * @param {GetPreciseTypeOptions["formatCase"]} [options.formatCase="toLowerCase"]
52
+ * Specifies how the returned type string should be formatted.
53
+ * - ⚠️ Special string literals in `SPECIAL_CASES`
54
+ * (`"-Infinity" | "Infinity" | "NaN"`) will remain
55
+ * unchanged even if a different `formatCase` is applied.
56
+ * @returns {string} The normalized and formatted type string
57
+ * @example
58
+ * getPreciseType(123); // ➔ "number"
59
+ * getPreciseType(null); // ➔ "null"
60
+ * getPreciseType(/regex/,{ formatCase: "toKebabCase" });
61
+ * // ➔ "reg-exp"
62
+ * getPreciseType(function* () {}, { formatCase: "toCamelCase" });
63
+ * // ➔ "generatorFunction"
64
+ * getPreciseType(async function () {}, { formatCase: "toPascalCaseSpace" });
65
+ * // ➔ "Async Function"
66
+ * getPreciseType(NaN, { formatCase: "toKebabCase" });
67
+ * // ➔ "NaN" (SPECIAL_CASES remain)
68
+ */
69
+ declare const getPreciseType:(value:unknown,options?:GetPreciseTypeOptions)=>string;type IsNumberOptions={
70
+ /** If set to `true`, `NaN` will be considered a valid number, defaultValue: `false`.
71
+ *
72
+ * @default false
73
+ */
74
+ includeNaN?:boolean;};
75
+ /** ---------------------------------------------------------
76
+ * * ***Type guard: `isNumber`.***
77
+ * ----------------------------------------------------------
78
+ * **Checks if a value is of type **`number`**.**
79
+ * - **Behavior:**
80
+ * - Uses `typeof value === "number"`.
81
+ * - By default, excludes **`NaN`**.
82
+ * - If `options.includeNaN` is `true`, then **`NaN`** is also considered valid.
83
+ * - Still considers `Infinity` and `-Infinity` as **numbers** (consistent with JavaScript).
84
+ * - **ℹ️ Note:**
85
+ * - To exclude `Infinity` and `-Infinity`, use **{@link isFinite | `isFinite`}** instead.
86
+ * @param {*} value - The value to check.
87
+ * @param {IsNumberOptions} [options] - Optional settings.
88
+ * @param {boolean} [options.includeNaN=false] If `true`, `NaN` will be considered a valid number, defaults to `false`, which excludes `NaN`.
89
+ * @returns {boolean} Returns `true` if the value is a number (and depending on `includeNaN`, `NaN` is included or excluded).
90
+ * @example
91
+ * isNumber(42);
92
+ * // ➔ true
93
+ * isNumber(Infinity);
94
+ * // ➔ true
95
+ * isNumber(-Infinity);
96
+ * // ➔ true
97
+ * isNumber(NaN);
98
+ * // ➔ false (default)
99
+ * isNumber(NaN, { includeNaN: true });
100
+ * // ➔ true
101
+ * isNumber("42");
102
+ * // ➔ false
103
+ */
104
+ declare const isNumber:(value:unknown,options?:IsNumberOptions)=>value is number;type HasKeys<T>=keyof T extends never?false:true;
105
+ /** ----------------------------------------------------------
106
+ * * ***Utility type: `IsPlainObjectResult`.***
107
+ * ----------------------------------------------------------
108
+ * **Represents the inferred type after asserting a value is a **plain object**.**
109
+ * - **Behavior:**
110
+ * - If `T` is `unknown`, the resulting type is `Record<PropertyKey, unknown> & T`.
111
+ * - If `T` is an object:
112
+ * - If it is a non-plain object (class instance, built-in object, etc.), the result is `never`.
113
+ * - If it has no keys (`HasKeys<T>` checked by **{@link HasKeys}** is false), the result is `Record<PropertyKey, unknown> & T`.
114
+ * - Otherwise, the result is `T` itself.
115
+ * - For any other types, the result is `never`.
116
+ * @template T - The input type to be asserted as a plain object.
117
+ * @example
118
+ * ```ts
119
+ * type A = IsPlainObjectResult<unknown>;
120
+ * // ➔ Record<PropertyKey, unknown> & unknown
121
+ * type B = IsPlainObjectResult<{}>;
122
+ * // ➔ Record<PropertyKey, unknown> & {}
123
+ * type C = IsPlainObjectResult<{ foo: string }>;
124
+ * // ➔ { foo: string }
125
+ * type D = IsPlainObjectResult<Date>;
126
+ * // ➔ never
127
+ * ```
128
+ */
129
+ type IsPlainObjectResult<T>=unknown extends T?Record<PropertyKey,unknown>& T:T extends object?T extends NonPlainObject?never:HasKeys<T>extends false?Record<PropertyKey,unknown>& T:T:Extract<T,Record<PropertyKey,unknown>>;
130
+ /** ----------------------------------------------------------
131
+ * * ***Type guard: `isPlainObject`.***
132
+ * ----------------------------------------------------------
133
+ * **Checks if a value is a **plain-object**.**
134
+ * - **A plain object is:**
135
+ * - Created by the `Object` constructor, or
136
+ * - Has a `[[Prototype]]` of `null` (e.g. `Object.create(null)`).
137
+ * - **✅ Returns `true` for:**
138
+ * - Empty object literals: `{}`
139
+ * - Objects with null prototype: `Object.create(null)`
140
+ * - **❌ Returns `false` for:**
141
+ * - Arrays (`[]`, `new Array()`)
142
+ * - Functions (regular, arrow, or class constructors)
143
+ * - Built-in objects: `Date`, `RegExp`, `Error`, `Map`, `Set`, `WeakMap`, `WeakSet`
144
+ * - Boxed primitives: `new String()`, `new Number()`, `new Boolean()`
145
+ * - `null` or `undefined`
146
+ * - Symbols
147
+ * - Class instances
148
+ * @template T - The type of the value being checked.
149
+ * @param {*} value - The value to check.
150
+ * @returns {boolean} Return `true` if `value` is a `plain-object`, otherwise `false`.
151
+ * @example
152
+ * isPlainObject({});
153
+ * // ➔ true
154
+ * isPlainObject(Object.create(null));
155
+ * // ➔ true
156
+ * isPlainObject(null);
157
+ * // ➔ false
158
+ * isPlainObject(() => {});
159
+ * // ➔ false
160
+ * isPlainObject([1, 2, 3]);
161
+ * // ➔ false
162
+ * isPlainObject(new Date());
163
+ * // ➔ false
164
+ * isPlainObject(new MyClass());
165
+ * // ➔ false
166
+ * isPlainObject(new String("x"));
167
+ * // ➔ false
168
+ */
169
+ declare function isPlainObject<T>(value:T):value is IsPlainObjectResult<T>;declare function isPlainObject<T>(value:T):value is NonNullable<Extract<T,Record<PropertyKey,unknown>>>;export{type GetPreciseTypeOptions as G,type IsNumberOptions as I,type IsPlainObjectResult as a,isPlainObject as b,getPreciseType as g,isNumber as i};
@@ -0,0 +1,75 @@
1
+ import{I as If}from'./if-CvT4R7Kh.js';
2
+ /** -------------------------------------------------------
3
+ * * ***IsNever.***
4
+ * -------------------------------------------------------
5
+ * **Conditional**: returns `true` if `T` is `never`, otherwise `false`.
6
+ *
7
+ * @template T - Type to check.
8
+ * @example
9
+ * ```ts
10
+ * type A = IsNever<never>; // ➔ true
11
+ * type B = IsNever<true>; // ➔ false
12
+ * ```
13
+ */
14
+ type IsNever<T>=[T] extends [never]?true:false;
15
+ /** -------------------------------------------------------
16
+ * * ***IfNever.***
17
+ * -------------------------------------------------------
18
+ * **Conditional**: Selects one of two branches depending on whether `T` is `never`.
19
+ * - Defaults: `IfTrue = true`, `IfFalse = false`.
20
+ *
21
+ * @template T - Type to check.
22
+ * @template IfTrue - The branch type if `T` is `never`, (default: `true`).
23
+ * @template IfFalse - The branch type if `T` is not `never`, (default: `false`).
24
+ * @example
25
+ * ```ts
26
+ * type A = IfNever<never>;
27
+ * // ➔ true
28
+ * type B = IfNever<string>;
29
+ * // ➔ false
30
+ * type C = IfNever<never, 'valid', 'no'>;
31
+ * // ➔ 'valid'
32
+ * type D = IfNever<string, 'valid', 'no'>;
33
+ * // ➔ 'no'
34
+ * ```
35
+ */
36
+ type IfNever<T,IfTrue=true,IfFalse=false>=If<IsNever<T>,IfTrue,IfFalse>;
37
+ /** -------------------------------------------------------
38
+ * * ***NeverifyPropertiesOptions.***
39
+ * -------------------------------------------------------
40
+ * Configuration options for the ***{@link NeverifyProperties}*** type utility.
41
+ *
42
+ * @property makeOptional - Whether to make all properties optional.
43
+ * - If `true`, resulting properties will be optional (`?`).
44
+ * - Default: `false`.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * type Opt1 = NeverifyPropertiesOptions;
49
+ * // ➔ { makeOptional: boolean }
50
+ * ```
51
+ */
52
+ type NeverifyPropertiesOptions={
53
+ /** Whether to make all properties optional, defaultValue: `false`.
54
+ *
55
+ * @default false
56
+ */
57
+ makeOptional:boolean;};
58
+ /** -------------------------------------------------------
59
+ * * ***NeverifyProperties.***
60
+ * -------------------------------------------------------
61
+ * Turns all properties of an object to type `never`.
62
+ * - If `Options["makeOptional"]` is `true`, properties will be optional.
63
+ *
64
+ * @template T - Object type to transform.
65
+ * @template Options - Configuration options (default: `{ makeOptional: false }`).
66
+ * @example
67
+ * ```ts
68
+ * type A = NeverifyProperties<{ a: string; b: string }>;
69
+ * // ➔ { a: never; b: never }
70
+ *
71
+ * type B = NeverifyProperties<{ a: string; b: string }, { makeOptional: true }>;
72
+ * // ➔ { a?: never; b?: never }
73
+ * ```
74
+ */
75
+ type NeverifyProperties<T extends object,Options extends NeverifyPropertiesOptions={makeOptional:false;}>={[K in keyof T]:never;}extends infer Result?If<Options["makeOptional"],Partial<Result>,Result>:never;export type{IsNever as I,NeverifyProperties as N,IfNever as a,NeverifyPropertiesOptions as b};
@@ -1 +1 @@
1
- 'use strict';function E(r){return Array.isArray(r)}var o=r=>typeof r=="string";var h=(r,e)=>{if(!o(r))return true;s(e)||(e={});let{trim:n=true}=e;return n&&(r=r.trim()),r===""};var d=r=>typeof r=="boolean";var $=r=>r instanceof Error;function T(r){return Array.isArray(r)&&r.length>0}function s(r){return typeof r=="object"&&!v(r)&&!E(r)}var p=(r,e)=>{if(!o(r))return false;s(e)||(e={});let{trim:n=true}=e;return(n?r.trim():r).length>0};var u=r=>typeof r>"u";function v(r){return r==null}var c=(r,e={trimOnly:false})=>{if(!p(r))return "";s(e)||(e={});let{trimOnly:n=false}=e;return n?r.trim():r.replace(/\s+/g,"")};var w=(r,e="/")=>{if(!p(e))throw new TypeError(`Invalid parameter:'defaultPath' must be a string and string is non-empty string. Received:${typeof e}(${e})`);if(!p(r))return e;try{if(r=c(r,{trimOnly:!0}),r=r.replace(/\s+/g,""),r.startsWith("http://")||r.startsWith("https://")){let n=new URL(r);return `${n.pathname}${n.search}${n.hash}`.replace(/^\/+/,"/")}return "/"+r.replace(/^\/+/,"").replace(/\/{2,}/g,"/")}catch(n){let t=$(n)?n:new Error("Unknown error from function `normalizePathname()`");throw new x(`Failed to normalize pathname in function \`normalizePathname()\`:${t.message}`,t)}};var y=(r,e)=>{if(!p(r))return "";if(!u(e)){if(!s(e))throw new TypeError("Options must be an object.");if("prefixColon"in e&&!d(e.prefixColon))throw new TypeError("Option `prefixColon` must be a boolean.")}let n=r.replace(/\D+/g,"");return n?e?.prefixColon??false?`:${n}`:n:""};var x=class r extends Error{constructor(n,t){super(n);this.originalError=t;this.name="NormalizePathnameError",Error.captureStackTrace&&Error.captureStackTrace(this,r);}};function G(r,e){if(!o(r)||h(r))throw new TypeError(`\u{1F6A8}'generateRoute' Failed:- Invalid 'route' value.- Expected a non-empty string,but received ${typeof r}:${JSON.stringify(r)}`);if(!r.includes("["))return r;if(!s(e))throw new Error(`\u{1F6A8}'generateRoute' Failed cause in route "${r}":- Missing or invalid parameters object for route:"${r}",expected an object mapping parameters.`);if(!e)throw new Error(`\u{1F6A8}'generateRoute' Failed cause in route "${r}":- Missing parameters object for route:"${r}"`);let n=["?","&","#","=","/"," ","'",'"',"(",")","+",";","%","@",":"],t=[],i=Array.from(r.matchAll(/\[(\w+)\]/g)).map(a=>a[1]);for(let a of i){let l=e[a];if(u(l)){t.push(`- Missing parameter:"${a}".`);continue}let f=l.trim();if(!f){t.push(`- Parameter "${a}" cannot be empty.`);continue}f.includes("/")&&t.push(`- Parameter "${a}" contains slashes "/" which is not allowed.`);let g=n.filter(m=>m!=="/").filter(m=>f.includes(m));g.length>0&&t.push(`- Parameter "${a}" contains invalid characters(${g.length>1?g.join(","):g}). These characters are not allowed because they could cause issues in URL structure. The following characters are forbidden in route parameters:(${n.join(",")}).`);}if(T(t))throw new Error(`\u{1F6A8}'generateRoute' Failed cause in route "${r}":${t.join(``)}`);return r.replace(/\[(\w+)\]/g,(a,l)=>e[l].trim().replace(/^\/+|\/+$/g,"")).replace(/\/+/g,"/")}var rr=(r="",e)=>{try{let f=function(m,P){return `${m.replace(/\/+$/,"")}/${P.replace(/^\/+/,"")}`};var n=f;if(!o(r))throw new TypeError(`Invalid type for 'pathname'. Expected 'string',received:${typeof r}`);s(e)||(e={});let{prefix:t="/api",withOrigin:i=!0}=e;if(!u(t)&&!o(t))throw new TypeError(`Invalid type for 'prefix'. Expected 'string',received:${typeof t}`);if(!d(i))throw new TypeError(`Invalid type for 'withOrigin'. Expected 'boolean',received:${typeof i}`);r=w(r),t=w(t);let a=t.endsWith("/")?t:t+"/";(r===t||r===t+"/"||r.startsWith(a))&&(r=r.slice(t.length),r=w(r));let l=b({suffix:t});return f(i?l:new URL(l).pathname,r).replace(/\/+$/,"")}catch(t){throw new Error("Failed to generate backend API URL in `createBeApiUrl()`,Error:"+t)}};var b=({suffix:r="/"}={})=>{if(!o(r))throw new TypeError(`Invalid type for 'suffix'. Expected string,received:${typeof r}`);try{let e=process.env.NEXT_PUBLIC_BACKEND_API_URL?.trim();if(e){e=c(e);let i=new URL(e);!!!i.port&&process.env.NEXT_PUBLIC_PORT_BE&&(e=i.origin+y(process.env.NEXT_PUBLIC_PORT_BE,{prefixColon:!0}));}else e="http://localhost"+y(process.env.NEXT_PUBLIC_PORT_BE||"8000",{prefixColon:!0});r=c(r).length?c(r):"/";let n=new URL(e.replace(/\/+$/,"")).origin,t=r==="/"?"/":`${r.startsWith("/")?"":"/"}${r.replace(/\/+$/,"")}`;return `${n}${t}`}catch(e){throw new Error("Invalid `NEXT_PUBLIC_BACKEND_API_URL`,failed to generate from `getBeApiUrl()`,Error:"+e)}};var or=()=>{try{let r=process.env.NEXT_PUBLIC_BASE_URL?.trim(),e=process.env.NEXT_PUBLIC_PORT_FE?.trim(),n=r||"http://localhost";n=c(n).replace(/\/+$/,"");let t=/:\/\/[^/]+:\d+/.test(n);!t&&e?n+=y(e,{prefixColon:!0}):!t&&!r&&(n+=":3000");let i=new URL(n);return `${i.protocol}//${i.hostname}${i.port?`:${i.port}`:""}`}catch(r){throw new Error("Invalid `NEXT_PUBLIC_BASE_URL`,failed to generate from `getBaseUrl()`,Error:"+r)}};exports.createBeApiUrl=rr;exports.generateRoute=G;exports.getBaseUrl=or;exports.getBeApiUrl=b;
1
+ "use strict";var e=require("../chunk-SBF43G3B.cjs"),r=require("../chunk-2HSNUPEO.cjs"),t=require("../chunk-4Z75R3IT.cjs"),n=require("../chunk-VCFXNV3Q.cjs");require("../chunk-DVMHRLKP.cjs");var s=require("../chunk-ZHV5ZYVN.cjs");require("../chunk-UDA26MCU.cjs");var i=require("../chunk-D3VSHABU.cjs");var a=({suffix:t="/"}={})=>{var s;n.assertIsString(t,{message:({currentType:e,validType:r})=>`Parameter \`suffix\` property of the first parameter must be of type \`${r}\`, but received: \`${e}\`.`});try{let n=null==(s=process.env.NEXT_PUBLIC_BACKEND_API_URL)?void 0:s.trim();if(n){n=r.removeSpaces(n);const t=new URL(n);!!!t.port&&process.env.NEXT_PUBLIC_PORT_BE&&(n=t.origin+e.formatEnvPort(process.env.NEXT_PUBLIC_PORT_BE,{prefixColon:!0}))}else n="http://localhost"+e.formatEnvPort(process.env.NEXT_PUBLIC_PORT_BE||"8000",{prefixColon:!0});t=r.removeSpaces(t).length?r.removeSpaces(t):"/";const i=new URL(n.replace(/\/+$/,"")).origin;return`${i}${"/"===t?"/":`${t.startsWith("/")?"":"/"}${t.replace(/\/+$/,"")}`}`}catch(e){throw new Error("Invalid `NEXT_PUBLIC_BACKEND_API_URL`, failed to generate from `getBeApiUrl()`, Error:"+e)}};exports.createBeApiUrl=(r,t={})=>{try{let s=function(e,r){return`${e.replace(/\/+$/,"")}/${r.replace(/^\/+/,"")}`};n.assertIsString(i.isNil(r)?"":r,{message:({currentType:e,validType:r})=>`First parameter (\`pathname\`) must be of type \`${r}\`, but received: \`${e}\`.`}),i.isPlainObject(t)||(t={});let{prefix:o="/api",withOrigin:c=!0}=t;if(!i.isUndefined(o)&&!i.isString(o))throw new TypeError(`Parameter \`prefix\` property of the \`options\` (second parameter) must be of type \`string\`, but received: \`${i.getPreciseType(o)}\`.`);i.assertIsBoolean(c,{message:({currentType:e,validType:r})=>`Parameter \`withOrigin\` property of the \`options\` (second parameter) must be of type \`${r}\`, but received: \`${e}\`.`}),r=e.normalizePathname(r),o=e.normalizePathname(o);const p=o.endsWith("/")?o:o+"/";(r===o||r===o+"/"||r.startsWith(p))&&(r=r.slice(o.length),r=e.normalizePathname(r));const u=a({suffix:o});return s(c?u:new URL(u).pathname,r).replace(/\/+$/,"")}catch(e){throw i.isError(e)?e:new Error("Failed to generate backend API URL in `createBeApiUrl()`, Error: "+new Error(String(e)).message.trim())}},exports.generateRoute=function(e,r){if(!i.isString(e)||t.isEmptyString(e))throw new TypeError(`❌ 'generateRoute' Failed:\n- Invalid 'route' value.\n- Must be of type \`string\` and non-empty string, but received: "${i.getPreciseType(e)}": \`${s.safeStableStringify(e)}\`.`);if(!/[\\[\]]/.test(e))return e;if(i.assertIsPlainObject(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.`}),i.isNil(r))throw new TypeError(`❌ 'generateRoute' Failed cause in route "${e}":\n- Missing parameters \`plain-object\` for route: "${e}".`);const n=["?","&","#","=","/","'",'"',"(",")","+",";","%","@",":"],a=[],o=Array.from(e.matchAll(/\[(\w+)\]/g)).map(e=>e[1]);for(const e of o){const s=r[e];if(!i.isString(s)){a.push(`- Invalid parameter: "${e}" must be of type \`string\`, but received: \`${i.getPreciseType(s)}\`.`);continue}if(t.isEmptyString(s)){a.push(`- Parameter "${e}" cannot be empty string.`);continue}const o=n.filter(e=>s.includes(e));if(/\s/.test(s)&&o.push("white-space(s)"),o.length>0){const r=o.map(e=>"`"===e?"backtick - (`)":`\`${e}\``);n.includes("white-space(s)")||n.push("white-space(s)");const t=n.map(e=>"`"===e?"backtick - (`)":`\`${e}\``);a.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: (${t.join(", ")}).`)}}if(i.isNonEmptyArray(a))throw new Error(`❌ 'generateRoute' Failed cause in route "${e}":\n${a.join("\n")}.`);return e.replace(/\[(\w+)\]/g,(e,t)=>(i.isNonEmptyString(r[t])?r[t]:"").trim().replace(/^\/+|\/+$/g,"")).replace(/\/+/g,"/")},exports.getBaseUrl=()=>{var t,n;try{const s=null==(t=process.env.NEXT_PUBLIC_BASE_URL)?void 0:t.trim(),i=null==(n=process.env.NEXT_PUBLIC_PORT_FE)?void 0:n.trim();let a=s||"http://localhost";a=r.removeSpaces(a).replace(/\/+$/,"");const o=/:\/\/[^/]+:\d+/.test(a);!o&&i?a+=e.formatEnvPort(i,{prefixColon:!0}):o||s||(a+=":3000");const c=new URL(a);return`${c.protocol}//${c.hostname}${c.port?`:${c.port}`:""}`}catch(e){throw new Error("Invalid `NEXT_PUBLIC_BASE_URL`, failed to generate from `getBaseUrl()`, Error:"+e)}},exports.getBeApiUrl=a;
@@ -1,184 +1,204 @@
1
-
2
- /** Extracts dynamic route parameters from a given route string.
3
- *
4
- * This utility type recursively searches for dynamic segments within a route,
1
+ import{I as IsAny}from'../any-BmdI8UbK.js';import'../if-CvT4R7Kh.js';
2
+ /** ---------------------------------------------------------
3
+ * * ***Extracts dynamic route parameters from a given route string.***
4
+ * ---------------------------------------------------------
5
+ * **This utility type recursively searches for dynamic segments within a route,
5
6
  * extracting each parameter and constructing an object where each key represents
6
- * a dynamic segment and its value is of type `string`.
7
- *
8
- * * ⚠️ ***Notes: This Type only support when using `NextJS`***
9
- *
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
10
  * @template T - The route string containing potential dynamic segments.
11
- *
12
11
  * @example
13
12
  * ```ts
14
13
  * type Params1 = ExtractRouteParams<"/user/[id]">;
15
- * // Result: { id: string }
16
- *
14
+ * // { id: string }
17
15
  * type Params2 = ExtractRouteParams<"/post/[slug]/comment/[commentId]">;
18
- * // Result: { slug: string; commentId: string }
19
- *
16
+ * // { slug: string; commentId: string }
20
17
  * type Params3 = ExtractRouteParams<"/dashboard">;
21
- * // Result: {} (no dynamic parameters)
18
+ * // {} (no dynamic parameters)
22
19
  * ```
23
20
  */
24
- type ExtractRouteParams<T extends string>=T extends `${infer _Start}[${infer Param}]${infer Rest}` ?{[K in Param]:string;}& ExtractRouteParams<Rest>:Record<any,any>;
25
- /** Determines whether a given route contains dynamic segments.
26
- *
27
- * This type checks if the route includes at least one `[param]` pattern.
28
- * If it does, the result is `true`, otherwise `false`.
29
- *
30
- * * ⚠️ ***Notes: This Type only support when using `NextJS`***
31
- *
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
+ /** ---------------------------------------------------------
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/)***.***
32
29
  * @template T - The route string to be evaluated.
33
- *
34
30
  * @example
35
31
  * ```ts
36
32
  * type HasParams1 = HasDynamicSegments<"/user/[id]">;
37
- * // Result: true
38
- *
33
+ * // true
39
34
  * type HasParams2 = HasDynamicSegments<"/settings/profile">;
40
- * // Result: false
41
- *
35
+ * // false
42
36
  * type HasParams3 = HasDynamicSegments<"/blog/[category]/[slug]">;
43
- * // Result: true
37
+ * // true
44
38
  * ```
45
39
  */
46
- type HasDynamicSegments<T extends string>=T extends `${string}[${string}]${string}` ? true:false;
40
+ type HasDynamicSegments<T>=T extends`${string}[${string}]${string}`?true:false;type GenerateRouteResult<T>=true extends IsAny<T>?unknown:T extends string?string:unknown;
47
41
  /** ---------------------------------
48
42
  * * ***Generates a URL by replacing dynamic route parameters with provided values.***
49
43
  * ---------------------------------
50
- *
51
- * * ⚠️ ***Notes: This Function only support when using `NextJS`***
52
- *
44
+ * - ***⚠️ Warning:***
45
+ * - ***This function only support when using ***[`NextJS`](https://nextjs.org/)***.***
53
46
  * @template T - The route string containing dynamic segments in the format `[param]`.
54
- *
55
47
  * @param {T} route - The route string containing dynamic segments.
56
48
  * @param {ExtractRouteParams<T>} [params] - An object containing key-value pairs that match the dynamic segments in the route.
57
- *
58
49
  * @returns {string} The formatted URL with all dynamic segments replaced.
59
- *
60
50
  * @throws {Error} If the route contains dynamic segments but no parameters object is provided.
61
51
  * @throws {Error} If a required parameter is missing from the `params` object.
62
52
  * @throws {Error} If a parameter value is an empty string.
63
53
  * @throws {Error} If any parameter contains invalid characters like `?`, `&`, `=`, `#`, `/`, spaces, `'`, `"`, `(`, `)`, `+`, `;`, `%`, `@`, or `:`, which can cause URL issues.
64
- *
65
54
  * @example
66
55
  * // Basic usage
67
56
  * generateRoute("/user/[id]", { id: "123" });
68
- * // Returns: "/user/123"
57
+ * // "/user/123"
69
58
  *
70
- * @example
71
59
  * // No dynamic segments, returns as-is
72
60
  * generateRoute("/dashboard");
73
- * // Returns: "/dashboard"
61
+ * // "/dashboard"
74
62
  *
75
- * @example
76
63
  * // Throws an error due to missing parameters object
77
64
  * generateRoute("/profile/[username]");
78
- * // ❌ Error: 🚨 Missing parameters object for route: "/profile/[username]"
65
+ * // ❌ Error: Missing parameters object for route: "/profile/[username]"
79
66
  *
80
- * @example
81
67
  * // Throws an error due to an empty parameter value
82
68
  * generateRoute("/post/[category]/[slug]", { category: "tech", slug: "" });
83
- * // ❌ Error: 🚨 Parameter "slug" cannot be empty in route: "/post/[category]/[slug]"
69
+ * // ❌ Error: Parameter "slug" cannot be empty in route: "/post/[category]/[slug]"
84
70
  *
85
- * @example
86
71
  * // Throws an error due to parameter containing invalid characters
87
72
  * generateRoute("/search/[query]", { query: "how to?learn" });
88
- * // ❌ Error: 🚨 Parameter "query" contains invalid character "?" in route: "/search/[query]"
73
+ * // ❌ Error: Parameter "query" contains invalid character "?" in route: "/search/[query]"
89
74
  *
90
- * @example
91
75
  * // Handles leading/trailing slashes correctly
92
76
  * generateRoute("/blog/[category]/[slug]", { category: "/news/", slug: "/latest-update/" });
93
- * // ❌ Error: 🚨 Parameter "category" and "slug" contains slashes "/" which is not allowed.
77
+ * // ❌ Error: Parameter "category" and "slug" contains slashes "/" which is not allowed.
94
78
  */
95
- declare function generateRoute<T extends string>(route:T,...params:HasDynamicSegments<T>extends true ? [ExtractRouteParams<T>]:[]):string;
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
+ /** * The prefix pathname api url, e.g:`"http://localhost.com/your-target-prefix-entri-point-api-is-here"`, default: `"/api"`.
81
+ *
82
+ * @default "/api" */
83
+ prefix?:string;
84
+ /** * Option to getting `prefix` and `pathname` of api url only `(removing origin base api url)`, default: `true`.
85
+ *
86
+ * @default true */
87
+ withOrigin?:boolean;};
96
88
  /** ---------------------------------
97
89
  * * ***Constructs a backend API URL by appending a given pathname to the base API URL.***
98
90
  * ---------------------------------
99
- * This function builds on top of `getBeApiUrl()`, which determines the base API URL from:
100
- * - `NEXT_PUBLIC_BACKEND_API_URL` environment variable (or defaults to `"http://localhost:8000"`).
101
- * - Automatically appends `NEXT_PUBLIC_PORT_BE` if the base URL does not already include a port.
102
- *
103
- * Features of this function:
104
- * - Allows customizing the API path with an optional `prefix` (defaults to `"/api"`).
105
- * - Can include or exclude the origin (protocol + host) via `withOrigin`.
106
- * - Normalizes paths to avoid duplicate slashes.
107
- *
108
- * * ⚠️ ***Notes: This Function only support when using `NextJS`***
109
- *
110
- * @param {string} pathname - The API endpoint path (e.g., `/users` or `/v1/posts`).
111
- * @param {Object} options - Configuration options.
112
- * @param {string} [options.prefix="/api"] - The prefix for the API path (default is `"/api"`).
113
- * @param {boolean} [options.withOrigin=true] - Whether to include the full base URL or return only the API path.
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.
114
105
  * @returns {string} The formatted API URL.
115
- *
116
106
  * @throws {TypeError} If `withOrigin` is not a boolean.
117
107
  * @throws {TypeError} If `prefix` and `pathname` is not a string.
118
108
  * @throws {Error} If constructing the API URL fails due to an invalid base URL.
119
- *
120
109
  * @example
121
110
  * createBeApiUrl("/users")
122
- * // -> "http://localhost:8000/api/users"
123
- *
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"
124
120
  * createBeApiUrl("/users", { withOrigin: false })
125
- * // -> "/api/users"
121
+ * // "/api/users"
122
+ * createBeApiUrl(null, { withOrigin: false })
123
+ * // ➔ "/api"
124
+ * createBeApiUrl(undefined, { withOrigin: false })
125
+ * // ➔ "/api"
126
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
129
  *
130
- * @default "" */
131
- pathname?:string,options?:{
132
- /** * The prefix pathname api url, e.g:`"http://localhost.com/your-target-prefix-entri-point-api-is-here"`.
133
- *
134
- * @default "/api" */
135
- prefix?:string;
136
- /** * Option to getting `prefix` and `pathname` of api url only `(removing origin base api url)`.
137
- *
138
- * @default true */
139
- withOrigin?:boolean;})=>string;
140
- /** ---------------------------------
141
- * * ***Retrieves the base API URL of the backend.***
142
- * ---------------------------------
143
- *
144
- * This function determines the backend API base URL from the `NEXT_PUBLIC_BACKEND_API_URL` environment variable.
145
- * If the variable is not set, it defaults to `"http://localhost:8000"`.
146
- * It also allows adding an optional suffix to the returned URL.
147
- *
148
- * * ⚠️ ***Notes: This Function only support when using `NextJS`***
130
+ * @default ""
131
+ */
132
+ pathname:string|null|undefined,options?:OptionsCreateBeApiUrl)=>string;type OptionsGetBeApiUrl={
133
+ /** * The Suffix origin base api url, e.g:`http://localhost.com/api`, default: `"/"`.
149
134
  *
135
+ * @default "/" */
136
+ suffix?:string;};
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
150
147
  * This function determines the backend API base URL from the `NEXT_PUBLIC_BACKEND_API_URL` environment variable.
151
148
  * - If `NEXT_PUBLIC_BACKEND_API_URL` is not set, it defaults to `"http://localhost:8000"`.
152
149
  * - If `NEXT_PUBLIC_BACKEND_API_URL` does **not** contain a port, it appends one from `NEXT_PUBLIC_PORT_BE` if available.
153
150
  * - Supports appending optional suffix (like "/api").
154
- *
155
- *
156
- * @param {Object} options - Configuration options.
157
- * @param {string} [options.suffix="/"] - The suffix to append to the base API URL.
151
+ * @param {OptionsGetBeApiUrl|undefined} options - Configuration options.
152
+ * @param {OptionsGetBeApiUrl["suffix"]} [options.suffix="/"] - The suffix to append to the base API URL.
158
153
  * @returns {string} The formatted backend API base URL.
159
154
  * @throws {TypeError} If `suffix` is not a `string`.
160
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"
161
172
  */
162
- declare const getBeApiUrl:({suffix,}?:{
163
- /** * The Suffix origin base api url, e.g:`http://localhost.com/api`.
164
- *
165
- * @default "/" */
166
- suffix?:string;})=>string;
167
- /** ---------------------------------
173
+ declare const getBeApiUrl:({suffix}?:OptionsGetBeApiUrl)=>string;
174
+ /** ---------------------------------------------------
168
175
  * * ***Retrieves the base URL of the application.***
169
- * ---------------------------------
170
- *
171
- * This function is designed to be used within Next.js applications.
172
- * It determines the base URL from the `NEXT_PUBLIC_BASE_URL` environment variable.
173
- *
174
- * * ⚠️ ***Notes: This Function only support when using `NextJS`***
175
- *
176
- * - If `NEXT_PUBLIC_BASE_URL` is not set, it defaults to `"http://localhost:3000"`.
177
- * - If `NEXT_PUBLIC_BASE_URL` does **not** contain a port, it appends one from `NEXT_PUBLIC_PORT_FE` if available.
178
- * - Ensures the final URL is valid and normalized (no trailing slashes).
179
- *
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/)***.***
180
185
  * @returns {string} The resolved base URL of the application.
181
186
  * @throws {Error} If the constructed URL is invalid or malformed.
182
- *
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"
183
203
  */
184
- declare const getBaseUrl:()=>string;export{createBeApiUrl,generateRoute,getBaseUrl,getBeApiUrl};export type{ExtractRouteParams,HasDynamicSegments};
204
+ declare const getBaseUrl:()=>string;export{type ExtractRouteParams,type HasDynamicSegments,createBeApiUrl,generateRoute,getBaseUrl,getBeApiUrl};