@boundlessgeo/cloud-core
Advanced tools
Comparing version 0.1.2 to 0.2.0
@@ -40,4 +40,8 @@ 'use strict'; | ||
return fetch(url, fetch_opts).then(function (r) { | ||
return r.json(); | ||
return fetch(url, fetch_opts).then(function (response) { | ||
if (response.ok) { | ||
return response.json(); | ||
} else { | ||
throw Error(response.statusText); | ||
} | ||
}); | ||
@@ -63,4 +67,8 @@ } | ||
var url = geoServerUrl + '/rest/auth/entitlement/' + identifier + '?' + query_string; | ||
return fetch(url, fetch_opts).then(function (r) { | ||
return r.json(); | ||
return fetch(url, fetch_opts).then(function (response) { | ||
if (response.ok) { | ||
return response.json(); | ||
} else { | ||
throw Error(response.statusText); | ||
} | ||
}); | ||
@@ -97,5 +105,9 @@ } | ||
var url = geoServerUrl + '/rest/auth/entitlement?' + query_string; | ||
return fetch(url, fetch_opts).then(function (r) { | ||
return r.json(); | ||
return fetch(url, fetch_opts).then(function (response) { | ||
if (response.ok) { | ||
return response.json(); | ||
} else { | ||
throw Error(response.statusText); | ||
} | ||
}); | ||
} |
@@ -17,2 +17,3 @@ 'use strict'; | ||
exports.getWorkspaces = getWorkspaces; | ||
exports.getAvailableStyles = getAvailableStyles; | ||
@@ -324,3 +325,3 @@ var _util = require('./util'); | ||
* @param {Array} layers - MapBox style layer definitions. | ||
* @param {object} [options] - Access control options, honors accessToken, headers | ||
* @param {object} [options] - Access control options, honors accessToken, headers, sprite | ||
* | ||
@@ -343,2 +344,5 @@ * @return {Promise} The promise from Fetch. | ||
}; | ||
if (options.sprite) { | ||
create_body.style.sprite = options.sprite; | ||
} | ||
@@ -421,3 +425,3 @@ fetch_opts.body = JSON.stringify(create_body); | ||
* @param {Array} layers - MapBox style layer definitions. | ||
* @param {object} [options] - Access control options, honors accessToken, headers | ||
* @param {object} [options] - Access control options, honors accessToken, headers, sprite | ||
* | ||
@@ -441,2 +445,5 @@ * @return {Promise} The promise from Fetch. | ||
}; | ||
if (options.sprite) { | ||
body.sprite = options.sprite; | ||
} | ||
fetch_opts.body = JSON.stringify(body); | ||
@@ -505,3 +512,3 @@ | ||
* @param {string} geoServerUrl - GeoServer URL | ||
* @param {object} [options] - Access control options, honors accessToken, headers | ||
* @param {object} [options] - Access control options, honors accessToken, headers, isDefault | ||
* | ||
@@ -515,3 +522,4 @@ * @return {Promise} The promise from Fetch. | ||
var fetch_opts = (0, _util.getFetchOptions)(options.headers); | ||
return fetch(geoServerUrl + '/rest/workspaces.json?' + query_string, fetch_opts).then(function (response) { | ||
var url = geoServerUrl + '/rest/workspaces' + (options.isDefault ? '/default' : '') + '.json?' + query_string; | ||
return fetch(url, fetch_opts).then(function (response) { | ||
if (response.ok) { | ||
@@ -525,2 +533,29 @@ return response.json(); | ||
}); | ||
} | ||
/** Get a list of available styles for a given layer. | ||
* | ||
* @param {string} geoServerUrl - GeoServer URL | ||
* @param {string} layerName - The name of the layer. | ||
* @param {object} [options] - Access control options, honors accessToken, headers | ||
* | ||
* @return {Promise} The promise from Fetch. | ||
*/ | ||
function getAvailableStyles(geoServerUrl, layerName) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var query_string = (0, _util.encodeQueryParams)({}, options.accessToken); | ||
var fetch_opts = (0, _util.getFetchOptions)(options.headers); | ||
return fetch(geoServerUrl + '/rest/layers/' + layerName + '/styles.json?' + query_string, fetch_opts).then(function (response) { | ||
if (response.ok) { | ||
return response.json(); | ||
} else { | ||
return response.text().then(function (text) { | ||
throw new Error(response.statusText + ': ' + text); | ||
}); | ||
} | ||
}).then(function (response) { | ||
return response.styles.style; | ||
}); | ||
} |
{ | ||
"name": "@boundlessgeo/cloud-core", | ||
"author": "Boundless Spatial Inc.", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"description": "A library for facilitating communication with the Boundless mBSE.", | ||
@@ -6,0 +6,0 @@ "repository": { |
# cloud-core | ||
[](https://ciapi.boundlessgeo.io/job/cloud-core/job/master/) | ||
A library for facilitating communication with the Boundless mBSE. The goal of this project is to encapsulate all communication patterns with the mBSE API such that downstream projects can use a common set of actions to interact with an mBSE instance without writing boilerplate code. |
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
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
5
31494
8
833
18