@salesforce/commerce-sdk-react 1.3.0 → 1.4.0-dev

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.
Files changed (71) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/auth/index.d.ts +0 -2
  3. package/auth/index.js +2 -5
  4. package/hooks/ShopperBaskets/paramKeys.d.ts +9 -0
  5. package/hooks/ShopperBaskets/paramKeys.js +25 -0
  6. package/hooks/ShopperBaskets/query.js +36 -5
  7. package/hooks/ShopperBaskets/queryKeyHelpers.d.ts +0 -5
  8. package/hooks/ShopperBaskets/queryKeyHelpers.js +22 -10
  9. package/hooks/ShopperContexts/paramKeys.d.ts +5 -0
  10. package/hooks/ShopperContexts/paramKeys.js +17 -0
  11. package/hooks/ShopperContexts/query.js +13 -1
  12. package/hooks/ShopperContexts/queryKeyHelpers.d.ts +0 -5
  13. package/hooks/ShopperContexts/queryKeyHelpers.js +6 -2
  14. package/hooks/ShopperCustomers/cache.js +7 -2
  15. package/hooks/ShopperCustomers/paramKeys.d.ts +26 -0
  16. package/hooks/ShopperCustomers/paramKeys.js +44 -0
  17. package/hooks/ShopperCustomers/query.js +73 -16
  18. package/hooks/ShopperCustomers/queryKeyHelpers.d.ts +0 -6
  19. package/hooks/ShopperCustomers/queryKeyHelpers.js +58 -28
  20. package/hooks/ShopperExperience/paramKeys.d.ts +6 -0
  21. package/hooks/ShopperExperience/paramKeys.js +19 -0
  22. package/hooks/ShopperExperience/query.js +18 -2
  23. package/hooks/ShopperExperience/queryKeyHelpers.d.ts +0 -5
  24. package/hooks/ShopperExperience/queryKeyHelpers.js +10 -4
  25. package/hooks/ShopperGiftCertificates/paramKeys.d.ts +5 -0
  26. package/hooks/ShopperGiftCertificates/paramKeys.js +17 -0
  27. package/hooks/ShopperGiftCertificates/query.js +8 -1
  28. package/hooks/ShopperGiftCertificates/queryKeyHelpers.d.ts +0 -5
  29. package/hooks/ShopperGiftCertificates/queryKeyHelpers.js +6 -2
  30. package/hooks/ShopperLogin/paramKeys.d.ts +7 -0
  31. package/hooks/ShopperLogin/paramKeys.js +21 -0
  32. package/hooks/ShopperLogin/query.js +24 -3
  33. package/hooks/ShopperLogin/queryKeyHelpers.d.ts +0 -5
  34. package/hooks/ShopperLogin/queryKeyHelpers.js +14 -6
  35. package/hooks/ShopperOrders/paramKeys.d.ts +7 -0
  36. package/hooks/ShopperOrders/paramKeys.js +21 -0
  37. package/hooks/ShopperOrders/query.js +24 -3
  38. package/hooks/ShopperOrders/queryKeyHelpers.d.ts +0 -5
  39. package/hooks/ShopperOrders/queryKeyHelpers.js +14 -6
  40. package/hooks/ShopperProducts/paramKeys.d.ts +8 -0
  41. package/hooks/ShopperProducts/paramKeys.js +23 -0
  42. package/hooks/ShopperProducts/query.js +30 -4
  43. package/hooks/ShopperProducts/queryKeyHelpers.d.ts +0 -5
  44. package/hooks/ShopperProducts/queryKeyHelpers.js +18 -8
  45. package/hooks/ShopperPromotions/paramKeys.d.ts +6 -0
  46. package/hooks/ShopperPromotions/paramKeys.js +19 -0
  47. package/hooks/ShopperPromotions/query.js +18 -2
  48. package/hooks/ShopperPromotions/queryKeyHelpers.d.ts +0 -5
  49. package/hooks/ShopperPromotions/queryKeyHelpers.js +10 -4
  50. package/hooks/ShopperSearch/paramKeys.d.ts +6 -0
  51. package/hooks/ShopperSearch/paramKeys.js +18 -0
  52. package/hooks/ShopperSearch/query.js +16 -2
  53. package/hooks/ShopperSearch/queryKeyHelpers.d.ts +0 -5
  54. package/hooks/ShopperSearch/queryKeyHelpers.js +10 -4
  55. package/hooks/ShopperSeo/index.d.ts +2 -0
  56. package/hooks/ShopperSeo/index.js +16 -0
  57. package/hooks/ShopperSeo/paramKeys.d.ts +5 -0
  58. package/hooks/ShopperSeo/paramKeys.js +17 -0
  59. package/hooks/ShopperSeo/query.d.ts +20 -0
  60. package/hooks/ShopperSeo/query.js +74 -0
  61. package/hooks/ShopperSeo/queryKeyHelpers.d.ts +24 -0
  62. package/hooks/ShopperSeo/queryKeyHelpers.js +28 -0
  63. package/hooks/index.d.ts +1 -0
  64. package/hooks/index.js +12 -0
  65. package/hooks/types.d.ts +2 -1
  66. package/hooks/useLocalStorage.d.ts +0 -1
  67. package/hooks/useLocalStorage.js +30 -20
  68. package/hooks/utils.d.ts +2 -0
  69. package/hooks/utils.js +11 -2
  70. package/package.json +5 -5
  71. package/provider.js +2 -1
