planet-client
Advanced tools
Comparing version 0.15.0 to 1.0.0
@@ -47,5 +47,5 @@ /** | ||
* @return {Promise.<Object[]>} A promise that resolves to an array of AOI | ||
* metadata or is rejected with any error. See the [`errors` module] | ||
* (#module:planet-client/api/errors) for a list of the possible error | ||
* types. | ||
* metadata or is rejected with any error. See the [`errors` | ||
* module](#module:planet-client/api/errors) for a list of the possible | ||
* error types. | ||
* @see {@link get} to obtain an individual AOI's GeoJSON and metadata. | ||
@@ -74,5 +74,5 @@ */ | ||
* @return {Promise.<Object[]>} A promise that resolves to an array of AOI | ||
* metadata or is rejected with any error. See the [`errors` module] | ||
* (#module:planet-client/api/errors) for a list of the possible error | ||
* types. | ||
* metadata or is rejected with any error. See the [`errors` | ||
* module](#module:planet-client/api/errors) for a list of the possible | ||
* error types. | ||
*/ | ||
@@ -79,0 +79,0 @@ function create(name, file, options) { |
@@ -58,10 +58,2 @@ /** | ||
// TODO: fix default port handling in http-browserify | ||
var defaultPort; | ||
if (config.protocol && config.protocol.indexOf('https') === 0) { | ||
defaultPort = '443'; | ||
} else { | ||
defaultPort = '80'; | ||
} | ||
var headers = assign({}, defaultHeaders); | ||
@@ -93,3 +85,2 @@ for (var key in config.headers) { | ||
hostname: config.hostname, | ||
port: config.port || defaultPort, | ||
method: config.method || 'GET', | ||
@@ -100,2 +91,6 @@ path: config.path, | ||
if (config.port) { | ||
options.port = config.port; | ||
} | ||
if ('withCredentials' in config) { | ||
@@ -262,11 +257,3 @@ options.withCredentials = config.withCredentials; | ||
if (!info.aborted && !info.completed) { | ||
info.aborted = true; | ||
if (client.abort) { | ||
client.abort(); | ||
} else if (client.xhr && client.xhr.abort) { | ||
// TODO: file a http-browserify issue for lack of abort | ||
client.xhr.abort(); | ||
} | ||
reject(new errors.AbortedRequest('Request aborted')); | ||
@@ -273,0 +260,0 @@ } |
@@ -86,5 +86,8 @@ #!/usr/bin/env node | ||
if (output) { | ||
process.stdout.write(output); | ||
process.stdout.write(output, function() { | ||
process.exit(0); | ||
}); | ||
} else { | ||
process.exit(0); | ||
} | ||
process.exit(0); | ||
}).catch(function(err) { | ||
@@ -91,0 +94,0 @@ log.error(err.message); |
@@ -135,3 +135,3 @@ var path = require('path'); | ||
/** | ||
* Recursively fetch all pages until the limit is reached. | ||
* Recursively request all pages until the limit is reached. | ||
* @param {Promise.<module:planet-client/api/page~Page>} promise A promise that | ||
@@ -143,7 +143,7 @@ * resolves to a page of scenes. | ||
*/ | ||
function fetch(promise, features, limit) { | ||
function keepRequesting(promise, features, limit) { | ||
return promise.then(function(page) { | ||
features = features.concat(page.data.features); | ||
if (page.next && features.length < limit) { | ||
return fetch(page.next(), features, limit); | ||
return keepRequesting(page.next(), features, limit); | ||
} else { | ||
@@ -168,3 +168,3 @@ if (features.length > limit) { | ||
log.debug('query: %j', query); | ||
return fetch(scenes.search(query), [], opts.limit); | ||
return keepRequesting(scenes.search(query), [], opts.limit); | ||
}).then(function(features) { | ||
@@ -212,3 +212,3 @@ return JSON.stringify({ | ||
exports.fetch = fetch; | ||
exports.keepRequesting = keepRequesting; | ||
exports.parseAcquired = parseAcquired; | ||
@@ -215,0 +215,0 @@ exports.parseWhere = parseWhere; |
@@ -90,8 +90,8 @@ var fs = require('fs'); | ||
return assertConfigNotFound().then(function() { | ||
return promptForMissing(opts); | ||
}).then(function(fullOpts) { | ||
return auth.login(fullOpts.email, fullOpts.password); | ||
}).then(function() { | ||
return writeKey(authStore.getKey()); | ||
}); | ||
return promptForMissing(opts); | ||
}).then(function(fullOpts) { | ||
return auth.login(fullOpts.email, fullOpts.password); | ||
}).then(function() { | ||
return writeKey(authStore.getKey()); | ||
}); | ||
} | ||
@@ -98,0 +98,0 @@ |
@@ -10,3 +10,3 @@ /* eslint-disable no-console */ | ||
function fetch(promise) { | ||
function keepRequesting(promise) { | ||
return promise.then(function(page) { | ||
@@ -16,3 +16,3 @@ mosaics = mosaics.concat(page.data.mosaics); | ||
if (page.next && mosaics.length < limit) { | ||
return fetch(page.next()); | ||
return keepRequesting(page.next()); | ||
} | ||
@@ -22,3 +22,3 @@ }); | ||
fetch(planet.mosaics.search()) | ||
keepRequesting(planet.mosaics.search()) | ||
.then(function() { | ||
@@ -25,0 +25,0 @@ console.log('done fetching'); |
@@ -16,3 +16,3 @@ /* eslint-disable no-console */ | ||
function fetch(promise) { | ||
function keepRequesting(promise) { | ||
return promise.then(function(page) { | ||
@@ -22,3 +22,3 @@ scenes = scenes.concat(page.data.features); | ||
if (page.next && scenes.length < limit) { | ||
return fetch(page.next()); | ||
return keepRequesting(page.next()); | ||
} | ||
@@ -28,3 +28,3 @@ }); | ||
fetch(planet.scenes.search(query)) | ||
keepRequesting(planet.scenes.search(query)) | ||
.then(function() { | ||
@@ -31,0 +31,0 @@ console.log('done fetching'); |
{ | ||
"name": "planet-client", | ||
"version": "0.15.0", | ||
"version": "1.0.0", | ||
"description": "A client for Planet's imagery API", | ||
@@ -17,10 +17,10 @@ "repository": { | ||
"test-node": "nyc mocha --recursive test", | ||
"test-browser": "karma start test/karma.config.js --single-run", | ||
"test": "npm run test-node && npm run test-browser", | ||
"coverage": "nyc report --reporter=html", | ||
"test-debug": "mocha --debug-brk --recursive test", | ||
"start": "watchy --watch bin,examples,api,cli,test -- npm test", | ||
"test-browser-once": "karma start test/karma.config.js --single-run", | ||
"test-browser-forever": "karma start test/karma.config.js", | ||
"test": "npm run test-node && npm run test-browser-once", | ||
"start": "npm run test-browser-forever & watchy --watch bin,examples,api,cli,test -- bash -c '(npm run pretest && npm run test-node)'", | ||
"coverage": "nyc report --reporter=text-lcov | coveralls", | ||
"postpublish": "npm run publish-doc", | ||
"apidoc": "mkdir -p build && jsdoc --template jsdoc-json --destination build/api.json api", | ||
"doc": "npm run apidoc && node --harmony-generators tasks/build-docs.js", | ||
"doc": "npm run apidoc && node tasks/build-docs.js", | ||
"start-doc": "watchy --watch doc,api,tasks -- npm run doc", | ||
@@ -38,27 +38,25 @@ "publish-doc": "npm run doc && gh-pages --dist build/doc" | ||
"devDependencies": { | ||
"browserify": "^7.0.3", | ||
"browserify": "^11.2.0", | ||
"chai": "^3.0.0", | ||
"coveralls": "^2.11.3", | ||
"envify": "^3.2.0", | ||
"eslint": "^0.22.1", | ||
"eslint-config-planet": "^2.0.0", | ||
"gh-pages": "^0.3.1", | ||
"handlebars": "^3.0.3", | ||
"jsdoc": "^3.3.2", | ||
"eslint": "^1.6.0", | ||
"eslint-config-planet": "^3.1.0", | ||
"gh-pages": "^0.4.0", | ||
"handlebars": "^4.0.3", | ||
"jsdoc": "^3.3.3", | ||
"jsdoc-json": "^2.0.0", | ||
"karma": "^0.13.9", | ||
"karma-browserify": "^4.3.0", | ||
"karma-chrome-launcher": "^0.2.0", | ||
"karma": "^0.13.10", | ||
"karma-browserify": "^4.4.0", | ||
"karma-chrome-launcher": "^0.2.1", | ||
"karma-mocha": "^0.2.0", | ||
"karma-sauce-launcher": "^0.2.14", | ||
"marked": "^0.3.5", | ||
"metalsmith": "^2.0.1", | ||
"metalsmith": "^2.1.0", | ||
"metalsmith-in-place": "^1.3.1", | ||
"metalsmith-layouts": "^1.3.0", | ||
"minami": "^1.1.0", | ||
"mocha": "^2.2.5", | ||
"nyc": "^3.1.0", | ||
"metalsmith-layouts": "^1.4.1", | ||
"mocha": "^2.3.3", | ||
"nyc": "^3.2.2", | ||
"readable-stream": "^2.0.2", | ||
"sinon": "^1.15.3", | ||
"watchy": "^0.6.2" | ||
"sinon": "^1.17.1", | ||
"watchy": "^0.6.5" | ||
}, | ||
@@ -69,2 +67,3 @@ "dependencies": { | ||
"bole": "^2.0.0", | ||
"envify": "^3.2.0", | ||
"jwt-claims": "^1.0.1", | ||
@@ -71,0 +70,0 @@ "os-homedir": "^1.0.0", |
@@ -51,10 +51,26 @@ ## planet-client | ||
Run the tests to ensure any changes meet the coding style and maintain the expected functionality: | ||
#### Running the tests | ||
The tests are run in a browser and in Node. You can run the linter and all tests once with the following: | ||
npm test | ||
During development, you can start a file watcher that runs the linter and tests with any file changes: | ||
To start a file watcher that runs the linter and tests with any file changes: | ||
npm start | ||
With the `npm start` task running, you can attach any number of browsers to the [test server](http://localhost:9876/). Every time you attach a new browser, tests run in all browsers. To debug any failing test, visit the test runner [debug page](http://localhost:9876/debug.html) and open your development console. | ||
#### Building the docs | ||
The project docs are generated from templates in the `doc` directory. The API docs are generated based on annotations in comments throughout the `api` modules. You can build the docs with the following task: | ||
npm run doc | ||
If you are making frequent changes and want to rebuild the docs with each change, use the `npm run start-doc` task. You can view the doc output in the `build/doc` directory. | ||
*Note* - Building the docs requires Node >= 4.0. | ||
#### Publishing a release | ||
Releases are published from the master branch. To cut a new minor release, do this: | ||
@@ -64,4 +80,6 @@ | ||
The `postpublish` script will update [the docs](http://planetlabs.github.io/planet-client-js/). | ||
The `postpublish` script will update the hosted version of [the docs](http://planetlabs.github.io/planet-client-js/). | ||
*Note* - Publishing a release requires Node >= 4.0. | ||
[![Build Status][travis-image]][travis-url] | ||
@@ -68,0 +86,0 @@ [![Coverage Status][coveralls-image]][coveralls-url] |
@@ -61,42 +61,42 @@ var Metalsmith = require('metalsmith'); | ||
switch (doc.kind) { | ||
case 'module': | ||
module = getNamed(doc.name, modules); | ||
assign(module, doc); | ||
break; | ||
case 'class': | ||
module = getModule(doc.longname, modules); | ||
case 'module': | ||
module = getNamed(doc.name, modules); | ||
assign(module, doc); | ||
break; | ||
case 'class': | ||
module = getModule(doc.longname, modules); | ||
if (!module.classes) { | ||
module.classes = []; | ||
} | ||
cls = getClass(doc.longname, module.classes); | ||
assign(cls, doc); | ||
break; | ||
case 'member': | ||
module = getModule(doc.longname, modules); | ||
cls = getClass(doc.memberof, module.classes); | ||
if (!cls.members) { | ||
cls.members = []; | ||
} | ||
cls.members.push(doc); | ||
break; | ||
case 'function': | ||
module = getModule(doc.longname, modules); | ||
if (doc.scope === 'instance') { | ||
if (!module.classes) { | ||
module.classes = []; | ||
} | ||
cls = getClass(doc.longname, module.classes); | ||
assign(cls, doc); | ||
break; | ||
case 'member': | ||
module = getModule(doc.longname, modules); | ||
cls = getClass(doc.memberof, module.classes); | ||
if (!cls.members) { | ||
cls.members = []; | ||
if (!cls.methods) { | ||
cls.methods = []; | ||
} | ||
cls.members.push(doc); | ||
break; | ||
case 'function': | ||
module = getModule(doc.longname, modules); | ||
if (doc.scope === 'instance') { | ||
if (!module.classes) { | ||
module.classes = []; | ||
} | ||
cls = getClass(doc.memberof, module.classes); | ||
if (!cls.methods) { | ||
cls.methods = []; | ||
} | ||
cls.methods.push(doc); | ||
} else { | ||
if (!module.functions) { | ||
module.functions = []; | ||
} | ||
module.functions.push(doc); | ||
cls.methods.push(doc); | ||
} else { | ||
if (!module.functions) { | ||
module.functions = []; | ||
} | ||
break; | ||
default: | ||
//pass | ||
module.functions.push(doc); | ||
} | ||
break; | ||
default: | ||
//pass | ||
} | ||
@@ -103,0 +103,0 @@ } |
@@ -72,3 +72,2 @@ /* eslint-env mocha */ | ||
hostname: 'example.com', | ||
port: '80', | ||
method: 'GET', | ||
@@ -346,3 +345,2 @@ path: '/', | ||
assert.instanceOf(err, errors.AbortedRequest); | ||
assert.equal(mockRequest.abort.callCount, 1); | ||
done(); | ||
@@ -352,24 +350,2 @@ }); | ||
it('calls request.xhr.abort() if request.abort is absent', function(done) { | ||
var promise = request({ | ||
url: 'http//example.com', | ||
terminator: function(abort) { | ||
setTimeout(abort, 10); | ||
} | ||
}); | ||
delete mockRequest.abort; | ||
mockRequest.xhr = { | ||
abort: sinon.spy() | ||
}; | ||
promise.then(function() { | ||
done(new Error('Expected promise to be rejected')); | ||
}).catch(function(err) { | ||
assert.instanceOf(err, errors.AbortedRequest); | ||
assert.equal(mockRequest.xhr.abort.callCount, 1); | ||
done(); | ||
}); | ||
}); | ||
it('allows termination on partial response', function(done) { | ||
@@ -393,3 +369,2 @@ var response = new stream.Readable(); | ||
assert.instanceOf(err, errors.AbortedRequest); | ||
assert.equal(mockRequest.abort.callCount, 1); | ||
}); | ||
@@ -491,3 +466,2 @@ | ||
hostname: 'example.com', | ||
port: '80', | ||
method: 'GET', | ||
@@ -524,3 +498,2 @@ path: '/', | ||
hostname: 'example.com', | ||
port: '80', | ||
method: 'GET', | ||
@@ -542,3 +515,2 @@ path: '/foo/relative/path/to/data.json', | ||
hostname: 'example.com', | ||
port: '80', | ||
method: 'GET', | ||
@@ -564,3 +536,2 @@ path: '/root/path/to/data.json', | ||
hostname: 'example.com', | ||
port: '80', | ||
method: 'GET', | ||
@@ -574,18 +545,2 @@ path: '/', | ||
it('uses the correct default port for https', function() { | ||
var config = { | ||
url: 'https://example.com' | ||
}; | ||
var options = { | ||
protocol: 'https:', | ||
hostname: 'example.com', | ||
port: '443', | ||
method: 'GET', | ||
path: '/', | ||
headers: defaultHeaders | ||
}; | ||
assert.deepEqual(parseConfig(config), options); | ||
}); | ||
it('works with a url.parse() response', function() { | ||
@@ -598,3 +553,2 @@ var config = url.parse('https://example.com/page/1', true); | ||
hostname: 'example.com', | ||
port: '443', | ||
method: 'GET', | ||
@@ -641,3 +595,2 @@ path: '/page/1?foo=bar', | ||
hostname: 'example.com', | ||
port: '80', | ||
method: 'POST', | ||
@@ -658,3 +611,2 @@ path: '/page', | ||
hostname: 'example.com', | ||
port: '80', | ||
method: 'GET', | ||
@@ -678,3 +630,2 @@ path: '/page?foo=bar', | ||
hostname: 'example.com', | ||
port: '80', | ||
method: 'GET', | ||
@@ -698,3 +649,2 @@ path: '/page?foo=bar%20bam', | ||
hostname: 'example.com', | ||
port: '80', | ||
method: 'GET', | ||
@@ -718,3 +668,2 @@ path: '/page?foo=bar&bam=baz', | ||
hostname: 'example.com', | ||
port: '80', | ||
method: 'GET', | ||
@@ -736,3 +685,2 @@ path: '/?foo=bam', | ||
hostname: 'example.com', | ||
port: '80', | ||
method: 'GET', | ||
@@ -739,0 +687,0 @@ path: '/', |
@@ -11,3 +11,3 @@ /* eslint-env mocha */ | ||
describe('fetch()', function() { | ||
describe('keepRequesting()', function() { | ||
@@ -40,3 +40,3 @@ var numPages = 10; | ||
findScenes.fetch(promise, [], 100).then(function(features) { | ||
findScenes.keepRequesting(promise, [], 100).then(function(features) { | ||
assert.lengthOf(features, 20); | ||
@@ -50,3 +50,3 @@ done(); | ||
findScenes.fetch(promise, [], 11).then(function(features) { | ||
findScenes.keepRequesting(promise, [], 11).then(function(features) { | ||
assert.lengthOf(features, 11); | ||
@@ -53,0 +53,0 @@ done(); |
@@ -7,3 +7,2 @@ var spy = require('sinon').spy; | ||
end: spy(), | ||
abort: spy(), | ||
on: spy() | ||
@@ -10,0 +9,0 @@ }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
23
1
100
12
147837
8
4165
+ Addedenvify@^3.2.0
+ Addedacorn@5.7.4(transitive)
+ Addedamdefine@1.0.1(transitive)
+ Addedast-types@0.9.6(transitive)
+ Addedbase62@1.2.8(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedcommoner@0.10.8(transitive)
+ Addeddefined@1.0.1(transitive)
+ Addeddetective@4.7.1(transitive)
+ Addedenvify@3.4.1(transitive)
+ Addedesprima@3.1.3(transitive)
+ Addedesprima-fb@15001.1.0-dev-harmony-fb(transitive)
+ Addedglob@5.0.15(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedjstransform@11.0.3(transitive)
+ Addedobject-assign@2.1.1(transitive)
+ Addedprivate@0.1.8(transitive)
+ Addedq@1.5.1(transitive)
+ Addedrecast@0.11.23(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsource-map@0.4.40.5.7(transitive)