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

hsdk

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hsdk - npm Package Compare versions

Comparing version 1.1.2 to 2.0.0

source/treeify/test.js

2

package.json
{
"name": "hsdk",
"version": "1.1.2",
"version": "2.0.0",
"description": "A hypermedia standard development kit for knowing about home api endpoints",

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

@@ -20,3 +20,3 @@ # hsdk

hsdk({protocol: "http", host: "hsdkjs.getsandbox.com", root: "v1/resources"})
.then((client) => client("v1/Accounts").list())
.then((client) => client.accounts.v1.list())
.then((value) => console.log(value))

@@ -43,2 +43,3 @@ ```

- namespace: The groupings this resource is under, can be anything
- version: The version of the endpoint, if no version you SHOULD use `latest`
- description: A short description for the resource

@@ -67,10 +68,11 @@ - method: The HTTP verb used

{
"id": "v1-accounts-list",
"id": "accounts-v1-list",
"type": "resources",
"attributes": {
"intent": "list",
"namespace": "v1/accounts",
"namespace": "accounts",
"version": "v1",
"description": "List accounts.",
"method": "GET",
"href": "http://hsdkjs.getsandbox.com/v2/accounts",
"href": "http://hsdkjs.getsandbox.com/v1/accounts",
"query": {

@@ -83,11 +85,12 @@ "filter": true,

"links": {
"self": "http://hsdkjs.getsandbox.com/v1/resources/v1-accounts-list"
"self": "http://hsdkjs.getsandbox.com/v1/resources/accounts-v1-list"
}
},
{
"id": "v1-accounts-show",
"id": "accounts-v1-show",
"type": "resources",
"attributes": {
"intent": "show",
"namespace": "v1/accounts",
"namespace": "accounts",
"version": "v1",
"description": "Show an individual account.",

@@ -102,11 +105,12 @@ "method": "GET",

"links": {
"self": "http://hsdkjs.getsandbox.com/v1/resources/v1-accounts-show"
"self": "http://hsdkjs.getsandbox.com/v1/resources/accounts-v1-show"
}
},
{
"id": "v1-accounts-update",
"id": "accounts-v1-update",
"type": "resources",
"attributes": {
"intent": "update",
"namespace": "v1/accounts",
"namespace": "accounts",
"version": "v1",
"description": "Update an individual account.",

@@ -125,3 +129,3 @@ "method": "PATCH",

"links": {
"self": "http://hsdkjs.getsandbox.com/v1/resources/v1-accounts-update"
"self": "http://hsdkjs.getsandbox.com/v1/resources/accounts-v1-update"
}

@@ -128,0 +132,0 @@ }

@@ -18,3 +18,2 @@ import axios from "axios"

.then(treeify)
.then((client) => (key) => client[key])
}

@@ -7,9 +7,11 @@ import {prop} from "ramda"

const groupByNamespace = groupBy(prop("namespace"))
const groupByVersion = groupBy(prop("version"))
const groupedByVersion = map(groupByVersion)
const indexByIntent = indexBy(prop("intent"))
const mapToRequest = map(prop("request"))
const mapToIntentIndex = map(indexByIntent)
const nestedMapToRequest = map(mapToRequest)
const indexedByIntent = map(map(indexByIntent))
const asRequest = map(prop("request"))
const asRequests = map(map(map(asRequest)))
export default function treeify (responses) {
return nestedMapToRequest(mapToIntentIndex(groupByNamespace(responses)))
return asRequests(indexedByIntent(groupedByVersion(groupByNamespace(responses))))
}

@@ -37,7 +37,3 @@ "use strict";

responseType: "json"
}).then(_handleResponse2.default).then(_wrapResources2.default).then(_treeify2.default).then(function (client) {
return function (key) {
return client[key];
};
});
}).then(_handleResponse2.default).then(_wrapResources2.default).then(_treeify2.default);
}

@@ -11,9 +11,11 @@ "use strict";

var groupByNamespace = (0, _ramda.groupBy)((0, _ramda.prop)("namespace"));
var groupByVersion = (0, _ramda.groupBy)((0, _ramda.prop)("version"));
var groupedByVersion = (0, _ramda.map)(groupByVersion);
var indexByIntent = (0, _ramda.indexBy)((0, _ramda.prop)("intent"));
var mapToRequest = (0, _ramda.map)((0, _ramda.prop)("request"));
var mapToIntentIndex = (0, _ramda.map)(indexByIntent);
var nestedMapToRequest = (0, _ramda.map)(mapToRequest);
var indexedByIntent = (0, _ramda.map)((0, _ramda.map)(indexByIntent));
var asRequest = (0, _ramda.map)((0, _ramda.prop)("request"));
var asRequests = (0, _ramda.map)((0, _ramda.map)((0, _ramda.map)(asRequest)));
function treeify(responses) {
return nestedMapToRequest(mapToIntentIndex(groupByNamespace(responses)));
return asRequests(indexedByIntent(groupedByVersion(groupByNamespace(responses))));
}
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