@bisondesk/website-commons-sdk 1.0.37 → 1.0.39
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/types/mailing-list.d.ts +78 -0
- package/lib/types/mailing-list.d.ts.map +1 -0
- package/lib/types/mailing-list.js +26 -0
- package/lib/types/mailing-list.js.map +1 -0
- package/lib/types/user-searches.d.ts +49 -6
- package/lib/types/user-searches.d.ts.map +1 -1
- package/lib/types/user-searches.js +1 -1
- package/lib/types/user-searches.js.map +1 -1
- package/lib/types/user.d.ts +87 -14
- package/lib/types/user.d.ts.map +1 -1
- package/lib/types/user.js +87 -0
- package/lib/types/user.js.map +1 -1
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/vehicle.d.ts.map +1 -1
- package/package.json +6 -3
- package/src/types/mailing-list.ts +53 -0
- package/src/types/user-searches.ts +1 -1
- package/src/types/user.test.ts +128 -0
- package/src/types/user.ts +116 -16
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const Contact: z.ZodObject<{
|
|
3
|
+
email: z.ZodString;
|
|
4
|
+
status: z.ZodOptional<z.ZodEnum<["unsubscribed", "subscribed", "pending"]>>;
|
|
5
|
+
fields: z.ZodEffects<z.ZodObject<{
|
|
6
|
+
Country: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
7
|
+
PreferredLanguage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
8
|
+
FirstName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
9
|
+
LastName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
Country?: string | null | undefined;
|
|
12
|
+
PreferredLanguage?: string | null | undefined;
|
|
13
|
+
FirstName?: string | null | undefined;
|
|
14
|
+
LastName?: string | null | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
Country?: string | null | undefined;
|
|
17
|
+
PreferredLanguage?: string | null | undefined;
|
|
18
|
+
FirstName?: string | null | undefined;
|
|
19
|
+
LastName?: string | null | undefined;
|
|
20
|
+
}>, {
|
|
21
|
+
[k: string]: string | null;
|
|
22
|
+
}, {
|
|
23
|
+
Country?: string | null | undefined;
|
|
24
|
+
PreferredLanguage?: string | null | undefined;
|
|
25
|
+
FirstName?: string | null | undefined;
|
|
26
|
+
LastName?: string | null | undefined;
|
|
27
|
+
}>;
|
|
28
|
+
tags: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
|
|
29
|
+
}, "strip", z.ZodTypeAny, {
|
|
30
|
+
email: string;
|
|
31
|
+
fields: {
|
|
32
|
+
[k: string]: string | null;
|
|
33
|
+
};
|
|
34
|
+
status?: "unsubscribed" | "subscribed" | "pending" | undefined;
|
|
35
|
+
tags?: Record<string, boolean> | undefined;
|
|
36
|
+
}, {
|
|
37
|
+
email: string;
|
|
38
|
+
fields: {
|
|
39
|
+
Country?: string | null | undefined;
|
|
40
|
+
PreferredLanguage?: string | null | undefined;
|
|
41
|
+
FirstName?: string | null | undefined;
|
|
42
|
+
LastName?: string | null | undefined;
|
|
43
|
+
};
|
|
44
|
+
status?: "unsubscribed" | "subscribed" | "pending" | undefined;
|
|
45
|
+
tags?: Record<string, boolean> | undefined;
|
|
46
|
+
}>;
|
|
47
|
+
export type Contact = z.input<typeof Contact>;
|
|
48
|
+
export declare const CheckUserIsSubscribedRequest: z.ZodObject<{
|
|
49
|
+
email: z.ZodString;
|
|
50
|
+
}, "strip", z.ZodTypeAny, {
|
|
51
|
+
email: string;
|
|
52
|
+
}, {
|
|
53
|
+
email: string;
|
|
54
|
+
}>;
|
|
55
|
+
export type CheckUserIsSubscribedRequest = z.infer<typeof CheckUserIsSubscribedRequest>;
|
|
56
|
+
export type ContactStatus = z.infer<typeof Contact.shape.status>;
|
|
57
|
+
export type CheckUserIsSubscribedResponse = {
|
|
58
|
+
createdAt?: string;
|
|
59
|
+
status?: 'unsubscribed' | 'subscribed' | 'pending';
|
|
60
|
+
};
|
|
61
|
+
export type UpsertContactResponse = {
|
|
62
|
+
subscribed: boolean;
|
|
63
|
+
};
|
|
64
|
+
export declare const SubscribeContactRequest: z.ZodObject<{
|
|
65
|
+
email: z.ZodString;
|
|
66
|
+
language: z.ZodString;
|
|
67
|
+
}, "strip", z.ZodTypeAny, {
|
|
68
|
+
email: string;
|
|
69
|
+
language: string;
|
|
70
|
+
}, {
|
|
71
|
+
email: string;
|
|
72
|
+
language: string;
|
|
73
|
+
}>;
|
|
74
|
+
export type SubscribeContactRequest = z.infer<typeof SubscribeContactRequest>;
|
|
75
|
+
export type SubscribeContactResponse = {
|
|
76
|
+
subscribedAt: string;
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=mailing-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mailing-list.d.ts","sourceRoot":"/","sources":["types/mailing-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkBlB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,CAAC;AAE9C,eAAO,MAAM,4BAA4B;;;;;;EAEvC,CAAC;AAEH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAExF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAEjE,MAAM,MAAM,6BAA6B,GAAG;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,cAAc,GAAG,YAAY,GAAG,SAAS,CAAC;CACpD,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;;;;;;EAGlC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE9E,MAAM,MAAM,wBAAwB,GAAG;IACrC,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const emailSchema = z.string().email().min(1).toLowerCase();
|
|
3
|
+
export const Contact = z.object({
|
|
4
|
+
email: emailSchema,
|
|
5
|
+
status: z.enum(['unsubscribed', 'subscribed', 'pending']).optional(),
|
|
6
|
+
fields: z
|
|
7
|
+
.object({
|
|
8
|
+
Country: z.string().nullable().optional(),
|
|
9
|
+
PreferredLanguage: z.string().nullable().optional(),
|
|
10
|
+
FirstName: z.string().nullable().optional(),
|
|
11
|
+
LastName: z.string().nullable().optional(),
|
|
12
|
+
})
|
|
13
|
+
.transform((data) => {
|
|
14
|
+
const normalizedData = Object.fromEntries(Object.entries(data).filter(([, value]) => value !== undefined));
|
|
15
|
+
return normalizedData;
|
|
16
|
+
}),
|
|
17
|
+
tags: z.record(z.string(), z.boolean()).optional(),
|
|
18
|
+
});
|
|
19
|
+
export const CheckUserIsSubscribedRequest = z.object({
|
|
20
|
+
email: emailSchema,
|
|
21
|
+
});
|
|
22
|
+
export const SubscribeContactRequest = z.object({
|
|
23
|
+
email: emailSchema,
|
|
24
|
+
language: z.string(),
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=mailing-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mailing-list.js","sourceRoot":"/","sources":["types/mailing-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,EAAE,C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AAK,EAAE,WAAW;IAClB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;CACrB,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\n\nconst emailSchema = z.string().email().min(1).toLowerCase();\n\nexport const Contact = z.object({\n email: emailSchema,\n status: z.enum(['unsubscribed', 'subscribed', 'pending']).optional(),\n fields: z\n .object({\n Country: z.string().nullable().optional(),\n PreferredLanguage: z.string().nullable().optional(),\n FirstName: z.string().nullable().optional(),\n LastName: z.string().nullable().optional(),\n })\n .transform((data) => {\n const normalizedData = Object.fromEntries(\n Object.entries(data).filter(([, value]) => value !== undefined)\n );\n\n return normalizedData;\n }),\n tags: z.record(z.string(), z.boolean()).optional(),\n});\n\nexport type Contact = z.input<typeof Contact>;\n\nexport const CheckUserIsSubscribedRequest = z.object({\n email: emailSchema,\n});\n\nexport type CheckUserIsSubscribedRequest = z.infer<typeof CheckUserIsSubscribedRequest>;\n\nexport type ContactStatus = z.infer<typeof Contact.shape.status>;\n\nexport type CheckUserIsSubscribedResponse = {\n createdAt?: string;\n status?: 'unsubscribed' | 'subscribed' | 'pending';\n};\n\nexport type UpsertContactResponse = {\n subscribed: boolean;\n};\n\nexport const SubscribeContactRequest = z.object({\n email: emailSchema,\n language: z.string(),\n});\n\nexport type SubscribeContactRequest = z.infer<typeof SubscribeContactRequest>;\n\nexport type SubscribeContactResponse = {\n subscribedAt: string;\n};\n"]}
|
|
@@ -1,27 +1,70 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export declare const UserSearch: z.ZodObject<{
|
|
2
|
+
export declare const UserSearch: z.ZodObject<z.objectUtil.extendShape<{
|
|
3
3
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
4
|
-
filters: z.ZodRecord<z.ZodString, z.ZodUnknown
|
|
4
|
+
filters: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnknown>, Record<string, unknown>, Record<string, unknown>>;
|
|
5
5
|
queryString: z.ZodString;
|
|
6
6
|
resultCount: z.ZodNumber;
|
|
7
7
|
countryCode: z.ZodOptional<z.ZodString>;
|
|
8
8
|
language: z.ZodOptional<z.ZodString>;
|
|
9
9
|
browserLocale: z.ZodOptional<z.ZodString>;
|
|
10
10
|
origin: z.ZodOptional<z.ZodString>;
|
|
11
|
-
|
|
11
|
+
}, {
|
|
12
|
+
id: z.ZodString;
|
|
12
13
|
createdBy: z.ZodString;
|
|
13
14
|
createdAt: z.ZodString;
|
|
14
|
-
}, z.
|
|
15
|
+
}>, "strict", z.ZodTypeAny, {
|
|
16
|
+
filters: Record<string, unknown>;
|
|
17
|
+
queryString: string;
|
|
18
|
+
resultCount: number;
|
|
19
|
+
id: string;
|
|
20
|
+
createdBy: string;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
language?: string | undefined;
|
|
23
|
+
sessionId?: string | undefined;
|
|
24
|
+
countryCode?: string | undefined;
|
|
25
|
+
browserLocale?: string | undefined;
|
|
26
|
+
origin?: string | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
filters: Record<string, unknown>;
|
|
29
|
+
queryString: string;
|
|
30
|
+
resultCount: number;
|
|
31
|
+
id: string;
|
|
32
|
+
createdBy: string;
|
|
33
|
+
createdAt: string;
|
|
34
|
+
language?: string | undefined;
|
|
35
|
+
sessionId?: string | undefined;
|
|
36
|
+
countryCode?: string | undefined;
|
|
37
|
+
browserLocale?: string | undefined;
|
|
38
|
+
origin?: string | undefined;
|
|
39
|
+
}>;
|
|
15
40
|
export type UserSearch = z.infer<typeof UserSearch>;
|
|
16
41
|
export declare const NewUserSearch: z.ZodObject<{
|
|
17
42
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
18
|
-
filters: z.ZodRecord<z.ZodString, z.ZodUnknown
|
|
43
|
+
filters: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnknown>, Record<string, unknown>, Record<string, unknown>>;
|
|
19
44
|
queryString: z.ZodString;
|
|
20
45
|
resultCount: z.ZodNumber;
|
|
21
46
|
countryCode: z.ZodOptional<z.ZodString>;
|
|
22
47
|
language: z.ZodOptional<z.ZodString>;
|
|
23
48
|
browserLocale: z.ZodOptional<z.ZodString>;
|
|
24
49
|
origin: z.ZodOptional<z.ZodString>;
|
|
25
|
-
}, z.
|
|
50
|
+
}, "strict", z.ZodTypeAny, {
|
|
51
|
+
filters: Record<string, unknown>;
|
|
52
|
+
queryString: string;
|
|
53
|
+
resultCount: number;
|
|
54
|
+
language?: string | undefined;
|
|
55
|
+
sessionId?: string | undefined;
|
|
56
|
+
countryCode?: string | undefined;
|
|
57
|
+
browserLocale?: string | undefined;
|
|
58
|
+
origin?: string | undefined;
|
|
59
|
+
}, {
|
|
60
|
+
filters: Record<string, unknown>;
|
|
61
|
+
queryString: string;
|
|
62
|
+
resultCount: number;
|
|
63
|
+
language?: string | undefined;
|
|
64
|
+
sessionId?: string | undefined;
|
|
65
|
+
countryCode?: string | undefined;
|
|
66
|
+
browserLocale?: string | undefined;
|
|
67
|
+
origin?: string | undefined;
|
|
68
|
+
}>;
|
|
26
69
|
export type NewUserSearch = z.infer<typeof NewUserSearch>;
|
|
27
70
|
//# sourceMappingURL=user-searches.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-searches.d.ts","sourceRoot":"/","sources":["types/user-searches.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAmBxB,eAAO,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"user-searches.d.ts","sourceRoot":"/","sources":["types/user-searches.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAmBxB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIrB,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAiB,CAAC;AAE5C,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-searches.js","sourceRoot":"/","sources":["types/user-searches.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,cAAc,GAAG,CAAC;KACrB,MAAM,CAAC;IACN,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,OAAO,EAAE,CAAC;SACP,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;SAC/B,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,EAAE,OAAO,EAAE,yBAAyB,EAAE,CAAC;IACvF,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACpC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC;KACD,MAAM,EAAE,CAAC;AAIZ,MAAM,CAAC,MAAM,UAAU,GAAG,cAAc,CAAC,MAAM,CAAC;IAC9C,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;
|
|
1
|
+
{"version":3,"file":"user-searches.js","sourceRoot":"/","sources":["types/user-searches.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,cAAc,GAAG,CAAC;KACrB,MAAM,CAAC;IACN,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,OAAO,EAAE,CAAC;SACP,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;SAC/B,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,EAAE,OAAO,EAAE,yBAAyB,EAAE,CAAC;IACvF,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACpC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC;KACD,MAAM,EAAE,CAAC;AAIZ,MAAM,CAAC,MAAM,UAAU,GAAG,cAAc,CAAC,MAAM,CAAC;IAC9C,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;IACrB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;CACtB,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,aAAa,GAAG,cAAc,CAAC","sourcesContent":["import { z } from 'zod';\n\nconst BaseUserSearch = z\n .object({\n sessionId: z.string().optional(),\n filters: z\n .record(z.string(), z.unknown())\n .refine((obj) => Object.keys(obj).length > 0, { message: 'filters cannot be empty' }),\n queryString: z.string(),\n resultCount: z.number(),\n countryCode: z.string().optional(),\n language: z.string().optional(),\n browserLocale: z.string().optional(),\n origin: z.string().optional(),\n })\n .strict();\n\ntype BaseUserSearch = z.infer<typeof BaseUserSearch>;\n\nexport const UserSearch = BaseUserSearch.extend({\n id: z.string().uuid(),\n createdBy: z.string(),\n createdAt: z.string(),\n});\n\nexport type UserSearch = z.infer<typeof UserSearch>;\n\nexport const NewUserSearch = BaseUserSearch;\n\nexport type NewUserSearch = z.infer<typeof NewUserSearch>;\n"]}
|
package/lib/types/user.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import { MarketingChannel } from './index.js';
|
|
2
3
|
export type AuthRequest = {
|
|
3
4
|
userId: string;
|
|
@@ -7,21 +8,93 @@ export declare enum FleetSize {
|
|
|
7
8
|
Medium = "2-5",
|
|
8
9
|
Large = "6+"
|
|
9
10
|
}
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
export declare const VatSchema: z.ZodEffects<z.ZodString, string | undefined, string>;
|
|
12
|
+
export declare const isValidVatForCountry: ({ vat, country, }: {
|
|
13
|
+
vat: string;
|
|
14
|
+
country: string;
|
|
15
|
+
}) => boolean;
|
|
16
|
+
export declare const CompanySchema: z.ZodObject<{
|
|
17
|
+
country: z.ZodOptional<z.ZodString>;
|
|
18
|
+
city: z.ZodOptional<z.ZodString>;
|
|
19
|
+
name: z.ZodOptional<z.ZodString>;
|
|
20
|
+
vat: z.ZodOptional<z.ZodEffects<z.ZodString, string | undefined, string>>;
|
|
21
|
+
postalCode: z.ZodOptional<z.ZodString>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
country?: string | undefined;
|
|
24
|
+
vat?: string | undefined;
|
|
25
|
+
city?: string | undefined;
|
|
26
|
+
name?: string | undefined;
|
|
27
|
+
postalCode?: string | undefined;
|
|
28
|
+
}, {
|
|
29
|
+
country?: string | undefined;
|
|
30
|
+
vat?: string | undefined;
|
|
31
|
+
city?: string | undefined;
|
|
32
|
+
name?: string | undefined;
|
|
33
|
+
postalCode?: string | undefined;
|
|
34
|
+
}>;
|
|
35
|
+
export declare function refineCompanySchema(schema: z.ZodRawShape): z.ZodEffects<z.ZodObject<z.objectUtil.extendShape<{
|
|
36
|
+
country: z.ZodOptional<z.ZodString>;
|
|
37
|
+
city: z.ZodOptional<z.ZodString>;
|
|
38
|
+
name: z.ZodOptional<z.ZodString>;
|
|
39
|
+
vat: z.ZodOptional<z.ZodEffects<z.ZodString, string | undefined, string>>;
|
|
40
|
+
postalCode: z.ZodOptional<z.ZodString>;
|
|
41
|
+
}, z.ZodRawShape>, "strip", z.ZodTypeAny, {
|
|
42
|
+
[x: string]: any;
|
|
43
|
+
}, {
|
|
44
|
+
[x: string]: any;
|
|
45
|
+
}>, {
|
|
46
|
+
[x: string]: any;
|
|
47
|
+
}, {
|
|
48
|
+
[x: string]: any;
|
|
49
|
+
}>;
|
|
50
|
+
export declare const UserDetails: z.ZodObject<{
|
|
51
|
+
firstName: z.ZodOptional<z.ZodString>;
|
|
52
|
+
lastName: z.ZodOptional<z.ZodString>;
|
|
53
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
54
|
+
preferredLanguage: z.ZodOptional<z.ZodString>;
|
|
55
|
+
fleetSize: z.ZodOptional<z.ZodNativeEnum<typeof FleetSize>>;
|
|
56
|
+
trader: z.ZodOptional<z.ZodBoolean>;
|
|
57
|
+
email: z.ZodString;
|
|
58
|
+
company: z.ZodEffects<z.ZodObject<z.objectUtil.extendShape<{
|
|
59
|
+
country: z.ZodOptional<z.ZodString>;
|
|
60
|
+
city: z.ZodOptional<z.ZodString>;
|
|
61
|
+
name: z.ZodOptional<z.ZodString>;
|
|
62
|
+
vat: z.ZodOptional<z.ZodEffects<z.ZodString, string | undefined, string>>;
|
|
63
|
+
postalCode: z.ZodOptional<z.ZodString>;
|
|
64
|
+
}, z.ZodRawShape>, "strip", z.ZodTypeAny, {
|
|
65
|
+
[x: string]: any;
|
|
66
|
+
}, {
|
|
67
|
+
[x: string]: any;
|
|
68
|
+
}>, {
|
|
69
|
+
[x: string]: any;
|
|
70
|
+
}, {
|
|
71
|
+
[x: string]: any;
|
|
72
|
+
}>;
|
|
73
|
+
marketingChannels: z.ZodArray<z.ZodNativeEnum<typeof MarketingChannel>, "many">;
|
|
74
|
+
}, "strip", z.ZodTypeAny, {
|
|
75
|
+
email: string;
|
|
18
76
|
company: {
|
|
19
|
-
|
|
20
|
-
city?: string | undefined;
|
|
21
|
-
name?: string | undefined;
|
|
22
|
-
vat?: string | undefined;
|
|
23
|
-
postalCode?: string | undefined;
|
|
77
|
+
[x: string]: any;
|
|
24
78
|
};
|
|
25
79
|
marketingChannels: MarketingChannel[];
|
|
26
|
-
|
|
80
|
+
phone?: string | undefined;
|
|
81
|
+
firstName?: string | undefined;
|
|
82
|
+
lastName?: string | undefined;
|
|
83
|
+
preferredLanguage?: string | undefined;
|
|
84
|
+
fleetSize?: FleetSize | undefined;
|
|
85
|
+
trader?: boolean | undefined;
|
|
86
|
+
}, {
|
|
87
|
+
email: string;
|
|
88
|
+
company: {
|
|
89
|
+
[x: string]: any;
|
|
90
|
+
};
|
|
91
|
+
marketingChannels: MarketingChannel[];
|
|
92
|
+
phone?: string | undefined;
|
|
93
|
+
firstName?: string | undefined;
|
|
94
|
+
lastName?: string | undefined;
|
|
95
|
+
preferredLanguage?: string | undefined;
|
|
96
|
+
fleetSize?: FleetSize | undefined;
|
|
97
|
+
trader?: boolean | undefined;
|
|
98
|
+
}>;
|
|
99
|
+
export type UserDetails = z.infer<typeof UserDetails>;
|
|
27
100
|
//# sourceMappingURL=user.d.ts.map
|
package/lib/types/user.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.d.ts","sourceRoot":"/","sources":["types/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,oBAAY,SAAS;IACnB,KAAK,MAAM;IACX,MAAM,QAAQ;IACd,KAAK,OAAO;CACb;AAED,
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"/","sources":["types/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,oBAAY,SAAS;IACnB,KAAK,MAAM;IACX,MAAM,QAAQ;IACd,KAAK,OAAO;CACb;AAED,eAAO,MAAM,SAAS,uDAGyB,CAAC;AAiDhD,eAAO,MAAM,oBAAoB,GAAI,mBAGlC;IACD,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACjB,KAAG,OAMH,CAAC;AAWF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;EAMxB,CAAC;AAMH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAC,WAAW;;;;;;;;;;;;;;GAcxD;AAED,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUtB,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC"}
|
package/lib/types/user.js
CHANGED
|
@@ -1,7 +1,94 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { MarketingChannel } from './index.js';
|
|
1
3
|
export var FleetSize;
|
|
2
4
|
(function (FleetSize) {
|
|
3
5
|
FleetSize["Small"] = "1";
|
|
4
6
|
FleetSize["Medium"] = "2-5";
|
|
5
7
|
FleetSize["Large"] = "6+";
|
|
6
8
|
})(FleetSize || (FleetSize = {}));
|
|
9
|
+
export const VatSchema = z
|
|
10
|
+
.string()
|
|
11
|
+
.toUpperCase()
|
|
12
|
+
.transform((v) => (v === '' ? undefined : v));
|
|
13
|
+
const VAT_PATTERNS = {
|
|
14
|
+
AT: /^AT.+/,
|
|
15
|
+
BE: /^BE.+/,
|
|
16
|
+
BG: /^BG.+/,
|
|
17
|
+
CY: /^CY.+/,
|
|
18
|
+
CZ: /^CZ.+/,
|
|
19
|
+
DE: /^DE.+/,
|
|
20
|
+
DK: /^DK.+/,
|
|
21
|
+
EE: /^EE.+/,
|
|
22
|
+
ES: /^ES.+/,
|
|
23
|
+
FI: /^FI.+/,
|
|
24
|
+
FR: /^FR.+/,
|
|
25
|
+
GR: /^EL.+/,
|
|
26
|
+
HR: /^HR.+/,
|
|
27
|
+
HU: /^HU.+/,
|
|
28
|
+
IE: /^IE.+/,
|
|
29
|
+
IT: /^IT.+/,
|
|
30
|
+
LT: /^LT.+/,
|
|
31
|
+
LU: /^LU.+/,
|
|
32
|
+
LV: /^LV.+/,
|
|
33
|
+
MT: /^MT.+/,
|
|
34
|
+
NL: /^NL.+/,
|
|
35
|
+
PL: /^PL.+/,
|
|
36
|
+
PT: /^PT.+/,
|
|
37
|
+
RO: /^RO.+/,
|
|
38
|
+
SE: /^SE.+/,
|
|
39
|
+
SI: /^SI.+/,
|
|
40
|
+
SK: /^SK.+/,
|
|
41
|
+
NO: /^NO.+/,
|
|
42
|
+
IS: /^IS.+/,
|
|
43
|
+
CH: /^CHE.+/,
|
|
44
|
+
GB: /^(GB|XI).+/,
|
|
45
|
+
};
|
|
46
|
+
export const isValidVatForCountry = ({ vat, country, }) => {
|
|
47
|
+
const pattern = VAT_PATTERNS[country.toUpperCase()];
|
|
48
|
+
if (!pattern) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
return pattern.test(vat);
|
|
52
|
+
};
|
|
53
|
+
const getVatPrefix = (country) => {
|
|
54
|
+
const pattern = VAT_PATTERNS[country.toUpperCase()];
|
|
55
|
+
if (!pattern) {
|
|
56
|
+
return '';
|
|
57
|
+
}
|
|
58
|
+
const match = pattern.toString().match(/\^(\w+)/);
|
|
59
|
+
return match ? match[1] : '';
|
|
60
|
+
};
|
|
61
|
+
export const CompanySchema = z.object({
|
|
62
|
+
country: z.string().optional(),
|
|
63
|
+
city: z.string().optional(),
|
|
64
|
+
name: z.string().optional(),
|
|
65
|
+
vat: VatSchema.optional(),
|
|
66
|
+
postalCode: z.string().optional(),
|
|
67
|
+
});
|
|
68
|
+
export function refineCompanySchema(schema) {
|
|
69
|
+
return CompanySchema.extend(schema).superRefine((data, ctx) => {
|
|
70
|
+
if (!data.vat || !data.country) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (!isValidVatForCountry({ vat: data.vat, country: data.country })) {
|
|
74
|
+
const prefix = getVatPrefix(data.country);
|
|
75
|
+
ctx.addIssue({
|
|
76
|
+
code: z.ZodIssueCode.custom,
|
|
77
|
+
path: ['vat'],
|
|
78
|
+
params: { prefix, messageKey: 'vat.invalidFormat' },
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
export const UserDetails = z.object({
|
|
84
|
+
firstName: z.string().optional(),
|
|
85
|
+
lastName: z.string().optional(),
|
|
86
|
+
phone: z.string().optional(),
|
|
87
|
+
preferredLanguage: z.string().optional(),
|
|
88
|
+
fleetSize: z.nativeEnum(FleetSize).optional(),
|
|
89
|
+
trader: z.boolean().optional(),
|
|
90
|
+
email: z.string().email().toLowerCase(),
|
|
91
|
+
company: refineCompanySchema({}),
|
|
92
|
+
marketingChannels: z.array(z.nativeEnum(MarketingChannel)),
|
|
93
|
+
});
|
|
7
94
|
//# sourceMappingURL=user.js.map
|
package/lib/types/user.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","sourceRoot":"/","sources":["types/user.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user.js","sourceRoot":"/","sources":["types/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAA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CAAC;QACD,IAAI,CAAC,oBAAoB,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;YACpE,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC1C,GAAG,CAAC,QAAQ,CAAC;gBACX,IAAI,EAAE,CAAC,CAAC,YAAY,CAAC,MAAM;gBAC3B,IAAI,EAAE,CAAC,KAAK,CAAC;gBACb,MAAM,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,mBAAmB,EAAE;aACpD,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACxC,SAAS,EAAE,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE;IAC7C,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC9B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE;IACvC,OAAO,EAAE,mBAAmB,CAAC,EAAE,CAAC;IAChC,iBAAiB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;CAC3D,CAAC,CAAC","sourcesContent":["import { z } from 'zod';\nimport { MarketingChannel } from './index.js';\n\nexport type AuthRequest = {\n userId: string;\n};\n\nexport enum FleetSize {\n Small = '1',\n Medium = '2-5',\n Large = '6+',\n}\n\nexport const VatSchema = z\n .string()\n .toUpperCase()\n .transform((v) => (v === '' ? undefined : v));\n\n/**\n * Light VAT-number validation patterns by country.\n *\n * Countries without an entry accept any VAT number (no validation).\n *\n * Includes EU-27, EEA non-EU (NO, IS), Switzerland (CH), and the UK (GB).\n * Note: Liechtenstein shares the Swiss CHE VAT system and is intentionally\n * excluded — its numbers don't start with \"LI\".\n */\nconst VAT_PATTERNS: Record<string, RegExp> = {\n // EU-27\n AT: /^AT.+/,\n BE: /^BE.+/,\n BG: /^BG.+/,\n CY: /^CY.+/,\n CZ: /^CZ.+/,\n DE: /^DE.+/,\n DK: /^DK.+/,\n EE: /^EE.+/,\n ES: /^ES.+/,\n FI: /^FI.+/,\n FR: /^FR.+/,\n GR: /^EL.+/,\n HR: /^HR.+/,\n HU: /^HU.+/,\n IE: /^IE.+/,\n IT: /^IT.+/,\n LT: /^LT.+/,\n LU: /^LU.+/,\n LV: /^LV.+/,\n MT: /^MT.+/,\n NL: /^NL.+/,\n PL: /^PL.+/,\n PT: /^PT.+/,\n RO: /^RO.+/,\n SE: /^SE.+/,\n SI: /^SI.+/,\n SK: /^SK.+/,\n // EEA non-EU\n NO: /^NO.+/,\n IS: /^IS.+/,\n // Switzerland — 3-letter CHE prefix\n CH: /^CHE.+/,\n // United Kingdom + Northern Ireland (XI prefix post-Brexit)\n GB: /^(GB|XI).+/,\n};\n\nexport const isValidVatForCountry = ({\n vat,\n country,\n}: {\n vat: string;\n country: string;\n}): boolean => {\n const pattern = VAT_PATTERNS[country.toUpperCase()];\n if (!pattern) {\n return true;\n }\n return pattern.test(vat);\n};\n\nconst getVatPrefix = (country: string): string => {\n const pattern = VAT_PATTERNS[country.toUpperCase()];\n if (!pattern) {\n return '';\n }\n const match = pattern.toString().match(/\\^(\\w+)/);\n return match ? match[1] : '';\n};\n\nexport const CompanySchema = z.object({\n country: z.string().optional(),\n city: z.string().optional(),\n name: z.string().optional(),\n vat: VatSchema.optional(),\n postalCode: z.string().optional(),\n});\n\n/* TODO when updating to zod v4, change addIssue options to\n message: 'vat.invalidFormat',\n path: ['vat'],\n */\nexport function refineCompanySchema(schema: z.ZodRawShape) {\n return CompanySchema.extend(schema).superRefine((data, ctx) => {\n if (!data.vat || !data.country) {\n return;\n }\n if (!isValidVatForCountry({ vat: data.vat, country: data.country })) {\n const prefix = getVatPrefix(data.country);\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['vat'],\n params: { prefix, messageKey: 'vat.invalidFormat' },\n });\n }\n });\n}\n\nexport const UserDetails = z.object({\n firstName: z.string().optional(),\n lastName: z.string().optional(),\n phone: z.string().optional(),\n preferredLanguage: z.string().optional(),\n fleetSize: z.nativeEnum(FleetSize).optional(),\n trader: z.boolean().optional(),\n email: z.string().email().toLowerCase(),\n company: refineCompanySchema({}),\n marketingChannels: z.array(z.nativeEnum(MarketingChannel)),\n});\n\nexport type UserDetails = z.infer<typeof UserDetails>;\n"]}
|
package/lib/utils/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["utils/index.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,oBAAY,QAAQ;IAClB,IAAI,oEAAoE;IACxE,YAAY,mEAAmE;IAC/E,SAAS,+BAA+B;IACxC,iBAAiB,yCAAyC;IAC1D,aAAa,qCAAqC;CACnD;AAED,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["utils/index.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,oBAAY,QAAQ;IAClB,IAAI,oEAAoE;IACxE,YAAY,mEAAmE;IAC/E,SAAS,+BAA+B;IACxC,iBAAiB,yCAAyC;IAC1D,aAAa,qCAAqC;CACnD;AAED,eAAO,MAAM,UAAU,GAAI,WAAU,MAAW,EAAE,WAAU,QAAwB,KAAG,MAQtF,CAAC;AA2DF,eAAO,MAAM,OAAO,GAAI,KAAK,MAAM,EAAE,OAAO,IAAI,CAAC,OAAO,WAMpD,CAAC;AAEL,eAAO,MAAM,aAAa,GAAI,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,EAAE,SAAS,MAAM,aACkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vehicle.d.ts","sourceRoot":"/","sources":["utils/vehicle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"vehicle.d.ts","sourceRoot":"/","sources":["utils/vehicle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,eAAO,MAAM,qBAAqB,GAAI,WAAW,MAAM,WAA0B,CAAC;AAElF,eAAO,MAAM,iBAAiB,GAAI,SAAS,cAAc,YAGV,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bisondesk/website-commons-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.39",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "npx tsc --build",
|
|
@@ -19,12 +19,15 @@
|
|
|
19
19
|
"pino": "9.8.0",
|
|
20
20
|
"pino-pretty": "13.1.1",
|
|
21
21
|
"slug": "11.0.1",
|
|
22
|
-
"zod": "
|
|
22
|
+
"zod": "3.23.8"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/lodash-es": "4.17.12",
|
|
26
26
|
"@types/slug": "5.0.9",
|
|
27
|
-
"typescript": "5.
|
|
27
|
+
"typescript": "5.8.3"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"zod": ">=3.23.8 <4.0.0"
|
|
28
31
|
},
|
|
29
32
|
"typesVersions": {
|
|
30
33
|
"*": {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const emailSchema = z.string().email().min(1).toLowerCase();
|
|
4
|
+
|
|
5
|
+
export const Contact = z.object({
|
|
6
|
+
email: emailSchema,
|
|
7
|
+
status: z.enum(['unsubscribed', 'subscribed', 'pending']).optional(),
|
|
8
|
+
fields: z
|
|
9
|
+
.object({
|
|
10
|
+
Country: z.string().nullable().optional(),
|
|
11
|
+
PreferredLanguage: z.string().nullable().optional(),
|
|
12
|
+
FirstName: z.string().nullable().optional(),
|
|
13
|
+
LastName: z.string().nullable().optional(),
|
|
14
|
+
})
|
|
15
|
+
.transform((data) => {
|
|
16
|
+
const normalizedData = Object.fromEntries(
|
|
17
|
+
Object.entries(data).filter(([, value]) => value !== undefined)
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
return normalizedData;
|
|
21
|
+
}),
|
|
22
|
+
tags: z.record(z.string(), z.boolean()).optional(),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export type Contact = z.input<typeof Contact>;
|
|
26
|
+
|
|
27
|
+
export const CheckUserIsSubscribedRequest = z.object({
|
|
28
|
+
email: emailSchema,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export type CheckUserIsSubscribedRequest = z.infer<typeof CheckUserIsSubscribedRequest>;
|
|
32
|
+
|
|
33
|
+
export type ContactStatus = z.infer<typeof Contact.shape.status>;
|
|
34
|
+
|
|
35
|
+
export type CheckUserIsSubscribedResponse = {
|
|
36
|
+
createdAt?: string;
|
|
37
|
+
status?: 'unsubscribed' | 'subscribed' | 'pending';
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type UpsertContactResponse = {
|
|
41
|
+
subscribed: boolean;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const SubscribeContactRequest = z.object({
|
|
45
|
+
email: emailSchema,
|
|
46
|
+
language: z.string(),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export type SubscribeContactRequest = z.infer<typeof SubscribeContactRequest>;
|
|
50
|
+
|
|
51
|
+
export type SubscribeContactResponse = {
|
|
52
|
+
subscribedAt: string;
|
|
53
|
+
};
|