@@ -0,0 +1,7 @@
1
+ declare const _default: {
2
+ getUserInfo: readonly ["organizationId", "channel_id"];
3
+ getWellknownOpenidConfiguration: readonly ["organizationId"];
4
+ getJwksUri: readonly ["organizationId"];
5
+ };
6
+ export default _default;
7
+ //# sourceMappingURL=paramKeys.d.ts.map
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ /*
8
+ * Copyright (c) 2023, Salesforce, Inc.
9
+ * All rights reserved.
10
+ * SPDX-License-Identifier: BSD-3-Clause
11
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
12
+ */
13
+
14
+ const getUserInfo = ['organizationId', 'channel_id'];
15
+ const getWellknownOpenidConfiguration = ['organizationId'];
16
+ const getJwksUri = ['organizationId'];
17
+ var _default = exports.default = {
18
+ getUserInfo,
19
+ getWellknownOpenidConfiguration,
20
+ getJwksUri
21
+ };
@@ -8,9 +8,15 @@ var _useCommerceApi = _interopRequireDefault(require("../useCommerceApi"));
8
8
  var _useQuery = require("../useQuery");
9
9
  var _utils = require("../utils");
10
10
  var queryKeyHelpers = _interopRequireWildcard(require("./queryKeyHelpers"));
11
+ var _paramKeys = _interopRequireDefault(require("./paramKeys"));
11
12
  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); }
12
13
  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; }
