Skip to content

Smoke Test SDK (@W-18482922@)#428

Merged
joeluong-sfcc merged 7 commits intofeature/oasfrom
ju/smoke-test
Aug 12, 2025
Merged

Smoke Test SDK (@W-18482922@)#428
joeluong-sfcc merged 7 commits intofeature/oasfrom
ju/smoke-test

Conversation

@joeluong-sfcc
Copy link
Collaborator

@joeluong-sfcc joeluong-sfcc commented Aug 8, 2025

This PR smoke tests the new OAS SDK and adds small updates for any gaps found.

The CI is expected to fail in this PR and will be fixed in a follow up PR to prepare for the release of the SDK. This is because we need to pull in the latest versions of the APIs and I don't want to bloat this PR with all the API changes.

npm run test should pass after updating the APIs

Testing Instructions

  1. git checkout ju/smoke-test
  2. npm run ci
  3. add ANYPOINT_USERNAME and ANYPOINT_PASSWORD to environment variables
  4. npm run updateApis
  5. npm run build
  6. In a new directory, set up a small node project to test the SDK, npm init -y
  7. in package.json dependencies, add the path to your local commerce-sdk project:
"commerce-sdk": "/Users/<User>/Desktop/workspace/commerce-sdk",

OR

"commerce-sdk": "file:../commerce-sdk",

  1. npm install
  2. and add the following script, index.js:
import { ShopperSearch, ShopperLogin, ShopperProducts, slasHelpers } from "commerce-sdk";

// Reach out to me for details
const CLIENT_ID = '<>'
const ORG_ID = '<>'
const SHORT_CODE ='<>'
const SITE_ID = '<>'

// must be registered in SLAS. On server, redirectURI is never called
const redirectURI = "http://localhost:3000/callback";

// client configuration parameters
const clientConfig = {
  parameters: {
    clientId: CLIENT_ID,
    organizationId: ORG_ID,
    shortCode: SHORT_CODE,
    siteId: SITE_ID,
  },
};

const slasClient = new ShopperLogin(clientConfig);

const guestTokenResponse = await slasHelpers.loginGuestUser({
    slasClient,
    parameters: {
        redirectURI,
    },
});

console.log("Guest Token Response: ", guestTokenResponse);

const shopperSearchClient = new ShopperSearch({
    ...clientConfig, 
    headers: {authorization: `Bearer ${guestTokenResponse.access_token}`}
});

const searchResponse = await shopperSearchClient.productSearch({
    parameters: {
        q: "skirt",
    },
});

console.log("Search Response: ", searchResponse);

const productId = searchResponse.hits[0].productId;

const shopperProductsClient = new ShopperProducts({
    ...clientConfig, 
    headers: {authorization: `Bearer ${guestTokenResponse.access_token}`}
});

const productResponse = await shopperProductsClient.getProduct({
    parameters: {
        id: productId,
    },
});

console.log("Product Response: ", productResponse);
  1. Run the script with node index.js in the sample project directory

@joeluong-sfcc joeluong-sfcc marked this pull request as ready for review August 12, 2025 16:49
@joeluong-sfcc joeluong-sfcc requested a review from a team as a code owner August 12, 2025 16:49
if (name === "Shopper Baskets OAS") {
return version === "v2" ? "ShopperBasketsV2" : "ShopperBasketsV1";
if (name === "Shopper Baskets OAS" && version === "v2") {
return "ShopperBasketsV2";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on this, I assume we've decided to name shopper baskets V1 as ShopperBaskets and not ShopperBasketsV1?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's correct

* Recursively removes all files ending in '-internal.yaml' from a directory and its subdirectories
* @param directoryPath - The path to the directory to process
*/
export function removeInternalOas(directoryPath: string): void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, do we need to run this more than once? Or is this just a helper function for cleaning up the -internal files current state of the repo?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll have to run it everytime we pull down the APIs as the internal OAS file will always be a part of anypoint exchange asset (at least for now)

@joeluong-sfcc joeluong-sfcc merged commit df85a14 into feature/oas Aug 12, 2025
5 of 7 checks passed
@joeluong-sfcc joeluong-sfcc deleted the ju/smoke-test branch August 12, 2025 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants