@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,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useSearchSuggestions = exports.useProductSearch = 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
|
+
* Provides keyword and refinement search functionality for products. Only returns the product ID, link, and name in
|
|
23
|
+
the product search hit. The search result contains only products that are online and assigned to site catalog.
|
|
24
|
+
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
25
|
+
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
26
|
+
* @returns A TanStack Query query hook with data from the Shopper Search `productSearch` endpoint.
|
|
27
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-search?meta=productSearch| Salesforce Developer Center} for more information about the API endpoint.
|
|
28
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppersearch.shoppersearch-1.html#productsearch | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
|
|
29
|
+
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
|
|
30
|
+
*/
|
|
31
|
+
const useProductSearch = (apiOptions, queryOptions = {}) => {
|
|
32
|
+
const {
|
|
33
|
+
shopperSearch: client
|
|
34
|
+
} = (0, _useCommerceApi.default)();
|
|
35
|
+
const methodName = 'productSearch';
|
|
36
|
+
const requiredParameters = ['organizationId', 'siteId'];
|
|
37
|
+
|
|
38
|
+
// Parameters can be set in `apiOptions` or `client.clientConfig`;
|
|
39
|
+
// we must merge them in order to generate the correct query key.
|
|
40
|
+
const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
|
|
41
|
+
const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
|
|
42
|
+
// We don't use `netOptions` here because we manipulate the options in `useQuery`.
|
|
43
|
+
const method = /*#__PURE__*/function () {
|
|
44
|
+
var _ref = _asyncToGenerator(function* (options) {
|
|
45
|
+
return yield client[methodName](options);
|
|
46
|
+
});
|
|
47
|
+
return function method(_x) {
|
|
48
|
+
return _ref.apply(this, arguments);
|
|
49
|
+
};
|
|
50
|
+
}();
|
|
51
|
+
|
|
52
|
+
// For some reason, if we don't explicitly set these generic parameters, the inferred type for
|
|
53
|
+
// `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
|
|
54
|
+
return (0, _useQuery.useQuery)(netOptions, queryOptions, {
|
|
55
|
+
method,
|
|
56
|
+
queryKey,
|
|
57
|
+
requiredParameters
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Provides keyword search functionality for products, categories, and brands suggestions. Returns suggested products, suggested categories, and suggested brands for the given search phrase.
|
|
62
|
+
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
63
|
+
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
64
|
+
* @returns A TanStack Query query hook with data from the Shopper Search `getSearchSuggestions` endpoint.
|
|
65
|
+
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-search?meta=getSearchSuggestions| Salesforce Developer Center} for more information about the API endpoint.
|
|
66
|
+
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shoppersearch.shoppersearch-1.html#getsearchsuggestions | `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/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
|
|
68
|
+
*/
|
|
69
|
+
exports.useProductSearch = useProductSearch;
|
|
70
|
+
const useSearchSuggestions = (apiOptions, queryOptions = {}) => {
|
|
71
|
+
const {
|
|
72
|
+
shopperSearch: client
|
|
73
|
+
} = (0, _useCommerceApi.default)();
|
|
74
|
+
const methodName = 'getSearchSuggestions';
|
|
75
|
+
const requiredParameters = ['organizationId', 'siteId', 'q'];
|
|
76
|
+
|
|
77
|
+
// Parameters can be set in `apiOptions` or `client.clientConfig`;
|
|
78
|
+
// we must merge them in order to generate the correct query key.
|
|
79
|
+
const netOptions = (0, _utils.omitNullableParameters)((0, _utils.mergeOptions)(client, apiOptions));
|
|
80
|
+
const queryKey = queryKeyHelpers[methodName].queryKey(netOptions.parameters);
|
|
81
|
+
// We don't use `netOptions` here because we manipulate the options in `useQuery`.
|
|
82
|
+
const method = /*#__PURE__*/function () {
|
|
83
|
+
var _ref2 = _asyncToGenerator(function* (options) {
|
|
84
|
+
return yield client[methodName](options);
|
|
85
|
+
});
|
|
86
|
+
return function method(_x2) {
|
|
87
|
+
return _ref2.apply(this, arguments);
|
|
88
|
+
};
|
|
89
|
+
}();
|
|
90
|
+
|
|
91
|
+
// For some reason, if we don't explicitly set these generic parameters, the inferred type for
|
|
92
|
+
// `Data` sometimes, but not always, includes `Response`, which is incorrect. I don't know why.
|
|
93
|
+
return (0, _useQuery.useQuery)(netOptions, queryOptions, {
|
|
94
|
+
method,
|
|
95
|
+
queryKey,
|
|
96
|
+
requiredParameters
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
exports.useSearchSuggestions = useSearchSuggestions;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ShopperSearch } from 'commerce-sdk-isomorphic';
|
|
2
|
+
import { Argument, ExcludeTail } from '../types';
|
|
3
|
+
declare type Client = ShopperSearch<{
|
|
4
|
+
shortCode: string;
|
|
5
|
+
}>;
|
|
6
|
+
declare type Params<T extends keyof QueryKeys> = Partial<Argument<Client[T]>['parameters']>;
|
|
7
|
+
export declare type QueryKeys = {
|
|
8
|
+
productSearch: [
|
|
9
|
+
'/commerce-sdk-react',
|
|
10
|
+
'/organizations/',
|
|
11
|
+
string | undefined,
|
|
12
|
+
'/product-search',
|
|
13
|
+
Params<'productSearch'>
|
|
14
|
+
];
|
|
15
|
+
getSearchSuggestions: [
|
|
16
|
+
'/commerce-sdk-react',
|
|
17
|
+
'/organizations/',
|
|
18
|
+
string | undefined,
|
|
19
|
+
'/search-suggestions',
|
|
20
|
+
Params<'getSearchSuggestions'>
|
|
21
|
+
];
|
|
22
|
+
};
|
|
23
|
+
declare type QueryKeyHelper<T extends keyof QueryKeys> = {
|
|
24
|
+
/**
|
|
25
|
+
* Reduces the given parameters (which may have additional, unknown properties) to an object
|
|
26
|
+
* containing *only* the properties required for an endpoint.
|
|
27
|
+
*/
|
|
28
|
+
parameters: (params: Params<T>) => Params<T>;
|
|
29
|
+
/** Generates the path component of the query key for an endpoint. */
|
|
30
|
+
path: (params: Params<T>) => ExcludeTail<QueryKeys[T]>;
|
|
31
|
+
/** Generates the full query key for an endpoint. */
|
|
32
|
+
queryKey: (params: Params<T>) => QueryKeys[T];
|
|
33
|
+
};
|
|
34
|
+
export declare const productSearch: QueryKeyHelper<'productSearch'>;
|
|
35
|
+
export declare const getSearchSuggestions: QueryKeyHelper<'getSearchSuggestions'>;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=queryKeyHelpers.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.productSearch = exports.getSearchSuggestions = 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 productSearch = {
|
|
21
|
+
parameters: params => (0, _utils.pick)(params, ['organizationId', 'siteId', 'q', 'refine', 'sort', 'currency', 'locale', 'expand', 'offset', 'limit']),
|
|
22
|
+
path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/product-search'],
|
|
23
|
+
queryKey: params => [...productSearch.path(params), productSearch.parameters(params)]
|
|
24
|
+
};
|
|
25
|
+
exports.productSearch = productSearch;
|
|
26
|
+
const getSearchSuggestions = {
|
|
27
|
+
parameters: params => (0, _utils.pick)(params, ['organizationId', 'siteId', 'q', 'limit', 'currency', 'locale']),
|
|
28
|
+
path: params => ['/commerce-sdk-react', '/organizations/', params.organizationId, '/search-suggestions'],
|
|
29
|
+
queryKey: params => [...getSearchSuggestions.path(params), getSearchSuggestions.parameters(params)]
|
|
30
|
+
};
|
|
31
|
+
exports.getSearchSuggestions = getSearchSuggestions;
|
package/hooks/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from './ShopperBaskets';
|
|
2
|
+
export * from './ShopperContexts';
|
|
3
|
+
export * from './ShopperCustomers';
|
|
4
|
+
export * from './ShopperExperience';
|
|
5
|
+
export * from './ShopperGiftCertificates';
|
|
6
|
+
export * from './ShopperLogin';
|
|
7
|
+
export * from './ShopperOrders';
|
|
8
|
+
export * from './ShopperProducts';
|
|
9
|
+
export * from './ShopperPromotions';
|
|
10
|
+
export * from './ShopperSearch';
|
|
11
|
+
export * from './useAuthHelper';
|
|
12
|
+
export { default as useAccessToken } from './useAccessToken';
|
|
13
|
+
export { default as useCommerceApi } from './useCommerceApi';
|
|
14
|
+
export { default as useEncUserId } from './useEncUserId';
|
|
15
|
+
export { default as useUsid } from './useUsid';
|
|
16
|
+
export { default as useCustomerId } from './useCustomerId';
|
|
17
|
+
export { default as useCustomerType } from './useCustomerType';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
package/hooks/index.js
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
useAccessToken: true,
|
|
8
|
+
useCommerceApi: true,
|
|
9
|
+
useEncUserId: true,
|
|
10
|
+
useUsid: true,
|
|
11
|
+
useCustomerId: true,
|
|
12
|
+
useCustomerType: true
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "useAccessToken", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () {
|
|
17
|
+
return _useAccessToken.default;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "useCommerceApi", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () {
|
|
23
|
+
return _useCommerceApi.default;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports, "useCustomerId", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () {
|
|
29
|
+
return _useCustomerId.default;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports, "useCustomerType", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _useCustomerType.default;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(exports, "useEncUserId", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () {
|
|
41
|
+
return _useEncUserId.default;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(exports, "useUsid", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function () {
|
|
47
|
+
return _useUsid.default;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
var _ShopperBaskets = require("./ShopperBaskets");
|
|
51
|
+
Object.keys(_ShopperBaskets).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
54
|
+
if (key in exports && exports[key] === _ShopperBaskets[key]) return;
|
|
55
|
+
Object.defineProperty(exports, key, {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function () {
|
|
58
|
+
return _ShopperBaskets[key];
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
var _ShopperContexts = require("./ShopperContexts");
|
|
63
|
+
Object.keys(_ShopperContexts).forEach(function (key) {
|
|
64
|
+
if (key === "default" || key === "__esModule") return;
|
|
65
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
66
|
+
if (key in exports && exports[key] === _ShopperContexts[key]) return;
|
|
67
|
+
Object.defineProperty(exports, key, {
|
|
68
|
+
enumerable: true,
|
|
69
|
+
get: function () {
|
|
70
|
+
return _ShopperContexts[key];
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
var _ShopperCustomers = require("./ShopperCustomers");
|
|
75
|
+
Object.keys(_ShopperCustomers).forEach(function (key) {
|
|
76
|
+
if (key === "default" || key === "__esModule") return;
|
|
77
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
78
|
+
if (key in exports && exports[key] === _ShopperCustomers[key]) return;
|
|
79
|
+
Object.defineProperty(exports, key, {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
get: function () {
|
|
82
|
+
return _ShopperCustomers[key];
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
var _ShopperExperience = require("./ShopperExperience");
|
|
87
|
+
Object.keys(_ShopperExperience).forEach(function (key) {
|
|
88
|
+
if (key === "default" || key === "__esModule") return;
|
|
89
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
90
|
+
if (key in exports && exports[key] === _ShopperExperience[key]) return;
|
|
91
|
+
Object.defineProperty(exports, key, {
|
|
92
|
+
enumerable: true,
|
|
93
|
+
get: function () {
|
|
94
|
+
return _ShopperExperience[key];
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
var _ShopperGiftCertificates = require("./ShopperGiftCertificates");
|
|
99
|
+
Object.keys(_ShopperGiftCertificates).forEach(function (key) {
|
|
100
|
+
if (key === "default" || key === "__esModule") return;
|
|
101
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
102
|
+
if (key in exports && exports[key] === _ShopperGiftCertificates[key]) return;
|
|
103
|
+
Object.defineProperty(exports, key, {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
get: function () {
|
|
106
|
+
return _ShopperGiftCertificates[key];
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
var _ShopperLogin = require("./ShopperLogin");
|
|
111
|
+
Object.keys(_ShopperLogin).forEach(function (key) {
|
|
112
|
+
if (key === "default" || key === "__esModule") return;
|
|
113
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
114
|
+
if (key in exports && exports[key] === _ShopperLogin[key]) return;
|
|
115
|
+
Object.defineProperty(exports, key, {
|
|
116
|
+
enumerable: true,
|
|
117
|
+
get: function () {
|
|
118
|
+
return _ShopperLogin[key];
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
var _ShopperOrders = require("./ShopperOrders");
|
|
123
|
+
Object.keys(_ShopperOrders).forEach(function (key) {
|
|
124
|
+
if (key === "default" || key === "__esModule") return;
|
|
125
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
126
|
+
if (key in exports && exports[key] === _ShopperOrders[key]) return;
|
|
127
|
+
Object.defineProperty(exports, key, {
|
|
128
|
+
enumerable: true,
|
|
129
|
+
get: function () {
|
|
130
|
+
return _ShopperOrders[key];
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
var _ShopperProducts = require("./ShopperProducts");
|
|
135
|
+
Object.keys(_ShopperProducts).forEach(function (key) {
|
|
136
|
+
if (key === "default" || key === "__esModule") return;
|
|
137
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
138
|
+
if (key in exports && exports[key] === _ShopperProducts[key]) return;
|
|
139
|
+
Object.defineProperty(exports, key, {
|
|
140
|
+
enumerable: true,
|
|
141
|
+
get: function () {
|
|
142
|
+
return _ShopperProducts[key];
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
var _ShopperPromotions = require("./ShopperPromotions");
|
|
147
|
+
Object.keys(_ShopperPromotions).forEach(function (key) {
|
|
148
|
+
if (key === "default" || key === "__esModule") return;
|
|
149
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
150
|
+
if (key in exports && exports[key] === _ShopperPromotions[key]) return;
|
|
151
|
+
Object.defineProperty(exports, key, {
|
|
152
|
+
enumerable: true,
|
|
153
|
+
get: function () {
|
|
154
|
+
return _ShopperPromotions[key];
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
var _ShopperSearch = require("./ShopperSearch");
|
|
159
|
+
Object.keys(_ShopperSearch).forEach(function (key) {
|
|
160
|
+
if (key === "default" || key === "__esModule") return;
|
|
161
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
162
|
+
if (key in exports && exports[key] === _ShopperSearch[key]) return;
|
|
163
|
+
Object.defineProperty(exports, key, {
|
|
164
|
+
enumerable: true,
|
|
165
|
+
get: function () {
|
|
166
|
+
return _ShopperSearch[key];
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
var _useAuthHelper = require("./useAuthHelper");
|
|
171
|
+
Object.keys(_useAuthHelper).forEach(function (key) {
|
|
172
|
+
if (key === "default" || key === "__esModule") return;
|
|
173
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
174
|
+
if (key in exports && exports[key] === _useAuthHelper[key]) return;
|
|
175
|
+
Object.defineProperty(exports, key, {
|
|
176
|
+
enumerable: true,
|
|
177
|
+
get: function () {
|
|
178
|
+
return _useAuthHelper[key];
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
var _useAccessToken = _interopRequireDefault(require("./useAccessToken"));
|
|
183
|
+
var _useCommerceApi = _interopRequireDefault(require("./useCommerceApi"));
|
|
184
|
+
var _useEncUserId = _interopRequireDefault(require("./useEncUserId"));
|
|
185
|
+
var _useUsid = _interopRequireDefault(require("./useUsid"));
|
|
186
|
+
var _useCustomerId = _interopRequireDefault(require("./useCustomerId"));
|
|
187
|
+
var _useCustomerType = _interopRequireDefault(require("./useCustomerType"));
|
|
188
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/hooks/types.d.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { InvalidateQueryFilters, QueryFilters, Updater, UseQueryOptions } from '@tanstack/react-query';
|
|
2
|
+
import { ShopperBaskets, ShopperContexts, ShopperCustomers, ShopperExperience, ShopperGiftCertificates, ShopperLogin, ShopperOrders, ShopperProducts, ShopperPromotions, ShopperSearch } from 'commerce-sdk-isomorphic';
|
|
3
|
+
/** Makes a type easier to read. */
|
|
4
|
+
export declare type Prettify<T extends object> = NonNullable<Pick<T, keyof T>>;
|
|
5
|
+
/**
|
|
6
|
+
* Marks the given keys as required.
|
|
7
|
+
* WARNING: Does not work if T has an index signature.
|
|
8
|
+
*/
|
|
9
|
+
export declare type RequireKeys<T, K extends keyof T> = Prettify<T & Required<Pick<T, K>>>;
|
|
10
|
+
/** Removes keys whose value is `never`. */
|
|
11
|
+
declare type RemoveNeverValues<T> = {
|
|
12
|
+
[K in keyof T as T[K] extends never ? never : K]: T[K];
|
|
13
|
+
};
|
|
14
|
+
/** Change string index type to `never`. */
|
|
15
|
+
declare type StringIndexToNever<T> = {
|
|
16
|
+
[K in keyof T]: string extends K ? never : T[K];
|
|
17
|
+
};
|
|
18
|
+
/** Removes a string index type. */
|
|
19
|
+
export declare type RemoveStringIndex<T> = RemoveNeverValues<StringIndexToNever<T>>;
|
|
20
|
+
/** Gets the last element of an array. */
|
|
21
|
+
export declare type Tail<T extends readonly unknown[]> = T extends [...head: unknown[], tail: infer Tail] ? Tail : T;
|
|
22
|
+
/** Remove the last entry from a tuple type. */
|
|
23
|
+
export declare type ExcludeTail<T extends readonly unknown[]> = T extends readonly [...infer Head, unknown] ? T extends unknown[] ? Head : Readonly<Head> : T;
|
|
24
|
+
/** Adds `null` as an allowed value to all properties. */
|
|
25
|
+
declare type AllowNull<T> = {
|
|
26
|
+
[K in keyof T]: T[K] | null;
|
|
27
|
+
};
|
|
28
|
+
/** Gets the keys of `T` which allow `null` as a possible value. */
|
|
29
|
+
declare type NullKeys<T> = {
|
|
30
|
+
[K in keyof T]-?: null extends T[K] ? K : never;
|
|
31
|
+
}[keyof T];
|
|
32
|
+
/** Removes `null` values and marks those properties as optional. */
|
|
33
|
+
export declare type NullToOptional<T> = Omit<T, NullKeys<T>> & {
|
|
34
|
+
[K in keyof T]?: NonNullable<T[K]>;
|
|
35
|
+
};
|
|
36
|
+
export declare type ApiClientConfigParams = {
|
|
37
|
+
clientId: string;
|
|
38
|
+
organizationId: string;
|
|
39
|
+
siteId: string;
|
|
40
|
+
shortCode: string;
|
|
41
|
+
locale?: string;
|
|
42
|
+
currency?: string;
|
|
43
|
+
};
|
|
44
|
+
export interface ApiClients {
|
|
45
|
+
shopperBaskets: ShopperBaskets<ApiClientConfigParams>;
|
|
46
|
+
shopperContexts: ShopperContexts<ApiClientConfigParams>;
|
|
47
|
+
shopperCustomers: ShopperCustomers<ApiClientConfigParams>;
|
|
48
|
+
shopperExperience: ShopperExperience<ApiClientConfigParams>;
|
|
49
|
+
shopperGiftCertificates: ShopperGiftCertificates<ApiClientConfigParams>;
|
|
50
|
+
shopperLogin: ShopperLogin<ApiClientConfigParams>;
|
|
51
|
+
shopperOrders: ShopperOrders<ApiClientConfigParams>;
|
|
52
|
+
shopperProducts: ShopperProducts<ApiClientConfigParams>;
|
|
53
|
+
shopperPromotions: ShopperPromotions<ApiClientConfigParams>;
|
|
54
|
+
shopperSearch: ShopperSearch<ApiClientConfigParams>;
|
|
55
|
+
}
|
|
56
|
+
export declare type ApiClient = ApiClients[keyof ApiClients];
|
|
57
|
+
/**
|
|
58
|
+
* Generic signature of the options objects used by commerce-sdk-isomorphic
|
|
59
|
+
*/
|
|
60
|
+
export declare type ApiOptions<Parameters extends object = Record<string, unknown>, Body extends object | unknown[] | undefined = Record<string, unknown> | unknown[] | undefined, Headers extends Record<string, string> = Record<string, string>> = {
|
|
61
|
+
parameters?: Parameters;
|
|
62
|
+
headers?: Headers;
|
|
63
|
+
body?: Body;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Generic signature of API methods exported by commerce-sdk-isomorphic
|
|
67
|
+
*/
|
|
68
|
+
export declare type ApiMethod<Options extends ApiOptions, Data> = {
|
|
69
|
+
(options: Options): Promise<Data>;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* The first argument of a function.
|
|
73
|
+
*/
|
|
74
|
+
export declare type Argument<T extends (arg: any) => unknown> = NonNullable<Parameters<T>[0]>;
|
|
75
|
+
/**
|
|
76
|
+
* The data type returned by a commerce-sdk-isomorphic method when the raw response
|
|
77
|
+
* flag is not set.
|
|
78
|
+
*/
|
|
79
|
+
export declare type DataType<T> = T extends ApiMethod<any, Response | infer R> ? R : never;
|
|
80
|
+
/**
|
|
81
|
+
* Merged headers and parameters from client config and options, mimicking the behavior
|
|
82
|
+
* of commerce-sdk-isomorphic.
|
|
83
|
+
*/
|
|
84
|
+
export declare type MergedOptions<Client extends ApiClient, Options extends ApiOptions> = Required<ApiOptions<NonNullable<Client['clientConfig']['parameters'] & Options['parameters']>, unknown extends Options['body'] ? never : Options['body'], NonNullable<Client['clientConfig']['headers'] & Options['headers']>>>;
|
|
85
|
+
/** Query key interface used by API query hooks. */
|
|
86
|
+
export declare type ApiQueryKey<Params extends Record<string, unknown> = Record<string, unknown>> = readonly [...path: (string | undefined)[], parameters: Params];
|
|
87
|
+
/** Query options for endpoint hooks. */
|
|
88
|
+
export declare type ApiQueryOptions<Method extends ApiMethod<any, unknown>> = Prettify<Omit<UseQueryOptions<DataType<Method>, unknown, DataType<Method>, ApiQueryKey>, 'queryFn' | 'queryKey'>>;
|
|
89
|
+
/** Adds `null` as an allowed value to all parameters. */
|
|
90
|
+
export declare type NullableParameters<T extends {
|
|
91
|
+
parameters?: object;
|
|
92
|
+
}> = {
|
|
93
|
+
[K in keyof T]: K extends 'parameters' ? AllowNull<T[K]> : T[K];
|
|
94
|
+
};
|
|
95
|
+
/** Remove `null` and `undefined` values from all parameters. */
|
|
96
|
+
export declare type OmitNullableParameters<T extends {
|
|
97
|
+
parameters: object;
|
|
98
|
+
}> = Omit<T, 'parameters'> & {
|
|
99
|
+
parameters: NullToOptional<T['parameters']>;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Interface to update a cached API response.
|
|
103
|
+
* @property queryKey - The query key to update
|
|
104
|
+
* @property updater - Either the new data or a function that accepts old data and returns new data
|
|
105
|
+
*/
|
|
106
|
+
export declare type CacheUpdateUpdate<T> = {
|
|
107
|
+
queryKey: ApiQueryKey;
|
|
108
|
+
updater?: Updater<T | undefined, T | undefined>;
|
|
109
|
+
};
|
|
110
|
+
/** Query predicate for queries to invalidate */
|
|
111
|
+
export declare type CacheUpdateInvalidate = InvalidateQueryFilters;
|
|
112
|
+
/** Query predicate for queries to remove */
|
|
113
|
+
export declare type CacheUpdateRemove = QueryFilters;
|
|
114
|
+
/** Collection of updates to make to the cache when a request completes. */
|
|
115
|
+
export declare type CacheUpdate = {
|
|
116
|
+
update?: CacheUpdateUpdate<unknown>[];
|
|
117
|
+
invalidate?: CacheUpdateInvalidate[];
|
|
118
|
+
remove?: CacheUpdateRemove[];
|
|
119
|
+
clear?: boolean;
|
|
120
|
+
};
|
|
121
|
+
/** Generates a collection of cache updates to make for a given request. */
|
|
122
|
+
export declare type CacheUpdateGetter<Options, Data> = (customerId: string | null, options: Options, response: Data) => CacheUpdate;
|
|
123
|
+
/** Collection of cache update getters for each method of an API client. */
|
|
124
|
+
export declare type CacheUpdateMatrix<Client extends ApiClient> = {
|
|
125
|
+
[Method in keyof Client]?: Client[Method] extends ApiMethod<any, Response | infer Data> ? CacheUpdateGetter<MergedOptions<Client, Argument<Client[Method]>>, Data> : never;
|
|
126
|
+
};
|
|
127
|
+
export {};
|
|
128
|
+
//# sourceMappingURL=types.d.ts.map
|
package/hooks/types.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface AccessToken {
|
|
2
|
+
token: string | null;
|
|
3
|
+
getTokenWhenReady: () => Promise<string>;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Hook that returns the access token.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
declare const useAccessToken: () => AccessToken;
|
|
10
|
+
export default useAccessToken;
|
|
11
|
+
//# sourceMappingURL=useAccessToken.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _useAuthContext = _interopRequireDefault(require("./useAuthContext"));
|
|
8
|
+
var _useLocalStorage = _interopRequireDefault(require("./useLocalStorage"));
|
|
9
|
+
var _useConfig = _interopRequireDefault(require("./useConfig"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
/*
|
|
12
|
+
* Copyright (c) 2022, salesforce.com, inc.
|
|
13
|
+
* All rights reserved.
|
|
14
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
15
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const onClient = typeof window !== 'undefined';
|
|
19
|
+
/**
|
|
20
|
+
* Hook that returns the access token.
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
const useAccessToken = () => {
|
|
24
|
+
const config = (0, _useConfig.default)();
|
|
25
|
+
const auth = (0, _useAuthContext.default)();
|
|
26
|
+
const token = onClient ?
|
|
27
|
+
// This conditional is a constant value based on the environment, so the same path will
|
|
28
|
+
// always be followed., and the "rule of hooks" is not violated.
|
|
29
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
30
|
+
(0, _useLocalStorage.default)(`access_token_${config.siteId}`) : auth.get('access_token');
|
|
31
|
+
|
|
32
|
+
// NOTE: auth.ready() is to be called later. If you call it immediately in this hook,
|
|
33
|
+
// it'll cause infinite re-renders during testing.
|
|
34
|
+
const getTokenWhenReady = () => auth.ready().then(({
|
|
35
|
+
access_token
|
|
36
|
+
}) => access_token);
|
|
37
|
+
return {
|
|
38
|
+
token,
|
|
39
|
+
getTokenWhenReady
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
var _default = useAccessToken;
|
|
43
|
+
exports.default = _default;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _provider = require("../provider");
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
/*
|
|
11
|
+
* Copyright (c) 2022, salesforce.com, inc.
|
|
12
|
+
* All rights reserved.
|
|
13
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
14
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* TBD
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
const useAuthContext = () => {
|
|
23
|
+
const context = _react.default.useContext(_provider.AuthContext);
|
|
24
|
+
if (!context) {
|
|
25
|
+
throw new Error('Missing CommerceApiProvider. You probably forget to render the provider.');
|
|
26
|
+
}
|
|
27
|
+
return context;
|
|
28
|
+
};
|
|
29
|
+
var _default = useAuthContext;
|
|
30
|
+
exports.default = _default;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { UseMutationResult } from '@tanstack/react-query';
|
|
2
|
+
import Auth from '../auth';
|
|
3
|
+
export declare const AuthHelpers: {
|
|
4
|
+
readonly LoginGuestUser: "loginGuestUser";
|
|
5
|
+
readonly LoginRegisteredUserB2C: "loginRegisteredUserB2C";
|
|
6
|
+
readonly Logout: "logout";
|
|
7
|
+
readonly Register: "register";
|
|
8
|
+
};
|
|
9
|
+
export declare type AuthHelper = (typeof AuthHelpers)[keyof typeof AuthHelpers];
|
|
10
|
+
/**
|
|
11
|
+
* A hook for Public Client OAuth helpers.
|
|
12
|
+
* The hook calls the SLAS helpers imported from commerce-sdk-isomorphic.
|
|
13
|
+
* For more, see https://github.com/SalesforceCommerceCloud/commerce-sdk-isomorphic/#public-client-shopper-login-helpers
|
|
14
|
+
*
|
|
15
|
+
* Avaliable helpers:
|
|
16
|
+
* - loginRegisteredUserB2C
|
|
17
|
+
* - loginGuestUser
|
|
18
|
+
* - logout
|
|
19
|
+
* - register
|
|
20
|
+
*/
|
|
21
|
+
export declare function useAuthHelper<Mutation extends AuthHelper>(mutation: Mutation): UseMutationResult<ReturnType<Auth[Mutation]> extends Promise<infer Data> ? Data : never, unknown, [
|
|
22
|
+
] extends Parameters<Auth[Mutation]> ? void : Parameters<Auth[Mutation]>[0], unknown>;
|
|
23
|
+
//# sourceMappingURL=useAuthHelper.d.ts.map
|