@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
@@ -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.
@@ -77,10 +83,10 @@ const useCustomer = (apiOptions, queryOptions = {}) => {
77
83
  } = (0, _useCommerceApi.default)();
78
84
  const methodName = 'getCustomer';
79
85
  const requiredParameters = ['organizationId', 'customerId', 'siteId'];
80
-
81
- // Parameters can be set in `apiOptions` or `client.clientConfig`;
82
- // we must merge them in order to generate the correct query key.
83
86
  const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
87
+ // get param keys for the api from netOptions
88
+ const paramKeys = [..._paramKeys.default[methodName], ...(0, _utils.getCustomKeys)(netOptions.parameters)];
89
+ const parameters = (0, _utils.pick)(netOptions.parameters, paramKeys);
84
90
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
85
91
  // We don't use `netOptions` here because we manipulate the options in `useQuery`.
86
92
  const method = /*#__PURE__*/function () {
@@ -94,7 +100,9 @@ const useCustomer = (apiOptions, queryOptions = {}) => {
94
100
 
95
101
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
96
102
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
97
- return (0, _useQuery.useQuery)(netOptions, queryOptions, {
103
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
104
+ parameters
105
+ }), queryOptions, {
98
106
  method,
99
107
  queryKey,
100
108
  requiredParameters
@@ -122,6 +130,9 @@ const useCustomerAddress = (apiOptions, queryOptions = {}) => {
122
130
  // Parameters can be set in `apiOptions` or `client.clientConfig`;
123
131
  // we must merge them in order to generate the correct query key.
124
132
  const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
133
+ // get param keys for the api from netOptions
134
+ const paramKeys = [..._paramKeys.default[methodName], ...(0, _utils.getCustomKeys)(netOptions.parameters)];
135
+ const parameters = (0, _utils.pick)(netOptions.parameters, paramKeys);
125
136
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
126
137
  // We don't use `netOptions` here because we manipulate the options in `useQuery`.
127
138
  const method = /*#__PURE__*/function () {
@@ -135,7 +146,9 @@ const useCustomerAddress = (apiOptions, queryOptions = {}) => {
135
146
 
136
147
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
137
148
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
138
- return (0, _useQuery.useQuery)(netOptions, queryOptions, {
149
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
150
+ parameters
151
+ }), queryOptions, {
139
152
  method,
140
153
  queryKey,
141
154
  requiredParameters
@@ -163,6 +176,9 @@ const useCustomerBaskets = (apiOptions, queryOptions = {}) => {
163
176
  // Parameters can be set in `apiOptions` or `client.clientConfig`;
164
177
  // we must merge them in order to generate the correct query key.
165
178
  const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
179
+ // get param keys for the api from netOptions
180
+ const paramKeys = [..._paramKeys.default[methodName], ...(0, _utils.getCustomKeys)(netOptions.parameters)];
181
+ const parameters = (0, _utils.pick)(netOptions.parameters, paramKeys);
166
182
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
167
183
  // We don't use `netOptions` here because we manipulate the options in `useQuery`.
168
184
  const method = /*#__PURE__*/function () {
@@ -173,10 +189,11 @@ const useCustomerBaskets = (apiOptions, queryOptions = {}) => {
173
189
  return _ref3.apply(this, arguments);
174
190
  };
175
191
  }();
176
-
177
192
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
178
193
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
179
- return (0, _useQuery.useQuery)(netOptions, queryOptions, {
194
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
195
+ parameters
196
+ }), queryOptions, {
180
197
  method,
181
198
  queryKey,
182
199
  requiredParameters
@@ -206,8 +223,11 @@ const useCustomerOrders = (apiOptions, queryOptions = {}) => {
206
223
  // Parameters can be set in `apiOptions` or `client.clientConfig`;
207
224
  // we must merge them in order to generate the correct query key.
208
225
  const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
226
+ // get param keys for the api from netOptions
227
+ const paramKeys = [..._paramKeys.default[methodName], ...(0, _utils.getCustomKeys)(netOptions.parameters)];
228
+ const parameters = (0, _utils.pick)(netOptions.parameters, paramKeys);
209
229
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
210
- // We don't use `netOptions` here because we manipulate the options in `useQuery`.
230
+ // We don't use `netOptions` here because we manipulate the option in `useQuery`.
211
231
  const method = /*#__PURE__*/function () {
212
232
  var _ref4 = _asyncToGenerator(function* (options) {
213
233
  return yield client[methodName](options);
@@ -219,7 +239,9 @@ const useCustomerOrders = (apiOptions, queryOptions = {}) => {
219
239
 
220
240
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
221
241
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
222
- return (0, _useQuery.useQuery)(netOptions, queryOptions, {
242
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
243
+ parameters
244
+ }), queryOptions, {
223
245
  method,
224
246
  queryKey,
225
247
  requiredParameters
@@ -247,6 +269,9 @@ const useCustomerPaymentInstrument = (apiOptions, queryOptions = {}) => {
247
269
  // Parameters can be set in `apiOptions` or `client.clientConfig`;
248
270
  // we must merge them in order to generate the correct query key.
249
271
  const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
272
+ // get param keys for the api from netOptions
273
+ const paramKeys = [..._paramKeys.default[methodName], ...(0, _utils.getCustomKeys)(netOptions.parameters)];
274
+ const parameters = (0, _utils.pick)(netOptions.parameters, paramKeys);
250
275
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
251
276
  // We don't use `netOptions` here because we manipulate the options in `useQuery`.
252
277
  const method = /*#__PURE__*/function () {
@@ -260,7 +285,9 @@ const useCustomerPaymentInstrument = (apiOptions, queryOptions = {}) => {
260
285
 
261
286
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
262
287
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
263
- return (0, _useQuery.useQuery)(netOptions, queryOptions, {
288
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
289
+ parameters
290
+ }), queryOptions, {
264
291
  method,
265
292
  queryKey,
266
293
  requiredParameters
@@ -288,6 +315,9 @@ const useCustomerProductLists = (apiOptions, queryOptions = {}) => {
288
315
  // Parameters can be set in `apiOptions` or `client.clientConfig`;
289
316
  // we must merge them in order to generate the correct query key.
290
317
  const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
318
+ // get param keys for the api from netOptions
319
+ const paramKeys = [..._paramKeys.default[methodName], ...(0, _utils.getCustomKeys)(netOptions.parameters)];
320
+ const parameters = (0, _utils.pick)(netOptions.parameters, paramKeys);
291
321
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
292
322
  // We don't use `netOptions` here because we manipulate the options in `useQuery`.
293
323
  const method = /*#__PURE__*/function () {
@@ -301,7 +331,9 @@ const useCustomerProductLists = (apiOptions, queryOptions = {}) => {
301
331
 
302
332
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
303
333
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
304
- return (0, _useQuery.useQuery)(netOptions, queryOptions, {
334
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
335
+ parameters
336
+ }), queryOptions, {
305
337
  method,
306
338
  queryKey,
307
339
  requiredParameters
@@ -329,6 +361,9 @@ const useCustomerProductList = (apiOptions, queryOptions = {}) => {
329
361
  // Parameters can be set in `apiOptions` or `client.clientConfig`;
330
362
  // we must merge them in order to generate the correct query key.
331
363
  const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
364
+ // get param keys for the api from netOptions
365
+ const paramKeys = [..._paramKeys.default[methodName], ...(0, _utils.getCustomKeys)(netOptions.parameters)];
366
+ const parameters = (0, _utils.pick)(netOptions.parameters, paramKeys);
332
367
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
333
368
  // We don't use `netOptions` here because we manipulate the options in `useQuery`.
334
369
  const method = /*#__PURE__*/function () {
@@ -342,7 +377,9 @@ const useCustomerProductList = (apiOptions, queryOptions = {}) => {
342
377
 
343
378
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
344
379
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
345
- return (0, _useQuery.useQuery)(netOptions, queryOptions, {
380
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
381
+ parameters
382
+ }), queryOptions, {
346
383
  method,
347
384
  queryKey,
348
385
  requiredParameters
@@ -370,6 +407,9 @@ const useCustomerProductListItem = (apiOptions, queryOptions = {}) => {
370
407
  // Parameters can be set in `apiOptions` or `client.clientConfig`;
371
408
  // we must merge them in order to generate the correct query key.
372
409
  const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
410
+ // get param keys for the api from netOptions
411
+ const paramKeys = [..._paramKeys.default[methodName], ...(0, _utils.getCustomKeys)(netOptions.parameters)];
412
+ const parameters = (0, _utils.pick)(netOptions.parameters, paramKeys);
373
413
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
374
414
  // We don't use `netOptions` here because we manipulate the options in `useQuery`.
375
415
  const method = /*#__PURE__*/function () {
@@ -383,7 +423,9 @@ const useCustomerProductListItem = (apiOptions, queryOptions = {}) => {
383
423
 
384
424
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
385
425
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
386
- return (0, _useQuery.useQuery)(netOptions, queryOptions, {
426
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
427
+ parameters
428
+ }), queryOptions, {
387
429
  method,
388
430
  queryKey,
389
431
  requiredParameters
@@ -411,6 +453,9 @@ const usePublicProductListsBySearchTerm = (apiOptions, queryOptions = {}) => {
411
453
  // Parameters can be set in `apiOptions` or `client.clientConfig`;
412
454
  // we must merge them in order to generate the correct query key.
413
455
  const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
456
+ // get param keys for the api from netOptions
457
+ const paramKeys = [..._paramKeys.default[methodName], ...(0, _utils.getCustomKeys)(netOptions.parameters)];
458
+ const parameters = (0, _utils.pick)(netOptions.parameters, paramKeys);
414
459
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
415
460
  // We don't use `netOptions` here because we manipulate the options in `useQuery`.
416
461
  const method = /*#__PURE__*/function () {
@@ -424,7 +469,9 @@ const usePublicProductListsBySearchTerm = (apiOptions, queryOptions = {}) => {
424
469
 
425
470
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
426
471
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
427
- return (0, _useQuery.useQuery)(netOptions, queryOptions, {
472
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
473
+ parameters
474
+ }), queryOptions, {
428
475
  method,
429
476
  queryKey,
430
477
  requiredParameters
@@ -452,6 +499,9 @@ const usePublicProductList = (apiOptions, queryOptions = {}) => {
452
499
  // Parameters can be set in `apiOptions` or `client.clientConfig`;
453
500
  // we must merge them in order to generate the correct query key.
454
501
  const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
502
+ // get param keys for the api from netOptions
503
+ const paramKeys = [..._paramKeys.default[methodName], ...(0, _utils.getCustomKeys)(netOptions.parameters)];
504
+ const parameters = (0, _utils.pick)(netOptions.parameters, paramKeys);
455
505
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
456
506
  // We don't use `netOptions` here because we manipulate the options in `useQuery`.
457
507
  const method = /*#__PURE__*/function () {
@@ -465,7 +515,9 @@ const usePublicProductList = (apiOptions, queryOptions = {}) => {
465
515
 
466
516
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
467
517
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
468
- return (0, _useQuery.useQuery)(netOptions, queryOptions, {
518
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
519
+ parameters
520
+ }), queryOptions, {
469
521
  method,
470
522
  queryKey,
471
523
  requiredParameters
@@ -493,6 +545,9 @@ const useProductListItem = (apiOptions, queryOptions = {}) => {
493
545
  // Parameters can be set in `apiOptions` or `client.clientConfig`;
494
546
  // we must merge them in order to generate the correct query key.
495
547
  const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
548
+ // get param keys for the api from netOptions
549
+ const paramKeys = [..._paramKeys.default[methodName], ...(0, _utils.getCustomKeys)(netOptions.parameters)];
550
+ const parameters = (0, _utils.pick)(netOptions.parameters, paramKeys);
496
551
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
497
552
  // We don't use `netOptions` here because we manipulate the options in `useQuery`.
498
553
  const method = /*#__PURE__*/function () {
@@ -506,7 +561,9 @@ const useProductListItem = (apiOptions, queryOptions = {}) => {
506
561
 
507
562
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
508
563
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
509
- return (0, _useQuery.useQuery)(netOptions, queryOptions, {
564
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
565
+ parameters
566
+ }), queryOptions, {
510
567
  method,
511
568
  queryKey,
512
569
  requiredParameters
@@ -116,17 +116,11 @@ export type QueryKeys = {
116
116
  ];
117
117
  };
118
118
  type QueryKeyHelper<T extends keyof QueryKeys> = {
119
- /**
120
- * Reduces the given parameters (which may have additional, unknown properties) to an object
121
- * containing *only* the properties required for an endpoint.
122
- */
123
- parameters: (params: Params<T>) => Params<T>;
124
119
  /** Generates the path component of the query key for an endpoint. */
125
120
  path: (params: Params<T>) => ExcludeTail<QueryKeys[T]>;
126
121
  /** Generates the full query key for an endpoint. */
127
122
  queryKey: (params: Params<T>) => QueryKeys[T];
128
123
  };
129
- export declare const getExternalProfile: QueryKeyHelper<'getExternalProfile'>;
130
124
  export declare const getCustomer: QueryKeyHelper<'getCustomer'>;
131
125
  export declare const getCustomerAddress: QueryKeyHelper<'getCustomerAddress'>;
132
126
  export declare const getCustomerBaskets: QueryKeyHelper<'getCustomerBaskets'>;
@@ -3,8 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getPublicProductListsBySearchTerm = exports.getPublicProductList = exports.getProductListItem = exports.getExternalProfile = exports.getCustomerProductLists = exports.getCustomerProductListItem = exports.getCustomerProductList = exports.getCustomerPaymentInstrument = exports.getCustomerOrders = exports.getCustomerBaskets = exports.getCustomerAddress = exports.getCustomer = void 0;
6
+ exports.getPublicProductListsBySearchTerm = exports.getPublicProductList = exports.getProductListItem = exports.getCustomerProductLists = exports.getCustomerProductListItem = exports.getCustomerProductList = exports.getCustomerPaymentInstrument = exports.getCustomerOrders = exports.getCustomerBaskets = exports.getCustomerAddress = exports.getCustomer = 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.
@@ -17,63 +19,91 @@ var _utils = require("../utils");
17
19
  // This is defined here, rather than `types.ts`, because it relies on `Client` and `QueryKeys`,
18
20
  // and making those generic would add too much complexity.
19
21
 
20
- const getExternalProfile = exports.getExternalProfile = {
21
- parameters: params => (0, _utils.pick)(params, ['organizationId', 'externalId', 'authenticationProviderId', 'siteId']),
22
- path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/customers/external-profile'],
23
- queryKey: params => [...getExternalProfile.path(params), getExternalProfile.parameters(params)]
24
- };
22
+ // TODO: Re-implement (and update description from RAML spec) when the endpoint exits closed beta.
23
+ // export const getExternalProfile: QueryKeyHelper<'getExternalProfile'> = {
24
+ // queryKey: (params: Params<'getExternalProfile'>) => {
25
+ // const paramKeys = [
26
+ // ...paramKeysMap['getExternalProfile'],
27
+ // ...getCustomKeys(getCustomerBaskets)
28
+ // ]
29
+ // return [...getExternalProfile.path(params), pick(params, paramKeys)]
30
+ // }
31
+ // }
32
+
25
33
  const getCustomer = exports.getCustomer = {
26
- parameters: params => (0, _utils.pick)(params, ['organizationId', 'customerId', 'siteId']),
27
34
  path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/customers/', params.customerId],
28
- queryKey: params => [...getCustomer.path(params), getCustomer.parameters(params)]
35
+ queryKey: params => {
36
+ const paramKeys = [..._paramKeys.default['getCustomer'], ...(0, _utils.getCustomKeys)(params)];
37
+ return [...getCustomer.path(params), (0, _utils.pick)(params, paramKeys)];
38
+ }
29
39
  };
30
40
  const getCustomerAddress = exports.getCustomerAddress = {
31
- parameters: params => (0, _utils.pick)(params, ['organizationId', 'customerId', 'addressName', 'siteId']),
32
41
  path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/customers/', params.customerId, '/addresses/', params.addressName],
33
- queryKey: params => [...getCustomerAddress.path(params), getCustomerAddress.parameters(params)]
42
+ queryKey: params => {
43
+ const paramKeys = [..._paramKeys.default['getCustomerAddress'], ...(0, _utils.getCustomKeys)(params)];
44
+ return [...getCustomerAddress.path(params), (0, _utils.pick)(params, paramKeys)];
45
+ }
34
46
  };
35
47
  const getCustomerBaskets = exports.getCustomerBaskets = {
36
- parameters: params => (0, _utils.pick)(params, ['organizationId', 'customerId', 'siteId']),
37
48
  path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/customers/', params.customerId, '/baskets'],
38
- queryKey: params => [...getCustomerBaskets.path(params), getCustomerBaskets.parameters(params)]
49
+ queryKey: params => {
50
+ const paramKeys = [..._paramKeys.default['getCustomerBaskets'], ...(0, _utils.getCustomKeys)(params)];
51
+ return [...getCustomerBaskets.path(params), (0, _utils.pick)(params, paramKeys)];
52
+ }
39
53
  };
40
54
  const getCustomerOrders = exports.getCustomerOrders = {
41
- parameters: params => (0, _utils.pick)(params, ['organizationId', 'customerId', 'crossSites', 'from', 'until', 'status', 'siteId', 'offset', 'limit']),
42
55
  path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/customers/', params.customerId, '/orders'],
43
- queryKey: params => [...getCustomerOrders.path(params), getCustomerOrders.parameters(params)]
56
+ queryKey: params => {
57
+ const paramKeys = [..._paramKeys.default['getCustomerOrders'], ...(0, _utils.getCustomKeys)(params)];
58
+ return [...getCustomerOrders.path(params), (0, _utils.pick)(params, paramKeys)];
59
+ }
44
60
  };
45
61
  const getCustomerPaymentInstrument = exports.getCustomerPaymentInstrument = {
46
- parameters: params => (0, _utils.pick)(params, ['organizationId', 'customerId', 'paymentInstrumentId', 'siteId']),
47
62
  path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/customers/', params.customerId, '/payment-instruments/', params.paymentInstrumentId],
48
- queryKey: params => [...getCustomerPaymentInstrument.path(params), getCustomerPaymentInstrument.parameters(params)]
63
+ queryKey: params => {
64
+ const paramKeys = [..._paramKeys.default['getCustomerPaymentInstrument'], ...(0, _utils.getCustomKeys)(params)];
65
+ return [...getCustomerPaymentInstrument.path(params), (0, _utils.pick)(params, paramKeys)];
66
+ }
49
67
  };
50
68
  const getCustomerProductLists = exports.getCustomerProductLists = {
51
- parameters: params => (0, _utils.pick)(params, ['organizationId', 'customerId', 'siteId']),
52
69
  path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/customers/', params.customerId, '/product-lists'],
53
- queryKey: params => [...getCustomerProductLists.path(params), getCustomerProductLists.parameters(params)]
70
+ queryKey: params => {
71
+ const paramKeys = [..._paramKeys.default['getCustomerProductLists'], ...(0, _utils.getCustomKeys)(params)];
72
+ return [...getCustomerProductLists.path(params), (0, _utils.pick)(params, paramKeys)];
73
+ }
54
74
  };
55
75
  const getCustomerProductList = exports.getCustomerProductList = {
56
- parameters: params => (0, _utils.pick)(params, ['organizationId', 'customerId', 'listId', 'siteId']),
57
76
  path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/customers/', params.customerId, '/product-lists/', params.listId],
58
- queryKey: params => [...getCustomerProductList.path(params), getCustomerProductList.parameters(params)]
77
+ queryKey: params => {
78
+ const paramKeys = [..._paramKeys.default['getCustomerProductList'], ...(0, _utils.getCustomKeys)(params)];
79
+ return [...getCustomerProductList.path(params), (0, _utils.pick)(params, paramKeys)];
80
+ }
59
81
  };
60
82
  const getCustomerProductListItem = exports.getCustomerProductListItem = {
61
- parameters: params => (0, _utils.pick)(params, ['organizationId', 'customerId', 'listId', 'itemId', 'siteId']),
62
83
  path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/customers/', params.customerId, '/product-lists/', params.listId, '/items/', params.itemId],
63
- queryKey: params => [...getCustomerProductListItem.path(params), getCustomerProductListItem.parameters(params)]
84
+ queryKey: params => {
85
+ const paramKeys = [..._paramKeys.default['getCustomerProductListItem'], ...(0, _utils.getCustomKeys)(params)];
86
+ return [...getCustomerProductListItem.path(params), (0, _utils.pick)(params, paramKeys)];
87
+ }
64
88
  };
65
89
  const getPublicProductListsBySearchTerm = exports.getPublicProductListsBySearchTerm = {
66
- parameters: params => (0, _utils.pick)(params, ['organizationId', 'email', 'firstName', 'lastName', 'siteId']),
67
90
  path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/product-lists'],
68
- queryKey: params => [...getPublicProductListsBySearchTerm.path(params), getPublicProductListsBySearchTerm.parameters(params)]
91
+ queryKey: params => {
92
+ const paramKeys = [..._paramKeys.default['getPublicProductListsBySearchTerm'], ...(0, _utils.getCustomKeys)(params)];
93
+ return [...getPublicProductListsBySearchTerm.path(params), (0, _utils.pick)(params, paramKeys)];
94
+ }
69
95
  };
70
96
  const getPublicProductList = exports.getPublicProductList = {
71
- parameters: params => (0, _utils.pick)(params, ['organizationId', 'listId', 'siteId']),
72
97
  path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/product-lists/', params.listId],
73
- queryKey: params => [...getPublicProductList.path(params), getPublicProductList.parameters(params)]
98
+ queryKey: params => {
99
+ const paramKeys = [..._paramKeys.default['getPublicProductList'], ...(0, _utils.getCustomKeys)(params)];
100
+ return [...getPublicProductList.path(params), (0, _utils.pick)(params, paramKeys)];
101
+ }
74
102
  };
75
103
  const getProductListItem = exports.getProductListItem = {
76
- parameters: params => (0, _utils.pick)(params, ['organizationId', 'listId', 'itemId', 'siteId']),
77
104
  path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/product-lists/', params.listId, '/items/', params.itemId],
78
- queryKey: params => [...getProductListItem.path(params), getProductListItem.parameters(params)]
105
+ queryKey: params => {
106
+ const paramKeys = [..._paramKeys.default['getProductListItem'], ...(0, _utils.getCustomKeys)(params)];
107
+ return [...getProductListItem.path(params), (0, _utils.pick)(params, paramKeys)];
108
+ }
79
109
  };
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ getPages: readonly ["organizationId", "categoryId", "productId", "aspectTypeId", "aspectAttributes", "parameters", "siteId", "locale"];
3
+ getPage: readonly ["organizationId", "pageId", "aspectAttributes", "parameters", "siteId", "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 getPages = ['organizationId', 'categoryId', 'productId', 'aspectTypeId', 'aspectAttributes', 'parameters', 'siteId', 'locale'];
15
+ const getPage = ['organizationId', 'pageId', 'aspectAttributes', 'parameters', 'siteId', 'locale'];
16
+ var _default = exports.default = {
17
+ getPages,
18
+ getPage
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.
@@ -42,6 +48,9 @@ const usePages = (apiOptions, queryOptions = {}) => {
42
48
  // Parameters can be set in `apiOptions` or `client.clientConfig`;
43
49
  // we must merge them in order to generate the correct query key.
44
50
  const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
51
+ // get param keys for the api from netOptions
52
+ const paramKeys = [..._paramKeys.default[methodName], ...(0, _utils.getCustomKeys)(netOptions.parameters)];
53
+ const parameters = (0, _utils.pick)(netOptions.parameters, paramKeys);
45
54
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
46
55
  // We don't use `netOptions` here because we manipulate the options in `useQuery`.
47
56
  const method = /*#__PURE__*/function () {
@@ -55,7 +64,9 @@ const usePages = (apiOptions, queryOptions = {}) => {
55
64
 
56
65
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
57
66
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
58
- return (0, _useQuery.useQuery)(netOptions, queryOptions, {
67
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
68
+ parameters
69
+ }), queryOptions, {
59
70
  method,
60
71
  queryKey,
61
72
  requiredParameters
@@ -86,6 +97,9 @@ const usePage = (apiOptions, queryOptions = {}) => {
86
97
  // Parameters can be set in `apiOptions` or `client.clientConfig`;
87
98
  // we must merge them in order to generate the correct query key.
88
99
  const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
100
+ // get param keys for the api from netOptions
101
+ const paramKeys = [..._paramKeys.default[methodName], ...(0, _utils.getCustomKeys)(netOptions.parameters)];
102
+ const parameters = (0, _utils.pick)(netOptions.parameters, paramKeys);
89
103
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
90
104
  // We don't use `netOptions` here because we manipulate the options in `useQuery`.
91
105
  const method = /*#__PURE__*/function () {
@@ -99,7 +113,9 @@ const usePage = (apiOptions, queryOptions = {}) => {
99
113
 
100
114
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
101
115
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
102
- return (0, _useQuery.useQuery)(netOptions, queryOptions, {
116
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
117
+ parameters
118
+ }), queryOptions, {
103
119
  method,
104
120
  queryKey,
105
121
  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. */
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getPages = exports.getPage = 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,12 +20,16 @@ var _utils = require("../utils");
18
20
  // and making those generic would add too much complexity.
19
21
 
20
22
  const getPages = exports.getPages = {
21
- parameters: params => (0, _utils.pick)(params, ['organizationId', 'categoryId', 'productId', 'aspectTypeId', 'aspectAttributes', 'parameters', 'siteId', 'locale']),
22
23
  path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/pages'],
23
- queryKey: params => [...getPages.path(params), getPages.parameters(params)]
24
+ queryKey: params => {
25
+ const paramKeys = [..._paramKeys.default['getPages'], ...(0, _utils.getCustomKeys)(params)];
26
+ return [...getPages.path(params), (0, _utils.pick)(params, paramKeys)];
27
+ }
24
28
  };
25
29
  const getPage = exports.getPage = {
26
- parameters: params => (0, _utils.pick)(params, ['organizationId', 'pageId', 'aspectAttributes', 'parameters', 'siteId', 'locale']),
27
30
  path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/pages/', params.pageId],
28
- queryKey: params => [...getPage.path(params), getPage.parameters(params)]
31
+ queryKey: params => {
32
+ const paramKeys = [..._paramKeys.default['getPage'], ...(0, _utils.getCustomKeys)(params)];
33
+ return [...getPage.path(params), (0, _utils.pick)(params, paramKeys)];
34
+ }
29
35
  };
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ getGiftCertificate: readonly ["organizationId", "siteId"];
3
+ };
4
+ export default _default;
5
+ //# sourceMappingURL=paramKeys.d.ts.map
@@ -0,0 +1,17 @@
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 getGiftCertificate = ['organizationId', 'siteId'];
15
+ var _default = exports.default = {
16
+ getGiftCertificate
17
+ };
@@ -8,6 +8,7 @@ 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 }; }
@@ -44,7 +45,11 @@ const useGiftCertificate = (apiOptions, queryOptions = {}) => {
44
45
  // Parameters can be set in `apiOptions` or `client.clientConfig`;
45
46
  // we must merge them in order to generate the correct query key.
46
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);
47
51
  const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
52
+
48
53
  // We don't use `netOptions` here because we manipulate the options in `useQuery`.
49
54
  const method = /*#__PURE__*/function () {
50
55
  var _ref = _asyncToGenerator(function* (options) {
@@ -57,7 +62,9 @@ const useGiftCertificate = (apiOptions, queryOptions = {}) => {
57
62
 
58
63
  // For some reason, if we don't explicitly set these generic parameters, the inferred type for
59
64
  // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
60
- return (0, _useQuery.useQuery)(netOptions, _objectSpread({
65
+ return (0, _useQuery.useQuery)(_objectSpread(_objectSpread({}, netOptions), {}, {
66
+ parameters
67
+ }), _objectSpread({
61
68
  // !!! This is a violation of our design goal of minimal logic in the indivudal endpoint
62
69
  // endpoint hooks. This is because this method is a post method, rather than GET,
63
70
  // and its body contains secrets. Setting cacheTime to 0 avoids exposing the secrets in
@@ -14,11 +14,6 @@ export type QueryKeys = {
14
14
  ];
15
15
  };
16
16
  type QueryKeyHelper<T extends keyof QueryKeys> = {
17
- /**
18
- * Reduces the given parameters (which may have additional, unknown properties) to an object
19
- * containing *only* the properties required for an endpoint.
20
- */
21
- parameters: (params: Params<T>) => Params<T>;
22
17
  /** Generates the path component of the query key for an endpoint. */
23
18
  path: (params: Params<T>) => ExcludeTail<QueryKeys[T]>;
24
19
  /** Generates the full query key for an endpoint. */
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getGiftCertificate = 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,7 +20,9 @@ var _utils = require("../utils");
18
20
  // and making those generic would add too much complexity.
19
21
 
20
22
  const getGiftCertificate = exports.getGiftCertificate = {
21
- parameters: params => (0, _utils.pick)(params, ['organizationId', 'siteId']),
22
23
  path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/gift-certificate'],
23
- queryKey: params => [...getGiftCertificate.path(params), getGiftCertificate.parameters(params)]
24
+ queryKey: params => {
25
+ const paramKeys = [..._paramKeys.default['getGiftCertificate'], ...(0, _utils.getCustomKeys)(params)];
26
+ return [...getGiftCertificate.path(params), (0, _utils.pick)(params, paramKeys)];
27
+ }
24
28
  };