@rzl-zone/utils-js 2.1.0 → 3.0.0-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 (128) hide show
  1. package/dist/NumberRangeUnion-DC-C3_Kq.d.ts +26 -0
  2. package/dist/any-BmdI8UbK.d.ts +67 -0
  3. package/dist/array-CIZRbqTF.d.ts +223 -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 +428 -0
  7. package/dist/assertions/index.js +1 -0
  8. package/dist/chunk-2TRAPBZ7.cjs +1 -0
  9. package/dist/chunk-3D74QO5D.cjs +1 -0
  10. package/dist/chunk-4DK3RCC4.js +2 -0
  11. package/dist/chunk-4JOQ45HL.js +1 -0
  12. package/dist/chunk-55CZALRS.js +1 -0
  13. package/dist/chunk-56QBKKRE.js +1 -0
  14. package/dist/chunk-5JFV3GDE.cjs +4 -0
  15. package/dist/chunk-5SZUSNGZ.js +1 -0
  16. package/dist/chunk-62HX5Z45.cjs +1 -0
  17. package/dist/chunk-7NA6DUHR.cjs +2 -0
  18. package/dist/chunk-7YWAQOA4.cjs +1 -0
  19. package/dist/chunk-BVPMMWDL.cjs +1 -0
  20. package/dist/chunk-BYZAD3XN.cjs +1 -0
  21. package/dist/chunk-CEFYHEM4.cjs +1 -0
  22. package/dist/chunk-CN53M4QZ.cjs +1 -0
  23. package/dist/chunk-D47MHBSD.cjs +1 -0
  24. package/dist/chunk-DGH75GJD.js +1 -0
  25. package/dist/chunk-E5NUI7PN.js +1 -0
  26. package/dist/chunk-ELDDNERR.js +1 -0
  27. package/dist/chunk-EXZ47NOW.js +1 -0
  28. package/dist/chunk-FDITZ5C6.cjs +1 -0
  29. package/dist/chunk-FF76ISQ2.js +1 -0
  30. package/dist/chunk-FIEZKTAZ.cjs +1 -0
  31. package/dist/chunk-FSSV24W7.cjs +1 -0
  32. package/dist/chunk-G5LXIEFO.js +0 -0
  33. package/dist/chunk-GCGU2WB7.js +1 -0
  34. package/dist/chunk-GECI2YBP.js +1 -0
  35. package/dist/chunk-GQE4OVHC.cjs +1 -0
  36. package/dist/chunk-GRVZXQXL.cjs +1 -0
  37. package/dist/chunk-I4AVNHPA.cjs +1 -0
  38. package/dist/chunk-JFRL7NKU.js +4 -0
  39. package/dist/chunk-JWHM3WZQ.cjs +1 -0
  40. package/dist/chunk-KCQDDZJE.cjs +1 -0
  41. package/dist/chunk-L54ZPSYJ.js +1 -0
  42. package/dist/chunk-LVKAYEZ4.js +1 -0
  43. package/dist/chunk-MBDWTK54.cjs +1 -0
  44. package/dist/chunk-MMSYCIJ2.cjs +1 -0
  45. package/dist/chunk-MNGGDB2G.js +1 -0
  46. package/dist/chunk-MY7BA4GI.cjs +1 -0
  47. package/dist/chunk-N2IJPIND.cjs +1 -0
  48. package/dist/chunk-NIMNTEGV.js +1 -0
  49. package/dist/chunk-NNM7QCNB.js +1 -0
  50. package/dist/chunk-PUQXRLZH.cjs +1 -0
  51. package/dist/chunk-PVJF2JHM.js +1 -0
  52. package/dist/chunk-QCFXEUKL.js +1 -0
  53. package/dist/chunk-QFCGBBSY.js +1 -0
  54. package/dist/chunk-QQYAUPSK.cjs +1 -0
  55. package/dist/chunk-RN3TP3S3.js +1 -0
  56. package/dist/chunk-RV2VULM7.cjs +1 -0
  57. package/dist/chunk-SW6HYEW7.cjs +1 -0
  58. package/dist/chunk-SYJC7UAW.js +1 -0
  59. package/dist/chunk-TC4VBE4Y.cjs +1 -0
  60. package/dist/chunk-TUXDINHF.cjs +1 -0
  61. package/dist/chunk-U5Y2FXMN.cjs +1 -0
  62. package/dist/chunk-UUPQI6ND.cjs +1 -0
  63. package/dist/chunk-VYCGZ2S6.js +1 -0
  64. package/dist/chunk-W5EDKJK3.js +1 -0
  65. package/dist/chunk-WHAVUFEU.js +1 -0
  66. package/dist/chunk-XCFIOTCV.js +1 -0
  67. package/dist/chunk-XE27XPJR.js +1 -0
  68. package/dist/chunk-XH6MCRLP.js +1 -0
  69. package/dist/chunk-XVB3ZZEB.js +1 -0
  70. package/dist/chunk-ZBSIGJFO.cjs +1 -0
  71. package/dist/chunk-ZYAML74V.js +1 -0
  72. package/dist/conversions/index.cjs +1 -0
  73. package/dist/conversions/index.d.ts +1633 -0
  74. package/dist/conversions/index.js +1 -0
  75. package/dist/env/index.cjs +1 -0
  76. package/dist/env/index.d.ts +19 -0
  77. package/dist/env/index.js +1 -0
  78. package/dist/events/index.cjs +1 -0
  79. package/dist/events/index.d.ts +119 -0
  80. package/dist/events/index.js +1 -0
  81. package/dist/extends-Mp81Hq9-.d.ts +145 -0
  82. package/dist/formatting/index.cjs +1 -0
  83. package/dist/formatting/index.d.ts +912 -0
  84. package/dist/formatting/index.js +1 -0
  85. package/dist/generator/index.cjs +1 -0
  86. package/dist/generator/index.d.ts +163 -0
  87. package/dist/generator/index.js +1 -0
  88. package/dist/if-CvT4R7Kh.d.ts +18 -0
  89. package/dist/index.cjs +1 -1
  90. package/dist/index.d.ts +1 -4334
  91. package/dist/index.js +1 -1
  92. package/dist/is-array-Ckm_47hw.d.ts +1557 -0
  93. package/dist/isPlainObject-BKYaI6a8.d.ts +182 -0
  94. package/dist/never-BfayMBF9.d.ts +75 -0
  95. package/dist/next/index.cjs +8 -1
  96. package/dist/next/index.d.ts +169 -169
  97. package/dist/next/index.js +8 -1
  98. package/dist/next/server/index.cjs +2 -1
  99. package/dist/next/server/index.d.ts +37 -37
  100. package/dist/next/server/index.js +2 -1
  101. package/dist/nils-DMz3kU7M.d.ts +177 -0
  102. package/dist/omit-VvmIsZmX.d.ts +28 -0
  103. package/dist/operations/index.cjs +1 -0
  104. package/dist/operations/index.d.ts +182 -0
  105. package/dist/operations/index.js +1 -0
  106. package/dist/parsers/index.cjs +1 -0
  107. package/dist/parsers/index.d.ts +37 -0
  108. package/dist/parsers/index.js +1 -0
  109. package/dist/predicates/index.cjs +1 -0
  110. package/dist/predicates/index.d.ts +1839 -0
  111. package/dist/predicates/index.js +1 -0
  112. package/dist/prettify-C4xLcYOP.d.ts +353 -0
  113. package/dist/promise/index.cjs +1 -0
  114. package/dist/promise/index.d.ts +40 -0
  115. package/dist/promise/index.js +1 -0
  116. package/dist/rzl-utils.global.js +4 -1
  117. package/dist/strings/index.cjs +1 -0
  118. package/dist/strings/index.d.ts +816 -0
  119. package/dist/strings/index.js +1 -0
  120. package/dist/stylings/index.cjs +1 -0
  121. package/dist/stylings/index.d.ts +49 -0
  122. package/dist/stylings/index.js +1 -0
  123. package/dist/type-data-DDs-u2kq.d.ts +261 -0
  124. package/dist/types/index.d.ts +3589 -2090
  125. package/dist/urls/index.cjs +1 -0
  126. package/dist/urls/index.d.ts +418 -0
  127. package/dist/urls/index.js +1 -0
  128. package/package.json +147 -21
