@scayle/storefront-nuxt 7.72.5 → 7.74.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.
@@ -1,15 +1,44 @@
1
1
  import { z } from "zod";
2
2
  import { HashAlgorithm } from "@scayle/storefront-core";
3
3
  import { builtinDrivers } from "unstorage";
4
- const RedirectsSchema = z.object({
4
+ export const RedirectsSchema = z.object({
5
5
  enabled: z.boolean(),
6
6
  queryParamWhitelist: z.array(z.string()).optional()
7
7
  });
8
+ const RedisConfigSchema = z.object({
9
+ port: z.number().optional(),
10
+ host: z.string().optional(),
11
+ prefix: z.string().optional(),
12
+ sslTransit: z.boolean().optional()
13
+ }).or(z.object({
14
+ port: z.number().optional(),
15
+ host: z.string().optional(),
16
+ prefix: z.string().optional(),
17
+ sslTransit: z.boolean().optional(),
18
+ user: z.string(),
19
+ password: z.string()
20
+ }));
8
21
  const SessionSchema = z.object({
22
+ /**
23
+ * The sameSite policy to use for the session cookie
24
+ */
9
25
  sameSite: z.enum(["lax", "strict", "none"]).optional(),
26
+ /**
27
+ * The default maxAge (in seconds) set on the session cookie and default TTL for session store
28
+ */
10
29
  maxAge: z.number().optional(),
30
+ /**
31
+ * The name used for the session cookie
32
+ */
11
33
  cookieName: z.string().optional(),
12
- secret: z.string().optional(),
34
+ /**
35
+ * The secret used for signing session cookies. If an array is passed, the last
36
+ * value is used for signing new cookies, but all values are used to verify cookies.
37
+ */
38
+ secret: z.string().or(z.array(z.string())).optional(),
39
+ /**
40
+ * Controls the domain option on the session cookie
41
+ */
13
42
  domain: z.string().optional()
14
43
  });
15
44
  const BapiSchema = z.object({
@@ -47,7 +76,17 @@ const AppKeysSchema = z.object(
47
76
  hashAlgorithm: z.enum(hashValues)
48
77
  }
49
78
  );
50
- const ShopConfigSchema = z.record(z.object({
79
+ const CheckoutShopConfigSchema = z.object({
80
+ token: z.string().min(1),
81
+ secret: z.string().min(1),
82
+ host: z.string().url(),
83
+ user: z.string().or(z.number()),
84
+ cbdExpiration: z.number().optional()
85
+ });
86
+ const emptyString = z.string().refine((val) => val === "", {
87
+ message: "Expected boolean, received string"
88
+ });
89
+ const ShopConfigSchema = z.object({
51
90
  idp: IdpSchema.optional(),
52
91
  shopId: z.number(),
53
92
  path: z.string().optional(),
@@ -59,23 +98,20 @@ const ShopConfigSchema = z.record(z.object({
59
98
  }),
60
99
  storeCampaignKeyword: z.string().optional(),
61
100
  currency: z.string(),
62
- checkout: z.object({
63
- token: z.string().min(1),
64
- secret: z.string().min(1),
65
- host: z.string().url(),
66
- user: z.string().or(z.number()),
67
- cbdExpiration: z.number().optional()
68
- }),
101
+ checkout: CheckoutShopConfigSchema,
69
102
  appKeys: AppKeysSchema.optional(),
70
- currencyFractionDigits: z.string().optional(),
103
+ currencyFractionDigits: z.number().optional(),
71
104
  isEnabled: z.boolean().optional(),
72
105
  sessionConfig: SessionSchema.optional(),
73
106
  bapi: BapiSchema.optional(),
74
107
  storage: z.object({
75
- session: StorageSchema,
76
- cache: StorageSchema
77
- }).optional()
78
- }));
108
+ session: StorageSchema.optional(),
109
+ cache: StorageSchema.optional()
110
+ }).optional(),
111
+ isDefault: z.boolean().optional().or(emptyString),
112
+ /** @deprecated shop-specific storefront.redis config is being removed in favor of global nitro.storage config */
113
+ redis: RedisConfigSchema.optional()
114
+ });
79
115
  const CacheSchema = z.object({
80
116
  auth: z.object({
81
117
  username: z.string().min(1),
@@ -83,31 +119,40 @@ const CacheSchema = z.object({
83
119
  }),
84
120
  enabled: z.boolean()
85
121
  });
86
- const storefrontRuntimeConfigPrivateSchema = z.object({
87
- publicShopData: z.array(z.string()),
88
- redirects: RedirectsSchema.optional(),
122
+ const ShopSelectorSchema = z.enum(["path", "domain", "path_or_default"]);
123
+ const StorefrontConfigSchema = z.object({
89
124
  session: SessionSchema.optional(),
90
125
  bapi: BapiSchema,
91
- oauth: OAuthSchema,
92
- idp: IdpSchema.optional(),
93
- shopSelector: z.enum(["path", "domain", "path_or_default"]),
94
- stores: ShopConfigSchema,
95
126
  storage: z.object({
96
- session: StorageSchema,
97
- cache: StorageSchema
98
- }),
127
+ session: StorageSchema.optional(),
128
+ cache: StorageSchema.optional()
129
+ }).optional(),
130
+ oauth: OAuthSchema,
131
+ appKeys: AppKeysSchema,
132
+ apiBasePath: z.string().optional(),
99
133
  cache: CacheSchema.optional(),
100
- appKeys: AppKeysSchema
134
+ publicShopData: z.array(z.string()).optional(),
135
+ idp: IdpSchema.optional(),
136
+ /** @deprecated Global storefront.redis config is being removed in favor of `storefront.storage` config */
137
+ redis: RedisConfigSchema.optional()
101
138
  });
102
- const publicRuntimeConfigSchema = z.object({
103
- storefront: z.object({
104
- log: z.object({
105
- name: z.string(),
106
- level: z.string()
107
- })
139
+ const ModuleOptionSchema = z.object(
140
+ {
141
+ shopSelector: ShopSelectorSchema,
142
+ stores: z.record(ShopConfigSchema),
143
+ redirects: RedirectsSchema.optional()
144
+ }
145
+ );
146
+ const logLevel = z.enum(["debug", "info", "warn", "error"]);
147
+ const PublicRuntimeConfigSchema = z.object({
148
+ log: z.object({
149
+ name: z.string(),
150
+ level: logLevel
108
151
  })
109
152
  });
110
- export const runtimeConfigSchema = z.object({
111
- storefront: storefrontRuntimeConfigPrivateSchema,
112
- public: publicRuntimeConfigSchema
153
+ export const RuntimeConfigSchema = z.object({
154
+ storefront: z.union([StorefrontConfigSchema, ModuleOptionSchema]),
155
+ public: z.object({
156
+ storefront: PublicRuntimeConfigSchema
157
+ })
113
158
  });