Comparing version 0.0.2 to 1.0.0
@@ -1,5 +0,3 @@ | ||
var ami = { | ||
Client: require(__dirname + '/client') | ||
} | ||
import {Socket} from './socket.js'; | ||
module.exports = ami; | ||
export default Socket; |
{ | ||
"author": "Brian M. Carlson <brian@enginode.com> (enginode.com)", | ||
"name": "ami", | ||
"description": "asterisk ami client", | ||
"version": "0.0.2", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/brianc/node-ami.git" | ||
}, | ||
"main": "lib/", | ||
"scripts": { | ||
"test": "mocha -r should -R tap -t 100" | ||
}, | ||
"engines": { | ||
"node": "~0.6.0" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"memory-socket" : "*" | ||
} | ||
"name": "ami", | ||
"version": "1.0.0", | ||
"description": "Astersik Manager Interface", | ||
"scripts": { | ||
"release": "standard-version --sign", | ||
"pretest": "cfware-lint .", | ||
"tests-only": "cross-env NODE_OPTIONS='--experimental-loader @istanbuljs/esm-loader-hook' nyc --no-check-coverage -s node test.js|tap-yaml-summary", | ||
"test": "npm run -s tests-only", | ||
"posttest": "nyc report", | ||
"snap": "cross-env TAP_SNAPSHOT=1 npm test" | ||
}, | ||
"type": "module", | ||
"main": "lib/index.js", | ||
"exports": "./lib/index.js", | ||
"engines": { | ||
"node": ">=14.0.0" | ||
}, | ||
"author": "Corey Farrell", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/cfware/ami.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/cfware/ami/issues" | ||
}, | ||
"homepage": "https://github.com/cfware/ami#readme", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@cfware/lint": "^1.0.1", | ||
"@cfware/nyc": "^0.6.0", | ||
"@istanbuljs/esm-loader-hook": "^0.1.0", | ||
"cross-env": "^7.0.0", | ||
"glob": "^7.1.6", | ||
"is-ci": "^2.0.0", | ||
"libtap": "^0.3.0", | ||
"nyc": "^15.0.0", | ||
"p-map": "^4.0.0", | ||
"standard-version": "^7.0.0", | ||
"tap-yaml-summary": "^0.1.0", | ||
"which": "^2.0.1" | ||
} | ||
} |
116
README.md
@@ -1,15 +0,115 @@ | ||
# node-ami | ||
# ami [![NPM Version][npm-image]][npm-url] | ||
node.js JavaScript client to communicate with an __A__sterisk __M__anager __I__nterface | ||
> Astersik Manager Interface | ||
## install | ||
## Install ami | ||
`npm install ami` | ||
This module requires node.js 14.0.0 or above and ES modules. | ||
## more info | ||
```sh | ||
npm install ami | ||
``` | ||
Completely in alpha status. Tests not passing yet. Watch this repo or check back around the end of Jan 2012 for a working version | ||
## class AMISocket | ||
## more, more info | ||
```js | ||
import AMISocket from 'ami'; | ||
Fork & contribute! Open Source is awesome. | ||
const ami = new AMISocket(); | ||
``` | ||
### new AMISocket(options) | ||
Construct a new AMI connection instance. Default options: | ||
```js | ||
{ | ||
connect: { | ||
host: 'localhost', | ||
port: 5038 | ||
}, | ||
credentials: { | ||
username: 'local', | ||
secret: 'local' | ||
}, | ||
events: true | ||
} | ||
``` | ||
### AMISocket#amiVersion | ||
Version string provided by the Asterisk server, example `2.10.5`. | ||
This property is `undefined` prior to receiving first line from connected | ||
socket. | ||
### AMISocket#connected | ||
Boolean value if the socket is connected. | ||
### AMISocket#authenticated | ||
Boolean value if the socket is authenticated. | ||
### async AMISocket#connect() | ||
Connect to the AMI server for this instance. Promise is resolved once authentication is | ||
successful. Rejection occurs if connection or authentication fails. | ||
This function resolves after queued packets are sent but before responses are received. | ||
### AMISocket#disconnect() | ||
Disconnect from the AMI server. No attempt is made to wait for responses to requests that | ||
are in progress. | ||
### async AMISocket#send(object, options) | ||
### async AMISocket#getList(object, options) | ||
`object` is the key/value pairs to send as an AMI request. This must contain an `action` key. | ||
A key can be specified multiple times by providing an array, for example: | ||
```js | ||
ami.send({ | ||
action: 'originate', | ||
// channel / app / etc | ||
variable: [ | ||
'CHANVAR1=value', | ||
'CHANVAR2=value' | ||
] | ||
}); | ||
``` | ||
`options.ignoreResponse` can be set to `true` if you don't care about the result. In this | ||
case the promise resolves as soon as the request is written to the socket. | ||
`options.responseType` controls the information provided when resolving: | ||
* `response`: resolves with a single object structured like the input object. This is default for `AMISocket#send`. | ||
* `responses`: resolves with an array of objects. This is default for `AMISocket#getList`. | ||
* `responsePacket`: resolves with a single `AMIPacket` instance. | ||
* `responsePackets`: resolves with an array of `AMIPacket` instances. | ||
Keys of all responses are normalized to lowercase strings. | ||
#### AMIPacket#asObject | ||
This is the property which resolve requests that used `responseType` of `response` or `responses`. | ||
#### AMIPacket#values | ||
An ordered array of name/value pairs, for example: | ||
```js | ||
[ | ||
['actionid', 'random-generated-id'], | ||
['response', 'success'] | ||
] | ||
``` | ||
This is only needed to deal with responses which violate the AMI specification. An example | ||
of this is the `app_queue` [QueueRule](https://github.com/asterisk/asterisk/blob/2e7866ebb7773fdd4f67e80f3747e41d84bcb93b/apps/app_queue.c#L9744-L9777) | ||
response, see [ASTERISK-27072](https://issues.asterisk.org/jira/browse/ASTERISK-27072). | ||
#### AMIPacket#toString() | ||
This is used internally to produce the raw data. It could also be used for debug output. | ||
Note that keys are already tranformed to lowercase. | ||
[npm-image]: https://img.shields.io/npm/v/ami.svg | ||
[npm-url]: https://npmjs.org/package/ami |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
16138
13
404
0
0
116
0
Yes
12
3