import { type TemplateResult } from "lit"; import { OrElement } from "@openremote/or-element"; import "@openremote/or-icon"; import { type AssetQuery, type AssetTypeInfo, type AttributeDescriptor, type JsonRule, type LogicGroup, type ManagerAppRealmNotificationConfig, type NotificationTargetType, type RuleActionUnion, type RuleCondition, RulesetLang, type RulesetUnion, type Asset } from "@openremote/model"; import "@openremote/or-translate"; import "@openremote/or-mwc-components/or-mwc-drawer"; import "@openremote/or-vaadin-components/or-vaadin-confirm-dialog"; import "./or-rule-viewer"; import "./or-rule-group-viewer"; import "./or-rule-tree"; import "./flow-viewer/flow-viewer"; import type { OrRuleViewer } from "./or-rule-viewer"; import type { RecurrenceOption } from "./json-viewer/or-rule-then-otherwise"; import type { ValueInputProviderGenerator } from "@openremote/or-mwc-components/or-mwc-input"; import { OrTreeDragEvent } from "@openremote/or-tree-menu"; export { buttonStyle } from "./style"; export declare const enum ConditionType { AGENT_QUERY = "agentQuery", ASSET_QUERY = "assetQuery", TIME = "time" } export declare const enum ActionType { WAIT = "wait", ALARM = "alarm", EMAIL = "email", EMAIL_LOCALIZED = "email_localized", PUSH_NOTIFICATION = "push", PUSH_LOCALIZED = "push_localized", ATTRIBUTE = "attribute", WEBHOOK = "webhook" } export declare enum TimeTriggerType { TIME_OF_DAY = "TIME_OF_DAY" } export declare enum AssetQueryOperator { VALUE_EMPTY = "empty", VALUE_NOT_EMPTY = "notEmpty", EQUALS = "equals", NOT_EQUALS = "notEquals", GREATER_THAN = "greaterThan", GREATER_EQUALS = "greaterEquals", LESS_THAN = "lessThan", LESS_EQUALS = "lessEquals", BETWEEN = "between", NOT_BETWEEN = "notBetween", CONTAINS = "contains", NOT_CONTAINS = "notContains", STARTS_WITH = "startsWith", NOT_STARTS_WITH = "notStartsWith", ENDS_WITH = "endsWith", NOT_ENDS_WITH = "notEndsWith", CONTAINS_KEY = "containsKey", NOT_CONTAINS_KEY = "notContainsKey", INDEX_CONTAINS = "indexContains", NOT_INDEX_CONTAINS = "notIndexContains", LENGTH_EQUALS = "lengthEquals", NOT_LENGTH_EQUALS = "notLengthEquals", LENGTH_GREATER_THAN = "lengthGreaterThan", LENGTH_LESS_THAN = "lengthLessThan", IS_TRUE = "true", IS_FALSE = "false", WITHIN_RADIUS = "withinRadius", OUTSIDE_RADIUS = "outsideRadius", WITHIN_RECTANGLE = "withinRectangle", OUTSIDE_RECTANGLE = "outsideRectangle", NOT_UPDATED_FOR = "notUpdatedFor", INSIDE_AREA = "insideArea", OUTSIDE_AREA = "outsideArea" } export interface AllowedActionTargetTypes { default?: NotificationTargetType[]; actions?: { [actionType in ActionType]?: NotificationTargetType[]; }; } export interface RulesConfig { controls?: { allowedLanguages?: RulesetLang[]; allowedConditionTypes?: ConditionType[]; allowedActionTypes?: ActionType[]; allowedAssetQueryOperators?: { [name: string]: AssetQueryOperator[]; }; allowedRecurrenceOptions?: RecurrenceOption[]; allowedActionTargetTypes?: AllowedActionTargetTypes; hideActionTypeOptions?: boolean; hideActionTargetOptions?: boolean; hideActionUpdateOptions?: boolean; hideConditionTypeOptions?: boolean; hideThenAddAction?: boolean; hideWhenAddCondition?: boolean; hideWhenAddAttribute?: boolean; hideWhenAddGroup?: boolean; multiSelect?: boolean; }; inputProvider?: ValueInputProviderGenerator; descriptors?: { all?: RulesDescriptorSection; when?: RulesDescriptorSection; action?: RulesDescriptorSection; }; rulesetTemplates?: { [key in RulesetLang]?: string; }; rulesetAddHandler?: (ruleset: RulesetUnion) => boolean; rulesetDeleteHandler?: (ruleset: RulesetUnion) => boolean; rulesetCopyHandler?: (ruleset: RulesetUnion) => boolean; rulesetSaveHandler?: (ruleset: RulesetUnion) => boolean; json?: { rule?: JsonRule; whenGroup?: LogicGroup; whenCondition?: RuleCondition; whenAssetQuery?: AssetQuery; then?: RuleActionUnion; otherwise?: RuleActionUnion; }; notifications?: { [realm: string]: ManagerAppRealmNotificationConfig; }; } export interface RulesDescriptorSection { includeAssets?: string[]; excludeAssets?: string[]; attributeDescriptors?: { [attributeName: string]: RulesConfigAttribute; }; /** * Asset type specific config; '*' key will be used as a default fallback if no asset type specific entry exists */ assets?: { [assetType: string]: RulesConfigAsset; }; } export interface RulesConfigAsset { includeAttributes?: string[]; excludeAttributes?: string[]; name?: string; icon?: string; color?: string; attributeDescriptors?: { [attributeName: string]: RulesConfigAttribute; }; } export interface RulesConfigAttribute extends AttributeDescriptor { } export interface RulesetBaseNode { type: "rule" | "group"; } export interface RulesetNode { type: "rule"; ruleset: RulesetUnion; selected: boolean; } export interface RulesetGroupNode extends RulesetBaseNode { type: "group"; groupId: string; } export interface RequestEventDetail { allow: boolean; detail: T; } export interface RuleView { validate: () => boolean; beforeSave: () => void; ruleset?: RulesetUnion; readonly?: boolean; config?: RulesConfig; } export interface RuleViewInfo { viewTemplateProvider: (ruleset: RulesetUnion, config: RulesConfig | undefined, readonly: boolean) => TemplateResult; viewRulesetTemplate?: string; } export declare const RuleViewInfoMap: { [key in RulesetLang]: RuleViewInfo; }; export declare function getAssetTypeFromQuery(query?: AssetQuery): string | undefined; export declare function getAssetIdsFromQuery(query?: AssetQuery): string[] | undefined; export declare const getAssetTypes: () => Promise; export declare function getAssetInfos(config: RulesConfig | undefined, useActionConfig: boolean): Promise; export declare function getAssetsByType(type: string, customQuery?: AssetQuery, loadedAssets?: Map): Promise<{ assets?: Asset[]; loadedAssets?: Map; }>; export declare class OrRulesRuleChangedEvent extends CustomEvent { static readonly NAME = "or-rules-rule-changed"; constructor(valid: boolean); } export declare class OrRulesRuleUnsupportedEvent extends CustomEvent { static readonly NAME = "or-rules-rule-unsupported"; constructor(); } export interface NodeSelectEventDetail { oldNodes: RulesetBaseNode[]; newNodes: RulesetBaseNode[]; } export declare class OrRulesRequestSelectionEvent extends CustomEvent { static readonly NAME = "or-rules-request-selection"; constructor(request: NodeSelectEventDetail); } export declare class OrRulesSelectionEvent extends CustomEvent { static readonly NAME = "or-rules-selection"; constructor(nodes: NodeSelectEventDetail); } export type AddEventDetail = { ruleset: RulesetUnion; sourceRuleset?: RulesetUnion; }; export declare class OrRulesRequestAddEvent extends CustomEvent> { static readonly NAME = "or-rules-request-add"; constructor(detail: AddEventDetail); } export declare class OrRulesRequestGroupEvent extends CustomEvent<{ value: string; }> { static readonly NAME = "or-rules-request-group"; constructor(name: string); } export declare class OrRulesAddEvent extends CustomEvent { static readonly NAME = "or-rules-add"; constructor(detail: AddEventDetail); } export declare class OrRulesRequestDeleteEvent extends CustomEvent> { static readonly NAME = "or-rules-request-delete"; constructor(request: RulesetNode[]); } export type SaveResult = { success: boolean; ruleset: RulesetUnion; isNew: boolean; }; export declare class OrRulesRequestSaveEvent extends CustomEvent> { static readonly NAME = "or-rules-request-save"; constructor(ruleset: RulesetUnion); } export declare class OrRulesSaveEvent extends CustomEvent { static readonly NAME = "or-rules-save"; constructor(result: SaveResult); } export declare class OrRulesDeleteEvent extends CustomEvent { static readonly NAME = "or-rules-delete"; constructor(rulesets: RulesetUnion[]); } export type OrRulesGroupNameChangeReason = "exists" | "legacyJavascript"; export declare class OrRulesGroupNameChangeEvent extends CustomEvent<{ value: string; reason?: OrRulesGroupNameChangeReason; }> { static readonly NAME = "or-rules-group-name-change"; constructor(name: string); } declare global { export interface HTMLElementEventMap { [OrRulesRuleUnsupportedEvent.NAME]: OrRulesRuleUnsupportedEvent; [OrRulesRuleChangedEvent.NAME]: OrRulesRuleChangedEvent; [OrRulesRequestSelectionEvent.NAME]: OrRulesRequestSelectionEvent; [OrRulesSelectionEvent.NAME]: OrRulesSelectionEvent; [OrRulesRequestAddEvent.NAME]: OrRulesRequestAddEvent; [OrRulesAddEvent.NAME]: OrRulesAddEvent; [OrRulesRequestDeleteEvent.NAME]: OrRulesRequestDeleteEvent; [OrRulesRequestSaveEvent.NAME]: OrRulesRequestSaveEvent; [OrRulesSaveEvent.NAME]: OrRulesSaveEvent; [OrRulesDeleteEvent.NAME]: OrRulesDeleteEvent; [OrTreeDragEvent.NAME]: OrTreeDragEvent; [OrRulesRequestGroupEvent.NAME]: OrRulesRequestGroupEvent; [OrRulesGroupNameChangeEvent.NAME]: OrRulesGroupNameChangeEvent; } } export declare const style: import("lit").CSSResult; declare const OrRules_base: (new (...args: any[]) => { _i18nextJustInitialized: boolean; _language: string; connectedCallback(): void; disconnectedCallback(): void; shouldUpdate(changedProps: import("lit").PropertyValues): any; initCallback: (options: import("i18next").InitOptions) => void; langChangedCallback: () => void; readonly isConnected: boolean; }) & typeof OrElement; export declare class OrRules extends OrRules_base { static DEFAULT_RULESET_NAME: string; static get styles(): import("lit").CSSResult[]; readonly?: boolean; config?: RulesConfig; realm?: string; language?: RulesetLang; private _isValidRule?; /** * Represents the selected group name. (groupId in rules meta) * Will be undefined once something else is selected */ protected _selectedGroup?: string; private _rulesTree?; private _viewer?; constructor(); protected render(): TemplateResult<1>; refresh(): void; protected _isReadonly(): boolean; protected _isLegacyJavascriptRuleset(ruleset?: RulesetUnion): boolean; protected _containsLegacyJavascriptRuleset(rulesets?: (RulesetUnion | undefined)[]): boolean; protected _confirmContinue(action: (ok: boolean) => void): void; /** * HTML event callback on when a "rule (or group) selection is requested". * It is a cancellable event that can prompt a user "to discard changes" if they have been made. * @param event - The cancellable selection event */ protected _onRuleSelectionRequested(event: OrRulesRequestSelectionEvent): void; /** * HTML event callback on when a new rule (or group) has been selected. * @param event - The selection event */ protected _onRuleSelectionChanged(event: OrRulesSelectionEvent): void; /** * Utility event callback function called by {@link _onRuleSelectionRequested} and {@link _onRuleSelectionChanged}, * when a new node in the {@link OrRuleTree} element is selected. It processes the event, and updates the {@link OrRuleViewer} with the new rule. * Alternatively, if a group is selected, it updates {@link _selectedGroup} instead. * @param payload - Event payload of the {@link RulesetBaseNode} selection */ protected _onNodeSelectionChanged(payload: NodeSelectEventDetail): void; /** * HTML callback event for when a new rule is added. * @param event - A {@link CustomEvent} with the new ruleset as payload. */ protected _onRuleAdd(event: OrRulesAddEvent): void; /** * HTML callback event for when a rule has been saved by the user. * @param event - A {@link CustomEvent} with a {@link SaveResult} payload. */ protected _onRuleSave(event: OrRulesSaveEvent): Promise; /** * Utility function that updates the viewer with the latest changes. * @param viewer - The or-rule-viewer HTML element * @param updatedRulesets - List of new rulesets that have been changed */ protected _checkForViewerUpdate(viewer?: OrRuleViewer | undefined, updatedRulesets?: RulesetUnion[]): void; /** * HTML callback for {@link OrTreeDragEvent}, for when a rule is dragged into (or outside) a group. * It handles updating of the 'meta groupId' in a rule, and persists the changes with the HTTP API. * @param ev - Tree drag event with a payload of the moved nodes */ protected _onRuleDrag(ev: OrTreeDragEvent): void; /** * Utility function that deselects the group by clearing {@link _selectedGroup}. */ protected _deselectGroup(): Promise; /** * HTML callback for when a new group is added to the {@link OrRuleTree}. * @param ev - Callback event */ protected _onGroupAddRequest(ev: OrRulesRequestGroupEvent): void; /** * HTML callback for when the selected group name has changed. * This function handles renaming the groupId of the rules within that group, * together with persisting the changes using the HTTP API. * @param ev - Callback event */ protected _onGroupNameChange(ev: OrRulesGroupNameChangeEvent): void; /** * Utility function that returns a promise for saving the ruleset, based on its type. * @param ruleset - The ruleset to be saved */ protected _saveRuleset(ruleset: RulesetUnion): Promise | undefined>; } //# sourceMappingURL=index.d.ts.map