import { CalendarDateOrTime } from './date'; import { CalendarDuration } from './duration'; import { Property } from './property/Property'; import type { AllowedPropertyName } from './property/names'; /** * Represents an error which occurs while validating a calendar component. */ export declare class ComponentValidationError extends Error { constructor(message: string); } /** * Represents an error which occurs when trying to perform an operation which * would break the state of a calendar component. */ export declare class IllegalOperationError extends Error { constructor(message: string); } export declare class Component { name: string; properties: Property[]; components: Component[]; constructor(name: string, properties?: Property[], components?: Component[]); serialize(): string; getProperty(name: string): Property | null; setProperty(name: string, value: string | CalendarDateOrTime | CalendarDuration): this; /** * Add a property to this component. * @param property The property to add. * @returns This component for chaining. * @throws {IllegalOperationError} If the property cannot be added to this component. */ addProperty(property: Property): this; /** * Check whether this component has a certain property. * @param name The property name to check. * @param value An optional value to check against the property. If this is specified the property value must equal this value. * @returns Whether the property is present and matches the value if given. */ hasProperty(name: string, value?: string): boolean; removePropertiesWithName(name: string): void; addComponent(component: Component): this; addComponents(components: Component[]): this; /** * Remove a component from this component. * @param component The component to remove. * @returns `true` if the component was removed. `false` if the component was not present. */ removeComponent(component: Component): boolean; getComponentsWithName(name: string): Component[]; /** * Validate the component according to the rules of the iCalendar * specification. * * This method should be overridden by subclasses to * implement specific validation logic. The methods * {@link validateRequiredProperty} and {@link validateOptionalProperty} may * help with this. * @throws {ComponentValidationError} If the component is invalid. */ validate(): void; /** * Validate that a property exists and is valid using {@link validateProperty}. * @param propertyName The name of the property to validate. * @throws {MissingPropertyError} If the property doesn't exist on this component. * @throws {PropertyValidationError} If the property exists but is invalid. */ validateRequiredProperty(propertyName: AllowedPropertyName): void; /** * Validate that a property is valid using {@link validateProperty} if it exists. * @param propertyName The name of the property to validate. * @throws {PropertyValidationError} If the property exists and is invalid. */ validateOptionalProperty(propertyName: AllowedPropertyName): void; /** * Validate all properties on this component. * * If a property is in `requiredProperties` it is * validated with {@link validateRequiredProperty}, otherwise it is * validated with {@link validateOptionalProperty}. * @param requiredProperties A list of property names which are required on this component. */ validateAllProperties(requiredProperties?: AllowedPropertyName[]): void; } //# sourceMappingURL=component.d.ts.map