Unified Configuration System with Plugin Extensibility Hooks#30
Unified Configuration System with Plugin Extensibility Hooks#30
Conversation
189dad3 to
782e21a
Compare
- Add b2c:config-sources hook for plugins to provide ConfigSource instances - Support priority ordering (before/after default sources) - Create example plugin demonstrating .env.b2c config loading - Add documentation for extending the CLI with custom plugins
|
@yhsieh1 This is a significant change in config. I've update the MCP Your services implementation is otherwise unchanged so I think everything should still work. |
OAuth (clientId/clientSecret) and Basic auth (username/password) credentials are now treated as atomic groups. If any field in a group is set by a higher-priority source, all fields in that group from lower-priority sources are skipped. This prevents accidentally mixing credentials that don't belong together.
|
It looks good overall but it seems there is check warning packages/b2c-cli/src/commands/job/run.ts |
We've had a few of these. Added a bug to fix them all #36 |
Summary
This PR introduces a unified configuration abstraction for the B2C SDK and adds a comprehensive plugin hook system for extending CLI functionality. The changes consolidate configuration loading logic, provide a consistent API across CLI and SDK consumers, and enable third-party plugins to inject configuration, middleware, lifecycle hooks, and custom cartridge discovery.
New Extensibility Hooks
b2c:config-sourcesb2c:http-middlewareb2c:operation-lifecycleb2c:cartridge-providersHTTP Middleware Hook
Plugins can inject middleware into all HTTP clients (OCAPI, SLAS, WebDAV, etc.) for logging, metrics, custom headers, or request/response transformation.
B2C Operation Lifecycle Hook
Plugins can observe and control B2C operation execution with before/after callbacks. The context includes the full
B2CInstancefor API access.Supported operations:
job:run,job:import,job:export,code:deployCartridge Providers Hook
Plugins can provide custom cartridge discovery logic (manifest files, remote sources, etc.).
Configuration System
New Components
ConfigResolver- High-level API for resolving configuration from multiple sourcesConfigSourceinterface - Extensible protocol for custom config sourcesDwJsonSource(dw.json),MobifySource(~/.mobify)NormalizedConfig- Canonical camelCase format for all configurationResolution Priority
priority: 'before'priority: 'after'(lowest)SDK Changes
New Files
src/cli/lifecycle.ts- B2C operation lifecycle types and runnersrc/cli/cartridge-providers.ts- Cartridge provider types and runnersrc/clients/middleware-registry.ts- HTTP middleware registry (SDK-level)src/config/resolver.ts- Configuration resolversrc/config/mapping.ts- Config format normalizationsrc/config/types.ts- Configuration type definitionsUpdated Base Commands
JobCommand- Lifecycle hook support for job operationsCartridgeCommand- Lifecycle hooks + cartridge provider integrationBaseCommand- HTTP middleware and config source collectionHTTP Client Updates
All clients now support middleware from the global registry:
Example Plugin
New package
@salesforce/b2c-plugin-example-configdemonstrating:EnvFileSource- Loads configuration from.env.b2cfilesDocumentation
docs/guide/extending.md- Comprehensive plugin development guide covering all four hooksdocs/guide/configuration.md- Resolution priority with plugin sources