Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mspgeek/labtech-script-decode
A set of utilities to decode and encode LT Script XML files to and from JSON.
https://github.com/mspgeek/labtech-script-decode
Last synced: 5 days ago
JSON representation
A set of utilities to decode and encode LT Script XML files to and from JSON.
- Host: GitHub
- URL: https://github.com/mspgeek/labtech-script-decode
- Owner: mspgeek
- License: mit
- Created: 2017-10-14T01:09:01.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-04-19T07:24:00.000Z (over 1 year ago)
- Last Synced: 2024-08-09T13:43:48.296Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 2.82 MB
- Stars: 26
- Watchers: 6
- Forks: 11
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## labtech-script-decode
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.
## Installation
```
npm install --save labtech-script-decode
```## Usage
### Server
```javascript
const labtech_script = require('labtech-script-decode');labtech_script.decodeXML(scriptXML).then(scriptJSON => {})
labtech_script.decode(base64string).then()
```### Browser
Include using Webpack, Browserify, etc, or directly using a script tag:
```html
labtech_script.decodeXML(scriptXML)
.then(scriptJSON => {
// scriptJSON
})```
## Documentation
Script functions and their associated [documentation](https://github.com/k-grube/labtech-script-decode/blob/master/DOC.md) for each script function.
## Examples
See the test folder for an example decoded script [here](https://github.com/k-grube/labtech-script-decode/blob/master/test/Export%20Test.json).
This library is documented with JSDoc for exported object schema.
## API
### decodeXML(value)
Decode and interpolate an XML string
**Arguments**
| Param | Type | Description |
| --- | --- | --- |
| value | String | Exported LabTech script |**Returns**
Promise ⇒ Object\
### decode(value)
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\
### encodeXML(object)
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 | Packed LabTech script |**Returns**
Promise ⇒ String\
### encode(object)
Encode a JSON object into a base64 encoded string such as for ScriptData or LicenseData.
**Arguments**
| Param | Type | Description |
| --- | --- | --- |
| object | object | |**Returns**
Promise ⇒ String
### interpolate(scriptData)
**Arguments**
| Param | Type | Description |
| --- | --- | --- |
| scriptData | Object\ | Uninterpolated script data |**Returns**
Promise ⇒ Object\
### toText(scriptJSON)
**Arguments**
| Param | Type | Description |
| --- | --- | --- |
| scriptJSON | LabTechScript | LabTech Script JSON returned by decodeXML |### Constants
A helper object containing a map of ids to
**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 |
| OsLimits | Function OS limits |## Schema
-
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
### LabTechScript : Object
**Kind**: global typedef
**Properties**
| Name | Type |
| --- | --- |
| LabTech_Expansion | |
| LabTech_Expansion.$ | |
| LabTech_Expansion.$.Name | |
| LabTech_Expansion.$.Type | |
| LabTech_Expansion.$.Version | |
| LabTech_Expansion.PackedScript | [PackedScript
](#PackedScript) |
### PackedScript : Array.<Object>
\| Object
**Kind**: global typedef
**Properties**
| Name | Type |
| --- | --- |
| NewDataSet | Object
|
| NewDataSet.Table | [ScriptTable
](#ScriptTable) |
| PackedScript | [Array.<PackedScript>
](#PackedScript) \| [PackedScript
](#PackedScript) |
| ScriptFolder | [ScriptFolder
](#ScriptFolder) |
### ScriptFolder : Array.<Object>
**Kind**: global typedef
**Properties**
| Name | Type |
| --- | --- |
| NewDataSet | |
| NewDataSet.Table | [FolderTable
](#FolderTable) |
### LicenseData : Object
**Kind**: global typedef
**Properties**
| Name |
| --- |
| ExpireDate |
| RunCounter |
| ScriptGuid |
| ScriptVersion |
| Type |
### ScriptData : Object
**Kind**: global typedef
**Properties**
| Name | Type |
| --- | --- |
| ScriptSteps | Array.<(ScriptStep\|ScriptStepXML)>
|
| Scripts | Object
|
| Scripts.ExtraDataFields | |
| Scripts.Globals | |
| Scripts.Parameters | |
| Scripts.ScriptGuid | |
| Scripts.ScriptVersion | |
### ScriptStepXML : Object
**Kind**: global typedef
**Properties**
| Name |
| --- |
| Action |
| Continue |
| FunctionId |
| Indentation |
| OsLimit |
| Param1 |
| Param2 |
| Param3 |
| Param4 |
| Param5 |
| Sort |
### ScriptStep : Object
**Kind**: global typedef
**Properties**
| Name | Type |
| --- | --- |
| Action | |
| Continue | |
| Function | [ScriptFunction
](#ScriptFunction) |
| FunctionId | |
| Indentation | |
| OsLimit | |
| Param1 | |
| Param2 | |
| Param3 | |
| Param4 | |
| Param5 | |
| Sort | |
### ScriptFunction : Object
**Kind**: global typedef
**Properties**
| Name | Type |
| --- | --- |
| Description | |
| FunctionFlag | |
| FunctionId | |
| FunctionType | |
| Name | |
| ParamNames | [Array.<ScriptParam>
](#ScriptParam) |
### ScriptParam : Object
**Kind**: global typedef
**Properties**
| Name | Type |
| --- | --- |
| Description | |
| ParamName | |
| Value | |
| Values | Array.<String>
|
### ScriptTable : Object
**Kind**: global typedef
**Properties**
| Name | Type |
| --- | --- |
| ComputerScript | |
| EditPermission | |
| FolderId | |
| FunctionScript | |
| LicenseData | |
| LocationScript | |
| MaintenanceScript | |
| Parameters | |
| Permission | |
| ScriptData | [ScriptData
](#ScriptData) |
| ScriptFlags | |
| ScriptGuid | |
| ScriptId | |
| ScriptName | |
| ScriptNotes | |
| ScriptVersion | |
### FolderTable : Object
**Kind**: global typedef
**Properties**
| Name |
| --- |
| FolderID |
| GUID |
| Name |
| ParentID |