aspernaturalias 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 +31 -0
- package/.vscode/launch.json +24 -0
- package/.vscode/settings.json +3 -0
- package/codecov.yml +3 -0
- package/demos/ago-node-cli/README.md +29 -0
- package/demos/ago-node-cli/ago.js +33 -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 +152 -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 +94 -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 +413 -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/node-cli-item-management/README.md +10 -0
- package/demos/node-cli-item-management/index.js +238 -0
- package/demos/node-cli-item-management/package-lock.json +152 -0
- package/demos/node-cli-item-management/package.json +27 -0
- package/demos/node-cli-item-management/screenshot.png +0 -0
- package/demos/oauth2-browser/README.md +14 -0
- package/demos/oauth2-browser/authenticate.html +30 -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 +22 -0
- package/demos/oauth2-browser-retry/index.html +116 -0
- package/demos/oauth2-browser-retry/logo.svg +4 -0
- package/demos/stream-response-to-file/README.md +7 -0
- package/demos/stream-response-to-file/index.js +36 -0
- package/demos/stream-response-to-file/output/.gitkeep +0 -0
- package/demos/stream-response-to-file/package-lock.json +60 -0
- package/demos/stream-response-to-file/package.json +33 -0
- package/demos/tree-shaking-rollup/.babelrc +3 -0
- package/demos/tree-shaking-rollup/README.md +9 -0
- package/demos/tree-shaking-rollup/index.html +11 -0
- package/demos/tree-shaking-rollup/package-lock.json +2225 -0
- package/demos/tree-shaking-rollup/package.json +25 -0
- package/demos/tree-shaking-rollup/rollup.config.js +17 -0
- package/demos/tree-shaking-rollup/src/index.js +8 -0
- package/demos/tree-shaking-webpack/README.md +9 -0
- package/demos/tree-shaking-webpack/index.html +11 -0
- package/demos/tree-shaking-webpack/package-lock.json +4595 -0
- package/demos/tree-shaking-webpack/package.json +24 -0
- package/demos/tree-shaking-webpack/src/index.js +10 -0
- package/demos/tree-shaking-webpack/webpack.config.js +27 -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 +305 -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/demos/webmap-checker-sapper/.env.example +5 -0
- package/demos/webmap-checker-sapper/README.md +123 -0
- package/demos/webmap-checker-sapper/appveyor.yml +18 -0
- package/demos/webmap-checker-sapper/cypress/fixtures/example.json +5 -0
- package/demos/webmap-checker-sapper/cypress/integration/spec.js +19 -0
- package/demos/webmap-checker-sapper/cypress/plugins/index.js +17 -0
- package/demos/webmap-checker-sapper/cypress/support/commands.js +25 -0
- package/demos/webmap-checker-sapper/cypress/support/index.js +20 -0
- package/demos/webmap-checker-sapper/cypress.json +4 -0
- package/demos/webmap-checker-sapper/package-lock.json +3851 -0
- package/demos/webmap-checker-sapper/package.json +50 -0
- package/demos/webmap-checker-sapper/rollup.config.js +87 -0
- package/demos/webmap-checker-sapper/src/client.js +20 -0
- package/demos/webmap-checker-sapper/src/components/LayerStatus.html +108 -0
- package/demos/webmap-checker-sapper/src/components/Nav.html +21 -0
- package/demos/webmap-checker-sapper/src/components/WebMap.html +62 -0
- package/demos/webmap-checker-sapper/src/routes/_error.html +41 -0
- package/demos/webmap-checker-sapper/src/routes/_layout.html +21 -0
- package/demos/webmap-checker-sapper/src/routes/auth/authorize.js +18 -0
- package/demos/webmap-checker-sapper/src/routes/auth/exchange-token.js +20 -0
- package/demos/webmap-checker-sapper/src/routes/auth/post-sign-in.js +24 -0
- package/demos/webmap-checker-sapper/src/routes/auth/sign-out.js +10 -0
- package/demos/webmap-checker-sapper/src/routes/index.html +20 -0
- package/demos/webmap-checker-sapper/src/routes/webmaps/[webmapId].html +83 -0
- package/demos/webmap-checker-sapper/src/routes/webmaps/index.html +59 -0
- package/demos/webmap-checker-sapper/src/server.js +101 -0
- package/demos/webmap-checker-sapper/src/service-worker.js +82 -0
- package/demos/webmap-checker-sapper/src/template.html +33 -0
- package/demos/webmap-checker-sapper/src/userInfoMiddleware.js +21 -0
- package/demos/webmap-checker-sapper/src/utils.js +33 -0
- package/demos/webmap-checker-sapper/static/favicon.png +0 -0
- package/demos/webmap-checker-sapper/static/global.css +36 -0
- package/demos/webmap-checker-sapper/static/manifest.json +20 -0
- package/demos/webmap-checker-sapper/static/svelte-logo-192.png +0 -0
- package/demos/webmap-checker-sapper/static/svelte-logo-512.png +0 -0
- package/docs/FAQ.md +48 -0
- package/docs/HISTORY.md +62 -0
- package/docs/acetate.config.js +262 -0
- package/docs/build-typedoc.js +434 -0
- package/docs/generate-srihashes.js +53 -0
- package/docs/src/_layout.html +86 -0
- package/docs/src/api/_declaration.html +600 -0
- package/docs/src/api/_layout.html +204 -0
- package/docs/src/api/_package.html +38 -0
- package/docs/src/api/index.html +16 -0
- package/docs/src/guides/_layout.html +24 -0
- package/docs/src/guides/amd-requirejs-dojo.md +40 -0
- package/docs/src/guides/browser-authentication.md +41 -0
- package/docs/src/guides/bundlers.md +52 -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 +38 -0
- package/docs/src/guides/index.md +59 -0
- package/docs/src/guides/node.md +87 -0
- package/docs/src/guides/package-overview.md +111 -0
- package/docs/src/guides/server-authentication.md +9 -0
- package/docs/src/guides/whats-new-v2-0.md +305 -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 +242 -0
- package/docs/src/srihashes.json +12 -0
- package/jasmine.json +7 -0
- package/karma.conf.js +106 -0
- package/lerna.json +8 -0
- package/notes/README.md +88 -0
- package/package.json +129 -0
- package/packages/arcgis-rest-auth/README.md +71 -0
- package/packages/arcgis-rest-auth/package-lock.json +11 -0
- package/packages/arcgis-rest-auth/package.json +69 -0
- package/packages/arcgis-rest-auth/src/ApplicationSession.ts +122 -0
- package/packages/arcgis-rest-auth/src/UserSession.ts +997 -0
- package/packages/arcgis-rest-auth/src/authenticated-request-options.ts +24 -0
- package/packages/arcgis-rest-auth/src/fetch-token.ts +50 -0
- package/packages/arcgis-rest-auth/src/generate-token.ts +35 -0
- package/packages/arcgis-rest-auth/src/index.ts +9 -0
- package/packages/arcgis-rest-auth/test/ApplicationSession.test.ts +124 -0
- package/packages/arcgis-rest-auth/test/UserSession.test.ts +1315 -0
- package/packages/arcgis-rest-auth/test/fetchToken.test.ts +112 -0
- package/packages/arcgis-rest-auth/test/generateToken.test.ts +102 -0
- package/packages/arcgis-rest-auth/test/utils.ts +14 -0
- package/packages/arcgis-rest-auth/tsconfig.json +6 -0
- package/packages/arcgis-rest-feature-layer/README.md +77 -0
- package/packages/arcgis-rest-feature-layer/package-lock.json +11 -0
- package/packages/arcgis-rest-feature-layer/package.json +64 -0
- package/packages/arcgis-rest-feature-layer/src/add.ts +56 -0
- package/packages/arcgis-rest-feature-layer/src/addAttachment.ts +53 -0
- package/packages/arcgis-rest-feature-layer/src/decodeValues.ts +124 -0
- package/packages/arcgis-rest-feature-layer/src/delete.ts +61 -0
- package/packages/arcgis-rest-feature-layer/src/deleteAttachments.ts +52 -0
- package/packages/arcgis-rest-feature-layer/src/getAttachments.ts +55 -0
- package/packages/arcgis-rest-feature-layer/src/getLayer.ts +24 -0
- package/packages/arcgis-rest-feature-layer/src/helpers.ts +55 -0
- package/packages/arcgis-rest-feature-layer/src/index.ts +28 -0
- package/packages/arcgis-rest-feature-layer/src/query.ts +203 -0
- package/packages/arcgis-rest-feature-layer/src/queryRelated.ts +89 -0
- package/packages/arcgis-rest-feature-layer/src/update.ts +56 -0
- package/packages/arcgis-rest-feature-layer/src/updateAttachment.ts +59 -0
- package/packages/arcgis-rest-feature-layer/test/attachments.test.ts +202 -0
- package/packages/arcgis-rest-feature-layer/test/crud.test.ts +130 -0
- package/packages/arcgis-rest-feature-layer/test/decodeValues.test.ts +67 -0
- package/packages/arcgis-rest-feature-layer/test/getLayer.test.ts +31 -0
- package/packages/arcgis-rest-feature-layer/test/mocks/cvdQueryResponse.ts +225 -0
- package/packages/arcgis-rest-feature-layer/test/mocks/feature.ts +281 -0
- package/packages/arcgis-rest-feature-layer/test/mocks/fields.ts +779 -0
- package/packages/arcgis-rest-feature-layer/test/mocks/foo.txt +1 -0
- package/packages/arcgis-rest-feature-layer/test/mocks/service.ts +259 -0
- package/packages/arcgis-rest-feature-layer/test/query.test.ts +168 -0
- package/packages/arcgis-rest-feature-layer/tsconfig.json +6 -0
- package/packages/arcgis-rest-geocoding/README.md +86 -0
- package/packages/arcgis-rest-geocoding/package-lock.json +11 -0
- package/packages/arcgis-rest-geocoding/package.json +64 -0
- package/packages/arcgis-rest-geocoding/src/bulk.ts +105 -0
- package/packages/arcgis-rest-geocoding/src/geocode.ts +130 -0
- package/packages/arcgis-rest-geocoding/src/helpers.ts +54 -0
- package/packages/arcgis-rest-geocoding/src/index.ts +15 -0
- package/packages/arcgis-rest-geocoding/src/reverse.ts +84 -0
- package/packages/arcgis-rest-geocoding/src/suggest.ts +45 -0
- package/packages/arcgis-rest-geocoding/test/bulk.test.ts +151 -0
- package/packages/arcgis-rest-geocoding/test/geocode.test.ts +212 -0
- package/packages/arcgis-rest-geocoding/test/helpers.test.ts +85 -0
- package/packages/arcgis-rest-geocoding/test/mocks/responses.ts +637 -0
- package/packages/arcgis-rest-geocoding/test/reverse.test.ts +126 -0
- package/packages/arcgis-rest-geocoding/test/suggest.test.ts +53 -0
- package/packages/arcgis-rest-geocoding/tsconfig.json +6 -0
- package/packages/arcgis-rest-portal/README.md +73 -0
- package/packages/arcgis-rest-portal/package-lock.json +11 -0
- package/packages/arcgis-rest-portal/package.json +64 -0
- package/packages/arcgis-rest-portal/src/groups/create.ts +43 -0
- package/packages/arcgis-rest-portal/src/groups/get.ts +99 -0
- package/packages/arcgis-rest-portal/src/groups/helpers.ts +14 -0
- package/packages/arcgis-rest-portal/src/groups/join.ts +57 -0
- package/packages/arcgis-rest-portal/src/groups/notification.ts +77 -0
- package/packages/arcgis-rest-portal/src/groups/protect.ts +56 -0
- package/packages/arcgis-rest-portal/src/groups/remove.ts +32 -0
- package/packages/arcgis-rest-portal/src/groups/search.ts +25 -0
- package/packages/arcgis-rest-portal/src/groups/update.ts +39 -0
- package/packages/arcgis-rest-portal/src/index.ts +48 -0
- package/packages/arcgis-rest-portal/src/items/add.ts +137 -0
- package/packages/arcgis-rest-portal/src/items/create.ts +128 -0
- package/packages/arcgis-rest-portal/src/items/get.ts +177 -0
- package/packages/arcgis-rest-portal/src/items/helpers.ts +193 -0
- package/packages/arcgis-rest-portal/src/items/protect.ts +39 -0
- package/packages/arcgis-rest-portal/src/items/remove.ts +131 -0
- package/packages/arcgis-rest-portal/src/items/search.ts +25 -0
- package/packages/arcgis-rest-portal/src/items/update.ts +145 -0
- package/packages/arcgis-rest-portal/src/sharing/access.ts +84 -0
- package/packages/arcgis-rest-portal/src/sharing/group-sharing.ts +210 -0
- package/packages/arcgis-rest-portal/src/sharing/helpers.ts +84 -0
- package/packages/arcgis-rest-portal/src/users/get-user-url.ts +18 -0
- package/packages/arcgis-rest-portal/src/users/get-user.ts +58 -0
- package/packages/arcgis-rest-portal/src/users/invitation.ts +162 -0
- package/packages/arcgis-rest-portal/src/users/notification.ts +70 -0
- package/packages/arcgis-rest-portal/src/users/update.ts +66 -0
- package/packages/arcgis-rest-portal/src/util/SearchQueryBuilder.ts +374 -0
- package/packages/arcgis-rest-portal/src/util/generic-search.ts +67 -0
- package/packages/arcgis-rest-portal/src/util/get-portal-url.ts +27 -0
- package/packages/arcgis-rest-portal/src/util/get-portal.ts +52 -0
- package/packages/arcgis-rest-portal/src/util/search.ts +38 -0
- package/packages/arcgis-rest-portal/test/groups/crud.test.ts +180 -0
- package/packages/arcgis-rest-portal/test/groups/get.test.ts +101 -0
- package/packages/arcgis-rest-portal/test/groups/join.test.ts +72 -0
- package/packages/arcgis-rest-portal/test/groups/notification.test.ts +112 -0
- package/packages/arcgis-rest-portal/test/groups/protect.test.ts +72 -0
- package/packages/arcgis-rest-portal/test/groups/search.test.ts +110 -0
- package/packages/arcgis-rest-portal/test/items/add.test.ts +321 -0
- package/packages/arcgis-rest-portal/test/items/create.test.ts +375 -0
- package/packages/arcgis-rest-portal/test/items/get.test.ts +309 -0
- package/packages/arcgis-rest-portal/test/items/protect.test.ts +122 -0
- package/packages/arcgis-rest-portal/test/items/remove.test.ts +238 -0
- package/packages/arcgis-rest-portal/test/items/search.test.ts +272 -0
- package/packages/arcgis-rest-portal/test/items/update.test.ts +515 -0
- package/packages/arcgis-rest-portal/test/mocks/groups/responses.ts +144 -0
- package/packages/arcgis-rest-portal/test/mocks/items/foo.zip +0 -0
- package/packages/arcgis-rest-portal/test/mocks/items/item.ts +122 -0
- package/packages/arcgis-rest-portal/test/mocks/items/resources.ts +31 -0
- package/packages/arcgis-rest-portal/test/mocks/items/search.ts +121 -0
- package/packages/arcgis-rest-portal/test/mocks/portal/response.ts +112 -0
- package/packages/arcgis-rest-portal/test/mocks/sharing/sharing.ts +18 -0
- package/packages/arcgis-rest-portal/test/mocks/users/invitation.ts +70 -0
- package/packages/arcgis-rest-portal/test/mocks/users/notification.ts +34 -0
- package/packages/arcgis-rest-portal/test/mocks/users/user.ts +173 -0
- package/packages/arcgis-rest-portal/test/sharing/access.test.ts +162 -0
- package/packages/arcgis-rest-portal/test/sharing/group-sharing.test.ts +650 -0
- package/packages/arcgis-rest-portal/test/sharing/helpers.test.ts +55 -0
- package/packages/arcgis-rest-portal/test/users/get-user-url.test.ts +40 -0
- package/packages/arcgis-rest-portal/test/users/get-user.test.ts +90 -0
- package/packages/arcgis-rest-portal/test/users/invitation.test.ts +127 -0
- package/packages/arcgis-rest-portal/test/users/notification.test.ts +77 -0
- package/packages/arcgis-rest-portal/test/users/update.test.ts +151 -0
- package/packages/arcgis-rest-portal/test/util/SearchQueryBuilder.test.ts +340 -0
- package/packages/arcgis-rest-portal/test/util/get-portal-url.test.ts +37 -0
- package/packages/arcgis-rest-portal/test/util/portal.test.ts +97 -0
- package/packages/arcgis-rest-portal/tsconfig.json +6 -0
- package/packages/arcgis-rest-request/README.md +72 -0
- package/packages/arcgis-rest-request/package-lock.json +11 -0
- package/packages/arcgis-rest-request/package.json +60 -0
- package/packages/arcgis-rest-request/src/index.ts +24 -0
- package/packages/arcgis-rest-request/src/request.ts +389 -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/GrantTypes.ts +5 -0
- package/packages/arcgis-rest-request/src/utils/HTTPMethods.ts +6 -0
- package/packages/arcgis-rest-request/src/utils/IAuthenticationManager.ts +21 -0
- package/packages/arcgis-rest-request/src/utils/IFetchTokenParams.ts +11 -0
- package/packages/arcgis-rest-request/src/utils/IGenerateTokenParams.ts +9 -0
- package/packages/arcgis-rest-request/src/utils/IParamBuilder.ts +3 -0
- package/packages/arcgis-rest-request/src/utils/IParams.ts +6 -0
- package/packages/arcgis-rest-request/src/utils/IParamsBuilder.ts +5 -0
- package/packages/arcgis-rest-request/src/utils/IRequestOptions.ts +43 -0
- package/packages/arcgis-rest-request/src/utils/ITokenRequestOptions.ts +9 -0
- package/packages/arcgis-rest-request/src/utils/ResponseFormats.ts +10 -0
- package/packages/arcgis-rest-request/src/utils/append-custom-params.ts +49 -0
- package/packages/arcgis-rest-request/src/utils/clean-url.ts +16 -0
- package/packages/arcgis-rest-request/src/utils/encode-form-data.ts +38 -0
- package/packages/arcgis-rest-request/src/utils/encode-query-string.ts +23 -0
- package/packages/arcgis-rest-request/src/utils/process-params.ts +109 -0
- package/packages/arcgis-rest-request/src/utils/retryAuthError.ts +10 -0
- package/packages/arcgis-rest-request/src/utils/warn.ts +11 -0
- package/packages/arcgis-rest-request/src/utils/with-options.ts +48 -0
- package/packages/arcgis-rest-request/test/mocks/errors.ts +76 -0
- package/packages/arcgis-rest-request/test/mocks/geojson-feature-collection.ts +13 -0
- package/packages/arcgis-rest-request/test/mocks/param-builder.ts +7 -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 +496 -0
- package/packages/arcgis-rest-request/test/utils/ArcGISAuthError.test.ts +191 -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/clean-url.test.ts +47 -0
- package/packages/arcgis-rest-request/test/utils/encode-form-data.test.ts +133 -0
- package/packages/arcgis-rest-request/test/utils/process-params.test.ts +193 -0
- package/packages/arcgis-rest-request/test/utils/with-options.test.ts +133 -0
- package/packages/arcgis-rest-request/tsconfig.json +4 -0
- package/packages/arcgis-rest-routing/README.md +75 -0
- package/packages/arcgis-rest-routing/package-lock.json +11 -0
- package/packages/arcgis-rest-routing/package.json +63 -0
- package/packages/arcgis-rest-routing/src/helpers.ts +16 -0
- package/packages/arcgis-rest-routing/src/index.ts +11 -0
- package/packages/arcgis-rest-routing/src/solveRoute.ts +124 -0
- package/packages/arcgis-rest-routing/test/mocks/responses.ts +825 -0
- package/packages/arcgis-rest-routing/test/solveRoute.test.ts +509 -0
- package/packages/arcgis-rest-routing/tsconfig.json +6 -0
- package/packages/arcgis-rest-service-admin/README.md +73 -0
- package/packages/arcgis-rest-service-admin/package-lock.json +11 -0
- package/packages/arcgis-rest-service-admin/package.json +65 -0
- package/packages/arcgis-rest-service-admin/src/addTo.ts +70 -0
- package/packages/arcgis-rest-service-admin/src/create.ts +213 -0
- package/packages/arcgis-rest-service-admin/src/index.ts +9 -0
- package/packages/arcgis-rest-service-admin/test/addTo.test.ts +350 -0
- package/packages/arcgis-rest-service-admin/test/create.test.ts +377 -0
- package/packages/arcgis-rest-service-admin/test/mocks/layerDefinition.ts +79 -0
- package/packages/arcgis-rest-service-admin/test/mocks/move.ts +11 -0
- package/packages/arcgis-rest-service-admin/test/mocks/service.ts +69 -0
- package/packages/arcgis-rest-service-admin/tsconfig.json +6 -0
- package/packages/arcgis-rest-types/README.md +66 -0
- package/packages/arcgis-rest-types/package.json +54 -0
- package/packages/arcgis-rest-types/src/feature.ts +39 -0
- package/packages/arcgis-rest-types/src/geometry.ts +272 -0
- package/packages/arcgis-rest-types/src/group.ts +72 -0
- package/packages/arcgis-rest-types/src/index.ts +7 -0
- package/packages/arcgis-rest-types/src/item.ts +65 -0
- package/packages/arcgis-rest-types/src/symbol.ts +170 -0
- package/packages/arcgis-rest-types/src/user.ts +48 -0
- package/packages/arcgis-rest-types/src/webmap.ts +1345 -0
- package/packages/arcgis-rest-types/tsconfig.json +9 -0
- package/support/changelog.js +393 -0
- package/support/deploy-doc-site.js +16 -0
- package/support/dev.sh +6 -0
- package/support/publish.sh +47 -0
- package/support/test-helpers.js +9 -0
- package/tsconfig.json +63 -0
- package/tslint.json +16 -0
- package/umd-base-profile.js +81 -0
- package/umd-production-profile.js +13 -0
@@ -0,0 +1,650 @@
|
|
1
|
+
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
|
2
|
+
* Apache-2.0 */
|
3
|
+
|
4
|
+
import * as fetchMock from "fetch-mock";
|
5
|
+
import {
|
6
|
+
shareItemWithGroup,
|
7
|
+
unshareItemWithGroup
|
8
|
+
} from "../../src/sharing/group-sharing";
|
9
|
+
import { MOCK_USER_SESSION } from "../mocks/sharing/sharing";
|
10
|
+
import { TOMORROW } from "@esri/arcgis-rest-auth/test/utils";
|
11
|
+
|
12
|
+
import {
|
13
|
+
AnonUserResponse,
|
14
|
+
GroupNonMemberUserResponse,
|
15
|
+
GroupMemberUserResponse,
|
16
|
+
GroupAdminUserResponse,
|
17
|
+
OrgAdminUserResponse
|
18
|
+
} from "../mocks/users/user";
|
19
|
+
|
20
|
+
import { SearchResponse } from "../mocks/items/search";
|
21
|
+
|
22
|
+
const SharingResponse = {
|
23
|
+
notSharedWith: [] as any,
|
24
|
+
itemId: "n3v"
|
25
|
+
};
|
26
|
+
|
27
|
+
const FailedSharingResponse = {
|
28
|
+
notSharedWith: ["t6b"],
|
29
|
+
itemId: "n3v"
|
30
|
+
};
|
31
|
+
|
32
|
+
const UnsharingResponse = {
|
33
|
+
notUnsharedFrom: [] as any,
|
34
|
+
itemId: "a5b"
|
35
|
+
};
|
36
|
+
|
37
|
+
const CachedSharingResponse = {
|
38
|
+
notSharedWith: [] as any,
|
39
|
+
itemId: "a5b",
|
40
|
+
shortcut: true
|
41
|
+
};
|
42
|
+
|
43
|
+
const CachedUnsharingResponse = {
|
44
|
+
notUnsharedFrom: [] as any,
|
45
|
+
itemId: "n3v",
|
46
|
+
shortcut: true
|
47
|
+
};
|
48
|
+
|
49
|
+
const NoResultsSearchResponse = {
|
50
|
+
query: "",
|
51
|
+
total: 0,
|
52
|
+
start: 0,
|
53
|
+
num: 0,
|
54
|
+
nextStart: 0,
|
55
|
+
results: [] as any
|
56
|
+
};
|
57
|
+
|
58
|
+
export const GroupOwnerResponse = {
|
59
|
+
id: "tb6",
|
60
|
+
title: "fake group",
|
61
|
+
userMembership: {
|
62
|
+
memberType: "owner"
|
63
|
+
}
|
64
|
+
};
|
65
|
+
|
66
|
+
export const GroupMemberResponse = {
|
67
|
+
id: "tb6",
|
68
|
+
title: "fake group",
|
69
|
+
userMembership: {
|
70
|
+
memberType: "member"
|
71
|
+
}
|
72
|
+
};
|
73
|
+
|
74
|
+
export const GroupAdminResponse = {
|
75
|
+
id: "tb6",
|
76
|
+
title: "fake group",
|
77
|
+
userMembership: {
|
78
|
+
memberType: "admin"
|
79
|
+
}
|
80
|
+
};
|
81
|
+
|
82
|
+
export const GroupNoAccessResponse = {
|
83
|
+
error: {
|
84
|
+
code: 400,
|
85
|
+
messageCode: "COM_0003",
|
86
|
+
message: "Group does not exist or is inaccessible.",
|
87
|
+
details: [] as any[]
|
88
|
+
}
|
89
|
+
};
|
90
|
+
|
91
|
+
describe("shareItemWithGroup() ::", () => {
|
92
|
+
// make sure session doesnt cache metadata
|
93
|
+
beforeEach(done => {
|
94
|
+
fetchMock.post("https://myorg.maps.arcgis.com/sharing/rest/generateToken", {
|
95
|
+
token: "fake-token",
|
96
|
+
expires: TOMORROW.getTime(),
|
97
|
+
username: " jsmith"
|
98
|
+
});
|
99
|
+
|
100
|
+
// make sure session doesnt cache metadata
|
101
|
+
MOCK_USER_SESSION.refreshSession()
|
102
|
+
.then(() => done())
|
103
|
+
.catch();
|
104
|
+
});
|
105
|
+
|
106
|
+
afterEach(fetchMock.restore);
|
107
|
+
|
108
|
+
it("should share an item with a group by owner", done => {
|
109
|
+
// this is used when isOrgAdmin is called...
|
110
|
+
fetchMock.once(
|
111
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
112
|
+
GroupMemberUserResponse
|
113
|
+
);
|
114
|
+
// this is called when we try to determine if the item is already in the group
|
115
|
+
fetchMock.once(
|
116
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
117
|
+
SearchResponse
|
118
|
+
);
|
119
|
+
|
120
|
+
// called when we determine if the user is a member of the group
|
121
|
+
fetchMock.get(
|
122
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
123
|
+
GroupOwnerResponse
|
124
|
+
);
|
125
|
+
|
126
|
+
// the actual sharing request
|
127
|
+
fetchMock.once(
|
128
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/users/jsmith/items/n3v/share",
|
129
|
+
SharingResponse
|
130
|
+
);
|
131
|
+
|
132
|
+
shareItemWithGroup({
|
133
|
+
authentication: MOCK_USER_SESSION,
|
134
|
+
id: "n3v",
|
135
|
+
groupId: "t6b"
|
136
|
+
})
|
137
|
+
.then(response => {
|
138
|
+
expect(fetchMock.done()).toBeTruthy(
|
139
|
+
"All fetchMocks should have been called"
|
140
|
+
);
|
141
|
+
const [url, options]: [string, RequestInit] = fetchMock.lastCall(
|
142
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/users/jsmith/items/n3v/share"
|
143
|
+
);
|
144
|
+
expect(url).toBe(
|
145
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/users/jsmith/items/n3v/share"
|
146
|
+
);
|
147
|
+
expect(options.method).toBe("POST");
|
148
|
+
expect(response).toEqual(SharingResponse);
|
149
|
+
expect(options.body).toContain("f=json");
|
150
|
+
expect(options.body).toContain("groups=t6b");
|
151
|
+
done();
|
152
|
+
})
|
153
|
+
.catch(e => {
|
154
|
+
expect(fetchMock.done()).toBeTruthy(
|
155
|
+
"All fetchMocks should have been called"
|
156
|
+
);
|
157
|
+
fail(e);
|
158
|
+
});
|
159
|
+
});
|
160
|
+
|
161
|
+
it("should fail to share an item with a group if the request is made by a non-org admin and non-group member", done => {
|
162
|
+
fetchMock.once(
|
163
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
164
|
+
GroupNonMemberUserResponse
|
165
|
+
);
|
166
|
+
|
167
|
+
fetchMock.once(
|
168
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
169
|
+
SearchResponse
|
170
|
+
);
|
171
|
+
|
172
|
+
fetchMock.once(
|
173
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
174
|
+
GroupNonMemberUserResponse
|
175
|
+
);
|
176
|
+
|
177
|
+
shareItemWithGroup({
|
178
|
+
authentication: MOCK_USER_SESSION,
|
179
|
+
id: "n3v",
|
180
|
+
groupId: "t6b"
|
181
|
+
}).catch(e => {
|
182
|
+
expect(fetchMock.done()).toBeTruthy(
|
183
|
+
"All fetchMocks should have been called"
|
184
|
+
);
|
185
|
+
expect(e.message).toBe(
|
186
|
+
"This item can not be shared by jsmith as they are not a member of the specified group t6b."
|
187
|
+
);
|
188
|
+
done();
|
189
|
+
});
|
190
|
+
});
|
191
|
+
|
192
|
+
it("should share an item with a group by org administrator", done => {
|
193
|
+
fetchMock.once(
|
194
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
195
|
+
OrgAdminUserResponse
|
196
|
+
);
|
197
|
+
|
198
|
+
fetchMock.once(
|
199
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
200
|
+
NoResultsSearchResponse
|
201
|
+
);
|
202
|
+
|
203
|
+
// called when we determine if the user is a member of the group
|
204
|
+
fetchMock.get(
|
205
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
206
|
+
GroupOwnerResponse
|
207
|
+
);
|
208
|
+
|
209
|
+
fetchMock.once(
|
210
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share",
|
211
|
+
SharingResponse
|
212
|
+
);
|
213
|
+
|
214
|
+
shareItemWithGroup({
|
215
|
+
authentication: MOCK_USER_SESSION,
|
216
|
+
id: "n3v",
|
217
|
+
groupId: "t6b",
|
218
|
+
owner: "casey"
|
219
|
+
})
|
220
|
+
.then(response => {
|
221
|
+
expect(fetchMock.done()).toBeTruthy(
|
222
|
+
"All fetchMocks should have been called"
|
223
|
+
);
|
224
|
+
const [url, options]: [string, RequestInit] = fetchMock.lastCall(
|
225
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share"
|
226
|
+
);
|
227
|
+
expect(url).toBe(
|
228
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share"
|
229
|
+
);
|
230
|
+
expect(options.method).toBe("POST");
|
231
|
+
expect(response).toEqual(SharingResponse);
|
232
|
+
expect(options.body).toContain("f=json");
|
233
|
+
expect(options.body).toContain("groups=t6b");
|
234
|
+
done();
|
235
|
+
})
|
236
|
+
.catch(e => {
|
237
|
+
fail(e);
|
238
|
+
});
|
239
|
+
});
|
240
|
+
|
241
|
+
it("should share an item with a group by org administrator and pass through confirmItemControl", done => {
|
242
|
+
fetchMock.once(
|
243
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
244
|
+
OrgAdminUserResponse
|
245
|
+
);
|
246
|
+
|
247
|
+
fetchMock.once(
|
248
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
249
|
+
NoResultsSearchResponse
|
250
|
+
);
|
251
|
+
|
252
|
+
// called when we determine if the user is a member of the group
|
253
|
+
fetchMock.get(
|
254
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
255
|
+
GroupOwnerResponse
|
256
|
+
);
|
257
|
+
|
258
|
+
fetchMock.once(
|
259
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share",
|
260
|
+
SharingResponse
|
261
|
+
);
|
262
|
+
|
263
|
+
shareItemWithGroup({
|
264
|
+
authentication: MOCK_USER_SESSION,
|
265
|
+
id: "n3v",
|
266
|
+
groupId: "t6b",
|
267
|
+
owner: "casey",
|
268
|
+
confirmItemControl: true
|
269
|
+
})
|
270
|
+
.then(response => {
|
271
|
+
expect(fetchMock.done()).toBeTruthy(
|
272
|
+
"All fetchMocks should have been called"
|
273
|
+
);
|
274
|
+
const [url, options]: [string, RequestInit] = fetchMock.lastCall(
|
275
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share"
|
276
|
+
);
|
277
|
+
expect(url).toBe(
|
278
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share"
|
279
|
+
);
|
280
|
+
expect(options.method).toBe("POST");
|
281
|
+
expect(response).toEqual(SharingResponse);
|
282
|
+
expect(options.body).toContain("f=json");
|
283
|
+
expect(options.body).toContain("groups=t6b");
|
284
|
+
expect(options.body).toContain("confirmItemControl=true");
|
285
|
+
done();
|
286
|
+
})
|
287
|
+
.catch(e => {
|
288
|
+
fail(e);
|
289
|
+
});
|
290
|
+
});
|
291
|
+
|
292
|
+
it("should share an item with a group by group owner/admin", done => {
|
293
|
+
fetchMock.once(
|
294
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
295
|
+
GroupAdminUserResponse
|
296
|
+
);
|
297
|
+
|
298
|
+
fetchMock.once(
|
299
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
300
|
+
SearchResponse
|
301
|
+
);
|
302
|
+
|
303
|
+
// called when we determine if the user is a member of the group
|
304
|
+
fetchMock.get(
|
305
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
306
|
+
GroupOwnerResponse
|
307
|
+
);
|
308
|
+
|
309
|
+
fetchMock.once(
|
310
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share",
|
311
|
+
SharingResponse
|
312
|
+
);
|
313
|
+
|
314
|
+
shareItemWithGroup({
|
315
|
+
authentication: MOCK_USER_SESSION,
|
316
|
+
id: "n3v",
|
317
|
+
groupId: "t6b",
|
318
|
+
owner: "otherguy"
|
319
|
+
})
|
320
|
+
.then(response => {
|
321
|
+
expect(fetchMock.done()).toBeTruthy(
|
322
|
+
"All fetchMocks should have been called"
|
323
|
+
);
|
324
|
+
const [url, options]: [string, RequestInit] = fetchMock.lastCall(
|
325
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share"
|
326
|
+
);
|
327
|
+
expect(url).toBe(
|
328
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/n3v/share"
|
329
|
+
);
|
330
|
+
expect(options.method).toBe("POST");
|
331
|
+
expect(response).toEqual(SharingResponse);
|
332
|
+
expect(options.body).toContain("f=json");
|
333
|
+
expect(options.body).toContain("groups=t6b");
|
334
|
+
done();
|
335
|
+
})
|
336
|
+
.catch(e => {
|
337
|
+
expect(fetchMock.done()).toBeTruthy(
|
338
|
+
"All fetchMocks should have been called"
|
339
|
+
);
|
340
|
+
fail(e);
|
341
|
+
});
|
342
|
+
});
|
343
|
+
|
344
|
+
it("should mock the response if an item was previously shared with a group", done => {
|
345
|
+
fetchMock.once(
|
346
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
347
|
+
GroupAdminUserResponse
|
348
|
+
);
|
349
|
+
|
350
|
+
fetchMock.once(
|
351
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
352
|
+
SearchResponse
|
353
|
+
);
|
354
|
+
|
355
|
+
shareItemWithGroup({
|
356
|
+
authentication: MOCK_USER_SESSION,
|
357
|
+
id: "a5b",
|
358
|
+
groupId: "t6b"
|
359
|
+
})
|
360
|
+
.then(response => {
|
361
|
+
// no web request to share at all
|
362
|
+
expect(response).toEqual(CachedSharingResponse);
|
363
|
+
done();
|
364
|
+
})
|
365
|
+
.catch(e => {
|
366
|
+
expect(fetchMock.done()).toBeTruthy(
|
367
|
+
"All fetchMocks should have been called"
|
368
|
+
);
|
369
|
+
fail(e);
|
370
|
+
});
|
371
|
+
});
|
372
|
+
|
373
|
+
it("should throw if the person trying to share doesnt own the item, is not an admin or member of said group", done => {
|
374
|
+
fetchMock.once(
|
375
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
376
|
+
GroupMemberUserResponse
|
377
|
+
);
|
378
|
+
|
379
|
+
fetchMock.once(
|
380
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
381
|
+
SearchResponse
|
382
|
+
);
|
383
|
+
|
384
|
+
// called when we determine if the user is a member of the group
|
385
|
+
fetchMock.get(
|
386
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
387
|
+
GroupMemberResponse
|
388
|
+
);
|
389
|
+
|
390
|
+
shareItemWithGroup({
|
391
|
+
authentication: MOCK_USER_SESSION,
|
392
|
+
id: "n3v",
|
393
|
+
groupId: "t6b",
|
394
|
+
owner: "casey"
|
395
|
+
}).catch(e => {
|
396
|
+
expect(fetchMock.done()).toBeTruthy(
|
397
|
+
"All fetchMocks should have been called"
|
398
|
+
);
|
399
|
+
expect(e.message).toContain(
|
400
|
+
"This item can not be shared by jsmith as they are neither the owner, a groupAdmin of t6b, nor an org_admin."
|
401
|
+
);
|
402
|
+
done();
|
403
|
+
});
|
404
|
+
});
|
405
|
+
|
406
|
+
it("should throw if the response from the server is fishy", done => {
|
407
|
+
fetchMock.once(
|
408
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
409
|
+
GroupMemberUserResponse
|
410
|
+
);
|
411
|
+
|
412
|
+
fetchMock.once(
|
413
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
414
|
+
SearchResponse
|
415
|
+
);
|
416
|
+
|
417
|
+
fetchMock.once(
|
418
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/users/jsmith/items/n3v/share",
|
419
|
+
FailedSharingResponse
|
420
|
+
);
|
421
|
+
|
422
|
+
fetchMock.get(
|
423
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
424
|
+
GroupMemberResponse
|
425
|
+
);
|
426
|
+
|
427
|
+
shareItemWithGroup({
|
428
|
+
authentication: MOCK_USER_SESSION,
|
429
|
+
id: "n3v",
|
430
|
+
groupId: "t6b"
|
431
|
+
}).catch(e => {
|
432
|
+
expect(fetchMock.done()).toBeTruthy(
|
433
|
+
"All fetchMocks should have been called"
|
434
|
+
);
|
435
|
+
expect(e.message).toBe("Item n3v could not be shared to group t6b.");
|
436
|
+
done();
|
437
|
+
});
|
438
|
+
});
|
439
|
+
});
|
440
|
+
|
441
|
+
describe("unshareItemWithGroup() ::", () => {
|
442
|
+
// make sure session doesnt cache metadata
|
443
|
+
beforeEach(done => {
|
444
|
+
fetchMock.post("https://myorg.maps.arcgis.com/sharing/rest/generateToken", {
|
445
|
+
token: "fake-token",
|
446
|
+
expires: TOMORROW.getTime(),
|
447
|
+
username: " jsmith"
|
448
|
+
});
|
449
|
+
|
450
|
+
// make sure session doesnt cache metadata
|
451
|
+
MOCK_USER_SESSION.refreshSession()
|
452
|
+
.then(() => done())
|
453
|
+
.catch();
|
454
|
+
});
|
455
|
+
|
456
|
+
afterEach(fetchMock.restore);
|
457
|
+
|
458
|
+
it("should unshare an item with a group by owner", done => {
|
459
|
+
fetchMock.once(
|
460
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
461
|
+
GroupMemberUserResponse
|
462
|
+
);
|
463
|
+
|
464
|
+
fetchMock.once(
|
465
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
466
|
+
SearchResponse
|
467
|
+
);
|
468
|
+
|
469
|
+
fetchMock.once(
|
470
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/users/jsmith/items/a5b/unshare",
|
471
|
+
UnsharingResponse
|
472
|
+
);
|
473
|
+
|
474
|
+
fetchMock.get(
|
475
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
476
|
+
GroupOwnerResponse
|
477
|
+
);
|
478
|
+
|
479
|
+
unshareItemWithGroup({
|
480
|
+
authentication: MOCK_USER_SESSION,
|
481
|
+
id: "a5b",
|
482
|
+
groupId: "t6b"
|
483
|
+
})
|
484
|
+
.then(response => {
|
485
|
+
const [url, options]: [string, RequestInit] = fetchMock.lastCall(
|
486
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/users/jsmith/items/a5b/unshare"
|
487
|
+
);
|
488
|
+
expect(url).toBe(
|
489
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/users/jsmith/items/a5b/unshare"
|
490
|
+
);
|
491
|
+
expect(options.method).toBe("POST");
|
492
|
+
expect(response).toEqual(UnsharingResponse);
|
493
|
+
expect(options.body).toContain("f=json");
|
494
|
+
expect(options.body).toContain("groups=t6b");
|
495
|
+
done();
|
496
|
+
})
|
497
|
+
.catch(e => {
|
498
|
+
expect(fetchMock.done()).toBeTruthy(
|
499
|
+
"All fetchMocks should have been called"
|
500
|
+
);
|
501
|
+
fail(e);
|
502
|
+
});
|
503
|
+
});
|
504
|
+
|
505
|
+
it("should unshare an item with a group by org administrator", done => {
|
506
|
+
fetchMock.once(
|
507
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
508
|
+
OrgAdminUserResponse
|
509
|
+
);
|
510
|
+
|
511
|
+
fetchMock.once(
|
512
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
513
|
+
SearchResponse
|
514
|
+
);
|
515
|
+
|
516
|
+
fetchMock.once(
|
517
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/a5b/unshare",
|
518
|
+
UnsharingResponse
|
519
|
+
);
|
520
|
+
|
521
|
+
fetchMock.get(
|
522
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
523
|
+
GroupOwnerResponse
|
524
|
+
);
|
525
|
+
|
526
|
+
unshareItemWithGroup({
|
527
|
+
authentication: MOCK_USER_SESSION,
|
528
|
+
id: "a5b",
|
529
|
+
groupId: "t6b",
|
530
|
+
owner: "casey"
|
531
|
+
})
|
532
|
+
.then(response => {
|
533
|
+
const [url, options]: [string, RequestInit] = fetchMock.lastCall(
|
534
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/a5b/unshare"
|
535
|
+
);
|
536
|
+
expect(url).toBe(
|
537
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/a5b/unshare"
|
538
|
+
);
|
539
|
+
expect(options.method).toBe("POST");
|
540
|
+
expect(response).toEqual(UnsharingResponse);
|
541
|
+
expect(options.body).toContain("f=json");
|
542
|
+
expect(options.body).toContain("groups=t6b");
|
543
|
+
done();
|
544
|
+
})
|
545
|
+
.catch(e => {
|
546
|
+
fail(e);
|
547
|
+
});
|
548
|
+
});
|
549
|
+
|
550
|
+
it("should unshare an item with a group by group admin", done => {
|
551
|
+
fetchMock.once(
|
552
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
553
|
+
GroupAdminUserResponse
|
554
|
+
);
|
555
|
+
|
556
|
+
fetchMock.once(
|
557
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
558
|
+
SearchResponse
|
559
|
+
);
|
560
|
+
|
561
|
+
fetchMock.once(
|
562
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/a5b/unshare",
|
563
|
+
UnsharingResponse
|
564
|
+
);
|
565
|
+
|
566
|
+
fetchMock.get(
|
567
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
568
|
+
GroupAdminResponse
|
569
|
+
);
|
570
|
+
|
571
|
+
unshareItemWithGroup({
|
572
|
+
authentication: MOCK_USER_SESSION,
|
573
|
+
id: "a5b",
|
574
|
+
groupId: "t6b",
|
575
|
+
owner: "otherguy"
|
576
|
+
})
|
577
|
+
.then(response => {
|
578
|
+
const [url, options]: [string, RequestInit] = fetchMock.lastCall(
|
579
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/a5b/unshare"
|
580
|
+
);
|
581
|
+
expect(url).toBe(
|
582
|
+
"https://myorg.maps.arcgis.com/sharing/rest/content/items/a5b/unshare"
|
583
|
+
);
|
584
|
+
expect(options.method).toBe("POST");
|
585
|
+
expect(response).toEqual(UnsharingResponse);
|
586
|
+
expect(options.body).toContain("f=json");
|
587
|
+
expect(options.body).toContain("groups=t6b");
|
588
|
+
done();
|
589
|
+
})
|
590
|
+
.catch(e => {
|
591
|
+
fail(e);
|
592
|
+
});
|
593
|
+
});
|
594
|
+
|
595
|
+
it("should shortcircuit share if an item was previously unshared with a group", done => {
|
596
|
+
fetchMock.once(
|
597
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
598
|
+
GroupMemberUserResponse
|
599
|
+
);
|
600
|
+
|
601
|
+
fetchMock.once(
|
602
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
603
|
+
SearchResponse
|
604
|
+
);
|
605
|
+
|
606
|
+
unshareItemWithGroup({
|
607
|
+
authentication: MOCK_USER_SESSION,
|
608
|
+
id: "n3v",
|
609
|
+
groupId: "t6b"
|
610
|
+
})
|
611
|
+
.then(response => {
|
612
|
+
// no web request to unshare at all
|
613
|
+
expect(response).toEqual(CachedUnsharingResponse);
|
614
|
+
done();
|
615
|
+
})
|
616
|
+
.catch(e => {
|
617
|
+
fail(e);
|
618
|
+
});
|
619
|
+
});
|
620
|
+
|
621
|
+
// this one
|
622
|
+
it("should throw if the person trying to unshare doesnt own the item, is not an admin or member of said group", done => {
|
623
|
+
fetchMock.once(
|
624
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/users/jsmith?f=json&token=fake-token",
|
625
|
+
AnonUserResponse
|
626
|
+
);
|
627
|
+
|
628
|
+
fetchMock.once(
|
629
|
+
"https://myorg.maps.arcgis.com/sharing/rest/search",
|
630
|
+
SearchResponse
|
631
|
+
);
|
632
|
+
|
633
|
+
fetchMock.once(
|
634
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/t6b?f=json&token=fake-token",
|
635
|
+
GroupNonMemberUserResponse
|
636
|
+
);
|
637
|
+
|
638
|
+
unshareItemWithGroup({
|
639
|
+
authentication: MOCK_USER_SESSION,
|
640
|
+
id: "a5b",
|
641
|
+
groupId: "t6b",
|
642
|
+
owner: "jones"
|
643
|
+
}).catch(e => {
|
644
|
+
expect(e.message).toContain(
|
645
|
+
"This item can not be unshared by jsmith as they are not a member of the specified group t6b."
|
646
|
+
);
|
647
|
+
done();
|
648
|
+
});
|
649
|
+
});
|
650
|
+
});
|
@@ -0,0 +1,55 @@
|
|
1
|
+
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
|
2
|
+
* Apache-2.0 */
|
3
|
+
|
4
|
+
import * as fetchMock from "fetch-mock";
|
5
|
+
import { getUserMembership } from "../../src/sharing/helpers";
|
6
|
+
import { MOCK_USER_SESSION } from "../mocks/sharing/sharing";
|
7
|
+
import {
|
8
|
+
GroupOwnerResponse,
|
9
|
+
GroupNoAccessResponse
|
10
|
+
} from "./group-sharing.test";
|
11
|
+
|
12
|
+
describe("sharing helpers ::", () => {
|
13
|
+
afterEach(fetchMock.restore);
|
14
|
+
describe("getUserMembership ::", () => {
|
15
|
+
it("should return nonmember if group could not be fetched", done => {
|
16
|
+
fetchMock.once(
|
17
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/tb6?f=json&token=fake-token",
|
18
|
+
GroupNoAccessResponse
|
19
|
+
);
|
20
|
+
getUserMembership({
|
21
|
+
id: "ignoreme",
|
22
|
+
groupId: "tb6",
|
23
|
+
authentication: MOCK_USER_SESSION
|
24
|
+
})
|
25
|
+
.then(result => {
|
26
|
+
expect(fetchMock.done()).toBeTruthy();
|
27
|
+
expect(result).toBe("nonmember", "should return nonmember");
|
28
|
+
done();
|
29
|
+
})
|
30
|
+
.catch(e => {
|
31
|
+
fail(e);
|
32
|
+
});
|
33
|
+
});
|
34
|
+
|
35
|
+
it("should request the group and return the member type", done => {
|
36
|
+
fetchMock.once(
|
37
|
+
"https://myorg.maps.arcgis.com/sharing/rest/community/groups/tb6?f=json&token=fake-token",
|
38
|
+
GroupOwnerResponse
|
39
|
+
);
|
40
|
+
getUserMembership({
|
41
|
+
id: "ignoreme",
|
42
|
+
groupId: "tb6",
|
43
|
+
authentication: MOCK_USER_SESSION
|
44
|
+
})
|
45
|
+
.then(result => {
|
46
|
+
expect(fetchMock.done()).toBeTruthy();
|
47
|
+
expect(result).toBe("owner", "should return owner");
|
48
|
+
done();
|
49
|
+
})
|
50
|
+
.catch(e => {
|
51
|
+
fail(e);
|
52
|
+
});
|
53
|
+
});
|
54
|
+
});
|
55
|
+
});
|