Socket
Socket
Sign inDemoInstall

rpcapi

Package Overview
Dependencies
181
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.4.0 to 2.5.0

42

package.json
{
"name": "rpcapi",
"version": "2.4.0",
"version": "2.5.0",
"description": "Provides a struture for hosting RPC style APIs, supports both http and websocket access out of the box",

@@ -13,5 +13,5 @@ "repository": {

"pretest": "tsc",
"test": "ava **/src/**/*.test.js **/src/**/*.itest.js",
"test": "ava src/*.test.js src/**/*.test.js src/**/*.itest.js",
"precoverage": "tsc",
"coverage": "nyc ava **/src/**/*.test.js **/src/**/*.itest.js"
"coverage": "node_modules/.bin/nyc node_modules/.bin/ava src/*.test.js src/**/*.test.js src/**/*.itest.js"
},

@@ -26,23 +26,23 @@ "keywords": [

"devDependencies": {
"ava": "^0.25.0",
"node-fetch": "^2.1.1",
"nyc": "^11.6.0",
"socket.io-client": "^2.0.4",
"typescript": "^2.7.2"
"ava": "^2.4.0",
"node-fetch": "^2.6.0",
"nyc": "^14.1.1",
"socket.io-client": "^2.3.0",
"typescript": "^3.7.3"
},
"dependencies": {
"@types/cors": "^2.8.3",
"@types/debug": "^0.0.30",
"@types/express": "^4.11.1",
"@types/helmet": "^0.0.37",
"@types/node-fetch": "^1.6.7",
"@types/socket.io": "^1.4.32",
"@types/cors": "^2.8.6",
"@types/debug": "^4.1.5",
"@types/express": "^4.17.2",
"@types/helmet": "^0.0.45",
"@types/node-fetch": "^2.5.4",
"@types/socket.io": "^2.1.4",
"@types/socket.io-client": "^1.4.32",
"body-parser": "^1.18.2",
"cors": "^2.8.4",
"coveralls": "^3.0.0",
"debug": "^3.1.0",
"express": "^4.16.3",
"helmet": "^3.12.0",
"socket.io": "^2.0.4"
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"coveralls": "^3.0.9",
"debug": "^4.1.1",
"express": "^4.17.1",
"helmet": "^3.21.2",
"socket.io": "^2.3.0"
},

@@ -49,0 +49,0 @@ "author": "Jye Lewis",

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -17,4 +18,4 @@ });

while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {

@@ -38,3 +39,2 @@ case 0: case 1: t = op; break;

};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -44,3 +44,3 @@ var ava_1 = require("ava");

var APIEndpoint_1 = require("../../APIEndpoint");
ava_1.default('Converts to string', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Converts to string', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var convertedVal;

@@ -53,3 +53,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Converts to number', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Converts to number', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var convertedVal;

@@ -62,3 +62,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Converts to boolean (str lit)', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Converts to boolean (str lit)', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var convertedValTrue, convertedValFalse;

@@ -73,3 +73,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Converts to boolean (int val)', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Converts to boolean (int val)', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var convertedValTrue, convertedValFalse;

@@ -84,3 +84,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Converts to array', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Converts to array', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var convertedVal;

@@ -93,3 +93,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Converts to object', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Converts to object', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var convertedVal;

@@ -102,3 +102,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Throws with invalid number', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Throws with invalid number', function (t) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {

@@ -109,3 +109,3 @@ t.throws(function () { return convertParamType_1.convertParamType(APIEndpoint_1.paramType.number, 'testVar', 'a'); });

}); });
ava_1.default('Throws with invalid bool type', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Throws with invalid bool type', function (t) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {

@@ -116,3 +116,3 @@ t.throws(function () { return convertParamType_1.convertParamType(APIEndpoint_1.paramType.boolean, 'testVar', 'hi'); });

}); });
ava_1.default('Throws with invalid object', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Throws with invalid object', function (t) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {

@@ -123,3 +123,3 @@ t.throws(function () { return convertParamType_1.convertParamType(APIEndpoint_1.paramType.object, 'testVar', '{'); });

}); });
ava_1.default('Throws with invalid array', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Throws with invalid array', function (t) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {

@@ -131,3 +131,3 @@ t.throws(function () { return convertParamType_1.convertParamType(APIEndpoint_1.paramType.array, 'testVar', 'asfd'); });

}); });
ava_1.default('Throws with empty parameter', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Throws with empty parameter', function (t) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {

@@ -134,0 +134,0 @@ t.throws(function () { return convertParamType_1.convertParamType(APIEndpoint_1.paramType.string, 'testVar', undefined); });

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {

@@ -7,0 +10,0 @@ extendStatics(d, b);

@@ -1,2 +0,1 @@

/// <reference types="express" />
import { API } from "../../API";

@@ -3,0 +2,0 @@ import { Express } from "express";

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -17,4 +18,4 @@ });

