@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,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.cacheUpdateMatrix = void 0;
|
|
7
|
+
var _queryKeyHelpers = require("../ShopperCustomers/queryKeyHelpers");
|
|
8
|
+
var _queryKeyHelpers2 = require("./queryKeyHelpers");
|
|
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
|
+
/** Parameters that get passed around, includes client config and possible parameters from other endpoints */
|
|
20
|
+
|
|
21
|
+
const updateOrderQuery = (customerId, {
|
|
22
|
+
parameters
|
|
23
|
+
}) => ({
|
|
24
|
+
update: [{
|
|
25
|
+
queryKey: _queryKeyHelpers2.getOrder.queryKey(parameters)
|
|
26
|
+
}]
|
|
27
|
+
});
|
|
28
|
+
const cacheUpdateMatrix = {
|
|
29
|
+
createOrder(customerId, {
|
|
30
|
+
parameters
|
|
31
|
+
}, response) {
|
|
32
|
+
const {
|
|
33
|
+
orderNo
|
|
34
|
+
} = response;
|
|
35
|
+
const update = !orderNo ? [] : [{
|
|
36
|
+
queryKey: _queryKeyHelpers2.getOrder.queryKey(_objectSpread(_objectSpread({}, parameters), {}, {
|
|
37
|
+
orderNo
|
|
38
|
+
}))
|
|
39
|
+
}];
|
|
40
|
+
const invalidate = !customerId ? [] : [{
|
|
41
|
+
queryKey: _queryKeyHelpers.getCustomerBaskets.queryKey(_objectSpread(_objectSpread({}, parameters), {}, {
|
|
42
|
+
customerId
|
|
43
|
+
}))
|
|
44
|
+
}];
|
|
45
|
+
return {
|
|
46
|
+
update,
|
|
47
|
+
invalidate
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
createPaymentInstrumentForOrder: updateOrderQuery,
|
|
51
|
+
updatePaymentInstrumentForOrder: updateOrderQuery,
|
|
52
|
+
removePaymentInstrumentFromOrder: updateOrderQuery
|
|
53
|
+
};
|
|
54
|
+
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,54 @@
|
|
|
1
|
+
import { ApiClients, Argument, DataType } from '../types';
|
|
2
|
+
import { UseMutationResult } from '@tanstack/react-query';
|
|
3
|
+
declare type Client = ApiClients['shopperOrders'];
|
|
4
|
+
/** Mutations available for Shopper Orders. */
|
|
5
|
+
export declare const ShopperOrdersMutations: {
|
|
6
|
+
/**
|
|
7
|
+
* Submits an order based on a prepared basket. The only considered value from the request body is basketId.
|
|
8
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Orders `createOrder` endpoint.
|
|
9
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-orders?meta=createOrder| Salesforce Developer Center} for more information about the API endpoint.
|
|
10
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperorders.shopperorders-1.html#createorder | `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 CreateOrder: "createOrder";
|
|
14
|
+
/**
|
|
15
|
+
* Adds a payment instrument to an order.
|
|
16
|
+
|
|
17
|
+
Details:
|
|
18
|
+
|
|
19
|
+
The payment instrument is added with the provided details. The payment method must be applicable for the order see GET
|
|
20
|
+
/baskets/\{basketId\}/payment-methods, if the payment method is 'CREDIT_CARD' a paymentCard must be specified in the request.
|
|
21
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Orders `createPaymentInstrumentForOrder` endpoint.
|
|
22
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-orders?meta=createPaymentInstrumentForOrder| Salesforce Developer Center} for more information about the API endpoint.
|
|
23
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperorders.shopperorders-1.html#createpaymentinstrumentfororder | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
24
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
25
|
+
*/
|
|
26
|
+
readonly CreatePaymentInstrumentForOrder: "createPaymentInstrumentForOrder";
|
|
27
|
+
/**
|
|
28
|
+
* Removes a payment instrument of an order.
|
|
29
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Orders `removePaymentInstrumentFromOrder` endpoint.
|
|
30
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-orders?meta=removePaymentInstrumentFromOrder| Salesforce Developer Center} for more information about the API endpoint.
|
|
31
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperorders.shopperorders-1.html#removepaymentinstrumentfromorder | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
32
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
33
|
+
*/
|
|
34
|
+
readonly RemovePaymentInstrumentFromOrder: "removePaymentInstrumentFromOrder";
|
|
35
|
+
/**
|
|
36
|
+
* Updates a payment instrument of an order.
|
|
37
|
+
|
|
38
|
+
Details:
|
|
39
|
+
|
|
40
|
+
The payment instrument is updated with the provided details. The payment method must be applicable for the
|
|
41
|
+
order see GET /baskets/\{basketId\}/payment-methods, if the payment method is 'CREDIT_CARD' a
|
|
42
|
+
paymentCard must be specified in the request.
|
|
43
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Orders `updatePaymentInstrumentForOrder` endpoint.
|
|
44
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-orders?meta=updatePaymentInstrumentForOrder| Salesforce Developer Center} for more information about the API endpoint.
|
|
45
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperorders.shopperorders-1.html#updatepaymentinstrumentfororder | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
46
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
47
|
+
*/
|
|
48
|
+
readonly UpdatePaymentInstrumentForOrder: "updatePaymentInstrumentForOrder";
|
|
49
|
+
};
|
|
50
|
+
/** Mutation for Shopper Orders. */
|
|
51
|
+
export declare type ShopperOrdersMutation = (typeof ShopperOrdersMutations)[keyof typeof ShopperOrdersMutations];
|
|
52
|
+
export declare function useShopperOrdersMutation<Mutation extends ShopperOrdersMutation>(mutation: Mutation): UseMutationResult<DataType<Client[Mutation]>, unknown, Argument<Client[Mutation]>>;
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=mutation.d.ts.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ShopperOrdersMutations = void 0;
|
|
7
|
+
exports.useShopperOrdersMutation = useShopperOrdersMutation;
|
|
8
|
+
var _useMutation = require("../useMutation");
|
|
9
|
+
var _utils = require("../utils");
|
|
10
|
+
var _useCommerceApi = _interopRequireDefault(require("../useCommerceApi"));
|
|
11
|
+
var _cache = require("./cache");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
/*
|
|
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
|
+
|
|
20
|
+
/** Mutations available for Shopper Orders. */
|
|
21
|
+
const ShopperOrdersMutations = {
|
|
22
|
+
/**
|
|
23
|
+
* Submits an order based on a prepared basket. The only considered value from the request body is basketId.
|
|
24
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Orders `createOrder` endpoint.
|
|
25
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-orders?meta=createOrder| Salesforce Developer Center} for more information about the API endpoint.
|
|
26
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperorders.shopperorders-1.html#createorder | `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
|
+
CreateOrder: 'createOrder',
|
|
30
|
+
/**
|
|
31
|
+
* Adds a payment instrument to an order.
|
|
32
|
+
Details:
|
|
33
|
+
The payment instrument is added with the provided details. The payment method must be applicable for the order see GET
|
|
34
|
+
/baskets/\{basketId\}/payment-methods, if the payment method is 'CREDIT_CARD' a paymentCard must be specified in the request.
|
|
35
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Orders `createPaymentInstrumentForOrder` endpoint.
|
|
36
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-orders?meta=createPaymentInstrumentForOrder| Salesforce Developer Center} for more information about the API endpoint.
|
|
37
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperorders.shopperorders-1.html#createpaymentinstrumentfororder | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
38
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
39
|
+
*/
|
|
40
|
+
CreatePaymentInstrumentForOrder: 'createPaymentInstrumentForOrder',
|
|
41
|
+
/**
|
|
42
|
+
* Removes a payment instrument of an order.
|
|
43
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Orders `removePaymentInstrumentFromOrder` endpoint.
|
|
44
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-orders?meta=removePaymentInstrumentFromOrder| Salesforce Developer Center} for more information about the API endpoint.
|
|
45
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperorders.shopperorders-1.html#removepaymentinstrumentfromorder | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
46
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
47
|
+
*/
|
|
48
|
+
RemovePaymentInstrumentFromOrder: 'removePaymentInstrumentFromOrder',
|
|
49
|
+
/**
|
|
50
|
+
* Updates a payment instrument of an order.
|
|
51
|
+
Details:
|
|
52
|
+
The payment instrument is updated with the provided details. The payment method must be applicable for the
|
|
53
|
+
order see GET /baskets/\{basketId\}/payment-methods, if the payment method is 'CREDIT_CARD' a
|
|
54
|
+
paymentCard must be specified in the request.
|
|
55
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Orders `updatePaymentInstrumentForOrder` endpoint.
|
|
56
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-orders?meta=updatePaymentInstrumentForOrder| Salesforce Developer Center} for more information about the API endpoint.
|
|
57
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperorders.shopperorders-1.html#updatepaymentinstrumentfororder | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
58
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useMutation | TanStack Query `useMutation` reference} for more information about the return value.
|
|
59
|
+
*/
|
|
60
|
+
UpdatePaymentInstrumentForOrder: 'updatePaymentInstrumentForOrder'
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/** Mutation for Shopper Orders. */
|
|
64
|
+
exports.ShopperOrdersMutations = ShopperOrdersMutations;
|
|
65
|
+
function useShopperOrdersMutation(mutation) {
|
|
66
|
+
const getCacheUpdates = _cache.cacheUpdateMatrix[mutation];
|
|
67
|
+
// TODO: Remove this check when all mutations are implemented.
|
|
68
|
+
if (!getCacheUpdates) throw new _utils.NotImplementedError(`The '${mutation}' mutation`);
|
|
69
|
+
|
|
70
|
+
// The `Options` and `Data` types for each mutation are similar, but distinct, and the union
|
|
71
|
+
// type generated from `Client[Mutation]` seems to be too complex for TypeScript to handle.
|
|
72
|
+
// I'm not sure if there's a way to avoid the type assertions in here for the methods that
|
|
73
|
+
// use them. However, I'm fairly confident that they are safe to do, as they seem to be simply
|
|
74
|
+
// re-asserting what we already have.
|
|
75
|
+
const {
|
|
76
|
+
shopperOrders: client
|
|
77
|
+
} = (0, _useCommerceApi.default)();
|
|
78
|
+
return (0, _useMutation.useMutation)({
|
|
79
|
+
client,
|
|
80
|
+
method: opts => client[mutation](opts),
|
|
81
|
+
getCacheUpdates: getCacheUpdates
|
|
82
|
+
});
|
|
83
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import { ApiClients, ApiQueryOptions, Argument, DataType, NullableParameters } from '../types';
|
|
3
|
+
declare type Client = ApiClients['shopperOrders'];
|
|
4
|
+
/**
|
|
5
|
+
* Gets information for an order.
|
|
6
|
+
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
7
|
+
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
8
|
+
* @returns A TanStack Query query hook with data from the Shopper Orders `getOrder` endpoint.
|
|
9
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-orders?meta=getOrder| Salesforce Developer Center} for more information about the API endpoint.
|
|
10
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperorders.shopperorders-1.html#getorder | `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/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
|
|
12
|
+
*/
|
|
13
|
+
export declare const useOrder: (apiOptions: NullableParameters<Argument<Client['getOrder']>>, queryOptions?: ApiQueryOptions<Client['getOrder']>) => UseQueryResult<DataType<Client['getOrder']>>;
|
|
14
|
+
/**
|
|
15
|
+
* Gets the applicable payment methods for an existing order considering the open payment amount only.
|
|
16
|
+
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
17
|
+
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
18
|
+
* @returns A TanStack Query query hook with data from the Shopper Orders `getPaymentMethodsForOrder` endpoint.
|
|
19
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-orders?meta=getPaymentMethodsForOrder| Salesforce Developer Center} for more information about the API endpoint.
|
|
20
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperorders.shopperorders-1.html#getpaymentmethodsfororder | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
21
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
|
|
22
|
+
*/
|
|
23
|
+
export declare const usePaymentMethodsForOrder: (apiOptions: NullableParameters<Argument<Client['getPaymentMethodsForOrder']>>, queryOptions?: ApiQueryOptions<Client['getPaymentMethodsForOrder']>) => UseQueryResult<DataType<Client['getPaymentMethodsForOrder']>>;
|
|
24
|
+
/**
|
|
25
|
+
* This method gives you the external taxation data of the order transferred from the basket during
|
|
26
|
+
order creation. This endpoint can be called only if external taxation was used. See POST /baskets
|
|
27
|
+
for more information.
|
|
28
|
+
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
29
|
+
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
30
|
+
* @returns A TanStack Query query hook with data from the Shopper Orders `getTaxesFromOrder` endpoint.
|
|
31
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-orders?meta=getTaxesFromOrder| Salesforce Developer Center} for more information about the API endpoint.
|
|
32
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperorders.shopperorders-1.html#gettaxesfromorder | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
33
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
|
|
34
|
+
*/
|
|
35
|
+
export declare const useTaxesFromOrder: (apiOptions: NullableParameters<Argument<Client['getTaxesFromOrder']>>, queryOptions?: ApiQueryOptions<Client['getTaxesFromOrder']>) => UseQueryResult<DataType<Client['getTaxesFromOrder']>>;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useTaxesFromOrder = exports.usePaymentMethodsForOrder = exports.useOrder = 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
|
+
/**
|
|
22
|
+
* Gets information for an order.
|
|
23
|
+
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
24
|
+
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
25
|
+
* @returns A TanStack Query query hook with data from the Shopper Orders `getOrder` endpoint.
|
|
26
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-orders?meta=getOrder| Salesforce Developer Center} for more information about the API endpoint.
|
|
27
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperorders.shopperorders-1.html#getorder | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
28
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
|
|
29
|
+
*/
|
|
30
|
+
const useOrder = (apiOptions, queryOptions = {}) => {
|
|
31
|
+
const {
|
|
32
|
+
shopperOrders: client
|
|
33
|
+
} = (0, _useCommerceApi.default)();
|
|
34
|
+
const methodName = 'getOrder';
|
|
35
|
+
const requiredParameters = ['organizationId', 'orderNo', 'siteId'];
|
|
36
|
+
|
|
37
|
+
// Parameters can be set in `apiOptions` or `client.clientConfig`;
|
|
38
|
+
// we must merge them in order to generate the correct query key.
|
|
39
|
+
const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
|
|
40
|
+
const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
|
|
41
|
+
// We don't use `netOptions` here because we manipulate the options in `useQuery`.
|
|
42
|
+
const method = /*#__PURE__*/function () {
|
|
43
|
+
var _ref = _asyncToGenerator(function* (options) {
|
|
44
|
+
return yield client[methodName](options);
|
|
45
|
+
});
|
|
46
|
+
return function method(_x) {
|
|
47
|
+
return _ref.apply(this, arguments);
|
|
48
|
+
};
|
|
49
|
+
}();
|
|
50
|
+
|
|
51
|
+
// For some reason, if we don't explicitly set these generic parameters, the inferred type for
|
|
52
|
+
// `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
|
|
53
|
+
return (0, _useQuery.useQuery)(netOptions, queryOptions, {
|
|
54
|
+
method,
|
|
55
|
+
queryKey,
|
|
56
|
+
requiredParameters
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Gets the applicable payment methods for an existing order considering the open payment amount only.
|
|
61
|
+
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
62
|
+
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
63
|
+
* @returns A TanStack Query query hook with data from the Shopper Orders `getPaymentMethodsForOrder` endpoint.
|
|
64
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-orders?meta=getPaymentMethodsForOrder| Salesforce Developer Center} for more information about the API endpoint.
|
|
65
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperorders.shopperorders-1.html#getpaymentmethodsfororder | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
66
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
|
|
67
|
+
*/
|
|
68
|
+
exports.useOrder = useOrder;
|
|
69
|
+
const usePaymentMethodsForOrder = (apiOptions, queryOptions = {}) => {
|
|
70
|
+
const {
|
|
71
|
+
shopperOrders: client
|
|
72
|
+
} = (0, _useCommerceApi.default)();
|
|
73
|
+
const methodName = 'getPaymentMethodsForOrder';
|
|
74
|
+
const requiredParameters = ['organizationId', 'orderNo', 'siteId'];
|
|
75
|
+
|
|
76
|
+
// Parameters can be set in `apiOptions` or `client.clientConfig`;
|
|
77
|
+
// we must merge them in order to generate the correct query key.
|
|
78
|
+
const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
|
|
79
|
+
const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
|
|
80
|
+
// We don't use `netOptions` here because we manipulate the options in `useQuery`.
|
|
81
|
+
const method = /*#__PURE__*/function () {
|
|
82
|
+
var _ref2 = _asyncToGenerator(function* (options) {
|
|
83
|
+
return yield client[methodName](options);
|
|
84
|
+
});
|
|
85
|
+
return function method(_x2) {
|
|
86
|
+
return _ref2.apply(this, arguments);
|
|
87
|
+
};
|
|
88
|
+
}();
|
|
89
|
+
|
|
90
|
+
// For some reason, if we don't explicitly set these generic parameters, the inferred type for
|
|
91
|
+
// `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
|
|
92
|
+
return (0, _useQuery.useQuery)(netOptions, queryOptions, {
|
|
93
|
+
method,
|
|
94
|
+
queryKey,
|
|
95
|
+
requiredParameters
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* This method gives you the external taxation data of the order transferred from the basket during
|
|
100
|
+
order creation. This endpoint can be called only if external taxation was used. See POST /baskets
|
|
101
|
+
for more information.
|
|
102
|
+
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
103
|
+
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
104
|
+
* @returns A TanStack Query query hook with data from the Shopper Orders `getTaxesFromOrder` endpoint.
|
|
105
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-orders?meta=getTaxesFromOrder| Salesforce Developer Center} for more information about the API endpoint.
|
|
106
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperorders.shopperorders-1.html#gettaxesfromorder | `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/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
|
|
108
|
+
*/
|
|
109
|
+
exports.usePaymentMethodsForOrder = usePaymentMethodsForOrder;
|
|
110
|
+
const useTaxesFromOrder = (apiOptions, queryOptions = {}) => {
|
|
111
|
+
const {
|
|
112
|
+
shopperOrders: client
|
|
113
|
+
} = (0, _useCommerceApi.default)();
|
|
114
|
+
const methodName = 'getTaxesFromOrder';
|
|
115
|
+
const requiredParameters = ['organizationId', 'orderNo', 'siteId'];
|
|
116
|
+
|
|
117
|
+
// Parameters can be set in `apiOptions` or `client.clientConfig`;
|
|
118
|
+
// we must merge them in order to generate the correct query key.
|
|
119
|
+
const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
|
|
120
|
+
const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
|
|
121
|
+
// We don't use `netOptions` here because we manipulate the options in `useQuery`.
|
|
122
|
+
const method = /*#__PURE__*/function () {
|
|
123
|
+
var _ref3 = _asyncToGenerator(function* (options) {
|
|
124
|
+
return yield client[methodName](options);
|
|
125
|
+
});
|
|
126
|
+
return function method(_x3) {
|
|
127
|
+
return _ref3.apply(this, arguments);
|
|
128
|
+
};
|
|
129
|
+
}();
|
|
130
|
+
|
|
131
|
+
// For some reason, if we don't explicitly set these generic parameters, the inferred type for
|
|
132
|
+
// `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
|
|
133
|
+
return (0, _useQuery.useQuery)(netOptions, queryOptions, {
|
|
134
|
+
method,
|
|
135
|
+
queryKey,
|
|
136
|
+
requiredParameters
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
exports.useTaxesFromOrder = useTaxesFromOrder;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ShopperOrders } from 'commerce-sdk-isomorphic';
|
|
2
|
+
import { Argument, ExcludeTail } from '../types';
|
|
3
|
+
declare type Client = ShopperOrders<{
|
|
4
|
+
shortCode: string;
|
|
5
|
+
}>;
|
|
6
|
+
declare type Params<T extends keyof QueryKeys> = Partial<Argument<Client[T]>['parameters']>;
|
|
7
|
+
export declare type QueryKeys = {
|
|
8
|
+
getOrder: [
|
|
9
|
+
'/commerce-sdk-react',
|
|
10
|
+
'/organizations/',
|
|
11
|
+
string | undefined,
|
|
12
|
+
'/orders/',
|
|
13
|
+
string | undefined,
|
|
14
|
+
Params<'getOrder'>
|
|
15
|
+
];
|
|
16
|
+
getPaymentMethodsForOrder: [
|
|
17
|
+
'/commerce-sdk-react',
|
|
18
|
+
'/organizations/',
|
|
19
|
+
string | undefined,
|
|
20
|
+
'/orders/',
|
|
21
|
+
string | undefined,
|
|
22
|
+
'/payment-methods',
|
|
23
|
+
Params<'getPaymentMethodsForOrder'>
|
|
24
|
+
];
|
|
25
|
+
getTaxesFromOrder: [
|
|
26
|
+
'/commerce-sdk-react',
|
|
27
|
+
'/organizations/',
|
|
28
|
+
string | undefined,
|
|
29
|
+
'/orders/',
|
|
30
|
+
string | undefined,
|
|
31
|
+
'/taxes',
|
|
32
|
+
Params<'getTaxesFromOrder'>
|
|
33
|
+
];
|
|
34
|
+
};
|
|
35
|
+
declare type QueryKeyHelper<T extends keyof QueryKeys> = {
|
|
36
|
+
/**
|
|
37
|
+
* Reduces the given parameters (which may have additional, unknown properties) to an object
|
|
38
|
+
* containing *only* the properties required for an endpoint.
|
|
39
|
+
*/
|
|
40
|
+
parameters: (params: Params<T>) => Params<T>;
|
|
41
|
+
/** Generates the path component of the query key for an endpoint. */
|
|
42
|
+
path: (params: Params<T>) => ExcludeTail<QueryKeys[T]>;
|
|
43
|
+
/** Generates the full query key for an endpoint. */
|
|
44
|
+
queryKey: (params: Params<T>) => QueryKeys[T];
|
|
45
|
+
};
|
|
46
|
+
export declare const getOrder: QueryKeyHelper<'getOrder'>;
|
|
47
|
+
export declare const getPaymentMethodsForOrder: QueryKeyHelper<'getPaymentMethodsForOrder'>;
|
|
48
|
+
export declare const getTaxesFromOrder: QueryKeyHelper<'getTaxesFromOrder'>;
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=queryKeyHelpers.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getTaxesFromOrder = exports.getPaymentMethodsForOrder = exports.getOrder = 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 getOrder = {
|
|
21
|
+
parameters: params => (0, _utils.pick)(params, ['organizationId', 'orderNo', 'siteId', 'locale']),
|
|
22
|
+
path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/orders/', params.orderNo],
|
|
23
|
+
queryKey: params => [...getOrder.path(params), getOrder.parameters(params)]
|
|
24
|
+
};
|
|
25
|
+
exports.getOrder = getOrder;
|
|
26
|
+
const getPaymentMethodsForOrder = {
|
|
27
|
+
parameters: params => (0, _utils.pick)(params, ['organizationId', 'orderNo', 'siteId', 'locale']),
|
|
28
|
+
path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/orders/', params.orderNo, '/payment-methods'],
|
|
29
|
+
queryKey: params => [...getPaymentMethodsForOrder.path(params), getPaymentMethodsForOrder.parameters(params)]
|
|
30
|
+
};
|
|
31
|
+
exports.getPaymentMethodsForOrder = getPaymentMethodsForOrder;
|
|
32
|
+
const getTaxesFromOrder = {
|
|
33
|
+
parameters: params => (0, _utils.pick)(params, ['organizationId', 'orderNo', 'siteId']),
|
|
34
|
+
path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/orders/', params.orderNo, '/taxes'],
|
|
35
|
+
queryKey: params => [...getTaxesFromOrder.path(params), getTaxesFromOrder.parameters(params)]
|
|
36
|
+
};
|
|
37
|
+
exports.getTaxesFromOrder = getTaxesFromOrder;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _query = require("./query");
|
|
7
|
+
Object.keys(_query).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _query[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _query[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import { ApiClients, ApiQueryOptions, Argument, DataType, NullableParameters } from '../types';
|
|
3
|
+
declare type Client = ApiClients['shopperProducts'];
|
|
4
|
+
/**
|
|
5
|
+
* Allows access to multiple products by a single request. Only products that are online and assigned to a site catalog are returned. The maximum number of productIDs that can be requested are 24. Along with product details, the availability, product options, images, price, promotions, and variations for the valid products will be included, as appropriate.
|
|
6
|
+
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
7
|
+
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
8
|
+
* @returns A TanStack Query query hook with data from the Shopper Products `getProducts` endpoint.
|
|
9
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-products?meta=getProducts| Salesforce Developer Center} for more information about the API endpoint.
|
|
10
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperproducts.shopperproducts-1.html#getproducts | `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/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
|
|
12
|
+
*/
|
|
13
|
+
export declare const useProducts: (apiOptions: NullableParameters<Argument<Client['getProducts']>>, queryOptions?: ApiQueryOptions<Client['getProducts']>) => UseQueryResult<DataType<Client['getProducts']>>;
|
|
14
|
+
/**
|
|
15
|
+
* Allows access to product details for a single product ID. Only products that are online and assigned to a site catalog are returned. Along with product details, the availability, images, price, bundled_products, set_products, recommedations, product options, variations, and promotions for the products will be included, as appropriate.
|
|
16
|
+
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
17
|
+
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
18
|
+
* @returns A TanStack Query query hook with data from the Shopper Products `getProduct` endpoint.
|
|
19
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-products?meta=getProduct| Salesforce Developer Center} for more information about the API endpoint.
|
|
20
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperproducts.shopperproducts-1.html#getproduct | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
21
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
|
|
22
|
+
*/
|
|
23
|
+
export declare const useProduct: (apiOptions: NullableParameters<Argument<Client['getProduct']>>, queryOptions?: ApiQueryOptions<Client['getProduct']>) => UseQueryResult<DataType<Client['getProduct']>>;
|
|
24
|
+
/**
|
|
25
|
+
* When you use the URL template, the server returns multiple categories (a result object of category documents). You can use this template as a convenient way of obtaining multiple categories in a single request, instead of issuing separate requests for each category. You can specify up to 50 multiple IDs. You must enclose the list of IDs in parentheses. If a category identifier contains parenthesis or the separator sign, you must URL encode the character. The server only returns online categories.
|
|
26
|
+
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
27
|
+
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
28
|
+
* @returns A TanStack Query query hook with data from the Shopper Products `getCategories` endpoint.
|
|
29
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-products?meta=getCategories| Salesforce Developer Center} for more information about the API endpoint.
|
|
30
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperproducts.shopperproducts-1.html#getcategories | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
31
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
|
|
32
|
+
*/
|
|
33
|
+
export declare const useCategories: (apiOptions: NullableParameters<Argument<Client['getCategories']>>, queryOptions?: ApiQueryOptions<Client['getCategories']>) => UseQueryResult<DataType<Client['getCategories']>>;
|
|
34
|
+
/**
|
|
35
|
+
* When you use the URL template below, the server returns a category identified by its ID; by default, the server
|
|
36
|
+
also returns the first level of subcategories, but you can specify another level by setting the levels
|
|
37
|
+
parameter. The server only returns online categories.
|
|
38
|
+
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
39
|
+
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
40
|
+
* @returns A TanStack Query query hook with data from the Shopper Products `getCategory` endpoint.
|
|
41
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-products?meta=getCategory| Salesforce Developer Center} for more information about the API endpoint.
|
|
42
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperproducts.shopperproducts-1.html#getcategory | `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/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
|
|
44
|
+
*/
|
|
45
|
+
export declare const useCategory: (apiOptions: NullableParameters<Argument<Client['getCategory']>>, queryOptions?: ApiQueryOptions<Client['getCategory']>) => UseQueryResult<DataType<Client['getCategory']>>;
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=query.d.ts.map
|