@scayle/storefront-nuxt 8.44.2 → 8.45.1
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/CHANGELOG.md +89 -2
- package/README.md +2 -2
- package/dist/module.d.mts +11 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +63 -39
- package/dist/runtime/campaignKey.d.ts +1 -1
- package/dist/runtime/composables/core/useIDP.d.ts +1 -1
- package/dist/runtime/composables/core/useRpc.d.ts +1 -1
- package/dist/runtime/composables/core/useSession.d.ts +2 -2
- package/dist/runtime/composables/storefront/useCurrentPromotions.d.ts +1 -1
- package/dist/runtime/composables/storefront/useWishlist.d.ts +1 -1
- package/dist/runtime/context.d.ts +4 -3
- package/dist/runtime/context.js +2 -1
- package/dist/runtime/server/middleware/bootstrap-utils.d.ts +5 -4
- package/dist/runtime/server/middleware/bootstrap.js +3 -2
- package/dist/runtime/server/middleware/redirects.d.ts +2 -2
- package/dist/runtime/types/module.d.ts +16 -98
- package/dist/runtime/utils/zodSchema.d.ts +440 -29
- package/dist/runtime/utils/zodSchema.js +69 -18
- package/dist/test/factories.d.mts +20 -3
- package/dist/test/factories.mjs +10 -2
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,92 @@
|
|
|
1
1
|
# @scayle/storefront-nuxt
|
|
2
2
|
|
|
3
|
+
## 8.45.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependency `@vercel/nft@0.30.2` to `@vercel/nft@0.30.3`
|
|
8
|
+
- Updated SCAYLE Resource Center references
|
|
9
|
+
|
|
10
|
+
**Dependencies**
|
|
11
|
+
|
|
12
|
+
- Updated dependency to @scayle/unstorage-compression-driver@1.2.1
|
|
13
|
+
|
|
14
|
+
**@scayle/storefront-core v8.45.1**
|
|
15
|
+
|
|
16
|
+
- Patch
|
|
17
|
+
- Updated SCAYLE Resource Center references
|
|
18
|
+
|
|
19
|
+
## 8.45.0
|
|
20
|
+
|
|
21
|
+
### Minor Changes
|
|
22
|
+
|
|
23
|
+
- The API routes structure was updated for multi-shop environments. The `apiBasePath` option was removed from per-shop configuration but remains configurable at the module level.
|
|
24
|
+
|
|
25
|
+
NOTE: Update your `nuxt.config.ts` to ensure `routeRules` for `/api/**` uses the manually set `apiBasePath` value to prevent caching issues with session-related RPC's and potentially failing requests!
|
|
26
|
+
|
|
27
|
+
**Before (per-shop apiBasePath):**
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
// This configuration is no longer supported
|
|
31
|
+
runtimeConfig: {
|
|
32
|
+
storefront: {
|
|
33
|
+
shops: {
|
|
34
|
+
1001: {
|
|
35
|
+
shopId: 1001,
|
|
36
|
+
path: 'de',
|
|
37
|
+
apiBasePath: '/custom-api', // ❌ No longer supported
|
|
38
|
+
// ... other shop config
|
|
39
|
+
},
|
|
40
|
+
1002: {
|
|
41
|
+
shopId: 1002,
|
|
42
|
+
path: 'en',
|
|
43
|
+
apiBasePath: '/different-api', // ❌ No longer supported
|
|
44
|
+
// ... other shop config
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**After (module-level apiBasePath):**
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
// nuxt.config.ts
|
|
55
|
+
export default defineNuxtConfig({
|
|
56
|
+
storefront: {
|
|
57
|
+
apiBasePath: '/custom-api', // ✅ Configure globally for all shops
|
|
58
|
+
},
|
|
59
|
+
runtimeConfig: {
|
|
60
|
+
storefront: {
|
|
61
|
+
shops: {
|
|
62
|
+
1001: {
|
|
63
|
+
shopId: 1001,
|
|
64
|
+
path: 'de',
|
|
65
|
+
// ✅ apiBasePath removed from shop config
|
|
66
|
+
// ... other shop config
|
|
67
|
+
},
|
|
68
|
+
1002: {
|
|
69
|
+
shopId: 1002,
|
|
70
|
+
path: 'en',
|
|
71
|
+
// ✅ apiBasePath removed from shop config
|
|
72
|
+
// ... other shop config
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
})
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Additionally, the types for the Storefront module options and Storefront runtime configuration have been cleaned up to properly reflect which settings can be set at runtime and which cannot. This clarifies the distinction between configuration that is static (set at build/module level) and configuration that is dynamic (set at runtime), improving type safety and developer experience.
|
|
81
|
+
|
|
82
|
+
### Patch Changes
|
|
83
|
+
|
|
84
|
+
**Dependencies**
|
|
85
|
+
|
|
86
|
+
**@scayle/storefront-core v8.45.0**
|
|
87
|
+
|
|
88
|
+
- No changes in this release.
|
|
89
|
+
|
|
3
90
|
## 8.44.2
|
|
4
91
|
|
|
5
92
|
### Patch Changes
|
|
@@ -1960,7 +2047,7 @@
|
|
|
1960
2047
|
Legacy configuration options `provider` and `redis` configuration are no longer supported and have been deprecated since Storefront Boilerplate v1.0.0-rc.05.
|
|
1961
2048
|
|
|
1962
2049
|
You'll need to migrate your existing storage settings to the new `storefront.storage` format.
|
|
1963
|
-
Check the [SCAYLE Resource Center](https://scayle.dev/en/storefront-guide/
|
|
2050
|
+
Check the [SCAYLE Resource Center](https://scayle.dev/en/core-documentation/storefront-guide/storefront-application/technical-foundation/storage) for more details.
|
|
1964
2051
|
|
|
1965
2052
|
- _No Longer Supported: Legacy Storage Setup in (`nuxt.config.ts`):_
|
|
1966
2053
|
|
|
@@ -2164,7 +2251,7 @@
|
|
|
2164
2251
|
|
|
2165
2252
|
- **\[💥 BREAKING\]** The `store` option in the module configuration has been removed. `@scayle/storefront-nuxt@7.84.0` introduced the `shops` option as a replacement, but maintained backward compatibility with the `store` option. Going forward, configuring shops must be done using the `shops` keyword.
|
|
2166
2253
|
|
|
2167
|
-
- For more information, please refer to the [documentation](https://scayle.dev/en/storefront-guide/
|
|
2254
|
+
- For more information, please refer to the [documentation](https://scayle.dev/en/core-documentation/storefront-guide/storefront-application/technical-foundation/configuration#shops).
|
|
2168
2255
|
- **NOTE:** These changes might impact your environment variables used for deployments. Please check your infrastructure and deployment setup and adapt accordingly!
|
|
2169
2256
|
- _Previous Store Configuration in `nuxt.config.ts`:_
|
|
2170
2257
|
|
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ npm install --save-dev @scayle/storefront-nuxt
|
|
|
36
36
|
|
|
37
37
|
## Getting Started
|
|
38
38
|
|
|
39
|
-
Visit the [Quickstart Guide](https://scayle.dev/en/
|
|
39
|
+
Visit the [Quickstart Guide](https://scayle.dev/en/core-documentation/storefront-guide/storefront-application/readme/setup-your-storefront) to get started with Storefront Nuxt.
|
|
40
40
|
|
|
41
41
|
Visit the [Docs](https://scayle.dev) to learn more about our system requirements.
|
|
42
42
|
|
|
@@ -45,7 +45,7 @@ Visit the [Docs](https://scayle.dev) to learn more about our system requirements
|
|
|
45
45
|
[SCAYLE](https://scayle.com) is a full-featured e-commerce software solution that comes with flexible APIs.
|
|
46
46
|
Within SCAYLE, you can manage all aspects of your shop, such as products, stocks, customers, and transactions.
|
|
47
47
|
|
|
48
|
-
Learn more about [SCAYLE’s architecture](https://scayle.dev/en/
|
|
48
|
+
Learn more about [SCAYLE’s architecture](https://scayle.dev/en/core-documentation/welcome-to-scayle/getting-started) and commerce modules in the docs.
|
|
49
49
|
|
|
50
50
|
## Other channels
|
|
51
51
|
|
package/dist/module.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
import { HookResult } from '@nuxt/schema';
|
|
3
|
-
import { ModuleBaseOptions } from '../dist/runtime/types/module.js';
|
|
4
3
|
export * from '../dist/runtime/types/module.js';
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -52,7 +51,17 @@ declare module '@nuxt/schema' {
|
|
|
52
51
|
*
|
|
53
52
|
* @returns The Nuxt module.
|
|
54
53
|
*/
|
|
55
|
-
declare const _default: _nuxt_schema.NuxtModule<
|
|
54
|
+
declare const _default: _nuxt_schema.NuxtModule<{
|
|
55
|
+
rpcDir?: string | undefined;
|
|
56
|
+
rpcMethodNames?: string[] | undefined;
|
|
57
|
+
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;
|
|
58
|
+
apiBasePath?: string | undefined;
|
|
59
|
+
}, {
|
|
60
|
+
rpcDir?: string | undefined;
|
|
61
|
+
rpcMethodNames?: string[] | undefined;
|
|
62
|
+
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;
|
|
63
|
+
apiBasePath?: string | undefined;
|
|
64
|
+
}, false>;
|
|
56
65
|
|
|
57
66
|
export { _default as default };
|
|
58
67
|
export type { ModuleHooks };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
|
-
import { defineNuxtModule, createResolver,
|
|
2
|
+
import { defineNuxtModule, createResolver, addServerTemplate, addTypeTemplate, extendViteConfig, addPlugin, addImportsDir } from '@nuxt/kit';
|
|
3
3
|
import { rpcMethods } from '@scayle/storefront-core';
|
|
4
4
|
import { defu } from 'defu';
|
|
5
5
|
import { genExport, genImport, genSafeVariableName } from 'knitwork';
|
|
@@ -54,7 +54,7 @@ export default {
|
|
|
54
54
|
}`;
|
|
55
55
|
}
|
|
56
56
|
const PACKAGE_NAME = "@scayle/storefront-nuxt";
|
|
57
|
-
const PACKAGE_VERSION = "8.
|
|
57
|
+
const PACKAGE_VERSION = "8.45.1";
|
|
58
58
|
const logger = createConsola({
|
|
59
59
|
fancy: true,
|
|
60
60
|
formatOptions: {
|
|
@@ -228,49 +228,73 @@ const module = defineNuxtModule({
|
|
|
228
228
|
},
|
|
229
229
|
// Default configuration options of the Nuxt module
|
|
230
230
|
defaults: {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
sameSite: "lax"
|
|
236
|
-
// TODO: If we give a default value here, nuxt will generate the runtime type incorrectly
|
|
237
|
-
// secret needs to be typed as string | string[]
|
|
238
|
-
// secret: 'current-secret',
|
|
239
|
-
// if we set maxAge explicitly to undefined `useRuntimeConfig` will set it default to '' which leads to no sessions not being saved
|
|
240
|
-
// maxAge: undefined,
|
|
241
|
-
},
|
|
242
|
-
shopSelector: "domain",
|
|
243
|
-
oauth: {
|
|
244
|
-
apiHost: "",
|
|
245
|
-
clientId: "",
|
|
246
|
-
clientSecret: ""
|
|
247
|
-
},
|
|
248
|
-
idp: {
|
|
249
|
-
enabled: false,
|
|
250
|
-
idpKeys: [],
|
|
251
|
-
idpRedirectURL: ""
|
|
252
|
-
},
|
|
253
|
-
appKeys: {
|
|
254
|
-
wishlistKey: "wishlist_{shopId}_{userId}",
|
|
255
|
-
basketKey: "basket_{shopId}_{userId}",
|
|
256
|
-
hashAlgorithm: "sha256"
|
|
257
|
-
},
|
|
258
|
-
legacy: {
|
|
259
|
-
enableSessionMigration: false
|
|
260
|
-
},
|
|
261
|
-
/**
|
|
262
|
-
* The internal access header.
|
|
263
|
-
*
|
|
264
|
-
* @hidden
|
|
265
|
-
*/
|
|
266
|
-
internalAccessHeader: ""
|
|
231
|
+
rpcDir: void 0,
|
|
232
|
+
rpcMethodNames: void 0,
|
|
233
|
+
rpcMethodOverrides: void 0,
|
|
234
|
+
apiBasePath: "/api"
|
|
267
235
|
},
|
|
268
236
|
async setup(options, nuxt) {
|
|
269
237
|
const { resolve } = createResolver(import.meta.url);
|
|
270
238
|
const { resolve: appResolve } = createResolver(nuxt.options.rootDir);
|
|
239
|
+
addServerTemplate({
|
|
240
|
+
filename: "#internal/storefront-options.mjs",
|
|
241
|
+
getContents: () => `
|
|
242
|
+
export const apiBasePath = '${options.apiBasePath}'
|
|
243
|
+
export const rpcMethodNames = ${options.rpcMethodNames ? JSON.stringify(options.rpcMethodNames, null, 2) : "undefined"}
|
|
244
|
+
export const rpcMethodOverrides = ${options.rpcMethodOverrides ? JSON.stringify(options.rpcMethodOverrides, null, 2) : "undefined"}
|
|
245
|
+
`
|
|
246
|
+
});
|
|
247
|
+
addTypeTemplate({
|
|
248
|
+
filename: "types/storefront-options.d.ts",
|
|
249
|
+
getContents: () => `
|
|
250
|
+
declare module '#internal/storefront-options.mjs' {
|
|
251
|
+
export const apiBasePath: string
|
|
252
|
+
export const rpcMethodNames: string[] | undefined
|
|
253
|
+
export const rpcMethodOverrides: string[] | undefined
|
|
254
|
+
}
|
|
255
|
+
`
|
|
256
|
+
});
|
|
257
|
+
const runtimeConfigDefaults = {
|
|
258
|
+
// TODO: Nuxt is making us give a default for each options
|
|
259
|
+
// How do we mark some as required?
|
|
260
|
+
session: {
|
|
261
|
+
cookieName: "$session",
|
|
262
|
+
sameSite: "lax"
|
|
263
|
+
// TODO: If we give a default value here, nuxt will generate the runtime type incorrectly
|
|
264
|
+
// secret needs to be typed as string | string[]
|
|
265
|
+
// secret: 'current-secret',
|
|
266
|
+
// if we set maxAge explicitly to undefined `useRuntimeConfig` will set it default to '' which leads to no sessions not being saved
|
|
267
|
+
// maxAge: undefined,
|
|
268
|
+
},
|
|
269
|
+
shopSelector: "domain",
|
|
270
|
+
oauth: {
|
|
271
|
+
apiHost: "",
|
|
272
|
+
clientId: "",
|
|
273
|
+
clientSecret: ""
|
|
274
|
+
},
|
|
275
|
+
idp: {
|
|
276
|
+
enabled: false,
|
|
277
|
+
idpKeys: [],
|
|
278
|
+
idpRedirectURL: ""
|
|
279
|
+
},
|
|
280
|
+
appKeys: {
|
|
281
|
+
wishlistKey: "wishlist_{shopId}_{userId}",
|
|
282
|
+
basketKey: "basket_{shopId}_{userId}",
|
|
283
|
+
hashAlgorithm: "sha256"
|
|
284
|
+
},
|
|
285
|
+
legacy: {
|
|
286
|
+
enableSessionMigration: false
|
|
287
|
+
},
|
|
288
|
+
internalAccessHeader: "",
|
|
289
|
+
shops: {},
|
|
290
|
+
sapi: {
|
|
291
|
+
host: "",
|
|
292
|
+
token: ""
|
|
293
|
+
}
|
|
294
|
+
};
|
|
271
295
|
nuxt.options.runtimeConfig.storefront = defu(
|
|
272
296
|
nuxt.options.runtimeConfig.storefront,
|
|
273
|
-
|
|
297
|
+
runtimeConfigDefaults
|
|
274
298
|
);
|
|
275
299
|
nuxt.options.runtimeConfig.public.storefront = defu(nuxt.options.runtimeConfig.public.storefront, {
|
|
276
300
|
log: {
|
|
@@ -6,7 +6,7 @@ import type { StorefrontAPIClient, CachedType, Log } from '@scayle/storefront-co
|
|
|
6
6
|
* sorts them, and returns the key of the first active one.
|
|
7
7
|
* The retrieved campaigns are cached for a specified duration.
|
|
8
8
|
*
|
|
9
|
-
* @see https://scayle.dev/en/
|
|
9
|
+
* @see https://scayle.dev/en/core-documentation/checkout-guide/features/promotions/discounts-and-offers/price-campaigns
|
|
10
10
|
* @see https://scayle.dev/en/api-guides/storefront-api/resources/campaigns/list-campaigns
|
|
11
11
|
*
|
|
12
12
|
* @param sapiClient The Storefront API client.
|
|
@@ -10,7 +10,7 @@ type UseIDPBaseReturn = Pick<Awaited<UseRpcReturn<'getExternalIdpRedirect'>>, 'd
|
|
|
10
10
|
*
|
|
11
11
|
* This composables uses the `useRpc` composable to call the `getExternalIdpRedirect` RPC method.
|
|
12
12
|
*
|
|
13
|
-
* @see https://scayle.dev/en/storefront-guide/
|
|
13
|
+
* @see https://scayle.dev/en/core-documentation/storefront-guide/storefront-application/technical-foundation/sessions#idp-redirect-url
|
|
14
14
|
*
|
|
15
15
|
* @param params The parameters for the `getExternalIdpRedirect` RPC call.
|
|
16
16
|
* @param key A unique key for the RPC call. Used for caching and invalidation. Defaults to 'useIDP'.
|
|
@@ -62,7 +62,7 @@ export type ExtendedAsyncData<ResT, ErrorT = unknown, DataT = ResT, PickKeys ext
|
|
|
62
62
|
* disabled globally via the `disableDefaultGetCachedDataOverride` option in the public runtime config, or individually per call using the `options` parameter.
|
|
63
63
|
*
|
|
64
64
|
* @see https://nuxt.com/docs/api/composables/use-async-data#params
|
|
65
|
-
* @see https://scayle.dev/en/storefront-guide/
|
|
65
|
+
* @see https://scayle.dev/en/core-documentation/storefront-guide/storefront-application/technical-foundation/rpc-methods#userpc
|
|
66
66
|
*
|
|
67
67
|
* @param method The name of the RPC method to call (e.g., 'useBrand).
|
|
68
68
|
* @param key A unique key for caching, persisting the data between server and client,
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This composable leverages `useRpcCall` to interact with corresponding RPC methods.
|
|
5
5
|
*
|
|
6
|
-
* @see https://scayle.dev/en/storefront-guide/
|
|
7
|
-
* @see https://scayle.dev/en/storefront-guide/
|
|
6
|
+
* @see https://scayle.dev/en/core-documentation/storefront-guide/storefront-application/technical-foundation/sessions
|
|
7
|
+
* @see https://scayle.dev/en/core-documentation/storefront-guide/storefront-application/features/login-and-registration
|
|
8
8
|
*
|
|
9
9
|
* @returns An object containing functions for various session management operations.
|
|
10
10
|
*/
|
|
@@ -11,7 +11,7 @@ import type { MaybeRefOrGetter } from 'vue';
|
|
|
11
11
|
* or from async data otherwise.
|
|
12
12
|
*
|
|
13
13
|
* @see https://scayle.dev/en/api-guides/storefront-api/resources/promotions/list-promotions
|
|
14
|
-
* @see https://scayle.dev/en/storefront-guide/
|
|
14
|
+
* @see https://scayle.dev/en/core-documentation/storefront-guide/storefront-application/technical-foundation/data-and-state#shared-state-and-caching
|
|
15
15
|
*
|
|
16
16
|
* @template DataT The type of the normalized RPC response data. Defaults to `NormalizedRpcResponse<'getCurrentPromotions'>`.
|
|
17
17
|
* @template PickKeys The keys to pick from the data. Defaults to all keys of `DataT`.
|
|
@@ -57,7 +57,7 @@ type UseWishlistBaseReturn = Awaited<UseRpcReturn<'getWishlist'>> & {
|
|
|
57
57
|
* requiring a type assertion to `WishlistResponseData`.
|
|
58
58
|
*
|
|
59
59
|
* @see https://scayle.dev/en/api-guides/storefront-api/resources/wishlists/get-a-wishlist
|
|
60
|
-
* @see https://scayle.dev/en/storefront-guide/
|
|
60
|
+
* @see https://scayle.dev/en/core-documentation/storefront-guide/storefront-application/technical-foundation/data-and-state#shared-state-and-caching
|
|
61
61
|
*
|
|
62
62
|
* @param params An object containing parameters and options for all wishlist-related RPC calls.
|
|
63
63
|
* @param params.params The parameters for the `useWishlist` RPC method.
|
|
@@ -3,14 +3,15 @@ import type { RuntimeConfig } from '@nuxt/schema';
|
|
|
3
3
|
import type { H3Event } from 'h3';
|
|
4
4
|
import type { Log, RpcContext, Cache as CacheInterface } from '@scayle/storefront-core';
|
|
5
5
|
import { StorefrontAPIClient } from '@scayle/storefront-core';
|
|
6
|
-
import type { ShopConfig
|
|
6
|
+
import type { ShopConfig } from '../module.js';
|
|
7
|
+
import type { StorefrontRuntimeConfigType } from './utils/zodSchema.js';
|
|
7
8
|
/**
|
|
8
9
|
* Interface defining the options for the context builder.
|
|
9
10
|
*/
|
|
10
11
|
export interface ContextBuilderOptions {
|
|
11
12
|
$cache: CacheInterface;
|
|
12
13
|
$shopConfig: ShopConfig;
|
|
13
|
-
$storefront:
|
|
14
|
+
$storefront: StorefrontRuntimeConfigType;
|
|
14
15
|
$log: Log;
|
|
15
16
|
sessionId?: string;
|
|
16
17
|
session?: Session;
|
|
@@ -26,7 +27,7 @@ export interface ContextBuilderOptions {
|
|
|
26
27
|
* It also sets up getters for IP, headers, user, access tokens,
|
|
27
28
|
* and functions for session management and user updates.
|
|
28
29
|
*
|
|
29
|
-
* @see https://scayle.dev/en/storefront-guide/
|
|
30
|
+
* @see https://scayle.dev/en/core-documentation/storefront-guide/storefront-application/technical-foundation/rpc-methods#rpc-context
|
|
30
31
|
*
|
|
31
32
|
* @param context The context builder options.
|
|
32
33
|
* @param context.$cache The cache instance.
|
package/dist/runtime/context.js
CHANGED
|
@@ -10,6 +10,7 @@ import { useNitroApp } from "nitropack/runtime";
|
|
|
10
10
|
import { getCachedFunction } from "./cached.js";
|
|
11
11
|
import { getApiBasePath } from "./server/middleware/bootstrap-utils.js";
|
|
12
12
|
import { fetchCampaignKey } from "./campaignKey.js";
|
|
13
|
+
import * as moduleOptions from "#internal/storefront-options.mjs";
|
|
13
14
|
async function getWishlistKey(appKeys, session, $log, $shopConfig) {
|
|
14
15
|
return session.data.user ? await generateWishlistKey({
|
|
15
16
|
keyTemplate: appKeys.wishlistKey,
|
|
@@ -69,7 +70,7 @@ export const buildContext = async (context) => {
|
|
|
69
70
|
const callRpc = buildRpcCall(
|
|
70
71
|
context.event,
|
|
71
72
|
$shopConfig,
|
|
72
|
-
getApiBasePath(
|
|
73
|
+
getApiBasePath(moduleOptions, "/")
|
|
73
74
|
);
|
|
74
75
|
const rpcContext = {
|
|
75
76
|
cached,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { H3Event } from 'h3';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ModuleOptions, PublicShopConfig, ShopConfig, ShopConfigIndexed } from '../../../module.js';
|
|
3
3
|
import type { NitroRuntimeConfigApp } from 'nitropack';
|
|
4
|
+
import type { StorefrontRuntimeConfigType } from '../../utils/zodSchema.js';
|
|
4
5
|
/**
|
|
5
6
|
* Represents the bootstrapped path information.
|
|
6
7
|
*/
|
|
@@ -39,7 +40,7 @@ export declare const getShopByPath: (event: H3Event, shops: ShopConfig[], appBas
|
|
|
39
40
|
*
|
|
40
41
|
* @returns The shops as an array.
|
|
41
42
|
*/
|
|
42
|
-
export declare const convertShopsToList: (shops: ShopConfig[] | ShopConfigIndexed) => ShopConfig[];
|
|
43
|
+
export declare const convertShopsToList: (shops: ShopConfig[] | ShopConfigIndexed | StorefrontRuntimeConfigType["shops"]) => ShopConfig[];
|
|
43
44
|
/**
|
|
44
45
|
* Gets the API base path.
|
|
45
46
|
*
|
|
@@ -48,7 +49,7 @@ export declare const convertShopsToList: (shops: ShopConfig[] | ShopConfigIndexe
|
|
|
48
49
|
*
|
|
49
50
|
* @returns The API base path.
|
|
50
51
|
*/
|
|
51
|
-
export declare function getApiBasePath(storefrontConfig: Pick<
|
|
52
|
+
export declare function getApiBasePath(storefrontConfig: Pick<ModuleOptions, 'apiBasePath'>, baseUrl: string): string;
|
|
52
53
|
/**
|
|
53
54
|
* Retrieves the current shop configuration for a given request.
|
|
54
55
|
*
|
|
@@ -58,7 +59,7 @@ export declare function getApiBasePath(storefrontConfig: Pick<ModuleBaseOptions,
|
|
|
58
59
|
*
|
|
59
60
|
* @returns The shop config for the current request if found or undefined.
|
|
60
61
|
*/
|
|
61
|
-
export declare function getCurrentShopConfigForRequest(event: H3Event, storefrontConfig: Pick<
|
|
62
|
+
export declare function getCurrentShopConfigForRequest(event: H3Event, storefrontConfig: Pick<StorefrontRuntimeConfigType, 'shops' | 'shopSelector'>, runtimeConfig: NitroRuntimeConfigApp): ShopConfig | undefined;
|
|
62
63
|
/**
|
|
63
64
|
* Transforms shop configuration data into a public representation, including active status.
|
|
64
65
|
*
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
} from "./bootstrap-utils.js";
|
|
16
16
|
import { useRedirects } from "./redirects.js";
|
|
17
17
|
import { useRuntimeConfig } from "#imports";
|
|
18
|
+
import * as moduleOptions from "#internal/storefront-options.mjs";
|
|
18
19
|
const generateSessionId = (event) => {
|
|
19
20
|
let userId;
|
|
20
21
|
if (event?.context.session?.data?.accessToken) {
|
|
@@ -147,7 +148,7 @@ export default defineEventHandler(async (event) => {
|
|
|
147
148
|
return;
|
|
148
149
|
}
|
|
149
150
|
const $storefrontConfig = config.storefront;
|
|
150
|
-
if (path === `${
|
|
151
|
+
if (path === `${getApiBasePath(moduleOptions, "/")}/up`) {
|
|
151
152
|
return;
|
|
152
153
|
}
|
|
153
154
|
const $shopConfig = getCurrentShopConfigForRequest(
|
|
@@ -163,7 +164,7 @@ export default defineEventHandler(async (event) => {
|
|
|
163
164
|
return;
|
|
164
165
|
}
|
|
165
166
|
const apiBasePath = getApiBasePath(
|
|
166
|
-
|
|
167
|
+
moduleOptions,
|
|
167
168
|
config.app.baseURL
|
|
168
169
|
);
|
|
169
170
|
if (!event.context.$rpcContext) {
|
|
@@ -7,8 +7,8 @@ import type { H3Event } from 'h3';
|
|
|
7
7
|
* It utilizes a cache to store redirect results and falls back to the
|
|
8
8
|
* Storefront API if no cached redirect is available.
|
|
9
9
|
*
|
|
10
|
-
* @see https://scayle.dev/en/
|
|
11
|
-
* @see https://scayle.dev/en/
|
|
10
|
+
* @see https://scayle.dev/en/core-documentation/storefront-guide/storefront-application/features/redirects#overview
|
|
11
|
+
* @see https://scayle.dev/en/core-documentation/the-basics/shops/redirects
|
|
12
12
|
*
|
|
13
13
|
* @param event The H3 event object.
|
|
14
14
|
*/
|