@salesforce/commerce-sdk-react 1.0.0-preview.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/.eslintrc.js +10 -0
  2. package/CHANGELOG.md +35 -0
  3. package/LICENSE +14 -0
  4. package/README.md +327 -0
  5. package/auth/index.d.ts +220 -0
  6. package/auth/index.js +472 -0
  7. package/auth/storage.d.ts +48 -0
  8. package/auth/storage.js +122 -0
  9. package/components/ShopperExperience/Component/index.d.ts +17 -0
  10. package/components/ShopperExperience/Component/index.js +49 -0
  11. package/components/ShopperExperience/Page/index.d.ts +28 -0
  12. package/components/ShopperExperience/Page/index.js +97 -0
  13. package/components/ShopperExperience/Region/index.d.ts +41 -0
  14. package/components/ShopperExperience/Region/index.js +64 -0
  15. package/components/ShopperExperience/index.d.ts +5 -0
  16. package/components/ShopperExperience/index.js +49 -0
  17. package/components/ShopperExperience/prop-types.d.ts +39 -0
  18. package/components/ShopperExperience/prop-types.js +46 -0
  19. package/components/ShopperExperience/types.d.ts +8 -0
  20. package/components/ShopperExperience/types.js +5 -0
  21. package/components/index.d.ts +2 -0
  22. package/components/index.js +16 -0
  23. package/hooks/ShopperBaskets/cache.d.ts +5 -0
  24. package/hooks/ShopperBaskets/cache.js +351 -0
  25. package/hooks/ShopperBaskets/index.d.ts +3 -0
  26. package/hooks/ShopperBaskets/index.js +27 -0
  27. package/hooks/ShopperBaskets/mutation.d.ts +381 -0
  28. package/hooks/ShopperBaskets/mutation.js +380 -0
  29. package/hooks/ShopperBaskets/query.d.ts +55 -0
  30. package/hooks/ShopperBaskets/query.js +215 -0
  31. package/hooks/ShopperBaskets/queryKeyHelpers.d.ts +72 -0
  32. package/hooks/ShopperBaskets/queryKeyHelpers.js +49 -0
  33. package/hooks/ShopperContexts/cache.d.ts +5 -0
  34. package/hooks/ShopperContexts/cache.js +45 -0
  35. package/hooks/ShopperContexts/index.d.ts +3 -0
  36. package/hooks/ShopperContexts/index.js +27 -0
  37. package/hooks/ShopperContexts/mutation.d.ts +35 -0
  38. package/hooks/ShopperContexts/mutation.js +68 -0
  39. package/hooks/ShopperContexts/query.d.ts +15 -0
  40. package/hooks/ShopperContexts/query.js +59 -0
  41. package/hooks/ShopperContexts/queryKeyHelpers.d.ts +30 -0
  42. package/hooks/ShopperContexts/queryKeyHelpers.js +25 -0
  43. package/hooks/ShopperCustomers/cache.d.ts +5 -0
  44. package/hooks/ShopperCustomers/cache.js +387 -0
  45. package/hooks/ShopperCustomers/index.d.ts +3 -0
  46. package/hooks/ShopperCustomers/index.js +27 -0
  47. package/hooks/ShopperCustomers/mutation.d.ts +163 -0
  48. package/hooks/ShopperCustomers/mutation.js +203 -0
  49. package/hooks/ShopperCustomers/query.d.ts +115 -0
  50. package/hooks/ShopperCustomers/query.js +489 -0
  51. package/hooks/ShopperCustomers/queryKeyHelpers.d.ts +142 -0
  52. package/hooks/ShopperCustomers/queryKeyHelpers.js +91 -0
  53. package/hooks/ShopperExperience/index.d.ts +2 -0
  54. package/hooks/ShopperExperience/index.js +16 -0
  55. package/hooks/ShopperExperience/query.d.ts +31 -0
  56. package/hooks/ShopperExperience/query.js +104 -0
  57. package/hooks/ShopperExperience/queryKeyHelpers.d.ts +38 -0
  58. package/hooks/ShopperExperience/queryKeyHelpers.js +31 -0
  59. package/hooks/ShopperGiftCertificates/index.d.ts +2 -0
  60. package/hooks/ShopperGiftCertificates/index.js +16 -0
  61. package/hooks/ShopperGiftCertificates/query.d.ts +15 -0
  62. package/hooks/ShopperGiftCertificates/query.js +70 -0
  63. package/hooks/ShopperGiftCertificates/queryKeyHelpers.d.ts +29 -0
  64. package/hooks/ShopperGiftCertificates/queryKeyHelpers.js +25 -0
  65. package/hooks/ShopperLogin/cache.d.ts +3 -0
  66. package/hooks/ShopperLogin/cache.js +33 -0
  67. package/hooks/ShopperLogin/index.d.ts +3 -0
  68. package/hooks/ShopperLogin/index.js +27 -0
  69. package/hooks/ShopperLogin/mutation.d.ts +119 -0
  70. package/hooks/ShopperLogin/mutation.js +138 -0
  71. package/hooks/ShopperLogin/query.d.ts +45 -0
  72. package/hooks/ShopperLogin/query.js +176 -0
  73. package/hooks/ShopperLogin/queryKeyHelpers.d.ts +53 -0
  74. package/hooks/ShopperLogin/queryKeyHelpers.js +43 -0
  75. package/hooks/ShopperOrders/cache.d.ts +5 -0
  76. package/hooks/ShopperOrders/cache.js +54 -0
  77. package/hooks/ShopperOrders/index.d.ts +3 -0
  78. package/hooks/ShopperOrders/index.js +27 -0
  79. package/hooks/ShopperOrders/mutation.d.ts +54 -0
  80. package/hooks/ShopperOrders/mutation.js +83 -0
  81. package/hooks/ShopperOrders/query.d.ts +37 -0
  82. package/hooks/ShopperOrders/query.js +139 -0
  83. package/hooks/ShopperOrders/queryKeyHelpers.d.ts +50 -0
  84. package/hooks/ShopperOrders/queryKeyHelpers.js +37 -0
  85. package/hooks/ShopperProducts/index.d.ts +2 -0
  86. package/hooks/ShopperProducts/index.js +16 -0
  87. package/hooks/ShopperProducts/query.d.ts +47 -0
  88. package/hooks/ShopperProducts/query.js +178 -0
  89. package/hooks/ShopperProducts/queryKeyHelpers.d.ts +55 -0
  90. package/hooks/ShopperProducts/queryKeyHelpers.js +43 -0
  91. package/hooks/ShopperPromotions/index.d.ts +2 -0
  92. package/hooks/ShopperPromotions/index.js +16 -0
  93. package/hooks/ShopperPromotions/query.d.ts +29 -0
  94. package/hooks/ShopperPromotions/query.js +102 -0
  95. package/hooks/ShopperPromotions/queryKeyHelpers.d.ts +38 -0
  96. package/hooks/ShopperPromotions/queryKeyHelpers.js +31 -0
  97. package/hooks/ShopperSearch/index.d.ts +2 -0
  98. package/hooks/ShopperSearch/index.js +16 -0
  99. package/hooks/ShopperSearch/query.d.ts +26 -0
  100. package/hooks/ShopperSearch/query.js +99 -0
  101. package/hooks/ShopperSearch/queryKeyHelpers.d.ts +37 -0
  102. package/hooks/ShopperSearch/queryKeyHelpers.js +31 -0
  103. package/hooks/index.d.ts +18 -0
  104. package/hooks/index.js +188 -0
  105. package/hooks/types.d.ts +128 -0
  106. package/hooks/types.js +5 -0
  107. package/hooks/useAccessToken.d.ts +11 -0
  108. package/hooks/useAccessToken.js +43 -0
  109. package/hooks/useAuthContext.d.ts +9 -0
  110. package/hooks/useAuthContext.js +30 -0
  111. package/hooks/useAuthHelper.d.ts +23 -0
  112. package/hooks/useAuthHelper.js +66 -0
  113. package/hooks/useAuthorizationHeader.d.ts +9 -0
  114. package/hooks/useAuthorizationHeader.js +45 -0
  115. package/hooks/useCommerceApi.d.ts +9 -0
  116. package/hooks/useCommerceApi.js +26 -0
  117. package/hooks/useConfig.d.ts +7 -0
  118. package/hooks/useConfig.js +24 -0
  119. package/hooks/useCustomerId.d.ts +7 -0
  120. package/hooks/useCustomerId.js +38 -0
  121. package/hooks/useCustomerType.d.ts +21 -0
  122. package/hooks/useCustomerType.js +43 -0
  123. package/hooks/useEncUserId.d.ts +9 -0
  124. package/hooks/useEncUserId.js +36 -0
  125. package/hooks/useLocalStorage.d.ts +8 -0
  126. package/hooks/useLocalStorage.js +40 -0
  127. package/hooks/useMutation.d.ts +12 -0
  128. package/hooks/useMutation.js +38 -0
  129. package/hooks/useQuery.d.ts +15 -0
  130. package/hooks/useQuery.js +57 -0
  131. package/hooks/useUsid.d.ts +7 -0
  132. package/hooks/useUsid.js +34 -0
  133. package/hooks/utils.d.ts +32 -0
  134. package/hooks/utils.js +125 -0
  135. package/index.d.ts +5 -0
  136. package/index.js +40 -0
  137. package/package.json +88 -0
  138. package/provider.d.ts +36 -0
  139. package/provider.js +124 -0
  140. package/scripts/build-and-release-docs.js +48 -0
  141. package/scripts/version.js +22 -0
  142. package/utils.d.ts +5 -0
  143. package/utils.js +18 -0
