@scayle/storefront-core 7.58.2 → 7.59.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 CHANGED
@@ -1,5 +1,22 @@
1
1
  # @scayle/storefront-core
2
2
 
3
+ ## 7.59.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Add `storefront:afterLogin` and `storefront:afterLogout` hooks to the respective RPC.
8
+
9
+ Add `callHook`, `callHookParallel` and `callHookWith` types to `RpcContext`
10
+
11
+ ## 7.58.3
12
+
13
+ ### Patch Changes
14
+
15
+ - Upgrades to the new Wishlist from @scayle/storefront-api
16
+ - `getDefaultFractionDigits` will return 2 if `maximumFractionDigits` is not defined
17
+ - Updated dependencies
18
+ - @scayle/storefront-api@17.3.0
19
+
3
20
  ## 7.58.2
4
21
 
5
22
  ### Patch Changes
@@ -2,4 +2,4 @@ import type { Attributes } from '@scayle/storefront-api';
2
2
  export declare const getFirstAttributeValue: (attributes: Attributes | undefined, attributeName: string) => import("@scayle/storefront-api").Value | undefined;
3
3
  export declare const getAttributeValue: (attributes: Attributes | undefined, attributeName: string) => string | undefined;
4
4
  export declare const getAttributeValueTuples: (attributes: Attributes | undefined, attributeName: string) => import("@scayle/storefront-api").Value[];
5
- export declare const getManyAttributeValueTuples: (attributes: Attributes | undefined, attributeNames: string[]) => (import("@scayle/storefront-api").Value | undefined)[];
5
+ export declare const getManyAttributeValueTuples: (attributes: Attributes | undefined, attributeNames: string[]) => import("@scayle/storefront-api").Value[];
@@ -8,9 +8,9 @@ export interface TransformedFilter {
8
8
  whereCondition: Record<string, any>;
9
9
  }
10
10
  export declare const transformToWhereCondition: (conditions: Record<string, any>) => {
11
- minPrice?: ProductSearchQuery['minPrice'];
12
- maxPrice?: ProductSearchQuery['maxPrice'];
13
- attributes: ProductSearchQuery['attributes'];
11
+ minPrice?: ProductSearchQuery["minPrice"];
12
+ maxPrice?: ProductSearchQuery["maxPrice"];
13
+ attributes: ProductSearchQuery["attributes"];
14
14
  };
