@salesforce/b2c-tooling-sdk / schemas
schemas
OpenAPI Schema utilities for B2C Commerce.
Provides utilities for working with OpenAPI schemas, including collapsing large schemas for context-efficient representation in agentic/LLM scenarios.
Schema Collapsing
Use collapseOpenApiSchema to reduce the size of large OpenAPI schemas while preserving structure for discovery:
typescript
import { collapseOpenApiSchema } from '@salesforce/b2c-tooling-sdk/schemas';
// Collapse to outline form (default)
const collapsed = collapseOpenApiSchema(fullSchema);
// Result: paths show only ["get", "post"], schemas show only {}
// Selectively expand specific items
const collapsed = collapseOpenApiSchema(fullSchema, {
expandPaths: ['/products/search'],
expandSchemas: ['Product', 'SearchResult']
});Utility Functions
Helper functions for inspecting schemas:
typescript
import {
getPathKeys,
getSchemaNames,
isCollapsedSchema
} from '@salesforce/b2c-tooling-sdk/schemas';
// Get available paths
const paths = getPathKeys(schema); // ["/products", "/orders", ...]
// Get available schemas
const schemas = getSchemaNames(schema); // ["Product", "Order", ...]
// Check if schema is collapsed
if (isCollapsedSchema(schema)) {
console.log('Schema is in collapsed form');
}