Skip to content

Commit fd2410e

Browse files
committed
doc updates
1 parent 9ec97dc commit fd2410e

4 files changed

Lines changed: 50 additions & 9 deletions

File tree

packages/b2c-tooling/src/clients/index.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,45 @@
77
* ## Available Clients
88
*
99
* - {@link WebDavClient} - File operations via WebDAV
10-
* - {@link OcapiClient} - Data API operations via OCAPI
10+
* - {@link OcapiClient} - Data API operations via OCAPI (openapi-fetch Client)
1111
*
1212
* ## Usage
1313
*
14-
* Clients are typically accessed via {@link B2CInstance} rather than
15-
* instantiated directly:
14+
* **Note:** These clients are typically accessed via {@link B2CInstance} rather than
15+
* instantiated directly. The `B2CInstance` class handles authentication setup
16+
* and provides convenient `webdav` and `ocapi` getters.
1617
*
1718
* ```typescript
18-
* const instance = B2CInstance.fromDwJson();
19+
* import { B2CInstance } from '@salesforce/b2c-tooling';
1920
*
20-
* // WebDAV operations
21+
* const instance = B2CInstance.fromDwJson({
22+
* clientSecret: process.env.SFCC_CLIENT_SECRET,
23+
* });
24+
*
25+
* // WebDAV operations via instance.webdav
2126
* await instance.webdav.put('Cartridges/v1/app.zip', content);
2227
*
23-
* // OCAPI operations (openapi-fetch)
28+
* // OCAPI operations via instance.ocapi (openapi-fetch)
2429
* const { data } = await instance.ocapi.GET('/sites', {});
2530
* ```
2631
*
32+
* ## Direct Client Usage
33+
*
34+
* For advanced use cases, clients can be instantiated directly:
35+
*
36+
* ```typescript
37+
* import { WebDavClient, createOcapiClient } from '@salesforce/b2c-tooling/clients';
38+
*
39+
* const webdav = new WebDavClient('sandbox.demandware.net', authStrategy);
40+
* const ocapi = createOcapiClient('sandbox.demandware.net', authStrategy);
41+
* ```
42+
*
2743
* @module clients
2844
*/
2945
export {WebDavClient} from './webdav.js';
3046
export type {PropfindEntry} from './webdav.js';
3147

32-
export {createOcapiClient, createAuthMiddleware} from './ocapi.js';
48+
export {createOcapiClient, createAuthMiddleware, createLoggingMiddleware} from './ocapi.js';
3349
export type {
3450
OcapiClient,
3551
OcapiError,

packages/b2c-tooling/src/clients/ocapi.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ const DEFAULT_API_VERSION = 'v25_6';
1919
export type {paths, components};
2020

2121
/**
22-
* The typed OCAPI client - this is the actual openapi-fetch Client.
22+
* The typed OCAPI client - this is the openapi-fetch Client with full type safety.
23+
*
24+
* **Note:** This client is typically accessed via {@link B2CInstance.ocapi} rather
25+
* than created directly. The `B2CInstance` class handles authentication setup.
26+
*
27+
* @see {@link createOcapiClient} for direct instantiation
2328
*/
2429
export type OcapiClient = Client<paths>;
2530

@@ -129,12 +134,21 @@ export function createLoggingMiddleware(): Middleware {
129134
* handled via middleware. This gives full access to all openapi-fetch
130135
* features with type-safe paths, parameters, and responses.
131136
*
137+
* **Note:** This client is typically accessed via {@link B2CInstance.ocapi} rather
138+
* than created directly. The `B2CInstance` class handles authentication setup.
139+
*
132140
* @param hostname - B2C instance hostname
133-
* @param auth - OAuth authentication strategy
141+
* @param auth - Authentication strategy (typically OAuth)
134142
* @param apiVersion - API version (defaults to v25_6)
135143
* @returns Typed openapi-fetch client
136144
*
137145
* @example
146+
* // Via B2CInstance (recommended)
147+
* const instance = B2CInstance.fromDwJson();
148+
* const { data, error } = await instance.ocapi.GET('/sites', {});
149+
*
150+
* @example
151+
* // Direct instantiation (advanced)
138152
* const client = createOcapiClient('sandbox.demandware.net', authStrategy);
139153
*
140154
* // Fully typed GET request

packages/b2c-tooling/src/clients/webdav.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,17 @@ export interface PropfindEntry {
2727
* Handles WebDAV requests with proper authentication and provides
2828
* typed methods for common operations.
2929
*
30+
* **Note:** This client is typically accessed via {@link B2CInstance.webdav} rather
31+
* than instantiated directly. The `B2CInstance` class handles authentication setup.
32+
*
33+
* @example
34+
* // Via B2CInstance (recommended)
35+
* const instance = B2CInstance.fromDwJson();
36+
* await instance.webdav.mkcol('Cartridges/v1');
37+
* await instance.webdav.put('Cartridges/v1/app.zip', zipBuffer);
38+
*
3039
* @example
40+
* // Direct instantiation (advanced)
3141
* const client = new WebDavClient('sandbox.demandware.net', authStrategy);
3242
* await client.mkcol('Cartridges/v1');
3343
* await client.put('Cartridges/v1/app_storefront/cartridge.zip', zipBuffer);

typedoc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"$schema": "https://typedoc.org/schema.json",
33
"entryPoints": [
44
"./packages/b2c-tooling/src/auth/index.ts",
5+
"./packages/b2c-tooling/src/clients/index.ts",
56
"./packages/b2c-tooling/src/instance/index.ts",
67
"./packages/b2c-tooling/src/platform/index.ts",
78
"./packages/b2c-tooling/src/operations/code/index.ts",

0 commit comments

Comments
 (0)