@scayle/storefront-nuxt 8.44.2 → 8.45.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,4 +1,7 @@
1
1
  import * as z from "zod/mini";
2
+ import {
3
+ rpcMethods
4
+ } from "@scayle/storefront-core";
2
5
  import { builtinDrivers } from "unstorage";
3
6
  export const RedirectsSchema = z.object({
4
7
  enabled: z.boolean(),
@@ -7,11 +10,11 @@ export const RedirectsSchema = z.object({
7
10
  });
8
11
  const SessionSchema = z.object({
9
12
  /**
10
- * The sameSite policy to use for the session cookie
13
+ * The `sameSite` policy to use for the session cookie
11
14
  */
12
15
  sameSite: z.optional(z.enum(["lax", "strict", "none"])),
13
16
  /**
14
- * The default maxAge (in seconds) set on the session cookie and default TTL for session store
17
+ * The default `maxAge` (in seconds) set on the session cookie and default TTL for session store
15
18
  */
16
19
  maxAge: z.optional(z.number()),
17
20
  /**
@@ -104,7 +107,9 @@ const ShopConfigSchema = z.object({
104
107
  isEnabled: z.optional(z.boolean()),
105
108
  sessionConfig: z.optional(SessionSchema),
106
109
  sapi: z.optional(SapiSchema),
107
- /** @deprecated The `storage` option within `shopConfig` is deprecated. Consider using nuxt storage configuration instead. */
110
+ /**
111
+ * @deprecated The `storage` option within `shopConfig` is deprecated. Consider using nuxt storage configuration instead.
112
+ */
108
113
  storage: z.optional(z.object({
109
114
  session: z.optional(StorageSchema),
110
115
  cache: z.optional(StorageSchema)
@@ -119,39 +124,63 @@ const CacheSchema = z.object({
119
124
  enabled: z.optional(z.boolean())
120
125
  });
121
126
  const ShopSelectorSchema = z.enum(["path", "domain", "path_or_default"]);
122
- const StorefrontConfigSchema = z.object({
127
+ const StorefrontRuntimeConfigSchema = z.object({
128
+ /**
129
+ * Determines how the application identifies and switches between different shops.
130
+ * It influences how the `domain` and `path` properties are used within the `shops` configuration.
131
+ *
132
+ * @see https://scayle.dev/en/storefront-guide/developer-guide/basic-setup/introduction#path-and-domain
133
+ */
134
+ shopSelector: ShopSelectorSchema,
135
+ /**
136
+ * Controls how the application handles URL redirects by leveraging the Storefront API,
137
+ * which is synchronized with the SCAYLE Panel. When enabled,
138
+ * the Storefront Core intercepts requests and checks for potential
139
+ * redirects via the Storefront API. If a match is found, a 30x HTTP response
140
+ * is returned with the target in the `Location` header and the appropriate
141
+ * status code.
142
+ *
143
+ * @see https://scayle.dev/en/storefront-guide/developer-guide/basic-setup/redirects
144
+ */
145
+ redirects: z.optional(RedirectsSchema),
146
+ /**
147
+ * Configures the available shops in the Storefront Application. Each shop represents a specific region or language,
148
+ * with each shop identified by its unique shop ID from the SCAYLE tenant.
149
+ *
150
+ * @see https://scayle.dev/en/storefront-guide/developer-guide/basic-setup/introduction#shops
151
+ */
152
+ shops: z.record(z.string(), ShopConfigSchema),
123
153
  session: z.optional(SessionSchema),
124
- /** @deprecated The `storage` option within `storefront` is deprecated. Consider using nuxt storage configuration instead. */
154
+ /**
155
+ * @deprecated The `storage` option within `storefront` is deprecated. Consider using nuxt storage configuration instead.
156
+ */
125
157
  storage: z.optional(z.object({
126
158
  session: z.optional(StorageSchema),
127
159
  cache: z.optional(StorageSchema)
128
160
  })),
129
161
  oauth: OAuthSchema,
130
162
  appKeys: AppKeysSchema,
131
- apiBasePath: z.optional(z.string()),
132
163
  cache: z.optional(CacheSchema),
133
164
  publicShopData: z.optional(z.array(z.string())),
134
165
  idp: z.optional(IdpSchema),
135
166
  sapi: SapiSchema,
136
- /** Collection of feature flags regarding legacy features and functionalities */
167
+ /**
168
+ * Collection of feature flags regarding legacy features and functionalities.
169
+ */
137
170
  legacy: z.optional(LegacySchema),
138
- /** Undocumented property intended for internal usage only */
171
+ /**
172
+ * @hidden
173
+ * Undocumented property intended for internal usage only
174
+ */
139
175
  internalAccessHeader: z.optional(z.string())
140
176
  });
141
- const ModuleOptionSchema = z.object(
142
- {
143
- shopSelector: ShopSelectorSchema,
144
- redirects: z.optional(RedirectsSchema),
145
- shops: z.record(z.string(), ShopConfigSchema)
146
- }
147
- );
148
177
  const logLevel = z.enum([
149
178
  "debug",
150
179
  "info",
151
180
  "warn",
152
181
  "error"
153
182
  ]);
154
- const PublicRuntimeConfigSchema = z.object({
183
+ const StorefrontPublicRuntimeConfigSchema = z.object({
155
184
  log: z.object({
156
185
  name: z.string(),
157
186
  level: logLevel,
@@ -164,8 +193,30 @@ const PublicRuntimeConfigSchema = z.object({
164
193
  }))
165
194
  });
166
195
  export const RuntimeConfigSchema = z.object({
167
- storefront: z.intersection(ModuleOptionSchema, StorefrontConfigSchema),
196
+ storefront: StorefrontRuntimeConfigSchema,
168
197
  public: z.object({
169
- storefront: PublicRuntimeConfigSchema
198
+ storefront: StorefrontPublicRuntimeConfigSchema
170
199
  })
171
200
  });
201
+ const AvailableRpcMethods = z.enum(
202
+ Object.keys(rpcMethods)
203
+ );
204
+ const ModuleOptionSchema = z.object({
205
+ /**
206
+ * The RPC directory where the custom application RPCs are defined.
207
+ * The directory should have an `index.ts` file where all RPCs are exported using their name.
208
+ * By default this will be `./rpcMethods`.
209
+ */
210
+ rpcDir: z.optional(z.string()),
211
+ /**
212
+ * The RPC method names which are exported from the `rpcDir`.
213
+ * Usually this can just be `Object.keys(rpcMethodsDir)`.
214
+ */
215
+ rpcMethodNames: z.optional(z.array(z.string())),
216
+ /** Specify explicitly overridden RPC methods that are provided by the Storefront Core package. */
217
+ rpcMethodOverrides: z.optional(z.array(AvailableRpcMethods)),
218
+ /**
219
+ * The base path for API routes.
220
+ */
221
+ apiBasePath: z.optional(z.string())
222
+ });
@@ -1,6 +1,7 @@
1
1
  import * as fishery from 'fishery';
2
2
  import { Factory } from 'fishery';
3
- import { ModuleBaseOptions, ShopConfig } from '../../dist/runtime/types/module.js';
3
+ import { StorefrontRuntimeConfigType } from '../../dist/runtime/utils/zodSchema.js';
4
+ import { ShopConfig } from '../../dist/runtime/types/module.js';
4
5
  import * as hookable from 'hookable';
5
6
  import * as _scayle_storefront_core from '@scayle/storefront-core';
6
7
  import { RpcContext, StorefrontAPIClient, Log, RuntimeConfiguration, ContextWithoutSession, ContextWithSession } from '@scayle/storefront-core';
@@ -10,7 +11,23 @@ export * from '@scayle/storefront-core/test/factories';
10
11
  interface ModuleOptionsFactoryParams {
11
12
  shops: ShopConfig[];
12
13
  }
13
- declare const moduleOptionsFactory: Factory<ModuleBaseOptions, ModuleOptionsFactoryParams, ModuleBaseOptions, fishery.DeepPartialObject<ModuleBaseOptions>>;
14
+ declare const moduleRuntimeOptionsFactory: Factory<StorefrontRuntimeConfigType, ModuleOptionsFactoryParams, StorefrontRuntimeConfigType, fishery.DeepPartialObject<StorefrontRuntimeConfigType>>;
15
+ declare const moduleOptionsFactory: Factory<{
16
+ rpcDir?: string | undefined;
17
+ rpcMethodNames?: string[] | undefined;
18
+ rpcMethodOverrides?: ("getProductById" | "getProductsByIds" | "getProductsByReferenceKeys" | "getProductsCount" | "fetchAllFiltersForCategory" | "getFilters" | "getProductsByCategory" | "oauthForgetPassword" | "oauthGuestLogin" | "oauthLogin" | "oauthRegister" | "oauthRevokeToken" | "refreshAccessToken" | "updatePasswordByHash" | "addItemToBasket" | "addItemsToBasket" | "getBasket" | "removeItemFromBasket" | "clearBasket" | "mergeBaskets" | "updateBasketItem" | "getApplicablePromotionsByCode" | "updatePromotions" | "getBrands" | "getBrandById" | "getRootCategories" | "getCategoryByPath" | "getCategoriesByPath" | "getCategoryById" | "getCategoryTree" | "getCampaign" | "getCampaignKey" | "getOrderDataByCbd" | "getSearchSuggestions" | "resolveSearch" | "getShopConfiguration" | "getUser" | "fetchUser" | "refreshUser" | "getAccessToken" | "getWishlist" | "addItemToWishlist" | "removeItemFromWishlist" | "clearWishlist" | "getOrderById" | "getShopUserAddresses" | "updateShopUser" | "updatePassword" | "getCheckoutToken" | "getVariantById" | "fetchAllNavigationTrees" | "fetchNavigationTreeById" | "fetchNavigationTreeByName" | "getPromotions" | "getCurrentPromotions" | "getPromotionsByIds" | "getExternalIdpRedirect" | "handleIDPLoginCallback")[] | undefined;
19
+ apiBasePath?: string | undefined;
20
+ }, any, {
21
+ rpcDir?: string | undefined;
22
+ rpcMethodNames?: string[] | undefined;
23
+ rpcMethodOverrides?: ("getProductById" | "getProductsByIds" | "getProductsByReferenceKeys" | "getProductsCount" | "fetchAllFiltersForCategory" | "getFilters" | "getProductsByCategory" | "oauthForgetPassword" | "oauthGuestLogin" | "oauthLogin" | "oauthRegister" | "oauthRevokeToken" | "refreshAccessToken" | "updatePasswordByHash" | "addItemToBasket" | "addItemsToBasket" | "getBasket" | "removeItemFromBasket" | "clearBasket" | "mergeBaskets" | "updateBasketItem" | "getApplicablePromotionsByCode" | "updatePromotions" | "getBrands" | "getBrandById" | "getRootCategories" | "getCategoryByPath" | "getCategoriesByPath" | "getCategoryById" | "getCategoryTree" | "getCampaign" | "getCampaignKey" | "getOrderDataByCbd" | "getSearchSuggestions" | "resolveSearch" | "getShopConfiguration" | "getUser" | "fetchUser" | "refreshUser" | "getAccessToken" | "getWishlist" | "addItemToWishlist" | "removeItemFromWishlist" | "clearWishlist" | "getOrderById" | "getShopUserAddresses" | "updateShopUser" | "updatePassword" | "getCheckoutToken" | "getVariantById" | "fetchAllNavigationTrees" | "fetchNavigationTreeById" | "fetchNavigationTreeByName" | "getPromotions" | "getCurrentPromotions" | "getPromotionsByIds" | "getExternalIdpRedirect" | "handleIDPLoginCallback")[] | undefined;
24
+ apiBasePath?: string | undefined;
25
+ }, fishery.DeepPartialObject<{
26
+ rpcDir?: string | undefined;
27
+ rpcMethodNames?: string[] | undefined;
28
+ rpcMethodOverrides?: ("getProductById" | "getProductsByIds" | "getProductsByReferenceKeys" | "getProductsCount" | "fetchAllFiltersForCategory" | "getFilters" | "getProductsByCategory" | "oauthForgetPassword" | "oauthGuestLogin" | "oauthLogin" | "oauthRegister" | "oauthRevokeToken" | "refreshAccessToken" | "updatePasswordByHash" | "addItemToBasket" | "addItemsToBasket" | "getBasket" | "removeItemFromBasket" | "clearBasket" | "mergeBaskets" | "updateBasketItem" | "getApplicablePromotionsByCode" | "updatePromotions" | "getBrands" | "getBrandById" | "getRootCategories" | "getCategoryByPath" | "getCategoriesByPath" | "getCategoryById" | "getCategoryTree" | "getCampaign" | "getCampaignKey" | "getOrderDataByCbd" | "getSearchSuggestions" | "resolveSearch" | "getShopConfiguration" | "getUser" | "fetchUser" | "refreshUser" | "getAccessToken" | "getWishlist" | "addItemToWishlist" | "removeItemFromWishlist" | "clearWishlist" | "getOrderById" | "getShopUserAddresses" | "updateShopUser" | "updatePassword" | "getCheckoutToken" | "getVariantById" | "fetchAllNavigationTrees" | "fetchNavigationTreeById" | "fetchNavigationTreeByName" | "getPromotions" | "getCurrentPromotions" | "getPromotionsByIds" | "getExternalIdpRedirect" | "handleIDPLoginCallback")[] | undefined;
29
+ apiBasePath?: string | undefined;
30
+ }>>;
14
31
 
15
32
  declare const shopConfigFactory: Factory<ShopConfig, any, ShopConfig, fishery.DeepPartialObject<ShopConfig>>;
16
33
 
@@ -99,4 +116,4 @@ declare const rpcContextFactory: Factory<RpcContext, RpcContextFactoryParams, Rp
99
116
 
100
117
  declare const routeFactory: Factory<RouteLocationNormalizedLoadedGeneric, any, RouteLocationNormalizedLoadedGeneric, fishery.DeepPartialObject<RouteLocationNormalizedLoadedGeneric>>;
101
118
 
102
- export { moduleOptionsFactory, routeFactory, rpcContextFactory, shopConfigFactory };
119
+ export { moduleOptionsFactory, moduleRuntimeOptionsFactory, routeFactory, rpcContextFactory, shopConfigFactory };
@@ -2,7 +2,7 @@ import { Factory } from 'fishery';
2
2
  import { HashAlgorithm, Log, StorefrontAPIClient } from '@scayle/storefront-core';
3
3
  export * from '@scayle/storefront-core/test/factories';
4
4
 
5
- const moduleOptionsFactory = Factory.define(({ transientParams }) => {
5
+ const moduleRuntimeOptionsFactory = Factory.define(({ transientParams }) => {
6
6
  return {
7
7
  sapi: {
8
8
  host: "sapiHost",
@@ -27,6 +27,14 @@ const moduleOptionsFactory = Factory.define(({ transientParams }) => {
27
27
  }, {})
28
28
  };
29
29
  });
30
+ const moduleOptionsFactory = Factory.define(() => {
31
+ return {
32
+ rpcDir: void 0,
33
+ rpcMethodNames: void 0,
34
+ rpcMethodOverrides: void 0,
35
+ apiBasePath: "/api"
36
+ };
37
+ });
30
38
 
31
39
  const shopConfigFactory = Factory.define(() => {
32
40
  return {
@@ -112,4 +120,4 @@ const routeFactory = Factory.define(
112
120
  })
113
121
  );
114
122
 
115
- export { moduleOptionsFactory, routeFactory, rpcContextFactory, shopConfigFactory };
123
+ export { moduleOptionsFactory, moduleRuntimeOptionsFactory, routeFactory, rpcContextFactory, shopConfigFactory };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@scayle/storefront-nuxt",
3
3
  "type": "module",
4
- "version": "8.44.2",
4
+ "version": "8.45.0",
5
5
  "description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
6
6
  "author": "SCAYLE Commerce Engine",
7
7
  "license": "MIT",
@@ -90,7 +90,7 @@
90
90
  "utility-types": "^3.11.0",
91
91
  "vue-router": "^4.4.0",
92
92
  "zod": "^4.0.0",
93
- "@scayle/storefront-core": "8.44.2",
93
+ "@scayle/storefront-core": "8.45.0",
94
94
  "@scayle/unstorage-compression-driver": "1.2.1"
95
95
  },
96
96
  "devDependencies": {