15
15
  /**
16
16
  * Compute an array of filters that can be used to render the quick filters, for example.
@@ -68,7 +68,7 @@ export declare const transformSortToFilter: (sort: string) => {
68
68
  export declare const getGroupedFilterableValues: (keys: Array<string>, filterableValues: ProductFilter[], { sortable }?: {
69
69
  sortable: boolean;
70
70
  }) => Record<string, TransformedFilter[]>;
71
- export declare const getFilterablePriceValue: (filterableValues: Record<string, any>, key?: 'min' | 'max') => any;
71
+ export declare const getFilterablePriceValue: (filterableValues: Record<string, any>, key?: "min" | "max") => any;
72
72
  export type SerializedFilter = Record<string, string>;
73
73
  export type Filter = Record<string, string | number | (string | number | null)[]>;
74
74
  /**
@@ -1,4 +1,4 @@
1
1
  import type { ProductImageType } from '../constants/product';
2
2
  import type { Product, ProductImage } from '../index';
3
3
  export declare function isImageType(type: ProductImageType, image: ProductImage): boolean;
4
- export declare const getImageFromList: (images: Product['images'], imageType: string, imageView: string, fallback?: boolean) => ProductImage | null;
4
+ export declare const getImageFromList: (images: Product["images"], imageType: string, imageView: string, fallback?: boolean) => ProductImage | null;
@@ -8,6 +8,6 @@ const getDefaultFractionDigits = (locale, currency) => {
8
8
  return new Intl.NumberFormat(locale, {
9
9
  style: "currency",
10
10
  currency
11
- }).resolvedOptions().maximumFractionDigits;
11
+ }).resolvedOptions().maximumFractionDigits ?? 2;
12
12
  };
13
13
  exports.getDefaultFractionDigits = getDefaultFractionDigits;
@@ -2,5 +2,5 @@ export const getDefaultFractionDigits = (locale, currency) => {
2
2
  return new Intl.NumberFormat(locale, {
3
3
  style: "currency",
4
4
  currency
5
- }).resolvedOptions().maximumFractionDigits;
5
+ }).resolvedOptions().maximumFractionDigits ?? 2;
6
6
  };
@@ -1,67 +1,67 @@
1
1
  import type { Order } from '../types';
2
2
  export declare const getUniqueItemsFromOrder: (order: Order) => {
3
- id?: number | undefined;
4
- availableQuantity?: number | undefined;
5
- currency?: string | undefined;
3
+ id?: import("../types").UniqueNumericIdentifierOfTheItem;
4
+ availableQuantity?: import("../types").AvailableQuantityInTheWarehouse;
5
+ currency?: import("../types").CharacterCurrencyCode1;
6
6
  customData?: {
7
7
  [k: string]: unknown;
8
- } | undefined;
9
- deliveryForecast?: import("../types").DeliveryForecastFromWarehouse | undefined;
10
- isManuallyReturnedByCci?: boolean | undefined;
11
- itemGroup?: {
8
+ };
9
+ deliveryForecast?: import("../types").DeliveryForecastFromWarehouse;
10
+ isManuallyReturnedByCci?: import("../types").TheReturnShipmentHasBeenTriggeredByCCI;
11
+ itemGroup?: null | {
12
12
  id: string;
13
13
  isMainItem: boolean;
14
14
  isRequired: boolean;
15
- } | null | undefined;
16
- key: string;
17
- lowestPriorPrice?: {
15
+ };
16
+ key: import("../types").UniqueIdentifierOfTheItem;
17
+ lowestPriorPrice?: null | {
18
18
  relativeDifferenceToPrice: number;
19
19
  withTax: number;
20
- } | null | undefined;
20
+ };
21
21
  merchant?: {
22
- [k: string]: unknown;
23
22
  id: number;
24
- } | undefined;
25
- packageId: number;
23
+ [k: string]: unknown;
24
+ };
25
+ packageId: import("../types").PackageReference;
26
26
  price: {
27
27
  appliedReductions?: {
28
28
  amount: {
29
- absoluteWithTax: number;
29
+ absoluteWithTax: import("../types").ThisFieldRepresentsTheDiscountAmountIncludingTheTaxes1;
30
30
  relative: number;
31
31
  };
32
- category: "voucher" | "sale" | "campaign";
33
- code?: string | undefined;
34
- type: "absolute" | "relative";
35
- }[] | undefined;
36
- overrideWithoutTax?: number | undefined;
37
- overrideWithTax?: number | undefined;
32
+ category: "sale" | "campaign" | "voucher";
33
+ code?: string;
34
+ type: "relative" | "absolute";
35
+ }[];
36
+ overrideWithoutTax?: number;
37
+ overrideWithTax?: number;
38
38
  reference?: {
39
- size?: string | undefined;
40
- unit?: string | undefined;
41
- withTax?: number | undefined;
42
- } | undefined;
39
+ size?: string;
40
+ unit?: string;
41
+ withTax?: number;
42
+ };
43
43
  tax: {
44
44
  [k: string]: {
45
- amount: number;
46
- rate: number;
45
+ amount: import("../types").AbsoluteValueOfTheAppliedTax1;
46
+ rate: import("../types").RelativeValueOfTheAppliedTax;
47
47
  };
48
48
  };
49
- undiscountedWithOutTax?: number | undefined;
50
- undiscountedWithTax?: number | undefined;
51
- withoutTax: number;
52
- withTax: number;
49
+ undiscountedWithOutTax?: import("../types").UndiscountedItemPriceExcludingTaxes;
50
+ undiscountedWithTax?: import("../types").UndiscountedItemPriceIncludingTaxes;
51
+ withoutTax: import("../types").ItemPriceExcludingTaxes1;
52
+ withTax: import("../types").ItemPriceIncludingTaxes1;
53
53
  };
54
54
  product: {
55
55
  [k: string]: unknown;
56
56
  };
57
- reservationKey?: string | undefined;
57
+ reservationKey?: string;
58
58
  status: "available" | "cancelled" | "delivered" | "returned" | "unavailable";
59
59
  variant: {
60
60
  [k: string]: unknown;
61
61
  };
62
- warehouseId?: import("../types").PickingWarehouseId | undefined;
63
- warehousePackageGroupId?: import("../types").WarehousePackageReference | undefined;
64
- createdAt: string;
65
- updatedAt: string;
62
+ warehouseId?: import("../types").PickingWarehouseId;
63
+ warehousePackageGroupId?: import("../types").WarehousePackageReference;
64
+ createdAt: import("../types").TimestampOfItemCreation;
65
+ updatedAt: import("../types").TimestampOfLastItemUpdate;
66
66
  }[] | undefined;
67
67
  export declare const getItemQuantityFromOrder: (order: Order, variantId: number) => number | undefined;
@@ -11,7 +11,7 @@ var _product = require("../constants/product.cjs");
11
11
  var _attributeHelpers = require("./attributeHelpers.cjs");
12
12
  var _imageHelpers = require("./imageHelpers.cjs");
13
13
  var _arrayHelpers = require("./arrayHelpers.cjs");
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
15
  const slugify = url => {
16
16
  return (0, _slugify.default)(url ?? "", {
17
17
  lower: true,
@@ -26,7 +26,7 @@ export declare const getTotalAppliedReductions: (price: {
26
26
  relative: number;
27
27
  };
28
28
  export declare const getLowestPrice: (variants: Variant[]) => VariantPrice;
29
- export declare const getAppliedReductionsByCategory: (price: VariantPrice | BasketItemPrice, category: AppliedReduction['category']) => AppliedReduction[];
29
+ export declare const getAppliedReductionsByCategory: (price: VariantPrice | BasketItemPrice, category: AppliedReduction["category"]) => AppliedReduction[];
30
30
  export declare const getSizeFromVariant: (variant: Variant, attributeName?: string) => Value | undefined;
31
31
  export declare const getSizeFromSpecificVariant: (product: Product, variantId?: number) => Value | null | undefined;
32
32
  export declare const getVariant: (variants: Variant[], id: number) => Variant | undefined;
@@ -39,7 +39,7 @@ export declare const isVariantInStock: (variants: Variant[], size: Value, sizeAt
39
39
  export declare const getAttribute: (product: Product, key: string) => any;
40
40
  export declare const getProductPath: (product: Product) => string;
41
41
  export declare const getCategoriesByRoute: (product: Product | null, route: Route | null) => import("@scayle/storefront-api").ProductCategory[];
42
- export declare const getLatestCategory: (categories?: Product['categories']) => import("@scayle/storefront-api").ProductCategory | undefined;
42
+ export declare const getLatestCategory: (categories?: Product["categories"]) => import("@scayle/storefront-api").ProductCategory | undefined;
43
43
  export declare const getProductAndSiblingsColors: (product: Product, colorAttributeName?: string) => Value[];
44
44
  export declare const getVariantCrosssellingValues: (variants: Variant[] | undefined) => (string | number)[];
45
45
  export {};
package/dist/index.cjs CHANGED
@@ -97,4 +97,4 @@ Object.keys(_types).forEach(function (key) {
97
97
  });
98
98
  var _storefrontApi = require("@scayle/storefront-api");
99
99
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
100
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
100
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -2,24 +2,24 @@ import type { AddOrUpdateItemError } from '@scayle/storefront-api';
2
2
  import type { AddOrUpdateItemType, BasketResponseData, BasketWithOptions, Product, RpcContext, Variant } from '../../../types';
3
3
  import { ExistingItemHandling } from '../../../constants';
4
4
  export declare const addItemToBasket: ({ variantId, promotionId, quantity, displayData, customData, existingItemHandling, itemGroup, with: _with, }: AddOrUpdateItemType & {
5
- existingItemHandling?: 0 | 1 | 2 | 3 | undefined;
6
- with?: BasketWithOptions | undefined;
5
+ existingItemHandling?: ExistingItemHandling;
6
+ with?: BasketWithOptions;
7
7
  }, context: RpcContext) => Promise<BasketResponseData<Product, Variant>>;
8
8
  export declare const addItemsToBasket: (params: {
9
9
  items: AddOrUpdateItemType[];
10
10
  existingItemHandling: ExistingItemHandling;
11
- with?: BasketWithOptions | undefined;
11
+ with?: BasketWithOptions;
12
12
  }, context: RpcContext) => Promise<BasketResponseData<Product, Variant>>;
13
13
  export declare const getBasket: (options: BasketWithOptions | undefined, context: RpcContext) => Promise<BasketResponseData<Product, Variant>>;
14
14
  export declare const removeItemFromBasket: (options: {
15
15
  itemKey: string;
16
- with?: BasketWithOptions | undefined;
16
+ with?: BasketWithOptions;
17
17
  }, context: RpcContext) => Promise<BasketResponseData<Product, Variant>>;
18
18
  export declare const clearBasket: (context: RpcContext) => Promise<boolean>;
19
19
  export declare const mergeBaskets: ({ fromBasketKey, toBasketKey, with: _with }: {
20
20
  fromBasketKey: string;
21
21
  toBasketKey: string;
22
- with?: BasketWithOptions | undefined;
22
+ with?: BasketWithOptions;
23
23
  }, context: RpcContext) => Promise<{
24
24
  type: "failure";
25
25
  statusCode: number;
@@ -1,23 +1,23 @@
1
1
  import type { Category, ProductCategoryPropertyWith } from '../../types';
2
2
  export declare const getRootCategories: ({ children, includeHidden, properties }: {
3
- children?: number | undefined;
4
- includeHidden?: true | undefined;
5
- properties?: ProductCategoryPropertyWith | undefined;
3
+ children?: number;
4
+ includeHidden?: true;
5
+ properties?: ProductCategoryPropertyWith;
6
6
  }, { cached, bapiClient }: import("../../types").RpcContext) => Promise<{
7
7
  categories: Category[];
8
8
  activeNode: undefined;
9
9
  }>;
10
10
  export declare const getCategoryByPath: ({ path, children, includeHidden, properties }: {
11
11
  path: string;
12
- children?: number | undefined;
13
- includeHidden?: true | undefined;
14
- properties?: ProductCategoryPropertyWith | undefined;
12
+ children?: number;
13
+ includeHidden?: true;
14
+ properties?: ProductCategoryPropertyWith;
15
15
  }, context: import("../../types").RpcContext) => Promise<Category>;
16
16
  export declare const getCategoriesByPath: ({ path, children, includeHidden, properties }: {
17
17
  path: string;
18
- children?: number | undefined;
19
- includeHidden?: true | undefined;
20
- properties?: ProductCategoryPropertyWith | undefined;
18
+ children?: number;
19
+ includeHidden?: true;
20
+ properties?: ProductCategoryPropertyWith;
21
21
  }, context: import("../../types").RpcContext) => Promise<{
22
22
  categories: Category[];
23
23
  activeNode: undefined;
@@ -27,7 +27,7 @@ export declare const getCategoriesByPath: ({ path, children, includeHidden, prop
27
27
  }>;
28
28
  export declare const getCategoryById: ({ id, children, includeHidden, properties }: {
29
29
  id: number;
30
- children?: number | undefined;
31
- includeHidden?: true | undefined;
32
- properties?: ProductCategoryPropertyWith | undefined;
30
+ children?: number;
31
+ includeHidden?: true;
32
+ properties?: ProductCategoryPropertyWith;
33
33
  }, context: import("../../types").RpcContext) => Promise<Category>;
@@ -31,7 +31,7 @@ const getCheckoutToken = exports.getCheckoutToken = async function getCheckoutTo
31
31
  carrier,
32
32
  basketId: context.basketKey,
33
33
  campaignKey: context.campaignKey
34
- }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"7.58.1"}`).setProtectedHeader({
34
+ }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"7.58.3"}`).setProtectedHeader({
35
35
  alg: "HS256",
36
36
  typ: "JWT"
37
37
  }).sign(secret);
@@ -21,7 +21,7 @@ export const getCheckoutToken = async function getCheckoutToken2(jwtPayload = {}
21
21
  carrier,
22
22
  basketId: context.basketKey,
23
23
  campaignKey: context.campaignKey
24
- }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"7.58.1"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
24
+ }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"7.58.3"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
25
25
  return {
26
26
  accessToken: refreshedAccessToken,
27
27
  checkoutJwt
@@ -7,7 +7,7 @@ export declare const getProductsCount: ({ category, categoryId, where, includeSo
7
7
  count: number;
8
8
  }>;
9
9
  export declare const fetchAllFiltersForCategory: ({ includedFilters, category }: {
10
- includedFilters?: string[] | undefined;
10
+ includedFilters?: string[];
11
11
  category: {
12
12
  slug: string;
13
13
  id: number;
@@ -4,9 +4,9 @@ type SearchWith = TypeaheadSuggestionsEndpointRequestParameters['with'];
4
4
  /** @deprecated `searchProducts` is deprecated. Please, use `getSuggestions` or `resolve` RPC methods */
