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

@salesforce/b2c-tooling-sdk / config / InstanceManager

Class: InstanceManager

Defined in: packages/b2c-tooling-sdk/src/config/instance-manager.ts:44

Service for managing B2C instances across multiple config sources.

This class aggregates instance management operations from all sources that implement the optional instance management methods.

Example

typescript
import { InstanceManager, DwJsonSource } from '@salesforce/b2c-tooling-sdk/config';

const manager = new InstanceManager([new DwJsonSource()]);

// List all instances
const instances = manager.listAllInstances();

// Create a new instance
manager.createInstance({
  name: 'staging',
  config: { hostname: 'staging.example.com' },
  setActive: true,
});

Constructors

Constructor

new InstanceManager(sources): InstanceManager

Defined in: packages/b2c-tooling-sdk/src/config/instance-manager.ts:45

Parameters

sources

ConfigSource[]

Returns

InstanceManager

Methods

createInstance()

createInstance(options, targetSource?): void

Defined in: packages/b2c-tooling-sdk/src/config/instance-manager.ts:92

Create an instance in the specified source (or default to first instance source).

Parameters

options

CreateInstanceOptions & ResolveConfigOptions

Instance creation options

targetSource?

string

Source name to use (optional, defaults to first available)

Returns

void

Throws

Error if no instance sources available or specified source not found


getCredentialSources()

getCredentialSources(field): ConfigSource[]

Defined in: packages/b2c-tooling-sdk/src/config/instance-manager.ts:81

Get sources that can store a specific credential field.

Parameters

field

keyof NormalizedConfig

The credential field to check

Returns

ConfigSource[]

Array of sources that can store the field


getInstanceSources()

getInstanceSources(): ConfigSource[]

Defined in: packages/b2c-tooling-sdk/src/config/instance-manager.ts:71

Get sources that can create instances.

Returns

ConfigSource[]

Array of sources with createInstance() method


listAllInstances()

listAllInstances(options?): InstanceInfo[]

Defined in: packages/b2c-tooling-sdk/src/config/instance-manager.ts:53

List instances from all sources that implement listInstances().

Parameters

options?

ResolveConfigOptions

Resolution options

Returns

InstanceInfo[]

Array of all instances from all sources


removeInstance()

removeInstance(name, options?): void

Defined in: packages/b2c-tooling-sdk/src/config/instance-manager.ts:121

Remove an instance from the source that contains it.

Parameters

name

string

Instance name to remove

options?

ResolveConfigOptions

Resolution options

Returns

void

Throws

Error if instance not found in any source


setActiveInstance()

setActiveInstance(name, options?): void

Defined in: packages/b2c-tooling-sdk/src/config/instance-manager.ts:143

Set an instance as active in the source that contains it.

Parameters

name

string

Instance name to set as active

options?

ResolveConfigOptions

Resolution options

Returns

void

Throws

Error if instance not found in any source


storeCredential()

storeCredential(instanceName, field, value, targetSource?, options?): void

Defined in: packages/b2c-tooling-sdk/src/config/instance-manager.ts:168

Store a credential for an instance in the specified source.

Parameters

instanceName

string

Instance name

field

keyof NormalizedConfig

Config field to store

value

string

Value to store

targetSource?

string

Source name to use (optional)

options?

ResolveConfigOptions

Resolution options

Returns

void

Throws

Error if no credential sources support the field

Released under the Apache-2.0 License.