Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ellipsis-api

Package Overview
Dependencies
Maintainers
3
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ellipsis-api - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

53

__tests__/test.js

@@ -221,2 +221,55 @@ "use strict";

describe("listen", () => {
const actionName = "some action";
const messageInputName = "message";
const args = [ {name: "param", value: "v" }];
const defaultOptions = {
actionName: actionName,
messageInputName: messageInputName
};
it("listens in default context", () => {
defaultExpectedForm = {
medium: api.ellipsis.userInfo.messageInfo.medium,
channel: api.ellipsis.userInfo.messageInfo.channel,
token: api.ellipsis.token,
userId: api.ellipsis.userInfo.ellipsisUserId
};
expect.assertions(2);
const options = Object.assign({}, { args: args }, defaultOptions);
return actionsApi.listen(options).then(body => {
const form = body.form;
const expectedForm = Object.assign({}, defaultExpectedForm, defaultOptions, {
actionName: options.actionName,
messageInputName: messageInputName,
"arguments[0].name": args[0].name,
"arguments[0].value": args[0].value
});
expect(form).toEqual(expectedForm);
expect(request.post.mock.calls[0][0].url).toEqual(actionsApi.urlFor("v1/add_message_listener"));
});
});
it("complains when no actionName", () => {
expect.assertions(1);
delete defaultOptions.actionName;
expect(actionsApi.listen(defaultOptions)).rejects.toHaveProperty('message', errorMessages.ACTION_NAME_MISSING);
});
it("complains when no messageInputName", () => {
expect.assertions(1);
delete defaultOptions.messageInputName;
expect(actionsApi.listen(defaultOptions)).rejects.toHaveProperty('message', errorMessages.MESSAGE_INPUT_NAME_MISSING);
});
});
describe("generateToken", () => {

@@ -223,0 +276,0 @@

3

error-messages.js

@@ -11,3 +11,4 @@ module.exports = {

GRAPHQL_QUERY_MISSING: "You need to pass a `query` argument containing the GraphQL query you want to execute",
EMAIL_MISSING: "You need to pass an `email` argument containing an email address you want to lookup"
EMAIL_MISSING: "You need to pass an `email` argument containing an email address you want to lookup",
MESSAGE_INPUT_NAME_MISSING: "You need to pass a `messageInputName` argument"
};

@@ -23,2 +23,6 @@ const request = require('request');

mediumFor(options) {
return options.medium ? options.medium : this.ellipsis.userInfo.messageInfo.medium;
}
originalEventType() {

@@ -181,2 +185,35 @@ return this.ellipsis.event ? this.ellipsis.event.originalEventType : null;

checkListeningOptionsIn(options) {
if (!options.actionName) {
this.handleError(options, errorMessages.ACTION_NAME_MISSING);
}
if (!options.messageInputName) {
this.handleError(options, errorMessages.MESSAGE_INPUT_NAME_MISSING);
}
}
listen(options) {
return new Promise((resolve, reject) => {
const mergedOptions = Object.assign({}, options, {
success: resolve,
error: reject
});
this.checkListeningOptionsIn(options);
const formData = Object.assign({
actionName: mergedOptions.actionName,
messageInputName: mergedOptions.messageInputName,
medium: this.mediumFor(mergedOptions),
channel: this.channelFor(mergedOptions),
thread: mergedOptions.thread,
userId: this.ellipsis.userInfo.ellipsisUserId,
token: this.token()
}, this.argsFormDataFor(mergedOptions.args));
request.post({
url: this.urlFor("v1/add_message_listener"),
form: formData,
json: true
}, (error, response, body) => this.handleResponse(mergedOptions, error, response, body));
});
}
generateToken(options) {

@@ -297,2 +334,3 @@ return new Promise((resolve, reject) => {

this.unschedule = this.actions.unschedule.bind(this.actions);
this.listen = this.actions.listen.bind(this.actions);
this.generateToken = this.actions.generateToken.bind(this.actions);

@@ -299,0 +337,0 @@ }

{
"name": "ellipsis-api",
"version": "0.1.1",
"version": "0.1.2",
"description": "Interact with Ellipsis skills & actions",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc