ducimusipsa 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 +34 -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 +180 -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 +15 -0
- package/demos/batch-geocoder-node/batch-geocode.js +115 -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 +38 -0
- package/demos/express/README.md +15 -0
- package/demos/express/config.json.template +3 -0
- package/demos/express/package-lock.json +428 -0
- package/demos/express/package.json +18 -0
- package/demos/express/server.js +33 -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 +182 -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 +25 -0
- package/demos/jsapi-integration/config.js +6 -0
- package/demos/jsapi-integration/index.html +85 -0
- package/demos/jsapi-integration/package-lock.json +184 -0
- package/demos/jsapi-integration/package.json +19 -0
- package/demos/oauth2-browser/README.md +14 -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/oauth2-browser-retry/README.md +25 -0
- package/demos/oauth2-browser-retry/authenticate.html +21 -0
- package/demos/oauth2-browser-retry/index.html +116 -0
- package/demos/oauth2-browser-retry/logo.svg +4 -0
- package/demos/vue/.env.example +11 -0
- package/demos/vue/.eslintrc.js +17 -0
- package/demos/vue/.postcssrc.js +5 -0
- package/demos/vue/README.md +17 -0
- package/demos/vue/babel.config.js +3 -0
- package/demos/vue/package-lock.json +11323 -0
- package/demos/vue/package.json +33 -0
- package/demos/vue/public/favicon.ico +0 -0
- package/demos/vue/public/index.html +24 -0
- package/demos/vue/src/assets/logo.svg +29 -0
- package/demos/vue/src/components/App.vue +308 -0
- package/demos/vue/src/components/Authenticate.vue +65 -0
- package/demos/vue/src/components/Loader.vue +230 -0
- package/demos/vue/src/main.js +92 -0
- package/docs/FAQ.md +28 -0
- package/docs/HISTORY.md +62 -0
- package/docs/acetate.config.js +223 -0
- package/docs/build-typedoc.js +303 -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 +41 -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 +70 -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 +112 -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 +129 -0
- package/packages/arcgis-rest-auth/README.md +67 -0
- package/packages/arcgis-rest-auth/package-lock.json +11 -0
- package/packages/arcgis-rest-auth/package.json +53 -0
- package/packages/arcgis-rest-auth/src/ApplicationSession.ts +108 -0
- package/packages/arcgis-rest-auth/src/UserSession.ts +880 -0
- package/packages/arcgis-rest-auth/src/authenticated-request-options.ts +24 -0
- package/packages/arcgis-rest-auth/src/fetch-token.ts +52 -0
- package/packages/arcgis-rest-auth/src/generate-token.ts +39 -0
- package/packages/arcgis-rest-auth/src/index.ts +8 -0
- package/packages/arcgis-rest-auth/test/ApplicationSession.test.ts +124 -0
- package/packages/arcgis-rest-auth/test/UserSession.test.ts +1005 -0
- package/packages/arcgis-rest-auth/test/fetchToken.test.ts +112 -0
- package/packages/arcgis-rest-auth/test/generateToken.test.ts +130 -0
- package/packages/arcgis-rest-auth/test/utils.ts +14 -0
- package/packages/arcgis-rest-auth/tsconfig.json +6 -0
- package/packages/arcgis-rest-common/README.md +57 -0
- package/packages/arcgis-rest-common/package-lock.json +11 -0
- package/packages/arcgis-rest-common/package.json +41 -0
- package/packages/arcgis-rest-common/src/index.ts +10 -0
- package/packages/arcgis-rest-common/src/types/feature.ts +14 -0
- package/packages/arcgis-rest-common/src/types/geometry.ts +47 -0
- package/packages/arcgis-rest-common/src/types/symbol.ts +21 -0
- package/packages/arcgis-rest-common/src/util/location.ts +19 -0
- package/packages/arcgis-rest-common/test/location.test.ts +73 -0
- package/packages/arcgis-rest-common/tsconfig.json +6 -0
- package/packages/arcgis-rest-common-types/README.md +64 -0
- package/packages/arcgis-rest-common-types/package.json +40 -0
- package/packages/arcgis-rest-common-types/src/group.ts +54 -0
- package/packages/arcgis-rest-common-types/src/index.ts +469 -0
- package/packages/arcgis-rest-common-types/src/item.ts +47 -0
- package/packages/arcgis-rest-common-types/src/webmap.ts +1267 -0
- package/packages/arcgis-rest-common-types/tsconfig.json +11 -0
- package/packages/arcgis-rest-feature-service/README.md +73 -0
- package/packages/arcgis-rest-feature-service/package-lock.json +11 -0
- package/packages/arcgis-rest-feature-service/package.json +53 -0
- package/packages/arcgis-rest-feature-service/src/add.ts +90 -0
- package/packages/arcgis-rest-feature-service/src/addAttachment.ts +64 -0
- package/packages/arcgis-rest-feature-service/src/decodeValues.ts +129 -0
- package/packages/arcgis-rest-feature-service/src/delete.ts +97 -0
- package/packages/arcgis-rest-feature-service/src/deleteAttachments.ts +67 -0
- package/packages/arcgis-rest-feature-service/src/getAttachments.ts +64 -0
- package/packages/arcgis-rest-feature-service/src/getLayer.ts +27 -0
- package/packages/arcgis-rest-feature-service/src/helpers.ts +50 -0
- package/packages/arcgis-rest-feature-service/src/index.ts +14 -0
- package/packages/arcgis-rest-feature-service/src/query.ts +183 -0
- package/packages/arcgis-rest-feature-service/src/queryRelated.ts +94 -0
- package/packages/arcgis-rest-feature-service/src/update.ts +90 -0
- package/packages/arcgis-rest-feature-service/src/updateAttachment.ts +73 -0
- package/packages/arcgis-rest-feature-service/test/attachments.test.ts +203 -0
- package/packages/arcgis-rest-feature-service/test/crud.test.ts +263 -0
- package/packages/arcgis-rest-feature-service/test/decodeValues.test.ts +67 -0
- package/packages/arcgis-rest-feature-service/test/getLayer.test.ts +31 -0
- package/packages/arcgis-rest-feature-service/test/mocks/cvdQueryResponse.ts +225 -0
- package/packages/arcgis-rest-feature-service/test/mocks/feature.ts +281 -0
- package/packages/arcgis-rest-feature-service/test/mocks/fields.ts +779 -0
- package/packages/arcgis-rest-feature-service/test/mocks/foo.txt +1 -0
- package/packages/arcgis-rest-feature-service/test/mocks/service.ts +259 -0
- package/packages/arcgis-rest-feature-service/test/query.test.ts +140 -0
- package/packages/arcgis-rest-feature-service/tsconfig.json +6 -0
- package/packages/arcgis-rest-feature-service-admin/README.md +69 -0
- package/packages/arcgis-rest-feature-service-admin/package-lock.json +11 -0
- package/packages/arcgis-rest-feature-service-admin/package.json +56 -0
- package/packages/arcgis-rest-feature-service-admin/src/addTo.ts +74 -0
- package/packages/arcgis-rest-feature-service-admin/src/create.ts +207 -0
- package/packages/arcgis-rest-feature-service-admin/src/index.ts +2 -0
- package/packages/arcgis-rest-feature-service-admin/test/addTo.test.ts +353 -0
- package/packages/arcgis-rest-feature-service-admin/test/create.test.ts +412 -0
- package/packages/arcgis-rest-feature-service-admin/test/mocks/layerDefinition.ts +79 -0
- package/packages/arcgis-rest-feature-service-admin/test/mocks/move.ts +14 -0
- package/packages/arcgis-rest-feature-service-admin/test/mocks/service.ts +72 -0
- package/packages/arcgis-rest-feature-service-admin/tsconfig.json +6 -0
- package/packages/arcgis-rest-geocoder/README.md +83 -0
- package/packages/arcgis-rest-geocoder/package-lock.json +11 -0
- package/packages/arcgis-rest-geocoder/package.json +55 -0
- package/packages/arcgis-rest-geocoder/src/bulk.ts +102 -0
- package/packages/arcgis-rest-geocoder/src/geocode.ts +130 -0
- package/packages/arcgis-rest-geocoder/src/helpers.ts +80 -0
- package/packages/arcgis-rest-geocoder/src/index.ts +8 -0
- package/packages/arcgis-rest-geocoder/src/reverse.ts +83 -0
- package/packages/arcgis-rest-geocoder/src/suggest.ts +69 -0
- package/packages/arcgis-rest-geocoder/test/bulk.test.ts +113 -0
- package/packages/arcgis-rest-geocoder/test/geocode.test.ts +176 -0
- package/packages/arcgis-rest-geocoder/test/helpers.test.ts +111 -0
- package/packages/arcgis-rest-geocoder/test/mocks/responses.ts +629 -0
- package/packages/arcgis-rest-geocoder/test/reverse.test.ts +126 -0
- package/packages/arcgis-rest-geocoder/test/suggest.test.ts +98 -0
- package/packages/arcgis-rest-geocoder/tsconfig.json +6 -0
- package/packages/arcgis-rest-groups/README.md +67 -0
- package/packages/arcgis-rest-groups/package-lock.json +11 -0
- package/packages/arcgis-rest-groups/package.json +55 -0
- package/packages/arcgis-rest-groups/src/create.ts +34 -0
- package/packages/arcgis-rest-groups/src/get.ts +95 -0
- package/packages/arcgis-rest-groups/src/helpers.ts +27 -0
- package/packages/arcgis-rest-groups/src/index.ts +11 -0
- package/packages/arcgis-rest-groups/src/notification.ts +77 -0
- package/packages/arcgis-rest-groups/src/protect.ts +40 -0
- package/packages/arcgis-rest-groups/src/remove.ts +23 -0
- package/packages/arcgis-rest-groups/src/search.ts +64 -0
- package/packages/arcgis-rest-groups/src/update.ts +36 -0
- package/packages/arcgis-rest-groups/test/crud.test.ts +134 -0
- package/packages/arcgis-rest-groups/test/get.test.ts +101 -0
- package/packages/arcgis-rest-groups/test/mocks/responses.ts +141 -0
- package/packages/arcgis-rest-groups/test/notification.test.ts +102 -0
- package/packages/arcgis-rest-groups/test/protect.test.ts +64 -0
- package/packages/arcgis-rest-groups/test/search.test.ts +85 -0
- package/packages/arcgis-rest-groups/tsconfig.json +6 -0
- package/packages/arcgis-rest-items/README.md +69 -0
- package/packages/arcgis-rest-items/package-lock.json +11 -0
- package/packages/arcgis-rest-items/package.json +55 -0
- package/packages/arcgis-rest-items/src/add.ts +103 -0
- package/packages/arcgis-rest-items/src/create.ts +110 -0
- package/packages/arcgis-rest-items/src/get.ts +79 -0
- package/packages/arcgis-rest-items/src/helpers.ts +147 -0
- package/packages/arcgis-rest-items/src/index.ts +11 -0
- package/packages/arcgis-rest-items/src/protect.ts +38 -0
- package/packages/arcgis-rest-items/src/remove.ts +58 -0
- package/packages/arcgis-rest-items/src/search.ts +78 -0
- package/packages/arcgis-rest-items/src/update.ts +134 -0
- package/packages/arcgis-rest-items/test/add.test.ts +256 -0
- package/packages/arcgis-rest-items/test/create.test.ts +371 -0
- package/packages/arcgis-rest-items/test/get.test.ts +181 -0
- package/packages/arcgis-rest-items/test/mocks/foo.zip +0 -0
- package/packages/arcgis-rest-items/test/mocks/item.ts +35 -0
- package/packages/arcgis-rest-items/test/mocks/resources.ts +31 -0
- package/packages/arcgis-rest-items/test/mocks/search.ts +62 -0
- package/packages/arcgis-rest-items/test/protect.test.ts +122 -0
- package/packages/arcgis-rest-items/test/remove.test.ts +161 -0
- package/packages/arcgis-rest-items/test/search.test.ts +159 -0
- package/packages/arcgis-rest-items/test/update.test.ts +450 -0
- package/packages/arcgis-rest-items/tsconfig.json +6 -0
- package/packages/arcgis-rest-request/README.md +68 -0
- package/packages/arcgis-rest-request/package-lock.json +11 -0
- package/packages/arcgis-rest-request/package.json +45 -0
- package/packages/arcgis-rest-request/src/index.ts +15 -0
- package/packages/arcgis-rest-request/src/request.ts +358 -0
- package/packages/arcgis-rest-request/src/utils/ArcGISRequestError.ts +76 -0
- package/packages/arcgis-rest-request/src/utils/ErrorTypes.ts +29 -0
- package/packages/arcgis-rest-request/src/utils/append-custom-params.ts +29 -0
- package/packages/arcgis-rest-request/src/utils/encode-form-data.ts +34 -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/params.ts +52 -0
- package/packages/arcgis-rest-request/src/utils/process-params.ts +99 -0
- package/packages/arcgis-rest-request/src/utils/retryAuthError.ts +9 -0
- package/packages/arcgis-rest-request/src/utils/warn.ts +11 -0
- package/packages/arcgis-rest-request/test/mocks/errors.ts +68 -0
- package/packages/arcgis-rest-request/test/mocks/geojson-feature-collection.ts +13 -0
- package/packages/arcgis-rest-request/test/mocks/portal.ts +112 -0
- package/packages/arcgis-rest-request/test/mocks/sharing-rest-info.ts +41 -0
- package/packages/arcgis-rest-request/test/mocks/webmap.ts +41 -0
- package/packages/arcgis-rest-request/test/request.test.ts +323 -0
- package/packages/arcgis-rest-request/test/utils/ArcGISAuthError.test.ts +170 -0
- package/packages/arcgis-rest-request/test/utils/ArcGISRequestError.test.ts +51 -0
- package/packages/arcgis-rest-request/test/utils/check-for-errors.test.ts +111 -0
- package/packages/arcgis-rest-request/test/utils/encode-form-data.test.ts +133 -0
- package/packages/arcgis-rest-request/test/utils/get-portal-url.test.ts +37 -0
- package/packages/arcgis-rest-request/test/utils/portal.test.ts +97 -0
- package/packages/arcgis-rest-request/test/utils/process-params.test.ts +193 -0
- package/packages/arcgis-rest-request/tsconfig.json +6 -0
- package/packages/arcgis-rest-routing/README.md +71 -0
- package/packages/arcgis-rest-routing/package-lock.json +11 -0
- package/packages/arcgis-rest-routing/package.json +54 -0
- package/packages/arcgis-rest-routing/src/helpers.ts +16 -0
- package/packages/arcgis-rest-routing/src/index.ts +4 -0
- package/packages/arcgis-rest-routing/src/solveRoute.ts +102 -0
- package/packages/arcgis-rest-routing/test/mocks/responses.ts +825 -0
- package/packages/arcgis-rest-routing/test/solveRoute.test.ts +267 -0
- package/packages/arcgis-rest-routing/tsconfig.json +6 -0
- package/packages/arcgis-rest-sharing/README.md +70 -0
- package/packages/arcgis-rest-sharing/package-lock.json +11 -0
- package/packages/arcgis-rest-sharing/package.json +60 -0
- package/packages/arcgis-rest-sharing/src/access.ts +85 -0
- package/packages/arcgis-rest-sharing/src/group-sharing.ts +211 -0
- package/packages/arcgis-rest-sharing/src/helpers.ts +82 -0
- package/packages/arcgis-rest-sharing/src/index.ts +5 -0
- package/packages/arcgis-rest-sharing/test/access.test.ts +154 -0
- package/packages/arcgis-rest-sharing/test/group-sharing.test.ts +566 -0
- package/packages/arcgis-rest-sharing/test/helpers.test.ts +55 -0
- package/packages/arcgis-rest-sharing/test/mocks/sharing.ts +18 -0
- package/packages/arcgis-rest-sharing/tsconfig.json +6 -0
- package/packages/arcgis-rest-users/README.md +74 -0
- package/packages/arcgis-rest-users/package-lock.json +11 -0
- package/packages/arcgis-rest-users/package.json +54 -0
- package/packages/arcgis-rest-users/src/get.ts +69 -0
- package/packages/arcgis-rest-users/src/index.ts +6 -0
- package/packages/arcgis-rest-users/src/invitation.ts +166 -0
- package/packages/arcgis-rest-users/src/notification.ts +73 -0
- package/packages/arcgis-rest-users/test/get.test.ts +99 -0
- package/packages/arcgis-rest-users/test/invitation.test.ts +169 -0
- package/packages/arcgis-rest-users/test/mocks/invitation.ts +70 -0
- package/packages/arcgis-rest-users/test/mocks/notification.ts +34 -0
- package/packages/arcgis-rest-users/test/mocks/user.ts +173 -0
- package/packages/arcgis-rest-users/test/notification.test.ts +83 -0
- package/packages/arcgis-rest-users/tsconfig.json +6 -0
- package/support/changelog.js +394 -0
- package/support/deploy-doc-site.js +16 -0
- package/support/dev.sh +6 -0
- package/support/publish.sh +43 -0
- package/support/test-helpers.js +8 -0
- package/tsconfig.json +69 -0
- package/tslint.json +16 -0
- package/umd-base-profile.js +82 -0
- package/umd-production-profile.js +13 -0
@@ -0,0 +1,73 @@
|
|
1
|
+
[![npm version][npm-img]][npm-url]
|
2
|
+
[![build status][travis-img]][travis-url]
|
3
|
+
[![Coverage Status][coverage-img]][coverage-url]
|
4
|
+
[![apache licensed](https://img.shields.io/badge/license-Apache-green.svg?style=flat-square)](https://raw.githubusercontent.com/Esri/arcgis-rest-js/master/LICENSE)
|
5
|
+
|
6
|
+
[npm-img]: https://img.shields.io/npm/v/@esri/arcgis-rest-feature-service.svg?style=flat-square
|
7
|
+
[npm-url]: https://www.npmjs.com/package/@esri/arcgis-rest-feature-service
|
8
|
+
[travis-img]: https://img.shields.io/travis/Esri/arcgis-rest-js/master.svg?style=flat-square
|
9
|
+
[travis-url]: https://travis-ci.org/Esri/arcgis-rest-js
|
10
|
+
[coverage-img]: https://coveralls.io/repos/github/Esri/arcgis-rest-js/badge.svg
|
11
|
+
[coverage-url]: https://coveralls.io/github/Esri/arcgis-rest-js
|
12
|
+
|
13
|
+
# @esri/arcgis-rest-feature-service
|
14
|
+
|
15
|
+
> A module for working with ArcGIS feature services that runs in Node.js and modern browsers.
|
16
|
+
|
17
|
+
### Example
|
18
|
+
|
19
|
+
```bash
|
20
|
+
npm install @esri/arcgis-rest-request
|
21
|
+
npm install @esri/arcgis-rest-feature-service
|
22
|
+
```
|
23
|
+
|
24
|
+
```js
|
25
|
+
import { getFeature } from '@esri/arcgis-rest-feature-service';
|
26
|
+
|
27
|
+
const options = {
|
28
|
+
url:
|
29
|
+
"https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Landscape_Trees/FeatureServer/0",
|
30
|
+
id: 42
|
31
|
+
};
|
32
|
+
|
33
|
+
getFeature(options)
|
34
|
+
.then(feature => {
|
35
|
+
console.log(feature.attributes.FID); // 42
|
36
|
+
});
|
37
|
+
```
|
38
|
+
|
39
|
+
### [API Reference](https://esri.github.io/arcgis-rest-js/api/feature-service/)
|
40
|
+
|
41
|
+
### Issues
|
42
|
+
|
43
|
+
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.
|
44
|
+
|
45
|
+
If you're looking for help you can also post issues on [GIS Stackexchange](http://gis.stackexchange.com/questions/ask?tags=esri-oss).
|
46
|
+
|
47
|
+
### Versioning
|
48
|
+
|
49
|
+
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.
|
50
|
+
|
51
|
+
For more information on SemVer, please visit <http://semver.org/>.
|
52
|
+
|
53
|
+
### Contributing
|
54
|
+
|
55
|
+
Esri welcomes contributions from anyone and everyone. Please see our [guidelines for contributing](CONTRIBUTING.md).
|
56
|
+
|
57
|
+
### License
|
58
|
+
|
59
|
+
Copyright © 2017-2018 Esri
|
60
|
+
|
61
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
62
|
+
you may not use this file except in compliance with the License.
|
63
|
+
You may obtain a copy of the License at
|
64
|
+
|
65
|
+
> http://www.apache.org/licenses/LICENSE-2.0
|
66
|
+
|
67
|
+
Unless required by applicable law or agreed to in writing, software
|
68
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
69
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
70
|
+
See the License for the specific language governing permissions and
|
71
|
+
limitations under the License.
|
72
|
+
|
73
|
+
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,53 @@
|
|
1
|
+
{
|
2
|
+
"name": "@esri/arcgis-rest-feature-service",
|
3
|
+
"version": "1.14.1",
|
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
|
+
"devDependencies": {
|
18
|
+
"@esri/arcgis-rest-common-types": "^1.14.1",
|
19
|
+
"@esri/arcgis-rest-request": "^1.14.1"
|
20
|
+
},
|
21
|
+
"peerDependencies": {
|
22
|
+
"@esri/arcgis-rest-common-types": "^1.14.1",
|
23
|
+
"@esri/arcgis-rest-request": "^1.14.1"
|
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
|
+
"dev:esm": "tsc -w --module es2015 --outDir ./dist/esm --declaration",
|
32
|
+
"dev:umd": "rollup -w -c ../../umd-base-profile.js",
|
33
|
+
"dev:node": "tsc -w --module commonjs --outDir ./dist/node"
|
34
|
+
},
|
35
|
+
"publishConfig": {
|
36
|
+
"access": "public"
|
37
|
+
},
|
38
|
+
"repository": {
|
39
|
+
"type": "git",
|
40
|
+
"url": "git+https://github.com/Esri/arcgis-rest-js.git"
|
41
|
+
},
|
42
|
+
"contributors": [
|
43
|
+
{
|
44
|
+
"name": "Tom Wayson",
|
45
|
+
"email": "twayson@esri.com",
|
46
|
+
"url": "http://tomwayson.com/"
|
47
|
+
}
|
48
|
+
],
|
49
|
+
"bugs": {
|
50
|
+
"url": "https://github.com/Esri/arcgis-rest-js/issues"
|
51
|
+
},
|
52
|
+
"homepage": "https://github.com/Esri/arcgis-rest-js#readme"
|
53
|
+
}
|
@@ -0,0 +1,90 @@
|
|
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 {
|
6
|
+
request,
|
7
|
+
IRequestOptions,
|
8
|
+
appendCustomParams,
|
9
|
+
warn
|
10
|
+
} from "@esri/arcgis-rest-request";
|
11
|
+
import { IEditFeaturesParams, IEditFeatureResult } 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 features - 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
|
+
features: IFeature[];
|
31
|
+
/**
|
32
|
+
* Deprecated. Please use `features` instead.
|
33
|
+
*/
|
34
|
+
adds?: IFeature[];
|
35
|
+
}
|
36
|
+
|
37
|
+
/**
|
38
|
+
* Add features results.
|
39
|
+
*/
|
40
|
+
export interface IAddFeaturesResult {
|
41
|
+
/**
|
42
|
+
* Array of JSON response Object(s) for each feature added.
|
43
|
+
*/
|
44
|
+
addResults?: IEditFeatureResult[];
|
45
|
+
}
|
46
|
+
|
47
|
+
/**
|
48
|
+
* Add features request. See the [REST Documentation](https://developers.arcgis.com/rest/services-reference/add-features.htm) for more information.
|
49
|
+
*
|
50
|
+
* ```js
|
51
|
+
* import { addFeatures } from '@esri/arcgis-rest-feature-service';
|
52
|
+
*
|
53
|
+
* const url = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0";
|
54
|
+
*
|
55
|
+
* addFeatures({
|
56
|
+
* url,
|
57
|
+
* features: [{
|
58
|
+
* geometry: { x: -120, y: 45, spatialReference: { wkid: 4326 } },
|
59
|
+
* attributes: { status: "alive" }
|
60
|
+
* }]
|
61
|
+
* });
|
62
|
+
* ```
|
63
|
+
*
|
64
|
+
* @param requestOptions - Options for the request.
|
65
|
+
* @returns A Promise that will resolve with the addFeatures response.
|
66
|
+
*/
|
67
|
+
export function addFeatures(
|
68
|
+
requestOptions: IAddFeaturesRequestOptions
|
69
|
+
): Promise<IAddFeaturesResult> {
|
70
|
+
const url = `${requestOptions.url}/addFeatures`;
|
71
|
+
|
72
|
+
// edit operations are POST only
|
73
|
+
const options: IAddFeaturesRequestOptions = {
|
74
|
+
params: {},
|
75
|
+
...requestOptions
|
76
|
+
};
|
77
|
+
|
78
|
+
appendCustomParams(requestOptions, options);
|
79
|
+
|
80
|
+
if (options.params.adds && options.params.adds.length) {
|
81
|
+
// mixin, don't overwrite
|
82
|
+
options.params.features = requestOptions.adds;
|
83
|
+
delete options.params.adds;
|
84
|
+
warn(
|
85
|
+
"The `adds` parameter is deprecated and will be removed in a future release. Please use `features` instead."
|
86
|
+
);
|
87
|
+
}
|
88
|
+
|
89
|
+
return request(url, options);
|
90
|
+
}
|
@@ -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
|
+
import { IEditFeatureResult } from "./helpers";
|
6
|
+
|
7
|
+
/**
|
8
|
+
* 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.
|
9
|
+
*
|
10
|
+
*/
|
11
|
+
export interface IAddAttachmentOptions extends IRequestOptions {
|
12
|
+
/**
|
13
|
+
* Feature service url.
|
14
|
+
*/
|
15
|
+
url: string;
|
16
|
+
/**
|
17
|
+
* Unique identifier of feature to add related attachment.
|
18
|
+
*/
|
19
|
+
featureId: number;
|
20
|
+
/**
|
21
|
+
* File to be attached.
|
22
|
+
*/
|
23
|
+
attachment: File;
|
24
|
+
}
|
25
|
+
|
26
|
+
/**
|
27
|
+
* `addAttachment()` request response.
|
28
|
+
*/
|
29
|
+
export interface IAddAttachmentResponse {
|
30
|
+
/**
|
31
|
+
* Standard AGS add/update/edit result Object for the attachment.
|
32
|
+
*/
|
33
|
+
addAttachmentResult: IEditFeatureResult;
|
34
|
+
}
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Attach a file to a feature by id. See [Add Attachment](https://developers.arcgis.com/rest/services-reference/add-attachment.htm) for more information.
|
38
|
+
*
|
39
|
+
* ```js
|
40
|
+
* import { addAttachment } from '@esri/arcgis-rest-feature-service';
|
41
|
+
*
|
42
|
+
* addAttachment({
|
43
|
+
* url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0",
|
44
|
+
* featureId: 8484,
|
45
|
+
* attachment: myFileInput.files[0]
|
46
|
+
* });
|
47
|
+
* ```
|
48
|
+
*
|
49
|
+
* @param requestOptions - Options for the request.
|
50
|
+
* @returns A Promise that will resolve with the `addAttachment()` response.
|
51
|
+
*/
|
52
|
+
export function addAttachment(
|
53
|
+
requestOptions: IAddAttachmentOptions
|
54
|
+
): Promise<IAddAttachmentResponse> {
|
55
|
+
const options: IAddAttachmentOptions = {
|
56
|
+
params: {},
|
57
|
+
...requestOptions
|
58
|
+
};
|
59
|
+
|
60
|
+
// `attachment` --> params: {}
|
61
|
+
options.params.attachment = requestOptions.attachment;
|
62
|
+
|
63
|
+
return request(`${options.url}/${options.featureId}/addAttachment`, options);
|
64
|
+
}
|
@@ -0,0 +1,129 @@
|
|
1
|
+
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
|
2
|
+
* Apache-2.0 */
|
3
|
+
|
4
|
+
import { IRequestOptions } from "@esri/arcgis-rest-request";
|
5
|
+
import {
|
6
|
+
IField,
|
7
|
+
ILayerDefinition,
|
8
|
+
IFeature
|
9
|
+
} from "@esri/arcgis-rest-common-types";
|
10
|
+
import { IQueryFeaturesResponse } from "./query";
|
11
|
+
import { getLayer } from "./getLayer";
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Request options to fetch a feature by id.
|
15
|
+
*/
|
16
|
+
export interface IDecodeValuesRequestOptions extends IRequestOptions {
|
17
|
+
/**
|
18
|
+
* Layer service url.
|
19
|
+
*/
|
20
|
+
url: string;
|
21
|
+
/**
|
22
|
+
* Unique identifier of the feature.
|
23
|
+
*/
|
24
|
+
queryResponse: IQueryFeaturesResponse;
|
25
|
+
/**
|
26
|
+
* * If a fieldset is provided, no internal metadata check will be issued to gather info about coded value domains.
|
27
|
+
*
|
28
|
+
* getFeatureService(url)
|
29
|
+
* .then(metadata => {
|
30
|
+
* queryFeatures({ url })
|
31
|
+
* .then(response => {
|
32
|
+
* decodeValues({
|
33
|
+
* url,
|
34
|
+
* queryResponse,
|
35
|
+
* fields: metadata.fields
|
36
|
+
* })
|
37
|
+
* .then(decodedResponse)
|
38
|
+
* })
|
39
|
+
* })
|
40
|
+
*/
|
41
|
+
fields?: IField[];
|
42
|
+
}
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Replaces the raw coded domain values in a query response with descriptions (for legibility).
|
46
|
+
*
|
47
|
+
* ```js
|
48
|
+
* import { queryFeatures, decodeValues } from '@esri/arcgis-rest-feature-service';
|
49
|
+
*
|
50
|
+
* const url = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0";
|
51
|
+
*
|
52
|
+
* queryFeatures({ url })
|
53
|
+
* .then(queryResponse => {
|
54
|
+
* decodeValues({
|
55
|
+
* url,
|
56
|
+
* queryResponse
|
57
|
+
* })
|
58
|
+
* .then(decodedResponse)
|
59
|
+
* })
|
60
|
+
* ```
|
61
|
+
*
|
62
|
+
* @param requestOptions - Options for the request.
|
63
|
+
* @returns A Promise that will resolve with the addFeatures response.
|
64
|
+
*/
|
65
|
+
export function decodeValues(
|
66
|
+
requestOptions: IDecodeValuesRequestOptions
|
67
|
+
): Promise<IQueryFeaturesResponse> {
|
68
|
+
return new Promise(resolve => {
|
69
|
+
if (!requestOptions.fields) {
|
70
|
+
return getLayer(requestOptions.url, requestOptions).then(
|
71
|
+
(metadata: ILayerDefinition) => {
|
72
|
+
resolve((requestOptions.fields = metadata.fields));
|
73
|
+
}
|
74
|
+
);
|
75
|
+
} else {
|
76
|
+
resolve(requestOptions.fields);
|
77
|
+
}
|
78
|
+
}).then(fields => {
|
79
|
+
// extract coded value domains
|
80
|
+
const domains = extractCodedValueDomains(fields as IField[]);
|
81
|
+
if (Object.keys(domains).length < 1) {
|
82
|
+
// no values to decode
|
83
|
+
return requestOptions.queryResponse;
|
84
|
+
}
|
85
|
+
|
86
|
+
// don't mutate original features
|
87
|
+
const decodedFeatures = requestOptions.queryResponse.features.map(
|
88
|
+
(feature: IFeature) => {
|
89
|
+
const decodedAttributes: { [index: string]: any } = {};
|
90
|
+
for (const key in feature.attributes) {
|
91
|
+
/* istanbul ignore next */
|
92
|
+
if (!feature.attributes.hasOwnProperty(key)) continue;
|
93
|
+
const value = feature.attributes[key];
|
94
|
+
const domain = domains[key];
|
95
|
+
decodedAttributes[key] =
|
96
|
+
value !== null && domain ? decodeValue(value, domain) : value;
|
97
|
+
}
|
98
|
+
// merge decoded attributes into the feature
|
99
|
+
return { ...feature, ...{ attributes: decodedAttributes } };
|
100
|
+
}
|
101
|
+
);
|
102
|
+
// merge decoded features into the response
|
103
|
+
return {
|
104
|
+
...requestOptions.queryResponse,
|
105
|
+
...{ features: decodedFeatures }
|
106
|
+
};
|
107
|
+
});
|
108
|
+
}
|
109
|
+
|
110
|
+
function extractCodedValueDomains(fields: IField[]) {
|
111
|
+
return fields.reduce(
|
112
|
+
(domains, field) => {
|
113
|
+
const domain = field.domain;
|
114
|
+
if (domain && domain.type === "codedValue") {
|
115
|
+
domains[field.name] = domain;
|
116
|
+
}
|
117
|
+
return domains;
|
118
|
+
},
|
119
|
+
{} as { [index: string]: any }
|
120
|
+
);
|
121
|
+
}
|
122
|
+
|
123
|
+
// TODO: add type for domain?
|
124
|
+
function decodeValue(value: any, domain: any) {
|
125
|
+
const codedValue = domain.codedValues.find((d: any) => {
|
126
|
+
return value === d.code;
|
127
|
+
});
|
128
|
+
return codedValue ? codedValue.name : value;
|
129
|
+
}
|
@@ -0,0 +1,97 @@
|
|
1
|
+
/* Copyright (c) 2017 Environmental Systems Research Institute, Inc.
|
2
|
+
* Apache-2.0 */
|
3
|
+
|
4
|
+
import {
|
5
|
+
request,
|
6
|
+
IRequestOptions,
|
7
|
+
appendCustomParams,
|
8
|
+
warn
|
9
|
+
} from "@esri/arcgis-rest-request";
|
10
|
+
import {
|
11
|
+
IEditFeaturesParams,
|
12
|
+
IEditFeatureResult,
|
13
|
+
ISharedQueryParams
|
14
|
+
} from "./helpers";
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Delete features parameters.
|
18
|
+
*/
|
19
|
+
export interface IDeleteFeaturesParams
|
20
|
+
extends IEditFeaturesParams,
|
21
|
+
ISharedQueryParams {}
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Delete features request options. See the [REST Documentation](https://developers.arcgis.com/rest/services-reference/delete-features.htm) for more information.
|
25
|
+
*
|
26
|
+
* @param url - Feature service url.
|
27
|
+
* @param objectIds - Array of objectIds to delete.
|
28
|
+
* @param params - Query parameters to be sent to the feature service via the request.
|
29
|
+
*/
|
30
|
+
export interface IDeleteFeaturesRequestOptions
|
31
|
+
extends IDeleteFeaturesParams,
|
32
|
+
IRequestOptions {
|
33
|
+
/**
|
34
|
+
* Feature service url.
|
35
|
+
*/
|
36
|
+
url: string;
|
37
|
+
/**
|
38
|
+
* Array of objectIds to delete.
|
39
|
+
*/
|
40
|
+
objectIds: number[];
|
41
|
+
/**
|
42
|
+
* Deprecated. Please use `objectIds` instead.
|
43
|
+
*/
|
44
|
+
deletes?: number[];
|
45
|
+
}
|
46
|
+
|
47
|
+
/**
|
48
|
+
* Delete features results.
|
49
|
+
*/
|
50
|
+
export interface IDeleteFeaturesResult {
|
51
|
+
/**
|
52
|
+
* Array of JSON response Object(s) for each feature deleted.
|
53
|
+
*/
|
54
|
+
deleteResults?: IEditFeatureResult[];
|
55
|
+
}
|
56
|
+
|
57
|
+
/**
|
58
|
+
* Delete features request. See the [REST Documentation](https://developers.arcgis.com/rest/services-reference/delete-features.htm) for more information.
|
59
|
+
*
|
60
|
+
* ```js
|
61
|
+
* import { deleteFeatures } from '@esri/arcgis-rest-feature-service';
|
62
|
+
*
|
63
|
+
* const url = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0";
|
64
|
+
*
|
65
|
+
* deleteFeatures({
|
66
|
+
* url,
|
67
|
+
* objectIds: [1,2,3]
|
68
|
+
* });
|
69
|
+
* ```
|
70
|
+
*
|
71
|
+
* @param deleteFeaturesRequestOptions - Options for the request.
|
72
|
+
* @returns A Promise that will resolve with the deleteFeatures response.
|
73
|
+
*/
|
74
|
+
export function deleteFeatures(
|
75
|
+
requestOptions: IDeleteFeaturesRequestOptions
|
76
|
+
): Promise<IDeleteFeaturesResult> {
|
77
|
+
const url = `${requestOptions.url}/deleteFeatures`;
|
78
|
+
|
79
|
+
// edit operations POST only
|
80
|
+
const options: IDeleteFeaturesRequestOptions = {
|
81
|
+
params: {},
|
82
|
+
...requestOptions
|
83
|
+
};
|
84
|
+
|
85
|
+
appendCustomParams(requestOptions, options);
|
86
|
+
|
87
|
+
if (options.params.deletes && options.params.deletes.length) {
|
88
|
+
// mixin, don't overwrite
|
89
|
+
options.params.objectIds = requestOptions.deletes;
|
90
|
+
delete options.params.deletes;
|
91
|
+
warn(
|
92
|
+
"The `deletes` parameter is deprecated and will be removed in a future release. Please use `objectIds` instead."
|
93
|
+
);
|
94
|
+
}
|
95
|
+
|
96
|
+
return request(url, options);
|
97
|
+
}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
|
2
|
+
* Apache-2.0 */
|
3
|
+
|
4
|
+
import { request, IRequestOptions } from "@esri/arcgis-rest-request";
|
5
|
+
import { IEditFeatureResult } from "./helpers";
|
6
|
+
|
7
|
+
/**
|
8
|
+
* 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.
|
9
|
+
*
|
10
|
+
*/
|
11
|
+
export interface IDeleteAttachmentsOptions extends IRequestOptions {
|
12
|
+
/**
|
13
|
+
* Feature service url.
|
14
|
+
*/
|
15
|
+
url: string;
|
16
|
+
/**
|
17
|
+
* Unique identifier of feature to delete related attachment(s).
|
18
|
+
*/
|
19
|
+
featureId: number;
|
20
|
+
/**
|
21
|
+
* Array of unique identifiers of attachments to delete.
|
22
|
+
*/
|
23
|
+
attachmentIds: number[];
|
24
|
+
}
|
25
|
+
|
26
|
+
/**
|
27
|
+
* `updateAttachment()` request response.
|
28
|
+
*/
|
29
|
+
export interface IDeleteAttachmentsResponse {
|
30
|
+
/**
|
31
|
+
* Array of standard AGS add/update/edit result Object(s) for the attachment(s).
|
32
|
+
*/
|
33
|
+
deleteAttachmentResults: IEditFeatureResult[];
|
34
|
+
}
|
35
|
+
|
36
|
+
/**
|
37
|
+
* 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.
|
38
|
+
*
|
39
|
+
* ```js
|
40
|
+
* import { deleteAttachments } from '@esri/arcgis-rest-feature-service';
|
41
|
+
*
|
42
|
+
* deleteAttachments({
|
43
|
+
* url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0",
|
44
|
+
* featureId: 8484,
|
45
|
+
* attachmentIds: [306]
|
46
|
+
* });
|
47
|
+
* ```
|
48
|
+
*
|
49
|
+
* @param requestOptions - Options for the request.
|
50
|
+
* @returns A Promise that will resolve with the `deleteAttachments()` response.
|
51
|
+
*/
|
52
|
+
export function deleteAttachments(
|
53
|
+
requestOptions: IDeleteAttachmentsOptions
|
54
|
+
): Promise<IDeleteAttachmentsResponse> {
|
55
|
+
const options: IDeleteAttachmentsOptions = {
|
56
|
+
params: {},
|
57
|
+
...requestOptions
|
58
|
+
};
|
59
|
+
|
60
|
+
// `attachmentIds` --> params: {}
|
61
|
+
options.params.attachmentIds = requestOptions.attachmentIds;
|
62
|
+
|
63
|
+
return request(
|
64
|
+
`${options.url}/${options.featureId}/deleteAttachments`,
|
65
|
+
options
|
66
|
+
);
|
67
|
+
}
|
@@ -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,27 @@
|
|
1
|
+
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
|
2
|
+
* Apache-2.0 */
|
3
|
+
|
4
|
+
import { request, IRequestOptions } from "@esri/arcgis-rest-request";
|
5
|
+
import { ILayerDefinition } from "@esri/arcgis-rest-common-types";
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Layer (Feature Service) request. See the [REST Documentation](https://developers.arcgis.com/rest/services-reference/layer-feature-service-.htm) for more information.
|
9
|
+
*
|
10
|
+
* ```js
|
11
|
+
* import { getLayer } from '@esri/arcgis-rest-feature-service';
|
12
|
+
*
|
13
|
+
* const url = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/ServiceRequest/FeatureServer/0";
|
14
|
+
*
|
15
|
+
* getLayer(url)
|
16
|
+
* .then(response) // { name: "311", id: 0, ... }
|
17
|
+
* ```
|
18
|
+
*
|
19
|
+
* @param requestOptions - Options for the request.
|
20
|
+
* @returns A Promise that will resolve with the addFeatures response.
|
21
|
+
*/
|
22
|
+
export function getLayer(
|
23
|
+
url: string,
|
24
|
+
requestOptions?: IRequestOptions
|
25
|
+
): Promise<ILayerDefinition> {
|
26
|
+
return request(url, requestOptions);
|
27
|
+
}
|