|
1 | 1 | --- |
2 | | -description: Commands for exporting and listing Page Designer content from B2C Commerce content libraries. |
| 2 | +description: Commands for exporting, listing, and validating Page Designer content from B2C Commerce content libraries. |
3 | 3 | --- |
4 | 4 |
|
5 | 5 | # Content Commands |
6 | 6 |
|
7 | | -Commands for working with Page Designer content libraries on B2C Commerce instances. |
| 7 | +Commands for working with Page Designer content libraries and metadefinitions. |
8 | 8 |
|
9 | 9 | ## Authentication |
10 | 10 |
|
11 | | -Content commands require OAuth authentication: |
| 11 | +The `content export` and `content list` commands require OAuth authentication: |
12 | 12 |
|
13 | 13 | | Operation | Auth Required | |
14 | 14 | |-----------|--------------| |
15 | 15 | | `content export` | OAuth (OCAPI for export job + WebDAV for assets) | |
16 | 16 | | `content list` | OAuth (OCAPI for export job) | |
| 17 | +| `content validate` | None (local file validation) | |
17 | 18 |
|
18 | 19 | ```bash |
19 | 20 | export SFCC_CLIENT_ID=your-client-id |
20 | 21 | export SFCC_CLIENT_SECRET=your-client-secret |
21 | 22 | ``` |
22 | 23 |
|
23 | | -Both commands also support a `--library-file` flag for offline use with a local XML file, which skips authentication entirely. |
| 24 | +The `content export` and `content list` commands also support a `--library-file` flag for offline use with a local XML file, which skips authentication entirely. |
24 | 25 |
|
25 | 26 | For complete setup instructions, see the [Authentication Guide](/guide/authentication). |
26 | 27 |
|
@@ -201,3 +202,96 @@ footer-content (CONTENT ASSET) |
201 | 202 | Pages show `id (typeId: type)`, components show `typeId (id)`, content assets show `id (CONTENT ASSET)`, and static assets show `path (STATIC ASSET)`. The tree uses color when output to a terminal: page names are bold, component type IDs are cyan, asset paths are green, and tree connectors are dim. |
202 | 203 |
|
203 | 204 | With `--json`, returns `{ data: [...] }` with each item containing `id`, `type`, `typeId`, and `children` count. |
| 205 | + |
| 206 | +--- |
| 207 | + |
| 208 | +## b2c content validate |
| 209 | + |
| 210 | +Validate Page Designer metadefinition JSON files against bundled JSON schemas. This is a local-only command — no instance connection or authentication is required. |
| 211 | + |
| 212 | +The command auto-detects the schema type using file path conventions (`experience/pages/` → pagetype, `experience/components/` → componenttype) and falls back to inspecting the JSON properties. You can also specify the type explicitly with `--type`. |
| 213 | + |
| 214 | +### Usage |
| 215 | + |
| 216 | +```bash |
| 217 | +b2c content validate <files...> |
| 218 | +``` |
| 219 | + |
| 220 | +### Arguments |
| 221 | + |
| 222 | +| Argument | Description | Required | |
| 223 | +|----------|-------------|----------| |
| 224 | +| `files` | One or more file paths, directories, or glob patterns | Yes | |
| 225 | + |
| 226 | +When a directory is passed, all `*.json` files within it are validated recursively. |
| 227 | + |
| 228 | +### Flags |
| 229 | + |
| 230 | +In addition to [global flags](./index#global-flags): |
| 231 | + |
| 232 | +| Flag | Description | Default | |
| 233 | +|------|-------------|---------| |
| 234 | +| `--type`, `-t` | Schema type to validate against (skips auto-detection) | Auto-detected | |
| 235 | + |
| 236 | +Available schema types: `pagetype`, `componenttype`, `aspecttype`, `cmsrecord`, `customeditortype`, `contentassetpageconfig`, `contentassetcomponentconfig`, `contentassetstructuredcontentdata`, `image`. |
| 237 | + |
| 238 | +### Examples |
| 239 | + |
| 240 | +```bash |
| 241 | +# Validate a single page type definition |
| 242 | +b2c content validate cartridge/experience/pages/storePage.json |
| 243 | + |
| 244 | +# Validate all metadefinitions in a directory recursively |
| 245 | +b2c content validate cartridge/experience/ |
| 246 | + |
| 247 | +# Validate with a glob pattern |
| 248 | +b2c content validate 'cartridge/experience/**/*.json' |
| 249 | + |
| 250 | +# Explicitly specify the schema type |
| 251 | +b2c content validate --type componenttype mycomponent.json |
| 252 | + |
| 253 | +# Validate multiple files |
| 254 | +b2c content validate pages/home.json pages/about.json components/hero.json |
| 255 | + |
| 256 | +# JSON output for CI/scripting |
| 257 | +b2c content validate cartridge/experience/ --json |
| 258 | +``` |
| 259 | + |
| 260 | +### Output |
| 261 | + |
| 262 | +The command prints a color-coded result for each file: |
| 263 | + |
| 264 | +``` |
| 265 | +PASS: experience/pages/storePage.json (pagetype) |
| 266 | +PASS: experience/components/hero.json (componenttype) |
| 267 | +FAIL: experience/components/broken.json (componenttype) |
| 268 | + ERROR at .attribute_definition_groups[0]: is required |
| 269 | +
|
| 270 | +2/3 file(s) valid, 1 error(s) |
| 271 | +``` |
| 272 | + |
| 273 | +The command exits with a non-zero status when any file fails validation. |
| 274 | + |
| 275 | +With `--json`, returns a structured result: |
| 276 | + |
| 277 | +```json |
| 278 | +{ |
| 279 | + "results": [ |
| 280 | + { |
| 281 | + "valid": true, |
| 282 | + "schemaType": "pagetype", |
| 283 | + "errors": [], |
| 284 | + "filePath": "/path/to/storePage.json" |
| 285 | + } |
| 286 | + ], |
| 287 | + "totalFiles": 1, |
| 288 | + "validFiles": 1, |
| 289 | + "totalErrors": 0 |
| 290 | +} |
| 291 | +``` |
| 292 | + |
| 293 | +### Notes |
| 294 | + |
| 295 | +- Auto-detection uses file path conventions first: files under `experience/pages/` are validated as `pagetype`, files under `experience/components/` as `componenttype`. For other schema types, use `--type`. |
| 296 | +- Schemas are bundled with the SDK and follow the [Page Designer metadefinition specification](https://developer.salesforce.com/docs/commerce/b2c-commerce/guide/b2c-page-designer.html). |
| 297 | +- Use `b2c content validate` in CI pipelines to catch metadefinition errors before deployment. |
0 commit comments