@scayle/storefront-core 7.45.0 → 7.46.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @scayle/storefront-core
2
2
 
3
+ ## 7.46.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Revert breaking change in `handleIDPLoginCallback` signature
8
+
9
+ ## 7.46.0
10
+
11
+ ### Minor Changes
12
+
13
+ - Add new RPC method `getProductsByReferenceKeys`
14
+
3
15
  ## 7.45.0
4
16
 
5
17
  ### Minor Changes
@@ -40,11 +40,10 @@ const getExternalIdpRedirect = exports.getExternalIdpRedirect = async function g
40
40
  }));
41
41
  return Object.fromEntries(results);
42
42
  };
43
- const handleIDPLoginCallback = exports.handleIDPLoginCallback = async function handleIDPLoginCallback2({
44
- code
45
- }, context) {
43
+ const handleIDPLoginCallback = exports.handleIDPLoginCallback = async function handleIDPLoginCallback2(payload, context) {
46
44
  (0, _types.assertSession)(context);
47
45
  const OAuthClient = (0, _oauth.getOAuthClient)(context);
46
+ const code = typeof payload === "string" ? payload : payload.code;
48
47
  const {
49
48
  access_token: accessToken,
50
49
  refresh_token: refreshToken
@@ -2,7 +2,7 @@ import type { RpcContext } from '../../../types';
2
2
  export declare const getExternalIdpRedirect: (context: RpcContext) => Promise<{
3
3
  [k: string]: string;
4
4
  }>;
5
- export declare const handleIDPLoginCallback: ({ code }: {
5
+ export declare const handleIDPLoginCallback: (payload: string | {
6
6
  code: string;
7
7
  }, context: RpcContext) => Promise<{
8
8
  message: string;
@@ -36,9 +36,10 @@ export const getExternalIdpRedirect = async function getExternalIdpRedirect2(con
36
36
  );
37
37
  return Object.fromEntries(results);
38
38
  };
39
- export const handleIDPLoginCallback = async function handleIDPLoginCallback2({ code }, context) {
39
+ export const handleIDPLoginCallback = async function handleIDPLoginCallback2(payload, context) {
40
40
  assertSession(context);
41
41
  const OAuthClient = getOAuthClient(context);
42
+ const code = typeof payload === "string" ? payload : payload.code;
42
43
  const { access_token: accessToken, refresh_token: refreshToken } = await OAuthClient.generateToken(code);
43
44
  context.updateTokens({
44
45
  accessToken,
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getProductsCount = exports.getProductsByIds = exports.getProductsByCategory = exports.getProductById = exports.getFilters = exports.fetchAllFiltersForCategory = void 0;
6
+ exports.getProductsCount = exports.getProductsByReferenceKeys = exports.getProductsByIds = exports.getProductsByCategory = exports.getProductById = exports.getFilters = exports.fetchAllFiltersForCategory = void 0;
7
7
  var _helpers = require("../../helpers/index.cjs");
8
8
  var _constants = require("../../constants/index.cjs");
9
9
  var _cache = require("../../cache/index.cjs");
@@ -37,8 +37,22 @@ const getProductsByIds = exports.getProductsByIds = async function getProductsBy
37
37
  })(options.ids, {
38
38
  with: options.with ?? withParams?.product ?? _constants.MIN_WITH_PARAMS_PRODUCT,
39
39
  campaignKey,
40
- pricePromotionKey: options.pricePromotionKey,
41
- includeSellableForFree: options.includeSellableForFree
40
+ pricePromotionKey: options.pricePromotionKey
41
+ });
42
+ };
43
+ const getProductsByReferenceKeys = exports.getProductsByReferenceKeys = async function getProductsByReferenceKeys2(options, {
44
+ bapiClient,
45
+ cached,
46
+ campaignKey,
47
+ withParams
48
+ }) {
49
+ return await cached(bapiClient.products.getByReferenceKeys, {
50
+ cacheKeyPrefix: "getByReferenceKeys-products",
51
+ ttl: 5 * _cache.MINUTE
52
+ })(options.referenceKeys, {
53
+ with: options.with ?? withParams?.product ?? _constants.MIN_WITH_PARAMS_PRODUCT,
54
+ campaignKey,
55
+ pricePromotionKey: options.pricePromotionKey
42
56
  });
43
57
  };
44
58
  const getProductsByCategory = exports.getProductsByCategory = async function getProductsByCategory2({
@@ -1,7 +1,8 @@
1
1
  import type { FiltersEndpointResponseData } from '@aboutyou/backbone/endpoints/filters/filters';
2
- import { FetchFiltersParams, FetchProductParams, FetchProductsByCategoryParams, FetchProductsCountParams, FetchProductsParams, Product, RpcContext } from '../../types';
2
+ import { FetchFiltersParams, FetchProductParams, FetchProductsByCategoryParams, FetchProductsByIdsParams, FetchProductsByReferenceKeysParams, FetchProductsCountParams, Product, RpcContext } from '../../types';
3
3
  export declare const getProductById: (options: FetchProductParams, { bapiClient, cached, campaignKey, withParams }: RpcContext) => Promise<Product>;
4
- export declare const getProductsByIds: (options: FetchProductsParams, { bapiClient, cached, campaignKey, withParams }: RpcContext) => Promise<Product[]>;
4
+ export declare const getProductsByIds: (options: FetchProductsByIdsParams, { bapiClient, cached, campaignKey, withParams }: RpcContext) => Promise<Product[]>;
5
+ export declare const getProductsByReferenceKeys: (options: FetchProductsByReferenceKeysParams, { bapiClient, cached, campaignKey, withParams }: RpcContext) => Promise<Product[]>;
5
6
  export declare const getProductsByCategory: ({ category, cache, with: _with, perPage, page, where, sort, pricePromotionKey, includeSellableForFree, includeSoldOut, orFiltersOperator, }: FetchProductsByCategoryParams, context: RpcContext) => Promise<{
6
7
  products: Product[];
7
8
  pagination: import("@aboutyou/backbone/endpoints/products/productsByIds").Pagination;
@@ -21,8 +21,17 @@ export const getProductsByIds = async function getProductsByIds2(options, { bapi
21
21
  })(options.ids, {
22
22
  with: options.with ?? withParams?.product ?? MIN_WITH_PARAMS_PRODUCT,
23
23
  campaignKey,
24
- pricePromotionKey: options.pricePromotionKey,
25
- includeSellableForFree: options.includeSellableForFree
24
+ pricePromotionKey: options.pricePromotionKey
25
+ });
26
+ };
27
+ export const getProductsByReferenceKeys = async function getProductsByReferenceKeys2(options, { bapiClient, cached, campaignKey, withParams }) {
28
+ return await cached(bapiClient.products.getByReferenceKeys, {
29
+ cacheKeyPrefix: "getByReferenceKeys-products",
30
+ ttl: 5 * MINUTE
31
+ })(options.referenceKeys, {
32
+ with: options.with ?? withParams?.product ?? MIN_WITH_PARAMS_PRODUCT,
33
+ campaignKey,
34
+ pricePromotionKey: options.pricePromotionKey
26
35
  });
27
36
  };
28
37
  export const getProductsByCategory = async function getProductsByCategory2({
@@ -36,6 +36,16 @@ export interface FetchProductsParams {
36
36
  pricePromotionKey?: string;
37
37
  includeSellableForFree?: boolean;
38
38
  }
39
+ export interface FetchProductsByIdsParams {
40
+ ids: number[];
41
+ with?: ProductWith;
42
+ pricePromotionKey?: string;
43
+ }
44
+ export interface FetchProductsByReferenceKeysParams {
45
+ referenceKeys: string[];
46
+ with?: ProductWith;
47
+ pricePromotionKey?: string;
48
+ }
39
49
  export interface FetchProductsByCategoryParams {
40
50
  category: string;
41
51
  with?: ProductWith;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-core",
3
- "version": "7.45.0",
3
+ "version": "7.46.1",
4
4
  "description": "Collection of essential utilities to work with the Storefront API",
5
5
  "author": "SCAYLE Commerce Engine",
6
6
  "license": "MIT",
@@ -64,26 +64,26 @@
64
64
  "jose": "5.2.3",
65
65
  "radash": "12.1.0",
66
66
  "slugify": "1.6.6",
67
- "ufo": "1.4.0",
67
+ "ufo": "1.5.3",
68
68
  "uncrypto": "0.1.3",
69
69
  "utility-types": "3.11.0"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@scayle/eslint-config-storefront": "3.2.6",
73
73
  "@types/crypto-js": "4.2.2",
74
- "@types/node": "20.11.28",
74
+ "@types/node": "20.11.30",
75
75
  "@types/webpack-env": "1.18.4",
76
- "@vitest/coverage-v8": "1.3.1",
76
+ "@vitest/coverage-v8": "1.4.0",
77
77
  "dprint": "0.45.0",
78
78
  "eslint": "8.57.0",
79
79
  "eslint-formatter-gitlab": "5.1.0",
80
80
  "publint": "0.2.7",
81
81
  "rimraf": "5.0.5",
82
82
  "ts-node": "10.9.2",
83
- "typescript": "5.4.2",
83
+ "typescript": "5.4.3",
84
84
  "unbuild": "2.0.0",
85
- "unstorage": "1.10.1",
86
- "vitest": "1.3.1"
85
+ "unstorage": "1.10.2",
86
+ "vitest": "1.4.0"
87
87
  },
88
88
  "optionalDependencies": {
89
89
  "redis": "4"