@voyantjs/storefront 0.3.0
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 +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/routes-public.d.ts +70 -0
- package/dist/routes-public.d.ts.map +1 -0
- package/dist/routes-public.js +8 -0
- package/dist/service.d.ts +9 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +66 -0
- package/dist/validation.d.ts +270 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +124 -0
- package/package.json +62 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Module } from "@voyantjs/core";
|
|
2
|
+
import type { HonoModule } from "@voyantjs/hono/module";
|
|
3
|
+
import { createStorefrontPublicRoutes } from "./routes-public.js";
|
|
4
|
+
export { createStorefrontPublicRoutes } from "./routes-public.js";
|
|
5
|
+
export type { StorefrontPublicRoutes } from "./routes-public.js";
|
|
6
|
+
export { createStorefrontService, resolveStorefrontSettings } from "./service.js";
|
|
7
|
+
export type { StorefrontServiceOptions } from "./service.js";
|
|
8
|
+
export type { StorefrontFormField, StorefrontFormFieldInput, StorefrontPaymentMethod, StorefrontPaymentMethodCode, StorefrontPaymentMethodInput, StorefrontSettings, StorefrontSettingsInput, } from "./validation.js";
|
|
9
|
+
export { storefrontFormFieldInputSchema, storefrontFormFieldOptionSchema, storefrontFormFieldSchema, storefrontFormFieldTypeSchema, storefrontPaymentMethodCodeSchema, storefrontPaymentMethodInputSchema, storefrontPaymentMethodSchema, storefrontSettingsInputSchema, storefrontSettingsSchema, } from "./validation.js";
|
|
10
|
+
export declare const storefrontModule: Module;
|
|
11
|
+
export declare function createStorefrontHonoModule(options?: Parameters<typeof createStorefrontPublicRoutes>[0]): HonoModule;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAA;AAEjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAA;AACjE,YAAY,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAChE,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACjF,YAAY,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA;AAC5D,YAAY,EACV,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EACvB,2BAA2B,EAC3B,4BAA4B,EAC5B,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,8BAA8B,EAC9B,+BAA+B,EAC/B,yBAAyB,EACzB,6BAA6B,EAC7B,iCAAiC,EACjC,kCAAkC,EAClC,6BAA6B,EAC7B,6BAA6B,EAC7B,wBAAwB,GACzB,MAAM,iBAAiB,CAAA;AAExB,eAAO,MAAM,gBAAgB,EAAE,MAE9B,CAAA;AAED,wBAAgB,0BAA0B,CACxC,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,4BAA4B,CAAC,CAAC,CAAC,CAAC,GAC3D,UAAU,CAKZ"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createStorefrontPublicRoutes } from "./routes-public.js";
|
|
2
|
+
export { createStorefrontPublicRoutes } from "./routes-public.js";
|
|
3
|
+
export { createStorefrontService, resolveStorefrontSettings } from "./service.js";
|
|
4
|
+
export { storefrontFormFieldInputSchema, storefrontFormFieldOptionSchema, storefrontFormFieldSchema, storefrontFormFieldTypeSchema, storefrontPaymentMethodCodeSchema, storefrontPaymentMethodInputSchema, storefrontPaymentMethodSchema, storefrontSettingsInputSchema, storefrontSettingsSchema, } from "./validation.js";
|
|
5
|
+
export const storefrontModule = {
|
|
6
|
+
name: "storefront",
|
|
7
|
+
};
|
|
8
|
+
export function createStorefrontHonoModule(options) {
|
|
9
|
+
return {
|
|
10
|
+
module: storefrontModule,
|
|
11
|
+
publicRoutes: createStorefrontPublicRoutes(options),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type StorefrontServiceOptions } from "./service.js";
|
|
2
|
+
export declare function createStorefrontPublicRoutes(options?: StorefrontServiceOptions): import("hono/hono-base").HonoBase<import("hono/types").BlankEnv, {
|
|
3
|
+
"/settings": {
|
|
4
|
+
$get: {
|
|
5
|
+
input: {};
|
|
6
|
+
output: {
|
|
7
|
+
data: {
|
|
8
|
+
branding: {
|
|
9
|
+
logoUrl: string | null;
|
|
10
|
+
supportedLanguages: string[];
|
|
11
|
+
};
|
|
12
|
+
support: {
|
|
13
|
+
email: string | null;
|
|
14
|
+
phone: string | null;
|
|
15
|
+
};
|
|
16
|
+
legal: {
|
|
17
|
+
termsUrl: string | null;
|
|
18
|
+
privacyUrl: string | null;
|
|
19
|
+
defaultContractTemplateId: string | null;
|
|
20
|
+
};
|
|
21
|
+
forms: {
|
|
22
|
+
billing: {
|
|
23
|
+
fields: {
|
|
24
|
+
key: string;
|
|
25
|
+
label: string;
|
|
26
|
+
type: "text" | "email" | "tel" | "textarea" | "select" | "checkbox" | "date" | "country";
|
|
27
|
+
required: boolean;
|
|
28
|
+
placeholder: string | null;
|
|
29
|
+
description: string | null;
|
|
30
|
+
autocomplete: string | null;
|
|
31
|
+
options: {
|
|
32
|
+
value: string;
|
|
33
|
+
label: string;
|
|
34
|
+
}[];
|
|
35
|
+
}[];
|
|
36
|
+
};
|
|
37
|
+
passengers: {
|
|
38
|
+
fields: {
|
|
39
|
+
key: string;
|
|
40
|
+
label: string;
|
|
41
|
+
type: "text" | "email" | "tel" | "textarea" | "select" | "checkbox" | "date" | "country";
|
|
42
|
+
required: boolean;
|
|
43
|
+
placeholder: string | null;
|
|
44
|
+
description: string | null;
|
|
45
|
+
autocomplete: string | null;
|
|
46
|
+
options: {
|
|
47
|
+
value: string;
|
|
48
|
+
label: string;
|
|
49
|
+
}[];
|
|
50
|
+
}[];
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
payment: {
|
|
54
|
+
defaultMethod: "card" | "bank_transfer" | "cash" | "voucher" | "invoice" | null;
|
|
55
|
+
methods: {
|
|
56
|
+
code: "card" | "bank_transfer" | "cash" | "voucher" | "invoice";
|
|
57
|
+
label: string;
|
|
58
|
+
description: string | null;
|
|
59
|
+
enabled: boolean;
|
|
60
|
+
}[];
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
outputFormat: "json";
|
|
65
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
}, "/", "/settings">;
|
|
69
|
+
export type StorefrontPublicRoutes = ReturnType<typeof createStorefrontPublicRoutes>;
|
|
70
|
+
//# sourceMappingURL=routes-public.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes-public.d.ts","sourceRoot":"","sources":["../src/routes-public.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2B,KAAK,wBAAwB,EAAE,MAAM,cAAc,CAAA;AAErF,wBAAgB,4BAA4B,CAAC,OAAO,CAAC,EAAE,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAM9E;AAED,MAAM,MAAM,sBAAsB,GAAG,UAAU,CAAC,OAAO,4BAA4B,CAAC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import { createStorefrontService } from "./service.js";
|
|
3
|
+
export function createStorefrontPublicRoutes(options) {
|
|
4
|
+
const storefrontService = createStorefrontService(options);
|
|
5
|
+
return new Hono().get("/settings", (c) => {
|
|
6
|
+
return c.json({ data: storefrontService.getSettings() });
|
|
7
|
+
});
|
|
8
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type StorefrontSettings, type StorefrontSettingsInput } from "./validation.js";
|
|
2
|
+
export interface StorefrontServiceOptions {
|
|
3
|
+
settings?: StorefrontSettingsInput;
|
|
4
|
+
}
|
|
5
|
+
export declare function resolveStorefrontSettings(input?: StorefrontSettingsInput): StorefrontSettings;
|
|
6
|
+
export declare function createStorefrontService(options?: StorefrontServiceOptions): {
|
|
7
|
+
getSettings(): StorefrontSettings;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC7B,MAAM,iBAAiB,CAAA;AAExB,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,uBAAuB,CAAA;CACnC;AAgCD,wBAAgB,yBAAyB,CAAC,KAAK,CAAC,EAAE,uBAAuB,GAAG,kBAAkB,CA8B7F;AAED,wBAAgB,uBAAuB,CAAC,OAAO,CAAC,EAAE,wBAAwB;mBAIvD,kBAAkB;EAIpC"}
|
package/dist/service.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { storefrontSettingsInputSchema, storefrontSettingsSchema, } from "./validation.js";
|
|
2
|
+
const defaultPaymentLabels = {
|
|
3
|
+
card: "Card",
|
|
4
|
+
bank_transfer: "Bank transfer",
|
|
5
|
+
cash: "Cash",
|
|
6
|
+
voucher: "Voucher",
|
|
7
|
+
invoice: "Invoice",
|
|
8
|
+
};
|
|
9
|
+
function normalizeField(field) {
|
|
10
|
+
return {
|
|
11
|
+
key: field.key,
|
|
12
|
+
label: field.label,
|
|
13
|
+
type: field.type,
|
|
14
|
+
required: field.required,
|
|
15
|
+
placeholder: field.placeholder ?? null,
|
|
16
|
+
description: field.description ?? null,
|
|
17
|
+
autocomplete: field.autocomplete ?? null,
|
|
18
|
+
options: field.options,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function normalizePaymentMethod(method) {
|
|
22
|
+
return {
|
|
23
|
+
code: method.code,
|
|
24
|
+
label: method.label ?? defaultPaymentLabels[method.code],
|
|
25
|
+
description: method.description ?? null,
|
|
26
|
+
enabled: method.enabled,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export function resolveStorefrontSettings(input) {
|
|
30
|
+
const parsed = storefrontSettingsInputSchema.parse(input ?? {});
|
|
31
|
+
return storefrontSettingsSchema.parse({
|
|
32
|
+
branding: {
|
|
33
|
+
logoUrl: parsed.branding?.logoUrl ?? null,
|
|
34
|
+
supportedLanguages: parsed.branding?.supportedLanguages ?? [],
|
|
35
|
+
},
|
|
36
|
+
support: {
|
|
37
|
+
email: parsed.support?.email ?? null,
|
|
38
|
+
phone: parsed.support?.phone ?? null,
|
|
39
|
+
},
|
|
40
|
+
legal: {
|
|
41
|
+
termsUrl: parsed.legal?.termsUrl ?? null,
|
|
42
|
+
privacyUrl: parsed.legal?.privacyUrl ?? null,
|
|
43
|
+
defaultContractTemplateId: parsed.legal?.defaultContractTemplateId ?? null,
|
|
44
|
+
},
|
|
45
|
+
forms: {
|
|
46
|
+
billing: {
|
|
47
|
+
fields: (parsed.forms?.billing?.fields ?? []).map(normalizeField),
|
|
48
|
+
},
|
|
49
|
+
passengers: {
|
|
50
|
+
fields: (parsed.forms?.passengers?.fields ?? []).map(normalizeField),
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
payment: {
|
|
54
|
+
defaultMethod: parsed.payment?.defaultMethod ?? null,
|
|
55
|
+
methods: (parsed.payment?.methods ?? []).map(normalizePaymentMethod),
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
export function createStorefrontService(options) {
|
|
60
|
+
const settings = resolveStorefrontSettings(options?.settings);
|
|
61
|
+
return {
|
|
62
|
+
getSettings() {
|
|
63
|
+
return settings;
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const storefrontPaymentMethodCodeSchema: z.ZodEnum<{
|
|
3
|
+
card: "card";
|
|
4
|
+
bank_transfer: "bank_transfer";
|
|
5
|
+
cash: "cash";
|
|
6
|
+
voucher: "voucher";
|
|
7
|
+
invoice: "invoice";
|
|
8
|
+
}>;
|
|
9
|
+
export declare const storefrontFormFieldTypeSchema: z.ZodEnum<{
|
|
10
|
+
text: "text";
|
|
11
|
+
email: "email";
|
|
12
|
+
tel: "tel";
|
|
13
|
+
textarea: "textarea";
|
|
14
|
+
select: "select";
|
|
15
|
+
checkbox: "checkbox";
|
|
16
|
+
date: "date";
|
|
17
|
+
country: "country";
|
|
18
|
+
}>;
|
|
19
|
+
export declare const storefrontFormFieldOptionSchema: z.ZodObject<{
|
|
20
|
+
value: z.ZodString;
|
|
21
|
+
label: z.ZodString;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export declare const storefrontFormFieldInputSchema: z.ZodObject<{
|
|
24
|
+
key: z.ZodString;
|
|
25
|
+
label: z.ZodString;
|
|
26
|
+
type: z.ZodDefault<z.ZodEnum<{
|
|
27
|
+
text: "text";
|
|
28
|
+
email: "email";
|
|
29
|
+
tel: "tel";
|
|
30
|
+
textarea: "textarea";
|
|
31
|
+
select: "select";
|
|
32
|
+
checkbox: "checkbox";
|
|
33
|
+
date: "date";
|
|
34
|
+
country: "country";
|
|
35
|
+
}>>;
|
|
36
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
37
|
+
placeholder: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
38
|
+
description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
39
|
+
autocomplete: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
40
|
+
options: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
41
|
+
value: z.ZodString;
|
|
42
|
+
label: z.ZodString;
|
|
43
|
+
}, z.core.$strip>>>;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
export declare const storefrontFormFieldSchema: z.ZodObject<{
|
|
46
|
+
key: z.ZodString;
|
|
47
|
+
label: z.ZodString;
|
|
48
|
+
type: z.ZodEnum<{
|
|
49
|
+
text: "text";
|
|
50
|
+
email: "email";
|
|
51
|
+
tel: "tel";
|
|
52
|
+
textarea: "textarea";
|
|
53
|
+
select: "select";
|
|
54
|
+
checkbox: "checkbox";
|
|
55
|
+
date: "date";
|
|
56
|
+
country: "country";
|
|
57
|
+
}>;
|
|
58
|
+
required: z.ZodBoolean;
|
|
59
|
+
placeholder: z.ZodNullable<z.ZodString>;
|
|
60
|
+
description: z.ZodNullable<z.ZodString>;
|
|
61
|
+
autocomplete: z.ZodNullable<z.ZodString>;
|
|
62
|
+
options: z.ZodArray<z.ZodObject<{
|
|
63
|
+
value: z.ZodString;
|
|
64
|
+
label: z.ZodString;
|
|
65
|
+
}, z.core.$strip>>;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
export declare const storefrontPaymentMethodInputSchema: z.ZodObject<{
|
|
68
|
+
code: z.ZodEnum<{
|
|
69
|
+
card: "card";
|
|
70
|
+
bank_transfer: "bank_transfer";
|
|
71
|
+
cash: "cash";
|
|
72
|
+
voucher: "voucher";
|
|
73
|
+
invoice: "invoice";
|
|
74
|
+
}>;
|
|
75
|
+
label: z.ZodOptional<z.ZodString>;
|
|
76
|
+
description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
77
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
78
|
+
}, z.core.$strip>;
|
|
79
|
+
export declare const storefrontPaymentMethodSchema: z.ZodObject<{
|
|
80
|
+
code: z.ZodEnum<{
|
|
81
|
+
card: "card";
|
|
82
|
+
bank_transfer: "bank_transfer";
|
|
83
|
+
cash: "cash";
|
|
84
|
+
voucher: "voucher";
|
|
85
|
+
invoice: "invoice";
|
|
86
|
+
}>;
|
|
87
|
+
label: z.ZodString;
|
|
88
|
+
description: z.ZodNullable<z.ZodString>;
|
|
89
|
+
enabled: z.ZodBoolean;
|
|
90
|
+
}, z.core.$strip>;
|
|
91
|
+
export declare const storefrontSettingsInputSchema: z.ZodObject<{
|
|
92
|
+
branding: z.ZodOptional<z.ZodObject<{
|
|
93
|
+
logoUrl: z.ZodNullable<z.ZodOptional<z.ZodURL>>;
|
|
94
|
+
supportedLanguages: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
95
|
+
}, z.core.$strip>>;
|
|
96
|
+
support: z.ZodOptional<z.ZodObject<{
|
|
97
|
+
email: z.ZodNullable<z.ZodOptional<z.ZodEmail>>;
|
|
98
|
+
phone: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
99
|
+
}, z.core.$strip>>;
|
|
100
|
+
legal: z.ZodOptional<z.ZodObject<{
|
|
101
|
+
termsUrl: z.ZodNullable<z.ZodOptional<z.ZodURL>>;
|
|
102
|
+
privacyUrl: z.ZodNullable<z.ZodOptional<z.ZodURL>>;
|
|
103
|
+
defaultContractTemplateId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
104
|
+
}, z.core.$strip>>;
|
|
105
|
+
forms: z.ZodOptional<z.ZodObject<{
|
|
106
|
+
billing: z.ZodOptional<z.ZodObject<{
|
|
107
|
+
fields: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
108
|
+
key: z.ZodString;
|
|
109
|
+
label: z.ZodString;
|
|
110
|
+
type: z.ZodDefault<z.ZodEnum<{
|
|
111
|
+
text: "text";
|
|
112
|
+
email: "email";
|
|
113
|
+
tel: "tel";
|
|
114
|
+
textarea: "textarea";
|
|
115
|
+
select: "select";
|
|
116
|
+
checkbox: "checkbox";
|
|
117
|
+
date: "date";
|
|
118
|
+
country: "country";
|
|
119
|
+
}>>;
|
|
120
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
121
|
+
placeholder: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
122
|
+
description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
123
|
+
autocomplete: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
124
|
+
options: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
125
|
+
value: z.ZodString;
|
|
126
|
+
label: z.ZodString;
|
|
127
|
+
}, z.core.$strip>>>;
|
|
128
|
+
}, z.core.$strip>>>;
|
|
129
|
+
}, z.core.$strip>>;
|
|
130
|
+
passengers: z.ZodOptional<z.ZodObject<{
|
|
131
|
+
fields: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
132
|
+
key: z.ZodString;
|
|
133
|
+
label: z.ZodString;
|
|
134
|
+
type: z.ZodDefault<z.ZodEnum<{
|
|
135
|
+
text: "text";
|
|
136
|
+
email: "email";
|
|
137
|
+
tel: "tel";
|
|
138
|
+
textarea: "textarea";
|
|
139
|
+
select: "select";
|
|
140
|
+
checkbox: "checkbox";
|
|
141
|
+
date: "date";
|
|
142
|
+
country: "country";
|
|
143
|
+
}>>;
|
|
144
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
145
|
+
placeholder: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
146
|
+
description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
147
|
+
autocomplete: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
148
|
+
options: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
149
|
+
value: z.ZodString;
|
|
150
|
+
label: z.ZodString;
|
|
151
|
+
}, z.core.$strip>>>;
|
|
152
|
+
}, z.core.$strip>>>;
|
|
153
|
+
}, z.core.$strip>>;
|
|
154
|
+
}, z.core.$strip>>;
|
|
155
|
+
payment: z.ZodOptional<z.ZodObject<{
|
|
156
|
+
defaultMethod: z.ZodNullable<z.ZodOptional<z.ZodEnum<{
|
|
157
|
+
card: "card";
|
|
158
|
+
bank_transfer: "bank_transfer";
|
|
159
|
+
cash: "cash";
|
|
160
|
+
voucher: "voucher";
|
|
161
|
+
invoice: "invoice";
|
|
162
|
+
}>>>;
|
|
163
|
+
methods: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
164
|
+
code: z.ZodEnum<{
|
|
165
|
+
card: "card";
|
|
166
|
+
bank_transfer: "bank_transfer";
|
|
167
|
+
cash: "cash";
|
|
168
|
+
voucher: "voucher";
|
|
169
|
+
invoice: "invoice";
|
|
170
|
+
}>;
|
|
171
|
+
label: z.ZodOptional<z.ZodString>;
|
|
172
|
+
description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
173
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
174
|
+
}, z.core.$strip>>>;
|
|
175
|
+
}, z.core.$strip>>;
|
|
176
|
+
}, z.core.$strip>;
|
|
177
|
+
export declare const storefrontSettingsSchema: z.ZodObject<{
|
|
178
|
+
branding: z.ZodObject<{
|
|
179
|
+
logoUrl: z.ZodNullable<z.ZodURL>;
|
|
180
|
+
supportedLanguages: z.ZodArray<z.ZodString>;
|
|
181
|
+
}, z.core.$strip>;
|
|
182
|
+
support: z.ZodObject<{
|
|
183
|
+
email: z.ZodNullable<z.ZodEmail>;
|
|
184
|
+
phone: z.ZodNullable<z.ZodString>;
|
|
185
|
+
}, z.core.$strip>;
|
|
186
|
+
legal: z.ZodObject<{
|
|
187
|
+
termsUrl: z.ZodNullable<z.ZodURL>;
|
|
188
|
+
privacyUrl: z.ZodNullable<z.ZodURL>;
|
|
189
|
+
defaultContractTemplateId: z.ZodNullable<z.ZodString>;
|
|
190
|
+
}, z.core.$strip>;
|
|
191
|
+
forms: z.ZodObject<{
|
|
192
|
+
billing: z.ZodObject<{
|
|
193
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
194
|
+
key: z.ZodString;
|
|
195
|
+
label: z.ZodString;
|
|
196
|
+
type: z.ZodEnum<{
|
|
197
|
+
text: "text";
|
|
198
|
+
email: "email";
|
|
199
|
+
tel: "tel";
|
|
200
|
+
textarea: "textarea";
|
|
201
|
+
select: "select";
|
|
202
|
+
checkbox: "checkbox";
|
|
203
|
+
date: "date";
|
|
204
|
+
country: "country";
|
|
205
|
+
}>;
|
|
206
|
+
required: z.ZodBoolean;
|
|
207
|
+
placeholder: z.ZodNullable<z.ZodString>;
|
|
208
|
+
description: z.ZodNullable<z.ZodString>;
|
|
209
|
+
autocomplete: z.ZodNullable<z.ZodString>;
|
|
210
|
+
options: z.ZodArray<z.ZodObject<{
|
|
211
|
+
value: z.ZodString;
|
|
212
|
+
label: z.ZodString;
|
|
213
|
+
}, z.core.$strip>>;
|
|
214
|
+
}, z.core.$strip>>;
|
|
215
|
+
}, z.core.$strip>;
|
|
216
|
+
passengers: z.ZodObject<{
|
|
217
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
218
|
+
key: z.ZodString;
|
|
219
|
+
label: z.ZodString;
|
|
220
|
+
type: z.ZodEnum<{
|
|
221
|
+
text: "text";
|
|
222
|
+
email: "email";
|
|
223
|
+
tel: "tel";
|
|
224
|
+
textarea: "textarea";
|
|
225
|
+
select: "select";
|
|
226
|
+
checkbox: "checkbox";
|
|
227
|
+
date: "date";
|
|
228
|
+
country: "country";
|
|
229
|
+
}>;
|
|
230
|
+
required: z.ZodBoolean;
|
|
231
|
+
placeholder: z.ZodNullable<z.ZodString>;
|
|
232
|
+
description: z.ZodNullable<z.ZodString>;
|
|
233
|
+
autocomplete: z.ZodNullable<z.ZodString>;
|
|
234
|
+
options: z.ZodArray<z.ZodObject<{
|
|
235
|
+
value: z.ZodString;
|
|
236
|
+
label: z.ZodString;
|
|
237
|
+
}, z.core.$strip>>;
|
|
238
|
+
}, z.core.$strip>>;
|
|
239
|
+
}, z.core.$strip>;
|
|
240
|
+
}, z.core.$strip>;
|
|
241
|
+
payment: z.ZodObject<{
|
|
242
|
+
defaultMethod: z.ZodNullable<z.ZodEnum<{
|
|
243
|
+
card: "card";
|
|
244
|
+
bank_transfer: "bank_transfer";
|
|
245
|
+
cash: "cash";
|
|
246
|
+
voucher: "voucher";
|
|
247
|
+
invoice: "invoice";
|
|
248
|
+
}>>;
|
|
249
|
+
methods: z.ZodArray<z.ZodObject<{
|
|
250
|
+
code: z.ZodEnum<{
|
|
251
|
+
card: "card";
|
|
252
|
+
bank_transfer: "bank_transfer";
|
|
253
|
+
cash: "cash";
|
|
254
|
+
voucher: "voucher";
|
|
255
|
+
invoice: "invoice";
|
|
256
|
+
}>;
|
|
257
|
+
label: z.ZodString;
|
|
258
|
+
description: z.ZodNullable<z.ZodString>;
|
|
259
|
+
enabled: z.ZodBoolean;
|
|
260
|
+
}, z.core.$strip>>;
|
|
261
|
+
}, z.core.$strip>;
|
|
262
|
+
}, z.core.$strip>;
|
|
263
|
+
export type StorefrontFormFieldInput = z.infer<typeof storefrontFormFieldInputSchema>;
|
|
264
|
+
export type StorefrontFormField = z.infer<typeof storefrontFormFieldSchema>;
|
|
265
|
+
export type StorefrontPaymentMethodInput = z.infer<typeof storefrontPaymentMethodInputSchema>;
|
|
266
|
+
export type StorefrontPaymentMethod = z.infer<typeof storefrontPaymentMethodSchema>;
|
|
267
|
+
export type StorefrontPaymentMethodCode = z.infer<typeof storefrontPaymentMethodCodeSchema>;
|
|
268
|
+
export type StorefrontSettingsInput = z.infer<typeof storefrontSettingsInputSchema>;
|
|
269
|
+
export type StorefrontSettings = z.infer<typeof storefrontSettingsSchema>;
|
|
270
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAKvB,eAAO,MAAM,iCAAiC;;;;;;EAM5C,CAAA;AAEF,eAAO,MAAM,6BAA6B;;;;;;;;;EASxC,CAAA;AAEF,eAAO,MAAM,+BAA+B;;;iBAG1C,CAAA;AAEF,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;iBASzC,CAAA;AAEF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;iBASpC,CAAA;AAEF,eAAO,MAAM,kCAAkC;;;;;;;;;;;iBAK7C,CAAA;AAEF,eAAO,MAAM,6BAA6B;;;;;;;;;;;iBAKxC,CAAA;AAEF,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwCxC,CAAA;AAEF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0BnC,CAAA;AAEF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAA;AACrF,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAC3E,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAA;AAC7F,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAA;AACnF,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAA;AAC3F,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAA;AACnF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const languageTagSchema = z.string().trim().regex(/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/);
|
|
3
|
+
const urlOrNullSchema = z.url().nullable();
|
|
4
|
+
export const storefrontPaymentMethodCodeSchema = z.enum([
|
|
5
|
+
"card",
|
|
6
|
+
"bank_transfer",
|
|
7
|
+
"cash",
|
|
8
|
+
"voucher",
|
|
9
|
+
"invoice",
|
|
10
|
+
]);
|
|
11
|
+
export const storefrontFormFieldTypeSchema = z.enum([
|
|
12
|
+
"text",
|
|
13
|
+
"email",
|
|
14
|
+
"tel",
|
|
15
|
+
"textarea",
|
|
16
|
+
"select",
|
|
17
|
+
"checkbox",
|
|
18
|
+
"date",
|
|
19
|
+
"country",
|
|
20
|
+
]);
|
|
21
|
+
export const storefrontFormFieldOptionSchema = z.object({
|
|
22
|
+
value: z.string().trim().min(1),
|
|
23
|
+
label: z.string().trim().min(1),
|
|
24
|
+
});
|
|
25
|
+
export const storefrontFormFieldInputSchema = z.object({
|
|
26
|
+
key: z.string().trim().min(1),
|
|
27
|
+
label: z.string().trim().min(1),
|
|
28
|
+
type: storefrontFormFieldTypeSchema.default("text"),
|
|
29
|
+
required: z.boolean().default(false),
|
|
30
|
+
placeholder: z.string().trim().min(1).optional().nullable(),
|
|
31
|
+
description: z.string().trim().min(1).optional().nullable(),
|
|
32
|
+
autocomplete: z.string().trim().min(1).optional().nullable(),
|
|
33
|
+
options: z.array(storefrontFormFieldOptionSchema).default([]),
|
|
34
|
+
});
|
|
35
|
+
export const storefrontFormFieldSchema = z.object({
|
|
36
|
+
key: z.string().trim().min(1),
|
|
37
|
+
label: z.string().trim().min(1),
|
|
38
|
+
type: storefrontFormFieldTypeSchema,
|
|
39
|
+
required: z.boolean(),
|
|
40
|
+
placeholder: z.string().trim().min(1).nullable(),
|
|
41
|
+
description: z.string().trim().min(1).nullable(),
|
|
42
|
+
autocomplete: z.string().trim().min(1).nullable(),
|
|
43
|
+
options: z.array(storefrontFormFieldOptionSchema),
|
|
44
|
+
});
|
|
45
|
+
export const storefrontPaymentMethodInputSchema = z.object({
|
|
46
|
+
code: storefrontPaymentMethodCodeSchema,
|
|
47
|
+
label: z.string().trim().min(1).optional(),
|
|
48
|
+
description: z.string().trim().min(1).optional().nullable(),
|
|
49
|
+
enabled: z.boolean().default(true),
|
|
50
|
+
});
|
|
51
|
+
export const storefrontPaymentMethodSchema = z.object({
|
|
52
|
+
code: storefrontPaymentMethodCodeSchema,
|
|
53
|
+
label: z.string().trim().min(1),
|
|
54
|
+
description: z.string().trim().min(1).nullable(),
|
|
55
|
+
enabled: z.boolean(),
|
|
56
|
+
});
|
|
57
|
+
export const storefrontSettingsInputSchema = z.object({
|
|
58
|
+
branding: z
|
|
59
|
+
.object({
|
|
60
|
+
logoUrl: z.url().optional().nullable(),
|
|
61
|
+
supportedLanguages: z.array(languageTagSchema).optional(),
|
|
62
|
+
})
|
|
63
|
+
.optional(),
|
|
64
|
+
support: z
|
|
65
|
+
.object({
|
|
66
|
+
email: z.email().optional().nullable(),
|
|
67
|
+
phone: z.string().trim().min(1).optional().nullable(),
|
|
68
|
+
})
|
|
69
|
+
.optional(),
|
|
70
|
+
legal: z
|
|
71
|
+
.object({
|
|
72
|
+
termsUrl: z.url().optional().nullable(),
|
|
73
|
+
privacyUrl: z.url().optional().nullable(),
|
|
74
|
+
defaultContractTemplateId: z.string().trim().min(1).optional().nullable(),
|
|
75
|
+
})
|
|
76
|
+
.optional(),
|
|
77
|
+
forms: z
|
|
78
|
+
.object({
|
|
79
|
+
billing: z
|
|
80
|
+
.object({
|
|
81
|
+
fields: z.array(storefrontFormFieldInputSchema).default([]),
|
|
82
|
+
})
|
|
83
|
+
.optional(),
|
|
84
|
+
passengers: z
|
|
85
|
+
.object({
|
|
86
|
+
fields: z.array(storefrontFormFieldInputSchema).default([]),
|
|
87
|
+
})
|
|
88
|
+
.optional(),
|
|
89
|
+
})
|
|
90
|
+
.optional(),
|
|
91
|
+
payment: z
|
|
92
|
+
.object({
|
|
93
|
+
defaultMethod: storefrontPaymentMethodCodeSchema.optional().nullable(),
|
|
94
|
+
methods: z.array(storefrontPaymentMethodInputSchema).optional(),
|
|
95
|
+
})
|
|
96
|
+
.optional(),
|
|
97
|
+
});
|
|
98
|
+
export const storefrontSettingsSchema = z.object({
|
|
99
|
+
branding: z.object({
|
|
100
|
+
logoUrl: urlOrNullSchema,
|
|
101
|
+
supportedLanguages: z.array(languageTagSchema),
|
|
102
|
+
}),
|
|
103
|
+
support: z.object({
|
|
104
|
+
email: z.email().nullable(),
|
|
105
|
+
phone: z.string().trim().min(1).nullable(),
|
|
106
|
+
}),
|
|
107
|
+
legal: z.object({
|
|
108
|
+
termsUrl: urlOrNullSchema,
|
|
109
|
+
privacyUrl: urlOrNullSchema,
|
|
110
|
+
defaultContractTemplateId: z.string().trim().min(1).nullable(),
|
|
111
|
+
}),
|
|
112
|
+
forms: z.object({
|
|
113
|
+
billing: z.object({
|
|
114
|
+
fields: z.array(storefrontFormFieldSchema),
|
|
115
|
+
}),
|
|
116
|
+
passengers: z.object({
|
|
117
|
+
fields: z.array(storefrontFormFieldSchema),
|
|
118
|
+
}),
|
|
119
|
+
}),
|
|
120
|
+
payment: z.object({
|
|
121
|
+
defaultMethod: storefrontPaymentMethodCodeSchema.nullable(),
|
|
122
|
+
methods: z.array(storefrontPaymentMethodSchema),
|
|
123
|
+
}),
|
|
124
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@voyantjs/storefront",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./src/index.ts",
|
|
8
|
+
"./public-routes": "./src/routes-public.ts",
|
|
9
|
+
"./service": "./src/service.ts",
|
|
10
|
+
"./validation": "./src/validation.ts"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"typecheck": "tsc --noEmit",
|
|
14
|
+
"lint": "biome check src/",
|
|
15
|
+
"test": "vitest run",
|
|
16
|
+
"build": "pnpm run clean && tsc -p tsconfig.json",
|
|
17
|
+
"clean": "rm -rf dist",
|
|
18
|
+
"prepack": "pnpm run build"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@voyantjs/core": "workspace:*",
|
|
22
|
+
"@voyantjs/hono": "workspace:*",
|
|
23
|
+
"hono": "^4.12.10",
|
|
24
|
+
"zod": "^4.3.6"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@voyantjs/voyant-typescript-config": "workspace:*",
|
|
28
|
+
"typescript": "^6.0.2",
|
|
29
|
+
"vitest": "^4.1.2"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist"
|
|
33
|
+
],
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public",
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
39
|
+
"import": "./dist/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./public-routes": {
|
|
42
|
+
"types": "./dist/routes-public.d.ts",
|
|
43
|
+
"import": "./dist/routes-public.js"
|
|
44
|
+
},
|
|
45
|
+
"./service": {
|
|
46
|
+
"types": "./dist/service.d.ts",
|
|
47
|
+
"import": "./dist/service.js"
|
|
48
|
+
},
|
|
49
|
+
"./validation": {
|
|
50
|
+
"types": "./dist/validation.d.ts",
|
|
51
|
+
"import": "./dist/validation.js"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"main": "./dist/index.js",
|
|
55
|
+
"types": "./dist/index.d.ts"
|
|
56
|
+
},
|
|
57
|
+
"repository": {
|
|
58
|
+
"type": "git",
|
|
59
|
+
"url": "https://github.com/voyantjs/voyant.git",
|
|
60
|
+
"directory": "packages/storefront"
|
|
61
|
+
}
|
|
62
|
+
}
|