while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {

@@ -21,0 +22,0 @@ case 0: case 1: t = op; break;

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {

@@ -13,6 +16,7 @@ extendStatics(d, b);

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -28,4 +32,4 @@ });

while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {

@@ -49,3 +53,2 @@ case 0: case 1: t = op; break;

};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -57,3 +60,3 @@ var ava_1 = require("ava");

var errorTypes_1 = require("../../errorTypes");
ava_1.default.before(function () { return __awaiter(_this, void 0, void 0, function () {
ava_1.default.before(function () { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, testAPI;

@@ -99,3 +102,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Calls action via webapi url', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Calls action via webapi url', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var res, _a, _b;

@@ -123,3 +126,3 @@ return __generator(this, function (_c) {

}); });
ava_1.default('Allows slashes in the endpoint url', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Allows slashes in the endpoint url', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var res, _a, _b;

@@ -147,3 +150,3 @@ return __generator(this, function (_c) {

}); });
ava_1.default('Gives error if AccessDeniedError is throw in action', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Gives error if AccessDeniedError is throw in action', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var res1, _a, _b, res2, _c, _d;

@@ -190,3 +193,3 @@ return __generator(this, function (_e) {

}); });
ava_1.default('Reads parameters from json encoded body', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Reads parameters from json encoded body', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var res1, _a, _b;

@@ -217,3 +220,3 @@ return __generator(this, function (_c) {

}); });
ava_1.default('reads parameters from urlencoded body', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('reads parameters from urlencoded body', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var res1, _a, _b;

@@ -241,3 +244,3 @@ return __generator(this, function (_c) {

}); });
ava_1.default('Allows authenticating via Bearer header', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Allows authenticating via Bearer header', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var res1, _a, _b, res2, _c, _d;

@@ -244,0 +247,0 @@ return __generator(this, function (_e) {

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {

@@ -13,6 +16,7 @@ extendStatics(d, b);

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -28,4 +32,4 @@ });

while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {

@@ -49,3 +53,2 @@ case 0: case 1: t = op; break;

};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -58,3 +61,3 @@ var ava_1 = require("ava");

var errorTypes_1 = require("../../errorTypes");
ava_1.default('Calls endpoint', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Calls endpoint', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var hasCalled, TestEndpoint, testApi, accessMethod, retVal;

@@ -88,3 +91,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Converts types', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Converts types', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, testApi, accessMethod, retVal;

@@ -130,3 +133,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Doesn\'t pass values that are not defined in params', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Doesn\'t pass values that are not defined in params', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, testApi, accessMethod, retVal;

@@ -166,3 +169,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Waits for connect() to complete before executing action', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Waits for connect() to complete before executing action', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var hasConnected, TestEndpoint, testApi, accessMethod;

@@ -207,3 +210,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Calls disconnect() in background after executing action', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Calls disconnect() in background after executing action', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var hasDisconnected, TestEndpoint, testApi, accessMethod;

@@ -252,3 +255,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Passes accessKey to endpoint before calling connect', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Passes accessKey to endpoint before calling connect', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, testApi, accessMethod;

@@ -282,3 +285,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Calling ActionError in endpoint passes out error message', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Calling ActionError in endpoint passes out error message', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, testApi, accessMethod, e_1;

@@ -318,3 +321,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Calling access denied in action causes processRequest to throw', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Calling access denied in action causes processRequest to throw', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, testApi, accessMethod, e_2;

@@ -321,0 +324,0 @@ return __generator(this, function (_a) {

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {

@@ -7,0 +10,0 @@ extendStatics(d, b);

@@ -1,2 +0,1 @@

/// <reference types="socket.io" />
import { API } from "../../API";

@@ -3,0 +2,0 @@ import { IEndpointConnection } from "./types";

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {

@@ -13,6 +16,7 @@ extendStatics(d, b);

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -28,4 +32,4 @@ });

while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {

@@ -32,0 +36,0 @@ case 0: case 1: t = op; break;

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -17,4 +18,4 @@ });

while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {

@@ -38,3 +39,2 @@ case 0: case 1: t = op; break;

};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -44,3 +44,3 @@ var ava_1 = require("ava");

var APIEndpoint_1 = require("../../APIEndpoint");
ava_1.default('Validates a string', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Validates a string', function (t) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {

@@ -51,3 +51,3 @@ t.notThrows(function () { return validateParamType_1.validateParamType(APIEndpoint_1.paramType.string, 'testVar', '123'); });

}); });
ava_1.default('Throws on invalid string', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Throws on invalid string', function (t) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {

@@ -58,3 +58,3 @@ t.throws(function () { return validateParamType_1.validateParamType(APIEndpoint_1.paramType.string, 'testVar', 123); });

}); });
ava_1.default('Validates a number', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Validates a number', function (t) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {

@@ -65,3 +65,3 @@ t.notThrows(function () { return validateParamType_1.validateParamType(APIEndpoint_1.paramType.number, 'testVar', 123); });

}); });
ava_1.default('Throws on invalid number', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Throws on invalid number', function (t) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {

@@ -72,3 +72,3 @@ t.throws(function () { return validateParamType_1.validateParamType(APIEndpoint_1.paramType.number, 'testVar', '123'); });

}); });
ava_1.default('Validates a boolean', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Validates a boolean', function (t) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {

@@ -80,3 +80,3 @@ t.notThrows(function () { return validateParamType_1.validateParamType(APIEndpoint_1.paramType.boolean, 'testVar', true); });

}); });
ava_1.default('Throws on invalid boolean', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Throws on invalid boolean', function (t) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {

@@ -87,3 +87,3 @@ t.throws(function () { return validateParamType_1.validateParamType(APIEndpoint_1.paramType.boolean, 'testVar', 1); });

}); });
ava_1.default('Validates an array', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Validates an array', function (t) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {

@@ -94,3 +94,3 @@ t.notThrows(function () { return validateParamType_1.validateParamType(APIEndpoint_1.paramType.array, 'testVar', [1, 2, 3]); });

}); });
ava_1.default('Throws on invalid array', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Throws on invalid array', function (t) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {

@@ -101,3 +101,3 @@ t.throws(function () { return validateParamType_1.validateParamType(APIEndpoint_1.paramType.array, 'testVar', '123'); });

}); });
ava_1.default('Validates an object', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Validates an object', function (t) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {

@@ -108,3 +108,3 @@ t.notThrows(function () { return validateParamType_1.validateParamType(APIEndpoint_1.paramType.object, 'testVar', { a: 1 }); });

}); });
ava_1.default('Throws on invalid object', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Throws on invalid object', function (t) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {

@@ -115,3 +115,3 @@ t.throws(function () { return validateParamType_1.validateParamType(APIEndpoint_1.paramType.array, 'testVar', 123); });

}); });
ava_1.default('Throws on invalid type', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Throws on invalid type', function (t) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {

@@ -122,3 +122,3 @@ t.throws(function () { return validateParamType_1.validateParamType('asdf', 'testVar', 123); });

}); });
ava_1.default('Throws with missing parameter', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Throws with missing parameter', function (t) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {

@@ -125,0 +125,0 @@ t.throws(function () { return validateParamType_1.validateParamType(APIEndpoint_1.paramType.string, 'testVar', undefined); });

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {

@@ -13,6 +16,7 @@ extendStatics(d, b);

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -28,4 +32,4 @@ });

