@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.
- package/.eslintrc.js +10 -0
- package/CHANGELOG.md +35 -0
- package/LICENSE +14 -0
- package/README.md +327 -0
- package/auth/index.d.ts +220 -0
- package/auth/index.js +472 -0
- package/auth/storage.d.ts +48 -0
- package/auth/storage.js +122 -0
- package/components/ShopperExperience/Component/index.d.ts +17 -0
- package/components/ShopperExperience/Component/index.js +49 -0
- package/components/ShopperExperience/Page/index.d.ts +28 -0
- package/components/ShopperExperience/Page/index.js +97 -0
- package/components/ShopperExperience/Region/index.d.ts +41 -0
- package/components/ShopperExperience/Region/index.js +64 -0
- package/components/ShopperExperience/index.d.ts +5 -0
- package/components/ShopperExperience/index.js +49 -0
- package/components/ShopperExperience/prop-types.d.ts +39 -0
- package/components/ShopperExperience/prop-types.js +46 -0
- package/components/ShopperExperience/types.d.ts +8 -0
- package/components/ShopperExperience/types.js +5 -0
- package/components/index.d.ts +2 -0
- package/components/index.js +16 -0
- package/hooks/ShopperBaskets/cache.d.ts +5 -0
- package/hooks/ShopperBaskets/cache.js +351 -0
- package/hooks/ShopperBaskets/index.d.ts +3 -0
- package/hooks/ShopperBaskets/index.js +27 -0
- package/hooks/ShopperBaskets/mutation.d.ts +381 -0
- package/hooks/ShopperBaskets/mutation.js +380 -0
- package/hooks/ShopperBaskets/query.d.ts +55 -0
- package/hooks/ShopperBaskets/query.js +215 -0
- package/hooks/ShopperBaskets/queryKeyHelpers.d.ts +72 -0
- package/hooks/ShopperBaskets/queryKeyHelpers.js +49 -0
- package/hooks/ShopperContexts/cache.d.ts +5 -0
- package/hooks/ShopperContexts/cache.js +45 -0
- package/hooks/ShopperContexts/index.d.ts +3 -0
- package/hooks/ShopperContexts/index.js +27 -0
- package/hooks/ShopperContexts/mutation.d.ts +35 -0
- package/hooks/ShopperContexts/mutation.js +68 -0
- package/hooks/ShopperContexts/query.d.ts +15 -0
- package/hooks/ShopperContexts/query.js +59 -0
- package/hooks/ShopperContexts/queryKeyHelpers.d.ts +30 -0
- package/hooks/ShopperContexts/queryKeyHelpers.js +25 -0
- package/hooks/ShopperCustomers/cache.d.ts +5 -0
- package/hooks/ShopperCustomers/cache.js +387 -0
- package/hooks/ShopperCustomers/index.d.ts +3 -0
- package/hooks/ShopperCustomers/index.js +27 -0
- package/hooks/ShopperCustomers/mutation.d.ts +163 -0
- package/hooks/ShopperCustomers/mutation.js +203 -0
- package/hooks/ShopperCustomers/query.d.ts +115 -0
- package/hooks/ShopperCustomers/query.js +489 -0
- package/hooks/ShopperCustomers/queryKeyHelpers.d.ts +142 -0
- package/hooks/ShopperCustomers/queryKeyHelpers.js +91 -0
- package/hooks/ShopperExperience/index.d.ts +2 -0
- package/hooks/ShopperExperience/index.js +16 -0
- package/hooks/ShopperExperience/query.d.ts +31 -0
- package/hooks/ShopperExperience/query.js +104 -0
- package/hooks/ShopperExperience/queryKeyHelpers.d.ts +38 -0
- package/hooks/ShopperExperience/queryKeyHelpers.js +31 -0
- package/hooks/ShopperGiftCertificates/index.d.ts +2 -0
- package/hooks/ShopperGiftCertificates/index.js +16 -0
- package/hooks/ShopperGiftCertificates/query.d.ts +15 -0
- package/hooks/ShopperGiftCertificates/query.js +70 -0
- package/hooks/ShopperGiftCertificates/queryKeyHelpers.d.ts +29 -0
- package/hooks/ShopperGiftCertificates/queryKeyHelpers.js +25 -0
- package/hooks/ShopperLogin/cache.d.ts +3 -0
- package/hooks/ShopperLogin/cache.js +33 -0
- package/hooks/ShopperLogin/index.d.ts +3 -0
- package/hooks/ShopperLogin/index.js +27 -0
- package/hooks/ShopperLogin/mutation.d.ts +119 -0
- package/hooks/ShopperLogin/mutation.js +138 -0
- package/hooks/ShopperLogin/query.d.ts +45 -0
- package/hooks/ShopperLogin/query.js +176 -0
- package/hooks/ShopperLogin/queryKeyHelpers.d.ts +53 -0
- package/hooks/ShopperLogin/queryKeyHelpers.js +43 -0
- package/hooks/ShopperOrders/cache.d.ts +5 -0
- package/hooks/ShopperOrders/cache.js +54 -0
- package/hooks/ShopperOrders/index.d.ts +3 -0
- package/hooks/ShopperOrders/index.js +27 -0
- package/hooks/ShopperOrders/mutation.d.ts +54 -0
- package/hooks/ShopperOrders/mutation.js +83 -0
- package/hooks/ShopperOrders/query.d.ts +37 -0
- package/hooks/ShopperOrders/query.js +139 -0
- package/hooks/ShopperOrders/queryKeyHelpers.d.ts +50 -0
- package/hooks/ShopperOrders/queryKeyHelpers.js +37 -0
- package/hooks/ShopperProducts/index.d.ts +2 -0
- package/hooks/ShopperProducts/index.js +16 -0
- package/hooks/ShopperProducts/query.d.ts +47 -0
- package/hooks/ShopperProducts/query.js +178 -0
- package/hooks/ShopperProducts/queryKeyHelpers.d.ts +55 -0
- package/hooks/ShopperProducts/queryKeyHelpers.js +43 -0
- package/hooks/ShopperPromotions/index.d.ts +2 -0
- package/hooks/ShopperPromotions/index.js +16 -0
- package/hooks/ShopperPromotions/query.d.ts +29 -0
- package/hooks/ShopperPromotions/query.js +102 -0
- package/hooks/ShopperPromotions/queryKeyHelpers.d.ts +38 -0
- package/hooks/ShopperPromotions/queryKeyHelpers.js +31 -0
- package/hooks/ShopperSearch/index.d.ts +2 -0
- package/hooks/ShopperSearch/index.js +16 -0
- package/hooks/ShopperSearch/query.d.ts +26 -0
- package/hooks/ShopperSearch/query.js +99 -0
- package/hooks/ShopperSearch/queryKeyHelpers.d.ts +37 -0
- package/hooks/ShopperSearch/queryKeyHelpers.js +31 -0
- package/hooks/index.d.ts +18 -0
- package/hooks/index.js +188 -0
- package/hooks/types.d.ts +128 -0
- package/hooks/types.js +5 -0
- package/hooks/useAccessToken.d.ts +11 -0
- package/hooks/useAccessToken.js +43 -0
- package/hooks/useAuthContext.d.ts +9 -0
- package/hooks/useAuthContext.js +30 -0
- package/hooks/useAuthHelper.d.ts +23 -0
- package/hooks/useAuthHelper.js +66 -0
- package/hooks/useAuthorizationHeader.d.ts +9 -0
- package/hooks/useAuthorizationHeader.js +45 -0
- package/hooks/useCommerceApi.d.ts +9 -0
- package/hooks/useCommerceApi.js +26 -0
- package/hooks/useConfig.d.ts +7 -0
- package/hooks/useConfig.js +24 -0
- package/hooks/useCustomerId.d.ts +7 -0
- package/hooks/useCustomerId.js +38 -0
- package/hooks/useCustomerType.d.ts +21 -0
- package/hooks/useCustomerType.js +43 -0
- package/hooks/useEncUserId.d.ts +9 -0
- package/hooks/useEncUserId.js +36 -0
- package/hooks/useLocalStorage.d.ts +8 -0
- package/hooks/useLocalStorage.js +40 -0
- package/hooks/useMutation.d.ts +12 -0
- package/hooks/useMutation.js +38 -0
- package/hooks/useQuery.d.ts +15 -0
- package/hooks/useQuery.js +57 -0
- package/hooks/useUsid.d.ts +7 -0
- package/hooks/useUsid.js +34 -0
- package/hooks/utils.d.ts +32 -0
- package/hooks/utils.js +125 -0
- package/index.d.ts +5 -0
- package/index.js +40 -0
- package/package.json +88 -0
- package/provider.d.ts +36 -0
- package/provider.js +124 -0
- package/scripts/build-and-release-docs.js +48 -0
- package/scripts/version.js +22 -0
- package/utils.d.ts +5 -0
- package/utils.js +18 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ShopperContexts } from 'commerce-sdk-isomorphic';
|
|
2
|
+
import { Argument, ExcludeTail } from '../types';
|
|
3
|
+
declare type Client = ShopperContexts<{
|
|
4
|
+
shortCode: string;
|
|
5
|
+
}>;
|
|
6
|
+
declare type Params<T extends keyof QueryKeys> = Partial<Argument<Client[T]>['parameters']>;
|
|
7
|
+
export declare type QueryKeys = {
|
|
8
|
+
getShopperContext: [
|
|
9
|
+
'/commerce-sdk-react',
|
|
10
|
+
'/organizations/',
|
|
11
|
+
string | undefined,
|
|
12
|
+
'/shopper-context/',
|
|
13
|
+
string | undefined,
|
|
14
|
+
Params<'getShopperContext'>
|
|
15
|
+
];
|
|
16
|
+
};
|
|
17
|
+
declare type QueryKeyHelper<T extends keyof QueryKeys> = {
|
|
18
|
+
/**
|
|
19
|
+
* Reduces the given parameters (which may have additional, unknown properties) to an object
|
|
20
|
+
* containing *only* the properties required for an endpoint.
|
|
21
|
+
*/
|
|
22
|
+
parameters: (params: Params<T>) => Params<T>;
|
|
23
|
+
/** Generates the path component of the query key for an endpoint. */
|
|
24
|
+
path: (params: Params<T>) => ExcludeTail<QueryKeys[T]>;
|
|
25
|
+
/** Generates the full query key for an endpoint. */
|
|
26
|
+
queryKey: (params: Params<T>) => QueryKeys[T];
|
|
27
|
+
};
|
|
28
|
+
export declare const getShopperContext: QueryKeyHelper<'getShopperContext'>;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=queryKeyHelpers.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getShopperContext = void 0;
|
|
7
|
+
var _utils = require("../utils");
|
|
8
|
+
/*
|
|
9
|
+
* Copyright (c) 2023, Salesforce, Inc.
|
|
10
|
+
* All rights reserved.
|
|
11
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
12
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
// We must use a client with no parameters in order to have required/optional match the API spec
|
|
16
|
+
|
|
17
|
+
// This is defined here, rather than `types.ts`, because it relies on `Client` and `QueryKeys`,
|
|
18
|
+
// and making those generic would add too much complexity.
|
|
19
|
+
|
|
20
|
+
const getShopperContext = {
|
|
21
|
+
parameters: params => (0, _utils.pick)(params, ['organizationId', 'usid']),
|
|
22
|
+
path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/shopper-context/', params.usid],
|
|
23
|
+
queryKey: params => [...getShopperContext.path(params), getShopperContext.parameters(params)]
|
|
24
|
+
};
|
|
25
|
+
exports.getShopperContext = getShopperContext;
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.cacheUpdateMatrix = void 0;
|
|
7
|
+
var _queryKeyHelpers = require("./queryKeyHelpers");
|
|
8
|
+
var _utils = require("../utils");
|
|
9
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
|
+
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; }
|
|
12
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
13
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /*
|
|
14
|
+
* Copyright (c) 2023, Salesforce, Inc.
|
|
15
|
+
* All rights reserved.
|
|
16
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
17
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
18
|
+
*/
|
|
19
|
+
const noop = () => ({});
|
|
20
|
+
|
|
21
|
+
// ReactQuery type def for the updater function uses type `unknown` for the first param,
|
|
22
|
+
// this makes it hard to define the `createUpdateFunction` below, so we created this type.
|
|
23
|
+
// This is a slight variation of above, but we know the data is not null.
|
|
24
|
+
/**
|
|
25
|
+
* Create an update handler for the cache matrix. This updater will implicitly clone and assert
|
|
26
|
+
* that the data being passed to is is not undefined.
|
|
27
|
+
*
|
|
28
|
+
* @param update
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
const createUpdateFunction = update => data => data ? update((0, _utils.clone)(data)) : undefined;
|
|
32
|
+
const cacheUpdateMatrix = {
|
|
33
|
+
createCustomerAddress(customerId, {
|
|
34
|
+
parameters
|
|
35
|
+
}, response) {
|
|
36
|
+
// getCustomerAddress uses `addressName` rather than `addressId`
|
|
37
|
+
const newParams = _objectSpread(_objectSpread({}, parameters), {}, {
|
|
38
|
+
addressName: response.addressId
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
update: [{
|
|
42
|
+
queryKey: _queryKeyHelpers.getCustomerAddress.queryKey(newParams)
|
|
43
|
+
}, {
|
|
44
|
+
queryKey: _queryKeyHelpers.getCustomer.queryKey(newParams),
|
|
45
|
+
updater: createUpdateFunction(customer => {
|
|
46
|
+
// Push new address onto the end of addresses list.
|
|
47
|
+
customer.addresses = [...(customer.addresses ?? []), response];
|
|
48
|
+
return customer;
|
|
49
|
+
})
|
|
50
|
+
}]
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
createCustomerPaymentInstrument(customerId, {
|
|
54
|
+
parameters
|
|
55
|
+
}, response) {
|
|
56
|
+
const newParams = _objectSpread(_objectSpread({}, parameters), {}, {
|
|
57
|
+
paymentInstrumentId: response.paymentInstrumentId
|
|
58
|
+
});
|
|
59
|
+
return {
|
|
60
|
+
update: [{
|
|
61
|
+
queryKey: _queryKeyHelpers.getCustomerPaymentInstrument.queryKey(newParams)
|
|
62
|
+
}, {
|
|
63
|
+
queryKey: _queryKeyHelpers.getCustomer.queryKey(newParams),
|
|
64
|
+
updater: createUpdateFunction(customer => {
|
|
65
|
+
customer.paymentInstruments = [...(customer.paymentInstruments ?? []), response];
|
|
66
|
+
return customer;
|
|
67
|
+
})
|
|
68
|
+
}]
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
createCustomerProductList(customerId, {
|
|
72
|
+
parameters
|
|
73
|
+
}, response) {
|
|
74
|
+
// We always invalidate, because even without an ID we assume that something has changed
|
|
75
|
+
const listId = response.id;
|
|
76
|
+
return {
|
|
77
|
+
update: [{
|
|
78
|
+
queryKey: _queryKeyHelpers.getCustomerProductLists.queryKey(parameters),
|
|
79
|
+
updater: createUpdateFunction(result => {
|
|
80
|
+
// Add new list to front of the lists.
|
|
81
|
+
result.data.unshift(response);
|
|
82
|
+
result.limit++;
|
|
83
|
+
result.total++;
|
|
84
|
+
return result;
|
|
85
|
+
})
|
|
86
|
+
}, {
|
|
87
|
+
queryKey: _queryKeyHelpers.getCustomerProductList.queryKey(_objectSpread(_objectSpread({}, parameters), {}, {
|
|
88
|
+
listId
|
|
89
|
+
}))
|
|
90
|
+
}]
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
createCustomerProductListItem(customerId, {
|
|
94
|
+
parameters
|
|
95
|
+
}, response) {
|
|
96
|
+
// We always invalidate, because even without an ID we assume that something has changed
|
|
97
|
+
// QUESTION: Why would we get a response that doesn't have an ID?
|
|
98
|
+
const itemId = response.id;
|
|
99
|
+
return {
|
|
100
|
+
update: [{
|
|
101
|
+
queryKey: _queryKeyHelpers.getCustomerProductListItem.queryKey(_objectSpread(_objectSpread({}, parameters), {}, {
|
|
102
|
+
itemId
|
|
103
|
+
}))
|
|
104
|
+
}, {
|
|
105
|
+
queryKey: _queryKeyHelpers.getCustomerProductList.queryKey(parameters),
|
|
106
|
+
updater: createUpdateFunction(list => {
|
|
107
|
+
return _objectSpread(_objectSpread({}, list), {}, {
|
|
108
|
+
customerProductListItems: [...((list === null || list === void 0 ? void 0 : list.customerProductListItems) || []), response]
|
|
109
|
+
});
|
|
110
|
+
})
|
|
111
|
+
}, {
|
|
112
|
+
queryKey: _queryKeyHelpers.getCustomerProductLists.queryKey(parameters),
|
|
113
|
+
updater: createUpdateFunction(result => {
|
|
114
|
+
// Find the list that we want to add the item to.
|
|
115
|
+
const list = result.data.find(({
|
|
116
|
+
id
|
|
117
|
+
}) => id === parameters.listId);
|
|
118
|
+
if (!list) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
list.customerProductListItems = [...(list.customerProductListItems ?? []), response];
|
|
122
|
+
return result;
|
|
123
|
+
})
|
|
124
|
+
}]
|
|
125
|
+
};
|
|
126
|
+
},
|
|
127
|
+
deleteCustomerPaymentInstrument(customerId, {
|
|
128
|
+
parameters
|
|
129
|
+
}) {
|
|
130
|
+
return {
|
|
131
|
+
update: [{
|
|
132
|
+
queryKey: _queryKeyHelpers.getCustomer.queryKey(parameters),
|
|
133
|
+
updater: createUpdateFunction(customer => {
|
|
134
|
+
var _customer$paymentInst, _customer$paymentInst2;
|
|
135
|
+
const paymentInstrumentIndex = (_customer$paymentInst = customer.paymentInstruments) === null || _customer$paymentInst === void 0 ? void 0 : _customer$paymentInst.findIndex(({
|
|
136
|
+
paymentInstrumentId
|
|
137
|
+
}) => paymentInstrumentId === parameters.paymentInstrumentId);
|
|
138
|
+
|
|
139
|
+
// Return undefined (no changes) if no payment instrument was found.
|
|
140
|
+
if (paymentInstrumentIndex === undefined || paymentInstrumentIndex < 0) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Remove the found payment instrument.
|
|
145
|
+
(_customer$paymentInst2 = customer.paymentInstruments) === null || _customer$paymentInst2 === void 0 ? void 0 : _customer$paymentInst2.splice(paymentInstrumentIndex, 1);
|
|
146
|
+
return customer;
|
|
147
|
+
})
|
|
148
|
+
}],
|
|
149
|
+
remove: [{
|
|
150
|
+
queryKey: _queryKeyHelpers.getCustomerPaymentInstrument.queryKey(parameters)
|
|
151
|
+
}]
|
|
152
|
+
};
|
|
153
|
+
},
|
|
154
|
+
deleteCustomerProductList(customerId, {
|
|
155
|
+
parameters
|
|
156
|
+
}) {
|
|
157
|
+
return {
|
|
158
|
+
update: [{
|
|
159
|
+
queryKey: _queryKeyHelpers.getCustomerProductLists.queryKey(parameters),
|
|
160
|
+
updater: createUpdateFunction(result => {
|
|
161
|
+
const listIndex = result.data.findIndex(({
|
|
162
|
+
id
|
|
163
|
+
}) => id === parameters.listId);
|
|
164
|
+
|
|
165
|
+
// Return undefined if no list is found
|
|
166
|
+
if (listIndex < 0) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Remove the list from the result object
|
|
171
|
+
result.data.splice(listIndex, 1);
|
|
172
|
+
result.limit--;
|
|
173
|
+
result.total--;
|
|
174
|
+
return result;
|
|
175
|
+
})
|
|
176
|
+
}],
|
|
177
|
+
remove: [{
|
|
178
|
+
queryKey: _queryKeyHelpers.getCustomerProductList.path(parameters)
|
|
179
|
+
}]
|
|
180
|
+
};
|
|
181
|
+
},
|
|
182
|
+
deleteCustomerProductListItem(customerId, {
|
|
183
|
+
parameters
|
|
184
|
+
}) {
|
|
185
|
+
return {
|
|
186
|
+
update: [{
|
|
187
|
+
queryKey: _queryKeyHelpers.getCustomerProductList.queryKey(parameters),
|
|
188
|
+
updater: createUpdateFunction(list => {
|
|
189
|
+
var _list$customerProduct, _list$customerProduct2;
|
|
190
|
+
const itemIndex = (_list$customerProduct = list.customerProductListItems) === null || _list$customerProduct === void 0 ? void 0 : _list$customerProduct.findIndex(({
|
|
191
|
+
id
|
|
192
|
+
}) => id === parameters.itemId);
|
|
193
|
+
|
|
194
|
+
// Return undefined if there is no item found.
|
|
195
|
+
if (itemIndex === undefined || itemIndex < 0) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Remove the list item
|
|
200
|
+
(_list$customerProduct2 = list.customerProductListItems) === null || _list$customerProduct2 === void 0 ? void 0 : _list$customerProduct2.splice(itemIndex, 1);
|
|
201
|
+
return list;
|
|
202
|
+
})
|
|
203
|
+
}, {
|
|
204
|
+
queryKey: _queryKeyHelpers.getCustomerProductLists.queryKey(parameters),
|
|
205
|
+
updater: createUpdateFunction(result => {
|
|
206
|
+
var _list$customerProduct3, _list$customerProduct4;
|
|
207
|
+
const list = result.data.find(({
|
|
208
|
+
id
|
|
209
|
+
}) => id === parameters.listId);
|
|
210
|
+
const itemIndex = list === null || list === void 0 ? void 0 : (_list$customerProduct3 = list.customerProductListItems) === null || _list$customerProduct3 === void 0 ? void 0 : _list$customerProduct3.findIndex(({
|
|
211
|
+
id
|
|
212
|
+
}) => id === parameters.itemId);
|
|
213
|
+
|
|
214
|
+
// Return undefined if no item was found in the provided list.
|
|
215
|
+
if (itemIndex === undefined || itemIndex < 0) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Remove the item from the list.
|
|
220
|
+
list === null || list === void 0 ? void 0 : (_list$customerProduct4 = list.customerProductListItems) === null || _list$customerProduct4 === void 0 ? void 0 : _list$customerProduct4.splice(itemIndex, 1);
|
|
221
|
+
return result;
|
|
222
|
+
})
|
|
223
|
+
}],
|
|
224
|
+
remove: [{
|
|
225
|
+
queryKey: _queryKeyHelpers.getCustomerProductListItem.queryKey(parameters)
|
|
226
|
+
}]
|
|
227
|
+
};
|
|
228
|
+
},
|
|
229
|
+
getResetPasswordToken: noop,
|
|
230
|
+
// TODO: Should this update the `getCustomer` cache?
|
|
231
|
+
registerCustomer: noop,
|
|
232
|
+
// TODO: Implement when the endpoint exits closed beta.
|
|
233
|
+
// registerExternalProfile: TODO('registerExternalProfile'),
|
|
234
|
+
removeCustomerAddress(customerId, {
|
|
235
|
+
parameters
|
|
236
|
+
}) {
|
|
237
|
+
return {
|
|
238
|
+
update: [{
|
|
239
|
+
queryKey: _queryKeyHelpers.getCustomer.queryKey(parameters),
|
|
240
|
+
updater: createUpdateFunction(customer => {
|
|
241
|
+
var _customer$addresses, _customer$addresses2;
|
|
242
|
+
const addressIndex = (_customer$addresses = customer.addresses) === null || _customer$addresses === void 0 ? void 0 : _customer$addresses.findIndex(({
|
|
243
|
+
addressId
|
|
244
|
+
}) => addressId === parameters.addressName);
|
|
245
|
+
|
|
246
|
+
// Return undefined if the address is not found...
|
|
247
|
+
if (addressIndex === undefined || addressIndex < 0) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Remove the found address.
|
|
252
|
+
(_customer$addresses2 = customer.addresses) === null || _customer$addresses2 === void 0 ? void 0 : _customer$addresses2.splice(addressIndex, 1);
|
|
253
|
+
return customer;
|
|
254
|
+
})
|
|
255
|
+
}],
|
|
256
|
+
remove: [{
|
|
257
|
+
queryKey: _queryKeyHelpers.getCustomerAddress.queryKey(parameters)
|
|
258
|
+
}]
|
|
259
|
+
};
|
|
260
|
+
},
|
|
261
|
+
resetPassword: noop,
|
|
262
|
+
updateCustomer(customerId, {
|
|
263
|
+
parameters
|
|
264
|
+
}) {
|
|
265
|
+
// When we update a customer, we don't know what data has changed, so we must invalidate all
|
|
266
|
+
// derivative endpoints. They conveniently all start with the same path as `getCustomer`,
|
|
267
|
+
// but we do NOT want to invalidate `getCustomer` itself, we want to _update_ it. (Ideally,
|
|
268
|
+
// we could invalidate *then* update, but React Query can't handle that.) To do so, we
|
|
269
|
+
// examine the path of each cached query. If it starts with the `getCustomer` path, we
|
|
270
|
+
// invalidate, UNLESS the first item afer the path is an object, because that means that it
|
|
271
|
+
// is the `getCustomer` query itself.
|
|
272
|
+
const path = _queryKeyHelpers.getCustomer.path(parameters);
|
|
273
|
+
const isNotGetCustomer = ({
|
|
274
|
+
queryKey
|
|
275
|
+
}) => typeof queryKey[path.length] !== 'object';
|
|
276
|
+
const predicate = (0, _utils.and)((0, _utils.pathStartsWith)(path), isNotGetCustomer);
|
|
277
|
+
return {
|
|
278
|
+
update: [{
|
|
279
|
+
queryKey: _queryKeyHelpers.getCustomer.queryKey(parameters)
|
|
280
|
+
}],
|
|
281
|
+
invalidate: [{
|
|
282
|
+
predicate
|
|
283
|
+
}]
|
|
284
|
+
};
|
|
285
|
+
},
|
|
286
|
+
updateCustomerAddress(customerId, {
|
|
287
|
+
parameters
|
|
288
|
+
}, response) {
|
|
289
|
+
return {
|
|
290
|
+
update: [{
|
|
291
|
+
queryKey: _queryKeyHelpers.getCustomerAddress.queryKey(parameters)
|
|
292
|
+
}, {
|
|
293
|
+
queryKey: _queryKeyHelpers.getCustomer.queryKey(parameters),
|
|
294
|
+
updater: createUpdateFunction(customer => {
|
|
295
|
+
if (!customer.addresses) return;
|
|
296
|
+
const addressIndex = customer.addresses.findIndex(({
|
|
297
|
+
addressId
|
|
298
|
+
}) => addressId === response.addressId);
|
|
299
|
+
|
|
300
|
+
// Return undefined if no address is found...
|
|
301
|
+
if (addressIndex === undefined || addressIndex < 0) {
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Update the found address.
|
|
306
|
+
customer.addresses[addressIndex] = response;
|
|
307
|
+
return customer;
|
|
308
|
+
})
|
|
309
|
+
}]
|
|
310
|
+
};
|
|
311
|
+
},
|
|
312
|
+
updateCustomerPassword: noop,
|
|
313
|
+
updateCustomerProductList(customerId, {
|
|
314
|
+
parameters
|
|
315
|
+
}, response) {
|
|
316
|
+
return {
|
|
317
|
+
update: [{
|
|
318
|
+
queryKey: _queryKeyHelpers.getCustomerProductList.queryKey(parameters)
|
|
319
|
+
}, {
|
|
320
|
+
queryKey: _queryKeyHelpers.getCustomerProductLists.queryKey(parameters),
|
|
321
|
+
updater: createUpdateFunction(result => {
|
|
322
|
+
const listIndex = result.data.findIndex(({
|
|
323
|
+
id
|
|
324
|
+
}) => id === response.id);
|
|
325
|
+
|
|
326
|
+
// Return undefined if we didn't find the product list we were looking for.
|
|
327
|
+
if (listIndex < 0) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// Update the product list.
|
|
332
|
+
result.data[listIndex] = response;
|
|
333
|
+
return result;
|
|
334
|
+
})
|
|
335
|
+
}]
|
|
336
|
+
};
|
|
337
|
+
},
|
|
338
|
+
updateCustomerProductListItem(customerId, {
|
|
339
|
+
parameters
|
|
340
|
+
}, response) {
|
|
341
|
+
return {
|
|
342
|
+
update: [{
|
|
343
|
+
queryKey: _queryKeyHelpers.getCustomerProductListItem.queryKey(parameters)
|
|
344
|
+
}, {
|
|
345
|
+
queryKey: _queryKeyHelpers.getCustomerProductList.queryKey(parameters),
|
|
346
|
+
updater: createUpdateFunction(list => {
|
|
347
|
+
var _list$customerProduct5;
|
|
348
|
+
if (!list.customerProductListItems) return;
|
|
349
|
+
// Find the index of the item we want to update.
|
|
350
|
+
const itemIndex = (_list$customerProduct5 = list.customerProductListItems) === null || _list$customerProduct5 === void 0 ? void 0 : _list$customerProduct5.findIndex(({
|
|
351
|
+
id
|
|
352
|
+
}) => id === parameters.itemId);
|
|
353
|
+
|
|
354
|
+
// Return undefined when item isn't found.
|
|
355
|
+
if (itemIndex === undefined || itemIndex < 0) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
list.customerProductListItems[itemIndex] = response;
|
|
359
|
+
return list;
|
|
360
|
+
})
|
|
361
|
+
}, {
|
|
362
|
+
queryKey: _queryKeyHelpers.getCustomerProductLists.queryKey(parameters),
|
|
363
|
+
updater: createUpdateFunction(result => {
|
|
364
|
+
// Find the list with the current list id.
|
|
365
|
+
const listIndex = result.data.findIndex(({
|
|
366
|
+
id
|
|
367
|
+
}) => id === parameters.listId);
|
|
368
|
+
// Find the index of the item in the list.
|
|
369
|
+
const items = result.data[listIndex].customerProductListItems;
|
|
370
|
+
if (!items) return;
|
|
371
|
+
const itemIndex = items.findIndex(({
|
|
372
|
+
id
|
|
373
|
+
}) => id === parameters.itemId);
|
|
374
|
+
|
|
375
|
+
// Return undefined if item isn't found...
|
|
376
|
+
if (itemIndex === undefined || itemIndex < 0) return;
|
|
377
|
+
|
|
378
|
+
// Update the item in the found list.
|
|
379
|
+
// NOTE: We know that there is an item to update given the item index is > -1
|
|
380
|
+
items[itemIndex] = response;
|
|
381
|
+
return result;
|
|
382
|
+
})
|
|
383
|
+
}]
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
exports.cacheUpdateMatrix = cacheUpdateMatrix;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _mutation = require("./mutation");
|
|
7
|
+
Object.keys(_mutation).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _mutation[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _mutation[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _query = require("./query");
|
|
18
|
+
Object.keys(_query).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _query[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _query[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { ApiClients, Argument, DataType } from '../types';
|
|
2
|
+
import { UseMutationResult } from '@tanstack/react-query';
|
|
3
|
+
declare type Client = ApiClients['shopperCustomers'];
|
|
4
|
+
/** Mutations available for Shopper Customers. */
|
|
5
|
+
export declare const ShopperCustomersMutations: {
|
|
6
|
+
/**
|
|
7
|
+
* Registers a new customer. The mandatory data are the credentials, profile last name, and email. This requires a JSON Web Token (JWT) which needs to be obtained using the POST /customers/auth API with type \"guest\".
|
|
8
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Customers `registerCustomer` endpoint.
|
|
9
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=registerCustomer| Salesforce Developer Center} for more information about the API endpoint.
|
|
10
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#registercustomer | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
11
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
12
|
+
*/
|
|
13
|
+
readonly RegisterCustomer: "registerCustomer";
|
|
14
|
+
/**
|
|
15
|
+
* Reset customer password, after obtaining a reset token. This is the second step in the reset customer password flow, where a customer password is reset by providing the new credentials along with a reset token. This call should be preceded by a call to the /create-reset-token endpoint.
|
|
16
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Customers `resetPassword` endpoint.
|
|
17
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=resetPassword| Salesforce Developer Center} for more information about the API endpoint.
|
|
18
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#resetpassword | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
19
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
20
|
+
*/
|
|
21
|
+
readonly ResetPassword: "resetPassword";
|
|
22
|
+
/**
|
|
23
|
+
* Get reset password token. This is the first step in the reset customer password flow, where a password reset token is requested for future use to reset a customer password. This call should be followed by a call to the /reset endpoint.
|
|
24
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Customers `getResetPasswordToken` endpoint.
|
|
25
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=getResetPasswordToken| Salesforce Developer Center} for more information about the API endpoint.
|
|
26
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#getresetpasswordtoken | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
27
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
28
|
+
*/
|
|
29
|
+
readonly GetResetPasswordToken: "getResetPasswordToken";
|
|
30
|
+
/**
|
|
31
|
+
* Updates a customer.
|
|
32
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Customers `updateCustomer` endpoint.
|
|
33
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=updateCustomer| Salesforce Developer Center} for more information about the API endpoint.
|
|
34
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#updatecustomer | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
35
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
36
|
+
*/
|
|
37
|
+
readonly UpdateCustomer: "updateCustomer";
|
|
38
|
+
/**
|
|
39
|
+
* Creates a new address with the given name for the given customer.
|
|
40
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Customers `createCustomerAddress` endpoint.
|
|
41
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=createCustomerAddress| Salesforce Developer Center} for more information about the API endpoint.
|
|
42
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#createcustomeraddress | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
43
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
44
|
+
*/
|
|
45
|
+
readonly CreateCustomerAddress: "createCustomerAddress";
|
|
46
|
+
/**
|
|
47
|
+
* Deletes a customer's address by address name.
|
|
48
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Customers `removeCustomerAddress` endpoint.
|
|
49
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=removeCustomerAddress| Salesforce Developer Center} for more information about the API endpoint.
|
|
50
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#removecustomeraddress | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
51
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
52
|
+
*/
|
|
53
|
+
readonly RemoveCustomerAddress: "removeCustomerAddress";
|
|
54
|
+
/**
|
|
55
|
+
* Updates a customer's address by address name.
|
|
56
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Customers `updateCustomerAddress` endpoint.
|
|
57
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=updateCustomerAddress| Salesforce Developer Center} for more information about the API endpoint.
|
|
58
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#updatecustomeraddress | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
59
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
60
|
+
*/
|
|
61
|
+
readonly UpdateCustomerAddress: "updateCustomerAddress";
|
|
62
|
+
/**
|
|
63
|
+
* Updates the customer's password.
|
|
64
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Customers `updateCustomerPassword` endpoint.
|
|
65
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=updateCustomerPassword| Salesforce Developer Center} for more information about the API endpoint.
|
|
66
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#updatecustomerpassword | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
67
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
68
|
+
*/
|
|
69
|
+
readonly UpdateCustomerPassword: "updateCustomerPassword";
|
|
70
|
+
/**
|
|
71
|
+
* Adds a payment instrument to the customer information.
|
|
72
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Customers `createCustomerPaymentInstrument` endpoint.
|
|
73
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=createCustomerPaymentInstrument| Salesforce Developer Center} for more information about the API endpoint.
|
|
74
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#createcustomerpaymentinstrument | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
75
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
76
|
+
*/
|
|
77
|
+
readonly CreateCustomerPaymentInstrument: "createCustomerPaymentInstrument";
|
|
78
|
+
/**
|
|
79
|
+
* Deletes a customer's payment instrument.
|
|
80
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Customers `deleteCustomerPaymentInstrument` endpoint.
|
|
81
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=deleteCustomerPaymentInstrument| Salesforce Developer Center} for more information about the API endpoint.
|
|
82
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#deletecustomerpaymentinstrument | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
83
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
84
|
+
*/
|
|
85
|
+
readonly DeleteCustomerPaymentInstrument: "deleteCustomerPaymentInstrument";
|
|
86
|
+
/**
|
|
87
|
+
* Creates a customer product list.
|
|
88
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Customers `createCustomerProductList` endpoint.
|
|
89
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=createCustomerProductList| Salesforce Developer Center} for more information about the API endpoint.
|
|
90
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#createcustomerproductlist | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
91
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
92
|
+
*/
|
|
93
|
+
readonly CreateCustomerProductList: "createCustomerProductList";
|
|
94
|
+
/**
|
|
95
|
+
* Deletes a customer product list.
|
|
96
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Customers `deleteCustomerProductList` endpoint.
|
|
97
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=deleteCustomerProductList| Salesforce Developer Center} for more information about the API endpoint.
|
|
98
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#deletecustomerproductlist | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
99
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
100
|
+
*/
|
|
101
|
+
readonly DeleteCustomerProductList: "deleteCustomerProductList";
|
|
102
|
+
/**
|
|
103
|
+
* Changes a product list. Changeable properties are the name, description, and if the list is public.
|
|
104
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Customers `updateCustomerProductList` endpoint.
|
|
105
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=updateCustomerProductList| Salesforce Developer Center} for more information about the API endpoint.
|
|
106
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#updatecustomerproductlist | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
107
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
108
|
+
*/
|
|
109
|
+
readonly UpdateCustomerProductList: "updateCustomerProductList";
|
|
110
|
+
/**
|
|
111
|
+
* Adds an item to the customer's product list. Considered values from the request body are:
|
|
112
|
+
|
|
113
|
+
type: A valid type, mandatory. This is the type of the item to be added to the customer's product.
|
|
114
|
+
list.
|
|
115
|
+
priority: This is the priority of the item to be added to the customer's product list.
|
|
116
|
+
public: This is the flag whether the item to be added to the customer's product list is public.
|
|
117
|
+
product_id: A valid product ID, used for product item type only. This is the ID (SKU)
|
|
118
|
+
of the product related to the item to be added to the customer's product list. It is mandatory for
|
|
119
|
+
product item type, and it must be a valid product id, otherwise
|
|
120
|
+
ProductListProductIdMissingException or ProductListProductNotFoundException
|
|
121
|
+
will be thrown.
|
|
122
|
+
quantity: Used for product item type only. This is the quantity of the item to be
|
|
123
|
+
added to the customer's product list.
|
|
124
|
+
custom properties in the form c_\<CUSTOM_NAME\>: The custom property must correspond to a custom
|
|
125
|
+
attribute (\<CUSTOM_NAME\>) defined for ProductListItem. The value of this property must be valid for the
|
|
126
|
+
type of custom attribute defined for ProductListItem.
|
|
127
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Customers `createCustomerProductListItem` endpoint.
|
|
128
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=createCustomerProductListItem| Salesforce Developer Center} for more information about the API endpoint.
|
|
129
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#createcustomerproductlistitem | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
130
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
131
|
+
*/
|
|
132
|
+
readonly CreateCustomerProductListItem: "createCustomerProductListItem";
|
|
133
|
+
/**
|
|
134
|
+
* Removes an item from a customer product list.
|
|
135
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Customers `deleteCustomerProductListItem` endpoint.
|
|
136
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=deleteCustomerProductListItem| Salesforce Developer Center} for more information about the API endpoint.
|
|
137
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#deletecustomerproductlistitem | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
138
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
139
|
+
*/
|
|
140
|
+
readonly DeleteCustomerProductListItem: "deleteCustomerProductListItem";
|
|
141
|
+
/**
|
|
142
|
+
* Updates an item of a customer's product list.
|
|
143
|
+
Considered values from the request body are:
|
|
144
|
+
|
|
145
|
+
priority: This is the priority of the customer's product list item.
|
|
146
|
+
public: This is the flag whether the customer's product list item is public.
|
|
147
|
+
quantity: This is the quantity of
|
|
148
|
+
the customer's product list item. Used for product item type only.
|
|
149
|
+
custom properties in the form c_\<CUSTOM_NAME\>: The custom property
|
|
150
|
+
must correspond to a custom attribute (\<CUSTOM_NAME\>) defined for ProductListItem.
|
|
151
|
+
The value of this property must be valid for the type of custom attribute defined for ProductListItem.
|
|
152
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Customers `updateCustomerProductListItem` endpoint.
|
|
153
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=updateCustomerProductListItem| Salesforce Developer Center} for more information about the API endpoint.
|
|
154
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppercustomers.shoppercustomers-1.html#updatecustomerproductlistitem | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
155
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
156
|
+
*/
|
|
157
|
+
readonly UpdateCustomerProductListItem: "updateCustomerProductListItem";
|
|
158
|
+
};
|
|
159
|
+
/** Mutation for Shopper Customers. */
|
|
160
|
+
export declare type ShopperCustomersMutation = (typeof ShopperCustomersMutations)[keyof typeof ShopperCustomersMutations];
|
|
161
|
+
export declare function useShopperCustomersMutation<Mutation extends ShopperCustomersMutation>(mutation: Mutation): UseMutationResult<DataType<Client[Mutation]>, unknown, Argument<Client[Mutation]>>;
|
|
162
|
+
export {};
|
|
163
|
+
//# sourceMappingURL=mutation.d.ts.map
|