wedance-shared 1.0.132 → 1.0.134

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 CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./types/index.js";
2
2
  export * from "./utils/date.js";
3
+ export * from "./utils/string.js";
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./types/index.js";
2
2
  export * from "./utils/date.js";
3
+ export * from "./utils/string.js";
3
4
  //# sourceMappingURL=index.js.map
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"}
@@ -0,0 +1,40 @@
1
+ export type TicketCouponDiscountType = "fixed" | "percentage";
2
+ /**
3
+ * Row shape for `public.ticket_coupons`.
4
+ */
5
+ export type TicketCoupon = {
6
+ id: string;
7
+ /**
8
+ * @deprecated Link is made with a join table `public.coupon_ticket_types`
9
+ */
10
+ ticketTypeId: string | null;
11
+ code: string;
12
+ discountType: TicketCouponDiscountType;
13
+ /**
14
+ * If fixed, discount amount is in MINOR unit. (eg: 1000 for 10.00)
15
+ * if percentage, discount amount is a percentage of the ticket price. (eg: 10 for 10%)
16
+ * So never decimal numbers are allowed.
17
+ */
18
+ discountAmount: number;
19
+ startDate: string | null;
20
+ expiryDate: string | null;
21
+ organizerId: string | null;
22
+ maxRedemptions: number | null;
23
+ redemptionCount: number;
24
+ /**
25
+ * ticketTypes will be populated in the server with join. It is not in the ticket_coupons table.
26
+ */
27
+ ticketTypes?: TicketTypeWithEvent[] | null;
28
+ };
29
+ export type TicketTypeWithEvent = {
30
+ id: string;
31
+ name: string;
32
+ event: {
33
+ id: string;
34
+ title: string;
35
+ from: string;
36
+ until: string;
37
+ status: string | null;
38
+ };
39
+ };
40
+ export type CreateTicketCouponInput = Pick<TicketCoupon, "code" | "discountType" | "discountAmount" | "organizerId" | "startDate" | "expiryDate" | "maxRedemptions">;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=coupons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coupons.js","sourceRoot":"","sources":["../../src/types/coupons.ts"],"names":[],"mappings":""}
@@ -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
- schedule: EventSchedule | null;
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;
@@ -8,4 +8,5 @@ export * from "./analytics.js";
8
8
  export * from "./infoBanner.js";
9
9
  export * from "./wedancePosts.js";
10
10
  export * from "./support.js";
11
+ export * from "./coupons.js";
11
12
  export * from "./festivals/index.js";
@@ -9,6 +9,7 @@ export * from "./analytics.js";
9
9
  export * from "./infoBanner.js";
10
10
  export * from "./wedancePosts.js";
11
11
  export * from "./support.js";
12
+ export * from "./coupons.js";
12
13
  // Re-export from subdirectories
13
14
  export * from "./festivals/index.js";
14
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAE7B,gCAAgC;AAChC,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAE7B,gCAAgC;AAChC,cAAc,sBAAsB,CAAC"}
@@ -87,26 +87,6 @@ export type CouponCode = {
87
87
  startDate: string | null;
88
88
  expiryDate: string | null;
89
89
  };
90
- export type TicketCouponDiscountType = "fixed" | "percentage";
91
- /**
92
- * Row shape for `public.ticket_coupons`.
93
- */
94
- export type TicketCoupon = {
95
- id: string;
96
- /**
97
- * @deprecated Link is made with a join table `public.coupon_ticket_types`
98
- */
99
- ticketTypeId: string | null;
100
- code: string;
101
- discountType: TicketCouponDiscountType;
102
- discountAmount: number;
103
- startDate: string | null;
104
- expiryDate: string | null;
105
- organizerId: string | null;
106
- maxRedemptions: number | null;
107
- redemptionCount: number;
108
- };
109
- export type CreateTicketCouponInput = Pick<TicketCoupon, "code" | "discountType" | "discountAmount" | "organizerId" | "startDate" | "expiryDate" | "maxRedemptions">;
110
90
  export type EventTicket = {
111
91
  id: string;
112
92
  /**
@@ -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,52 @@
1
+ /**
2
+ * Removes accents/diacritics from a string
3
+ * e.g., "café" -> "cafe", "Zürich" -> "Zurich"
4
+ */
5
+ export function removeAccents(str) {
6
+ return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
7
+ }
8
+ /**
9
+ * Converts a string to a URL-safe slug
10
+ * e.g., "São Paulo Festival 2024!" -> "sao-paulo-festival-2024"
11
+ */
12
+ export function slugify(str, maxLength = 50, separator = "-") {
13
+ let result = removeAccents(str)
14
+ .toLowerCase()
15
+ .trim()
16
+ .replace(/[^a-z0-9\s]/g, "")
17
+ .replace(/\s+/g, separator);
18
+ if (separator) {
19
+ const escapedSep = separator.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
20
+ result = result
21
+ .replace(new RegExp(`${escapedSep}+`, "g"), separator)
22
+ .replace(new RegExp(`^${escapedSep}|${escapedSep}$`, "g"), "");
23
+ }
24
+ result = result.substring(0, maxLength);
25
+ if (separator) {
26
+ const escapedSep = separator.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
27
+ result = result.replace(new RegExp(`${escapedSep}$`), "");
28
+ }
29
+ return result;
30
+ }
31
+ /**
32
+ * Creates a unique ID from a string with optional suffix
33
+ * e.g., "Kizomba Festival Paris" -> "kizomba-festival-paris-a1b2c3"
34
+ */
35
+ export function createUniqueId(str) {
36
+ const slug = slugify(str, 30);
37
+ const suffix = generateRandomSuffix();
38
+ return `${slug}-${suffix}`;
39
+ }
40
+ /**
41
+ * Generates a random alphanumeric suffix
42
+ */
43
+ export function generateRandomSuffix() {
44
+ const uuid = globalThis.crypto.randomUUID();
45
+ const array = uuid.split("-");
46
+ const firstPart = array[0];
47
+ if (!firstPart) {
48
+ throw new Error("Failed to generate random suffix");
49
+ }
50
+ return firstPart;
51
+ }
52
+ //# sourceMappingURL=string.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.js","sourceRoot":"","sources":["../../src/utils/string.ts"],"names":[],"mappings":"AAAA;;;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,EAAE,EAAE,CAAC;SAC3B,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAE9B,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,UAAU,GAAG,SAAS,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;QACpE,MAAM,GAAG,MAAM;aACZ,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG,UAAU,GAAG,EAAE,GAAG,CAAC,EAAE,SAAS,CAAC;aACrD,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,UAAU,IAAI,UAAU,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;IACnE,CAAC;IAED,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IAExC,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,UAAU,GAAG,SAAS,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;QACpE,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG,UAAU,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAC9B,MAAM,MAAM,GAAG,oBAAoB,EAAE,CAAC;IACtC,OAAO,GAAG,IAAI,IAAI,MAAM,EAAE,CAAC;AAC7B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IAC5C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE9B,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,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.132",
3
+ "version": "1.0.134",
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",