while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {

@@ -49,3 +53,2 @@ case 0: case 1: t = op; break;

};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -128,3 +131,3 @@ var ava_1 = require("ava");

});
ava_1.default.after(function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default.after(function (t) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {

@@ -135,3 +138,3 @@ server.close();

}); });
ava_1.default('Throws if attempting to bind io while already bound', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Throws if attempting to bind io while already bound', function (t) { return __awaiter(void 0, void 0, void 0, function () {
return __generator(this, function (_a) {

@@ -144,182 +147,160 @@ t.throws(function () {

}); });
ava_1.default('Websocket emits serverReady after connecting', function (t) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve) {
var connection = ioClient('http://localhost:8056/');
connection.on('serverReady', function () {
t.pass();
resolve();
});
})];
ava_1.default('Websocket emits serverReady after connecting', function (t) {
return new Promise(function (resolve) {
var connection = ioClient('http://localhost:8056/');
connection.on('serverReady', function () {
t.pass();
resolve();
});
});
}); });
ava_1.default('Returns error when trying to connect to endpoint that doesnt exist', function (t) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve) {
var connection = ioClient('http://localhost:8056/');
connection.on('serverReady', function () {
connection.emit('connectToEndpoint', 'doesntExist', undefined, function (error) {
t.is(error, 'Unable to create endpoint connection, \'doesntExist\' does not exist');
resolve();
});
});
})];
});
ava_1.default('Returns error when trying to connect to endpoint that doesnt exist', function (t) {
return new Promise(function (resolve) {
var connection = ioClient('http://localhost:8056/');
connection.on('serverReady', function () {
connection.emit('connectToEndpoint', 'doesntExist', undefined, function (error) {
t.is(error, 'Unable to create endpoint connection, \'doesntExist\' does not exist');
resolve();
});
});
});
}); });
ava_1.default('Gets endpoint conenction ID when connected to endpoint', function (t) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve) {
var connection = ioClient('http://localhost:8056/');
connection.on('serverReady', function () {
connection.emit('connectToEndpoint', 'test', undefined, function (error, epcid) {
t.falsy(error);
t.truthy(epcid);
resolve();
});
});
})];
});
ava_1.default('Gets endpoint conenction ID when connected to endpoint', function (t) {
return new Promise(function (resolve) {
var connection = ioClient('http://localhost:8056/');
connection.on('serverReady', function () {
connection.emit('connectToEndpoint', 'test', undefined, function (error, epcid) {
t.falsy(error);
t.truthy(epcid);
resolve();
});
});
});
}); });
ava_1.default('Calls action and gets return value', function (t) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve) {
var connection = ioClient('http://localhost:8056/');
connection.on('serverReady', function () {
connection.emit('connectToEndpoint', 'test', undefined, function (error, epcid) {
t.falsy(error);
t.truthy(epcid);
connection.emit('callEndpointFunction', epcid, 'sayHello', {}, function (error, res) {
t.falsy(error);
t.deepEqual(res, { hello: 'world' });
resolve();
});
});
});
ava_1.default('Calls action and gets return value', function (t) {
return new Promise(function (resolve) {
var connection = ioClient('http://localhost:8056/');
connection.on('serverReady', function () {
connection.emit('connectToEndpoint', 'test', undefined, function (error, epcid) {
t.falsy(error);
t.truthy(epcid);
connection.emit('callEndpointFunction', epcid, 'sayHello', {}, function (error, res) {
t.falsy(error);
t.deepEqual(res, { hello: 'world' });
resolve();
});
})];
});
});
});
}); });
ava_1.default('Sends NotFoundError if action doesnt exist', function (t) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve) {
var connection = ioClient('http://localhost:8056/');
connection.on('serverReady', function () {
connection.emit('connectToEndpoint', 'test', undefined, function (error, epcid) {
t.falsy(error);
t.truthy(epcid);
connection.emit('callEndpointFunction', epcid, 'doesntExist', {}, function (error, res) {
t.is(error, 'action \'doesntExist\' does not exist');
t.falsy(res);
resolve();
});
});
});
ava_1.default('Sends NotFoundError if action doesnt exist', function (t) {
return new Promise(function (resolve) {
var connection = ioClient('http://localhost:8056/');
connection.on('serverReady', function () {
connection.emit('connectToEndpoint', 'test', undefined, function (error, epcid) {
t.falsy(error);
t.truthy(epcid);
connection.emit('callEndpointFunction', epcid, 'doesntExist', {}, function (error, res) {
t.is(error, 'action \'doesntExist\' does not exist');
t.falsy(res);
resolve();
});
})];
});
});
});
}); });
ava_1.default('Sends InvalidTypeError if types are invalid', function (t) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve) {
var connection = ioClient('http://localhost:8056/');
connection.on('serverReady', function () {
connection.emit('connectToEndpoint', 'test', undefined, function (error, epcid) {
t.falsy(error);
t.truthy(epcid);
connection.emit('callEndpointFunction', epcid, 'add', { a: 'a', b: 2 }, function (error, res) {
t.is(error, 'Expected param \'a\' to be a number, but it was not');
t.falsy(res);
resolve();
});
});
});
ava_1.default('Sends InvalidTypeError if types are invalid', function (t) {
return new Promise(function (resolve) {
var connection = ioClient('http://localhost:8056/');
connection.on('serverReady', function () {
connection.emit('connectToEndpoint', 'test', undefined, function (error, epcid) {
t.falsy(error);
t.truthy(epcid);
connection.emit('callEndpointFunction', epcid, 'add', { a: 'a', b: 2 }, function (error, res) {
t.is(error, 'Expected param \'a\' to be a number, but it was not');
t.falsy(res);
resolve();
});
})];
});
});
});
}); });
ava_1.default('Sends Internal server error if action throws', function (t) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve) {
var connection = ioClient('http://localhost:8056/');
connection.on('serverReady', function () {
connection.emit('connectToEndpoint', 'test', undefined, function (error, epcid) {
t.falsy(error);
t.truthy(epcid);
connection.emit('callEndpointFunction', epcid, 'throws', { a: 'a', b: 2 }, function (error, res) {
t.is(error, 'Internal server error');
t.falsy(res);
resolve();
});
});
});
ava_1.default('Sends Internal server error if action throws', function (t) {
return new Promise(function (resolve) {
var connection = ioClient('http://localhost:8056/');
connection.on('serverReady', function () {
connection.emit('connectToEndpoint', 'test', undefined, function (error, epcid) {
t.falsy(error);
t.truthy(epcid);
connection.emit('callEndpointFunction', epcid, 'throws', { a: 'a', b: 2 }, function (error, res) {
t.is(error, 'Internal server error');
t.falsy(res);
resolve();
});
})];
});
});
});
}); });
ava_1.default('Sends AccessDeniedError if action throws AccessDeniedError', function (t) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve) {
var connection = ioClient('http://localhost:8056/');
connection.on('serverReady', function () {
connection.emit('connectToEndpoint', 'test', undefined, function (error, epcid) {
t.falsy(error);
t.truthy(epcid);
connection.emit('callEndpointFunction', epcid, 'accessDenied', {}, function (error, res) {
t.is(error, 'Access denied: Test access denied');
t.falsy(res);
resolve();
});
});
});
ava_1.default('Sends AccessDeniedError if action throws AccessDeniedError', function (t) {
return new Promise(function (resolve) {
var connection = ioClient('http://localhost:8056/');
connection.on('serverReady', function () {
connection.emit('connectToEndpoint', 'test', undefined, function (error, epcid) {
t.falsy(error);
t.truthy(epcid);
connection.emit('callEndpointFunction', epcid, 'accessDenied', {}, function (error, res) {
t.is(error, 'Access denied: Test access denied');
t.falsy(res);
resolve();
});
})];
});
});
});
}); });
ava_1.default('Sends AccessDeniedError if endpoint connect throws AccessDeniedError', function (t) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve) {
var connection = ioClient('http://localhost:8056/');
connection.on('serverReady', function () {
connection.emit('connectToEndpoint', 'throws', undefined, function (error, epcid) {
t.is(error, 'Access denied: Access denied');
t.falsy(epcid);
resolve();
});
});
})];
});
ava_1.default('Sends AccessDeniedError if endpoint connect throws AccessDeniedError', function (t) {
return new Promise(function (resolve) {
var connection = ioClient('http://localhost:8056/');
connection.on('serverReady', function () {
connection.emit('connectToEndpoint', 'throws', undefined, function (error, epcid) {
t.is(error, 'Access denied: Access denied');
t.falsy(epcid);
resolve();
});
});
});
}); });
ava_1.default('Calls disconenct() on the endpoint when client asks to disconnect endpoint', function (t) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve) {
var connection = ioClient('http://localhost:8056/');
connection.on('serverReady', function () {
connection.emit('connectToEndpoint', 'test', undefined, function (error, epcid) {
t.falsy(error);
t.truthy(epcid);
t.false(hasDisconnected1);
connection.emit('disconnectEndpointConnection', epcid);
setTimeout(function () {
t.true(hasDisconnected1);
resolve();
}, 50);
});
});
})];
});
ava_1.default('Calls disconenct() on the endpoint when client asks to disconnect endpoint', function (t) {
return new Promise(function (resolve) {
var connection = ioClient('http://localhost:8056/');
connection.on('serverReady', function () {
connection.emit('connectToEndpoint', 'test', undefined, function (error, epcid) {
t.falsy(error);
t.truthy(epcid);
t.false(hasDisconnected1);
connection.emit('disconnectEndpointConnection', epcid);
setTimeout(function () {
t.true(hasDisconnected1);
resolve();
}, 50);
});
});
});
}); });
ava_1.default('Calls disconnect() on all endpoints when client socket conenction is lost', function (t) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve) {
var connection = ioClient('http://localhost:8056/');
connection.on('serverReady', function () {
connection.emit('connectToEndpoint', 'test2', undefined, function (error, epcid) {
t.falsy(error);
t.truthy(epcid);
t.false(hasDisconnected2);
connection.close();
setTimeout(function () {
t.true(hasDisconnected2);
resolve();
}, 50);
});
});
})];
});
ava_1.default('Calls disconnect() on all endpoints when client socket conenction is lost', function (t) {
return new Promise(function (resolve) {
var connection = ioClient('http://localhost:8056/');
connection.on('serverReady', function () {
connection.emit('connectToEndpoint', 'test2', undefined, function (error, epcid) {
t.falsy(error);
t.truthy(epcid);
t.false(hasDisconnected2);
connection.close();
setTimeout(function () {
t.true(hasDisconnected2);
resolve();
}, 50);
});
});
});
}); });
});
//# sourceMappingURL=WebSocketAccessMethod.itest.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {

