@rzl-zone/utils-js 3.0.1-beta.0 → 3.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assertions/index.cjs +1 -1
- package/dist/assertions/index.d.ts +96 -116
- package/dist/assertions/index.js +1 -1
- package/dist/chunk-25G6B35W.js +1 -0
- package/dist/chunk-2AUUPGMN.js +1 -0
- package/dist/chunk-2JQQQ625.js +1 -0
- package/dist/chunk-445TAVT4.cjs +1 -0
- package/dist/chunk-467VEMJH.js +1 -0
- package/dist/chunk-6Q4I2RPC.cjs +1 -0
- package/dist/chunk-6SMJMZ7G.cjs +1 -0
- package/dist/chunk-BLCANGFS.js +1 -0
- package/dist/chunk-CK3BZGEU.js +1 -0
- package/dist/{chunk-JWHM3WZQ.cjs → chunk-D43GV6EF.cjs} +1 -1
- package/dist/chunk-DFSTVQFI.cjs +1 -0
- package/dist/chunk-DYRDBYPF.cjs +1 -0
- package/dist/chunk-EXXLUO7L.cjs +1 -0
- package/dist/chunk-G72VSVGO.js +1 -0
- package/dist/chunk-GAJTFCUA.js +1 -0
- package/dist/chunk-GOJNH55O.cjs +1 -0
- package/dist/chunk-HXST7RJB.js +1 -0
- package/dist/{chunk-BYZAD3XN.cjs → chunk-HXTACM3O.cjs} +1 -1
- package/dist/chunk-IJTZWWRJ.cjs +1 -0
- package/dist/chunk-ISJ33O2J.cjs +1 -0
- package/dist/chunk-JISH2VGG.js +1 -0
- package/dist/{chunk-FF76ISQ2.js → chunk-JQZUWBIX.js} +1 -1
- package/dist/{chunk-XH6MCRLP.js → chunk-K4PLGD7C.js} +1 -1
- package/dist/chunk-KZQB7H4E.cjs +1 -0
- package/dist/chunk-LUVV5KSD.cjs +2 -0
- package/dist/chunk-LVUSFXQS.cjs +1 -0
- package/dist/chunk-ME5OV5HN.js +1 -0
- package/dist/chunk-MF5Y5K4N.cjs +1 -0
- package/dist/chunk-MJAW5RAK.js +1 -0
- package/dist/chunk-MWLEM7ED.js +1 -0
- package/dist/chunk-NSVLG7NY.js +4 -0
- package/dist/chunk-NUHOOAUN.cjs +1 -0
- package/dist/chunk-NUVGETPD.js +2 -0
- package/dist/chunk-O5VXBNUQ.cjs +4 -0
- package/dist/chunk-O7SJR4CY.cjs +1 -0
- package/dist/chunk-OX6RLS2F.cjs +1 -0
- package/dist/chunk-PFLNHD4B.cjs +1 -0
- package/dist/chunk-PSWITZK5.js +1 -0
- package/dist/chunk-PYUVKHUF.cjs +1 -0
- package/dist/chunk-REFMEB4A.js +1 -0
- package/dist/chunk-RHE3M2NJ.cjs +1 -0
- package/dist/chunk-RHIBYOFQ.js +1 -0
- package/dist/chunk-S7GMG4TB.js +1 -0
- package/dist/chunk-TQMZ2LPI.js +1 -0
- package/dist/{chunk-RN3TP3S3.js → chunk-U4TZO7WV.js} +1 -1
- package/dist/chunk-UUMKL74S.js +1 -0
- package/dist/{chunk-EXZ47NOW.js → chunk-VQLAPEL3.js} +1 -1
- package/dist/chunk-VTR75UID.cjs +1 -0
- package/dist/chunk-XFCJDSB2.cjs +1 -0
- package/dist/chunk-XOYX4PLZ.cjs +1 -0
- package/dist/chunk-Z6FLCEN6.js +1 -0
- package/dist/chunk-ZO5364A6.cjs +1 -0
- package/dist/conversions/index.cjs +1 -1
- package/dist/conversions/index.d.ts +396 -593
- package/dist/conversions/index.js +1 -1
- package/dist/env/index.d.ts +5 -8
- package/dist/events/index.cjs +1 -1
- package/dist/events/index.d.ts +80 -77
- package/dist/events/index.js +1 -1
- package/dist/{array-CIZRbqTF.d.ts → extends-Bk_SBGdT.d.ts} +145 -1
- package/dist/formatting/index.cjs +1 -1
- package/dist/formatting/index.d.ts +478 -440
- package/dist/formatting/index.js +1 -1
- package/dist/generator/index.cjs +1 -1
- package/dist/generator/index.d.ts +135 -112
- package/dist/generator/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{is-array-Ckm_47hw.d.ts → is-array--YjXV-Wx.d.ts} +2 -352
- package/dist/{isPlainObject-BKYaI6a8.d.ts → isPlainObject-BVhBAPHX.d.ts} +49 -62
- package/dist/next/index.cjs +6 -6
- package/dist/next/index.d.ts +125 -105
- package/dist/next/index.js +5 -5
- package/dist/next/server/index.cjs +1 -1
- package/dist/next/server/index.d.ts +8 -22
- package/dist/next/server/index.js +1 -1
- package/dist/operations/index.cjs +1 -1
- package/dist/operations/index.d.ts +72 -127
- package/dist/operations/index.js +1 -1
- package/dist/parsers/index.cjs +1 -1
- package/dist/parsers/index.d.ts +26 -27
- package/dist/parsers/index.js +1 -1
- package/dist/predicates/index.cjs +1 -1
- package/dist/predicates/index.d.ts +686 -660
- package/dist/predicates/index.js +1 -1
- package/dist/promise/index.cjs +1 -1
- package/dist/promise/index.d.ts +14 -23
- package/dist/promise/index.js +1 -1
- package/dist/rzl-utils.global.js +3 -3
- package/dist/string-XA-til3C.d.ts +351 -0
- package/dist/strings/index.cjs +1 -1
- package/dist/strings/index.d.ts +301 -376
- package/dist/strings/index.js +1 -1
- package/dist/stylings/index.cjs +1 -1
- package/dist/stylings/index.d.ts +15 -23
- package/dist/stylings/index.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/urls/index.cjs +1 -1
- package/dist/urls/index.d.ts +279 -302
- package/dist/urls/index.js +1 -1
- package/package.json +53 -11
- package/dist/chunk-2TRAPBZ7.cjs +0 -1
- package/dist/chunk-4DK3RCC4.js +0 -2
- package/dist/chunk-4JOQ45HL.js +0 -1
- package/dist/chunk-55CZALRS.js +0 -1
- package/dist/chunk-62HX5Z45.cjs +0 -1
- package/dist/chunk-7NA6DUHR.cjs +0 -2
- package/dist/chunk-BVPMMWDL.cjs +0 -1
- package/dist/chunk-CEFYHEM4.cjs +0 -1
- package/dist/chunk-CN53M4QZ.cjs +0 -1
- package/dist/chunk-D47MHBSD.cjs +0 -1
- package/dist/chunk-DGH75GJD.js +0 -1
- package/dist/chunk-E5NUI7PN.js +0 -1
- package/dist/chunk-FDITZ5C6.cjs +0 -1
- package/dist/chunk-FSSV24W7.cjs +0 -1
- package/dist/chunk-GCGU2WB7.js +0 -1
- package/dist/chunk-GECI2YBP.js +0 -1
- package/dist/chunk-GQE4OVHC.cjs +0 -1
- package/dist/chunk-GRVZXQXL.cjs +0 -1
- package/dist/chunk-I4AVNHPA.cjs +0 -1
- package/dist/chunk-KBKYG3IY.cjs +0 -1
- package/dist/chunk-KCQDDZJE.cjs +0 -1
- package/dist/chunk-LVKAYEZ4.js +0 -1
- package/dist/chunk-MBDWTK54.cjs +0 -1
- package/dist/chunk-MNGGDB2G.js +0 -1
- package/dist/chunk-MY7BA4GI.cjs +0 -1
- package/dist/chunk-N2IJPIND.cjs +0 -1
- package/dist/chunk-NIMNTEGV.js +0 -1
- package/dist/chunk-POCPQYZS.js +0 -1
- package/dist/chunk-PVJF2JHM.js +0 -1
- package/dist/chunk-QCFXEUKL.js +0 -1
- package/dist/chunk-QFCGBBSY.js +0 -1
- package/dist/chunk-QQYAUPSK.cjs +0 -1
- package/dist/chunk-TC4VBE4Y.cjs +0 -1
- package/dist/chunk-TUXDINHF.cjs +0 -1
- package/dist/chunk-U5Y2FXMN.cjs +0 -1
- package/dist/chunk-UUPQI6ND.cjs +0 -1
- package/dist/chunk-VYCGZ2S6.js +0 -1
- package/dist/chunk-W5EDKJK3.js +0 -1
- package/dist/chunk-WHAVUFEU.js +0 -1
- package/dist/chunk-X3GTRVVK.cjs +0 -4
- package/dist/chunk-XCFIOTCV.js +0 -1
- package/dist/chunk-XE27XPJR.js +0 -1
- package/dist/chunk-XVB3ZZEB.js +0 -1
- package/dist/chunk-YEERJDOF.js +0 -4
- package/dist/chunk-ZBSIGJFO.cjs +0 -1
- package/dist/chunk-ZYAML74V.js +0 -1
- package/dist/extends-Mp81Hq9-.d.ts +0 -145
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{I as
|
|
1
|
+
import{I as IfExtends,E as Extends,N as Not,a as NotExtends}from'./extends-Bk_SBGdT.js';import{I as If}from'./if-CvT4R7Kh.js';import{T as Trim,I as IfNot}from'./string-XA-til3C.js';import{I as IsNever}from'./never-BfayMBF9.js';import{I as IsAny}from'./any-BmdI8UbK.js';import{P as Prettify}from'./prettify-C4xLcYOP.js';
|
|
2
2
|
/** -------------------------------------------------------
|
|
3
3
|
* * ***And.***
|
|
4
4
|
* -------------------------------------------------------
|
|
@@ -55,356 +55,6 @@ type AndArr<Conditions extends readonly unknown[]>=Extends<Conditions[number],tr
|
|
|
55
55
|
*/
|
|
56
56
|
type IsStringLiteral<T>=If<Extends<T,string>,Extends<string,T>extends true?false:true,false>;
|
|
57
57
|
/** -------------------------------------------------------
|
|
58
|
-
* * ***IfNot.***
|
|
59
|
-
* -------------------------------------------------------
|
|
60
|
-
*
|
|
61
|
-
* Conditional: returns the second argument if the first argument is `false`, otherwise returns the third argument.
|
|
62
|
-
* - Defaults: `IfTrue = true`, `IfFalse = false`.
|
|
63
|
-
*
|
|
64
|
-
* @template Condition - The boolean condition to check.
|
|
65
|
-
* @template IfTrue - The branch type if condition is `false`. (default: `true`)
|
|
66
|
-
* @template IfFalse - The branch type if condition is `true`. (default: `false`)
|
|
67
|
-
*
|
|
68
|
-
* ### Examples
|
|
69
|
-
* ```ts
|
|
70
|
-
* type A = IfNot<false, "valid">;
|
|
71
|
-
* // ➔ "valid"
|
|
72
|
-
* type B = IfNot<false, "valid", "invalid">;
|
|
73
|
-
* // ➔ "invalid"
|
|
74
|
-
* ```
|
|
75
|
-
*/
|
|
76
|
-
type IfNot<Condition,IfTrue=true,IfFalse=false>=If<Condition,IfFalse,IfTrue>;
|
|
77
|
-
/** -------------------------------------------------------
|
|
78
|
-
* * ***WordSeparator.***
|
|
79
|
-
* -------------------------------------------------------
|
|
80
|
-
* A type-level utility that defines all valid ***word separators***.
|
|
81
|
-
* - Can be a space `" "`, a dash `"-"`, or an underscore `"_"`.
|
|
82
|
-
*
|
|
83
|
-
* @example
|
|
84
|
-
* ```ts
|
|
85
|
-
* type A = WordSeparator; // ➔ " " | "-" | "_"
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
|
-
type WordSeparator=" "|"-"|"_";
|
|
89
|
-
/** --------------------------------------------------
|
|
90
|
-
* * ***Whitespace.***
|
|
91
|
-
* --------------------------------------------------
|
|
92
|
-
* Represents common whitespace characters.
|
|
93
|
-
*
|
|
94
|
-
* ✅ Used as the default trimming characters in string utility types.
|
|
95
|
-
*
|
|
96
|
-
* @example
|
|
97
|
-
* type W = Whitespace;
|
|
98
|
-
* // ➔ " " | "\t" | "\r" | "\n"
|
|
99
|
-
*/
|
|
100
|
-
type Whitespace=" "|"\t"|"\r"|"\n";
|
|
101
|
-
/** **Helper Internal.** */
|
|
102
|
-
type SafeKeyTrimming<T>=Exclude<T,symbol>;
|
|
103
|
-
/** --------------------------------------------------
|
|
104
|
-
* * ***TrimLeft.***
|
|
105
|
-
* --------------------------------------------------
|
|
106
|
-
* Recursively trims specified characters (default: **{@link Whitespace}**)
|
|
107
|
-
* from the **start (left)** of a string.
|
|
108
|
-
*
|
|
109
|
-
* @template Text - The string to trim.
|
|
110
|
-
* @template Chars - The characters to remove (default: `Whitespace`).
|
|
111
|
-
*
|
|
112
|
-
* @example
|
|
113
|
-
* type T1 = TrimLeft<"\n hello", " " | "\n">;
|
|
114
|
-
* // ➔ "hello"
|
|
115
|
-
*
|
|
116
|
-
* type T2 = TrimLeft<" world">;
|
|
117
|
-
* // ➔ "world"
|
|
118
|
-
*
|
|
119
|
-
* type T3 = TrimLeft<" world ">;
|
|
120
|
-
* // ➔ "world "
|
|
121
|
-
*/
|
|
122
|
-
type TrimLeft<Text extends PropertyKey,Chars extends PropertyKey=Whitespace>=Text extends`${SafeKeyTrimming<Chars>}${infer Rest}`?TrimLeft<Rest,Chars>:Text;
|
|
123
|
-
/** --------------------------------------------------
|
|
124
|
-
* * ***TrimRight.***
|
|
125
|
-
* --------------------------------------------------
|
|
126
|
-
* Recursively trims specified characters (default: **{@link Whitespace}**)
|
|
127
|
-
* from the **end (right)** of a string.
|
|
128
|
-
*
|
|
129
|
-
* @template Text - The string to trim.
|
|
130
|
-
* @template Chars - The characters to remove (default: `Whitespace`).
|
|
131
|
-
*
|
|
132
|
-
* @example
|
|
133
|
-
* type T1 = TrimRight<"hello \t", " " | "\t">;
|
|
134
|
-
* // ➔ "hello"
|
|
135
|
-
*
|
|
136
|
-
* type T2 = TrimRight<"world ">;
|
|
137
|
-
* // ➔ "world"
|
|
138
|
-
*
|
|
139
|
-
* type T2 = TrimRight<" world ">;
|
|
140
|
-
* // ➔ " world"
|
|
141
|
-
*/
|
|
142
|
-
type TrimRight<Text extends PropertyKey,Chars extends PropertyKey=Whitespace>=Text extends`${infer Rest}${SafeKeyTrimming<Chars>}`?TrimRight<Rest,Chars>:Text;
|
|
143
|
-
/** --------------------------------------------------
|
|
144
|
-
* * ***Trim.***
|
|
145
|
-
* --------------------------------------------------
|
|
146
|
-
* Trims specified characters (default: **{@link Whitespace}**)
|
|
147
|
-
* from **both the start and end** of a string.
|
|
148
|
-
*
|
|
149
|
-
* @template Text - The string to trim.
|
|
150
|
-
* @template Chars - The characters to remove (default: `Whitespace`).
|
|
151
|
-
*
|
|
152
|
-
* @example
|
|
153
|
-
* type T1 = Trim<" hello ", " ">;
|
|
154
|
-
* // ➔ "hello"
|
|
155
|
-
*
|
|
156
|
-
* type T2 = Trim<"\n world \t">;
|
|
157
|
-
* // ➔ "world"
|
|
158
|
-
*/
|
|
159
|
-
type Trim<Text extends PropertyKey,Chars extends PropertyKey=Whitespace>=TrimRight<TrimLeft<Text,Chars>,Chars>;
|
|
160
|
-
/** -------------------------------------------------------
|
|
161
|
-
* * ***TrimsLower***
|
|
162
|
-
* -------------------------------------------------------
|
|
163
|
-
* Trims leading & trailing whitespace from a string and
|
|
164
|
-
* converts it to **lowercase**.
|
|
165
|
-
*
|
|
166
|
-
* Utilizes **{@link Trim}** to remove whitespace and **{@link Lowercase}** to convert the string to lowercase.
|
|
167
|
-
*
|
|
168
|
-
* @template S - The input string to transform.
|
|
169
|
-
*
|
|
170
|
-
* @example
|
|
171
|
-
* ```ts
|
|
172
|
-
* type T1 = TrimsLower<" HeLLo \n">;
|
|
173
|
-
* // ➔ "hello"
|
|
174
|
-
*
|
|
175
|
-
* type T2 = TrimsLower<" WoRLD ">;
|
|
176
|
-
* // ➔ "world"
|
|
177
|
-
* ```
|
|
178
|
-
*/
|
|
179
|
-
type TrimsLower<S extends string>=Lowercase<Trim<S>>;
|
|
180
|
-
/** -------------------------------------------------------
|
|
181
|
-
* * ***TrimsUpper***
|
|
182
|
-
* -------------------------------------------------------
|
|
183
|
-
* Trims leading & trailing whitespace from a string and
|
|
184
|
-
* converts it to **uppercase**.
|
|
185
|
-
*
|
|
186
|
-
* Utilizes **{@link Trim}** to remove whitespace and **{@link Uppercase}** to convert the string to uppercase.
|
|
187
|
-
*
|
|
188
|
-
* @template S - The input string to transform.
|
|
189
|
-
*
|
|
190
|
-
* @example
|
|
191
|
-
* ```ts
|
|
192
|
-
* type T1 = TrimsUpper<" HeLLo \n">;
|
|
193
|
-
* // ➔ "HELLO"
|
|
194
|
-
*
|
|
195
|
-
* type T2 = TrimsUpper<" WoRLD ">;
|
|
196
|
-
* // ➔ "WORLD"
|
|
197
|
-
* ```
|
|
198
|
-
*/
|
|
199
|
-
type TrimsUpper<S extends string>=Uppercase<Trim<S>>;
|
|
200
|
-
/** -------------------------------------------------------
|
|
201
|
-
* * ***AnyString.***
|
|
202
|
-
* -------------------------------------------------------
|
|
203
|
-
*
|
|
204
|
-
* A utility type that represents **any string value** while
|
|
205
|
-
* preventing unwanted widening of string literals to `string`.
|
|
206
|
-
*
|
|
207
|
-
* 🔹 This is achieved by intersecting `string` with `{}`,
|
|
208
|
-
* ensuring that the type remains assignable to `string`
|
|
209
|
-
* but is treated as a unique type in generic constraints.
|
|
210
|
-
*
|
|
211
|
-
* 📌 Useful in scenarios where:
|
|
212
|
-
* - You want to accept **any string**, but still preserve
|
|
213
|
-
* literal types in inference.
|
|
214
|
-
* - You need stricter typing than just `string`.
|
|
215
|
-
*
|
|
216
|
-
* @example
|
|
217
|
-
* ```ts
|
|
218
|
-
* declare function acceptsAnyString<T extends AnyString>(value: T): T;
|
|
219
|
-
*
|
|
220
|
-
* // Preserves literal
|
|
221
|
-
* const a = acceptsAnyString("hello");
|
|
222
|
-
* // ➔ "hello"
|
|
223
|
-
*
|
|
224
|
-
* // Also allows generic string
|
|
225
|
-
* const b = acceptsAnyString(String("world"));
|
|
226
|
-
* // ➔ string
|
|
227
|
-
* ```
|
|
228
|
-
*/
|
|
229
|
-
type AnyString={}& string;
|
|
230
|
-
/** -------------------------------------------------------
|
|
231
|
-
* * ***EmptyString.***
|
|
232
|
-
* -------------------------------------------------------
|
|
233
|
-
* Returns the type `T` only if it is the empty string `""`.
|
|
234
|
-
* Optionally trims whitespace before checking.
|
|
235
|
-
*
|
|
236
|
-
* Behavior:
|
|
237
|
-
* - If `WithTrim` is `true` (default), trims `T` before checking.
|
|
238
|
-
* - If `T` is the general `string` type, returns `never`.
|
|
239
|
-
* - If `T` is empty (after optional trimming), returns `T` or `Trim<T>`.
|
|
240
|
-
*
|
|
241
|
-
* @template T - The string type to check.
|
|
242
|
-
* @template WithTrim - Whether to trim whitespace before checking (default `true`).
|
|
243
|
-
*
|
|
244
|
-
* @example
|
|
245
|
-
* ```ts
|
|
246
|
-
* // Basic empty string
|
|
247
|
-
* type Case1 = EmptyString<"">;
|
|
248
|
-
* // ➔ ""
|
|
249
|
-
*
|
|
250
|
-
* // Non-empty string
|
|
251
|
-
* type Case2 = EmptyString<"abc">;
|
|
252
|
-
* // ➔ never
|
|
253
|
-
*
|
|
254
|
-
* // General string type
|
|
255
|
-
* type Case3 = EmptyString<string>;
|
|
256
|
-
* // ➔ never
|
|
257
|
-
*
|
|
258
|
-
* // With leading/trailing whitespace
|
|
259
|
-
* type Case4 = EmptyString<" ", true>;
|
|
260
|
-
* // ➔ "" (trimmed)
|
|
261
|
-
* type Case5 = EmptyString<" ", false>;
|
|
262
|
-
* // ➔ never (not trimmed)
|
|
263
|
-
* ```
|
|
264
|
-
*/
|
|
265
|
-
type EmptyString<T extends string,WithTrim extends boolean=true>=""extends(WithTrim extends true?Trim<T>:T)?string extends(WithTrim extends true?Trim<T>:T)?never:WithTrim extends true?Trim<T>:T:never;
|
|
266
|
-
/** -------------------------------------------------------
|
|
267
|
-
* * ***NonEmptyString.***
|
|
268
|
-
* -------------------------------------------------------
|
|
269
|
-
* Returns the type `T` only if it is a non-empty string.
|
|
270
|
-
* Optionally trims whitespace before checking.
|
|
271
|
-
*
|
|
272
|
-
* Behavior:
|
|
273
|
-
* - If `WithTrim` is `true` (default), trims `T` before checking.
|
|
274
|
-
* - If `T` is the general `string` type, returns `string`.
|
|
275
|
-
* - If `T` is empty (after optional trimming), returns `never`.
|
|
276
|
-
*
|
|
277
|
-
* @template T - The string type to check.
|
|
278
|
-
* @template WithTrim - Whether to trim whitespace before checking (default `true`).
|
|
279
|
-
*
|
|
280
|
-
* @example
|
|
281
|
-
* ```ts
|
|
282
|
-
* // Non-empty string
|
|
283
|
-
* type Case1 = NonEmptyString<"abc">; // ➔ "abc"
|
|
284
|
-
*
|
|
285
|
-
* // Empty string
|
|
286
|
-
* type Case2 = NonEmptyString<"">; // ➔ never
|
|
287
|
-
*
|
|
288
|
-
* // General string type
|
|
289
|
-
* type Case3 = NonEmptyString<string>; // ➔ string
|
|
290
|
-
*
|
|
291
|
-
* // String with whitespace
|
|
292
|
-
* type Case4 = NonEmptyString<" ", true>; // ➔ never (trimmed to empty)
|
|
293
|
-
* type Case5 = NonEmptyString<" ", false>; // ➔ " " (not trimmed)
|
|
294
|
-
* ```
|
|
295
|
-
*/
|
|
296
|
-
type NonEmptyString<T extends string,WithTrim extends boolean=true>=string extends T?string:If<IsNever<EmptyString<T,WithTrim>>,WithTrim extends true?Trim<T>:T,never>;
|
|
297
|
-
/** -------------------------------------------------------
|
|
298
|
-
* * ***IsEmptyString.***
|
|
299
|
-
* -------------------------------------------------------
|
|
300
|
-
* Returns `true` if `T` is exactly the empty string `""`.
|
|
301
|
-
* Optionally trims whitespace before checking.
|
|
302
|
-
*
|
|
303
|
-
* Behavior:
|
|
304
|
-
* - If `WithTrim` is `true` (default), trims `T` before checking.
|
|
305
|
-
* - If `T` is empty after optional trimming, returns `true`.
|
|
306
|
-
* - Otherwise, returns `false`.
|
|
307
|
-
*
|
|
308
|
-
* @template T - The string type to check.
|
|
309
|
-
* @template WithTrim - Whether to trim whitespace before checking (default `true`).
|
|
310
|
-
*
|
|
311
|
-
* @example
|
|
312
|
-
* ```ts
|
|
313
|
-
* type Case1 = IsEmptyString<"">;
|
|
314
|
-
* // ➔ true
|
|
315
|
-
* type Case2 = IsEmptyString<"abc">;
|
|
316
|
-
* // ➔ false
|
|
317
|
-
* type Case3 = IsEmptyString<" ", true>;
|
|
318
|
-
* // ➔ true (trimmed)
|
|
319
|
-
* type Case4 = IsEmptyString<" ", false>;
|
|
320
|
-
* // ➔ false (not trimmed)
|
|
321
|
-
* ```
|
|
322
|
-
*/
|
|
323
|
-
type IsEmptyString<T extends string,WithTrim extends boolean=true>=IfNot<IsNever<EmptyString<T,WithTrim>>>;
|
|
324
|
-
/** -------------------------------------------------------
|
|
325
|
-
* * ***IsNonEmptyString.***
|
|
326
|
-
* -------------------------------------------------------
|
|
327
|
-
* Returns `true` if `T` is a non-empty string.
|
|
328
|
-
* Optionally trims whitespace before checking.
|
|
329
|
-
*
|
|
330
|
-
* Behavior:
|
|
331
|
-
* - If `WithTrim` is `true` (default), trims `T` before checking.
|
|
332
|
-
* - Returns `true` if `T` is non-empty after optional trimming.
|
|
333
|
-
* - Returns `false` if `T` is empty (after trimming if `WithTrim=true`).
|
|
334
|
-
*
|
|
335
|
-
* @template T - The string type to check.
|
|
336
|
-
* @template WithTrim - Whether to trim whitespace before checking (default `true`).
|
|
337
|
-
*
|
|
338
|
-
* @example
|
|
339
|
-
* ```ts
|
|
340
|
-
* type Case1 = IsNonEmptyString<"abc">;
|
|
341
|
-
* // ➔ true
|
|
342
|
-
* type Case2 = IsNonEmptyString<"">;
|
|
343
|
-
* // ➔ false
|
|
344
|
-
* type Case3 = IsNonEmptyString<" ", true>;
|
|
345
|
-
* // ➔ false (trimmed)
|
|
346
|
-
* type Case4 = IsNonEmptyString<" ", false>;
|
|
347
|
-
* // ➔ true (not trimmed)
|
|
348
|
-
* ```
|
|
349
|
-
*/
|
|
350
|
-
type IsNonEmptyString<T extends string,WithTrim extends boolean=true>=IfNot<IsNever<NonEmptyString<T,WithTrim>>>;
|
|
351
|
-
/** -------------------------------------------------------
|
|
352
|
-
* * ***IfEmptyString.***
|
|
353
|
-
* -------------------------------------------------------
|
|
354
|
-
* Conditional type: returns `IfTrue` if `T` is an empty string `""`,
|
|
355
|
-
* otherwise returns `IfFalse`. Optionally trims whitespace before checking.
|
|
356
|
-
*
|
|
357
|
-
* @template T - The string type to check.
|
|
358
|
-
* @template IfTrue - Type returned if `T` is empty (default `true`).
|
|
359
|
-
* @template IfFalse - Type returned if `T` is not empty (default `false`).
|
|
360
|
-
* @template WithTrim - Whether to trim whitespace before checking (default `true`).
|
|
361
|
-
*
|
|
362
|
-
* @example
|
|
363
|
-
* ```ts
|
|
364
|
-
* type Case1 = IfEmptyString<"">;
|
|
365
|
-
* // ➔ true
|
|
366
|
-
* type Case2 = IfEmptyString<"abc">;
|
|
367
|
-
* // ➔ false
|
|
368
|
-
* type Case3 = IfEmptyString<"", "yes", "no">;
|
|
369
|
-
* // ➔ "yes"
|
|
370
|
-
* type Case4 = IfEmptyString<"abc", "yes", "no">;
|
|
371
|
-
* // ➔ "no"
|
|
372
|
-
* type Case5 = IfEmptyString<" ", "yes", "no", true>;
|
|
373
|
-
* // ➔ "yes" (trimmed)
|
|
374
|
-
* type Case6 = IfEmptyString<" ", "yes", "no", false>;
|
|
375
|
-
* // ➔ "no" (not trimmed)
|
|
376
|
-
* ```
|
|
377
|
-
*/
|
|
378
|
-
type IfEmptyString<T extends string,IfTrue=true,IfFalse=false,WithTrim extends boolean=true>=IfNot<IsNever<EmptyString<T,WithTrim>>,IfTrue,IfFalse>;
|
|
379
|
-
/** -------------------------------------------------------
|
|
380
|
-
* * ***IfNonEmptyString.***
|
|
381
|
-
* -------------------------------------------------------
|
|
382
|
-
* Conditional type: returns `IfTrue` if `T` is a non-empty string,
|
|
383
|
-
* otherwise returns `IfFalse`. Optionally trims whitespace before checking.
|
|
384
|
-
*
|
|
385
|
-
* @template T - The string type to check.
|
|
386
|
-
* @template IfTrue - Type returned if `T` is non-empty (default `true`).
|
|
387
|
-
* @template IfFalse - Type returned if `T` is empty (default `false`).
|
|
388
|
-
* @template WithTrim - Whether to trim whitespace before checking (default `true`).
|
|
389
|
-
*
|
|
390
|
-
* @example
|
|
391
|
-
* ```ts
|
|
392
|
-
* type Case1 = IfNonEmptyString<"abc">;
|
|
393
|
-
* // ➔ true
|
|
394
|
-
* type Case2 = IfNonEmptyString<"">;
|
|
395
|
-
* // ➔ false
|
|
396
|
-
* type Case3 = IfNonEmptyString<"abc", "yes", "no">;
|
|
397
|
-
* // ➔ "yes"
|
|
398
|
-
* type Case4 = IfNonEmptyString<"", "yes", "no">;
|
|
399
|
-
* // ➔ "no"
|
|
400
|
-
* type Case5 = IfNonEmptyString<" ", "yes", "no", true>;
|
|
401
|
-
* // ➔ "no" (trimmed)
|
|
402
|
-
* type Case6 = IfNonEmptyString<" ", "yes", "no", false>;
|
|
403
|
-
* // ➔ "yes" (not trimmed)
|
|
404
|
-
* ```
|
|
405
|
-
*/
|
|
406
|
-
type IfNonEmptyString<T extends string,IfTrue=true,IfFalse=false,WithTrim extends boolean=true>=IfNot<IsNever<NonEmptyString<T,WithTrim>>,IfTrue,IfFalse>;
|
|
407
|
-
/** -------------------------------------------------------
|
|
408
58
|
* * ***Or.***
|
|
409
59
|
* -------------------------------------------------------
|
|
410
60
|
*
|
|
@@ -1554,4 +1204,4 @@ type IsMutableArray<T>=And<IsArray<T>,NotExtends<Readonly<T>,T>>;
|
|
|
1554
1204
|
* type Case2 = IsReadonlyArray<[]>;
|
|
1555
1205
|
* // ➔ false
|
|
1556
1206
|
*/
|
|
1557
|
-
type IsReadonlyArray<T>=And<IsArray<T>,NotExtends<T,Mutable<T>>>;export type{
|
|
1207
|
+
type IsReadonlyArray<T>=And<IsArray<T>,NotExtends<T,Mutable<T>>>;export type{PositiveInteger as $,And as A,IfPositiveFloat as B,CharAt as C,IfPositiveInteger as D,Even as E,Float as F,Integer as G,IsNegativeFloat as H,IsStringLiteral as I,IsOdd as J,IsPositiveFloat as K,IsPositiveInteger as L,Mutable as M,Negate as N,Or as O,ParseNumber as P,IsScientificNumber as Q,Repeat as R,Split as S,Negative as T,NegativeFloat as U,NegativeInteger as V,Odd as W,OddDigit as X,ParseScientificNumber as Y,Positive as Z,PositiveFloat as _,IsNegative as a,IfUnknown as a0,UnknownifyProperties as a1,UnknownifyPropertiesOptions as a2,Abs as b,IsFloat as c,IsUnknown as d,IsNegativeInteger as e,OrArr as f,AndArr as g,IsInteger as h,Push as i,IfNegative as j,IsPositive as k,IsEven as l,IsReadonlyArray as m,IfPositive as n,IsArray as o,IsMutableArray as p,MutableExcept as q,MutableOnly as r,MutableOptions as s,EvenDigit as t,IfEven as u,IfFloat as v,IfInteger as w,IfNegativeFloat as x,IfNegativeInteger as y,IfOdd as z};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import{N as NonPlainObject}from'./type-data-DDs-u2kq.js';
|
|
1
|
+
import{N as NonPlainObject}from'./type-data-DDs-u2kq.js';
|
|
2
|
+
/** Types for **{@link getPreciseType}**. */
|
|
3
|
+
type GetPreciseTypeOptions={
|
|
2
4
|
/** -------------------------------------------------------
|
|
3
5
|
* * ***Specifies the format in which the returned string type should be transformed.***
|
|
4
6
|
* -------------------------------------------------------
|
|
@@ -30,31 +32,28 @@ import{N as NonPlainObject}from'./type-data-DDs-u2kq.js';type GetPreciseTypeOpti
|
|
|
30
32
|
*/
|
|
31
33
|
formatCase?:"toPascalCaseSpace"|"toPascalCase"|"toCamelCase"|"toKebabCase"|"toSnakeCase"|"toDotCase"|"slugify"|"toLowerCase";};
|
|
32
34
|
/** ----------------------------------------------------------
|
|
33
|
-
* * ***
|
|
35
|
+
* * ***Utility-Predicate: `getPreciseType`.***
|
|
34
36
|
* ----------------------------------------------------------
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* formatted according to the `options.formatCase` setting.
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* -
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* - Falls back to constructor name or `Object.prototype.toString` tag
|
|
48
|
-
*
|
|
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
49
|
* @param {*} value - The value to detect the precise type of
|
|
50
|
-
* @param {
|
|
51
|
-
* @param {"
|
|
52
|
-
*
|
|
53
|
-
* - ⚠️ Special string literals in `SPECIAL_CASES`
|
|
54
|
-
*
|
|
55
|
-
*
|
|
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
56
|
* @returns {string} The normalized and formatted type string
|
|
57
|
-
*
|
|
58
57
|
* @example
|
|
59
58
|
* getPreciseType(123); // ➔ "number"
|
|
60
59
|
* getPreciseType(null); // ➔ "null"
|
|
@@ -64,32 +63,30 @@ formatCase?:"toPascalCaseSpace"|"toPascalCase"|"toCamelCase"|"toKebabCase"|"toSn
|
|
|
64
63
|
* // ➔ "generatorFunction"
|
|
65
64
|
* getPreciseType(async function () {}, { formatCase: "toPascalCaseSpace" });
|
|
66
65
|
* // ➔ "Async Function"
|
|
67
|
-
* getPreciseType(
|
|
66
|
+
* getPreciseType(NaN, { formatCase: "toKebabCase" });
|
|
68
67
|
* // ➔ "NaN" (SPECIAL_CASES remain)
|
|
69
68
|
*/
|
|
70
69
|
declare const getPreciseType:(value:unknown,options?:GetPreciseTypeOptions)=>string;type IsNumberOptions={
|
|
71
|
-
/**
|
|
72
|
-
*
|
|
70
|
+
/** If set to `true`, `NaN` will be considered a valid number, defaultValue: `false`.
|
|
71
|
+
*
|
|
73
72
|
* @default false
|
|
74
73
|
*/
|
|
75
74
|
includeNaN?:boolean;};
|
|
76
75
|
/** ---------------------------------------------------------
|
|
77
76
|
* * ***Type guard: `isNumber`.***
|
|
78
77
|
* ----------------------------------------------------------
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
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.
|
|
88
86
|
* @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,
|
|
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`.
|
|
91
89
|
* @returns {boolean} Returns `true` if the value is a number (and depending on `includeNaN`, `NaN` is included or excluded).
|
|
92
|
-
*
|
|
93
90
|
* @example
|
|
94
91
|
* isNumber(42);
|
|
95
92
|
* // ➔ true
|
|
@@ -108,18 +105,14 @@ declare const isNumber:(value:unknown,options?:IsNumberOptions)=>value is number
|
|
|
108
105
|
/** ----------------------------------------------------------
|
|
109
106
|
* * ***Utility type: `IsPlainObjectResult`.***
|
|
110
107
|
* ----------------------------------------------------------
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
* -
|
|
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
|
-
*
|
|
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`.
|
|
123
116
|
* @template T - The input type to be asserted as a plain object.
|
|
124
117
|
* @example
|
|
125
118
|
* ```ts
|
|
@@ -137,18 +130,14 @@ type IsPlainObjectResult<T>=unknown extends T?Record<PropertyKey,unknown>& T:T e
|
|
|
137
130
|
/** ----------------------------------------------------------
|
|
138
131
|
* * ***Type guard: `isPlainObject`.***
|
|
139
132
|
* ----------------------------------------------------------
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
* -
|
|
145
|
-
* - Has a `[[Prototype]]` of `null` (e.g. `Object.create(null)`).
|
|
146
|
-
* ----------------------------------------------------------
|
|
147
|
-
* - ✅ Returns `true` for:
|
|
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:**
|
|
148
138
|
* - Empty object literals: `{}`
|
|
149
139
|
* - Objects with null prototype: `Object.create(null)`
|
|
150
|
-
*
|
|
151
|
-
* - ❌ Returns `false` for:
|
|
140
|
+
* - **❌ Returns `false` for:**
|
|
152
141
|
* - Arrays (`[]`, `new Array()`)
|
|
153
142
|
* - Functions (regular, arrow, or class constructors)
|
|
154
143
|
* - Built-in objects: `Date`, `RegExp`, `Error`, `Map`, `Set`, `WeakMap`, `WeakSet`
|
|
@@ -156,11 +145,9 @@ type IsPlainObjectResult<T>=unknown extends T?Record<PropertyKey,unknown>& T:T e
|
|
|
156
145
|
* - `null` or `undefined`
|
|
157
146
|
* - Symbols
|
|
158
147
|
* - Class instances
|
|
159
|
-
*
|
|
160
148
|
* @template T - The type of the value being checked.
|
|
161
149
|
* @param {*} value - The value to check.
|
|
162
150
|
* @returns {boolean} Return `true` if `value` is a `plain-object`, otherwise `false`.
|
|
163
|
-
*
|
|
164
151
|
* @example
|
|
165
152
|
* isPlainObject({});
|
|
166
153
|
* // ➔ true
|
package/dist/next/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkO5VXBNUQ_cjs=require('../chunk-O5VXBNUQ.cjs'),chunk445TAVT4_cjs=require('../chunk-445TAVT4.cjs'),chunk6Q4I2RPC_cjs=require('../chunk-6Q4I2RPC.cjs'),chunkDYRDBYPF_cjs=require('../chunk-DYRDBYPF.cjs');require('../chunk-PUQXRLZH.cjs');var chunkO7SJR4CY_cjs=require('../chunk-O7SJR4CY.cjs');require('../chunk-7YWAQOA4.cjs');var chunkLVUSFXQS_cjs=require('../chunk-LVUSFXQS.cjs');function N(e,t){if(!chunkLVUSFXQS_cjs.g(e)||chunk6Q4I2RPC_cjs.a(e))throw new TypeError(`\u274C 'generateRoute' Failed:
|
|
2
2
|
- Invalid 'route' value.
|
|
3
|
-
- Must be of type \`string\` and non-empty string, but received: "${
|
|
4
|
-
- Missing or invalid parameters \`${o}\` for route: "${e}", must be of type \`${o}\` mapping parameters.`}),
|
|
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(!
|
|
3
|
+
- Must be of type \`string\` and non-empty string, but received: "${chunkLVUSFXQS_cjs.E(e)}": \`${chunkO7SJR4CY_cjs.c(e)}\`.`);if(!/[\\[\]]/.test(e))return e;if(chunkLVUSFXQS_cjs.j(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.`}),chunkLVUSFXQS_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(!chunkLVUSFXQS_cjs.g(i)){r.push(`- Invalid parameter: "${o}" must be of type \`string\`, but received: \`${chunkLVUSFXQS_cjs.E(i)}\`.`);continue}if(chunk6Q4I2RPC_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 m=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: (${m.join(", ")}).`);}}if(chunkLVUSFXQS_cjs.r(r))throw new Error(`\u274C 'generateRoute' Failed cause in route "${e}":
|
|
6
6
|
${r.join(`
|
|
7
|
-
`)}.`);return e.replace(/\[(\w+)\]/g,(o,i)=>(
|
|
8
|
-
exports.createBeApiUrl=
|
|
7
|
+
`)}.`);return e.replace(/\[(\w+)\]/g,(o,i)=>(chunkLVUSFXQS_cjs.p(t[i])?t[i]:"").trim().replace(/^\/+|\/+$/g,"")).replace(/\/+/g,"/")}var q=(e,t={})=>{try{let p=function(m,a){return `${m.replace(/\/+$/,"")}/${a.replace(/^\/+/,"")}`};var n=p;chunkDYRDBYPF_cjs.a(chunkLVUSFXQS_cjs.c(e)?"":e,{message({currentType:m,validType:a}){return `First parameter (\`pathname\`) must be of type \`${a}\`, but received: \`${m}\`.`}}),chunkLVUSFXQS_cjs.f(t)||(t={});let{prefix:r="/api",withOrigin:s=!0}=t;if(!chunkLVUSFXQS_cjs.m(r)&&!chunkLVUSFXQS_cjs.g(r))throw new TypeError(`Parameter \`prefix\` property of the \`options\` (second parameter) must be of type \`string\`, but received: \`${chunkLVUSFXQS_cjs.E(r)}\`.`);chunkLVUSFXQS_cjs.G(s,{message:({currentType:m,validType:a})=>`Parameter \`withOrigin\` property of the \`options\` (second parameter) must be of type \`${a}\`, but received: \`${m}\`.`}),e=chunkO5VXBNUQ_cjs.c(e),r=chunkO5VXBNUQ_cjs.c(r);let o=r.endsWith("/")?r:r+"/";(e===r||e===r+"/"||e.startsWith(o))&&(e=e.slice(r.length),e=chunkO5VXBNUQ_cjs.c(e));let i=b({suffix:r});return p(s?i:new URL(i).pathname,e).replace(/\/+$/,"")}catch(r){throw chunkLVUSFXQS_cjs.C(r)?r:new Error("Failed to generate backend API URL in `createBeApiUrl()`, Error: "+new Error(String(r)).message.trim())}};var b=({suffix:e="/"}={})=>{chunkDYRDBYPF_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=chunk445TAVT4_cjs.c(t);let s=new URL(t);!!!s.port&&process.env.NEXT_PUBLIC_PORT_BE&&(t=s.origin+chunkO5VXBNUQ_cjs.d(process.env.NEXT_PUBLIC_PORT_BE,{prefixColon:!0}));}else t="http://localhost"+chunkO5VXBNUQ_cjs.d(process.env.NEXT_PUBLIC_PORT_BE||"8000",{prefixColon:!0});e=chunk445TAVT4_cjs.c(e).length?chunk445TAVT4_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 te=()=>{try{let e=process.env.NEXT_PUBLIC_BASE_URL?.trim(),t=process.env.NEXT_PUBLIC_PORT_FE?.trim(),n=e||"http://localhost";n=chunk445TAVT4_cjs.c(n).replace(/\/+$/,"");let r=/:\/\/[^/]+:\d+/.test(n);!r&&t?n+=chunkO5VXBNUQ_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=q;exports.generateRoute=N;exports.getBaseUrl=te;exports.getBeApiUrl=b;
|