commerce-sdk-isomorphic 1.3.0 → 1.5.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 +80 -3
- package/README.md +83 -66
- package/lib/index.cjs.d.ts +10168 -0
- package/lib/index.cjs.js +1 -1
- package/lib/index.esm.d.ts +10168 -0
- package/lib/index.esm.js +1 -1
- package/package.json +76 -59
package/CHANGELOG.md
CHANGED
|
@@ -1,36 +1,113 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## v1.5.1
|
|
4
|
+
|
|
5
|
+
#### Documentation
|
|
6
|
+
|
|
7
|
+
* Replaced links to the [Commerce Cloud Developer Center](https://developer.commercecloud.com/s/salesforce-developer-center) with links to the new [Salesforce Developer Portal](https://developer.salesforce.com/docs/commerce/commerce-api).
|
|
8
|
+
|
|
9
|
+
#### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* SLAS Login Helper no longer requests `redirect_uri` when running server-side
|
|
12
|
+
|
|
13
|
+
## v1.5.0
|
|
14
|
+
|
|
15
|
+
#### New Features
|
|
16
|
+
|
|
17
|
+
* SLAS helper functions have been added.
|
|
18
|
+
* New client configuration setting `throwOnBadResponse`. When set to true, responses other than `2xx` and `304` will throw an error.
|
|
19
|
+
|
|
20
|
+
#### New APIs
|
|
21
|
+
|
|
22
|
+
* *Shopper Context* has been added to the SDK.
|
|
23
|
+
|
|
24
|
+
#### API Changes
|
|
25
|
+
|
|
26
|
+
*Shopper Login*
|
|
27
|
+
|
|
28
|
+
* New Endpoints
|
|
29
|
+
|
|
30
|
+
| **Endpoint Name** | **Description** |
|
|
31
|
+
| ------------- |-------------|
|
|
32
|
+
| authorizePasswordlessCustomer | Logs a customer in using Core with their customer profiles loaded in ECOM. Allows the user to authenticate when their identity provider (Core) is down. |
|
|
33
|
+
| getPasswordLessAccessToken | Evaluate the `pwdless_token` and issue the shopper token (JWT). |
|
|
34
|
+
|
|
35
|
+
#### Bug Fixes
|
|
36
|
+
|
|
37
|
+
* Added support for `application/x-www-form-urlencoded` request bodies.
|
|
38
|
+
- SLAS endpoints now work out of the box
|
|
39
|
+
## v1.4.0
|
|
40
|
+
|
|
41
|
+
#### New Features
|
|
42
|
+
|
|
43
|
+
* TypeScript type definitions are now exported! :tada:
|
|
44
|
+
* Any parameter for any method can now be specified in the client configuration.
|
|
45
|
+
* Parameters not used by an endpoint will now be ignored, rather than included.
|
|
46
|
+
* A custom user agent is now sent with requests (node.js only)
|
|
47
|
+
|
|
48
|
+
#### API Changes
|
|
49
|
+
|
|
50
|
+
*Shopper Baskets*
|
|
51
|
+
|
|
52
|
+
* New endpoints
|
|
53
|
+
|
|
54
|
+
| **Endpoint Name** | **Description** |
|
|
55
|
+
| ------------- |-------------|
|
|
56
|
+
| transferBasket | Transfer the previous shopper's basket to the current shopper by updating the basket's owner. No other values change. You must obtain the shopper authorization token via SLAS, and it must contain both the previous and current shopper IDs. |
|
|
57
|
+
| mergeBasket | Merge data from the previous shopper's basket into the current shopper's active basket and delete the previous shopper's basket. This endpoint doesn't merge Personally Identifiable Information (PII). You must obtain the shopper authorization token via SLAS, and it must contain both the previous and current shopper IDs. After the merge, all basket amounts are recalculated and totaled, including lookups for prices, taxes, shipping, and promotions. |
|
|
58
|
+
| updatePaymentInstrumentInBasket | Success, the response body contains the basket with the updated payment instrument. |
|
|
59
|
+
|
|
60
|
+
*Shopper Login*
|
|
61
|
+
|
|
62
|
+
* New endpoints
|
|
63
|
+
|
|
64
|
+
| **Endpoint Name** | **Description** |
|
|
65
|
+
| ------------- |-------------|
|
|
66
|
+
| retrieveCredQualityUserInfo | Retrieve credential quality statistics for a user. |
|
|
67
|
+
|
|
3
68
|
## v1.3.0
|
|
69
|
+
|
|
4
70
|
#### New APIs
|
|
71
|
+
|
|
5
72
|
* *Shopper Discovery Search* has been added to the SDK.
|
|
6
73
|
|
|
7
74
|
#### API Changes
|
|
75
|
+
|
|
8
76
|
*Shopper Login*
|
|
77
|
+
|
|
9
78
|
* New operation: `getTrustedSystemAccessToken`
|
|
10
79
|
|
|
11
80
|
## v1.2.0
|
|
12
81
|
|
|
13
82
|
#### API Changes
|
|
83
|
+
|
|
14
84
|
*Shopper Customers*
|
|
85
|
+
|
|
15
86
|
* New operations
|
|
16
87
|
* registerExternalProfile
|
|
17
88
|
* getExternalProfile
|
|
18
89
|
|
|
19
90
|
## v1.1.2
|
|
91
|
+
|
|
20
92
|
* Fixed issue causing endpoints that accept array values to not properly set `Content-Type` header to `application/json`.
|
|
21
93
|
|
|
22
94
|
## v1.1.1
|
|
95
|
+
|
|
23
96
|
* Fixed issue causing `shortCode` to not be properly set
|
|
24
97
|
|
|
25
98
|
## v1.1.0
|
|
99
|
+
|
|
26
100
|
#### **API Changes**
|
|
101
|
+
|
|
27
102
|
*Shopper Baskets API*
|
|
28
|
-
|
|
29
|
-
|
|
103
|
+
|
|
104
|
+
* Endpoint Added
|
|
105
|
+
* organizations/{organizationId}/baskets/{basketId}/price-books
|
|
30
106
|
|
|
31
107
|
*Shopper Login API*
|
|
108
|
+
|
|
32
109
|
* Endpoint Added
|
|
33
|
-
|
|
110
|
+
* organizations/{organizationId}/oauth2/logout
|
|
34
111
|
* customer_id and enc_user_id were added to the TokenResponse type
|
|
35
112
|
* LoginRequest type was added
|
|
36
113
|
* Query param uuid for /organizations/{organizationId}/oauth2/authorize was renamed to usid
|
package/README.md
CHANGED
|
@@ -2,102 +2,119 @@
|
|
|
2
2
|
|
|
3
3
|
[![CircleCI][circleci-image]][circleci-url]
|
|
4
4
|
|
|
5
|
-
The Salesforce Commerce SDK Isomorphic allows easy interaction with the Salesforce B2C Commerce platform Shopper APIs through a lightweight SDK that works both on browsers and
|
|
5
|
+
The Salesforce Commerce SDK Isomorphic allows easy interaction with the Salesforce B2C Commerce platform Shopper APIs through a lightweight SDK that works both on browsers and NodeJS applications. For a more robust SDK, which includes our B2C Data APIS and Shopper APIs, see [our Node.js Commerce SDK](https://github.com/SalesforceCommerceCloud/commerce-sdk).
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Getting Started
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
### Requirements
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
# Install dependencies needed to run generation
|
|
13
|
-
$ yarn install
|
|
14
|
-
|
|
15
|
-
# Parse API files, render templates to src/lib folder and copy static files to src/lib
|
|
16
|
-
$ yarn run renderTemplates
|
|
11
|
+
- Node `^12.x`, `^14.x`, or `^16.x`
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
$ yarn start
|
|
13
|
+
### Installation
|
|
20
14
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
# Run tests
|
|
25
|
-
$ yarn test
|
|
15
|
+
```bash
|
|
16
|
+
npm install commerce-sdk-isomorphic
|
|
26
17
|
```
|
|
27
18
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
An example React App is available at `./src/environment/App` directory. To use the sample application, configure these parameters in `./src/environment/config.js` file.
|
|
19
|
+
### Usage
|
|
31
20
|
|
|
32
21
|
> **Note:** These are required parameters.
|
|
33
22
|
|
|
34
|
-
| Parameter | Description
|
|
35
|
-
| -------------- |
|
|
36
|
-
| clientId | ID of the client account created with Salesforce Commerce.
|
|
37
|
-
| organizationId | The unique identifier for your Salesforce identity.
|
|
38
|
-
| shortCode | Region
|
|
39
|
-
| siteId |
|
|
23
|
+
| Parameter | Description |
|
|
24
|
+
| -------------- | :------------------------------------------------------------------------- |
|
|
25
|
+
| clientId | ID of the client account created with Salesforce Commerce. |
|
|
26
|
+
| organizationId | The unique identifier for your Salesforce identity. |
|
|
27
|
+
| shortCode | Region-specific merchant ID. |
|
|
28
|
+
| siteId | Name of the site to access data from, for example, RefArch or SiteGenesis. |
|
|
40
29
|
|
|
41
30
|
```javascript
|
|
42
31
|
/**
|
|
43
32
|
* Configure required parameters
|
|
44
|
-
*
|
|
45
|
-
* To learn more about the parameters please refer to https://developer.
|
|
33
|
+
*
|
|
34
|
+
* To learn more about the parameters please refer to https://developer.salesforce.com/docs/commerce/commerce-api/guide/get-started.html
|
|
46
35
|
*/
|
|
36
|
+
import {helpers, ShopperLogin, ShopperSearch} from 'commerce-sdk-isomorphic';
|
|
37
|
+
|
|
47
38
|
// Create a configuration to use when creating API clients
|
|
48
39
|
const config = {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
40
|
+
proxy: 'https://localhost:3000', // Routes API calls through a proxy when set
|
|
41
|
+
headers: {},
|
|
42
|
+
parameters: {
|
|
43
|
+
clientId: '<your-client-id>',
|
|
44
|
+
organizationId: '<your-org-id>',
|
|
45
|
+
shortCode: '<your-short-code>',
|
|
46
|
+
siteId: '<your-site-id>',
|
|
47
|
+
},
|
|
48
|
+
throwOnBadResponse: true,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const shopperLogin = new ShopperLogin(config);
|
|
52
|
+
// Execute Public Client OAuth with PKCE to acquire guest tokens
|
|
53
|
+
const {access_token, refresh_token} = await helpers.loginGuestUser(
|
|
54
|
+
shopperLogin,
|
|
55
|
+
{redirectURI: `${config.proxy}/callback`} // Callback URL must be configured in SLAS Admin
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const shopperSearch = new ShopperSearch({
|
|
59
|
+
...config,
|
|
60
|
+
headers: {authorization: `Bearer ${access_token}`},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const searchResult = await shopperSearch.productSearch({
|
|
64
|
+
parameters: {q: 'shirt'},
|
|
65
|
+
});
|
|
58
66
|
```
|
|
59
|
-
Launch the sample application using `yarn start`. Access the sample application using a new browser window at this url `localhost:3000`.
|
|
60
67
|
|
|
61
68
|
### Advanced options
|
|
62
69
|
|
|
63
|
-
Commerce SDK Isomorphic supports
|
|
64
|
-
This sample code shows how to configure HTTP timeout and agent options
|
|
70
|
+
Commerce SDK Isomorphic supports Fetch API options for [node-fetch](https://github.com/node-fetch/node-fetch/1#api) on server and [whatwg-fetch](https://github.github.io/fetch/) on browser with a simple configuration.
|
|
71
|
+
This sample code shows how to configure HTTP timeout and agent options.
|
|
65
72
|
|
|
66
73
|
```javascript
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const https = require(
|
|
74
|
+
/**
|
|
75
|
+
* Configure advanced timeout and agent parameters
|
|
76
|
+
*
|
|
77
|
+
* To learn more about the parameters please refer to the [Salesforce Developer Center](https://developer.salesforce.com/docs/commerce/commerce-api).
|
|
78
|
+
*/
|
|
79
|
+
// Create a configuration to use when creating API clients
|
|
80
|
+
const https = require('https');
|
|
74
81
|
|
|
75
82
|
const config = {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
83
|
+
proxy: 'https://localhost:3000',
|
|
84
|
+
headers: {},
|
|
85
|
+
parameters: {
|
|
86
|
+
clientId: '<your-client-id>',
|
|
87
|
+
organizationId: '<your-org-id>',
|
|
88
|
+
shortCode: '<your-short-code>',
|
|
89
|
+
siteId: '<your-site-id>',
|
|
90
|
+
},
|
|
91
|
+
fetchOptions: {
|
|
92
|
+
timeout: 2000, //request times out after 2 seconds
|
|
93
|
+
agent: new https.agent({
|
|
94
|
+
// a custom http agent
|
|
95
|
+
keepAlive: true,
|
|
96
|
+
}),
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Additional Config Settings
|
|
102
|
+
|
|
103
|
+
_headers:_ A collection of key/value string pairs representing additional headers to include with API requests.
|
|
104
|
+
|
|
105
|
+
_throwOnBadResponse:_ Default value is false. When set to true, the SDK throws an Error on responses with statuses that are not 2xx or 304.
|
|
106
|
+
|
|
107
|
+
### Public Client Shopper Login helpers
|
|
108
|
+
|
|
109
|
+
A collection of helper functions are available in this SDK to simplify [Public
|
|
110
|
+
Client Shopper Login OAuth
|
|
111
|
+
flows](https://developer.salesforce.com/docs/commerce/commerce-api/references#shopper-login-and-api-access:Summary). See sample code above for guest login.
|
|
96
112
|
|
|
97
113
|
## License Information
|
|
98
114
|
|
|
99
115
|
The Commerce SDK Isomorphic is licensed under BSD-3-Clause license. See the [license](./LICENSE.txt) for details.
|
|
100
116
|
|
|
101
117
|
<!-- Markdown link & img dfn's -->
|
|
118
|
+
|
|
102
119
|
[circleci-image]: https://circleci.com/gh/SalesforceCommerceCloud/commerce-sdk-isomorphic.svg?style=svg&circle-token=379eaa6f00e0840e10dd80585b2b045d02a8f3b7
|
|
103
120
|
[circleci-url]: https://circleci.com/gh/SalesforceCommerceCloud/commerce-sdk-isomorphic
|