Skip to content

Commit c60a111

Browse files
committed
Rename SDK to b2c-tooling-sdk (#10)
* rename sdk package name * linting
1 parent d19e1a6 commit c60a111

116 files changed

Lines changed: 282 additions & 148 deletions

File tree

Some content is hidden

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

AGENTS.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

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

66
## Setup/Packaging
77

@@ -14,22 +14,22 @@
1414

1515
- prefer verbose jsdoc comments for all public methods and classes
1616
- TypeDoc and vitepress will generate documentation from these comments in the `./docs/api` folder
17-
- 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
17+
- 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
1818
- see the typedoc.json file for configuration options including the entry points for documentation generation
1919
- update the docs/ markdown files (non-generated) for user guides and CLI reference when updating major CLI functionalty or adding new commands
2020

2121
## Logging
2222

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

2727
## Table Output
2828

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

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

3434
// Define columns with header and getter function
3535
const COLUMNS: Record<string, ColumnDef<MyDataType>> = {

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ This is a pnpm monorepo with the following packages:
2121
| Package | Description |
2222
|---------|-------------|
2323
| [`@salesforce/b2c-cli`](./packages/b2c-cli/README.md) | Command line interface built with oclif |
24-
| [`@salesforce/b2c-tooling`](./packages/b2c-tooling/README.md) | SDK/library for B2C Commerce operations; supports the CLI and can be used standalone |
24+
| [`@salesforce/b2c-tooling-sdk`](./packages/b2c-tooling-sdk/README.md) | SDK/library for B2C Commerce operations; supports the CLI and can be used standalone |
2525

2626
## Development
2727

@@ -46,7 +46,7 @@ pnpm --filter @salesforce/b2c-cli run dev
4646
./cli
4747
```
4848

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

5151
### Building
5252

@@ -56,7 +56,7 @@ pnpm -r run build
5656

5757
# Build individual packages
5858
pnpm --filter @salesforce/b2c-cli run build
59-
pnpm --filter @salesforce/b2c-tooling run build
59+
pnpm --filter @salesforce/b2c-tooling-sdk run build
6060
```
6161

6262
### Testing and Linting
@@ -67,7 +67,7 @@ pnpm test
6767

6868
# Run linter only
6969
pnpm --filter @salesforce/b2c-cli run lint
70-
pnpm --filter @salesforce/b2c-tooling run lint
70+
pnpm --filter @salesforce/b2c-tooling-sdk run lint
7171
```
7272

7373
### Code Formatting
@@ -116,7 +116,7 @@ pnpm run docs:preview
116116

117117
### API Documentation
118118

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

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

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

134134
## Package Exports
135135

136-
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:
136+
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:
137137

138138
```typescript
139-
import { OAuthStrategy } from '@salesforce/b2c-tooling/auth';
140-
import { B2CInstance } from '@salesforce/b2c-tooling/instance';
141-
import { getLogger } from '@salesforce/b2c-tooling/logging';
139+
import { OAuthStrategy } from '@salesforce/b2c-tooling-sdk/auth';
140+
import { B2CInstance } from '@salesforce/b2c-tooling-sdk/instance';
141+
import { getLogger } from '@salesforce/b2c-tooling-sdk/logging';
142142
```
143143

144144
The `development` condition in exports enables direct TypeScript source resolution when using `--conditions=development`, which is how `bin/dev.js` works for local development.

b2c_log_center_stream3.png

46.8 KB
Loading

docs/api-readme.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# API Reference
22

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

55
## Installation
66

77
```bash
8-
npm install @salesforce/b2c-tooling
8+
npm install @salesforce/b2c-tooling-sdk
99
```
1010

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

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

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

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

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

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

150150
// Enable debug logging (shows HTTP request summaries)
151151
configureLogger({ level: 'debug' });

docs/guide/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ The command-line interface that you interact with directly. It provides a set of
2020
b2c code deploy --server your-instance.demandware.net
2121
```
2222

23-
### @salesforce/b2c-tooling
23+
### @salesforce/b2c-tooling-sdk
2424

2525
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.
2626

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

3030
const instance = new B2CInstance({
3131
server: 'your-instance.demandware.net',

docs/guide/installation.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ If you want to use the SDK library in your own projects:
4040
::: code-group
4141

4242
```bash [npm]
43-
npm install @salesforce/b2c-tooling
43+
npm install @salesforce/b2c-tooling-sdk
4444
```
4545

4646
```bash [pnpm]
47-
pnpm add @salesforce/b2c-tooling
47+
pnpm add @salesforce/b2c-tooling-sdk
4848
```
4949

5050
```bash [yarn]
51-
yarn add @salesforce/b2c-tooling
51+
yarn add @salesforce/b2c-tooling-sdk
5252
```
5353

5454
:::

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ features:
2424
- title: Managed Runtime
2525
details: Configure and manage MRT environments and environment variables.
2626
- title: SDK Library
27-
details: Use the @salesforce/b2c-tooling package to build your own integrations.
27+
details: Use the @salesforce/b2c-tooling-sdk package to build your own integrations.
2828
---

dw.json.bak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Users/clavery/code/b2c-commerce-industries/dw.json

easy-setup-step-by-step.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
3+
export SFCC_MRT_PROJECT=cli
4+
export REALM="zzpq"
5+
export SFCC_CLIENT_ID="a0a4deb0-5e03-477b-bfdc-e42ccfae6161"
6+
7+
b2c ods create -r $REALM --wait --ttl 0
8+
9+
# create mrt env called chuck in the cli project
10+
b2c mrt env create chuck --name chuck \
11+
--allow-cookies \
12+
--proxy api=kv7kzm78.api.commercecloud.salesforce.com \
13+
--proxy einstein=api.cquotient.com
14+
15+
# construct redirect-uri from ssr_external_hostname above and don't use localhost:3000
16+
b2c slas client create \
17+
--channels MarketStreet \
18+
--tenant-id zzpq_014 \
19+
--short-code kv7kzm78 \
20+
--redirect-uri https://myproject-chuck.sfdc-8tgtt5-ecom1.exp-delivery.com/callback,http://localhost:3000/callback \
21+
--default-scopes
22+
23+
# get clientId and COMMERCE_API_SLAS_SECRET from the output of the previous command and callback from the redirect-uri above
24+
b2c mrt env var set -e chuck \
25+
PUBLIC__app__commerce__api__clientId=5810be72-3b2f-49bc-8ca1-eb88119de2fa \
26+
PUBLIC__app__commerce__api__organizationId=f_ecom_zzpq_014 \
27+
PUBLIC__app__commerce__api__siteId=RefArch \
28+
PUBLIC__app__commerce__api__shortCode= \
29+
PUBLIC__app__commerce__api__callback=https://myproject-chuck.sfdc-8tgtt5-ecom1.exp-delivery.com/callback \
30+
PUBLIC__app__commerce__api__privateKeyEnabled=true \
31+
COMMERCE_API_SLAS_SECRET=sk_kasdjlkjsalkjasd
32+
33+
# import market street data from storefront-datasets repo
34+
b2c job import --server zzpq-014.dx.commercecloud.salesforce.com ~/code/storefront-datasets/demo_data_marketstreet
35+
36+
b2c code deploy
37+
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/**/*'
38+
39+

easy-setup.sh

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Configuration - modify these values for your setup
5+
ENV_SLUG="demo15"
6+
ENV_NAME="demo15"
7+
SITE_ID="RefArch"
8+
TENANT_ID="zzpq_013"
9+
ORGANIZATION_ID="f_ecom_zzsa_009"
10+
SHORT_CODE="kv7kzm78"
11+
BUILD_PATH="${BUILD_PATH:-$HOME/code/SFCC-Odyssey/packages/template-retail-rsc-app/build}"
12+
13+
export SFCC_MRT_PROJECT="${SFCC_MRT_PROJECT:-cli}"
14+
15+
echo "=== Step 1: Creating MRT environment ==="
16+
ENV_JSON=$(b2c mrt env create "$ENV_SLUG" --name "$ENV_NAME" --json)
17+
echo "Environment created."
18+
19+
# Extract the external hostname for the callback URL
20+
SSR_EXTERNAL_HOSTNAME=$(echo "$ENV_JSON" | jq -r '.ssr_external_hostname // empty')
21+
if [[ -z "$SSR_EXTERNAL_HOSTNAME" ]]; then
22+
# Fall back to hostname if external hostname not set
23+
SSR_EXTERNAL_HOSTNAME=$(echo "$ENV_JSON" | jq -r '.hostname // empty')
24+
fi
25+
26+
if [[ -z "$SSR_EXTERNAL_HOSTNAME" ]]; then
27+
echo "Warning: Could not determine external hostname from environment. Using localhost."
28+
CALLBACK_URL="http://localhost:3000/callback"
29+
else
30+
CALLBACK_URL="https://${SSR_EXTERNAL_HOSTNAME}/callback"
31+
fi
32+
echo "Callback URL: $CALLBACK_URL"
33+
34+
echo ""
35+
echo "=== Step 2: Creating SLAS client ==="
36+
SLAS_JSON=$(b2c slas client create --channels "$SITE_ID" \
37+
--redirect-uri "$CALLBACK_URL" \
38+
--default-scopes \
39+
--tenant-id "$TENANT_ID" \
40+
--json)
41+
echo "SLAS client created."
42+
43+
# Extract client ID and secret from SLAS response
44+
CLIENT_ID=$(echo "$SLAS_JSON" | jq -r '.clientId')
45+
CLIENT_SECRET=$(echo "$SLAS_JSON" | jq -r '.secret // empty')
46+
47+
if [[ -z "$CLIENT_ID" ]]; then
48+
echo "Error: Failed to get client ID from SLAS response"
49+
exit 1
50+
fi
51+
52+
echo "Client ID: $CLIENT_ID"
53+
if [[ -n "$CLIENT_SECRET" ]]; then
54+
echo "Client Secret: $CLIENT_SECRET (save this - it won't be shown again)"
55+
fi
56+
57+
echo ""
58+
echo "=== Step 3: Setting environment variables ==="
59+
b2c mrt env var set -e "$ENV_SLUG" \
60+
"PUBLIC__app__commerce__api__clientId=$CLIENT_ID" \
61+
"PUBLIC__app__commerce__api__organizationId=$ORGANIZATION_ID" \
62+
"PUBLIC__app__commerce__api__siteId=$SITE_ID" \
63+
"PUBLIC__app__commerce__api__shortCode=$SHORT_CODE" \
64+
"PUBLIC__app__commerce__api__proxy=/mobify/proxy/api" \
65+
"PUBLIC__app__commerce__api__callback=$CALLBACK_URL" \
66+
"PUBLIC__app__commerce__api__privateKeyEnabled=true" \
67+
${CLIENT_SECRET:+"COMMERCE_API_SLAS_SECRET=$CLIENT_SECRET"}
68+
69+
echo ""
70+
echo "=== Step 4: Deploying code ==="
71+
b2c code deploy
72+
73+
echo ""
74+
echo "=== Step 5: Importing job data ==="
75+
b2c job import data/urls
76+
77+
echo ""
78+
echo "=== Step 6: Pushing to MRT ==="
79+
b2c mrt push -e "$ENV_SLUG" -b "$BUILD_PATH"
80+
81+
echo ""
82+
echo "=== Setup Complete ==="
83+
echo "Environment: $ENV_SLUG"
84+
echo "Client ID: $CLIENT_ID"
85+
echo "URL: https://${SSR_EXTERNAL_HOSTNAME:-localhost:3000}"

0 commit comments

Comments
 (0)