@ikalogic/at1000 0.1.34 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/{at1000-CPP2QQVp.d.mts → at1000-BXtrf8Rt.d.cts} +7 -7
- package/build/{at1000-D0rR4HmP.d.cts.map → at1000-BXtrf8Rt.d.cts.map} +1 -1
- package/build/at1000-BuI_g7jF.cjs +3 -0
- package/build/{at1000-DfziElfg.cjs.map → at1000-BuI_g7jF.cjs.map} +1 -1
- package/build/{at1000-CfhKJdSC.mjs → at1000-DVDltAyk.mjs} +2 -2
- package/build/{at1000-CfhKJdSC.mjs.map → at1000-DVDltAyk.mjs.map} +1 -1
- package/build/{at1000-D0rR4HmP.d.cts → at1000-D_rOUVFH.d.mts} +7 -7
- package/build/{at1000-CPP2QQVp.d.mts.map → at1000-D_rOUVFH.d.mts.map} +1 -1
- package/build/browser.cjs +1 -1
- package/build/browser.cjs.map +1 -1
- package/build/browser.d.cts +1 -1
- package/build/browser.d.cts.map +1 -1
- package/build/browser.d.mts +1 -1
- package/build/browser.d.mts.map +1 -1
- package/build/browser.mjs +1 -1
- package/build/browser.mjs.map +1 -1
- package/build/{chunk-Bmb41Sf3.cjs → chunk-CMqjfN_6.cjs} +1 -1
- package/build/{com-BjLONerN.d.cts → com-CBhjFJPB.d.cts} +7 -2
- package/build/com-CBhjFJPB.d.cts.map +1 -0
- package/build/{com-DwQrU-7L.d.mts → com-CBhjFJPB.d.mts} +7 -2
- package/build/com-CBhjFJPB.d.mts.map +1 -0
- package/build/com.cjs +1 -1
- package/build/com.cjs.map +1 -1
- package/build/com.d.cts +1 -1
- package/build/com.d.mts +1 -1
- package/build/com.mjs +1 -1
- package/build/com.mjs.map +1 -1
- package/build/common-BSabSaAU.cjs +2 -0
- package/build/{common-PXzrB8CC.cjs.map → common-BSabSaAU.cjs.map} +1 -1
- package/build/{common-Cc9ZDx5b.d.mts → common-BY1vXz1l.d.cts} +1 -1
- package/build/{common-Cc9ZDx5b.d.mts.map → common-BY1vXz1l.d.cts.map} +1 -1
- package/build/{common-DWQyDOs5.d.cts → common-BY1vXz1l.d.mts} +1 -1
- package/build/{common-DWQyDOs5.d.cts.map → common-BY1vXz1l.d.mts.map} +1 -1
- package/build/{common-DzTRbz1N.mjs → common-Ce3FeF-Q.mjs} +1 -1
- package/build/{common-DzTRbz1N.mjs.map → common-Ce3FeF-Q.mjs.map} +1 -1
- package/build/{gpio-BvBm3GF2.d.cts → gpio-DNrdX-QV.d.cts} +3 -3
- package/build/gpio-DNrdX-QV.d.cts.map +1 -0
- package/build/{gpio-COBjpH3q.d.mts → gpio-DchxrXWK.d.mts} +3 -3
- package/build/gpio-DchxrXWK.d.mts.map +1 -0
- package/build/gpio.cjs +1 -1
- package/build/gpio.cjs.map +1 -1
- package/build/gpio.d.cts +3 -3
- package/build/gpio.d.mts +3 -3
- package/build/gpio.mjs +1 -1
- package/build/gpio.mjs.map +1 -1
- package/build/{hmi-BAaIE12L.d.mts → hmi-DszM-Hfp.d.cts} +1 -1
- package/build/hmi-DszM-Hfp.d.cts.map +1 -0
- package/build/{hmi-C5ga9KYh.d.cts → hmi-DszM-Hfp.d.mts} +1 -1
- package/build/hmi-DszM-Hfp.d.mts.map +1 -0
- package/build/hmi.cjs +1 -1
- package/build/hmi.cjs.map +1 -1
- package/build/hmi.d.cts +1 -1
- package/build/hmi.d.mts +1 -1
- package/build/hmi.mjs +1 -1
- package/build/hmi.mjs.map +1 -1
- package/build/{management-B6XF1gCN.d.mts → management-C0iQha23.d.cts} +6 -3
- package/build/management-C0iQha23.d.cts.map +1 -0
- package/build/{management-DUeEuVUY.d.cts → management-C0iQha23.d.mts} +6 -3
- package/build/management-C0iQha23.d.mts.map +1 -0
- package/build/management.cjs +1 -1
- package/build/management.cjs.map +1 -1
- package/build/management.d.cts +1 -1
- package/build/management.d.mts +1 -1
- 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 +1 -1
- package/build/node.d.mts +1 -1
- package/build/node.mjs +1 -1
- package/build/node.mjs.map +1 -1
- package/build/{power-BOYFnxXm.d.cts → power-CN_9o_NX.d.mts} +3 -3
- package/build/power-CN_9o_NX.d.mts.map +1 -0
- package/build/{power-BT1cG5Kn.d.mts → power-o75Gjpwf.d.cts} +3 -3
- package/build/power-o75Gjpwf.d.cts.map +1 -0
- package/build/power.cjs +1 -1
- package/build/power.cjs.map +1 -1
- package/build/power.d.cts +3 -3
- package/build/power.d.mts +3 -3
- package/build/power.mjs +1 -1
- package/build/power.mjs.map +1 -1
- package/build/{relays-C-vNqDM-.d.cts → relays-BCn6rQN1.d.cts} +1 -1
- package/build/relays-BCn6rQN1.d.cts.map +1 -0
- package/build/{relays-CbyqFtJP.d.mts → relays-BCn6rQN1.d.mts} +1 -1
- package/build/relays-BCn6rQN1.d.mts.map +1 -0
- package/build/relays.cjs +1 -1
- package/build/relays.cjs.map +1 -1
- package/build/relays.d.cts +1 -1
- package/build/relays.d.mts +1 -1
- package/build/relays.mjs +1 -1
- package/build/relays.mjs.map +1 -1
- package/package.json +10 -10
- package/build/at1000-DfziElfg.cjs +0 -3
- package/build/com-BjLONerN.d.cts.map +0 -1
- package/build/com-DwQrU-7L.d.mts.map +0 -1
- package/build/common-PXzrB8CC.cjs +0 -2
- package/build/gpio-BvBm3GF2.d.cts.map +0 -1
- package/build/gpio-COBjpH3q.d.mts.map +0 -1
- package/build/hmi-BAaIE12L.d.mts.map +0 -1
- package/build/hmi-C5ga9KYh.d.cts.map +0 -1
- package/build/management-B6XF1gCN.d.mts.map +0 -1
- package/build/management-DUeEuVUY.d.cts.map +0 -1
- package/build/power-BOYFnxXm.d.cts.map +0 -1
- package/build/power-BT1cG5Kn.d.mts.map +0 -1
- package/build/relays-C-vNqDM-.d.cts.map +0 -1
- package/build/relays-CbyqFtJP.d.mts.map +0 -1
package/build/hmi.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hmi.mjs","names":[],"sources":["../src/api/hmi.ts"],"sourcesContent":["import type { UpFetch } from 'up-fetch';\nimport * as v from 'valibot';\n\nconst screenText = v.pipe(v.string(), v.maxLength(1024));\nexport type ScreenText = v.InferOutput<typeof screenText>;\n\nconst text = v.object({ text: screenText });\ntype Text = v.InferOutput<typeof text>;\n\nconst optionalHexColor = v.optional(v.pipe(v.string(), v.length(7), v.hexColor()));\nconst color = v.object({\n text: optionalHexColor,\n progress: optionalHexColor,\n background: optionalHexColor,\n});\nexport type Color = v.InferOutput<typeof color>;\n\nconst progressValue = v.pipe(v.number(), v.minValue(0), v.maxValue(100));\nexport type ProgressValue = v.InferOutput<typeof progressValue>;\nconst progress = v.object({ progress: progressValue });\nexport type Progress = v.InferOutput<typeof progress>;\n\nconst playbackConfiguration = v.object({\n sound_id: v.picklist(\n ['success', 'warning', 'failure', 'notification_1', 'notification_2',\n 'imperial_march'] as const,\n ),\n volume: v.pipe(v.number(), v.minValue(0), v.maxValue(100)),\n});\nexport type PlaybackConfiguration = v.InferOutput<typeof playbackConfiguration>;\n\nconst internalKnobEvent = v.object({\n button_pressed: v.boolean(),\n button_held: v.boolean(),\n rotation_delta: v.number(),\n});\nconst knobEvent = v.omit(internalKnobEvent, ['button_held']);\nexport type KnobEvent = v.InferOutput<typeof knobEvent>;\n\n/** @hideconstructor */\nexport class HmiApi {\n constructor(private readonly fetch: UpFetch) {}\n\n /**\n * Resets the HMI.\n */\n reset(): Promise<void> {\n return this.fetch('/hmi/reset', { method: 'POST', parseResponse: () => {} });\n }\n\n /**\n * Access the screen API.\n * @returns The screen instance.\n */\n screen(): Screen {\n return new Screen(this.fetch);\n }\n\n /**\n * Access the audio API.\n * @returns The audio instance.\n */\n audio(): Audio {\n return new Audio(this.fetch);\n }\n\n /**\n * Access the knob API.\n * @returns The knob instance.\n */\n knob(): Knob {\n return new Knob(this.fetch);\n }\n}\n\n/** @hideconstructor */\nexport class Screen {\n constructor(private readonly fetch: UpFetch) {}\n\n /**\n * Prints text to the screen.\n * @param data The text to print.\n * @returns The printed text.\n */\n async print(data: ScreenText): Promise<string> {\n return (await this.fetch('/hmi/screen/text', {\n method: 'POST',\n body: v.parse(text, { text: data } satisfies Text),\n schema: text,\n }))\n .text;\n }\n\n /**\n * Sets the screen colors.\n * @param colors The colors to set.\n * @returns The updated colors.\n */\n colors(colors: Color): Promise<Color> {\n return this.fetch('/hmi/screen/colors', {\n method: 'PATCH',\n body: v.parse(color, colors satisfies Color),\n schema: color,\n });\n }\n\n /**\n * Sets the screen progress.\n * @param data The progress value to set.\n * @returns The updated progress.\n */\n async progress(data: ProgressValue): Promise<Progress> {\n if (data == 0) {\n return await this.fetch('/hmi/screen/progress', {\n method: 'DELETE',\n parseResponse: () => ({ progress: 0 }),\n });\n }\n\n return this.fetch('/hmi/screen/progress', {\n method: 'PUT',\n body: v.parse(progress, { progress: data } satisfies Progress),\n schema: progress,\n });\n }\n\n /**\n * Clears the screen.\n */\n clear(): Promise<void> {\n return this.fetch('/hmi/screen/clear', { method: 'POST', parseResponse: () => {} });\n }\n}\n\n/** @hideconstructor */\nexport class Audio {\n constructor(private readonly fetch: UpFetch) {}\n\n /**\n * Plays a sound.\n * @param config The configuration (sound_id, volume).\n * @returns The play configuration.\n */\n async play(config: PlaybackConfiguration): Promise<PlaybackConfiguration> {\n return this.fetch('/hmi/speaker/play', {\n method: 'POST',\n body: v.parse(playbackConfiguration, config),\n schema: playbackConfiguration,\n });\n }\n}\n\n/** @hideconstructor */\nexport class Knob {\n constructor(private readonly fetch: UpFetch) {}\n\n read_event = () => this.fetch('/hmi/knob/get_knob_event', { schema: internalKnobEvent });\n\n is_button_held = async () => (await this.read_event()).button_held;\n is_knob_turned = async () => Math.abs((await this.read_event()).rotation_delta) >= 4;\n\n /**\n * Waits for a knob event and returns it.\n * @param timeout_ms The timeout in milliseconds.\n * @returns The knob event or null if the timeout was reached.\n */\n async wait_event(timeout_ms?: number): Promise<KnobEvent | null> {\n await this.read_event(); // Discard any previous events\n let delta = 0;\n\n const interval = Math.min(50, (timeout_ms ?? 500) / 10);\n\n const startTime = Date.now();\n while (timeout_ms !== undefined ? Date.now() - startTime < timeout_ms : true) {\n const knobEvent = await this.read_event();\n delta += knobEvent.rotation_delta;\n\n if (knobEvent.button_pressed || Math.abs(delta) >= 4) {\n return { button_pressed: knobEvent.button_pressed, rotation_delta: Math.sign(delta) };\n }\n await new Promise((resolve) => setTimeout(resolve, interval));\n }\n\n return null;\n }\n}\n"],"mappings":"0BAGA,MAAM,EAAa,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"hmi.mjs","names":[],"sources":["../src/api/hmi.ts"],"sourcesContent":["import type { UpFetch } from 'up-fetch';\nimport * as v from 'valibot';\n\nconst screenText = v.pipe(v.string(), v.maxLength(1024));\nexport type ScreenText = v.InferOutput<typeof screenText>;\n\nconst text = v.object({ text: screenText });\ntype Text = v.InferOutput<typeof text>;\n\nconst optionalHexColor = v.optional(v.pipe(v.string(), v.length(7), v.hexColor()));\nconst color = v.object({\n text: optionalHexColor,\n progress: optionalHexColor,\n background: optionalHexColor,\n});\nexport type Color = v.InferOutput<typeof color>;\n\nconst progressValue = v.pipe(v.number(), v.minValue(0), v.maxValue(100));\nexport type ProgressValue = v.InferOutput<typeof progressValue>;\nconst progress = v.object({ progress: progressValue });\nexport type Progress = v.InferOutput<typeof progress>;\n\nconst playbackConfiguration = v.object({\n sound_id: v.picklist(\n ['success', 'warning', 'failure', 'notification_1', 'notification_2',\n 'imperial_march'] as const,\n ),\n volume: v.pipe(v.number(), v.minValue(0), v.maxValue(100)),\n});\nexport type PlaybackConfiguration = v.InferOutput<typeof playbackConfiguration>;\n\nconst internalKnobEvent = v.object({\n button_pressed: v.boolean(),\n button_held: v.boolean(),\n rotation_delta: v.number(),\n});\nconst knobEvent = v.omit(internalKnobEvent, ['button_held']);\nexport type KnobEvent = v.InferOutput<typeof knobEvent>;\n\n/** @hideconstructor */\nexport class HmiApi {\n constructor(private readonly fetch: UpFetch) {}\n\n /**\n * Resets the HMI.\n */\n reset(): Promise<void> {\n return this.fetch('/hmi/reset', { method: 'POST', parseResponse: () => {} });\n }\n\n /**\n * Access the screen API.\n * @returns The screen instance.\n */\n screen(): Screen {\n return new Screen(this.fetch);\n }\n\n /**\n * Access the audio API.\n * @returns The audio instance.\n */\n audio(): Audio {\n return new Audio(this.fetch);\n }\n\n /**\n * Access the knob API.\n * @returns The knob instance.\n */\n knob(): Knob {\n return new Knob(this.fetch);\n }\n}\n\n/** @hideconstructor */\nexport class Screen {\n constructor(private readonly fetch: UpFetch) {}\n\n /**\n * Prints text to the screen.\n * @param data The text to print.\n * @returns The printed text.\n */\n async print(data: ScreenText): Promise<string> {\n return (await this.fetch('/hmi/screen/text', {\n method: 'POST',\n body: v.parse(text, { text: data } satisfies Text),\n schema: text,\n }))\n .text;\n }\n\n /**\n * Sets the screen colors.\n * @param colors The colors to set.\n * @returns The updated colors.\n */\n colors(colors: Color): Promise<Color> {\n return this.fetch('/hmi/screen/colors', {\n method: 'PATCH',\n body: v.parse(color, colors satisfies Color),\n schema: color,\n });\n }\n\n /**\n * Sets the screen progress.\n * @param data The progress value to set.\n * @returns The updated progress.\n */\n async progress(data: ProgressValue): Promise<Progress> {\n if (data == 0) {\n return await this.fetch('/hmi/screen/progress', {\n method: 'DELETE',\n parseResponse: () => ({ progress: 0 }),\n });\n }\n\n return this.fetch('/hmi/screen/progress', {\n method: 'PUT',\n body: v.parse(progress, { progress: data } satisfies Progress),\n schema: progress,\n });\n }\n\n /**\n * Clears the screen.\n */\n clear(): Promise<void> {\n return this.fetch('/hmi/screen/clear', { method: 'POST', parseResponse: () => {} });\n }\n}\n\n/** @hideconstructor */\nexport class Audio {\n constructor(private readonly fetch: UpFetch) {}\n\n /**\n * Plays a sound.\n * @param config The configuration (sound_id, volume).\n * @returns The play configuration.\n */\n async play(config: PlaybackConfiguration): Promise<PlaybackConfiguration> {\n return this.fetch('/hmi/speaker/play', {\n method: 'POST',\n body: v.parse(playbackConfiguration, config),\n schema: playbackConfiguration,\n });\n }\n}\n\n/** @hideconstructor */\nexport class Knob {\n constructor(private readonly fetch: UpFetch) {}\n\n read_event = () => this.fetch('/hmi/knob/get_knob_event', { schema: internalKnobEvent });\n\n is_button_held = async () => (await this.read_event()).button_held;\n is_knob_turned = async () => Math.abs((await this.read_event()).rotation_delta) >= 4;\n\n /**\n * Waits for a knob event and returns it.\n * @param timeout_ms The timeout in milliseconds.\n * @returns The knob event or null if the timeout was reached.\n */\n async wait_event(timeout_ms?: number): Promise<KnobEvent | null> {\n await this.read_event(); // Discard any previous events\n let delta = 0;\n\n const interval = Math.min(50, (timeout_ms ?? 500) / 10);\n\n const startTime = Date.now();\n while (timeout_ms !== undefined ? Date.now() - startTime < timeout_ms : true) {\n const knobEvent = await this.read_event();\n delta += knobEvent.rotation_delta;\n\n if (knobEvent.button_pressed || Math.abs(delta) >= 4) {\n return { button_pressed: knobEvent.button_pressed, rotation_delta: Math.sign(delta) };\n }\n await new Promise((resolve) => setTimeout(resolve, interval));\n }\n\n return null;\n }\n}\n"],"mappings":"0BAGA,MAAM,EAAa,EAAE,KAAK,EAAE,OAAO,EAAG,EAAE,UAAU,IAAI,CAAC,EAGjD,EAAO,EAAE,OAAO,CAAE,KAAM,CAAW,CAAC,EAGpC,EAAmB,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAG,EAAE,OAAO,CAAC,EAAG,EAAE,SAAS,CAAC,CAAC,EAC3E,EAAQ,EAAE,OAAO,CACrB,KAAM,EACN,SAAU,EACV,WAAY,CACd,CAAC,EAGK,EAAgB,EAAE,KAAK,EAAE,OAAO,EAAG,EAAE,SAAS,CAAC,EAAG,EAAE,SAAS,GAAG,CAAC,EAEjE,EAAW,EAAE,OAAO,CAAE,SAAU,CAAc,CAAC,EAG/C,EAAwB,EAAE,OAAO,CACrC,SAAU,EAAE,SACV,CAAC,UAAW,UAAW,UAAW,iBAAkB,iBAClD,gBAAgB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AQ,CACV,CAAC,CACH,CAKA,OAAuB,CACrB,OAAO,KAAK,MAAM,oBAAqB,CAAE,OAAQ,OAAQ,kBAAqB,CAAC,CAAE,CAAC,CACpF,CACF,EAGa,EAAb,KAAmB,CACY,MAA7B,YAAY,EAAiC,CAAhB,KAAA,MAAA,CAAiB,CAO9C,MAAM,KAAK,EAA+D,CACxE,OAAO,KAAK,MAAM,oBAAqB,CACrC,OAAQ,OACR,KAAM,EAAE,MAAM,EAAuB,CAAM,EAC3C,OAAQ,CACV,CAAC,CACH,CACF,EAGa,EAAb,KAAkB,CACa,MAA7B,YAAY,EAAiC,CAAhB,KAAA,MAAA,CAAiB,CAE9C,eAAmB,KAAK,MAAM,2BAA4B,CAAE,OAAQ,CAAkB,CAAC,EAEvF,eAAiB,UAAa,MAAM,KAAK,WAAW,EAAA,CAAG,YACvD,eAAiB,SAAY,KAAK,KAAK,MAAM,KAAK,WAAW,EAAA,CAAG,cAAc,GAAK,EAOnF,MAAM,WAAW,EAAgD,CAC/D,MAAM,KAAK,WAAW,EACtB,IAAI,EAAQ,EAEN,EAAW,KAAK,IAAI,IAAK,GAAc,KAAO,EAAE,EAEhD,EAAY,KAAK,IAAI,EAC3B,KAAO,IAAe,IAAA,IAAY,KAAK,IAAI,EAAI,EAAY,GAAmB,CAC5E,IAAM,EAAY,MAAM,KAAK,WAAW,EAGxC,GAFA,GAAS,EAAU,eAEf,EAAU,gBAAkB,KAAK,IAAI,CAAK,GAAK,EACjD,MAAO,CAAE,eAAgB,EAAU,eAAgB,eAAgB,KAAK,KAAK,CAAK,CAAE,EAEtF,MAAM,IAAI,QAAS,GAAY,WAAW,EAAS,CAAQ,CAAC,CAC9D,CAEA,OAAO,IACT,CACF"}
|
|
@@ -16,6 +16,7 @@ declare const info: v.ObjectSchema<{
|
|
|
16
16
|
readonly serial_number: v.StringSchema<undefined>;
|
|
17
17
|
readonly firmware_version: v.StringSchema<undefined>;
|
|
18
18
|
readonly firmware_commit: v.StringSchema<undefined>;
|
|
19
|
+
readonly hardware_version: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
19
20
|
readonly disk_used: v.NumberSchema<undefined>;
|
|
20
21
|
readonly disk_total: v.NumberSchema<undefined>;
|
|
21
22
|
readonly docker_used: v.NumberSchema<undefined>;
|
|
@@ -224,7 +225,7 @@ declare const calibrationData: v.ObjectSchema<{
|
|
|
224
225
|
readonly max_error: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
225
226
|
readonly avg_error: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
226
227
|
}, undefined>, undefined>;
|
|
227
|
-
readonly adc_negative: v.ArraySchema<v.ObjectSchema<{
|
|
228
|
+
readonly adc_negative: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
228
229
|
readonly channel: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 31, undefined>]>;
|
|
229
230
|
readonly points: v.ArraySchema<v.ObjectSchema<{
|
|
230
231
|
readonly set: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
@@ -233,7 +234,7 @@ declare const calibrationData: v.ObjectSchema<{
|
|
|
233
234
|
}, undefined>, undefined>;
|
|
234
235
|
readonly max_error: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
235
236
|
readonly avg_error: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
236
|
-
}, undefined>, undefined>;
|
|
237
|
+
}, undefined>, undefined>, undefined>;
|
|
237
238
|
readonly dut_psu: v.ObjectSchema<{
|
|
238
239
|
readonly voltage: v.ObjectSchema<{
|
|
239
240
|
readonly points: v.ArraySchema<v.ObjectSchema<{
|
|
@@ -290,6 +291,7 @@ declare const calibrationState: v.ObjectSchema<{
|
|
|
290
291
|
readonly enabled: v.BooleanSchema<undefined>;
|
|
291
292
|
readonly loaded: v.BooleanSchema<undefined>;
|
|
292
293
|
readonly last_error: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
294
|
+
readonly calibrated_at: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
293
295
|
}, undefined>;
|
|
294
296
|
type CalibrationState = v.InferOutput<typeof calibrationState>;
|
|
295
297
|
/** @hideconstructor */
|
|
@@ -306,6 +308,7 @@ declare class ManagementApi {
|
|
|
306
308
|
serial_number: string;
|
|
307
309
|
firmware_version: string;
|
|
308
310
|
firmware_commit: string;
|
|
311
|
+
hardware_version?: number | undefined;
|
|
309
312
|
disk_used: number;
|
|
310
313
|
disk_total: number;
|
|
311
314
|
docker_used: number;
|
|
@@ -506,4 +509,4 @@ declare class ManagementApi {
|
|
|
506
509
|
}
|
|
507
510
|
//#endregion
|
|
508
511
|
export { ChannelCalibration as a, DutPsuCalibration as c, ManagementApi as d, RebootResponse as f, UsbTestResult as h, CalibrationState as i, Information as l, UpdateStatus as m, CalibrationData as n, CommunicationInterfaceType as o, RelayTestResult as p, CalibrationPoint as r, CurrentTestResult as s, BundleInfo as t, InstallResponse as u };
|
|
509
|
-
//# sourceMappingURL=management-
|
|
512
|
+
//# sourceMappingURL=management-C0iQha23.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"management-C0iQha23.d.cts","names":[],"sources":["../src/api/management.ts"],"mappings":";;;;aAGY,0BAAA;EACV,GAAA;EACA,KAAA;EACA,KAAA;EACA,GAAA;EACA,GAAA;EACA,IAAA;AAAA;AAAA,cA+EI,IAAA,EAAI,CAAA,CAAA,YAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAYE,WAAA,GAAc,CAAA,CAAE,WAAW,QAAQ,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;;;;;;;;EAY9C,UAAA,CAAW,SAAA,WAAiB,OAAA;;;;;EAQ5B,WAAA,CAAY,SAAA,WAAiB,OAAA;EAvPV;;;;EA+PnB,aAAA,CAAc,SAAA,WAAiB,OAAA;EA7P3B;;;;;;;EAwQJ,aAAA,CAAc,IAAA,EAAM,IAAA,EAAM,QAAA,YAAyB,OAAA;;;;;;;;;;EAenD,WAAA,IAAW,OAAA;;;;;;;;;AAjRb;EAyRE,cAAA,IAAc,OAAA;;;;EAzRW;;;AAA6B;EAiStD,aAAA,IAAa,OAAA;;;;;;EA/RM;;;;EAuSnB,MAAA,IAAM,OAAA"}
|
|
@@ -16,6 +16,7 @@ declare const info: v.ObjectSchema<{
|
|
|
16
16
|
readonly serial_number: v.StringSchema<undefined>;
|
|
17
17
|
readonly firmware_version: v.StringSchema<undefined>;
|
|
18
18
|
readonly firmware_commit: v.StringSchema<undefined>;
|
|
19
|
+
readonly hardware_version: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
19
20
|
readonly disk_used: v.NumberSchema<undefined>;
|
|
20
21
|
readonly disk_total: v.NumberSchema<undefined>;
|
|
21
22
|
readonly docker_used: v.NumberSchema<undefined>;
|
|
@@ -224,7 +225,7 @@ declare const calibrationData: v.ObjectSchema<{
|
|
|
224
225
|
readonly max_error: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
225
226
|
readonly avg_error: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
226
227
|
}, undefined>, undefined>;
|
|
227
|
-
readonly adc_negative: v.ArraySchema<v.ObjectSchema<{
|
|
228
|
+
readonly adc_negative: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
228
229
|
readonly channel: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 31, undefined>]>;
|
|
229
230
|
readonly points: v.ArraySchema<v.ObjectSchema<{
|
|
230
231
|
readonly set: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
@@ -233,7 +234,7 @@ declare const calibrationData: v.ObjectSchema<{
|
|
|
233
234
|
}, undefined>, undefined>;
|
|
234
235
|
readonly max_error: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
235
236
|
readonly avg_error: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>;
|
|
236
|
-
}, undefined>, undefined>;
|
|
237
|
+
}, undefined>, undefined>, undefined>;
|
|
237
238
|
readonly dut_psu: v.ObjectSchema<{
|
|
238
239
|
readonly voltage: v.ObjectSchema<{
|
|
239
240
|
readonly points: v.ArraySchema<v.ObjectSchema<{
|
|
@@ -290,6 +291,7 @@ declare const calibrationState: v.ObjectSchema<{
|
|
|
290
291
|
readonly enabled: v.BooleanSchema<undefined>;
|
|
291
292
|
readonly loaded: v.BooleanSchema<undefined>;
|
|
292
293
|
readonly last_error: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
294
|
+
readonly calibrated_at: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
293
295
|
}, undefined>;
|
|
294
296
|
type CalibrationState = v.InferOutput<typeof calibrationState>;
|
|
295
297
|
/** @hideconstructor */
|
|
@@ -306,6 +308,7 @@ declare class ManagementApi {
|
|
|
306
308
|
serial_number: string;
|
|
307
309
|
firmware_version: string;
|
|
308
310
|
firmware_commit: string;
|
|
311
|
+
hardware_version?: number | undefined;
|
|
309
312
|
disk_used: number;
|
|
310
313
|
disk_total: number;
|
|
311
314
|
docker_used: number;
|
|
@@ -506,4 +509,4 @@ declare class ManagementApi {
|
|
|
506
509
|
}
|
|
507
510
|
//#endregion
|
|
508
511
|
export { ChannelCalibration as a, DutPsuCalibration as c, ManagementApi as d, RebootResponse as f, UsbTestResult as h, CalibrationState as i, Information as l, UpdateStatus as m, CalibrationData as n, CommunicationInterfaceType as o, RelayTestResult as p, CalibrationPoint as r, CurrentTestResult as s, BundleInfo as t, InstallResponse as u };
|
|
509
|
-
//# sourceMappingURL=management-
|
|
512
|
+
//# sourceMappingURL=management-C0iQha23.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"management-C0iQha23.d.mts","names":[],"sources":["../src/api/management.ts"],"mappings":";;;;aAGY,0BAAA;EACV,GAAA;EACA,KAAA;EACA,KAAA;EACA,GAAA;EACA,GAAA;EACA,IAAA;AAAA;AAAA,cA+EI,IAAA,EAAI,CAAA,CAAA,YAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAYE,WAAA,GAAc,CAAA,CAAE,WAAW,QAAQ,IAAA;AAAA,cAEzC,OAAA,EAAO,CAAA,CAAA,YAAA;EAAA;;;;;KAMR,OAAA,GAAU,CAAA,CAAE,WAAW,QAAQ,OAAA;AAAA,cAE9B,aAAA,EAAa,CAAA,CAAA,YAAA;EAAA;;;KACd,aAAA,GAAgB,CAAA,CAAE,WAAW,QAAQ,aAAA;AAAA,cAEpC,UAAA,EAAU,CAAA,CAAA,YAAA;EAAA;;;;;KAMJ,UAAA,GAAa,CAAA,CAAE,WAAW,QAAQ,UAAA;AAAA,cAExC,eAAA,EAAe,CAAA,CAAA,YAAA;EAAA;;;KACT,eAAA,GAAkB,CAAA,CAAE,WAAW,QAAQ,eAAA;AAAA,cAE7C,YAAA,EAAY,CAAA,CAAA,YAAA;EAAA;;;;;KAMN,YAAA,GAAe,CAAA,CAAE,WAAW,QAAQ,YAAA;AAAA,cAE1C,cAAA,EAAc,CAAA,CAAA,YAAA;EAAA,kBAAoC,CAAA,CAAA,YAAA;AAAA;AAAA,KAC5C,cAAA,GAAiB,CAAA,CAAE,WAAW,QAAQ,cAAA;AAAA,cAS5C,gBA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B,IAAA,EAAM,eAAA,GAAkB,OAAA,CAAQ,eAAA;;AAtJlD;;EAiKE,qBAAA,IAAyB,OAAA,CAAQ,gBAAA;EAjKI;;;;EAyKrC,uBAAA,CAAwB,OAAA,YAAmB,OAAA,CAAQ,gBAAA;EAzKF;EAkLjD,kBAAA,IAAsB,OAAA,CAAQ,gBAAA;EA3K9B;EAgLA,mBAAA,IAAuB,OAAA,CAAQ,gBAAA;;;;;EAQzB,QAAA,IAAY,OAAA,CAAQ,IAAA;EA7Lf;;;;;;;EA2MX,WAAA,CAAY,QAAA,EAAU,IAAA,GAAO,OAAA;;;;;EAY7B,WAAA,IAAW,OAAA;;;;;;EAjNR;;;;EAyNH,aAAA,CAAc,UAAA,EAAY,aAAA,GAAa,OAAA;;;;;;EAvN8B;;;;;EAoOrE,aAAA,CAAc,SAAA,UAAmB,IAAA,EAAM,OAAA,GAAO,OAAA;;;;;;;;;;EAY9C,UAAA,CAAW,SAAA,WAAiB,OAAA;;;;;EAQ5B,WAAA,CAAY,SAAA,WAAiB,OAAA;EAvPV;;;;EA+PnB,aAAA,CAAc,SAAA,WAAiB,OAAA;EA7P3B;;;;;;;EAwQJ,aAAA,CAAc,IAAA,EAAM,IAAA,EAAM,QAAA,YAAyB,OAAA;;;;;;;;;;EAenD,WAAA,IAAW,OAAA;;;;;;;;;AAjRb;EAyRE,cAAA,IAAc,OAAA;;;;EAzRW;;;AAA6B;EAiStD,aAAA,IAAa,OAAA;;;;;;EA/RM;;;;EAuSnB,MAAA,IAAM,OAAA"}
|
package/build/management.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(
|
|
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(),container_id:t.string(),image:t.string()});t.object({name:t.string(),image:t.string()});const x=t.object({bundle:t.string(),version:t.string(),compatible:t.string(),description:t.string()}),S=t.object({message:t.string(),bundle:t.string()}),C=t.object({state:t.picklist([`idle`,`installing`,`failed`]),progress:t.number(),message:t.string(),error:t.string()}),w=t.object({message:t.string()}),T=t.pipe(t.number(),t.finite()),E=t.pipe(t.number(),t.finite(),t.minValue(Number.MIN_VALUE)),D=t.pipe(t.number(),t.integer(),t.minValue(0),t.maxValue(31)),O=t.pipe(t.number(),t.integer(),t.minValue(0),t.maxValue(7)),k=t.pipe(t.number(),t.integer(),t.minValue(0),t.maxValue(1)),A=t.picklist([`pass`,`fail`]),j=t.object({set:T,measured:T,reading:t.optional(T)}),M=t.object({channel:D,points:t.array(j),max_error:T,avg_error:T}),N=t.object({voltage:t.object({points:t.array(j),max_error:T,avg_error:T}),current:t.object({load_ohms:E,points:t.array(j),max_error:T,avg_error:T})}),P=t.object({load_ohms:E,voltage_applied:T,measured_current:T,expected_current:T,error_percent:T}),F=t.object({relay:O,status:A,test_voltage:T,closed_current:T,open_current:T,calibration:t.optional(M)}),I=t.object({port:k,status:A,voltage:T,current_tests:t.optional(t.array(P))}),L=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(M),adc_positive:t.array(M),adc_negative:t.optional(t.array(M)),dut_psu:N,relays:t.array(F),usb:t.array(I)}),R=t.object({enabled:t.boolean(),loaded:t.boolean(),last_error:t.optional(t.nullable(t.string())),calibrated_at:t.optional(t.nullable(t.string()))}),z=t.object({enabled:t.boolean()});var B=class{fetch;constructor(e){this.fetch=e}info(){return this.fetch(`/management/info`,{schema:y})}get_calibration(){return this.fetch(`/management/calibration`,{schema:L})}set_calibration(e){return this.fetch(`/management/calibration`,{method:`PUT`,body:t.parse(L,e),schema:L})}get_calibration_state(){return this.fetch(`/management/calibration/state`,{schema:R})}set_calibration_enabled(e){return this.fetch(`/management/calibration/state`,{method:`PATCH`,body:t.parse(z,{enabled:e}),schema:R})}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(b)})}createProject(e){return this.fetch(`/management/projects`,{method:`POST`,body:e,schema:b})}updateProject(e,t){return this.fetch(`/management/projects/${e}`,{method:`PATCH`,body:t,schema:b})}runProject(e){return this.fetch(`/management/projects/${e}/run`,{method:`POST`})}stopProject(e){return this.fetch(`/management/projects/${e}/stop`,{method:`POST`})}deleteProject(e){return this.fetch(`/management/projects/${e}`,{method:`DELETE`})}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:x})}bundle_info(){return this.fetch(`/management/update/bundle-info`,{schema:x})}install_update(){return this.fetch(`/management/update/install`,{method:`POST`,schema:S})}update_status(){return this.fetch(`/management/update/status`,{schema:C})}reboot(){return this.fetch(`/management/reboot`,{method:`POST`,schema:w})}};exports.CommunicationInterfaceType=n,exports.ManagementApi=B;
|
|
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 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.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});\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/time', {\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/time', {\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":"iKAGA,IAAY,EAAL,SAAA,EAAA,OACL,GAAA,IAAA,MACA,EAAA,MAAA,QACA,EAAA,MAAA,QACA,EAAA,IAAA,MACA,EAAA,IAAA,MACA,EAAA,KAAA,aACD,CACD,MAAM,EAAyBA,EAAE,KAA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,CAOJ,aAAc,CACZ,OAAO,KAAK,MAAM,uBAAwB,CAAE,OAAQA,EAAE,MAAM,EAAQ,CAAE,CAAC,CAOzE,cAAc,EAA2B,CACvC,OAAO,KAAK,MAAM,uBAAwB,CACxC,OAAQ,OACR,KAAM,EACN,OAAQ,EACT,CAAC,CAQJ,cAAc,EAAmB,EAAe,CAC9C,OAAO,KAAK,MAAM,wBAAwB,IAAa,CACrD,OAAQ,QACR,KAAM,EACN,OAAQ,EACT,CAAC,CAOJ,WAAW,EAAmB,CAC5B,OAAO,KAAK,MAAM,wBAAwB,EAAU,MAAO,CAAE,OAAQ,OAAQ,CAAC,CAOhF,YAAY,EAAmB,CAC7B,OAAO,KAAK,MAAM,wBAAwB,EAAU,OAAQ,CAAE,OAAQ,OAAQ,CAAC,CAOjF,cAAc,EAAmB,CAC/B,OAAO,KAAK,MAAM,wBAAwB,IAAa,CAAE,OAAQ,SAAU,CAAC,CAU9E,cAAc,EAAY,EAAW,eAAgB,CACnD,OAAO,KAAK,MAAM,4BAA6B,CAC7C,OAAQ,OACR,KAAM,EACN,QAAS,CAAE,eAAgB,2BAA4B,oBAAqB,EAAU,CACtF,cAAgB,GAAM,EACtB,QAAS,IACT,OAAQ,EACT,CAAC,CAOJ,aAAc,CACZ,OAAO,KAAK,MAAM,iCAAkC,CAAE,OAAQ,EAAY,CAAC,CAO7E,gBAAiB,CACf,OAAO,KAAK,MAAM,6BAA8B,CAAE,OAAQ,OAAQ,OAAQ,EAAiB,CAAC,CAO9F,eAAgB,CACd,OAAO,KAAK,MAAM,4BAA6B,CAAE,OAAQ,EAAc,CAAC,CAO1E,QAAS,CACP,OAAO,KAAK,MAAM,qBAAsB,CAAE,OAAQ,OAAQ,OAAQ,EAAgB,CAAC"}
|
|
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,CA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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/management.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ChannelCalibration, c as DutPsuCalibration, d as ManagementApi, f as RebootResponse, h as UsbTestResult, i as CalibrationState, l as Information, m as UpdateStatus, n as CalibrationData, o as CommunicationInterfaceType, p as RelayTestResult, r as CalibrationPoint, s as CurrentTestResult, t as BundleInfo, u as InstallResponse } from "./management-
|
|
1
|
+
import { a as ChannelCalibration, c as DutPsuCalibration, d as ManagementApi, f as RebootResponse, h as UsbTestResult, i as CalibrationState, l as Information, m as UpdateStatus, n as CalibrationData, o as CommunicationInterfaceType, p as RelayTestResult, r as CalibrationPoint, s as CurrentTestResult, t as BundleInfo, u as InstallResponse } from "./management-C0iQha23.cjs";
|
|
2
2
|
export { BundleInfo, CalibrationData, CalibrationPoint, CalibrationState, ChannelCalibration, CommunicationInterfaceType, CurrentTestResult, DutPsuCalibration, Information, InstallResponse, ManagementApi, RebootResponse, RelayTestResult, UpdateStatus, UsbTestResult };
|
package/build/management.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ChannelCalibration, c as DutPsuCalibration, d as ManagementApi, f as RebootResponse, h as UsbTestResult, i as CalibrationState, l as Information, m as UpdateStatus, n as CalibrationData, o as CommunicationInterfaceType, p as RelayTestResult, r as CalibrationPoint, s as CurrentTestResult, t as BundleInfo, u as InstallResponse } from "./management-
|
|
1
|
+
import { a as ChannelCalibration, c as DutPsuCalibration, d as ManagementApi, f as RebootResponse, h as UsbTestResult, i as CalibrationState, l as Information, m as UpdateStatus, n as CalibrationData, o as CommunicationInterfaceType, p as RelayTestResult, r as CalibrationPoint, s as CurrentTestResult, t as BundleInfo, u as InstallResponse } from "./management-C0iQha23.mjs";
|
|
2
2
|
export { BundleInfo, CalibrationData, CalibrationPoint, CalibrationState, ChannelCalibration, CommunicationInterfaceType, CurrentTestResult, DutPsuCalibration, Information, InstallResponse, ManagementApi, RebootResponse, RelayTestResult, UpdateStatus, UsbTestResult };
|
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(),disk_used:e.number(),disk_total:e.number(),docker_used:e.number(),capabilities:_}),y=e.object({name:e.string(),path:e.string(),container_id:e.string(),image:e.string()});e.object({name:e.string(),image:e.string()});const b=e.object({bundle:e.string(),version:e.string(),compatible:e.string(),description:e.string()}),x=e.object({message:e.string(),bundle:e.string()}),S=e.object({state:e.picklist([`idle`,`installing`,`failed`]),progress:e.number(),message:e.string(),error:e.string()}),C=e.object({message:e.string()}),w=e.pipe(e.number(),e.finite()),T=e.pipe(e.number(),e.finite(),e.minValue(Number.MIN_VALUE)),E=e.pipe(e.number(),e.integer(),e.minValue(0),e.maxValue(31)),D=e.pipe(e.number(),e.integer(),e.minValue(0),e.maxValue(7)),O=e.pipe(e.number(),e.integer(),e.minValue(0),e.maxValue(1)),k=e.picklist([`pass`,`fail`]),A=e.object({set:w,measured:w,reading:e.optional(w)}),j=e.object({channel:E,points:e.array(A),max_error:w,avg_error:w}),M=e.object({voltage:e.object({points:e.array(A),max_error:w,avg_error:w}),current:e.object({load_ohms:T,points:e.array(A),max_error:w,avg_error:w})}),N=e.object({load_ohms:T,voltage_applied:w,measured_current:w,expected_current:w,error_percent:w}),P=e.object({relay:D,status:k,test_voltage:w,closed_current:w,open_current:w,calibration:e.optional(j)}),F=e.object({port:O,status:k,voltage:w,current_tests:e.optional(e.array(N))}),I=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(j),adc_positive:e.array(j),adc_negative:e.array(j),dut_psu:M,relays:e.array(P),usb:e.array(F)}),L=e.object({enabled:e.boolean(),loaded:e.boolean(),last_error:e.optional(e.nullable(e.string()))}),R=e.object({enabled:e.boolean()});var z=class{constructor(e){this.fetch=e}info(){return this.fetch(`/management/info`,{schema:v})}get_calibration(){return this.fetch(`/management/calibration`,{schema:I})}set_calibration(t){return this.fetch(`/management/calibration`,{method:`PUT`,body:e.parse(I,t),schema:I})}get_calibration_state(){return this.fetch(`/management/calibration/state`,{schema:L})}set_calibration_enabled(t){return this.fetch(`/management/calibration/state`,{method:`PATCH`,body:e.parse(R,{enabled:t}),schema:L})}enable_calibration(){return this.set_calibration_enabled(!0)}disable_calibration(){return this.set_calibration_enabled(!1)}async datetime(){let t=await this.fetch(`/management/
|
|
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(),container_id:e.string(),image:e.string()});e.object({name:e.string(),image:e.string()});const b=e.object({bundle:e.string(),version:e.string(),compatible:e.string(),description:e.string()}),x=e.object({message:e.string(),bundle:e.string()}),S=e.object({state:e.picklist([`idle`,`installing`,`failed`]),progress:e.number(),message:e.string(),error:e.string()}),C=e.object({message:e.string()}),w=e.pipe(e.number(),e.finite()),T=e.pipe(e.number(),e.finite(),e.minValue(Number.MIN_VALUE)),E=e.pipe(e.number(),e.integer(),e.minValue(0),e.maxValue(31)),D=e.pipe(e.number(),e.integer(),e.minValue(0),e.maxValue(7)),O=e.pipe(e.number(),e.integer(),e.minValue(0),e.maxValue(1)),k=e.picklist([`pass`,`fail`]),A=e.object({set:w,measured:w,reading:e.optional(w)}),j=e.object({channel:E,points:e.array(A),max_error:w,avg_error:w}),M=e.object({voltage:e.object({points:e.array(A),max_error:w,avg_error:w}),current:e.object({load_ohms:T,points:e.array(A),max_error:w,avg_error:w})}),N=e.object({load_ohms:T,voltage_applied:w,measured_current:w,expected_current:w,error_percent:w}),P=e.object({relay:D,status:k,test_voltage:w,closed_current:w,open_current:w,calibration:e.optional(j)}),F=e.object({port:O,status:k,voltage:w,current_tests:e.optional(e.array(N))}),I=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(j),adc_positive:e.array(j),adc_negative:e.optional(e.array(j)),dut_psu:M,relays:e.array(P),usb:e.array(F)}),L=e.object({enabled:e.boolean(),loaded:e.boolean(),last_error:e.optional(e.nullable(e.string())),calibrated_at:e.optional(e.nullable(e.string()))}),R=e.object({enabled:e.boolean()});var z=class{fetch;constructor(e){this.fetch=e}info(){return this.fetch(`/management/info`,{schema:v})}get_calibration(){return this.fetch(`/management/calibration`,{schema:I})}set_calibration(t){return this.fetch(`/management/calibration`,{method:`PUT`,body:e.parse(I,t),schema:I})}get_calibration_state(){return this.fetch(`/management/calibration/state`,{schema:L})}set_calibration_enabled(t){return this.fetch(`/management/calibration/state`,{method:`PATCH`,body:e.parse(R,{enabled:t}),schema:L})}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(y)})}createProject(e){return this.fetch(`/management/projects`,{method:`POST`,body:e,schema:y})}updateProject(e,t){return this.fetch(`/management/projects/${e}`,{method:`PATCH`,body:t,schema:y})}runProject(e){return this.fetch(`/management/projects/${e}/run`,{method:`POST`})}stopProject(e){return this.fetch(`/management/projects/${e}/stop`,{method:`POST`})}deleteProject(e){return this.fetch(`/management/projects/${e}`,{method:`DELETE`})}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:b})}bundle_info(){return this.fetch(`/management/update/bundle-info`,{schema:b})}install_update(){return this.fetch(`/management/update/install`,{method:`POST`,schema:x})}update_status(){return this.fetch(`/management/update/status`,{schema:S})}reboot(){return this.fetch(`/management/reboot`,{method:`POST`,schema:C})}};export{t as CommunicationInterfaceType,z as ManagementApi};
|
|
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 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.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});\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/time', {\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/time', {\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,aACD,CACD,MAAM,EAAyB,EAAE,KAAK,EAA2B,CAE3D,EAAe,EAAE,OAAO,CAC5B,IAAK,EAAE,KAAK,EAAE,QAAQ,CAAE,EAAE,SAAS,IAAI,CAAE,EAAE,SAAS,GAAG,CAAC,CACxD,IAAK,EAAE,KAAK,EAAE,QAAQ,CAAE,EAAE,SAAS,IAAI,CAAE,EAAE,SAAS,GAAG,CAAC,CACzD,CAAC,CAEI,EAAe,EAAE,OAAO,CAAE,IAAK,EAAE,QAAQ,CAAE,CAAC,CAE5C,EAAiB,EAAE,OAAO,CAC9B,MAAO,EAAE,KAAK,EAAE,QAAQ,CAAE,EAAE,SAAS,EAAE,CAAC,CACxC,cAAe,EACf,eAAgB,EACjB,CAAC,CAEI,EAAqB,EAAE,OAAO,CAClC,MAAO,EAAE,KAAK,EAAE,QAAQ,CAAE,EAAE,SAAS,EAAE,CAAC,CACxC,YAAa,EAAE,QAAQ,CACvB,YAAa,EAAE,QAAQ,CACvB,cAAe,EAAE,KAAK,EAAE,QAAQ,CAAE,EAAE,SAAS,EAAE,CAAC,CACjD,CAAC,CAEI,EAAgB,EAAE,OAAO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E,gBAAiB,CACf,OAAO,KAAK,MAAM,6BAA8B,CAAE,OAAQ,OAAQ,OAAQ,EAAiB,CAAC,CAO9F,eAAgB,CACd,OAAO,KAAK,MAAM,4BAA6B,CAAE,OAAQ,EAAc,CAAC,CAO1E,QAAS,CACP,OAAO,KAAK,MAAM,qBAAsB,CAAE,OAAQ,OAAQ,OAAQ,EAAgB,CAAC"}
|
|
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,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,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AQ,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"}
|
package/build/node.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./chunk-Bmb41Sf3.cjs`),t=require(`./at1000-DfziElfg.cjs`);let n=require(`dns-packet`);n=e.t(n);let r=require(`node:events`),i=require(`node:util`);i=e.t(i);let a=require(`ip-address`);a=e.t(a);let o=require(`node:os`);o=e.t(o);let s=require(`node:dgram`);s=e.t(s);const c=`224.0.0.251`,l=`FF02::FB`,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=o.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 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 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 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)?[d,4]:[f,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 _={reuseAddr:!0,srcPort:5353,interfaces:null,ttl:255,loopback:!0,debug:!1};var v=class extends r.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: ${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=>[d,4].includes(e.family)),t=this.interfaces.filter(e=>[f,6].includes(e.family));if(this.emitDebug(`Create receive sockets for${e.length?` `+d:``}${e.length&&t.length?` and`:``}${t.length?` `+f:``}`),e.length){let t=await g.createMulticastSocket({multicastAddress:c,multicastPort:u,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 g.createMulticastSocket({multicastAddress:l,multicastPort:u,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 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.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,u,[`IPv4`,4].includes(n.iface.family)?c:l+`%`+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 r.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 n=new v({debug:!0}),r=new b(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?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 t.t{static apiVersion=t.n;static findDevices(e=500){return S(e)}};exports.AT1000=C;
|
|
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;
|
|
2
2
|
//# sourceMappingURL=node.cjs.map
|