@ikalogic/at1000 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/at1000-BGZGhgco.mjs +3 -0
- package/build/at1000-BGZGhgco.mjs.map +1 -0
- package/build/at1000-D9r6GCs0.cjs +3 -0
- package/build/at1000-D9r6GCs0.cjs.map +1 -0
- package/build/browser.cjs +1 -1
- package/build/browser.cjs.map +1 -1
- package/build/browser.d.cts +1 -1
- package/build/browser.d.mts +1 -1
- package/build/browser.mjs +1 -1
- package/build/browser.mjs.map +1 -1
- package/build/{com-DN1l6xqC.d.cts → com-XQjoTBdU.d.cts} +25 -25
- package/build/{com-DN1l6xqC.d.cts.map → com-XQjoTBdU.d.cts.map} +1 -1
- package/build/{com-DN1l6xqC.d.mts → com-XQjoTBdU.d.mts} +25 -25
- package/build/{com-DN1l6xqC.d.mts.map → com-XQjoTBdU.d.mts.map} +1 -1
- package/build/com.d.cts +1 -1
- package/build/com.d.mts +1 -1
- package/build/events.cjs +1 -1
- package/build/events.mjs +1 -1
- package/build/{gpio-CsxbjhA_.d.cts → gpio-Bk1VEKYF.d.cts} +19 -9
- package/build/gpio-Bk1VEKYF.d.cts.map +1 -0
- package/build/{gpio-Dk-s_yMc.d.mts → gpio-bFe112uI.d.mts} +19 -9
- package/build/gpio-bFe112uI.d.mts.map +1 -0
- package/build/gpio.cjs.map +1 -1
- package/build/gpio.d.cts +1 -1
- package/build/gpio.d.mts +1 -1
- package/build/gpio.mjs.map +1 -1
- package/build/{at1000-tUTVczQa.d.cts → host-BCOEcUog.d.cts} +15 -13
- package/build/host-BCOEcUog.d.cts.map +1 -0
- package/build/{at1000-gm586Tc9.d.mts → host-DJ8SAGMC.d.mts} +15 -13
- package/build/host-DJ8SAGMC.d.mts.map +1 -0
- package/build/management-BGrPAG5k.cjs +7 -0
- package/build/management-BGrPAG5k.cjs.map +1 -0
- package/build/management-CuI4cenF.mjs +7 -0
- package/build/management-CuI4cenF.mjs.map +1 -0
- package/build/management.cjs +1 -1
- package/build/management.d.cts +27 -21
- package/build/management.d.cts.map +1 -1
- package/build/management.d.mts +27 -21
- package/build/management.d.mts.map +1 -1
- package/build/management.mjs +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/package-CXtuh0C5.mjs +2 -0
- package/build/package-CXtuh0C5.mjs.map +1 -0
- package/build/{package-0hAwYBa1.cjs → package-DDLRsahz.cjs} +2 -2
- package/build/package-DDLRsahz.cjs.map +1 -0
- package/build/power.cjs.map +1 -1
- package/build/power.mjs.map +1 -1
- package/build/session.cjs +1 -1
- package/build/session.mjs +1 -1
- package/package.json +1 -1
- package/build/at1000-DbIvMQUc.cjs +0 -8
- package/build/at1000-DbIvMQUc.cjs.map +0 -1
- package/build/at1000-Zs18VzlP.mjs +0 -8
- package/build/at1000-Zs18VzlP.mjs.map +0 -1
- package/build/at1000-gm586Tc9.d.mts.map +0 -1
- package/build/at1000-tUTVczQa.d.cts.map +0 -1
- package/build/gpio-CsxbjhA_.d.cts.map +0 -1
- package/build/gpio-Dk-s_yMc.d.mts.map +0 -1
- package/build/package-0hAwYBa1.cjs.map +0 -1
- package/build/package-CU5MagIg.mjs +0 -2
- package/build/package-CU5MagIg.mjs.map +0 -1
package/build/gpio.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gpio.mjs","names":[],"sources":["../src/api/gpio.ts"],"sourcesContent":["import type { UpFetch } from 'up-fetch';\nimport * as v from 'valibot';\n\nimport { analogLevel, type AnalogOutputLevel, analogOutputLevel, digitalLevel } from './common';\nimport type { Information } from './management';\n\nexport type { AnalogOutputLevel };\n\nconst syncAction = v.picklist(['release', 'hold'], 'Invalid sync action');\nexport const analogInputConfiguration = v.object({\n mode: v.literal('analog'),\n direction: v.literal('input'),\n});\nexport const analogOutputConfiguration = v.object({\n mode: v.literal('analog'),\n direction: v.literal('output'),\n value: v.optional(analogOutputLevel),\n});\nexport const digitalInputConfiguration = v.object({\n mode: v.literal('digital'),\n direction: v.literal('input'),\n vil: analogLevel,\n vih: analogLevel,\n});\nexport const digitalOutputConfiguration = v.object({\n mode: v.literal('digital'),\n direction: v.literal('output'),\n value: digitalLevel,\n vol: analogOutputLevel,\n voh: analogOutputLevel,\n vil: analogLevel,\n vih: analogLevel,\n});\nexport const openDrainConfiguration = v.object({\n mode: v.literal('digital'),\n direction: v.literal('open_drain'),\n value: digitalLevel,\n vil: analogLevel,\n vih: analogLevel,\n});\nexport type AnalogInputConfiguration = v.InferOutput<typeof analogInputConfiguration>;\nexport type AnalogOutputConfiguration = v.InferOutput<typeof analogOutputConfiguration>;\nexport type DigitalInputConfiguration = v.InferOutput<typeof digitalInputConfiguration>;\nexport type DigitalOutputConfiguration = v.InferOutput<typeof digitalOutputConfiguration>;\nexport type OpenDrainConfiguration = v.InferOutput<typeof openDrainConfiguration>;\n\nconst partialAnalogOutputConfiguration = v.omit(analogOutputConfiguration, ['direction', 'mode']);\nexport type PartialAnalogOutputConfiguration = v.InferOutput<\n typeof partialAnalogOutputConfiguration\n>;\nconst partialDigitalInputConfiguration = v.omit(digitalInputConfiguration, ['direction', 'mode']);\nexport type PartialDigitalInputConfiguration = v.InferOutput<\n typeof partialDigitalInputConfiguration\n>;\nconst partialDigitalOutputConfiguration = v.partial(\n v.omit(digitalOutputConfiguration, ['direction', 'mode']),\n ['vih', 'vil'],\n);\nexport type PartialDigitalOutputConfiguration = v.InferInput<\n typeof partialDigitalOutputConfiguration\n>;\nconst partialOpenDrainConfiguration = v.omit(openDrainConfiguration, ['direction', 'mode']);\nexport type PartialOpenDrainConfiguration = v.InferOutput<typeof partialOpenDrainConfiguration>;\n\nexport const digitalState = v.object({ value: digitalLevel });\nexport const analogState = v.object({ value: analogLevel });\n\nconst syncConfiguration = v.object({ action: syncAction });\nexport type SyncConfiguration = v.InferOutput<typeof syncConfiguration>;\n\nexport const syncState = v.object({ hold_state: v.picklist(['held', 'released']) });\nexport type SyncState = v.InferOutput<typeof syncState>;\n\nexport const gpioConfiguration = v.union([\n digitalOutputConfiguration,\n openDrainConfiguration,\n digitalInputConfiguration,\n analogOutputConfiguration,\n analogInputConfiguration,\n]);\nexport type GpioConfiguration = v.InferOutput<typeof gpioConfiguration>;\n\n/** @hideconstructor */\nexport class GpioApi {\n private count: number;\n\n constructor(private readonly fetch: UpFetch, info: Information) {\n this.count = info.capabilities.io.count;\n }\n\n /**\n * Resets all IO configurations to default.\n */\n reset(): Promise<void> {\n return this.fetch('/gpio/reset', { method: 'POST', parseResponse: () => {} });\n }\n\n /**\n * Access a specific digital IO pin by id.\n * @param io The IO pin id.\n * @returns The digital IO instance.\n */\n digital(io: number): DigitalIO {\n if (io < 0 || io >= this.count) {\n throw new Error(\n `Invalid GPIO pin ${io} (RESOURCE_NOT_FOUND)\\n Suggestion: Use a pin number between 0 and ${\n this.count - 1\n }\\n Path: /gpio/${io}`,\n );\n }\n\n return new DigitalIO(this.fetch, io);\n }\n\n /**\n * Access a specific analog IO pin by id.\n * @param io The IO pin id.\n * @returns The analog IO instance.\n */\n analog(io: number): AnalogIO {\n if (io < 0 || io >= this.count) {\n throw new Error(\n `Invalid GPIO pin ${io} (RESOURCE_NOT_FOUND)\\n Suggestion: Use a pin number between 0 and ${\n this.count - 1\n }\\n Path: /gpio/${io}`,\n );\n }\n\n return new AnalogIO(this.fetch, io);\n }\n\n /**\n * Holds the current state of all GPIO pins.\n * @returns The applied sync state.\n */\n hold(): Promise<SyncConfiguration> {\n return this.fetch('/gpio/sync', {\n method: 'POST',\n body: { action: 'hold' } satisfies SyncConfiguration,\n schema: syncConfiguration,\n });\n }\n\n /**\n * Releases control of the IO pins, allowing external control.\n *\n * This also sets the device as a slave.\n *\n * @returns The applied sync state.\n */\n release(): Promise<SyncConfiguration> {\n return this.fetch('/gpio/sync', {\n method: 'POST',\n body: { action: 'release' } satisfies SyncConfiguration,\n schema: syncConfiguration,\n });\n }\n\n /**\n * Reads back the current configuration of a specific IO pin.\n * @param io The IO pin id.\n * @returns The pin's current configuration.\n */\n read_config(io: number): Promise<GpioConfiguration> {\n if (io < 0 || io >= this.count) {\n throw new Error(\n `Invalid GPIO pin ${io} (RESOURCE_NOT_FOUND)\\n Suggestion: Use a pin number between 0 and ${\n this.count - 1\n }\\n Path: /gpio/${io}/config`,\n );\n }\n\n return this.fetch(`/gpio/${io}/config`, { schema: gpioConfiguration });\n }\n\n /**\n * Reads the current hold state of all GPIO pins.\n * @returns The current sync state.\n */\n read_sync(): Promise<SyncState> {\n return this.fetch('/gpio/sync', { schema: syncState });\n }\n}\n\n/** @hideconstructor */\nexport class DigitalIO {\n constructor(private readonly fetch: UpFetch, public readonly id: number) {}\n\n /**\n * Configure the pin as a digital input.\n * @param config The digital input configuration.\n * @returns The applied configuration.\n */\n configure_input(config: PartialDigitalInputConfiguration): Promise<DigitalInputConfiguration> {\n return this.fetch(`/gpio/${this.id}/config`, {\n method: 'PATCH',\n body: v.parse(\n digitalInputConfiguration,\n { ...config, mode: 'digital', direction: 'input' } satisfies DigitalInputConfiguration,\n ),\n schema: digitalInputConfiguration,\n });\n }\n\n /**\n * Configures the pin as a digital output.\n * @param config The digital output configuration.\n * @returns The applied configuration.\n */\n configure_output(config: PartialDigitalOutputConfiguration): Promise<DigitalOutputConfiguration> {\n config = v.parse(partialDigitalOutputConfiguration, config);\n\n const fullConfig = {\n mode: 'digital' as const,\n direction: 'output' as const,\n value: config.value,\n vol: config.vol,\n voh: config.voh,\n vil: config.vil ?? config.vol + (config.voh - config.vol) / 4,\n vih: config.vih ?? config.voh - (config.voh - config.vol) / 4,\n };\n\n return this.fetch(`/gpio/${this.id}/config`, {\n method: 'PATCH',\n body: v.parse(digitalOutputConfiguration, fullConfig),\n schema: digitalOutputConfiguration,\n });\n }\n\n /**\n * Reads the current state of the pin.\n * @returns The current state of the pin.\n */\n async read(): Promise<boolean> {\n return (await this.fetch(`/gpio/${this.id}/state`, { schema: digitalState })).value;\n }\n\n /**\n * Writes a value to the pin.\n * @param value The value to write.\n * @returns The written value.\n */\n async write(value: boolean | number): Promise<boolean> {\n return (await this.fetch(`/gpio/${this.id}/state`, {\n method: 'PUT',\n body: v.parse(digitalState, { value }),\n schema: digitalState,\n }))\n .value;\n }\n\n /**\n * Configure the pin as an open drain output.\n * @param config The open drain configuration.\n * @returns The applied configuration.\n */\n configure_open_drain(config: PartialOpenDrainConfiguration): Promise<OpenDrainConfiguration> {\n return this.fetch(`/gpio/${this.id}/config`, {\n method: 'PATCH',\n body: v.parse(\n openDrainConfiguration,\n { ...config, mode: 'digital', direction: 'open_drain' } satisfies OpenDrainConfiguration,\n ),\n schema: openDrainConfiguration,\n });\n }\n}\n\n/** @hideconstructor */\nexport class AnalogIO {\n constructor(private readonly fetch: UpFetch, public readonly id: number) {}\n\n /**\n * Configures the pin as an analog input.\n * @returns The applied configuration.\n * @returns The applied configuration.\n */\n configure_input(): Promise<AnalogInputConfiguration> {\n return this.fetch(`/gpio/${this.id}/config`, {\n method: 'PATCH',\n body: { mode: 'analog', direction: 'input' } satisfies AnalogInputConfiguration,\n schema: analogInputConfiguration,\n });\n }\n\n /**\n * Configures the pin as an analog output.\n * @param config The analog output configuration.\n * @returns The applied configuration.\n */\n configure_output(value: AnalogOutputLevel): Promise<AnalogOutputConfiguration> {\n return this.fetch(`/gpio/${this.id}/config`, {\n method: 'PATCH',\n body: v.parse(\n analogOutputConfiguration,\n { value, mode: 'analog', direction: 'output' } satisfies AnalogOutputConfiguration,\n ),\n schema: analogOutputConfiguration,\n });\n }\n\n /**\n * Reads the current state of the pin.\n * @returns The current state of the pin.\n */\n async read(): Promise<number> {\n return (await this.fetch(`/gpio/${this.id}/state`, { schema: analogState })).value;\n }\n\n /**\n * Writes a value to the pin.\n * @param value The value to write.\n * @returns The written value.\n */\n async write(value: number): Promise<number> {\n return (await this.fetch(`/gpio/${this.id}/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B,CAA5C,KAAA,MAAA,EAAgC,KAAA,GAAA,CAAa,CAO1E,iBAAqD,CACnD,OAAO,KAAK,MAAM,SAAS,KAAK,GAAG,SAAU,CAC3C,OAAQ,QACR,KAAM,CAAE,KAAM,SAAU,UAAW,OAAQ,EAC3C,OAAQ,CACV,CAAC,CACH,CAOA,iBAAiB,EAA8D,CAC7E,OAAO,KAAK,MAAM,SAAS,KAAK,GAAG,SAAU,CAC3C,OAAQ,QACR,KAAM,EAAE,MACN,EACA,CAAE,QAAO,KAAM,SAAU,UAAW,QAAS,CAC/C,EACA,OAAQ,CACV,CAAC,CACH,CAMA,MAAM,MAAwB,CAC5B,OAAQ,MAAM,KAAK,MAAM,SAAS,KAAK,GAAG,QAAS,CAAE,OAAQ,CAAY,CAAC,EAAA,CAAG,KAC/E,CAOA,MAAM,MAAM,EAAgC,CAC1C,OAAQ,MAAM,KAAK,MAAM,SAAS,KAAK,GAAG,QAAS,CACjD,OAAQ,MACR,KAAM,CAAE,OAAM,EACd,OAAQ,CACV,CAAC,EAAA,CACE,KACL,CACF"}
|
|
1
|
+
{"version":3,"file":"gpio.mjs","names":[],"sources":["../src/api/gpio.ts"],"sourcesContent":["import type { UpFetch } from 'up-fetch';\nimport * as v from 'valibot';\n\nimport { type AnalogOutputLevel, analogLevel, analogOutputLevel, digitalLevel } from './common';\nimport type { Information } from './management';\n\nexport type { AnalogOutputLevel };\n\nconst syncAction = v.picklist(['release', 'hold'], 'Invalid sync action');\nexport const analogInputConfiguration = v.object({\n mode: v.literal('analog'),\n direction: v.literal('input'),\n});\nexport const analogOutputConfiguration = v.object({\n mode: v.literal('analog'),\n direction: v.literal('output'),\n value: v.optional(analogOutputLevel),\n});\n/**\n * Input thresholds `vil` and `vih` are in [-25, 25] V, inclusive.\n */\nexport const digitalInputConfiguration = v.object({\n mode: v.literal('digital'),\n direction: v.literal('input'),\n vil: analogLevel,\n vih: analogLevel,\n});\n/**\n * Readback thresholds `vil` and `vih` are in [-25, 25] V, inclusive.\n * Output levels `vol` and `voh` are in [0, 24] V, inclusive.\n */\nexport const digitalOutputConfiguration = v.object({\n mode: v.literal('digital'),\n direction: v.literal('output'),\n value: digitalLevel,\n vol: analogOutputLevel,\n voh: analogOutputLevel,\n vil: analogLevel,\n vih: analogLevel,\n});\n/**\n * Readback thresholds `vil` and `vih` are in [-25, 25] V, inclusive.\n */\nexport const openDrainConfiguration = v.object({\n mode: v.literal('digital'),\n direction: v.literal('open_drain'),\n value: digitalLevel,\n vil: analogLevel,\n vih: analogLevel,\n});\nexport type AnalogInputConfiguration = v.InferOutput<typeof analogInputConfiguration>;\nexport type AnalogOutputConfiguration = v.InferOutput<typeof analogOutputConfiguration>;\nexport type DigitalInputConfiguration = v.InferOutput<typeof digitalInputConfiguration>;\nexport type DigitalOutputConfiguration = v.InferOutput<typeof digitalOutputConfiguration>;\nexport type OpenDrainConfiguration = v.InferOutput<typeof openDrainConfiguration>;\n\nconst partialAnalogOutputConfiguration = v.omit(analogOutputConfiguration, ['direction', 'mode']);\nexport type PartialAnalogOutputConfiguration = v.InferOutput<\n typeof partialAnalogOutputConfiguration\n>;\nconst partialDigitalInputConfiguration = v.omit(digitalInputConfiguration, ['direction', 'mode']);\nexport type PartialDigitalInputConfiguration = v.InferOutput<\n typeof partialDigitalInputConfiguration\n>;\nconst partialDigitalOutputConfiguration = v.partial(\n v.omit(digitalOutputConfiguration, ['direction', 'mode']),\n ['vih', 'vil'],\n);\nexport type PartialDigitalOutputConfiguration = v.InferInput<\n typeof partialDigitalOutputConfiguration\n>;\nconst partialOpenDrainConfiguration = v.omit(openDrainConfiguration, ['direction', 'mode']);\nexport type PartialOpenDrainConfiguration = v.InferOutput<typeof partialOpenDrainConfiguration>;\n\nexport const digitalState = v.object({ value: digitalLevel });\nexport const analogState = v.object({ value: analogLevel });\n\nconst syncConfiguration = v.object({ action: syncAction });\nexport type SyncConfiguration = v.InferOutput<typeof syncConfiguration>;\n\nexport const syncState = v.object({ hold_state: v.picklist(['held', 'released']) });\nexport type SyncState = v.InferOutput<typeof syncState>;\n\nexport const gpioConfiguration = v.union([\n digitalOutputConfiguration,\n openDrainConfiguration,\n digitalInputConfiguration,\n analogOutputConfiguration,\n analogInputConfiguration,\n]);\nexport type GpioConfiguration = v.InferOutput<typeof gpioConfiguration>;\n\n/** @hideconstructor */\nexport class GpioApi {\n private count: number;\n\n constructor(private readonly fetch: UpFetch, info: Information) {\n this.count = info.capabilities.io.count;\n }\n\n /**\n * Resets all IO configurations to default.\n */\n reset(): Promise<void> {\n return this.fetch('/gpio/reset', { method: 'POST', parseResponse: () => {} });\n }\n\n /**\n * Access a specific digital IO pin by id.\n * @param io The IO pin id.\n * @returns The digital IO instance.\n */\n digital(io: number): DigitalIO {\n if (io < 0 || io >= this.count) {\n throw new Error(\n `Invalid GPIO pin ${io} (RESOURCE_NOT_FOUND)\\n Suggestion: Use a pin number between 0 and ${\n this.count - 1\n }\\n Path: /gpio/${io}`,\n );\n }\n\n return new DigitalIO(this.fetch, io);\n }\n\n /**\n * Access a specific analog IO pin by id.\n * @param io The IO pin id.\n * @returns The analog IO instance.\n */\n analog(io: number): AnalogIO {\n if (io < 0 || io >= this.count) {\n throw new Error(\n `Invalid GPIO pin ${io} (RESOURCE_NOT_FOUND)\\n Suggestion: Use a pin number between 0 and ${\n this.count - 1\n }\\n Path: /gpio/${io}`,\n );\n }\n\n return new AnalogIO(this.fetch, io);\n }\n\n /**\n * Holds the current state of all GPIO pins.\n * @returns The applied sync state.\n */\n hold(): Promise<SyncConfiguration> {\n return this.fetch('/gpio/sync', {\n method: 'POST',\n body: { action: 'hold' } satisfies SyncConfiguration,\n schema: syncConfiguration,\n });\n }\n\n /**\n * Releases control of the IO pins, allowing external control.\n *\n * This also sets the device as a slave.\n *\n * @returns The applied sync state.\n */\n release(): Promise<SyncConfiguration> {\n return this.fetch('/gpio/sync', {\n method: 'POST',\n body: { action: 'release' } satisfies SyncConfiguration,\n schema: syncConfiguration,\n });\n }\n\n /**\n * Reads back the current configuration of a specific IO pin.\n * @param io The IO pin id.\n * @returns The pin's current configuration.\n */\n read_config(io: number): Promise<GpioConfiguration> {\n if (io < 0 || io >= this.count) {\n throw new Error(\n `Invalid GPIO pin ${io} (RESOURCE_NOT_FOUND)\\n Suggestion: Use a pin number between 0 and ${\n this.count - 1\n }\\n Path: /gpio/${io}/config`,\n );\n }\n\n return this.fetch(`/gpio/${io}/config`, { schema: gpioConfiguration });\n }\n\n /**\n * Reads the current hold state of all GPIO pins.\n * @returns The current sync state.\n */\n read_sync(): Promise<SyncState> {\n return this.fetch('/gpio/sync', { schema: syncState });\n }\n}\n\n/** @hideconstructor */\nexport class DigitalIO {\n constructor(private readonly fetch: UpFetch, public readonly id: number) {}\n\n /**\n * Configure the pin as a digital input.\n * @param config The digital input configuration.\n * @returns The applied configuration.\n */\n configure_input(config: PartialDigitalInputConfiguration): Promise<DigitalInputConfiguration> {\n return this.fetch(`/gpio/${this.id}/config`, {\n method: 'PATCH',\n body: v.parse(\n digitalInputConfiguration,\n { ...config, mode: 'digital', direction: 'input' } satisfies DigitalInputConfiguration,\n ),\n schema: digitalInputConfiguration,\n });\n }\n\n /**\n * Configures the pin as a digital output.\n * @param config The digital output configuration.\n * @returns The applied configuration.\n */\n configure_output(config: PartialDigitalOutputConfiguration): Promise<DigitalOutputConfiguration> {\n config = v.parse(partialDigitalOutputConfiguration, config);\n\n const fullConfig = {\n mode: 'digital' as const,\n direction: 'output' as const,\n value: config.value,\n vol: config.vol,\n voh: config.voh,\n vil: config.vil ?? config.vol + (config.voh - config.vol) / 4,\n vih: config.vih ?? config.voh - (config.voh - config.vol) / 4,\n };\n\n return this.fetch(`/gpio/${this.id}/config`, {\n method: 'PATCH',\n body: v.parse(digitalOutputConfiguration, fullConfig),\n schema: digitalOutputConfiguration,\n });\n }\n\n /**\n * Reads the current state of the pin.\n * @returns The current state of the pin.\n */\n async read(): Promise<boolean> {\n return (await this.fetch(`/gpio/${this.id}/state`, { schema: digitalState })).value;\n }\n\n /**\n * Writes a value to the pin.\n * @param value The value to write.\n * @returns The written value.\n */\n async write(value: boolean | number): Promise<boolean> {\n return (await this.fetch(`/gpio/${this.id}/state`, {\n method: 'PUT',\n body: v.parse(digitalState, { value }),\n schema: digitalState,\n }))\n .value;\n }\n\n /**\n * Configure the pin as an open drain output.\n * @param config The open drain configuration.\n * @returns The applied configuration.\n */\n configure_open_drain(config: PartialOpenDrainConfiguration): Promise<OpenDrainConfiguration> {\n return this.fetch(`/gpio/${this.id}/config`, {\n method: 'PATCH',\n body: v.parse(\n openDrainConfiguration,\n { ...config, mode: 'digital', direction: 'open_drain' } satisfies OpenDrainConfiguration,\n ),\n schema: openDrainConfiguration,\n });\n }\n}\n\n/** @hideconstructor */\nexport class AnalogIO {\n constructor(private readonly fetch: UpFetch, public readonly id: number) {}\n\n /**\n * Configures the pin as an analog input.\n * @returns The applied configuration.\n * @returns The applied configuration.\n */\n configure_input(): Promise<AnalogInputConfiguration> {\n return this.fetch(`/gpio/${this.id}/config`, {\n method: 'PATCH',\n body: { mode: 'analog', direction: 'input' } satisfies AnalogInputConfiguration,\n schema: analogInputConfiguration,\n });\n }\n\n /**\n * Configures the pin as an analog output.\n * @param config The analog output configuration.\n * @returns The applied configuration.\n */\n configure_output(value: AnalogOutputLevel): Promise<AnalogOutputConfiguration> {\n return this.fetch(`/gpio/${this.id}/config`, {\n method: 'PATCH',\n body: v.parse(\n analogOutputConfiguration,\n { value, mode: 'analog', direction: 'output' } satisfies AnalogOutputConfiguration,\n ),\n schema: analogOutputConfiguration,\n });\n }\n\n /**\n * Reads the current state of the pin.\n * @returns The current state of the pin.\n */\n async read(): Promise<number> {\n return (await this.fetch(`/gpio/${this.id}/state`, { schema: analogState })).value;\n }\n\n /**\n * Writes a value to the pin.\n * @param value The value to write.\n * @returns The written value.\n */\n async write(value: number): Promise<number> {\n return (await this.fetch(`/gpio/${this.id}/state`, {\n method: 'PUT',\n body: { value },\n schema: analogState,\n }))\n .value;\n }\n}\n"],"mappings":"kFAQA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OAAO,KAAK,MAAM,SAAS,KAAK,GAAG,SAAU,CAC3C,OAAQ,QACR,KAAM,CAAE,KAAM,SAAU,UAAW,OAAQ,EAC3C,OAAQ,CACV,CAAC,CACH,CAOA,iBAAiB,EAA8D,CAC7E,OAAO,KAAK,MAAM,SAAS,KAAK,GAAG,SAAU,CAC3C,OAAQ,QACR,KAAM,EAAE,MACN,EACA,CAAE,QAAO,KAAM,SAAU,UAAW,QAAS,CAC/C,EACA,OAAQ,CACV,CAAC,CACH,CAMA,MAAM,MAAwB,CAC5B,OAAQ,MAAM,KAAK,MAAM,SAAS,KAAK,GAAG,QAAS,CAAE,OAAQ,CAAY,CAAC,EAAA,CAAG,KAC/E,CAOA,MAAM,MAAM,EAAgC,CAC1C,OAAQ,MAAM,KAAK,MAAM,SAAS,KAAK,GAAG,QAAS,CACjD,OAAQ,MACR,KAAM,CAAE,OAAM,EACd,OAAQ,CACV,CAAC,EAAA,CACE,KACL,CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { s as ComApi } from "./com-
|
|
1
|
+
import { s as ComApi } from "./com-XQjoTBdU.cjs";
|
|
2
2
|
import { i as EventsApi } from "./events-Cf7iAMZP.cjs";
|
|
3
3
|
import { Information, ManagementApi } from "./management.cjs";
|
|
4
|
-
import { s as GpioApi } from "./gpio-
|
|
4
|
+
import { s as GpioApi } from "./gpio-Bk1VEKYF.cjs";
|
|
5
5
|
import { r as HmiApi } from "./hmi-B-potLdl.cjs";
|
|
6
6
|
import { i as PowerApi } from "./power-B8QFbKdP.cjs";
|
|
7
7
|
import { n as RelaysApi } from "./relays-TADiLsPk.cjs";
|
|
@@ -21,15 +21,6 @@ declare class ApiError extends Error {
|
|
|
21
21
|
path: string;
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Formats a host into a URL authority. Returns `host` unchanged when it already
|
|
26
|
-
* carries an explicit port; otherwise appends `fallbackPort` (the device's
|
|
27
|
-
* mDNS-advertised port when known, else the default 8080). Bare IPv6 literals
|
|
28
|
-
* are bracketed. Idempotent: re-formatting an authority is a no-op.
|
|
29
|
-
*/
|
|
30
|
-
declare function format_host_for_url(host: string, fallbackPort?: number): string;
|
|
31
|
-
/** Returns the bare host (IP or hostname) from a URL authority, dropping any port. */
|
|
32
|
-
declare function host_without_port(host: string): string;
|
|
33
24
|
/** Options for opening a device. */
|
|
34
25
|
interface OpenOptions {
|
|
35
26
|
/** Open read-only: skip `session/open`, mint no token, send no session header. */
|
|
@@ -99,5 +90,16 @@ declare class AT1000Base {
|
|
|
99
90
|
}): Promise<AT1000Base>;
|
|
100
91
|
}
|
|
101
92
|
//#endregion
|
|
102
|
-
|
|
103
|
-
|
|
93
|
+
//#region src/host.d.ts
|
|
94
|
+
/**
|
|
95
|
+
* Formats a host into a URL authority. Returns `host` unchanged when it already
|
|
96
|
+
* carries an explicit port; otherwise appends `fallbackPort` (the device's
|
|
97
|
+
* mDNS-advertised port when known, else the default 8080). Bare IPv6 literals
|
|
98
|
+
* are bracketed. Idempotent: re-formatting an authority is a no-op.
|
|
99
|
+
*/
|
|
100
|
+
declare function format_host_for_url(host: string, fallbackPort?: number): string;
|
|
101
|
+
/** Returns the bare host (IP or hostname) from a URL authority, dropping any port. */
|
|
102
|
+
declare function host_without_port(host: string): string;
|
|
103
|
+
//#endregion
|
|
104
|
+
export { OpenOptions as a, ApiError as i, host_without_port as n, AT1000Base as r, format_host_for_url as t };
|
|
105
|
+
//# sourceMappingURL=host-BCOEcUog.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-BCOEcUog.d.cts","names":[],"sources":["../src/at1000.ts","../src/host.ts"],"mappings":";;;;;;;;;;cAaa,iBAAiB;WACnB;;WAEA;WACA;WACA;EAEG,YAAA;IAAQ;IAAc;IAAiB;IAAoB;;;;UAoDxD;;EAEf;;EAEA;;;cAIW;;;;WAIK;;;;WAIA,MAAM;;;;;WAKN;;;;;WAKA;UAER;;;;WAIQ,KAAK;;;;WAIL,KAAK;;;;WAIL,MAAM;;;;WAIN,YAAY;;;;WAIZ,OAAO;;;;WAIP,QAAQ;;;;WAIR,QAAQ;;;;WAIR,SAAS;EAEb,YAAA,cAAc,MAAM,aAAa,gBAAgB;EA4BvD,SAAK;mBAQY,SACrB,cACA,UAAU,aACV;IAAY;IAA4B;IAAkB;MACzD,QAAQ;;;;;;;;;;iBCtKG,oBAAoB,cAAc;;iBAgBlC,kBAAkB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { s as ComApi } from "./com-
|
|
1
|
+
import { s as ComApi } from "./com-XQjoTBdU.mjs";
|
|
2
2
|
import { i as EventsApi } from "./events-Cf7iAMZP.mjs";
|
|
3
3
|
import { Information, ManagementApi } from "./management.mjs";
|
|
4
|
-
import { s as GpioApi } from "./gpio-
|
|
4
|
+
import { s as GpioApi } from "./gpio-bFe112uI.mjs";
|
|
5
5
|
import { r as HmiApi } from "./hmi-B-potLdl.mjs";
|
|
6
6
|
import { i as PowerApi } from "./power-BZmXOJyK.mjs";
|
|
7
7
|
import { n as RelaysApi } from "./relays-TADiLsPk.mjs";
|
|
@@ -21,15 +21,6 @@ declare class ApiError extends Error {
|
|
|
21
21
|
path: string;
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Formats a host into a URL authority. Returns `host` unchanged when it already
|
|
26
|
-
* carries an explicit port; otherwise appends `fallbackPort` (the device's
|
|
27
|
-
* mDNS-advertised port when known, else the default 8080). Bare IPv6 literals
|
|
28
|
-
* are bracketed. Idempotent: re-formatting an authority is a no-op.
|
|
29
|
-
*/
|
|
30
|
-
declare function format_host_for_url(host: string, fallbackPort?: number): string;
|
|
31
|
-
/** Returns the bare host (IP or hostname) from a URL authority, dropping any port. */
|
|
32
|
-
declare function host_without_port(host: string): string;
|
|
33
24
|
/** Options for opening a device. */
|
|
34
25
|
interface OpenOptions {
|
|
35
26
|
/** Open read-only: skip `session/open`, mint no token, send no session header. */
|
|
@@ -99,5 +90,16 @@ declare class AT1000Base {
|
|
|
99
90
|
}): Promise<AT1000Base>;
|
|
100
91
|
}
|
|
101
92
|
//#endregion
|
|
102
|
-
|
|
103
|
-
|
|
93
|
+
//#region src/host.d.ts
|
|
94
|
+
/**
|
|
95
|
+
* Formats a host into a URL authority. Returns `host` unchanged when it already
|
|
96
|
+
* carries an explicit port; otherwise appends `fallbackPort` (the device's
|
|
97
|
+
* mDNS-advertised port when known, else the default 8080). Bare IPv6 literals
|
|
98
|
+
* are bracketed. Idempotent: re-formatting an authority is a no-op.
|
|
99
|
+
*/
|
|
100
|
+
declare function format_host_for_url(host: string, fallbackPort?: number): string;
|
|
101
|
+
/** Returns the bare host (IP or hostname) from a URL authority, dropping any port. */
|
|
102
|
+
declare function host_without_port(host: string): string;
|
|
103
|
+
//#endregion
|
|
104
|
+
export { OpenOptions as a, ApiError as i, host_without_port as n, AT1000Base as r, format_host_for_url as t };
|
|
105
|
+
//# sourceMappingURL=host-DJ8SAGMC.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-DJ8SAGMC.d.mts","names":[],"sources":["../src/at1000.ts","../src/host.ts"],"mappings":";;;;;;;;;;cAaa,iBAAiB;WACnB;;WAEA;WACA;WACA;EAEG,YAAA;IAAQ;IAAc;IAAiB;IAAoB;;;;UAoDxD;;EAEf;;EAEA;;;cAIW;;;;WAIK;;;;WAIA,MAAM;;;;;WAKN;;;;;WAKA;UAER;;;;WAIQ,KAAK;;;;WAIL,KAAK;;;;WAIL,MAAM;;;;WAIN,YAAY;;;;WAIZ,OAAO;;;;WAIP,QAAQ;;;;WAIR,QAAQ;;;;WAIR,SAAS;EAEb,YAAA,cAAc,MAAM,aAAa,gBAAgB;EA4BvD,SAAK;mBAQY,SACrB,cACA,UAAU,aACV;IAAY;IAA4B;IAAkB;MACzD,QAAQ;;;;;;;;;;iBCtKG,oBAAoB,cAAc;;iBAgBlC,kBAAkB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime-CMqjfN_6.cjs"),t=require("./common-BSrNhbq_.cjs");require("up-fetch");let n=require("valibot");n=e.t(n,1);function r(e,t){let n=t||8080;if(e.startsWith(`[`))return e.includes(`]:`)?e:`${e}:${n}`;let r=e.indexOf(`:`);return r===-1?`${e}:${n}`:r===e.lastIndexOf(`:`)?e:`[${e}]:${n}`}function i(e){if(e.startsWith(`[`)){let t=e.indexOf(`]`);return t===-1?e:e.slice(1,t)}let t=e.indexOf(`:`);return t!==-1&&t===e.lastIndexOf(`:`)?e.slice(0,t):e}let a=function(e){return e.Can=`can`,e.Rs232=`rs232`,e.Rs485=`rs485`,e.I2c=`i2c`,e.Spi=`spi`,e.Uart=`uart`,e}({});const o=n.enum(a),s=n.object({min:n.pipe(n.number(),n.minValue(-24),n.maxValue(24)),max:n.pipe(n.number(),n.minValue(-24),n.maxValue(24))}),c=n.object({min:t.t,max:t.t}),l=n.object({max:n.number()}),u=n.object({count:n.pipe(n.number(),n.minValue(1)),input_voltage:c,output_voltage:s}),d=n.object({count:n.pipe(n.number(),n.minValue(0)),max_current:n.number(),max_voltage:n.number(),on_resistance:n.pipe(n.number(),n.minValue(0))}),f=n.object({type:n.picklist([`3.0`,`2.0`]),count:n.pipe(n.number(),n.minValue(1))}),p=n.object({type:n.picklist([`1000BASE-T`,`100BASE-T`,`10BASE-T`]),count:n.pipe(n.number(),n.minValue(1))}),m=n.object({type:o,count:n.pipe(n.number(),n.minValue(1))}),h=n.object({count:n.pipe(n.number(),n.minValue(1)),output_voltage:s,current:l}),g=n.object({type:n.picklist([`low_precision`,`high_precision`]),source:n.string(),resolution:n.pipe(n.number(),n.minValue(0))}),_=n.object({width:n.pipe(n.number(),n.minValue(1)),height:n.pipe(n.number(),n.minValue(1))}),v=n.object({type:n.string(),size:_}),y=n.object({count:n.pipe(n.number(),n.minValue(0)),type:n.string()}),b=n.object({count:n.pipe(n.number(),n.minValue(0)),type:n.string()}),x=n.object({display:v,input:y,speaker:b}),S=n.object({io:u,relays:d,usb_ports:n.array(f),ethernet:n.array(p),communication:n.array(m),power_supply:h,current_measurement:n.array(g),hmi:x}),C=n.object({model:n.string(),hostname:n.string(),serial_number:n.string(),firmware_version:n.string(),firmware_commit:n.string(),hardware_version:n.optional(n.number()),disk_used:n.number(),disk_total:n.number(),docker_used:n.number(),ram_used:n.optional(n.number()),ram_total:n.optional(n.number()),cpu_temperature:n.optional(n.number()),capabilities:S}),w=n.picklist([`idle`,`running`,`error`]),T=n.picklist([`created`,`started`,`stopped`,`removed`,`error`]),E=n.picklist([`tcp`,`udp`]),D=n.pipe(n.number(),n.integer(),n.minValue(1),n.maxValue(65535)),O=n.object({host:D,container:D,proto:E}),k=n.pipe(n.string(),n.trim(),n.regex(/^(ssh-|ecdsa-sha2-|sk-ssh-|sk-ecdsa-)/,`Not a recognized SSH public key`)),A=n.picklist([`normal`,`development`]),j=n.object({stream:n.picklist([`stdout`,`stderr`]),line:n.string()}),M=n.object({name:n.string(),path:n.string(),id:n.string(),image:n.string(),is_default:n.boolean(),ports:n.optional(n.array(O),[]),command:n.optional(n.string(),``),state:w,mode:n.optional(A),password_set:n.optional(n.boolean())}),N=n.variant(`change`,[n.object({change:n.literal(`state_changed`),id:n.string(),state:T}),n.object({change:n.literal(`renamed`),id:n.string(),name:n.string()}),n.object({change:n.literal(`default_changed`),id:n.string(),is_default:n.boolean()})]),P=n.partial(n.pick(M,[`name`,`is_default`,`command`])),F=n.picklist([`nodejs`,`python`]);n.object({name:n.string(),template:F,command:n.optional(n.string())});const I=n.object({bundle:n.string(),version:n.string(),compatible:n.string(),description:n.string()}),L=n.object({message:n.string(),bundle:n.string()}),R=n.object({state:n.picklist([`idle`,`installing`,`failed`]),progress:n.number(),message:n.string(),error:n.string(),boot:n.optional(n.picklist([`confirmed`,`pending`,`unknown`]))}),z=n.object({message:n.string()}),B=n.pipe(n.number(),n.finite()),V=n.pipe(n.number(),n.finite(),n.minValue(Number.MIN_VALUE)),H=n.pipe(n.number(),n.integer(),n.minValue(0),n.maxValue(31)),U=n.pipe(n.number(),n.integer(),n.minValue(0),n.maxValue(7)),W=n.pipe(n.number(),n.integer(),n.minValue(0),n.maxValue(1)),G=n.picklist([`pass`,`fail`]),K=n.object({set:B,measured:B,reading:n.optional(B)}),q=n.object({channel:H,points:n.array(K),max_error:B,avg_error:B}),J=n.object({voltage:n.object({points:n.array(K),max_error:B,avg_error:B}),current:n.object({load_ohms:V,points:n.array(K),max_error:B,avg_error:B})}),Y=n.object({load_ohms:V,voltage_applied:B,measured_current:B,expected_current:B,error_percent:B}),X=n.object({relay:U,status:G,test_voltage:B,closed_current:B,open_current:B,calibration:n.optional(q)}),Z=n.object({port:W,status:G,voltage:B,current_tests:n.optional(n.array(Y))}),Q=n.object({schema_version:n.literal(1),tool_version:n.string(),device_id:n.string(),timestamp:n.string(),firmware_version:n.string(),dac:n.array(q),adc_positive:n.array(q),adc_negative:n.optional(n.array(q)),dut_psu:J,relays:n.array(X),usb:n.array(Z)}),$=n.object({enabled:n.boolean(),loaded:n.boolean(),last_error:n.optional(n.nullable(n.string())),calibrated_at:n.optional(n.nullable(n.string()))}),ee=n.object({enabled:n.boolean()});var te=class{fetch;host;constructor(e,t){this.fetch=e,this.host=t}info(){return this.fetch(`/management/info`,{schema:C})}get_calibration(){return this.fetch(`/management/calibration`,{schema:Q})}set_calibration(e){return this.fetch(`/management/calibration`,{method:`PUT`,body:n.parse(Q,e),schema:Q})}get_calibration_state(){return this.fetch(`/management/calibration/state`,{schema:$})}set_calibration_enabled(e){return this.fetch(`/management/calibration/state`,{method:`PATCH`,body:n.parse(ee,{enabled:e}),schema:$})}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:n.object({epoch_seconds:n.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:n.array(M)})}listImages(){return this.fetch(`/management/images`,{schema:n.array(n.string())})}getProject(e){return this.fetch(`/management/projects/${e}`,{schema:M})}createProject(e){return this.fetch(`/management/projects`,{method:`POST`,body:e,timeout:3e4,schema:M})}importProject(e,t){return this.fetch(`/management/projects/import`,{method:`POST`,body:e,headers:{"Content-Type":`application/x-tar`,"X-Project-Name":encodeURIComponent(t)},serializeBody:e=>e,timeout:6e5,schema:M})}updateProject(e,t){return this.fetch(`/management/projects/${e}`,{method:`PATCH`,body:n.parse(P,t),schema:M})}runProject(e,t=`normal`){return this.fetch(`/management/projects/${e}/run`,{method:`POST`,body:{mode:t},timeout:3e4})}stopProject(e){return this.fetch(`/management/projects/${e}/stop`,{method:`POST`,timeout:3e4})}getProjectPorts(e){return this.fetch(`/management/projects/${e}/ports`,{schema:n.array(O)})}setProjectPorts(e,t){return this.fetch(`/management/projects/${e}/ports`,{method:`PUT`,body:n.parse(n.array(O),t),timeout:3e4,schema:n.array(O)})}addProjectPort(e,t){return this.fetch(`/management/projects/${e}/ports`,{method:`POST`,body:n.parse(O,t),timeout:3e4,schema:n.array(O)})}deleteProjectPort(e,t){return this.fetch(`/management/projects/${e}/ports/${t}`,{method:`DELETE`,parseResponse:()=>{},timeout:3e4})}setProjectPassword(e,t){return this.fetch(`/management/projects/${e}/password`,{method:`POST`,body:n.parse(n.object({password:n.pipe(n.string(),n.minLength(1))}),{password:t}),parseResponse:()=>{},timeout:3e4})}getProjectAuthorizedKeys(e){return this.fetch(`/management/projects/${e}/authorized_keys`,{schema:n.array(n.string())})}setProjectAuthorizedKeys(e,t){return this.fetch(`/management/projects/${e}/authorized_keys`,{method:`PUT`,body:n.parse(n.array(k),t),timeout:3e4,schema:n.array(n.string())})}deleteProject(e){return this.fetch(`/management/projects/${e}`,{method:`DELETE`,timeout:3e4})}upload_bundle(e,t=`bundle.raucb`){return this.fetch(`/management/update/upload`,{method:`POST`,body:e,headers:{"Content-Type":`application/octet-stream`,"X-Bundle-Filename":t},serializeBody:e=>e,timeout:6e5,schema:I})}bundle_info(){return this.fetch(`/management/update/bundle-info`,{schema:I})}install_update(){return this.fetch(`/management/update/install`,{method:`POST`,schema:L})}update_status(){return this.fetch(`/management/update/status`,{schema:R})}reboot(){return this.fetch(`/management/reboot`,{method:`POST`,schema:z})}getProjectLogs(e,t){let r=t?.tail??1e3;return this.fetch(`/management/projects/${e}/logs?tail=${r}`,{schema:n.array(j)})}streamProjectLogs(e,t,i){let a=i?.tail??1e3,o=new AbortController,s=`http://${r(this.host)}/v0/management/projects/${e}/logs/stream?tail=${a}`;return(async()=>{try{let e=await fetch(s,{signal:o.signal});if(!e.ok||e.body===null)throw Error(`Log stream failed: HTTP ${e.status}`);let r=e.body.getReader(),i=new TextDecoder,a=``,c=e=>{let r=`message`,i=``;for(let t of e.split(`
|
|
2
|
+
`))t.startsWith(`event:`)?r=t.slice(6).trim():t.startsWith(`data:`)&&(i+=t.slice(5).trim());if(r===`end`)return t.onEnd?.(),!0;if(r===`log`&&i.length>0){let e=n.safeParse(j,JSON.parse(i));e.success&&t.onLine(e.output)}return!1};for(;;){let{done:e,value:t}=await r.read();if(e)break;a+=i.decode(t,{stream:!0});let n=a.indexOf(`
|
|
3
|
+
|
|
4
|
+
`);for(;n!==-1;){let e=a.slice(0,n);if(a=a.slice(n+2),c(e)){o.abort();return}n=a.indexOf(`
|
|
5
|
+
|
|
6
|
+
`)}}}catch(e){if(o.signal.aborted)return;t.onError?.(e)}})(),{close:()=>o.abort()}}};Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return r}});
|
|
7
|
+
//# sourceMappingURL=management-BGrPAG5k.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"management-BGrPAG5k.cjs","names":["v","analogLevel"],"sources":["../src/host.ts","../src/api/management.ts"],"sourcesContent":["const DEFAULT_PORT = 8080;\n\n/**\n * Formats a host into a URL authority. Returns `host` unchanged when it already\n * carries an explicit port; otherwise appends `fallbackPort` (the device's\n * mDNS-advertised port when known, else the default 8080). Bare IPv6 literals\n * are bracketed. Idempotent: re-formatting an authority is a no-op.\n */\nexport function format_host_for_url(host: string, fallbackPort?: number): string {\n const port = fallbackPort || DEFAULT_PORT;\n if (host.startsWith('[')) {\n return host.includes(']:') ? host : `${host}:${port}`;\n }\n const firstColon = host.indexOf(':');\n if (firstColon === -1) {\n return `${host}:${port}`;\n }\n if (firstColon === host.lastIndexOf(':')) {\n return host; // exactly one colon: host:port already specified\n }\n return `[${host}]:${port}`; // bare IPv6 literal, no port\n}\n\n/** Returns the bare host (IP or hostname) from a URL authority, dropping any port. */\nexport function host_without_port(host: string): string {\n if (host.startsWith('[')) {\n const end = host.indexOf(']');\n return end === -1 ? host : host.slice(1, end); // [ipv6] / [ipv6]:port -> ipv6\n }\n const firstColon = host.indexOf(':');\n if (firstColon !== -1 && firstColon === host.lastIndexOf(':')) {\n return host.slice(0, firstColon); // host:port -> host\n }\n return host; // bare hostname/IPv4 or bare IPv6 literal\n}\n","import { type UpFetch } from 'up-fetch';\nimport * as v from 'valibot';\n\nimport { format_host_for_url } from '../host';\nimport { analogLevel } from './common';\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 inputVoltageRange = v.object({ min: analogLevel, max: analogLevel });\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: inputVoltageRange,\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 // Added to the server after firmware 0.3.3 — optional so older devices stay discoverable.\n ram_used: v.optional(v.number()),\n ram_total: v.optional(v.number()),\n cpu_temperature: v.optional(v.number()),\n capabilities: capabilities,\n});\nexport type Information = v.InferOutput<typeof info>;\n\nconst projectStatus = v.picklist(['idle', 'running', 'error']);\nconst projectEventState = v.picklist(['created', 'started', 'stopped', 'removed', 'error']);\nconst portProtocol = v.picklist(['tcp', 'udp']);\nconst port = v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(65535));\nexport const portMapping = v.object({ host: port, container: port, proto: portProtocol });\nexport type PortMapping = v.InferOutput<typeof portMapping>;\nconst authorizedKey = v.pipe(\n v.string(),\n v.trim(),\n v.regex(/^(ssh-|ecdsa-sha2-|sk-ssh-|sk-ecdsa-)/, 'Not a recognized SSH public key'),\n);\nexport const runMode = v.picklist(['normal', 'development']);\nexport type RunMode = v.InferOutput<typeof runMode>;\n\nconst logLine = v.object({ stream: v.picklist(['stdout', 'stderr']), line: v.string() });\nexport type LogLine = v.InferOutput<typeof logLine>;\n\nexport const project = v.object({\n name: v.string(),\n path: v.string(),\n id: v.string(),\n image: v.string(),\n is_default: v.boolean(),\n ports: v.optional(v.array(portMapping), []),\n command: v.optional(v.string(), ''),\n state: projectStatus,\n mode: v.optional(runMode),\n password_set: v.optional(v.boolean()),\n});\nexport type Project = v.InferOutput<typeof project>;\n\n// Merged management.project realtime event, discriminated on `change`.\nexport const projectEvent = v.variant('change', [\n v.object({ change: v.literal('state_changed'), id: v.string(), state: projectEventState }),\n v.object({ change: v.literal('renamed'), id: v.string(), name: v.string() }),\n v.object({ change: v.literal('default_changed'), id: v.string(), is_default: v.boolean() }),\n]);\nexport type ProjectEvent = v.InferOutput<typeof projectEvent>;\n\nconst projectPatch = v.partial(v.pick(project, ['name', 'is_default', 'command']));\nexport type ProjectPatch = v.InferOutput<typeof projectPatch>;\n\nconst projectTemplate = v.picklist(['nodejs', 'python']);\nexport type ProjectTemplate = v.InferOutput<typeof projectTemplate>;\n\nconst createProject = v.object({\n name: v.string(),\n template: projectTemplate,\n command: v.optional(v.string()),\n});\nexport type CreateProject = v.InferOutput<typeof createProject>;\n\nconst bundleInfo = v.object({\n bundle: v.string(),\n version: v.string(),\n compatible: v.string(),\n description: v.string(),\n});\nexport type BundleInfo = v.InferOutput<typeof bundleInfo>;\n\nconst installResponse = v.object({ message: v.string(), bundle: v.string() });\nexport type InstallResponse = v.InferOutput<typeof installResponse>;\n\nexport const updateStatus = v.object({\n state: v.picklist(['idle', 'installing', 'failed']),\n progress: v.number(),\n message: v.string(),\n error: v.string(),\n boot: v.optional(v.picklist(['confirmed', 'pending', 'unknown'])),\n});\nexport type UpdateStatus = v.InferOutput<typeof updateStatus>;\n\nconst rebootResponse = v.object({ message: v.string() });\nexport type RebootResponse = v.InferOutput<typeof rebootResponse>;\n\nconst finiteNumber = v.pipe(v.number(), v.finite());\nconst positiveFiniteNumber = v.pipe(v.number(), v.finite(), v.minValue(Number.MIN_VALUE));\nconst channelId = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(31));\nconst relayId = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(7));\nconst usbPortId = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(1));\nconst calibrationStatus = v.picklist(['pass', 'fail']);\n\nconst calibrationPoint = v.object({\n set: finiteNumber,\n measured: finiteNumber,\n reading: v.optional(finiteNumber),\n});\nexport type CalibrationPoint = v.InferOutput<typeof calibrationPoint>;\n\nconst channelCalibration = v.object({\n channel: channelId,\n points: v.array(calibrationPoint),\n max_error: finiteNumber,\n avg_error: finiteNumber,\n});\nexport type ChannelCalibration = v.InferOutput<typeof channelCalibration>;\n\nconst dutPsuCalibration = v.object({\n voltage: v.object({\n points: v.array(calibrationPoint),\n max_error: finiteNumber,\n avg_error: finiteNumber,\n }),\n current: v.object({\n load_ohms: positiveFiniteNumber,\n points: v.array(calibrationPoint),\n max_error: finiteNumber,\n avg_error: finiteNumber,\n }),\n});\nexport type DutPsuCalibration = v.InferOutput<typeof dutPsuCalibration>;\n\nconst currentTestResult = v.object({\n load_ohms: positiveFiniteNumber,\n voltage_applied: finiteNumber,\n measured_current: finiteNumber,\n expected_current: finiteNumber,\n error_percent: finiteNumber,\n});\n/** @deprecated See {@link currentTestResult}. */\nexport type CurrentTestResult = v.InferOutput<typeof currentTestResult>;\n\nconst relayTestResult = v.object({\n relay: relayId,\n status: calibrationStatus,\n test_voltage: finiteNumber,\n closed_current: finiteNumber,\n open_current: finiteNumber,\n calibration: v.optional(channelCalibration),\n});\nexport type RelayTestResult = v.InferOutput<typeof relayTestResult>;\n\nconst usbTestResult = v.object({\n port: usbPortId,\n status: calibrationStatus,\n voltage: finiteNumber,\n /** @deprecated Legacy field; only present on calibrations from older devices. */\n current_tests: v.optional(v.array(currentTestResult)),\n});\nexport type UsbTestResult = v.InferOutput<typeof usbTestResult>;\n\nexport const calibrationData = v.object({\n schema_version: v.literal(1),\n tool_version: v.string(),\n device_id: v.string(),\n timestamp: v.string(),\n firmware_version: v.string(),\n dac: v.array(channelCalibration),\n adc_positive: v.array(channelCalibration),\n adc_negative: v.optional(v.array(channelCalibration)),\n dut_psu: dutPsuCalibration,\n relays: v.array(relayTestResult),\n usb: v.array(usbTestResult),\n});\nexport type CalibrationData = v.InferOutput<typeof calibrationData>;\n\nexport const calibrationState = v.object({\n enabled: v.boolean(),\n loaded: v.boolean(),\n last_error: v.optional(v.nullable(v.string())),\n calibrated_at: v.optional(v.nullable(v.string())),\n});\nexport type CalibrationState = v.InferOutput<typeof calibrationState>;\n\nconst calibrationStatePatch = v.object({ enabled: v.boolean() });\n\n/** @hideconstructor */\nexport class ManagementApi {\n constructor(private readonly fetch: UpFetch, private readonly host: string) {}\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 * Lists the AT1000 base images present on the device.\n * @returns Repo tags of on-device base images (e.g. \"localhost/at1000-base:latest\").\n */\n listImages() {\n return this.fetch('/management/images', { schema: v.array(v.string()) });\n }\n\n /**\n * Gets a single project by id.\n * @param projectId The project slug id.\n * @returns The project info.\n */\n getProject(projectId: string) {\n return this.fetch(`/management/projects/${projectId}`, { schema: project });\n }\n\n /**\n * Creates a new project from a preinstalled template.\n * @param newProject The project creation data.\n */\n createProject(newProject: CreateProject) {\n return this.fetch('/management/projects', {\n method: 'POST',\n body: newProject,\n timeout: 30_000,\n schema: project,\n });\n }\n\n /**\n * Imports a project from a container image archive (.tar / .tar.gz). The archive streams\n * straight to the device, so pass a lazily file-backed Blob (`await fs.openAsBlob(path)` on\n * Node, a `File` from an input element in the browser): `new Blob([await readFile(path)])`\n * buffers the whole archive in the caller's heap.\n * @param file The image archive to import.\n * @param name The project name (sent percent-encoded; the server decodes it).\n * @returns The created project.\n */\n importProject(file: Blob, name: string) {\n return this.fetch('/management/projects/import', {\n method: 'POST',\n body: file,\n headers: { 'Content-Type': 'application/x-tar', 'X-Project-Name': encodeURIComponent(name) },\n serializeBody: (b) => b as any,\n timeout: 600_000,\n schema: project,\n });\n }\n\n /**\n * Patches an existing project (`name`, `is_default`, `command`). An empty `command` clears it (entrypoint autodetect).\n * @param projectId The project slug id.\n * @param data The data to patch the project with.\n */\n updateProject(projectId: string, data: ProjectPatch) {\n return this.fetch(`/management/projects/${projectId}`, {\n method: 'PATCH',\n body: v.parse(projectPatch, data),\n schema: project,\n });\n }\n\n /**\n * Runs a project.\n * @param projectId The project slug id.\n * @param mode The run mode: 'normal' (default) or 'development' (starts sshd).\n */\n runProject(projectId: string, mode: RunMode = 'normal') {\n return this.fetch(`/management/projects/${projectId}/run`, {\n method: 'POST',\n body: { mode },\n timeout: 30_000,\n });\n }\n\n /**\n * Stops a running project.\n * @param projectId The project slug id.\n */\n stopProject(projectId: string) {\n return this.fetch(`/management/projects/${projectId}/stop`, {\n method: 'POST',\n timeout: 30_000,\n });\n }\n\n /**\n * Gets the port mappings for a project.\n * @param projectId The project slug id.\n * @returns The project's port mappings.\n */\n getProjectPorts(projectId: string) {\n return this.fetch(`/management/projects/${projectId}/ports`, { schema: v.array(portMapping) });\n }\n\n /**\n * Replaces the full set of port mappings for a project.\n * @param projectId The project slug id.\n * @param ports The complete list of port mappings.\n * @returns The updated port mappings.\n */\n setProjectPorts(projectId: string, ports: PortMapping[]) {\n return this.fetch(`/management/projects/${projectId}/ports`, {\n method: 'PUT',\n body: v.parse(v.array(portMapping), ports),\n timeout: 30_000,\n schema: v.array(portMapping),\n });\n }\n\n /**\n * Adds a single port mapping to a project.\n * @param projectId The project slug id.\n * @param mapping The port mapping to add.\n * @returns The updated port mappings.\n */\n addProjectPort(projectId: string, mapping: PortMapping) {\n return this.fetch(`/management/projects/${projectId}/ports`, {\n method: 'POST',\n body: v.parse(portMapping, mapping),\n timeout: 30_000,\n schema: v.array(portMapping),\n });\n }\n\n /**\n * Removes the port mapping for a host port from a project.\n * @param projectId The project slug id.\n * @param hostPort The host port to unmap.\n */\n deleteProjectPort(projectId: string, hostPort: number) {\n return this.fetch(`/management/projects/${projectId}/ports/${hostPort}`, {\n method: 'DELETE',\n parseResponse: () => {},\n timeout: 30_000,\n });\n }\n\n /**\n * Sets the password of the project's dev user (used for SSH password login in\n * development mode).\n * @param projectId The project slug id.\n * @param password The new password.\n */\n setProjectPassword(projectId: string, password: string) {\n return this.fetch(`/management/projects/${projectId}/password`, {\n method: 'POST',\n body: v.parse(v.object({ password: v.pipe(v.string(), v.minLength(1)) }), { password }),\n parseResponse: () => {},\n timeout: 30_000,\n });\n }\n\n /**\n * Gets the SSH authorized_keys for the project's dev user.\n * @param projectId The project slug id.\n * @returns The list of authorized public keys.\n */\n getProjectAuthorizedKeys(projectId: string) {\n return this.fetch(`/management/projects/${projectId}/authorized_keys`, {\n schema: v.array(v.string()),\n });\n }\n\n /**\n * Replaces the SSH authorized_keys for the project's dev user.\n * @param projectId The project slug id.\n * @param keys The complete list of authorized public keys.\n * @returns The updated list of authorized public keys.\n */\n setProjectAuthorizedKeys(projectId: string, keys: string[]) {\n return this.fetch(`/management/projects/${projectId}/authorized_keys`, {\n method: 'PUT',\n body: v.parse(v.array(authorizedKey), keys),\n timeout: 30_000,\n schema: v.array(v.string()),\n });\n }\n\n /**\n * Deletes a project.\n * @param projectId The project slug id.\n */\n deleteProject(projectId: string) {\n return this.fetch(`/management/projects/${projectId}`, { method: 'DELETE', timeout: 30_000 });\n }\n\n /**\n * Uploads a firmware bundle to the device and inspects it.\n * The bundle is staged for installation but not installed yet. The body streams straight to\n * the device, so pass a lazily file-backed Blob (`await fs.openAsBlob(path)` on Node, a `File`\n * from an input element in the browser): `new Blob([await readFile(path)])` buffers the whole\n * bundle in the caller's heap.\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 /**\n * Gets the current run's container logs for a project (one-shot).\n *\n * Lines are scoped server-side to the container's most recent start: a running\n * project returns the live run so far, an idle/stopped project the last run.\n * stdout and stderr are merged into one chronological array; each entry's\n * `stream` field says which it came from.\n *\n * @param projectId The project slug id.\n * @param options.tail Max number of trailing lines (default 1000, clamped 1..10000).\n * @returns The current run's log lines, in order.\n */\n getProjectLogs(projectId: string, options?: { tail?: number }) {\n const tail = options?.tail ?? 1000;\n return this.fetch(`/management/projects/${projectId}/logs?tail=${tail}`, {\n schema: v.array(logLine),\n });\n }\n\n /**\n * Streams the current run's container logs for a project over SSE.\n *\n * Replays the current run's recent lines (bounded by `tail`) then follows live\n * with zero gap. `onLine` fires once per line (stdout and stderr merged in\n * order); `onEnd` fires when the follow ends (the container stopped, or an\n * idle project's last-run replay completed). No auto-reconnect.\n *\n * @param projectId The project slug id.\n * @param handlers Line/end/error callbacks.\n * @param options.tail Max number of trailing lines (default 1000, clamped 1..10000).\n * @returns A handle whose `close()` aborts the stream.\n */\n streamProjectLogs(\n projectId: string,\n handlers: {\n onLine: (line: LogLine) => void;\n onEnd?: () => void;\n onError?: (err: unknown) => void;\n },\n options?: { tail?: number },\n ): { close: () => void } {\n const tail = options?.tail ?? 1000;\n const controller = new AbortController();\n const url = `http://${format_host_for_url(this.host)}`\n + `/v0/management/projects/${projectId}/logs/stream?tail=${tail}`;\n\n void (async () => {\n try {\n const response = await fetch(url, { signal: controller.signal });\n if (!response.ok || response.body === null) {\n throw new Error(`Log stream failed: HTTP ${response.status}`);\n }\n\n const reader = response.body.getReader();\n const decoder = new TextDecoder();\n let buffer = '';\n\n const dispatch = (record: string): boolean => {\n let event = 'message';\n let data = '';\n for (const rawLine of record.split('\\n')) {\n if (rawLine.startsWith('event:')) {\n event = rawLine.slice('event:'.length).trim();\n } else if (rawLine.startsWith('data:')) {\n data += rawLine.slice('data:'.length).trim();\n }\n }\n if (event === 'end') {\n handlers.onEnd?.();\n return true; // terminal\n }\n if (event === 'log' && data.length > 0) {\n const parsed = v.safeParse(logLine, JSON.parse(data));\n if (parsed.success) {\n handlers.onLine(parsed.output);\n }\n }\n return false;\n };\n\n for (;;) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n buffer += decoder.decode(value, { stream: true });\n let separator = buffer.indexOf('\\n\\n');\n while (separator !== -1) {\n const record = buffer.slice(0, separator);\n buffer = buffer.slice(separator + 2);\n if (dispatch(record)) {\n controller.abort();\n return;\n }\n separator = buffer.indexOf('\\n\\n');\n }\n }\n } catch (err) {\n if (controller.signal.aborted) {\n return; // caller closed, or terminal end handled above\n }\n handlers.onError?.(err);\n }\n })();\n\n return { close: () => controller.abort() };\n }\n}\n"],"mappings":"8IAQA,SAAgB,EAAoB,EAAc,EAA+B,CAC/E,IAAM,EAAO,GAAgB,KAC7B,GAAI,EAAK,WAAW,GAAG,EACrB,OAAO,EAAK,SAAS,IAAI,EAAI,EAAO,GAAG,EAAK,GAAG,IAEjD,IAAM,EAAa,EAAK,QAAQ,GAAG,EAOnC,OANI,IAAe,GACV,GAAG,EAAK,GAAG,IAEhB,IAAe,EAAK,YAAY,GAAG,EAC9B,EAEF,IAAI,EAAK,IAAI,GACtB,CAGA,SAAgB,EAAkB,EAAsB,CACtD,GAAI,EAAK,WAAW,GAAG,EAAG,CACxB,IAAM,EAAM,EAAK,QAAQ,GAAG,EAC5B,OAAO,IAAQ,GAAK,EAAO,EAAK,MAAM,EAAG,CAAG,CAC9C,CACA,IAAM,EAAa,EAAK,QAAQ,GAAG,EAInC,OAHI,IAAe,IAAM,IAAe,EAAK,YAAY,GAAG,EACnD,EAAK,MAAM,EAAG,CAAU,EAE1B,CACT,CC5BA,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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,EAAK,CACZ,GAAI,EAAW,OAAO,QACpB,OAEF,EAAS,UAAU,CAAG,CACxB,CACF,EAAA,CAAG,EAEI,CAAE,UAAa,EAAW,MAAM,CAAE,CAC3C,CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{t as e}from"./common-Ce3FeF-Q.mjs";import"up-fetch";import*as t from"valibot";function n(e,t){let n=t||8080;if(e.startsWith(`[`))return e.includes(`]:`)?e:`${e}:${n}`;let r=e.indexOf(`:`);return r===-1?`${e}:${n}`:r===e.lastIndexOf(`:`)?e:`[${e}]:${n}`}function r(e){if(e.startsWith(`[`)){let t=e.indexOf(`]`);return t===-1?e:e.slice(1,t)}let t=e.indexOf(`:`);return t!==-1&&t===e.lastIndexOf(`:`)?e.slice(0,t):e}let i=function(e){return e.Can=`can`,e.Rs232=`rs232`,e.Rs485=`rs485`,e.I2c=`i2c`,e.Spi=`spi`,e.Uart=`uart`,e}({});const a=t.enum(i),o=t.object({min:t.pipe(t.number(),t.minValue(-24),t.maxValue(24)),max:t.pipe(t.number(),t.minValue(-24),t.maxValue(24))}),s=t.object({min:e,max:e}),c=t.object({max:t.number()}),l=t.object({count:t.pipe(t.number(),t.minValue(1)),input_voltage:s,output_voltage:o}),u=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))}),d=t.object({type:t.picklist([`3.0`,`2.0`]),count:t.pipe(t.number(),t.minValue(1))}),f=t.object({type:t.picklist([`1000BASE-T`,`100BASE-T`,`10BASE-T`]),count:t.pipe(t.number(),t.minValue(1))}),p=t.object({type:a,count:t.pipe(t.number(),t.minValue(1))}),m=t.object({count:t.pipe(t.number(),t.minValue(1)),output_voltage:o,current:c}),h=t.object({type:t.picklist([`low_precision`,`high_precision`]),source:t.string(),resolution:t.pipe(t.number(),t.minValue(0))}),g=t.object({width:t.pipe(t.number(),t.minValue(1)),height:t.pipe(t.number(),t.minValue(1))}),_=t.object({type:t.string(),size:g}),v=t.object({count:t.pipe(t.number(),t.minValue(0)),type:t.string()}),y=t.object({count:t.pipe(t.number(),t.minValue(0)),type:t.string()}),b=t.object({display:_,input:v,speaker:y}),x=t.object({io:l,relays:u,usb_ports:t.array(d),ethernet:t.array(f),communication:t.array(p),power_supply:m,current_measurement:t.array(h),hmi:b}),S=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(),ram_used:t.optional(t.number()),ram_total:t.optional(t.number()),cpu_temperature:t.optional(t.number()),capabilities:x}),C=t.picklist([`idle`,`running`,`error`]),w=t.picklist([`created`,`started`,`stopped`,`removed`,`error`]),T=t.picklist([`tcp`,`udp`]),E=t.pipe(t.number(),t.integer(),t.minValue(1),t.maxValue(65535)),D=t.object({host:E,container:E,proto:T}),O=t.pipe(t.string(),t.trim(),t.regex(/^(ssh-|ecdsa-sha2-|sk-ssh-|sk-ecdsa-)/,`Not a recognized SSH public key`)),k=t.picklist([`normal`,`development`]),A=t.object({stream:t.picklist([`stdout`,`stderr`]),line:t.string()}),j=t.object({name:t.string(),path:t.string(),id:t.string(),image:t.string(),is_default:t.boolean(),ports:t.optional(t.array(D),[]),command:t.optional(t.string(),``),state:C,mode:t.optional(k),password_set:t.optional(t.boolean())}),M=t.variant(`change`,[t.object({change:t.literal(`state_changed`),id:t.string(),state:w}),t.object({change:t.literal(`renamed`),id:t.string(),name:t.string()}),t.object({change:t.literal(`default_changed`),id:t.string(),is_default:t.boolean()})]),N=t.partial(t.pick(j,[`name`,`is_default`,`command`])),P=t.picklist([`nodejs`,`python`]);t.object({name:t.string(),template:P,command:t.optional(t.string())});const F=t.object({bundle:t.string(),version:t.string(),compatible:t.string(),description:t.string()}),I=t.object({message:t.string(),bundle:t.string()}),L=t.object({state:t.picklist([`idle`,`installing`,`failed`]),progress:t.number(),message:t.string(),error:t.string(),boot:t.optional(t.picklist([`confirmed`,`pending`,`unknown`]))}),R=t.object({message:t.string()}),z=t.pipe(t.number(),t.finite()),B=t.pipe(t.number(),t.finite(),t.minValue(Number.MIN_VALUE)),V=t.pipe(t.number(),t.integer(),t.minValue(0),t.maxValue(31)),H=t.pipe(t.number(),t.integer(),t.minValue(0),t.maxValue(7)),U=t.pipe(t.number(),t.integer(),t.minValue(0),t.maxValue(1)),W=t.picklist([`pass`,`fail`]),G=t.object({set:z,measured:z,reading:t.optional(z)}),K=t.object({channel:V,points:t.array(G),max_error:z,avg_error:z}),q=t.object({voltage:t.object({points:t.array(G),max_error:z,avg_error:z}),current:t.object({load_ohms:B,points:t.array(G),max_error:z,avg_error:z})}),J=t.object({load_ohms:B,voltage_applied:z,measured_current:z,expected_current:z,error_percent:z}),Y=t.object({relay:H,status:W,test_voltage:z,closed_current:z,open_current:z,calibration:t.optional(K)}),X=t.object({port:U,status:W,voltage:z,current_tests:t.optional(t.array(J))}),Z=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(K),adc_positive:t.array(K),adc_negative:t.optional(t.array(K)),dut_psu:q,relays:t.array(Y),usb:t.array(X)}),Q=t.object({enabled:t.boolean(),loaded:t.boolean(),last_error:t.optional(t.nullable(t.string())),calibrated_at:t.optional(t.nullable(t.string()))}),$=t.object({enabled:t.boolean()});var ee=class{fetch;host;constructor(e,t){this.fetch=e,this.host=t}info(){return this.fetch(`/management/info`,{schema:S})}get_calibration(){return this.fetch(`/management/calibration`,{schema:Z})}set_calibration(e){return this.fetch(`/management/calibration`,{method:`PUT`,body:t.parse(Z,e),schema:Z})}get_calibration_state(){return this.fetch(`/management/calibration/state`,{schema:Q})}set_calibration_enabled(e){return this.fetch(`/management/calibration/state`,{method:`PATCH`,body:t.parse($,{enabled:e}),schema:Q})}enable_calibration(){return this.set_calibration_enabled(!0)}disable_calibration(){return this.set_calibration_enabled(!1)}async datetime(){let e=await this.fetch(`/management/datetime`,{schema:t.object({epoch_seconds:t.number()})});return new Date(e.epoch_seconds*1e3)}setDatetime(e){return this.fetch(`/management/datetime`,{method:`POST`,body:{epoch_seconds:Math.floor(e.getTime()/1e3)},parseResponse:()=>{}})}getProjects(){return this.fetch(`/management/projects`,{schema:t.array(j)})}listImages(){return this.fetch(`/management/images`,{schema:t.array(t.string())})}getProject(e){return this.fetch(`/management/projects/${e}`,{schema:j})}createProject(e){return this.fetch(`/management/projects`,{method:`POST`,body:e,timeout:3e4,schema:j})}importProject(e,t){return this.fetch(`/management/projects/import`,{method:`POST`,body:e,headers:{"Content-Type":`application/x-tar`,"X-Project-Name":encodeURIComponent(t)},serializeBody:e=>e,timeout:6e5,schema:j})}updateProject(e,n){return this.fetch(`/management/projects/${e}`,{method:`PATCH`,body:t.parse(N,n),schema:j})}runProject(e,t=`normal`){return this.fetch(`/management/projects/${e}/run`,{method:`POST`,body:{mode:t},timeout:3e4})}stopProject(e){return this.fetch(`/management/projects/${e}/stop`,{method:`POST`,timeout:3e4})}getProjectPorts(e){return this.fetch(`/management/projects/${e}/ports`,{schema:t.array(D)})}setProjectPorts(e,n){return this.fetch(`/management/projects/${e}/ports`,{method:`PUT`,body:t.parse(t.array(D),n),timeout:3e4,schema:t.array(D)})}addProjectPort(e,n){return this.fetch(`/management/projects/${e}/ports`,{method:`POST`,body:t.parse(D,n),timeout:3e4,schema:t.array(D)})}deleteProjectPort(e,t){return this.fetch(`/management/projects/${e}/ports/${t}`,{method:`DELETE`,parseResponse:()=>{},timeout:3e4})}setProjectPassword(e,n){return this.fetch(`/management/projects/${e}/password`,{method:`POST`,body:t.parse(t.object({password:t.pipe(t.string(),t.minLength(1))}),{password:n}),parseResponse:()=>{},timeout:3e4})}getProjectAuthorizedKeys(e){return this.fetch(`/management/projects/${e}/authorized_keys`,{schema:t.array(t.string())})}setProjectAuthorizedKeys(e,n){return this.fetch(`/management/projects/${e}/authorized_keys`,{method:`PUT`,body:t.parse(t.array(O),n),timeout:3e4,schema:t.array(t.string())})}deleteProject(e){return this.fetch(`/management/projects/${e}`,{method:`DELETE`,timeout:3e4})}upload_bundle(e,t=`bundle.raucb`){return this.fetch(`/management/update/upload`,{method:`POST`,body:e,headers:{"Content-Type":`application/octet-stream`,"X-Bundle-Filename":t},serializeBody:e=>e,timeout:6e5,schema:F})}bundle_info(){return this.fetch(`/management/update/bundle-info`,{schema:F})}install_update(){return this.fetch(`/management/update/install`,{method:`POST`,schema:I})}update_status(){return this.fetch(`/management/update/status`,{schema:L})}reboot(){return this.fetch(`/management/reboot`,{method:`POST`,schema:R})}getProjectLogs(e,n){let r=n?.tail??1e3;return this.fetch(`/management/projects/${e}/logs?tail=${r}`,{schema:t.array(A)})}streamProjectLogs(e,r,i){let a=i?.tail??1e3,o=new AbortController,s=`http://${n(this.host)}/v0/management/projects/${e}/logs/stream?tail=${a}`;return(async()=>{try{let e=await fetch(s,{signal:o.signal});if(!e.ok||e.body===null)throw Error(`Log stream failed: HTTP ${e.status}`);let n=e.body.getReader(),i=new TextDecoder,a=``,c=e=>{let n=`message`,i=``;for(let t of e.split(`
|
|
2
|
+
`))t.startsWith(`event:`)?n=t.slice(6).trim():t.startsWith(`data:`)&&(i+=t.slice(5).trim());if(n===`end`)return r.onEnd?.(),!0;if(n===`log`&&i.length>0){let e=t.safeParse(A,JSON.parse(i));e.success&&r.onLine(e.output)}return!1};for(;;){let{done:e,value:t}=await n.read();if(e)break;a+=i.decode(t,{stream:!0});let r=a.indexOf(`
|
|
3
|
+
|
|
4
|
+
`);for(;r!==-1;){let e=a.slice(0,r);if(a=a.slice(r+2),c(e)){o.abort();return}r=a.indexOf(`
|
|
5
|
+
|
|
6
|
+
`)}}}catch(e){if(o.signal.aborted)return;r.onError?.(e)}})(),{close:()=>o.abort()}}};export{D as a,k as c,r as d,Q as i,L as l,ee as n,j as o,Z as r,M as s,i as t,n as u};
|
|
7
|
+
//# sourceMappingURL=management-CuI4cenF.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"management-CuI4cenF.mjs","names":[],"sources":["../src/host.ts","../src/api/management.ts"],"sourcesContent":["const DEFAULT_PORT = 8080;\n\n/**\n * Formats a host into a URL authority. Returns `host` unchanged when it already\n * carries an explicit port; otherwise appends `fallbackPort` (the device's\n * mDNS-advertised port when known, else the default 8080). Bare IPv6 literals\n * are bracketed. Idempotent: re-formatting an authority is a no-op.\n */\nexport function format_host_for_url(host: string, fallbackPort?: number): string {\n const port = fallbackPort || DEFAULT_PORT;\n if (host.startsWith('[')) {\n return host.includes(']:') ? host : `${host}:${port}`;\n }\n const firstColon = host.indexOf(':');\n if (firstColon === -1) {\n return `${host}:${port}`;\n }\n if (firstColon === host.lastIndexOf(':')) {\n return host; // exactly one colon: host:port already specified\n }\n return `[${host}]:${port}`; // bare IPv6 literal, no port\n}\n\n/** Returns the bare host (IP or hostname) from a URL authority, dropping any port. */\nexport function host_without_port(host: string): string {\n if (host.startsWith('[')) {\n const end = host.indexOf(']');\n return end === -1 ? host : host.slice(1, end); // [ipv6] / [ipv6]:port -> ipv6\n }\n const firstColon = host.indexOf(':');\n if (firstColon !== -1 && firstColon === host.lastIndexOf(':')) {\n return host.slice(0, firstColon); // host:port -> host\n }\n return host; // bare hostname/IPv4 or bare IPv6 literal\n}\n","import { type UpFetch } from 'up-fetch';\nimport * as v from 'valibot';\n\nimport { format_host_for_url } from '../host';\nimport { analogLevel } from './common';\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 inputVoltageRange = v.object({ min: analogLevel, max: analogLevel });\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: inputVoltageRange,\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 // Added to the server after firmware 0.3.3 — optional so older devices stay discoverable.\n ram_used: v.optional(v.number()),\n ram_total: v.optional(v.number()),\n cpu_temperature: v.optional(v.number()),\n capabilities: capabilities,\n});\nexport type Information = v.InferOutput<typeof info>;\n\nconst projectStatus = v.picklist(['idle', 'running', 'error']);\nconst projectEventState = v.picklist(['created', 'started', 'stopped', 'removed', 'error']);\nconst portProtocol = v.picklist(['tcp', 'udp']);\nconst port = v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(65535));\nexport const portMapping = v.object({ host: port, container: port, proto: portProtocol });\nexport type PortMapping = v.InferOutput<typeof portMapping>;\nconst authorizedKey = v.pipe(\n v.string(),\n v.trim(),\n v.regex(/^(ssh-|ecdsa-sha2-|sk-ssh-|sk-ecdsa-)/, 'Not a recognized SSH public key'),\n);\nexport const runMode = v.picklist(['normal', 'development']);\nexport type RunMode = v.InferOutput<typeof runMode>;\n\nconst logLine = v.object({ stream: v.picklist(['stdout', 'stderr']), line: v.string() });\nexport type LogLine = v.InferOutput<typeof logLine>;\n\nexport const project = v.object({\n name: v.string(),\n path: v.string(),\n id: v.string(),\n image: v.string(),\n is_default: v.boolean(),\n ports: v.optional(v.array(portMapping), []),\n command: v.optional(v.string(), ''),\n state: projectStatus,\n mode: v.optional(runMode),\n password_set: v.optional(v.boolean()),\n});\nexport type Project = v.InferOutput<typeof project>;\n\n// Merged management.project realtime event, discriminated on `change`.\nexport const projectEvent = v.variant('change', [\n v.object({ change: v.literal('state_changed'), id: v.string(), state: projectEventState }),\n v.object({ change: v.literal('renamed'), id: v.string(), name: v.string() }),\n v.object({ change: v.literal('default_changed'), id: v.string(), is_default: v.boolean() }),\n]);\nexport type ProjectEvent = v.InferOutput<typeof projectEvent>;\n\nconst projectPatch = v.partial(v.pick(project, ['name', 'is_default', 'command']));\nexport type ProjectPatch = v.InferOutput<typeof projectPatch>;\n\nconst projectTemplate = v.picklist(['nodejs', 'python']);\nexport type ProjectTemplate = v.InferOutput<typeof projectTemplate>;\n\nconst createProject = v.object({\n name: v.string(),\n template: projectTemplate,\n command: v.optional(v.string()),\n});\nexport type CreateProject = v.InferOutput<typeof createProject>;\n\nconst bundleInfo = v.object({\n bundle: v.string(),\n version: v.string(),\n compatible: v.string(),\n description: v.string(),\n});\nexport type BundleInfo = v.InferOutput<typeof bundleInfo>;\n\nconst installResponse = v.object({ message: v.string(), bundle: v.string() });\nexport type InstallResponse = v.InferOutput<typeof installResponse>;\n\nexport const updateStatus = v.object({\n state: v.picklist(['idle', 'installing', 'failed']),\n progress: v.number(),\n message: v.string(),\n error: v.string(),\n boot: v.optional(v.picklist(['confirmed', 'pending', 'unknown'])),\n});\nexport type UpdateStatus = v.InferOutput<typeof updateStatus>;\n\nconst rebootResponse = v.object({ message: v.string() });\nexport type RebootResponse = v.InferOutput<typeof rebootResponse>;\n\nconst finiteNumber = v.pipe(v.number(), v.finite());\nconst positiveFiniteNumber = v.pipe(v.number(), v.finite(), v.minValue(Number.MIN_VALUE));\nconst channelId = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(31));\nconst relayId = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(7));\nconst usbPortId = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(1));\nconst calibrationStatus = v.picklist(['pass', 'fail']);\n\nconst calibrationPoint = v.object({\n set: finiteNumber,\n measured: finiteNumber,\n reading: v.optional(finiteNumber),\n});\nexport type CalibrationPoint = v.InferOutput<typeof calibrationPoint>;\n\nconst channelCalibration = v.object({\n channel: channelId,\n points: v.array(calibrationPoint),\n max_error: finiteNumber,\n avg_error: finiteNumber,\n});\nexport type ChannelCalibration = v.InferOutput<typeof channelCalibration>;\n\nconst dutPsuCalibration = v.object({\n voltage: v.object({\n points: v.array(calibrationPoint),\n max_error: finiteNumber,\n avg_error: finiteNumber,\n }),\n current: v.object({\n load_ohms: positiveFiniteNumber,\n points: v.array(calibrationPoint),\n max_error: finiteNumber,\n avg_error: finiteNumber,\n }),\n});\nexport type DutPsuCalibration = v.InferOutput<typeof dutPsuCalibration>;\n\nconst currentTestResult = v.object({\n load_ohms: positiveFiniteNumber,\n voltage_applied: finiteNumber,\n measured_current: finiteNumber,\n expected_current: finiteNumber,\n error_percent: finiteNumber,\n});\n/** @deprecated See {@link currentTestResult}. */\nexport type CurrentTestResult = v.InferOutput<typeof currentTestResult>;\n\nconst relayTestResult = v.object({\n relay: relayId,\n status: calibrationStatus,\n test_voltage: finiteNumber,\n closed_current: finiteNumber,\n open_current: finiteNumber,\n calibration: v.optional(channelCalibration),\n});\nexport type RelayTestResult = v.InferOutput<typeof relayTestResult>;\n\nconst usbTestResult = v.object({\n port: usbPortId,\n status: calibrationStatus,\n voltage: finiteNumber,\n /** @deprecated Legacy field; only present on calibrations from older devices. */\n current_tests: v.optional(v.array(currentTestResult)),\n});\nexport type UsbTestResult = v.InferOutput<typeof usbTestResult>;\n\nexport const calibrationData = v.object({\n schema_version: v.literal(1),\n tool_version: v.string(),\n device_id: v.string(),\n timestamp: v.string(),\n firmware_version: v.string(),\n dac: v.array(channelCalibration),\n adc_positive: v.array(channelCalibration),\n adc_negative: v.optional(v.array(channelCalibration)),\n dut_psu: dutPsuCalibration,\n relays: v.array(relayTestResult),\n usb: v.array(usbTestResult),\n});\nexport type CalibrationData = v.InferOutput<typeof calibrationData>;\n\nexport const calibrationState = v.object({\n enabled: v.boolean(),\n loaded: v.boolean(),\n last_error: v.optional(v.nullable(v.string())),\n calibrated_at: v.optional(v.nullable(v.string())),\n});\nexport type CalibrationState = v.InferOutput<typeof calibrationState>;\n\nconst calibrationStatePatch = v.object({ enabled: v.boolean() });\n\n/** @hideconstructor */\nexport class ManagementApi {\n constructor(private readonly fetch: UpFetch, private readonly host: string) {}\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 * Lists the AT1000 base images present on the device.\n * @returns Repo tags of on-device base images (e.g. \"localhost/at1000-base:latest\").\n */\n listImages() {\n return this.fetch('/management/images', { schema: v.array(v.string()) });\n }\n\n /**\n * Gets a single project by id.\n * @param projectId The project slug id.\n * @returns The project info.\n */\n getProject(projectId: string) {\n return this.fetch(`/management/projects/${projectId}`, { schema: project });\n }\n\n /**\n * Creates a new project from a preinstalled template.\n * @param newProject The project creation data.\n */\n createProject(newProject: CreateProject) {\n return this.fetch('/management/projects', {\n method: 'POST',\n body: newProject,\n timeout: 30_000,\n schema: project,\n });\n }\n\n /**\n * Imports a project from a container image archive (.tar / .tar.gz). The archive streams\n * straight to the device, so pass a lazily file-backed Blob (`await fs.openAsBlob(path)` on\n * Node, a `File` from an input element in the browser): `new Blob([await readFile(path)])`\n * buffers the whole archive in the caller's heap.\n * @param file The image archive to import.\n * @param name The project name (sent percent-encoded; the server decodes it).\n * @returns The created project.\n */\n importProject(file: Blob, name: string) {\n return this.fetch('/management/projects/import', {\n method: 'POST',\n body: file,\n headers: { 'Content-Type': 'application/x-tar', 'X-Project-Name': encodeURIComponent(name) },\n serializeBody: (b) => b as any,\n timeout: 600_000,\n schema: project,\n });\n }\n\n /**\n * Patches an existing project (`name`, `is_default`, `command`). An empty `command` clears it (entrypoint autodetect).\n * @param projectId The project slug id.\n * @param data The data to patch the project with.\n */\n updateProject(projectId: string, data: ProjectPatch) {\n return this.fetch(`/management/projects/${projectId}`, {\n method: 'PATCH',\n body: v.parse(projectPatch, data),\n schema: project,\n });\n }\n\n /**\n * Runs a project.\n * @param projectId The project slug id.\n * @param mode The run mode: 'normal' (default) or 'development' (starts sshd).\n */\n runProject(projectId: string, mode: RunMode = 'normal') {\n return this.fetch(`/management/projects/${projectId}/run`, {\n method: 'POST',\n body: { mode },\n timeout: 30_000,\n });\n }\n\n /**\n * Stops a running project.\n * @param projectId The project slug id.\n */\n stopProject(projectId: string) {\n return this.fetch(`/management/projects/${projectId}/stop`, {\n method: 'POST',\n timeout: 30_000,\n });\n }\n\n /**\n * Gets the port mappings for a project.\n * @param projectId The project slug id.\n * @returns The project's port mappings.\n */\n getProjectPorts(projectId: string) {\n return this.fetch(`/management/projects/${projectId}/ports`, { schema: v.array(portMapping) });\n }\n\n /**\n * Replaces the full set of port mappings for a project.\n * @param projectId The project slug id.\n * @param ports The complete list of port mappings.\n * @returns The updated port mappings.\n */\n setProjectPorts(projectId: string, ports: PortMapping[]) {\n return this.fetch(`/management/projects/${projectId}/ports`, {\n method: 'PUT',\n body: v.parse(v.array(portMapping), ports),\n timeout: 30_000,\n schema: v.array(portMapping),\n });\n }\n\n /**\n * Adds a single port mapping to a project.\n * @param projectId The project slug id.\n * @param mapping The port mapping to add.\n * @returns The updated port mappings.\n */\n addProjectPort(projectId: string, mapping: PortMapping) {\n return this.fetch(`/management/projects/${projectId}/ports`, {\n method: 'POST',\n body: v.parse(portMapping, mapping),\n timeout: 30_000,\n schema: v.array(portMapping),\n });\n }\n\n /**\n * Removes the port mapping for a host port from a project.\n * @param projectId The project slug id.\n * @param hostPort The host port to unmap.\n */\n deleteProjectPort(projectId: string, hostPort: number) {\n return this.fetch(`/management/projects/${projectId}/ports/${hostPort}`, {\n method: 'DELETE',\n parseResponse: () => {},\n timeout: 30_000,\n });\n }\n\n /**\n * Sets the password of the project's dev user (used for SSH password login in\n * development mode).\n * @param projectId The project slug id.\n * @param password The new password.\n */\n setProjectPassword(projectId: string, password: string) {\n return this.fetch(`/management/projects/${projectId}/password`, {\n method: 'POST',\n body: v.parse(v.object({ password: v.pipe(v.string(), v.minLength(1)) }), { password }),\n parseResponse: () => {},\n timeout: 30_000,\n });\n }\n\n /**\n * Gets the SSH authorized_keys for the project's dev user.\n * @param projectId The project slug id.\n * @returns The list of authorized public keys.\n */\n getProjectAuthorizedKeys(projectId: string) {\n return this.fetch(`/management/projects/${projectId}/authorized_keys`, {\n schema: v.array(v.string()),\n });\n }\n\n /**\n * Replaces the SSH authorized_keys for the project's dev user.\n * @param projectId The project slug id.\n * @param keys The complete list of authorized public keys.\n * @returns The updated list of authorized public keys.\n */\n setProjectAuthorizedKeys(projectId: string, keys: string[]) {\n return this.fetch(`/management/projects/${projectId}/authorized_keys`, {\n method: 'PUT',\n body: v.parse(v.array(authorizedKey), keys),\n timeout: 30_000,\n schema: v.array(v.string()),\n });\n }\n\n /**\n * Deletes a project.\n * @param projectId The project slug id.\n */\n deleteProject(projectId: string) {\n return this.fetch(`/management/projects/${projectId}`, { method: 'DELETE', timeout: 30_000 });\n }\n\n /**\n * Uploads a firmware bundle to the device and inspects it.\n * The bundle is staged for installation but not installed yet. The body streams straight to\n * the device, so pass a lazily file-backed Blob (`await fs.openAsBlob(path)` on Node, a `File`\n * from an input element in the browser): `new Blob([await readFile(path)])` buffers the whole\n * bundle in the caller's heap.\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 /**\n * Gets the current run's container logs for a project (one-shot).\n *\n * Lines are scoped server-side to the container's most recent start: a running\n * project returns the live run so far, an idle/stopped project the last run.\n * stdout and stderr are merged into one chronological array; each entry's\n * `stream` field says which it came from.\n *\n * @param projectId The project slug id.\n * @param options.tail Max number of trailing lines (default 1000, clamped 1..10000).\n * @returns The current run's log lines, in order.\n */\n getProjectLogs(projectId: string, options?: { tail?: number }) {\n const tail = options?.tail ?? 1000;\n return this.fetch(`/management/projects/${projectId}/logs?tail=${tail}`, {\n schema: v.array(logLine),\n });\n }\n\n /**\n * Streams the current run's container logs for a project over SSE.\n *\n * Replays the current run's recent lines (bounded by `tail`) then follows live\n * with zero gap. `onLine` fires once per line (stdout and stderr merged in\n * order); `onEnd` fires when the follow ends (the container stopped, or an\n * idle project's last-run replay completed). No auto-reconnect.\n *\n * @param projectId The project slug id.\n * @param handlers Line/end/error callbacks.\n * @param options.tail Max number of trailing lines (default 1000, clamped 1..10000).\n * @returns A handle whose `close()` aborts the stream.\n */\n streamProjectLogs(\n projectId: string,\n handlers: {\n onLine: (line: LogLine) => void;\n onEnd?: () => void;\n onError?: (err: unknown) => void;\n },\n options?: { tail?: number },\n ): { close: () => void } {\n const tail = options?.tail ?? 1000;\n const controller = new AbortController();\n const url = `http://${format_host_for_url(this.host)}`\n + `/v0/management/projects/${projectId}/logs/stream?tail=${tail}`;\n\n void (async () => {\n try {\n const response = await fetch(url, { signal: controller.signal });\n if (!response.ok || response.body === null) {\n throw new Error(`Log stream failed: HTTP ${response.status}`);\n }\n\n const reader = response.body.getReader();\n const decoder = new TextDecoder();\n let buffer = '';\n\n const dispatch = (record: string): boolean => {\n let event = 'message';\n let data = '';\n for (const rawLine of record.split('\\n')) {\n if (rawLine.startsWith('event:')) {\n event = rawLine.slice('event:'.length).trim();\n } else if (rawLine.startsWith('data:')) {\n data += rawLine.slice('data:'.length).trim();\n }\n }\n if (event === 'end') {\n handlers.onEnd?.();\n return true; // terminal\n }\n if (event === 'log' && data.length > 0) {\n const parsed = v.safeParse(logLine, JSON.parse(data));\n if (parsed.success) {\n handlers.onLine(parsed.output);\n }\n }\n return false;\n };\n\n for (;;) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n buffer += decoder.decode(value, { stream: true });\n let separator = buffer.indexOf('\\n\\n');\n while (separator !== -1) {\n const record = buffer.slice(0, separator);\n buffer = buffer.slice(separator + 2);\n if (dispatch(record)) {\n controller.abort();\n return;\n }\n separator = buffer.indexOf('\\n\\n');\n }\n }\n } catch (err) {\n if (controller.signal.aborted) {\n return; // caller closed, or terminal end handled above\n }\n handlers.onError?.(err);\n }\n })();\n\n return { close: () => controller.abort() };\n }\n}\n"],"mappings":"qFAQA,SAAgB,EAAoB,EAAc,EAA+B,CAC/E,IAAM,EAAO,GAAgB,KAC7B,GAAI,EAAK,WAAW,GAAG,EACrB,OAAO,EAAK,SAAS,IAAI,EAAI,EAAO,GAAG,EAAK,GAAG,IAEjD,IAAM,EAAa,EAAK,QAAQ,GAAG,EAOnC,OANI,IAAe,GACV,GAAG,EAAK,GAAG,IAEhB,IAAe,EAAK,YAAY,GAAG,EAC9B,EAEF,IAAI,EAAK,IAAI,GACtB,CAGA,SAAgB,EAAkB,EAAsB,CACtD,GAAI,EAAK,WAAW,GAAG,EAAG,CACxB,IAAM,EAAM,EAAK,QAAQ,GAAG,EAC5B,OAAO,IAAQ,GAAK,EAAO,EAAK,MAAM,EAAG,CAAG,CAC9C,CACA,IAAM,EAAa,EAAK,QAAQ,GAAG,EAInC,OAHI,IAAe,IAAM,IAAe,EAAK,YAAY,GAAG,EACnD,EAAK,MAAM,EAAG,CAAU,EAE1B,CACT,CC5BA,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,EAAoB,EAAE,OAAO,CAAE,IAAK,EAAa,IAAK,CAAY,C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C,KAAK,EACnC,EAAQ,WAAW,OAAO,IACnC,GAAQ,EAAQ,MAAM,CAAc,CAAC,CAAC,KAAK,GAG/C,GAAI,IAAU,MAEZ,OADA,EAAS,QAAQ,EACV,GAET,GAAI,IAAU,OAAS,EAAK,OAAS,EAAG,CACtC,IAAM,EAAS,EAAE,UAAU,EAAS,KAAK,MAAM,CAAI,CAAC,EAChD,EAAO,SACT,EAAS,OAAO,EAAO,MAAM,CAEjC,CACA,MAAO,EACT,EAEA,OAAS,CACP,GAAM,CAAE,OAAM,SAAU,MAAM,EAAO,KAAK,EAC1C,GAAI,EACF,MAEF,GAAU,EAAQ,OAAO,EAAO,CAAE,OAAQ,EAAK,CAAC,EAChD,IAAI,EAAY,EAAO,QAAQ;;CAAM,EACrC,KAAO,IAAc,IAAI,CACvB,IAAM,EAAS,EAAO,MAAM,EAAG,CAAS,EAExC,GADA,EAAS,EAAO,MAAM,EAAY,CAAC,EAC/B,EAAS,CAAM,EAAG,CACpB,EAAW,MAAM,EACjB,MACF,CACA,EAAY,EAAO,QAAQ;;CAAM,CACnC,CACF,CACF,OAAS,EAAK,CACZ,GAAI,EAAW,OAAO,QACpB,OAEF,EAAS,UAAU,CAAG,CACxB,CACF,EAAA,CAAG,EAEI,CAAE,UAAa,EAAW,MAAM,CAAE,CAC3C,CACF"}
|
package/build/management.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./management-BGrPAG5k.cjs");exports.CommunicationInterfaceType=e.t,exports.ManagementApi=e.n,exports.calibrationData=e.r,exports.calibrationState=e.i,exports.portMapping=e.a,exports.project=e.o,exports.projectEvent=e.s,exports.runMode=e.c,exports.updateStatus=e.l;
|
package/build/management.d.cts
CHANGED
|
@@ -26,8 +26,8 @@ declare const info: v.ObjectSchema<{
|
|
|
26
26
|
readonly io: v.ObjectSchema<{
|
|
27
27
|
readonly count: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>]>;
|
|
28
28
|
readonly input_voltage: v.ObjectSchema<{
|
|
29
|
-
readonly min: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -
|
|
30
|
-
readonly max: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -
|
|
29
|
+
readonly min: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -25, undefined>, v.MaxValueAction<number, 25, undefined>]>;
|
|
30
|
+
readonly max: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -25, undefined>, v.MaxValueAction<number, 25, undefined>]>;
|
|
31
31
|
}, undefined>;
|
|
32
32
|
readonly output_voltage: v.ObjectSchema<{
|
|
33
33
|
readonly min: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -24, undefined>, v.MaxValueAction<number, 24, undefined>]>;
|
|
@@ -162,64 +162,64 @@ declare const projectPatch: Omit<Omit<v.ObjectSchema<{
|
|
|
162
162
|
readonly state: v.PicklistSchema<["idle", "running", "error"], undefined>;
|
|
163
163
|
readonly mode: v.OptionalSchema<v.PicklistSchema<["normal", "development"], undefined>, undefined>;
|
|
164
164
|
readonly password_set: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
165
|
-
}, "
|
|
165
|
+
}, "command" | "name" | "is_default">;
|
|
166
166
|
readonly "~standard": v.StandardProps<{
|
|
167
|
+
command?: string | undefined;
|
|
167
168
|
name: string;
|
|
168
169
|
is_default: boolean;
|
|
169
|
-
command?: string | undefined;
|
|
170
170
|
}, {
|
|
171
|
+
command: string;
|
|
171
172
|
name: string;
|
|
172
173
|
is_default: boolean;
|
|
173
|
-
command: string;
|
|
174
174
|
}>;
|
|
175
175
|
readonly "~run": (dataset: v.UnknownDataset, config: v.Config<v.BaseIssue<unknown>>) => v.OutputDataset<{
|
|
176
|
+
command: string;
|
|
176
177
|
name: string;
|
|
177
178
|
is_default: boolean;
|
|
178
|
-
command: string;
|
|
179
179
|
}, v.BooleanIssue | v.StringIssue | v.ObjectIssue>;
|
|
180
180
|
readonly "~types"?: {
|
|
181
181
|
readonly input: {
|
|
182
|
+
command?: string | undefined;
|
|
182
183
|
name: string;
|
|
183
184
|
is_default: boolean;
|
|
184
|
-
command?: string | undefined;
|
|
185
185
|
};
|
|
186
186
|
readonly output: {
|
|
187
|
+
command: string;
|
|
187
188
|
name: string;
|
|
188
189
|
is_default: boolean;
|
|
189
|
-
command: string;
|
|
190
190
|
};
|
|
191
191
|
readonly issue: v.BooleanIssue | v.StringIssue | v.ObjectIssue;
|
|
192
192
|
} | undefined;
|
|
193
193
|
}, "~types" | "~run" | "~standard" | "entries"> & {
|
|
194
194
|
readonly entries: {
|
|
195
|
+
readonly command: v.OptionalSchema<v.OptionalSchema<v.StringSchema<undefined>, "">, undefined>;
|
|
195
196
|
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
196
197
|
readonly is_default: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
197
|
-
readonly command: v.OptionalSchema<v.OptionalSchema<v.StringSchema<undefined>, "">, undefined>;
|
|
198
198
|
};
|
|
199
199
|
readonly "~standard": v.StandardProps<{
|
|
200
|
+
command?: string | undefined;
|
|
200
201
|
name?: string | undefined;
|
|
201
202
|
is_default?: boolean | undefined;
|
|
202
|
-
command?: string | undefined;
|
|
203
203
|
}, {
|
|
204
|
+
command?: string | undefined;
|
|
204
205
|
name?: string | undefined;
|
|
205
206
|
is_default?: boolean | undefined;
|
|
206
|
-
command?: string | undefined;
|
|
207
207
|
}>;
|
|
208
208
|
readonly "~run": (dataset: v.UnknownDataset, config: v.Config<v.BaseIssue<unknown>>) => v.OutputDataset<{
|
|
209
|
+
command?: string | undefined;
|
|
209
210
|
name?: string | undefined;
|
|
210
211
|
is_default?: boolean | undefined;
|
|
211
|
-
command?: string | undefined;
|
|
212
212
|
}, v.BooleanIssue | v.StringIssue | v.ObjectIssue>;
|
|
213
213
|
readonly "~types"?: {
|
|
214
214
|
readonly input: {
|
|
215
|
+
command?: string | undefined;
|
|
215
216
|
name?: string | undefined;
|
|
216
217
|
is_default?: boolean | undefined;
|
|
217
|
-
command?: string | undefined;
|
|
218
218
|
};
|
|
219
219
|
readonly output: {
|
|
220
|
+
command?: string | undefined;
|
|
220
221
|
name?: string | undefined;
|
|
221
222
|
is_default?: boolean | undefined;
|
|
222
|
-
command?: string | undefined;
|
|
223
223
|
};
|
|
224
224
|
readonly issue: v.BooleanIssue | v.StringIssue | v.ObjectIssue;
|
|
225
225
|
} | undefined;
|
|
@@ -571,7 +571,7 @@ declare class ManagementApi {
|
|
|
571
571
|
proto: "tcp" | "udp";
|
|
572
572
|
}[];
|
|
573
573
|
command: string;
|
|
574
|
-
state: "
|
|
574
|
+
state: "idle" | "running" | "error";
|
|
575
575
|
mode?: "normal" | "development" | undefined;
|
|
576
576
|
password_set?: boolean | undefined;
|
|
577
577
|
}[]>;
|
|
@@ -597,7 +597,7 @@ declare class ManagementApi {
|
|
|
597
597
|
proto: "tcp" | "udp";
|
|
598
598
|
}[];
|
|
599
599
|
command: string;
|
|
600
|
-
state: "
|
|
600
|
+
state: "idle" | "running" | "error";
|
|
601
601
|
mode?: "normal" | "development" | undefined;
|
|
602
602
|
password_set?: boolean | undefined;
|
|
603
603
|
}>;
|
|
@@ -617,12 +617,15 @@ declare class ManagementApi {
|
|
|
617
617
|
proto: "tcp" | "udp";
|
|
618
618
|
}[];
|
|
619
619
|
command: string;
|
|
620
|
-
state: "
|
|
620
|
+
state: "idle" | "running" | "error";
|
|
621
621
|
mode?: "normal" | "development" | undefined;
|
|
622
622
|
password_set?: boolean | undefined;
|
|
623
623
|
}>;
|
|
624
624
|
/**
|
|
625
|
-
* Imports a project from a container image archive (.tar / .tar.gz).
|
|
625
|
+
* Imports a project from a container image archive (.tar / .tar.gz). The archive streams
|
|
626
|
+
* straight to the device, so pass a lazily file-backed Blob (`await fs.openAsBlob(path)` on
|
|
627
|
+
* Node, a `File` from an input element in the browser): `new Blob([await readFile(path)])`
|
|
628
|
+
* buffers the whole archive in the caller's heap.
|
|
626
629
|
* @param file The image archive to import.
|
|
627
630
|
* @param name The project name (sent percent-encoded; the server decodes it).
|
|
628
631
|
* @returns The created project.
|
|
@@ -639,7 +642,7 @@ declare class ManagementApi {
|
|
|
639
642
|
proto: "tcp" | "udp";
|
|
640
643
|
}[];
|
|
641
644
|
command: string;
|
|
642
|
-
state: "
|
|
645
|
+
state: "idle" | "running" | "error";
|
|
643
646
|
mode?: "normal" | "development" | undefined;
|
|
644
647
|
password_set?: boolean | undefined;
|
|
645
648
|
}>;
|
|
@@ -660,7 +663,7 @@ declare class ManagementApi {
|
|
|
660
663
|
proto: "tcp" | "udp";
|
|
661
664
|
}[];
|
|
662
665
|
command: string;
|
|
663
|
-
state: "
|
|
666
|
+
state: "idle" | "running" | "error";
|
|
664
667
|
mode?: "normal" | "development" | undefined;
|
|
665
668
|
password_set?: boolean | undefined;
|
|
666
669
|
}>;
|
|
@@ -740,7 +743,10 @@ declare class ManagementApi {
|
|
|
740
743
|
deleteProject(projectId: string): Promise<any>;
|
|
741
744
|
/**
|
|
742
745
|
* Uploads a firmware bundle to the device and inspects it.
|
|
743
|
-
* The bundle is staged for installation but not installed yet.
|
|
746
|
+
* The bundle is staged for installation but not installed yet. The body streams straight to
|
|
747
|
+
* the device, so pass a lazily file-backed Blob (`await fs.openAsBlob(path)` on Node, a `File`
|
|
748
|
+
* from an input element in the browser): `new Blob([await readFile(path)])` buffers the whole
|
|
749
|
+
* bundle in the caller's heap.
|
|
744
750
|
* @param file The firmware bundle file (.raucb).
|
|
745
751
|
* @param filename Optional filename for the bundle. Defaults to 'bundle.raucb'.
|
|
746
752
|
* @returns Bundle metadata including version information.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"management.d.cts","names":[],"sources":["../src/api/management.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