5
5
  export declare const searchProducts: ({ term, slug, with: _with, productLimit }: {
6
6
  term: string;
7
- slug?: string | undefined;
7
+ slug?: string;
8
8
  with?: SearchWith;
9
- productLimit?: number | undefined;
9
+ productLimit?: number;
10
10
  }, { cached, bapiClient, withParams }: import("../../types").RpcContext) => Promise<TypeaheadSuggestionsEndpointResponseData>;
11
11
  export declare const getSearchSuggestions: ({ term, with: _with, categoryId }: SearchV2SuggestionsEndpointParameters, { bapiClient, withParams }: import("../../types").RpcContext) => Promise<SearchV2SuggestionsEndpointResponseData>;
12
12
  export declare const resolveSearch: ({ term, with: _with, categoryId }: SearchV2ResolveEndpointParameters, { cached, bapiClient, withParams }: import("../../types").RpcContext) => Promise<import("@scayle/storefront-api").SearchEntity | null>;
@@ -35,6 +35,12 @@ async function postLogin(context, tokens) {
35
35
  } = (0, _jose.decodeJwt)(tokens.access_token);
36
36
  await Promise.all([(0, _user.mergeBaskets)(context.sessionId, await context.generateBasketKeyForUserId(customerId), _constants.DEFAULT_WITH_LISTING, context), (0, _user.mergeWishlists)(context.sessionId, await context.generateWishlistKeyForUserId(customerId), _constants.DEFAULT_WITH_LISTING, context)]);
