export type SwitchOptions = 'on' | 'off'; export type Toggle = {status: SwitchOptions}; export type Switch = {status: SwitchOptions}; export type RollerDirection = 'up' | 'down'; export type Roller = {status: SwitchOptions, direction: RollerDirection}; export type CleanerMode = 'dock' | 'clean'; export type FanStrengthOptions = 'low' | 'med' | 'high' | 'auto'; export type Cleaner = {status: SwitchOptions, mode: CleanerMode, fanSpeed: FanStrengthOptions}; export type ACModeOptions = 'hot' | 'cold' | 'dry' | 'auto'; export type AirConditioning = {status: SwitchOptions, temperature: number, mode: ACModeOptions, fanStrength: FanStrengthOptions}; export type Light = {status: SwitchOptions, brightness: number}; export type TemperatureLight = {status: SwitchOptions, brightness: number, temperature: number}; export type ColorLight = {status: SwitchOptions, brightness: number, temperature: number, red: number, green: number, blue: number}; export type TemperatureSensor = {status: SwitchOptions, temperature: number}; export type MinionStatus = {toggle?: Toggle | undefined, switch?: Switch | undefined, roller?: Roller | undefined, cleaner?: Cleaner | undefined, airConditioning?: AirConditioning | undefined, light?: Light | undefined, temperatureLight?: TemperatureLight | undefined, colorLight?: ColorLight | undefined, temperatureSensor?: TemperatureSensor | undefined}; export type OperationActivity = {minionId: string, minionStatus: MinionStatus}; export type Operation = {operationId: string, operationName: string, activities: Array}; export type UpdateApiOperationsOperationIdArgs = {operationId: string, body: Operation}; export type UpdateApiOperationsOperationIdOptions = {baseUrl: string, adminAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update operation properties. * * PUT /operations/{operationId} */ export const updateApiOperationsOperationId = async (args: UpdateApiOperationsOperationIdArgs, options: UpdateApiOperationsOperationIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, adminAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (adminAuth !== undefined) headers.set("authentication", adminAuth) const url = `${baseUrl.replace(/\/+$/, '')}/operations/${encodeURIComponent(String(args.operationId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 undefined };