wedance-shared 1.0.133 → 1.0.135
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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types/event.d.ts +7 -1
- package/dist/utils/string.d.ts +19 -0
- package/dist/utils/string.js +53 -0
- package/dist/utils/string.js.map +1 -0
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC"}
|
package/dist/types/event.d.ts
CHANGED
|
@@ -53,8 +53,14 @@ export type EventData = {
|
|
|
53
53
|
hasSeveralPrices?: boolean;
|
|
54
54
|
createdAt: string;
|
|
55
55
|
lastUpdated?: string;
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated Schedule will be removed in the future
|
|
58
|
+
*/
|
|
56
59
|
publishedSchedule?: boolean;
|
|
57
|
-
|
|
60
|
+
/**
|
|
61
|
+
* @deprecated Schedule will be removed in the future
|
|
62
|
+
*/
|
|
63
|
+
schedule?: EventSchedule | null;
|
|
58
64
|
addedBy: string;
|
|
59
65
|
updatedBy: string;
|
|
60
66
|
paymentLink: string | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes accents/diacritics from a string
|
|
3
|
+
* e.g., "café" -> "cafe", "Zürich" -> "Zurich"
|
|
4
|
+
*/
|
|
5
|
+
export declare function removeAccents(str: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Converts a string to a URL-safe slug
|
|
8
|
+
* e.g., "São Paulo Festival 2024!" -> "sao-paulo-festival-2024"
|
|
9
|
+
*/
|
|
10
|
+
export declare function slugify(str: string, maxLength?: number, separator?: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a unique ID from a string with optional suffix
|
|
13
|
+
* e.g., "Kizomba Festival Paris" -> "kizomba-festival-paris-a1b2c3"
|
|
14
|
+
*/
|
|
15
|
+
export declare function createUniqueId(str: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Generates a random alphanumeric suffix
|
|
18
|
+
*/
|
|
19
|
+
export declare function generateRandomSuffix(): string;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from "uuid";
|
|
2
|
+
/**
|
|
3
|
+
* Removes accents/diacritics from a string
|
|
4
|
+
* e.g., "café" -> "cafe", "Zürich" -> "Zurich"
|
|
5
|
+
*/
|
|
6
|
+
export function removeAccents(str) {
|
|
7
|
+
return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Converts a string to a URL-safe slug
|
|
11
|
+
* e.g., "São Paulo Festival 2024!" -> "sao-paulo-festival-2024"
|
|
12
|
+
*/
|
|
13
|
+
export function slugify(str, maxLength = 50, separator = "-") {
|
|
14
|
+
let result = removeAccents(str)
|
|
15
|
+
.toLowerCase()
|
|
16
|
+
.trim()
|
|
17
|
+
.replace(/[^a-z0-9\s]/g, "")
|
|
18
|
+
.replace(/\s+/g, separator);
|
|
19
|
+
if (separator) {
|
|
20
|
+
const escapedSep = separator.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
21
|
+
result = result
|
|
22
|
+
.replace(new RegExp(`${escapedSep}+`, "g"), separator)
|
|
23
|
+
.replace(new RegExp(`^${escapedSep}|${escapedSep}$`, "g"), "");
|
|
24
|
+
}
|
|
25
|
+
result = result.substring(0, maxLength);
|
|
26
|
+
if (separator) {
|
|
27
|
+
const escapedSep = separator.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
28
|
+
result = result.replace(new RegExp(`${escapedSep}$`), "");
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Creates a unique ID from a string with optional suffix
|
|
34
|
+
* e.g., "Kizomba Festival Paris" -> "kizomba-festival-paris-a1b2c3"
|
|
35
|
+
*/
|
|
36
|
+
export function createUniqueId(str) {
|
|
37
|
+
const slug = slugify(str, 30);
|
|
38
|
+
const suffix = generateRandomSuffix();
|
|
39
|
+
return `${slug}-${suffix}`;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Generates a random alphanumeric suffix
|
|
43
|
+
*/
|
|
44
|
+
export function generateRandomSuffix() {
|
|
45
|
+
const uuid = uuidv4();
|
|
46
|
+
const array = uuid.split("-");
|
|
47
|
+
const firstPart = array[0];
|
|
48
|
+
if (!firstPart) {
|
|
49
|
+
throw new Error("Failed to generate random suffix");
|
|
50
|
+
}
|
|
51
|
+
return firstPart;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=string.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../src/utils/string.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,OAAO,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;AAC9D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,GAAW,EAAE,SAAS,GAAG,EAAE,EAAE,SAAS,GAAG,GAAG;IAClE,IAAI,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC;SAC5B,WAAW,EAAE;SACb,IAAI,EAAE;SACN,OAAO,CAAC,cAAc,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CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wedance-shared",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.135",
|
|
4
4
|
"description": "This repository contains shared TypeScript types and interfaces used across multiple WeDance applications:",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"type": "module",
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"dayjs": "^1.11.13",
|
|
50
|
-
"firebase": "11.5.0"
|
|
50
|
+
"firebase": "11.5.0",
|
|
51
|
+
"uuid": "^14.0.0"
|
|
51
52
|
}
|
|
52
53
|
}
|