UNPKG

dt-common-device

Version:

A secure and robust device management library for IoT applications

119 lines (118 loc) 3.88 kB
import { CreateIssueData, IssuesCategory, IssuePriority, EntityType, IssueType, EntitySubType } from "./issue.types"; /** * IssueBuilder - A builder pattern implementation for constructing CreateIssueData objects * * This builder provides a fluent interface for creating issue data with proper validation * and default values. It follows the Builder pattern which is a standard design pattern * in TypeScript for constructing complex objects. * * Usage example: * const issueData = new IssueBuilder() * .setCategory(IssuesCategory.OPERATIONS) * .setPropertyId("prop123") * .setTitle("Device Maintenance Required") * .setDescription("Device requires scheduled maintenance") * .setEntityId("device456") * .setEntityType(EntityType.DEVICE) * .setPriority(IssuePriority.HIGH) * .setAssignedTo("tech789") * .setCreatedBy("user123") * .setDueDate(new Date("2024-01-15")) * .build(); */ export declare class IssueBuilder { private data; /** * Sets the issue category */ setCategory(category: IssuesCategory): this; /** * Sets the property ID */ setPropertyId(propertyId: string): this; /** * Sets the zone ID (optional) */ setZoneId(zoneId?: string): this; /** * Sets the issue type */ setType(type: IssueType): this; /** * Sets the issue title */ setTitle(title: string): this; /** * Sets the issue description */ setDescription(description: string): this; /** * Sets the entity ID (optional) */ setEntityId(entityId?: string): this; /** * Sets the entity type */ setEntityType(entityType: EntityType): this; /** * Sets the entity sub type */ setEntitySubType(entitySubType: EntitySubType): this; /** * Sets the issue priority (optional, defaults to LOW) */ setPriority(priority?: IssuePriority): this; /** * Sets the user assigned to the issue (optional) */ setAssignedTo(assignedTo?: string): this; /** * Sets the user who created the issue (required) */ setCreatedBy(createdBy: string): this; /** * Sets the due date (optional) */ setDueDate(dueDate?: Date): this; /** * Validates that all required fields are present */ private validate; /** * Builds and returns the CreateIssueData object * @throws Error if required fields are missing */ build(): CreateIssueData; /** * Resets the builder to its initial state */ reset(): this; static createOperationsIssue(): IssueBuilder; static createSecurityIssue(): IssueBuilder; static createEnergyIssue(): IssueBuilder; /** * Creates a device-specific issue builder */ static createDeviceIssue(deviceId: string, propertyId: string, type: IssueType, entitySubType: EntitySubType): IssueBuilder; /** * Creates a hub-specific issue builder */ static createHubIssue(hubId: string, propertyId: string, type: IssueType): IssueBuilder; /** * Creates a user-specific issue builder */ static createUserIssue(userId: string, propertyId: string, type: IssueType): IssueBuilder; /** * Creates a property-specific issue builder */ static createPropertyIssue(propertyId: string, type: IssueType): IssueBuilder; /** * Creates a maintenance issue builder */ static createMaintenanceIssue(propertyId: string, type: IssueType, entityId?: string, entityType?: EntityType): IssueBuilder; /** * Creates a high priority issue builder */ static createHighPriorityIssue(propertyId: string, type: IssueType, entityId?: string, entityType?: EntityType): IssueBuilder; static createCloudAccountAuthorizationIssue(propertyId: string, entityId: string, entityType: EntityType, type: IssueType): IssueBuilder; }