@@ -0,0 +1,182 @@
1
+ import{N as NonPlainObject}from'./type-data-DDs-u2kq.js';type GetPreciseTypeOptions={
2
+ /** -------------------------------------------------------
3
+ * * ***Specifies the format in which the returned string type should be transformed.***
4
+ * -------------------------------------------------------
5
+ *
6
+ * ℹ️ For special string literals in `SPECIAL_CASES` (`"-Infinity" | "Infinity" | "NaN"`), which will remain unchanged.
7
+ * @default "toLowerCase"
8
+ *
9
+ * @description
10
+ * Supported formats:
11
+ * - `"toLowerCase"` (default) — converts all letters to lowercase.
12
+ * - ➔ `"result example type"`
13
+ * - `"toDotCase"` — words separated by dots.
14
+ * - ➔ `"result.example.type"`
15
+ * - `"toCamelCase"` — first word lowercase, subsequent words capitalized.
16
+ * - ➔ `"resultExampleType"`
17
+ * - `"toKebabCase"` — words separated by hyphens.
18
+ * - ➔ `"result-example-type"`
19
+ * - `"toSnakeCase"` — words separated by underscores.
20
+ * - ➔ `"result_example_type"`
21
+ * - `"toPascalCase"` — all words capitalized, no spaces.
22
+ * - ➔ `"ResultExampleType"`
23
+ * - `"toPascalCaseSpace"` — all words capitalized with spaces between words.
24
+ * - ➔ `"Result Example Type"`
25
+ * - `"slugify"` — URL-friendly slug (lowercase with hyphens).
26
+ * - ➔ `"result-example-type"`
27
+ *
28
+ * @note
29
+ * ⚠️ If an invalid value is provided, the function will automatically fallback to the default `"toLowerCase"`.
30
+ */
31
+ formatCase?:"toPascalCaseSpace"|"toPascalCase"|"toCamelCase"|"toKebabCase"|"toSnakeCase"|"toDotCase"|"slugify"|"toLowerCase";};
32
+ /** ----------------------------------------------------------
33
+ * * ***Returns a detailed and normalized type string for the given value.***
34
+ * ----------------------------------------------------------
35
+ *
36
+ * The returned string is human-readable _**toLowerCase**_ with spaces _***(by default)***_ or
37
+ * formatted according to the `options.formatCase` setting.
38
+ *
39
+ * Handles:
40
+ * - Primitives (`string`, `number`, `boolean`, `null`, `undefined`, `symbol`, `bigint`)
41
+ * - Built-in objects (`Array`, `Map`, `Set`, `Error subclasses`, `Typed Arrays`, etc)
42
+ * - Objects created with `Object.create(null)`
43
+ * - Generator instances
44
+ * - Node.js `Buffer` instances
45
+ * - Proxy detection (returns `"Proxy"` if detected; detection is not 100% accurate)
46
+ * - Uses cached mapping table (`FIXES`) for known types to provide consistent naming
47
+ * - Falls back to constructor name or `Object.prototype.toString` tag
48
+ *
49
+ * @param {*} value - The value to detect the precise type of
50
+ * @param {Object} [options] - Optional configuration
51
+ * @param {"toPascalCaseSpace"|"toLowerCase"|"toPascalCase"|"toCamelCase"|"toKebabCase"|"toSnakeCase"|"toDotCase"|"slugify"} [options.formatCase="toLowerCase"]
52
+ * - Specifies how the returned type string should be formatted.
53
+ * - ⚠️ Special string literals in `SPECIAL_CASES` (`"-Infinity" | "Infinity" | "NaN"`)
54
+ * will remain unchanged even if a different `formatCase` is applied.
55
+ *
56
+ * @returns {string} The normalized and formatted type string
57
+ *
58
+ * @example
59
+ * getPreciseType(123); // ➔ "number"
60
+ * getPreciseType(null); // ➔ "null"
61
+ * getPreciseType(/regex/,{ formatCase: "toKebabCase" });
62
+ * // ➔ "reg-exp"
63
+ * getPreciseType(function* () {}, { formatCase: "toCamelCase" });
64
+ * // ➔ "generatorFunction"
65
+ * getPreciseType(async function () {}, { formatCase: "toPascalCaseSpace" });
66
+ * // ➔ "Async Function"
67
+ * getPreciseType("NaN", { formatCase: "toKebabCase" });
68
+ * // ➔ "NaN" (SPECIAL_CASES remain)
69
+ */
70
+ declare const getPreciseType:(value:unknown,options?:GetPreciseTypeOptions)=>string;type IsNumberOptions={
71
+ /**
72
+ * If set to `true`, `NaN` will be considered a valid number.
73
+ * @default false
74
+ */
75
+ includeNaN?:boolean;};
76
+ /** ---------------------------------------------------------
77
+ * * ***Type guard: `isNumber`.***
78
+ * ----------------------------------------------------------
79
+ * @description Checks if a value is of type **`number`**.
80
+ *
81
+ * - Uses `typeof value === "number"`.
82
+ * - By default, excludes **`NaN`**.
83
+ * - If `options.includeNaN` is `true`, then **`NaN`** is also considered valid.
84
+ * - Still considers `Infinity` and `-Infinity` as numbers (consistent with JavaScript).
85
+ *
86
+ * ℹ️ To exclude `Infinity` and `-Infinity`, use **{@link isFinite}** instead.
87
+ *
88
+ * @param {*} value - The value to check.
89
+ * @param {IsNumberOptions} options - Optional settings.
90
+ * @param {boolean} options.includeNaN If `true`, `NaN` will be considered a valid number, dsefaults to `false`, which excludes `NaN`.
91
+ * @returns {boolean} Returns `true` if the value is a number (and depending on `includeNaN`, `NaN` is included or excluded).
92
+ *
93
+ * @example
94
+ * isNumber(42);
95
+ * // ➔ true
96
+ * isNumber(Infinity);
97
+ * // ➔ true
98
+ * isNumber(-Infinity);
99
+ * // ➔ true
100
+ * isNumber(NaN);
101
+ * // ➔ false (default)
102
+ * isNumber(NaN, { includeNaN: true });
103
+ * // ➔ true
104
+ * isNumber("42");
105
+ * // ➔ false
106
+ */
107
+ declare const isNumber:(value:unknown,options?:IsNumberOptions)=>value is number;type HasKeys<T>=keyof T extends never?false:true;
108
+ /** ----------------------------------------------------------
109
+ * * ***Utility type: `IsPlainObjectResult`.***
110
+ * ----------------------------------------------------------
111
+ * @description
112
+ * Represents the inferred type after asserting a value is a **plain object**.
113
+ *
114
+
115
+ *
116
+ * - If `T` is `unknown`, the resulting type is `Record<PropertyKey, unknown> & T`.
117
+ * - If `T` is an object:
118
+ * - If it is a non-plain object (class instance, built-in object, etc.), the result is `never`.
119
+ * - If it has no keys (`HasKeys<T>` checked by **{@link HasKeys}** is false), the result is `Record<PropertyKey, unknown> & T`.
120
+ * - Otherwise, the result is `T` itself.
121
+ * - For any other types, the result is `never`.
122
+ *
123
+ * @template T - The input type to be asserted as a plain object.
124
+ * @example
125
+ * ```ts
126
+ * type A = IsPlainObjectResult<unknown>;
127
+ * // ➔ Record<PropertyKey, unknown> & unknown
128
+ * type B = IsPlainObjectResult<{}>;
129
+ * // ➔ Record<PropertyKey, unknown> & {}
130
+ * type C = IsPlainObjectResult<{ foo: string }>;
131
+ * // ➔ { foo: string }
132
+ * type D = IsPlainObjectResult<Date>;
133
+ * // ➔ never
134
+ * ```
135
+ */
136
+ 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>>;
137
+ /** ----------------------------------------------------------
138
+ * * ***Type guard: `isPlainObject`.***
139
+ * ----------------------------------------------------------
140
+ * @description
141
+ * Checks if a value is a **plain-object**.
142
+ *
143
+ * A plain object is:
144
+ * - Created by the `Object` constructor, or
145
+ * - Has a `[[Prototype]]` of `null` (e.g. `Object.create(null)`).
146
+ * ----------------------------------------------------------
147
+ * - ✅ Returns `true` for:
148
+ * - Empty object literals: `{}`
149
+ * - Objects with null prototype: `Object.create(null)`
150
+ * ----------------------------------------------------------
151
+ * - ❌ Returns `false` for:
152
+ * - Arrays (`[]`, `new Array()`)
153
+ * - Functions (regular, arrow, or class constructors)
154
+ * - Built-in objects: `Date`, `RegExp`, `Error`, `Map`, `Set`, `WeakMap`, `WeakSet`
155
+ * - Boxed primitives: `new String()`, `new Number()`, `new Boolean()`
156
+ * - `null` or `undefined`
157
+ * - Symbols
158
+ * - Class instances
159
+ *
160
+ * @template T - The type of the value being checked.
161
+ * @param {*} value - The value to check.
162
+ * @returns {boolean} Return `true` if `value` is a `plain-object`, otherwise `false`.
163
+ *
164
+ * @example
165
+ * isPlainObject({});
166
+ * // ➔ true
167
+ * isPlainObject(Object.create(null));
168
+ * // ➔ true
169
+ * isPlainObject(null);
170
+ * // ➔ false
171
+ * isPlainObject(() => {});
172
+ * // ➔ false
173
+ * isPlainObject([1, 2, 3]);
174
+ * // ➔ false
175
+ * isPlainObject(new Date());
176
+ * // ➔ false
177
+ * isPlainObject(new MyClass());
178
+ * // ➔ false
179
+ * isPlainObject(new String("x"));
180
+ * // ➔ false
181
+ */
182
+ 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,8 @@
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 chunk5JFV3GDE_cjs=require('../chunk-5JFV3GDE.cjs'),chunkN2IJPIND_cjs=require('../chunk-N2IJPIND.cjs'),chunk2TRAPBZ7_cjs=require('../chunk-2TRAPBZ7.cjs'),chunkBVPMMWDL_cjs=require('../chunk-BVPMMWDL.cjs');require('../chunk-PUQXRLZH.cjs');var chunkU5Y2FXMN_cjs=require('../chunk-U5Y2FXMN.cjs');require('../chunk-7YWAQOA4.cjs');var chunkCN53M4QZ_cjs=require('../chunk-CN53M4QZ.cjs');function C(e,t){if(!chunkCN53M4QZ_cjs.h(e)||chunk2TRAPBZ7_cjs.a(e))throw new TypeError(`\u274C 'generateRoute' Failed:
2
+ - Invalid 'route' value.
3
+ - Must be of type \`string\` and non-empty string, but received: "${chunkCN53M4QZ_cjs.E(e)}": \`${chunkU5Y2FXMN_cjs.c(e)}\`.`);if(!/[\\[\]]/.test(e))return e;if(chunkCN53M4QZ_cjs.m(t,{message:({validType:o})=>`\u274C 'generateRoute' Failed cause in route "${e}":
4
+ - Missing or invalid parameters \`${o}\` for route: "${e}", must be of type \`${o}\` mapping parameters.`}),chunkCN53M4QZ_cjs.c(t))throw new TypeError(`\u274C 'generateRoute' Failed cause in route "${e}":
5
+ - Missing parameters \`plain-object\` for route: "${e}".`);let n=["?","&","#","=","/","'",'"',"(",")","+",";","%","@",":"],r=[],s=Array.from(e.matchAll(/\[(\w+)\]/g)).map(o=>o[1]);for(let o of s){let i=t[o];if(!chunkCN53M4QZ_cjs.h(i)){r.push(`- Invalid parameter: "${o}" must be of type \`string\`, but received: \`${chunkCN53M4QZ_cjs.E(i)}\`.`);continue}if(chunk2TRAPBZ7_cjs.a(i)){r.push(`- Parameter "${o}" cannot be empty string.`);continue}let p=n.filter(g=>i.includes(g));if(/\s/.test(i)&&p.push("white-space(s)"),p.length>0){let g=p.map(a=>a==="`"?"backtick - (`)":`\`${a}\``);n.includes("white-space(s)")||n.push("white-space(s)");let c=n.map(a=>a==="`"?"backtick - (`)":`\`${a}\``);r.push(`- Parameter "${o}" contains invalid characters (${g.join(", ")}). These characters are not allowed because they could cause issues in URL structure. The following characters are forbidden in route parameters: (${c.join(", ")}).`);}}if(chunkCN53M4QZ_cjs.r(r))throw new Error(`\u274C 'generateRoute' Failed cause in route "${e}":
6
+ ${r.join(`
7
+ `)}.`);return e.replace(/\[(\w+)\]/g,(o,i)=>(chunkCN53M4QZ_cjs.p(t[i])?t[i]:"").trim().replace(/^\/+|\/+$/g,"")).replace(/\/+/g,"/")}var M=(e="",t)=>{try{let p=function(c,a){return `${c.replace(/\/+$/,"")}/${a.replace(/^\/+/,"")}`};var n=p;chunkBVPMMWDL_cjs.a(e,{message({currentType:c,validType:a}){return `First parameter \`pathname\` must be of type \`${a}\`, but received: \`${c}\`.`}}),chunkCN53M4QZ_cjs.f(t)||(t={});let{prefix:r="/api",withOrigin:s=!0}=t;if(!chunkCN53M4QZ_cjs.k(r)&&!chunkCN53M4QZ_cjs.h(r))throw new TypeError(`Parameter \`prefix\` property of the \`options\` (second parameter) must be of type \`string\`, but received: ${chunkCN53M4QZ_cjs.E(r)}.`);chunkCN53M4QZ_cjs.G(s,{message:({currentType:c,validType:a})=>`Parameter \`withOrigin\` property of the \`options\` (second parameter) must be of type \`${a}\`, but received: \`${c}\`.`}),e=chunk5JFV3GDE_cjs.c(e),r=chunk5JFV3GDE_cjs.c(r);let o=r.endsWith("/")?r:r+"/";(e===r||e===r+"/"||e.startsWith(o))&&(e=e.slice(r.length),e=chunk5JFV3GDE_cjs.c(e));let i=U({suffix:r});return p(s?i:new URL(i).pathname,e).replace(/\/+$/,"")}catch(r){throw new Error("Failed to generate backend API URL in `createBeApiUrl()`, Error:"+r)}};var U=({suffix:e="/"}={})=>{chunkBVPMMWDL_cjs.a(e,{message({currentType:t,validType:n}){return `Parameter \`suffix\` property of the first parameter must be of type \`${n}\`, but received: \`${t}\`.`}});try{let t=process.env.NEXT_PUBLIC_BACKEND_API_URL?.trim();if(t){t=chunkN2IJPIND_cjs.c(t);let s=new URL(t);!!!s.port&&process.env.NEXT_PUBLIC_PORT_BE&&(t=s.origin+chunk5JFV3GDE_cjs.d(process.env.NEXT_PUBLIC_PORT_BE,{prefixColon:!0}));}else t="http://localhost"+chunk5JFV3GDE_cjs.d(process.env.NEXT_PUBLIC_PORT_BE||"8000",{prefixColon:!0});e=chunkN2IJPIND_cjs.c(e).length?chunkN2IJPIND_cjs.c(e):"/";let n=new URL(t.replace(/\/+$/,"")).origin,r=e==="/"?"/":`${e.startsWith("/")?"":"/"}${e.replace(/\/+$/,"")}`;return `${n}${r}`}catch(t){throw new Error("Invalid `NEXT_PUBLIC_BACKEND_API_URL`, failed to generate from `getBeApiUrl()`, Error:"+t)}};var Z=()=>{try{let e=process.env.NEXT_PUBLIC_BASE_URL?.trim(),t=process.env.NEXT_PUBLIC_PORT_FE?.trim(),n=e||"http://localhost";n=chunkN2IJPIND_cjs.c(n).replace(/\/+$/,"");let r=/:\/\/[^/]+:\d+/.test(n);!r&&t?n+=chunk5JFV3GDE_cjs.d(t,{prefixColon:!0}):!r&&!e&&(n+=":3000");let s=new URL(n);return `${s.protocol}//${s.hostname}${s.port?`:${s.port}`:""}`}catch(e){throw new Error("Invalid `NEXT_PUBLIC_BASE_URL`, failed to generate from `getBaseUrl()`, Error:"+e)}};
8
+ exports.createBeApiUrl=M;exports.generateRoute=C;exports.getBaseUrl=Z;exports.getBeApiUrl=U;
@@ -1,184 +1,184 @@
1
-
1
+ import{I as IsAny}from'../any-BmdI8UbK.js';import'../if-CvT4R7Kh.js';
2
2
  /** Extracts dynamic route parameters from a given route string.
3
- *
4
- * This utility type recursively searches for dynamic segments within a route,
5
- * 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
- *
10
- * @template T - The route string containing potential dynamic segments.
11
- *
12
- * @example
13
- * ```ts
14
- * type Params1 = ExtractRouteParams<"/user/[id]">;
15
- * // Result: { id: string }
16
- *
17
- * type Params2 = ExtractRouteParams<"/post/[slug]/comment/[commentId]">;
18
- * // Result: { slug: string; commentId: string }
19
- *
20
- * type Params3 = ExtractRouteParams<"/dashboard">;
21
- * // Result: {} (no dynamic parameters)
22
- * ```
23
- */
24
- type ExtractRouteParams<T extends string>=T extends `${infer _Start}[${infer Param}]${infer Rest}` ?{[K in Param]:string;}& ExtractRouteParams<Rest>:Record<any,any>;
3
+ *
4
+ * This utility type recursively searches for dynamic segments within a route,
5
+ * 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
+ *
10
+ * @template T - The route string containing potential dynamic segments.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * type Params1 = ExtractRouteParams<"/user/[id]">;
15
+ * // Result: { id: string }
16
+ *
17
+ * type Params2 = ExtractRouteParams<"/post/[slug]/comment/[commentId]">;
18
+ * // Result: { slug: string; commentId: string }
19
+ *
20
+ * type Params3 = ExtractRouteParams<"/dashboard">;
21
+ * // Result: {} (no dynamic parameters)
22
+ * ```
23
+ */
24
+ 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;
25
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
- *
32
- * @template T - The route string to be evaluated.
33
- *
34
- * @example
35
- * ```ts
36
- * type HasParams1 = HasDynamicSegments<"/user/[id]">;
37
- * // Result: true
38
- *
39
- * type HasParams2 = HasDynamicSegments<"/settings/profile">;
40
- * // Result: false
41
- *
42
- * type HasParams3 = HasDynamicSegments<"/blog/[category]/[slug]">;
43
- * // Result: true
44
- * ```
45
- */
46
- type HasDynamicSegments<T extends string>=T extends `${string}[${string}]${string}` ? true:false;
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
+ *
32
+ * @template T - The route string to be evaluated.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * type HasParams1 = HasDynamicSegments<"/user/[id]">;
37
+ * // Result: true
38
+ *
39
+ * type HasParams2 = HasDynamicSegments<"/settings/profile">;
40
+ * // Result: false
41
+ *
42
+ * type HasParams3 = HasDynamicSegments<"/blog/[category]/[slug]">;
43
+ * // Result: true
44
+ * ```
45
+ */
46
+ type HasDynamicSegments<T>=T extends`${string}[${string}]${string}`?true:false;type GenerateRouteResult<T>=true extends IsAny<T>?unknown:T extends string?string:unknown;
47
47
  /** ---------------------------------
48
- * * ***Generates a URL by replacing dynamic route parameters with provided values.***
49
- * ---------------------------------
50
- *
51
- * * ⚠️ ***Notes: This Function only support when using `NextJS`***
52
- *
53
- * @template T - The route string containing dynamic segments in the format `[param]`.
54
- *
55
- * @param {T} route - The route string containing dynamic segments.
56
- * @param {ExtractRouteParams<T>} [params] - An object containing key-value pairs that match the dynamic segments in the route.
57
- *
58
- * @returns {string} The formatted URL with all dynamic segments replaced.
59
- *
60
- * @throws {Error} If the route contains dynamic segments but no parameters object is provided.
61
- * @throws {Error} If a required parameter is missing from the `params` object.
62
- * @throws {Error} If a parameter value is an empty string.
63
- * @throws {Error} If any parameter contains invalid characters like `?`, `&`, `=`, `#`, `/`, spaces, `'`, `"`, `(`, `)`, `+`, `;`, `%`, `@`, or `:`, which can cause URL issues.
64
- *
65
- * @example
66
- * // Basic usage
67
- * generateRoute("/user/[id]", { id: "123" });
68
- * // Returns: "/user/123"
69
- *
70
- * @example
71
- * // No dynamic segments, returns as-is
72
- * generateRoute("/dashboard");
73
- * // Returns: "/dashboard"
74
- *
75
- * @example
76
- * // Throws an error due to missing parameters object
77
- * generateRoute("/profile/[username]");
78
- * // ❌ Error: 🚨 Missing parameters object for route: "/profile/[username]"
79
- *
80
- * @example
81
- * // Throws an error due to an empty parameter value
82
- * generateRoute("/post/[category]/[slug]", { category: "tech", slug: "" });
83
- * // ❌ Error: 🚨 Parameter "slug" cannot be empty in route: "/post/[category]/[slug]"
84
- *
85
- * @example
86
- * // Throws an error due to parameter containing invalid characters
87
- * generateRoute("/search/[query]", { query: "how to?learn" });
88
- * // ❌ Error: 🚨 Parameter "query" contains invalid character "?" in route: "/search/[query]"
89
- *
90
- * @example
91
- * // Handles leading/trailing slashes correctly
92
- * generateRoute("/blog/[category]/[slug]", { category: "/news/", slug: "/latest-update/" });
93
- * // ❌ Error: 🚨 Parameter "category" and "slug" contains slashes "/" which is not allowed.
94
- */
95
- declare function generateRoute<T extends string>(route:T,...params:HasDynamicSegments<T>extends true ? [ExtractRouteParams<T>]:[]):string;
48
+ * * ***Generates a URL by replacing dynamic route parameters with provided values.***
49
+ * ---------------------------------
50
+ *
51
+ * * ⚠️ ***Notes: This Function only support when using `NextJS`***
52
+ *
53
+ * @template T - The route string containing dynamic segments in the format `[param]`.
54
+ *
55
+ * @param {T} route - The route string containing dynamic segments.
56
+ * @param {ExtractRouteParams<T>} [params] - An object containing key-value pairs that match the dynamic segments in the route.
57
+ *
58
+ * @returns {string} The formatted URL with all dynamic segments replaced.
59
+ *
60
+ * @throws {Error} If the route contains dynamic segments but no parameters object is provided.
61
+ * @throws {Error} If a required parameter is missing from the `params` object.
62
+ * @throws {Error} If a parameter value is an empty string.
63
+ * @throws {Error} If any parameter contains invalid characters like `?`, `&`, `=`, `#`, `/`, spaces, `'`, `"`, `(`, `)`, `+`, `;`, `%`, `@`, or `:`, which can cause URL issues.
64
+ *
65
+ * @example
66
+ * // Basic usage
67
+ * generateRoute("/user/[id]", { id: "123" });
68
+ * // Returns: "/user/123"
69
+ *
70
+ * @example
71
+ * // No dynamic segments, returns as-is
72
+ * generateRoute("/dashboard");
73
+ * // Returns: "/dashboard"
74
+ *
75
+ * @example
76
+ * // Throws an error due to missing parameters object
77
+ * generateRoute("/profile/[username]");
78
+ * // ❌ Error: Missing parameters object for route: "/profile/[username]"
79
+ *
80
+ * @example
81
+ * // Throws an error due to an empty parameter value
82
+ * generateRoute("/post/[category]/[slug]", { category: "tech", slug: "" });
83
+ * // ❌ Error: Parameter "slug" cannot be empty in route: "/post/[category]/[slug]"
84
+ *
85
+ * @example
86
+ * // Throws an error due to parameter containing invalid characters
87
+ * generateRoute("/search/[query]", { query: "how to?learn" });
88
+ * // ❌ Error: Parameter "query" contains invalid character "?" in route: "/search/[query]"
89
+ *
90
+ * @example
91
+ * // Handles leading/trailing slashes correctly
92
+ * generateRoute("/blog/[category]/[slug]", { category: "/news/", slug: "/latest-update/" });
93
+ * // ❌ Error: Parameter "category" and "slug" contains slashes "/" which is not allowed.
94
+ */
95
+ 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;
96
96
  /** ---------------------------------
97
- * * ***Constructs a backend API URL by appending a given pathname to the base API URL.***
98
- * ---------------------------------
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.
114
- * @returns {string} The formatted API URL.
115
- *
116
- * @throws {TypeError} If `withOrigin` is not a boolean.
117
- * @throws {TypeError} If `prefix` and `pathname` is not a string.
118
- * @throws {Error} If constructing the API URL fails due to an invalid base URL.
119
- *
120
- * @example
121
- * createBeApiUrl("/users")
122
- * // -> "http://localhost:8000/api/users"
123
- *
124
- * createBeApiUrl("/users", { withOrigin: false })
125
- * // -> "/api/users"
126
- */
97
+ * * ***Constructs a backend API URL by appending a given pathname to the base API URL.***
98
+ * ---------------------------------
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.
114
+ * @returns {string} The formatted API URL.
115
+ *
116
+ * @throws {TypeError} If `withOrigin` is not a boolean.
117
+ * @throws {TypeError} If `prefix` and `pathname` is not a string.
118
+ * @throws {Error} If constructing the API URL fails due to an invalid base URL.
119
+ *
120
+ * @example
121
+ * createBeApiUrl("/users")
122
+ * // -> "http://localhost:8000/api/users"
123
+ *
124
+ * createBeApiUrl("/users", { withOrigin: false })
125
+ * // -> "/api/users"
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 "" */
129
+ *
130
+ * @default "" */
131
131
  pathname?:string,options?:{
132
132
  /** * The prefix pathname api url, e.g:`"http://localhost.com/your-target-prefix-entri-point-api-is-here"`.
133
- *
134
- * @default "/api" */
133
+ *
134
+ * @default "/api" */
135
135
  prefix?:string;
136
136
  /** * Option to getting `prefix` and `pathname` of api url only `(removing origin base api url)`.
137
- *
138
- * @default true */
137
+ *
138
+ * @default true */
139
139
  withOrigin?:boolean;})=>string;
