Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

- this is a monorepo project; packages:
- ./packages/b2c-cli - the command line interface built with oclif
- ./packages/b2c-tooling - the SDK/library for B2C Commerce operations; support the CLI and can be used standalone
- ./packages/b2c-tooling-sdk - the SDK/library for B2C Commerce operations; support the CLI and can be used standalone

## Setup/Packaging

Expand All @@ -14,22 +14,22 @@

- prefer verbose jsdoc comments for all public methods and classes
- TypeDoc and vitepress will generate documentation from these comments in the `./docs/api` folder
- module level jsdocs will be used for organization; for example packages/b2c-tooling/src/auth/index.ts barrel file has the module level docs for the `auth` module
- module level jsdocs will be used for organization; for example packages/b2c-tooling-sdk/src/auth/index.ts barrel file has the module level docs for the `auth` module
- see the typedoc.json file for configuration options including the entry points for documentation generation
- update the docs/ markdown files (non-generated) for user guides and CLI reference when updating major CLI functionalty or adding new commands

## Logging

- when logging use the logger instance from `@salesforce/b2c-tooling/logger` package
- when logging use the logger instance from `@salesforce/b2c-tooling-sdk/logger` package
- CLI commands have access to this logger via `this.log` method from oclif Command class
- CLI commands can write directly to stdout/stderr if their primary purpose is to output or stream data

## Table Output

When rendering tabular data in CLI commands, use the shared `TableRenderer` utility from `@salesforce/b2c-tooling/cli`:
When rendering tabular data in CLI commands, use the shared `TableRenderer` utility from `@salesforce/b2c-tooling-sdk/cli`:

```typescript
import { createTable, type ColumnDef } from '@salesforce/b2c-tooling/cli';
import { createTable, type ColumnDef } from '@salesforce/b2c-tooling-sdk/cli';

// Define columns with header and getter function
const COLUMNS: Record<string, ColumnDef<MyDataType>> = {
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This is a pnpm monorepo with the following packages:
| Package | Description |
|---------|-------------|
| [`@salesforce/b2c-cli`](./packages/b2c-cli/README.md) | Command line interface built with oclif |
| [`@salesforce/b2c-tooling`](./packages/b2c-tooling/README.md) | SDK/library for B2C Commerce operations; supports the CLI and can be used standalone |
| [`@salesforce/b2c-tooling-sdk`](./packages/b2c-tooling-sdk/README.md) | SDK/library for B2C Commerce operations; supports the CLI and can be used standalone |

## Development

Expand All @@ -46,7 +46,7 @@ pnpm --filter @salesforce/b2c-cli run dev
./cli
```

The dev mode uses Node.js `--conditions=development` to resolve TypeScript source files directly from `@salesforce/b2c-tooling` without needing to build first.
The dev mode uses Node.js `--conditions=development` to resolve TypeScript source files directly from `@salesforce/b2c-tooling-sdk` without needing to build first.

### Building

Expand All @@ -56,7 +56,7 @@ pnpm -r run build

# Build individual packages
pnpm --filter @salesforce/b2c-cli run build
pnpm --filter @salesforce/b2c-tooling run build
pnpm --filter @salesforce/b2c-tooling-sdk run build
```

### Testing and Linting
Expand All @@ -67,7 +67,7 @@ pnpm test

# Run linter only
pnpm --filter @salesforce/b2c-cli run lint
pnpm --filter @salesforce/b2c-tooling run lint
pnpm --filter @salesforce/b2c-tooling-sdk run lint
```

### Code Formatting
Expand Down Expand Up @@ -116,7 +116,7 @@ pnpm run docs:preview

### API Documentation

API documentation is auto-generated from JSDoc comments in the `@salesforce/b2c-tooling` package. The entry points are defined in `typedoc.json`:
API documentation is auto-generated from JSDoc comments in the `@salesforce/b2c-tooling-sdk` package. The entry points are defined in `typedoc.json`:

