commerce-sdk-isomorphic 4.0.0-nightly-20251023080805 → 4.0.0-nightly-20251025080611
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 +56 -0
- package/lib/helpers.cjs.d.ts +5 -0
- package/lib/helpers.cjs.js +1 -1
- package/lib/helpers.d.ts +5 -0
- package/lib/helpers.js +1 -1
- package/lib/importUtil.cjs.d.ts +4 -0
- package/lib/importUtil.cjs.js +1 -0
- package/lib/importUtil.d.ts +4 -0
- package/lib/importUtil.js +1 -0
- package/lib/index.cjs.d.ts +5 -0
- package/lib/index.cjs.js +1 -1
- package/lib/index.esm.d.ts +5 -0
- package/lib/index.esm.js +1 -1
- package/lib/shopperBaskets.cjs.js +1 -1
- package/lib/shopperBaskets.js +1 -1
- package/lib/shopperBasketsv2.cjs.js +1 -1
- package/lib/shopperBasketsv2.js +1 -1
- package/lib/shopperConfigurations.cjs.js +1 -1
- package/lib/shopperConfigurations.js +1 -1
- package/lib/shopperConsents.cjs.js +1 -1
- package/lib/shopperConsents.js +1 -1
- package/lib/shopperContext.cjs.js +1 -1
- package/lib/shopperContext.js +1 -1
- package/lib/shopperCustomers.cjs.js +1 -1
- package/lib/shopperCustomers.js +1 -1
- package/lib/shopperExperience.cjs.js +1 -1
- package/lib/shopperExperience.js +1 -1
- package/lib/shopperGiftCertificates.cjs.js +1 -1
- package/lib/shopperGiftCertificates.js +1 -1
- package/lib/shopperLogin.cjs.js +1 -1
- package/lib/shopperLogin.js +1 -1
- package/lib/shopperOrders.cjs.js +1 -1
- package/lib/shopperOrders.js +1 -1
- package/lib/shopperPayments.cjs.js +1 -1
- package/lib/shopperPayments.js +1 -1
- package/lib/shopperProducts.cjs.js +1 -1
- package/lib/shopperProducts.js +1 -1
- package/lib/shopperPromotions.cjs.js +1 -1
- package/lib/shopperPromotions.js +1 -1
- package/lib/shopperSearch.cjs.js +1 -1
- package/lib/shopperSearch.js +1 -1
- package/lib/shopperSeo.cjs.js +1 -1
- package/lib/shopperSeo.js +1 -1
- package/lib/shopperStores.cjs.js +1 -1
- package/lib/shopperStores.js +1 -1
- package/lib/version.cjs.d.ts +1 -1
- package/lib/version.cjs.js +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +14 -2
package/README.md
CHANGED
|
@@ -340,6 +340,62 @@ console.log("categoriesResult: ", categoriesResult);
|
|
|
340
340
|
|
|
341
341
|
**NOTE: In the next major version release, path parameters will be single encoded by default**
|
|
342
342
|
|
|
343
|
+
#### Dynamic Import Utility (`importUtil`)
|
|
344
|
+
|
|
345
|
+
This utility enables on-demand loading of individual APIs to keep your initial bundle small and improve page performance.
|
|
346
|
+
|
|
347
|
+
##### When and why to use it
|
|
348
|
+
- **Slimmer initial bundle**: Only load the API you need at the moment (e.g., load `ShopperSearch` on a search page, not at app startup).
|
|
349
|
+
- **Code-splitting friendly**: Uses dynamic `import()` under the hood so bundlers split APIs into separate chunks automatically.
|
|
350
|
+
- **Faster startup/TTI**: Defer heavy SDK code until the user triggers a feature.
|
|
351
|
+
- **Server and browser**: Works in both ESM and CommonJS environments.
|
|
352
|
+
|
|
353
|
+
##### How to use
|
|
354
|
+
|
|
355
|
+
1) Import the utility (and optional key type):
|
|
356
|
+
|
|
357
|
+
```ts
|
|
358
|
+
import { sdkImporters } from 'commerce-sdk-isomorphic/importUtil';
|
|
359
|
+
import type { CommerceSdkKeyMap } from 'commerce-sdk-isomorphic/importUtil';
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
2) Dynamically load a specific API (ESM):
|
|
363
|
+
|
|
364
|
+
```ts
|
|
365
|
+
// inside an async function
|
|
366
|
+
const { ShopperSearch } = await sdkImporters.ShopperSearch();
|
|
367
|
+
|
|
368
|
+
const shopperSearch = new ShopperSearch({
|
|
369
|
+
proxy: 'https://localhost:3000',
|
|
370
|
+
parameters: {
|
|
371
|
+
clientId: '<your-client-id>',
|
|
372
|
+
organizationId: '<your-org-id>',
|
|
373
|
+
shortCode: '<your-short-code>',
|
|
374
|
+
siteId: '<your-site-id>',
|
|
375
|
+
},
|
|
376
|
+
headers: { authorization: `Bearer ${accessToken}` },
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
const result = await shopperSearch.productSearch({ parameters: { q: 'shirt' } });
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
3) CommonJS usage:
|
|
383
|
+
|
|
384
|
+
```js
|
|
385
|
+
const { sdkImporters } = require('commerce-sdk-isomorphic/importUtil');
|
|
386
|
+
|
|
387
|
+
(async () => {
|
|
388
|
+
const { ShopperLogin } = await sdkImporters.ShopperLogin();
|
|
389
|
+
const slas = new ShopperLogin({ /* config */ });
|
|
390
|
+
})();
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
##### Additional notes
|
|
394
|
+
- **Subpath exports**: This utility depends on `package.json` subpath exports (e.g., `"./shopperSearch"`). When adding a new API, ensure you add matching entries; see Contributing > New APIs.
|
|
395
|
+
- **Chunking behavior**: Each API becomes a separate chunk in modern bundlers. Prefer loading at route or feature boundaries.
|
|
396
|
+
- **Error handling**: If a subpath export is missing or fails to load, the promise will reject. Handle with `try/catch` as needed.
|
|
397
|
+
- **Naming**: Keys are PascalCase (e.g., `ShopperBasketsV2`) while subpaths are lower camel case (e.g., `shopperBasketsv2`).
|
|
398
|
+
|
|
343
399
|
## License Information
|
|
344
400
|
|
|
345
401
|
The Commerce SDK Isomorphic is licensed under BSD-3-Clause license. See the [license](./LICENSE.txt) for details.
|
package/lib/helpers.cjs.d.ts
CHANGED
|
@@ -2093,6 +2093,11 @@ declare function authorizePasswordless(options: {
|
|
|
2093
2093
|
userid: string;
|
|
2094
2094
|
locale?: string;
|
|
2095
2095
|
mode: string;
|
|
2096
|
+
registerCustomer?: boolean;
|
|
2097
|
+
lastName?: string;
|
|
2098
|
+
email?: string;
|
|
2099
|
+
firstName?: string;
|
|
2100
|
+
phoneNumber?: string;
|
|
2096
2101
|
};
|
|
2097
2102
|
}): Promise<Response>;
|
|
2098
2103
|
/**
|