@esri/arcgis-rest-feature-service
Advanced tools
Comparing version 1.13.2 to 1.14.0
@@ -10,1 +10,3 @@ export * from "./query"; | ||
export * from "./queryRelated"; | ||
export * from "./getLayer"; | ||
export * from "./decodeValues"; |
@@ -12,2 +12,4 @@ /* Copyright (c) 2018 Environmental Systems Research Institute, Inc. | ||
export * from "./queryRelated"; | ||
export * from "./getLayer"; | ||
export * from "./decodeValues"; | ||
//# sourceMappingURL=index.js.map |
@@ -109,3 +109,3 @@ import { IRequestOptions } from "@esri/arcgis-rest-request"; | ||
* url, | ||
* where: "STATE_NAME = 'Alaska" | ||
* where: "STATE_NAME = 'Alaska'" | ||
* }).then(result => { | ||
@@ -112,0 +112,0 @@ * console.log(result.features); // array of features |
@@ -1,2 +0,2 @@ | ||
/* Copyright (c) 2017 Environmental Systems Research Institute, Inc. | ||
/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
@@ -40,3 +40,3 @@ import * as tslib_1 from "tslib"; | ||
* url, | ||
* where: "STATE_NAME = 'Alaska" | ||
* where: "STATE_NAME = 'Alaska'" | ||
* }).then(result => { | ||
@@ -51,14 +51,13 @@ * console.log(result.features); // array of features | ||
export function queryFeatures(requestOptions) { | ||
// default to a GET request | ||
var options = tslib_1.__assign({ params: {}, httpMethod: "GET", url: requestOptions.url }, requestOptions); | ||
appendCustomParams(requestOptions, options); | ||
var queryOptions = tslib_1.__assign({ params: {}, httpMethod: "GET", url: requestOptions.url }, requestOptions); | ||
appendCustomParams(requestOptions, queryOptions); | ||
// set default query parameters | ||
if (!options.params.where) { | ||
options.params.where = "1=1"; | ||
if (!queryOptions.params.where) { | ||
queryOptions.params.where = "1=1"; | ||
} | ||
if (!options.params.outFields) { | ||
options.params.outFields = "*"; | ||
if (!queryOptions.params.outFields) { | ||
queryOptions.params.outFields = "*"; | ||
} | ||
return request(options.url + "/query", options); | ||
return request(queryOptions.url + "/query", queryOptions); | ||
} | ||
//# sourceMappingURL=query.js.map |
@@ -15,2 +15,4 @@ "use strict"; | ||
tslib_1.__exportStar(require("./queryRelated"), exports); | ||
tslib_1.__exportStar(require("./getLayer"), exports); | ||
tslib_1.__exportStar(require("./decodeValues"), exports); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
/* Copyright (c) 2017 Environmental Systems Research Institute, Inc. | ||
/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
@@ -43,3 +43,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
* url, | ||
* where: "STATE_NAME = 'Alaska" | ||
* where: "STATE_NAME = 'Alaska'" | ||
* }).then(result => { | ||
@@ -54,15 +54,14 @@ * console.log(result.features); // array of features | ||
function queryFeatures(requestOptions) { | ||
// default to a GET request | ||
var options = tslib_1.__assign({ params: {}, httpMethod: "GET", url: requestOptions.url }, requestOptions); | ||
arcgis_rest_request_1.appendCustomParams(requestOptions, options); | ||
var queryOptions = tslib_1.__assign({ params: {}, httpMethod: "GET", url: requestOptions.url }, requestOptions); | ||
arcgis_rest_request_1.appendCustomParams(requestOptions, queryOptions); | ||
// set default query parameters | ||
if (!options.params.where) { | ||
options.params.where = "1=1"; | ||
if (!queryOptions.params.where) { | ||
queryOptions.params.where = "1=1"; | ||
} | ||
if (!options.params.outFields) { | ||
options.params.outFields = "*"; | ||
if (!queryOptions.params.outFields) { | ||
queryOptions.params.outFields = "*"; | ||
} | ||
return arcgis_rest_request_1.request(options.url + "/query", options); | ||
return arcgis_rest_request_1.request(queryOptions.url + "/query", queryOptions); | ||
} | ||
exports.queryFeatures = queryFeatures; | ||
//# sourceMappingURL=query.js.map |
/* @preserve | ||
* @esri/arcgis-rest-feature-service - v1.13.2 - Apache-2.0 | ||
* @esri/arcgis-rest-feature-service - v1.14.0 - Apache-2.0 | ||
* Copyright (c) 2017-2018 Esri, Inc. | ||
* Fri Nov 02 2018 15:54:14 GMT-0700 (Pacific Daylight Time) | ||
* Wed Nov 14 2018 14:40:06 GMT-0800 (Pacific Standard Time) | ||
*/ | ||
@@ -27,11 +27,14 @@ (function (global, factory) { | ||
var __assign = Object.assign || function __assign(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
var __assign = function() { | ||
__assign = Object.assign || function __assign(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
/* Copyright (c) 2017 Environmental Systems Research Institute, Inc. | ||
/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
@@ -73,3 +76,3 @@ /** | ||
* url, | ||
* where: "STATE_NAME = 'Alaska" | ||
* where: "STATE_NAME = 'Alaska'" | ||
* }).then(result => { | ||
@@ -84,13 +87,12 @@ * console.log(result.features); // array of features | ||
function queryFeatures(requestOptions) { | ||
// default to a GET request | ||
var options = __assign({ params: {}, httpMethod: "GET", url: requestOptions.url }, requestOptions); | ||
arcgisRestRequest.appendCustomParams(requestOptions, options); | ||
var queryOptions = __assign({ params: {}, httpMethod: "GET", url: requestOptions.url }, requestOptions); | ||
arcgisRestRequest.appendCustomParams(requestOptions, queryOptions); | ||
// set default query parameters | ||
if (!options.params.where) { | ||
options.params.where = "1=1"; | ||
if (!queryOptions.params.where) { | ||
queryOptions.params.where = "1=1"; | ||
} | ||
if (!options.params.outFields) { | ||
options.params.outFields = "*"; | ||
if (!queryOptions.params.outFields) { | ||
queryOptions.params.outFields = "*"; | ||
} | ||
return arcgisRestRequest.request(options.url + "/query", options); | ||
return arcgisRestRequest.request(queryOptions.url + "/query", queryOptions); | ||
} | ||
@@ -333,3 +335,117 @@ | ||
* Apache-2.0 */ | ||
/** | ||
* Layer (Feature Service) request. See the [REST Documentation](https://developers.arcgis.com/rest/services-reference/layer-feature-service-.htm) for more information. | ||
* | ||
* ```js | ||
* import { getLayer } from '@esri/arcgis-rest-feature-service'; | ||
* | ||
* const url = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0"; | ||
* | ||
* getLayer(url) | ||
* .then(response) // { name: "311", id: 0, ... } | ||
* ``` | ||
* | ||
* @param requestOptions - Options for the request. | ||
* @returns A Promise that will resolve with the addFeatures response. | ||
*/ | ||
function getLayer(url, requestOptions) { | ||
return arcgisRestRequest.request(url, requestOptions); | ||
} | ||
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
/** | ||
* Replaces the raw coded domain values in a query response with descriptions (for legibility). | ||
* | ||
* ```js | ||
* import { queryFeatures, decodeValues } from '@esri/arcgis-rest-feature-service'; | ||
* | ||
* const url = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0"; | ||
* | ||
* queryFeatures({ url }) | ||
* .then(queryResponse => { | ||
* decodeValues({ | ||
* url, | ||
* queryResponse | ||
* }) | ||
* .then(decodedResponse) | ||
* }) | ||
* ``` | ||
* | ||
* @param requestOptions - Options for the request. | ||
* @returns A Promise that will resolve with the addFeatures response. | ||
*/ | ||
function decodeValues(requestOptions) { | ||
return new Promise(function (resolve) { | ||
if (!requestOptions.fields) { | ||
return getLayer(requestOptions.url, requestOptions).then(function (metadata) { | ||
resolve((requestOptions.fields = metadata.fields)); | ||
}); | ||
} | ||
else { | ||
resolve(requestOptions.fields); | ||
} | ||
}).then(function (fields) { | ||
// turn the fields array into a POJO to avoid multiple calls to Array.find() | ||
var fieldsObject = {}; | ||
var fieldsArray = fields; | ||
fieldsArray.forEach(function (field) { | ||
fieldsObject[field.name] = field; | ||
}); | ||
// dont mutate original response | ||
var clonedResponse = JSON.parse(JSON.stringify(requestOptions.queryResponse)); | ||
clonedResponse.features.forEach(function (feature) { | ||
for (var key in feature.attributes) { | ||
/* istanbul ignore next */ | ||
if (!feature.attributes.hasOwnProperty(key)) | ||
continue; | ||
feature.attributes[key] = convertAttribute(feature.attributes, fieldsObject[key]); | ||
} | ||
}); | ||
return clonedResponse; | ||
}); | ||
} | ||
/** | ||
* ripped off from https://github.com/GeoXForm/esri-to-geojson/blob/55d32955d8ef0acb26de70025539e7c7a37d838e/src/index.js#L193-L220 | ||
* | ||
* Decodes an attributes CVD and standardizes any date fields | ||
* | ||
* @params {object} attribute - a single esri feature attribute | ||
* @params {object} field - the field metadata describing that attribute | ||
* @returns {object} outAttribute - the converted attribute | ||
* @private | ||
*/ | ||
function convertAttribute(attribute, field) { | ||
var inValue = attribute[field.name]; | ||
var value; | ||
if (inValue === null) | ||
return inValue; | ||
if (field.domain && field.domain.type === "codedValue") { | ||
value = cvd(inValue, field); | ||
} | ||
else { | ||
value = inValue; | ||
} | ||
return value; | ||
} | ||
/** | ||
* also ripped off from https://github.com/GeoXForm/esri-to-geojson/blob/55d32955d8ef0acb26de70025539e7c7a37d838e/src/index.js#L222-L235 | ||
* | ||
* Looks up a value from a coded domain | ||
* | ||
* @params {integer} value - The original field value | ||
* @params {object} field - metadata describing the attribute field | ||
* @returns {string/integerfloat} - The decoded field value | ||
* @private | ||
*/ | ||
function cvd(value, field) { | ||
var domain = field.domain.codedValues.find(function (d) { | ||
return value === d.code; | ||
}); | ||
return domain ? domain.name : value; | ||
} | ||
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
exports.getFeature = getFeature; | ||
@@ -345,2 +461,4 @@ exports.queryFeatures = queryFeatures; | ||
exports.queryRelated = queryRelated; | ||
exports.getLayer = getLayer; | ||
exports.decodeValues = decodeValues; | ||
@@ -347,0 +465,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
/* @preserve | ||
* @esri/arcgis-rest-feature-service - v1.13.2 - Apache-2.0 | ||
* @esri/arcgis-rest-feature-service - v1.14.0 - Apache-2.0 | ||
* Copyright (c) 2017-2018 Esri, Inc. | ||
* Fri Nov 02 2018 15:54:17 GMT-0700 (Pacific Daylight Time) | ||
* Wed Nov 14 2018 14:40:09 GMT-0800 (Pacific Standard Time) | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@esri/arcgis-rest-request")):"function"==typeof define&&define.amd?define(["exports","@esri/arcgis-rest-request"],t):t(e.arcgisRest=e.arcgisRest||{},e.arcgisRest)}(this,function(e,t){"use strict";var a=Object.assign||function(e){for(var t,a=1,r=arguments.length;a<r;a++)for(var s in t=arguments[a])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e};e.getFeature=function(e){var r=e.url+"/"+e.id,s=a({httpMethod:"GET"},e);return t.request(r,s).then(function(e){return e.feature})},e.queryFeatures=function(e){var r=a({params:{},httpMethod:"GET",url:e.url},e);return t.appendCustomParams(e,r),r.params.where||(r.params.where="1=1"),r.params.outFields||(r.params.outFields="*"),t.request(r.url+"/query",r)},e.addFeatures=function(e){var r=e.url+"/addFeatures",s=a({params:{}},e);return t.appendCustomParams(e,s),s.params.features=e.adds,delete s.params.adds,t.request(r,s)},e.updateFeatures=function(e){var r=e.url+"/updateFeatures",s=a({params:{}},e);return t.appendCustomParams(e,s),s.params.features=e.updates,delete s.params.updates,t.request(r,s)},e.deleteFeatures=function(e){var r=e.url+"/deleteFeatures",s=a({params:{}},e);return t.appendCustomParams(e,s),s.params.objectIds=e.deletes,delete s.params.deletes,t.request(r,s)},e.getAttachments=function(e){return t.request(e.url+"/"+e.featureId+"/attachments",e)},e.addAttachment=function(e){var r=a({params:{}},e);return r.params.attachment=e.attachment,t.request(r.url+"/"+r.featureId+"/addAttachment",r)},e.updateAttachment=function(e){var r=a({params:{}},e);return r.params.attachment=e.attachment,r.params.attachmentId=e.attachmentId,t.request(r.url+"/"+r.featureId+"/updateAttachment",r)},e.deleteAttachments=function(e){var r=a({params:{}},e);return r.params.attachmentIds=e.attachmentIds,t.request(r.url+"/"+r.featureId+"/deleteAttachments",r)},e.queryRelated=function(e){var r=a({params:{},httpMethod:"GET",url:e.url},e);return t.appendCustomParams(e,r),r.params.definitionExpression||(r.params.definitionExpression="1=1"),r.params.outFields||(r.params.outFields="*"),r.params.relationshipId||(r.params.relationshipId=0),t.request(r.url+"/queryRelatedRecords",r)},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@esri/arcgis-rest-request")):"function"==typeof define&&define.amd?define(["exports","@esri/arcgis-rest-request"],t):t(e.arcgisRest=e.arcgisRest||{},e.arcgisRest)}(this,function(e,t){"use strict";var r=function(){return(r=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function a(e,r){return t.request(e,r)}e.getFeature=function(e){var a=e.url+"/"+e.id,n=r({httpMethod:"GET"},e);return t.request(a,n).then(function(e){return e.feature})},e.queryFeatures=function(e){var a=r({params:{},httpMethod:"GET",url:e.url},e);return t.appendCustomParams(e,a),a.params.where||(a.params.where="1=1"),a.params.outFields||(a.params.outFields="*"),t.request(a.url+"/query",a)},e.addFeatures=function(e){var a=e.url+"/addFeatures",n=r({params:{}},e);return t.appendCustomParams(e,n),n.params.features=e.adds,delete n.params.adds,t.request(a,n)},e.updateFeatures=function(e){var a=e.url+"/updateFeatures",n=r({params:{}},e);return t.appendCustomParams(e,n),n.params.features=e.updates,delete n.params.updates,t.request(a,n)},e.deleteFeatures=function(e){var a=e.url+"/deleteFeatures",n=r({params:{}},e);return t.appendCustomParams(e,n),n.params.objectIds=e.deletes,delete n.params.deletes,t.request(a,n)},e.getAttachments=function(e){return t.request(e.url+"/"+e.featureId+"/attachments",e)},e.addAttachment=function(e){var a=r({params:{}},e);return a.params.attachment=e.attachment,t.request(a.url+"/"+a.featureId+"/addAttachment",a)},e.updateAttachment=function(e){var a=r({params:{}},e);return a.params.attachment=e.attachment,a.params.attachmentId=e.attachmentId,t.request(a.url+"/"+a.featureId+"/updateAttachment",a)},e.deleteAttachments=function(e){var a=r({params:{}},e);return a.params.attachmentIds=e.attachmentIds,t.request(a.url+"/"+a.featureId+"/deleteAttachments",a)},e.queryRelated=function(e){var a=r({params:{},httpMethod:"GET",url:e.url},e);return t.appendCustomParams(e,a),a.params.definitionExpression||(a.params.definitionExpression="1=1"),a.params.outFields||(a.params.outFields="*"),a.params.relationshipId||(a.params.relationshipId=0),t.request(a.url+"/queryRelatedRecords",a)},e.getLayer=a,e.decodeValues=function(e){return new Promise(function(t){if(!e.fields)return a(e.url,e).then(function(r){t(e.fields=r.fields)});t(e.fields)}).then(function(t){var r={};t.forEach(function(e){r[e.name]=e});var a=JSON.parse(JSON.stringify(e.queryResponse));return a.features.forEach(function(e){for(var t in e.attributes)e.attributes.hasOwnProperty(t)&&(e.attributes[t]=(a=e.attributes,n=r[t],void 0,null===(s=a[n.name])?s:n.domain&&"codedValue"===n.domain.type?function(e,t){var r=t.domain.codedValues.find(function(t){return e===t.code});return r?r.name:e}(s,n):s));var a,n,s}),a})},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=feature-service.umd.min.js.map |
{ | ||
"name": "@esri/arcgis-rest-feature-service", | ||
"version": "1.13.2", | ||
"version": "1.14.0", | ||
"description": "Feature service helpers for @esri/arcgis-rest-request", | ||
@@ -18,4 +18,4 @@ "main": "dist/node/index.js", | ||
"devDependencies": { | ||
"@esri/arcgis-rest-common-types": "^1.13.2", | ||
"@esri/arcgis-rest-request": "^1.13.2" | ||
"@esri/arcgis-rest-common-types": "^1.14.0", | ||
"@esri/arcgis-rest-request": "^1.14.0" | ||
}, | ||
@@ -22,0 +22,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
174427
72
1
1997