See the [documentation site](https://verbose-adventure-1eqmr1r.pages.github.io/) for the generated API reference.

Expand All @@ -133,12 +133,12 @@ When adding new public APIs, ensure they have comprehensive JSDoc comments as th

## Package Exports

The `@salesforce/b2c-tooling` package uses the `exports` field in package.json to define its public API surface. Each module is available as a subpath export:
The `@salesforce/b2c-tooling-sdk` package uses the `exports` field in package.json to define its public API surface. Each module is available as a subpath export:

```typescript
import { OAuthStrategy } from '@salesforce/b2c-tooling/auth';
import { B2CInstance } from '@salesforce/b2c-tooling/instance';
import { getLogger } from '@salesforce/b2c-tooling/logging';
import { OAuthStrategy } from '@salesforce/b2c-tooling-sdk/auth';
import { B2CInstance } from '@salesforce/b2c-tooling-sdk/instance';
import { getLogger } from '@salesforce/b2c-tooling-sdk/logging';
```

The `development` condition in exports enables direct TypeScript source resolution when using `--conditions=development`, which is how `bin/dev.js` works for local development.
Binary file added b2c_log_center_stream3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions docs/api-readme.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# API Reference

The `@salesforce/b2c-tooling` package provides a programmatic API for interacting with Salesforce B2C Commerce instances.
The `@salesforce/b2c-tooling-sdk` package provides a programmatic API for interacting with Salesforce B2C Commerce instances.

## Installation

```bash
npm install @salesforce/b2c-tooling
npm install @salesforce/b2c-tooling-sdk
```

## Quick Start
Expand All @@ -15,7 +15,7 @@ npm install @salesforce/b2c-tooling
The easiest way to create an instance is from a `dw.json` file:

```typescript
import { B2CInstance } from '@salesforce/b2c-tooling';
import { B2CInstance } from '@salesforce/b2c-tooling-sdk';

// Load configuration from dw.json, override secrets from environment
const instance = B2CInstance.fromDwJson({
Expand All @@ -38,7 +38,7 @@ const { data, error } = await instance.ocapi.GET('/sites', {
You can also construct an instance directly with configuration:

```typescript
import { B2CInstance } from '@salesforce/b2c-tooling';
import { B2CInstance } from '@salesforce/b2c-tooling-sdk';

const instance = new B2CInstance(
{ hostname: 'your-sandbox.demandware.net', codeVersion: 'v1' },
Expand Down Expand Up @@ -145,7 +145,7 @@ const { data, error } = await instance.ocapi.PATCH('/code_versions/{code_version
Configure logging for debugging HTTP requests:

```typescript
import { configureLogger } from '@salesforce/b2c-tooling/logging';
import { configureLogger } from '@salesforce/b2c-tooling-sdk/logging';

// Enable debug logging (shows HTTP request summaries)
configureLogger({ level: 'debug' });
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ The command-line interface that you interact with directly. It provides a set of
b2c code deploy --server your-instance.demandware.net
```

### @salesforce/b2c-tooling
### @salesforce/b2c-tooling-sdk

The underlying SDK library that powers the CLI. You can use this package directly in your own Node.js applications to automate B2C Commerce operations.

```typescript
import { uploadCartridges, B2CInstance } from '@salesforce/b2c-tooling';
import { uploadCartridges, B2CInstance } from '@salesforce/b2c-tooling-sdk';

const instance = new B2CInstance({
server: 'your-instance.demandware.net',
Expand Down
6 changes: 3 additions & 3 deletions docs/guide/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ If you want to use the SDK library in your own projects:
::: code-group

```bash [npm]
npm install @salesforce/b2c-tooling
npm install @salesforce/b2c-tooling-sdk
```

```bash [pnpm]
pnpm add @salesforce/b2c-tooling
pnpm add @salesforce/b2c-tooling-sdk
```

```bash [yarn]
yarn add @salesforce/b2c-tooling
yarn add @salesforce/b2c-tooling-sdk
```

:::
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ features:
- title: Managed Runtime
details: Configure and manage MRT environments and environment variables.
- title: SDK Library
details: Use the @salesforce/b2c-tooling package to build your own integrations.
details: Use the @salesforce/b2c-tooling-sdk package to build your own integrations.
---
1 change: 1 addition & 0 deletions dw.json.bak
39 changes: 39 additions & 0 deletions easy-setup-step-by-step.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

export SFCC_MRT_PROJECT=cli
export REALM="zzpq"
export SFCC_CLIENT_ID="a0a4deb0-5e03-477b-bfdc-e42ccfae6161"

b2c ods create -r $REALM --wait --ttl 0

# create mrt env called chuck in the cli project
b2c mrt env create chuck --name chuck \
--allow-cookies \
--proxy api=kv7kzm78.api.commercecloud.salesforce.com \
--proxy einstein=api.cquotient.com

# construct redirect-uri from ssr_external_hostname above and don't use localhost:3000
b2c slas client create \
--channels MarketStreet \
--tenant-id zzpq_014 \
--short-code kv7kzm78 \
--redirect-uri https://myproject-chuck.sfdc-8tgtt5-ecom1.exp-delivery.com/callback,http://localhost:3000/callback \
--default-scopes

# get clientId and COMMERCE_API_SLAS_SECRET from the output of the previous command and callback from the redirect-uri above
b2c mrt env var set -e chuck \
PUBLIC__app__commerce__api__clientId=5810be72-3b2f-49bc-8ca1-eb88119de2fa \
PUBLIC__app__commerce__api__organizationId=f_ecom_zzpq_014 \
PUBLIC__app__commerce__api__siteId=RefArch \
PUBLIC__app__commerce__api__shortCode= \
PUBLIC__app__commerce__api__callback=https://myproject-chuck.sfdc-8tgtt5-ecom1.exp-delivery.com/callback \
PUBLIC__app__commerce__api__privateKeyEnabled=true \
COMMERCE_API_SLAS_SECRET=sk_kasdjlkjsalkjasd

# import market street data from storefront-datasets repo
b2c job import --server zzpq-014.dx.commercecloud.salesforce.com ~/code/storefront-datasets/demo_data_marketstreet

b2c code deploy
b2c mrt push -e headertest -p cli -b ~/code/SFCC-Odyssey/packages/template-retail-rsc-app/build --ssr-only='ssr.js,ssr.mjs,chunk.mjs,server/**/*'


85 changes: 85 additions & 0 deletions easy-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/usr/bin/env bash
set -euo pipefail

# Configuration - modify these values for your setup
ENV_SLUG="demo15"
ENV_NAME="demo15"
SITE_ID="RefArch"
TENANT_ID="zzpq_013"
ORGANIZATION_ID="f_ecom_zzsa_009"
SHORT_CODE="kv7kzm78"
BUILD_PATH="${BUILD_PATH:-$HOME/code/SFCC-Odyssey/packages/template-retail-rsc-app/build}"

export SFCC_MRT_PROJECT="${SFCC_MRT_PROJECT:-cli}"

echo "=== Step 1: Creating MRT environment ==="
ENV_JSON=$(b2c mrt env create "$ENV_SLUG" --name "$ENV_NAME" --json)
echo "Environment created."

# Extract the external hostname for the callback URL
SSR_EXTERNAL_HOSTNAME=$(echo "$ENV_JSON" | jq -r '.ssr_external_hostname // empty')
if [[ -z "$SSR_EXTERNAL_HOSTNAME" ]]; then
# Fall back to hostname if external hostname not set
SSR_EXTERNAL_HOSTNAME=$(echo "$ENV_JSON" | jq -r '.hostname // empty')
fi

if [[ -z "$SSR_EXTERNAL_HOSTNAME" ]]; then
echo "Warning: Could not determine external hostname from environment. Using localhost."
CALLBACK_URL="http://localhost:3000/callback"
else
CALLBACK_URL="https://${SSR_EXTERNAL_HOSTNAME}/callback"
fi
echo "Callback URL: $CALLBACK_URL"

echo ""
echo "=== Step 2: Creating SLAS client ==="
SLAS_JSON=$(b2c slas client create --channels "$SITE_ID" \
--redirect-uri "$CALLBACK_URL" \
--default-scopes \
--tenant-id "$TENANT_ID" \
--json)
echo "SLAS client created."

# Extract client ID and secret from SLAS response
CLIENT_ID=$(echo "$SLAS_JSON" | jq -r '.clientId')
CLIENT_SECRET=$(echo "$SLAS_JSON" | jq -r '.secret // empty')

if [[ -z "$CLIENT_ID" ]]; then
echo "Error: Failed to get client ID from SLAS response"
exit 1
fi

echo "Client ID: $CLIENT_ID"
if [[ -n "$CLIENT_SECRET" ]]; then
echo "Client Secret: $CLIENT_SECRET (save this - it won't be shown again)"
fi

echo ""
echo "=== Step 3: Setting environment variables ==="
b2c mrt env var set -e "$ENV_SLUG" \
"PUBLIC__app__commerce__api__clientId=$CLIENT_ID" \
"PUBLIC__app__commerce__api__organizationId=$ORGANIZATION_ID" \
"PUBLIC__app__commerce__api__siteId=$SITE_ID" \
"PUBLIC__app__commerce__api__shortCode=$SHORT_CODE" \
"PUBLIC__app__commerce__api__proxy=/mobify/proxy/api" \
"PUBLIC__app__commerce__api__callback=$CALLBACK_URL" \
"PUBLIC__app__commerce__api__privateKeyEnabled=true" \
${CLIENT_SECRET:+"COMMERCE_API_SLAS_SECRET=$CLIENT_SECRET"}

echo ""
echo "=== Step 4: Deploying code ==="
b2c code deploy

echo ""
echo "=== Step 5: Importing job data ==="
b2c job import data/urls

echo ""
echo "=== Step 6: Pushing to MRT ==="
b2c mrt push -e "$ENV_SLUG" -b "$BUILD_PATH"

echo ""
echo "=== Setup Complete ==="
echo "Environment: $ENV_SLUG"
echo "Client ID: $CLIENT_ID"
echo "URL: https://${SSR_EXTERNAL_HOSTNAME:-localhost:3000}"
2 changes: 1 addition & 1 deletion packages/b2c-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@oclif/plugin-not-found": "^3",
"@oclif/plugin-autocomplete": "^3",
"@oclif/plugin-version": "^2",
"@salesforce/b2c-tooling": "workspace:*",
"@salesforce/b2c-tooling-sdk": "workspace:*",
"cliui": "^9.0.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/b2c-cli/src/commands/_test/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {BaseCommand} from '@salesforce/b2c-tooling/cli';
import {BaseCommand} from '@salesforce/b2c-tooling-sdk/cli';

export default class Test extends BaseCommand<typeof Test> {
static description = 'Test logging output';
Expand Down
4 changes: 2 additions & 2 deletions packages/b2c-cli/src/commands/auth/token.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {ux} from '@oclif/core';
import {OAuthCommand} from '@salesforce/b2c-tooling/cli';
import type {AccessTokenResponse} from '@salesforce/b2c-tooling/auth';
import {OAuthCommand} from '@salesforce/b2c-tooling-sdk/cli';
import type {AccessTokenResponse} from '@salesforce/b2c-tooling-sdk/auth';
import {t} from '../../i18n/index.js';

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/b2c-cli/src/commands/code/activate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Args, Flags} from '@oclif/core';
import {InstanceCommand} from '@salesforce/b2c-tooling/cli';
import {activateCodeVersion, reloadCodeVersion} from '@salesforce/b2c-tooling/operations/code';
import {InstanceCommand} from '@salesforce/b2c-tooling-sdk/cli';
import {activateCodeVersion, reloadCodeVersion} from '@salesforce/b2c-tooling-sdk/operations/code';
import {t} from '../../i18n/index.js';

export default class CodeActivate extends InstanceCommand<typeof CodeActivate> {
Expand Down
4 changes: 2 additions & 2 deletions packages/b2c-cli/src/commands/code/delete.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as readline from 'node:readline';
import {Args, Flags} from '@oclif/core';
import {InstanceCommand} from '@salesforce/b2c-tooling/cli';
import {deleteCodeVersion} from '@salesforce/b2c-tooling/operations/code';
import {InstanceCommand} from '@salesforce/b2c-tooling-sdk/cli';
import {deleteCodeVersion} from '@salesforce/b2c-tooling-sdk/operations/code';
import {t} from '../../i18n/index.js';

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/b2c-cli/src/commands/code/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {
findAndDeployCartridges,
getActiveCodeVersion,
type DeployResult,
} from '@salesforce/b2c-tooling/operations/code';
import {CartridgeCommand} from '@salesforce/b2c-tooling/cli';
} from '@salesforce/b2c-tooling-sdk/operations/code';
import {CartridgeCommand} from '@salesforce/b2c-tooling-sdk/cli';
import {t} from '../../i18n/index.js';

export default class CodeDeploy extends CartridgeCommand<typeof CodeDeploy> {
Expand Down
4 changes: 2 additions & 2 deletions packages/b2c-cli/src/commands/code/list.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {ux} from '@oclif/core';
import {InstanceCommand, createTable, type ColumnDef} from '@salesforce/b2c-tooling/cli';
import {listCodeVersions, type CodeVersion, type CodeVersionResult} from '@salesforce/b2c-tooling/operations/code';
import {InstanceCommand, createTable, type ColumnDef} from '@salesforce/b2c-tooling-sdk/cli';
import {listCodeVersions, type CodeVersion, type CodeVersionResult} from '@salesforce/b2c-tooling-sdk/operations/code';
import {t} from '../../i18n/index.js';

const COLUMNS: Record<string, ColumnDef<CodeVersion>> = {
Expand Down
4 changes: 2 additions & 2 deletions packages/b2c-cli/src/commands/code/watch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {watchCartridges} from '@salesforce/b2c-tooling/operations/code';
import {CartridgeCommand} from '@salesforce/b2c-tooling/cli';
import {watchCartridges} from '@salesforce/b2c-tooling-sdk/operations/code';
import {CartridgeCommand} from '@salesforce/b2c-tooling-sdk/cli';
import {t} from '../../i18n/index.js';

export default class CodeWatch extends CartridgeCommand<typeof CodeWatch> {
Expand Down
4 changes: 2 additions & 2 deletions packages/b2c-cli/src/commands/job/export.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {Flags} from '@oclif/core';
import {JobCommand} from '@salesforce/b2c-tooling/cli';
import {JobCommand} from '@salesforce/b2c-tooling-sdk/cli';
import {
siteArchiveExportToPath,
JobExecutionError,
type SiteArchiveExportResult,
type ExportDataUnitsConfiguration,
} from '@salesforce/b2c-tooling/operations/jobs';
} from '@salesforce/b2c-tooling-sdk/operations/jobs';
import {t} from '../../i18n/index.js';

export default class JobExport extends JobCommand<typeof JobExport> {
Expand Down
Loading