@@ -13,6 +16,7 @@ extendStatics(d, b);

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -28,4 +32,4 @@ });

while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {

@@ -49,3 +53,2 @@ case 0: case 1: t = op; break;

};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -58,3 +61,3 @@ var ava_1 = require("ava");

var errorTypes_1 = require("../../errorTypes");
ava_1.default('Calls connect() when new endpoint is created', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Calls connect() when new endpoint is created', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var hasCalled, TestEndpoint, testApi, accessMethod;

@@ -86,3 +89,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Doesnt return the endpoint until callConnect() has resolved', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Doesnt return the endpoint until callConnect() has resolved', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var hasConnected, TestEndpoint, testApi, accessMethod;

@@ -124,3 +127,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Throws while connecing to endpoint if connect() fails', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Throws while connecing to endpoint if connect() fails', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, testApi, accessMethod, e_1;

@@ -159,3 +162,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Calls disconnect() when socket disconnects', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Calls disconnect() when socket disconnects', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var hasCalled1, hasCalled2, TestEndpoint1, TestEndpoint2, testApi, accessMethod;

@@ -204,3 +207,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Calling socket endpoint after disconnecting fails', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Calling socket endpoint after disconnecting fails', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, testApi, accessMethod, endpointConnection, e_2;

@@ -248,3 +251,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Disconnecting a socket cleans up all endpoints', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Disconnecting a socket cleans up all endpoints', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint1, TestEndpoint2, testApi, accessMethod, endpointConnection;

@@ -303,3 +306,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('disconnectEndpointConnection() calls disconnect on endpoint', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('disconnectEndpointConnection() calls disconnect on endpoint', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, testApi, accessMethod, endpointConnection;

@@ -338,3 +341,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('disconnectEndpointConnection() garbage collects endpoint', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('disconnectEndpointConnection() garbage collects endpoint', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, testApi, accessMethod, endpointConnection;

@@ -376,3 +379,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('disconnectEndpointConnection() fails if endpoint doesnt belong to given socket', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('disconnectEndpointConnection() fails if endpoint doesnt belong to given socket', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, testApi, accessMethod, endpointConnection;

@@ -419,3 +422,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Calls action', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Calls action', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var hasCalled, TestEndpoint, testApi, accessMethod, endpointConnection, retVal;

@@ -452,3 +455,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('callAction() fails if endpoint doesnt belong to socket', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('callAction() fails if endpoint doesnt belong to socket', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, testApi, accessMethod, endpointConnection, e_3;

@@ -490,3 +493,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('callAction() fails with valid error message if connection is closed', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('callAction() fails with valid error message if connection is closed', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, testApi, accessMethod, endpointConnection, e_4;

@@ -530,3 +533,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Passes param to action', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Passes param to action', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, testApi, accessMethod, endpointConnection, retVal;

@@ -565,3 +568,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Doesn\'t pass unspecified params', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Doesn\'t pass unspecified params', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, testApi, accessMethod, endpointConnection, retVal;

@@ -601,3 +604,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Throws if params are not the correct type', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Throws if params are not the correct type', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, testApi, accessMethod, endpointConnection, e_5;

@@ -641,3 +644,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Pasing accessKey when creating endpoint assigns it on the endpoint before calling connect()', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Pasing accessKey when creating endpoint assigns it on the endpoint before calling connect()', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, testApi, accessMethod;

@@ -667,3 +670,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Throwing AccessDeniedError returns error when connecting to endpoint', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Throwing AccessDeniedError returns error when connecting to endpoint', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, testApi, accessMethod, e_6;

@@ -703,3 +706,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Throwing AccessDeniedError returns error when calling action', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Throwing AccessDeniedError returns error when calling action', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, testApi, accessMethod, ep, e_7;

@@ -742,3 +745,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Throwing AccessDeniedError returns error when calling action', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Throwing AccessDeniedError returns error when calling action', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, testApi, accessMethod, ep, e_8;

@@ -745,0 +748,0 @@ return __generator(this, function (_a) {

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {

@@ -13,6 +16,7 @@ extendStatics(d, b);

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -28,4 +32,4 @@ });

while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {

@@ -49,3 +53,2 @@ case 0: case 1: t = op; break;

};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -57,3 +60,3 @@ var ava_1 = require("ava");

var ioClient = require("socket.io-client");
ava_1.default.before('Setup server', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default.before('Setup server', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, api;

@@ -84,3 +87,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Serves webapi requests from built in server', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Serves webapi requests from built in server', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var response, _a, _b;

@@ -102,13 +105,11 @@ return __generator(this, function (_c) {

}); });
ava_1.default('Serves websocket requests from built in server', function (t) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, new Promise(function (resolve) {
var socket = ioClient.connect('http://localhost:8258');
socket.on('serverReady', function () {
t.pass();
resolve();
});
})];
ava_1.default('Serves websocket requests from built in server', function (t) {
return new Promise(function (resolve) {
var socket = ioClient.connect('http://localhost:8258');
socket.on('serverReady', function () {
t.pass();
resolve();
});
});
}); });
});
//# sourceMappingURL=API.itest.js.map

@@ -63,2 +63,9 @@ "use strict";

var io = socketio(_this.server);
// pass express "app" & socket io into each endpoint to allow custom configuration
for (var endpointName in _this.endpoints) {
var endpointCls = _this.endpoints[endpointName];
if (typeof endpointCls.configureServer === "function") {
endpointCls.configureServer(app, io, _this.server);
}
}
//Setup access methods

@@ -65,0 +72,0 @@ var webApi = new WebAPIAccessMethod_1.WebAPIAccessMethod(_this, options.webApi);

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {

@@ -13,6 +16,7 @@ extendStatics(d, b);

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -28,4 +32,4 @@ });

while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {

@@ -49,3 +53,2 @@ case 0: case 1: t = op; break;

};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -55,3 +58,3 @@ var ava_1 = require("ava");

var APIEndpoint_1 = require("./APIEndpoint");
ava_1.default('Registers and returns endpoint', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Registers and returns endpoint', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint1, TestEndpoint2, api, inst1, inst2, inst3;

@@ -86,3 +89,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Returns null if endpoint doesnt exist', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Returns null if endpoint doesnt exist', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var api;

@@ -95,3 +98,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Allows using a custom ep constructor', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Allows using a custom ep constructor', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint1, api, inst1;

@@ -121,3 +124,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Endpoint names are case insensitive', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Endpoint names are case insensitive', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, api, inst1, inst2, inst3;

@@ -145,3 +148,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Validates endpoint name on register', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Validates endpoint name on register', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, api;

@@ -171,2 +174,26 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Calls static configureServer on endpoint when setting up, if available', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, api;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
TestEndpoint = /** @class */ (function (_super) {
__extends(TestEndpoint, _super);
function TestEndpoint() {
return _super !== null && _super.apply(this, arguments) || this;
}
TestEndpoint.configureServer = function (app, io, server) {
t.pass();
};
return TestEndpoint;
}(APIEndpoint_1.APIEndpoint));
api = new API_1.API();
api.registerEndpoint('test', TestEndpoint);
return [4 /*yield*/, api.listen(65432)];
case 1:
_a.sent();
return [2 /*return*/];
}
});
}); });
//# sourceMappingURL=API.test.js.map

@@ -6,3 +6,3 @@ export declare enum paramType {

array = "array",
boolean = "boolean",
boolean = "boolean"
}

@@ -13,3 +13,3 @@ export declare class APIEndpoint {

accessKey: string;
readonly isConnected: boolean;
get isConnected(): boolean;
actionExists(actionName: string): boolean;

@@ -16,0 +16,0 @@ actionParams(actionName: string): {

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -17,4 +18,4 @@ });

while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {

@@ -21,0 +22,0 @@ case 0: case 1: t = op; break;

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {

@@ -13,6 +16,7 @@ extendStatics(d, b);

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -28,4 +32,4 @@ });

while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {

@@ -49,3 +53,2 @@ case 0: case 1: t = op; break;

};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -55,3 +58,3 @@ var ava_1 = require("ava");

var delay_1 = require("./util/delay");
ava_1.default('actionExists()', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('actionExists()', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, ep;

@@ -77,3 +80,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('actionParams()', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('actionParams()', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, ep;

@@ -99,3 +102,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('callAction() sync', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('callAction() sync', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, ep, val;

@@ -135,3 +138,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('callAction() async', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('callAction() async', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, ep, val;

@@ -175,3 +178,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('callAction() calls with correct "this" context', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('callAction() calls with correct "this" context', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, ep;

@@ -207,3 +210,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('callAction() throws if an action doesnt exist', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('callAction() throws if an action doesnt exist', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, ep, e_1;

@@ -242,3 +245,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('callAction() throws if an action doesnt return an object', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('callAction() throws if an action doesnt return an object', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, ep, e_2;

@@ -277,3 +280,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('canEmit() correctly tells if an emitHandler has been registered', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('canEmit() correctly tells if an emitHandler has been registered', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var ep;

@@ -289,3 +292,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Emit handler is called when emitting', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Emit handler is called when emitting', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var ep;

@@ -310,3 +313,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Throws if .emit is called with no handler registered', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Throws if .emit is called with no handler registered', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var ep;

@@ -327,3 +330,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Throws if .emit is called before connect', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Throws if .emit is called before connect', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var ep;

@@ -339,3 +342,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Throws if .emit is called after disconnect', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Throws if .emit is called after disconnect', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var ep;

@@ -360,3 +363,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('callConnect and callDisconnect do not fail if the endpoint does not have functions for these hooks', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('callConnect and callDisconnect do not fail if the endpoint does not have functions for these hooks', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, ep;

@@ -385,3 +388,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('callConnect() calls connect and returns once connect() resolves', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('callConnect() calls connect and returns once connect() resolves', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var assert1, assert2, TestEndpoint, ep;

@@ -427,3 +430,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('callDisconnect() calls disconnect and returns once disconnect() resolves', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('callDisconnect() calls disconnect and returns once disconnect() resolves', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var assert1, assert2, TestEndpoint, ep;

@@ -472,3 +475,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Throws if trying to callConnect() while already connected', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Throws if trying to callConnect() while already connected', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, ep, e_3;

@@ -505,3 +508,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Throws if trying to callDisconnect() while not connected', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Throws if trying to callDisconnect() while not connected', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var TestEndpoint, ep, e_4;

@@ -508,0 +511,0 @@ return __generator(this, function (_a) {

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {

@@ -7,0 +10,0 @@ extendStatics(d, b);

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -17,4 +18,4 @@ });

while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {

@@ -38,3 +39,2 @@ case 0: case 1: t = op; break;

};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -46,3 +46,3 @@ var ava_1 = require("ava");

var CalculatorEndpoint_1 = require("../testEndpoints/CalculatorEndpoint");
ava_1.default.before(function () { return __awaiter(_this, void 0, void 0, function () {
ava_1.default.before(function () { return __awaiter(void 0, void 0, void 0, function () {
var api;

@@ -65,3 +65,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('API Responds to action', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('API Responds to action', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var res;

@@ -88,3 +88,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('API gives 404 when endpoint doesnt exist', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('API gives 404 when endpoint doesnt exist', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var res;

@@ -111,3 +111,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('API gives 404 when action doesnt exist', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('API gives 404 when action doesnt exist', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var res;

@@ -134,3 +134,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('API responds with return value and empty error', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('API responds with return value and empty error', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var res, _a, _b;

@@ -161,3 +161,3 @@ return __generator(this, function (_c) {

}); });
ava_1.default('API waits for an async action to complete', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('API waits for an async action to complete', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var res, _a, _b;

@@ -188,3 +188,3 @@ return __generator(this, function (_c) {

}); });
ava_1.default('API responds with error if arguments are an incorrect type', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('API responds with error if arguments are an incorrect type', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var res, _a, _b;

@@ -215,3 +215,3 @@ return __generator(this, function (_c) {

}); });
ava_1.default('API responds with error if arguments are missing', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('API responds with error if arguments are missing', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var res, _a, _b;

@@ -241,3 +241,3 @@ return __generator(this, function (_c) {

}); });
ava_1.default('API responds with error an internal server error occurs', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('API responds with error an internal server error occurs', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var res, _a, _b;

@@ -265,3 +265,3 @@ return __generator(this, function (_c) {

}); });
ava_1.default('API accepts boolean values', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('API accepts boolean values', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var res, _a, _b, res2, _c, _d;

@@ -268,0 +268,0 @@ return __generator(this, function (_e) {

@@ -11,3 +11,3 @@ import { APIEndpoint } from "../APIEndpoint";

};
$add({a, b}: {
$add({ a, b }: {
a: number;

@@ -23,3 +23,3 @@ b: number;

};
$specialAdd({a, b, strAdd}: {
$specialAdd({ a, b, strAdd }: {
a: number;

@@ -35,3 +35,3 @@ b: number;

};
$subtract({a, b}: {
$subtract({ a, b }: {
a: number;

@@ -46,3 +46,3 @@ b: number;

};
$multiply({a, b}: {
$multiply({ a, b }: {
a: number;

@@ -57,3 +57,3 @@ b: number;

};
$slowAdd({a, b}: {
$slowAdd({ a, b }: {
a: number;

@@ -60,0 +60,0 @@ b: number;

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {

@@ -13,6 +16,7 @@ extendStatics(d, b);

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -28,4 +32,4 @@ });

while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {

@@ -32,0 +36,0 @@ case 0: case 1: t = op; break;

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -17,4 +18,4 @@ });

while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {

@@ -38,3 +39,2 @@ case 0: case 1: t = op; break;

};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -44,3 +44,3 @@ var ava_1 = require("ava");

var delay_1 = require("../util/delay");
ava_1.default('Add basic numbers', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Add basic numbers', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var calc, value;

@@ -62,3 +62,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Throws adding larger numbers (ActionError)', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Throws adding larger numbers (ActionError)', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var calc, e_1;

@@ -89,3 +89,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Special adds using numbers', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Special adds using numbers', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var calc, value;

@@ -107,3 +107,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Special adds using strings', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Special adds using strings', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var calc, value;

@@ -125,3 +125,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Subtracts', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Subtracts', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var calc, value;

@@ -143,3 +143,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Multiplies', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Multiplies', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var calc, value, value2;

@@ -165,3 +165,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Slow adds', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Slow adds', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var calc, value;

@@ -183,4 +183,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Slow adds many items in parallel', function (t) { return __awaiter(_this, void 0, void 0, function () {
var _this = this;
ava_1.default('Slow adds many items in parallel', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var calc, testCases;

@@ -202,3 +201,3 @@ return __generator(this, function (_a) {

];
return [4 /*yield*/, Promise.all(testCases.map(function (c) { return __awaiter(_this, void 0, void 0, function () {
return [4 /*yield*/, Promise.all(testCases.map(function (c) { return __awaiter(void 0, void 0, void 0, function () {
var res;

@@ -221,3 +220,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Watches adds', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Watches adds', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var calc, value;

@@ -250,3 +249,3 @@ return __generator(this, function (_a) {

}); });
ava_1.default('Fails to watch adds if the connection doenst allow emitting', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Fails to watch adds if the connection doenst allow emitting', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var calc, e_2;

@@ -253,0 +252,0 @@ return __generator(this, function (_a) {

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -17,4 +18,4 @@ });

while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {

@@ -21,0 +22,0 @@ case 0: case 1: t = op; break;

@@ -1,1 +0,1 @@

export declare function delay(timeout: number): Promise<{}>;
export declare function delay(timeout: number): Promise<unknown>;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -17,4 +18,4 @@ });

while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {

@@ -38,7 +39,6 @@ case 0: case 1: t = op; break;

};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });
var ava_1 = require("ava");
var delay_1 = require("./delay");
ava_1.default('Resolves after given delay', function (t) { return __awaiter(_this, void 0, void 0, function () {
ava_1.default('Resolves after given delay', function (t) { return __awaiter(void 0, void 0, void 0, function () {
var testTimeout, startTime, endTime, timeTaken, tolerance;

@@ -45,0 +45,0 @@ return __generator(this, function (_a) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc