Comparing version 6.1.0 to 7.0.0
{ | ||
"name": "hsdk", | ||
"version": "6.1.0", | ||
"version": "7.0.0", | ||
"description": "A hypermedia standard development kit for knowing about home api endpoints", | ||
@@ -60,3 +60,3 @@ "main": "transpiled/source/index.js", | ||
"@unction/treeify": "1.0.8", | ||
"abstraction": "10.0.0", | ||
"abstraction": "10.1.0", | ||
"axios": "0.16.1", | ||
@@ -63,0 +63,0 @@ "httpstatuses": "3.0.0", |
@@ -1,4 +0,2 @@ | ||
/* eslint-disable no-console */ | ||
import {path} from "ramda" | ||
import {merge} from "ramda" | ||
import {prop} from "ramda" | ||
@@ -8,10 +6,10 @@ import {groupBy} from "ramda" | ||
import treeify from "@unction/treeify" | ||
import mapValues from "@unction/mapvalues" | ||
import wrapResources from "../wrapResources" | ||
import request from "./request" | ||
import resource from "./resource" | ||
const tree = treeify([ | ||
groupBy(prop("namespace")), | ||
groupBy(prop("version")), | ||
indexBy(prop("intent")), | ||
groupBy(path(["attributes", "namespace"])), | ||
groupBy(path(["attributes", "version"])), | ||
indexBy(path(["attributes", "intent"])), | ||
prop("request"), | ||
@@ -23,5 +21,4 @@ ]) | ||
.then(path(["data", "data"])) | ||
.then(wrapResources) | ||
.then(mapValues(resource)) | ||
.then(tree) | ||
.then(merge({request})) | ||
} |
@@ -13,8 +13,10 @@ /* eslint-disable flowtype/require-parameter-type, flowtype/require-return-type */ | ||
attributes: { | ||
intent: "list", | ||
intent: "show", | ||
version: "v1", | ||
namespace: "accounts", | ||
verb: "GET", | ||
method: "GET", | ||
description: "test", | ||
query: {}, | ||
href: "https://example.com/v1/accounts/{id}", | ||
mediatype: "application/json", | ||
mediatype: "application/vnd.api+json", | ||
}, | ||
@@ -28,4 +30,6 @@ }, | ||
type(subject, "function") | ||
end() | ||
}) | ||
test("Must return a promise", ({type, end}) => { | ||
@@ -36,4 +40,6 @@ type(subject( | ||
), "Promise") | ||
end() | ||
}) | ||
test("Returned promise resolution must be an object", ({type}) => { | ||
@@ -52,3 +58,3 @@ return subject( | ||
) | ||
.then((client) => type(client.accounts.v1.list, "function")) | ||
.then((client) => type(client.accounts.v1.show, "function")) | ||
}) |
@@ -14,17 +14,16 @@ "use strict"; | ||
var _wrapResources = require("../wrapResources"); | ||
var _mapvalues = require("@unction/mapvalues"); | ||
var _wrapResources2 = _interopRequireDefault(_wrapResources); | ||
var _mapvalues2 = _interopRequireDefault(_mapvalues); | ||
var _request = require("./request"); | ||
var _resource = require("./resource"); | ||
var _request2 = _interopRequireDefault(_request); | ||
var _resource2 = _interopRequireDefault(_resource); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/* eslint-disable no-console */ | ||
var tree = (0, _treeify2.default)([(0, _ramda.groupBy)((0, _ramda.prop)("namespace")), (0, _ramda.groupBy)((0, _ramda.prop)("version")), (0, _ramda.indexBy)((0, _ramda.prop)("intent")), (0, _ramda.prop)("request")]); | ||
var tree = (0, _treeify2.default)([(0, _ramda.groupBy)((0, _ramda.path)(["attributes", "namespace"])), (0, _ramda.groupBy)((0, _ramda.path)(["attributes", "version"])), (0, _ramda.indexBy)((0, _ramda.path)(["attributes", "intent"])), (0, _ramda.prop)("request")]); | ||
function callHome(client) { | ||
return client.then((0, _ramda.path)(["data", "data"])).then(_wrapResources2.default).then(tree).then((0, _ramda.merge)({ request: _request2.default })); | ||
return client.then((0, _ramda.path)(["data", "data"])).then((0, _mapvalues2.default)(_resource2.default)).then(tree); | ||
} |
@@ -18,8 +18,10 @@ "use strict"; | ||
attributes: { | ||
intent: "list", | ||
intent: "show", | ||
version: "v1", | ||
namespace: "accounts", | ||
verb: "GET", | ||
method: "GET", | ||
description: "test", | ||
query: {}, | ||
href: "https://example.com/v1/accounts/{id}", | ||
mediatype: "application/json" | ||
mediatype: "application/vnd.api+json" | ||
} | ||
@@ -35,4 +37,6 @@ }] | ||
type(_2.default, "function"); | ||
end(); | ||
}); | ||
(0, _tap.test)("Must return a promise", function (_ref2) { | ||
@@ -43,4 +47,6 @@ var type = _ref2.type, | ||
type((0, _2.default)("", mocks), "Promise"); | ||
end(); | ||
}); | ||
(0, _tap.test)("Returned promise resolution must be an object", function (_ref3) { | ||
@@ -58,4 +64,4 @@ var type = _ref3.type; | ||
return (0, _2.default)("", mocks).then(function (client) { | ||
return type(client.accounts.v1.list, "function"); | ||
return type(client.accounts.v1.show, "function"); | ||
}); | ||
}); |
@@ -14,2 +14,6 @@ "use strict"; | ||
var _istype = require("@unction/istype"); | ||
var _istype2 = _interopRequireDefault(_istype); | ||
var _ispopulated = require("@unction/ispopulated"); | ||
@@ -19,3 +23,3 @@ | ||
var _resource = require("./resource"); | ||
var _resource = require("../resource"); | ||
@@ -27,3 +31,3 @@ var _resource2 = _interopRequireDefault(_resource); | ||
function wrapResources(resources) { | ||
if ((0, _ramda.isNil)(resources)) { | ||
if (!(0, _istype2.default)("Array")(resources)) { | ||
throw new Error("Resources was " + (0, _ramda.type)(resources) + " and not an Array"); | ||
@@ -30,0 +34,0 @@ } |
54846
61
1243
+ Addedabstraction@10.1.0(transitive)
- Removedabstraction@10.0.0(transitive)
Updatedabstraction@10.1.0