@scayle/storefront-core 8.34.1 → 8.36.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 +30 -1
- package/dist/helpers/categoryHelper.d.ts +1 -1
- package/dist/helpers/categoryHelper.mjs +1 -1
- package/dist/rpc/methods/campaign.d.ts +11 -5
- package/dist/rpc/methods/campaign.mjs +15 -6
- package/dist/rpc/methods/checkout/checkout.mjs +1 -1
- package/dist/types/sapi/filter.d.ts +2 -2
- package/dist/types/sapi/order.d.ts +3 -3
- package/dist/types/user.d.ts +0 -2
- package/package.json +4 -4
package/CHANGELOG-V7.md
CHANGED
|
@@ -43,7 +43,7 @@ This changelog contains all changes of `@scayle/storefront-core` above v6.0.0 an
|
|
|
43
43
|
|
|
44
44
|
### Minor Changes
|
|
45
45
|
|
|
46
|
-
- Set `sapiClient` in `RpcContext` as required to improve the
|
|
46
|
+
- Set `sapiClient` in `RpcContext` as required to improve the upgradability of RPC methods.
|
|
47
47
|
|
|
48
48
|
## 7.67.1
|
|
49
49
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @scayle/storefront-core
|
|
2
2
|
|
|
3
|
+
## 8.36.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Created a new RPC method `getCampaign` to retrieve the first active campaign.
|
|
8
|
+
|
|
9
|
+
More details can be found in the official SCAYLE Resource Center under [API Guides / Storefront API / Campaigns / List Campaigns](https://scayle.dev/en/api-guides/storefront-api/resources/campaigns/list-campaigns).
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
**Dependencies**
|
|
14
|
+
|
|
15
|
+
- Updated dependency to @scayle/storefront-api@18.11.0
|
|
16
|
+
|
|
17
|
+
## 8.35.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- Removed optional key `fbook` from `ShopUser` interface
|
|
22
|
+
- Renamed incorrectly formatted function `getBackurlFromBreadcrumbs` to `getBackURLFromBreadcrumbs`
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Renamed interface incorrectly named `IdenfitierFilterItemWithValues` to `IdentifierFilterItemWithValues`
|
|
27
|
+
|
|
28
|
+
**Dependencies**
|
|
29
|
+
|
|
30
|
+
- Updated dependency to @scayle/storefront-api@18.10.0
|
|
31
|
+
|
|
3
32
|
## 8.34.1
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
|
@@ -337,7 +366,7 @@ No changes in this release.
|
|
|
337
366
|
- `FilterItemWithValues`
|
|
338
367
|
- `BooleanFilterItemWithValues`
|
|
339
368
|
- `RangeFilterItemWithValues`
|
|
340
|
-
- `
|
|
369
|
+
- `IdentifierFilterItemWithValues`
|
|
341
370
|
- `AttributesFilterValue`
|
|
342
371
|
|
|
343
372
|
## 8.20.1
|
|
@@ -42,4 +42,4 @@ export declare const getBreadcrumbs: (categories: ProductCategory[] | Category,
|
|
|
42
42
|
*
|
|
43
43
|
* @returns The back URL or '/' if breadcrumbs is undefined or empty.
|
|
44
44
|
*/
|
|
45
|
-
export declare const
|
|
45
|
+
export declare const getBackURLFromBreadcrumbs: (breadcrumbs?: BreadcrumbItem[]) => string;
|
|
@@ -39,6 +39,6 @@ export const getBreadcrumbsFromPath = (path = "", shopLocale = "") => {
|
|
|
39
39
|
export const getBreadcrumbs = (categories, activeNode) => {
|
|
40
40
|
return Array.isArray(categories) ? getBreadcrumbsFromProductCategories(categories) : getBreadcrumbsFromCategory(categories, activeNode);
|
|
41
41
|
};
|
|
42
|
-
export const
|
|
42
|
+
export const getBackURLFromBreadcrumbs = (breadcrumbs) => {
|
|
43
43
|
return breadcrumbs?.[breadcrumbs?.length - 1].to ?? "/";
|
|
44
44
|
};
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
+
import type { Campaign } from '@scayle/storefront-api';
|
|
1
2
|
import type { RpcHandler } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves the active campaign.
|
|
5
|
+
*
|
|
6
|
+
* This RPC method retrieves the active campaign.
|
|
7
|
+
* It then returns the first active campaign.
|
|
8
|
+
*
|
|
9
|
+
* @param context The RPC Context
|
|
10
|
+
* @returns The current active campaign.
|
|
11
|
+
*/
|
|
12
|
+
export declare const getCampaign: RpcHandler<Campaign | undefined>;
|
|
2
13
|
/**
|
|
3
14
|
* Retrieves the active campaign key.
|
|
4
15
|
*
|
|
@@ -6,11 +17,6 @@ import type { RpcHandler } from '../../types';
|
|
|
6
17
|
* for an existing `campaignKey`. If not present, it fetches active campaigns from the SAPI
|
|
7
18
|
* `list-campaigns` endpoint using the `sapiClient`, caching the result for 5 minutes.
|
|
8
19
|
*
|
|
9
|
-
* @see https://scayle.dev/en/api-guides/storefront-api/resources/campaigns/list-campaigns
|
|
10
|
-
*
|
|
11
|
-
* This function uses the Storefront cache (`cached()`) with a `get-campaignKey` key prefix to improve performance.
|
|
12
|
-
* Cached entries are returned if found; otherwise, data is fetched and cached.
|
|
13
|
-
*
|
|
14
20
|
* @param context The RPC Context
|
|
15
21
|
* @returns The current active campaign key.
|
|
16
22
|
*/
|
|
@@ -4,10 +4,7 @@ import {
|
|
|
4
4
|
isCampaignActive
|
|
5
5
|
} from "../../utils/campaign.mjs";
|
|
6
6
|
import { defineRpcHandler } from "../../utils/index.mjs";
|
|
7
|
-
|
|
8
|
-
if (context.campaignKey) {
|
|
9
|
-
return context.campaignKey;
|
|
10
|
-
}
|
|
7
|
+
const getCampaigns = async (context) => {
|
|
11
8
|
const { cached, sapiClient } = context;
|
|
12
9
|
const { campaigns } = await cached(async () => {
|
|
13
10
|
const { entities } = await sapiClient.campaigns.get();
|
|
@@ -17,8 +14,20 @@ export const getCampaignKey = defineRpcHandler(async (context) => {
|
|
|
17
14
|
}).sort(sortCampaignsByDateAscending)
|
|
18
15
|
};
|
|
19
16
|
}, {
|
|
20
|
-
cacheKeyPrefix: "get-
|
|
17
|
+
cacheKeyPrefix: "get-campaigns",
|
|
21
18
|
ttl: 5 * 60
|
|
22
19
|
})();
|
|
23
|
-
return campaigns
|
|
20
|
+
return campaigns;
|
|
21
|
+
};
|
|
22
|
+
export const getCampaign = defineRpcHandler(async (context) => {
|
|
23
|
+
const campaigns = await getCampaigns(context);
|
|
24
|
+
return campaigns.find(isCampaignActive);
|
|
25
|
+
});
|
|
26
|
+
export const getCampaignKey = defineRpcHandler(async (context) => {
|
|
27
|
+
if (context.campaignKey) {
|
|
28
|
+
return context.campaignKey;
|
|
29
|
+
}
|
|
30
|
+
const campaigns = await getCampaigns(context);
|
|
31
|
+
const campaign = campaigns.find(isCampaignActive);
|
|
32
|
+
return campaign?.key;
|
|
24
33
|
});
|
|
@@ -37,7 +37,7 @@ export const getCheckoutToken = defineRpcHandler(async (jwtPayload = {}, context
|
|
|
37
37
|
carrier,
|
|
38
38
|
basketId: context.basketKey,
|
|
39
39
|
campaignKey
|
|
40
|
-
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.
|
|
40
|
+
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.36.0"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
|
|
41
41
|
return {
|
|
42
42
|
accessToken: refreshedAccessToken,
|
|
43
43
|
checkoutJwt
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AttributeWithBooleanValueFilter, AttributeWithValuesFilter, FiltersEndpointResponseData, ProductSearchQuery, ProductSortConfig, ProductsSearchEndpointParameters } from '@scayle/storefront-api';
|
|
2
2
|
import type { Query } from './router';
|
|
3
|
-
export type { FilterItemWithValues, BooleanFilterItemWithValues, AttributesFilterItemWithValues, RangeFilterItemWithValues,
|
|
3
|
+
export type { FilterItemWithValues, BooleanFilterItemWithValues, AttributesFilterItemWithValues, RangeFilterItemWithValues, IdentifierFilterItemWithValues, AttributesFilterValue, AttributeWithBooleanValueFilter, AttributeWithValuesFilter, AttributeKey, } from '@scayle/storefront-api';
|
|
4
4
|
/**
|
|
5
5
|
* Parameters for filtering products.
|
|
6
6
|
*/
|
|
@@ -30,7 +30,7 @@ export interface FilterParams {
|
|
|
30
30
|
*/
|
|
31
31
|
export type FetchFiltersParams = {
|
|
32
32
|
includedFilters?: Array<string>;
|
|
33
|
-
/** where clause for
|
|
33
|
+
/** where clause for pre-filtering the filters */
|
|
34
34
|
where?: {
|
|
35
35
|
/** The search term. */
|
|
36
36
|
term?: ProductSearchQuery['term'];
|
|
@@ -30,7 +30,7 @@ export type ListOfPackages = {
|
|
|
30
30
|
};
|
|
31
31
|
}[];
|
|
32
32
|
/**
|
|
33
|
-
* When an item cannot be shipped within the regular delivery
|
|
33
|
+
* When an item cannot be shipped within the regular delivery time frame,
|
|
34
34
|
* and the warehouse is already aware of this, prior to the customer placing the
|
|
35
35
|
* order (ie it is not an unintentionally delayed delivery).
|
|
36
36
|
* This is generally the case when the item is out of stock and:
|
|
@@ -104,7 +104,7 @@ export interface OrderForwardAddress {
|
|
|
104
104
|
export type OrderStatus = 'order_open' | 'payment_pending' | 'payment_reserved' | 'invoice_completed' | 'cancellation_pending' | 'cancellation_completed' | 'invoice_partially_completed';
|
|
105
105
|
export type OrderStatusCode = 'order_created' | 'order_open' | 'order_pended' | 'order_confirmed' | 'order_delegated' | 'order_shipped' | 'order_invoiced' | 'order_aborted' | 'order_cancelled' | 'order_imported' | 'order_invoice_error';
|
|
106
106
|
export type BillingStatusCode = 'billing_open' | 'billing_pending' | 'billing_payment_pending' | 'billing_completed' | 'billing_payment_cancelled' | 'billing_partially_refunded' | 'billing_refunded';
|
|
107
|
-
export type ShippingStatusCode = 'shipping_open' | '
|
|
107
|
+
export type ShippingStatusCode = 'shipping_open' | 'shipping_not_deliverable' | 'shipping_ordered' | 'shipping_delivered' | 'shipping_cancelled' | 'shipping_undeliverable' | 'shipping_returned' | 'shipping_partially_returned' | 'shipping_partially_undeliverable';
|
|
108
108
|
export interface OrderItem<Product = Record<string, unknown>, Variant = Record<string, unknown>> {
|
|
109
109
|
id?: string;
|
|
110
110
|
/**
|
|
@@ -307,7 +307,7 @@ export interface Order<Product = Record<string, unknown>, Variant = Record<strin
|
|
|
307
307
|
*/
|
|
308
308
|
withoutTax: CentAmount;
|
|
309
309
|
/**
|
|
310
|
-
* The price is calculated including taxes and all applicable reductions such as discounts for sale and campaigns (should a campaign key be
|
|
310
|
+
* The price is calculated including taxes and all applicable reductions such as discounts for sale and campaigns (should a campaign key be provided on the request).
|
|
311
311
|
*/
|
|
312
312
|
withTax: CentAmount;
|
|
313
313
|
};
|
package/dist/types/user.d.ts
CHANGED
|
@@ -166,8 +166,6 @@ export interface ShopUser {
|
|
|
166
166
|
updatedAt: string;
|
|
167
167
|
/** The user's email address. */
|
|
168
168
|
email?: string;
|
|
169
|
-
/** Whether user has a connected facebook account*/
|
|
170
|
-
fbook?: boolean;
|
|
171
169
|
/** The user's ID. */
|
|
172
170
|
id: number;
|
|
173
171
|
/** Whether the user is a guest. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-core",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.36.0",
|
|
4
4
|
"description": "Collection of essential utilities to work with the Storefront API",
|
|
5
5
|
"author": "SCAYLE Commerce Engine",
|
|
6
6
|
"license": "MIT",
|
|
@@ -56,12 +56,12 @@
|
|
|
56
56
|
"ufo": "^1.5.3",
|
|
57
57
|
"uncrypto": "^0.1.3",
|
|
58
58
|
"utility-types": "^3.11.0",
|
|
59
|
-
"@scayle/storefront-api": "18.
|
|
59
|
+
"@scayle/storefront-api": "18.11.0",
|
|
60
60
|
"@scayle/unstorage-scayle-kv-driver": "1.0.2"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/crypto-js": "4.2.2",
|
|
64
|
-
"@types/node": "22.16.
|
|
64
|
+
"@types/node": "22.16.5",
|
|
65
65
|
"@types/webpack-env": "1.18.8",
|
|
66
66
|
"@vitest/coverage-v8": "3.2.4",
|
|
67
67
|
"dprint": "0.50.1",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@scayle/eslint-config-storefront": "4.6.1"
|
|
78
78
|
},
|
|
79
79
|
"volta": {
|
|
80
|
-
"node": "22.17.
|
|
80
|
+
"node": "22.17.1"
|
|
81
81
|
},
|
|
82
82
|
"scripts": {
|
|
83
83
|
"clean": "rimraf ./dist",
|