node-red-contrib-padavan 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- class z{#j;#h;#b;#k;constructor(b,j,h){this.#h=b,this.#b=j,this.#j=h;let q=h.nodes.getNode(j.settings);if(q)this.#k=q.instance;else this.#h.warn("Config node not found or configured.");this.#h.on("input",this.#q.bind(this))}get client(){if(!this.#k)throw Error("Client is not initialized. Check configuration.");return this.#k.client}async#q(b,j,h){let q=this.#j.util.evaluateNodeProperty(this.#b.topic,this.#b.topicType,this.#h,b),w=this.#j.util.evaluateNodeProperty(this.#b.payload,this.#b.payloadType,this.#h,b),B=this.#j.util.evaluateNodeProperty(this.#b.action,this.#b.actionType,this.#h,b),F=this.#j.util.evaluateNodeProperty(this.#b.script,this.#b.scriptType,this.#h,b),G=this.#j.util.evaluateNodeProperty(this.#b.sid,this.#b.sidType,this.#h,b),H=this.#j.util.evaluateNodeProperty(this.#b.group,this.#b.groupType,this.#h,b),x=this.#j.util.evaluateNodeProperty(this.#b.page,this.#b.pageType,this.#h,b);try{this.#h.status({fill:"blue",shape:"dot",text:"Processing..."});let k;switch(q){case"list":{k=await this.client.getParams();break}case"get":{k=await this.client.getParams(w,x);break}case"set":{if(!w||typeof w!=="object")throw Error("Input payload missing or not an object");await this.client.setParams(w,{action_mode:B,action_script:F,sid_list:G,group_id:H,current_page:x}),k=w;break}default:throw Error(`Invalid topic: "${q}". Must be 'list', 'get', or 'set'.`)}if(k)b.payload=k,j(b);this.#h.status({}),h()}catch(k){this.#h.status({fill:"red",shape:"ring",text:"Error"}),h(k)}}}function J(b){b.nodes.registerType("padavan-params",function(j){b.nodes.createNode(this,j);let h=this;h.instance=new z(h,j,b)})}export{J as default,z as ParamsNode};
1
+ class z{#j;#h;#b;#k;constructor(b,j,h){this.#h=b,this.#b=j,this.#j=h;let q=h.nodes.getNode(j.settings);if(q)this.#k=q.instance;else this.#h.warn("Config node not found or configured.");this.#h.on("input",this.#q.bind(this))}get client(){if(!this.#k)throw Error("Client is not initialized. Check configuration.");return this.#k.client}async#q(b,j,h){let q=this.#j.util.evaluateNodeProperty(this.#b.topic,this.#b.topicType,this.#h,b),w=this.#j.util.evaluateNodeProperty(this.#b.payload,this.#b.payloadType,this.#h,b),B=this.#j.util.evaluateNodeProperty(this.#b.action,this.#b.actionType,this.#h,b),F=this.#j.util.evaluateNodeProperty(this.#b.script,this.#b.scriptType,this.#h,b),G=this.#j.util.evaluateNodeProperty(this.#b.sid,this.#b.sidType,this.#h,b),H=this.#j.util.evaluateNodeProperty(this.#b.group,this.#b.groupType,this.#h,b),x=this.#j.util.evaluateNodeProperty(this.#b.page,this.#b.pageType,this.#h,b);try{this.#h.status({fill:"blue",shape:"dot",text:"Processing..."});let k;switch(q){case"list":{k=await this.client.getParams();break}case"get":{k=await this.client.getParams(w,x);break}case"set":{if(!w||typeof w!=="object")throw Error("Input payload missing or not an object");await this.client.setParams(w,{action_mode:B,action_script:F,sid_list:G,group_id:H,current_page:x}),k=w;break}default:throw Error(`Invalid topic: "${q}". Must be 'list', 'get', or 'set'.`)}if(k){if(!b.topic)b.topic=q;b.payload=k,j(b)}this.#h.status({}),h()}catch(k){this.#h.status({fill:"red",shape:"ring",text:"Error"}),h(k)}}}function J(b){b.nodes.registerType("padavan-params",function(j){b.nodes.createNode(this,j);let h=this;h.instance=new z(h,j,b)})}export{J as default,z as ParamsNode};
@@ -1 +1 @@
1
- class z{#k;#h;#j;#q;constructor(h,q,k){this.#h=h,this.#j=q,this.#k=k;let w=k.nodes.getNode(q.settings);if(w)this.#q=w.instance;else this.#h.warn("Config node not found or configured.");this.#h.on("input",this.#w.bind(this))}get client(){if(!this.#q)throw Error("Client is not initialized. Check configuration.");return this.#q.client}async#w(h,q,k){let w=this.#k.util.evaluateNodeProperty(this.#j.topic,this.#j.topicType,this.#h,h),x=this.#k.util.evaluateNodeProperty(this.#j.band,this.#j.bandType,this.#h,h)||"2.4";try{this.#h.status({fill:"blue",shape:"dot",text:`Running ${w}...`});let j;switch(w){case"status":{j=await this.client.getStatus();break}case"log":{j=await this.client.getLog();break}case"reboot":{j=await this.client.startReboot();break}case"scan":{j=await this.client.startScan(x);break}case"doctor":{j=await this.client.getBestChannel(x);break}default:throw Error(`Invalid topic: "${w}".`)}if(j!==void 0)h.payload=j,q(h);this.#h.status({}),k()}catch(j){this.#h.status({fill:"red",shape:"ring",text:"Error"}),k(j)}}}function B(h){h.nodes.registerType("padavan-system",function(q){h.nodes.createNode(this,q);let k=this;k.instance=new z(k,q,h)})}export{B as default,z as SystemNode};
1
+ class z{#k;#h;#j;#q;constructor(h,q,k){this.#h=h,this.#j=q,this.#k=k;let w=k.nodes.getNode(q.settings);if(w)this.#q=w.instance;else this.#h.warn("Config node not found or configured.");this.#h.on("input",this.#w.bind(this))}get client(){if(!this.#q)throw Error("Client is not initialized. Check configuration.");return this.#q.client}async#w(h,q,k){let w=this.#k.util.evaluateNodeProperty(this.#j.topic,this.#j.topicType,this.#h,h),x=this.#k.util.evaluateNodeProperty(this.#j.band,this.#j.bandType,this.#h,h)||"2.4";try{this.#h.status({fill:"blue",shape:"dot",text:`Running ${w}...`});let j;switch(w){case"status":{j=await this.client.getStatus();break}case"log":{j=await this.client.getLog();break}case"reboot":{j=await this.client.startReboot();break}case"scan":{j=await this.client.startScan(x);break}case"doctor":{j=await this.client.getBestChannel(x);break}default:throw Error(`Invalid topic: "${w}".`)}if(j!==void 0){if(!h.topic)h.topic=w;h.payload=j,q(h)}this.#h.status({}),k()}catch(j){this.#h.status({fill:"red",shape:"ring",text:"Error"}),k(j)}}}function B(h){h.nodes.registerType("padavan-system",function(q){h.nodes.createNode(this,q);let k=this;k.instance=new z(k,q,h)})}export{B as default,z as SystemNode};
@@ -1 +1 @@
1
- class w{#k;#b;#h;#j;constructor(h,k,j){this.#b=h,this.#h=k,this.#k=j;let q=j.nodes.getNode(k.settings);if(q)this.#j=q.instance;else this.#b.warn("Config node not found or configured.");this.#b.on("input",this.#q.bind(this))}get client(){if(!this.#j)throw Error("Client is not initialized. Check configuration.");return this.#j.client}async#q(h,k,j){let q=this.#k.util.evaluateNodeProperty(this.#h.topic,this.#h.topicType,this.#b,h);try{this.#b.status({fill:"blue",shape:"dot",text:"Processing..."});let b;switch(q){case"changelog":{if(this.#b.status({fill:"blue",shape:"dot",text:"Checking updates..."}),b=await this.client.getChangelog(),b.messages&&b.messages.length>0)this.#b.status({fill:"green",shape:"dot",text:`New updates: ${b.messages.length}`});else this.#b.status({fill:"green",shape:"ring",text:"Up to date"});break}case"build":{this.#b.status({fill:"blue",shape:"dot",text:"Triggering build..."}),await this.client.startBuild(),b={status:"success",message:"Build triggered"},this.#b.status({fill:"green",shape:"dot",text:"Build started"}),setTimeout(()=>this.#b.status({}),5000);break}case"upgrade":{this.#b.status({fill:"blue",shape:"dot",text:"Downloading & Flashing..."}),await this.client.startUpgrade(),b={status:"success",message:"Firmware uploaded, router is rebooting"},this.#b.status({fill:"green",shape:"dot",text:"Rebooting..."}),setTimeout(()=>this.#b.status({}),1e4);break}default:throw Error(`Invalid topic: "${q}". Must be 'changelog', 'build', or 'upgrade'.`)}if(b)h.payload=b,k(h);j()}catch(b){this.#b.status({fill:"red",shape:"ring",text:"Error"}),j(b)}}}function x(h){h.nodes.registerType("padavan-upgrade",function(k){h.nodes.createNode(this,k);let j=this;j.instance=new w(j,k,h)})}export{x as default,w as UpgradeNode};
1
+ class w{#k;#b;#h;#j;constructor(b,k,j){this.#b=b,this.#h=k,this.#k=j;let q=j.nodes.getNode(k.settings);if(q)this.#j=q.instance;else this.#b.warn("Config node not found or configured.");this.#b.on("input",this.#q.bind(this))}get client(){if(!this.#j)throw Error("Client is not initialized. Check configuration.");return this.#j.client}async#q(b,k,j){let q=this.#k.util.evaluateNodeProperty(this.#h.topic,this.#h.topicType,this.#b,b);try{this.#b.status({fill:"blue",shape:"dot",text:"Processing..."});let h;switch(q){case"changelog":{if(this.#b.status({fill:"blue",shape:"dot",text:"Checking updates..."}),h=await this.client.getChangelog(),h.messages&&h.messages.length>0)this.#b.status({fill:"green",shape:"dot",text:`New updates: ${h.messages.length}`});else this.#b.status({fill:"green",shape:"ring",text:"Up to date"});break}case"build":{this.#b.status({fill:"blue",shape:"dot",text:"Triggering build..."}),await this.client.startBuild(),h={status:"success",message:"Build triggered"},this.#b.status({fill:"green",shape:"dot",text:"Build started"}),setTimeout(()=>this.#b.status({}),5000);break}case"upgrade":{this.#b.status({fill:"blue",shape:"dot",text:"Downloading & Flashing..."}),await this.client.startUpgrade(),h={status:"success",message:"Firmware uploaded, router is rebooting"},this.#b.status({fill:"green",shape:"dot",text:"Rebooting..."}),setTimeout(()=>this.#b.status({}),1e4);break}default:throw Error(`Invalid topic: "${q}". Must be 'changelog', 'build', or 'upgrade'.`)}if(h){if(!b.topic)b.topic=q;b.payload=h,k(b)}j()}catch(h){this.#b.status({fill:"red",shape:"ring",text:"Error"}),j(h)}}}function x(b){b.nodes.registerType("padavan-upgrade",function(k){b.nodes.createNode(this,k);let j=this;j.instance=new w(j,k,b)})}export{x as default,w as UpgradeNode};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-padavan",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Node-RED nodes for managing routers with Padavan firmware.",
@@ -27,7 +27,7 @@
27
27
  }
28
28
  },
29
29
  "dependencies": {
30
- "padavan": "2.0.0"
30
+ "padavan": "2.0.2"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/bun": "^1.2.17",