MasterdataDirector#
Note
This is advanced documentation regarding a scope that can be accessed when executing a step of type Script.
The MasterdataDirector class orchestrates the creation of complex objects like automation protocols, driver definitions, and controllers using the Builder Design Pattern. It interacts with builder instances to construct these objects in a flexible and modular way.
Public Methods#
setBuilder#
setBuilder(type: MasterdataBuilderTypes): void
Assigns a specific builder type to the MasterdataDirector, used to switch between different builder implementations dynamically.
type: The type of builder (MasterdataBuilderTypes) to be set. Example:MasterdataBuilderTypes.JSON.
Throws an error if an unsupported builder type is provided.
buildProtocol#
buildProtocol(protocol: AutomationProtocol, protocolParameters?: AutomationProtocolParameter[]): Promise<void>
Builds an automation protocol, including optional protocol parameters.
- If no
protocolParametersare provided, a default protocol parameter is added. - Uses the builder to add protocol details to the underlying master data.
protocol: TheAutomationProtocolobject containing protocol details such as name, type, package information, etc.protocolParameters(optional): An array ofAutomationProtocolParameterobjects specifying additional parameters for the protocol.
A Promise that resolves when the operation is complete.
buildDriverDefinition#
buildDriverDefinition(driverDefinition: AutomationDriverDefinition, properties?: AutomationProperty[], events?: AutomationEvent[], eventProperties?: AutomationEventProperty[], commands?: AutomationCommand[], commandParameters?: AutomationCommandParameter[]): void
Constructs a driver definition with optional associated properties, events, and commands.
driverDefinition: TheAutomationDriverDefinitionobject containing details of the driver to be created.properties(optional): An array ofAutomationPropertyobjects for the driver.events(optional): An array ofAutomationEventobjects.eventProperties(optional): An array ofAutomationEventPropertyobjects.commands(optional): An array ofAutomationCommandobjects.commandParameters(optional): An array ofAutomationCommandParameterobjects.
void
const driverDefinition = {
name: `${this.answers.integrationName} Driver Definition`,
type: `General`,
automationProtocol: `${this.answers.integrationName} Protocol`,
objectType: this.answers.iotEnabledEntity.Name,
description
};
await this.masterdataDirector.buildDriverDefinition(driverDefinition);
buildController#
buildController(controller: AutomationController, controllerDriverDefinitions: AutomationControllerDriverDefinition[], controllerWorkflows: AutomationControllerWorkflow[]): Promise<void>
Creates an automation controller with driver definitions and workflows.
controller: TheAutomationControllerobject containing controller details.controllerDriverDefinitions: An array ofAutomationControllerDriverDefinitionobjects specifying drivers associated with the controller.controllerWorkflows: An array ofAutomationControllerWorkflowobjects specifying workflows for the controller.
A Promise that resolves when the operation is complete.
resetBuilder#
resetBuilder(): void
Resets the current builder instance.
void