planet-client
Advanced tools
Comparing version 0.8.2 to 0.9.0
@@ -21,3 +21,3 @@ /** | ||
var config = { | ||
url: urls.LOGIN, | ||
url: urls.login(), | ||
body: { | ||
@@ -24,0 +24,0 @@ email: email, |
@@ -27,3 +27,3 @@ /** | ||
var config = { | ||
url: urls.join(urls.MOSAICS, id), | ||
url: urls.mosaics(id), | ||
terminator: options.terminator | ||
@@ -55,3 +55,3 @@ }; | ||
var config = { | ||
url: urls.MOSAICS, | ||
url: urls.mosaics(), | ||
query: query, | ||
@@ -58,0 +58,0 @@ terminator: options.terminator |
@@ -28,3 +28,3 @@ /** | ||
var config = { | ||
url: urls.join(urls.MOSAICS, mosaicId, 'quads', quadId), | ||
url: urls.mosaics(mosaicId, 'quads', quadId), | ||
terminator: options.terminator | ||
@@ -57,3 +57,3 @@ }; | ||
var config = { | ||
url: urls.join(urls.MOSAICS, mosaicId, 'quads', ''), | ||
url: urls.mosaics(mosaicId, 'quads', ''), | ||
query: query, | ||
@@ -90,3 +90,3 @@ terminator: options.terminator | ||
var config = { | ||
url: urls.join(urls.MOSAICS, mosaicId, 'quads', quadId, 'scenes', ''), | ||
url: urls.mosaics(mosaicId, 'quads', quadId, 'scenes', ''), | ||
terminator: options.terminator | ||
@@ -93,0 +93,0 @@ }; |
@@ -35,3 +35,3 @@ /** | ||
var config = { | ||
url: urls.join(urls.SCENES, scene.type, scene.id), | ||
url: urls.scenes(scene.type, scene.id), | ||
terminator: options.terminator | ||
@@ -71,3 +71,3 @@ }; | ||
var config = { | ||
url: urls.join(urls.SCENES, type, ''), | ||
url: urls.scenes(type, ''), | ||
query: query, | ||
@@ -74,0 +74,0 @@ terminator: options.terminator |
@@ -7,3 +7,3 @@ /** | ||
var API = require('./config').API_URL; | ||
var config = require('./config'); | ||
@@ -13,6 +13,7 @@ /** | ||
* slashes will be removed from the parts before they are joined. | ||
* A single trailing slash can forced by an empty string as the final vararg. | ||
* @return {string} The joined URL. | ||
*/ | ||
function join() { | ||
return Array.prototype.map.call(arguments, function(part) { | ||
var components = Array.prototype.map.call(arguments, function(part) { | ||
if (!(typeof part === 'string' || typeof part === 'number')) { | ||
@@ -23,11 +24,31 @@ throw new Error( | ||
return String(part).replace(/^\/?(.*?)\/?$/, '$1'); | ||
}).join('/'); | ||
}); | ||
// Preserve trailing slashes but remove every other interstitial. | ||
var lastComponent = components.pop(); | ||
return components | ||
.filter(function(el) { | ||
return el !== ''; | ||
}) | ||
.concat(lastComponent) | ||
.join('/'); | ||
} | ||
exports.API = API; | ||
exports.MOSAICS = join(API, 'mosaics', ''); | ||
exports.SCENES = join(API, 'scenes', ''); | ||
exports.WORKSPACES = join(API, 'workspaces', ''); | ||
exports.LOGIN = join(API, 'auth', 'login'); | ||
function rootUrl() { | ||
var baseComponents = Array.prototype.slice.call(arguments); | ||
return function() { | ||
return join.apply(null, | ||
[config.API_URL] | ||
.concat(baseComponents) | ||
.concat(Array.prototype.slice.call(arguments)) | ||
); | ||
}; | ||
} | ||
exports.api = rootUrl(); | ||
exports.mosaics = rootUrl('mosaics', ''); | ||
exports.scenes = rootUrl('scenes', ''); | ||
exports.workspaces = rootUrl('workspaces', ''); | ||
exports.login = rootUrl('auth', 'login'); | ||
exports.join = join; |
@@ -11,3 +11,3 @@ /** | ||
function get(id) { | ||
var url = urls.join(urls.WORKSPACES, id); | ||
var url = urls.workspaces(id); | ||
return request.get(url).then(function(res) { | ||
@@ -19,3 +19,3 @@ return res.body; | ||
function search() { | ||
var url = urls.WORKSPACES; | ||
var url = urls.workspaces(); | ||
return request.get(url).then(function(res) { | ||
@@ -22,0 +22,0 @@ return res.body; |
{ | ||
"name": "planet-client", | ||
"version": "0.8.2", | ||
"version": "0.9.0", | ||
"description": "A client for Planet's imagery API", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -59,3 +59,8 @@ ## planet-client | ||
Releases are published from the master branch. To cut a new minor release, do this: | ||
npm version minor && git push --tags origin master && npm publish | ||
The `postpublish` script will update [the docs](http://planetlabs.github.io/planet-client-js/). | ||
[![Build Status][travis-image]][travis-url] | ||
@@ -62,0 +67,0 @@ [![Coverage Status][coveralls-image]][coveralls-url] |
@@ -12,2 +12,4 @@ /* eslint-env mocha */ | ||
var MOSAICS = 'https://api.planet.com/v0/mosaics/'; | ||
describe('api/mosaics', function() { | ||
@@ -65,3 +67,3 @@ | ||
var arg = calls[0]; | ||
assert.equal(arg.url, urls.join(urls.MOSAICS, 'one')); | ||
assert.equal(arg.url, urls.join(MOSAICS, 'one')); | ||
@@ -135,3 +137,3 @@ promise.then(function(got) { | ||
var arg = calls[0]; | ||
assert.equal(arg.url, urls.MOSAICS); | ||
assert.equal(arg.url, MOSAICS); | ||
assert.deepEqual(arg.query, query); | ||
@@ -138,0 +140,0 @@ |
@@ -12,2 +12,4 @@ /* eslint-env mocha */ | ||
var MOSAICS = 'https://api.planet.com/v0/mosaics/'; | ||
describe('api/mosaics', function() { | ||
@@ -70,3 +72,3 @@ | ||
assert.equal(arg.url, | ||
urls.join(urls.MOSAICS, 'my-mosaic', 'quads', 'my-quad')); | ||
urls.join(MOSAICS, 'my-mosaic', 'quads', 'my-quad')); | ||
@@ -140,3 +142,3 @@ promise.then(function(got) { | ||
var arg = calls[0]; | ||
assert.equal(arg.url, urls.join(urls.MOSAICS, 'my-mosaic', 'quads', '')); | ||
assert.equal(arg.url, urls.join(MOSAICS, 'my-mosaic', 'quads', '')); | ||
assert.deepEqual(arg.query, query); | ||
@@ -232,3 +234,3 @@ | ||
assert.equal(arg.url, urls.join( | ||
urls.MOSAICS, 'my-mosaic', 'quads', 'my-quad', 'scenes', '')); | ||
MOSAICS, 'my-mosaic', 'quads', 'my-quad', 'scenes', '')); | ||
@@ -235,0 +237,0 @@ promise.then(function(got) { |
@@ -12,2 +12,4 @@ /* eslint-env mocha */ | ||
var SCENES = 'https://api.planet.com/v0/scenes/'; | ||
describe('api/scenes', function() { | ||
@@ -56,3 +58,3 @@ | ||
var arg = calls[0]; | ||
assert.equal(arg.url, urls.join(urls.SCENES, 'foo', 'bar')); | ||
assert.equal(arg.url, urls.join(SCENES, 'foo', 'bar')); | ||
@@ -76,3 +78,3 @@ promise.then(function(got) { | ||
var promise = scenes.get('bar'); | ||
assert.equal(calls[0].url, urls.join(urls.SCENES, 'ortho', 'bar')); | ||
assert.equal(calls[0].url, urls.join(SCENES, 'ortho', 'bar')); | ||
@@ -166,3 +168,3 @@ promise.then(function(got) { | ||
var arg = calls[0]; | ||
assert.equal(arg.url, urls.join(urls.SCENES, 'landsat', '')); | ||
assert.equal(arg.url, urls.join(SCENES, 'landsat', '')); | ||
assert.deepEqual(arg.query, query); | ||
@@ -198,3 +200,3 @@ | ||
var arg = calls[0]; | ||
assert.equal(arg.url, urls.join(urls.SCENES, 'ortho', '')); | ||
assert.equal(arg.url, urls.join(SCENES, 'ortho', '')); | ||
assert.deepEqual(arg.query, query); | ||
@@ -201,0 +203,0 @@ |
@@ -42,2 +42,5 @@ /* eslint-env mocha */ | ||
expected: 'http://example.com/foo/bar/bam' | ||
}, { | ||
actual: urls.join('http://example.com', '', 'foo/', 'bam/', '', ''), | ||
expected: 'http://example.com/foo/bam/' | ||
}]; | ||
@@ -76,4 +79,19 @@ | ||
it('works with degenerate cases', function() { | ||
var cases = [{ | ||
actual: urls.join(), | ||
expected: '' | ||
}, { | ||
actual: urls.join('', ''), | ||
expected: '' | ||
}]; | ||
for (var i = 0, ii = cases.length; i < ii; ++i) { | ||
var c = cases[i]; | ||
assert.deepEqual(c.actual, c.expected, 'case ' + i); | ||
} | ||
}); | ||
}); | ||
}); |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
2770919
63
86356
82
19