37
37
  await context.createUserBoundSession();
38
+ await context.callHook?.("storefront:afterLogin", {
39
+ shopId: context.shopId,
40
+ user,
41
+ authenticationType: user.authentication?.type,
42
+ accessToken: tokens.access_token
43
+ }, context);
38
44
  }
39
45
  const oauthLogin = async (login, context) => {
40
46
  (0, _types.assertSession)(context);
@@ -141,10 +147,16 @@ const oauthRevokeToken = async context => {
141
147
  if (!accessToken) {
142
148
  throw new Error("No app oauth authentication credentials");
143
149
  }
150
+ const user = context.user;
144
151
  const client = (0, _oauth.getOAuthClient)(context);
145
152
  await context.destroySession();
146
153
  try {
147
154
  await client.revokeToken(context.shopId, accessToken);
155
+ await context.callHook?.("storefront:afterLogout", {
156
+ shopId: context.shopId,
157
+ user,
158
+ authenticationType: user.authentication?.type
159
+ }, context);
148
160
  return {
149
161
  result: true
150
162
  };
@@ -36,6 +36,12 @@ export async function postLogin(context, tokens) {
36
36
  )
37
37
  ]);
38
38
  await context.createUserBoundSession();
39
+ await context.callHook?.("storefront:afterLogin", {
40
+ shopId: context.shopId,
41
+ user,
42
+ authenticationType: user.authentication?.type,
43
+ accessToken: tokens.access_token
44
+ }, context);
39
45
  }