140
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`***
149
- *
150
- * This function determines the backend API base URL from the `NEXT_PUBLIC_BACKEND_API_URL` environment variable.
151
- * - If `NEXT_PUBLIC_BACKEND_API_URL` is not set, it defaults to `"http://localhost:8000"`.
152
- * - If `NEXT_PUBLIC_BACKEND_API_URL` does **not** contain a port, it appends one from `NEXT_PUBLIC_PORT_BE` if available.
153
- * - 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.
158
- * @returns {string} The formatted backend API base URL.
159
- * @throws {TypeError} If `suffix` is not a `string`.
160
- * @throws {Error} If `NEXT_PUBLIC_BACKEND_API_URL` is invalid.
161
- */
162
- declare const getBeApiUrl:({suffix,}?:{
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`***
149
+ *
150
+ * This function determines the backend API base URL from the `NEXT_PUBLIC_BACKEND_API_URL` environment variable.
151
+ * - If `NEXT_PUBLIC_BACKEND_API_URL` is not set, it defaults to `"http://localhost:8000"`.
152
+ * - If `NEXT_PUBLIC_BACKEND_API_URL` does **not** contain a port, it appends one from `NEXT_PUBLIC_PORT_BE` if available.
153
+ * - 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.
158
+ * @returns {string} The formatted backend API base URL.
159
+ * @throws {TypeError} If `suffix` is not a `string`.
160
+ * @throws {Error} If `NEXT_PUBLIC_BACKEND_API_URL` is invalid.
161
+ */
162
+ declare const getBeApiUrl:({suffix}?:{
163
163
  /** * The Suffix origin base api url, e.g:`http://localhost.com/api`.
164
- *
165
- * @default "/" */
164
+ *
165
+ * @default "/" */
166
166
  suffix?:string;})=>string;
167
167
  /** ---------------------------------
168
- * * ***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
- *
180
- * @returns {string} The resolved base URL of the application.
181
- * @throws {Error} If the constructed URL is invalid or malformed.
182
- *
183
- */
184
- declare const getBaseUrl:()=>string;export{createBeApiUrl,generateRoute,getBaseUrl,getBeApiUrl};export type{ExtractRouteParams,HasDynamicSegments};
168
+ * * ***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
+ *
180
+ * @returns {string} The resolved base URL of the application.
181
+ * @throws {Error} If the constructed URL is invalid or malformed.
182
+ *
183
+ */
184
+ declare const getBaseUrl:()=>string;export{type ExtractRouteParams,type HasDynamicSegments,createBeApiUrl,generateRoute,getBaseUrl,getBeApiUrl};