import {z} from 'zod' export type IconUrl = string; export type Value = string; export type ValueType = string; export type Operator = 'CONTAINS' | 'DOES_NOT_CONTAIN' | 'EQUALS' | 'DOES_NOT_EQUAL' | 'GREATER_THAN' | 'GREATER_THAN_OR_EQUALS' | 'LESS_THAN' | 'LESS_THAN_OR_EQUALS' | 'ONE_OF'; export type Component = string; export type Version = number; export type VisibleCondition = {value: Value, valueType?: ValueType | undefined, operator: Operator, operand: string, component: Component, capability: string, version?: Version | undefined}; export type Icons = Array<{group?: string | undefined, iconUrl?: IconUrl | undefined, runningConditions?: Array | undefined, badge?: (Array<{iconUrl: IconUrl, visibleConditions?: Array | undefined}>) | undefined, productKeys?: Array<{mnId: string, setupId: string}> | undefined}>; export type Idx = number; export type Group = string; export type AlternativeItem = {key: string, value: string, type?: ('inactive' | 'active') | undefined, iconUrl?: IconUrl | undefined, description?: string | undefined}; export type Alternatives = Array; export type CapabilityValueForDashboardState = {label?: string | undefined, alternatives?: Alternatives | undefined}; export type Composite = boolean; export type TimeFormat = string; export type FormatInfo = Array<{key: Value, type: 'remainingTime' | 'time', remainingTime?: ({timeFormat: TimeFormat, frequency?: number | undefined}) | undefined, time?: {timeFormat: TimeFormat} | undefined}>; export type VisibleConditionForDashboardState = {value: Value, valueType?: ValueType | undefined, operator: Operator, operand: string, component: Component, capability: string, version?: Version | undefined, isOffline?: boolean | undefined}; export type DeviceConfigEntryForDashboardState = {component: string, capability: string, version?: Version | undefined, idx?: Idx | undefined, group?: Group | undefined, values?: Array | undefined, composite?: Composite | undefined, formatInfo?: FormatInfo | undefined, visibleCondition?: VisibleConditionForDashboardState | undefined}; export type ArgumentType = string; export type PushButton = {command: string, argument?: string | undefined, argumentType?: ArgumentType | undefined}; export type ToggleSwitchForDashboard = {command: {name?: string | undefined, on: string, off: string, argumentType?: ArgumentType | undefined}, state?: ({value?: Value | undefined, on: string, off: string, valueType?: ValueType | undefined, alternatives?: Alternatives | undefined}) | undefined}; export type SwitchForDashboard = {command: {name?: string | undefined, on: string, off: string, argumentType?: ArgumentType | undefined}, state?: ({value?: Value | undefined, on: string, off: string, valueType?: ValueType | undefined, alternatives?: Alternatives | undefined}) | undefined}; export type FormattedLabel = string; export type StandbyPowerSwitchForDashboard = {command: {name?: string | undefined, on: string, off: string, argumentType?: ArgumentType | undefined}, state?: ({value: Value, valueType?: ValueType | undefined, on: string, off: string, label?: FormattedLabel | undefined, alternatives?: Alternatives | undefined}) | undefined}; export type StatelessPowerToggleForDashboard = {command: string, argument?: string | undefined, argumentType?: ArgumentType | undefined}; export type PlayPause = {command: {name?: string | undefined, play: string, pause: string, argumentType?: ArgumentType | undefined}, state: {value: Value, valueType?: ValueType | undefined, play: string, pause: string, alternatives?: Alternatives | undefined}}; export type PlayStop = {command: {name?: string | undefined, play: string, stop: string, argumentType?: ArgumentType | undefined}, state: {value: Value, play: string, stop: string, alternatives?: Alternatives | undefined, valueType?: ValueType | undefined}}; export type DeviceConfigEntryForDashboardAction = {component: string, capability: string, version?: Version | undefined, idx?: Idx | undefined, group?: Group | undefined, inline?: ({displayType: 'pushButton' | 'toggleSwitch' | 'switch' | 'standbyPowerSwitch' | 'statelessPowerToggle' | 'playPause' | 'playStop', pushButton?: PushButton | undefined, toggleSwitch?: ToggleSwitchForDashboard | undefined, switch?: SwitchForDashboard | undefined, standbyPowerSwitch?: StandbyPowerSwitchForDashboard | undefined, statelessPowerToggle?: StatelessPowerToggleForDashboard | undefined, playPause?: PlayPause | undefined, playStop?: PlayStop | undefined, group?: Group | undefined}) | undefined, visibleCondition?: VisibleCondition | undefined}; export type BasicPlusCamera = {image: {capability: string, version?: Version | undefined, component: Component, value: Value}, overlayIcons?: (Array<{iconUrl: string, visibleCondition?: VisibleCondition | undefined}>) | undefined}; export type Step = number; export type Range = Array; export type SupportedValuesForNumericConstraints = string; export type ButtonForTv = {capability: string, version?: Version | undefined, component: Component, command: string, argument?: string | undefined, iconUrl?: string | undefined}; export type OperatorForVisibleConditions = 'AND' | 'OR'; export type HideDashboardActions = boolean; export type BasicPlusTv = {volume?: ({capability: string, version?: Version | undefined, component: Component, label?: string | undefined, command: {name?: string | undefined, increase?: string | undefined, decrease?: string | undefined}, value?: Value | undefined, step?: Step | undefined, range?: Range | undefined, supportedValues?: SupportedValuesForNumericConstraints | undefined}) | undefined, buttons: Array, channel?: ({capability: string, version?: Version | undefined, component: Component, label?: string | undefined, value?: Value | undefined, command: {name?: string | undefined, increase?: string | undefined, decrease?: string | undefined}}) | undefined, directionalPad?: ({capability: string, version?: Version | undefined, component: Component, command: {name?: string | undefined, up: string, down: string, left: string, right: string, ok: string}}) | undefined, operator?: OperatorForVisibleConditions | undefined, visibleConditions?: Array | undefined, hideDashboardActions?: HideDashboardActions | undefined}; export type Unit = string; export type SliderForLight = {component: string, capability: string, version?: Version | undefined, range: Range, step?: Step | undefined, unit?: Unit | undefined, supportedValues?: SupportedValuesForNumericConstraints | undefined, command: string, value: Value, valueType?: ValueType | undefined, argumentType?: ArgumentType | undefined, label: string}; export type BasicPlusLight = {dimmer: SliderForLight, colorTemperature?: SliderForLight | undefined, colorControl?: ({component: string, capability: string, version?: Version | undefined, command: string, value?: Value | undefined, color: {hue?: Value | undefined, saturation?: Value | undefined}}) | undefined, hideDashboardActions?: HideDashboardActions | undefined}; export type BasicPlusActions = Array<{command: string, argument?: string | undefined, argumentType?: ArgumentType | undefined, iconUrl?: string | undefined, component: string, capability: string, version?: Version | undefined, operator?: OperatorForVisibleConditions | undefined, visibleConditions?: Array | undefined}>; export type VisibleConditionForColorItem = {referTo?: ({component: Component, capability: string, version?: Version | undefined, value: Value, valueType?: ValueType | undefined}) | undefined, operator: Operator, operand: string}; export type BasicPlusStateBoardColors = {color: string, operator?: OperatorForVisibleConditions | undefined, visibleConditions?: Array | undefined}; export type BasicPlusStateBoardItem = {capability: string, version?: Version | undefined, component: string, value: Value, valueType?: ValueType | undefined, label: string, unit?: Unit | undefined, alternatives?: Alternatives | undefined, iconUrl?: string | undefined, colors?: Array | undefined, operator?: OperatorForVisibleConditions | undefined, visibleConditions?: Array | undefined}; export type BasicPlusStateBoard = Array; export type BasicPlusProgressBarsStateItem = {label: FormattedLabel, alternatives?: Alternatives | undefined, capability: string, version?: Version | undefined, component: Component, formatInfo?: FormatInfo | undefined, iconUrl?: string | undefined, placement?: ('START' | 'END') | undefined}; export type BasicPlusProgressBarsBarItem = {capability: string, version?: Version | undefined, component: string, value: Value, valueType?: ValueType | undefined, range?: Array | undefined}; export type BasicPlusProgressBars = Array<{headers?: Array | undefined, bar?: BasicPlusProgressBarsBarItem | undefined, footers?: Array | undefined, operator?: OperatorForVisibleConditions | undefined, visibleConditions?: Array | undefined}>; export type SizeForPanelItem = '1x1' | '2x1' | '3x1' | '4x1' | '1/3x1' | '1x2' | '2x2' | '4x2'; export type CapabilityValueForPanel = {enabledValues?: Array | undefined, label?: string | undefined, alternatives?: Alternatives | undefined, range?: Range | undefined, step?: Step | undefined, key?: string | undefined}; export type StepperWithAvailableSize = {command: {name?: string | undefined, increase?: string | undefined, decrease?: string | undefined, argumentType?: ArgumentType | undefined}, step: Step, range: Range, supportedValues?: SupportedValuesForNumericConstraints | undefined, state: {value: Value, unit?: Unit | undefined, valueType?: ValueType | undefined, label?: string | undefined, alternatives?: Alternatives | undefined}, availableSizes?: (Array<'2x1' | '3x1' | '4x1' | '1x2' | '2x2'>) | undefined}; export type SupportedValues = string; export type ListWithAvailableSize = {command: {name?: string | undefined, description?: string | undefined, alternatives: Alternatives, argumentType?: ArgumentType | undefined, supportedValues?: SupportedValues | undefined}, state?: ({value: Value, valueType?: ValueType | undefined, alternatives: Alternatives}) | undefined, availableSizes?: (Array<'2x1' | '3x1' | '4x1' | '1/3x1' | '2x2'>) | undefined}; export type PushButtonWithAvailableSize = {command: string, argument?: string | undefined, argumentType?: ArgumentType | undefined, iconUrl?: string | undefined, availableSizes?: (Array<'1x1' | '2x1' | '3x1' | '4x1' | '1/3x1' | '2x2'>) | undefined}; export type ArgumentName = string; export type ListForInvokeButtonArgument = {alternatives: Alternatives, supportedValues?: SupportedValues | undefined, label: string}; export type StateInvokeButtonArgument = {label: string, alternatives?: Alternatives | undefined}; export type ArgumentsForInvokeButton = {name: ArgumentName, value: string, argumentType?: ArgumentType | undefined, displayType?: ('list' | 'state') | undefined, list?: ListForInvokeButtonArgument | undefined, state?: StateInvokeButtonArgument | undefined}; export type CommandsForInvokeButton = {state: string, label?: string | undefined, iconUrl?: string | undefined, command: {name: string, argument?: string | undefined, argumentType?: ArgumentType | undefined, confirmation?: ({label: string, title?: string | undefined, description?: string | undefined}) | undefined, arguments?: Array | undefined, supportedValues?: string | undefined}}; export type InvokeButtonWithAvailableSize = {value: string, valueType?: ValueType | undefined, refreshInterval?: number | undefined, commands: Array, availableSizes?: (Array<'1x1' | '2x1' | '3x1' | '4x1' | '1/3x1' | '2x2'>) | undefined}; export type StateWithAvailableSize = {label: FormattedLabel, unit?: Unit | undefined, alternatives?: Alternatives | undefined, availableSizes?: Array<'2x1'> | undefined}; export type SliderWithAvailableSize = {range: Range, step?: Step | undefined, unit?: Unit | undefined, supportedValues?: SupportedValuesForNumericConstraints | undefined, alternatives?: Alternatives | undefined, command: string, argumentType?: ArgumentType | undefined, value?: Value | undefined, valueType?: ValueType | undefined, availableSizes?: (Array<'4x1' | '4x2'>) | undefined}; export type EmptyWithAvailableSize = {availableSizes?: (Array<'1x1' | '2x1' | '3x1' | '4x1' | '1/3x1' | '1x2' | '2x2'>) | undefined}; export type HideOnUnmatchForVisibleCondition = boolean; export type PanelForDeviceConfig = {items: Array<{component: string, capability: string, version?: Version | undefined, idx?: number | undefined, size: SizeForPanelItem, values?: Array | undefined, inline?: ({label?: string | undefined, displayType: 'stepper' | 'list' | 'pushButton' | 'invokeButton' | 'state' | 'slider' | 'empty', stepper?: StepperWithAvailableSize | undefined, list?: ListWithAvailableSize | undefined, pushButton?: PushButtonWithAvailableSize | undefined, invokeButton?: InvokeButtonWithAvailableSize | undefined, state?: StateWithAvailableSize | undefined, slider?: SliderWithAvailableSize | undefined, empty?: EmptyWithAvailableSize | undefined}) | undefined, operator?: OperatorForVisibleConditions | undefined, visibleConditions?: Array | undefined, hideOnUnmatch?: HideOnUnmatchForVisibleCondition | undefined}>, operator?: OperatorForVisibleConditions | undefined, visibleConditions?: Array | undefined, hideDashboardActions?: HideDashboardActions | undefined}; export type BasicPlusItem = {displayType: 'camera' | 'tv' | 'light' | 'panel' | 'actions' | 'stateBoard' | 'progressBars', camera?: BasicPlusCamera | undefined, tv?: BasicPlusTv | undefined, light?: BasicPlusLight | undefined, actions?: BasicPlusActions | undefined, stateBoard?: BasicPlusStateBoard | undefined, progressBars?: BasicPlusProgressBars | undefined, panel?: PanelForDeviceConfig | undefined}; export type GroupVisibleConditions = {value: Value, valueType?: ValueType | undefined, operator: Operator, operand: string, component: Component, capability: string, version?: Version | undefined}; export type CapabilityValue = {enabledValues?: Array | undefined, label?: string | undefined, alternatives?: Alternatives | undefined, range?: Range | undefined, step?: Step | undefined, key: string}; export type PatchItem = {op: 'add' | 'replace' | 'remove', path: string, value?: Record | undefined}; export type DeviceConfigEntryForDetailView = {component: string, capability: string, version?: Version | undefined, values?: Array | undefined, patch?: Array | undefined, visibleCondition?: ({value: Value, valueType?: ValueType | undefined, operator: Operator, operand: string, component: Component, capability: string, version?: Version | undefined, hideOnUnmatch?: HideOnUnmatchForVisibleCondition | undefined}) | undefined}; export type ExcludeItemsAttributes = Array<{name: string, excludedValues?: Array | undefined}>; export type ExcludedConditionItemId = {id?: number | undefined, value?: Record | undefined, exclude: Array<{component?: string | undefined, capability: string, version?: number | undefined, attributes?: ExcludeItemsAttributes | undefined}>}; export type ExcludedDeviceConditionConfigEntry = {component: string, capability: string, version?: Version | undefined, values?: Array | undefined, patch?: Array | undefined, visibleCondition?: VisibleCondition | undefined, exclusion?: Array | undefined}; export type ExcludeItemsCommands = Array<{name: string, excludedValues?: Array | undefined}>; export type ExcludedActionItemId = {id?: number | undefined, value?: Record | undefined, exclude: Array<{component?: string | undefined, capability: string, version?: number | undefined, commands?: ExcludeItemsCommands | undefined}>}; export type ExcludedDeviceActionConfigEntry = {component: string, capability: string, version?: Version | undefined, values?: Array | undefined, patch?: Array | undefined, visibleCondition?: VisibleCondition | undefined, exclusion?: Array | undefined}; export type CreateDeviceConfigWithProfileIdRequest = {iconUrl?: IconUrl | undefined, icons?: Icons | undefined, dashboard?: ({states?: Array | undefined, actions?: Array | undefined, basicPlus?: Array | undefined, groupVisibleConditions?: GroupVisibleConditions | undefined}) | undefined, detailView?: Array | undefined, automation?: ({conditions?: Array | undefined, actions?: Array | undefined}) | undefined, type?: ('dth' | 'profile') | undefined, deviceProfileId?: string | undefined}; export type CreateApiPresentationDeviceconfigArgs = {body: CreateDeviceConfigWithProfileIdRequest}; export type CreateApiPresentationDeviceconfigOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; export const mnmn = z.string(); export const vid = z.string(); export const presentationDescription = z.string(); export const dpInfo = z.array(z.object({os: z.enum(["android", "ios", "tizen", "web"]), dpUri: z.string(), serverDpUri: z.string().optional(), operatingMode: z.string().optional(), arguments: z.array(z.object({key: z.string(), value: z.string()})).optional()})); export const stPluginApiVersion = z.string(); export const dpInfos = z.array(z.object({stPluginApiVersion: stPluginApiVersion.optional(), dpInfo: dpInfo})); export const iconUrl = z.string(); export const value = z.string(); export const valueType = z.string(); export const operator = z.enum(["CONTAINS", "DOES_NOT_CONTAIN", "EQUALS", "DOES_NOT_EQUAL", "GREATER_THAN", "GREATER_THAN_OR_EQUALS", "LESS_THAN", "LESS_THAN_OR_EQUALS", "ONE_OF"]); export const component = z.string(); export const version = z.number().int(); export const visibleCondition = z.object({value: value, valueType: valueType.optional(), operator: operator, operand: z.string(), component: component, capability: z.string(), version: version.optional()}); export const icons = z.array(z.object({group: z.string().optional(), iconUrl: iconUrl.optional(), runningConditions: z.array(visibleCondition).optional(), badge: z.array(z.object({iconUrl: iconUrl, visibleConditions: z.array(visibleCondition).optional()})).optional(), productKeys: z.array(z.object({mnId: z.string(), setupId: z.string()})).optional()})); export const idx = z.number().int(); export const group = z.string(); export const alternativeItem = z.object({key: z.string(), value: z.string(), type: z.enum(["inactive", "active"]).optional(), iconUrl: iconUrl.optional(), description: z.string().optional()}); export const alternatives = z.array(alternativeItem); export const capabilityValueForDashboardState = z.object({label: z.string().optional(), alternatives: alternatives.optional()}); export const composite = z.boolean(); export const timeFormat = z.string(); export const formatInfo = z.array(z.object({key: value, type: z.enum(["remainingTime", "time"]), remainingTime: z.object({timeFormat: timeFormat, frequency: z.number().int().optional()}).optional(), time: z.object({timeFormat: timeFormat}).optional()})); export const visibleConditionForDashboardState = z.object({value: value, valueType: valueType.optional(), operator: operator, operand: z.string(), component: component, capability: z.string(), version: version.optional(), isOffline: z.boolean().optional()}); export const deviceConfigEntryForDashboardState = z.object({component: z.string(), capability: z.string(), version: version.optional(), idx: idx.optional(), group: group.optional(), values: z.array(capabilityValueForDashboardState).optional(), composite: composite.optional(), formatInfo: formatInfo.optional(), visibleCondition: visibleConditionForDashboardState.optional()}); export const argumentType = z.string(); export const pushButton = z.object({command: z.string(), argument: z.string().optional(), argumentType: argumentType.optional()}); export const toggleSwitchForDashboard = z.object({command: z.object({name: z.string().optional(), on: z.string(), off: z.string(), argumentType: argumentType.optional()}), state: z.object({value: value.optional(), on: z.string(), off: z.string(), valueType: valueType.optional(), alternatives: alternatives.optional()}).optional()}); export const switchForDashboard = z.object({command: z.object({name: z.string().optional(), on: z.string(), off: z.string(), argumentType: argumentType.optional()}), state: z.object({value: value.optional(), on: z.string(), off: z.string(), valueType: valueType.optional(), alternatives: alternatives.optional()}).optional()}); export const formattedLabel = z.string(); export const standbyPowerSwitchForDashboard = z.object({command: z.object({name: z.string().optional(), on: z.string(), off: z.string(), argumentType: argumentType.optional()}), state: z.object({value: value, valueType: valueType.optional(), on: z.string(), off: z.string(), label: formattedLabel.optional(), alternatives: alternatives.optional()}).optional()}); export const statelessPowerToggleForDashboard = z.object({command: z.string(), argument: z.string().optional(), argumentType: argumentType.optional()}); export const playPause = z.object({command: z.object({name: z.string().optional(), play: z.string(), pause: z.string(), argumentType: argumentType.optional()}), state: z.object({value: value, valueType: valueType.optional(), play: z.string(), pause: z.string(), alternatives: alternatives.optional()})}); export const playStop = z.object({command: z.object({name: z.string().optional(), play: z.string(), stop: z.string(), argumentType: argumentType.optional()}), state: z.object({value: value, play: z.string(), stop: z.string(), alternatives: alternatives.optional(), valueType: valueType.optional()})}); export const deviceConfigEntryForDashboardAction = z.object({component: z.string(), capability: z.string(), version: version.optional(), idx: idx.optional(), group: group.optional(), inline: z.object({displayType: z.enum(["pushButton", "toggleSwitch", "switch", "standbyPowerSwitch", "statelessPowerToggle", "playPause", "playStop"]), pushButton: pushButton.optional(), toggleSwitch: toggleSwitchForDashboard.optional(), switch: switchForDashboard.optional(), standbyPowerSwitch: standbyPowerSwitchForDashboard.optional(), statelessPowerToggle: statelessPowerToggleForDashboard.optional(), playPause: playPause.optional(), playStop: playStop.optional(), group: group.optional()}).optional(), visibleCondition: visibleCondition.optional()}); export const basicPlusCamera = z.object({image: z.object({capability: z.string(), version: version.optional(), component: component, value: value}), overlayIcons: z.array(z.object({iconUrl: z.string(), visibleCondition: visibleCondition.optional()})).optional()}); export const step = z.number(); export const range = z.array(z.number()); export const supportedValuesForNumericConstraints = z.string(); export const buttonForTv = z.object({capability: z.string(), version: version.optional(), component: component, command: z.string(), argument: z.string().optional(), iconUrl: z.string().optional()}); export const operatorForVisibleConditions = z.enum(["AND", "OR"]); export const hideDashboardActions = z.boolean(); export const basicPlusTv = z.object({volume: z.object({capability: z.string(), version: version.optional(), component: component, label: z.string().optional(), command: z.object({name: z.string().optional(), increase: z.string().optional(), decrease: z.string().optional()}), value: value.optional(), step: step.optional(), range: range.optional(), supportedValues: supportedValuesForNumericConstraints.optional()}).optional(), buttons: z.array(buttonForTv), channel: z.object({capability: z.string(), version: version.optional(), component: component, label: z.string().optional(), value: value.optional(), command: z.object({name: z.string().optional(), increase: z.string().optional(), decrease: z.string().optional()})}).optional(), directionalPad: z.object({capability: z.string(), version: version.optional(), component: component, command: z.object({name: z.string().optional(), up: z.string(), down: z.string(), left: z.string(), right: z.string(), ok: z.string()})}).optional(), operator: operatorForVisibleConditions.optional(), visibleConditions: z.array(visibleCondition).optional(), hideDashboardActions: hideDashboardActions.optional()}); export const unit = z.string(); export const sliderForLight = z.object({component: z.string(), capability: z.string(), version: version.optional(), range: range, step: step.optional(), unit: unit.optional(), supportedValues: supportedValuesForNumericConstraints.optional(), command: z.string(), value: value, valueType: valueType.optional(), argumentType: argumentType.optional(), label: z.string()}); export const basicPlusLight = z.object({dimmer: sliderForLight, colorTemperature: sliderForLight.optional(), colorControl: z.object({component: z.string(), capability: z.string(), version: version.optional(), command: z.string(), value: value.optional(), color: z.object({hue: value.optional(), saturation: value.optional()})}).optional(), hideDashboardActions: hideDashboardActions.optional()}); export const basicPlusActions = z.array(z.object({command: z.string(), argument: z.string().optional(), argumentType: argumentType.optional(), iconUrl: z.string().optional(), component: z.string(), capability: z.string(), version: version.optional(), operator: operatorForVisibleConditions.optional(), visibleConditions: z.array(visibleCondition).optional()})); export const visibleConditionForColorItem = z.object({referTo: z.object({component: component, capability: z.string(), version: version.optional(), value: value, valueType: valueType.optional()}).optional(), operator: operator, operand: z.string()}); export const basicPlusStateBoardColors = z.object({color: z.string(), operator: operatorForVisibleConditions.optional(), visibleConditions: z.array(visibleConditionForColorItem).optional()}); export const basicPlusStateBoardItem = z.object({capability: z.string(), version: version.optional(), component: z.string(), value: value, valueType: valueType.optional(), label: z.string(), unit: unit.optional(), alternatives: alternatives.optional(), iconUrl: z.string().optional(), colors: z.array(basicPlusStateBoardColors).optional(), operator: operatorForVisibleConditions.optional(), visibleConditions: z.array(visibleCondition).optional()}); export const basicPlusStateBoard = z.array(basicPlusStateBoardItem); export const basicPlusProgressBarsStateItem = z.object({label: formattedLabel, alternatives: alternatives.optional(), capability: z.string(), version: version.optional(), component: component, formatInfo: formatInfo.optional(), iconUrl: z.string().optional(), placement: z.enum(["START", "END"]).optional()}); export const basicPlusProgressBarsBarItem = z.object({capability: z.string(), version: version.optional(), component: z.string(), value: value, valueType: valueType.optional(), range: z.array(z.number()).optional()}); export const basicPlusProgressBars = z.array(z.object({headers: z.array(basicPlusProgressBarsStateItem).optional(), bar: basicPlusProgressBarsBarItem.optional(), footers: z.array(basicPlusProgressBarsStateItem).optional(), operator: operatorForVisibleConditions.optional(), visibleConditions: z.array(visibleCondition).optional()})); export const sizeForPanelItem = z.enum(["1x1", "2x1", "3x1", "4x1", "1/3x1", "1x2", "2x2", "4x2"]); export const capabilityValueForPanel = z.object({enabledValues: z.array(z.string()).optional(), label: z.string().optional(), alternatives: alternatives.optional(), range: range.optional(), step: step.optional(), key: z.string().optional()}); export const stepperWithAvailableSize = z.object({command: z.object({name: z.string().optional(), increase: z.string().optional(), decrease: z.string().optional(), argumentType: argumentType.optional()}), step: step, range: range, supportedValues: supportedValuesForNumericConstraints.optional(), state: z.object({value: value, unit: unit.optional(), valueType: valueType.optional(), label: z.string().optional(), alternatives: alternatives.optional()}), availableSizes: z.array(z.enum(["2x1", "3x1", "4x1", "1x2", "2x2"])).optional()}); export const supportedValues = z.string(); export const listWithAvailableSize = z.object({command: z.object({name: z.string().optional(), description: z.string().optional(), alternatives: alternatives, argumentType: argumentType.optional(), supportedValues: supportedValues.optional()}), state: z.object({value: value, valueType: valueType.optional(), alternatives: alternatives}).optional(), availableSizes: z.array(z.enum(["2x1", "3x1", "4x1", "1/3x1", "2x2"])).optional()}); export const pushButtonWithAvailableSize = z.object({command: z.string(), argument: z.string().optional(), argumentType: argumentType.optional(), iconUrl: z.string().optional(), availableSizes: z.array(z.enum(["1x1", "2x1", "3x1", "4x1", "1/3x1", "2x2"])).optional()}); export const argumentName = z.string(); export const listForInvokeButtonArgument = z.object({alternatives: alternatives, supportedValues: supportedValues.optional(), label: z.string()}); export const stateInvokeButtonArgument = z.object({label: z.string(), alternatives: alternatives.optional()}); export const argumentsForInvokeButton = z.object({name: argumentName, value: z.string(), argumentType: argumentType.optional(), displayType: z.enum(["list", "state"]).optional(), list: listForInvokeButtonArgument.optional(), state: stateInvokeButtonArgument.optional()}); export const commandsForInvokeButton = z.object({state: z.string(), label: z.string().optional(), iconUrl: z.string().optional(), command: z.object({name: z.string(), argument: z.string().optional(), argumentType: argumentType.optional(), confirmation: z.object({label: z.string(), title: z.string().optional(), description: z.string().optional()}).optional(), arguments: z.array(argumentsForInvokeButton).optional(), supportedValues: z.string().optional()})}); export const invokeButtonWithAvailableSize = z.object({value: z.string(), valueType: valueType.optional(), refreshInterval: z.number().int().optional(), commands: z.array(commandsForInvokeButton), availableSizes: z.array(z.enum(["1x1", "2x1", "3x1", "4x1", "1/3x1", "2x2"])).optional()}); export const stateWithAvailableSize = z.object({label: formattedLabel, unit: unit.optional(), alternatives: alternatives.optional(), availableSizes: z.array(z.literal("2x1")).optional()}); export const sliderWithAvailableSize = z.object({range: range, step: step.optional(), unit: unit.optional(), supportedValues: supportedValuesForNumericConstraints.optional(), alternatives: alternatives.optional(), command: z.string(), argumentType: argumentType.optional(), value: value.optional(), valueType: valueType.optional(), availableSizes: z.array(z.enum(["4x1", "4x2"])).optional()}); export const emptyWithAvailableSize = z.object({availableSizes: z.array(z.enum(["1x1", "2x1", "3x1", "4x1", "1/3x1", "1x2", "2x2"])).optional()}); export const hideOnUnmatchForVisibleCondition = z.boolean(); export const panelForDeviceConfig = z.object({items: z.array(z.object({component: z.string(), capability: z.string(), version: version.optional(), idx: z.number().int().optional(), size: sizeForPanelItem, values: z.array(capabilityValueForPanel).optional(), inline: z.object({label: z.string().optional(), displayType: z.enum(["stepper", "list", "pushButton", "invokeButton", "state", "slider", "empty"]), stepper: stepperWithAvailableSize.optional(), list: listWithAvailableSize.optional(), pushButton: pushButtonWithAvailableSize.optional(), invokeButton: invokeButtonWithAvailableSize.optional(), state: stateWithAvailableSize.optional(), slider: sliderWithAvailableSize.optional(), empty: emptyWithAvailableSize.optional()}).optional(), operator: operatorForVisibleConditions.optional(), visibleConditions: z.array(visibleCondition).optional(), hideOnUnmatch: hideOnUnmatchForVisibleCondition.optional()})), operator: operatorForVisibleConditions.optional(), visibleConditions: z.array(visibleCondition).optional(), hideDashboardActions: hideDashboardActions.optional()}); export const basicPlusItem = z.object({displayType: z.enum(["camera", "tv", "light", "panel", "actions", "stateBoard", "progressBars"]), camera: basicPlusCamera.optional(), tv: basicPlusTv.optional(), light: basicPlusLight.optional(), actions: basicPlusActions.optional(), stateBoard: basicPlusStateBoard.optional(), progressBars: basicPlusProgressBars.optional(), panel: panelForDeviceConfig.optional()}); export const groupVisibleConditions = z.object({value: value, valueType: valueType.optional(), operator: operator, operand: z.string(), component: component, capability: z.string(), version: version.optional()}); export const capabilityValue = z.object({enabledValues: z.array(z.string()).optional(), label: z.string().optional(), alternatives: alternatives.optional(), range: range.optional(), step: step.optional(), key: z.string()}); export const patchItem = z.object({op: z.enum(["add", "replace", "remove"]), path: z.string(), value: z.object({}).optional()}); export const deviceConfigEntryForDetailView = z.object({component: z.string(), capability: z.string(), version: version.optional(), values: z.array(capabilityValue).optional(), patch: z.array(patchItem).optional(), visibleCondition: z.object({value: value, valueType: valueType.optional(), operator: operator, operand: z.string(), component: component, capability: z.string(), version: version.optional(), hideOnUnmatch: hideOnUnmatchForVisibleCondition.optional()}).optional()}); export const excludeItemsAttributes = z.array(z.object({name: z.string(), excludedValues: z.array(z.string()).optional()})); export const excludedConditionItemId = z.object({id: z.number().int().optional(), value: z.object({}).optional(), exclude: z.array(z.object({component: z.string().optional(), capability: z.string(), version: z.number().int().optional(), attributes: excludeItemsAttributes.optional()}))}); export const excludedDeviceConditionConfigEntry = z.object({component: z.string(), capability: z.string(), version: version.optional(), values: z.array(capabilityValue).optional(), patch: z.array(patchItem).optional(), visibleCondition: visibleCondition.optional(), exclusion: z.array(excludedConditionItemId).optional()}); export const excludeItemsCommands = z.array(z.object({name: z.string(), excludedValues: z.array(z.string()).optional()})); export const excludedActionItemId = z.object({id: z.number().int().optional(), value: z.object({}).optional(), exclude: z.array(z.object({component: z.string().optional(), capability: z.string(), version: z.number().int().optional(), commands: excludeItemsCommands.optional()}))}); export const excludedDeviceActionConfigEntry = z.object({component: z.string(), capability: z.string(), version: version.optional(), values: z.array(capabilityValue).optional(), patch: z.array(patchItem).optional(), visibleCondition: visibleCondition.optional(), exclusion: z.array(excludedActionItemId).optional()}); export const descriptionItem = z.object({operator: operatorForVisibleConditions.optional(), label: z.string(), visibleConditions: z.array(visibleCondition).optional()}); export const descriptionsInAutomation = z.object({conditions: z.array(descriptionItem).optional(), actions: z.array(descriptionItem).optional()}); export const publicDeviceConfiguration = z.object({mnmn: mnmn, vid: vid, version: z.string().optional(), description: presentationDescription.optional(), type: z.enum(["dth", "profile"]).optional(), dpInfo: dpInfo.optional(), dpInfos: dpInfos.optional(), iconUrl: z.string().optional(), icons: icons.optional(), dashboard: z.object({states: z.array(deviceConfigEntryForDashboardState).optional(), actions: z.array(deviceConfigEntryForDashboardAction).optional(), basicPlus: z.array(basicPlusItem).optional(), groupVisibleConditions: groupVisibleConditions.optional()}).optional(), detailView: z.array(deviceConfigEntryForDetailView).optional(), automation: z.object({conditions: z.array(excludedDeviceConditionConfigEntry).optional(), actions: z.array(excludedDeviceActionConfigEntry).optional(), descriptions: descriptionsInAutomation.optional()}).optional(), presentationId: z.string().optional(), manufacturerName: z.string().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Create a Device Configuration * * POST /presentation/deviceconfig */ export const createApiPresentationDeviceconfig = async (args: CreateApiPresentationDeviceconfigArgs, options?: CreateApiPresentationDeviceconfigOptions) => { const {baseUrl = "https://api.smartthings.com/v1", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/presentation/deviceconfig${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(publicDeviceConfiguration, await res.json()) };