@scayle/storefront-core 8.21.0 → 8.23.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/CHANGELOG.md +16 -0
- package/dist/helpers/advancedAttributeHelpers.d.ts +4 -0
- package/dist/helpers/attributeHelpers.d.ts +2 -18
- package/dist/helpers/attributeHelpers.mjs +3 -8
- package/dist/index.d.ts +1 -1
- package/dist/rpc/methods/checkout/checkout.mjs +1 -1
- package/dist/rpc/methods/oauth/idp.d.ts +2 -0
- package/dist/rpc/methods/oauth/idp.mjs +3 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @scayle/storefront-core
|
|
2
2
|
|
|
3
|
+
## 8.23.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Deprecated attribute group specific utilities `getFlattenedVariantCrosssellings` and
|
|
8
|
+
`getFlattenedMaterialComposition`.
|
|
9
|
+
|
|
10
|
+
These functions should be a part of the Storefront application.
|
|
11
|
+
|
|
12
|
+
## 8.22.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- Allow passing `authUrlParameters` to the `getExternalIdpRedirect` RPC method. This parameter is an optional `Record<string, string>`. Values provided here will be processed by the Auth service and appended to the final redirect URL.
|
|
17
|
+
- Exported the `ShopCountryCustomData` interface.
|
|
18
|
+
|
|
3
19
|
## 8.21.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
|
@@ -21,6 +21,8 @@ interface FlattenedMaterialComposition {
|
|
|
21
21
|
* @param materialCompositions The material compositions to flatten.
|
|
22
22
|
*
|
|
23
23
|
* @returns An array of flattened material compositions.
|
|
24
|
+
*
|
|
25
|
+
* @deprecated Logic for flattening material compositions should be handled within the Storefront project itself.
|
|
24
26
|
*/
|
|
25
27
|
export declare const getFlattenedMaterialComposition: (materialCompositions: Array<{
|
|
26
28
|
fieldSet: FieldSet;
|
|
@@ -42,6 +44,8 @@ export declare const getFlattenedAdvancedAttribute: <T>(attributeGroup: Array<{
|
|
|
42
44
|
*
|
|
43
45
|
* @param variantCrosssellings The variant cross-selling data to flatten.
|
|
44
46
|
* @returns A generically typed array of flattened variant cross-selling data.
|
|
47
|
+
*
|
|
48
|
+
* @deprecated Logic for flattening variant crosssellings should be handled within the Storefront project itself.
|
|
45
49
|
*/
|
|
46
50
|
export declare const getFlattenedVariantCrosssellings: <T>(variantCrosssellings: Array<{
|
|
47
51
|
fieldSet: FieldSet;
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import type { Attributes, Value } from '@scayle/storefront-api';
|
|
2
|
-
|
|
3
|
-
* Retrieves the first attribute value for a given attribute name from a set of attributes.
|
|
4
|
-
*
|
|
5
|
-
* @param attributes The set of attributes.
|
|
6
|
-
* @param attributeName The name of the attribute to retrieve.
|
|
7
|
-
*
|
|
8
|
-
* @returns The first attribute value, or undefined if not found.
|
|
9
|
-
*/
|
|
10
|
-
export declare const getFirstAttributeValue: (attributes: Attributes | undefined, attributeName: string) => Value | undefined;
|
|
2
|
+
import { getAttributeValues, getFirstAttributeValue } from '@scayle/storefront-api';
|
|
11
3
|
/**
|
|
12
4
|
* Retrieves the value or label of the first attribute value for a given attribute name.
|
|
13
5
|
*
|
|
@@ -17,15 +9,6 @@ export declare const getFirstAttributeValue: (attributes: Attributes | undefined
|
|
|
17
9
|
* @returns The value or label of the first attribute value, or null if not found.
|
|
18
10
|
*/
|
|
19
11
|
export declare const getAttributeValue: (attributes: Attributes | undefined, attributeName: string) => string | undefined;
|
|
20
|
-
/**
|
|
21
|
-
* Retrieves all attribute values for a given attribute name.
|
|
22
|
-
*
|
|
23
|
-
* @param attributes The set of attributes.
|
|
24
|
-
* @param attributeName The name of the attribute to retrieve.
|
|
25
|
-
*
|
|
26
|
-
* @returns An array of attribute values, or an empty array if not found.
|
|
27
|
-
*/
|
|
28
|
-
export declare const getAttributeValueTuples: (attributes: Attributes | undefined, attributeName: string) => Value[];
|
|
29
12
|
/**
|
|
30
13
|
* Retrieves the first attribute value for multiple attribute names.
|
|
31
14
|
*
|
|
@@ -35,3 +18,4 @@ export declare const getAttributeValueTuples: (attributes: Attributes | undefine
|
|
|
35
18
|
* @returns An array of attribute values, filtered to remove any null or undefined values.
|
|
36
19
|
*/
|
|
37
20
|
export declare const getManyAttributeValueTuples: (attributes: Attributes | undefined, attributeNames: string[]) => Value[];
|
|
21
|
+
export { getAttributeValues as getAttributeValueTuples, getFirstAttributeValue };
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
getAttributeValues
|
|
3
|
-
getFirstAttributeValue
|
|
2
|
+
getAttributeValues,
|
|
3
|
+
getFirstAttributeValue
|
|
4
4
|
} from "@scayle/storefront-api";
|
|
5
|
-
export const getFirstAttributeValue = (attributes, attributeName) => {
|
|
6
|
-
return _getFirstAttributeValue(attributes, attributeName);
|
|
7
|
-
};
|
|
8
5
|
export const getAttributeValue = (attributes, attributeName) => {
|
|
9
6
|
const values = getFirstAttributeValue(attributes, attributeName);
|
|
10
7
|
return values?.value ?? values?.label;
|
|
11
8
|
};
|
|
12
|
-
export const getAttributeValueTuples = (attributes, attributeName) => {
|
|
13
|
-
return _getAttributeValues(attributes, attributeName);
|
|
14
|
-
};
|
|
15
9
|
export const getManyAttributeValueTuples = (attributes, attributeNames) => {
|
|
16
10
|
return attributeNames.map((key) => getFirstAttributeValue(attributes, key)).filter((entry) => !!entry);
|
|
17
11
|
};
|
|
12
|
+
export { getAttributeValues as getAttributeValueTuples, getFirstAttributeValue };
|
package/dist/index.d.ts
CHANGED
|
@@ -68,4 +68,4 @@ export type RpcMethodParameters<N extends RpcMethodName> = Parameters<RpcMethod<
|
|
|
68
68
|
*/
|
|
69
69
|
export type RpcMethodReturnType<N extends RpcMethodName> = ReturnType<RpcMethod<N>>;
|
|
70
70
|
export type RpcMethodCall = <N extends RpcMethodName, P extends RpcMethodParameters<N>, TResult extends Exclude<Awaited<RpcMethodReturnType<N>>, Response>>(...args: P extends RpcContext ? [N] : [N, P]) => Promise<TResult>;
|
|
71
|
-
export { ExistingItemHandling, AddToBasketFailureKind, UpdateBasketItemFailureKind, AddToWishlistFailureKind, PromotionEffectType, FilterTypes, APISortOption, APISortOrder, type ProductSortConfig, } from '@scayle/storefront-api';
|
|
71
|
+
export { ExistingItemHandling, AddToBasketFailureKind, UpdateBasketItemFailureKind, AddToWishlistFailureKind, PromotionEffectType, FilterTypes, APISortOption, APISortOrder, type ProductSortConfig, type ShopCountryCustomData, } from '@scayle/storefront-api';
|
|
@@ -36,7 +36,7 @@ export const getCheckoutToken = async function getCheckoutToken2(jwtPayload = {}
|
|
|
36
36
|
carrier,
|
|
37
37
|
basketId: context.basketKey,
|
|
38
38
|
campaignKey
|
|
39
|
-
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.
|
|
39
|
+
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.23.0"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
|
|
40
40
|
return {
|
|
41
41
|
accessToken: refreshedAccessToken,
|
|
42
42
|
checkoutJwt
|
|
@@ -6,6 +6,7 @@ import type { RpcHandler } from '../../../types';
|
|
|
6
6
|
*
|
|
7
7
|
* @param params The parameters for retrieving the external IDP redirect.
|
|
8
8
|
* @param params.queryParams Optional query parameters to include in the redirect URLs.
|
|
9
|
+
* @param params.authUrlParameters Optional query parameters to provide to the IDP service.
|
|
9
10
|
* @param context The RPC context.
|
|
10
11
|
*
|
|
11
12
|
* @returns A record mapping IDP keys to their corresponding redirect URLs,
|
|
@@ -14,6 +15,7 @@ import type { RpcHandler } from '../../../types';
|
|
|
14
15
|
*/
|
|
15
16
|
export declare const getExternalIdpRedirect: RpcHandler<{
|
|
16
17
|
queryParams?: Record<string, string>;
|
|
18
|
+
authUrlParameters?: Record<string, string>;
|
|
17
19
|
}, Record<string, string>>;
|
|
18
20
|
/**
|
|
19
21
|
* Handles the IDP login callback.
|
|
@@ -4,7 +4,7 @@ import { HttpStatusCode, HttpStatusMessage } from "../../../constants/index.mjs"
|
|
|
4
4
|
import { hasSession } from "../../../types/index.mjs";
|
|
5
5
|
import { getOAuthClient } from "../../../api/oauth.mjs";
|
|
6
6
|
import { postLogin } from "../session.mjs";
|
|
7
|
-
export const getExternalIdpRedirect = async function getExternalIdpRedirect2({ queryParams }, context) {
|
|
7
|
+
export const getExternalIdpRedirect = async function getExternalIdpRedirect2({ queryParams, authUrlParameters }, context) {
|
|
8
8
|
if (!context.idp?.enabled) {
|
|
9
9
|
return {};
|
|
10
10
|
}
|
|
@@ -35,7 +35,8 @@ export const getExternalIdpRedirect = async function getExternalIdpRedirect2({ q
|
|
|
35
35
|
const jwtPayload = await new SignJWT({
|
|
36
36
|
idpKey,
|
|
37
37
|
callbackUrl: redirectUrl.toString(),
|
|
38
|
-
clientId: OAuthClient.clientId.toString()
|
|
38
|
+
clientId: OAuthClient.clientId.toString(),
|
|
39
|
+
authUrlParameters
|
|
39
40
|
}).setProtectedHeader({ alg: "HS256", typ: "JWT" }).setIssuedAt().setExpirationTime("2h").sign(secret);
|
|
40
41
|
const url = new URL(`${OAuthClient.baseURL}/auth/external/redirect`);
|
|
41
42
|
url.searchParams.set("shopId", `${context.shopId}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-core",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.23.0",
|
|
4
4
|
"description": "Collection of essential utilities to work with the Storefront API",
|
|
5
5
|
"author": "SCAYLE Commerce Engine",
|
|
6
6
|
"license": "MIT",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"@types/crypto-js": "4.2.2",
|
|
80
80
|
"@types/node": "22.14.1",
|
|
81
81
|
"@types/webpack-env": "1.18.8",
|
|
82
|
-
"@vitest/coverage-v8": "
|
|
82
|
+
"@vitest/coverage-v8": "3.1.1",
|
|
83
83
|
"dprint": "0.49.1",
|
|
84
84
|
"eslint": "9.24.0",
|
|
85
85
|
"eslint-formatter-gitlab": "5.1.0",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"typescript": "5.8.3",
|
|
90
90
|
"unbuild": "3.5.0",
|
|
91
91
|
"unstorage": "1.15.0",
|
|
92
|
-
"vitest": "
|
|
92
|
+
"vitest": "3.1.1"
|
|
93
93
|
},
|
|
94
94
|
"volta": {
|
|
95
95
|
"node": "22.14.0"
|