@rzl-zone/utils-js 3.9.1 → 3.11.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.
- package/README.md +111 -73
- package/dist/assertions/index.cjs +11 -11
- package/dist/assertions/index.d.ts +487 -215
- package/dist/assertions/index.js +5 -5
- package/dist/{chunk-SN5HAK3Y.js → chunk-22V4WP3H.js} +4 -4
- package/dist/{chunk-EJV5AF4L.js → chunk-2XSZ2ANI.js} +2 -2
- package/dist/{chunk-OSSFLQDD.js → chunk-3T6VSWYX.js} +2 -2
- package/dist/{chunk-3LE6NX57.js → chunk-5WIEDF2J.js} +4 -4
- package/dist/{chunk-WLEZ2KSG.cjs → chunk-6EDFZJZ5.cjs} +126 -126
- package/dist/{chunk-GHU356XQ.js → chunk-6LXWT2I5.js} +3 -3
- package/dist/{chunk-GKDSBOYE.js → chunk-6YGBRENU.js} +3 -3
- package/dist/{chunk-NAOVH4OH.cjs → chunk-7FGNVDEV.cjs} +7 -7
- package/dist/{chunk-X6ULJZ3X.js → chunk-AXDYWO67.js} +2 -2
- package/dist/{chunk-UV5BKAYW.cjs → chunk-B6PMNZ4M.cjs} +7 -7
- package/dist/chunk-BAV5T2E3.cjs +1 -1
- package/dist/{chunk-YHFRCVTN.js → chunk-BLF7SD66.js} +3 -3
- package/dist/{chunk-QZI5PVCI.cjs → chunk-BMZZXZJ2.cjs} +4 -4
- package/dist/{chunk-DXPM4NOU.js → chunk-BOYP3ARU.js} +4 -4
- package/dist/{chunk-UXT4XSUK.js → chunk-BPYW5YL7.js} +2 -2
- package/dist/{chunk-QGTFQ7RO.cjs → chunk-C2PV3VWC.cjs} +6 -6
- package/dist/{chunk-MZ3T6L7Z.js → chunk-CCJ2MSN7.js} +2 -2
- package/dist/{chunk-H44QVAZL.cjs → chunk-DAPAK2W3.cjs} +31 -31
- package/dist/{chunk-OYFUBKEG.cjs → chunk-DLS3G6WQ.cjs} +4 -4
- package/dist/{chunk-MS2KSKD7.js → chunk-DNMCR5JH.js} +9 -9
- package/dist/chunk-DVMHRLKP.cjs +1 -1
- package/dist/{chunk-IX6PF5ZP.cjs → chunk-EBYFYZW4.cjs} +4 -4
- package/dist/{chunk-5Y6JL47L.js → chunk-ENMRZ4BE.js} +3 -3
- package/dist/{chunk-7EIFPHV3.js → chunk-FJ4BQFVO.js} +8 -8
- package/dist/{chunk-TJ5OY6MC.cjs → chunk-GIKL4PUF.cjs} +10 -10
- package/dist/{chunk-M5QB2GM5.js → chunk-GOFINGT6.js} +2 -2
- package/dist/{chunk-J6VLFVIL.js → chunk-GXKQ3LHF.js} +3 -3
- package/dist/{chunk-5KDVIEVO.js → chunk-HNBRGN4R.js} +2 -2
- package/dist/{chunk-OCTHWEZK.cjs → chunk-HYN6FC5A.cjs} +34 -34
- package/dist/{chunk-MBFVTGYS.js → chunk-IZGVBYFN.js} +4 -4
- package/dist/{chunk-QXTJVDWE.js → chunk-JIE447J5.js} +3 -3
- package/dist/{chunk-UFYMRRJH.cjs → chunk-JXEIJM5M.cjs} +61 -61
- package/dist/{chunk-WB3FT62A.js → chunk-K47GZDBH.js} +3 -3
- package/dist/{chunk-KUVRZ2JW.cjs → chunk-K5536YHG.cjs} +50 -50
- package/dist/chunk-KHO2SBNA.cjs +1 -1
- package/dist/{chunk-NJ24M6ZH.cjs → chunk-KXJ7X325.cjs} +37 -37
- package/dist/chunk-L5RDAVVH.js +1 -1
- package/dist/{chunk-SRWL4YCP.js → chunk-LJHPTLWB.js} +7 -7
- package/dist/{chunk-6AMDHVS2.cjs → chunk-M7ELWZXM.cjs} +9 -9
- package/dist/chunk-MSUW5VHZ.js +1590 -0
- package/dist/{chunk-2XGQQZ6A.cjs → chunk-MUHRPRR7.cjs} +3 -3
- package/dist/{chunk-XYWC4EQ3.cjs → chunk-MV3TSQSH.cjs} +71 -71
- package/dist/{chunk-VCYXNIZ2.cjs → chunk-NLZLXWAU.cjs} +9 -9
- package/dist/{chunk-76ATVDCR.cjs → chunk-NVRZPF5M.cjs} +3 -3
- package/dist/chunk-ONZFBJVW.js +1 -1
- package/dist/{chunk-62FS7WMB.cjs → chunk-PGNL7JXO.cjs} +31 -31
- package/dist/{chunk-JI57K7D4.cjs → chunk-Q4GEQS7X.cjs} +161 -161
- package/dist/chunk-QNKGP5DY.js +1 -1
- package/dist/{chunk-ZTHJQJ5F.cjs → chunk-QYI2VJLS.cjs} +9 -9
- package/dist/{chunk-C7GC2PFX.js → chunk-RBWZII5I.js} +3 -3
- package/dist/{chunk-MMRHKYT6.cjs → chunk-RMP7VMPB.cjs} +12 -12
- package/dist/{chunk-TXOVQZPU.js → chunk-RZOGBYIS.js} +2 -2
- package/dist/{chunk-ALRISPTL.cjs → chunk-SU3UELUB.cjs} +3 -3
- package/dist/chunk-SYHPSOUU.cjs +1626 -0
- package/dist/{chunk-R2DR7SPJ.js → chunk-SZUNAEMR.js} +6 -6
- package/dist/{chunk-YVRUY4EW.cjs → chunk-TER22LO4.cjs} +8 -8
- package/dist/{chunk-WRGN6UBK.js → chunk-TJHGRQ4P.js} +2 -2
- package/dist/{chunk-I33PB44Q.cjs → chunk-U23I7JPB.cjs} +15 -15
- package/dist/{chunk-VBSLIIDB.js → chunk-U7HHN47R.js} +10 -10
- package/dist/chunk-UDA26MCU.cjs +1 -1
- package/dist/{chunk-44X74C26.js → chunk-UIAWUZ4H.js} +4 -4
- package/dist/{chunk-5O66AUEC.js → chunk-ULQPCIA2.js} +2 -2
- package/dist/chunk-VJDDGRIK.cjs +1 -1
- package/dist/{chunk-6WVOUVWD.js → chunk-WETQI6HM.js} +9 -9
- package/dist/{chunk-FWWPEL7J.cjs → chunk-WLOQQFDS.cjs} +3 -3
- package/dist/chunk-WVSPXFTY.js +1 -1
- package/dist/{chunk-WKM6UVMG.cjs → chunk-WXFTVXBF.cjs} +4 -4
- package/dist/{chunk-YQHJB7KR.cjs → chunk-XPVTIGU2.cjs} +26 -26
- package/dist/{chunk-PWKOFPAH.cjs → chunk-XX6RUGTM.cjs} +3 -3
- package/dist/chunk-YWHHVDT4.js +1 -1
- package/dist/{chunk-7NXFGJJE.cjs → chunk-ZPDMWDGZ.cjs} +14 -14
- package/dist/{chunk-JYOCB6OV.js → chunk-ZVWZEGQP.js} +2 -2
- package/dist/conversions/index.cjs +34 -34
- package/dist/conversions/index.d.ts +489 -333
- package/dist/conversions/index.js +15 -15
- package/dist/events/index.cjs +8 -8
- package/dist/events/index.d.ts +35 -29
- package/dist/events/index.js +4 -4
- package/dist/formatters/index.cjs +19 -19
- package/dist/formatters/index.d.ts +917 -873
- package/dist/formatters/index.js +9 -9
- package/dist/generators/index.cjs +9 -9
- package/dist/generators/index.d.ts +104 -86
- package/dist/generators/index.js +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/isPlainObject-0p3VveWr.d.ts +534 -0
- package/dist/next/index.cjs +37 -37
- package/dist/next/index.d.ts +36 -21
- package/dist/next/index.js +9 -9
- package/dist/next/server/index.cjs +4 -4
- package/dist/next/server/index.d.ts +6 -3
- package/dist/next/server/index.js +2 -2
- package/dist/operations/index.cjs +11 -11
- package/dist/operations/index.d.ts +14 -5
- package/dist/operations/index.js +8 -8
- package/dist/parsers/index.cjs +6 -6
- package/dist/parsers/index.d.ts +68 -65
- package/dist/parsers/index.js +5 -5
- package/dist/predicates/index.cjs +77 -77
- package/dist/predicates/index.d.ts +442 -258
- package/dist/predicates/index.js +14 -14
- package/dist/promises/index.cjs +6 -6
- package/dist/promises/index.d.ts +28 -16
- package/dist/promises/index.js +4 -4
- package/dist/rzl-utils.global.js +2 -2
- package/dist/strings/index.cjs +23 -23
- package/dist/strings/index.d.ts +82 -54
- package/dist/strings/index.js +7 -7
- package/dist/tailwind/index.cjs +13 -13
- package/dist/tailwind/index.d.ts +186 -169
- package/dist/tailwind/index.js +5 -5
- package/dist/urls/index.cjs +23 -23
- package/dist/urls/index.d.ts +252 -229
- package/dist/urls/index.js +16 -16
- package/package.json +3 -3
- package/dist/chunk-7C7TQC5J.cjs +0 -620
- package/dist/chunk-J4TT33ZX.js +0 -584
- package/dist/isPlainObject-BTPjv6zB.d.ts +0 -178
package/dist/next/index.cjs
CHANGED
|
@@ -2,31 +2,31 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.11.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
-
var
|
|
13
|
-
require('../chunk-
|
|
14
|
-
require('../chunk-
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
12
|
+
var chunkHYN6FC5A_cjs = require('../chunk-HYN6FC5A.cjs');
|
|
13
|
+
require('../chunk-M7ELWZXM.cjs');
|
|
14
|
+
require('../chunk-QYI2VJLS.cjs');
|
|
15
|
+
var chunkEBYFYZW4_cjs = require('../chunk-EBYFYZW4.cjs');
|
|
16
|
+
var chunkWLOQQFDS_cjs = require('../chunk-WLOQQFDS.cjs');
|
|
17
|
+
var chunkWXFTVXBF_cjs = require('../chunk-WXFTVXBF.cjs');
|
|
18
|
+
var chunkDAPAK2W3_cjs = require('../chunk-DAPAK2W3.cjs');
|
|
19
19
|
require('../chunk-UDA26MCU.cjs');
|
|
20
|
-
var
|
|
20
|
+
var chunkSYHPSOUU_cjs = require('../chunk-SYHPSOUU.cjs');
|
|
21
21
|
|
|
22
22
|
function generateRoute(route, params) {
|
|
23
|
-
if (!
|
|
23
|
+
if (!chunkSYHPSOUU_cjs.isString(route) || chunkWLOQQFDS_cjs.isEmptyString(route)) {
|
|
24
24
|
throw new TypeError(
|
|
25
25
|
`\u274C 'generateRoute' Failed:
|
|
26
26
|
- Invalid 'route' value.
|
|
27
|
-
- Must be of type \`string\` and non-empty string, but received: "${
|
|
27
|
+
- Must be of type \`string\` and non-empty string, but received: "${chunkSYHPSOUU_cjs.getPreciseType(
|
|
28
28
|
route
|
|
29
|
-
)}": \`${
|
|
29
|
+
)}": \`${chunkDAPAK2W3_cjs.safeStableStringify(route, {
|
|
30
30
|
keepUndefined: true
|
|
31
31
|
})}\`.`
|
|
32
32
|
);
|
|
@@ -34,11 +34,11 @@ function generateRoute(route, params) {
|
|
|
34
34
|
if (!/[\\[\]]/.test(route)) {
|
|
35
35
|
return route;
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
chunkSYHPSOUU_cjs.assertIsPlainObject(params, {
|
|
38
38
|
message: ({ validType }) => `\u274C 'generateRoute' Failed cause in route "${route}":
|
|
39
39
|
- Missing or invalid parameters \`${validType}\` for route: "${route}", must be of type \`${validType}\` mapping parameters.`
|
|
40
40
|
});
|
|
41
|
-
if (
|
|
41
|
+
if (chunkSYHPSOUU_cjs.isNil(params)) {
|
|
42
42
|
throw new TypeError(
|
|
43
43
|
`\u274C 'generateRoute' Failed cause in route "${route}":
|
|
44
44
|
- Missing parameters \`plain-object\` for route: "${route}".`
|
|
@@ -67,15 +67,15 @@ function generateRoute(route, params) {
|
|
|
67
67
|
const requiredKeys = Array.from(route.matchAll(/\[(\w+)\]/g)).map((m) => m[1]);
|
|
68
68
|
for (const key of requiredKeys) {
|
|
69
69
|
const value = params[key];
|
|
70
|
-
if (!
|
|
70
|
+
if (!chunkSYHPSOUU_cjs.isString(value)) {
|
|
71
71
|
errors.push(
|
|
72
|
-
`- Invalid parameter: "${key}" must be of type \`string\`, but received: \`${
|
|
72
|
+
`- Invalid parameter: "${key}" must be of type \`string\`, but received: \`${chunkSYHPSOUU_cjs.getPreciseType(
|
|
73
73
|
value
|
|
74
74
|
)}\`.`
|
|
75
75
|
);
|
|
76
76
|
continue;
|
|
77
77
|
}
|
|
78
|
-
if (
|
|
78
|
+
if (chunkWLOQQFDS_cjs.isEmptyString(value)) {
|
|
79
79
|
errors.push(`- Parameter "${key}" cannot be empty string.`);
|
|
80
80
|
continue;
|
|
81
81
|
}
|
|
@@ -100,14 +100,14 @@ function generateRoute(route, params) {
|
|
|
100
100
|
);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
if (
|
|
103
|
+
if (chunkSYHPSOUU_cjs.isNonEmptyArray(errors)) {
|
|
104
104
|
throw new Error(
|
|
105
105
|
`\u274C 'generateRoute' Failed cause in route "${route}":
|
|
106
106
|
${errors.join("\n")}.`
|
|
107
107
|
);
|
|
108
108
|
}
|
|
109
109
|
return route.replace(/\[(\w+)\]/g, (_, key) => {
|
|
110
|
-
const paramKey =
|
|
110
|
+
const paramKey = chunkSYHPSOUU_cjs.isNonEmptyString(params[key]) ? params[key] : "";
|
|
111
111
|
return paramKey.trim().replace(/^\/+|\/+$/g, "");
|
|
112
112
|
}).replace(/\/+/g, "/");
|
|
113
113
|
}
|
|
@@ -118,40 +118,40 @@ var createBeApiUrl = (pathname, options = {}) => {
|
|
|
118
118
|
return `${a.replace(/\/+$/, "")}/${b.replace(/^\/+/, "")}`;
|
|
119
119
|
};
|
|
120
120
|
var joinPath = joinPath2;
|
|
121
|
-
|
|
121
|
+
chunkWXFTVXBF_cjs.assertIsString(chunkSYHPSOUU_cjs.isNil(pathname) ? "" : pathname, {
|
|
122
122
|
message({ currentType, validType }) {
|
|
123
123
|
return `First parameter (\`pathname\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`;
|
|
124
124
|
}
|
|
125
125
|
});
|
|
126
|
-
if (!
|
|
126
|
+
if (!chunkSYHPSOUU_cjs.isPlainObject(options)) {
|
|
127
127
|
options = {};
|
|
128
128
|
}
|
|
129
129
|
let {
|
|
130
130
|
prefix = "/api",
|
|
131
131
|
withOrigin = true
|
|
132
132
|
} = options;
|
|
133
|
-
if (!
|
|
133
|
+
if (!chunkSYHPSOUU_cjs.isUndefined(prefix) && !chunkSYHPSOUU_cjs.isString(prefix)) {
|
|
134
134
|
throw new TypeError(
|
|
135
|
-
`Parameter \`prefix\` property of the \`options\` (second parameter) must be of type \`string\`, but received: \`${
|
|
135
|
+
`Parameter \`prefix\` property of the \`options\` (second parameter) must be of type \`string\`, but received: \`${chunkSYHPSOUU_cjs.getPreciseType(
|
|
136
136
|
prefix
|
|
137
137
|
)}\`.`
|
|
138
138
|
);
|
|
139
139
|
}
|
|
140
|
-
|
|
140
|
+
chunkSYHPSOUU_cjs.assertIsBoolean(withOrigin, {
|
|
141
141
|
message: ({ currentType, validType }) => `Parameter \`withOrigin\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
142
142
|
});
|
|
143
|
-
pathname =
|
|
144
|
-
prefix =
|
|
143
|
+
pathname = chunkHYN6FC5A_cjs.normalizePathname(pathname);
|
|
144
|
+
prefix = chunkHYN6FC5A_cjs.normalizePathname(prefix);
|
|
145
145
|
const normalizedPrefix = prefix.endsWith("/") ? prefix : prefix + "/";
|
|
146
146
|
if (pathname === prefix || pathname === prefix + "/" || pathname.startsWith(normalizedPrefix)) {
|
|
147
147
|
pathname = pathname.slice(prefix.length);
|
|
148
|
-
pathname =
|
|
148
|
+
pathname = chunkHYN6FC5A_cjs.normalizePathname(pathname);
|
|
149
149
|
}
|
|
150
150
|
const baseApiUrl = getBeApiUrl({ suffix: prefix });
|
|
151
151
|
const fullPath = withOrigin ? joinPath2(baseApiUrl, pathname) : joinPath2(new URL(baseApiUrl).pathname, pathname);
|
|
152
152
|
return fullPath.replace(/\/+$/, "");
|
|
153
153
|
} catch (err) {
|
|
154
|
-
if (
|
|
154
|
+
if (chunkSYHPSOUU_cjs.isError(err)) {
|
|
155
155
|
throw err;
|
|
156
156
|
} else
|
|
157
157
|
throw new Error(
|
|
@@ -161,9 +161,9 @@ var createBeApiUrl = (pathname, options = {}) => {
|
|
|
161
161
|
};
|
|
162
162
|
|
|
163
163
|
var getBeApiUrl = (options = {}) => {
|
|
164
|
-
if (!
|
|
165
|
-
let suffix =
|
|
166
|
-
|
|
164
|
+
if (!chunkSYHPSOUU_cjs.isPlainObject(options)) options = {};
|
|
165
|
+
let suffix = chunkSYHPSOUU_cjs.hasOwnProp(options, "suffix") ? options.suffix : "/";
|
|
166
|
+
chunkWXFTVXBF_cjs.assertIsString(suffix, {
|
|
167
167
|
message({ currentType, validType }) {
|
|
168
168
|
return `Parameter \`suffix\` property of the first parameter must be of type \`${validType}\`, but received: \`${currentType}\`.`;
|
|
169
169
|
}
|
|
@@ -171,20 +171,20 @@ var getBeApiUrl = (options = {}) => {
|
|
|
171
171
|
try {
|
|
172
172
|
let rawBaseUrl = process.env.NEXT_PUBLIC_BACKEND_API_URL?.trim();
|
|
173
173
|
if (rawBaseUrl) {
|
|
174
|
-
rawBaseUrl =
|
|
174
|
+
rawBaseUrl = chunkEBYFYZW4_cjs.removeSpaces(rawBaseUrl);
|
|
175
175
|
const urlObj = new URL(rawBaseUrl);
|
|
176
176
|
const hasPort = !!urlObj.port;
|
|
177
177
|
if (!hasPort && process.env.NEXT_PUBLIC_PORT_BE) {
|
|
178
|
-
rawBaseUrl = urlObj.origin +
|
|
178
|
+
rawBaseUrl = urlObj.origin + chunkHYN6FC5A_cjs.formatEnvPort(process.env.NEXT_PUBLIC_PORT_BE, {
|
|
179
179
|
prefixColon: true
|
|
180
180
|
});
|
|
181
181
|
}
|
|
182
182
|
} else {
|
|
183
|
-
rawBaseUrl = "http://localhost" +
|
|
183
|
+
rawBaseUrl = "http://localhost" + chunkHYN6FC5A_cjs.formatEnvPort(process.env.NEXT_PUBLIC_PORT_BE || "8000", {
|
|
184
184
|
prefixColon: true
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
|
-
suffix =
|
|
187
|
+
suffix = chunkEBYFYZW4_cjs.removeSpaces(suffix).length ? chunkEBYFYZW4_cjs.removeSpaces(suffix) : "/";
|
|
188
188
|
const baseApiUrl = new URL(rawBaseUrl.replace(/\/+$/, "")).origin;
|
|
189
189
|
const finalSuffix = suffix === "/" ? "/" : `${suffix.startsWith("/") ? "" : "/"}${suffix.replace(/\/+$/, "")}`;
|
|
190
190
|
return `${baseApiUrl}${finalSuffix}`;
|
|
@@ -200,10 +200,10 @@ var getBaseUrl = () => {
|
|
|
200
200
|
const baseEnv = process.env.NEXT_PUBLIC_BASE_URL?.trim();
|
|
201
201
|
const portEnv = process.env.NEXT_PUBLIC_PORT_FE?.trim();
|
|
202
202
|
let baseUrl = baseEnv || "http://localhost";
|
|
203
|
-
baseUrl =
|
|
203
|
+
baseUrl = chunkEBYFYZW4_cjs.removeSpaces(baseUrl).replace(/\/+$/, "");
|
|
204
204
|
const hasPort = /:\/\/[^/]+:\d+/.test(baseUrl);
|
|
205
205
|
if (!hasPort && portEnv) {
|
|
206
|
-
baseUrl +=
|
|
206
|
+
baseUrl += chunkHYN6FC5A_cjs.formatEnvPort(portEnv, { prefixColon: true });
|
|
207
207
|
} else if (!hasPort && !baseEnv) {
|
|
208
208
|
baseUrl += ":3000";
|
|
209
209
|
}
|
package/dist/next/index.d.ts
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.11.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
|
-
import{IsAny}from'@rzl-zone/ts-types-plus';
|
|
10
|
+
import { IsAny } from '@rzl-zone/ts-types-plus';
|
|
11
|
+
|
|
11
12
|
/** ---------------------------------------------------------
|
|
12
13
|
* * ***Extracts dynamic route parameters from a given route string.***
|
|
13
14
|
* ---------------------------------------------------------
|
|
@@ -27,7 +28,9 @@ import{IsAny}from'@rzl-zone/ts-types-plus';
|
|
|
27
28
|
* // ➔ {} (no dynamic parameters)
|
|
28
29
|
* ```
|
|
29
30
|
*/
|
|
30
|
-
type ExtractRouteParams<T
|
|
31
|
+
type ExtractRouteParams<T> = T extends string ? HasDynamicSegments<T> extends true ? T extends `${infer _Start}[${infer Param}]${infer Rest}` ? {
|
|
32
|
+
[K in Param | keyof ExtractRouteParams<Rest>]: string;
|
|
33
|
+
} : unknown : unknown : unknown;
|
|
31
34
|
/** ---------------------------------------------------------
|
|
32
35
|
* * ***Determines whether a given route contains dynamic segments.***
|
|
33
36
|
* ---------------------------------------------------------
|
|
@@ -46,7 +49,8 @@ type ExtractRouteParams<T>=T extends string?HasDynamicSegments<T>extends true?T
|
|
|
46
49
|
* // ➔ true
|
|
47
50
|
* ```
|
|
48
51
|
*/
|
|
49
|
-
type HasDynamicSegments<T
|
|
52
|
+
type HasDynamicSegments<T> = T extends `${string}[${string}]${string}` ? true : false;
|
|
53
|
+
type GenerateRouteResult<T> = true extends IsAny<T> ? unknown : T extends string ? string : unknown;
|
|
50
54
|
/** ---------------------------------
|
|
51
55
|
* * ***Utility for NextJS: `generateRoute`.***
|
|
52
56
|
* ---------------------------------
|
|
@@ -86,15 +90,20 @@ type HasDynamicSegments<T>=T extends`${string}[${string}]${string}`?true:false;t
|
|
|
86
90
|
* generateRoute("/blog/[category]/[slug]", { category: "/news/", slug: "/latest-update/" });
|
|
87
91
|
* // ➔ ❌ Error: ❌ Parameter "category" and "slug" contains slashes "/" which is not allowed.
|
|
88
92
|
*/
|
|
89
|
-
declare function generateRoute<T extends string>(route:T extends string?(HasDynamicSegments<T>extends true
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
/** *
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
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>;
|
|
94
|
+
declare function generateRoute<T extends string>(route: T extends string ? T : never, params?: Extract<ExtractRouteParams<T>, Record<string, unknown>>): GenerateRouteResult<T>;
|
|
95
|
+
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
|
+
|
|
97
|
+
type OptionsCreateBeApiUrl = {
|
|
98
|
+
/** * The prefix pathname api url, e.g:`"http://localhost.com/your-target-prefix-entri-point-api-is-here"`, default: `"/api"`.
|
|
99
|
+
*
|
|
100
|
+
* @default "/api" */
|
|
101
|
+
prefix?: string;
|
|
102
|
+
/** * Option to getting `prefix` and `pathname` of api url only `(removing origin base api url)`, default: `true`.
|
|
103
|
+
*
|
|
104
|
+
* @default true */
|
|
105
|
+
withOrigin?: boolean;
|
|
106
|
+
};
|
|
98
107
|
/** ---------------------------------
|
|
99
108
|
* * ***Utility for NextJS: `createBeApiUrl`.***
|
|
100
109
|
* ---------------------------------
|
|
@@ -136,16 +145,19 @@ withOrigin?:boolean;};
|
|
|
136
145
|
* createBeApiUrl(undefined, { withOrigin: false })
|
|
137
146
|
* // ➔ "/api"
|
|
138
147
|
*/
|
|
139
|
-
declare const createBeApiUrl:(
|
|
148
|
+
declare const createBeApiUrl: (
|
|
140
149
|
/** * The pathname api url, e.g:`"http://localhost.com/your-target-prefix-entri-point-api-is-here/your-target-pathname-is-here"`.
|
|
141
150
|
*
|
|
142
151
|
* @default ""
|
|
143
152
|
*/
|
|
144
|
-
pathname:string|null|undefined,options?:OptionsCreateBeApiUrl)=>string;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
*
|
|
148
|
-
|
|
153
|
+
pathname: string | null | undefined, options?: OptionsCreateBeApiUrl) => string;
|
|
154
|
+
|
|
155
|
+
type OptionsGetBeApiUrl = {
|
|
156
|
+
/** * ***The Suffix origin base api url, e.g:`http://localhost.com/api`, default: `"/"`.***
|
|
157
|
+
*
|
|
158
|
+
* @default "/" */
|
|
159
|
+
suffix?: string;
|
|
160
|
+
};
|
|
149
161
|
/** ---------------------------------------------------
|
|
150
162
|
* * ***Utility for NextJS: `getBeApiUrl`.***
|
|
151
163
|
* ---------------------------------------------------
|
|
@@ -182,7 +194,8 @@ suffix?:string;};
|
|
|
182
194
|
* getBeApiUrl({ suffix: "/v1" });
|
|
183
195
|
* // ➔ "http://localhost:8000/v1"
|
|
184
196
|
*/
|
|
185
|
-
declare const getBeApiUrl:(options?:OptionsGetBeApiUrl)=>string;
|
|
197
|
+
declare const getBeApiUrl: (options?: OptionsGetBeApiUrl) => string;
|
|
198
|
+
|
|
186
199
|
/** ---------------------------------------------------
|
|
187
200
|
* * ***Utility for NextJS: `getBaseUrl`.***
|
|
188
201
|
* ---------------------------------------------------
|
|
@@ -213,4 +226,6 @@ declare const getBeApiUrl:(options?:OptionsGetBeApiUrl)=>string;
|
|
|
213
226
|
* getBaseUrl();
|
|
214
227
|
* // ➔ "http://localhost:3000"
|
|
215
228
|
*/
|
|
216
|
-
declare const getBaseUrl:()=>string;
|
|
229
|
+
declare const getBaseUrl: () => string;
|
|
230
|
+
|
|
231
|
+
export { type ExtractRouteParams, type HasDynamicSegments, createBeApiUrl, generateRoute, getBaseUrl, getBeApiUrl };
|
package/dist/next/index.js
CHANGED
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.11.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
|
-
import { normalizePathname, formatEnvPort } from '../chunk-
|
|
11
|
-
import '../chunk-
|
|
12
|
-
import '../chunk-
|
|
13
|
-
import { removeSpaces } from '../chunk-
|
|
14
|
-
import { isEmptyString } from '../chunk-
|
|
15
|
-
import { assertIsString } from '../chunk-
|
|
16
|
-
import { safeStableStringify } from '../chunk-
|
|
10
|
+
import { normalizePathname, formatEnvPort } from '../chunk-SZUNAEMR.js';
|
|
11
|
+
import '../chunk-5WIEDF2J.js';
|
|
12
|
+
import '../chunk-6YGBRENU.js';
|
|
13
|
+
import { removeSpaces } from '../chunk-HNBRGN4R.js';
|
|
14
|
+
import { isEmptyString } from '../chunk-ULQPCIA2.js';
|
|
15
|
+
import { assertIsString } from '../chunk-3T6VSWYX.js';
|
|
16
|
+
import { safeStableStringify } from '../chunk-AXDYWO67.js';
|
|
17
17
|
import '../chunk-QNKGP5DY.js';
|
|
18
|
-
import { isString, getPreciseType, assertIsPlainObject, isNil, isNonEmptyArray, isNonEmptyString, isPlainObject, isUndefined, assertIsBoolean, isError, hasOwnProp } from '../chunk-
|
|
18
|
+
import { isString, getPreciseType, assertIsPlainObject, isNil, isNonEmptyArray, isNonEmptyString, isPlainObject, isUndefined, assertIsBoolean, isError, hasOwnProp } from '../chunk-MSUW5VHZ.js';
|
|
19
19
|
|
|
20
20
|
function generateRoute(route, params) {
|
|
21
21
|
if (!isString(route) || isEmptyString(route)) {
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.11.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var chunkSYHPSOUU_cjs = require('../../chunk-SYHPSOUU.cjs');
|
|
13
13
|
require('server-only');
|
|
14
14
|
var server = require('next/server');
|
|
15
15
|
|
|
16
16
|
var getClientIpOrUrl = (request, includeFullUrl = true) => {
|
|
17
|
-
if (!
|
|
17
|
+
if (!chunkSYHPSOUU_cjs.isFunction(server.NextRequest)) {
|
|
18
18
|
throw new Error(
|
|
19
19
|
"Function `getClientIpOrUrl` is designed to be used in a `NextJS` environment."
|
|
20
20
|
);
|
|
@@ -24,7 +24,7 @@ var getClientIpOrUrl = (request, includeFullUrl = true) => {
|
|
|
24
24
|
"First parameter (`request`) must be an `instance of NextRequest` from `NextJS`."
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
chunkSYHPSOUU_cjs.assertIsBoolean(includeFullUrl, {
|
|
28
28
|
message: ({ currentType, validType }) => `Second parameter (\`includeFullUrl\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
29
29
|
});
|
|
30
30
|
const forwardedIps = (request.headers.get("x-forwarded-for") ?? "127.0.0.1").trim().split(",");
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.11.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
|
-
import{NextRequest}from'next/server';
|
|
10
|
+
import { NextRequest } from 'next/server';
|
|
11
|
+
|
|
11
12
|
/** ---------------------------------
|
|
12
13
|
* * ***Utility for NextJS Server: `getClientIpOrUrl`.***
|
|
13
14
|
* ---------------------------------
|
|
@@ -34,4 +35,6 @@ import{NextRequest}from'next/server';
|
|
|
34
35
|
* const url = getClientIpOrUrl(request);
|
|
35
36
|
* console.log("Client full URL:", url);
|
|
36
37
|
*/
|
|
37
|
-
declare const getClientIpOrUrl:(request:NextRequest,includeFullUrl?:boolean)=>string;
|
|
38
|
+
declare const getClientIpOrUrl: (request: NextRequest, includeFullUrl?: boolean) => string;
|
|
39
|
+
|
|
40
|
+
export { getClientIpOrUrl };
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.11.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
|
-
import { isFunction, assertIsBoolean } from '../../chunk-
|
|
10
|
+
import { isFunction, assertIsBoolean } from '../../chunk-MSUW5VHZ.js';
|
|
11
11
|
import 'server-only';
|
|
12
12
|
import { NextRequest } from 'next/server';
|
|
13
13
|
|
|
@@ -2,32 +2,32 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.11.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
-
var
|
|
13
|
-
require('../chunk-
|
|
14
|
-
require('../chunk-
|
|
15
|
-
require('../chunk-
|
|
16
|
-
require('../chunk-
|
|
12
|
+
var chunkXPVTIGU2_cjs = require('../chunk-XPVTIGU2.cjs');
|
|
13
|
+
require('../chunk-K5536YHG.cjs');
|
|
14
|
+
require('../chunk-GIKL4PUF.cjs');
|
|
15
|
+
require('../chunk-7FGNVDEV.cjs');
|
|
16
|
+
require('../chunk-DLS3G6WQ.cjs');
|
|
17
17
|
require('../chunk-BAV5T2E3.cjs');
|
|
18
|
-
require('../chunk-
|
|
18
|
+
require('../chunk-DAPAK2W3.cjs');
|
|
19
19
|
require('../chunk-UDA26MCU.cjs');
|
|
20
|
-
require('../chunk-
|
|
20
|
+
require('../chunk-SYHPSOUU.cjs');
|
|
21
21
|
|
|
22
22
|
Object.defineProperty(exports, "findDuplicates", {
|
|
23
23
|
enumerable: true,
|
|
24
|
-
get: function () { return
|
|
24
|
+
get: function () { return chunkXPVTIGU2_cjs.findDuplicates; }
|
|
25
25
|
});
|
|
26
26
|
Object.defineProperty(exports, "omitKeys", {
|
|
27
27
|
enumerable: true,
|
|
28
|
-
get: function () { return
|
|
28
|
+
get: function () { return chunkXPVTIGU2_cjs.omitKeys; }
|
|
29
29
|
});
|
|
30
30
|
Object.defineProperty(exports, "omitKeysDeep", {
|
|
31
31
|
enumerable: true,
|
|
32
|
-
get: function () { return
|
|
32
|
+
get: function () { return chunkXPVTIGU2_cjs.omitKeysDeep; }
|
|
33
33
|
});
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.11.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
|
-
import{NumberRangeUnion}from'@rzl-zone/ts-types-plus';
|
|
10
|
+
import { NumberRangeUnion } from '@rzl-zone/ts-types-plus';
|
|
11
|
+
|
|
11
12
|
/** ----------------------------------------------------------------------
|
|
12
13
|
* * ***Utility: `findDuplicates`.***
|
|
13
14
|
* ----------------------------------------------------------------------
|
|
@@ -37,7 +38,8 @@ import{NumberRangeUnion}from'@rzl-zone/ts-types-plus';
|
|
|
37
38
|
* findDuplicates([1, 2, 3]);
|
|
38
39
|
* // ➔ []
|
|
39
40
|
*/
|
|
40
|
-
declare const findDuplicates
|
|
41
|
+
declare const findDuplicates: <T>(values: T[]) => T[];
|
|
42
|
+
|
|
41
43
|
/** --------------------------------
|
|
42
44
|
* * ***Utility: `omitKeys`.***
|
|
43
45
|
* --------------------------------
|
|
@@ -64,7 +66,12 @@ declare const findDuplicates:<T>(values:T[])=>T[];
|
|
|
64
66
|
* omitKeys({ a: 1, b: 2 }, []);
|
|
65
67
|
* //➔ { a: 1, b: 2 } (no changes)
|
|
66
68
|
*/
|
|
67
|
-
declare const omitKeys
|
|
69
|
+
declare const omitKeys: <I extends Record<string, unknown>, K extends keyof I>(object: I, keysToOmit: K[]) => Omit<I, K>;
|
|
70
|
+
|
|
71
|
+
type IndexArray = NumberRangeUnion<0, 30>;
|
|
72
|
+
type DotPath<T, Prev extends string = ""> = T extends Array<infer U> ? DotPath<U, `${Prev}${Prev extends "" ? "" : "."}${IndexArray}`> : T extends object ? {
|
|
73
|
+
[K in keyof T & string]: `${Prev}${Prev extends "" ? "" : "."}${K}` | DotPath<T[K], `${Prev}${Prev extends "" ? "" : "."}${K}`>;
|
|
74
|
+
}[keyof T & string] : never;
|
|
68
75
|
/** ------------------------------------------------------
|
|
69
76
|
* * ***Utility: `omitKeysDeep`.***
|
|
70
77
|
* ------------------------------------------------------
|
|
@@ -132,4 +139,6 @@ declare const omitKeys:<I extends Record<string,unknown>,K extends keyof I>(obje
|
|
|
132
139
|
* omitKeysDeep({ mixed: { a: [1, 2, 3], b: { c: 4 } } }, ["mixed.b.c"]);
|
|
133
140
|
* // ➔ { mixed: { a: [1, 2, 3] } }
|
|
134
141
|
*/
|
|
135
|
-
declare const omitKeysDeep
|
|
142
|
+
declare const omitKeysDeep: <I extends Record<string, unknown>>(object: I, keysToOmit: DotPath<I>[]) => Partial<I>;
|
|
143
|
+
|
|
144
|
+
export { findDuplicates, omitKeys, omitKeysDeep };
|
package/dist/operations/index.js
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.11.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
|
-
export { findDuplicates, omitKeys, omitKeysDeep } from '../chunk-
|
|
11
|
-
import '../chunk-
|
|
12
|
-
import '../chunk-
|
|
13
|
-
import '../chunk-
|
|
14
|
-
import '../chunk-
|
|
10
|
+
export { findDuplicates, omitKeys, omitKeysDeep } from '../chunk-LJHPTLWB.js';
|
|
11
|
+
import '../chunk-BOYP3ARU.js';
|
|
12
|
+
import '../chunk-GXKQ3LHF.js';
|
|
13
|
+
import '../chunk-GOFINGT6.js';
|
|
14
|
+
import '../chunk-RZOGBYIS.js';
|
|
15
15
|
import '../chunk-YWHHVDT4.js';
|
|
16
|
-
import '../chunk-
|
|
16
|
+
import '../chunk-AXDYWO67.js';
|
|
17
17
|
import '../chunk-QNKGP5DY.js';
|
|
18
|
-
import '../chunk-
|
|
18
|
+
import '../chunk-MSUW5VHZ.js';
|
package/dist/parsers/index.cjs
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.11.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
-
var
|
|
13
|
-
require('../chunk-
|
|
14
|
-
require('../chunk-
|
|
15
|
-
require('../chunk-
|
|
12
|
+
var chunkNLZLXWAU_cjs = require('../chunk-NLZLXWAU.cjs');
|
|
13
|
+
require('../chunk-QYI2VJLS.cjs');
|
|
14
|
+
require('../chunk-WXFTVXBF.cjs');
|
|
15
|
+
require('../chunk-SYHPSOUU.cjs');
|
|
16
16
|
|
|
17
17
|
Object.defineProperty(exports, "extractFileName", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: function () { return
|
|
19
|
+
get: function () { return chunkNLZLXWAU_cjs.extractFileName; }
|
|
20
20
|
});
|