A set of utilities to load, parse, encode and interpolate exported LabTech scripts from XML into JSON and from JSON to XML. This module will run in the browser or on the server.
npm install --save labtech-script-decode
- Node >= 20.19.0, ESM-first (CJS and UMD builds included via the exports map)
npm run build # Vite build (ESM, CJS, and UMD outputs)
npm test # Vitest suite
npm run docs # Generate DOC.md from function definitions// ESM import
import * as labtech_script from 'labtech-script-decode'
// or CommonJS require
const labtech_script = require('labtech-script-decode')
labtech_script.decodeXML(scriptXML).then((scriptJSON) => {})
labtech_script.decode(base64string).then()Use via script tag or bundler:
<script src="/dist/labtech-script-decode.umd.js"></script>
<script>
labtech_script.decodeXML(scriptXML).then((scriptJSON) => {
// scriptJSON
})
</script>See DOC.md for step descriptions of the functions used in the doc fixture. Full function definitions live in src/constants.js.
See the test folder for an example decoded script here.
This library is documented with JSDoc for exported object schema.
Decode and interpolate an XML string
Arguments
| Param | Type | Description |
|---|---|---|
| value | String | Exported LabTech script |
Returns
Promise ⇒ Object<LabTechScript>
Decode and parse a base 64 encoded string such as ScriptData or LicenseData. This function does not interpolate constants such as function names into decoded values.
Arguments
| Param | Type | Description |
|---|---|---|
| value | String or Array | Base 64 encoded |
Returns
Promise ⇒ Object<Parsed XML>
Encode and de-interpolate object into an XML string. The input's schema is validated to confirm that the output will produce a valid LabTech script.
Arguments
| Param | Type | Description |
|---|---|---|
| object | Object<LabTech_Expansion> | Packed LabTech script |
Returns
Promise ⇒ String<XML>
Encode a JSON object into a base64 encoded string such as for ScriptData or LicenseData.
Arguments
| Param | Type | Description |
|---|---|---|
| object | object |
Returns
Promise ⇒ String
Arguments
| Param | Type | Description |
|---|---|---|
| scriptData | Object<ScriptData> | Uninterpolated script data |
Returns
Promise ⇒ Object<ScriptData>
Arguments
| Param | Type | Description |
|---|---|---|
| scriptJSON | LabTechScript | LabTech Script JSON returned by decodeXML |
A helper object containing a map of ids to function definitions and related data. Available via ESM import, CommonJS require, or UMD global (checks for CommonJS first, then falls back to UMD).
Properties
| Property | Values |
|---|---|
| Actions | Function location in script |
| Continues | Function enabled or disabled |
| FunctionFlags | Base 10 bitstring determining target for this function |
| FunctionTypes | If or regular function |
| Functions | Function definitions (IDs 1-259) |
| OsLimits | Function OS limits |
Interpolated function templates mapping function IDs to template functions for rendering script steps. Available via ESM import, CommonJS require, or UMD global.
- LabTechScript :
Object - PackedScript :
Array.<Object>|Object - ScriptFolder :
Array.<Object> - LicenseData :
Object - ScriptData :
Object - ScriptStepXML :
Object - ScriptStep :
Object - ScriptFunction :
Object - ScriptParam :
Object - ScriptTable :
Object - FolderTable :
Object
Kind: global typedef Properties
| Name | Type |
|---|---|
| LabTech_Expansion | |
| LabTech_Expansion.$ | |
| LabTech_Expansion.$.Name | |
| LabTech_Expansion.$.Type | |
| LabTech_Expansion.$.Version | |
| LabTech_Expansion.PackedScript | PackedScript |
Kind: global typedef Properties
| Name | Type |
|---|---|
| NewDataSet | Object |
| NewDataSet.Table | ScriptTable |
| PackedScript | Array.<PackedScript> | PackedScript |
| ScriptFolder | ScriptFolder |
Kind: global typedef Properties
| Name | Type |
|---|---|
| NewDataSet | |
| NewDataSet.Table | FolderTable |
Kind: global typedef Properties
| Name |
|---|
| ExpireDate |
| RunCounter |
| ScriptGuid |
| ScriptVersion |
| Type |
Kind: global typedef Properties
| Name | Type |
|---|---|
| ScriptSteps | Array.<(ScriptStep|ScriptStepXML)> |
| Scripts | Object |
| Scripts.ExtraDataFields | |
| Scripts.Globals | |
| Scripts.Parameters | |
| Scripts.ScriptGuid | |
| Scripts.ScriptVersion |
Kind: global typedef Properties
| Name |
|---|
| Action |
| Continue |
| FunctionId |
| Indentation |
| OsLimit |
| Param1 |
| Param2 |
| Param3 |
| Param4 |
| Param5 |
| Sort |
Kind: global typedef Properties
| Name | Type |
|---|---|
| Action | |
| Continue | |
| Function | ScriptFunction |
| FunctionId | |
| Indentation | |
| OsLimit | |
| Param1 | |
| Param2 | |
| Param3 | |
| Param4 | |
| Param5 | |
| Sort |
Kind: global typedef Properties
| Name | Type |
|---|---|
| Description | |
| FunctionFlag | |
| FunctionId | |
| FunctionType | |
| Name | |
| ParamNames | Array.<ScriptParam> |
Kind: global typedef Properties
| Name | Type |
|---|---|
| Description | |
| ParamName | |
| Value | |
| Values | Array.<String> |
Kind: global typedef Properties
| Name | Type |
|---|---|
| ComputerScript | |
| EditPermission | |
| FolderId | |
| FunctionScript | |
| LicenseData | |
| LocationScript | |
| MaintenanceScript | |
| Parameters | |
| Permission | |
| ScriptData | ScriptData |
| ScriptFlags | |
| ScriptGuid | |
| ScriptId | |
| ScriptName | |
| ScriptNotes | |
| ScriptVersion |
Kind: global typedef Properties
| Name |
|---|
| FolderID |
| GUID |
| Name |
| ParentID |