Skip to content

Commit 97a7604

Browse files
@W-20893693: Adding AM - org topic
1 parent 8ce259a commit 97a7604

5 files changed

Lines changed: 347 additions & 1 deletion

File tree

docs/api-readme.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ const { data, error } = await instance.ocapi.PATCH('/code_versions/{code_version
242242

243243
## Account Manager Operations
244244

245-
The SDK provides operations for managing users and roles.
245+
The SDK provides operations for managing users, roles, and organizations.
246246

247247
### User Management
248248

@@ -350,6 +350,45 @@ const userRoles = await listRoles(client, {
350350
});
351351
```
352352

353+
### Organization Management
354+
355+
```typescript
356+
import {
357+
createAccountManagerOrgsClient,
358+
getOrg,
359+
getOrgByName,
360+
listOrgs,
361+
getOrgAuditLogs,
362+
} from '@salesforce/b2c-tooling-sdk/operations/orgs';
363+
import { OAuthStrategy } from '@salesforce/b2c-tooling-sdk/auth';
364+
365+
// Create Account Manager Organizations client
366+
const auth = new OAuthStrategy({
367+
clientId: 'your-client-id',
368+
clientSecret: 'your-client-secret',
369+
});
370+
371+
const client = createAccountManagerOrgsClient(
372+
{ accountManagerHost: 'account.demandware.com' },
373+
auth,
374+
);
375+
376+
// Get organization by ID
377+
const org = await getOrg(client, 'org-123');
378+
379+
// Get organization by name
380+
const orgByName = await getOrgByName(client, 'My Organization');
381+
382+
// List organizations with pagination
383+
const orgs = await listOrgs(client, { size: 25, page: 0 });
384+
385+
// List all organizations (uses max page size of 5000)
386+
const allOrgs = await listOrgs(client, { all: true });
387+
388+
// Get audit logs for an organization
389+
const auditLogs = await getOrgAuditLogs(client, 'org-123');
390+
```
391+
353392
### Required Permissions
354393

355394
Account Manager operations require:

docs/cli/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ These flags are available on all commands that interact with B2C instances:
4747

4848
- [User Management](./user) - Manage Account Manager users (list, create, update, delete, reset)
4949
- [Role Management](./role) - Manage Account Manager roles and role assignments
50+
- [Organization Management](./org) - Manage Account Manager organizations (list, view details, audit logs)
5051

5152
### Utilities
5253

docs/cli/org.md

Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
---
2+
description: Commands for managing Account Manager organizations including listing, viewing details, and accessing audit logs.
3+
---
4+
5+
# Organization Management Commands
6+
7+
Commands for managing organizations in Account Manager.
8+
9+
## Global Org Flags
10+
11+
These flags are available on all org commands:
12+
13+
| Flag | Environment Variable | Description |
14+
|------|---------------------|-------------|
15+
| `--account-manager-host` | `SFCC_ACCOUNT_MANAGER_HOST` | Account Manager hostname (e.g., `account.demandware.com`) |
16+
17+
## Authentication
18+
19+
Org commands require an Account Manager API Client with OAuth authentication.
20+
21+
### Required Configuration
22+
23+
| Flag | Environment Variable | Description |
24+
|------|---------------------|-------------|
25+
| `--client-id` | `SFCC_CLIENT_ID` | OAuth client ID for Account Manager |
26+
| `--client-secret` | `SFCC_CLIENT_SECRET` | OAuth client secret for Account Manager |
27+
28+
### Required Roles
29+
30+
The API client must have the following role:
31+
- `sfcc.accountmanager.user.manage` - Required for organization management operations
32+
33+
### Configuration
34+
35+
```bash
36+
# Set Account Manager host
37+
export SFCC_ACCOUNT_MANAGER_HOST=account.demandware.com
38+
39+
# Set OAuth credentials
40+
export SFCC_CLIENT_ID=my-client-id
41+
export SFCC_CLIENT_SECRET=my-client-secret
42+
43+
# List organizations
44+
b2c org list
45+
```
46+
47+
---
48+
49+
## b2c org list
50+
51+
List organizations in Account Manager with pagination support.
52+
53+
### Usage
54+
55+
```bash
56+
b2c org list [FLAGS]
57+
```
58+
59+
### Flags
60+
61+
| Flag | Description | Default |
62+
|------|-------------|---------|
63+
| `--page` | Page number (0-based) | `0` |
64+
| `--size`, `-s` | Number of results per page (1-5000) | `25` |
65+
| `--all`, `-a` | Return all organizations (uses max page size of 5000) | `false` |
66+
| `--columns` | Comma-separated list of columns to display | Default columns |
67+
| `--extended`, `-x` | Show all available columns | `false` |
68+
| `--json` | Output results as JSON | `false` |
69+
70+
### Default Columns
71+
72+
- ID
73+
- Name
74+
- Realms
75+
- Email Domains
76+
- 2FA Enabled
77+
- VaaS Enabled
78+
- SF Identity
79+
- Min Password Length
80+
81+
### Extended Columns
82+
83+
- 2FA Roles
84+
- Verifier Types
85+
86+
### Examples
87+
88+
```bash
89+
# List first page of organizations (default: 25 per page)
90+
b2c org list
91+
92+
# List organizations with custom page size
93+
b2c org list --size 50
94+
95+
# Get second page of results
96+
b2c org list --page 1 --size 25
97+
98+
# Get all organizations (uses max page size of 5000)
99+
b2c org list --all
100+
101+
# Show all columns
102+
b2c org list --extended
103+
104+
# Show only specific columns
105+
b2c org list --columns id,name,twoFAEnabled
106+
107+
# Output as JSON
108+
b2c org list --json
109+
110+
# Using environment variables
111+
export SFCC_ACCOUNT_MANAGER_HOST=account.demandware.com
112+
export SFCC_CLIENT_ID=my-client-id
113+
export SFCC_CLIENT_SECRET=my-client-secret
114+
b2c org list
115+
```
116+
117+
### Output
118+
119+
Displays a table of organizations with the selected columns. If more pages are available, an info message is displayed at the end.
120+
121+
### Notes
122+
123+
- Page size must be between 1 and 5000
124+
- Page number must be a non-negative integer (0-based)
125+
- If the requested page exceeds available data, an error is returned
126+
- The `--all` flag uses a page size of 5000 to fetch all organizations in a single request
127+
128+
---
129+
130+
## b2c org get
131+
132+
Get detailed information about a specific organization.
133+
134+
### Usage
135+
136+
```bash
137+
b2c org get <ORG>
138+
```
139+
140+
### Arguments
141+
142+
| Argument | Description | Required |
143+
|----------|-------------|----------|
144+
| `ORG` | Organization ID or name | Yes |
145+
146+
### Flags
147+
148+
| Flag | Description |
149+
|------|-------------|
150+
| `--json` | Output results as JSON |
151+
152+
### Examples
153+
154+
```bash
155+
# Get organization details by ID
156+
b2c org get org-123
157+
158+
# Get organization details by name
159+
b2c org get "My Organization"
160+
161+
# Output as JSON
162+
b2c org get org-123 --json
163+
```
164+
165+
### Output
166+
167+
When not using `--json`, displays formatted organization information including:
168+
169+
- **Organization Details**: ID, Name, 2FA Enabled, VaaS Enabled, SF Identity
170+
- **Contact Users**: List of contact user IDs
171+
- **Allowed Verifier Types**: List of allowed verifier types
172+
- **Account Ids**: List of Salesforce account IDs
173+
- **Password Policy**: Minimum Password Length, Length of Password History, Days Until Password Expires
174+
- **Realms**: Comma-separated list of realm names
175+
- **Email Domains**: List of allowed email domains
176+
- **2FA Roles**: List of roles that require 2FA
177+
178+
### Notes
179+
180+
- Organization can be identified by ID or name
181+
- If organization is not found, an error is returned
182+
- Name matching is case-sensitive and requires an exact match
183+
184+
---
185+
186+
## b2c org audit
187+
188+
Get audit logs for an Account Manager organization.
189+
190+
### Usage
191+
192+
```bash
193+
b2c org audit <ORG> [FLAGS]
194+
```
195+
196+
### Arguments
197+
198+
| Argument | Description | Required |
199+
|----------|-------------|----------|
200+
| `ORG` | Organization ID or name | Yes |
201+
202+
### Flags
203+
204+
| Flag | Description |
205+
|------|-------------|
206+
| `--columns` | Comma-separated list of columns to display |
207+
| `--extended`, `-x` | Show all available columns |
208+
| `--json` | Output results as JSON |
209+
210+
### Default Columns
211+
212+
- Timestamp
213+
- Author
214+
- Email
215+
- Event Type
216+
- Message
217+
218+
### Examples
219+
220+
```bash
221+
# Get audit logs for an organization by ID
222+
b2c org audit org-123
223+
224+
# Get audit logs for an organization by name
225+
b2c org audit "My Organization"
226+
227+
# Show all columns
228+
b2c org audit org-123 --extended
229+
230+
# Show only specific columns
231+
b2c org audit org-123 --columns timestamp,eventType,eventMessage
232+
233+
# Output as JSON
234+
b2c org audit org-123 --json
235+
```
236+
237+
### Output
238+
239+
Displays a table of audit log records with the selected columns. Timestamps are formatted as `MM/DD/YYYY HH:MM:SS` for readability.
240+
241+
### Notes
242+
243+
- Organization can be identified by ID or name
244+
- If organization is not found, an error is returned
245+
- If no audit records are found, a message is displayed
246+
- Timestamps are displayed in a human-readable format with zero-padding for consistent spacing

packages/b2c-cli/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,30 @@ b2c role grant user@example.com --role bm-admin --scope "tenant1,tenant2"
231231
b2c role revoke user@example.com --role bm-admin
232232
```
233233

234+
### Organization Management (Account Manager)
235+
236+
Manage organizations in Account Manager.
237+
238+
```sh
239+
# List organizations with pagination
240+
b2c org list --page 0 --size 25
241+
242+
# List all organizations
243+
b2c org list --all
244+
245+
# Get organization details by ID
246+
b2c org get org-123
247+
248+
# Get organization details by name
249+
b2c org get "My Organization"
250+
251+
# Get audit logs for an organization
252+
b2c org audit org-123
253+
254+
# Get audit logs with extended columns
255+
b2c org audit org-123 --extended
256+
```
257+
234258
### Authentication
235259

236260
Get OAuth tokens for scripting.

packages/b2c-tooling-sdk/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,41 @@ const userRoles = await listRoles(client, {
210210
});
211211
```
212212

213+
### Account Manager Organization Management
214+
215+
```typescript
216+
import {
217+
getOrg,
218+
getOrgByName,
219+
listOrgs,
220+
getOrgAuditLogs,
221+
} from '@salesforce/b2c-tooling-sdk/operations/orgs';
222+
import {createAccountManagerOrgsClient} from '@salesforce/b2c-tooling-sdk/clients';
223+
import {OAuthStrategy} from '@salesforce/b2c-tooling-sdk/auth';
224+
225+
const auth = new OAuthStrategy({
226+
clientId: 'your-client-id',
227+
clientSecret: 'your-client-secret',
228+
});
229+
230+
const client = createAccountManagerOrgsClient({}, auth);
231+
232+
// Get organization by ID
233+
const org = await getOrg(client, 'org-123');
234+
235+
// Get organization by name
236+
const orgByName = await getOrgByName(client, 'My Organization');
237+
238+
// List organizations with pagination
239+
const orgs = await listOrgs(client, {size: 25, page: 0});
240+
241+
// List all organizations (uses max page size of 5000)
242+
const allOrgs = await listOrgs(client, {all: true});
243+
244+
// Get audit logs for an organization
245+
const auditLogs = await getOrgAuditLogs(client, 'org-123');
246+
```
247+
213248
## Module Exports
214249

215250
The SDK provides subpath exports for tree-shaking and organization:
@@ -226,6 +261,7 @@ The SDK provides subpath exports for tree-shaking and organization:
226261
| `@salesforce/b2c-tooling-sdk/operations/sites` | Site management |
227262
| `@salesforce/b2c-tooling-sdk/operations/users` | Account Manager user management |
228263
| `@salesforce/b2c-tooling-sdk/operations/roles` | Account Manager role management |
264+
| `@salesforce/b2c-tooling-sdk/operations/orgs` | Account Manager organization management |
229265
| `@salesforce/b2c-tooling-sdk/discovery` | Workspace type detection (PWA Kit, SFRA, etc.) |
230266
| `@salesforce/b2c-tooling-sdk/cli` | CLI utilities (BaseCommand, table rendering) |
231267
| `@salesforce/b2c-tooling-sdk/logging` | Structured logging utilities |

0 commit comments

Comments
 (0)