@esri/arcgis-rest-feature-service
Advanced tools
Comparing version
/* @preserve | ||
* @esri/arcgis-rest-feature-service - v1.13.1 - Apache-2.0 | ||
* @esri/arcgis-rest-feature-service - v1.13.2 - Apache-2.0 | ||
* Copyright (c) 2017-2018 Esri, Inc. | ||
* Mon Oct 15 2018 12:06:20 GMT-0700 (Pacific Daylight Time) | ||
* Fri Nov 02 2018 15:54:14 GMT-0700 (Pacific Daylight Time) | ||
*/ | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@esri/arcgis-rest-request')) : | ||
typeof define === 'function' && define.amd ? define(['exports', '@esri/arcgis-rest-request'], factory) : | ||
(factory((global.arcgisRest = global.arcgisRest || {}),global.arcgisRest)); | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@esri/arcgis-rest-request')) : | ||
typeof define === 'function' && define.amd ? define(['exports', '@esri/arcgis-rest-request'], factory) : | ||
(factory((global.arcgisRest = global.arcgisRest || {}),global.arcgisRest)); | ||
}(this, (function (exports,arcgisRestRequest) { 'use strict'; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. 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 | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. 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 | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
***************************************************************************** */ | ||
/* global Reflect, Promise */ | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
***************************************************************************** */ | ||
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; | ||
}; | ||
/* Copyright (c) 2017 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
/** | ||
* Get a feature by id. | ||
* | ||
* ```js | ||
* import { getFeature } from '@esri/arcgis-rest-feature-service'; | ||
* | ||
* const url = "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Landscape_Trees/FeatureServer/0"; | ||
* | ||
* getFeature({ | ||
* url, | ||
* id: 42 | ||
* }).then(feature => { | ||
* console.log(feature.attributes.FID); // 42 | ||
* }); | ||
* ``` | ||
* | ||
* @param requestOptions - Options for the request | ||
* @returns A Promise that will resolve with the feature. | ||
*/ | ||
function getFeature(requestOptions) { | ||
var url = requestOptions.url + "/" + requestOptions.id; | ||
// default to a GET request | ||
var options = __assign({ httpMethod: "GET" }, requestOptions); | ||
return arcgisRestRequest.request(url, options).then(function (response) { return response.feature; }); | ||
} | ||
/** | ||
* Query a feature service. See [REST Documentation](https://developers.arcgis.com/rest/services-reference/query-feature-service-layer-.htm) for more information. | ||
* | ||
* ```js | ||
* import { queryFeatures } from '@esri/arcgis-rest-feature-service'; | ||
* | ||
* const url = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3"; | ||
* | ||
* queryFeatures({ | ||
* url, | ||
* where: "STATE_NAME = 'Alaska" | ||
* }).then(result => { | ||
* console.log(result.features); // array of features | ||
* }); | ||
* ``` | ||
* | ||
* @param requestOptions - Options for the request | ||
* @returns A Promise that will resolve with the query response. | ||
*/ | ||
function queryFeatures(requestOptions) { | ||
// default to a GET request | ||
var options = __assign({ params: {}, httpMethod: "GET", url: requestOptions.url }, requestOptions); | ||
arcgisRestRequest.appendCustomParams(requestOptions, options); | ||
// set default query parameters | ||
if (!options.params.where) { | ||
options.params.where = "1=1"; | ||
} | ||
if (!options.params.outFields) { | ||
options.params.outFields = "*"; | ||
} | ||
return arcgisRestRequest.request(options.url + "/query", options); | ||
} | ||
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]; | ||
/* Copyright (c) 2017 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
/** | ||
* Add features request. See the [REST Documentation](https://developers.arcgis.com/rest/services-reference/add-features.htm) for more information. | ||
* | ||
* ```js | ||
* import { addFeatures } from '@esri/arcgis-rest-feature-service'; | ||
* | ||
* const url = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0"; | ||
* | ||
* addFeatures({ | ||
* url, | ||
* adds: [{ | ||
* geometry: { x: -120, y: 45, spatialReference: { wkid: 4326 } }, | ||
* attributes: { status: "alive" } | ||
* }] | ||
* }); | ||
* ``` | ||
* | ||
* @param requestOptions - Options for the request. | ||
* @returns A Promise that will resolve with the addFeatures response. | ||
*/ | ||
function addFeatures(requestOptions) { | ||
var url = requestOptions.url + "/addFeatures"; | ||
// edit operations are POST only | ||
var options = __assign({ params: {} }, requestOptions); | ||
arcgisRestRequest.appendCustomParams(requestOptions, options); | ||
// mixin, don't overwrite | ||
options.params.features = requestOptions.adds; | ||
delete options.params.adds; | ||
return arcgisRestRequest.request(url, options); | ||
} | ||
return t; | ||
}; | ||
/* Copyright (c) 2017 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
/** | ||
* Get a feature by id. | ||
* | ||
* ```js | ||
* import { getFeature } from '@esri/arcgis-rest-feature-service'; | ||
* | ||
* const url = "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Landscape_Trees/FeatureServer/0"; | ||
* | ||
* getFeature({ | ||
* url, | ||
* id: 42 | ||
* }).then(feature => { | ||
* console.log(feature.attributes.FID); // 42 | ||
* }); | ||
* ``` | ||
* | ||
* @param requestOptions - Options for the request | ||
* @returns A Promise that will resolve with the feature. | ||
*/ | ||
function getFeature(requestOptions) { | ||
var url = requestOptions.url + "/" + requestOptions.id; | ||
// default to a GET request | ||
var options = __assign({ httpMethod: "GET" }, requestOptions); | ||
return arcgisRestRequest.request(url, options).then(function (response) { return response.feature; }); | ||
} | ||
/** | ||
* Query a feature service. See [REST Documentation](https://developers.arcgis.com/rest/services-reference/query-feature-service-layer-.htm) for more information. | ||
* | ||
* ```js | ||
* import { queryFeatures } from '@esri/arcgis-rest-feature-service'; | ||
* | ||
* const url = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3"; | ||
* | ||
* queryFeatures({ | ||
* url, | ||
* where: "STATE_NAME = 'Alaska" | ||
* }).then(result => { | ||
* console.log(result.features); // array of features | ||
* }); | ||
* ``` | ||
* | ||
* @param requestOptions - Options for the request | ||
* @returns A Promise that will resolve with the query response. | ||
*/ | ||
function queryFeatures(requestOptions) { | ||
// default to a GET request | ||
var options = __assign({ params: {}, httpMethod: "GET", url: requestOptions.url }, requestOptions); | ||
arcgisRestRequest.appendCustomParams(requestOptions, options); | ||
// set default query parameters | ||
if (!options.params.where) { | ||
options.params.where = "1=1"; | ||
/* Copyright (c) 2017 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
/** | ||
* Update features request. See the [REST Documentation](https://developers.arcgis.com/rest/services-reference/update-features.htm) for more information. | ||
* | ||
* ```js | ||
* import { updateFeatures } from '@esri/arcgis-rest-feature-service'; | ||
* | ||
* const url = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0"; | ||
* | ||
* updateFeatures({ | ||
* url, | ||
* updates: [{ | ||
* geometry: { x: -120, y: 45, spatialReference: { wkid: 4326 } }, | ||
* attributes: { status: "alive" } | ||
* }] | ||
* }); | ||
* ``` | ||
* | ||
* @param requestOptions - Options for the request. | ||
* @returns A Promise that will resolve with the updateFeatures response. | ||
*/ | ||
function updateFeatures(requestOptions) { | ||
var url = requestOptions.url + "/updateFeatures"; | ||
// edit operations are POST only | ||
var options = __assign({ params: {} }, requestOptions); | ||
arcgisRestRequest.appendCustomParams(requestOptions, options); | ||
// mixin, don't overwrite | ||
options.params.features = requestOptions.updates; | ||
delete options.params.updates; | ||
return arcgisRestRequest.request(url, options); | ||
} | ||
if (!options.params.outFields) { | ||
options.params.outFields = "*"; | ||
/* Copyright (c) 2017 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
/** | ||
* Delete features request. See the [REST Documentation](https://developers.arcgis.com/rest/services-reference/delete-features.htm) for more information. | ||
* | ||
* ```js | ||
* import { deleteFeatures } from '@esri/arcgis-rest-feature-service'; | ||
* | ||
* const url = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0"; | ||
* | ||
* deleteFeatures({ | ||
* url, | ||
* deletes: [1,2,3] | ||
* }); | ||
* ``` | ||
* | ||
* @param deleteFeaturesRequestOptions - Options for the request. | ||
* @returns A Promise that will resolve with the deleteFeatures response. | ||
*/ | ||
function deleteFeatures(requestOptions) { | ||
var url = requestOptions.url + "/deleteFeatures"; | ||
// edit operations POST only | ||
var options = __assign({ params: {} }, requestOptions); | ||
arcgisRestRequest.appendCustomParams(requestOptions, options); | ||
// mixin, don't overwrite | ||
options.params.objectIds = requestOptions.deletes; | ||
delete options.params.deletes; | ||
return arcgisRestRequest.request(url, options); | ||
} | ||
return arcgisRestRequest.request(options.url + "/query", options); | ||
} | ||
/* Copyright (c) 2017 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
/** | ||
* Add features request. See the [REST Documentation](https://developers.arcgis.com/rest/services-reference/add-features.htm) for more information. | ||
* | ||
* ```js | ||
* import { addFeatures } from '@esri/arcgis-rest-feature-service'; | ||
* | ||
* const url = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0"; | ||
* | ||
* addFeatures({ | ||
* url, | ||
* adds: [{ | ||
* geometry: { x: -120, y: 45, spatialReference: { wkid: 4326 } }, | ||
* attributes: { status: "alive" } | ||
* }] | ||
* }); | ||
* ``` | ||
* | ||
* @param requestOptions - Options for the request. | ||
* @returns A Promise that will resolve with the addFeatures response. | ||
*/ | ||
function addFeatures(requestOptions) { | ||
var url = requestOptions.url + "/addFeatures"; | ||
// edit operations are POST only | ||
var options = __assign({ params: {} }, requestOptions); | ||
arcgisRestRequest.appendCustomParams(requestOptions, options); | ||
// mixin, don't overwrite | ||
options.params.features = requestOptions.adds; | ||
delete options.params.adds; | ||
return arcgisRestRequest.request(url, options); | ||
} | ||
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
/** | ||
* Request `attachmentInfos` of a feature by id. See [Attachment Infos](https://developers.arcgis.com/rest/services-reference/attachment-infos-feature-service-.htm) for more information. | ||
* | ||
* ```js | ||
* import { getAttachments } from '@esri/arcgis-rest-feature-service'; | ||
* | ||
* getAttachments({ | ||
* url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0", | ||
* featureId: 8484 | ||
* }); | ||
* ``` | ||
* | ||
* @param requestOptions - Options for the request. | ||
* @returns A Promise that will resolve with the `getAttachments()` response. | ||
*/ | ||
function getAttachments(requestOptions) { | ||
// pass through | ||
return arcgisRestRequest.request(requestOptions.url + "/" + requestOptions.featureId + "/attachments", requestOptions); | ||
} | ||
/* Copyright (c) 2017 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
/** | ||
* Update features request. See the [REST Documentation](https://developers.arcgis.com/rest/services-reference/update-features.htm) for more information. | ||
* | ||
* ```js | ||
* import { updateFeatures } from '@esri/arcgis-rest-feature-service'; | ||
* | ||
* const url = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0"; | ||
* | ||
* updateFeatures({ | ||
* url, | ||
* updates: [{ | ||
* geometry: { x: -120, y: 45, spatialReference: { wkid: 4326 } }, | ||
* attributes: { status: "alive" } | ||
* }] | ||
* }); | ||
* ``` | ||
* | ||
* @param requestOptions - Options for the request. | ||
* @returns A Promise that will resolve with the updateFeatures response. | ||
*/ | ||
function updateFeatures(requestOptions) { | ||
var url = requestOptions.url + "/updateFeatures"; | ||
// edit operations are POST only | ||
var options = __assign({ params: {} }, requestOptions); | ||
arcgisRestRequest.appendCustomParams(requestOptions, options); | ||
// mixin, don't overwrite | ||
options.params.features = requestOptions.updates; | ||
delete options.params.updates; | ||
return arcgisRestRequest.request(url, options); | ||
} | ||
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
/** | ||
* Attach a file to a feature by id. See [Add Attachment](https://developers.arcgis.com/rest/services-reference/add-attachment.htm) for more information. | ||
* | ||
* ```js | ||
* import { addAttachment } from '@esri/arcgis-rest-feature-service'; | ||
* | ||
* addAttachment({ | ||
* url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0", | ||
* featureId: 8484, | ||
* attachment: myFileInput.files[0] | ||
* }); | ||
* ``` | ||
* | ||
* @param requestOptions - Options for the request. | ||
* @returns A Promise that will resolve with the `addAttachment()` response. | ||
*/ | ||
function addAttachment(requestOptions) { | ||
var options = __assign({ params: {} }, requestOptions); | ||
// `attachment` --> params: {} | ||
options.params.attachment = requestOptions.attachment; | ||
return arcgisRestRequest.request(options.url + "/" + options.featureId + "/addAttachment", options); | ||
} | ||
/* Copyright (c) 2017 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
/** | ||
* Delete features request. See the [REST Documentation](https://developers.arcgis.com/rest/services-reference/delete-features.htm) for more information. | ||
* | ||
* ```js | ||
* import { deleteFeatures } from '@esri/arcgis-rest-feature-service'; | ||
* | ||
* const url = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0"; | ||
* | ||
* deleteFeatures({ | ||
* url, | ||
* deletes: [1,2,3] | ||
* }); | ||
* ``` | ||
* | ||
* @param deleteFeaturesRequestOptions - Options for the request. | ||
* @returns A Promise that will resolve with the deleteFeatures response. | ||
*/ | ||
function deleteFeatures(requestOptions) { | ||
var url = requestOptions.url + "/deleteFeatures"; | ||
// edit operations POST only | ||
var options = __assign({ params: {} }, requestOptions); | ||
arcgisRestRequest.appendCustomParams(requestOptions, options); | ||
// mixin, don't overwrite | ||
options.params.objectIds = requestOptions.deletes; | ||
delete options.params.deletes; | ||
return arcgisRestRequest.request(url, options); | ||
} | ||
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
/** | ||
* Update a related attachment to a feature by id. See [Update Attachment](https://developers.arcgis.com/rest/services-reference/update-attachment.htm) for more information. | ||
* | ||
* ```js | ||
* import { updateAttachment } from '@esri/arcgis-rest-feature-service'; | ||
* | ||
* updateAttachment({ | ||
* url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0", | ||
* featureId: 8484, | ||
* attachment: myFileInput.files[0], | ||
* attachmentId: 306 | ||
* }); | ||
* ``` | ||
* | ||
* @param requestOptions - Options for the request. | ||
* @returns A Promise that will resolve with the `updateAttachment()` response. | ||
*/ | ||
function updateAttachment(requestOptions) { | ||
var options = __assign({ params: {} }, requestOptions); | ||
// `attachment` and `attachmentId` --> params: {} | ||
options.params.attachment = requestOptions.attachment; | ||
options.params.attachmentId = requestOptions.attachmentId; | ||
return arcgisRestRequest.request(options.url + "/" + options.featureId + "/updateAttachment", options); | ||
} | ||
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
/** | ||
* Request `attachmentInfos` of a feature by id. See [Attachment Infos](https://developers.arcgis.com/rest/services-reference/attachment-infos-feature-service-.htm) for more information. | ||
* | ||
* ```js | ||
* import { getAttachments } from '@esri/arcgis-rest-feature-service'; | ||
* | ||
* getAttachments({ | ||
* url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0", | ||
* featureId: 8484 | ||
* }); | ||
* ``` | ||
* | ||
* @param requestOptions - Options for the request. | ||
* @returns A Promise that will resolve with the `getAttachments()` response. | ||
*/ | ||
function getAttachments(requestOptions) { | ||
// pass through | ||
return arcgisRestRequest.request(requestOptions.url + "/" + requestOptions.featureId + "/attachments", requestOptions); | ||
} | ||
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
/** | ||
* Delete existing attachment files of a feature by id. See [Delete Attachments](https://developers.arcgis.com/rest/services-reference/delete-attachments.htm) for more information. | ||
* | ||
* ```js | ||
* import { deleteAttachments } from '@esri/arcgis-rest-feature-service'; | ||
* | ||
* deleteAttachments({ | ||
* url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0", | ||
* featureId: 8484, | ||
* attachmentIds: [306] | ||
* }); | ||
* ``` | ||
* | ||
* @param requestOptions - Options for the request. | ||
* @returns A Promise that will resolve with the `deleteAttachments()` response. | ||
*/ | ||
function deleteAttachments(requestOptions) { | ||
var options = __assign({ params: {} }, requestOptions); | ||
// `attachmentIds` --> params: {} | ||
options.params.attachmentIds = requestOptions.attachmentIds; | ||
return arcgisRestRequest.request(options.url + "/" + options.featureId + "/deleteAttachments", options); | ||
} | ||
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
/** | ||
* Attach a file to a feature by id. See [Add Attachment](https://developers.arcgis.com/rest/services-reference/add-attachment.htm) for more information. | ||
* | ||
* ```js | ||
* import { addAttachment } from '@esri/arcgis-rest-feature-service'; | ||
* | ||
* addAttachment({ | ||
* url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0", | ||
* featureId: 8484, | ||
* attachment: myFileInput.files[0] | ||
* }); | ||
* ``` | ||
* | ||
* @param requestOptions - Options for the request. | ||
* @returns A Promise that will resolve with the `addAttachment()` response. | ||
*/ | ||
function addAttachment(requestOptions) { | ||
var options = __assign({ params: {} }, requestOptions); | ||
// `attachment` --> params: {} | ||
options.params.attachment = requestOptions.attachment; | ||
return arcgisRestRequest.request(options.url + "/" + options.featureId + "/addAttachment", options); | ||
} | ||
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
/** | ||
* Update a related attachment to a feature by id. See [Update Attachment](https://developers.arcgis.com/rest/services-reference/update-attachment.htm) for more information. | ||
* | ||
* ```js | ||
* import { updateAttachment } from '@esri/arcgis-rest-feature-service'; | ||
* | ||
* updateAttachment({ | ||
* url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0", | ||
* featureId: 8484, | ||
* attachment: myFileInput.files[0], | ||
* attachmentId: 306 | ||
* }); | ||
* ``` | ||
* | ||
* @param requestOptions - Options for the request. | ||
* @returns A Promise that will resolve with the `updateAttachment()` response. | ||
*/ | ||
function updateAttachment(requestOptions) { | ||
var options = __assign({ params: {} }, requestOptions); | ||
// `attachment` and `attachmentId` --> params: {} | ||
options.params.attachment = requestOptions.attachment; | ||
options.params.attachmentId = requestOptions.attachmentId; | ||
return arcgisRestRequest.request(options.url + "/" + options.featureId + "/updateAttachment", options); | ||
} | ||
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
/** | ||
* Delete existing attachment files of a feature by id. See [Delete Attachments](https://developers.arcgis.com/rest/services-reference/delete-attachments.htm) for more information. | ||
* | ||
* ```js | ||
* import { deleteAttachments } from '@esri/arcgis-rest-feature-service'; | ||
* | ||
* deleteAttachments({ | ||
* url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0", | ||
* featureId: 8484, | ||
* attachmentIds: [306] | ||
* }); | ||
* ``` | ||
* | ||
* @param requestOptions - Options for the request. | ||
* @returns A Promise that will resolve with the `deleteAttachments()` response. | ||
*/ | ||
function deleteAttachments(requestOptions) { | ||
var options = __assign({ params: {} }, requestOptions); | ||
// `attachmentIds` --> params: {} | ||
options.params.attachmentIds = requestOptions.attachmentIds; | ||
return arcgisRestRequest.request(options.url + "/" + options.featureId + "/deleteAttachments", options); | ||
} | ||
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
/** | ||
* Query the related records for a feature service. See the [REST Documentation](https://developers.arcgis.com/rest/services-reference/query-related-records-feature-service-.htm) for more information. | ||
* | ||
* ```js | ||
* import { queryRelated } from '@esri/arcgis-rest-feature-service' | ||
* | ||
* const url = "http://services.myserver/OrgID/ArcGIS/rest/services/Petroleum/KSPetro/FeatureServer/0" | ||
* | ||
* queryRelated({ | ||
* url: url, | ||
* relationshipId: 1, | ||
* params: { returnCountOnly: true } | ||
* }) | ||
* .then(response => { | ||
* console.log(response.relatedRecords) | ||
* }) | ||
* ``` | ||
* | ||
* @param requestOptions | ||
* @returns A Promise that will resolve with the query response | ||
*/ | ||
function queryRelated(requestOptions) { | ||
var options = __assign({ params: {}, httpMethod: "GET", url: requestOptions.url }, requestOptions); | ||
arcgisRestRequest.appendCustomParams(requestOptions, options); | ||
if (!options.params.definitionExpression) { | ||
options.params.definitionExpression = "1=1"; | ||
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
/** | ||
* Query the related records for a feature service. See the [REST Documentation](https://developers.arcgis.com/rest/services-reference/query-related-records-feature-service-.htm) for more information. | ||
* | ||
* ```js | ||
* import { queryRelated } from '@esri/arcgis-rest-feature-service' | ||
* | ||
* const url = "http://services.myserver/OrgID/ArcGIS/rest/services/Petroleum/KSPetro/FeatureServer/0" | ||
* | ||
* queryRelated({ | ||
* url: url, | ||
* relationshipId: 1, | ||
* params: { returnCountOnly: true } | ||
* }) | ||
* .then(response => { | ||
* console.log(response.relatedRecords) | ||
* }) | ||
* ``` | ||
* | ||
* @param requestOptions | ||
* @returns A Promise that will resolve with the query response | ||
*/ | ||
function queryRelated(requestOptions) { | ||
var options = __assign({ params: {}, httpMethod: "GET", url: requestOptions.url }, requestOptions); | ||
arcgisRestRequest.appendCustomParams(requestOptions, options); | ||
if (!options.params.definitionExpression) { | ||
options.params.definitionExpression = "1=1"; | ||
} | ||
if (!options.params.outFields) { | ||
options.params.outFields = "*"; | ||
} | ||
if (!options.params.relationshipId) { | ||
options.params.relationshipId = 0; | ||
} | ||
return arcgisRestRequest.request(options.url + "/queryRelatedRecords", options); | ||
} | ||
if (!options.params.outFields) { | ||
options.params.outFields = "*"; | ||
} | ||
if (!options.params.relationshipId) { | ||
options.params.relationshipId = 0; | ||
} | ||
return arcgisRestRequest.request(options.url + "/queryRelatedRecords", options); | ||
} | ||
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
exports.getFeature = getFeature; | ||
exports.queryFeatures = queryFeatures; | ||
exports.addFeatures = addFeatures; | ||
exports.updateFeatures = updateFeatures; | ||
exports.deleteFeatures = deleteFeatures; | ||
exports.getAttachments = getAttachments; | ||
exports.addAttachment = addAttachment; | ||
exports.updateAttachment = updateAttachment; | ||
exports.deleteAttachments = deleteAttachments; | ||
exports.queryRelated = queryRelated; | ||
exports.getFeature = getFeature; | ||
exports.queryFeatures = queryFeatures; | ||
exports.addFeatures = addFeatures; | ||
exports.updateFeatures = updateFeatures; | ||
exports.deleteFeatures = deleteFeatures; | ||
exports.getAttachments = getAttachments; | ||
exports.addAttachment = addAttachment; | ||
exports.updateAttachment = updateAttachment; | ||
exports.deleteAttachments = deleteAttachments; | ||
exports.queryRelated = queryRelated; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); | ||
//# sourceMappingURL=feature-service.umd.js.map |
/* @preserve | ||
* @esri/arcgis-rest-feature-service - v1.13.1 - Apache-2.0 | ||
* @esri/arcgis-rest-feature-service - v1.13.2 - Apache-2.0 | ||
* Copyright (c) 2017-2018 Esri, Inc. | ||
* Mon Oct 15 2018 12:06:23 GMT-0700 (Pacific Daylight Time) | ||
* Fri Nov 02 2018 15:54:17 GMT-0700 (Pacific Daylight 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})}); | ||
//# sourceMappingURL=feature-service.umd.min.js.map |
{ | ||
"name": "@esri/arcgis-rest-feature-service", | ||
"version": "1.13.1", | ||
"version": "1.13.2", | ||
"description": "Feature service helpers for @esri/arcgis-rest-request", | ||
@@ -17,7 +17,7 @@ "main": "dist/node/index.js", | ||
}, | ||
"devDependencies": { | ||
"@esri/arcgis-rest-common-types": "^1.13.2", | ||
"@esri/arcgis-rest-request": "^1.13.2" | ||
}, | ||
"peerDependencies": { | ||
"@esri/arcgis-rest-common-types": "^1.11.0", | ||
"@esri/arcgis-rest-request": "^1.11.0" | ||
}, | ||
"devDependencies": { | ||
"@esri/arcgis-rest-common-types": "^1.13.1", | ||
@@ -31,3 +31,6 @@ "@esri/arcgis-rest-request": "^1.13.1" | ||
"build:umd": "rollup -c ../../umd-base-profile.js && rollup -c ../../umd-production-profile.js", | ||
"build:node": "tsc -p ./tsconfig.json --module commonjs --outDir ./dist/node" | ||
"build:node": "tsc -p ./tsconfig.json --module commonjs --outDir ./dist/node", | ||
"dev:esm": "tsc -w --module es2015 --outDir ./dist/esm --declaration", | ||
"dev:umd": "rollup -w -c ../../umd-base-profile.js", | ||
"dev:node": "tsc -w --module commonjs --outDir ./dist/node" | ||
}, | ||
@@ -34,0 +37,0 @@ "publishConfig": { |
[![npm version][npm-img]][npm-url] | ||
[![build status][travis-img]][travis-url] | ||
[![Coverage Status][coverage-img]][coverage-url] | ||
[](https://raw.githubusercontent.com/Esri/arcgis-rest-js/master/LICENSE) | ||
@@ -9,2 +10,4 @@ | ||
[travis-url]: https://travis-ci.org/Esri/arcgis-rest-js | ||
[coverage-img]: https://coveralls.io/repos/github/Esri/arcgis-rest-js/badge.svg | ||
[coverage-url]: https://coveralls.io/github/Esri/arcgis-rest-js | ||
@@ -11,0 +14,0 @@ # @esri/arcgis-rest-feature-service |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
169660
0.97%74
4.23%2191
-0.05%