Developer Preview — This project is in active development. APIs may change. Provide feedback
Skip to content

@salesforce/b2c-tooling-sdk / cli / B2COperationLifecycleHook

Type Alias: B2COperationLifecycleHook

B2COperationLifecycleHook = Hook<"b2c:operation-lifecycle">

Defined in: packages/b2c-tooling-sdk/src/cli/lifecycle.ts:205

Hook type for b2c:operation-lifecycle.

Implement this hook in your oclif plugin to receive B2C operation lifecycle events for jobs, deployments, and other B2C Commerce operations.

Plugin Registration

Register the hook in your plugin's package.json:

json
{
  "oclif": {
    "hooks": {
      "b2c:operation-lifecycle": "./dist/hooks/operation-lifecycle.js"
    }
  }
}

Example

typescript
import type { B2COperationLifecycleHook } from '@salesforce/b2c-tooling-sdk/cli';

const hook: B2COperationLifecycleHook = async function(options) {
  return {
    providers: [{
      name: 'my-audit-provider',
      async beforeOperation(context) {
        // Access context.instance for API calls
        // Log or check policies before operation
      },
      async afterOperation(context, result) {
        // Log results, send notifications, etc.
      },
    }],
  };
};

export default hook;

All rights reserved.