repzo 1.0.236 → 1.0.237
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/lib/helper.d.ts +1 -1
- package/lib/helper.js +4 -10
- package/lib/index.js +1 -1
- package/package.json +2 -2
- package/src/helper.ts +4 -20
- package/src/index.ts +1 -1
package/lib/helper.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const generateUUID: (prefix?: string, suffix?: string
|
|
1
|
+
export declare const generateUUID: (prefix?: string, suffix?: string) => string;
|
package/lib/helper.js
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
export const generateUUID = (prefix = "", suffix = ""
|
|
1
|
+
import { v7 as uuidv7 } from "uuid";
|
|
2
|
+
export const generateUUID = (prefix = "", suffix = "") => {
|
|
3
3
|
if ((prefix && typeof prefix !== "string") ||
|
|
4
4
|
(suffix && typeof suffix !== "string")) {
|
|
5
5
|
throw new Error("Prefix and suffix must be strings");
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
typeof crypto.randomBytes !== "function") {
|
|
9
|
-
throw new Error("crypto module or randomBytes function is unavailable");
|
|
10
|
-
}
|
|
11
|
-
const randomPortion = BigInt(`0x${crypto.randomBytes(length).toString("hex")}`).toString(36);
|
|
12
|
-
const timestamp = Date.now().toString(36);
|
|
7
|
+
const uuid = uuidv7();
|
|
13
8
|
const formattedPrefix = prefix ? `${prefix}-` : "";
|
|
14
9
|
const formattedSuffix = suffix ? `-${suffix}` : "";
|
|
15
|
-
|
|
16
|
-
return uuid;
|
|
10
|
+
return `${formattedPrefix}${uuid}${formattedSuffix}`;
|
|
17
11
|
};
|
package/lib/index.js
CHANGED
|
@@ -222,7 +222,7 @@ class Repzo {
|
|
|
222
222
|
constructor(apiKey, options) {
|
|
223
223
|
this.available_services = availableService;
|
|
224
224
|
this.generateUUID = ({ prefix, suffix, length, }) => {
|
|
225
|
-
return generateUUID(prefix, suffix
|
|
225
|
+
return generateUUID(prefix, suffix);
|
|
226
226
|
};
|
|
227
227
|
this.core = {
|
|
228
228
|
updateHeader: (newHeaders) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "repzo",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.237",
|
|
4
4
|
"description": "Repzo TypeScript SDK",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@babel/parser": "^7.14.7",
|
|
54
54
|
"@types/axios": "^0.9.36",
|
|
55
|
-
"uuid": "^
|
|
55
|
+
"uuid": "^13.0.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@apidevtools/swagger-parser": "^12.0.0",
|
package/src/helper.ts
CHANGED
|
@@ -1,32 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { v7 as uuidv7 } from "uuid";
|
|
2
2
|
|
|
3
|
-
export const generateUUID = (
|
|
4
|
-
prefix = "",
|
|
5
|
-
suffix = "",
|
|
6
|
-
length: number = 8,
|
|
7
|
-
): string => {
|
|
3
|
+
export const generateUUID = (prefix = "", suffix = ""): string => {
|
|
8
4
|
if (
|
|
9
5
|
(prefix && typeof prefix !== "string") ||
|
|
10
6
|
(suffix && typeof suffix !== "string")
|
|
11
7
|
) {
|
|
12
8
|
throw new Error("Prefix and suffix must be strings");
|
|
13
9
|
}
|
|
14
|
-
if (
|
|
15
|
-
typeof crypto === "undefined" ||
|
|
16
|
-
typeof crypto.randomBytes !== "function"
|
|
17
|
-
) {
|
|
18
|
-
throw new Error("crypto module or randomBytes function is unavailable");
|
|
19
|
-
}
|
|
20
|
-
const randomPortion = BigInt(
|
|
21
|
-
`0x${crypto.randomBytes(length).toString("hex")}`,
|
|
22
|
-
).toString(36);
|
|
23
|
-
|
|
24
|
-
const timestamp = Date.now().toString(36);
|
|
25
10
|
|
|
11
|
+
const uuid = uuidv7();
|
|
26
12
|
const formattedPrefix = prefix ? `${prefix}-` : "";
|
|
27
13
|
const formattedSuffix = suffix ? `-${suffix}` : "";
|
|
28
14
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return uuid;
|
|
15
|
+
return `${formattedPrefix}${uuid}${formattedSuffix}`;
|
|
32
16
|
};
|