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,207 @@
|
|
1
|
+
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
|
2
|
+
* Apache-2.0 */
|
3
|
+
|
4
|
+
import { request, getPortalUrl } from "@esri/arcgis-rest-request";
|
5
|
+
import {
|
6
|
+
moveItem,
|
7
|
+
IItemCrudRequestOptions,
|
8
|
+
determineOwner
|
9
|
+
} from "@esri/arcgis-rest-items";
|
10
|
+
import { IExtent, ISpatialReference } from "@esri/arcgis-rest-common-types";
|
11
|
+
|
12
|
+
/**
|
13
|
+
* A [`createParameters` JSON object for a new
|
14
|
+
* service](https://developers.arcgis.com/rest/users-groups-and-items/create-service.htm).
|
15
|
+
*/
|
16
|
+
export interface ICreateServiceParams {
|
17
|
+
/**
|
18
|
+
* Name of the service to be created. This name must be unique. If the name already exists, the operation will fail. ArcGIS Enterprise does not allow spaces or special characters other than underscores in a service name.
|
19
|
+
*/
|
20
|
+
name: string;
|
21
|
+
/**
|
22
|
+
* Description given to the service.
|
23
|
+
*/
|
24
|
+
serviceDescription?: string;
|
25
|
+
/**
|
26
|
+
* Indicates whether the data changes.
|
27
|
+
*/
|
28
|
+
hasStaticData?: boolean;
|
29
|
+
/**
|
30
|
+
* A double value indicating any constraints enforced on query operations.
|
31
|
+
*/
|
32
|
+
maxRecordCount?: number;
|
33
|
+
/**
|
34
|
+
* The formats in which query results are returned.
|
35
|
+
*/
|
36
|
+
supportedQueryFormats?: string;
|
37
|
+
/**
|
38
|
+
* Specify feature service editing capabilities for Create, Delete, Query, Update, and Sync.
|
39
|
+
*/
|
40
|
+
capabilities?: string;
|
41
|
+
/**
|
42
|
+
* A user-friendly description for the published dataset.
|
43
|
+
*/
|
44
|
+
description?: string;
|
45
|
+
/**
|
46
|
+
* Copyright information associated with the dataset.
|
47
|
+
*/
|
48
|
+
copyrightText?: string;
|
49
|
+
/**
|
50
|
+
* All layers added to a hosted feature service need to have the same spatial reference defined for
|
51
|
+
* the feature service. When creating a new empty service without specifying its spatial reference,
|
52
|
+
* the spatial reference of the hosted feature service is set to the first layer added to that
|
53
|
+
* feature service.
|
54
|
+
*/
|
55
|
+
spatialReference?: ISpatialReference;
|
56
|
+
/**
|
57
|
+
* The initial extent set for the service.
|
58
|
+
*/
|
59
|
+
initialExtent?: IExtent;
|
60
|
+
/**
|
61
|
+
* Indicates if updating the geometry of the service is permitted.
|
62
|
+
*/
|
63
|
+
allowGeometryUpdates?: boolean;
|
64
|
+
/**
|
65
|
+
* Units used by the feature service
|
66
|
+
*/
|
67
|
+
units?: string;
|
68
|
+
/**
|
69
|
+
* A JSON object specifying the properties of cross-site scripting prevention.
|
70
|
+
*/
|
71
|
+
xssPreventionInfo?: any;
|
72
|
+
/**
|
73
|
+
* Editor tracking info.
|
74
|
+
*/
|
75
|
+
editorTrackingInfo?: {
|
76
|
+
enableEditorTracking?: boolean;
|
77
|
+
enableOwnershipAccessControl?: boolean;
|
78
|
+
allowOthersToUpdate?: boolean;
|
79
|
+
allowOthersToDelete?: boolean;
|
80
|
+
allowOthersToQuery?: boolean;
|
81
|
+
allowAnonymousToUpdate?: boolean;
|
82
|
+
allowAnonymousToDelete?: boolean;
|
83
|
+
};
|
84
|
+
}
|
85
|
+
|
86
|
+
export interface ICreateServiceRequestOptions extends IItemCrudRequestOptions {
|
87
|
+
/**
|
88
|
+
* A JSON object specifying the properties of the newly-created service. See the [REST
|
89
|
+
* Documentation](https://developers.arcgis.com/rest/users-groups-and-items/working-with-users-groups-and-items.htm)
|
90
|
+
* for more information.
|
91
|
+
*/
|
92
|
+
item: ICreateServiceParams;
|
93
|
+
/**
|
94
|
+
* Alphanumeric id of folder to house moved item. If null, empty, or "/", the destination is the
|
95
|
+
* root folder.
|
96
|
+
*/
|
97
|
+
folderId?: string;
|
98
|
+
}
|
99
|
+
|
100
|
+
export interface ICreateServiceResult {
|
101
|
+
/**
|
102
|
+
* The encoded URL to the hosted service.
|
103
|
+
*/
|
104
|
+
encodedServiceURL: string;
|
105
|
+
|
106
|
+
/**
|
107
|
+
* Indicates if this feature service represents a view.
|
108
|
+
*/
|
109
|
+
isView: boolean;
|
110
|
+
|
111
|
+
/**
|
112
|
+
* The unique ID for this item.
|
113
|
+
*/
|
114
|
+
itemId: string;
|
115
|
+
|
116
|
+
/**
|
117
|
+
* Name of the service item.
|
118
|
+
*/
|
119
|
+
name: string;
|
120
|
+
|
121
|
+
/**
|
122
|
+
* The ID of the new service item.
|
123
|
+
*/
|
124
|
+
serviceItemId: string;
|
125
|
+
|
126
|
+
/**
|
127
|
+
* The URL to the hosted service.
|
128
|
+
*/
|
129
|
+
serviceurl: string;
|
130
|
+
|
131
|
+
/**
|
132
|
+
* The size of the item.
|
133
|
+
*/
|
134
|
+
size: number;
|
135
|
+
|
136
|
+
/**
|
137
|
+
* Indicates if the operation was successful.
|
138
|
+
*/
|
139
|
+
success: boolean;
|
140
|
+
|
141
|
+
/**
|
142
|
+
* The type of service created.
|
143
|
+
*/
|
144
|
+
type: string;
|
145
|
+
}
|
146
|
+
|
147
|
+
/**
|
148
|
+
* Create a new hosted feature service.
|
149
|
+
*
|
150
|
+
* ```js
|
151
|
+
* import { createFeatureService } from '@esri/arcgis-rest-feature-service-admin';
|
152
|
+
*
|
153
|
+
* createFeatureService({
|
154
|
+
* authentication: userSession,
|
155
|
+
* item: {
|
156
|
+
* "name": "NewEmptyService",
|
157
|
+
* "capabilities": "Create,Delete,Query,Update,Editing"
|
158
|
+
* }
|
159
|
+
* });
|
160
|
+
* ```
|
161
|
+
*
|
162
|
+
* @param requestOptions - Options for the request
|
163
|
+
* @returns A Promise that resolves with service details once the service has been created
|
164
|
+
*/
|
165
|
+
export function createFeatureService(
|
166
|
+
requestOptions: ICreateServiceRequestOptions
|
167
|
+
): Promise<ICreateServiceResult> {
|
168
|
+
const owner = determineOwner(requestOptions);
|
169
|
+
|
170
|
+
const baseUrl = `${getPortalUrl(requestOptions)}/content/users/${owner}`;
|
171
|
+
const url = `${baseUrl}/createService`;
|
172
|
+
|
173
|
+
// Create the service
|
174
|
+
requestOptions.params = {
|
175
|
+
createParameters: requestOptions.item,
|
176
|
+
outputType: "featureService",
|
177
|
+
...requestOptions.params
|
178
|
+
};
|
179
|
+
|
180
|
+
if (!requestOptions.folderId || requestOptions.folderId === "/") {
|
181
|
+
// If the service is destined for the root folder, just send the request and return the promise;
|
182
|
+
// services are created in the root folder
|
183
|
+
return request(url, requestOptions);
|
184
|
+
} else {
|
185
|
+
// If the service is destined for a subfolder, catch the results of the request and then move
|
186
|
+
// the item to the desired folder
|
187
|
+
return new Promise((resolve, reject) => {
|
188
|
+
request(url, requestOptions).then(createResults => {
|
189
|
+
if (createResults.success) {
|
190
|
+
moveItem({
|
191
|
+
itemId: createResults.itemId,
|
192
|
+
folderId: requestOptions.folderId,
|
193
|
+
authentication: requestOptions.authentication
|
194
|
+
}).then(moveResults => {
|
195
|
+
if (moveResults.success) {
|
196
|
+
resolve(createResults);
|
197
|
+
} else {
|
198
|
+
reject({ success: false });
|
199
|
+
}
|
200
|
+
});
|
201
|
+
} else {
|
202
|
+
reject({ success: false });
|
203
|
+
}
|
204
|
+
});
|
205
|
+
});
|
206
|
+
}
|
207
|
+
}
|
@@ -0,0 +1,353 @@
|
|
1
|
+
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
|
2
|
+
* Apache-2.0 */
|
3
|
+
|
4
|
+
import * as fetchMock from "fetch-mock";
|
5
|
+
|
6
|
+
import { addToServiceDefinition } from "../src/addTo";
|
7
|
+
|
8
|
+
import {
|
9
|
+
AddToFeatureServiceSuccessResponseFredAndGinger,
|
10
|
+
AddToFeatureServiceSuccessResponseFayardAndHarold,
|
11
|
+
AddToFeatureServiceSuccessResponseCydAndGene,
|
12
|
+
AddToFeatureServiceError
|
13
|
+
} from "./mocks/service";
|
14
|
+
|
15
|
+
import { layerDefinitionSid } from "./mocks/layerDefinition";
|
16
|
+
|
17
|
+
import { UserSession } from "@esri/arcgis-rest-auth";
|
18
|
+
import { TOMORROW } from "@esri/arcgis-rest-auth/test/utils";
|
19
|
+
import { encodeParam, ErrorTypes } from "@esri/arcgis-rest-request";
|
20
|
+
import { ILayer, ITable } from "@esri/arcgis-rest-common-types";
|
21
|
+
|
22
|
+
describe("add to feature service", () => {
|
23
|
+
afterEach(fetchMock.restore);
|
24
|
+
|
25
|
+
describe("Authenticated methods", () => {
|
26
|
+
// setup a UserSession to use in all these tests
|
27
|
+
const MOCK_USER_SESSION = new UserSession({
|
28
|
+
clientId: "clientId",
|
29
|
+
redirectUri: "https://example-app.com/redirect-uri",
|
30
|
+
token: "fake-token",
|
31
|
+
tokenExpires: TOMORROW,
|
32
|
+
refreshToken: "refreshToken",
|
33
|
+
refreshTokenExpires: TOMORROW,
|
34
|
+
refreshTokenTTL: 1440,
|
35
|
+
username: "casey",
|
36
|
+
password: "123456",
|
37
|
+
portal: "https://myorg.maps.arcgis.com/sharing/rest"
|
38
|
+
});
|
39
|
+
|
40
|
+
const MOCK_USER_REQOPTS = {
|
41
|
+
authentication: MOCK_USER_SESSION
|
42
|
+
};
|
43
|
+
|
44
|
+
const layerDescriptionFred: ILayer = {
|
45
|
+
name: "Fred",
|
46
|
+
id: "1899",
|
47
|
+
layerType: "Feature Layer"
|
48
|
+
};
|
49
|
+
|
50
|
+
const layerDescriptionGinger: ILayer = {
|
51
|
+
name: "Ginger",
|
52
|
+
id: "1911",
|
53
|
+
layerType: "Feature Layer"
|
54
|
+
};
|
55
|
+
|
56
|
+
const layerDescriptionCyd: ILayer = {
|
57
|
+
name: "Cyd",
|
58
|
+
id: "1922",
|
59
|
+
layerType: "Feature Layer"
|
60
|
+
};
|
61
|
+
|
62
|
+
const layerDescriptionFail: ILayer = {
|
63
|
+
name: "",
|
64
|
+
id: "",
|
65
|
+
layerType: "Feature Layer"
|
66
|
+
};
|
67
|
+
|
68
|
+
const tableDescriptionFayard: ITable = {
|
69
|
+
name: "Fayard",
|
70
|
+
id: "1914"
|
71
|
+
};
|
72
|
+
|
73
|
+
const tableDescriptionHarold: ITable = {
|
74
|
+
name: "Harold",
|
75
|
+
id: "1921"
|
76
|
+
};
|
77
|
+
|
78
|
+
const tableDescriptionGene: ITable = {
|
79
|
+
name: "Gene",
|
80
|
+
id: "1912"
|
81
|
+
};
|
82
|
+
|
83
|
+
const tableDescriptionFail: ITable = {
|
84
|
+
name: "",
|
85
|
+
id: ""
|
86
|
+
};
|
87
|
+
|
88
|
+
it("should add a pair of layers", done => {
|
89
|
+
fetchMock.once("*", AddToFeatureServiceSuccessResponseFredAndGinger);
|
90
|
+
|
91
|
+
addToServiceDefinition(
|
92
|
+
"https://services1.arcgis.com/ORG/arcgis/rest/services/FEATURE_SERVICE/FeatureServer",
|
93
|
+
{
|
94
|
+
layers: [layerDescriptionFred, layerDescriptionGinger],
|
95
|
+
...MOCK_USER_REQOPTS
|
96
|
+
}
|
97
|
+
)
|
98
|
+
.then(
|
99
|
+
response => {
|
100
|
+
// Check service call
|
101
|
+
expect(fetchMock.called()).toEqual(true);
|
102
|
+
const [url, options]: [string, RequestInit] = fetchMock.lastCall(
|
103
|
+
"*"
|
104
|
+
);
|
105
|
+
|
106
|
+
expect(url).toEqual(
|
107
|
+
"https://services1.arcgis.com/ORG/arcgis/rest/admin/services/FEATURE_SERVICE/FeatureServer/addToDefinition"
|
108
|
+
);
|
109
|
+
expect(options.method).toBe("POST");
|
110
|
+
expect(options.body).toContain("f=json");
|
111
|
+
expect(options.body).toContain(encodeParam("token", "fake-token"));
|
112
|
+
expect(options.body).toContain(
|
113
|
+
encodeParam(
|
114
|
+
"addToDefinition",
|
115
|
+
JSON.stringify({
|
116
|
+
layers: [layerDescriptionFred, layerDescriptionGinger]
|
117
|
+
})
|
118
|
+
)
|
119
|
+
);
|
120
|
+
|
121
|
+
// Check response
|
122
|
+
expect(response).toEqual(
|
123
|
+
AddToFeatureServiceSuccessResponseFredAndGinger
|
124
|
+
);
|
125
|
+
|
126
|
+
done();
|
127
|
+
},
|
128
|
+
() => {
|
129
|
+
fail(); // call is supposed to succeed
|
130
|
+
}
|
131
|
+
)
|
132
|
+
.catch(e => {
|
133
|
+
fail(e);
|
134
|
+
});
|
135
|
+
});
|
136
|
+
|
137
|
+
it("should add a pair of tables", done => {
|
138
|
+
fetchMock.once("*", AddToFeatureServiceSuccessResponseFayardAndHarold);
|
139
|
+
|
140
|
+
addToServiceDefinition(
|
141
|
+
"https://services1.arcgis.com/ORG/arcgis/rest/services/FEATURE_SERVICE/FeatureServer",
|
142
|
+
{
|
143
|
+
tables: [tableDescriptionFayard, tableDescriptionHarold],
|
144
|
+
...MOCK_USER_REQOPTS
|
145
|
+
}
|
146
|
+
)
|
147
|
+
.then(
|
148
|
+
response => {
|
149
|
+
// Check service call
|
150
|
+
expect(fetchMock.called()).toEqual(true);
|
151
|
+
const [url, options]: [string, RequestInit] = fetchMock.lastCall(
|
152
|
+
"*"
|
153
|
+
);
|
154
|
+
|
155
|
+
expect(url).toEqual(
|
156
|
+
"https://services1.arcgis.com/ORG/arcgis/rest/admin/services/FEATURE_SERVICE/FeatureServer/addToDefinition"
|
157
|
+
);
|
158
|
+
expect(options.method).toBe("POST");
|
159
|
+
expect(options.body).toContain("f=json");
|
160
|
+
expect(options.body).toContain(encodeParam("token", "fake-token"));
|
161
|
+
expect(options.body).toContain(
|
162
|
+
encodeParam(
|
163
|
+
"addToDefinition",
|
164
|
+
JSON.stringify({
|
165
|
+
tables: [tableDescriptionFayard, tableDescriptionHarold]
|
166
|
+
})
|
167
|
+
)
|
168
|
+
);
|
169
|
+
|
170
|
+
// Check response
|
171
|
+
expect(response).toEqual(
|
172
|
+
AddToFeatureServiceSuccessResponseFayardAndHarold
|
173
|
+
);
|
174
|
+
|
175
|
+
done();
|
176
|
+
},
|
177
|
+
() => {
|
178
|
+
fail(); // call is supposed to succeed
|
179
|
+
}
|
180
|
+
)
|
181
|
+
.catch(e => {
|
182
|
+
fail(e);
|
183
|
+
});
|
184
|
+
});
|
185
|
+
|
186
|
+
it("should add a layer and a table", done => {
|
187
|
+
fetchMock.once("*", AddToFeatureServiceSuccessResponseCydAndGene);
|
188
|
+
|
189
|
+
addToServiceDefinition(
|
190
|
+
"https://services1.arcgis.com/ORG/arcgis/rest/services/FEATURE_SERVICE/FeatureServer",
|
191
|
+
{
|
192
|
+
layers: [layerDescriptionCyd],
|
193
|
+
tables: [tableDescriptionGene],
|
194
|
+
...MOCK_USER_REQOPTS
|
195
|
+
}
|
196
|
+
)
|
197
|
+
.then(response => {
|
198
|
+
// Check service call
|
199
|
+
expect(fetchMock.called()).toEqual(true);
|
200
|
+
const [url, options]: [string, RequestInit] = fetchMock.lastCall("*");
|
201
|
+
|
202
|
+
expect(url).toEqual(
|
203
|
+
"https://services1.arcgis.com/ORG/arcgis/rest/admin/services/FEATURE_SERVICE/FeatureServer/addToDefinition"
|
204
|
+
);
|
205
|
+
expect(options.method).toBe("POST");
|
206
|
+
expect(options.body).toContain("f=json");
|
207
|
+
expect(options.body).toContain(encodeParam("token", "fake-token"));
|
208
|
+
expect(options.body).toContain(
|
209
|
+
encodeParam(
|
210
|
+
"addToDefinition",
|
211
|
+
JSON.stringify({
|
212
|
+
layers: [layerDescriptionCyd],
|
213
|
+
tables: [tableDescriptionGene]
|
214
|
+
})
|
215
|
+
)
|
216
|
+
);
|
217
|
+
|
218
|
+
// Check response
|
219
|
+
expect(response).toEqual(
|
220
|
+
AddToFeatureServiceSuccessResponseCydAndGene
|
221
|
+
);
|
222
|
+
done();
|
223
|
+
})
|
224
|
+
.catch(e => {
|
225
|
+
fail(e);
|
226
|
+
});
|
227
|
+
});
|
228
|
+
|
229
|
+
it("should add a layer definition", done => {
|
230
|
+
fetchMock.once("*", AddToFeatureServiceSuccessResponseCydAndGene);
|
231
|
+
|
232
|
+
addToServiceDefinition(
|
233
|
+
"https://services1.arcgis.com/ORG/arcgis/rest/services/FEATURE_SERVICE/FeatureServer",
|
234
|
+
{
|
235
|
+
layers: [layerDefinitionSid],
|
236
|
+
...MOCK_USER_REQOPTS
|
237
|
+
}
|
238
|
+
)
|
239
|
+
.then(response => {
|
240
|
+
// Check service call
|
241
|
+
expect(fetchMock.called()).toEqual(true);
|
242
|
+
const [url, options]: [string, RequestInit] = fetchMock.lastCall("*");
|
243
|
+
|
244
|
+
expect(url).toEqual(
|
245
|
+
"https://services1.arcgis.com/ORG/arcgis/rest/admin/services/FEATURE_SERVICE/FeatureServer/addToDefinition"
|
246
|
+
);
|
247
|
+
expect(options.method).toBe("POST");
|
248
|
+
expect(options.body).toContain("f=json");
|
249
|
+
expect(options.body).toContain(encodeParam("token", "fake-token"));
|
250
|
+
expect(options.body).toContain(
|
251
|
+
encodeParam(
|
252
|
+
"addToDefinition",
|
253
|
+
JSON.stringify({
|
254
|
+
layers: [layerDefinitionSid]
|
255
|
+
})
|
256
|
+
)
|
257
|
+
);
|
258
|
+
|
259
|
+
// Check response
|
260
|
+
expect(response).toEqual(
|
261
|
+
AddToFeatureServiceSuccessResponseCydAndGene
|
262
|
+
);
|
263
|
+
done();
|
264
|
+
})
|
265
|
+
.catch(e => {
|
266
|
+
fail(e);
|
267
|
+
});
|
268
|
+
});
|
269
|
+
|
270
|
+
it("should fail to add a bad layer", done => {
|
271
|
+
fetchMock.once("*", AddToFeatureServiceError);
|
272
|
+
|
273
|
+
addToServiceDefinition(
|
274
|
+
"https://services1.arcgis.com/ORG/arcgis/rest/services/FEATURE_SERVICE/FeatureServer",
|
275
|
+
{
|
276
|
+
layers: [layerDescriptionFail],
|
277
|
+
...MOCK_USER_REQOPTS
|
278
|
+
}
|
279
|
+
).catch(error => {
|
280
|
+
expect(error.name).toBe(ErrorTypes.ArcGISRequestError);
|
281
|
+
expect(error.message).toBe(
|
282
|
+
"400: Unable to add feature service definition."
|
283
|
+
);
|
284
|
+
expect(error instanceof Error).toBeTruthy();
|
285
|
+
expect(error.url).toBe(
|
286
|
+
"https://services1.arcgis.com/ORG/arcgis/rest/admin/services/FEATURE_SERVICE/FeatureServer/addToDefinition"
|
287
|
+
);
|
288
|
+
// params added internally aren't surfaced in the error
|
289
|
+
expect(error.options.params.addToDefinition).toEqual({
|
290
|
+
layers: [layerDescriptionFail]
|
291
|
+
});
|
292
|
+
expect(error.options.httpMethod).toEqual("POST");
|
293
|
+
done();
|
294
|
+
});
|
295
|
+
});
|
296
|
+
|
297
|
+
it("should fail to add a bad table", done => {
|
298
|
+
fetchMock.once("*", AddToFeatureServiceError);
|
299
|
+
|
300
|
+
addToServiceDefinition(
|
301
|
+
"https://services1.arcgis.com/ORG/arcgis/rest/services/FEATURE_SERVICE/FeatureServer",
|
302
|
+
{
|
303
|
+
tables: [tableDescriptionFail],
|
304
|
+
...MOCK_USER_REQOPTS
|
305
|
+
}
|
306
|
+
).catch(error => {
|
307
|
+
expect(error.name).toBe(ErrorTypes.ArcGISRequestError);
|
308
|
+
expect(error.message).toBe(
|
309
|
+
"400: Unable to add feature service definition."
|
310
|
+
);
|
311
|
+
expect(error instanceof Error).toBeTruthy();
|
312
|
+
expect(error.url).toBe(
|
313
|
+
"https://services1.arcgis.com/ORG/arcgis/rest/admin/services/FEATURE_SERVICE/FeatureServer/addToDefinition"
|
314
|
+
);
|
315
|
+
// params added internally aren't surfaced in the error
|
316
|
+
expect(error.options.params.addToDefinition).toEqual({
|
317
|
+
tables: [tableDescriptionFail]
|
318
|
+
});
|
319
|
+
expect(error.options.httpMethod).toEqual("POST");
|
320
|
+
done();
|
321
|
+
});
|
322
|
+
});
|
323
|
+
|
324
|
+
it("should fail to add a bad layer and a bad table", done => {
|
325
|
+
fetchMock.once("*", AddToFeatureServiceError);
|
326
|
+
|
327
|
+
addToServiceDefinition(
|
328
|
+
"https://services1.arcgis.com/ORG/arcgis/rest/services/FEATURE_SERVICE/FeatureServer",
|
329
|
+
{
|
330
|
+
layers: [layerDescriptionFail],
|
331
|
+
tables: [tableDescriptionFail],
|
332
|
+
...MOCK_USER_REQOPTS
|
333
|
+
}
|
334
|
+
).catch(error => {
|
335
|
+
expect(error.name).toBe(ErrorTypes.ArcGISRequestError);
|
336
|
+
expect(error.message).toBe(
|
337
|
+
"400: Unable to add feature service definition."
|
338
|
+
);
|
339
|
+
expect(error instanceof Error).toBeTruthy();
|
340
|
+
expect(error.url).toBe(
|
341
|
+
"https://services1.arcgis.com/ORG/arcgis/rest/admin/services/FEATURE_SERVICE/FeatureServer/addToDefinition"
|
342
|
+
);
|
343
|
+
// params added internally aren't surfaced in the error
|
344
|
+
expect(error.options.params.addToDefinition).toEqual({
|
345
|
+
tables: [tableDescriptionFail],
|
346
|
+
layers: [layerDescriptionFail]
|
347
|
+
});
|
348
|
+
expect(error.options.httpMethod).toEqual("POST");
|
349
|
+
done();
|
350
|
+
});
|
351
|
+
});
|
352
|
+
}); // auth requests
|
353
|
+
});
|