Skip to content

Commit ac1728d

Browse files
Fix: Revert experimental features (@W-20201209@) (#253)
* Release v4.0.1 (#251) * add hot fix * bump size * revert experimental features * update README and bump size
1 parent 30911a2 commit ac1728d

File tree

16 files changed

+121
-565
lines changed

16 files changed

+121
-565
lines changed

CHANGELOG.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
# CHANGELOG
22

3-
## v4.1.0
4-
5-
### Enhancements
6-
7-
- Allow developers to pass in custom fetch implementation via `clientConfig` [#246](https://github.com/SalesforceCommerceCloud/commerce-sdk-isomorphic/pull/246)
8-
- Support subpath imports for individual APIs and named imports [#219](https://github.com/SalesforceCommerceCloud/commerce-sdk-isomorphic/pull/219)
3+
## v4.0.1
94

105
### Bug Fixes
11-
126
- Fix incorrect encoding of multi-segment endpoint paths in `callCustomEndpoint` [#246](https://github.com/SalesforceCommerceCloud/commerce-sdk-isomorphic/pull/246)
137

148
## v4.0.0

README.md

Lines changed: 1 addition & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,7 @@ yarn install commerce-sdk-isomorphic
6565
### Usage
6666

6767
```javascript
68-
import ocapi from 'commerce-sdk-isomorphic';
69-
const { helpers, ShopperLogin, ShopperSearch } = ocapi;
70-
71-
// Named imports also work
72-
// import {helpers, ShopperLogin, ShopperSearch} from 'commerce-sdk-isomorphic';
73-
74-
// Alternatively, you can use subpath imports to import a single API at a time instead of the entire SDK
75-
// Useful for when you want a slimmer bundle size and only need a single API
76-
// import * as helpers from 'commerce-sdk-isomorphic/helpers'
77-
// import { ShopperProducts } from 'commerce-sdk-isomorphic/shopperProducts';
78-
// import { ShopperSearch } from 'commerce-sdk-isomorphic/shopperSearch';
68+
import {helpers, ShopperLogin, ShopperSearch} from 'commerce-sdk-isomorphic';
7969

8070
const config = {
8171
// SCAPI does not support CORS, so client side requests must use a reverse proxy.
@@ -103,91 +93,6 @@ const searchResult = await shopperSearch.productSearch({
10393
});
10494
```
10595

106-
#### Import Strategies
107-
108-
The SDK supports multiple import patterns to accommodate different use cases:
109-
110-
**Default Import (Full SDK)**
111-
```javascript
112-
import ocapi from 'commerce-sdk-isomorphic';
113-
const { helpers, ShopperLogin, ShopperSearch } = ocapi;
114-
```
115-
116-
**Named Imports (Full SDK)**
117-
```javascript
118-
import { helpers, ShopperLogin, ShopperSearch } from 'commerce-sdk-isomorphic';
119-
```
120-
121-
**Subpath Imports (Individual APIs and Common dependencies)**
122-
123-
*ESM (ES Modules):*
124-
```javascript
125-
import { ShopperLogin } from 'commerce-sdk-isomorphic/shopperLogin';
126-
import * as helpers from 'commerce-sdk-isomorphic/helpers';
127-
```
128-
129-
*CommonJS:*
130-
```javascript
131-
const { ShopperLogin } = require('commerce-sdk-isomorphic/shopperLogin');
132-
const helpers = require('commerce-sdk-isomorphic/helpers');
133-
```
134-
135-
#### Choosing the Right Import Strategy
136-
137-
**Use Default/Named Imports when:**
138-
- You need multiple APIs from the SDK
139-
- You want the smallest overall bundle size for comprehensive usage
140-
- The entire SDK is optimized and maximally compressed as a single bundle
141-
142-
**Note:** Default and named imports load the entire SDK, including all APIs, helpers, and dependencies.
143-
144-
**Use Subpath Imports when:**
145-
- You only need specific APIs
146-
- You want to minimize initial bundle size
147-
- You're implementing dynamic loading for better page performance
148-
- You need granular control over which APIs are loaded
149-
150-
**Note:** While subpath imports reduce initial bundle size, using them for all APIs will result in a larger total bundle size due to duplicated dependencies required for standalone operation.
151-
152-
#### Custom Fetch function
153-
154-
You can provide your own custom fetch function to intercept, log, or modify all SDK requests. This is useful for:
155-
- **Request/Response Logging**: Track all API calls for debugging and monitoring
156-
- **Request Interception**: Add custom headers, modify request URLs, or implement custom retry logic
157-
- **Error Handling**: Add custom error processing or transformation before responses reach your application
158-
- **Performance Monitoring**: Measure request/response times and track API performance metrics
159-
160-
**Example with Logging:**
161-
```javascript
162-
// Custom fetch function with detailed logging
163-
const customFetch = async (url, options) => {
164-
console.log(`[SDK Request] ${options?.method || 'GET'} ${url}`);
165-
console.log('[SDK Request Headers]', options?.headers);
166-
if (options?.body) {
167-
console.log('[SDK Request Body]', options.body);
168-
}
169-
170-
const startTime = Date.now();
171-
const response = await fetch(url, options);
172-
const duration = Date.now() - startTime;
173-
174-
console.log(`[SDK Response] ${response.status} ${response.statusText} (${duration}ms)`);
175-
console.log('[SDK Response Headers]', Object.fromEntries(response.headers.entries()));
176-
177-
return response;
178-
};
179-
180-
const config = {
181-
parameters: {
182-
clientId: '<your-client-id>',
183-
organizationId: '<your-org-id>',
184-
shortCode: '<your-short-code>',
185-
siteId: '<your-site-id>',
186-
},
187-
fetch: customFetch,
188-
};
189-
```
190-
19196
#### Fetch Options
19297

19398
You can configure how the SDK makes requests using the `fetchOptions` parameter. It is passed to [node-fetch](https://github.com/node-fetch/node-fetch/1#api) on the server and [whatwg-fetch](https://github.github.io/fetch/) on browser.
@@ -379,24 +284,6 @@ console.log("categoriesResult: ", categoriesResult);
379284

380285
**NOTE: In the next major version release, path parameters will be single encoded by default**
381286

382-
## Unstable Releases
383-
384-
**⚠️ Important: Unstable/preview releases are experimental and not officially supported.**
385-
386-
Preview releases (e.g., preview, unstable, or pre-release versions) are provided for experimental purposes and early testing of upcoming features. These releases:
387-
388-
- **Are not intended for production use** - Do not use unstable releases in production environments
389-
- **May contain breaking changes** - API signatures, behavior, and structure may change without notice
390-
- **Are not officially supported** - No support, bug fixes, or security patches are guaranteed
391-
- **May have incomplete features** - Functionality may be partially implemented or subject to change
392-
393-
**Use stable releases for production applications.** Only use unstable releases for:
394-
- Testing upcoming features in development environments
395-
- Providing feedback on new functionality before official release
396-
- Experimental integrations that are not mission-critical
397-
398-
For production deployments, always use the latest stable release version available on npm.
399-
400287
## License Information
401288

402289
The Commerce SDK Isomorphic is licensed under BSD-3-Clause license. See the [license](./LICENSE.txt) for details.

docs/assets/js/search.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/modules/version.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ <h3><span class="tsd-flag ts-flagConst">Const</span> USER_<wbr>AGENT_<wbr>HEADER
9595
<section class="tsd-panel tsd-member tsd-kind-variable tsd-parent-kind-module">
9696
<a name="user_agent_value" class="tsd-anchor"></a>
9797
<h3><span class="tsd-flag ts-flagConst">Const</span> USER_<wbr>AGENT_<wbr>VALUE</h3>
98-
<div class="tsd-signature tsd-kind-icon">USER_<wbr>AGENT_<wbr>VALUE<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">"commerce-sdk-isomorphic@4.1.0"</span><span class="tsd-signature-symbol"> = &quot;commerce-sdk-isomorphic@4.1.0&quot;</span></div>
98+
<div class="tsd-signature tsd-kind-icon">USER_<wbr>AGENT_<wbr>VALUE<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">"commerce-sdk-isomorphic@4.0.1"</span><span class="tsd-signature-symbol"> = &quot;commerce-sdk-isomorphic@4.0.1&quot;</span></div>
9999
<aside class="tsd-sources">
100100
<ul>
101101
<li>Defined in src/lib/version.ts:8</li>

jest.config.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ module.exports = {
1111
'src/static/**/*.{js,jsx,ts,tsx}',
1212
'scripts/**/*.{js,jsx,ts,tsx}',
1313
'!scripts/generate.ts',
14-
'!scripts/generateFileList.ts',
1514
'!scripts/updateApis.ts',
1615
'!scripts/generateVersionTable.ts',
17-
'!scripts/fileList.ts',
1816
'!<rootDir>/node_modules/',
1917
],
2018
coverageReporters: ['text'],

package.json

Lines changed: 24 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "commerce-sdk-isomorphic",
3-
"version": "4.1.0",
3+
"version": "4.0.1",
44
"private": false,
55
"description": "Salesforce Commerce SDK Isomorphic",
66
"bugs": {
@@ -11,94 +11,6 @@
1111
"url": "git+https://github.com/SalesforceCommerceCloud/commerce-sdk-isomorphic.git"
1212
},
1313
"license": "BSD-3-Clause",
14-
"sideEffects": false,
15-
"exports": {
16-
".": {
17-
"import": "./lib/index.esm.js",
18-
"require": "./lib/index.cjs.js"
19-
},
20-
"./shopperBaskets": {
21-
"import": "./lib/shopperBaskets.js",
22-
"require": "./lib/shopperBaskets.cjs.js"
23-
},
24-
"./shopperBasketsv2": {
25-
"import": "./lib/shopperBasketsv2.js",
26-
"require": "./lib/shopperBasketsv2.cjs.js"
27-
},
28-
"./shopperConsents": {
29-
"import": "./lib/shopperConsents.js",
30-
"require": "./lib/shopperConsents.cjs.js"
31-
},
32-
"./shopperContext": {
33-
"import": "./lib/shopperContext.js",
34-
"require": "./lib/shopperContext.cjs.js"
35-
},
36-
"./shopperCustomers": {
37-
"import": "./lib/shopperCustomers.js",
38-
"require": "./lib/shopperCustomers.cjs.js"
39-
},
40-
"./shopperExperience": {
41-
"import": "./lib/shopperExperience.js",
42-
"require": "./lib/shopperExperience.cjs.js"
43-
},
44-
"./shopperGiftCertificates": {
45-
"import": "./lib/shopperGiftCertificates.js",
46-
"require": "./lib/shopperGiftCertificates.cjs.js"
47-
},
48-
"./shopperLogin": {
49-
"import": "./lib/shopperLogin.js",
50-
"require": "./lib/shopperLogin.cjs.js"
51-
},
52-
"./shopperOrders": {
53-
"import": "./lib/shopperOrders.js",
54-
"require": "./lib/shopperOrders.cjs.js"
55-
},
56-
"./shopperProducts": {
57-
"import": "./lib/shopperProducts.js",
58-
"require": "./lib/shopperProducts.cjs.js"
59-
},
60-
"./shopperPromotions": {
61-
"import": "./lib/shopperPromotions.js",
62-
"require": "./lib/shopperPromotions.cjs.js"
63-
},
64-
"./shopperSearch": {
65-
"import": "./lib/shopperSearch.js",
66-
"require": "./lib/shopperSearch.cjs.js"
67-
},
68-
"./shopperSeo": {
69-
"import": "./lib/shopperSeo.js",
70-
"require": "./lib/shopperSeo.cjs.js"
71-
},
72-
"./shopperStores": {
73-
"import": "./lib/shopperStores.js",
74-
"require": "./lib/shopperStores.cjs.js"
75-
},
76-
"./helpers": {
77-
"import": "./lib/helpers.js",
78-
"require": "./lib/helpers.cjs.js"
79-
},
80-
"./clientConfig": {
81-
"import": "./lib/clientConfig.js",
82-
"require": "./lib/clientConfig.cjs.js"
83-
},
84-
"./config": {
85-
"import": "./lib/config.js",
86-
"require": "./lib/config.cjs.js"
87-
},
88-
"./responseError": {
89-
"import": "./lib/responseError.js",
90-
"require": "./lib/responseError.cjs.js"
91-
},
92-
"./templateUrl": {
93-
"import": "./lib/templateUrl.js",
94-
"require": "./lib/templateUrl.cjs.js"
95-
},
96-
"./version": {
97-
"import": "./lib/version.js",
98-
"require": "./lib/version.cjs.js"
99-
},
100-
"./package.json": "./package.json"
101-
},
10214
"main": "lib/index.cjs.js",
10315
"module": "lib/index.esm.js",
10416
"style": "lib/default.css",
@@ -109,7 +21,7 @@
10921
],
11022
"scripts": {
11123
"build": "react-scripts build",
112-
"build:lib": "ts-node --compiler-options '{\"module\": \"commonjs\", \"target\": \"ES6\" }' ./scripts/generateFileList.ts && rollup -c",
24+
"build:lib": "rollup -c",
11325
"check:size": "npm-pack-all --output commerce-sdk-isomorphic-with-deps.tgz && bundlesize",
11426
"check:types": "tsc --noEmit",
11527
"ci": "rm -rf node_modules && yarn install",
@@ -129,7 +41,7 @@
12941
"start": "HTTPS=true react-scripts start",
13042
"pretest": "yarn run lint && yarn run lint:style && depcheck && yarn run check:size",
13143
"test": "yarn run check:types && yarn run test:unit && CI=true yarn run test:react",
132-
"test:react": "react-scripts test --env=jest-environment-jsdom-sixteen src/environment --setupFilesAfterEnv ./src/test/setupTests.ts",
44+
"test:react": "react-scripts test --env=jest-environment-jsdom-sixteen src/environment",
13345
"test:unit": "jest --coverage --testPathIgnorePatterns node_modules src/environment --silent",
13446
"updateApis": "ts-node --compiler-options '{\"module\": \"commonjs\", \"target\": \"ES6\" }' ./scripts/updateApis.ts && yarn diffApis"
13547
},
@@ -157,6 +69,27 @@
15769
"last 1 safari version"
15870
]
15971
},
72+
"jest": {
73+
"collectCoverageFrom": [
74+
"src/static/**/*.{js,jsx,ts,tsx}",
75+
"scripts/**/*.{js,jsx,ts,tsx}",
76+
"!scripts/generate.ts",
77+
"!scripts/updateApis.ts",
78+
"!scripts/generateVersionTable.ts",
79+
"!<rootDir>/node_modules/"
80+
],
81+
"coverageReporters": [
82+
"text"
83+
],
84+
"coverageThreshold": {
85+
"global": {
86+
"branches": 90,
87+
"functions": 90,
88+
"lines": 90,
89+
"statements": 90
90+
}
91+
}
92+
},
16093
"resolutions": {
16194
"**/@npmcli/fs": "<1.1.0",
16295
"**/@oclif/command": "<=1.8.3",

0 commit comments

Comments
 (0)