stratumn-agent
Advanced tools
Comparing version 0.17.0 to 0.18.0
@@ -6,27 +6,6 @@ 'use strict'; | ||
}); | ||
var _keys = require('babel-runtime/core-js/object/keys'); | ||
var _keys2 = _interopRequireDefault(_keys); | ||
exports.default = makeQueryString; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _qs = require('qs'); | ||
/* | ||
Copyright 2017 Stratumn SAS. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
/** | ||
@@ -38,13 +17,25 @@ * Makes a query string. | ||
function makeQueryString(obj) { | ||
const parts = (0, _keys2.default)(obj).reduce((curr, key) => { | ||
const val = Array.isArray(obj[key]) ? obj[key].join('+') : obj[key]; | ||
curr.push(`${encodeURIComponent(key)}=${encodeURIComponent(val)}`); | ||
return curr; | ||
}, []); | ||
if (parts.length) { | ||
return `?${parts.join('&')}`; | ||
// use brackets format for compatibility with GO: | ||
// https://github.com/google/go-querystring | ||
// see also conversation in: | ||
// https://github.com/stratumn/indigo-js/pull/18 | ||
const query = (0, _qs.stringify)(obj, { arrayFormat: 'brackets' }); | ||
if (query.length) { | ||
return `?${query}`; | ||
} | ||
return ''; | ||
} | ||
} /* | ||
Copyright 2017 Stratumn SAS. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ |
@@ -66,3 +66,2 @@ 'use strict'; | ||
const QUEUED = 'QUEUED'; | ||
const DISABLED = 'DISABLED'; | ||
const COMPLETE = 'COMPLETE'; | ||
@@ -153,6 +152,3 @@ | ||
const meta = { | ||
linkHash: linkHash, | ||
evidence: { state: this.fossilizerClient ? QUEUED : DISABLED } | ||
}; | ||
const meta = (0, _assign2.default)({ linkHash: linkHash }, this.fossilizerClient ? { evidence: { state: QUEUED } } : {}); | ||
@@ -204,8 +200,4 @@ segment = { link: link, meta: meta }; | ||
const linkHash = (0, _hashJson2.default)(createdLink); | ||
const meta = (0, _assign2.default)({ linkHash: linkHash }, this.fossilizerClient ? { evidence: { state: QUEUED } } : {}); | ||
const meta = { | ||
linkHash: linkHash, | ||
evidence: { state: this.fossilizerClient ? QUEUED : DISABLED } | ||
}; | ||
segment = { link: createdLink, meta: meta }; | ||
@@ -212,0 +204,0 @@ return this.applyPlugins('didCreateSegment', segment, action, args); |
{ | ||
"name": "stratumn-agent", | ||
"version": "0.17.0", | ||
"version": "0.18.0", | ||
"description": "", | ||
@@ -39,2 +39,3 @@ "main": "lib/index.js", | ||
"express": "^4.14.0", | ||
"qs": "^6.5.1", | ||
"request": "^2.73.0", | ||
@@ -41,0 +42,0 @@ "stratumn-mock-agent": "^1.2.0", |
@@ -59,3 +59,3 @@ # Stratumn agent for NodeJS | ||
server.listen(3000, () => { | ||
console.log('Listening on ' + server.adress().port); | ||
console.log('Listening on ' + server.address().port); | ||
}); | ||
@@ -62,0 +62,0 @@ |
@@ -17,2 +17,4 @@ /* | ||
import { stringify } from 'qs'; | ||
/** | ||
@@ -24,13 +26,11 @@ * Makes a query string. | ||
export default function makeQueryString(obj) { | ||
const parts = Object.keys(obj).reduce((curr, key) => { | ||
const val = Array.isArray(obj[key]) ? obj[key].join('+') : obj[key]; | ||
curr.push(`${encodeURIComponent(key)}=${encodeURIComponent(val)}`); | ||
return curr; | ||
}, []); | ||
if (parts.length) { | ||
return `?${parts.join('&')}`; | ||
// use brackets format for compatibility with GO: | ||
// https://github.com/google/go-querystring | ||
// see also conversation in: | ||
// https://github.com/stratumn/indigo-js/pull/18 | ||
const query = stringify(obj, { arrayFormat: 'brackets' }); | ||
if (query.length) { | ||
return `?${query}`; | ||
} | ||
return ''; | ||
} |
@@ -27,3 +27,2 @@ /* | ||
const QUEUED = 'QUEUED'; | ||
const DISABLED = 'DISABLED'; | ||
const COMPLETE = 'COMPLETE'; | ||
@@ -118,6 +117,4 @@ | ||
const meta = { | ||
linkHash, | ||
evidence: { state: this.fossilizerClient ? QUEUED : DISABLED } | ||
}; | ||
const meta = Object.assign({ linkHash }, | ||
this.fossilizerClient ? { evidence: { state: QUEUED } } : {}); | ||
@@ -170,8 +167,5 @@ segment = { link, meta }; | ||
const linkHash = hashJson(createdLink); | ||
const meta = Object.assign({ linkHash }, | ||
this.fossilizerClient ? { evidence: { state: QUEUED } } : {}); | ||
const meta = { | ||
linkHash, | ||
evidence: { state: this.fossilizerClient ? QUEUED : DISABLED } | ||
}; | ||
segment = { link: createdLink, meta }; | ||
@@ -250,8 +244,8 @@ return this.applyPlugins('didCreateSegment', segment, action, args); | ||
/** | ||
* Gets map IDs. | ||
* @param {object} [opts] - pagination options | ||
* @param {number} [opts.offset] - offset of the first map ID to return | ||
* @param {number} [opts.limit] - maximum number of map IDs to return | ||
* @returns {Promise} - a promise that resolve with the map IDs | ||
*/ | ||
* Gets map IDs. | ||
* @param {object} [opts] - pagination options | ||
* @param {number} [opts.offset] - offset of the first map ID to return | ||
* @param {number} [opts.limit] - maximum number of map IDs to return | ||
* @returns {Promise} - a promise that resolve with the map IDs | ||
*/ | ||
getMapIds(opts) { | ||
@@ -258,0 +252,0 @@ return this.storeClient.getMapIds(this.name, opts); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
153533
11
3418
+ Addedqs@^6.5.1