@salesforce/commerce-sdk-react 1.0.0-preview.0 → 1.0.0-preview.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 +1 -0
- package/README.md +4 -0
- package/auth/index.d.ts +16 -1
- package/auth/index.js +49 -1
- package/hooks/ShopperBaskets/mutation.d.ts +61 -280
- package/hooks/ShopperBaskets/mutation.js +60 -254
- package/hooks/ShopperBaskets/query.d.ts +10 -0
- package/hooks/ShopperBaskets/query.js +10 -0
- package/hooks/ShopperContexts/mutation.d.ts +16 -11
- package/hooks/ShopperContexts/mutation.js +16 -11
- package/hooks/ShopperContexts/query.d.ts +3 -1
- package/hooks/ShopperContexts/query.js +3 -1
- package/hooks/ShopperCustomers/mutation.d.ts +20 -80
- package/hooks/ShopperCustomers/mutation.js +20 -81
- package/hooks/ShopperCustomers/query.d.ts +27 -2
- package/hooks/ShopperCustomers/query.js +28 -2
- package/hooks/ShopperExperience/query.d.ts +12 -8
- package/hooks/ShopperExperience/query.js +12 -8
- package/hooks/ShopperGiftCertificates/query.d.ts +2 -0
- package/hooks/ShopperGiftCertificates/query.js +2 -0
- package/hooks/ShopperLogin/mutation.d.ts +19 -47
- package/hooks/ShopperLogin/mutation.js +19 -41
- package/hooks/ShopperLogin/query.d.ts +8 -0
- package/hooks/ShopperLogin/query.js +8 -0
- package/hooks/ShopperOrders/mutation.d.ts +19 -23
- package/hooks/ShopperOrders/mutation.js +19 -21
- package/hooks/ShopperOrders/query.d.ts +6 -0
- package/hooks/ShopperOrders/query.js +7 -1
- package/hooks/ShopperProducts/query.d.ts +8 -0
- package/hooks/ShopperProducts/query.js +8 -0
- package/hooks/ShopperPromotions/query.d.ts +4 -0
- package/hooks/ShopperPromotions/query.js +4 -0
- package/hooks/ShopperSearch/query.d.ts +11 -3
- package/hooks/ShopperSearch/query.js +11 -3
- package/hooks/types.d.ts +3 -0
- package/hooks/useAccessToken.d.ts +6 -0
- package/hooks/useAccessToken.js +8 -0
- package/hooks/useAuthHelper.d.ts +14 -0
- package/hooks/useAuthHelper.js +19 -0
- package/hooks/useCommerceApi.d.ts +2 -0
- package/hooks/useCommerceApi.js +2 -0
- package/hooks/useCustomerId.d.ts +2 -0
- package/hooks/useCustomerId.js +2 -0
- package/hooks/useCustomerType.d.ts +3 -0
- package/hooks/useCustomerType.js +12 -1
- package/hooks/useEncUserId.d.ts +3 -0
- package/hooks/useEncUserId.js +3 -0
- package/hooks/useUsid.d.ts +2 -0
- package/hooks/useUsid.js +2 -0
- package/package.json +8 -6
- package/provider.d.ts +27 -1
- package/provider.js +27 -1
- package/scripts/build-and-release-docs.js +1 -0
|
@@ -17,14 +17,16 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
17
17
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Mutations available for Shopper Orders
|
|
22
|
+
* @group ShopperOrders
|
|
23
|
+
* @category Mutation
|
|
24
|
+
* @enum
|
|
25
|
+
*/
|
|
21
26
|
const ShopperOrdersMutations = {
|
|
22
27
|
/**
|
|
23
28
|
* Submits an order based on a prepared basket. The only considered value from the request body is basketId.
|
|
24
29
|
* @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
30
|
*/
|
|
29
31
|
CreateOrder: 'createOrder',
|
|
30
32
|
/**
|
|
@@ -33,35 +35,31 @@ const ShopperOrdersMutations = {
|
|
|
33
35
|
The payment instrument is added with the provided details. The payment method must be applicable for the order see GET
|
|
34
36
|
/baskets/\{basketId\}/payment-methods, if the payment method is 'CREDIT_CARD' a paymentCard must be specified in the request.
|
|
35
37
|
* @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
38
|
*/
|
|
40
39
|
CreatePaymentInstrumentForOrder: 'createPaymentInstrumentForOrder',
|
|
41
40
|
/**
|
|
42
41
|
* Removes a payment instrument of an order.
|
|
43
42
|
* @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
43
|
*/
|
|
48
44
|
RemovePaymentInstrumentFromOrder: 'removePaymentInstrumentFromOrder',
|
|
49
45
|
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
*/
|
|
46
|
+
* Updates a payment instrument of an order.
|
|
47
|
+
* @returns A TanStack Query mutation hook for interacting with the Shopper Orders `updatePaymentInstrumentForOrder` endpoint.
|
|
48
|
+
*/
|
|
60
49
|
UpdatePaymentInstrumentForOrder: 'updatePaymentInstrumentForOrder'
|
|
61
50
|
};
|
|
62
51
|
|
|
63
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* Mutation for Shopper Orders.
|
|
54
|
+
* @group ShopperOrders
|
|
55
|
+
* @category Mutation
|
|
56
|
+
*/
|
|
64
57
|
exports.ShopperOrdersMutations = ShopperOrdersMutations;
|
|
58
|
+
/**
|
|
59
|
+
* Mutation hook for Shopper Orders.
|
|
60
|
+
* @group ShopperOrders
|
|
61
|
+
* @category Mutation
|
|
62
|
+
*/
|
|
65
63
|
function useShopperOrdersMutation(mutation) {
|
|
66
64
|
const getCacheUpdates = _cache.cacheUpdateMatrix[mutation];
|
|
67
65
|
// TODO: Remove this check when all mutations are implemented.
|
|
@@ -3,6 +3,8 @@ import { ApiClients, ApiQueryOptions, Argument, DataType, NullableParameters } f
|
|
|
3
3
|
declare type Client = ApiClients['shopperOrders'];
|
|
4
4
|
/**
|
|
5
5
|
* Gets information for an order.
|
|
6
|
+
* @group ShopperOrders
|
|
7
|
+
* @category Query
|
|
6
8
|
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
7
9
|
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
8
10
|
* @returns A TanStack Query query hook with data from the Shopper Orders `getOrder` endpoint.
|
|
@@ -13,6 +15,8 @@ declare type Client = ApiClients['shopperOrders'];
|
|
|
13
15
|
export declare const useOrder: (apiOptions: NullableParameters<Argument<Client['getOrder']>>, queryOptions?: ApiQueryOptions<Client['getOrder']>) => UseQueryResult<DataType<Client['getOrder']>>;
|
|
14
16
|
/**
|
|
15
17
|
* Gets the applicable payment methods for an existing order considering the open payment amount only.
|
|
18
|
+
* @group ShopperOrders
|
|
19
|
+
* @category Query
|
|
16
20
|
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
17
21
|
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
18
22
|
* @returns A TanStack Query query hook with data from the Shopper Orders `getPaymentMethodsForOrder` endpoint.
|
|
@@ -25,6 +29,8 @@ export declare const usePaymentMethodsForOrder: (apiOptions: NullableParameters<
|
|
|
25
29
|
* This method gives you the external taxation data of the order transferred from the basket during
|
|
26
30
|
order creation. This endpoint can be called only if external taxation was used. See POST /baskets
|
|
27
31
|
for more information.
|
|
32
|
+
* @group ShopperOrders
|
|
33
|
+
* @category Query
|
|
28
34
|
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
29
35
|
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
30
36
|
* @returns A TanStack Query query hook with data from the Shopper Orders `getTaxesFromOrder` endpoint.
|
|
@@ -20,6 +20,8 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
20
20
|
*/
|
|
21
21
|
/**
|
|
22
22
|
* Gets information for an order.
|
|
23
|
+
* @group ShopperOrders
|
|
24
|
+
* @category Query
|
|
23
25
|
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
24
26
|
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
25
27
|
* @returns A TanStack Query query hook with data from the Shopper Orders `getOrder` endpoint.
|
|
@@ -58,6 +60,8 @@ const useOrder = (apiOptions, queryOptions = {}) => {
|
|
|
58
60
|
};
|
|
59
61
|
/**
|
|
60
62
|
* Gets the applicable payment methods for an existing order considering the open payment amount only.
|
|
63
|
+
* @group ShopperOrders
|
|
64
|
+
* @category Query
|
|
61
65
|
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
62
66
|
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
63
67
|
* @returns A TanStack Query query hook with data from the Shopper Orders `getPaymentMethodsForOrder` endpoint.
|
|
@@ -98,7 +102,9 @@ const usePaymentMethodsForOrder = (apiOptions, queryOptions = {}) => {
|
|
|
98
102
|
/**
|
|
99
103
|
* This method gives you the external taxation data of the order transferred from the basket during
|
|
100
104
|
order creation. This endpoint can be called only if external taxation was used. See POST /baskets
|
|
101
|
-
for more information.
|
|
105
|
+
for more information.
|
|
106
|
+
* @group ShopperOrders
|
|
107
|
+
* @category Query
|
|
102
108
|
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
103
109
|
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
104
110
|
* @returns A TanStack Query query hook with data from the Shopper Orders `getTaxesFromOrder` endpoint.
|
|
@@ -3,6 +3,8 @@ import { ApiClients, ApiQueryOptions, Argument, DataType, NullableParameters } f
|
|
|
3
3
|
declare type Client = ApiClients['shopperProducts'];
|
|
4
4
|
/**
|
|
5
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
|
+
* @group ShopperProducts
|
|
7
|
+
* @category Query
|
|
6
8
|
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
7
9
|
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
8
10
|
* @returns A TanStack Query query hook with data from the Shopper Products `getProducts` endpoint.
|
|
@@ -13,6 +15,8 @@ declare type Client = ApiClients['shopperProducts'];
|
|
|
13
15
|
export declare const useProducts: (apiOptions: NullableParameters<Argument<Client['getProducts']>>, queryOptions?: ApiQueryOptions<Client['getProducts']>) => UseQueryResult<DataType<Client['getProducts']>>;
|
|
14
16
|
/**
|
|
15
17
|
* 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.
|
|
18
|
+
* @group ShopperProducts
|
|
19
|
+
* @category Query
|
|
16
20
|
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
17
21
|
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
18
22
|
* @returns A TanStack Query query hook with data from the Shopper Products `getProduct` endpoint.
|
|
@@ -23,6 +27,8 @@ export declare const useProducts: (apiOptions: NullableParameters<Argument<Clien
|
|
|
23
27
|
export declare const useProduct: (apiOptions: NullableParameters<Argument<Client['getProduct']>>, queryOptions?: ApiQueryOptions<Client['getProduct']>) => UseQueryResult<DataType<Client['getProduct']>>;
|
|
24
28
|
/**
|
|
25
29
|
* 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.
|
|
30
|
+
* @group ShopperProducts
|
|
31
|
+
* @category Query
|
|
26
32
|
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
27
33
|
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
28
34
|
* @returns A TanStack Query query hook with data from the Shopper Products `getCategories` endpoint.
|
|
@@ -35,6 +41,8 @@ export declare const useCategories: (apiOptions: NullableParameters<Argument<Cli
|
|
|
35
41
|
* When you use the URL template below, the server returns a category identified by its ID; by default, the server
|
|
36
42
|
also returns the first level of subcategories, but you can specify another level by setting the levels
|
|
37
43
|
parameter. The server only returns online categories.
|
|
44
|
+
* @group ShopperProducts
|
|
45
|
+
* @category Query
|
|
38
46
|
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
39
47
|
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
40
48
|
* @returns A TanStack Query query hook with data from the Shopper Products `getCategory` endpoint.
|
|
@@ -20,6 +20,8 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
20
20
|
*/
|
|
21
21
|
/**
|
|
22
22
|
* 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.
|
|
23
|
+
* @group ShopperProducts
|
|
24
|
+
* @category Query
|
|
23
25
|
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
24
26
|
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
25
27
|
* @returns A TanStack Query query hook with data from the Shopper Products `getProducts` endpoint.
|
|
@@ -58,6 +60,8 @@ const useProducts = (apiOptions, queryOptions = {}) => {
|
|
|
58
60
|
};
|
|
59
61
|
/**
|
|
60
62
|
* 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.
|
|
63
|
+
* @group ShopperProducts
|
|
64
|
+
* @category Query
|
|
61
65
|
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
62
66
|
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
63
67
|
* @returns A TanStack Query query hook with data from the Shopper Products `getProduct` endpoint.
|
|
@@ -97,6 +101,8 @@ const useProduct = (apiOptions, queryOptions = {}) => {
|
|
|
97
101
|
};
|
|
98
102
|
/**
|
|
99
103
|
* 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.
|
|
104
|
+
* @group ShopperProducts
|
|
105
|
+
* @category Query
|
|
100
106
|
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
101
107
|
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
102
108
|
* @returns A TanStack Query query hook with data from the Shopper Products `getCategories` endpoint.
|
|
@@ -138,6 +144,8 @@ const useCategories = (apiOptions, queryOptions = {}) => {
|
|
|
138
144
|
* When you use the URL template below, the server returns a category identified by its ID; by default, the server
|
|
139
145
|
also returns the first level of subcategories, but you can specify another level by setting the levels
|
|
140
146
|
parameter. The server only returns online categories.
|
|
147
|
+
* @group ShopperProducts
|
|
148
|
+
* @category Query
|
|
141
149
|
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
142
150
|
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
143
151
|
* @returns A TanStack Query query hook with data from the Shopper Products `getCategory` endpoint.
|
|
@@ -3,6 +3,8 @@ import { ApiClients, ApiQueryOptions, Argument, DataType, NullableParameters } f
|
|
|
3
3
|
declare type Client = ApiClients['shopperPromotions'];
|
|
4
4
|
/**
|
|
5
5
|
* Returns an array of enabled promotions for a list of specified IDs. In the request URL, you can specify up to 50 IDs. If you specify an ID that contains either parentheses or the separator characters, you must URL encode these characters. Each request returns only enabled promotions as the server does not consider promotion qualifiers or schedules.
|
|
6
|
+
* @group ShopperPromotions
|
|
7
|
+
* @category Query
|
|
6
8
|
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
7
9
|
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
8
10
|
* @returns A TanStack Query query hook with data from the Shopper Promotions `getPromotions` endpoint.
|
|
@@ -17,6 +19,8 @@ criteria. In the request URL, you must provide a campaign_id parameter, and you
|
|
|
17
19
|
range by providing start_date and end_date parameters. Both parameters are required to specify a date range, as
|
|
18
20
|
omitting one causes the server to return a MissingParameterException fault. Each request returns only enabled
|
|
19
21
|
promotions, since the server does not consider promotion qualifiers or schedules.
|
|
22
|
+
* @group ShopperPromotions
|
|
23
|
+
* @category Query
|
|
20
24
|
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
21
25
|
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
22
26
|
* @returns A TanStack Query query hook with data from the Shopper Promotions `getPromotionsForCampaign` endpoint.
|
|
@@ -20,6 +20,8 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
20
20
|
*/
|
|
21
21
|
/**
|
|
22
22
|
* Returns an array of enabled promotions for a list of specified IDs. In the request URL, you can specify up to 50 IDs. If you specify an ID that contains either parentheses or the separator characters, you must URL encode these characters. Each request returns only enabled promotions as the server does not consider promotion qualifiers or schedules.
|
|
23
|
+
* @group ShopperPromotions
|
|
24
|
+
* @category Query
|
|
23
25
|
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
24
26
|
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
25
27
|
* @returns A TanStack Query query hook with data from the Shopper Promotions `getPromotions` endpoint.
|
|
@@ -62,6 +64,8 @@ criteria. In the request URL, you must provide a campaign_id parameter, and you
|
|
|
62
64
|
range by providing start_date and end_date parameters. Both parameters are required to specify a date range, as
|
|
63
65
|
omitting one causes the server to return a MissingParameterException fault. Each request returns only enabled
|
|
64
66
|
promotions, since the server does not consider promotion qualifiers or schedules.
|
|
67
|
+
* @group ShopperPromotions
|
|
68
|
+
* @category Query
|
|
65
69
|
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
66
70
|
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
67
71
|
* @returns A TanStack Query query hook with data from the Shopper Promotions `getPromotionsForCampaign` endpoint.
|
|
@@ -2,8 +2,12 @@ import { UseQueryResult } from '@tanstack/react-query';
|
|
|
2
2
|
import { ApiClients, ApiQueryOptions, Argument, DataType, NullableParameters } from '../types';
|
|
3
3
|
declare type Client = ApiClients['shopperSearch'];
|
|
4
4
|
/**
|
|
5
|
-
* Provides keyword and refinement search functionality for products.
|
|
6
|
-
|
|
5
|
+
* Provides keyword and refinement search functionality for products.
|
|
6
|
+
*
|
|
7
|
+
* Only returns the product ID, link, and name in the product search hit.
|
|
8
|
+
* The search result contains only products that are online and assigned to site catalog.
|
|
9
|
+
* @group ShopperSearch
|
|
10
|
+
* @category Query
|
|
7
11
|
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
8
12
|
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
9
13
|
* @returns A TanStack Query query hook with data from the Shopper Search `productSearch` endpoint.
|
|
@@ -13,7 +17,11 @@ the product search hit. The search result contains only products that are online
|
|
|
13
17
|
*/
|
|
14
18
|
export declare const useProductSearch: (apiOptions: NullableParameters<Argument<Client['productSearch']>>, queryOptions?: ApiQueryOptions<Client['productSearch']>) => UseQueryResult<DataType<Client['productSearch']>>;
|
|
15
19
|
/**
|
|
16
|
-
* Provides keyword search functionality for products, categories, and brands suggestions.
|
|
20
|
+
* Provides keyword search functionality for products, categories, and brands suggestions.
|
|
21
|
+
*
|
|
22
|
+
* Returns suggested products, suggested categories, and suggested brands for the given search phrase.
|
|
23
|
+
* @group ShopperSearch
|
|
24
|
+
* @category Query
|
|
17
25
|
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
18
26
|
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
19
27
|
* @returns A TanStack Query query hook with data from the Shopper Search `getSearchSuggestions` endpoint.
|
|
@@ -19,8 +19,12 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
19
19
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
20
20
|
*/
|
|
21
21
|
/**
|
|
22
|
-
* Provides keyword and refinement search functionality for products.
|
|
23
|
-
|
|
22
|
+
* Provides keyword and refinement search functionality for products.
|
|
23
|
+
*
|
|
24
|
+
* Only returns the product ID, link, and name in the product search hit.
|
|
25
|
+
* The search result contains only products that are online and assigned to site catalog.
|
|
26
|
+
* @group ShopperSearch
|
|
27
|
+
* @category Query
|
|
24
28
|
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
25
29
|
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
26
30
|
* @returns A TanStack Query query hook with data from the Shopper Search `productSearch` endpoint.
|
|
@@ -58,7 +62,11 @@ const useProductSearch = (apiOptions, queryOptions = {}) => {
|
|
|
58
62
|
});
|
|
59
63
|
};
|
|
60
64
|
/**
|
|
61
|
-
* Provides keyword search functionality for products, categories, and brands suggestions.
|
|
65
|
+
* Provides keyword search functionality for products, categories, and brands suggestions.
|
|
66
|
+
*
|
|
67
|
+
* Returns suggested products, suggested categories, and suggested brands for the given search phrase.
|
|
68
|
+
* @group ShopperSearch
|
|
69
|
+
* @category Query
|
|
62
70
|
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
|
|
63
71
|
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
|
|
64
72
|
* @returns A TanStack Query query hook with data from the Shopper Search `getSearchSuggestions` endpoint.
|
package/hooks/types.d.ts
CHANGED
|
@@ -41,6 +41,9 @@ export declare type ApiClientConfigParams = {
|
|
|
41
41
|
locale?: string;
|
|
42
42
|
currency?: string;
|
|
43
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* A map of commerce-sdk-isomorphic API client instances.
|
|
46
|
+
*/
|
|
44
47
|
export interface ApiClients {
|
|
45
48
|
shopperBaskets: ShopperBaskets<ApiClientConfigParams>;
|
|
46
49
|
shopperContexts: ShopperContexts<ApiClientConfigParams>;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @group Shopper Authentication helpers
|
|
3
|
+
*/
|
|
1
4
|
interface AccessToken {
|
|
2
5
|
token: string | null;
|
|
3
6
|
getTokenWhenReady: () => Promise<string>;
|
|
@@ -5,6 +8,9 @@ interface AccessToken {
|
|
|
5
8
|
/**
|
|
6
9
|
* Hook that returns the access token.
|
|
7
10
|
*
|
|
11
|
+
* @group Helpers
|
|
12
|
+
* @category Shopper Authentication
|
|
13
|
+
*
|
|
8
14
|
*/
|
|
9
15
|
declare const useAccessToken: () => AccessToken;
|
|
10
16
|
export default useAccessToken;
|
package/hooks/useAccessToken.js
CHANGED
|
@@ -16,9 +16,17 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
const onClient = typeof window !== 'undefined';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @group Shopper Authentication helpers
|
|
22
|
+
*/
|
|
23
|
+
|
|
19
24
|
/**
|
|
20
25
|
* Hook that returns the access token.
|
|
21
26
|
*
|
|
27
|
+
* @group Helpers
|
|
28
|
+
* @category Shopper Authentication
|
|
29
|
+
*
|
|
22
30
|
*/
|
|
23
31
|
const useAccessToken = () => {
|
|
24
32
|
const config = (0, _useConfig.default)();
|
package/hooks/useAuthHelper.d.ts
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
import { UseMutationResult } from '@tanstack/react-query';
|
|
2
2
|
import Auth from '../auth';
|
|
3
|
+
/**
|
|
4
|
+
* @group Helpers
|
|
5
|
+
* @category Shopper Authentication
|
|
6
|
+
* @enum
|
|
7
|
+
*/
|
|
3
8
|
export declare const AuthHelpers: {
|
|
4
9
|
readonly LoginGuestUser: "loginGuestUser";
|
|
5
10
|
readonly LoginRegisteredUserB2C: "loginRegisteredUserB2C";
|
|
6
11
|
readonly Logout: "logout";
|
|
7
12
|
readonly Register: "register";
|
|
8
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* @group Helpers
|
|
16
|
+
* @category Shopper Authentication
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
9
19
|
export declare type AuthHelper = (typeof AuthHelpers)[keyof typeof AuthHelpers];
|
|
10
20
|
/**
|
|
11
21
|
* A hook for Public Client OAuth helpers.
|
|
22
|
+
*
|
|
12
23
|
* The hook calls the SLAS helpers imported from commerce-sdk-isomorphic.
|
|
13
24
|
* For more, see https://github.com/SalesforceCommerceCloud/commerce-sdk-isomorphic/#public-client-shopper-login-helpers
|
|
14
25
|
*
|
|
@@ -17,6 +28,9 @@ export declare type AuthHelper = (typeof AuthHelpers)[keyof typeof AuthHelpers];
|
|
|
17
28
|
* - loginGuestUser
|
|
18
29
|
* - logout
|
|
19
30
|
* - register
|
|
31
|
+
*
|
|
32
|
+
* @group Helpers
|
|
33
|
+
* @category Shopper Authentication
|
|
20
34
|
*/
|
|
21
35
|
export declare function useAuthHelper<Mutation extends AuthHelper>(mutation: Mutation): UseMutationResult<ReturnType<Auth[Mutation]> extends Promise<infer Data> ? Data : never, unknown, [
|
|
22
36
|
] extends Parameters<Auth[Mutation]> ? void : Parameters<Auth[Mutation]>[0], unknown>;
|
package/hooks/useAuthHelper.js
CHANGED
|
@@ -16,16 +16,32 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
16
16
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* @group Helpers
|
|
21
|
+
* @category Shopper Authentication
|
|
22
|
+
* @enum
|
|
23
|
+
*/
|
|
19
24
|
const AuthHelpers = {
|
|
20
25
|
LoginGuestUser: 'loginGuestUser',
|
|
21
26
|
LoginRegisteredUserB2C: 'loginRegisteredUserB2C',
|
|
22
27
|
Logout: 'logout',
|
|
23
28
|
Register: 'register'
|
|
24
29
|
};
|
|
30
|
+
/**
|
|
31
|
+
* @group Helpers
|
|
32
|
+
* @category Shopper Authentication
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
25
35
|
exports.AuthHelpers = AuthHelpers;
|
|
26
36
|
const noop = () => ({});
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
|
|
27
42
|
/**
|
|
28
43
|
* A hook for Public Client OAuth helpers.
|
|
44
|
+
*
|
|
29
45
|
* The hook calls the SLAS helpers imported from commerce-sdk-isomorphic.
|
|
30
46
|
* For more, see https://github.com/SalesforceCommerceCloud/commerce-sdk-isomorphic/#public-client-shopper-login-helpers
|
|
31
47
|
*
|
|
@@ -34,6 +50,9 @@ const noop = () => ({});
|
|
|
34
50
|
* - loginGuestUser
|
|
35
51
|
* - logout
|
|
36
52
|
* - register
|
|
53
|
+
*
|
|
54
|
+
* @group Helpers
|
|
55
|
+
* @category Shopper Authentication
|
|
37
56
|
*/
|
|
38
57
|
function useAuthHelper(mutation) {
|
|
39
58
|
const auth = (0, _useAuthContext.default)();
|
|
@@ -2,6 +2,8 @@ import { ApiClients } from './types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Access a set of initialized Commerce API clients, which are initialized using the configurations passed to the CommerceApiProvider.
|
|
4
4
|
*
|
|
5
|
+
* @group Helpers
|
|
6
|
+
*
|
|
5
7
|
* @returns Commerce API clients
|
|
6
8
|
*/
|
|
7
9
|
declare const useCommerceApi: () => ApiClients;
|
package/hooks/useCommerceApi.js
CHANGED
|
@@ -17,6 +17,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
17
17
|
/**
|
|
18
18
|
* Access a set of initialized Commerce API clients, which are initialized using the configurations passed to the CommerceApiProvider.
|
|
19
19
|
*
|
|
20
|
+
* @group Helpers
|
|
21
|
+
*
|
|
20
22
|
* @returns Commerce API clients
|
|
21
23
|
*/
|
|
22
24
|
const useCommerceApi = () => {
|
package/hooks/useCustomerId.d.ts
CHANGED
package/hooks/useCustomerId.js
CHANGED
|
@@ -15,6 +15,9 @@ declare type useCustomerType = {
|
|
|
15
15
|
* During initialization, type is null. And it is possible that
|
|
16
16
|
* isGuest and isRegistered to both be false.
|
|
17
17
|
*
|
|
18
|
+
* @group Helpers
|
|
19
|
+
* @category Shopper Authentication
|
|
20
|
+
*
|
|
18
21
|
*/
|
|
19
22
|
declare const useCustomerType: () => useCustomerType;
|
|
20
23
|
export default useCustomerType;
|
package/hooks/useCustomerType.js
CHANGED
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _useAuthContext = _interopRequireDefault(require("./useAuthContext"));
|
|
8
|
+
var _useLocalStorage = _interopRequireDefault(require("./useLocalStorage"));
|
|
9
|
+
var _useConfig = _interopRequireDefault(require("./useConfig"));
|
|
8
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
11
|
/*
|
|
10
12
|
* Copyright (c) 2023, salesforce.com, inc.
|
|
@@ -13,6 +15,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
13
15
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
14
16
|
*/
|
|
15
17
|
|
|
18
|
+
const onClient = typeof window !== 'undefined';
|
|
16
19
|
/**
|
|
17
20
|
* A hook to return customer auth type.
|
|
18
21
|
*
|
|
@@ -24,10 +27,18 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
24
27
|
* During initialization, type is null. And it is possible that
|
|
25
28
|
* isGuest and isRegistered to both be false.
|
|
26
29
|
*
|
|
30
|
+
* @group Helpers
|
|
31
|
+
* @category Shopper Authentication
|
|
32
|
+
*
|
|
27
33
|
*/
|
|
28
34
|
const useCustomerType = () => {
|
|
35
|
+
const config = (0, _useConfig.default)();
|
|
29
36
|
const auth = (0, _useAuthContext.default)();
|
|
30
|
-
let customerType =
|
|
37
|
+
let customerType = onClient ?
|
|
38
|
+
// This conditional is a constant value based on the environment, so the same path will
|
|
39
|
+
// always be followed., and the "rule of hooks" is not violated.
|
|
40
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
41
|
+
(0, _useLocalStorage.default)(`customer_type_${config.siteId}`) : auth.get('customer_type');
|
|
31
42
|
const isGuest = customerType === 'guest';
|
|
32
43
|
const isRegistered = customerType === 'registered';
|
|
33
44
|
if (customerType !== null && customerType !== 'guest' && customerType !== 'registered') {
|
package/hooks/useEncUserId.d.ts
CHANGED
package/hooks/useEncUserId.js
CHANGED
|
@@ -22,6 +22,9 @@ const onClient = typeof window !== 'undefined';
|
|
|
22
22
|
*
|
|
23
23
|
* This is sometimes used as the user ID for Einstein.
|
|
24
24
|
*
|
|
25
|
+
* @group Helpers
|
|
26
|
+
* @category Shopper Authentication
|
|
27
|
+
*
|
|
25
28
|
*/
|
|
26
29
|
const useEncUserId = () => {
|
|
27
30
|
const config = (0, _useConfig.default)();
|
package/hooks/useUsid.d.ts
CHANGED
package/hooks/useUsid.js
CHANGED
|
@@ -20,6 +20,8 @@ const onClient = typeof window !== 'undefined';
|
|
|
20
20
|
/**
|
|
21
21
|
* Hook that returns the usid associated with the current access token.
|
|
22
22
|
*
|
|
23
|
+
* @group Helpers
|
|
24
|
+
* @category Shopper Authentication
|
|
23
25
|
*/
|
|
24
26
|
const useUsid = () => {
|
|
25
27
|
const config = (0, _useConfig.default)();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/commerce-sdk-react",
|
|
3
|
-
"version": "1.0.0-preview.
|
|
3
|
+
"version": "1.0.0-preview.1",
|
|
4
4
|
"description": "A library that provides react hooks for fetching data from Commerce Cloud",
|
|
5
5
|
"homepage": "https://github.com/SalesforceCommerceCloud/pwa-kit/tree/develop/packages/ecom-react-hooks#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build": "cross-env NODE_ENV=production internal-lib-build build && tsc --emitDeclarationOnly",
|
|
29
|
-
"build:docs": "typedoc",
|
|
29
|
+
"build:docs": "typedoc --plugin typedoc-plugin-missing-exports --hideGenerator",
|
|
30
30
|
"build:watch": "nodemon --watch 'src/**' --ext 'tsx,ts' --exec 'npm run build'",
|
|
31
31
|
"format": "internal-lib-build format \"**/*.{js,jsx,ts,tsx}\"",
|
|
32
32
|
"lint": "npm run lint:js && tsc --noEmit",
|
|
@@ -42,10 +42,12 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"commerce-sdk-isomorphic": "^1.10.1",
|
|
44
44
|
"js-cookie": "^3.0.1",
|
|
45
|
-
"jwt-decode": "^3.1.2"
|
|
45
|
+
"jwt-decode": "^3.1.2",
|
|
46
|
+
"typedoc": "^0.24.7",
|
|
47
|
+
"typedoc-plugin-missing-exports": "^2.0.0"
|
|
46
48
|
},
|
|
47
49
|
"devDependencies": {
|
|
48
|
-
"@salesforce/pwa-kit-dev": "3.0.0-preview.
|
|
50
|
+
"@salesforce/pwa-kit-dev": "3.0.0-preview.1",
|
|
49
51
|
"@tanstack/react-query": "^4.28.0",
|
|
50
52
|
"@testing-library/jest-dom": "^5.16.5",
|
|
51
53
|
"@testing-library/react": "^14.0.0",
|
|
@@ -57,7 +59,7 @@
|
|
|
57
59
|
"@types/react-dom": "^18.2.1",
|
|
58
60
|
"@types/react-helmet": "^6.1.6",
|
|
59
61
|
"cross-env": "^5.2.1",
|
|
60
|
-
"internal-lib-build": "3.0.0-preview.
|
|
62
|
+
"internal-lib-build": "3.0.0-preview.1",
|
|
61
63
|
"jsonwebtoken": "^8.5.1",
|
|
62
64
|
"nock": "^13.3.0",
|
|
63
65
|
"nodemon": "^2.0.22",
|
|
@@ -84,5 +86,5 @@
|
|
|
84
86
|
"publishConfig": {
|
|
85
87
|
"directory": "dist"
|
|
86
88
|
},
|
|
87
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "457b0179e4cf536e55bf9b21758302ff68ef3ea4"
|
|
88
90
|
}
|
package/provider.d.ts
CHANGED
|
@@ -28,7 +28,33 @@ export declare const AuthContext: React.Context<Auth>;
|
|
|
28
28
|
/**
|
|
29
29
|
* Initialize a set of Commerce API clients and make it available to all of descendant components
|
|
30
30
|
*
|
|
31
|
-
* @
|
|
31
|
+
* @group Components
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```js
|
|
35
|
+
import {CommerceApiProvider} from '@salesforce/commerce-sdk-react'
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
const App = ({children}) => {
|
|
39
|
+
return (
|
|
40
|
+
<CommerceApiProvider
|
|
41
|
+
clientId="12345678-1234-1234-1234-123412341234"
|
|
42
|
+
organizationId="f_ecom_aaaa_001"
|
|
43
|
+
proxy="localhost:3000/mobify/proxy/api"
|
|
44
|
+
redirectURI="localhost:3000/callback"
|
|
45
|
+
siteId="RefArch"
|
|
46
|
+
shortCode="12345678"
|
|
47
|
+
locale="en-US"
|
|
48
|
+
currency="USD"
|
|
49
|
+
>
|
|
50
|
+
{children}
|
|
51
|
+
</CommerceApiProvider>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default App
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
32
58
|
* @returns Provider to wrap your app with
|
|
33
59
|
*/
|
|
34
60
|
declare const CommerceApiProvider: (props: CommerceApiProviderProps) => ReactElement;
|