-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #214 from Esri/chore/feature-service-params
refactor(feature-service): update signatures
- Loading branch information
Showing
10 changed files
with
509 additions
and
408 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* Copyright (c) 2017 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
|
||
import { IFeature } from "@esri/arcgis-rest-common-types"; | ||
import { request, IRequestOptions } from "@esri/arcgis-rest-request"; | ||
|
||
import { | ||
IEditFeaturesParams, | ||
IEditFeatureResult, | ||
appendCustomParams | ||
} from "./helpers"; | ||
|
||
/** | ||
* Add features request options. See the [REST Documentation](https://developers.arcgis.com/rest/services-reference/add-features.htm) for more information. | ||
* | ||
* @param url - Feature service url. | ||
* @param adds - Array of JSON features to add. | ||
* @param params - Query parameters to be sent to the feature service via the request. | ||
*/ | ||
export interface IAddFeaturesRequestOptions | ||
extends IEditFeaturesParams, | ||
IRequestOptions { | ||
/** | ||
* Feature service url. | ||
*/ | ||
url: string; | ||
/** | ||
* Array of JSON features to add. | ||
*/ | ||
adds: IFeature[]; | ||
} | ||
|
||
/** | ||
* Add features results. | ||
*/ | ||
export interface IAddFeaturesResult { | ||
/** | ||
* Array of JSON response Object(s) for each feature added. | ||
*/ | ||
addResults?: IEditFeatureResult[]; | ||
} | ||
|
||
/** | ||
* Add features request. See the [REST Documentation](https://developers.arcgis.com/rest/services-reference/add-features.htm) for more information. | ||
* | ||
* @param requestOptions - Options for the request. | ||
* ```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. | ||
*/ | ||
export function addFeatures( | ||
requestOptions: IAddFeaturesRequestOptions | ||
): Promise<IAddFeaturesResult> { | ||
const url = `${requestOptions.url}/addFeatures`; | ||
|
||
// edit operations are POST only | ||
const options: IAddFeaturesRequestOptions = { | ||
params: {}, | ||
...requestOptions | ||
}; | ||
|
||
appendCustomParams(requestOptions, options); | ||
|
||
// mixin, don't overwrite | ||
options.params.features = requestOptions.adds; | ||
|
||
return request(url, options); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* Copyright (c) 2017 Environmental Systems Research Institute, Inc. | ||
* Apache-2.0 */ | ||
|
||
import { request, IRequestOptions } from "@esri/arcgis-rest-request"; | ||
|
||
import { | ||
IEditFeaturesParams, | ||
IEditFeatureResult, | ||
ISharedQueryParams, | ||
appendCustomParams | ||
} from "./helpers"; | ||
|
||
/** | ||
* Delete features parameters. | ||
*/ | ||
export interface IDeleteFeaturesParams | ||
extends IEditFeaturesParams, | ||
ISharedQueryParams {} | ||
|
||
/** | ||
* Delete features request options. See the [REST Documentation](https://developers.arcgis.com/rest/services-reference/delete-features.htm) for more information. | ||
* | ||
* @param url - Feature service url. | ||
* @param deletes - Array of objectIds to delete. | ||
* @param params - Query parameters to be sent to the feature service via the request. | ||
*/ | ||
export interface IDeleteFeaturesRequestOptions | ||
extends IDeleteFeaturesParams, | ||
IRequestOptions { | ||
/** | ||
* Feature service url. | ||
*/ | ||
url: string; | ||
/** | ||
* Array of objectIds to delete. | ||
*/ | ||
deletes: number[]; | ||
} | ||
|
||
/** | ||
* Delete features results. | ||
*/ | ||
export interface IDeleteFeaturesResult { | ||
/** | ||
* Array of JSON response Object(s) for each feature deleted. | ||
*/ | ||
deleteResults?: IEditFeatureResult[]; | ||
} | ||
|
||
/** | ||
* 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. | ||
*/ | ||
export function deleteFeatures( | ||
requestOptions: IDeleteFeaturesRequestOptions | ||
): Promise<IDeleteFeaturesResult> { | ||
const url = `${requestOptions.url}/deleteFeatures`; | ||
|
||
// edit operations POST only | ||
const options: IDeleteFeaturesRequestOptions = { | ||
params: {}, | ||
...requestOptions | ||
}; | ||
|
||
appendCustomParams(requestOptions, options); | ||
|
||
// mixin, don't overwrite | ||
options.params.objectIds = requestOptions.deletes; | ||
|
||
return request(url, options); | ||
} |
Oops, something went wrong.