/** * CLI utilities and base command classes for building B2C Commerce CLI commands. * * This module provides reusable base classes, configuration loading, and table * rendering utilities for oclif-based CLI applications. * * ## Base Command Classes * * Extend these classes to create CLI commands with pre-configured functionality: * * - {@link BaseCommand} - Foundation class with logging, JSON output, and error handling * - {@link OAuthCommand} - Adds OAuth authentication setup * - {@link InstanceCommand} - Adds B2C Commerce instance configuration * - {@link CartridgeCommand} - Adds cartridge path configuration for code operations * - {@link JobCommand} - Adds job execution configuration * - {@link WebDavCommand} - Adds WebDAV root directory configuration for file operations * - {@link MrtCommand} - Adds Managed Runtime API authentication * - {@link OdsCommand} - Adds On-Demand Sandbox configuration * * ## Command Hierarchy * * Commands inherit in a chain, each adding specific functionality: * * ``` * BaseCommand * └─ OAuthCommand (adds OAuth) * └─ InstanceCommand (adds instance config) * ├─ CartridgeCommand (adds cartridge paths) * ├─ JobCommand (adds job config) * └─ WebDavCommand (adds WebDAV root config) * └─ MrtCommand (adds MRT API auth) * └─ OdsCommand (adds ODS config) * ``` * * ## Example Usage * * ```typescript * import { InstanceCommand, createTable, type ColumnDef } from '@salesforce/b2c-tooling-sdk/cli'; * * export default class ListSites extends InstanceCommand { * static description = 'List all sites on the instance'; * * async run() { * const client = await this.createOcapiClient(); * const sites = await client.getSites(); * * const columns: Record> = { * id: { header: 'ID', get: (s) => s.id }, * name: { header: 'Name', get: (s) => s.display_name }, * }; * * createTable(columns).render(sites, ['id', 'name']); * } * } * ``` * * ## Configuration Loading * * Use {@link loadConfig} to resolve configuration from multiple sources: * * ```typescript * import { loadConfig } from '@salesforce/b2c-tooling-sdk/cli'; * * const config = await loadConfig({ * flags: { hostname: 'example.com' }, * configPath: './dw.json', * }); * ``` * * ## Table Rendering * * Use {@link createTable} for consistent tabular output: * * ```typescript * import { createTable, type ColumnDef } from '@salesforce/b2c-tooling-sdk/cli'; * * const columns: Record> = { * id: { header: 'ID', get: (item) => item.id }, * status: { header: 'Status', get: (item) => item.status }, * }; * * createTable(columns).render(items, ['id', 'status']); * ``` * * @module cli */ export { BaseCommand, ERROR_CODE, classifyError } from './base-command.js'; export type { Flags, Args, ErrorCategory } from './base-command.js'; export { OAuthCommand } from './oauth-command.js'; export { InstanceCommand } from './instance-command.js'; export { CartridgeCommand } from './cartridge-command.js'; export { JobCommand } from './job-command.js'; export { MrtCommand } from './mrt-command.js'; export { OdsCommand } from './ods-command.js'; export { AmCommand } from './am-command.js'; export { WebDavCommand, WEBDAV_ROOTS, VALID_ROOTS } from './webdav-command.js'; export type { WebDavRootKey } from './webdav-command.js'; export { loadConfig, findDwJson, extractOAuthFlags, extractInstanceFlags, extractMrtFlags, } from './config.js'; export type { LoadConfigOptions, PluginSources, ParsedFlags, ExtractedMrtFlags } from './config.js'; export type { ConfigSourcesHookOptions, ConfigSourcesHookResult, ConfigSourcesHook, HttpMiddlewareHookOptions, HttpMiddlewareHookResult, HttpMiddlewareHook, B2COperationType, B2COperationContext, BeforeB2COperationResult, B2COperationResult, AfterB2COperationResult, B2COperationLifecycleProvider, B2COperationLifecycleHookOptions, B2COperationLifecycleHookResult, B2COperationLifecycleHook, CartridgeDiscoveryOptions, CartridgeProvider, CartridgeTransformer, CartridgeProvidersHookOptions, CartridgeProvidersHookResult, CartridgeProvidersHook, } from './hooks.js'; export { createB2COperationContext, B2CLifecycleRunner } from './hooks.js'; export {} from './hooks.js'; export { TableRenderer, createTable } from './table.js'; export type { ColumnDef, TableRenderOptions } from './table.js'; export { columnFlagsFor, selectColumns } from './columns.js'; export type { ColumnFlags, ColumnFlagsOptions, WarnFn } from './columns.js'; export { printFieldsBlock } from './details.js'; export type { DetailField, DetailFieldObject, DetailSection, DetailValue, PrintFieldsBlockOptions } from './details.js';