Skip to content

Commit 5494666

Browse files
committed
W-21432256 Continue addressing code review comments
1 parent 4ff3c4f commit 5494666

File tree

14 files changed

+55
-46
lines changed

14 files changed

+55
-46
lines changed

packages/commerce-sdk-react/src/hooks/ShopperBasketsV2/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {cacheUpdateMatrix} from './cache'
1010
import {ShopperBasketsMutations as mutations} from './mutation'
1111
import * as queries from './query'
1212

13-
describe('Shopper Baskets hooks', () => {
13+
describe('Shopper Baskets V2 hooks', () => {
1414
test('all endpoints have hooks', () => {
1515
// unimplemented = SDK method exists, but no query hook or value in mutations enum
1616
const unimplemented = getUnimplementedEndpoints(ShopperBasketsV2, queries, mutations)

packages/commerce-sdk-react/src/hooks/ShopperBasketsV2/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023, Salesforce, Inc.
2+
* Copyright (c) 2026, Salesforce, Inc.
33
* All rights reserved.
44
* SPDX-License-Identifier: BSD-3-Clause
55
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause

packages/commerce-sdk-react/src/hooks/ShopperBasketsV2/mutation.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ const emptyResponseTestCases = [
203203
// Most test cases only apply to non-empty response test cases, some (error handling) can include deleteBasket
204204
const allTestCases = [...nonEmptyResponseTestCases, ...emptyResponseTestCases]
205205

206-
describe('ShopperBaskets mutations', () => {
206+
describe('ShopperBasketsV2 mutations', () => {
207207
const storedCustomerIdKey = `customer_id_${DEFAULT_TEST_CONFIG.siteId}`
208208
beforeAll(() => {
209209
// Make sure we don't accidentally overwrite something before setting up our test state

packages/commerce-sdk-react/src/hooks/ShopperBasketsV2/mutation.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ const CLIENT_KEY = CLIENT_KEYS.SHOPPER_BASKETS_V2
1515
type Client = NonNullable<ApiClients[typeof CLIENT_KEY]>
1616

1717
/**
18-
* Mutations available for Shopper Baskets.
19-
* @group ShopperBaskets
18+
* Mutations available for Shopper Baskets V2.
19+
* @group ShopperBasketsV2
2020
* @category Mutation
2121
* @enum
2222
*/
@@ -165,16 +165,16 @@ export const ShopperBasketsMutations = {
165165
} as const
166166

167167
/**
168-
* Type for Shopper Baskets Mutation.
169-
* @group ShopperBaskets
168+
* Type for Shopper Baskets V2 Mutation.
169+
* @group ShopperBasketsV2
170170
* @category Mutation
171171
*/
172172
export type ShopperBasketsMutation =
173173
(typeof ShopperBasketsMutations)[keyof typeof ShopperBasketsMutations]
174174

175175
/**
176-
* Mutation hook for Shopper Baskets.
177-
* @group ShopperBaskets
176+
* Mutation hook for Shopper Baskets V2.
177+
* @group ShopperBasketsV2
178178
* @category Mutation
179179
*/
180180
export function useShopperBasketsMutation<Mutation extends ShopperBasketsMutation>(

packages/commerce-sdk-react/src/hooks/ShopperBasketsV2/query.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const testMap: TestMap = {
4141
}
4242
// Type assertion is necessary because `Object.entries` is limited
4343
const testCases = Object.entries(testMap) as Array<[keyof TestMap, TestMap[keyof TestMap]]>
44-
describe('Shopper Baskets query hooks', () => {
44+
describe('Shopper Baskets V2 query hooks', () => {
4545
beforeEach(() => nock.cleanAll())
4646
afterEach(() => {
4747
expect(nock.pendingMocks()).toHaveLength(0)

packages/commerce-sdk-react/src/hooks/ShopperBasketsV2/query.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ type Client = NonNullable<ApiClients[typeof CLIENT_KEY]>
1818

1919
/**
2020
* Gets a basket.
21-
* @group ShopperBaskets
21+
* @group ShopperBasketsV2
2222
* @category Query
2323
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
2424
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
25-
* @returns A TanStack Query query hook with data from the Shopper Baskets `getBasket` endpoint.
25+
* @returns A TanStack Query query hook with data from the Shopper Baskets V2 `getBasket` endpoint.
2626
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-baskets?meta=getBasket| Salesforce Developer Center} for more information about the API endpoint.
2727
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperbaskets.shopperbaskets-1.html#getbasket | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
2828
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
@@ -63,11 +63,11 @@ export const useBasket = (
6363
}
6464
/**
6565
* Gets applicable payment methods for an existing basket considering the open payment amount only.
66-
* @group ShopperBaskets
66+
* @group ShopperBasketsV2
6767
* @category Query
6868
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
6969
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
70-
* @returns A TanStack Query query hook with data from the Shopper Baskets `getPaymentMethodsForBasket` endpoint.
70+
* @returns A TanStack Query query hook with data from the Shopper Baskets V2 `getPaymentMethodsForBasket` endpoint.
7171
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-baskets?meta=getPaymentMethodsForBasket| Salesforce Developer Center} for more information about the API endpoint.
7272
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperbaskets.shopperbaskets-1.html#getpaymentmethodsforbasket | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
7373
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
@@ -108,11 +108,11 @@ export const usePaymentMethodsForBasket = (
108108
}
109109
/**
110110
* Gets applicable price books for an existing basket.
111-
* @group ShopperBaskets
111+
* @group ShopperBasketsV2
112112
* @category Query
113113
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
114114
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
115-
* @returns A TanStack Query query hook with data from the Shopper Baskets `getPriceBooksForBasket` endpoint.
115+
* @returns A TanStack Query query hook with data from the Shopper Baskets V2 `getPriceBooksForBasket` endpoint.
116116
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-baskets?meta=getPriceBooksForBasket| Salesforce Developer Center} for more information about the API endpoint.
117117
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperbaskets.shopperbaskets-1.html#getpricebooksforbasket | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
118118
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
@@ -153,11 +153,11 @@ export const usePriceBooksForBasket = (
153153
}
154154
/**
155155
* Gets the applicable shipping methods for a certain shipment of a basket.
156-
* @group ShopperBaskets
156+
* @group ShopperBasketsV2
157157
* @category Query
158158
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
159159
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
160-
* @returns A TanStack Query query hook with data from the Shopper Baskets `getShippingMethodsForShipment` endpoint.
160+
* @returns A TanStack Query query hook with data from the Shopper Baskets V2 `getShippingMethodsForShipment` endpoint.
161161
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-baskets?meta=getShippingMethodsForShipment| Salesforce Developer Center} for more information about the API endpoint.
162162
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperbaskets.shopperbaskets-1.html#getshippingmethodsforshipment | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
163163
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.
@@ -198,11 +198,11 @@ export const useShippingMethodsForShipment = (
198198
}
199199
/**
200200
* This method gives you the external taxation data set by the PUT taxes API. This endpoint can be called only if external taxation mode was used for basket creation. See POST /baskets for more information.
201-
* @group ShopperBaskets
201+
* @group ShopperBasketsV2
202202
* @category Query
203203
* @parameter apiOptions - Options to pass through to `commerce-sdk-isomorphic`, with `null` accepted for unset API parameters.
204204
* @parameter queryOptions - TanStack Query query options, with `enabled` by default set to check that all required API parameters have been set.
205-
* @returns A TanStack Query query hook with data from the Shopper Baskets `getTaxesFromBasket` endpoint.
205+
* @returns A TanStack Query query hook with data from the Shopper Baskets V2 `getTaxesFromBasket` endpoint.
206206
* @see {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-baskets?meta=getTaxesFromBasket| Salesforce Developer Center} for more information about the API endpoint.
207207
* @see {@link https://salesforcecommercecloud.github.io/commerce-sdk-isomorphic/classes/shopperbaskets.shopperbaskets-1.html#gettaxesfrombasket | `commerce-sdk-isomorphic` documentation} for more information on the parameters and returned data type.
208208
* @see {@link https://tanstack.com/query/latest/docs/react/reference/useQuery | TanStack Query `useQuery` reference} for more information about the return value.

packages/commerce-sdk-react/src/hooks/ShopperBasketsV2/queryKeyHelpers.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ export type QueryKeys = {
1616
'/commerce-sdk-react',
1717
'/organizations/',
1818
string | undefined,
19-
'/baskets/',
19+
'/baskets/v2',
2020
string | undefined,
2121
Params<'getBasket'>
2222
]
2323
getPaymentMethodsForBasket: [
2424
'/commerce-sdk-react',
2525
'/organizations/',
2626
string | undefined,
27-
'/baskets/',
27+
'/baskets/v2',
2828
string | undefined,
2929
'/payment-methods',
3030
Params<'getPaymentMethodsForBasket'>
@@ -33,7 +33,7 @@ export type QueryKeys = {
3333
'/commerce-sdk-react',
3434
'/organizations/',
3535
string | undefined,
36-
'/baskets/',
36+
'/baskets/v2',
3737
string | undefined,
3838
'/price-books',
3939
Params<'getPriceBooksForBasket'>
@@ -42,7 +42,7 @@ export type QueryKeys = {
4242
'/commerce-sdk-react',
4343
'/organizations/',
4444
string | undefined,
45-
'/baskets/',
45+
'/baskets/v2',
4646
string | undefined,
4747
'/shipments/',
4848
string | undefined,
@@ -53,7 +53,7 @@ export type QueryKeys = {
5353
'/commerce-sdk-react',
5454
'/organizations/',
5555
string | undefined,
56-
'/baskets/',
56+
'/baskets/v2',
5757
string | undefined,
5858
'/taxes',
5959
Params<'getTaxesFromBasket'>
@@ -74,7 +74,7 @@ export const getBasket: QueryKeyHelper<'getBasket'> = {
7474
'/commerce-sdk-react',
7575
'/organizations/',
7676
params?.organizationId,
77-
'/baskets/',
77+
'/baskets/v2',
7878
params?.basketId
7979
],
8080
queryKey: (params: Params<'getBasket'>) => {
@@ -90,7 +90,7 @@ export const getPaymentMethodsForBasket: QueryKeyHelper<'getPaymentMethodsForBas
9090
'/commerce-sdk-react',
9191
'/organizations/',
9292
params?.organizationId,
93-
'/baskets/',
93+
'/baskets/v2',
9494
params?.basketId,
9595
'/payment-methods'
9696
],
@@ -107,7 +107,7 @@ export const getPriceBooksForBasket: QueryKeyHelper<'getPriceBooksForBasket'> =
107107
'/commerce-sdk-react',
108108
'/organizations/',
109109
params?.organizationId,
110-
'/baskets/',
110+
'/baskets/v2',
111111
params?.basketId,
112112
'/price-books'
113113
],
@@ -124,7 +124,7 @@ export const getShippingMethodsForShipment: QueryKeyHelper<'getShippingMethodsFo
124124
'/commerce-sdk-react',
125125
'/organizations/',
126126
params?.organizationId,
127-
'/baskets/',
127+
'/baskets/v2',
128128
params?.basketId,
129129
'/shipments/',
130130
params?.shipmentId,
@@ -143,7 +143,7 @@ export const getTaxesFromBasket: QueryKeyHelper<'getTaxesFromBasket'> = {
143143
'/commerce-sdk-react',
144144
'/organizations/',
145145
params?.organizationId,
146-
'/baskets/',
146+
'/baskets/v2',
147147
params?.basketId,
148148
'/taxes'
149149
],

packages/pwa-kit-create-app/assets/bootstrap/js/config/default.js.hbs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,9 @@ module.exports = {
160160
// Salesforce Payments configuration
161161
// Set enabled to true to enable Salesforce Payments (requires the Salesforce Payments feature toggle to be enabled on the Commerce Cloud instance).
162162
// Set enabled to false to disable Salesforce Payments on the storefront (the Commerce Cloud feature toggle is unaffected).
163-
// sdkUrl and metadataUrl are hosted on your Commerce Cloud instance. Replace <hostname> with your instance hostname.
164-
// This may be a demandware.net hostname (e.g., myinstance.unified.demandware.net) or a vanity/custom hostname.
165-
// sdkUrl: 'https://<hostname>/on/demandware.static/Sites-Site/-/-/internal/jscript/sfp/v1/sfp.js'
166-
// metadataUrl: 'https://<hostname>/on/demandware.static/Sites-Site/-/-/internal/metadata/v1.json'
163+
// Set the sdkUrl and metadataUrl values to point to your Commerce Cloud instance host by replacing the [bm_or_vanity_host] placeholder with your Business Manager or vanity URL host name.
164+
// sdkUrl: 'https://[bm_or_vanity_host]/on/demandware.static/Sites-Site/-/-/internal/jscript/sfp/v1/sfp.js'
165+
// metadataUrl: 'https://[bm_or_vanity_host]/on/demandware.static/Sites-Site/-/-/internal/metadata/v1.json'
167166
sfPayments: {
168167
enabled: false,
169168
sdkUrl: '',

packages/pwa-kit-create-app/assets/bootstrap/js/overrides/app/ssr.js.hbs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,14 @@ const options = {
3333
port: 3000,
3434

3535
// The protocol on which the development Express app listens.
36+
// Set DEV_SERVER_PROTOCOL to 'https' for HTTPS; defaults to 'http' when unset.
3637
// Note that http://localhost is treated as a secure context for development,
3738
// except by Safari.
38-
protocol: 'http',
39+
protocol: process.env.DEV_SERVER_PROTOCOL || 'http',
40+
41+
// Optional. Path to SSL certificate (.pem) for HTTPS development. Typically a
42+
// self-signed cert for localhost; set DEV_SERVER_SSL_FILE_PATH when using https.
43+
sslFilePath: process.env.DEV_SERVER_SSL_FILE_PATH,
3944

4045
// Option for whether to set up a special endpoint for handling
4146
// private SLAS clients

packages/pwa-kit-create-app/assets/templates/@salesforce/retail-react-app/app/ssr.js.hbs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,14 @@ const options = {
3333
port: 3000,
3434

3535
// The protocol on which the development Express app listens.
36+
// Set DEV_SERVER_PROTOCOL to 'https' for HTTPS; defaults to 'http' when unset.
3637
// Note that http://localhost is treated as a secure context for development,
3738
// except by Safari.
38-
protocol: 'http',
39+
protocol: process.env.DEV_SERVER_PROTOCOL || 'http',
40+
41+
// Optional. Path to SSL certificate (.pem) for HTTPS development. Typically a
42+
// self-signed cert for localhost; set DEV_SERVER_SSL_FILE_PATH when using https.
43+
sslFilePath: process.env.DEV_SERVER_SSL_FILE_PATH,
3944

4045
// Option for whether to set up a special endpoint for handling
4146
// private SLAS clients

0 commit comments

Comments
 (0)