node-red-contrib-home-assistant-websocket
Version:
Node-RED integration with Home Assistant through websocket and REST API
2 lines (1 loc) • 1.99 kB
JavaScript
"use strict";var c=Object.create;var d=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var m=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var D=(t,e)=>{for(var r in e)d(t,r,{get:e[r],enumerable:!0})},l=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of h(e))!y.call(t,i)&&i!==r&&d(t,i,{get:()=>e[i],enumerable:!(a=g(e,i))||a.enumerable});return t};var p=(t,e,r)=>(r=t!=null?c(m(t)):{},l(e||!t||!t.__esModule?d(r,"default",{value:t,enumerable:!0}):r,t)),f=t=>l(d({},"__esModule",{value:!0}),t);var O={};D(O,{createCalendarItem:()=>I,default:()=>u});module.exports=f(O);var o=p(require("crypto")),s=require("./const"),n=require("./helpers");class u{#t;#r;#n;#s;#a;#e;#i;#d;constructor(e){this.#t=e.start,this.#r=e.end,this.#n=e.summary??"",this.#s=e.description??void 0,this.#a=e.location??void 0,this.#e=e.uid??void 0,this.#i=e.recurrence_id??void 0,this.#d=e.rrule??void 0}get start(){return this.#t}get end(){return this.#r}get summary(){return this.#n}get description(){return this.#s}get location(){return this.#a}get uid(){return this.#e}get recurrence_id(){return this.#i}get rrule(){return this.#d}get isAllDayEvent(){return(0,n.isWithDate)(this.#t)&&(0,n.isWithDate)(this.#r)}get uniqueId(){if(this.#e)return`${this.#e}${this.#i??""}`;const e=this.date(s.CalendarEventType.Start).toISOString(),r=this.date(s.CalendarEventType.End).toISOString(),a=this.#n,i=`${e}|${r}|${a}`;return o.default.createHash("sha256").update(i).digest("hex").slice(0,16)}date(e){const r=e===s.CalendarEventType.Start?this.#t:this.#r;return(0,n.parseCalendarDate)(r)}convertToObject(){return{start:(0,n.toLocalISOWithOffset)(this.date(s.CalendarEventType.Start)),end:(0,n.toLocalISOWithOffset)(this.date(s.CalendarEventType.End)),summary:this.#n,description:this.#s,location:this.#a,uid:this.#e,recurrence_id:this.#i,rrule:this.#d,all_day:this.isAllDayEvent}}}function I(t){return new u(t)}0&&(module.exports={createCalendarItem});