40
46
  export const oauthLogin = async (login, context) => {
41
47
  assertSession(context);
@@ -146,10 +152,16 @@ export const oauthRevokeToken = async (context) => {
146
152
  if (!accessToken) {
147
153
  throw new Error("No app oauth authentication credentials");
148
154
  }
155
+ const user = context.user;
149
156
  const client = getOAuthClient(context);
150
157
  await context.destroySession();
151
158
  try {
152
159
  await client.revokeToken(context.shopId, accessToken);
160
+ await context.callHook?.("storefront:afterLogout", {
161
+ shopId: context.shopId,
162
+ user,
163
+ authenticationType: user.authentication?.type
164
+ }, context);
153
165
  return { result: true };
154
166
  } catch (error) {
155
167
  const res = convertErrorForRpcCall(error, [
@@ -17,6 +17,6 @@ declare const refreshUser: (context: RpcContext) => Promise<{
17
17
  user: ShopUser;
18
18
  }>;
19
19
  declare const getAccessToken: ({ forceTokenRefresh }: {
20
- forceTokenRefresh?: boolean | undefined;
20
+ forceTokenRefresh?: boolean;
21
21
  }, context: RpcContext) => Promise<string | Response>;
22
22
  export { getUser, fetchUser, refreshUser, getAccessToken };
@@ -1,13 +1,13 @@
1
- import type { WishlistResponseData } from '@scayle/storefront-api';
1
+ import type { Wishlist } from '@scayle/storefront-api';
2
2
  import type { RpcContext, WishlistWithOptions } from '../../types';
3
- export declare const getWishlist: (options: WishlistWithOptions | undefined, context: RpcContext) => Promise<WishlistResponseData>;
3
+ export declare const getWishlist: (options: WishlistWithOptions | undefined, context: RpcContext) => Promise<Wishlist>;
4
4
  export declare const addItemToWishlist: (options: {
5
- variantId?: number | undefined;
6
- productId?: number | undefined;
7
- with?: WishlistWithOptions | undefined;
8
- }, context: RpcContext) => Promise<WishlistResponseData | Response>;
5
+ variantId?: number;
6
+ productId?: number;
7
+ with?: WishlistWithOptions;
8
+ }, context: RpcContext) => Promise<Wishlist | Response>;
9
9
  export declare const removeItemFromWishlist: (options: {
10
10
  itemKey: string;
11
- with?: WishlistWithOptions | undefined;
12
- }, context: RpcContext) => Promise<WishlistResponseData>;
13
- export declare const clearWishlist: (context: RpcContext) => Promise<WishlistResponseData>;
11
+ with?: WishlistWithOptions;
12
+ }, context: RpcContext) => Promise<Wishlist>;
13
+ export declare const clearWishlist: (context: RpcContext) => Promise<Wishlist>;
@@ -1,7 +1,8 @@
1
1
  import type { StorefrontAPIClient } from '@scayle/storefront-api';
2
+ import type { Hookable } from 'hookable';
2
3
  import type { Log } from '../../utils';
3
4
  import type { CachedType } from '../../cache/cached';
4
- import type { ShopUser } from '../user';
5
+ import type { AuthenticationType, ShopUser } from '../user';
5
6
  import type { BasketWithOptions, CategoryWith, ProductCategoryWith, ProductWith, SearchV2With, SearchWith, VariantWith, WishlistWithOptions } from '../';
6
7
  import type { IDPConfig, OAuthTokens } from './auth';
7
8
  export type WithParams = Partial<{
@@ -43,6 +44,21 @@ export interface ContextWithoutSession {
43
44
  updateUser: undefined;
44
45
  updateTokens: undefined;
45
46
  }
47
+ interface LoginInformation {
48
+ shopId: number;
49
+ user: ShopUser;
50
+ authenticationType?: AuthenticationType;
51
+ accessToken: string;
52
+ }
53
+ interface LogoutInformation {
54
+ shopId: number;
55
+ user: ShopUser;
56
+ authenticationType?: AuthenticationType;
57
+ }
58
+ export interface StorefrontHooks {
59
+ 'storefront:afterLogin': (loginInfo: LoginInformation, context: RpcContext) => Promise<void> | void;
60
+ 'storefront:afterLogout': (logoutInfo: LogoutInformation, context: RpcContext) => Promise<void> | void;
61
+ }
46
62
  export type RpcContext = {
47
63
  locale: string;
48
64
  checkout: {
@@ -84,6 +100,10 @@ export type RpcContext = {
84
100
  runtimeConfiguration: RuntimeConfiguration;
85
101
  idp?: IDPConfig;
86
102
  headers: Headers;
103
+ callHook?: Hookable<StorefrontHooks>['callHook'];
104
+ callHookParallel?: Hookable<StorefrontHooks>['callHookParallel'];
105
+ callHookWith?: Hookable<StorefrontHooks>['callHookWith'];
87
106
  } & AdditionalRpcContext & (ContextWithoutSession | ContextWithSession);
88
107
  export type RpcContextWithSession = RpcContext & ContextWithSession;
89
108
  export declare function assertSession(context: RpcContext): asserts context is RpcContextWithSession;
109
+ export {};
@@ -14,7 +14,7 @@ interface MemberRole {
14
14
  memberPriority: number;
15
15
  memberRoleSap: string;
16
16
  }
17
- type AuthenticationType = 'password' | string;
17
+ export type AuthenticationType = 'password' | string;
18
18
  interface UserAuthentication {
19
19
  data?: {
20
20
  accessToken?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-core",
3
- "version": "7.58.2",
3
+ "version": "7.59.0",
4
4
  "description": "Collection of essential utilities to work with the Storefront API",
5
5
  "author": "SCAYLE Commerce Engine",
6
6
  "license": "MIT",
@@ -59,9 +59,10 @@
59
59
  "test:ci": "vitest --run --passWithNoTests --coverage --reporter=default --reporter=junit"
60
60
  },
61
61
  "dependencies": {
62
- "@scayle/storefront-api": "17.2.0",
62
+ "@scayle/storefront-api": "17.3.0",
63
63
  "crypto-js": "4.2.0",
64
- "jose": "5.4.1",
64
+ "hookable": "5.5.3",
65
+ "jose": "5.6.2",
65
66
  "radash": "12.1.0",
66
67
  "slugify": "1.6.6",
67
68
  "ufo": "1.5.3",
@@ -71,16 +72,16 @@
71
72
  "devDependencies": {
72
73
  "@scayle/eslint-config-storefront": "4.2.0",
73
74
  "@types/crypto-js": "4.2.2",
74
- "@types/node": "20.14.7",
75
+ "@types/node": "20.14.9",
75
76
  "@types/webpack-env": "1.18.5",
76
77
  "@vitest/coverage-v8": "1.6.0",
77
- "dprint": "0.46.3",
78
- "eslint": "9.5.0",
78
+ "dprint": "0.47.0",
79
+ "eslint": "9.6.0",
79
80
  "eslint-formatter-gitlab": "5.1.0",
80
81
  "publint": "0.2.8",
81
82
  "rimraf": "5.0.7",
82
83
  "ts-node": "10.9.2",
83
- "typescript": "5.4.5",
84
+ "typescript": "5.5.3",
84
85
  "unbuild": "2.0.0",
85
86
  "unstorage": "1.10.2",
86
87
  "vitest": "1.6.0"