@scayle/storefront-core 8.45.0 → 8.46.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-V7.md +1 -1
- package/CHANGELOG.md +68 -1
- package/README.md +2 -2
- package/dist/api/customer.d.ts +1 -1
- package/dist/api/oauth.d.ts +8 -8
- package/dist/api/oauth.mjs +7 -7
- package/dist/helpers/attributeHelpers.d.ts +64 -2
- package/dist/helpers/attributeHelpers.mjs +34 -5
- package/dist/rpc/methods/checkout/checkout.mjs +1 -1
- package/dist/rpc/methods/oauth/idp.d.ts +2 -2
- package/dist/rpc/methods/products.mjs +1 -1
- package/dist/types/api/auth.d.ts +9 -10
- package/dist/types/api/context.d.ts +1 -1
- package/dist/types/sapi/product.d.ts +3 -3
- package/dist/types/sapi/productFilter.d.ts +1 -1
- package/dist/utils/campaign.d.ts +3 -3
- package/package.json +9 -9
package/CHANGELOG-V7.md
CHANGED
|
@@ -25,7 +25,7 @@ This changelog contains all changes of `@scayle/storefront-core` above v6.0.0 an
|
|
|
25
25
|
- Extend `FetchProductsByCategoryParams` type to support `trackSearchAnalyticsEvent?: boolean`
|
|
26
26
|
- Allow passing of the `trackSearchAnalyticsEvent` parameter into the `getProductsByCategory` RPC method.
|
|
27
27
|
**NOTE**: To prevent logging the search term on every page request when when paginating with the `page` parameter, the `trackSearchAnalyticsEvent` parameter is only passed on the first page (`page === 1`).
|
|
28
|
-
For more details on how to utilize this, check the [SCAYLE Search Analytics section](https://scayle.dev/en/
|
|
28
|
+
For more details on how to utilize this, check the [SCAYLE Search Analytics section](https://scayle.dev/en/core-documentation/the-basics/shops/search#scayle-search-analytics) in the SCAYLE Resource Center.
|
|
29
29
|
|
|
30
30
|
## 7.69.0
|
|
31
31
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,72 @@
|
|
|
1
1
|
# @scayle/storefront-core
|
|
2
2
|
|
|
3
|
+
## 8.46.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added `getAttributeValuesByGroupId` function to the `attributeHelpers` helper for retrieving attribute values by their numeric attribute group ID.
|
|
8
|
+
|
|
9
|
+
This function allows you to retrieve attribute values filtered by a specific attribute group ID, providing a more targeted approach when working with grouped product attributes.
|
|
10
|
+
The existing `getAttributeValues` function has been renamed to `getAttributeValuesByName` to better differentiate between the two lookup methods.
|
|
11
|
+
|
|
12
|
+
### Usage Examples
|
|
13
|
+
|
|
14
|
+
Both functions return an array of values for consistency, making them safe to use in iterations. For single-select attributes, the value is wrapped in an array. For multi-select attributes, the array is returned directly.
|
|
15
|
+
|
|
16
|
+
#### Looking up by name (existing, now renamed):
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { getAttributeValuesByName } from '@scayle/storefront-core'
|
|
20
|
+
|
|
21
|
+
// Single-select attribute
|
|
22
|
+
const sizes = getAttributeValuesByName(product.attributes, 'size')
|
|
23
|
+
// Returns: [{ id: 1, label: 'M', value: 'medium' }]
|
|
24
|
+
|
|
25
|
+
// Multi-select attribute
|
|
26
|
+
const colors = getAttributeValuesByName(product.attributes, 'color')
|
|
27
|
+
// Returns: [{ id: 1, label: 'Red' }, { id: 2, label: 'Blue' }]
|
|
28
|
+
|
|
29
|
+
// Non-existent attribute
|
|
30
|
+
const missing = getAttributeValuesByName(product.attributes, 'doesNotExist')
|
|
31
|
+
// Returns: []
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
#### Looking up by group ID (new):
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { getAttributeValuesByGroupId } from '@scayle/storefront-core'
|
|
38
|
+
|
|
39
|
+
// Look up attribute by its numeric ID from the SCAYLE API
|
|
40
|
+
const promotionValues = getAttributeValuesByGroupId(product.attributes, 42)
|
|
41
|
+
// Returns: [{ id: 123, label: 'Summer Sale', value: 'summer-2024' }]
|
|
42
|
+
|
|
43
|
+
// Non-existent attribute group
|
|
44
|
+
const missing = getAttributeValuesByGroupId(product.attributes, 9999)
|
|
45
|
+
// Returns: []
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### When to Use Each Function
|
|
49
|
+
|
|
50
|
+
- **`getAttributeValuesByName`**: Use when you know the attribute name key (e.g., 'color', 'size'). This is the most common use case in application code.
|
|
51
|
+
- **`getAttributeValuesByGroupId`**: Use when you have the numeric attribute group ID from the SCAYLE API, such as when processing API configurations, handling dynamic attribute mappings, or working with attribute group references.
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
**Dependencies**
|
|
56
|
+
|
|
57
|
+
- Updated dependency to @scayle/storefront-api@18.17.0
|
|
58
|
+
|
|
59
|
+
## 8.45.1
|
|
60
|
+
|
|
61
|
+
### Patch Changes
|
|
62
|
+
|
|
63
|
+
- Updated SCAYLE Resource Center references
|
|
64
|
+
|
|
65
|
+
**Dependencies**
|
|
66
|
+
|
|
67
|
+
- Updated dependency to @scayle/unstorage-scayle-kv-driver@2.0.6
|
|
68
|
+
- Updated dependency to @scayle/storefront-api@18.16.1
|
|
69
|
+
|
|
3
70
|
## 8.45.0
|
|
4
71
|
|
|
5
72
|
## 8.44.2
|
|
@@ -890,7 +957,7 @@ async function rpcMethod(context) {
|
|
|
890
957
|
```
|
|
891
958
|
|
|
892
959
|
To override the default campaign key, override the getCampaignKey RPC with your own implementation.
|
|
893
|
-
See [Overriding core RPC Methods](https://scayle.dev/en/storefront-guide/
|
|
960
|
+
See [Overriding core RPC Methods](https://scayle.dev/en/core-documentation/storefront-guide/storefront-application/technical-foundation/rpc-methods#overriding-core-rpc-methods) for more.
|
|
894
961
|
|
|
895
962
|
## 8.7.1
|
|
896
963
|
|
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ npm install @scayle/storefront-core
|
|
|
35
35
|
|
|
36
36
|
## Getting Started
|
|
37
37
|
|
|
38
|
-
Visit the [Quickstart Guide](https://scayle.dev/en/
|
|
38
|
+
Visit the [Quickstart Guide](https://scayle.dev/en/core-documentation/storefront-guide/storefront-application/readme/setup-your-storefront) to get started with Storefront Core.
|
|
39
39
|
|
|
40
40
|
Visit the [Docs](https://scayle.dev) to learn more about our system requirements.
|
|
41
41
|
|
|
@@ -44,7 +44,7 @@ Visit the [Docs](https://scayle.dev) to learn more about our system requirements
|
|
|
44
44
|
[SCAYLE](https://scayle.com) is a full-featured e-commerce software solution that comes with flexible APIs.
|
|
45
45
|
Within SCAYLE, you can manage all aspects of your shop, such as products, stocks, customers, and transactions.
|
|
46
46
|
|
|
47
|
-
Learn more about [SCAYLE’s architecture](https://scayle.dev/en/
|
|
47
|
+
Learn more about [SCAYLE’s architecture](https://scayle.dev/en/core-documentation/welcome-to-scayle/getting-started) and commerce modules in the docs.
|
|
48
48
|
|
|
49
49
|
## Other channels
|
|
50
50
|
|
package/dist/api/customer.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ interface PasswordUpdate {
|
|
|
46
46
|
*
|
|
47
47
|
* Should be initialized with the token set acquired from the Auth API.
|
|
48
48
|
*
|
|
49
|
-
* @see https://scayle.dev/en/api-guides/customer-account-api
|
|
49
|
+
* @see https://scayle.dev/en/api-guides/customer-account-api/
|
|
50
50
|
*/
|
|
51
51
|
export declare class CustomerAPIClient {
|
|
52
52
|
/**
|
package/dist/api/oauth.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export declare function getOAuthClient(context: RpcContext): OAuthClient;
|
|
|
29
29
|
/**
|
|
30
30
|
* A client for interacting with the Checkout Authentication API
|
|
31
31
|
*
|
|
32
|
-
* @see https://scayle.dev/en/api-guides/
|
|
32
|
+
* @see https://scayle.dev/en/api-guides/authentication-api/
|
|
33
33
|
*/
|
|
34
34
|
export declare class OAuthClient {
|
|
35
35
|
/**
|
|
@@ -64,7 +64,7 @@ export declare class OAuthClient {
|
|
|
64
64
|
*
|
|
65
65
|
* @returns The OAuth response containing access and refresh tokens.
|
|
66
66
|
*
|
|
67
|
-
* @see https://scayle.dev/en/api-guides/
|
|
67
|
+
* @see https://scayle.dev/en/api-guides/authentication-api/resources/oauth-client/create-new-user
|
|
68
68
|
*/
|
|
69
69
|
register(payload: RegisterRequest): Promise<Oauth>;
|
|
70
70
|
/**
|
|
@@ -74,7 +74,7 @@ export declare class OAuthClient {
|
|
|
74
74
|
*
|
|
75
75
|
* @returns The OAuth response containing access and refresh tokens.
|
|
76
76
|
*
|
|
77
|
-
* @see https://scayle.dev/en/api-guides/
|
|
77
|
+
* @see https://scayle.dev/en/api-guides/authentication-api/resources/oauth-client/log-in-users
|
|
78
78
|
*/
|
|
79
79
|
login(payload: LoginRequest): Promise<Oauth>;
|
|
80
80
|
/**
|
|
@@ -84,7 +84,7 @@ export declare class OAuthClient {
|
|
|
84
84
|
*
|
|
85
85
|
* @returns The OAuth response containing access and refresh tokens.
|
|
86
86
|
*
|
|
87
|
-
* @see https://scayle.dev/en/api-guides/
|
|
87
|
+
* @see https://scayle.dev/en/api-guides/authentication-api/resources/oauth-client/log-in-users-as-guest
|
|
88
88
|
*/
|
|
89
89
|
guestLogin(payload: GuestRequest): Promise<Oauth>;
|
|
90
90
|
/**
|
|
@@ -94,7 +94,7 @@ export declare class OAuthClient {
|
|
|
94
94
|
*
|
|
95
95
|
* @returns Nothing (resolves when the request completes successfully).
|
|
96
96
|
*
|
|
97
|
-
* @see https://scayle.dev/en/api-guides/
|
|
97
|
+
* @see https://scayle.dev/en/api-guides/authentication-api/resources/oauth-client/send-password-reset-email
|
|
98
98
|
*/
|
|
99
99
|
sendPasswordResetEmail(payload: SendResetPasswordEmailRequest): Promise<void>;
|
|
100
100
|
/**
|
|
@@ -105,7 +105,7 @@ export declare class OAuthClient {
|
|
|
105
105
|
*
|
|
106
106
|
* @returns The new OAuth response with updated tokens.
|
|
107
107
|
*
|
|
108
|
-
* @see https://scayle.dev/en/api-guides/
|
|
108
|
+
* @see https://scayle.dev/en/api-guides/authentication-api/resources/oauth-client/update-password-by-hash
|
|
109
109
|
*/
|
|
110
110
|
updatePasswordByHash(payload: UpdatePasswordByHashRequest): Promise<Oauth>;
|
|
111
111
|
/**
|
|
@@ -131,7 +131,7 @@ export declare class OAuthClient {
|
|
|
131
131
|
*
|
|
132
132
|
* @returns Nothing (resolves if the token is valid, rejects otherwise).
|
|
133
133
|
*
|
|
134
|
-
* @see https://scayle.dev/en/api-guides/
|
|
134
|
+
* @see https://scayle.dev/en/api-guides/authentication-api/resources/bearer-auth/validate-present-token
|
|
135
135
|
*/
|
|
136
136
|
validateToken(accessToken: string): Promise<void>;
|
|
137
137
|
/**
|
|
@@ -149,7 +149,7 @@ export declare class OAuthClient {
|
|
|
149
149
|
* @param accessToken The access token to use for authorization.
|
|
150
150
|
* @returns Nothing (resolves when the token is successfully revoked).
|
|
151
151
|
*
|
|
152
|
-
* @see https://scayle.dev/en/api-guides/
|
|
152
|
+
* @see https://scayle.dev/en/api-guides/authentication-api/resources/bearer-auth/delete-access-token-with-id
|
|
153
153
|
*/
|
|
154
154
|
revokeToken(shopId: number, accessToken: string): Promise<void>;
|
|
155
155
|
/**
|
package/dist/api/oauth.mjs
CHANGED
|
@@ -121,7 +121,7 @@ export class OAuthClient {
|
|
|
121
121
|
*
|
|
122
122
|
* @returns The OAuth response containing access and refresh tokens.
|
|
123
123
|
*
|
|
124
|
-
* @see https://scayle.dev/en/api-guides/
|
|
124
|
+
* @see https://scayle.dev/en/api-guides/authentication-api/resources/oauth-client/create-new-user
|
|
125
125
|
*/
|
|
126
126
|
async register(payload) {
|
|
127
127
|
this.logger?.debug("Registering user");
|
|
@@ -138,7 +138,7 @@ export class OAuthClient {
|
|
|
138
138
|
*
|
|
139
139
|
* @returns The OAuth response containing access and refresh tokens.
|
|
140
140
|
*
|
|
141
|
-
* @see https://scayle.dev/en/api-guides/
|
|
141
|
+
* @see https://scayle.dev/en/api-guides/authentication-api/resources/oauth-client/log-in-users
|
|
142
142
|
*/
|
|
143
143
|
async login(payload) {
|
|
144
144
|
this.logger?.debug("Logging in");
|
|
@@ -155,7 +155,7 @@ export class OAuthClient {
|
|
|
155
155
|
*
|
|
156
156
|
* @returns The OAuth response containing access and refresh tokens.
|
|
157
157
|
*
|
|
158
|
-
* @see https://scayle.dev/en/api-guides/
|
|
158
|
+
* @see https://scayle.dev/en/api-guides/authentication-api/resources/oauth-client/log-in-users-as-guest
|
|
159
159
|
*/
|
|
160
160
|
async guestLogin(payload) {
|
|
161
161
|
this.logger?.debug("Logging in as guest");
|
|
@@ -172,7 +172,7 @@ export class OAuthClient {
|
|
|
172
172
|
*
|
|
173
173
|
* @returns Nothing (resolves when the request completes successfully).
|
|
174
174
|
*
|
|
175
|
-
* @see https://scayle.dev/en/api-guides/
|
|
175
|
+
* @see https://scayle.dev/en/api-guides/authentication-api/resources/oauth-client/send-password-reset-email
|
|
176
176
|
*/
|
|
177
177
|
async sendPasswordResetEmail(payload) {
|
|
178
178
|
this.logger?.debug("Sending password reset email");
|
|
@@ -190,7 +190,7 @@ export class OAuthClient {
|
|
|
190
190
|
*
|
|
191
191
|
* @returns The new OAuth response with updated tokens.
|
|
192
192
|
*
|
|
193
|
-
* @see https://scayle.dev/en/api-guides/
|
|
193
|
+
* @see https://scayle.dev/en/api-guides/authentication-api/resources/oauth-client/update-password-by-hash
|
|
194
194
|
*/
|
|
195
195
|
async updatePasswordByHash(payload) {
|
|
196
196
|
this.logger?.debug("Updating password by hash");
|
|
@@ -240,7 +240,7 @@ export class OAuthClient {
|
|
|
240
240
|
*
|
|
241
241
|
* @returns Nothing (resolves if the token is valid, rejects otherwise).
|
|
242
242
|
*
|
|
243
|
-
* @see https://scayle.dev/en/api-guides/
|
|
243
|
+
* @see https://scayle.dev/en/api-guides/authentication-api/resources/bearer-auth/validate-present-token
|
|
244
244
|
*/
|
|
245
245
|
async validateToken(accessToken) {
|
|
246
246
|
this.logger?.debug("Validating access token");
|
|
@@ -266,7 +266,7 @@ export class OAuthClient {
|
|
|
266
266
|
* @param accessToken The access token to use for authorization.
|
|
267
267
|
* @returns Nothing (resolves when the token is successfully revoked).
|
|
268
268
|
*
|
|
269
|
-
* @see https://scayle.dev/en/api-guides/
|
|
269
|
+
* @see https://scayle.dev/en/api-guides/authentication-api/resources/bearer-auth/delete-access-token-with-id
|
|
270
270
|
*/
|
|
271
271
|
async revokeToken(shopId, accessToken) {
|
|
272
272
|
this.logger?.debug("Revoking access token");
|
|
@@ -1,5 +1,64 @@
|
|
|
1
1
|
import type { Attributes, Value } from '@scayle/storefront-api';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Returns the first value of an attribute.
|
|
4
|
+
* This function is useful when you need to get the first value of an attribute.
|
|
5
|
+
*
|
|
6
|
+
* This returns undefined, if the attribute doesn't exist or if it doesn't have any values.
|
|
7
|
+
*
|
|
8
|
+
* @param attributes - The product attributes object
|
|
9
|
+
* @param attributeName - The name of the attribute to look up
|
|
10
|
+
*
|
|
11
|
+
* @returns The first value of the attribute, or undefined if the attribute doesn't exist or has no values
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const firstColor = getFirstAttributeValue(product.attributes, 'color')
|
|
16
|
+
* // Returns: { id: 1, label: 'Red', value: 'red' }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare const getFirstAttributeValue: (attributes: Attributes | undefined, attributeName: string) => Value | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Returns all values of an attribute group by its name key.
|
|
22
|
+
* This function always returns an array, making it safe to use in iterations.
|
|
23
|
+
* For single-select attributes, the value is wrapped in an array.
|
|
24
|
+
* For multi-select attributes, the array is returned directly.
|
|
25
|
+
*
|
|
26
|
+
* @param attributes - The product attributes object
|
|
27
|
+
* @param name - The name key of the attribute group to look up (e.g., 'color', 'size')
|
|
28
|
+
*
|
|
29
|
+
* @returns An array of values, or an empty array if the attribute doesn't exist or has no values
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* // Single-select attribute
|
|
34
|
+
* const sizes = getAttributeValuesByName(product.attributes, 'size')
|
|
35
|
+
* // Returns: [{ id: 1, label: 'M', value: 'medium' }]
|
|
36
|
+
*
|
|
37
|
+
* // Multi-select attribute
|
|
38
|
+
* const colors = getAttributeValuesByName(product.attributes, 'color')
|
|
39
|
+
* // Returns: [{ id: 1, label: 'Red' }, { id: 2, label: 'Blue' }]
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare const getAttributeValuesByName: (attributes: Attributes | undefined, name: string) => Value[];
|
|
43
|
+
/**
|
|
44
|
+
* Returns all values of an attribute group by its numeric ID.
|
|
45
|
+
*
|
|
46
|
+
* This function searches through all attribute groups to find one matching the given ID.
|
|
47
|
+
* This is useful when you need to look up attributes by their SCAYLE API identifier rather than by name.
|
|
48
|
+
* Like {@link getAttributeValuesByName}, this always returns an array for consistency.
|
|
49
|
+
*
|
|
50
|
+
* @param attributes - The product attributes object
|
|
51
|
+
* @param groupId - The numeric ID of the attribute group to look up
|
|
52
|
+
* @returns An array of values, or an empty array if the attribute doesn't exist or has no values
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* // Look up by attribute group ID instead of name
|
|
57
|
+
* const promotionValues = getAttributeValuesByGroupId(product.attributes, 42)
|
|
58
|
+
* // Returns: [{ id: 123, label: 'Summer Sale', value: 'summer-2024' }]
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare const getAttributeValuesByGroupId: (attributes: Attributes | undefined, groupId: number) => Value[];
|
|
3
62
|
/**
|
|
4
63
|
* Retrieves the value or label of the first attribute value for a given attribute name.
|
|
5
64
|
*
|
|
@@ -18,4 +77,7 @@ export declare const getAttributeValue: (attributes: Attributes | undefined, att
|
|
|
18
77
|
* @returns An array of attribute values, filtered to remove any null or undefined values.
|
|
19
78
|
*/
|
|
20
79
|
export declare const getManyAttributeValueTuples: (attributes: Attributes | undefined, attributeNames: string[]) => Value[];
|
|
21
|
-
|
|
80
|
+
/**
|
|
81
|
+
* @deprecated This function will be removed in the next major version. Use {@link getAttributeValuesByName} instead.
|
|
82
|
+
*/
|
|
83
|
+
export { getAttributeValuesByName as getAttributeValueTuples };
|
|
@@ -1,7 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export const getFirstAttributeValue = (attributes, attributeName) => {
|
|
2
|
+
const attribute = attributes && attributes[attributeName];
|
|
3
|
+
if (!attribute || !attribute.values) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
if (attribute.multiSelect) {
|
|
7
|
+
return attribute.values.length > 0 ? attribute.values[0] : void 0;
|
|
8
|
+
}
|
|
9
|
+
return attribute.values;
|
|
10
|
+
};
|
|
11
|
+
export const getAttributeValuesByName = (attributes, name) => {
|
|
12
|
+
const attribute = attributes && attributes[name];
|
|
13
|
+
if (!attribute || !attribute.values) {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
if (attribute.multiSelect) {
|
|
17
|
+
return attribute.values;
|
|
18
|
+
}
|
|
19
|
+
return [attribute.values];
|
|
20
|
+
};
|
|
21
|
+
export const getAttributeValuesByGroupId = (attributes, groupId) => {
|
|
22
|
+
if (!attributes) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
const attribute = Object.values(attributes).find((attribute2) => attribute2?.id === groupId);
|
|
26
|
+
if (!attribute || !attribute.values) {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
if (attribute.multiSelect) {
|
|
30
|
+
return attribute.values;
|
|
31
|
+
}
|
|
32
|
+
return [attribute.values];
|
|
33
|
+
};
|
|
5
34
|
export const getAttributeValue = (attributes, attributeName) => {
|
|
6
35
|
const values = getFirstAttributeValue(attributes, attributeName);
|
|
7
36
|
return values?.value ?? values?.label;
|
|
@@ -9,4 +38,4 @@ export const getAttributeValue = (attributes, attributeName) => {
|
|
|
9
38
|
export const getManyAttributeValueTuples = (attributes, attributeNames) => {
|
|
10
39
|
return attributeNames.map((key) => getFirstAttributeValue(attributes, key)).filter((entry) => !!entry);
|
|
11
40
|
};
|
|
12
|
-
export {
|
|
41
|
+
export { getAttributeValuesByName as getAttributeValueTuples };
|
|
@@ -33,7 +33,7 @@ export const getCheckoutToken = defineRpcHandler(async (jwtPayload = {}, context
|
|
|
33
33
|
carrier,
|
|
34
34
|
basketId: context.basketKey,
|
|
35
35
|
campaignKey
|
|
36
|
-
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.
|
|
36
|
+
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.46.0"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
|
|
37
37
|
return {
|
|
38
38
|
accessToken: refreshedAccessToken,
|
|
39
39
|
checkoutJwt
|
|
@@ -2,7 +2,7 @@ import type { RpcHandler } from '../../../types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Retrieves external IDP redirect URLs.
|
|
4
4
|
*
|
|
5
|
-
* @see https://scayle.dev/en/storefront-guide/
|
|
5
|
+
* @see https://scayle.dev/en/core-documentation/storefront-guide/storefront-application/features/login-and-registration#overview
|
|
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.
|
|
@@ -20,7 +20,7 @@ export declare const getExternalIdpRedirect: RpcHandler<{
|
|
|
20
20
|
/**
|
|
21
21
|
* Handles the IDP login callback.
|
|
22
22
|
*
|
|
23
|
-
* @see https://scayle.dev/en/storefront-guide/
|
|
23
|
+
* @see https://scayle.dev/en/core-documentation/storefront-guide/storefront-application/features/login-and-registration#overview
|
|
24
24
|
*
|
|
25
25
|
* @param payload The payload containing the authorization code.
|
|
26
26
|
* @param payload.code The authorization code.
|
|
@@ -291,7 +291,7 @@ export const getProductsByCategory = async function getProductsByCategory2(param
|
|
|
291
291
|
// The consuming project should not include trackSearchAnalyticsEvent parameter when paginating through
|
|
292
292
|
// results with the page parameter, as this logs the search term on every page request.
|
|
293
293
|
// Instead, log the term only once, when the search is first performed.
|
|
294
|
-
// https://scayle.dev/en/
|
|
294
|
+
// https://scayle.dev/en/core-documentation/the-basics/shops/search#scayle-search-analytics
|
|
295
295
|
trackSearchAnalyticsEvent
|
|
296
296
|
});
|
|
297
297
|
return {
|
package/dist/types/api/auth.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Gender } from '../user';
|
|
|
3
3
|
* Represents a pair of OAuth 2.0 access and refresh tokens. These tokens are used for authentication and authorization within an OAuth 2.0 flow.
|
|
4
4
|
*
|
|
5
5
|
* @see https://datatracker.ietf.org/doc/html/rfc6749#section-1.4
|
|
6
|
-
* @see https://scayle.dev/en/checkout-guide/authentication-accounts/token-
|
|
6
|
+
* @see https://scayle.dev/en/core-documentation/checkout-guide/authentication-accounts/authetication/token-management#token-types
|
|
7
7
|
*/
|
|
8
8
|
export interface OAuthTokens {
|
|
9
9
|
accessToken: string;
|
|
@@ -21,7 +21,7 @@ interface BaseError {
|
|
|
21
21
|
* Represents a Bad Request (400) error indicating a validation failure, often caused by incorrect client input.
|
|
22
22
|
*
|
|
23
23
|
* @see https://datatracker.ietf.org/doc/html/rfc6750#section-3.1
|
|
24
|
-
* @see https://scayle.dev/en/api-guides/
|
|
24
|
+
* @see https://scayle.dev/en/api-guides/authentication-api/getting-started/errors#_400s-status-codes
|
|
25
25
|
*/
|
|
26
26
|
export interface BadRequestError extends BaseError {
|
|
27
27
|
error: 'validation_error';
|
|
@@ -35,7 +35,7 @@ export interface BadRequestError extends BaseError {
|
|
|
35
35
|
* Represents an Unauthorized (401) error indicating client authentication failure, typically due to invalid credentials.
|
|
36
36
|
*
|
|
37
37
|
* @see https://datatracker.ietf.org/doc/html/rfc6750#section-3.1
|
|
38
|
-
* @see https://scayle.dev/en/api-guides/
|
|
38
|
+
* @see https://scayle.dev/en/api-guides/authentication-api/getting-started/errors#unauthorized-client
|
|
39
39
|
*/
|
|
40
40
|
export interface UnauthorizedError extends BaseError {
|
|
41
41
|
error: 'INVALID_CLIENT';
|
|
@@ -45,7 +45,7 @@ export interface UnauthorizedError extends BaseError {
|
|
|
45
45
|
/**
|
|
46
46
|
* Represents the request body for login.
|
|
47
47
|
*
|
|
48
|
-
* @see https://scayle.dev/en/api-guides/
|
|
48
|
+
* @see https://scayle.dev/en/api-guides/authentication-api/resources/oauth-client/log-in-users
|
|
49
49
|
*/
|
|
50
50
|
export interface LoginRequest {
|
|
51
51
|
email: string;
|
|
@@ -55,7 +55,7 @@ export interface LoginRequest {
|
|
|
55
55
|
/**
|
|
56
56
|
* Represents the request body for registration.
|
|
57
57
|
*
|
|
58
|
-
* @see https://scayle.dev/en/api-guides/
|
|
58
|
+
* @see https://scayle.dev/en/api-guides/authentication-api/resources/oauth-client/create-new-user
|
|
59
59
|
*/
|
|
60
60
|
export interface RegisterRequest {
|
|
61
61
|
first_name: string;
|
|
@@ -68,7 +68,7 @@ export interface RegisterRequest {
|
|
|
68
68
|
/**
|
|
69
69
|
* Represents the request body for guest checkout.
|
|
70
70
|
*
|
|
71
|
-
* @see https://scayle.dev/en/api-guides/
|
|
71
|
+
* @see https://scayle.dev/en/api-guides/authentication-api/resources/oauth-client/log-in-users-as-guest
|
|
72
72
|
*/
|
|
73
73
|
export interface GuestRequest {
|
|
74
74
|
first_name: string;
|
|
@@ -80,7 +80,7 @@ export interface GuestRequest {
|
|
|
80
80
|
/**
|
|
81
81
|
* Represents the request body for sending a password reset email.
|
|
82
82
|
*
|
|
83
|
-
* @see https://scayle.dev/en/api-guides/
|
|
83
|
+
* @see https://scayle.dev/en/api-guides/authentication-api/resources/oauth-client/send-password-reset-email
|
|
84
84
|
*/
|
|
85
85
|
export interface SendResetPasswordEmailRequest {
|
|
86
86
|
email: string;
|
|
@@ -90,7 +90,7 @@ export interface SendResetPasswordEmailRequest {
|
|
|
90
90
|
/**
|
|
91
91
|
* Represents the request body for updating a password using a hash.
|
|
92
92
|
*
|
|
93
|
-
* @see https://scayle.dev/en/api-guides/
|
|
93
|
+
* @see https://scayle.dev/en/api-guides/authentication-api/resources/oauth-client/update-password-by-hash
|
|
94
94
|
*/
|
|
95
95
|
export interface UpdatePasswordByHashRequest {
|
|
96
96
|
password: string;
|
|
@@ -100,7 +100,7 @@ export interface UpdatePasswordByHashRequest {
|
|
|
100
100
|
/**
|
|
101
101
|
* Represents the request body for updating a password.
|
|
102
102
|
*
|
|
103
|
-
* @see https://scayle.dev/en/api-guides/
|
|
103
|
+
* @see https://scayle.dev/en/api-guides/authentication-api/resources/bearer-auth/update-customers-password
|
|
104
104
|
*/
|
|
105
105
|
export interface UpdatePasswordRequest {
|
|
106
106
|
password: string;
|
|
@@ -119,7 +119,6 @@ export interface RefreshTokenRequest {
|
|
|
119
119
|
* Represents a standard OAuth 2.0 access token response as defined in RFC 6750.
|
|
120
120
|
*
|
|
121
121
|
* @see https://datatracker.ietf.org/doc/html/rfc6750
|
|
122
|
-
* @see https://scayle.dev/en/api-guides/checkout-authentication-api/getting-started/authentication#auth-response
|
|
123
122
|
*/
|
|
124
123
|
export interface Oauth {
|
|
125
124
|
/** The type of token. A `Bearer` token indicates that anyone who possesses the token can use it to access the protected resources, without further authentication. */
|
|
@@ -142,7 +142,7 @@ export type RpcContext = {
|
|
|
142
142
|
* ```
|
|
143
143
|
*
|
|
144
144
|
* To override the default campaign key, override the getCampaignKey RPC with your own implementation
|
|
145
|
-
* @see https://scayle.dev/en/storefront-guide/
|
|
145
|
+
* @see https://scayle.dev/en/core-documentation/storefront-guide/storefront-application/technical-foundation/rpc-methods#overriding-core-rpc-methods
|
|
146
146
|
*/
|
|
147
147
|
campaignKey?: string;
|
|
148
148
|
destroySessionsForUserId: (userId: number, sessionsToKeep?: string[]) => Promise<void>;
|
|
@@ -21,7 +21,7 @@ export type VariantId = number;
|
|
|
21
21
|
* a `FieldSet` might represent "cotton" with fields like
|
|
22
22
|
* `"material name"`: `"cotton"`, `"percentage"`: `70`.
|
|
23
23
|
*
|
|
24
|
-
* @see https://scayle.dev/en/
|
|
24
|
+
* @see https://scayle.dev/en/core-documentation/the-basics/products/attribute-groups#advanced-attribute-groups
|
|
25
25
|
*/
|
|
26
26
|
export type FieldSet = Array<Array<{
|
|
27
27
|
[key: string]: string | number | null | undefined;
|
|
@@ -37,7 +37,7 @@ export type FieldSet = Array<Array<{
|
|
|
37
37
|
* - Simple: `"material: 70% cotton, 30% polyester"`
|
|
38
38
|
* - Complex: `"inner material: 100% polyester, upper material: 70% cotton, 30% polyester"`
|
|
39
39
|
*
|
|
40
|
-
* @see https://scayle.dev/en/
|
|
40
|
+
* @see https://scayle.dev/en/core-documentation/the-basics/products/attribute-groups#advanced-attribute-groups
|
|
41
41
|
*/
|
|
42
42
|
export declare type GroupSet = Array<{
|
|
43
43
|
fieldSet: FieldSet;
|
|
@@ -115,7 +115,7 @@ export type FetchProductsByCategoryParams = {
|
|
|
115
115
|
/**
|
|
116
116
|
* Whether to track search analytics event.
|
|
117
117
|
*
|
|
118
|
-
* @see https://scayle.dev/en/
|
|
118
|
+
* @see https://scayle.dev/en/core-documentation/the-basics/shops/search#search-analytics-and-tracking
|
|
119
119
|
*/
|
|
120
120
|
trackSearchAnalyticsEvent?: boolean;
|
|
121
121
|
} & ({
|
|
@@ -11,7 +11,7 @@ export type ProductFilterValues = ProductFilter['values'];
|
|
|
11
11
|
* Represents a single value of a product filter. This can be a value of an attribute filter,
|
|
12
12
|
* a boolean value indicating a filter state (e.g., sale: true/false), or a value of an identifier filter.
|
|
13
13
|
*
|
|
14
|
-
* @see https://scayle.dev/en/
|
|
14
|
+
* @see https://scayle.dev/en/core-documentation/the-basics/shops/filters#get-filter-values
|
|
15
15
|
*/
|
|
16
16
|
export type ProductFilterValue = AttributesFilterValue | {
|
|
17
17
|
/** The boolean value of the filter, e.g. for a "sale" filter. */
|
package/dist/utils/campaign.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { Campaign } from '@scayle/storefront-api';
|
|
|
4
4
|
*
|
|
5
5
|
* Determines if the current time falls within the campaign's start and end dates.
|
|
6
6
|
*
|
|
7
|
-
* @see https://scayle.dev/en/
|
|
7
|
+
* @see https://scayle.dev/en/core-documentation/checkout-guide/features/promotions/discounts-and-offers/price-campaigns
|
|
8
8
|
*
|
|
9
9
|
* @param campaign The campaign to check.
|
|
10
10
|
*
|
|
@@ -16,7 +16,7 @@ export declare const isCampaignActive: (campaign?: Campaign) => boolean;
|
|
|
16
16
|
*
|
|
17
17
|
* Compares the campaign's end date with the current time.
|
|
18
18
|
*
|
|
19
|
-
* @see https://scayle.dev/en/
|
|
19
|
+
* @see https://scayle.dev/en/core-documentation/checkout-guide/features/promotions/discounts-and-offers/price-campaigns
|
|
20
20
|
*
|
|
21
21
|
* @param campaign The campaign to check.
|
|
22
22
|
*
|
|
@@ -28,7 +28,7 @@ export declare const campaignHasNotEnded: (campaign: Campaign) => boolean;
|
|
|
28
28
|
*
|
|
29
29
|
* Uses the difference between start times to determine order.
|
|
30
30
|
*
|
|
31
|
-
* @see https://scayle.dev/en/
|
|
31
|
+
* @see https://scayle.dev/en/core-documentation/checkout-guide/features/promotions/discounts-and-offers/price-campaigns
|
|
32
32
|
*
|
|
33
33
|
* @param a The first campaign to compare.
|
|
34
34
|
* @param b The second campaign to compare.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-core",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.46.0",
|
|
4
4
|
"description": "Collection of essential utilities to work with the Storefront API",
|
|
5
5
|
"author": "SCAYLE Commerce Engine",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"repository": {
|
|
12
12
|
"url": "git+https://github.com/scayle/storefront-core.git"
|
|
13
13
|
},
|
|
14
|
-
"website": "https://scayle.dev/en/
|
|
14
|
+
"website": "https://scayle.dev/en/core-documentation/storefront-guide/storefront-application/readme/what-is-storefront",
|
|
15
15
|
"sideEffects": false,
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -48,26 +48,26 @@
|
|
|
48
48
|
"ufo": "^1.5.3",
|
|
49
49
|
"uncrypto": "^0.1.3",
|
|
50
50
|
"utility-types": "^3.11.0",
|
|
51
|
-
"@scayle/storefront-api": "18.
|
|
52
|
-
"@scayle/unstorage-scayle-kv-driver": "2.0.
|
|
51
|
+
"@scayle/storefront-api": "18.17.0",
|
|
52
|
+
"@scayle/unstorage-scayle-kv-driver": "2.0.6"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/crypto-js": "4.2.2",
|
|
56
|
-
"@types/node": "22.18.
|
|
56
|
+
"@types/node": "22.18.12",
|
|
57
57
|
"@types/webpack-env": "1.18.8",
|
|
58
58
|
"@vitest/coverage-v8": "3.2.4",
|
|
59
59
|
"dprint": "0.50.2",
|
|
60
60
|
"eslint-formatter-gitlab": "6.0.1",
|
|
61
|
-
"eslint": "9.
|
|
61
|
+
"eslint": "9.38.0",
|
|
62
62
|
"fishery": "2.3.1",
|
|
63
|
-
"publint": "0.3.
|
|
63
|
+
"publint": "0.3.15",
|
|
64
64
|
"rimraf": "6.0.1",
|
|
65
65
|
"typescript": "5.9.3",
|
|
66
66
|
"unbuild": "3.6.1",
|
|
67
67
|
"unstorage": "1.17.1",
|
|
68
68
|
"vitest": "3.2.4",
|
|
69
|
-
"@scayle/
|
|
70
|
-
"@scayle/
|
|
69
|
+
"@scayle/vitest-config-storefront": "1.0.0",
|
|
70
|
+
"@scayle/eslint-config-storefront": "4.7.10"
|
|
71
71
|
},
|
|
72
72
|
"volta": {
|
|
73
73
|
"node": "22.20.0"
|