13
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
19
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
20
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
15
21
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } /*
16
22
  * Copyright (c) 2023, Salesforce, Inc.
@@ -39,6 +45,9 @@ const useUserInfo = (apiOptions, queryOptions = {}) => {
39
45
  // Parameters can be set in `apiOptions` or `client.clientConfig`;
40
46
  // we must merge them in order to generate the correct query key.
41
47
  const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
48
+ // get param keys for the api from netOptions
49
+ const paramKeys = [..._paramKeys.default[methodName], ...(0, _utils.getCustomKeys)(netOptions.parameters)];
50
+ const parameters = (0, _utils.pick)(netOptions.parameters, paramKeys);
42
51
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
43
52
  // We don't use `netOptions` here because we manipulate the options in `useQuery`.
44
53
  const method = /*#__PURE__*/function () {
@@ -52,7 +61,9 @@ const useUserInfo = (apiOptions, queryOptions = {}) => {
52
61
 
53
62
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
54
63
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
55
- return (0, _useQuery.useQuery)(netOptions, queryOptions, {
64
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
65
+ parameters
66
+ }), queryOptions, {
56
67
  method,
57
68
  queryKey,
58
69
  requiredParameters
@@ -80,6 +91,9 @@ const useWellknownOpenidConfiguration = (apiOptions, queryOptions = {}) => {
80
91
  // Parameters can be set in `apiOptions` or `client.clientConfig`;
81
92
  // we must merge them in order to generate the correct query key.
82
93
  const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
94
+ // get param keys for the api from netOptions
95
+ const paramKeys = [..._paramKeys.default[methodName], ...(0, _utils.getCustomKeys)(netOptions.parameters)];
96
+ const parameters = (0, _utils.pick)(netOptions.parameters, paramKeys);
83
97
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
84
98
  // We don't use `netOptions` here because we manipulate the options in `useQuery`.
85
99
  const method = /*#__PURE__*/function () {
@@ -93,7 +107,9 @@ const useWellknownOpenidConfiguration = (apiOptions, queryOptions = {}) => {
93
107
 
94
108
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
95
109
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
96
- return (0, _useQuery.useQuery)(netOptions, queryOptions, {
110
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
111
+ parameters
112
+ }), queryOptions, {
97
113
  method,
98
114
  queryKey,
99
115
  requiredParameters
@@ -121,6 +137,9 @@ const useJwksUri = (apiOptions, queryOptions = {}) => {
121
137
  // Parameters can be set in `apiOptions` or `client.clientConfig`;
122
138
  // we must merge them in order to generate the correct query key.
123
139
  const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
140
+ // get param keys for the api from netOptions
141
+ const paramKeys = [..._paramKeys.default[methodName], ...(0, _utils.getCustomKeys)(netOptions.parameters)];
142
+ const parameters = (0, _utils.pick)(netOptions.parameters, paramKeys);
124
143
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
125
144
  // We don't use `netOptions` here because we manipulate the options in `useQuery`.
126
145
  const method = /*#__PURE__*/function () {
@@ -134,7 +153,9 @@ const useJwksUri = (apiOptions, queryOptions = {}) => {
134
153
 
135
154
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
136
155
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
137
- return (0, _useQuery.useQuery)(netOptions, queryOptions, {
156
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
157
+ parameters
158
+ }), queryOptions, {
138
159
  method,
139
160
  queryKey,
140
161
  requiredParameters
@@ -28,11 +28,6 @@ export type QueryKeys = {
28
28
  ];
29
29
  };
30
30
  type QueryKeyHelper<T extends keyof QueryKeys> = {
31
- /**
32
- * Reduces the given parameters (which may have additional, unknown properties) to an object
33
- * containing *only* the properties required for an endpoint.
34
- */
35
- parameters: (params: Params<T>) => Params<T>;
36
31
  /** Generates the path component of the query key for an endpoint. */
37
32
  path: (params: Params<T>) => ExcludeTail<QueryKeys[T]>;
38
33
  /** Generates the full query key for an endpoint. */
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getWellknownOpenidConfiguration = exports.getUserInfo = exports.getJwksUri = void 0;
7
7
  var _utils = require("../utils");
8
+ var _paramKeys = _interopRequireDefault(require("./paramKeys"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
10
  /*
9
11
  * Copyright (c) 2023, Salesforce, Inc.
10
12
  * All rights reserved.
@@ -18,17 +20,23 @@ var _utils = require("../utils");
18
20
  // and making those generic would add too much complexity.
19
21
 
20
22
  const getUserInfo = exports.getUserInfo = {
21
- parameters: params => (0, _utils.pick)(params, ['organizationId', 'channel_id']),
22
23
  path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/oauth2/userinfo'],
23
- queryKey: params => [...getUserInfo.path(params), getUserInfo.parameters(params)]
24
+ queryKey: params => {
25
+ const paramKeys = [..._paramKeys.default['getUserInfo'], ...(0, _utils.getCustomKeys)(params)];
26
+ return [...getUserInfo.path(params), (0, _utils.pick)(params, paramKeys)];
27
+ }
24
28
  };
25
29
  const getWellknownOpenidConfiguration = exports.getWellknownOpenidConfiguration = {
26
- parameters: params => (0, _utils.pick)(params, ['organizationId']),
27
30
  path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/oauth2/.well-known/openid-configuration'],
28
- queryKey: params => [...getWellknownOpenidConfiguration.path(params), getWellknownOpenidConfiguration.parameters(params)]
31
+ queryKey: params => {
32
+ const paramKeys = [..._paramKeys.default['getWellknownOpenidConfiguration'], ...(0, _utils.getCustomKeys)(params)];
33
+ return [...getWellknownOpenidConfiguration.path(params), (0, _utils.pick)(params, paramKeys)];
34
+ }
29
35
  };
30
36
  const getJwksUri = exports.getJwksUri = {
31
- parameters: params => (0, _utils.pick)(params, ['organizationId']),
32
37
  path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/oauth2/jwks'],
33
- queryKey: params => [...getJwksUri.path(params), getJwksUri.parameters(params)]
38
+ queryKey: params => {
39
+ const paramKeys = [..._paramKeys.default['getJwksUri'], ...(0, _utils.getCustomKeys)(params)];
40
+ return [...getJwksUri.path(params), (0, _utils.pick)(params, paramKeys)];
41
+ }
34
42
  };
@@ -0,0 +1,7 @@
1
+ declare const _default: {
2
+ getOrder: readonly ["organizationId", "orderNo", "siteId", "locale"];
3
+ getPaymentMethodsForOrder: readonly ["organizationId", "orderNo", "siteId", "locale"];
4
+ getTaxesFromOrder: readonly ["organizationId", "orderNo", "siteId"];
5
+ };
6
+ export default _default;
7
+ //# sourceMappingURL=paramKeys.d.ts.map
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ /*
8
+ * Copyright (c) 2023, Salesforce, Inc.
9
+ * All rights reserved.
10
+ * SPDX-License-Identifier: BSD-3-Clause
11
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
12
+ */
13
+
14
+ const getOrder = ['organizationId', 'orderNo', 'siteId', 'locale'];
15
+ const getPaymentMethodsForOrder = ['organizationId', 'orderNo', 'siteId', 'locale'];
16
+ const getTaxesFromOrder = ['organizationId', 'orderNo', 'siteId'];
17
+ var _default = exports.default = {
18
+ getOrder,
19
+ getPaymentMethodsForOrder,
20
+ getTaxesFromOrder
21
+ };
@@ -8,9 +8,15 @@ var _useCommerceApi = _interopRequireDefault(require("../useCommerceApi"));
8
8
  var _useQuery = require("../useQuery");
9
9
  var _utils = require("../utils");
10
10
  var queryKeyHelpers = _interopRequireWildcard(require("./queryKeyHelpers"));
11
+ var _paramKeys = _interopRequireDefault(require("./paramKeys"));
11
12
  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); }
12
13
  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; }
13
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
19
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
20
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
15
21
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } /*
16
22
  * Copyright (c) 2023, Salesforce, Inc.
@@ -39,6 +45,9 @@ const useOrder = (apiOptions, queryOptions = {}) => {
39
45
  // Parameters can be set in `apiOptions` or `client.clientConfig`;
40
46
  // we must merge them in order to generate the correct query key.
41
47
  const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
48
+ // get param keys for the api from netOptions
49
+ const paramKeys = [..._paramKeys.default[methodName], ...(0, _utils.getCustomKeys)(netOptions.parameters)];
50
+ const parameters = (0, _utils.pick)(netOptions.parameters, paramKeys);
42
51
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
43
52
  // We don't use `netOptions` here because we manipulate the options in `useQuery`.
44
53
  const method = /*#__PURE__*/function () {
@@ -52,7 +61,9 @@ const useOrder = (apiOptions, queryOptions = {}) => {
52
61
 
53
62
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
54
63
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
55
- return (0, _useQuery.useQuery)(netOptions, queryOptions, {
64
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
65
+ parameters
66
+ }), queryOptions, {
56
67
  method,
57
68
  queryKey,
58
69
  requiredParameters
@@ -80,6 +91,9 @@ const usePaymentMethodsForOrder = (apiOptions, queryOptions = {}) => {
80
91
  // Parameters can be set in `apiOptions` or `client.clientConfig`;
81
92
  // we must merge them in order to generate the correct query key.
82
93
  const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
94
+ // get param keys for the api from netOptions
95
+ const paramKeys = [..._paramKeys.default[methodName], ...(0, _utils.getCustomKeys)(netOptions.parameters)];
96
+ const parameters = (0, _utils.pick)(netOptions.parameters, paramKeys);
83
97
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
84
98
  // We don't use `netOptions` here because we manipulate the options in `useQuery`.
85
99
  const method = /*#__PURE__*/function () {
@@ -93,7 +107,9 @@ const usePaymentMethodsForOrder = (apiOptions, queryOptions = {}) => {
93
107
 
94
108
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
95
109
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
96
- return (0, _useQuery.useQuery)(netOptions, queryOptions, {
110
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
111
+ parameters
112
+ }), queryOptions, {
97
113
  method,
98
114
  queryKey,
99
115
  requiredParameters
@@ -123,6 +139,9 @@ const useTaxesFromOrder = (apiOptions, queryOptions = {}) => {
123
139
  // Parameters can be set in `apiOptions` or `client.clientConfig`;
124
140
  // we must merge them in order to generate the correct query key.
125
141
  const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
142
+ // get param keys for the api from netOptions
143
+ const paramKeys = [..._paramKeys.default[methodName], ...(0, _utils.getCustomKeys)(netOptions.parameters)];
144
+ const parameters = (0, _utils.pick)(netOptions.parameters, paramKeys);
126
145
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
127
146
  // We don't use `netOptions` here because we manipulate the options in `useQuery`.
128
147
  const method = /*#__PURE__*/function () {
@@ -136,7 +155,9 @@ const useTaxesFromOrder = (apiOptions, queryOptions = {}) => {
136
155
 
137
156
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
138
157
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
139
- return (0, _useQuery.useQuery)(netOptions, queryOptions, {
158
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
159
+ parameters
160
+ }), queryOptions, {
140
161
  method,
141
162
  queryKey,
142
163
  requiredParameters
@@ -33,11 +33,6 @@ export type QueryKeys = {
33
33
  ];
34
34
  };
35
35
  type QueryKeyHelper<T extends keyof QueryKeys> = {
36
- /**
37
- * Reduces the given parameters (which may have additional, unknown properties) to an object
38
- * containing *only* the properties required for an endpoint.
39
- */
40
- parameters: (params: Params<T>) => Params<T>;
41
36
  /** Generates the path component of the query key for an endpoint. */
42
37
  path: (params: Params<T>) => ExcludeTail<QueryKeys[T]>;
43
38
  /** Generates the full query key for an endpoint. */
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getTaxesFromOrder = exports.getPaymentMethodsForOrder = exports.getOrder = void 0;
7
7
  var _utils = require("../utils");
8
+ var _paramKeys = _interopRequireDefault(require("./paramKeys"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
10
  /*
9
11
  * Copyright (c) 2023, Salesforce, Inc.
10
12
  * All rights reserved.
@@ -18,17 +20,23 @@ var _utils = require("../utils");
18
20
  // and making those generic would add too much complexity.
19
21
 
20
22
  const getOrder = exports.getOrder = {
21
- parameters: params => (0, _utils.pick)(params, ['organizationId', 'orderNo', 'siteId', 'locale']),
22
23
  path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/orders/', params.orderNo],
23
- queryKey: params => [...getOrder.path(params), getOrder.parameters(params)]
24
+ queryKey: params => {
25
+ const paramKeys = [..._paramKeys.default['getOrder'], ...(0, _utils.getCustomKeys)(params)];
26
+ return [...getOrder.path(params), (0, _utils.pick)(params, paramKeys)];
27
+ }
24
28
  };
25
29
  const getPaymentMethodsForOrder = exports.getPaymentMethodsForOrder = {
26
- parameters: params => (0, _utils.pick)(params, ['organizationId', 'orderNo', 'siteId', 'locale']),
27
30
  path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/orders/', params.orderNo, '/payment-methods'],
28
- queryKey: params => [...getPaymentMethodsForOrder.path(params), getPaymentMethodsForOrder.parameters(params)]
31
+ queryKey: params => {
32
+ const paramKeys = [..._paramKeys.default['getPaymentMethodsForOrder'], ...(0, _utils.getCustomKeys)(params)];
33
+ return [...getPaymentMethodsForOrder.path(params), (0, _utils.pick)(params, paramKeys)];
34
+ }
29
35
  };
30
36
  const getTaxesFromOrder = exports.getTaxesFromOrder = {
31
- parameters: params => (0, _utils.pick)(params, ['organizationId', 'orderNo', 'siteId']),
32
37
  path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/orders/', params.orderNo, '/taxes'],
33
- queryKey: params => [...getTaxesFromOrder.path(params), getTaxesFromOrder.parameters(params)]
38
+ queryKey: params => {
39
+ const paramKeys = [..._paramKeys.default['getTaxesFromOrder'], ...(0, _utils.getCustomKeys)(params)];
40
+ return [...getTaxesFromOrder.path(params), (0, _utils.pick)(params, paramKeys)];
41
+ }
34
42
  };
@@ -0,0 +1,8 @@
1
+ declare const _default: {
2
+ getProducts: readonly ["organizationId", "ids", "inventoryIds", "select", "currency", "expand", "locale", "allImages", "perPricebook", "siteId"];
3
+ getProduct: readonly ["organizationId", "id", "inventoryIds", "currency", "expand", "locale", "allImages", "perPricebook", "siteId"];
4
+ getCategories: readonly ["organizationId", "ids", "levels", "locale", "siteId"];
5
+ getCategory: readonly ["organizationId", "id", "levels", "locale", "siteId"];
6
+ };
7
+ export default _default;
8
+ //# sourceMappingURL=paramKeys.d.ts.map
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ /*
8
+ * Copyright (c) 2023, Salesforce, Inc.
9
+ * All rights reserved.
10
+ * SPDX-License-Identifier: BSD-3-Clause
11
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
12
+ */
13
+
14
+ const getProducts = ['organizationId', 'ids', 'inventoryIds', 'select', 'currency', 'expand', 'locale', 'allImages', 'perPricebook', 'siteId'];
15
+ const getProduct = ['organizationId', 'id', 'inventoryIds', 'currency', 'expand', 'locale', 'allImages', 'perPricebook', 'siteId'];
16
+ const getCategories = ['organizationId', 'ids', 'levels', 'locale', 'siteId'];
17
+ const getCategory = ['organizationId', 'id', 'levels', 'locale', 'siteId'];
18
+ var _default = exports.default = {
19
+ getProducts,
20
+ getProduct,
21
+ getCategories,
22
+ getCategory
23
+ };
@@ -8,9 +8,15 @@ var _useCommerceApi = _interopRequireDefault(require("../useCommerceApi"));
8
8
  var _useQuery = require("../useQuery");
9
9
  var _utils = require("../utils");
10
10
  var queryKeyHelpers = _interopRequireWildcard(require("./queryKeyHelpers"));
11
+ var _paramKeys = _interopRequireDefault(require("./paramKeys"));
11
12
  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); }
12
13
  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; }
13
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
19
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
20
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
15
21
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } /*
16
22
  * Copyright (c) 2023, Salesforce, Inc.
@@ -39,6 +45,9 @@ const useProducts = (apiOptions, queryOptions = {}) => {
39
45
  // Parameters can be set in `apiOptions` or `client.clientConfig`;
40
46
  // we must merge them in order to generate the correct query key.
41
47
  const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
48
+ // get param keys for the api from netOptions
49
+ const paramKeys = [..._paramKeys.default[methodName], ...(0, _utils.getCustomKeys)(netOptions.parameters)];
50
+ const parameters = (0, _utils.pick)(netOptions.parameters, paramKeys);
42
51
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
43
52
  // We don't use `netOptions` here because we manipulate the options in `useQuery`.
44
53
  const method = /*#__PURE__*/function () {
@@ -52,7 +61,9 @@ const useProducts = (apiOptions, queryOptions = {}) => {
52
61
 
53
62
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
54
63
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
55
- return (0, _useQuery.useQuery)(netOptions, queryOptions, {
64
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
65
+ parameters
66
+ }), queryOptions, {
56
67
  method,
57
68
  queryKey,
58
69
  requiredParameters
@@ -80,6 +91,9 @@ const useProduct = (apiOptions, queryOptions = {}) => {
80
91
  // Parameters can be set in `apiOptions` or `client.clientConfig`;
81
92
  // we must merge them in order to generate the correct query key.
82
93
  const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
94
+ // get param keys for the api from netOptions
95
+ const paramKeys = [..._paramKeys.default[methodName], ...(0, _utils.getCustomKeys)(netOptions.parameters)];
96
+ const parameters = (0, _utils.pick)(netOptions.parameters, paramKeys);
83
97
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
84
98
  // We don't use `netOptions` here because we manipulate the options in `useQuery`.
85
99
  const method = /*#__PURE__*/function () {
@@ -93,7 +107,9 @@ const useProduct = (apiOptions, queryOptions = {}) => {
93
107
 
94
108
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
95
109
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
96
- return (0, _useQuery.useQuery)(netOptions, queryOptions, {
110
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
111
+ parameters
112
+ }), queryOptions, {
97
113
  method,
98
114
  queryKey,
99
115
  requiredParameters
@@ -121,6 +137,9 @@ const useCategories = (apiOptions, queryOptions = {}) => {
121
137
  // Parameters can be set in `apiOptions` or `client.clientConfig`;
122
138
  // we must merge them in order to generate the correct query key.
123
139
  const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
140
+ // get param keys for the api from netOptions
141
+ const paramKeys = [..._paramKeys.default[methodName], ...(0, _utils.getCustomKeys)(netOptions.parameters)];
142
+ const parameters = (0, _utils.pick)(netOptions.parameters, paramKeys);
124
143
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
125
144
  // We don't use `netOptions` here because we manipulate the options in `useQuery`.
126
145
  const method = /*#__PURE__*/function () {
@@ -134,7 +153,9 @@ const useCategories = (apiOptions, queryOptions = {}) => {
134
153
 
135
154
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
136
155
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
137
- return (0, _useQuery.useQuery)(netOptions, queryOptions, {
156
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
157
+ parameters
158
+ }), queryOptions, {
138
159
  method,
139
160
  queryKey,
140
161
  requiredParameters
@@ -164,6 +185,9 @@ const useCategory = (apiOptions, queryOptions = {}) => {
164
185
  // Parameters can be set in `apiOptions` or `client.clientConfig`;
165
186
  // we must merge them in order to generate the correct query key.
166
187
  const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
188
+ // get param keys for the api from netOptions
189
+ const paramKeys = [..._paramKeys.default[methodName], ...(0, _utils.getCustomKeys)(netOptions.parameters)];
190
+ const parameters = (0, _utils.pick)(netOptions.parameters, paramKeys);
167
191
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
168
192
  // We don't use `netOptions` here because we manipulate the options in `useQuery`.
169
193
  const method = /*#__PURE__*/function () {
@@ -177,7 +201,9 @@ const useCategory = (apiOptions, queryOptions = {}) => {
177
201
 
178
202
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
179
203
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
180
- return (0, _useQuery.useQuery)(netOptions, queryOptions, {
204
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
205
+ parameters
206
+ }), queryOptions, {
181
207
  method,
182
208
  queryKey,
183
209
  requiredParameters
@@ -37,11 +37,6 @@ export type QueryKeys = {
37
37
  ];
38
38
  };
39
39
  type QueryKeyHelper<T extends keyof QueryKeys> = {
40
- /**
41
- * Reduces the given parameters (which may have additional, unknown properties) to an object
42
- * containing *only* the properties required for an endpoint.
43
- */
44
- parameters: (params: Params<T>) => Params<T>;
45
40
  /** Generates the path component of the query key for an endpoint. */
46
41
  path: (params: Params<T>) => ExcludeTail<QueryKeys[T]>;
47
42
  /** Generates the full query key for an endpoint. */
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getProducts = exports.getProduct = exports.getCategory = exports.getCategories = void 0;
7
7
  var _utils = require("../utils");
8
+ var _paramKeys = _interopRequireDefault(require("./paramKeys"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
10
  /*
9
11
  * Copyright (c) 2023, Salesforce, Inc.
10
12
  * All rights reserved.
@@ -18,22 +20,30 @@ var _utils = require("../utils");
18
20
  // and making those generic would add too much complexity.
19
21
 
20
22
  const getProducts = exports.getProducts = {
21
- parameters: params => (0, _utils.pick)(params, ['organizationId', 'ids', 'inventoryIds', 'currency', 'expand', 'locale', 'allImages', 'perPricebook', 'siteId']),
22
23
  path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/products'],
23
- queryKey: params => [...getProducts.path(params), getProducts.parameters(params)]
24
+ queryKey: params => {
25
+ const paramKeys = [..._paramKeys.default['getProducts'], ...(0, _utils.getCustomKeys)(params)];
26
+ return [...getProducts.path(params), (0, _utils.pick)(params, paramKeys)];
27
+ }
24
28
  };
25
29
  const getProduct = exports.getProduct = {
26
- parameters: params => (0, _utils.pick)(params, ['organizationId', 'id', 'inventoryIds', 'currency', 'expand', 'locale', 'allImages', 'perPricebook', 'siteId']),
27
30
  path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/products/', params.id],
28
- queryKey: params => [...getProduct.path(params), getProduct.parameters(params)]
31
+ queryKey: params => {
32
+ const paramKeys = [..._paramKeys.default['getProduct'], ...(0, _utils.getCustomKeys)(params)];
33
+ return [...getProduct.path(params), (0, _utils.pick)(params, paramKeys)];
34
+ }
29
35
  };
30
36
  const getCategories = exports.getCategories = {
31
- parameters: params => (0, _utils.pick)(params, ['organizationId', 'ids', 'levels', 'locale', 'siteId']),
32
37
  path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/categories'],
33
- queryKey: params => [...getCategories.path(params), getCategories.parameters(params)]
38
+ queryKey: params => {
39
+ const paramKeys = [..._paramKeys.default['getCategories'], ...(0, _utils.getCustomKeys)(params)];
40
+ return [...getCategories.path(params), (0, _utils.pick)(params, paramKeys)];
41
+ }
34
42
  };
35
43
  const getCategory = exports.getCategory = {
36
- parameters: params => (0, _utils.pick)(params, ['organizationId', 'id', 'levels', 'locale', 'siteId']),
37
44
  path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/categories/', params.id],
38
- queryKey: params => [...getCategory.path(params), getCategory.parameters(params)]
45
+ queryKey: params => {
46
+ const paramKeys = [..._paramKeys.default['getCategory'], ...(0, _utils.getCustomKeys)(params)];
47
+ return [...getCategory.path(params), (0, _utils.pick)(params, paramKeys)];
48
+ }
39
49
  };
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ getPromotionsForCampaign: readonly ["organizationId", "campaignId", "siteId", "startDate", "endDate", "currency"];
3
+ getPromotions: readonly ["organizationId", "siteId", "ids", "locale"];
4
+ };
5
+ export default _default;
6
+ //# sourceMappingURL=paramKeys.d.ts.map
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ /*
8
+ * Copyright (c) 2023, Salesforce, Inc.
9
+ * All rights reserved.
10
+ * SPDX-License-Identifier: BSD-3-Clause
11
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
12
+ */
13
+
14
+ const getPromotionsForCampaign = ['organizationId', 'campaignId', 'siteId', 'startDate', 'endDate', 'currency'];
15
+ const getPromotions = ['organizationId', 'siteId', 'ids', 'locale'];
16
+ var _default = exports.default = {
17
+ getPromotionsForCampaign,
18
+ getPromotions
19
+ };
@@ -8,9 +8,15 @@ var _useCommerceApi = _interopRequireDefault(require("../useCommerceApi"));
8
8
  var _useQuery = require("../useQuery");
9
9
  var _utils = require("../utils");
10
10
  var queryKeyHelpers = _interopRequireWildcard(require("./queryKeyHelpers"));
11
+ var _paramKeys = _interopRequireDefault(require("./paramKeys"));
11
12
  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); }
12
13
  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; }
13
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
19
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
20
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
15
21
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } /*
16
22
  * Copyright (c) 2023, Salesforce, Inc.
@@ -39,6 +45,9 @@ const usePromotions = (apiOptions, queryOptions = {}) => {
39
45
  // Parameters can be set in `apiOptions` or `client.clientConfig`;
40
46
  // we must merge them in order to generate the correct query key.
41
47
  const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
48
+ // get param keys for the api from netOptions
49
+ const paramKeys = [..._paramKeys.default[methodName], ...(0, _utils.getCustomKeys)(netOptions.parameters)];
50
+ const parameters = (0, _utils.pick)(netOptions.parameters, paramKeys);
42
51
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
43
52
  // We don't use `netOptions` here because we manipulate the options in `useQuery`.
44
53
  const method = /*#__PURE__*/function () {
@@ -52,7 +61,9 @@ const usePromotions = (apiOptions, queryOptions = {}) => {
52
61
 
53
62
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
54
63
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
55
- return (0, _useQuery.useQuery)(netOptions, queryOptions, {
64
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
65
+ parameters
66
+ }), queryOptions, {
56
67
  method,
57
68
  queryKey,
58
69
  requiredParameters
@@ -84,6 +95,9 @@ const usePromotionsForCampaign = (apiOptions, queryOptions = {}) => {
84
95
  // Parameters can be set in `apiOptions` or `client.clientConfig`;
85
96
  // we must merge them in order to generate the correct query key.
86
97
  const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
98
+ // get param keys for the api from netOptions
99
+ const paramKeys = [..._paramKeys.default[methodName], ...(0, _utils.getCustomKeys)(netOptions.parameters)];
100
+ const parameters = (0, _utils.pick)(netOptions.parameters, paramKeys);
87
101
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
88
102
  // We don't use `netOptions` here because we manipulate the options in `useQuery`.
89
103
  const method = /*#__PURE__*/function () {
@@ -97,7 +111,9 @@ const usePromotionsForCampaign = (apiOptions, queryOptions = {}) => {
97
111
 
98
112
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
99
113
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
100
- return (0, _useQuery.useQuery)(netOptions, queryOptions, {
114
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
115
+ parameters
116
+ }), queryOptions, {
101
117
  method,
102
118
  queryKey,
103
119
  requiredParameters
@@ -22,11 +22,6 @@ export type QueryKeys = {
22
22
  ];
23
23
  };
24
24
  type QueryKeyHelper<T extends keyof QueryKeys> = {
25
- /**
26
- * Reduces the given parameters (which may have additional, unknown properties) to an object
27
- * containing *only* the properties required for an endpoint.
28
- */
29
- parameters: (params: Params<T>) => Params<T>;
30
25
  /** Generates the path component of the query key for an endpoint. */
31
26
  path: (params: Params<T>) => ExcludeTail<QueryKeys[T]>;
32
27
  /** Generates the full query key for an endpoint. */