etincidunt 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.prettierignore +2 -0
- package/.travis.yml +29 -0
- package/.vscode/launch.json +24 -0
- package/.vscode/settings.json +3 -0
- package/demos/ago-node-cli/README.md +29 -0
- package/demos/ago-node-cli/ago.js +32 -0
- package/demos/ago-node-cli/index.js +11 -0
- package/demos/ago-node-cli/lib/item-export-command.js +48 -0
- package/demos/ago-node-cli/lib/item-search-command.js +35 -0
- package/demos/ago-node-cli/package-lock.json +172 -0
- package/demos/ago-node-cli/package.json +30 -0
- package/demos/attachments/README.md +5 -0
- package/demos/attachments/index.html +164 -0
- package/demos/attachments/package-lock.json +182 -0
- package/demos/attachments/package.json +18 -0
- package/demos/batch-geocoder-node/NYC_Restaurant_Inspection_Results.csv +100 -0
- package/demos/batch-geocoder-node/README.md +14 -0
- package/demos/batch-geocoder-node/batch-geocode.js +112 -0
- package/demos/batch-geocoder-node/config-template.js +18 -0
- package/demos/batch-geocoder-node/package-lock.json +109 -0
- package/demos/batch-geocoder-node/package.json +37 -0
- package/demos/express/README.md +10 -0
- package/demos/express/config.json.template +3 -0
- package/demos/express/package-lock.json +388 -0
- package/demos/express/package.json +18 -0
- package/demos/express/server.js +28 -0
- package/demos/feature-service-browser/README.md +6 -0
- package/demos/feature-service-browser/index.html +122 -0
- package/demos/feature-service-browser/package-lock.json +182 -0
- package/demos/feature-service-browser/package.json +18 -0
- package/demos/geocoder-browser/README.md +10 -0
- package/demos/geocoder-browser/config.js.template +1 -0
- package/demos/geocoder-browser/index.html +131 -0
- package/demos/geocoder-browser/package-lock.json +163 -0
- package/demos/geocoder-browser/package.json +19 -0
- package/demos/geocoder-browser/post-sign-in.html +25 -0
- package/demos/jsapi-integration/README.md +8 -0
- package/demos/jsapi-integration/config.js +6 -0
- package/demos/jsapi-integration/index.html +79 -0
- package/demos/jsapi-integration/package-lock.json +184 -0
- package/demos/jsapi-integration/package.json +19 -0
- package/demos/oauth2-browser/README.md +12 -0
- package/demos/oauth2-browser/authenticate.html +32 -0
- package/demos/oauth2-browser/config.js.template +6 -0
- package/demos/oauth2-browser/index.html +202 -0
- package/demos/oauth2-browser/logo.svg +4 -0
- package/demos/oauth2-browser/package-lock.json +163 -0
- package/demos/oauth2-browser/package.json +18 -0
- package/demos/oauth2-browser/style.css +36 -0
- package/demos/vue/.babelrc +6 -0
- package/demos/vue/.env.example +8 -0
- package/demos/vue/README.md +17 -0
- package/demos/vue/index.html +21 -0
- package/demos/vue/package-lock.json +7236 -0
- package/demos/vue/package.json +39 -0
- package/demos/vue/src/assets/logo.svg +29 -0
- package/demos/vue/src/components/App.vue +302 -0
- package/demos/vue/src/components/Authenticate.vue +68 -0
- package/demos/vue/src/components/Loader.vue +216 -0
- package/demos/vue/src/main.js +75 -0
- package/demos/vue/webpack.config.js +84 -0
- package/docs/FAQ.md +28 -0
- package/docs/HISTORY.md +62 -0
- package/docs/acetate.config.js +214 -0
- package/docs/build-typedoc.js +301 -0
- package/docs/src/_layout.html +82 -0
- package/docs/src/api/_declaration.html +496 -0
- package/docs/src/api/_layout.html +127 -0
- package/docs/src/api/_package.html +13 -0
- package/docs/src/api/index.html +23 -0
- package/docs/src/guides/_layout.html +24 -0
- package/docs/src/guides/amd-requirejs-dojo.md +40 -0
- package/docs/src/guides/babel-and-rollup.md +30 -0
- package/docs/src/guides/babel-and-webpack.md +30 -0
- package/docs/src/guides/browser-authentication.md +9 -0
- package/docs/src/guides/browserify.md +9 -0
- package/docs/src/guides/cli-authentication.md +9 -0
- package/docs/src/guides/client-server-authentication.md +9 -0
- package/docs/src/guides/from-a-cdn.md +36 -0
- package/docs/src/guides/index.md +52 -0
- package/docs/src/guides/node.md +30 -0
- package/docs/src/guides/package-overview.md +8 -0
- package/docs/src/guides/server-authentication.md +9 -0
- package/docs/src/guides/typescript-and-webpack.md +9 -0
- package/docs/src/img/icons.png +0 -0
- package/docs/src/img/icons@2x.png +0 -0
- package/docs/src/index.html +12 -0
- package/docs/src/js/api-search.js +113 -0
- package/docs/src/js/index.js +1 -0
- package/docs/src/js/nav-toggle.js +41 -0
- package/docs/src/sass/_highlight.scss +96 -0
- package/docs/src/sass/_icons.scss +157 -0
- package/docs/src/sass/style.scss +169 -0
- package/jasmine.json +7 -0
- package/karma.conf.js +100 -0
- package/lerna.json +8 -0
- package/notes/README.md +88 -0
- package/package.json +91 -0
- package/packages/arcgis-rest-auth/README.md +64 -0
- package/packages/arcgis-rest-auth/package-lock.json +11 -0
- package/packages/arcgis-rest-auth/package.json +51 -0
- package/packages/arcgis-rest-auth/src/ApplicationSession.ts +91 -0
- package/packages/arcgis-rest-auth/src/UserSession.ts +829 -0
- package/packages/arcgis-rest-auth/src/authenticated-request-options.ts +21 -0
- package/packages/arcgis-rest-auth/src/fetch-token.ts +55 -0
- package/packages/arcgis-rest-auth/src/generate-token.ts +36 -0
- package/packages/arcgis-rest-auth/src/index.ts +5 -0
- package/packages/arcgis-rest-auth/test/ApplicationSession.test.ts +121 -0
- package/packages/arcgis-rest-auth/test/UserSession.test.ts +883 -0
- package/packages/arcgis-rest-auth/test/fetchToken.test.ts +76 -0
- package/packages/arcgis-rest-auth/test/generateToken.test.ts +36 -0
- package/packages/arcgis-rest-auth/test/utils.ts +11 -0
- package/packages/arcgis-rest-auth/tsconfig.json +6 -0
- package/packages/arcgis-rest-common-types/README.md +61 -0
- package/packages/arcgis-rest-common-types/package.json +38 -0
- package/packages/arcgis-rest-common-types/src/group.ts +51 -0
- package/packages/arcgis-rest-common-types/src/index.ts +467 -0
- package/packages/arcgis-rest-common-types/src/item.ts +45 -0
- package/packages/arcgis-rest-common-types/src/webmap.ts +1225 -0
- package/packages/arcgis-rest-common-types/tsconfig.json +11 -0
- package/packages/arcgis-rest-feature-service/README.md +70 -0
- package/packages/arcgis-rest-feature-service/package-lock.json +11 -0
- package/packages/arcgis-rest-feature-service/package.json +50 -0
- package/packages/arcgis-rest-feature-service/src/add.ts +82 -0
- package/packages/arcgis-rest-feature-service/src/addAttachment.ts +65 -0
- package/packages/arcgis-rest-feature-service/src/delete.ts +85 -0
- package/packages/arcgis-rest-feature-service/src/deleteAttachments.ts +68 -0
- package/packages/arcgis-rest-feature-service/src/getAttachments.ts +64 -0
- package/packages/arcgis-rest-feature-service/src/helpers.ts +77 -0
- package/packages/arcgis-rest-feature-service/src/index.ts +8 -0
- package/packages/arcgis-rest-feature-service/src/query.ts +174 -0
- package/packages/arcgis-rest-feature-service/src/update.ts +81 -0
- package/packages/arcgis-rest-feature-service/src/updateAttachment.ts +74 -0
- package/packages/arcgis-rest-feature-service/test/attachments.test.ts +179 -0
- package/packages/arcgis-rest-feature-service/test/features.test.ts +172 -0
- package/packages/arcgis-rest-feature-service/test/mocks/feature.ts +220 -0
- package/packages/arcgis-rest-feature-service/test/mocks/foo.txt +1 -0
- package/packages/arcgis-rest-feature-service/tsconfig.json +6 -0
- package/packages/arcgis-rest-geocoder/README.md +73 -0
- package/packages/arcgis-rest-geocoder/package-lock.json +11 -0
- package/packages/arcgis-rest-geocoder/package.json +52 -0
- package/packages/arcgis-rest-geocoder/src/bulk.ts +102 -0
- package/packages/arcgis-rest-geocoder/src/geocode.ts +117 -0
- package/packages/arcgis-rest-geocoder/src/helpers.ts +81 -0
- package/packages/arcgis-rest-geocoder/src/index.ts +4 -0
- package/packages/arcgis-rest-geocoder/src/reverse.ts +84 -0
- package/packages/arcgis-rest-geocoder/src/suggest.ts +72 -0
- package/packages/arcgis-rest-geocoder/test/geocoder.test.ts +510 -0
- package/packages/arcgis-rest-geocoder/test/mocks/responses.ts +588 -0
- package/packages/arcgis-rest-geocoder/tsconfig.json +6 -0
- package/packages/arcgis-rest-groups/README.md +64 -0
- package/packages/arcgis-rest-groups/package-lock.json +11 -0
- package/packages/arcgis-rest-groups/package.json +52 -0
- package/packages/arcgis-rest-groups/src/groups.ts +272 -0
- package/packages/arcgis-rest-groups/src/index.ts +1 -0
- package/packages/arcgis-rest-groups/test/groups.test.ts +280 -0
- package/packages/arcgis-rest-groups/test/mocks/responses.ts +137 -0
- package/packages/arcgis-rest-groups/tsconfig.json +6 -0
- package/packages/arcgis-rest-items/README.md +66 -0
- package/packages/arcgis-rest-items/package-lock.json +11 -0
- package/packages/arcgis-rest-items/package.json +52 -0
- package/packages/arcgis-rest-items/src/index.ts +1 -0
- package/packages/arcgis-rest-items/src/items.ts +498 -0
- package/packages/arcgis-rest-items/test/items.test.ts +1153 -0
- package/packages/arcgis-rest-items/test/mocks/foo.zip +0 -0
- package/packages/arcgis-rest-items/test/mocks/item.ts +30 -0
- package/packages/arcgis-rest-items/test/mocks/resources.ts +28 -0
- package/packages/arcgis-rest-items/test/mocks/search.ts +60 -0
- package/packages/arcgis-rest-items/tsconfig.json +6 -0
- package/packages/arcgis-rest-request/README.md +65 -0
- package/packages/arcgis-rest-request/package-lock.json +11 -0
- package/packages/arcgis-rest-request/package.json +42 -0
- package/packages/arcgis-rest-request/src/index.ts +10 -0
- package/packages/arcgis-rest-request/src/request.ts +259 -0
- package/packages/arcgis-rest-request/src/utils/ArcGISAuthError.ts +67 -0
- package/packages/arcgis-rest-request/src/utils/ArcGISRequestError.ts +73 -0
- package/packages/arcgis-rest-request/src/utils/ErrorTypes.ts +29 -0
- package/packages/arcgis-rest-request/src/utils/check-for-errors.ts +65 -0
- package/packages/arcgis-rest-request/src/utils/encode-form-data.ts +29 -0
- package/packages/arcgis-rest-request/src/utils/encode-query-string.ts +23 -0
- package/packages/arcgis-rest-request/src/utils/get-portal-url.ts +25 -0
- package/packages/arcgis-rest-request/src/utils/get-portal.ts +45 -0
- package/packages/arcgis-rest-request/src/utils/process-params.ts +99 -0
- package/packages/arcgis-rest-request/test/mocks/errors.ts +59 -0
- package/packages/arcgis-rest-request/test/mocks/geojson-feature-collection.ts +10 -0
- package/packages/arcgis-rest-request/test/mocks/portal.ts +109 -0
- package/packages/arcgis-rest-request/test/mocks/sharing-rest-info.ts +38 -0
- package/packages/arcgis-rest-request/test/mocks/webmap.ts +38 -0
- package/packages/arcgis-rest-request/test/request.test.ts +296 -0
- package/packages/arcgis-rest-request/test/utils/ArcGISAuthError.test.ts +167 -0
- package/packages/arcgis-rest-request/test/utils/ArcGISRequestError.test.ts +40 -0
- package/packages/arcgis-rest-request/test/utils/check-for-errors.test.ts +101 -0
- package/packages/arcgis-rest-request/test/utils/encode-form-data.test.ts +112 -0
- package/packages/arcgis-rest-request/test/utils/get-portal-url.test.ts +34 -0
- package/packages/arcgis-rest-request/test/utils/portal.test.ts +94 -0
- package/packages/arcgis-rest-request/test/utils/process-params.test.ts +190 -0
- package/packages/arcgis-rest-request/tsconfig.json +6 -0
- package/packages/arcgis-rest-sharing/README.md +67 -0
- package/packages/arcgis-rest-sharing/package-lock.json +11 -0
- package/packages/arcgis-rest-sharing/package.json +55 -0
- package/packages/arcgis-rest-sharing/src/access.ts +91 -0
- package/packages/arcgis-rest-sharing/src/group-sharing.ts +212 -0
- package/packages/arcgis-rest-sharing/src/helpers.ts +92 -0
- package/packages/arcgis-rest-sharing/src/index.ts +2 -0
- package/packages/arcgis-rest-sharing/test/access.test.ts +153 -0
- package/packages/arcgis-rest-sharing/test/group-sharing.test.ts +436 -0
- package/packages/arcgis-rest-sharing/test/mocks/sharing.ts +15 -0
- package/packages/arcgis-rest-sharing/tsconfig.json +6 -0
- package/packages/arcgis-rest-users/README.md +71 -0
- package/packages/arcgis-rest-users/package-lock.json +11 -0
- package/packages/arcgis-rest-users/package.json +51 -0
- package/packages/arcgis-rest-users/src/index.ts +1 -0
- package/packages/arcgis-rest-users/src/users.ts +70 -0
- package/packages/arcgis-rest-users/test/mocks/responses.ts +170 -0
- package/packages/arcgis-rest-users/test/users.test.ts +97 -0
- package/packages/arcgis-rest-users/tsconfig.json +6 -0
- package/support/FormData.d.ts +1 -0
- package/support/changelog.js +388 -0
- package/support/commit-template.txt +19 -0
- package/support/deploy-doc-site.js +16 -0
- package/support/publish.sh +40 -0
- package/support/test-helpers.js +8 -0
- package/tsconfig.json +69 -0
- package/tslint.json +14 -0
- package/umd-base-profile.js +82 -0
- package/umd-production-profile.js +13 -0
@@ -0,0 +1,70 @@
|
|
1
|
+
[![npm version][npm-img]][npm-url]
|
2
|
+
[![build status][travis-img]][travis-url]
|
3
|
+
[![apache licensed](https://img.shields.io/badge/license-Apache-green.svg?style=flat-square)](https://raw.githubusercontent.com/Esri/arcgis-rest-js/master/LICENSE)
|
4
|
+
|
5
|
+
[npm-img]: https://img.shields.io/npm/v/@esri/arcgis-rest-feature-service.svg?style=flat-square
|
6
|
+
[npm-url]: https://www.npmjs.com/package/@esri/arcgis-rest-feature-service
|
7
|
+
[travis-img]: https://img.shields.io/travis/Esri/arcgis-rest-js/master.svg?style=flat-square
|
8
|
+
[travis-url]: https://travis-ci.org/Esri/arcgis-rest-js
|
9
|
+
|
10
|
+
# @esri/arcgis-rest-feature-service
|
11
|
+
|
12
|
+
> A module for working with ArcGIS feature services that runs in Node.js and modern browsers.
|
13
|
+
|
14
|
+
### Example
|
15
|
+
|
16
|
+
```bash
|
17
|
+
npm install @esri/arcgis-rest-request
|
18
|
+
npm install @esri/arcgis-rest-feature-service
|
19
|
+
```
|
20
|
+
|
21
|
+
```js
|
22
|
+
import { getFeature } from '@esri/arcgis-rest-feature-service';
|
23
|
+
|
24
|
+
const options = {
|
25
|
+
url:
|
26
|
+
"https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Landscape_Trees/FeatureServer/0",
|
27
|
+
id: 42
|
28
|
+
};
|
29
|
+
|
30
|
+
getFeature(options)
|
31
|
+
.then(feature => {
|
32
|
+
console.log(feature.attributes.FID); // 42
|
33
|
+
});
|
34
|
+
```
|
35
|
+
|
36
|
+
### [API Reference](https://esri.github.io/arcgis-rest-js/api/feature-service/)
|
37
|
+
|
38
|
+
### Issues
|
39
|
+
|
40
|
+
If something isn't working the way you expected, please take a look at [previously logged issues](https://github.com/Esri/arcgis-rest-js/issues) first. Have you found a new bug? Want to request a new feature? We'd [**love**](https://github.com/Esri/arcgis-rest-js/issues/new) to hear from you.
|
41
|
+
|
42
|
+
If you're looking for help you can also post issues on [GIS Stackexchange](http://gis.stackexchange.com/questions/ask?tags=esri-oss).
|
43
|
+
|
44
|
+
### Versioning
|
45
|
+
|
46
|
+
For transparency into the release cycle and in striving to maintain backward compatibility, @esri/arcgis-rest-js is maintained under Semantic Versioning guidelines and will adhere to these rules whenever possible.
|
47
|
+
|
48
|
+
For more information on SemVer, please visit <http://semver.org/>.
|
49
|
+
|
50
|
+
### Contributing
|
51
|
+
|
52
|
+
Esri welcomes contributions from anyone and everyone. Please see our [guidelines for contributing](CONTRIBUTING.md).
|
53
|
+
|
54
|
+
### License
|
55
|
+
|
56
|
+
Copyright © 2017-2018 Esri
|
57
|
+
|
58
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
59
|
+
you may not use this file except in compliance with the License.
|
60
|
+
You may obtain a copy of the License at
|
61
|
+
|
62
|
+
> http://www.apache.org/licenses/LICENSE-2.0
|
63
|
+
|
64
|
+
Unless required by applicable law or agreed to in writing, software
|
65
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
66
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
67
|
+
See the License for the specific language governing permissions and
|
68
|
+
limitations under the License.
|
69
|
+
|
70
|
+
A copy of the license is available in the repository's [LICENSE](../../LICENSE) file.
|
@@ -0,0 +1,11 @@
|
|
1
|
+
{
|
2
|
+
"requires": true,
|
3
|
+
"lockfileVersion": 1,
|
4
|
+
"dependencies": {
|
5
|
+
"tslib": {
|
6
|
+
"version": "1.8.0",
|
7
|
+
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.8.0.tgz",
|
8
|
+
"integrity": "sha512-ymKWWZJST0/CkgduC2qkzjMOWr4bouhuURNXCn/inEX0L57BnRG6FhX76o7FOnsjHazCjfU2LKeSrlS2sIKQJg=="
|
9
|
+
}
|
10
|
+
}
|
11
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
{
|
2
|
+
"name": "@esri/arcgis-rest-feature-service",
|
3
|
+
"version": "1.6.0",
|
4
|
+
"description": "Feature service helpers for @esri/arcgis-rest-request",
|
5
|
+
"main": "dist/node/index.js",
|
6
|
+
"browser": "dist/umd/feature-service.umd.js",
|
7
|
+
"module": "dist/esm/index.js",
|
8
|
+
"js:next": "dist/esm/index.js",
|
9
|
+
"types": "dist/esm/index.d.ts",
|
10
|
+
"license": "Apache-2.0",
|
11
|
+
"files": [
|
12
|
+
"dist/**"
|
13
|
+
],
|
14
|
+
"dependencies": {
|
15
|
+
"tslib": "^1.7.1"
|
16
|
+
},
|
17
|
+
"peerDependencies": {
|
18
|
+
"@esri/arcgis-rest-common-types": "^1.5.1",
|
19
|
+
"@esri/arcgis-rest-request": "^1.5.1"
|
20
|
+
},
|
21
|
+
"devDependencies": {
|
22
|
+
"@esri/arcgis-rest-common-types": "^1.6.0",
|
23
|
+
"@esri/arcgis-rest-request": "^1.6.0"
|
24
|
+
},
|
25
|
+
"scripts": {
|
26
|
+
"prepare": "npm run build",
|
27
|
+
"build": "npm run build:node && npm run build:umd && npm run build:esm",
|
28
|
+
"build:esm": "tsc -p ./tsconfig.json --module es2015 --outDir ./dist/esm --declaration",
|
29
|
+
"build:umd": "rollup -c ../../umd-base-profile.js && rollup -c ../../umd-production-profile.js",
|
30
|
+
"build:node": "tsc -p ./tsconfig.json --module commonjs --outDir ./dist/node"
|
31
|
+
},
|
32
|
+
"publishConfig": {
|
33
|
+
"access": "public"
|
34
|
+
},
|
35
|
+
"repository": {
|
36
|
+
"type": "git",
|
37
|
+
"url": "git+https://github.com/Esri/arcgis-rest-js.git"
|
38
|
+
},
|
39
|
+
"contributors": [
|
40
|
+
{
|
41
|
+
"name": "Tom Wayson",
|
42
|
+
"email": "twayson@esri.com",
|
43
|
+
"url": "http://tomwayson.com/"
|
44
|
+
}
|
45
|
+
],
|
46
|
+
"bugs": {
|
47
|
+
"url": "https://github.com/Esri/arcgis-rest-js/issues"
|
48
|
+
},
|
49
|
+
"homepage": "https://github.com/Esri/arcgis-rest-js#readme"
|
50
|
+
}
|
@@ -0,0 +1,82 @@
|
|
1
|
+
/* Copyright (c) 2017 Environmental Systems Research Institute, Inc.
|
2
|
+
* Apache-2.0 */
|
3
|
+
|
4
|
+
import { IFeature } from "@esri/arcgis-rest-common-types";
|
5
|
+
import { request, IRequestOptions } from "@esri/arcgis-rest-request";
|
6
|
+
|
7
|
+
import {
|
8
|
+
IEditFeaturesParams,
|
9
|
+
IEditFeatureResult,
|
10
|
+
appendCustomParams
|
11
|
+
} from "./helpers";
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Add features request options. See the [REST Documentation](https://developers.arcgis.com/rest/services-reference/add-features.htm) for more information.
|
15
|
+
*
|
16
|
+
* @param url - Feature service url.
|
17
|
+
* @param adds - Array of JSON features to add.
|
18
|
+
* @param params - Query parameters to be sent to the feature service via the request.
|
19
|
+
*/
|
20
|
+
export interface IAddFeaturesRequestOptions
|
21
|
+
extends IEditFeaturesParams,
|
22
|
+
IRequestOptions {
|
23
|
+
/**
|
24
|
+
* Feature service url.
|
25
|
+
*/
|
26
|
+
url: string;
|
27
|
+
/**
|
28
|
+
* Array of JSON features to add.
|
29
|
+
*/
|
30
|
+
adds: IFeature[];
|
31
|
+
}
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Add features results.
|
35
|
+
*/
|
36
|
+
export interface IAddFeaturesResult {
|
37
|
+
/**
|
38
|
+
* Array of JSON response Object(s) for each feature added.
|
39
|
+
*/
|
40
|
+
addResults?: IEditFeatureResult[];
|
41
|
+
}
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Add features request. See the [REST Documentation](https://developers.arcgis.com/rest/services-reference/add-features.htm) for more information.
|
45
|
+
*
|
46
|
+
* @param requestOptions - Options for the request.
|
47
|
+
* ```js
|
48
|
+
* import { addFeatures } from '@esri/arcgis-rest-feature-service';
|
49
|
+
*
|
50
|
+
* const url = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0";
|
51
|
+
*
|
52
|
+
* addFeatures({
|
53
|
+
* url,
|
54
|
+
* adds: [{
|
55
|
+
* geometry: { x: -120, y: 45, spatialReference: { wkid: 4326 } },
|
56
|
+
* attributes: { status: "alive" }
|
57
|
+
* }]
|
58
|
+
* });
|
59
|
+
* ```
|
60
|
+
*
|
61
|
+
* @param requestOptions - Options for the request.
|
62
|
+
* @returns A Promise that will resolve with the addFeatures response.
|
63
|
+
*/
|
64
|
+
export function addFeatures(
|
65
|
+
requestOptions: IAddFeaturesRequestOptions
|
66
|
+
): Promise<IAddFeaturesResult> {
|
67
|
+
const url = `${requestOptions.url}/addFeatures`;
|
68
|
+
|
69
|
+
// edit operations are POST only
|
70
|
+
const options: IAddFeaturesRequestOptions = {
|
71
|
+
params: {},
|
72
|
+
...requestOptions
|
73
|
+
};
|
74
|
+
|
75
|
+
appendCustomParams(requestOptions, options);
|
76
|
+
|
77
|
+
// mixin, don't overwrite
|
78
|
+
options.params.features = requestOptions.adds;
|
79
|
+
delete options.params.adds;
|
80
|
+
|
81
|
+
return request(url, options);
|
82
|
+
}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
|
2
|
+
* Apache-2.0 */
|
3
|
+
|
4
|
+
import { request, IRequestOptions } from "@esri/arcgis-rest-request";
|
5
|
+
|
6
|
+
import { IEditFeatureResult } from "./helpers";
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Request options for adding a related attachment to a feature by id. See [Add Attachment](https://developers.arcgis.com/rest/services-reference/add-attachment.htm) for more information.
|
10
|
+
*
|
11
|
+
*/
|
12
|
+
export interface IAddAttachmentOptions extends IRequestOptions {
|
13
|
+
/**
|
14
|
+
* Feature service url.
|
15
|
+
*/
|
16
|
+
url: string;
|
17
|
+
/**
|
18
|
+
* Unique identifier of feature to add related attachment.
|
19
|
+
*/
|
20
|
+
featureId: number;
|
21
|
+
/**
|
22
|
+
* File to be attached.
|
23
|
+
*/
|
24
|
+
attachment: File;
|
25
|
+
}
|
26
|
+
|
27
|
+
/**
|
28
|
+
* `addAttachment()` request response.
|
29
|
+
*/
|
30
|
+
export interface IAddAttachmentResponse {
|
31
|
+
/**
|
32
|
+
* Standard AGS add/update/edit result Object for the attachment.
|
33
|
+
*/
|
34
|
+
addAttachmentResult: IEditFeatureResult;
|
35
|
+
}
|
36
|
+
|
37
|
+
/**
|
38
|
+
* Attach a file to a feature by id. See [Add Attachment](https://developers.arcgis.com/rest/services-reference/add-attachment.htm) for more information.
|
39
|
+
*
|
40
|
+
* ```js
|
41
|
+
* import { addAttachment } from '@esri/arcgis-rest-feature-service';
|
42
|
+
*
|
43
|
+
* addAttachment({
|
44
|
+
* url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0",
|
45
|
+
* featureId: 8484,
|
46
|
+
* attachment: myFileInput.files[0]
|
47
|
+
* });
|
48
|
+
* ```
|
49
|
+
*
|
50
|
+
* @param requestOptions - Options for the request.
|
51
|
+
* @returns A Promise that will resolve with the `addAttachment()` response.
|
52
|
+
*/
|
53
|
+
export function addAttachment(
|
54
|
+
requestOptions: IAddAttachmentOptions
|
55
|
+
): Promise<IAddAttachmentResponse> {
|
56
|
+
const options: IAddAttachmentOptions = {
|
57
|
+
params: {},
|
58
|
+
...requestOptions
|
59
|
+
};
|
60
|
+
|
61
|
+
// `attachment` --> params: {}
|
62
|
+
options.params.attachment = requestOptions.attachment;
|
63
|
+
|
64
|
+
return request(`${options.url}/${options.featureId}/addAttachment`, options);
|
65
|
+
}
|
@@ -0,0 +1,85 @@
|
|
1
|
+
/* Copyright (c) 2017 Environmental Systems Research Institute, Inc.
|
2
|
+
* Apache-2.0 */
|
3
|
+
|
4
|
+
import { request, IRequestOptions } from "@esri/arcgis-rest-request";
|
5
|
+
|
6
|
+
import {
|
7
|
+
IEditFeaturesParams,
|
8
|
+
IEditFeatureResult,
|
9
|
+
ISharedQueryParams,
|
10
|
+
appendCustomParams
|
11
|
+
} from "./helpers";
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Delete features parameters.
|
15
|
+
*/
|
16
|
+
export interface IDeleteFeaturesParams
|
17
|
+
extends IEditFeaturesParams,
|
18
|
+
ISharedQueryParams {}
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Delete features request options. See the [REST Documentation](https://developers.arcgis.com/rest/services-reference/delete-features.htm) for more information.
|
22
|
+
*
|
23
|
+
* @param url - Feature service url.
|
24
|
+
* @param deletes - Array of objectIds to delete.
|
25
|
+
* @param params - Query parameters to be sent to the feature service via the request.
|
26
|
+
*/
|
27
|
+
export interface IDeleteFeaturesRequestOptions
|
28
|
+
extends IDeleteFeaturesParams,
|
29
|
+
IRequestOptions {
|
30
|
+
/**
|
31
|
+
* Feature service url.
|
32
|
+
*/
|
33
|
+
url: string;
|
34
|
+
/**
|
35
|
+
* Array of objectIds to delete.
|
36
|
+
*/
|
37
|
+
deletes: number[];
|
38
|
+
}
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Delete features results.
|
42
|
+
*/
|
43
|
+
export interface IDeleteFeaturesResult {
|
44
|
+
/**
|
45
|
+
* Array of JSON response Object(s) for each feature deleted.
|
46
|
+
*/
|
47
|
+
deleteResults?: IEditFeatureResult[];
|
48
|
+
}
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Delete features request. See the [REST Documentation](https://developers.arcgis.com/rest/services-reference/delete-features.htm) for more information.
|
52
|
+
*
|
53
|
+
* ```js
|
54
|
+
* import { deleteFeatures } from '@esri/arcgis-rest-feature-service';
|
55
|
+
*
|
56
|
+
* const url = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0";
|
57
|
+
*
|
58
|
+
* deleteFeatures({
|
59
|
+
* url,
|
60
|
+
* deletes: [1,2,3]
|
61
|
+
* });
|
62
|
+
* ```
|
63
|
+
*
|
64
|
+
* @param deleteFeaturesRequestOptions - Options for the request.
|
65
|
+
* @returns A Promise that will resolve with the deleteFeatures response.
|
66
|
+
*/
|
67
|
+
export function deleteFeatures(
|
68
|
+
requestOptions: IDeleteFeaturesRequestOptions
|
69
|
+
): Promise<IDeleteFeaturesResult> {
|
70
|
+
const url = `${requestOptions.url}/deleteFeatures`;
|
71
|
+
|
72
|
+
// edit operations POST only
|
73
|
+
const options: IDeleteFeaturesRequestOptions = {
|
74
|
+
params: {},
|
75
|
+
...requestOptions
|
76
|
+
};
|
77
|
+
|
78
|
+
appendCustomParams(requestOptions, options);
|
79
|
+
|
80
|
+
// mixin, don't overwrite
|
81
|
+
options.params.objectIds = requestOptions.deletes;
|
82
|
+
delete options.params.deletes;
|
83
|
+
|
84
|
+
return request(url, options);
|
85
|
+
}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
|
2
|
+
* Apache-2.0 */
|
3
|
+
|
4
|
+
import { request, IRequestOptions } from "@esri/arcgis-rest-request";
|
5
|
+
|
6
|
+
import { IEditFeatureResult } from "./helpers";
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Request options to for deleting related attachments of a feature by id. See [Delete Attachments](https://developers.arcgis.com/rest/services-reference/delete-attachments.htm) for more information.
|
10
|
+
*
|
11
|
+
*/
|
12
|
+
export interface IDeleteAttachmentsOptions extends IRequestOptions {
|
13
|
+
/**
|
14
|
+
* Feature service url.
|
15
|
+
*/
|
16
|
+
url: string;
|
17
|
+
/**
|
18
|
+
* Unique identifier of feature to delete related attachment(s).
|
19
|
+
*/
|
20
|
+
featureId: number;
|
21
|
+
/**
|
22
|
+
* Array of unique identifiers of attachments to delete.
|
23
|
+
*/
|
24
|
+
attachmentIds: number[];
|
25
|
+
}
|
26
|
+
|
27
|
+
/**
|
28
|
+
* `updateAttachment()` request response.
|
29
|
+
*/
|
30
|
+
export interface IDeleteAttachmentsResponse {
|
31
|
+
/**
|
32
|
+
* Array of standard AGS add/update/edit result Object(s) for the attachment(s).
|
33
|
+
*/
|
34
|
+
deleteAttachmentResults: IEditFeatureResult[];
|
35
|
+
}
|
36
|
+
|
37
|
+
/**
|
38
|
+
* 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.
|
39
|
+
*
|
40
|
+
* ```js
|
41
|
+
* import { deleteAttachments } from '@esri/arcgis-rest-feature-service';
|
42
|
+
*
|
43
|
+
* deleteAttachments({
|
44
|
+
* url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0",
|
45
|
+
* featureId: 8484,
|
46
|
+
* attachmentIds: [306]
|
47
|
+
* });
|
48
|
+
* ```
|
49
|
+
*
|
50
|
+
* @param requestOptions - Options for the request.
|
51
|
+
* @returns A Promise that will resolve with the `deleteAttachments()` response.
|
52
|
+
*/
|
53
|
+
export function deleteAttachments(
|
54
|
+
requestOptions: IDeleteAttachmentsOptions
|
55
|
+
): Promise<IDeleteAttachmentsResponse> {
|
56
|
+
const options: IDeleteAttachmentsOptions = {
|
57
|
+
params: {},
|
58
|
+
...requestOptions
|
59
|
+
};
|
60
|
+
|
61
|
+
// `attachmentIds` --> params: {}
|
62
|
+
options.params.attachmentIds = requestOptions.attachmentIds;
|
63
|
+
|
64
|
+
return request(
|
65
|
+
`${options.url}/${options.featureId}/deleteAttachments`,
|
66
|
+
options
|
67
|
+
);
|
68
|
+
}
|
@@ -0,0 +1,64 @@
|
|
1
|
+
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
|
2
|
+
* Apache-2.0 */
|
3
|
+
|
4
|
+
import { request, IRequestOptions } from "@esri/arcgis-rest-request";
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Request options to fetch `attachmentInfos` of a feature by id. See [Attachment Infos](https://developers.arcgis.com/rest/services-reference/attachment-infos-feature-service-.htm) for more information.
|
8
|
+
*
|
9
|
+
*/
|
10
|
+
export interface IGetAttachmentsOptions extends IRequestOptions {
|
11
|
+
/**
|
12
|
+
* Feature service url.
|
13
|
+
*/
|
14
|
+
url: string;
|
15
|
+
/**
|
16
|
+
* Unique identifier of feature to request related `attachmentInfos`.
|
17
|
+
*/
|
18
|
+
featureId: number;
|
19
|
+
}
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Attachment, a.k.a. `attachmentInfo`. See [Attachment](https://developers.arcgis.com/rest/services-reference/attachment-feature-service-.htm) for more information.
|
23
|
+
*/
|
24
|
+
export interface IAttachmentInfo {
|
25
|
+
id: number;
|
26
|
+
contentType: string;
|
27
|
+
size: number;
|
28
|
+
name: string;
|
29
|
+
}
|
30
|
+
|
31
|
+
/**
|
32
|
+
* `getAttachments()` request response.
|
33
|
+
*/
|
34
|
+
export interface IGetAttachmentsResponse {
|
35
|
+
/**
|
36
|
+
* Array of `attachmentInfo` Object(s) for each related attachment. Empty Array means no attachments.
|
37
|
+
*/
|
38
|
+
attachmentInfos: IAttachmentInfo[];
|
39
|
+
}
|
40
|
+
|
41
|
+
/**
|
42
|
+
* 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.
|
43
|
+
*
|
44
|
+
* ```js
|
45
|
+
* import { getAttachments } from '@esri/arcgis-rest-feature-service';
|
46
|
+
*
|
47
|
+
* getAttachments({
|
48
|
+
* url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0",
|
49
|
+
* featureId: 8484
|
50
|
+
* });
|
51
|
+
* ```
|
52
|
+
*
|
53
|
+
* @param requestOptions - Options for the request.
|
54
|
+
* @returns A Promise that will resolve with the `getAttachments()` response.
|
55
|
+
*/
|
56
|
+
export function getAttachments(
|
57
|
+
requestOptions: IGetAttachmentsOptions
|
58
|
+
): Promise<IGetAttachmentsResponse> {
|
59
|
+
// pass through
|
60
|
+
return request(
|
61
|
+
`${requestOptions.url}/${requestOptions.featureId}/attachments`,
|
62
|
+
requestOptions
|
63
|
+
);
|
64
|
+
}
|
@@ -0,0 +1,77 @@
|
|
1
|
+
/* Copyright (c) 2017 Environmental Systems Research Institute, Inc.
|
2
|
+
* Apache-2.0 */
|
3
|
+
import {
|
4
|
+
esriGeometryType,
|
5
|
+
SpatialRelationship,
|
6
|
+
IGeometry,
|
7
|
+
ISpatialReference
|
8
|
+
} from "@esri/arcgis-rest-common-types";
|
9
|
+
import { request, IRequestOptions, IParams } from "@esri/arcgis-rest-request";
|
10
|
+
|
11
|
+
import { IQueryFeaturesRequestOptions } from "./query";
|
12
|
+
import { IAddFeaturesRequestOptions } from "./add";
|
13
|
+
import { IUpdateFeaturesRequestOptions } from "./update";
|
14
|
+
import { IDeleteFeaturesRequestOptions } from "./delete";
|
15
|
+
|
16
|
+
export interface ISharedQueryParams {
|
17
|
+
where?: string;
|
18
|
+
geometry?: IGeometry;
|
19
|
+
geometryType?: esriGeometryType;
|
20
|
+
// NOTE: either WKID or ISpatialReference
|
21
|
+
inSR?: string | ISpatialReference;
|
22
|
+
spatialRel?: SpatialRelationship;
|
23
|
+
}
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Add, update and delete features result Object.
|
27
|
+
*/
|
28
|
+
export interface IEditFeatureResult {
|
29
|
+
objectId: number;
|
30
|
+
globalId?: string;
|
31
|
+
success: boolean;
|
32
|
+
}
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Common add and update features parameters.
|
36
|
+
*/
|
37
|
+
export interface IEditFeaturesParams {
|
38
|
+
/**
|
39
|
+
* The geodatabase version to apply the edits.
|
40
|
+
*/
|
41
|
+
gdbVersion?: string;
|
42
|
+
/**
|
43
|
+
* Optional parameter specifying whether the response will report the time features were added.
|
44
|
+
*/
|
45
|
+
returnEditMoment?: boolean;
|
46
|
+
/**
|
47
|
+
* Optional parameter to specify if the edits should be applied only if all submitted edits succeed.
|
48
|
+
*/
|
49
|
+
rollbackOnFailure?: boolean;
|
50
|
+
}
|
51
|
+
|
52
|
+
/**
|
53
|
+
* Used internally by the package to ensure that first order request options are passed through as request parameters.
|
54
|
+
*/
|
55
|
+
export function appendCustomParams(
|
56
|
+
oldOptions:
|
57
|
+
| IQueryFeaturesRequestOptions
|
58
|
+
| IAddFeaturesRequestOptions
|
59
|
+
| IUpdateFeaturesRequestOptions
|
60
|
+
| IDeleteFeaturesRequestOptions,
|
61
|
+
newOptions: IRequestOptions
|
62
|
+
) {
|
63
|
+
// only pass query parameters through in the request, not generic IRequestOptions props
|
64
|
+
Object.keys(oldOptions).forEach(function(key: string) {
|
65
|
+
if (
|
66
|
+
key !== "url" &&
|
67
|
+
key !== "params" &&
|
68
|
+
key !== "authentication" &&
|
69
|
+
key !== "httpMethod" &&
|
70
|
+
key !== "fetch" &&
|
71
|
+
key !== "portal" &&
|
72
|
+
key !== "maxUrlLength"
|
73
|
+
) {
|
74
|
+
newOptions.params[key] = (oldOptions as { [key: string]: any })[key];
|
75
|
+
}
|
76
|
+
});
|
77
|
+
}
|