@bisondesk/website-commons-sdk 1.0.33 → 1.0.35

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.
@@ -0,0 +1,30 @@
1
+ type BaseSEOStockPath = {
2
+ /* The path i.e /truck */
3
+ id: string;
4
+ };
5
+
6
+ export type CanonicalSEOStockPath = BaseSEOStockPath & {
7
+ filters: Record<string, unknown>;
8
+ canonical?: undefined;
9
+
10
+ /* The SEO path for markdown content i.e /truck/daf */
11
+ seoPath: string;
12
+ };
13
+
14
+ export type LocalizedSEOStockPath = BaseSEOStockPath & {
15
+ /* The canonical id for the localised stock path, null if canonical */
16
+ language: string;
17
+ canonical: string;
18
+ };
19
+
20
+ export type SEOStockPath = CanonicalSEOStockPath | LocalizedSEOStockPath;
21
+
22
+ export type GroupedSEOStockPaths = {
23
+ canonical: CanonicalSEOStockPath;
24
+ localizations: LocalizedSEOStockPath[];
25
+ }[];
26
+
27
+ export type LocalizedSEOStockPathWithCanonical = {
28
+ localizedData?: LocalizedSEOStockPath;
29
+ canonicalData?: CanonicalSEOStockPath;
30
+ };
@@ -18,7 +18,7 @@ const BaseUserSearch = z
18
18
  type BaseUserSearch = z.infer<typeof BaseUserSearch>;
19
19
 
20
20
  export const UserSearch = BaseUserSearch.extend({
21
- id: z.uuidv7(),
21
+ id: z.string().uuid(),
22
22
  createdBy: z.string(),
23
23
  createdAt: z.string(),
24
24
  });
package/src/types/user.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { z } from 'zod';
1
2
  import { MarketingChannel } from './index.js';
2
3
 
3
4
  export type AuthRequest = {
@@ -10,20 +11,29 @@ export enum FleetSize {
10
11
  Large = '6+',
11
12
  }
12
13
 
13
- export type UserDetails = {
14
- firstName?: string;
15
- lastName?: string;
16
- phone?: string;
17
- preferredLanguage?: string;
18
- fleetSize?: FleetSize;
19
- trader?: boolean;
20
- email?: string;
21
- company: {
22
- country?: string;
23
- city?: string | undefined;
24
- name?: string | undefined;
25
- vat?: string | undefined;
26
- postalCode?: string | undefined;
27
- };
28
- marketingChannels: MarketingChannel[];
29
- };
14
+ export const UserDetails = z.object({
15
+ firstName: z.string().optional(),
16
+ lastName: z.string().optional(),
17
+ phone: z.string().optional(),
18
+ preferredLanguage: z.string().optional(),
19
+ fleetSize: z.nativeEnum(FleetSize).optional(),
20
+ trader: z.boolean().optional(),
21
+ email: z.string().email().optional(),
22
+ company: z.object({
23
+ country: z.string().optional(),
24
+ city: z.string().optional(),
25
+ name: z.string().optional(),
26
+ vat: z.string().optional(),
27
+ postalCode: z.string().optional(),
28
+ }),
29
+ marketingChannels: z.array(z.nativeEnum(MarketingChannel)),
30
+ });
31
+
32
+ export type UserDetails = z.infer<typeof UserDetails>;
33
+
34
+ export const UserDetailsRequest = z.object({
35
+ subsribeToNewsletter: z.boolean().optional(),
36
+ data: UserDetails,
37
+ });
38
+
39
+ export type UserDetailsRequest = z.infer<typeof UserDetailsRequest>;
@@ -1,4 +1,5 @@
1
1
  import { customAlphabet } from 'nanoid';
2
+ import slug from 'slug';
2
3
 
3
4
  export enum Alphabet {
4
5
  Full = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_',
@@ -33,3 +34,55 @@ const isValid = (id: string): boolean => {
33
34
 
34
35
  return true;
35
36
  };
37
+
38
+ const arabic = {
39
+ ء: 'ء',
40
+ ا: 'ا',
41
+ أ: 'أ',
42
+ إ: 'إ',
43
+ آ: 'آ',
44
+ ؤ: 'ؤ',
45
+ ئ: 'ئ',
46
+ ب: 'ب',
47
+ ت: 'ت',
48
+ ث: 'ث',
49
+ ج: 'ج',
50
+ ح: 'ح',
51
+ خ: 'خ',
52
+ د: 'د',
53
+ ذ: 'ذ',
54
+ ر: 'ر',
55
+ ز: 'ز',
56
+ س: 'س',
57
+ ش: 'ش',
58
+ ص: 'ص',
59
+ ض: 'ض',
60
+ ط: 'ط',
61
+ ظ: 'ظ',
62
+ ع: 'ع',
63
+ غ: 'غ',
64
+ ف: 'ف',
65
+ ق: 'ق',
66
+ ك: 'ك',
67
+ ل: 'ل',
68
+ م: 'م',
69
+ ن: 'ن',
70
+ ه: 'ه',
71
+ و: 'و',
72
+ ي: 'ي',
73
+ ة: 'ة',
74
+ ى: 'ى',
75
+ };
76
+
77
+ slug.extend(arabic);
78
+
79
+ export const slugify = (str: string, opts?: slug.Options) =>
80
+ slug(str, {
81
+ lower: true,
82
+ // Preserve Arabic characters
83
+ remove: /[$*_+~.()'"!\-:@]+/g,
84
+ ...opts,
85
+ });
86
+
87
+ export const normalizeSlug = (slug: (string | undefined)[], locale?: string) =>
88
+ slug.filter((v: string | undefined): v is string => !!v).map((s) => slugify(s, { locale }));
@@ -0,0 +1,29 @@
1
+ import { slugify } from './index.js';
2
+
3
+ describe('utils', () => {
4
+ test.each([
5
+ {
6
+ actual: 'سيارة إسعاف سيارة إسعاف',
7
+ expected: 'سيارة-إسعاف-سيارة-إسعاف',
8
+ locale: 'ar',
9
+ },
10
+ {
11
+ actual: 'رأس جرار',
12
+ expected: 'رأس-جرار',
13
+ locale: 'ar',
14
+ },
15
+ {
16
+ actual: 'اختبار خاص!@#',
17
+ expected: 'اختبار-خاص',
18
+ locale: 'ar',
19
+ },
20
+ {
21
+ actual: 'Café com leite',
22
+ expected: 'cafe-com-leite',
23
+ },
24
+ ])('slug', ({ actual, expected, locale }) => {
25
+ const slugified = slugify(actual, { locale });
26
+
27
+ expect(slugified).toBe(expected);
28
+ });
29
+ });