@ikalogic/at1000 0.2.2 → 0.3.0
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.
- package/README.md +21 -0
- package/build/at1000-3evjqv7V.d.mts +69 -0
- package/build/at1000-3evjqv7V.d.mts.map +1 -0
- package/build/at1000-BAZbVgLx.cjs +3 -0
- package/build/at1000-BAZbVgLx.cjs.map +1 -0
- package/build/at1000-Cxx254i3.mjs +3 -0
- package/build/at1000-Cxx254i3.mjs.map +1 -0
- package/build/at1000-D_y0MxFy.d.cts +69 -0
- package/build/at1000-D_y0MxFy.d.cts.map +1 -0
- package/build/browser.cjs +1 -1
- package/build/browser.cjs.map +1 -1
- package/build/browser.d.cts +2 -2
- package/build/browser.d.cts.map +1 -1
- package/build/browser.d.mts +2 -2
- package/build/browser.d.mts.map +1 -1
- package/build/browser.mjs +1 -1
- package/build/browser.mjs.map +1 -1
- package/build/{com-CBhjFJPB.d.cts → com-BzaKOH_B.d.cts} +8 -8
- package/build/{com-CBhjFJPB.d.cts.map → com-BzaKOH_B.d.cts.map} +1 -1
- package/build/{com-CBhjFJPB.d.mts → com-BzaKOH_B.d.mts} +8 -8
- package/build/{com-CBhjFJPB.d.mts.map → com-BzaKOH_B.d.mts.map} +1 -1
- package/build/com.cjs +1 -1
- package/build/com.cjs.map +1 -1
- package/build/com.d.cts +2 -2
- package/build/com.d.mts +2 -2
- package/build/com.mjs +1 -1
- package/build/com.mjs.map +1 -1
- package/build/events-PyyK1XbE.d.cts +351 -0
- package/build/events-PyyK1XbE.d.cts.map +1 -0
- package/build/events-PyyK1XbE.d.mts +351 -0
- package/build/events-PyyK1XbE.d.mts.map +1 -0
- package/build/events.cjs +1 -0
- package/build/events.d.cts +2 -0
- package/build/events.d.mts +2 -0
- package/build/events.mjs +1 -0
- package/build/{gpio-DNrdX-QV.d.cts → gpio-CHg2nztz.d.cts} +17 -11
- package/build/gpio-CHg2nztz.d.cts.map +1 -0
- package/build/{gpio-DchxrXWK.d.mts → gpio-CbGcoT9b.d.mts} +17 -11
- package/build/gpio-CbGcoT9b.d.mts.map +1 -0
- package/build/gpio.cjs +1 -1
- package/build/gpio.cjs.map +1 -1
- package/build/gpio.d.cts +2 -2
- package/build/gpio.d.mts +2 -2
- package/build/gpio.mjs +1 -1
- package/build/gpio.mjs.map +1 -1
- package/build/{hmi-DszM-Hfp.d.cts → hmi-B6LU4yaL.d.cts} +10 -2
- package/build/hmi-B6LU4yaL.d.cts.map +1 -0
- package/build/{hmi-DszM-Hfp.d.mts → hmi-B6LU4yaL.d.mts} +10 -2
- package/build/hmi-B6LU4yaL.d.mts.map +1 -0
- package/build/hmi.cjs +1 -1
- package/build/hmi.cjs.map +1 -1
- package/build/hmi.d.cts +2 -2
- package/build/hmi.d.mts +2 -2
- package/build/hmi.mjs +1 -1
- package/build/hmi.mjs.map +1 -1
- package/build/{management-C0iQha23.d.cts → management-DliNzoq1.d.cts} +243 -12
- package/build/management-DliNzoq1.d.cts.map +1 -0
- package/build/{management-C0iQha23.d.mts → management-DliNzoq1.d.mts} +243 -12
- package/build/management-DliNzoq1.d.mts.map +1 -0
- package/build/management.cjs +1 -1
- package/build/management.cjs.map +1 -1
- package/build/management.d.cts +2 -2
- package/build/management.d.mts +2 -2
- package/build/management.mjs +1 -1
- package/build/management.mjs.map +1 -1
- package/build/node.cjs +1 -1
- package/build/node.cjs.map +1 -1
- package/build/node.d.cts +2 -2
- package/build/node.d.cts.map +1 -1
- package/build/node.d.mts +2 -2
- package/build/node.d.mts.map +1 -1
- package/build/node.mjs +1 -1
- package/build/node.mjs.map +1 -1
- package/build/package-BGnFmux8.mjs +2 -0
- package/build/package-BGnFmux8.mjs.map +1 -0
- package/build/package-Dd7S_M7n.cjs +2 -0
- package/build/package-Dd7S_M7n.cjs.map +1 -0
- package/build/{power-CN_9o_NX.d.mts → power-DUs5Sw8n.d.mts} +16 -16
- package/build/{power-CN_9o_NX.d.mts.map → power-DUs5Sw8n.d.mts.map} +1 -1
- package/build/{power-o75Gjpwf.d.cts → power-zT64Y-Q9.d.cts} +16 -16
- package/build/{power-o75Gjpwf.d.cts.map → power-zT64Y-Q9.d.cts.map} +1 -1
- package/build/power.cjs +1 -1
- package/build/power.cjs.map +1 -1
- package/build/power.d.cts +2 -2
- package/build/power.d.mts +2 -2
- package/build/power.mjs +1 -1
- package/build/power.mjs.map +1 -1
- package/build/{relays-BCn6rQN1.d.cts → relays-8EGNIK1T.d.cts} +5 -2
- package/build/relays-8EGNIK1T.d.cts.map +1 -0
- package/build/{relays-BCn6rQN1.d.mts → relays-8EGNIK1T.d.mts} +5 -2
- package/build/relays-8EGNIK1T.d.mts.map +1 -0
- package/build/relays.cjs +1 -1
- package/build/relays.cjs.map +1 -1
- package/build/relays.d.cts +2 -2
- package/build/relays.d.mts +2 -2
- package/build/relays.mjs +1 -1
- package/build/relays.mjs.map +1 -1
- package/package.json +11 -1
- package/build/at1000-BXtrf8Rt.d.cts +0 -50
- package/build/at1000-BXtrf8Rt.d.cts.map +0 -1
- package/build/at1000-BuI_g7jF.cjs +0 -3
- package/build/at1000-BuI_g7jF.cjs.map +0 -1
- package/build/at1000-DVDltAyk.mjs +0 -3
- package/build/at1000-DVDltAyk.mjs.map +0 -1
- package/build/at1000-D_rOUVFH.d.mts +0 -50
- package/build/at1000-D_rOUVFH.d.mts.map +0 -1
- package/build/gpio-DNrdX-QV.d.cts.map +0 -1
- package/build/gpio-DchxrXWK.d.mts.map +0 -1
- package/build/hmi-DszM-Hfp.d.cts.map +0 -1
- package/build/hmi-DszM-Hfp.d.mts.map +0 -1
- package/build/management-C0iQha23.d.cts.map +0 -1
- package/build/management-C0iQha23.d.mts.map +0 -1
- package/build/relays-BCn6rQN1.d.cts.map +0 -1
- package/build/relays-BCn6rQN1.d.mts.map +0 -1
package/build/management.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./chunk-CMqjfN_6.cjs");require("up-fetch");let t=require("valibot");t=e.t(t,1);let n=function(e){return e.Can=`can`,e.Rs232=`rs232`,e.Rs485=`rs485`,e.I2c=`i2c`,e.Spi=`spi`,e.Uart=`uart`,e}({});const r=t.enum(n),i=t.object({min:t.pipe(t.number(),t.minValue(-24),t.maxValue(24)),max:t.pipe(t.number(),t.minValue(-24),t.maxValue(24))}),a=t.object({max:t.number()}),o=t.object({count:t.pipe(t.number(),t.minValue(1)),input_voltage:i,output_voltage:i}),s=t.object({count:t.pipe(t.number(),t.minValue(0)),max_current:t.number(),max_voltage:t.number(),on_resistance:t.pipe(t.number(),t.minValue(0))}),c=t.object({type:t.picklist([`3.0`,`2.0`]),count:t.pipe(t.number(),t.minValue(1))}),l=t.object({type:t.picklist([`1000BASE-T`,`100BASE-T`,`10BASE-T`]),count:t.pipe(t.number(),t.minValue(1))}),u=t.object({type:r,count:t.pipe(t.number(),t.minValue(1))}),d=t.object({count:t.pipe(t.number(),t.minValue(1)),output_voltage:i,current:a}),f=t.object({type:t.picklist([`low_precision`,`high_precision`]),source:t.string(),resolution:t.pipe(t.number(),t.minValue(0))}),p=t.object({width:t.pipe(t.number(),t.minValue(1)),height:t.pipe(t.number(),t.minValue(1))}),m=t.object({type:t.string(),size:p}),h=t.object({count:t.pipe(t.number(),t.minValue(0)),type:t.string()}),g=t.object({count:t.pipe(t.number(),t.minValue(0)),type:t.string()}),_=t.object({display:m,input:h,speaker:g}),v=t.object({io:o,relays:s,usb_ports:t.array(c),ethernet:t.array(l),communication:t.array(u),power_supply:d,current_measurement:t.array(f),hmi:_}),y=t.object({model:t.string(),hostname:t.string(),serial_number:t.string(),firmware_version:t.string(),firmware_commit:t.string(),hardware_version:t.optional(t.number()),disk_used:t.number(),disk_total:t.number(),docker_used:t.number(),capabilities:v}),b=t.object({name:t.string(),path:t.string(),
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./chunk-CMqjfN_6.cjs");require("up-fetch");let t=require("valibot");t=e.t(t,1);let n=function(e){return e.Can=`can`,e.Rs232=`rs232`,e.Rs485=`rs485`,e.I2c=`i2c`,e.Spi=`spi`,e.Uart=`uart`,e}({});const r=t.enum(n),i=t.object({min:t.pipe(t.number(),t.minValue(-24),t.maxValue(24)),max:t.pipe(t.number(),t.minValue(-24),t.maxValue(24))}),a=t.object({max:t.number()}),o=t.object({count:t.pipe(t.number(),t.minValue(1)),input_voltage:i,output_voltage:i}),s=t.object({count:t.pipe(t.number(),t.minValue(0)),max_current:t.number(),max_voltage:t.number(),on_resistance:t.pipe(t.number(),t.minValue(0))}),c=t.object({type:t.picklist([`3.0`,`2.0`]),count:t.pipe(t.number(),t.minValue(1))}),l=t.object({type:t.picklist([`1000BASE-T`,`100BASE-T`,`10BASE-T`]),count:t.pipe(t.number(),t.minValue(1))}),u=t.object({type:r,count:t.pipe(t.number(),t.minValue(1))}),d=t.object({count:t.pipe(t.number(),t.minValue(1)),output_voltage:i,current:a}),f=t.object({type:t.picklist([`low_precision`,`high_precision`]),source:t.string(),resolution:t.pipe(t.number(),t.minValue(0))}),p=t.object({width:t.pipe(t.number(),t.minValue(1)),height:t.pipe(t.number(),t.minValue(1))}),m=t.object({type:t.string(),size:p}),h=t.object({count:t.pipe(t.number(),t.minValue(0)),type:t.string()}),g=t.object({count:t.pipe(t.number(),t.minValue(0)),type:t.string()}),_=t.object({display:m,input:h,speaker:g}),v=t.object({io:o,relays:s,usb_ports:t.array(c),ethernet:t.array(l),communication:t.array(u),power_supply:d,current_measurement:t.array(f),hmi:_}),y=t.object({model:t.string(),hostname:t.string(),serial_number:t.string(),firmware_version:t.string(),firmware_commit:t.string(),hardware_version:t.optional(t.number()),disk_used:t.number(),disk_total:t.number(),docker_used:t.number(),capabilities:v}),b=t.picklist([`idle`,`running`,`error`]),x=t.picklist([`created`,`started`,`stopped`,`removed`,`error`]),S=t.picklist([`tcp`,`udp`]),C=t.pipe(t.number(),t.integer(),t.minValue(1),t.maxValue(65535)),w=t.object({host:C,container:C,proto:S}),T=t.pipe(t.string(),t.trim(),t.regex(/^(ssh-|ecdsa-sha2-|sk-ssh-|sk-ecdsa-)/,`Not a recognized SSH public key`)),E=t.picklist([`normal`,`development`]),D=t.object({name:t.string(),path:t.string(),id:t.string(),image:t.string(),is_default:t.boolean(),ports:t.optional(t.array(w),[]),state:b,mode:t.optional(E)}),O=t.variant(`change`,[t.object({change:t.literal(`state_changed`),id:t.string(),state:x}),t.object({change:t.literal(`renamed`),id:t.string(),name:t.string()}),t.object({change:t.literal(`default_changed`),id:t.string(),is_default:t.boolean()})]),k=t.partial(t.pick(D,[`name`,`is_default`]));t.object({name:t.string(),image:t.string()});const A=t.object({bundle:t.string(),version:t.string(),compatible:t.string(),description:t.string()}),j=t.object({message:t.string(),bundle:t.string()}),M=t.object({state:t.picklist([`idle`,`installing`,`failed`]),progress:t.number(),message:t.string(),error:t.string()}),N=t.object({message:t.string()}),P=t.pipe(t.number(),t.finite()),F=t.pipe(t.number(),t.finite(),t.minValue(Number.MIN_VALUE)),I=t.pipe(t.number(),t.integer(),t.minValue(0),t.maxValue(31)),L=t.pipe(t.number(),t.integer(),t.minValue(0),t.maxValue(7)),R=t.pipe(t.number(),t.integer(),t.minValue(0),t.maxValue(1)),z=t.picklist([`pass`,`fail`]),B=t.object({set:P,measured:P,reading:t.optional(P)}),V=t.object({channel:I,points:t.array(B),max_error:P,avg_error:P}),H=t.object({voltage:t.object({points:t.array(B),max_error:P,avg_error:P}),current:t.object({load_ohms:F,points:t.array(B),max_error:P,avg_error:P})}),U=t.object({load_ohms:F,voltage_applied:P,measured_current:P,expected_current:P,error_percent:P}),W=t.object({relay:L,status:z,test_voltage:P,closed_current:P,open_current:P,calibration:t.optional(V)}),G=t.object({port:R,status:z,voltage:P,current_tests:t.optional(t.array(U))}),K=t.object({schema_version:t.literal(1),tool_version:t.string(),device_id:t.string(),timestamp:t.string(),firmware_version:t.string(),dac:t.array(V),adc_positive:t.array(V),adc_negative:t.optional(t.array(V)),dut_psu:H,relays:t.array(W),usb:t.array(G)}),q=t.object({enabled:t.boolean(),loaded:t.boolean(),last_error:t.optional(t.nullable(t.string())),calibrated_at:t.optional(t.nullable(t.string()))}),J=t.object({enabled:t.boolean()});var Y=class{fetch;constructor(e){this.fetch=e}info(){return this.fetch(`/management/info`,{schema:y})}get_calibration(){return this.fetch(`/management/calibration`,{schema:K})}set_calibration(e){return this.fetch(`/management/calibration`,{method:`PUT`,body:t.parse(K,e),schema:K})}get_calibration_state(){return this.fetch(`/management/calibration/state`,{schema:q})}set_calibration_enabled(e){return this.fetch(`/management/calibration/state`,{method:`PATCH`,body:t.parse(J,{enabled:e}),schema:q})}enable_calibration(){return this.set_calibration_enabled(!0)}disable_calibration(){return this.set_calibration_enabled(!1)}async datetime(){let e=await this.fetch(`/management/datetime`,{schema:t.object({epoch_seconds:t.number()})});return new Date(e.epoch_seconds*1e3)}setDatetime(e){return this.fetch(`/management/datetime`,{method:`POST`,body:{epoch_seconds:Math.floor(e.getTime()/1e3)},parseResponse:()=>{}})}getProjects(){return this.fetch(`/management/projects`,{schema:t.array(D)})}getProject(e){return this.fetch(`/management/projects/${e}`,{schema:D})}createProject(e){return this.fetch(`/management/projects`,{method:`POST`,body:e,timeout:3e4,schema:D})}importProject(e,t){return this.fetch(`/management/projects/import`,{method:`POST`,body:e,headers:{"Content-Type":`application/x-tar`,"X-Project-Name":encodeURIComponent(t)},serializeBody:e=>e,timeout:6e5,schema:D})}updateProject(e,n){return this.fetch(`/management/projects/${e}`,{method:`PATCH`,body:t.parse(k,n),schema:D})}runProject(e,t=`normal`){return this.fetch(`/management/projects/${e}/run`,{method:`POST`,body:{mode:t},timeout:3e4})}stopProject(e){return this.fetch(`/management/projects/${e}/stop`,{method:`POST`,timeout:3e4})}getProjectPorts(e){return this.fetch(`/management/projects/${e}/ports`,{schema:t.array(w)})}setProjectPorts(e,n){return this.fetch(`/management/projects/${e}/ports`,{method:`PUT`,body:t.parse(t.array(w),n),timeout:3e4,schema:t.array(w)})}addProjectPort(e,n){return this.fetch(`/management/projects/${e}/ports`,{method:`POST`,body:t.parse(w,n),timeout:3e4,schema:t.array(w)})}deleteProjectPort(e,t){return this.fetch(`/management/projects/${e}/ports/${t}`,{method:`DELETE`,parseResponse:()=>{},timeout:3e4})}setProjectPassword(e,n){return this.fetch(`/management/projects/${e}/password`,{method:`POST`,body:t.parse(t.object({password:t.pipe(t.string(),t.minLength(1))}),{password:n}),parseResponse:()=>{},timeout:3e4})}getProjectAuthorizedKeys(e){return this.fetch(`/management/projects/${e}/authorized_keys`,{schema:t.array(t.string())})}setProjectAuthorizedKeys(e,n){return this.fetch(`/management/projects/${e}/authorized_keys`,{method:`PUT`,body:t.parse(t.array(T),n),timeout:3e4,schema:t.array(t.string())})}deleteProject(e){return this.fetch(`/management/projects/${e}`,{method:`DELETE`,timeout:3e4})}upload_bundle(e,t=`bundle.raucb`){return this.fetch(`/management/update/upload`,{method:`POST`,body:e,headers:{"Content-Type":`application/octet-stream`,"X-Bundle-Filename":t},serializeBody:e=>e,timeout:6e5,schema:A})}bundle_info(){return this.fetch(`/management/update/bundle-info`,{schema:A})}install_update(){return this.fetch(`/management/update/install`,{method:`POST`,schema:j})}update_status(){return this.fetch(`/management/update/status`,{schema:M})}reboot(){return this.fetch(`/management/reboot`,{method:`POST`,schema:N})}};exports.CommunicationInterfaceType=n,exports.ManagementApi=Y,exports.calibrationData=K,exports.calibrationState=q,exports.portMapping=w,exports.project=D,exports.projectEvent=O,exports.runMode=E,exports.updateStatus=M;
|
|
2
2
|
//# sourceMappingURL=management.cjs.map
|
package/build/management.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"management.cjs","names":["v"],"sources":["../src/api/management.ts"],"sourcesContent":["import { type UpFetch } from 'up-fetch';\nimport * as v from 'valibot';\n\nexport enum CommunicationInterfaceType {\n Can = 'can',\n Rs232 = 'rs232',\n Rs485 = 'rs485',\n I2c = 'i2c',\n Spi = 'spi',\n Uart = 'uart',\n}\nconst communicationInterface = v.enum(CommunicationInterfaceType);\n\nconst voltageRange = v.object({\n min: v.pipe(v.number(), v.minValue(-24), v.maxValue(24)),\n max: v.pipe(v.number(), v.minValue(-24), v.maxValue(24)),\n});\n\nconst currentRange = v.object({ max: v.number() });\n\nconst ioCapabilities = v.object({\n count: v.pipe(v.number(), v.minValue(1)),\n input_voltage: voltageRange,\n output_voltage: voltageRange,\n});\n\nconst relaysCapabilities = v.object({\n count: v.pipe(v.number(), v.minValue(0)),\n max_current: v.number(),\n max_voltage: v.number(),\n on_resistance: v.pipe(v.number(), v.minValue(0)),\n});\n\nconst usbCapability = v.object({\n type: v.picklist(['3.0', '2.0']),\n count: v.pipe(v.number(), v.minValue(1)),\n});\n\nconst ethernetCapability = v.object({\n type: v.picklist(['1000BASE-T', '100BASE-T', '10BASE-T']),\n count: v.pipe(v.number(), v.minValue(1)),\n});\n\nconst communicationCapability = v.object({\n type: communicationInterface,\n count: v.pipe(v.number(), v.minValue(1)),\n});\n\nconst powerSupplyCapabilities = v.object({\n count: v.pipe(v.number(), v.minValue(1)),\n output_voltage: voltageRange,\n current: currentRange,\n});\n\nconst currentMeasurementCapabilities = v.object({\n type: v.picklist(['low_precision', 'high_precision']),\n source: v.string(),\n resolution: v.pipe(v.number(), v.minValue(0)),\n});\n\nconst screenSize = v.object({\n width: v.pipe(v.number(), v.minValue(1)),\n height: v.pipe(v.number(), v.minValue(1)),\n});\n\nconst displayCapabilities = v.object({ type: v.string(), size: screenSize });\n\nconst inputCapabilities = v.object({ count: v.pipe(v.number(), v.minValue(0)), type: v.string() });\n\nconst audioCapabilities = v.object({ count: v.pipe(v.number(), v.minValue(0)), type: v.string() });\n\nconst hmiCapabilities = v.object({\n display: displayCapabilities,\n input: inputCapabilities,\n speaker: audioCapabilities,\n});\n\nconst capabilities = v.object({\n io: ioCapabilities,\n relays: relaysCapabilities,\n usb_ports: v.array(usbCapability),\n ethernet: v.array(ethernetCapability),\n communication: v.array(communicationCapability),\n power_supply: powerSupplyCapabilities,\n current_measurement: v.array(currentMeasurementCapabilities),\n hmi: hmiCapabilities,\n});\n\nconst info = v.object({\n model: v.string(),\n hostname: v.string(),\n serial_number: v.string(),\n firmware_version: v.string(),\n firmware_commit: v.string(),\n hardware_version: v.optional(v.number()),\n disk_used: v.number(),\n disk_total: v.number(),\n docker_used: v.number(),\n capabilities: capabilities,\n});\nexport type Information = v.InferOutput<typeof info>;\n\nconst project = v.object({\n name: v.string(),\n path: v.string(),\n container_id: v.string(),\n image: v.string(),\n});\ntype Project = v.InferOutput<typeof project>;\n\nconst createProject = v.object({ name: v.string(), image: v.string() });\ntype CreateProject = v.InferOutput<typeof createProject>;\n\nconst bundleInfo = v.object({\n bundle: v.string(),\n version: v.string(),\n compatible: v.string(),\n description: v.string(),\n});\nexport type BundleInfo = v.InferOutput<typeof bundleInfo>;\n\nconst installResponse = v.object({ message: v.string(), bundle: v.string() });\nexport type InstallResponse = v.InferOutput<typeof installResponse>;\n\nconst updateStatus = v.object({\n state: v.picklist(['idle', 'installing', 'failed']),\n progress: v.number(),\n message: v.string(),\n error: v.string(),\n});\nexport type UpdateStatus = v.InferOutput<typeof updateStatus>;\n\nconst rebootResponse = v.object({ message: v.string() });\nexport type RebootResponse = v.InferOutput<typeof rebootResponse>;\n\nconst finiteNumber = v.pipe(v.number(), v.finite());\nconst positiveFiniteNumber = v.pipe(v.number(), v.finite(), v.minValue(Number.MIN_VALUE));\nconst channelId = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(31));\nconst relayId = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(7));\nconst usbPortId = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(1));\nconst calibrationStatus = v.picklist(['pass', 'fail']);\n\nconst calibrationPoint = v.object({\n set: finiteNumber,\n measured: finiteNumber,\n reading: v.optional(finiteNumber),\n});\nexport type CalibrationPoint = v.InferOutput<typeof calibrationPoint>;\n\nconst channelCalibration = v.object({\n channel: channelId,\n points: v.array(calibrationPoint),\n max_error: finiteNumber,\n avg_error: finiteNumber,\n});\nexport type ChannelCalibration = v.InferOutput<typeof channelCalibration>;\n\nconst dutPsuCalibration = v.object({\n voltage: v.object({\n points: v.array(calibrationPoint),\n max_error: finiteNumber,\n avg_error: finiteNumber,\n }),\n current: v.object({\n load_ohms: positiveFiniteNumber,\n points: v.array(calibrationPoint),\n max_error: finiteNumber,\n avg_error: finiteNumber,\n }),\n});\nexport type DutPsuCalibration = v.InferOutput<typeof dutPsuCalibration>;\n\nconst currentTestResult = v.object({\n load_ohms: positiveFiniteNumber,\n voltage_applied: finiteNumber,\n measured_current: finiteNumber,\n expected_current: finiteNumber,\n error_percent: finiteNumber,\n});\n/** @deprecated See {@link currentTestResult}. */\nexport type CurrentTestResult = v.InferOutput<typeof currentTestResult>;\n\nconst relayTestResult = v.object({\n relay: relayId,\n status: calibrationStatus,\n test_voltage: finiteNumber,\n closed_current: finiteNumber,\n open_current: finiteNumber,\n calibration: v.optional(channelCalibration),\n});\nexport type RelayTestResult = v.InferOutput<typeof relayTestResult>;\n\nconst usbTestResult = v.object({\n port: usbPortId,\n status: calibrationStatus,\n voltage: finiteNumber,\n /** @deprecated Legacy field; only present on calibrations from older devices. */\n current_tests: v.optional(v.array(currentTestResult)),\n});\nexport type UsbTestResult = v.InferOutput<typeof usbTestResult>;\n\nconst calibrationData = v.object({\n schema_version: v.literal(1),\n tool_version: v.string(),\n device_id: v.string(),\n timestamp: v.string(),\n firmware_version: v.string(),\n dac: v.array(channelCalibration),\n adc_positive: v.array(channelCalibration),\n adc_negative: v.optional(v.array(channelCalibration)),\n dut_psu: dutPsuCalibration,\n relays: v.array(relayTestResult),\n usb: v.array(usbTestResult),\n});\nexport type CalibrationData = v.InferOutput<typeof calibrationData>;\n\nconst calibrationState = v.object({\n enabled: v.boolean(),\n loaded: v.boolean(),\n last_error: v.optional(v.nullable(v.string())),\n calibrated_at: v.optional(v.nullable(v.string())),\n});\nexport type CalibrationState = v.InferOutput<typeof calibrationState>;\n\nconst calibrationStatePatch = v.object({ enabled: v.boolean() });\n\n/** @hideconstructor */\nexport class ManagementApi {\n constructor(private readonly fetch: UpFetch) {}\n\n /**\n * Gets device information and capabilities.\n * @returns The device information.\n */\n info() {\n return this.fetch('/management/info', { schema: info });\n }\n\n /**\n * Gets the loaded calibration data.\n * @returns The canonical calibration data stored on the device.\n */\n get_calibration(): Promise<CalibrationData> {\n return this.fetch('/management/calibration', { schema: calibrationData });\n }\n\n /**\n * Uploads and activates calibration data.\n * @param data The full calibration report to store on the device.\n */\n set_calibration(data: CalibrationData): Promise<CalibrationData> {\n return this.fetch('/management/calibration', {\n method: 'PUT',\n body: v.parse(calibrationData, data),\n schema: calibrationData,\n });\n }\n\n /**\n * Gets runtime calibration enable/load state.\n */\n get_calibration_state(): Promise<CalibrationState> {\n return this.fetch('/management/calibration/state', { schema: calibrationState });\n }\n\n /**\n * Enables or disables runtime calibration correction.\n * @param enabled Whether calibration correction should be applied.\n */\n set_calibration_enabled(enabled: boolean): Promise<CalibrationState> {\n return this.fetch('/management/calibration/state', {\n method: 'PATCH',\n body: v.parse(calibrationStatePatch, { enabled }),\n schema: calibrationState,\n });\n }\n\n /** Enables runtime calibration correction. */\n enable_calibration(): Promise<CalibrationState> {\n return this.set_calibration_enabled(true);\n }\n\n /** Disables runtime calibration correction. */\n disable_calibration(): Promise<CalibrationState> {\n return this.set_calibration_enabled(false);\n }\n\n /**\n * Gets the current date and time of the device.\n * @returns The current date and time.\n */\n async datetime(): Promise<Date> {\n const time = await this.fetch('/management/datetime', {\n schema: v.object({ epoch_seconds: v.number() }),\n });\n return new Date(time.epoch_seconds * 1000);\n }\n\n /**\n * Sets the date and time of the device.\n *\n * This will only work if the device is not connected to the internet.\n *\n * @param datetime The date and time to set.\n */\n setDatetime(datetime: Date): Promise<void> {\n return this.fetch('/management/datetime', {\n method: 'POST',\n body: { epoch_seconds: Math.floor(datetime.getTime() / 1000) },\n parseResponse: () => {},\n });\n }\n\n /**\n * Gets a list of all projects.\n * @returns An array of projects.\n */\n getProjects() {\n return this.fetch('/management/projects', { schema: v.array(project) });\n }\n\n /**\n * Creates a new project.\n * @param data The project creation data.\n */\n createProject(newProject: CreateProject) {\n return this.fetch('/management/projects', {\n method: 'POST',\n body: newProject,\n schema: project,\n });\n }\n\n /**\n * Patches an existing project.\n * @param projectId The ID or name of the project to patch.\n * @param data The data to patch the project with.\n */\n updateProject(projectId: string, data: Project) {\n return this.fetch(`/management/projects/${projectId}`, {\n method: 'PATCH',\n body: data,\n schema: project,\n });\n }\n\n /**\n * Runs a project.\n * @param projectId The ID or name of the project to run.\n */\n runProject(projectId: string) {\n return this.fetch(`/management/projects/${projectId}/run`, { method: 'POST' });\n }\n\n /**\n * Stops a running project.\n * @param projectId The ID or name of the project to stop.\n */\n stopProject(projectId: string) {\n return this.fetch(`/management/projects/${projectId}/stop`, { method: 'POST' });\n }\n\n /**\n * Deletes a project.\n * @param projectId The ID or name of the project to delete.\n */\n deleteProject(projectId: string) {\n return this.fetch(`/management/projects/${projectId}`, { method: 'DELETE' });\n }\n\n /**\n * Uploads a firmware bundle to the device and inspects it.\n * The bundle is staged for installation but not installed yet.\n * @param file The firmware bundle file (.raucb).\n * @param filename Optional filename for the bundle. Defaults to 'bundle.raucb'.\n * @returns Bundle metadata including version information.\n */\n upload_bundle(file: Blob, filename = 'bundle.raucb') {\n return this.fetch('/management/update/upload', {\n method: 'POST',\n body: file,\n headers: { 'Content-Type': 'application/octet-stream', 'X-Bundle-Filename': filename },\n serializeBody: (b) => b as any,\n timeout: 600_000,\n schema: bundleInfo,\n });\n }\n\n /**\n * Gets metadata for the currently staged firmware bundle.\n * @returns Bundle metadata including version information.\n */\n bundle_info() {\n return this.fetch('/management/update/bundle-info', { schema: bundleInfo });\n }\n\n /**\n * Installs a previously uploaded firmware bundle.\n * @returns The install response with message and bundle name.\n */\n install_update() {\n return this.fetch('/management/update/install', { method: 'POST', schema: installResponse });\n }\n\n /**\n * Gets the current firmware update status.\n * @returns The update status including state, progress, message and error.\n */\n update_status() {\n return this.fetch('/management/update/status', { schema: updateStatus });\n }\n\n /**\n * Reboots the device.\n * @returns The reboot response message.\n */\n reboot() {\n return this.fetch('/management/reboot', { method: 'POST', schema: rebootResponse });\n }\n}\n"],"mappings":"mKAGA,IAAY,EAAL,SAAA,EAAA,OACL,GAAA,IAAA,MACA,EAAA,MAAA,QACA,EAAA,MAAA,QACA,EAAA,IAAA,MACA,EAAA,IAAA,MACA,EAAA,KAAA,QACF,EAAA,CAAA,CAAA,EACA,MAAM,EAAyBA,EAAE,KAAK,CAA0B,EAE1D,EAAeA,EAAE,OAAO,CAC5B,IAAKA,EAAE,KAAKA,EAAE,OAAO,EAAGA,EAAE,SAAS,GAAG,EAAGA,EAAE,SAAS,EAAE,CAAC,EACvD,IAAKA,EAAE,KAAKA,EAAE,OAAO,EAAGA,EAAE,SAAS,GAAG,EAAGA,EAAE,SAAS,EAAE,CAAC,CACzD,CAAC,EAEK,EAAeA,EAAE,OAAO,CAAE,IAAKA,EAAE,OAAO,CAAE,CAAC,EAE3C,EAAiBA,EAAE,OAAO,CAC9B,MAAOA,EAAE,KAAKA,EAAE,OAAO,EAAGA,EAAE,SAAS,CAAC,CAAC,EACvC,cAAe,EACf,eAAgB,CAClB,CAAC,EAEK,EAAqBA,EAAE,OAAO,CAClC,MAAOA,EAAE,KAAKA,EAAE,OAAO,EAAGA,EAAE,SAAS,CAAC,CAAC,EACvC,YAAaA,EAAE,OAAO,EACtB,YAAaA,EAAE,OAAO,EACtB,cAAeA,EAAE,KAAKA,EAAE,OAAO,EAAGA,EAAE,SAAS,CAAC,CAAC,CACjD,CAAC,EAEK,EAAgBA,EAAE,OAAO,CAC7B,KAAMA,EAAE,SAAS,CAAC,MAAO,KAAK,CAAC,EAC/B,MAAOA,EAAE,KAAKA,EAAE,OAAO,EAAGA,EAAE,SAAS,CAAC,CAAC,CACzC,CAAC,EAEK,EAAqBA,EAAE,OAAO,CAClC,KAAMA,EAAE,SAAS,CAAC,aA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B,QAAS,IACT,OAAQ,CACV,CAAC,CACH,CAMA,aAAc,CACZ,OAAO,KAAK,MAAM,iCAAkC,CAAE,OAAQ,CAAW,CAAC,CAC5E,CAMA,gBAAiB,CACf,OAAO,KAAK,MAAM,6BAA8B,CAAE,OAAQ,OAAQ,OAAQ,CAAgB,CAAC,CAC7F,CAMA,eAAgB,CACd,OAAO,KAAK,MAAM,4BAA6B,CAAE,OAAQ,CAAa,CAAC,CACzE,CAMA,QAAS,CACP,OAAO,KAAK,MAAM,qBAAsB,CAAE,OAAQ,OAAQ,OAAQ,CAAe,CAAC,CACpF,CACF"}
|
|
1
|
+
{"version":3,"file":"management.cjs","names":["v"],"sources":["../src/api/management.ts"],"sourcesContent":["import { type UpFetch } from 'up-fetch';\nimport * as v from 'valibot';\n\nexport enum CommunicationInterfaceType {\n Can = 'can',\n Rs232 = 'rs232',\n Rs485 = 'rs485',\n I2c = 'i2c',\n Spi = 'spi',\n Uart = 'uart',\n}\nconst communicationInterface = v.enum(CommunicationInterfaceType);\n\nconst voltageRange = v.object({\n min: v.pipe(v.number(), v.minValue(-24), v.maxValue(24)),\n max: v.pipe(v.number(), v.minValue(-24), v.maxValue(24)),\n});\n\nconst currentRange = v.object({ max: v.number() });\n\nconst ioCapabilities = v.object({\n count: v.pipe(v.number(), v.minValue(1)),\n input_voltage: voltageRange,\n output_voltage: voltageRange,\n});\n\nconst relaysCapabilities = v.object({\n count: v.pipe(v.number(), v.minValue(0)),\n max_current: v.number(),\n max_voltage: v.number(),\n on_resistance: v.pipe(v.number(), v.minValue(0)),\n});\n\nconst usbCapability = v.object({\n type: v.picklist(['3.0', '2.0']),\n count: v.pipe(v.number(), v.minValue(1)),\n});\n\nconst ethernetCapability = v.object({\n type: v.picklist(['1000BASE-T', '100BASE-T', '10BASE-T']),\n count: v.pipe(v.number(), v.minValue(1)),\n});\n\nconst communicationCapability = v.object({\n type: communicationInterface,\n count: v.pipe(v.number(), v.minValue(1)),\n});\n\nconst powerSupplyCapabilities = v.object({\n count: v.pipe(v.number(), v.minValue(1)),\n output_voltage: voltageRange,\n current: currentRange,\n});\n\nconst currentMeasurementCapabilities = v.object({\n type: v.picklist(['low_precision', 'high_precision']),\n source: v.string(),\n resolution: v.pipe(v.number(), v.minValue(0)),\n});\n\nconst screenSize = v.object({\n width: v.pipe(v.number(), v.minValue(1)),\n height: v.pipe(v.number(), v.minValue(1)),\n});\n\nconst displayCapabilities = v.object({ type: v.string(), size: screenSize });\n\nconst inputCapabilities = v.object({ count: v.pipe(v.number(), v.minValue(0)), type: v.string() });\n\nconst audioCapabilities = v.object({ count: v.pipe(v.number(), v.minValue(0)), type: v.string() });\n\nconst hmiCapabilities = v.object({\n display: displayCapabilities,\n input: inputCapabilities,\n speaker: audioCapabilities,\n});\n\nconst capabilities = v.object({\n io: ioCapabilities,\n relays: relaysCapabilities,\n usb_ports: v.array(usbCapability),\n ethernet: v.array(ethernetCapability),\n communication: v.array(communicationCapability),\n power_supply: powerSupplyCapabilities,\n current_measurement: v.array(currentMeasurementCapabilities),\n hmi: hmiCapabilities,\n});\n\nconst info = v.object({\n model: v.string(),\n hostname: v.string(),\n serial_number: v.string(),\n firmware_version: v.string(),\n firmware_commit: v.string(),\n hardware_version: v.optional(v.number()),\n disk_used: v.number(),\n disk_total: v.number(),\n docker_used: v.number(),\n capabilities: capabilities,\n});\nexport type Information = v.InferOutput<typeof info>;\n\nconst projectStatus = v.picklist(['idle', 'running', 'error']);\nconst projectEventState = v.picklist(['created', 'started', 'stopped', 'removed', 'error']);\nconst portProtocol = v.picklist(['tcp', 'udp']);\nconst port = v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(65535));\nexport const portMapping = v.object({ host: port, container: port, proto: portProtocol });\nexport type PortMapping = v.InferOutput<typeof portMapping>;\nconst authorizedKey = v.pipe(\n v.string(),\n v.trim(),\n v.regex(/^(ssh-|ecdsa-sha2-|sk-ssh-|sk-ecdsa-)/, 'Not a recognized SSH public key'),\n);\nexport const runMode = v.picklist(['normal', 'development']);\nexport type RunMode = v.InferOutput<typeof runMode>;\n\nexport const project = v.object({\n name: v.string(),\n path: v.string(),\n id: v.string(),\n image: v.string(),\n is_default: v.boolean(),\n ports: v.optional(v.array(portMapping), []),\n state: projectStatus,\n mode: v.optional(runMode),\n});\nexport type Project = v.InferOutput<typeof project>;\n\n// Merged management.project realtime event, discriminated on `change`.\nexport const projectEvent = v.variant('change', [\n v.object({ change: v.literal('state_changed'), id: v.string(), state: projectEventState }),\n v.object({ change: v.literal('renamed'), id: v.string(), name: v.string() }),\n v.object({ change: v.literal('default_changed'), id: v.string(), is_default: v.boolean() }),\n]);\nexport type ProjectEvent = v.InferOutput<typeof projectEvent>;\n\nconst projectPatch = v.partial(v.pick(project, ['name', 'is_default']));\nexport type ProjectPatch = v.InferOutput<typeof projectPatch>;\n\nconst createProject = v.object({ name: v.string(), image: v.string() });\nexport type CreateProject = v.InferOutput<typeof createProject>;\n\nconst bundleInfo = v.object({\n bundle: v.string(),\n version: v.string(),\n compatible: v.string(),\n description: v.string(),\n});\nexport type BundleInfo = v.InferOutput<typeof bundleInfo>;\n\nconst installResponse = v.object({ message: v.string(), bundle: v.string() });\nexport type InstallResponse = v.InferOutput<typeof installResponse>;\n\nexport const updateStatus = v.object({\n state: v.picklist(['idle', 'installing', 'failed']),\n progress: v.number(),\n message: v.string(),\n error: v.string(),\n});\nexport type UpdateStatus = v.InferOutput<typeof updateStatus>;\n\nconst rebootResponse = v.object({ message: v.string() });\nexport type RebootResponse = v.InferOutput<typeof rebootResponse>;\n\nconst finiteNumber = v.pipe(v.number(), v.finite());\nconst positiveFiniteNumber = v.pipe(v.number(), v.finite(), v.minValue(Number.MIN_VALUE));\nconst channelId = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(31));\nconst relayId = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(7));\nconst usbPortId = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(1));\nconst calibrationStatus = v.picklist(['pass', 'fail']);\n\nconst calibrationPoint = v.object({\n set: finiteNumber,\n measured: finiteNumber,\n reading: v.optional(finiteNumber),\n});\nexport type CalibrationPoint = v.InferOutput<typeof calibrationPoint>;\n\nconst channelCalibration = v.object({\n channel: channelId,\n points: v.array(calibrationPoint),\n max_error: finiteNumber,\n avg_error: finiteNumber,\n});\nexport type ChannelCalibration = v.InferOutput<typeof channelCalibration>;\n\nconst dutPsuCalibration = v.object({\n voltage: v.object({\n points: v.array(calibrationPoint),\n max_error: finiteNumber,\n avg_error: finiteNumber,\n }),\n current: v.object({\n load_ohms: positiveFiniteNumber,\n points: v.array(calibrationPoint),\n max_error: finiteNumber,\n avg_error: finiteNumber,\n }),\n});\nexport type DutPsuCalibration = v.InferOutput<typeof dutPsuCalibration>;\n\nconst currentTestResult = v.object({\n load_ohms: positiveFiniteNumber,\n voltage_applied: finiteNumber,\n measured_current: finiteNumber,\n expected_current: finiteNumber,\n error_percent: finiteNumber,\n});\n/** @deprecated See {@link currentTestResult}. */\nexport type CurrentTestResult = v.InferOutput<typeof currentTestResult>;\n\nconst relayTestResult = v.object({\n relay: relayId,\n status: calibrationStatus,\n test_voltage: finiteNumber,\n closed_current: finiteNumber,\n open_current: finiteNumber,\n calibration: v.optional(channelCalibration),\n});\nexport type RelayTestResult = v.InferOutput<typeof relayTestResult>;\n\nconst usbTestResult = v.object({\n port: usbPortId,\n status: calibrationStatus,\n voltage: finiteNumber,\n /** @deprecated Legacy field; only present on calibrations from older devices. */\n current_tests: v.optional(v.array(currentTestResult)),\n});\nexport type UsbTestResult = v.InferOutput<typeof usbTestResult>;\n\nexport const calibrationData = v.object({\n schema_version: v.literal(1),\n tool_version: v.string(),\n device_id: v.string(),\n timestamp: v.string(),\n firmware_version: v.string(),\n dac: v.array(channelCalibration),\n adc_positive: v.array(channelCalibration),\n adc_negative: v.optional(v.array(channelCalibration)),\n dut_psu: dutPsuCalibration,\n relays: v.array(relayTestResult),\n usb: v.array(usbTestResult),\n});\nexport type CalibrationData = v.InferOutput<typeof calibrationData>;\n\nexport const calibrationState = v.object({\n enabled: v.boolean(),\n loaded: v.boolean(),\n last_error: v.optional(v.nullable(v.string())),\n calibrated_at: v.optional(v.nullable(v.string())),\n});\nexport type CalibrationState = v.InferOutput<typeof calibrationState>;\n\nconst calibrationStatePatch = v.object({ enabled: v.boolean() });\n\n/** @hideconstructor */\nexport class ManagementApi {\n constructor(private readonly fetch: UpFetch) {}\n\n /**\n * Gets device information and capabilities.\n * @returns The device information.\n */\n info() {\n return this.fetch('/management/info', { schema: info });\n }\n\n /**\n * Gets the loaded calibration data.\n * @returns The canonical calibration data stored on the device.\n */\n get_calibration(): Promise<CalibrationData> {\n return this.fetch('/management/calibration', { schema: calibrationData });\n }\n\n /**\n * Uploads and activates calibration data.\n * @param data The full calibration report to store on the device.\n */\n set_calibration(data: CalibrationData): Promise<CalibrationData> {\n return this.fetch('/management/calibration', {\n method: 'PUT',\n body: v.parse(calibrationData, data),\n schema: calibrationData,\n });\n }\n\n /**\n * Gets runtime calibration enable/load state.\n */\n get_calibration_state(): Promise<CalibrationState> {\n return this.fetch('/management/calibration/state', { schema: calibrationState });\n }\n\n /**\n * Enables or disables runtime calibration correction.\n * @param enabled Whether calibration correction should be applied.\n */\n set_calibration_enabled(enabled: boolean): Promise<CalibrationState> {\n return this.fetch('/management/calibration/state', {\n method: 'PATCH',\n body: v.parse(calibrationStatePatch, { enabled }),\n schema: calibrationState,\n });\n }\n\n /** Enables runtime calibration correction. */\n enable_calibration(): Promise<CalibrationState> {\n return this.set_calibration_enabled(true);\n }\n\n /** Disables runtime calibration correction. */\n disable_calibration(): Promise<CalibrationState> {\n return this.set_calibration_enabled(false);\n }\n\n /**\n * Gets the current date and time of the device.\n * @returns The current date and time.\n */\n async datetime(): Promise<Date> {\n const time = await this.fetch('/management/datetime', {\n schema: v.object({ epoch_seconds: v.number() }),\n });\n return new Date(time.epoch_seconds * 1000);\n }\n\n /**\n * Sets the date and time of the device.\n *\n * This will only work if the device is not connected to the internet.\n *\n * @param datetime The date and time to set.\n */\n setDatetime(datetime: Date): Promise<void> {\n return this.fetch('/management/datetime', {\n method: 'POST',\n body: { epoch_seconds: Math.floor(datetime.getTime() / 1000) },\n parseResponse: () => {},\n });\n }\n\n /**\n * Gets a list of all projects.\n * @returns An array of projects.\n */\n getProjects() {\n return this.fetch('/management/projects', { schema: v.array(project) });\n }\n\n /**\n * Gets a single project by id.\n * @param projectId The project slug id.\n * @returns The project info.\n */\n getProject(projectId: string) {\n return this.fetch(`/management/projects/${projectId}`, { schema: project });\n }\n\n /**\n * Creates a new project.\n * @param data The project creation data.\n */\n createProject(newProject: CreateProject) {\n return this.fetch('/management/projects', {\n method: 'POST',\n body: newProject,\n timeout: 30_000,\n schema: project,\n });\n }\n\n /**\n * Imports a project from a container image archive (.tar / .tar.gz).\n * @param file The image archive to import.\n * @param name The project name (sent percent-encoded; the server decodes it).\n * @returns The created project.\n */\n importProject(file: Blob, name: string) {\n return this.fetch('/management/projects/import', {\n method: 'POST',\n body: file,\n headers: { 'Content-Type': 'application/x-tar', 'X-Project-Name': encodeURIComponent(name) },\n serializeBody: (b) => b as any,\n timeout: 600_000,\n schema: project,\n });\n }\n\n /**\n * Patches an existing project.\n * @param projectId The project slug id.\n * @param data The data to patch the project with.\n */\n updateProject(projectId: string, data: ProjectPatch) {\n return this.fetch(`/management/projects/${projectId}`, {\n method: 'PATCH',\n body: v.parse(projectPatch, data),\n schema: project,\n });\n }\n\n /**\n * Runs a project.\n * @param projectId The project slug id.\n * @param mode The run mode: 'normal' (default) or 'development' (starts sshd).\n */\n runProject(projectId: string, mode: RunMode = 'normal') {\n return this.fetch(`/management/projects/${projectId}/run`, {\n method: 'POST',\n body: { mode },\n timeout: 30_000,\n });\n }\n\n /**\n * Stops a running project.\n * @param projectId The project slug id.\n */\n stopProject(projectId: string) {\n return this.fetch(`/management/projects/${projectId}/stop`, {\n method: 'POST',\n timeout: 30_000,\n });\n }\n\n /**\n * Gets the port mappings for a project.\n * @param projectId The project slug id.\n * @returns The project's port mappings.\n */\n getProjectPorts(projectId: string) {\n return this.fetch(`/management/projects/${projectId}/ports`, { schema: v.array(portMapping) });\n }\n\n /**\n * Replaces the full set of port mappings for a project.\n * @param projectId The project slug id.\n * @param ports The complete list of port mappings.\n * @returns The updated port mappings.\n */\n setProjectPorts(projectId: string, ports: PortMapping[]) {\n return this.fetch(`/management/projects/${projectId}/ports`, {\n method: 'PUT',\n body: v.parse(v.array(portMapping), ports),\n timeout: 30_000,\n schema: v.array(portMapping),\n });\n }\n\n /**\n * Adds a single port mapping to a project.\n * @param projectId The project slug id.\n * @param mapping The port mapping to add.\n * @returns The updated port mappings.\n */\n addProjectPort(projectId: string, mapping: PortMapping) {\n return this.fetch(`/management/projects/${projectId}/ports`, {\n method: 'POST',\n body: v.parse(portMapping, mapping),\n timeout: 30_000,\n schema: v.array(portMapping),\n });\n }\n\n /**\n * Removes the port mapping for a host port from a project.\n * @param projectId The project slug id.\n * @param hostPort The host port to unmap.\n */\n deleteProjectPort(projectId: string, hostPort: number) {\n return this.fetch(`/management/projects/${projectId}/ports/${hostPort}`, {\n method: 'DELETE',\n parseResponse: () => {},\n timeout: 30_000,\n });\n }\n\n /**\n * Sets the password of the project's dev user (used for SSH password login in\n * development mode).\n * @param projectId The project slug id.\n * @param password The new password.\n */\n setProjectPassword(projectId: string, password: string) {\n return this.fetch(`/management/projects/${projectId}/password`, {\n method: 'POST',\n body: v.parse(v.object({ password: v.pipe(v.string(), v.minLength(1)) }), { password }),\n parseResponse: () => {},\n timeout: 30_000,\n });\n }\n\n /**\n * Gets the SSH authorized_keys for the project's dev user.\n * @param projectId The project slug id.\n * @returns The list of authorized public keys.\n */\n getProjectAuthorizedKeys(projectId: string) {\n return this.fetch(`/management/projects/${projectId}/authorized_keys`, {\n schema: v.array(v.string()),\n });\n }\n\n /**\n * Replaces the SSH authorized_keys for the project's dev user.\n * @param projectId The project slug id.\n * @param keys The complete list of authorized public keys.\n * @returns The updated list of authorized public keys.\n */\n setProjectAuthorizedKeys(projectId: string, keys: string[]) {\n return this.fetch(`/management/projects/${projectId}/authorized_keys`, {\n method: 'PUT',\n body: v.parse(v.array(authorizedKey), keys),\n timeout: 30_000,\n schema: v.array(v.string()),\n });\n }\n\n /**\n * Deletes a project.\n * @param projectId The project slug id.\n */\n deleteProject(projectId: string) {\n return this.fetch(`/management/projects/${projectId}`, { method: 'DELETE', timeout: 30_000 });\n }\n\n /**\n * Uploads a firmware bundle to the device and inspects it.\n * The bundle is staged for installation but not installed yet.\n * @param file The firmware bundle file (.raucb).\n * @param filename Optional filename for the bundle. Defaults to 'bundle.raucb'.\n * @returns Bundle metadata including version information.\n */\n upload_bundle(file: Blob, filename = 'bundle.raucb') {\n return this.fetch('/management/update/upload', {\n method: 'POST',\n body: file,\n headers: { 'Content-Type': 'application/octet-stream', 'X-Bundle-Filename': filename },\n serializeBody: (b) => b as any,\n timeout: 600_000,\n schema: bundleInfo,\n });\n }\n\n /**\n * Gets metadata for the currently staged firmware bundle.\n * @returns Bundle metadata including version information.\n */\n bundle_info() {\n return this.fetch('/management/update/bundle-info', { schema: bundleInfo });\n }\n\n /**\n * Installs a previously uploaded firmware bundle.\n * @returns The install response with message and bundle name.\n */\n install_update() {\n return this.fetch('/management/update/install', { method: 'POST', schema: installResponse });\n }\n\n /**\n * Gets the current firmware update status.\n * @returns The update status including state, progress, message and error.\n */\n update_status() {\n return this.fetch('/management/update/status', { schema: updateStatus });\n }\n\n /**\n * Reboots the device.\n * @returns The reboot response message.\n */\n reboot() {\n return this.fetch('/management/reboot', { method: 'POST', schema: rebootResponse });\n }\n}\n"],"mappings":"mKAGA,IAAY,EAAL,SAAA,EAAA,OACL,GAAA,IAAA,MACA,EAAA,MAAA,QACA,EAAA,MAAA,QACA,EAAA,IAAA,MACA,EAAA,IAAA,MACA,EAAA,KAAA,QACF,EAAA,CAAA,CAAA,EACA,MAAM,EAAyBA,EAAE,KAAK,CAA0B,EAE1D,EAAeA,EAAE,OAAO,CAC5B,IAAKA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AQ,CAAW,CAAC,CAC5E,CAMA,gBAAiB,CACf,OAAO,KAAK,MAAM,6BAA8B,CAAE,OAAQ,OAAQ,OAAQ,CAAgB,CAAC,CAC7F,CAMA,eAAgB,CACd,OAAO,KAAK,MAAM,4BAA6B,CAAE,OAAQ,CAAa,CAAC,CACzE,CAMA,QAAS,CACP,OAAO,KAAK,MAAM,qBAAsB,CAAE,OAAQ,OAAQ,OAAQ,CAAe,CAAC,CACpF,CACF"}
|
package/build/management.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ChannelCalibration, c as
|
|
2
|
-
export { BundleInfo, CalibrationData, CalibrationPoint, CalibrationState, ChannelCalibration, CommunicationInterfaceType, CurrentTestResult, DutPsuCalibration, Information, InstallResponse, ManagementApi, RebootResponse, RelayTestResult, UpdateStatus, UsbTestResult };
|
|
1
|
+
import { C as calibrationState, D as runMode, E as projectEvent, O as updateStatus, S as calibrationData, T as project, _ as RebootResponse, a as ChannelCalibration, b as UpdateStatus, c as CurrentTestResult, d as InstallResponse, f as ManagementApi, g as ProjectPatch, h as ProjectEvent, i as CalibrationState, l as DutPsuCalibration, m as Project, n as CalibrationData, o as CommunicationInterfaceType, p as PortMapping, r as CalibrationPoint, s as CreateProject, t as BundleInfo, u as Information, v as RelayTestResult, w as portMapping, x as UsbTestResult, y as RunMode } from "./management-DliNzoq1.cjs";
|
|
2
|
+
export { BundleInfo, CalibrationData, CalibrationPoint, CalibrationState, ChannelCalibration, CommunicationInterfaceType, CreateProject, CurrentTestResult, DutPsuCalibration, Information, InstallResponse, ManagementApi, PortMapping, Project, ProjectEvent, ProjectPatch, RebootResponse, RelayTestResult, RunMode, UpdateStatus, UsbTestResult, calibrationData, calibrationState, portMapping, project, projectEvent, runMode, updateStatus };
|
package/build/management.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ChannelCalibration, c as
|
|
2
|
-
export { BundleInfo, CalibrationData, CalibrationPoint, CalibrationState, ChannelCalibration, CommunicationInterfaceType, CurrentTestResult, DutPsuCalibration, Information, InstallResponse, ManagementApi, RebootResponse, RelayTestResult, UpdateStatus, UsbTestResult };
|
|
1
|
+
import { C as calibrationState, D as runMode, E as projectEvent, O as updateStatus, S as calibrationData, T as project, _ as RebootResponse, a as ChannelCalibration, b as UpdateStatus, c as CurrentTestResult, d as InstallResponse, f as ManagementApi, g as ProjectPatch, h as ProjectEvent, i as CalibrationState, l as DutPsuCalibration, m as Project, n as CalibrationData, o as CommunicationInterfaceType, p as PortMapping, r as CalibrationPoint, s as CreateProject, t as BundleInfo, u as Information, v as RelayTestResult, w as portMapping, x as UsbTestResult, y as RunMode } from "./management-DliNzoq1.mjs";
|
|
2
|
+
export { BundleInfo, CalibrationData, CalibrationPoint, CalibrationState, ChannelCalibration, CommunicationInterfaceType, CreateProject, CurrentTestResult, DutPsuCalibration, Information, InstallResponse, ManagementApi, PortMapping, Project, ProjectEvent, ProjectPatch, RebootResponse, RelayTestResult, RunMode, UpdateStatus, UsbTestResult, calibrationData, calibrationState, portMapping, project, projectEvent, runMode, updateStatus };
|
package/build/management.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"up-fetch";import*as e from"valibot";let t=function(e){return e.Can=`can`,e.Rs232=`rs232`,e.Rs485=`rs485`,e.I2c=`i2c`,e.Spi=`spi`,e.Uart=`uart`,e}({});const n=e.enum(t),r=e.object({min:e.pipe(e.number(),e.minValue(-24),e.maxValue(24)),max:e.pipe(e.number(),e.minValue(-24),e.maxValue(24))}),i=e.object({max:e.number()}),a=e.object({count:e.pipe(e.number(),e.minValue(1)),input_voltage:r,output_voltage:r}),o=e.object({count:e.pipe(e.number(),e.minValue(0)),max_current:e.number(),max_voltage:e.number(),on_resistance:e.pipe(e.number(),e.minValue(0))}),s=e.object({type:e.picklist([`3.0`,`2.0`]),count:e.pipe(e.number(),e.minValue(1))}),c=e.object({type:e.picklist([`1000BASE-T`,`100BASE-T`,`10BASE-T`]),count:e.pipe(e.number(),e.minValue(1))}),l=e.object({type:n,count:e.pipe(e.number(),e.minValue(1))}),u=e.object({count:e.pipe(e.number(),e.minValue(1)),output_voltage:r,current:i}),d=e.object({type:e.picklist([`low_precision`,`high_precision`]),source:e.string(),resolution:e.pipe(e.number(),e.minValue(0))}),f=e.object({width:e.pipe(e.number(),e.minValue(1)),height:e.pipe(e.number(),e.minValue(1))}),p=e.object({type:e.string(),size:f}),m=e.object({count:e.pipe(e.number(),e.minValue(0)),type:e.string()}),h=e.object({count:e.pipe(e.number(),e.minValue(0)),type:e.string()}),g=e.object({display:p,input:m,speaker:h}),_=e.object({io:a,relays:o,usb_ports:e.array(s),ethernet:e.array(c),communication:e.array(l),power_supply:u,current_measurement:e.array(d),hmi:g}),v=e.object({model:e.string(),hostname:e.string(),serial_number:e.string(),firmware_version:e.string(),firmware_commit:e.string(),hardware_version:e.optional(e.number()),disk_used:e.number(),disk_total:e.number(),docker_used:e.number(),capabilities:_}),y=e.object({name:e.string(),path:e.string(),
|
|
1
|
+
import"up-fetch";import*as e from"valibot";let t=function(e){return e.Can=`can`,e.Rs232=`rs232`,e.Rs485=`rs485`,e.I2c=`i2c`,e.Spi=`spi`,e.Uart=`uart`,e}({});const n=e.enum(t),r=e.object({min:e.pipe(e.number(),e.minValue(-24),e.maxValue(24)),max:e.pipe(e.number(),e.minValue(-24),e.maxValue(24))}),i=e.object({max:e.number()}),a=e.object({count:e.pipe(e.number(),e.minValue(1)),input_voltage:r,output_voltage:r}),o=e.object({count:e.pipe(e.number(),e.minValue(0)),max_current:e.number(),max_voltage:e.number(),on_resistance:e.pipe(e.number(),e.minValue(0))}),s=e.object({type:e.picklist([`3.0`,`2.0`]),count:e.pipe(e.number(),e.minValue(1))}),c=e.object({type:e.picklist([`1000BASE-T`,`100BASE-T`,`10BASE-T`]),count:e.pipe(e.number(),e.minValue(1))}),l=e.object({type:n,count:e.pipe(e.number(),e.minValue(1))}),u=e.object({count:e.pipe(e.number(),e.minValue(1)),output_voltage:r,current:i}),d=e.object({type:e.picklist([`low_precision`,`high_precision`]),source:e.string(),resolution:e.pipe(e.number(),e.minValue(0))}),f=e.object({width:e.pipe(e.number(),e.minValue(1)),height:e.pipe(e.number(),e.minValue(1))}),p=e.object({type:e.string(),size:f}),m=e.object({count:e.pipe(e.number(),e.minValue(0)),type:e.string()}),h=e.object({count:e.pipe(e.number(),e.minValue(0)),type:e.string()}),g=e.object({display:p,input:m,speaker:h}),_=e.object({io:a,relays:o,usb_ports:e.array(s),ethernet:e.array(c),communication:e.array(l),power_supply:u,current_measurement:e.array(d),hmi:g}),v=e.object({model:e.string(),hostname:e.string(),serial_number:e.string(),firmware_version:e.string(),firmware_commit:e.string(),hardware_version:e.optional(e.number()),disk_used:e.number(),disk_total:e.number(),docker_used:e.number(),capabilities:_}),y=e.picklist([`idle`,`running`,`error`]),b=e.picklist([`created`,`started`,`stopped`,`removed`,`error`]),x=e.picklist([`tcp`,`udp`]),S=e.pipe(e.number(),e.integer(),e.minValue(1),e.maxValue(65535)),C=e.object({host:S,container:S,proto:x}),w=e.pipe(e.string(),e.trim(),e.regex(/^(ssh-|ecdsa-sha2-|sk-ssh-|sk-ecdsa-)/,`Not a recognized SSH public key`)),T=e.picklist([`normal`,`development`]),E=e.object({name:e.string(),path:e.string(),id:e.string(),image:e.string(),is_default:e.boolean(),ports:e.optional(e.array(C),[]),state:y,mode:e.optional(T)}),D=e.variant(`change`,[e.object({change:e.literal(`state_changed`),id:e.string(),state:b}),e.object({change:e.literal(`renamed`),id:e.string(),name:e.string()}),e.object({change:e.literal(`default_changed`),id:e.string(),is_default:e.boolean()})]),O=e.partial(e.pick(E,[`name`,`is_default`]));e.object({name:e.string(),image:e.string()});const k=e.object({bundle:e.string(),version:e.string(),compatible:e.string(),description:e.string()}),A=e.object({message:e.string(),bundle:e.string()}),j=e.object({state:e.picklist([`idle`,`installing`,`failed`]),progress:e.number(),message:e.string(),error:e.string()}),M=e.object({message:e.string()}),N=e.pipe(e.number(),e.finite()),P=e.pipe(e.number(),e.finite(),e.minValue(Number.MIN_VALUE)),F=e.pipe(e.number(),e.integer(),e.minValue(0),e.maxValue(31)),I=e.pipe(e.number(),e.integer(),e.minValue(0),e.maxValue(7)),L=e.pipe(e.number(),e.integer(),e.minValue(0),e.maxValue(1)),R=e.picklist([`pass`,`fail`]),z=e.object({set:N,measured:N,reading:e.optional(N)}),B=e.object({channel:F,points:e.array(z),max_error:N,avg_error:N}),V=e.object({voltage:e.object({points:e.array(z),max_error:N,avg_error:N}),current:e.object({load_ohms:P,points:e.array(z),max_error:N,avg_error:N})}),H=e.object({load_ohms:P,voltage_applied:N,measured_current:N,expected_current:N,error_percent:N}),U=e.object({relay:I,status:R,test_voltage:N,closed_current:N,open_current:N,calibration:e.optional(B)}),W=e.object({port:L,status:R,voltage:N,current_tests:e.optional(e.array(H))}),G=e.object({schema_version:e.literal(1),tool_version:e.string(),device_id:e.string(),timestamp:e.string(),firmware_version:e.string(),dac:e.array(B),adc_positive:e.array(B),adc_negative:e.optional(e.array(B)),dut_psu:V,relays:e.array(U),usb:e.array(W)}),K=e.object({enabled:e.boolean(),loaded:e.boolean(),last_error:e.optional(e.nullable(e.string())),calibrated_at:e.optional(e.nullable(e.string()))}),q=e.object({enabled:e.boolean()});var J=class{fetch;constructor(e){this.fetch=e}info(){return this.fetch(`/management/info`,{schema:v})}get_calibration(){return this.fetch(`/management/calibration`,{schema:G})}set_calibration(t){return this.fetch(`/management/calibration`,{method:`PUT`,body:e.parse(G,t),schema:G})}get_calibration_state(){return this.fetch(`/management/calibration/state`,{schema:K})}set_calibration_enabled(t){return this.fetch(`/management/calibration/state`,{method:`PATCH`,body:e.parse(q,{enabled:t}),schema:K})}enable_calibration(){return this.set_calibration_enabled(!0)}disable_calibration(){return this.set_calibration_enabled(!1)}async datetime(){let t=await this.fetch(`/management/datetime`,{schema:e.object({epoch_seconds:e.number()})});return new Date(t.epoch_seconds*1e3)}setDatetime(e){return this.fetch(`/management/datetime`,{method:`POST`,body:{epoch_seconds:Math.floor(e.getTime()/1e3)},parseResponse:()=>{}})}getProjects(){return this.fetch(`/management/projects`,{schema:e.array(E)})}getProject(e){return this.fetch(`/management/projects/${e}`,{schema:E})}createProject(e){return this.fetch(`/management/projects`,{method:`POST`,body:e,timeout:3e4,schema:E})}importProject(e,t){return this.fetch(`/management/projects/import`,{method:`POST`,body:e,headers:{"Content-Type":`application/x-tar`,"X-Project-Name":encodeURIComponent(t)},serializeBody:e=>e,timeout:6e5,schema:E})}updateProject(t,n){return this.fetch(`/management/projects/${t}`,{method:`PATCH`,body:e.parse(O,n),schema:E})}runProject(e,t=`normal`){return this.fetch(`/management/projects/${e}/run`,{method:`POST`,body:{mode:t},timeout:3e4})}stopProject(e){return this.fetch(`/management/projects/${e}/stop`,{method:`POST`,timeout:3e4})}getProjectPorts(t){return this.fetch(`/management/projects/${t}/ports`,{schema:e.array(C)})}setProjectPorts(t,n){return this.fetch(`/management/projects/${t}/ports`,{method:`PUT`,body:e.parse(e.array(C),n),timeout:3e4,schema:e.array(C)})}addProjectPort(t,n){return this.fetch(`/management/projects/${t}/ports`,{method:`POST`,body:e.parse(C,n),timeout:3e4,schema:e.array(C)})}deleteProjectPort(e,t){return this.fetch(`/management/projects/${e}/ports/${t}`,{method:`DELETE`,parseResponse:()=>{},timeout:3e4})}setProjectPassword(t,n){return this.fetch(`/management/projects/${t}/password`,{method:`POST`,body:e.parse(e.object({password:e.pipe(e.string(),e.minLength(1))}),{password:n}),parseResponse:()=>{},timeout:3e4})}getProjectAuthorizedKeys(t){return this.fetch(`/management/projects/${t}/authorized_keys`,{schema:e.array(e.string())})}setProjectAuthorizedKeys(t,n){return this.fetch(`/management/projects/${t}/authorized_keys`,{method:`PUT`,body:e.parse(e.array(w),n),timeout:3e4,schema:e.array(e.string())})}deleteProject(e){return this.fetch(`/management/projects/${e}`,{method:`DELETE`,timeout:3e4})}upload_bundle(e,t=`bundle.raucb`){return this.fetch(`/management/update/upload`,{method:`POST`,body:e,headers:{"Content-Type":`application/octet-stream`,"X-Bundle-Filename":t},serializeBody:e=>e,timeout:6e5,schema:k})}bundle_info(){return this.fetch(`/management/update/bundle-info`,{schema:k})}install_update(){return this.fetch(`/management/update/install`,{method:`POST`,schema:A})}update_status(){return this.fetch(`/management/update/status`,{schema:j})}reboot(){return this.fetch(`/management/reboot`,{method:`POST`,schema:M})}};export{t as CommunicationInterfaceType,J as ManagementApi,G as calibrationData,K as calibrationState,C as portMapping,E as project,D as projectEvent,T as runMode,j as updateStatus};
|
|
2
2
|
//# sourceMappingURL=management.mjs.map
|
package/build/management.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"management.mjs","names":[],"sources":["../src/api/management.ts"],"sourcesContent":["import { type UpFetch } from 'up-fetch';\nimport * as v from 'valibot';\n\nexport enum CommunicationInterfaceType {\n Can = 'can',\n Rs232 = 'rs232',\n Rs485 = 'rs485',\n I2c = 'i2c',\n Spi = 'spi',\n Uart = 'uart',\n}\nconst communicationInterface = v.enum(CommunicationInterfaceType);\n\nconst voltageRange = v.object({\n min: v.pipe(v.number(), v.minValue(-24), v.maxValue(24)),\n max: v.pipe(v.number(), v.minValue(-24), v.maxValue(24)),\n});\n\nconst currentRange = v.object({ max: v.number() });\n\nconst ioCapabilities = v.object({\n count: v.pipe(v.number(), v.minValue(1)),\n input_voltage: voltageRange,\n output_voltage: voltageRange,\n});\n\nconst relaysCapabilities = v.object({\n count: v.pipe(v.number(), v.minValue(0)),\n max_current: v.number(),\n max_voltage: v.number(),\n on_resistance: v.pipe(v.number(), v.minValue(0)),\n});\n\nconst usbCapability = v.object({\n type: v.picklist(['3.0', '2.0']),\n count: v.pipe(v.number(), v.minValue(1)),\n});\n\nconst ethernetCapability = v.object({\n type: v.picklist(['1000BASE-T', '100BASE-T', '10BASE-T']),\n count: v.pipe(v.number(), v.minValue(1)),\n});\n\nconst communicationCapability = v.object({\n type: communicationInterface,\n count: v.pipe(v.number(), v.minValue(1)),\n});\n\nconst powerSupplyCapabilities = v.object({\n count: v.pipe(v.number(), v.minValue(1)),\n output_voltage: voltageRange,\n current: currentRange,\n});\n\nconst currentMeasurementCapabilities = v.object({\n type: v.picklist(['low_precision', 'high_precision']),\n source: v.string(),\n resolution: v.pipe(v.number(), v.minValue(0)),\n});\n\nconst screenSize = v.object({\n width: v.pipe(v.number(), v.minValue(1)),\n height: v.pipe(v.number(), v.minValue(1)),\n});\n\nconst displayCapabilities = v.object({ type: v.string(), size: screenSize });\n\nconst inputCapabilities = v.object({ count: v.pipe(v.number(), v.minValue(0)), type: v.string() });\n\nconst audioCapabilities = v.object({ count: v.pipe(v.number(), v.minValue(0)), type: v.string() });\n\nconst hmiCapabilities = v.object({\n display: displayCapabilities,\n input: inputCapabilities,\n speaker: audioCapabilities,\n});\n\nconst capabilities = v.object({\n io: ioCapabilities,\n relays: relaysCapabilities,\n usb_ports: v.array(usbCapability),\n ethernet: v.array(ethernetCapability),\n communication: v.array(communicationCapability),\n power_supply: powerSupplyCapabilities,\n current_measurement: v.array(currentMeasurementCapabilities),\n hmi: hmiCapabilities,\n});\n\nconst info = v.object({\n model: v.string(),\n hostname: v.string(),\n serial_number: v.string(),\n firmware_version: v.string(),\n firmware_commit: v.string(),\n hardware_version: v.optional(v.number()),\n disk_used: v.number(),\n disk_total: v.number(),\n docker_used: v.number(),\n capabilities: capabilities,\n});\nexport type Information = v.InferOutput<typeof info>;\n\nconst project = v.object({\n name: v.string(),\n path: v.string(),\n container_id: v.string(),\n image: v.string(),\n});\ntype Project = v.InferOutput<typeof project>;\n\nconst createProject = v.object({ name: v.string(), image: v.string() });\ntype CreateProject = v.InferOutput<typeof createProject>;\n\nconst bundleInfo = v.object({\n bundle: v.string(),\n version: v.string(),\n compatible: v.string(),\n description: v.string(),\n});\nexport type BundleInfo = v.InferOutput<typeof bundleInfo>;\n\nconst installResponse = v.object({ message: v.string(), bundle: v.string() });\nexport type InstallResponse = v.InferOutput<typeof installResponse>;\n\nconst updateStatus = v.object({\n state: v.picklist(['idle', 'installing', 'failed']),\n progress: v.number(),\n message: v.string(),\n error: v.string(),\n});\nexport type UpdateStatus = v.InferOutput<typeof updateStatus>;\n\nconst rebootResponse = v.object({ message: v.string() });\nexport type RebootResponse = v.InferOutput<typeof rebootResponse>;\n\nconst finiteNumber = v.pipe(v.number(), v.finite());\nconst positiveFiniteNumber = v.pipe(v.number(), v.finite(), v.minValue(Number.MIN_VALUE));\nconst channelId = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(31));\nconst relayId = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(7));\nconst usbPortId = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(1));\nconst calibrationStatus = v.picklist(['pass', 'fail']);\n\nconst calibrationPoint = v.object({\n set: finiteNumber,\n measured: finiteNumber,\n reading: v.optional(finiteNumber),\n});\nexport type CalibrationPoint = v.InferOutput<typeof calibrationPoint>;\n\nconst channelCalibration = v.object({\n channel: channelId,\n points: v.array(calibrationPoint),\n max_error: finiteNumber,\n avg_error: finiteNumber,\n});\nexport type ChannelCalibration = v.InferOutput<typeof channelCalibration>;\n\nconst dutPsuCalibration = v.object({\n voltage: v.object({\n points: v.array(calibrationPoint),\n max_error: finiteNumber,\n avg_error: finiteNumber,\n }),\n current: v.object({\n load_ohms: positiveFiniteNumber,\n points: v.array(calibrationPoint),\n max_error: finiteNumber,\n avg_error: finiteNumber,\n }),\n});\nexport type DutPsuCalibration = v.InferOutput<typeof dutPsuCalibration>;\n\nconst currentTestResult = v.object({\n load_ohms: positiveFiniteNumber,\n voltage_applied: finiteNumber,\n measured_current: finiteNumber,\n expected_current: finiteNumber,\n error_percent: finiteNumber,\n});\n/** @deprecated See {@link currentTestResult}. */\nexport type CurrentTestResult = v.InferOutput<typeof currentTestResult>;\n\nconst relayTestResult = v.object({\n relay: relayId,\n status: calibrationStatus,\n test_voltage: finiteNumber,\n closed_current: finiteNumber,\n open_current: finiteNumber,\n calibration: v.optional(channelCalibration),\n});\nexport type RelayTestResult = v.InferOutput<typeof relayTestResult>;\n\nconst usbTestResult = v.object({\n port: usbPortId,\n status: calibrationStatus,\n voltage: finiteNumber,\n /** @deprecated Legacy field; only present on calibrations from older devices. */\n current_tests: v.optional(v.array(currentTestResult)),\n});\nexport type UsbTestResult = v.InferOutput<typeof usbTestResult>;\n\nconst calibrationData = v.object({\n schema_version: v.literal(1),\n tool_version: v.string(),\n device_id: v.string(),\n timestamp: v.string(),\n firmware_version: v.string(),\n dac: v.array(channelCalibration),\n adc_positive: v.array(channelCalibration),\n adc_negative: v.optional(v.array(channelCalibration)),\n dut_psu: dutPsuCalibration,\n relays: v.array(relayTestResult),\n usb: v.array(usbTestResult),\n});\nexport type CalibrationData = v.InferOutput<typeof calibrationData>;\n\nconst calibrationState = v.object({\n enabled: v.boolean(),\n loaded: v.boolean(),\n last_error: v.optional(v.nullable(v.string())),\n calibrated_at: v.optional(v.nullable(v.string())),\n});\nexport type CalibrationState = v.InferOutput<typeof calibrationState>;\n\nconst calibrationStatePatch = v.object({ enabled: v.boolean() });\n\n/** @hideconstructor */\nexport class ManagementApi {\n constructor(private readonly fetch: UpFetch) {}\n\n /**\n * Gets device information and capabilities.\n * @returns The device information.\n */\n info() {\n return this.fetch('/management/info', { schema: info });\n }\n\n /**\n * Gets the loaded calibration data.\n * @returns The canonical calibration data stored on the device.\n */\n get_calibration(): Promise<CalibrationData> {\n return this.fetch('/management/calibration', { schema: calibrationData });\n }\n\n /**\n * Uploads and activates calibration data.\n * @param data The full calibration report to store on the device.\n */\n set_calibration(data: CalibrationData): Promise<CalibrationData> {\n return this.fetch('/management/calibration', {\n method: 'PUT',\n body: v.parse(calibrationData, data),\n schema: calibrationData,\n });\n }\n\n /**\n * Gets runtime calibration enable/load state.\n */\n get_calibration_state(): Promise<CalibrationState> {\n return this.fetch('/management/calibration/state', { schema: calibrationState });\n }\n\n /**\n * Enables or disables runtime calibration correction.\n * @param enabled Whether calibration correction should be applied.\n */\n set_calibration_enabled(enabled: boolean): Promise<CalibrationState> {\n return this.fetch('/management/calibration/state', {\n method: 'PATCH',\n body: v.parse(calibrationStatePatch, { enabled }),\n schema: calibrationState,\n });\n }\n\n /** Enables runtime calibration correction. */\n enable_calibration(): Promise<CalibrationState> {\n return this.set_calibration_enabled(true);\n }\n\n /** Disables runtime calibration correction. */\n disable_calibration(): Promise<CalibrationState> {\n return this.set_calibration_enabled(false);\n }\n\n /**\n * Gets the current date and time of the device.\n * @returns The current date and time.\n */\n async datetime(): Promise<Date> {\n const time = await this.fetch('/management/datetime', {\n schema: v.object({ epoch_seconds: v.number() }),\n });\n return new Date(time.epoch_seconds * 1000);\n }\n\n /**\n * Sets the date and time of the device.\n *\n * This will only work if the device is not connected to the internet.\n *\n * @param datetime The date and time to set.\n */\n setDatetime(datetime: Date): Promise<void> {\n return this.fetch('/management/datetime', {\n method: 'POST',\n body: { epoch_seconds: Math.floor(datetime.getTime() / 1000) },\n parseResponse: () => {},\n });\n }\n\n /**\n * Gets a list of all projects.\n * @returns An array of projects.\n */\n getProjects() {\n return this.fetch('/management/projects', { schema: v.array(project) });\n }\n\n /**\n * Creates a new project.\n * @param data The project creation data.\n */\n createProject(newProject: CreateProject) {\n return this.fetch('/management/projects', {\n method: 'POST',\n body: newProject,\n schema: project,\n });\n }\n\n /**\n * Patches an existing project.\n * @param projectId The ID or name of the project to patch.\n * @param data The data to patch the project with.\n */\n updateProject(projectId: string, data: Project) {\n return this.fetch(`/management/projects/${projectId}`, {\n method: 'PATCH',\n body: data,\n schema: project,\n });\n }\n\n /**\n * Runs a project.\n * @param projectId The ID or name of the project to run.\n */\n runProject(projectId: string) {\n return this.fetch(`/management/projects/${projectId}/run`, { method: 'POST' });\n }\n\n /**\n * Stops a running project.\n * @param projectId The ID or name of the project to stop.\n */\n stopProject(projectId: string) {\n return this.fetch(`/management/projects/${projectId}/stop`, { method: 'POST' });\n }\n\n /**\n * Deletes a project.\n * @param projectId The ID or name of the project to delete.\n */\n deleteProject(projectId: string) {\n return this.fetch(`/management/projects/${projectId}`, { method: 'DELETE' });\n }\n\n /**\n * Uploads a firmware bundle to the device and inspects it.\n * The bundle is staged for installation but not installed yet.\n * @param file The firmware bundle file (.raucb).\n * @param filename Optional filename for the bundle. Defaults to 'bundle.raucb'.\n * @returns Bundle metadata including version information.\n */\n upload_bundle(file: Blob, filename = 'bundle.raucb') {\n return this.fetch('/management/update/upload', {\n method: 'POST',\n body: file,\n headers: { 'Content-Type': 'application/octet-stream', 'X-Bundle-Filename': filename },\n serializeBody: (b) => b as any,\n timeout: 600_000,\n schema: bundleInfo,\n });\n }\n\n /**\n * Gets metadata for the currently staged firmware bundle.\n * @returns Bundle metadata including version information.\n */\n bundle_info() {\n return this.fetch('/management/update/bundle-info', { schema: bundleInfo });\n }\n\n /**\n * Installs a previously uploaded firmware bundle.\n * @returns The install response with message and bundle name.\n */\n install_update() {\n return this.fetch('/management/update/install', { method: 'POST', schema: installResponse });\n }\n\n /**\n * Gets the current firmware update status.\n * @returns The update status including state, progress, message and error.\n */\n update_status() {\n return this.fetch('/management/update/status', { schema: updateStatus });\n }\n\n /**\n * Reboots the device.\n * @returns The reboot response message.\n */\n reboot() {\n return this.fetch('/management/reboot', { method: 'POST', schema: rebootResponse });\n }\n}\n"],"mappings":"2CAGA,IAAY,EAAL,SAAA,EAAA,OACL,GAAA,IAAA,MACA,EAAA,MAAA,QACA,EAAA,MAAA,QACA,EAAA,IAAA,MACA,EAAA,IAAA,MACA,EAAA,KAAA,QACF,EAAA,CAAA,CAAA,EACA,MAAM,EAAyB,EAAE,KAAK,CAA0B,EAE1D,EAAe,EAAE,OAAO,CAC5B,IAAK,EAAE,KAAK,EAAE,OAAO,EAAG,EAAE,SAAS,GAAG,EAAG,EAAE,SAAS,EAAE,CAAC,EACvD,IAAK,EAAE,KAAK,EAAE,OAAO,EAAG,EAAE,SAAS,GAAG,EAAG,EAAE,SAAS,EAAE,CAAC,CACzD,CAAC,EAEK,EAAe,EAAE,OAAO,CAAE,IAAK,EAAE,OA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AAW,EAAmB,CAC5B,OAAO,KAAK,MAAM,wBAAwB,EAAU,MAAO,CAAE,OAAQ,MAAO,CAAC,CAC/E,CAMA,YAAY,EAAmB,CAC7B,OAAO,KAAK,MAAM,wBAAwB,EAAU,OAAQ,CAAE,OAAQ,MAAO,CAAC,CAChF,CAMA,cAAc,EAAmB,CAC/B,OAAO,KAAK,MAAM,wBAAwB,IAAa,CAAE,OAAQ,QAAS,CAAC,CAC7E,CASA,cAAc,EAAY,EAAW,eAAgB,CACnD,OAAO,KAAK,MAAM,4BAA6B,CAC7C,OAAQ,OACR,KAAM,EACN,QAAS,CAAE,eAAgB,2BAA4B,oBAAqB,CAAS,EACrF,cAAgB,GAAM,EACtB,QAAS,IACT,OAAQ,CACV,CAAC,CACH,CAMA,aAAc,CACZ,OAAO,KAAK,MAAM,iCAAkC,CAAE,OAAQ,CAAW,CAAC,CAC5E,CAMA,gBAAiB,CACf,OAAO,KAAK,MAAM,6BAA8B,CAAE,OAAQ,OAAQ,OAAQ,CAAgB,CAAC,CAC7F,CAMA,eAAgB,CACd,OAAO,KAAK,MAAM,4BAA6B,CAAE,OAAQ,CAAa,CAAC,CACzE,CAMA,QAAS,CACP,OAAO,KAAK,MAAM,qBAAsB,CAAE,OAAQ,OAAQ,OAAQ,CAAe,CAAC,CACpF,CACF"}
|
|
1
|
+
{"version":3,"file":"management.mjs","names":[],"sources":["../src/api/management.ts"],"sourcesContent":["import { type UpFetch } from 'up-fetch';\nimport * as v from 'valibot';\n\nexport enum CommunicationInterfaceType {\n Can = 'can',\n Rs232 = 'rs232',\n Rs485 = 'rs485',\n I2c = 'i2c',\n Spi = 'spi',\n Uart = 'uart',\n}\nconst communicationInterface = v.enum(CommunicationInterfaceType);\n\nconst voltageRange = v.object({\n min: v.pipe(v.number(), v.minValue(-24), v.maxValue(24)),\n max: v.pipe(v.number(), v.minValue(-24), v.maxValue(24)),\n});\n\nconst currentRange = v.object({ max: v.number() });\n\nconst ioCapabilities = v.object({\n count: v.pipe(v.number(), v.minValue(1)),\n input_voltage: voltageRange,\n output_voltage: voltageRange,\n});\n\nconst relaysCapabilities = v.object({\n count: v.pipe(v.number(), v.minValue(0)),\n max_current: v.number(),\n max_voltage: v.number(),\n on_resistance: v.pipe(v.number(), v.minValue(0)),\n});\n\nconst usbCapability = v.object({\n type: v.picklist(['3.0', '2.0']),\n count: v.pipe(v.number(), v.minValue(1)),\n});\n\nconst ethernetCapability = v.object({\n type: v.picklist(['1000BASE-T', '100BASE-T', '10BASE-T']),\n count: v.pipe(v.number(), v.minValue(1)),\n});\n\nconst communicationCapability = v.object({\n type: communicationInterface,\n count: v.pipe(v.number(), v.minValue(1)),\n});\n\nconst powerSupplyCapabilities = v.object({\n count: v.pipe(v.number(), v.minValue(1)),\n output_voltage: voltageRange,\n current: currentRange,\n});\n\nconst currentMeasurementCapabilities = v.object({\n type: v.picklist(['low_precision', 'high_precision']),\n source: v.string(),\n resolution: v.pipe(v.number(), v.minValue(0)),\n});\n\nconst screenSize = v.object({\n width: v.pipe(v.number(), v.minValue(1)),\n height: v.pipe(v.number(), v.minValue(1)),\n});\n\nconst displayCapabilities = v.object({ type: v.string(), size: screenSize });\n\nconst inputCapabilities = v.object({ count: v.pipe(v.number(), v.minValue(0)), type: v.string() });\n\nconst audioCapabilities = v.object({ count: v.pipe(v.number(), v.minValue(0)), type: v.string() });\n\nconst hmiCapabilities = v.object({\n display: displayCapabilities,\n input: inputCapabilities,\n speaker: audioCapabilities,\n});\n\nconst capabilities = v.object({\n io: ioCapabilities,\n relays: relaysCapabilities,\n usb_ports: v.array(usbCapability),\n ethernet: v.array(ethernetCapability),\n communication: v.array(communicationCapability),\n power_supply: powerSupplyCapabilities,\n current_measurement: v.array(currentMeasurementCapabilities),\n hmi: hmiCapabilities,\n});\n\nconst info = v.object({\n model: v.string(),\n hostname: v.string(),\n serial_number: v.string(),\n firmware_version: v.string(),\n firmware_commit: v.string(),\n hardware_version: v.optional(v.number()),\n disk_used: v.number(),\n disk_total: v.number(),\n docker_used: v.number(),\n capabilities: capabilities,\n});\nexport type Information = v.InferOutput<typeof info>;\n\nconst projectStatus = v.picklist(['idle', 'running', 'error']);\nconst projectEventState = v.picklist(['created', 'started', 'stopped', 'removed', 'error']);\nconst portProtocol = v.picklist(['tcp', 'udp']);\nconst port = v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(65535));\nexport const portMapping = v.object({ host: port, container: port, proto: portProtocol });\nexport type PortMapping = v.InferOutput<typeof portMapping>;\nconst authorizedKey = v.pipe(\n v.string(),\n v.trim(),\n v.regex(/^(ssh-|ecdsa-sha2-|sk-ssh-|sk-ecdsa-)/, 'Not a recognized SSH public key'),\n);\nexport const runMode = v.picklist(['normal', 'development']);\nexport type RunMode = v.InferOutput<typeof runMode>;\n\nexport const project = v.object({\n name: v.string(),\n path: v.string(),\n id: v.string(),\n image: v.string(),\n is_default: v.boolean(),\n ports: v.optional(v.array(portMapping), []),\n state: projectStatus,\n mode: v.optional(runMode),\n});\nexport type Project = v.InferOutput<typeof project>;\n\n// Merged management.project realtime event, discriminated on `change`.\nexport const projectEvent = v.variant('change', [\n v.object({ change: v.literal('state_changed'), id: v.string(), state: projectEventState }),\n v.object({ change: v.literal('renamed'), id: v.string(), name: v.string() }),\n v.object({ change: v.literal('default_changed'), id: v.string(), is_default: v.boolean() }),\n]);\nexport type ProjectEvent = v.InferOutput<typeof projectEvent>;\n\nconst projectPatch = v.partial(v.pick(project, ['name', 'is_default']));\nexport type ProjectPatch = v.InferOutput<typeof projectPatch>;\n\nconst createProject = v.object({ name: v.string(), image: v.string() });\nexport type CreateProject = v.InferOutput<typeof createProject>;\n\nconst bundleInfo = v.object({\n bundle: v.string(),\n version: v.string(),\n compatible: v.string(),\n description: v.string(),\n});\nexport type BundleInfo = v.InferOutput<typeof bundleInfo>;\n\nconst installResponse = v.object({ message: v.string(), bundle: v.string() });\nexport type InstallResponse = v.InferOutput<typeof installResponse>;\n\nexport const updateStatus = v.object({\n state: v.picklist(['idle', 'installing', 'failed']),\n progress: v.number(),\n message: v.string(),\n error: v.string(),\n});\nexport type UpdateStatus = v.InferOutput<typeof updateStatus>;\n\nconst rebootResponse = v.object({ message: v.string() });\nexport type RebootResponse = v.InferOutput<typeof rebootResponse>;\n\nconst finiteNumber = v.pipe(v.number(), v.finite());\nconst positiveFiniteNumber = v.pipe(v.number(), v.finite(), v.minValue(Number.MIN_VALUE));\nconst channelId = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(31));\nconst relayId = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(7));\nconst usbPortId = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(1));\nconst calibrationStatus = v.picklist(['pass', 'fail']);\n\nconst calibrationPoint = v.object({\n set: finiteNumber,\n measured: finiteNumber,\n reading: v.optional(finiteNumber),\n});\nexport type CalibrationPoint = v.InferOutput<typeof calibrationPoint>;\n\nconst channelCalibration = v.object({\n channel: channelId,\n points: v.array(calibrationPoint),\n max_error: finiteNumber,\n avg_error: finiteNumber,\n});\nexport type ChannelCalibration = v.InferOutput<typeof channelCalibration>;\n\nconst dutPsuCalibration = v.object({\n voltage: v.object({\n points: v.array(calibrationPoint),\n max_error: finiteNumber,\n avg_error: finiteNumber,\n }),\n current: v.object({\n load_ohms: positiveFiniteNumber,\n points: v.array(calibrationPoint),\n max_error: finiteNumber,\n avg_error: finiteNumber,\n }),\n});\nexport type DutPsuCalibration = v.InferOutput<typeof dutPsuCalibration>;\n\nconst currentTestResult = v.object({\n load_ohms: positiveFiniteNumber,\n voltage_applied: finiteNumber,\n measured_current: finiteNumber,\n expected_current: finiteNumber,\n error_percent: finiteNumber,\n});\n/** @deprecated See {@link currentTestResult}. */\nexport type CurrentTestResult = v.InferOutput<typeof currentTestResult>;\n\nconst relayTestResult = v.object({\n relay: relayId,\n status: calibrationStatus,\n test_voltage: finiteNumber,\n closed_current: finiteNumber,\n open_current: finiteNumber,\n calibration: v.optional(channelCalibration),\n});\nexport type RelayTestResult = v.InferOutput<typeof relayTestResult>;\n\nconst usbTestResult = v.object({\n port: usbPortId,\n status: calibrationStatus,\n voltage: finiteNumber,\n /** @deprecated Legacy field; only present on calibrations from older devices. */\n current_tests: v.optional(v.array(currentTestResult)),\n});\nexport type UsbTestResult = v.InferOutput<typeof usbTestResult>;\n\nexport const calibrationData = v.object({\n schema_version: v.literal(1),\n tool_version: v.string(),\n device_id: v.string(),\n timestamp: v.string(),\n firmware_version: v.string(),\n dac: v.array(channelCalibration),\n adc_positive: v.array(channelCalibration),\n adc_negative: v.optional(v.array(channelCalibration)),\n dut_psu: dutPsuCalibration,\n relays: v.array(relayTestResult),\n usb: v.array(usbTestResult),\n});\nexport type CalibrationData = v.InferOutput<typeof calibrationData>;\n\nexport const calibrationState = v.object({\n enabled: v.boolean(),\n loaded: v.boolean(),\n last_error: v.optional(v.nullable(v.string())),\n calibrated_at: v.optional(v.nullable(v.string())),\n});\nexport type CalibrationState = v.InferOutput<typeof calibrationState>;\n\nconst calibrationStatePatch = v.object({ enabled: v.boolean() });\n\n/** @hideconstructor */\nexport class ManagementApi {\n constructor(private readonly fetch: UpFetch) {}\n\n /**\n * Gets device information and capabilities.\n * @returns The device information.\n */\n info() {\n return this.fetch('/management/info', { schema: info });\n }\n\n /**\n * Gets the loaded calibration data.\n * @returns The canonical calibration data stored on the device.\n */\n get_calibration(): Promise<CalibrationData> {\n return this.fetch('/management/calibration', { schema: calibrationData });\n }\n\n /**\n * Uploads and activates calibration data.\n * @param data The full calibration report to store on the device.\n */\n set_calibration(data: CalibrationData): Promise<CalibrationData> {\n return this.fetch('/management/calibration', {\n method: 'PUT',\n body: v.parse(calibrationData, data),\n schema: calibrationData,\n });\n }\n\n /**\n * Gets runtime calibration enable/load state.\n */\n get_calibration_state(): Promise<CalibrationState> {\n return this.fetch('/management/calibration/state', { schema: calibrationState });\n }\n\n /**\n * Enables or disables runtime calibration correction.\n * @param enabled Whether calibration correction should be applied.\n */\n set_calibration_enabled(enabled: boolean): Promise<CalibrationState> {\n return this.fetch('/management/calibration/state', {\n method: 'PATCH',\n body: v.parse(calibrationStatePatch, { enabled }),\n schema: calibrationState,\n });\n }\n\n /** Enables runtime calibration correction. */\n enable_calibration(): Promise<CalibrationState> {\n return this.set_calibration_enabled(true);\n }\n\n /** Disables runtime calibration correction. */\n disable_calibration(): Promise<CalibrationState> {\n return this.set_calibration_enabled(false);\n }\n\n /**\n * Gets the current date and time of the device.\n * @returns The current date and time.\n */\n async datetime(): Promise<Date> {\n const time = await this.fetch('/management/datetime', {\n schema: v.object({ epoch_seconds: v.number() }),\n });\n return new Date(time.epoch_seconds * 1000);\n }\n\n /**\n * Sets the date and time of the device.\n *\n * This will only work if the device is not connected to the internet.\n *\n * @param datetime The date and time to set.\n */\n setDatetime(datetime: Date): Promise<void> {\n return this.fetch('/management/datetime', {\n method: 'POST',\n body: { epoch_seconds: Math.floor(datetime.getTime() / 1000) },\n parseResponse: () => {},\n });\n }\n\n /**\n * Gets a list of all projects.\n * @returns An array of projects.\n */\n getProjects() {\n return this.fetch('/management/projects', { schema: v.array(project) });\n }\n\n /**\n * Gets a single project by id.\n * @param projectId The project slug id.\n * @returns The project info.\n */\n getProject(projectId: string) {\n return this.fetch(`/management/projects/${projectId}`, { schema: project });\n }\n\n /**\n * Creates a new project.\n * @param data The project creation data.\n */\n createProject(newProject: CreateProject) {\n return this.fetch('/management/projects', {\n method: 'POST',\n body: newProject,\n timeout: 30_000,\n schema: project,\n });\n }\n\n /**\n * Imports a project from a container image archive (.tar / .tar.gz).\n * @param file The image archive to import.\n * @param name The project name (sent percent-encoded; the server decodes it).\n * @returns The created project.\n */\n importProject(file: Blob, name: string) {\n return this.fetch('/management/projects/import', {\n method: 'POST',\n body: file,\n headers: { 'Content-Type': 'application/x-tar', 'X-Project-Name': encodeURIComponent(name) },\n serializeBody: (b) => b as any,\n timeout: 600_000,\n schema: project,\n });\n }\n\n /**\n * Patches an existing project.\n * @param projectId The project slug id.\n * @param data The data to patch the project with.\n */\n updateProject(projectId: string, data: ProjectPatch) {\n return this.fetch(`/management/projects/${projectId}`, {\n method: 'PATCH',\n body: v.parse(projectPatch, data),\n schema: project,\n });\n }\n\n /**\n * Runs a project.\n * @param projectId The project slug id.\n * @param mode The run mode: 'normal' (default) or 'development' (starts sshd).\n */\n runProject(projectId: string, mode: RunMode = 'normal') {\n return this.fetch(`/management/projects/${projectId}/run`, {\n method: 'POST',\n body: { mode },\n timeout: 30_000,\n });\n }\n\n /**\n * Stops a running project.\n * @param projectId The project slug id.\n */\n stopProject(projectId: string) {\n return this.fetch(`/management/projects/${projectId}/stop`, {\n method: 'POST',\n timeout: 30_000,\n });\n }\n\n /**\n * Gets the port mappings for a project.\n * @param projectId The project slug id.\n * @returns The project's port mappings.\n */\n getProjectPorts(projectId: string) {\n return this.fetch(`/management/projects/${projectId}/ports`, { schema: v.array(portMapping) });\n }\n\n /**\n * Replaces the full set of port mappings for a project.\n * @param projectId The project slug id.\n * @param ports The complete list of port mappings.\n * @returns The updated port mappings.\n */\n setProjectPorts(projectId: string, ports: PortMapping[]) {\n return this.fetch(`/management/projects/${projectId}/ports`, {\n method: 'PUT',\n body: v.parse(v.array(portMapping), ports),\n timeout: 30_000,\n schema: v.array(portMapping),\n });\n }\n\n /**\n * Adds a single port mapping to a project.\n * @param projectId The project slug id.\n * @param mapping The port mapping to add.\n * @returns The updated port mappings.\n */\n addProjectPort(projectId: string, mapping: PortMapping) {\n return this.fetch(`/management/projects/${projectId}/ports`, {\n method: 'POST',\n body: v.parse(portMapping, mapping),\n timeout: 30_000,\n schema: v.array(portMapping),\n });\n }\n\n /**\n * Removes the port mapping for a host port from a project.\n * @param projectId The project slug id.\n * @param hostPort The host port to unmap.\n */\n deleteProjectPort(projectId: string, hostPort: number) {\n return this.fetch(`/management/projects/${projectId}/ports/${hostPort}`, {\n method: 'DELETE',\n parseResponse: () => {},\n timeout: 30_000,\n });\n }\n\n /**\n * Sets the password of the project's dev user (used for SSH password login in\n * development mode).\n * @param projectId The project slug id.\n * @param password The new password.\n */\n setProjectPassword(projectId: string, password: string) {\n return this.fetch(`/management/projects/${projectId}/password`, {\n method: 'POST',\n body: v.parse(v.object({ password: v.pipe(v.string(), v.minLength(1)) }), { password }),\n parseResponse: () => {},\n timeout: 30_000,\n });\n }\n\n /**\n * Gets the SSH authorized_keys for the project's dev user.\n * @param projectId The project slug id.\n * @returns The list of authorized public keys.\n */\n getProjectAuthorizedKeys(projectId: string) {\n return this.fetch(`/management/projects/${projectId}/authorized_keys`, {\n schema: v.array(v.string()),\n });\n }\n\n /**\n * Replaces the SSH authorized_keys for the project's dev user.\n * @param projectId The project slug id.\n * @param keys The complete list of authorized public keys.\n * @returns The updated list of authorized public keys.\n */\n setProjectAuthorizedKeys(projectId: string, keys: string[]) {\n return this.fetch(`/management/projects/${projectId}/authorized_keys`, {\n method: 'PUT',\n body: v.parse(v.array(authorizedKey), keys),\n timeout: 30_000,\n schema: v.array(v.string()),\n });\n }\n\n /**\n * Deletes a project.\n * @param projectId The project slug id.\n */\n deleteProject(projectId: string) {\n return this.fetch(`/management/projects/${projectId}`, { method: 'DELETE', timeout: 30_000 });\n }\n\n /**\n * Uploads a firmware bundle to the device and inspects it.\n * The bundle is staged for installation but not installed yet.\n * @param file The firmware bundle file (.raucb).\n * @param filename Optional filename for the bundle. Defaults to 'bundle.raucb'.\n * @returns Bundle metadata including version information.\n */\n upload_bundle(file: Blob, filename = 'bundle.raucb') {\n return this.fetch('/management/update/upload', {\n method: 'POST',\n body: file,\n headers: { 'Content-Type': 'application/octet-stream', 'X-Bundle-Filename': filename },\n serializeBody: (b) => b as any,\n timeout: 600_000,\n schema: bundleInfo,\n });\n }\n\n /**\n * Gets metadata for the currently staged firmware bundle.\n * @returns Bundle metadata including version information.\n */\n bundle_info() {\n return this.fetch('/management/update/bundle-info', { schema: bundleInfo });\n }\n\n /**\n * Installs a previously uploaded firmware bundle.\n * @returns The install response with message and bundle name.\n */\n install_update() {\n return this.fetch('/management/update/install', { method: 'POST', schema: installResponse });\n }\n\n /**\n * Gets the current firmware update status.\n * @returns The update status including state, progress, message and error.\n */\n update_status() {\n return this.fetch('/management/update/status', { schema: updateStatus });\n }\n\n /**\n * Reboots the device.\n * @returns The reboot response message.\n */\n reboot() {\n return this.fetch('/management/reboot', { method: 'POST', schema: rebootResponse });\n }\n}\n"],"mappings":"2CAGA,IAAY,EAAL,SAAA,EAAA,OACL,GAAA,IAAA,MACA,EAAA,MAAA,QACA,EAAA,MAAA,QACA,EAAA,IAAA,MACA,EAAA,IAAA,MACA,EAAA,KAAA,QACF,EAAA,CAAA,CAAA,EACA,MAAM,EAAyB,EAAE,KAAK,CAA0B,EAE1D,EAAe,EAAE,OAAO,CAC5B,IAAK,EAAE,KAAK,EAAE,OAAO,EAAG,EAAE,SAAS,GAAG,EAAG,EAAE,SAAS,EAAE,CAAC,EACvD,IAAK,EAAE,KAAK,EAAE,OAAO,EAAG,EAAE,SAAS,GAAG,EAAG,EAAE,SAAS,EAAE,CAAC,CACzD,CAAC,EAEK,EAAe,EAAE,OAAO,CAAE,IAAK,EAAE,OAAO,CAAE,CAAC,EAE3C,EAAiB,EAAE,OAAO,CAC9B,MAAO,EAAE,KAAK,EAAE,OAAO,EAAG,EAAE,SAAS,CAAC,CAAC,EACvC,cAAe,EACf,eAAgB,CAClB,CAAC,EAEK,EAAqB,EAAE,OAAO,CAClC,MAAO,EAAE,KAAK,EAAE,OAAO,EAAG,EAAE,SAAS,CAAC,CAAC,EACvC,YAAa,EAAE,OAAO,EACtB,YAAa,EAAE,OAAO,EACtB,cAAe,EAAE,KAAK,EAAE,OAAO,EAAG,EAAE,SAAS,CAAC,CAAC,CACjD,CAAC,EAEK,EAAgB,EAAE,OAAO,CAC7B,KAAM,EAAE,SAAS,CAAC,MAAO,KAAK,CAAC,EAC/B,MAAO,EAAE,KAAK,EAAE,OAAO,EAAG,EAAE,SAAS,CAAC,CAAC,CACzC,CAAC,EAEK,EAAqB,EAAE,OAAO,CAClC,KAAM,EAAE,SAAS,CAAC,aA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AAO,KAAK,MAAM,4BAA6B,CAC7C,OAAQ,OACR,KAAM,EACN,QAAS,CAAE,eAAgB,2BAA4B,oBAAqB,CAAS,EACrF,cAAgB,GAAM,EACtB,QAAS,IACT,OAAQ,CACV,CAAC,CACH,CAMA,aAAc,CACZ,OAAO,KAAK,MAAM,iCAAkC,CAAE,OAAQ,CAAW,CAAC,CAC5E,CAMA,gBAAiB,CACf,OAAO,KAAK,MAAM,6BAA8B,CAAE,OAAQ,OAAQ,OAAQ,CAAgB,CAAC,CAC7F,CAMA,eAAgB,CACd,OAAO,KAAK,MAAM,4BAA6B,CAAE,OAAQ,CAAa,CAAC,CACzE,CAMA,QAAS,CACP,OAAO,KAAK,MAAM,qBAAsB,CAAE,OAAQ,OAAQ,OAAQ,CAAe,CAAC,CACpF,CACF"}
|
package/build/node.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./chunk-CMqjfN_6.cjs"),t=require("./at1000-BuI_g7jF.cjs");let n=require("dns-packet");n=e.t(n,1);let r=require("node:events"),i=require("node:util");i=e.t(i,1);let a=require("ip-address");a=e.t(a,1);let o=require("node:os");o=e.t(o,1);let s=require("node:dgram");s=e.t(s,1);const c=`224.0.0.251`,l=5353,u=`IPv4`,d=`IPv6`,f=[u,4,d,6];var p=class e{static getInterfaces(t){return t?e.getInterfacesFromStrings(t):e.getAllInterfaces()}static getAllInterfaces(){let e=[],t=[],n=o.default.networkInterfaces();for(let[r,i]of Object.entries(n))t.includes(r)||(t.push(r),i?.forEach(t=>{t.internal||!f.includes(t.family)||/^(2002|2001):/gi.exec(t.address)||e.push({name:r,address:t.address,family:t.family,scopeid:t.scopeid})}));if(!e.length)throw Error(`No usable network interfaces returned by OS.`);return e}static getInterfacesFromStrings(t){let n=Array.isArray(t)?t:[t],r=this.getAllInterfaces().filter(t=>n.reduce((n,r)=>n||!!(e.stringMatchesAddress(r,t.address)||t.name===r),!1));if(!r||!r.length)throw Error(`No usable network interfaces returned by OS.`);return r}static stringMatchesAddress(e,t){let n,r;try{n=new a.default.Address4(e),r=new a.default.Address4(t)}catch{try{n=new a.default.Address6(e),r=new a.default.Address6(t)}catch{return!1}}return n.bigInt()===r.bigInt()}};const m={interfaces:[],reuseAddr:!0,ttl:255,loopback:!0,onMessage:(e,t)=>{console.log(`Message `+e.toString())},socketError:e=>{console.log(`Socket error `+e.message)}};var h=class e{static validateSettings(e){if(!e.multicastAddress)throw Error(`Socket settings require multicastAddress`);if(!e.multicastPort)throw Error(`Socket settings require multicastPort`)}static createMulticastSocket(t){return new Promise((n,r)=>{let i=Object.assign({},m,t);e.validateSettings(i);let o=s.default.createSocket({type:a.default.Address4.isValid(i.multicastAddress)?`udp4`:`udp6`,reuseAddr:i.reuseAddr}),c=!1;o.on(`error`,e=>{c?i.socketError(e):(o.close(),n({success:!1,error:e}))}).on(`listening`,()=>{c=!0,o.setMulticastTTL(i.ttl??255),o.setMulticastLoopback(i.loopback??!0);let t=e.addMulticastMemberships(o,i);if(!t.memberships.length){c=!1,o.close(),n({success:!1,error:Error(`No interface memberships for multicast address `+i.multicastAddress)});return}n(Object.assign({success:!0},t,{socket:o}))}).on(`message`,(e,t)=>{i.onMessage(e,t)}),o.bind({port:i.multicastPort,exclusive:!1})})}static addMulticastMemberships(t,n){let r=[],i=[],o=a.default.Address4.isValid(n.multicastAddress)?[u,4]:[d,6];return n.interfaces.forEach(a=>{if(o.includes(a.family))try{t.addMembership(n.multicastAddress,e.interfaceAddress(a)),r.push(a)}catch{i.push(a)}}),{memberships:r,failedMemberships:i}}static async createSendSocket(t,n,r,i,a){return new Promise(o=>{let c=[`IPv4`,4].includes(t.family)?`udp4`:`udp6`,l=e.interfaceAddress(t),u=n.srcPort??0,d=!1,f=e=>{let u=s.default.createSocket({type:c,reuseAddr:!!n.reuseAddr,reusePort:!0}),p=!1;u.on(`error`,t=>{p?i(t):(u.close(),e!==0&&!d?(d=!0,a?.(`mDNS send socket bind to ${l}:${e} failed (${t.message}); falling back to ephemeral source port — discovery may be unreliable on strict firewalls.`),f(0)):o({success:!1,error:Error(t.message)}))}).on(`listening`,()=>{p=!0,o({success:!0,iface:t,socket:u,send:u.send.bind(u)})}).on(`message`,(e,n)=>{n.interface=t.name,r(e,n)}).bind(e,l)};f(u)})}static interfaceAddress(e){return[`IPv4`,4].includes(e.family)?e.address:e.scopeid?`${e.address}%${e.scopeid}`:e.address}};const g={reuseAddr:!0,srcPort:5353,interfaces:null,ttl:255,loopback:!0,debug:!1};var _=class extends r.EventEmitter{Config;ready;receiveSockets;sendSockets;interfaces;destroyed;constructor(e){super(),this.Config=Object.assign({},g,e),this.ready=!1,this.receiveSockets=[],this.sendSockets=[]}async init(){try{this.interfaces=p.getInterfaces(this.Config.interfaces||void 0)}catch(e){throw this.emitError(e),e}return this.emitDebug(`Scanner interfaces: ${i.default.inspect(this.interfaces)}`),await this.createReceiveSockets(),await this.createSendSockets(),this.receiveSockets.length&&this.sendSockets.length&&(this.ready=!0),this.ready}async createReceiveSockets(){if(!this.interfaces)return[];let e=this.interfaces.filter(e=>[u,4].includes(e.family)),t=this.interfaces.filter(e=>[d,6].includes(e.family));if(this.emitDebug(`Create receive sockets for${e.length?` IPv4`:``}${e.length&&t.length?` and`:``}${t.length?` IPv6`:``}`),e.length){let t=await h.createMulticastSocket({multicastAddress:c,multicastPort:l,interfaces:e,onMessage:this.onMessage.bind(this),socketError:this.socketError.bind(this)});t.success?this.receiveSockets.push(t):t.error&&this.emitError(t.error.message)}if(t.length){let e=await h.createMulticastSocket({multicastAddress:`FF02::FB`,multicastPort:l,interfaces:t,onMessage:this.onMessage.bind(this),socketError:this.socketError.bind(this)});e.success?this.receiveSockets.push(e):e.error&&this.emitError(e.error.message)}return this.receiveSockets}async createSendSockets(){if(this.interfaces){this.emitDebug(`Create send sockets on ${this.interfaces.length} interfaces/addresses.`);for(let e=0;e<this.interfaces.length;e++){let t=await h.createSendSocket(this.interfaces[e],this.Config,this.onMessage.bind(this),this.socketError.bind(this),this.emitWarn.bind(this));t.success?this.sendSockets.push(t):t.error&&this.emitError(t.error.message)}}}onMessage(e,t){let r;try{r=n.default.decode(e)}catch(e){return this.emitWarn(e)}this.emit(`packet`,r,t)}socketError(e){e.code===`EACCES`||e.code===`EADDRINUSE`||e.code===`EADDRNOTAVAIL`?this.emitError(e):this.emitWarn(e)}query(e,t){let n;if(typeof e==`string`)n=[{name:e,type:t||`ANY`}];else if(Array.isArray(e))n=e;else throw Error(`Query questions must be an array of mDNS query questions.`);let r={type:`query`,questions:n};this.emitDebug(`Send mDNS query: ${i.default.inspect(r)}`),this.send(r)}send(e){if(this.destroyed)return;let t=n.default.encode(e);for(let e=0;e<this.sendSockets.length;e++){let n=this.sendSockets[e];if(n.send&&n.iface)try{n.send(t,0,t.length,l,[`IPv4`,4].includes(n.iface.family)?c:`FF02::FB%`+n.iface.name),this.emitDebug(`Send packet on ${n.iface.address}`)}catch{}}}destroy(){this.destroyed=!0,this.ready=!1,this.removeAllListeners(),this.sendSockets.forEach(e=>{try{e.socket?.close()}catch{}}),this.sendSockets=[],this.receiveSockets.forEach(e=>{try{e.socket?.close()}catch{}}),this.receiveSockets=[]}emitError(e){this.emit(`error`,e)}emitWarn(e){this.emit(`warn`,e)}emitDebug(e){this.Config.debug&&this.emit(`debug`,e)}};const v={debug:!1};var y=class extends r.EventEmitter{Config;scanner;types;namedServices;packetListener;constructor(e,t){super(),this.packetListener=this.onPacket.bind(this),this.scanner=e,this.Config=Object.assign({},v,t),this.types=[],this.namedServices={},this.forwardEvents(this.scanner),this.reset()}reset(){this.removeMDNSListener(this.scanner),this.types=[],this.namedServices={},this.listenMDNSEvents(this.scanner)}forwardEvents(e){e.on(`error`,e=>{this.emitError(e)}).on(`warn`,e=>{this.emitWarn(e)}).on(`debug`,e=>{this.emitDebug(e)})}listenMDNSEvents(e){e.on(`packet`,this.packetListener)}removeMDNSListener(e){e.removeListener(`packet`,this.packetListener)}onPacket(e,t){switch(this.emitDebug(`Received packet type ${e.type} from ${t.address}.`),e.type){case`query`:this.emit(`query`,e,t);break;case`response`:this.emitDebug(`Received response packet from ${t.address} with ${e.answers?e.answers.length:0} answers and ${e.additionals?e.additionals.length:0} additionals.`),e.answers&&this.processAnswers(e.answers,t),e.additionals&&this.processAnswers(e.additionals,t);break}}processAnswers(e,t){this.emitDebug(`Processing answers or additionals...`);let n=this.processSRVAnswers(e);this.processTXTAnswers(e),this.processAAnswers(e),this.processAAAAAnswers(e),this.processPTRAnswers(e,t),n.forEach(e=>{this.emit(`discovered`,{type:`service`,data:this.namedServices[e]})})}processSRVAnswers(e){let t=[];return e.forEach(e=>{if(e.type!==`SRV`)return;this.emitDebug(`Processing SRV answer.`);let n=e.name.toString();t.includes(n)||t.push(n),this.namedServices[n]=this.namedServices[n]||{},this.namedServices[n].service=e,this.namedServices[n].host=e.data.target.toString(),this.namedServices[n].port=e.data.port}),t}processTXTAnswers(e){e.forEach(e=>{if(e.type!==`TXT`)return;this.emitDebug(`Processing TXT answer.`);let t=e.data;if(Array.isArray(t)&&t.length>1){let n=e.name.toString();this.namedServices[n]=this.namedServices[n]||{},this.namedServices[n].txt=this.answerDataToKeyValues(Buffer.concat(t))}else if(Buffer.isBuffer(t)){let n=e.name.toString();this.namedServices[n]=this.namedServices[n]||{},this.namedServices[n].txt=this.answerDataToKeyValues(t)}})}processAAnswers(e){e.forEach(e=>{if(e.type!==`A`)return;this.emitDebug(`Processing A answer.`);let t=e.name.toString(),n=e.data.toString();for(let e in this.namedServices)this.namedServices[e].host===t&&(this.namedServices[e].addresses=this.namedServices[e].addresses||[],this.namedServices[e].addresses.reduce((e,t)=>e||t.address===n,!1)||this.namedServices[e].addresses.push({family:u,address:n}))})}processAAAAAnswers(e){e.forEach(e=>{if(e.type!==`AAAA`)return;this.emitDebug(`Processing AAAA answer.`);let t=e.name.toString(),n=e.data.toString();for(let e in this.namedServices)this.namedServices[e].host===t&&(this.namedServices[e].addresses=this.namedServices[e].addresses||[],this.namedServices[e].addresses.reduce((e,t)=>e||t.address===n,!1)||this.namedServices[e].addresses.push({family:d,address:n}))})}processPTRAnswers(e,t){e.forEach(e=>{if(e.type!==`PTR`)return;this.emitDebug(`Processing PTR answer.`);let n=this.serviceTypeFromPTR(e),r=e.data.toString();n!==r&&(this.namedServices[r]=this.namedServices[r]||{},this.namedServices[r].name=r.replace(`.`+n,``),this.namedServices[r].rinfo=t)})}serviceTypeFromPTR(e){let t=e.data,n=/(?:^|^.+?(?:\.))(_.*)$/gm.exec(t.toString()),r=n?n[1]:t.toString();return this.types.includes(r)||(this.types.push(r),this.emit(`discovered`,{type:`type`,data:r}),this.emitDebug(`Scanning service type ${r}.`),this.scanner.query(r,`ANY`)),r}answerDataToKeyValues(e){let t=[],n={},r=0,i=e[r];for(;i;){let a=e.slice(r+1,r+1+i);t.push(a.toString());let o=/^([^=]+)=([^=]*)$/.exec(a.toString());o&&(n[o[1]]=o[2]),r=r+1+i,i=e[r]}return{strings:t,keyValuePairs:n}}emitError(e){this.emit(`error`,e)}emitWarn(e){this.emit(`warn`,e)}emitDebug(e){this.Config.debug&&this.emit(`debug`,e)}};function b(e){return e.startsWith(`192.168.`)?0:e.startsWith(`169.254.`)?1:2}const x=async(e=500)=>{e<10&&(e=10);let n=new _({debug:!0}),r=new y(n);if(r.on(`error`,e=>{if(!e.includes(`bind ENOENT`))throw Error(e)}),!await n.init())throw Error(`Failed to initialize mDNS scanner`);n.query(`_at1000_server._tcp.local`),await new Promise(t=>setTimeout(t,e));let i=[...new Set(Object.values(r.namedServices).filter(e=>e!==void 0&&e.service!==void 0).filter(e=>e.service.name.endsWith(`_at1000_server._tcp.local`)).flatMap(e=>{let t=e.addresses??[],n=t.filter(e=>e.family===`IPv4`).map(e=>e.address),r=t.filter(e=>e.family===`IPv6`).map(e=>e.address);return[...n,...r]}))];n.destroy();let a=(await Promise.allSettled(i.map(e=>t.t.create(e)))).filter(e=>e.status===`fulfilled`).map(e=>e.value),o=new Map;for(let e of a){let t=o.get(e.info.hostname);t?b(e.host)<b(t.host)&&o.set(e.info.hostname,e):o.set(e.info.hostname,e)}return[...o.values()]};var S=class extends t.t{static apiVersion=t.n;static findDevices(e=500){return x(e)}};exports.AT1000=S;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./chunk-CMqjfN_6.cjs"),t=require("./package-Dd7S_M7n.cjs"),n=require("./at1000-BAZbVgLx.cjs");let r=require("dns-packet");r=e.t(r,1);let i=require("node:events"),a=require("node:util");a=e.t(a,1);let o=require("ip-address");o=e.t(o,1);let s=require("node:os");s=e.t(s,1);let c=require("node:dgram");c=e.t(c,1);const l=`224.0.0.251`,u=5353,d=`IPv4`,f=`IPv6`,p=[d,4,f,6];var m=class e{static getInterfaces(t){return t?e.getInterfacesFromStrings(t):e.getAllInterfaces()}static getAllInterfaces(){let e=[],t=[],n=s.default.networkInterfaces();for(let[r,i]of Object.entries(n))t.includes(r)||(t.push(r),i?.forEach(t=>{t.internal||!p.includes(t.family)||/^(2002|2001):/gi.exec(t.address)||e.push({name:r,address:t.address,family:t.family,scopeid:t.scopeid})}));if(!e.length)throw Error(`No usable network interfaces returned by OS.`);return e}static getInterfacesFromStrings(t){let n=Array.isArray(t)?t:[t],r=this.getAllInterfaces().filter(t=>n.reduce((n,r)=>n||!!(e.stringMatchesAddress(r,t.address)||t.name===r),!1));if(!r||!r.length)throw Error(`No usable network interfaces returned by OS.`);return r}static stringMatchesAddress(e,t){let n,r;try{n=new o.default.Address4(e),r=new o.default.Address4(t)}catch{try{n=new o.default.Address6(e),r=new o.default.Address6(t)}catch{return!1}}return n.bigInt()===r.bigInt()}};const h={interfaces:[],reuseAddr:!0,ttl:255,loopback:!0,onMessage:(e,t)=>{console.log(`Message `+e.toString())},socketError:e=>{console.log(`Socket error `+e.message)}};var g=class e{static validateSettings(e){if(!e.multicastAddress)throw Error(`Socket settings require multicastAddress`);if(!e.multicastPort)throw Error(`Socket settings require multicastPort`)}static createMulticastSocket(t){return new Promise((n,r)=>{let i=Object.assign({},h,t);e.validateSettings(i);let a=c.default.createSocket({type:o.default.Address4.isValid(i.multicastAddress)?`udp4`:`udp6`,reuseAddr:i.reuseAddr}),s=!1;a.on(`error`,e=>{s?i.socketError(e):(a.close(),n({success:!1,error:e}))}).on(`listening`,()=>{s=!0,a.setMulticastTTL(i.ttl??255),a.setMulticastLoopback(i.loopback??!0);let t=e.addMulticastMemberships(a,i);if(!t.memberships.length){s=!1,a.close(),n({success:!1,error:Error(`No interface memberships for multicast address `+i.multicastAddress)});return}n(Object.assign({success:!0},t,{socket:a}))}).on(`message`,(e,t)=>{i.onMessage(e,t)}),a.bind({port:i.multicastPort,exclusive:!1})})}static addMulticastMemberships(t,n){let r=[],i=[],a=o.default.Address4.isValid(n.multicastAddress)?[d,4]:[f,6];return n.interfaces.forEach(o=>{if(a.includes(o.family))try{t.addMembership(n.multicastAddress,e.interfaceAddress(o)),r.push(o)}catch{i.push(o)}}),{memberships:r,failedMemberships:i}}static async createSendSocket(t,n,r,i,a){return new Promise(o=>{let s=[`IPv4`,4].includes(t.family)?`udp4`:`udp6`,l=e.interfaceAddress(t),u=n.srcPort??0,d=!1,f=e=>{let u=c.default.createSocket({type:s,reuseAddr:!!n.reuseAddr,reusePort:!0}),p=!1;u.on(`error`,t=>{p?i(t):(u.close(),e!==0&&!d?(d=!0,a?.(`mDNS send socket bind to ${l}:${e} failed (${t.message}); falling back to ephemeral source port — discovery may be unreliable on strict firewalls.`),f(0)):o({success:!1,error:Error(t.message)}))}).on(`listening`,()=>{p=!0,o({success:!0,iface:t,socket:u,send:u.send.bind(u)})}).on(`message`,(e,n)=>{n.interface=t.name,r(e,n)}).bind(e,l)};f(u)})}static interfaceAddress(e){return[`IPv4`,4].includes(e.family)?e.address:e.scopeid?`${e.address}%${e.name}`:e.address}};const _={reuseAddr:!0,srcPort:5353,interfaces:null,ttl:255,loopback:!0,debug:!1};var v=class extends i.EventEmitter{Config;ready;receiveSockets;sendSockets;interfaces;destroyed;constructor(e){super(),this.Config=Object.assign({},_,e),this.ready=!1,this.receiveSockets=[],this.sendSockets=[]}async init(){try{this.interfaces=m.getInterfaces(this.Config.interfaces||void 0)}catch(e){throw this.emitError(e),e}return this.emitDebug(`Scanner interfaces: ${a.default.inspect(this.interfaces)}`),await this.createReceiveSockets(),await this.createSendSockets(),this.receiveSockets.length&&this.sendSockets.length&&(this.ready=!0),this.ready}async createReceiveSockets(){if(!this.interfaces)return[];let e=this.interfaces.filter(e=>[d,4].includes(e.family)),t=this.interfaces.filter(e=>[f,6].includes(e.family));if(this.emitDebug(`Create receive sockets for${e.length?` IPv4`:``}${e.length&&t.length?` and`:``}${t.length?` IPv6`:``}`),e.length){let t=await g.createMulticastSocket({multicastAddress:l,multicastPort:u,interfaces:e,onMessage:this.onMessage.bind(this),socketError:this.socketError.bind(this)});t.success?this.receiveSockets.push(t):t.error&&this.emitWarn(t.error.message)}if(t.length){let e=await g.createMulticastSocket({multicastAddress:`FF02::FB`,multicastPort:u,interfaces:t,onMessage:this.onMessage.bind(this),socketError:this.socketError.bind(this)});e.success?this.receiveSockets.push(e):e.error&&this.emitWarn(e.error.message)}return this.receiveSockets}async createSendSockets(){if(this.interfaces){this.emitDebug(`Create send sockets on ${this.interfaces.length} interfaces/addresses.`);for(let e=0;e<this.interfaces.length;e++){let t=await g.createSendSocket(this.interfaces[e],this.Config,this.onMessage.bind(this),this.socketError.bind(this),this.emitWarn.bind(this));t.success?this.sendSockets.push(t):t.error&&this.emitWarn(t.error.message)}}}onMessage(e,t){let n;try{n=r.default.decode(e)}catch(e){return this.emitWarn(e)}this.emit(`packet`,n,t)}socketError(e){e.code===`EACCES`||e.code===`EADDRINUSE`||e.code===`EADDRNOTAVAIL`?this.emitError(e):this.emitWarn(e)}query(e,t){let n;if(typeof e==`string`)n=[{name:e,type:t||`ANY`}];else if(Array.isArray(e))n=e;else throw Error(`Query questions must be an array of mDNS query questions.`);let r={type:`query`,questions:n};this.emitDebug(`Send mDNS query: ${a.default.inspect(r)}`),this.send(r)}send(e){if(this.destroyed)return;let t=r.default.encode(e);for(let e=0;e<this.sendSockets.length;e++){let n=this.sendSockets[e];if(n.send&&n.iface)try{n.send(t,0,t.length,u,[`IPv4`,4].includes(n.iface.family)?l:`FF02::FB%`+n.iface.name),this.emitDebug(`Send packet on ${n.iface.address}`)}catch{}}}destroy(){this.destroyed=!0,this.ready=!1,this.removeAllListeners(),this.sendSockets.forEach(e=>{try{e.socket?.close()}catch{}}),this.sendSockets=[],this.receiveSockets.forEach(e=>{try{e.socket?.close()}catch{}}),this.receiveSockets=[]}emitError(e){this.emit(`error`,e)}emitWarn(e){this.emit(`warn`,e)}emitDebug(e){this.Config.debug&&this.emit(`debug`,e)}};const y={debug:!1};var b=class extends i.EventEmitter{Config;scanner;types;namedServices;packetListener;constructor(e,t){super(),this.packetListener=this.onPacket.bind(this),this.scanner=e,this.Config=Object.assign({},y,t),this.types=[],this.namedServices={},this.forwardEvents(this.scanner),this.reset()}reset(){this.removeMDNSListener(this.scanner),this.types=[],this.namedServices={},this.listenMDNSEvents(this.scanner)}forwardEvents(e){e.on(`error`,e=>{this.emitError(e)}).on(`warn`,e=>{this.emitWarn(e)}).on(`debug`,e=>{this.emitDebug(e)})}listenMDNSEvents(e){e.on(`packet`,this.packetListener)}removeMDNSListener(e){e.removeListener(`packet`,this.packetListener)}onPacket(e,t){switch(this.emitDebug(`Received packet type ${e.type} from ${t.address}.`),e.type){case`query`:this.emit(`query`,e,t);break;case`response`:this.emitDebug(`Received response packet from ${t.address} with ${e.answers?e.answers.length:0} answers and ${e.additionals?e.additionals.length:0} additionals.`),e.answers&&this.processAnswers(e.answers,t),e.additionals&&this.processAnswers(e.additionals,t);break}}processAnswers(e,t){this.emitDebug(`Processing answers or additionals...`);let n=this.processSRVAnswers(e);this.processTXTAnswers(e),this.processAAnswers(e),this.processAAAAAnswers(e),this.processPTRAnswers(e,t),n.forEach(e=>{this.emit(`discovered`,{type:`service`,data:this.namedServices[e]})})}processSRVAnswers(e){let t=[];return e.forEach(e=>{if(e.type!==`SRV`)return;this.emitDebug(`Processing SRV answer.`);let n=e.name.toString();t.includes(n)||t.push(n),this.namedServices[n]=this.namedServices[n]||{},this.namedServices[n].service=e,this.namedServices[n].host=e.data.target.toString(),this.namedServices[n].port=e.data.port}),t}processTXTAnswers(e){e.forEach(e=>{if(e.type!==`TXT`)return;this.emitDebug(`Processing TXT answer.`);let t=e.data;if(Array.isArray(t)&&t.length>1){let n=e.name.toString();this.namedServices[n]=this.namedServices[n]||{},this.namedServices[n].txt=this.answerDataToKeyValues(Buffer.concat(t))}else if(Buffer.isBuffer(t)){let n=e.name.toString();this.namedServices[n]=this.namedServices[n]||{},this.namedServices[n].txt=this.answerDataToKeyValues(t)}})}processAAnswers(e){e.forEach(e=>{if(e.type!==`A`)return;this.emitDebug(`Processing A answer.`);let t=e.name.toString(),n=e.data.toString();for(let e in this.namedServices)this.namedServices[e].host===t&&(this.namedServices[e].addresses=this.namedServices[e].addresses||[],this.namedServices[e].addresses.reduce((e,t)=>e||t.address===n,!1)||this.namedServices[e].addresses.push({family:d,address:n}))})}processAAAAAnswers(e){e.forEach(e=>{if(e.type!==`AAAA`)return;this.emitDebug(`Processing AAAA answer.`);let t=e.name.toString(),n=e.data.toString();for(let e in this.namedServices)this.namedServices[e].host===t&&(this.namedServices[e].addresses=this.namedServices[e].addresses||[],this.namedServices[e].addresses.reduce((e,t)=>e||t.address===n,!1)||this.namedServices[e].addresses.push({family:f,address:n}))})}processPTRAnswers(e,t){e.forEach(e=>{if(e.type!==`PTR`)return;this.emitDebug(`Processing PTR answer.`);let n=this.serviceTypeFromPTR(e),r=e.data.toString();n!==r&&(this.namedServices[r]=this.namedServices[r]||{},this.namedServices[r].name=r.replace(`.`+n,``),this.namedServices[r].rinfo=t)})}serviceTypeFromPTR(e){let t=e.data,n=/(?:^|^.+?(?:\.))(_.*)$/gm.exec(t.toString()),r=n?n[1]:t.toString();return this.types.includes(r)||(this.types.push(r),this.emit(`discovered`,{type:`type`,data:r}),this.emitDebug(`Scanning service type ${r}.`),this.scanner.query(r,`ANY`)),r}answerDataToKeyValues(e){let t=[],n={},r=0,i=e[r];for(;i;){let a=e.slice(r+1,r+1+i);t.push(a.toString());let o=/^([^=]+)=([^=]*)$/.exec(a.toString());o&&(n[o[1]]=o[2]),r=r+1+i,i=e[r]}return{strings:t,keyValuePairs:n}}emitError(e){this.emit(`error`,e)}emitWarn(e){this.emit(`warn`,e)}emitDebug(e){this.Config.debug&&this.emit(`debug`,e)}};function x(e){return e.startsWith(`192.168.`)?0:e.startsWith(`169.254.`)?1:2}const S=async(e=500)=>{e<10&&(e=10);let t=new v({debug:!0}),r=new b(t);if(r.on(`error`,e=>{if(!e.includes(`bind ENOENT`))throw Error(e)}),!await t.init())throw Error(`Failed to initialize mDNS scanner`);t.query(`_at1000_server._tcp.local`),await new Promise(t=>setTimeout(t,e));let i=[...new Set(Object.values(r.namedServices).filter(e=>e!==void 0&&e.service!==void 0).filter(e=>e.service.name.endsWith(`_at1000_server._tcp.local`)).flatMap(e=>{let t=e.addresses??[],n=t.filter(e=>e.family===`IPv4`).map(e=>e.address),r=t.filter(e=>e.family===`IPv6`).map(e=>e.address);return[...n,...r]}))];t.destroy();let a=(await Promise.allSettled(i.map(e=>n.t.create(e)))).filter(e=>e.status===`fulfilled`).map(e=>e.value),o=new Map;for(let e of a){let t=o.get(e.info.hostname);t?x(e.host)<x(t.host)&&o.set(e.info.hostname,e):o.set(e.info.hostname,e)}return[...o.values()]};var C=class extends n.t{static apiVersion=t.t;static findDevices(e=500){return S(e)}};exports.AT1000=C,exports.ApiError=n.n;
|
|
2
2
|
//# sourceMappingURL=node.cjs.map
|