commerce-sdk-isomorphic 4.1.0 → 4.2.0
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/README.md +1 -114
- package/lib/index.cjs.d.ts +1320 -169
- package/lib/index.cjs.js +1 -1
- package/lib/index.esm.d.ts +1320 -169
- package/lib/index.esm.js +1 -1
- package/package.json +24 -91
- package/lib/clientConfig.cjs.d.ts +0 -54
- package/lib/clientConfig.cjs.js +0 -1
- package/lib/clientConfig.d.ts +0 -54
- package/lib/clientConfig.js +0 -1
- package/lib/config.cjs.d.ts +0 -2
- package/lib/config.cjs.js +0 -1
- package/lib/config.d.ts +0 -2
- package/lib/config.js +0 -1
- package/lib/helpers.cjs.d.ts +0 -2225
- package/lib/helpers.cjs.js +0 -1
- package/lib/helpers.d.ts +0 -2225
- package/lib/helpers.js +0 -1
- package/lib/responseError.cjs.d.ts +0 -12
- package/lib/responseError.cjs.js +0 -1
- package/lib/responseError.d.ts +0 -12
- package/lib/responseError.js +0 -1
- package/lib/shopperBaskets.cjs.d.ts +0 -10264
- package/lib/shopperBaskets.cjs.js +0 -1
- package/lib/shopperBaskets.d.ts +0 -10264
- package/lib/shopperBaskets.js +0 -1
- package/lib/shopperBasketsv2.cjs.d.ts +0 -10458
- package/lib/shopperBasketsv2.cjs.js +0 -1
- package/lib/shopperBasketsv2.d.ts +0 -10458
- package/lib/shopperBasketsv2.js +0 -1
- package/lib/shopperConsents.cjs.d.ts +0 -1147
- package/lib/shopperConsents.cjs.js +0 -1
- package/lib/shopperConsents.d.ts +0 -1147
- package/lib/shopperConsents.js +0 -1
- package/lib/shopperContext.cjs.d.ts +0 -1406
- package/lib/shopperContext.cjs.js +0 -1
- package/lib/shopperContext.d.ts +0 -1406
- package/lib/shopperContext.js +0 -1
- package/lib/shopperCustomers.cjs.d.ts +0 -12190
- package/lib/shopperCustomers.cjs.js +0 -1
- package/lib/shopperCustomers.d.ts +0 -12190
- package/lib/shopperCustomers.js +0 -1
- package/lib/shopperExperience.cjs.d.ts +0 -1174
- package/lib/shopperExperience.cjs.js +0 -1
- package/lib/shopperExperience.d.ts +0 -1174
- package/lib/shopperExperience.js +0 -1
- package/lib/shopperGiftCertificates.cjs.d.ts +0 -734
- package/lib/shopperGiftCertificates.cjs.js +0 -1
- package/lib/shopperGiftCertificates.d.ts +0 -734
- package/lib/shopperGiftCertificates.js +0 -1
- package/lib/shopperLogin.cjs.d.ts +0 -3847
- package/lib/shopperLogin.cjs.js +0 -1
- package/lib/shopperLogin.d.ts +0 -3847
- package/lib/shopperLogin.js +0 -1
- package/lib/shopperOrders.cjs.d.ts +0 -5398
- package/lib/shopperOrders.cjs.js +0 -1
- package/lib/shopperOrders.d.ts +0 -5398
- package/lib/shopperOrders.js +0 -1
- package/lib/shopperProducts.cjs.d.ts +0 -3484
- package/lib/shopperProducts.cjs.js +0 -1
- package/lib/shopperProducts.d.ts +0 -3484
- package/lib/shopperProducts.js +0 -1
- package/lib/shopperPromotions.cjs.d.ts +0 -1006
- package/lib/shopperPromotions.cjs.js +0 -1
- package/lib/shopperPromotions.d.ts +0 -1006
- package/lib/shopperPromotions.js +0 -1
- package/lib/shopperSearch.cjs.d.ts +0 -3357
- package/lib/shopperSearch.cjs.js +0 -1
- package/lib/shopperSearch.d.ts +0 -3357
- package/lib/shopperSearch.js +0 -1
- package/lib/shopperSeo.cjs.d.ts +0 -774
- package/lib/shopperSeo.cjs.js +0 -1
- package/lib/shopperSeo.d.ts +0 -774
- package/lib/shopperSeo.js +0 -1
- package/lib/shopperStores.cjs.d.ts +0 -1294
- package/lib/shopperStores.cjs.js +0 -1
- package/lib/shopperStores.d.ts +0 -1294
- package/lib/shopperStores.js +0 -1
- package/lib/templateUrl.cjs.d.ts +0 -76
- package/lib/templateUrl.cjs.js +0 -1
- package/lib/templateUrl.d.ts +0 -76
- package/lib/templateUrl.js +0 -1
- package/lib/version.cjs.d.ts +0 -3
- package/lib/version.cjs.js +0 -1
- package/lib/version.d.ts +0 -3
- package/lib/version.js +0 -1
package/README.md
CHANGED
|
@@ -65,17 +65,7 @@ yarn install commerce-sdk-isomorphic
|
|
|
65
65
|
### Usage
|
|
66
66
|
|
|
67
67
|
```javascript
|
|
68
|
-
import
|
|
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';
|
|
79
69
|
|
|
80
70
|
const config = {
|
|
81
71
|
// SCAPI does not support CORS, so client side requests must use a reverse proxy.
|
|
@@ -103,91 +93,6 @@ const searchResult = await shopperSearch.productSearch({
|
|
|
103
93
|
});
|
|
104
94
|
```
|
|
105
95
|
|
|
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
|
-
|
|
191
96
|
#### Fetch Options
|
|
192
97
|
|
|
193
98
|
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);
|
|
|
379
284
|
|
|
380
285
|
**NOTE: In the next major version release, path parameters will be single encoded by default**
|
|
381
286
|
|
|
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
|
-
|
|
400
287
|
## License Information
|
|
401
288
|
|
|
402
289
|
The Commerce SDK Isomorphic is licensed under BSD-3-Clause license. See the [license](./LICENSE.txt) for details.
|