import {z} from 'zod' export type FormattedLabel = string; export type IconUrl = string; export type AlternativeItem = {key: string, value: string, type?: ('inactive' | 'active') | undefined, iconUrl?: IconUrl | undefined, description?: string | undefined}; export type Alternatives = Array; export type StateItem = {label: FormattedLabel, alternatives?: Alternatives | undefined}; export type ArgumentType = string; export type PushButton = {command: string, argument?: string | undefined, argumentType?: ArgumentType | undefined}; export type Value = string; export type ValueType = string; 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 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 Group = string; export type ActionItem = {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}; export type Step = number; export type Range = Array; export type SupportedValuesForNumericConstraints = string; export type Unit = string; 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 PanelItemForCapability = {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}; export type DashboardForCapability = {states?: Array | undefined, actions?: Array | undefined, panelItems?: Array | undefined}; export type ToggleSwitch = {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 StandbyPowerSwitch = {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 Switch = {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 SliderType = {range: Range, step?: Step | undefined, unit?: Unit | undefined, supportedValues?: SupportedValuesForNumericConstraints | undefined, alternatives?: Alternatives | undefined, command?: string | undefined, argumentType?: ArgumentType | undefined, value?: Value | undefined, valueType?: ValueType | undefined}; export type TextButton = {command?: string | undefined, value?: Value | undefined, buttons: Array<{key: string, label: string, state?: string | undefined}>, supportedValues?: SupportedValues | undefined}; export type ListForDetailView = {command: {name?: string | undefined, description?: string | undefined, alternatives: Alternatives, argumentType?: ArgumentType | undefined, supportedValues?: SupportedValues | undefined}, state?: ({value: Value, valueType?: ValueType | undefined, alternatives: Alternatives}) | undefined}; export type TextField = {command: string, argumentType?: ArgumentType | undefined, value?: Value | undefined, valueType?: ValueType | undefined, range?: Range | undefined}; export type NumberField = {value?: Value | undefined, valueType?: ValueType | undefined, unit?: Unit | undefined, command: string, argumentType?: ArgumentType | undefined, range?: Range | undefined, supportedValues?: SupportedValuesForNumericConstraints | undefined}; export type Stepper = {command: {name?: string | undefined, increase?: string | undefined, decrease?: string | undefined, argumentType?: ArgumentType | undefined}, step: Step, range: Range, supportedValues?: SupportedValuesForNumericConstraints | undefined, value?: Value | undefined, valueType?: ValueType | undefined}; export type State = {label: FormattedLabel, unit?: Unit | undefined, alternatives?: Alternatives | undefined}; 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 VisibleConditionBase = {value: Value, valueType?: ValueType | undefined, operator: Operator, operand: string}; export type DetailViewForCapability = Array<{label: string, displayType: 'toggleSwitch' | 'standbyPowerSwitch' | 'switch' | 'slider' | 'pushButton' | 'textButton' | 'playPause' | 'playStop' | 'list' | 'textField' | 'numberField' | 'stepper' | 'state', toggleSwitch?: ToggleSwitch | undefined, standbyPowerSwitch?: StandbyPowerSwitch | undefined, switch?: Switch | undefined, slider?: SliderType | undefined, pushButton?: PushButton | undefined, textButton?: TextButton | undefined, playPause?: PlayPause | undefined, playStop?: PlayStop | undefined, list?: ListForDetailView | undefined, textField?: TextField | undefined, numberField?: NumberField | undefined, stepper?: Stepper | undefined, state?: State | undefined, visibleCondition?: VisibleConditionBase | undefined}>; export type DescriptionForAutomationItem = string; export type DescriptionForAutomatioDisplayType = string; export type SliderForAutomationCondition = {range: Range, step?: Step | undefined, unit?: Unit | undefined, supportedValues?: SupportedValuesForNumericConstraints | undefined, alternatives?: Alternatives | undefined, value: Value, valueType?: ValueType | undefined, description?: DescriptionForAutomatioDisplayType | undefined}; export type ListForAutomationCondition = {alternatives: Alternatives, supportedValues?: SupportedValues | undefined, value: Value, valueType?: ValueType | undefined, description?: DescriptionForAutomatioDisplayType | undefined, multiSelectable?: boolean | undefined}; export type SupportedValuesForDynamicList = {value: string, valueMap?: {key: string, value: string} | undefined}; export type AlternativesForDynamicList = Array; export type DynamicListForAutomationCondition = {value: Value, valueType?: string | undefined, supportedValues: SupportedValuesForDynamicList, alternatives?: AlternativesForDynamicList | undefined, description?: DescriptionForAutomatioDisplayType | undefined, multiSelectable?: boolean | undefined}; export type NumberFieldForAutomationCondition = {value: Value, valueType?: ValueType | undefined, unit?: Unit | undefined, range?: Range | undefined, alternatives?: Alternatives | undefined, supportedValues?: SupportedValuesForNumericConstraints | undefined, description?: DescriptionForAutomatioDisplayType | undefined}; export type TextFieldForAutomationCondition = {value: Value, valueType?: ValueType | undefined, range?: Range | undefined, description?: DescriptionForAutomatioDisplayType | undefined}; export type EnumSliderForAutomationCondition = {alternatives: Alternatives, value: Value, supportedOperators?: (Array<{operator: 'EQUALS' | 'GREATER_THAN_OR_EQUALS' | 'LESS_THAN_OR_EQUALS', label: string}>) | undefined}; export type UnitWithoutPatternForPresentation = string; export type NumberPickerForAutomationCondition = {value: Value, valueType?: ValueType | undefined, unit?: UnitWithoutPatternForPresentation | undefined, range?: Range | undefined, supportedValues?: SupportedValuesForNumericConstraints | undefined, description?: DescriptionForAutomatioDisplayType | undefined}; export type SliderForAutomationAction = {range: Range, step?: Step | undefined, unit?: Unit | undefined, supportedValues?: SupportedValuesForNumericConstraints | undefined, alternatives?: Alternatives | undefined, command: string, argumentType?: ArgumentType | undefined, description?: DescriptionForAutomatioDisplayType | undefined}; export type ListForAutomationAction = {alternatives: Alternatives, supportedValues?: SupportedValues | undefined, command?: string | undefined, argumentType?: ArgumentType | undefined, description?: DescriptionForAutomatioDisplayType | undefined}; export type DynamicListForAutomationAction = {command?: string | undefined, argumentType?: string | undefined, supportedValues: SupportedValuesForDynamicList, alternatives?: AlternativesForDynamicList | undefined, description?: DescriptionForAutomatioDisplayType | undefined}; export type TextFieldForAutomationAction = {command: string, argumentType?: ArgumentType | undefined, range?: Range | undefined, description?: DescriptionForAutomatioDisplayType | undefined}; export type NumberFieldForAutomationAction = {command: string, argumentType?: ArgumentType | undefined, unit?: Unit | undefined, range?: Range | undefined, alternatives?: Alternatives | undefined, supportedValues?: SupportedValuesForNumericConstraints | undefined, description?: DescriptionForAutomatioDisplayType | undefined}; export type NumberPickerForAutomationAction = {command: string, argumentType?: ArgumentType | undefined, unit?: UnitWithoutPatternForPresentation | undefined, range?: Range | undefined, supportedValues?: SupportedValuesForNumericConstraints | undefined, description?: DescriptionForAutomatioDisplayType | undefined}; export type SliderForArgument = {range: Range, step?: Step | undefined, unit?: Unit | undefined, supportedValues?: SupportedValuesForNumericConstraints | undefined, name: ArgumentName, argumentType?: ArgumentType | undefined, alternatives?: Alternatives | undefined}; export type ListForArgument = {alternatives: Alternatives, supportedValues?: SupportedValues | undefined, name: ArgumentName, argumentType?: ArgumentType | undefined}; export type TextFieldForArgument = {name: ArgumentName, argumentType?: ArgumentType | undefined, range?: Range | undefined}; export type NumberFieldForArgument = {name: ArgumentName, unit?: Unit | undefined, argumentType?: ArgumentType | undefined, range?: Range | undefined, supportedValues?: SupportedValuesForNumericConstraints | undefined}; export type MultiArgCommand = {command: string, arguments: Array<{label: string, displayType: 'slider' | 'list' | 'textField' | 'numberField', slider?: SliderForArgument | undefined, list?: ListForArgument | undefined, textField?: TextFieldForArgument | undefined, numberField?: NumberFieldForArgument | undefined}>, supportedValues?: string | undefined}; export type AutomationForCapability = {conditions?: (Array<{label: string, description?: DescriptionForAutomationItem | undefined, displayType: 'slider' | 'list' | 'dynamicList' | 'numberField' | 'textField' | 'enumSlider' | 'numberPicker', slider?: SliderForAutomationCondition | undefined, list?: ListForAutomationCondition | undefined, dynamicList?: DynamicListForAutomationCondition | undefined, numberField?: NumberFieldForAutomationCondition | undefined, textField?: TextFieldForAutomationCondition | undefined, enumSlider?: EnumSliderForAutomationCondition | undefined, numberPicker?: NumberPickerForAutomationCondition | undefined, emphasis?: boolean | undefined, visibleCondition?: VisibleConditionBase | undefined}>) | undefined, actions?: (Array<{label: string, description?: DescriptionForAutomationItem | undefined, displayType: 'slider' | 'list' | 'dynamicList' | 'numberField' | 'textField' | 'numberPicker' | 'multiArgCommand', slider?: SliderForAutomationAction | undefined, list?: ListForAutomationAction | undefined, dynamicList?: DynamicListForAutomationAction | undefined, textField?: TextFieldForAutomationAction | undefined, numberField?: NumberFieldForAutomationAction | undefined, numberPicker?: NumberPickerForAutomationAction | undefined, multiArgCommand?: MultiArgCommand | undefined, emphasis?: boolean | undefined, visibleCondition?: VisibleConditionBase | undefined}>) | undefined}; export type PresentationSettings = {temperatureConversions?: (Array<{value: Value, unit?: Unit | undefined}>) | undefined}; export type Version = number; export type CreateCapabilityPresentationRequest = {dashboard?: DashboardForCapability | undefined, detailView?: DetailViewForCapability | undefined, automation?: AutomationForCapability | undefined, presentationSettings?: PresentationSettings | undefined, id: string, version: Version}; export type CreateApiCapabilitiesCapabilityIdCapabilityVersionPresentationArgs = {'X-ST-Organization'?: unknown | undefined, body: CreateCapabilityPresentationRequest}; export type CreateApiCapabilitiesCapabilityIdCapabilityVersionPresentationOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; export const version = z.number().int(); export const formattedLabel = z.string(); export const iconUrl = 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 stateItem = z.object({label: formattedLabel, alternatives: alternatives.optional()}); export const argumentType = z.string(); export const pushButton = z.object({command: z.string(), argument: z.string().optional(), argumentType: argumentType.optional()}); export const value = z.string(); export const valueType = z.string(); 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 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 group = z.string(); export const actionItem = 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()}); export const step = z.number(); export const range = z.array(z.number()); export const supportedValuesForNumericConstraints = z.string(); export const unit = z.string(); 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 panelItemForCapability = 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()}); export const dashboardForCapability = z.object({states: z.array(stateItem).optional(), actions: z.array(actionItem).optional(), panelItems: z.array(panelItemForCapability).optional()}); export const toggleSwitch = 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 standbyPowerSwitch = 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 switch = 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 sliderType = z.object({range: range, step: step.optional(), unit: unit.optional(), supportedValues: supportedValuesForNumericConstraints.optional(), alternatives: alternatives.optional(), command: z.string().optional(), argumentType: argumentType.optional(), value: value.optional(), valueType: valueType.optional()}); export const textButton = z.object({command: z.string().optional(), value: value.optional(), buttons: z.array(z.object({key: z.string(), label: z.string(), state: z.string().optional()})), supportedValues: supportedValues.optional()}); export const listForDetailView = 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()}); export const textField = z.object({command: z.string(), argumentType: argumentType.optional(), value: value.optional(), valueType: valueType.optional(), range: range.optional()}); export const numberField = z.object({value: value.optional(), valueType: valueType.optional(), unit: unit.optional(), command: z.string(), argumentType: argumentType.optional(), range: range.optional(), supportedValues: supportedValuesForNumericConstraints.optional()}); export const stepper = 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(), value: value.optional(), valueType: valueType.optional()}); export const state = z.object({label: formattedLabel, unit: unit.optional(), alternatives: alternatives.optional()}); 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 visibleConditionBase = z.object({value: value, valueType: valueType.optional(), operator: operator, operand: z.string()}); export const detailViewForCapability = z.array(z.object({label: z.string(), displayType: z.enum(["toggleSwitch", "standbyPowerSwitch", "switch", "slider", "pushButton", "textButton", "playPause", "playStop", "list", "textField", "numberField", "stepper", "state"]), toggleSwitch: toggleSwitch.optional(), standbyPowerSwitch: standbyPowerSwitch.optional(), switch: switch.optional(), slider: sliderType.optional(), pushButton: pushButton.optional(), textButton: textButton.optional(), playPause: playPause.optional(), playStop: playStop.optional(), list: listForDetailView.optional(), textField: textField.optional(), numberField: numberField.optional(), stepper: stepper.optional(), state: state.optional(), visibleCondition: visibleConditionBase.optional()})); export const descriptionForAutomationItem = z.string(); export const descriptionForAutomatioDisplayType = z.string(); export const sliderForAutomationCondition = z.object({range: range, step: step.optional(), unit: unit.optional(), supportedValues: supportedValuesForNumericConstraints.optional(), alternatives: alternatives.optional(), value: value, valueType: valueType.optional(), description: descriptionForAutomatioDisplayType.optional()}); export const listForAutomationCondition = z.object({alternatives: alternatives, supportedValues: supportedValues.optional(), value: value, valueType: valueType.optional(), description: descriptionForAutomatioDisplayType.optional(), multiSelectable: z.boolean().optional()}); export const supportedValuesForDynamicList = z.object({value: z.string(), valueMap: z.object({key: z.string(), value: z.string()}).optional()}); export const alternativesForDynamicList = z.array(alternativeItem); export const dynamicListForAutomationCondition = z.object({value: value, valueType: z.string().optional(), supportedValues: supportedValuesForDynamicList, alternatives: alternativesForDynamicList.optional(), description: descriptionForAutomatioDisplayType.optional(), multiSelectable: z.boolean().optional()}); export const numberFieldForAutomationCondition = z.object({value: value, valueType: valueType.optional(), unit: unit.optional(), range: range.optional(), alternatives: alternatives.optional(), supportedValues: supportedValuesForNumericConstraints.optional(), description: descriptionForAutomatioDisplayType.optional()}); export const textFieldForAutomationCondition = z.object({value: value, valueType: valueType.optional(), range: range.optional(), description: descriptionForAutomatioDisplayType.optional()}); export const enumSliderForAutomationCondition = z.object({alternatives: alternatives, value: value, supportedOperators: z.array(z.object({operator: z.enum(["EQUALS", "GREATER_THAN_OR_EQUALS", "LESS_THAN_OR_EQUALS"]), label: z.string()})).optional()}); export const unitWithoutPatternForPresentation = z.string(); export const numberPickerForAutomationCondition = z.object({value: value, valueType: valueType.optional(), unit: unitWithoutPatternForPresentation.optional(), range: range.optional(), supportedValues: supportedValuesForNumericConstraints.optional(), description: descriptionForAutomatioDisplayType.optional()}); export const sliderForAutomationAction = z.object({range: range, step: step.optional(), unit: unit.optional(), supportedValues: supportedValuesForNumericConstraints.optional(), alternatives: alternatives.optional(), command: z.string(), argumentType: argumentType.optional(), description: descriptionForAutomatioDisplayType.optional()}); export const listForAutomationAction = z.object({alternatives: alternatives, supportedValues: supportedValues.optional(), command: z.string().optional(), argumentType: argumentType.optional(), description: descriptionForAutomatioDisplayType.optional()}); export const dynamicListForAutomationAction = z.object({command: z.string().optional(), argumentType: z.string().optional(), supportedValues: supportedValuesForDynamicList, alternatives: alternativesForDynamicList.optional(), description: descriptionForAutomatioDisplayType.optional()}); export const textFieldForAutomationAction = z.object({command: z.string(), argumentType: argumentType.optional(), range: range.optional(), description: descriptionForAutomatioDisplayType.optional()}); export const numberFieldForAutomationAction = z.object({command: z.string(), argumentType: argumentType.optional(), unit: unit.optional(), range: range.optional(), alternatives: alternatives.optional(), supportedValues: supportedValuesForNumericConstraints.optional(), description: descriptionForAutomatioDisplayType.optional()}); export const numberPickerForAutomationAction = z.object({command: z.string(), argumentType: argumentType.optional(), unit: unitWithoutPatternForPresentation.optional(), range: range.optional(), supportedValues: supportedValuesForNumericConstraints.optional(), description: descriptionForAutomatioDisplayType.optional()}); export const sliderForArgument = z.object({range: range, step: step.optional(), unit: unit.optional(), supportedValues: supportedValuesForNumericConstraints.optional(), name: argumentName, argumentType: argumentType.optional(), alternatives: alternatives.optional()}); export const listForArgument = z.object({alternatives: alternatives, supportedValues: supportedValues.optional(), name: argumentName, argumentType: argumentType.optional()}); export const textFieldForArgument = z.object({name: argumentName, argumentType: argumentType.optional(), range: range.optional()}); export const numberFieldForArgument = z.object({name: argumentName, unit: unit.optional(), argumentType: argumentType.optional(), range: range.optional(), supportedValues: supportedValuesForNumericConstraints.optional()}); export const multiArgCommand = z.object({command: z.string(), arguments: z.array(z.object({label: z.string(), displayType: z.enum(["slider", "list", "textField", "numberField"]), slider: sliderForArgument.optional(), list: listForArgument.optional(), textField: textFieldForArgument.optional(), numberField: numberFieldForArgument.optional()})), supportedValues: z.string().optional()}); export const automationForCapability = z.object({conditions: z.array(z.object({label: z.string(), description: descriptionForAutomationItem.optional(), displayType: z.enum(["slider", "list", "dynamicList", "numberField", "textField", "enumSlider", "numberPicker"]), slider: sliderForAutomationCondition.optional(), list: listForAutomationCondition.optional(), dynamicList: dynamicListForAutomationCondition.optional(), numberField: numberFieldForAutomationCondition.optional(), textField: textFieldForAutomationCondition.optional(), enumSlider: enumSliderForAutomationCondition.optional(), numberPicker: numberPickerForAutomationCondition.optional(), emphasis: z.boolean().optional(), visibleCondition: visibleConditionBase.optional()})).optional(), actions: z.array(z.object({label: z.string(), description: descriptionForAutomationItem.optional(), displayType: z.enum(["slider", "list", "dynamicList", "numberField", "textField", "numberPicker", "multiArgCommand"]), slider: sliderForAutomationAction.optional(), list: listForAutomationAction.optional(), dynamicList: dynamicListForAutomationAction.optional(), textField: textFieldForAutomationAction.optional(), numberField: numberFieldForAutomationAction.optional(), numberPicker: numberPickerForAutomationAction.optional(), multiArgCommand: multiArgCommand.optional(), emphasis: z.boolean().optional(), visibleCondition: visibleConditionBase.optional()})).optional()}); export const presentationSettings = z.object({temperatureConversions: z.array(z.object({value: value, unit: unit.optional()})).optional()}); export const capabilityPresentation = z.object({id: z.string(), version: version, dashboard: dashboardForCapability.optional(), detailView: detailViewForCapability.optional(), automation: automationForCapability.optional(), presentationSettings: presentationSettings.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 Capability Presentation * * POST /capabilities/{capabilityId}/{capabilityVersion}/presentation */ export const createApiCapabilitiesCapabilityIdCapabilityVersionPresentation = async (args: CreateApiCapabilitiesCapabilityIdCapabilityVersionPresentationArgs, options?: CreateApiCapabilitiesCapabilityIdCapabilityVersionPresentationOptions) => { 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 (args['X-ST-Organization'] != null) headers.set("X-ST-Organization", String(args['X-ST-Organization'])) if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/capabilities/${encodeURIComponent(String(args.capabilityId))}/${encodeURIComponent(String(args.capabilityVersion))}/presentation${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(capabilityPresentation, await res.json()) };