@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.
Files changed (79) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/README.md +62 -1
  3. package/auth/index.d.ts +21 -16
  4. package/auth/index.js +127 -57
  5. package/auth/storage/cookie.js +25 -1
  6. package/components/StorefrontPreview/storefront-preview.js +20 -0
  7. package/components/StorefrontPreview/utils.d.ts +6 -0
  8. package/components/StorefrontPreview/utils.js +20 -6
  9. package/constant.d.ts +3 -0
  10. package/constant.js +5 -2
  11. package/hooks/ShopperBaskets/paramKeys.d.ts +9 -0
  12. package/hooks/ShopperBaskets/paramKeys.js +25 -0
  13. package/hooks/ShopperBaskets/query.js +36 -5
  14. package/hooks/ShopperBaskets/queryKeyHelpers.d.ts +0 -5
  15. package/hooks/ShopperBaskets/queryKeyHelpers.js +22 -10
  16. package/hooks/ShopperContexts/paramKeys.d.ts +5 -0
  17. package/hooks/ShopperContexts/paramKeys.js +17 -0
  18. package/hooks/ShopperContexts/query.js +13 -1
  19. package/hooks/ShopperContexts/queryKeyHelpers.d.ts +0 -5
  20. package/hooks/ShopperContexts/queryKeyHelpers.js +6 -2
  21. package/hooks/ShopperCustomers/cache.js +7 -2
  22. package/hooks/ShopperCustomers/paramKeys.d.ts +26 -0
  23. package/hooks/ShopperCustomers/paramKeys.js +44 -0
  24. package/hooks/ShopperCustomers/query.js +73 -16
  25. package/hooks/ShopperCustomers/queryKeyHelpers.d.ts +0 -6
  26. package/hooks/ShopperCustomers/queryKeyHelpers.js +58 -28
  27. package/hooks/ShopperExperience/paramKeys.d.ts +6 -0
  28. package/hooks/ShopperExperience/paramKeys.js +19 -0
  29. package/hooks/ShopperExperience/query.js +18 -2
  30. package/hooks/ShopperExperience/queryKeyHelpers.d.ts +0 -5
  31. package/hooks/ShopperExperience/queryKeyHelpers.js +10 -4
  32. package/hooks/ShopperGiftCertificates/paramKeys.d.ts +5 -0
  33. package/hooks/ShopperGiftCertificates/paramKeys.js +17 -0
  34. package/hooks/ShopperGiftCertificates/query.js +8 -1
  35. package/hooks/ShopperGiftCertificates/queryKeyHelpers.d.ts +0 -5
  36. package/hooks/ShopperGiftCertificates/queryKeyHelpers.js +6 -2
  37. package/hooks/ShopperLogin/paramKeys.d.ts +7 -0
  38. package/hooks/ShopperLogin/paramKeys.js +21 -0
  39. package/hooks/ShopperLogin/query.js +24 -3
  40. package/hooks/ShopperLogin/queryKeyHelpers.d.ts +0 -5
  41. package/hooks/ShopperLogin/queryKeyHelpers.js +14 -6
  42. package/hooks/ShopperOrders/paramKeys.d.ts +7 -0
  43. package/hooks/ShopperOrders/paramKeys.js +21 -0
  44. package/hooks/ShopperOrders/query.js +24 -3
  45. package/hooks/ShopperOrders/queryKeyHelpers.d.ts +0 -5
  46. package/hooks/ShopperOrders/queryKeyHelpers.js +14 -6
  47. package/hooks/ShopperProducts/paramKeys.d.ts +8 -0
  48. package/hooks/ShopperProducts/paramKeys.js +23 -0
  49. package/hooks/ShopperProducts/query.js +30 -4
  50. package/hooks/ShopperProducts/queryKeyHelpers.d.ts +0 -5
  51. package/hooks/ShopperProducts/queryKeyHelpers.js +18 -8
  52. package/hooks/ShopperPromotions/paramKeys.d.ts +6 -0
  53. package/hooks/ShopperPromotions/paramKeys.js +19 -0
  54. package/hooks/ShopperPromotions/query.js +18 -2
  55. package/hooks/ShopperPromotions/queryKeyHelpers.d.ts +0 -5
  56. package/hooks/ShopperPromotions/queryKeyHelpers.js +10 -4
  57. package/hooks/ShopperSearch/paramKeys.d.ts +6 -0
  58. package/hooks/ShopperSearch/paramKeys.js +18 -0
  59. package/hooks/ShopperSearch/query.js +16 -2
  60. package/hooks/ShopperSearch/queryKeyHelpers.d.ts +0 -5
  61. package/hooks/ShopperSearch/queryKeyHelpers.js +10 -4
  62. package/hooks/ShopperSeo/index.d.ts +2 -0
  63. package/hooks/ShopperSeo/index.js +16 -0
  64. package/hooks/ShopperSeo/paramKeys.d.ts +5 -0
  65. package/hooks/ShopperSeo/paramKeys.js +17 -0
  66. package/hooks/ShopperSeo/query.d.ts +20 -0
  67. package/hooks/ShopperSeo/query.js +74 -0
  68. package/hooks/ShopperSeo/queryKeyHelpers.d.ts +24 -0
  69. package/hooks/ShopperSeo/queryKeyHelpers.js +28 -0
  70. package/hooks/index.d.ts +1 -0
  71. package/hooks/index.js +12 -0
  72. package/hooks/types.d.ts +2 -1
  73. package/hooks/useLocalStorage.d.ts +0 -1
  74. package/hooks/useLocalStorage.js +30 -20
  75. package/hooks/utils.d.ts +2 -0
  76. package/hooks/utils.js +11 -2
  77. package/package.json +5 -5
  78. package/provider.d.ts +12 -0
  79. 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