delectusnon 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 +33 -0
- package/.vscode/launch.json +24 -0
- package/.vscode/settings.json +3 -0
- package/demos/ago-node-cli/README.md +29 -0
- package/demos/ago-node-cli/ago.js +32 -0
- package/demos/ago-node-cli/index.js +11 -0
- package/demos/ago-node-cli/lib/item-export-command.js +48 -0
- package/demos/ago-node-cli/lib/item-search-command.js +35 -0
- package/demos/ago-node-cli/package-lock.json +172 -0
- package/demos/ago-node-cli/package.json +30 -0
- package/demos/attachments/README.md +5 -0
- package/demos/attachments/index.html +164 -0
- package/demos/attachments/package-lock.json +182 -0
- package/demos/attachments/package.json +18 -0
- package/demos/batch-geocoder-node/NYC_Restaurant_Inspection_Results.csv +100 -0
- package/demos/batch-geocoder-node/README.md +15 -0
- package/demos/batch-geocoder-node/batch-geocode.js +118 -0
- package/demos/batch-geocoder-node/config-template.js +18 -0
- package/demos/batch-geocoder-node/package-lock.json +116 -0
- package/demos/batch-geocoder-node/package.json +39 -0
- package/demos/express/README.md +10 -0
- package/demos/express/config.json.template +3 -0
- package/demos/express/package-lock.json +473 -0
- package/demos/express/package.json +18 -0
- package/demos/express/server.js +28 -0
- package/demos/feature-service-browser/README.md +6 -0
- package/demos/feature-service-browser/index.html +122 -0
- package/demos/feature-service-browser/package-lock.json +182 -0
- package/demos/feature-service-browser/package.json +18 -0
- package/demos/geocoder-browser/README.md +10 -0
- package/demos/geocoder-browser/config.js.template +1 -0
- package/demos/geocoder-browser/index.html +131 -0
- package/demos/geocoder-browser/package-lock.json +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 +8 -0
- package/demos/jsapi-integration/config.js +6 -0
- package/demos/jsapi-integration/index.html +79 -0
- package/demos/jsapi-integration/package-lock.json +184 -0
- package/demos/jsapi-integration/package.json +19 -0
- package/demos/oauth2-browser/README.md +12 -0
- package/demos/oauth2-browser/authenticate.html +32 -0
- package/demos/oauth2-browser/config.js.template +6 -0
- package/demos/oauth2-browser/index.html +202 -0
- package/demos/oauth2-browser/logo.svg +4 -0
- package/demos/oauth2-browser/package-lock.json +163 -0
- package/demos/oauth2-browser/package.json +18 -0
- package/demos/oauth2-browser/style.css +36 -0
- package/demos/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 +301 -0
- package/docs/src/_layout.html +82 -0
- package/docs/src/api/_declaration.html +496 -0
- package/docs/src/api/_layout.html +127 -0
- package/docs/src/api/_package.html +13 -0
- package/docs/src/api/index.html +23 -0
- package/docs/src/guides/_layout.html +24 -0
- package/docs/src/guides/amd-requirejs-dojo.md +40 -0
- package/docs/src/guides/babel-and-rollup.md +30 -0
- package/docs/src/guides/babel-and-webpack.md +30 -0
- package/docs/src/guides/browser-authentication.md +31 -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 +88 -0
- package/packages/arcgis-rest-auth/README.md +64 -0
- package/packages/arcgis-rest-auth/package-lock.json +11 -0
- package/packages/arcgis-rest-auth/package.json +51 -0
- package/packages/arcgis-rest-auth/src/ApplicationSession.ts +109 -0
- package/packages/arcgis-rest-auth/src/UserSession.ts +873 -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 +995 -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-types/README.md +61 -0
- package/packages/arcgis-rest-common-types/package.json +38 -0
- package/packages/arcgis-rest-common-types/src/group.ts +54 -0
- package/packages/arcgis-rest-common-types/src/index.ts +467 -0
- package/packages/arcgis-rest-common-types/src/item.ts +45 -0
- package/packages/arcgis-rest-common-types/src/webmap.ts +1232 -0
- package/packages/arcgis-rest-common-types/tsconfig.json +11 -0
- package/packages/arcgis-rest-feature-service/README.md +70 -0
- package/packages/arcgis-rest-feature-service/package-lock.json +11 -0
- package/packages/arcgis-rest-feature-service/package.json +50 -0
- package/packages/arcgis-rest-feature-service/src/add.ts +81 -0
- package/packages/arcgis-rest-feature-service/src/addAttachment.ts +65 -0
- package/packages/arcgis-rest-feature-service/src/delete.ts +85 -0
- package/packages/arcgis-rest-feature-service/src/deleteAttachments.ts +68 -0
- package/packages/arcgis-rest-feature-service/src/getAttachments.ts +64 -0
- package/packages/arcgis-rest-feature-service/src/helpers.ts +80 -0
- package/packages/arcgis-rest-feature-service/src/index.ts +12 -0
- package/packages/arcgis-rest-feature-service/src/query.ts +172 -0
- package/packages/arcgis-rest-feature-service/src/queryRelated.ts +91 -0
- package/packages/arcgis-rest-feature-service/src/update.ts +81 -0
- package/packages/arcgis-rest-feature-service/src/updateAttachment.ts +74 -0
- package/packages/arcgis-rest-feature-service/test/attachments.test.ts +203 -0
- package/packages/arcgis-rest-feature-service/test/features.test.ts +252 -0
- package/packages/arcgis-rest-feature-service/test/mocks/feature.ts +279 -0
- package/packages/arcgis-rest-feature-service/test/mocks/foo.txt +1 -0
- package/packages/arcgis-rest-feature-service/tsconfig.json +6 -0
- package/packages/arcgis-rest-feature-service-admin/README.md +66 -0
- package/packages/arcgis-rest-feature-service-admin/package-lock.json +11 -0
- package/packages/arcgis-rest-feature-service-admin/package.json +53 -0
- package/packages/arcgis-rest-feature-service-admin/src/addTo.ts +70 -0
- package/packages/arcgis-rest-feature-service-admin/src/create.ts +195 -0
- package/packages/arcgis-rest-feature-service-admin/src/index.ts +2 -0
- package/packages/arcgis-rest-feature-service-admin/test/addTo.test.ts +310 -0
- package/packages/arcgis-rest-feature-service-admin/test/create.test.ts +412 -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 +79 -0
- package/packages/arcgis-rest-geocoder/package-lock.json +11 -0
- package/packages/arcgis-rest-geocoder/package.json +52 -0
- package/packages/arcgis-rest-geocoder/src/bulk.ts +102 -0
- package/packages/arcgis-rest-geocoder/src/geocode.ts +117 -0
- package/packages/arcgis-rest-geocoder/src/helpers.ts +79 -0
- package/packages/arcgis-rest-geocoder/src/index.ts +8 -0
- package/packages/arcgis-rest-geocoder/src/reverse.ts +84 -0
- package/packages/arcgis-rest-geocoder/src/suggest.ts +72 -0
- package/packages/arcgis-rest-geocoder/test/bulk.test.ts +113 -0
- package/packages/arcgis-rest-geocoder/test/geocode.test.ts +121 -0
- package/packages/arcgis-rest-geocoder/test/helpers.test.ts +113 -0
- package/packages/arcgis-rest-geocoder/test/mocks/responses.ts +591 -0
- package/packages/arcgis-rest-geocoder/test/reverse.test.ts +126 -0
- package/packages/arcgis-rest-geocoder/test/suggest.test.ts +77 -0
- package/packages/arcgis-rest-geocoder/tsconfig.json +6 -0
- package/packages/arcgis-rest-groups/README.md +64 -0
- package/packages/arcgis-rest-groups/package-lock.json +11 -0
- package/packages/arcgis-rest-groups/package.json +52 -0
- package/packages/arcgis-rest-groups/src/create.ts +34 -0
- package/packages/arcgis-rest-groups/src/get.ts +95 -0
- package/packages/arcgis-rest-groups/src/helpers.ts +26 -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 +104 -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 +66 -0
- package/packages/arcgis-rest-items/package-lock.json +11 -0
- package/packages/arcgis-rest-items/package.json +52 -0
- package/packages/arcgis-rest-items/src/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 +33 -0
- package/packages/arcgis-rest-items/test/mocks/resources.ts +31 -0
- package/packages/arcgis-rest-items/test/mocks/search.ts +63 -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 +65 -0
- package/packages/arcgis-rest-request/package-lock.json +11 -0
- package/packages/arcgis-rest-request/package.json +42 -0
- package/packages/arcgis-rest-request/src/index.ts +13 -0
- package/packages/arcgis-rest-request/src/request.ts +293 -0
- package/packages/arcgis-rest-request/src/utils/ArcGISAuthError.ts +67 -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/check-for-errors.ts +65 -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/process-params.ts +99 -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 +299 -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-sharing/README.md +67 -0
- package/packages/arcgis-rest-sharing/package-lock.json +11 -0
- package/packages/arcgis-rest-sharing/package.json +57 -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 +71 -0
- package/packages/arcgis-rest-users/package-lock.json +11 -0
- package/packages/arcgis-rest-users/package.json +51 -0
- package/packages/arcgis-rest-users/src/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/publish.sh +43 -0
- package/support/test-helpers.js +8 -0
- package/tsconfig.json +69 -0
- package/tslint.json +15 -0
- package/umd-base-profile.js +82 -0
- package/umd-production-profile.js +13 -0
@@ -0,0 +1,92 @@
|
|
1
|
+
// Import VueJS.
|
2
|
+
import Vue from "vue";
|
3
|
+
// Using the router to treat this like a single-page application.
|
4
|
+
import Router from "vue-router";
|
5
|
+
// Import the store plugin, Vuex.
|
6
|
+
import Vuex from "vuex";
|
7
|
+
// Import the arcgis-rest-auth bit required for deserializing local storage sessions.
|
8
|
+
import { UserSession } from "@esri/arcgis-rest-auth";
|
9
|
+
// Importing the main application.
|
10
|
+
import App from "./components/App.vue";
|
11
|
+
// Importing the authentication component that post-processes the OAuth response.
|
12
|
+
import Authenticate from "./components/Authenticate.vue";
|
13
|
+
|
14
|
+
// Tell Vue to use the vue-router plugin.
|
15
|
+
Vue.use(Router);
|
16
|
+
|
17
|
+
// Define the router.
|
18
|
+
const router = new Router({
|
19
|
+
routes: [
|
20
|
+
// The root path will render the main application component.
|
21
|
+
{ path: "/", component: App },
|
22
|
+
// At /authenticate, the authentication component will be rendered.
|
23
|
+
{ path: "/authenticate", component: Authenticate }
|
24
|
+
]
|
25
|
+
});
|
26
|
+
|
27
|
+
// Tell Vue to use the Vuex plugin.
|
28
|
+
Vue.use(Vuex);
|
29
|
+
|
30
|
+
// Define the application store.
|
31
|
+
const store = new Vuex.Store({
|
32
|
+
state: {
|
33
|
+
session: null
|
34
|
+
},
|
35
|
+
mutations: {
|
36
|
+
setSession(state, data) {
|
37
|
+
state.session = data;
|
38
|
+
}
|
39
|
+
},
|
40
|
+
actions: {
|
41
|
+
updateSession({ commit }, session) {
|
42
|
+
// Apply the changes to the state's session.
|
43
|
+
commit("setSession", session);
|
44
|
+
// If the browser supports local storage, re-serialize it on change
|
45
|
+
// and update the local storage.
|
46
|
+
if (typeof Storage !== "undefined") {
|
47
|
+
if (session && session.serialize) {
|
48
|
+
localStorage.setItem(
|
49
|
+
"__ARCGIS_REST_USER_SESSION__",
|
50
|
+
session.serialize()
|
51
|
+
);
|
52
|
+
} else {
|
53
|
+
localStorage.removeItem("__ARCGIS_REST_USER_SESSION__");
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
58
|
+
});
|
59
|
+
|
60
|
+
// Define the main Vue instance.
|
61
|
+
new Vue({
|
62
|
+
el: "#app",
|
63
|
+
router,
|
64
|
+
store,
|
65
|
+
data() {
|
66
|
+
return {};
|
67
|
+
},
|
68
|
+
created() {
|
69
|
+
// Load any previously serialized session.
|
70
|
+
this.loadSerializedSession();
|
71
|
+
},
|
72
|
+
methods: {
|
73
|
+
// Function to load any serialized session from local storage.
|
74
|
+
loadSerializedSession() {
|
75
|
+
if (typeof Storage !== "undefined") {
|
76
|
+
const serializedSession = localStorage.getItem(
|
77
|
+
"__ARCGIS_REST_USER_SESSION__"
|
78
|
+
);
|
79
|
+
if (serializedSession !== null && serializedSession !== "undefined") {
|
80
|
+
// If there is a serialized session, deserialize it into a new session object.
|
81
|
+
store.dispatch(
|
82
|
+
"updateSession",
|
83
|
+
UserSession.deserialize(serializedSession)
|
84
|
+
);
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
88
|
+
},
|
89
|
+
render(createElement) {
|
90
|
+
return createElement("router-view");
|
91
|
+
}
|
92
|
+
});
|
package/docs/FAQ.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
## Is this a _supported_ Esri product?
|
2
|
+
|
3
|
+
It is not. We offer no guarantees, SLAs, nor a product lifecycle to support planning.
|
4
|
+
|
5
|
+
This project is an open source collaboration between developers from a variety of teams at Esri that was initially developed to scratch an itch of our own. That said, we are actively recruiting outside contributors and fully expect that the tools here will be useful to a subset of our customers.
|
6
|
+
|
7
|
+
## Comparison with the ArcGIS API for JavaScript
|
8
|
+
|
9
|
+
The ArcGIS API for JavaScript is Esri's flagship product for building web applications to visualize, edit, map and analyze geospatial data. It is a feature complete client side API for working with the REST services based ArcGIS platform.
|
10
|
+
The ArcGIS API for JavaScript includes significant client side functionality including smart mapping, 3D rendering, geometric analysis and feature editing as well as full support for working with web maps and web scenes.
|
11
|
+
|
12
|
+
The goal of this project on the other hand is to provide a convenient binding to the underlying REST API for those who need to work directly with it from JavaScript. This project includes functional equivalents of the low-level request methods and identity management in the ArcGIS API for JavaScript, along with additional thin wrappers to assist developers in scripting against the ArcGIS REST API directly in Node.js and browser applications that do _not_ incorporate a map.
|
13
|
+
|
14
|
+
We aim to make interacting with the platform as intuitive as possible, but the surface area of the project currently does not nearly encompass the entire ArcGIS REST API.
|
15
|
+
|
16
|
+
## Comparison with the ArcGIS API for Python
|
17
|
+
|
18
|
+
This project is similar to the ArcGIS API for Python in many ways. Like the ArcGIS API for Python, this library aims to be a scripting tool that simplifies interacting with the ArcGIS REST API, but where the ArcGIS API for Python highlights integration with dataframes and Jupyter Notebooks for visualization and sharing this project provides only generic tools for JavaScript applications running on a server, CLI, in a browser or as a script.
|
19
|
+
|
20
|
+
## Why TypeScript
|
21
|
+
|
22
|
+
Using TypeScript allows us to add type information to request params and response structures. This vastly simplifies development. TypeScript also has excellent support for newer `async`/`await` patterns and for generating API documentation with [TypeDoc](http://typedoc.org/).
|
23
|
+
|
24
|
+
TypeScript compiles to JavaScript so you can use @esri/arcgis-rest-js in any JavaScript project. However if you use TypeScript you will get the benefits of type checking for free.
|
25
|
+
|
26
|
+
We also _really_ like TypeScript because it supports exporting to both [ES 2015 modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) (use `import`/`export`) and [UMD](http://davidbcalhoun.com/2014/what-is-amd-commonjs-and-umd/) modules. This allows us to support a wide variety of module loaders and bundlers, including Browserify, Webpack, RequireJS, and Dojo 1 and 2.
|
27
|
+
|
28
|
+
We include [`tslib`](https://www.npmjs.com/package/tslib) as a dependency of individual npm packages to make usage of `_extends` and `_assign` in our compiled code more concise.
|
package/docs/HISTORY.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
## Origins
|
2
|
+
|
3
|
+
The idea for this library originated in a slack conversation between @patrickarlt and @ajturner when he was looking for a library to automate the creation of Feature Layers in ArcGIS Online for the Hub project.
|
4
|
+
|
5
|
+
## Key Collaborators
|
6
|
+
|
7
|
+
This list includes people who contributed to the original conversation and those who have contributed to similar projects.
|
8
|
+
|
9
|
+
* @ajturner - ArcGIS Hub
|
10
|
+
* @dbouwman - ArcGIS Hub
|
11
|
+
* @tomwayson - ArcGIS Hub
|
12
|
+
* @patricakrlt - ArcGIS for Developers
|
13
|
+
* @noahmulfinger - ArcGIS for Developers
|
14
|
+
* @araedavis - ArcGIS for Developers
|
15
|
+
* @nixta - Developer Outreach
|
16
|
+
* @jgravois - Developer Outreach
|
17
|
+
|
18
|
+
## Use Cases and Target Audience
|
19
|
+
|
20
|
+
This API intends to simplify interactions with the ArcGIS REST API, enabling the creation of powerful scripting tools in both Node.js and the browser that currently require deep knowledge of the REST API, and coordinating chained calls with a variety of complex parameters. This library also enables downstream projects like the ArcGIS for Developers website and ArcGIS Hub to achieve identity management.
|
21
|
+
|
22
|
+
The tools proposed here are intended to be useful in internal projects such as ArcGIS for Developers and ArcGIS Hub, but they also strongly target outside developers who need to script and automate the platform but do not know or are not willing to integrate the ArcGIS API for Python into their projects. Hopefully, this project will also have appeal to enterprise developers who have existing Node.js systems and want to integrate with ArcGIS.
|
23
|
+
|
24
|
+
## Functionality Roadmap
|
25
|
+
|
26
|
+
* Manage feature layers
|
27
|
+
* Create new feature layers
|
28
|
+
* Add/Remove/Update fields in feature layers
|
29
|
+
* Query and edit features
|
30
|
+
* Get statistics
|
31
|
+
* Make interacting with premium ArcGIS Online services intuitive
|
32
|
+
* Geocoding
|
33
|
+
* Routing
|
34
|
+
* Geoenrichment
|
35
|
+
* Spatial Analysis
|
36
|
+
* Elevation Analysis
|
37
|
+
* Managing groups and users
|
38
|
+
* Create/invite new users
|
39
|
+
* Create/edit/delete/share with groups
|
40
|
+
* Manage content
|
41
|
+
* Create, edit and delete items, maps and scenes
|
42
|
+
* Handle authentication and identity
|
43
|
+
* Compatible with Node 6+ and the 2 latest releases of every browser and IE 11.
|
44
|
+
|
45
|
+
## Prior Projects
|
46
|
+
|
47
|
+
* [node-arcgis](https://github.com/Esri/node-arcgis) - Originally started by Nik Wise and currently maintained by John Gravois this library wraps a large amount of functionality for ArcGIS Online into a single API. However this library lacks much key functionality and does not handle authentication at all leaving it to the user to obtain and manage tokens. This library also lacks a significant test suite.
|
48
|
+
* [geoservices.js](https://github.com/Esri/geoservices-js) - Originally created by Jerry Seivert to wrap the [Geoservices](https://geoservices.github.io/) specification it is currently maintained by John Gravois. However this library does not fully implement the specification, handle authentication with ArcGIS or work in browsers.
|
49
|
+
* ArcGIS for Developers - The developers website has a large amount of internal tooling for working with Portal APIs and publishing feature services, we have plans to add additional features that would require either creating our own implementations or writing a common implementation in this project.
|
50
|
+
* Koop
|
51
|
+
* ArcGIS Hub
|
52
|
+
|
53
|
+
## Project Architecture
|
54
|
+
|
55
|
+
As with any new JavaScript project there are numerous decisions to make regarding which technologies to use. We decided to go with the options below, but all these choices are up for debate.
|
56
|
+
|
57
|
+
* Implemented as a [monorepo managed with Lerna](https://lernajs.io/). The monorepo approach allows us to manage distinct packages like `arcgis-rest-geocoding` and separate functionality while sharing build, test and documentation tooling.
|
58
|
+
* Author the library in [TypeScript](https://www.typescriptlang.org/). Using TypeScript will allow us to add type information to request params and response structures which vastly simplifies development. TypeScript also has excellent support for newer `async`/`await` patterns with miminal code overhead and can publish to any module format we might need to support. Additionally TypeScript has excellent support for generating API documentation with [TypeDoc](http://typedoc.org/). TypeScript also has better internal adoption since Dojo 2 is using it as well as the JSAPI, Insights and the ArcGIS for Developers site.
|
59
|
+
* ~Would recommend using a Node/browser HTTP library like [Axios](https://github.com/mzabriskie/axios) which also has support for mocking in tests via [axios-mock-adapter](https://github.com/ctimmerm/axios-mock-adapter).~ We have decided to use the new [fetch](https://fetch.spec.whatwg.org/) standard.
|
60
|
+
* Testing is a concern. I initially thought that we could simply use Karma to test all the code. However Karma can only be used to test browser based code. We could however use the `jasmine` command line tool it would just mean we would have to compile the TypeScript source first and then run the Jasmine CLI tools. Karma would use the `karma-typescript` plugin and run the browser tests. ~An alternative to this might be to use [The Intern](https://theintern.github.io/) setup according to this [blog post about testing with TypeScript](https://www.sitepen.com/blog/2015/03/24/testing-typescript-with-intern/). However the Intern doesn't have super great support for TypeScript currently though these issues should be solved in this Falls Intern 4 release.~ We have decided to use Jasmine and the Jasmine CLI for Node tests and Karma with Jasmine for browser tests.
|
61
|
+
|
62
|
+
It is worth noting that a TypeScript/Intern approach aligns perfectly with the direction of the JavaScript API team.
|
@@ -0,0 +1,223 @@
|
|
1
|
+
const path = require("path");
|
2
|
+
const fs = require("fs");
|
3
|
+
const { inspect } = require("util");
|
4
|
+
const _ = require("lodash");
|
5
|
+
|
6
|
+
const IS_DEV = process.env.ENV !== "prod";
|
7
|
+
|
8
|
+
module.exports = function(acetate) {
|
9
|
+
/**
|
10
|
+
* Load all .html and markdown pages in the `src` folder, assigning them a
|
11
|
+
* default layout.
|
12
|
+
*/
|
13
|
+
acetate.load("**/*.+(html|md)", {
|
14
|
+
basePath: "arcgis-rest-js",
|
15
|
+
metadata: {
|
16
|
+
layout: "_layout:main"
|
17
|
+
}
|
18
|
+
});
|
19
|
+
|
20
|
+
acetate.metadata("**/*", {
|
21
|
+
isDev: IS_DEV
|
22
|
+
});
|
23
|
+
|
24
|
+
/**
|
25
|
+
* Add a different layout for guides. Add an array of `titleSegments` to go
|
26
|
+
* inbetween the page title and the "Esri REST JS" title suffix.
|
27
|
+
*/
|
28
|
+
acetate.metadata("guides/**/*", {
|
29
|
+
layout: "guides/_layout:content",
|
30
|
+
titleSegments: ["Guide"]
|
31
|
+
});
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Now we need to make a new query called `guides` that will be used to render
|
35
|
+
* the guide navigation.
|
36
|
+
*/
|
37
|
+
acetate.query(
|
38
|
+
/**
|
39
|
+
* results will be accessible as `queries.guides` in templates
|
40
|
+
*/
|
41
|
+
"guides",
|
42
|
+
/**
|
43
|
+
* start by getting all markdown pages in the `guides` folder
|
44
|
+
*/
|
45
|
+
"guides/**/*.md",
|
46
|
+
/**
|
47
|
+
* Now map over each page extracting values from it into a new array.
|
48
|
+
*/
|
49
|
+
page => {
|
50
|
+
return {
|
51
|
+
title: page.navTitle || page.title,
|
52
|
+
order: page.order,
|
53
|
+
group: page.group,
|
54
|
+
url: page.url
|
55
|
+
};
|
56
|
+
},
|
57
|
+
/**
|
58
|
+
* Now reduce our array from the previous step sorting the items into sections
|
59
|
+
* based on their `group` property.
|
60
|
+
*/
|
61
|
+
(sections, item) => {
|
62
|
+
if (!item.group) {
|
63
|
+
return sections;
|
64
|
+
}
|
65
|
+
|
66
|
+
// does this items `section` already have a `section` in `sections`?
|
67
|
+
const idx = _.findIndex(sections, section => section.id === item.group);
|
68
|
+
|
69
|
+
if (idx >= 0) {
|
70
|
+
// if it does push this item into it.
|
71
|
+
sections[idx].items.push(item);
|
72
|
+
} else {
|
73
|
+
// if it does not push a new `section` into `sections`.
|
74
|
+
sections.push({
|
75
|
+
name: _.startCase(item.group.replace(/\d-/, "")),
|
76
|
+
id: item.group,
|
77
|
+
items: [item]
|
78
|
+
});
|
79
|
+
}
|
80
|
+
|
81
|
+
/**
|
82
|
+
* sort our sections by their `id` (which starts with a number) an sort
|
83
|
+
* each sections items by their `order` property
|
84
|
+
*/
|
85
|
+
return _(sections)
|
86
|
+
.sortBy("id")
|
87
|
+
.map(section => {
|
88
|
+
section.items = _.sortBy(section.items, "order");
|
89
|
+
return section;
|
90
|
+
})
|
91
|
+
.value();
|
92
|
+
},
|
93
|
+
/**
|
94
|
+
* The initial value for the above reduce function.
|
95
|
+
*/
|
96
|
+
[]
|
97
|
+
);
|
98
|
+
|
99
|
+
/**
|
100
|
+
* Load the typedoc.json file as a page in Acetate. This makes the watcher
|
101
|
+
* start looking for changes and we can listen for the events later.
|
102
|
+
*/
|
103
|
+
acetate.load("typedoc.json", {
|
104
|
+
basePath: "arcgis-rest-js",
|
105
|
+
metadata: {
|
106
|
+
layout: false,
|
107
|
+
prettyUrl: false
|
108
|
+
}
|
109
|
+
});
|
110
|
+
|
111
|
+
/**
|
112
|
+
* Use Acetates generate helper to generate a page for each `declaration`
|
113
|
+
* and `package` in the typedoc.json and generate the search index file
|
114
|
+
*/
|
115
|
+
acetate.generate((createPage, callback) => {
|
116
|
+
fs.readFile(
|
117
|
+
path.join(acetate.root, "src", "typedoc.json"),
|
118
|
+
(e, contents) => {
|
119
|
+
const typedoc = JSON.parse(contents.toString());
|
120
|
+
|
121
|
+
const declarationPages = typedoc.declarations.map(declaration => {
|
122
|
+
return createPage.fromTemplate(
|
123
|
+
declaration.src,
|
124
|
+
path.join(acetate.sourceDir, "api", "_declaration.html"),
|
125
|
+
Object.assign({}, declaration, {
|
126
|
+
layout: "api/_layout:content"
|
127
|
+
})
|
128
|
+
);
|
129
|
+
});
|
130
|
+
|
131
|
+
const packagePages = typedoc.packages.map(package => {
|
132
|
+
return createPage.fromTemplate(
|
133
|
+
package.src,
|
134
|
+
path.join(acetate.sourceDir, "api", "_package.html"),
|
135
|
+
Object.assign({}, package, {
|
136
|
+
layout: "api/_layout:content"
|
137
|
+
})
|
138
|
+
);
|
139
|
+
});
|
140
|
+
|
141
|
+
const searchIndex = createPage.fromTemplateString(
|
142
|
+
"arcgis-rest-js/js/index.js",
|
143
|
+
`const ESRI_REST_API_REF_INDEX = ${JSON.stringify(
|
144
|
+
typedoc.quickSearchIndex
|
145
|
+
)}`,
|
146
|
+
path.join(acetate.sourceDir, "js", "index.js"),
|
147
|
+
{ layout: false, prettyUrl: false }
|
148
|
+
);
|
149
|
+
|
150
|
+
// once all the pages have been generated provide them to Acetate.
|
151
|
+
Promise.all(declarationPages.concat(packagePages)).then(pages => {
|
152
|
+
callback(null, pages.concat(searchIndex));
|
153
|
+
});
|
154
|
+
}
|
155
|
+
);
|
156
|
+
});
|
157
|
+
|
158
|
+
/**
|
159
|
+
* Also register typedoc.json as a global data object called `typedoc`.
|
160
|
+
*/
|
161
|
+
acetate.data("typedoc", "typedoc.json");
|
162
|
+
|
163
|
+
/**
|
164
|
+
* Register some tools for working with the typedoc output.
|
165
|
+
*/
|
166
|
+
acetate.global("API_TOOLS", {
|
167
|
+
findById: function(typedoc, id) {
|
168
|
+
return typedoc.index[id];
|
169
|
+
},
|
170
|
+
findByName: function(typedoc, name) {
|
171
|
+
return typedoc.declarations.find(c => c.name === name);
|
172
|
+
},
|
173
|
+
findChildById: function(id, children) {
|
174
|
+
return children.find(c => c.id === id);
|
175
|
+
}
|
176
|
+
});
|
177
|
+
|
178
|
+
acetate.filter("findPackage", (typedoc, name) => {
|
179
|
+
console.log(typedoc.packages, name);
|
180
|
+
return typedoc.packages.find(p => p.pkg.name === name).pkg;
|
181
|
+
});
|
182
|
+
|
183
|
+
/**
|
184
|
+
* Listen for changes, if we see a change in typedoc.json we know we need to
|
185
|
+
* regenerate all the dymanically generated pages so reload this config file.
|
186
|
+
*/
|
187
|
+
acetate.on("watcher:change", page => {
|
188
|
+
if (page.src === "typedoc.json") {
|
189
|
+
acetate.reloadConfig();
|
190
|
+
}
|
191
|
+
});
|
192
|
+
|
193
|
+
/**
|
194
|
+
* Template helper for safely inspecting objects with circular references.
|
195
|
+
*/
|
196
|
+
acetate.filter("inspect", function(obj) {
|
197
|
+
return inspect(obj, { depth: 3 });
|
198
|
+
});
|
199
|
+
|
200
|
+
// without the '.js' on the end, for the benefit of the AMD sample
|
201
|
+
acetate.helper("cdnUrl", function(context, package) {
|
202
|
+
return `https://unpkg.com/${
|
203
|
+
package.name
|
204
|
+
}@${package.version}/dist/umd/${package.name.replace("@esri/arcgis-rest-", "")}.umd`;
|
205
|
+
});
|
206
|
+
|
207
|
+
// <code> friendly script tag string
|
208
|
+
// future entry point for adding SRI hash
|
209
|
+
acetate.helper("scriptTag", function(context, package) {
|
210
|
+
return `<script src="https://unpkg.com/${
|
211
|
+
package.name
|
212
|
+
}@${package.version}/dist/umd/${package.name.replace("@esri/arcgis-rest-", "")}.umd.min.js"></script>`;
|
213
|
+
});
|
214
|
+
|
215
|
+
acetate.helper("npmInstallCmd", function(context, package) {
|
216
|
+
const peers = package.peerDependencies
|
217
|
+
? Object.keys(package.peerDependencies).map(
|
218
|
+
pkg => `${pkg}@${package.peerDependencies[pkg]} `
|
219
|
+
)
|
220
|
+
: [];
|
221
|
+
return `npm install ${package.name} ${peers.join(" ")}`;
|
222
|
+
});
|
223
|
+
};
|