@salesforce/commerce-sdk-react 1.3.0 → 1.4.0-dev.1
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/CHANGELOG.md +9 -1
- package/README.md +62 -1
- package/auth/index.d.ts +21 -16
- package/auth/index.js +127 -57
- package/auth/storage/cookie.js +25 -1
- package/components/StorefrontPreview/storefront-preview.js +20 -0
- package/components/StorefrontPreview/utils.d.ts +6 -0
- package/components/StorefrontPreview/utils.js +20 -6
- package/constant.d.ts +3 -0
- package/constant.js +5 -2
- package/hooks/ShopperBaskets/paramKeys.d.ts +9 -0
- package/hooks/ShopperBaskets/paramKeys.js +25 -0
- package/hooks/ShopperBaskets/query.js +36 -5
- package/hooks/ShopperBaskets/queryKeyHelpers.d.ts +0 -5
- package/hooks/ShopperBaskets/queryKeyHelpers.js +22 -10
- package/hooks/ShopperContexts/paramKeys.d.ts +5 -0
- package/hooks/ShopperContexts/paramKeys.js +17 -0
- package/hooks/ShopperContexts/query.js +13 -1
- package/hooks/ShopperContexts/queryKeyHelpers.d.ts +0 -5
- package/hooks/ShopperContexts/queryKeyHelpers.js +6 -2
- package/hooks/ShopperCustomers/cache.js +7 -2
- package/hooks/ShopperCustomers/paramKeys.d.ts +26 -0
- package/hooks/ShopperCustomers/paramKeys.js +44 -0
- package/hooks/ShopperCustomers/query.js +73 -16
- package/hooks/ShopperCustomers/queryKeyHelpers.d.ts +0 -6
- package/hooks/ShopperCustomers/queryKeyHelpers.js +58 -28
- package/hooks/ShopperExperience/paramKeys.d.ts +6 -0
- package/hooks/ShopperExperience/paramKeys.js +19 -0
- package/hooks/ShopperExperience/query.js +18 -2
- package/hooks/ShopperExperience/queryKeyHelpers.d.ts +0 -5
- package/hooks/ShopperExperience/queryKeyHelpers.js +10 -4
- package/hooks/ShopperGiftCertificates/paramKeys.d.ts +5 -0
- package/hooks/ShopperGiftCertificates/paramKeys.js +17 -0
- package/hooks/ShopperGiftCertificates/query.js +8 -1
- package/hooks/ShopperGiftCertificates/queryKeyHelpers.d.ts +0 -5
- package/hooks/ShopperGiftCertificates/queryKeyHelpers.js +6 -2
- package/hooks/ShopperLogin/paramKeys.d.ts +7 -0
- package/hooks/ShopperLogin/paramKeys.js +21 -0
- package/hooks/ShopperLogin/query.js +24 -3
- package/hooks/ShopperLogin/queryKeyHelpers.d.ts +0 -5
- package/hooks/ShopperLogin/queryKeyHelpers.js +14 -6
- package/hooks/ShopperOrders/paramKeys.d.ts +7 -0
- package/hooks/ShopperOrders/paramKeys.js +21 -0
- package/hooks/ShopperOrders/query.js +24 -3
- package/hooks/ShopperOrders/queryKeyHelpers.d.ts +0 -5
- package/hooks/ShopperOrders/queryKeyHelpers.js +14 -6
- package/hooks/ShopperProducts/paramKeys.d.ts +8 -0
- package/hooks/ShopperProducts/paramKeys.js +23 -0
- package/hooks/ShopperProducts/query.js +30 -4
- package/hooks/ShopperProducts/queryKeyHelpers.d.ts +0 -5
- package/hooks/ShopperProducts/queryKeyHelpers.js +18 -8
- package/hooks/ShopperPromotions/paramKeys.d.ts +6 -0
- package/hooks/ShopperPromotions/paramKeys.js +19 -0
- package/hooks/ShopperPromotions/query.js +18 -2
- package/hooks/ShopperPromotions/queryKeyHelpers.d.ts +0 -5
- package/hooks/ShopperPromotions/queryKeyHelpers.js +10 -4
- package/hooks/ShopperSearch/paramKeys.d.ts +6 -0
- package/hooks/ShopperSearch/paramKeys.js +18 -0
- package/hooks/ShopperSearch/query.js +16 -2
- package/hooks/ShopperSearch/queryKeyHelpers.d.ts +0 -5
- package/hooks/ShopperSearch/queryKeyHelpers.js +10 -4
- package/hooks/ShopperSeo/index.d.ts +2 -0
- package/hooks/ShopperSeo/index.js +16 -0
- package/hooks/ShopperSeo/paramKeys.d.ts +5 -0
- package/hooks/ShopperSeo/paramKeys.js +17 -0
- package/hooks/ShopperSeo/query.d.ts +20 -0
- package/hooks/ShopperSeo/query.js +74 -0
- package/hooks/ShopperSeo/queryKeyHelpers.d.ts +24 -0
- package/hooks/ShopperSeo/queryKeyHelpers.js +28 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +12 -0
- package/hooks/types.d.ts +2 -1
- package/hooks/useLocalStorage.d.ts +0 -1
- package/hooks/useLocalStorage.js +30 -20
- package/hooks/utils.d.ts +2 -0
- package/hooks/utils.js +11 -2
- package/package.json +5 -5
- package/provider.d.ts +12 -0
- package/provider.js +25 -8
package/provider.js
CHANGED
|
@@ -36,7 +36,7 @@ const AuthContext = exports.AuthContext = /*#__PURE__*/_react.default.createCont
|
|
|
36
36
|
* Initialize a set of Commerce API clients and make it available to all of descendant components
|
|
37
37
|
*
|
|
38
38
|
* @group Components
|
|
39
|
-
*
|
|
39
|
+
*
|
|
40
40
|
* @example
|
|
41
41
|
* ```js
|
|
42
42
|
import {CommerceApiProvider} from '@salesforce/commerce-sdk-react'
|
|
@@ -52,16 +52,25 @@ const AuthContext = exports.AuthContext = /*#__PURE__*/_react.default.createCont
|
|
|
52
52
|
siteId="RefArch"
|
|
53
53
|
shortCode="12345678"
|
|
54
54
|
locale="en-US"
|
|
55
|
+
enablePWAKitPrivateClient={true}
|
|
55
56
|
currency="USD"
|
|
56
57
|
>
|
|
57
58
|
{children}
|
|
58
59
|
</CommerceApiProvider>
|
|
59
60
|
)
|
|
60
|
-
}
|
|
61
|
+
}
|
|
61
62
|
|
|
62
63
|
export default App
|
|
63
64
|
* ```
|
|
64
|
-
*
|
|
65
|
+
* Note: The provider can enable SLAS Private Client mode in 2 ways.
|
|
66
|
+
* `enablePWAKitPrivateClient` sets commerce-sdk-react to work with the PWA proxy
|
|
67
|
+
* `/mobify/scapi/api/auth` to set the private client secret. PWA users should use
|
|
68
|
+
* this option.
|
|
69
|
+
*
|
|
70
|
+
* Non-PWA Kit users can enable private client mode by passing in a client secret
|
|
71
|
+
* directly to the provider. However, be careful when doing this as you will have
|
|
72
|
+
* to make sure the secret is not unexpectedly exposed to the client.
|
|
73
|
+
*
|
|
65
74
|
* @returns Provider to wrap your app with
|
|
66
75
|
*/
|
|
67
76
|
const CommerceApiProvider = props => {
|
|
@@ -78,7 +87,10 @@ const CommerceApiProvider = props => {
|
|
|
78
87
|
locale,
|
|
79
88
|
currency,
|
|
80
89
|
fetchedToken,
|
|
81
|
-
OCAPISessionsURL
|
|
90
|
+
OCAPISessionsURL,
|
|
91
|
+
enablePWAKitPrivateClient,
|
|
92
|
+
clientSecret,
|
|
93
|
+
silenceWarnings
|
|
82
94
|
} = props;
|
|
83
95
|
const config = {
|
|
84
96
|
proxy,
|
|
@@ -105,7 +117,8 @@ const CommerceApiProvider = props => {
|
|
|
105
117
|
shopperOrders: new _commerceSdkIsomorphic.ShopperOrders(config),
|
|
106
118
|
shopperProducts: new _commerceSdkIsomorphic.ShopperProducts(config),
|
|
107
119
|
shopperPromotions: new _commerceSdkIsomorphic.ShopperPromotions(config),
|
|
108
|
-
shopperSearch: new _commerceSdkIsomorphic.ShopperSearch(config)
|
|
120
|
+
shopperSearch: new _commerceSdkIsomorphic.ShopperSearch(config),
|
|
121
|
+
shopperSeo: new _commerceSdkIsomorphic.ShopperSeo(config)
|
|
109
122
|
};
|
|
110
123
|
}, [clientId, organizationId, shortCode, siteId, proxy, fetchOptions, locale, currency, headers === null || headers === void 0 ? void 0 : headers['correlation-id']]);
|
|
111
124
|
const auth = (0, _react.useMemo)(() => {
|
|
@@ -118,9 +131,12 @@ const CommerceApiProvider = props => {
|
|
|
118
131
|
redirectURI,
|
|
119
132
|
fetchOptions,
|
|
120
133
|
fetchedToken,
|
|
121
|
-
OCAPISessionsURL
|
|
134
|
+
OCAPISessionsURL,
|
|
135
|
+
enablePWAKitPrivateClient,
|
|
136
|
+
clientSecret,
|
|
137
|
+
silenceWarnings
|
|
122
138
|
});
|
|
123
|
-
}, [clientId, organizationId, shortCode, siteId, proxy, redirectURI, fetchOptions, fetchedToken, OCAPISessionsURL]);
|
|
139
|
+
}, [clientId, organizationId, shortCode, siteId, proxy, redirectURI, fetchOptions, fetchedToken, OCAPISessionsURL, enablePWAKitPrivateClient, clientSecret, silenceWarnings]);
|
|
124
140
|
|
|
125
141
|
// Initialize the session
|
|
126
142
|
(0, _react.useEffect)(() => void auth.ready(), [auth]);
|
|
@@ -135,7 +151,8 @@ const CommerceApiProvider = props => {
|
|
|
135
151
|
siteId,
|
|
136
152
|
shortCode,
|
|
137
153
|
locale,
|
|
138
|
-
currency
|
|
154
|
+
currency,
|
|
155
|
+
silenceWarnings
|
|
139
156
|
}
|
|
140
157
|
}, /*#__PURE__*/_react.default.createElement(CommerceApiContext.Provider, {
|
|
141
158
|
value: apiClients
|