@@ -0,0 +1,489 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.usePublicProductListsBySearchTerm = exports.usePublicProductList = exports.useProductListItem = exports.useCustomerProductLists = exports.useCustomerProductListItem = exports.useCustomerProductList = exports.useCustomerPaymentInstrument = exports.useCustomerOrders = exports.useCustomerBaskets = exports.useCustomerAddress = exports.useCustomer = void 0;
7
+ var _useCommerceApi = _interopRequireDefault(require("../useCommerceApi"));
8
+ var _useQuery = require("../useQuery");
9
+ var _utils = require("../utils");
10
+ var queryKeyHelpers = _interopRequireWildcard(require("./queryKeyHelpers"));
11
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ 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
+ 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
+ * Copyright (c) 2023, Salesforce, Inc.
17
+ * All rights reserved.
18
+ * SPDX-License-Identifier: BSD-3-Clause
19
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
20
+ */
21
+ // TODO: Re-implement (and update description from RAML spec) when the endpoint exits closed beta.
22
+ // /**
23
+ // * Gets the new external profile for a customer.This endpoint is in closed beta, available to select few customers. Please get in touch with your Account Team if you'd like to participate in the beta program
24
+ // * @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
25
+ // * @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
26
+ // * @returns A TanStack Query query hook with data from the Shopper Customers `getExternalProfile` endpoint.
27
+ // * @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=getExternalProfile| Salesforce Developer Center} for more information about the API endpoint.
28
+ // * @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#getexternalprofile | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
29
+ // * @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
30
+ // */
31
+ // export const useExternalProfile = (
32
+ // apiOptions: NullableParameters<Argument<Client['getExternalProfile']>>,
33
+ // queryOptions: ApiQueryOptions<Client['getExternalProfile']> = {}
34
+ // ): UseQueryResult<DataType<Client['getExternalProfile']>> => {
35
+ // type Options = Argument<Client['getExternalProfile']>
36
+ // type Data = DataType<Client['getExternalProfile']>
37
+ // const {shopperCustomers: client} = useCommerceApi()
38
+ // const methodName = 'getExternalProfile'
39
+ // const requiredParameters = [
40
+ // 'organizationId',
41
+ // 'externalId',
42
+ // 'authenticationProviderId',
43
+ // 'siteId'
44
+ // ] as const
45
+
46
+ // // Parameters can be set in `apiOptions` or `client.clientConfig`;
47
+ // // we must merge them in order to generate the correct query key.
48
+ // const netOptions = omitNullableParameters(mergeOptions(client, apiOptions))
49
+ // const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters)
50
+ // // We don't use `netOptions` here because we manipulate the options in `useQuery`.
51
+ // const method = async (options: Options) => await client[methodName](options)
52
+
53
+ // // For some reason, if we don't explicitly set these generic parameters, the inferred type for
54
+ // // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
55
+ // return useQuery<Client, Options, Data>(netOptions, queryOptions, {
56
+ // method,
57
+ // queryKey,
58
+ // requiredParameters
59
+ // })
60
+ // }
61
+ /**
62
+ * Gets a customer with all existing addresses and payment instruments associated with the requested customer.
63
+ * @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
64
+ * @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
65
+ * @returns A TanStack Query query hook with data from the Shopper Customers `getCustomer` endpoint.
66
+ * @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=getCustomer| Salesforce Developer Center} for more information about the API endpoint.
67
+ * @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#getcustomer | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
68
+ * @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
69
+ */
70
+ const useCustomer = (apiOptions, queryOptions = {}) => {
71
+ const {
72
+ shopperCustomers: client
73
+ } = (0, _useCommerceApi.default)();
74
+ const methodName = 'getCustomer';
75
+ const requiredParameters = ['organizationId', 'customerId', 'siteId'];
76
+
77
+ // Parameters can be set in `apiOptions` or `client.clientConfig`;
78
+ // we must merge them in order to generate the correct query key.
79
+ const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
80
+ const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
81
+ // We don't use `netOptions` here because we manipulate the options in `useQuery`.
82
+ const method = /*#__PURE__*/function () {
83
+ var _ref = _asyncToGenerator(function* (options) {
84
+ return yield client[methodName](options);
85
+ });
86
+ return function method(_x) {
87
+ return _ref.apply(this, arguments);
88
+ };
89
+ }();
90
+
91
+ // For some reason, if we don't explicitly set these generic parameters, the inferred type for
92
+ // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
93
+ return (0, _useQuery.useQuery)(netOptions, queryOptions, {
94
+ method,
95
+ queryKey,
96
+ requiredParameters
97
+ });
98
+ };
99
+ /**
100
+ * Retrieves a customer's address by address name.
101
+ * @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
102
+ * @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
103
+ * @returns A TanStack Query query hook with data from the Shopper Customers `getCustomerAddress` endpoint.
104
+ * @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=getCustomerAddress| Salesforce Developer Center} for more information about the API endpoint.
105
+ * @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#getcustomeraddress | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
106
+ * @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
107
+ */
108
+ exports.useCustomer = useCustomer;
109
+ const useCustomerAddress = (apiOptions, queryOptions = {}) => {
110
+ const {
111
+ shopperCustomers: client
112
+ } = (0, _useCommerceApi.default)();
113
+ const methodName = 'getCustomerAddress';
114
+ const requiredParameters = ['organizationId', 'customerId', 'addressName', 'siteId'];
115
+
116
+ // Parameters can be set in `apiOptions` or `client.clientConfig`;
117
+ // we must merge them in order to generate the correct query key.
118
+ const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
119
+ const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
120
+ // We don't use `netOptions` here because we manipulate the options in `useQuery`.
121
+ const method = /*#__PURE__*/function () {
122
+ var _ref2 = _asyncToGenerator(function* (options) {
123
+ return yield client[methodName](options);
124
+ });
125
+ return function method(_x2) {
126
+ return _ref2.apply(this, arguments);
127
+ };
128
+ }();
129
+
130
+ // For some reason, if we don't explicitly set these generic parameters, the inferred type for
131
+ // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
132
+ return (0, _useQuery.useQuery)(netOptions, queryOptions, {
133
+ method,
134
+ queryKey,
135
+ requiredParameters
136
+ });
137
+ };
138
+ /**
139
+ * Gets the baskets of a customer.
140
+ * @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
141
+ * @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
142
+ * @returns A TanStack Query query hook with data from the Shopper Customers `getCustomerBaskets` endpoint.
143
+ * @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=getCustomerBaskets| Salesforce Developer Center} for more information about the API endpoint.
144
+ * @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#getcustomerbaskets | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
145
+ * @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
146
+ */
147
+ exports.useCustomerAddress = useCustomerAddress;
148
+ const useCustomerBaskets = (apiOptions, queryOptions = {}) => {
149
+ const {
150
+ shopperCustomers: client
151
+ } = (0, _useCommerceApi.default)();
152
+ const methodName = 'getCustomerBaskets';
153
+ const requiredParameters = ['organizationId', 'customerId', 'siteId'];
154
+
155
+ // Parameters can be set in `apiOptions` or `client.clientConfig`;
156
+ // we must merge them in order to generate the correct query key.
157
+ const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
158
+ const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
159
+ // We don't use `netOptions` here because we manipulate the options in `useQuery`.
160
+ const method = /*#__PURE__*/function () {
161
+ var _ref3 = _asyncToGenerator(function* (options) {
162
+ return yield client[methodName](options);
163
+ });
164
+ return function method(_x3) {
165
+ return _ref3.apply(this, arguments);
166
+ };
167
+ }();
168
+
169
+ // For some reason, if we don't explicitly set these generic parameters, the inferred type for
170
+ // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
171
+ return (0, _useQuery.useQuery)(netOptions, queryOptions, {
172
+ method,
173
+ queryKey,
174
+ requiredParameters
175
+ });
176
+ };
177
+ /**
178
+ * Returns a pageable list of all customer's orders. The default page size is 10.
179
+ * @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
180
+ * @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
181
+ * @returns A TanStack Query query hook with data from the Shopper Customers `getCustomerOrders` endpoint.
182
+ * @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=getCustomerOrders| Salesforce Developer Center} for more information about the API endpoint.
183
+ * @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#getcustomerorders | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
184
+ * @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
185
+ */
186
+ exports.useCustomerBaskets = useCustomerBaskets;
187
+ const useCustomerOrders = (apiOptions, queryOptions = {}) => {
188
+ const {
189
+ shopperCustomers: client
190
+ } = (0, _useCommerceApi.default)();
191
+ const methodName = 'getCustomerOrders';
192
+ const requiredParameters = ['organizationId', 'customerId', 'siteId'];
193
+
194
+ // Parameters can be set in `apiOptions` or `client.clientConfig`;
195
+ // we must merge them in order to generate the correct query key.
196
+ const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
197
+ const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
198
+ // We don't use `netOptions` here because we manipulate the options in `useQuery`.
199
+ const method = /*#__PURE__*/function () {
200
+ var _ref4 = _asyncToGenerator(function* (options) {
201
+ return yield client[methodName](options);
202
+ });
203
+ return function method(_x4) {
204
+ return _ref4.apply(this, arguments);
205
+ };
206
+ }();
207
+
208
+ // For some reason, if we don't explicitly set these generic parameters, the inferred type for
209
+ // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
210
+ return (0, _useQuery.useQuery)(netOptions, queryOptions, {
211
+ method,
212
+ queryKey,
213
+ requiredParameters
214
+ });
215
+ };
216
+ /**
217
+ * Retrieves a customer's payment instrument by its ID.
218
+ * @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
219
+ * @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
220
+ * @returns A TanStack Query query hook with data from the Shopper Customers `getCustomerPaymentInstrument` endpoint.
221
+ * @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=getCustomerPaymentInstrument| Salesforce Developer Center} for more information about the API endpoint.
222
+ * @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#getcustomerpaymentinstrument | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
223
+ * @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
224
+ */
225
+ exports.useCustomerOrders = useCustomerOrders;
226
+ const useCustomerPaymentInstrument = (apiOptions, queryOptions = {}) => {
227
+ const {
228
+ shopperCustomers: client
229
+ } = (0, _useCommerceApi.default)();
230
+ const methodName = 'getCustomerPaymentInstrument';
231
+ const requiredParameters = ['organizationId', 'customerId', 'paymentInstrumentId', 'siteId'];
232
+
233
+ // Parameters can be set in `apiOptions` or `client.clientConfig`;
234
+ // we must merge them in order to generate the correct query key.
235
+ const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
236
+ const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
237
+ // We don't use `netOptions` here because we manipulate the options in `useQuery`.
238
+ const method = /*#__PURE__*/function () {
239
+ var _ref5 = _asyncToGenerator(function* (options) {
240
+ return yield client[methodName](options);
241
+ });
242
+ return function method(_x5) {
243
+ return _ref5.apply(this, arguments);
244
+ };
245
+ }();
246
+
247
+ // For some reason, if we don't explicitly set these generic parameters, the inferred type for
248
+ // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
249
+ return (0, _useQuery.useQuery)(netOptions, queryOptions, {
250
+ method,
251
+ queryKey,
252
+ requiredParameters
253
+ });
254
+ };
255
+ /**
256
+ * Returns all customer product lists.
257
+ * @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
258
+ * @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
259
+ * @returns A TanStack Query query hook with data from the Shopper Customers `getCustomerProductLists` endpoint.
260
+ * @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=getCustomerProductLists| Salesforce Developer Center} for more information about the API endpoint.
261
+ * @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#getcustomerproductlists | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
262
+ * @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
263
+ */
264
+ exports.useCustomerPaymentInstrument = useCustomerPaymentInstrument;
265
+ const useCustomerProductLists = (apiOptions, queryOptions = {}) => {
266
+ const {
267
+ shopperCustomers: client
268
+ } = (0, _useCommerceApi.default)();
269
+ const methodName = 'getCustomerProductLists';
270
+ const requiredParameters = ['organizationId', 'customerId', 'siteId'];
271
+
272
+ // Parameters can be set in `apiOptions` or `client.clientConfig`;
273
+ // we must merge them in order to generate the correct query key.
274
+ const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
275
+ const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
276
+ // We don't use `netOptions` here because we manipulate the options in `useQuery`.
277
+ const method = /*#__PURE__*/function () {
278
+ var _ref6 = _asyncToGenerator(function* (options) {
279
+ return yield client[methodName](options);
280
+ });
281
+ return function method(_x6) {
282
+ return _ref6.apply(this, arguments);
283
+ };
284
+ }();
285
+
286
+ // For some reason, if we don't explicitly set these generic parameters, the inferred type for
287
+ // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
288
+ return (0, _useQuery.useQuery)(netOptions, queryOptions, {
289
+ method,
290
+ queryKey,
291
+ requiredParameters
292
+ });
293
+ };
294
+ /**
295
+ * Returns a customer product list of the given customer and the items in the list.
296
+ * @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
297
+ * @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
298
+ * @returns A TanStack Query query hook with data from the Shopper Customers `getCustomerProductList` endpoint.
299
+ * @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=getCustomerProductList| Salesforce Developer Center} for more information about the API endpoint.
300
+ * @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#getcustomerproductlist | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
301
+ * @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
302
+ */
303
+ exports.useCustomerProductLists = useCustomerProductLists;
304
+ const useCustomerProductList = (apiOptions, queryOptions = {}) => {
305
+ const {
306
+ shopperCustomers: client
307
+ } = (0, _useCommerceApi.default)();
308
+ const methodName = 'getCustomerProductList';
309
+ const requiredParameters = ['organizationId', 'customerId', 'listId', 'siteId'];
310
+
311
+ // Parameters can be set in `apiOptions` or `client.clientConfig`;
312
+ // we must merge them in order to generate the correct query key.
313
+ const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
314
+ const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
315
+ // We don't use `netOptions` here because we manipulate the options in `useQuery`.
316
+ const method = /*#__PURE__*/function () {
317
+ var _ref7 = _asyncToGenerator(function* (options) {
318
+ return yield client[methodName](options);
319
+ });
320
+ return function method(_x7) {
321
+ return _ref7.apply(this, arguments);
322
+ };
323
+ }();
324
+
325
+ // For some reason, if we don't explicitly set these generic parameters, the inferred type for
326
+ // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
327
+ return (0, _useQuery.useQuery)(netOptions, queryOptions, {
328
+ method,
329
+ queryKey,
330
+ requiredParameters
331
+ });
332
+ };
333
+ /**
334
+ * Returns an item of a customer product list and the actual product details like image, availability and price.
335
+ * @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
336
+ * @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
337
+ * @returns A TanStack Query query hook with data from the Shopper Customers `getCustomerProductListItem` endpoint.
338
+ * @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=getCustomerProductListItem| Salesforce Developer Center} for more information about the API endpoint.
339
+ * @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#getcustomerproductlistitem | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
340
+ * @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
341
+ */
342
+ exports.useCustomerProductList = useCustomerProductList;
343
+ const useCustomerProductListItem = (apiOptions, queryOptions = {}) => {
344
+ const {
345
+ shopperCustomers: client
346
+ } = (0, _useCommerceApi.default)();
347
+ const methodName = 'getCustomerProductListItem';
348
+ const requiredParameters = ['organizationId', 'customerId', 'listId', 'itemId', 'siteId'];
349
+
350
+ // Parameters can be set in `apiOptions` or `client.clientConfig`;
351
+ // we must merge them in order to generate the correct query key.
352
+ const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
353
+ const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
354
+ // We don't use `netOptions` here because we manipulate the options in `useQuery`.
355
+ const method = /*#__PURE__*/function () {
356
+ var _ref8 = _asyncToGenerator(function* (options) {
357
+ return yield client[methodName](options);
358
+ });
359
+ return function method(_x8) {
360
+ return _ref8.apply(this, arguments);
361
+ };
362
+ }();
363
+
364
+ // For some reason, if we don't explicitly set these generic parameters, the inferred type for
365
+ // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
366
+ return (0, _useQuery.useQuery)(netOptions, queryOptions, {
367
+ method,
368
+ queryKey,
369
+ requiredParameters
370
+ });
371
+ };
372
+ /**
373
+ * Retrieves all public product lists as defined by the given search term (for example, email OR first name and last name).
374
+ * @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
375
+ * @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
376
+ * @returns A TanStack Query query hook with data from the Shopper Customers `getPublicProductListsBySearchTerm` endpoint.
377
+ * @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=getPublicProductListsBySearchTerm| Salesforce Developer Center} for more information about the API endpoint.
378
+ * @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#getpublicproductlistsbysearchterm | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
379
+ * @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
380
+ */
381
+ exports.useCustomerProductListItem = useCustomerProductListItem;
382
+ const usePublicProductListsBySearchTerm = (apiOptions, queryOptions = {}) => {
383
+ const {
384
+ shopperCustomers: client
385
+ } = (0, _useCommerceApi.default)();
386
+ const methodName = 'getPublicProductListsBySearchTerm';
387
+ const requiredParameters = ['organizationId', 'siteId'];
388
+
389
+ // Parameters can be set in `apiOptions` or `client.clientConfig`;
390
+ // we must merge them in order to generate the correct query key.
391
+ const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
392
+ const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
393
+ // We don't use `netOptions` here because we manipulate the options in `useQuery`.
394
+ const method = /*#__PURE__*/function () {
395
+ var _ref9 = _asyncToGenerator(function* (options) {
396
+ return yield client[methodName](options);
397
+ });
398
+ return function method(_x9) {
399
+ return _ref9.apply(this, arguments);
400
+ };
401
+ }();
402
+
403
+ // For some reason, if we don't explicitly set these generic parameters, the inferred type for
404
+ // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
405
+ return (0, _useQuery.useQuery)(netOptions, queryOptions, {
406
+ method,
407
+ queryKey,
408
+ requiredParameters
409
+ });
410
+ };
411
+ /**
412
+ * Retrieves a public product list by ID and the items under that product list.
413
+ * @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
414
+ * @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
415
+ * @returns A TanStack Query query hook with data from the Shopper Customers `getPublicProductList` endpoint.
416
+ * @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=getPublicProductList| Salesforce Developer Center} for more information about the API endpoint.
417
+ * @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#getpublicproductlist | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
418
+ * @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
419
+ */
420
+ exports.usePublicProductListsBySearchTerm = usePublicProductListsBySearchTerm;
421
+ const usePublicProductList = (apiOptions, queryOptions = {}) => {
422
+ const {
423
+ shopperCustomers: client
424
+ } = (0, _useCommerceApi.default)();
425
+ const methodName = 'getPublicProductList';
426
+ const requiredParameters = ['organizationId', 'listId', 'siteId'];
427
+
428
+ // Parameters can be set in `apiOptions` or `client.clientConfig`;
429
+ // we must merge them in order to generate the correct query key.
430
+ const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
431
+ const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
432
+ // We don't use `netOptions` here because we manipulate the options in `useQuery`.
433
+ const method = /*#__PURE__*/function () {
434
+ var _ref10 = _asyncToGenerator(function* (options) {
435
+ return yield client[methodName](options);
436
+ });
437
+ return function method(_x10) {
438
+ return _ref10.apply(this, arguments);
439
+ };
440
+ }();
441
+
442
+ // For some reason, if we don't explicitly set these generic parameters, the inferred type for
443
+ // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
444
+ return (0, _useQuery.useQuery)(netOptions, queryOptions, {
445
+ method,
446
+ queryKey,
447
+ requiredParameters
448
+ });
449
+ };
450
+ /**
451
+ * Retrieves an item from a public product list and the actual product details like product, image, availability and price.
452
+ * @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
453
+ * @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
454
+ * @returns A TanStack Query query hook with data from the Shopper Customers `getProductListItem` endpoint.
455
+ * @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=getProductListItem| Salesforce Developer Center} for more information about the API endpoint.
456
+ * @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#getproductlistitem | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
457
+ * @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
458
+ */
459
+ exports.usePublicProductList = usePublicProductList;
460
+ const useProductListItem = (apiOptions, queryOptions = {}) => {
461
+ const {
462
+ shopperCustomers: client
463
+ } = (0, _useCommerceApi.default)();
464
+ const methodName = 'getProductListItem';
465
+ const requiredParameters = ['organizationId', 'listId', 'itemId', 'siteId'];
466
+
467
+ // Parameters can be set in `apiOptions` or `client.clientConfig`;
468
+ // we must merge them in order to generate the correct query key.
469
+ const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
470
+ const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
471
+ // We don't use `netOptions` here because we manipulate the options in `useQuery`.
472
+ const method = /*#__PURE__*/function () {
473
+ var _ref11 = _asyncToGenerator(function* (options) {
474
+ return yield client[methodName](options);
475
+ });
476
+ return function method(_x11) {
477
+ return _ref11.apply(this, arguments);
478
+ };
479
+ }();
480
+
481
+ // For some reason, if we don't explicitly set these generic parameters, the inferred type for
482
+ // `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
483
+ return (0, _useQuery.useQuery)(netOptions, queryOptions, {
484
+ method,
485
+ queryKey,
486
+ requiredParameters
487
+ });
488
+ };
489
+ exports.useProductListItem = useProductListItem;
@@ -0,0 +1,142 @@
1
+ import type { ShopperCustomers } from 'commerce-sdk-isomorphic';
2
+ import { Argument, ExcludeTail } from '../types';
3
+ declare type Client = ShopperCustomers<{
4
+ shortCode: string;
5
+ }>;
6
+ declare type Params<T extends keyof QueryKeys> = Partial<Argument<Client[T]>['parameters']>;
7
+ export declare type QueryKeys = {
8
+ getExternalProfile: [
9
+ '/commerce-sdk-react',
10
+ '/organizations/',
11
+ string | undefined,
12
+ '/customers/external-profile',
13
+ Params<'getExternalProfile'>
14
+ ];
15
+ getCustomer: [
16
+ '/commerce-sdk-react',
17
+ '/organizations/',
18
+ string | undefined,
19
+ '/customers/',
20
+ string | undefined,
21
+ Params<'getCustomer'>
22
+ ];
23
+ getCustomerAddress: [
24
+ '/commerce-sdk-react',
25
+ '/organizations/',
26
+ string | undefined,
27
+ '/customers/',
28
+ string | undefined,
29
+ '/addresses/',
30
+ string | undefined,
31
+ Params<'getCustomerAddress'>
32
+ ];
33
+ getCustomerBaskets: [
34
+ '/commerce-sdk-react',
35
+ '/organizations/',
36
+ string | undefined,
37
+ '/customers/',
38
+ string | undefined,
39
+ '/baskets',
40
+ Params<'getCustomerBaskets'>
41
+ ];
42
+ getCustomerOrders: [
43
+ '/commerce-sdk-react',
44
+ '/organizations/',
45
+ string | undefined,
46
+ '/customers/',
47
+ string | undefined,
48
+ '/orders',
49
+ Params<'getCustomerOrders'>
50
+ ];
51
+ getCustomerPaymentInstrument: [
52
+ '/commerce-sdk-react',
53
+ '/organizations/',
54
+ string | undefined,
55
+ '/customers/',
56
+ string | undefined,
57
+ '/payment-instruments/',
58
+ string | undefined,
59
+ Params<'getCustomerPaymentInstrument'>
60
+ ];
61
+ getCustomerProductLists: [
62
+ '/commerce-sdk-react',
63
+ '/organizations/',
64
+ string | undefined,
65
+ '/customers/',
66
+ string | undefined,
67
+ '/product-lists',
68
+ Params<'getCustomerProductLists'>
69
+ ];
70
+ getCustomerProductList: [
71
+ '/commerce-sdk-react',
72
+ '/organizations/',
73
+ string | undefined,
74
+ '/customers/',
75
+ string | undefined,
76
+ '/product-lists/',
77
+ string | undefined,
78
+ Params<'getCustomerProductList'>
79
+ ];
80
+ getCustomerProductListItem: [
81
+ '/commerce-sdk-react',
82
+ '/organizations/',
83
+ string | undefined,
84
+ '/customers/',
85
+ string | undefined,
86
+ '/product-lists/',
87
+ string | undefined,
88
+ '/items/',
89
+ string | undefined,
90
+ Params<'getCustomerProductListItem'>
91
+ ];
92
+ getPublicProductListsBySearchTerm: [
93
+ '/commerce-sdk-react',
94
+ '/organizations/',
95
+ string | undefined,
96
+ '/product-lists',
97
+ Params<'getPublicProductListsBySearchTerm'>
98
+ ];
99
+ getPublicProductList: [
100
+ '/commerce-sdk-react',
101
+ '/organizations/',
102
+ string | undefined,
103
+ '/product-lists/',
104
+ string | undefined,
105
+ Params<'getPublicProductList'>
106
+ ];
107
+ getProductListItem: [
108
+ '/commerce-sdk-react',
109
+ '/organizations/',
110
+ string | undefined,
111
+ '/product-lists/',
112
+ string | undefined,
113
+ '/items/',
114
+ string | undefined,
115
+ Params<'getProductListItem'>
116
+ ];
117
+ };
118
+ declare 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
+ /** Generates the path component of the query key for an endpoint. */
125
+ path: (params: Params<T>) => ExcludeTail<QueryKeys[T]>;
126
+ /** Generates the full query key for an endpoint. */
127
+ queryKey: (params: Params<T>) => QueryKeys[T];
128
+ };
129
+ export declare const getExternalProfile: QueryKeyHelper<'getExternalProfile'>;
130
+ export declare const getCustomer: QueryKeyHelper<'getCustomer'>;
131
+ export declare const getCustomerAddress: QueryKeyHelper<'getCustomerAddress'>;
132
+ export declare const getCustomerBaskets: QueryKeyHelper<'getCustomerBaskets'>;
133
+ export declare const getCustomerOrders: QueryKeyHelper<'getCustomerOrders'>;
134
+ export declare const getCustomerPaymentInstrument: QueryKeyHelper<'getCustomerPaymentInstrument'>;
135
+ export declare const getCustomerProductLists: QueryKeyHelper<'getCustomerProductLists'>;
136
+ export declare const getCustomerProductList: QueryKeyHelper<'getCustomerProductList'>;
137
+ export declare const getCustomerProductListItem: QueryKeyHelper<'getCustomerProductListItem'>;
138
+ export declare const getPublicProductListsBySearchTerm: QueryKeyHelper<'getPublicProductListsBySearchTerm'>;
139
+ export declare const getPublicProductList: QueryKeyHelper<'getPublicProductList'>;
140
+ export declare const getProductListItem: QueryKeyHelper<'getProductListItem'>;
141
+ export {};
142
+ //# sourceMappingURL=queryKeyHelpers.d.ts.map