# amlenginewrapper

> This wrapper allows easy access to the most important functionality of the AMLEnginge.dll inside of a Node project.

Latest version **1.0.7** (published 2020-05-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install amlenginewrapper
pnpm add amlenginewrapper
yarn add amlenginewrapper
bun add amlenginewrapper
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2020-05-11 |
| First published | 2020-04-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 675.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | inf18201 |

## Links

- npm: https://www.npmjs.com/package/amlenginewrapper
- npm.io page: https://npm.io/package/amlenginewrapper

## Dependencies (1)

- [edge-js](https://npm.io/package/edge-js.md) ^13.0.1

## Recent versions

- 1.0.7 (latest) — 2020-05-11
- 1.0.6 — 2020-05-03
- 1.0.5 — 2020-05-02
- 1.0.4 — 2020-04-29
- 1.0.3 — 2020-04-29
- 1.0.2 — 2020-04-26
- 1.0.1 — 2020-04-24
- 1.0.0 — 2020-04-23

## README

# AMLEngineWrapper
##### *Version 1.0.7*
Wrapper for the [AMLEngine.dll](https://www.nuget.org/packages/Aml.Engine) for [Node.js](https://nodejs.org/)

````
const wrapper = require('amlenginewrapper');

wrapper.validate("path/to/AML-File");
````

# Installation
````
$ npm install amlenginewrapper
````

# Usage
## How to call a function
There are two possible ways to call the functions contained inside this wrapper. The first one is to use the [call()](#call) method of the wrapper and call functions directly. This however requires you to know all required parameters of all the functions you want to use. The easier way to call a functions is to use the predefined handler of that function. The list of supported functions contains usage examples for all of those predifined functions.

## How to handle the result of a function call
### Function calls using return statements
The return value of a function can be accessed by assigning it to a variable, as shown in the example below.
````
var result = wrapper.getInstanceHierarchy(...);
````

### Function calls using callbacks
You can also specify a callback to handle the result of a function, as shown in the example below.
````
function resultHandler(result) {
  console.log(result);
}

wrapper.getInstanceHierarchy(..., resultHandler);
````

### Failed function calls
If a function call fails an error will be thrown, detailing the reason for the error. More information on Node.js handles errors can be found [here](https://nodejs.dev/error-handling-in-nodejs).

## List of supported functions
- [appendToInstanceHierarchy](#appendtoinstancehierarchy)
- [getInstanceHierarchy](#getinstancehierarchy)
- [createSystemUnitClass](#createsystemunitclass)
- [createInterfaceClass](#createinterfaceclass)
- [appendInstanceElement](#appendinstanceelement)
- [renameElement](#renameElement)
- [validate](#validate)
- [repair](#repair)

## Usage examples
### call
````
wrapper.call(functionName, path, input = {}, callback = null);
````
##### Description
This function offers the possibility to directly call a function inside the wrapper. Only use this function if you really have to. Most of the time using one of the functions below will be more convenient
##### Parameters
| Parameter | Description |
|-----------|-------------|
|functionName|The name of the function you want to call|
|path|The path to the AML file you want to use|
|input|The payload required by the function you want to use in JSON notation<br />**Default value:** {}|
|callback|The callback function that should handle the result of this function call.<br />If no callback is specified the result will be returned by using a return statement.<br />*See [How to handle the result of a function call](#how-to-handle-the-result-of-a-function-call) for more information.*<br />**Default value:** null|
##### Return value
This function returns what ever is specified for the function you specified
<hr />

### appendToInstanceHierarchy
````
wrapper.appendToInstanceHierarchy(path, instanceName, 
  internalElement = null, callback = null);
````
##### Description
This function appends a new instance hierarchy
##### Parameters
| Parameter | Description |
|-----------|-------------|
|path|The path to the AML file you want to use|
|index|The name of the instance you want to append|
|internalElement|The internalElement you want to include in the instance hierarchy|
|callback|The callback function that should handle the result of this function call.<br />If no callback is specified the result will be returned by using a return statement.<br />*See [How to handle the result of a function call](#how-to-handle-the-result-of-a-function-call) for more information.*<br />**Default value:** null|
##### Return value
This function returns a confirmation message, letting you know whether the operation was successful
<hr />

### getInstanceHierarchy
````
wrapper.getInstanceHierarchy(path, index, callback = null);
````
##### Description
This function returns a hierarchy element as string
##### Parameters
| Parameter | Description |
|-----------|-------------|
|path|The path to the AML file you want to use|
|index|The index of the instanceHierarchy you are trying to get|
|callback|The callback function that should handle the result of this function call.<br />If no callback is specified the result will be returned by using a return statement.<br />*See [How to handle the result of a function call](#how-to-handle-the-result-of-a-function-call) for more information.*<br />**Default value:** null|
##### Return value
This function returns the InstanceHierarchy you were trying to get as a string
<hr />

### createSystemUnitClass
````
wrapper.createSystemUnitClass(path, unitClassLibName,
  unitClassName = null, index = null, callback = null);
````
##### Description
This function creates a new system unit class
##### Parameters
| Parameter | Description |
|-----------|-------------|
|path|The path to the AML file you want to use|
|unitClassLibName|The name of the new SystemUnitClassLib|
|unitClassName|The name of a UnitClass you want to include in the SystemUnitClassLib<br />**Default value:** null|
|index|The index of the SystemUnitClass<br />**Default value:** null|
|callback|The callback function that should handle the result of this function call. <br />If no callback is specified the result will be returned by using a return statement.<br />*See [How to handle the result of a function call](#how-to-handle-the-result-of-a-function-call) for more information.*<br />**Default value:** null|
##### Return value
This function returns a confirmation message, letting you know whether the operation was successful
<hr />

### createInterfaceClass
````
wrapper.createInterfaceClass(path, interfaceClassName,
  interfaceName = null, callback = null);
````
##### Description
This function creates a new interface class
##### Parameters
| Parameter | Description |
|-----------|-------------|
|path|The path to the AML file you want to use|
|interfaceClassName|The name of the new InterfaceClass|
|interfaceName|The name of an interface you want to include<br />**Default value:** null|
|callback|The callback function that should handle the result of this function call.<br />If no callback is specified the result will be returned by using a return statement.<br />*See [How to handle the result of a function call](#how-to-handle-the-result-of-a-function-call) for more information.*<br />**Default value:** null|
##### Return value
This function returns a confirmation message, letting you know whether the operation was successful
<hr />

### appendInstanceElement
````
wrapper.appendInstanceElement(path, index, 
  instanceElement, callback = null);
````
##### Description
This function appends a new instance element
##### Parameters
| Parameter | Description |
|-----------|-------------|
|path|The path to the AML file you want to use|
|index|The index of the InstanceHierarchy you want to append to|
|instanceElement|The name of the instanceElement you want to append|
|callback|The callback function that should handle the result of this function call.<br />If no callback is specified the result will be returned by using a return statement.<br />*See [How to handle the result of a function call](#how-to-handle-the-result-of-a-function-call) for more information.*<br />**Default value:** null|
##### Return value
This function returns a confirmation message, letting you know whether the operation was successful
<hr />

### renameElement
````
wrapper.renameElement(path, index, data, callback = null);
````
##### Description
This function can be used to rename a given element
##### Parameters
| Parameter | Description |
|-----------|-------------|
|path|The path to the AML file you want to use|
|indexer|The index of the instanceHierarchy that contains the element|
|newName|The new name for the element|
|internalElement|The name of the element you want to rename|
|callback|The callback function that should handle the result of this function call.<br />If no callback is specified the result will be returned by using a return statement.<br />*See [How to handle the result of a function call](#how-to-handle-the-result-of-a-function-call) for more information.*<br />**Default value:** null|
##### Return value
This function returns a confirmation message, letting you know whether the operation was successful
<hr />

### validate
````
wrapper.validate(path, callback = null);
````
##### Description
This function simply validates a file on a given path
##### Parameters
| Parameter | Description |
|-----------|-------------|
|path|The path to the AML file you want to validate|
|callback|The callback function that should handle the result of this function call.<br />If no callback is specified the result will be returned by using a return statement.<br />*See [How to handle the result of a function call](#how-to-handle-the-result-of-a-function-call) for more information.*<br />**Default value:** null|
##### Return value
This function returns the result of the validation
<hr />

### repair
````
wrapper.repair(path, callback = null);
````
##### Description
This function validates and repairs a given document
##### Parameters
| Parameter | Description |
|-----------|-------------|
|path|The path to the AML file you want to repair|
|callback|The callback function that should handle the result of this function call.<br />If no callback is specified the result will be returned by using a return statement.<br />*See [How to handle the result of a function call](#how-to-handle-the-result-of-a-function-call) for more information.*<br />**Default value:** null|
##### Return value
This function returns the result of the repair

---
_Source: https://npm.io/package/amlenginewrapper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
