Skip to content

Commit 7dd2f29

Browse files
Merge pull request #423 from SalesforceCommerceCloud/feature/oas
Feat: Merge feature OAS branch
2 parents 1c729a9 + 7780ed3 commit 7dd2f29

File tree

7,299 files changed

+185692
-435367
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

7,299 files changed

+185692
-435367
lines changed

.depcheckrc.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,11 @@ ignores:
55
- node-fetch # We only use @types/node-fetch, not node-fetch itself
66
- retry # Use OperationOptions from retry in templates but not recognized by depcheck
77
- '@types/retry' # Corresponds to retry
8+
- '@openapitools/openapi-generator-cli' # Used by openapi-generator-cli in `npm run renderTemplates`
9+
- '@types/node-fetch' # Used by multiple files for fetch types
10+
- chai # Used by multiple files for testing
11+
- sinon # Used by multiple files for testing
12+
- nock # Used by multiple files for testing to mock API calls
13+
- handlebars # Used by generation script to generate version.ts and top level index.ts files
14+
- fs-extra # Used by generation script and updateApis script
15+
- tslib # Used by the TypeScript compiler

.eslintrc.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"plugins": [
88
"@typescript-eslint",
99
"@typescript-eslint/eslint-plugin",
10-
"tsdoc",
1110
"header",
1211
"jsdoc"
1312
],
@@ -32,7 +31,7 @@
3231
"selector": "interface",
3332
"format": ["PascalCase"],
3433
"custom": {
35-
"regex": "^I[A-Z]",
34+
"regex": "^[A-Z]",
3635
"match": true
3736
}
3837
}
@@ -53,7 +52,7 @@
5352
]
5453
],
5554
"jsdoc/require-description": [
56-
"error",
55+
"warn",
5756
{
5857
"checkConstructors": false
5958
}
@@ -76,8 +75,7 @@
7675
"jsdoc/require-param-type": "off",
7776
"jsdoc/require-returns-check": "error",
7877
"jsdoc/require-returns-description": "error",
79-
"jsdoc/require-returns-type": "off",
80-
"tsdoc/syntax": "error"
78+
"jsdoc/require-returns-type": "off"
8179
},
8280
"overrides": [
8381
{

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
linux-tests:
1010
strategy:
1111
matrix:
12-
node: [16, 18, 20, 22]
12+
node: [20, 22]
1313
fail-fast: false
1414
runs-on: ubuntu-latest
1515
steps:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ dist
6666

6767
.idea
6868

69+
# Openapi-generator generates this when running renderTemplates
70+
openapitools.json
71+
6972
# Release folders
7073
renderedTemplates
7174
.vscode

.nycrc.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
"branches": 80,
44
"check-coverage": true,
55
"exclude": [
6-
"src/generate.ts",
76
"src/updateApis.ts",
8-
"src/lib/config.ts"
7+
"src/lib/config.ts",
8+
"src/generate-oas.ts",
9+
"src/generateVersionTable.ts",
10+
"src/removeInternalOas.ts",
11+
"src/static/helpers/index.ts",
12+
"src/lib/utils.ts"
913
],
1014
"extends": "@istanbuljs/nyc-config-typescript",
1115
"extension": [

CHANGELOG.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,48 @@
1-
## CHANGELOG
1+
# CHANGELOG
2+
3+
## v5.0.0
4+
5+
### API Versions
6+
7+
| API Name | API Version |
8+
|----------|-------------|
9+
| assignments | 1.0.35 |
10+
| campaigns | 1.0.37 |
11+
| catalogs | 1.0.42 |
12+
| cdn-api-process-apis | 1.0.39 |
13+
| cors-preferences | 1.0.5 |
14+
| coupons | 1.0.39 |
15+
| customers | 1.0.32 |
16+
| gift-certificates | 1.0.39 |
17+
| orders | 1.4.10 |
18+
| preferences | 1.1.3 |
19+
| products | 1.0.40 |
20+
| promotions | 1.0.33 |
21+
| shopper-baskets | 1.9.0 |
22+
| shopper-baskets | 2.1.0 |
23+
| shopper-consents | 1.1.0 |
24+
| shopper-context | 1.1.1 |
25+
| shopper-customers | 1.1.1 |
26+
| shopper-experience | 1.0.7 |
27+
| shopper-gift-certificates | 1.0.26 |
28+
| shopper-login | 1.39.41 |
29+
| shopper-orders | 1.5.0 |
30+
| shopper-products | 1.0.37 |
31+
| shopper-promotions | 1.0.36 |
32+
| shopper-search | 1.3.0 |
33+
| shopper-seo | 1.0.13 |
34+
| shopper-stores | 1.0.17 |
35+
| slas-admin | 1.12.30 |
36+
| source-code-groups | 1.0.37 |
37+
38+
### Enchancements
39+
- Enum types have been added for certain operations and types
40+
- Certain operations have had types updated for query parameters
41+
- SLAS helpers have been refactored to accept a single `options` object argument, where the properties are the old arguments
42+
- `loginGuestUserPrivate` now passes `usid` under `options.parameters`
43+
- Path parameter special characters are encoded by default
44+
- API family layer and API namespace has been removed. To import API classes, please refer to the [README](https://github.com/SalesforceCommerceCloud/commerce-sdk?tab=readme-ov-file#sample-code)
45+
- Docs Site has been upgraded to reflect new directory structure [#426](https://github.com/SalesforceCommerceCloud/commerce-sdk/pull/426)
246

347

448
## v4.2.0

README.md

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,28 @@ The Salesforce Commerce SDK allows easy interaction with the Salesforce B2C Comm
44

55
Visit the [Commerce Cloud Developer Center](https://developer.salesforce.com/developer-centers/commerce-cloud) to learn more about Salesforce Commerce. The developer center has API documentation, getting started guides, community forums, and more.
66
7+
## Documentation
8+
9+
An auto-generated [documentation site](https://salesforcecommercecloud.github.io/commerce-sdk/) provides comprehensive reference for all available endpoints and types across API classes. Following the v5.0.0 release, the underlying SDK file structure has been reorganized, introducing additional layers of imports/exports that may affect navigation.
10+
11+
### Navigating the Documentation
12+
13+
**For API Classes:**
14+
15+
1. **Accessing API Classes:** Click on the API class name (e.g., `shopperProducts`) on the right hand side
16+
2. **Viewing Endpoints:** Scroll to the `Classes` section and click the corresponding API class link (e.g., `ShopperProducts`) to see available endpoints and their parameters
17+
3. **Type Definitions:** Scroll to the `Type aliases` section for available types
18+
4. **Navigating Back to API Classes**: To return to the main documentation page with all API classes listed on the right sidebar, click on `Globals` in the navigation.
19+
20+
**Utility Classes:** Utility classes and methods such as `clientConfig` and `helpers` maintain the same structure as previous versions.
21+
22+
**NOTES:**
23+
24+
1. **Type Access**: API class types are accessible through the `<api_class>Types` namespace (e.g., `ShopperProductsTypes`). Individual types can be accessed as `ShopperProductsTypes.Product`.
25+
2. **Type References**: The `References` section under API classes in the generated documentation may show duplicate entries. This occurs because types are exported both at their original definition and under the API class namespace. Both references point to the same underlying type definition.
26+
3. **V4 Migration Guide**: Starting in v5, API classes will no longer be exported under API family namespaces. See the [Sample Code](#sample-code) section for migration examples.
27+
4. **Supporting Files**: The SDK includes additional supporting modules beyond the `helpers` SLAS functions. The `types` module provides common type definitions shared across API classes, while the `version` module automatically implements user agent headers for all requests. The user agent value follows the format `commerce-sdk@<version>` based on the current SDK version.
28+
729
## :warning: Planned API Changes :warning:
830

931
### Shopper Context
@@ -64,14 +86,25 @@ To use an SDK client, instantiate an object of that client and configure these p
6486

6587
// Import the SDK in TypeScript
6688
// tsc requires the --esModuleInterop flag for this
67-
import { Search, Customer, helpers, slasHelpers } from "commerce-sdk";
89+
// Starting in v5, API classes will no longer be namespaced under API family
90+
import { ShopperSearch, ShopperLogin, helpers, slasHelpers } from "commerce-sdk";
91+
// For v4 and below, you'll have to import the API family first
92+
// import { Search, Customer, helpers, slasHelpers } from "commerce-sdk";
93+
// const loginClient = new Customer.ShopperLogin(config);
94+
// const searchClient = new Search.ShopperSearch(config);
95+
6896
// Older Node.js versions can instead use:
6997
// const { ClientConfig, helpers, slasHelpers Search } = require("commerce-sdk");
7098

99+
// Types for each individual API can be imported as <api_name>Types starting in v5
100+
import type { ShopperLoginTypes } from "commerce-sdk"
101+
71102
// demo client credentials, if you have access to your own please replace them below.
72103
// do not store client secret as plaintext. Store it in a secure location.
104+
// For guidance on generating a private client with a client secret, please refer to:
105+
// https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/use-a-slas-private-client.html
106+
const CLIENT_SECRET = "<INSERT_CLIENT_SECRET>";
73107
const CLIENT_ID = "da422690-7800-41d1-8ee4-3ce983961078";
74-
const CLIENT_SECRET = "D*HHUrgO2%qADp2JTIUi";
75108
const ORG_ID = "f_ecom_zzte_053";
76109
const SHORT_CODE = "kv7kzm78";
77110
const SITE_ID = "RefArch";
@@ -92,10 +125,10 @@ const config = {
92125
*
93126
* @returns guest user authorization token
94127
*/
95-
async function getGuestUserAuthToken(): Promise<Customer.ShopperLogin.TokenResponse> {
128+
async function getGuestUserAuthToken(): Promise<ShopperLoginTypes.TokenResponse> {
96129
const base64data = Buffer.from(`${CLIENT_ID}:${CLIENT_SECRET}`).toString("base64");
97130
const headers = { Authorization: `Basic ${base64data}` };
98-
const loginClient = new Customer.ShopperLogin(config);
131+
const loginClient = new ShopperLogin(config);
99132

100133
return await loginClient.getAccessToken({
101134
headers,
@@ -104,10 +137,10 @@ async function getGuestUserAuthToken(): Promise<Customer.ShopperLogin.TokenRespo
104137
}
105138

106139
// Alternatively you may use the SLAS helper functions to generate JWT/access token
107-
const guestTokenResponse = await slasHelpers.loginGuestUser(
108-
new Customer.ShopperLogin(config),
109-
{ redirectURI: 'http://localhost:3000/callback' }
110-
)
140+
const guestTokenResponse = await slasHelpers.loginGuestUser({
141+
slasClient: new ShopperLogin(config),
142+
parameters: { redirectURI: 'http://localhost:3000/callback' }
143+
})
111144
.then((guestTokenResponse) => {
112145
console.log("Guest Token Response: ", guestTokenResponse);
113146
return guestTokenResponse;
@@ -119,7 +152,7 @@ getGuestUserAuthToken().then(async (token) => {
119152
// Add the token to the client configuration
120153
config.headers["authorization"] = `Bearer ${token.access_token}`;
121154

122-
const searchClient = new Search.ShopperSearch(config);
155+
const searchClient = new ShopperSearch(config);
123156

124157
// Search for dresses
125158
const searchResults = await searchClient.productSearch({

apis/.metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"shopperAuthClient":"Customer.ShopperCustomers","shopperAuthApi":"authorizeCustomer","shopperAuthDataType":"Customer","enforceCcdcId":true}
1+
{"shopperAuthClient":"Customer.ShopperCustomers","shopperAuthApi":"authorizeCustomer","shopperAuthDataType":"Customer"}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"id": "893f605e-10e2-423a-bdb4-f952f56eb6d8/assignments-oas/1.0.35",
3+
"name": "Assignments OAS",
4+
"description": "",
5+
"groupId": "893f605e-10e2-423a-bdb4-f952f56eb6d8",
6+
"assetId": "assignments-oas",
7+
"version": "1.0.35",
8+
"categories": {
9+
"SDK Type": [
10+
"Commerce"
11+
],
12+
"Visibility": [
13+
"External"
14+
]
15+
}
16+
}

0 commit comments

Comments
 (0)