etincidunt 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (226) hide show
  1. package/.prettierignore +2 -0
  2. package/.travis.yml +29 -0
  3. package/.vscode/launch.json +24 -0
  4. package/.vscode/settings.json +3 -0
  5. package/demos/ago-node-cli/README.md +29 -0
  6. package/demos/ago-node-cli/ago.js +32 -0
  7. package/demos/ago-node-cli/index.js +11 -0
  8. package/demos/ago-node-cli/lib/item-export-command.js +48 -0
  9. package/demos/ago-node-cli/lib/item-search-command.js +35 -0
  10. package/demos/ago-node-cli/package-lock.json +172 -0
  11. package/demos/ago-node-cli/package.json +30 -0
  12. package/demos/attachments/README.md +5 -0
  13. package/demos/attachments/index.html +164 -0
  14. package/demos/attachments/package-lock.json +182 -0
  15. package/demos/attachments/package.json +18 -0
  16. package/demos/batch-geocoder-node/NYC_Restaurant_Inspection_Results.csv +100 -0
  17. package/demos/batch-geocoder-node/README.md +14 -0
  18. package/demos/batch-geocoder-node/batch-geocode.js +112 -0
  19. package/demos/batch-geocoder-node/config-template.js +18 -0
  20. package/demos/batch-geocoder-node/package-lock.json +109 -0
  21. package/demos/batch-geocoder-node/package.json +37 -0
  22. package/demos/express/README.md +10 -0
  23. package/demos/express/config.json.template +3 -0
  24. package/demos/express/package-lock.json +388 -0
  25. package/demos/express/package.json +18 -0
  26. package/demos/express/server.js +28 -0
  27. package/demos/feature-service-browser/README.md +6 -0
  28. package/demos/feature-service-browser/index.html +122 -0
  29. package/demos/feature-service-browser/package-lock.json +182 -0
  30. package/demos/feature-service-browser/package.json +18 -0
  31. package/demos/geocoder-browser/README.md +10 -0
  32. package/demos/geocoder-browser/config.js.template +1 -0
  33. package/demos/geocoder-browser/index.html +131 -0
  34. package/demos/geocoder-browser/package-lock.json +163 -0
  35. package/demos/geocoder-browser/package.json +19 -0
  36. package/demos/geocoder-browser/post-sign-in.html +25 -0
  37. package/demos/jsapi-integration/README.md +8 -0
  38. package/demos/jsapi-integration/config.js +6 -0
  39. package/demos/jsapi-integration/index.html +79 -0
  40. package/demos/jsapi-integration/package-lock.json +184 -0
  41. package/demos/jsapi-integration/package.json +19 -0
  42. package/demos/oauth2-browser/README.md +12 -0
  43. package/demos/oauth2-browser/authenticate.html +32 -0
  44. package/demos/oauth2-browser/config.js.template +6 -0
  45. package/demos/oauth2-browser/index.html +202 -0
  46. package/demos/oauth2-browser/logo.svg +4 -0
  47. package/demos/oauth2-browser/package-lock.json +163 -0
  48. package/demos/oauth2-browser/package.json +18 -0
  49. package/demos/oauth2-browser/style.css +36 -0
  50. package/demos/vue/.babelrc +6 -0
  51. package/demos/vue/.env.example +8 -0
  52. package/demos/vue/README.md +17 -0
  53. package/demos/vue/index.html +21 -0
  54. package/demos/vue/package-lock.json +7236 -0
  55. package/demos/vue/package.json +39 -0
  56. package/demos/vue/src/assets/logo.svg +29 -0
  57. package/demos/vue/src/components/App.vue +302 -0
  58. package/demos/vue/src/components/Authenticate.vue +68 -0
  59. package/demos/vue/src/components/Loader.vue +216 -0
  60. package/demos/vue/src/main.js +75 -0
  61. package/demos/vue/webpack.config.js +84 -0
  62. package/docs/FAQ.md +28 -0
  63. package/docs/HISTORY.md +62 -0
  64. package/docs/acetate.config.js +214 -0
  65. package/docs/build-typedoc.js +301 -0
  66. package/docs/src/_layout.html +82 -0
  67. package/docs/src/api/_declaration.html +496 -0
  68. package/docs/src/api/_layout.html +127 -0
  69. package/docs/src/api/_package.html +13 -0
  70. package/docs/src/api/index.html +23 -0
  71. package/docs/src/guides/_layout.html +24 -0
  72. package/docs/src/guides/amd-requirejs-dojo.md +40 -0
  73. package/docs/src/guides/babel-and-rollup.md +30 -0
  74. package/docs/src/guides/babel-and-webpack.md +30 -0
  75. package/docs/src/guides/browser-authentication.md +9 -0
  76. package/docs/src/guides/browserify.md +9 -0
  77. package/docs/src/guides/cli-authentication.md +9 -0
  78. package/docs/src/guides/client-server-authentication.md +9 -0
  79. package/docs/src/guides/from-a-cdn.md +36 -0
  80. package/docs/src/guides/index.md +52 -0
  81. package/docs/src/guides/node.md +30 -0
  82. package/docs/src/guides/package-overview.md +8 -0
  83. package/docs/src/guides/server-authentication.md +9 -0
  84. package/docs/src/guides/typescript-and-webpack.md +9 -0
  85. package/docs/src/img/icons.png +0 -0
  86. package/docs/src/img/icons@2x.png +0 -0
  87. package/docs/src/index.html +12 -0
  88. package/docs/src/js/api-search.js +113 -0
  89. package/docs/src/js/index.js +1 -0
  90. package/docs/src/js/nav-toggle.js +41 -0
  91. package/docs/src/sass/_highlight.scss +96 -0
  92. package/docs/src/sass/_icons.scss +157 -0
  93. package/docs/src/sass/style.scss +169 -0
  94. package/jasmine.json +7 -0
  95. package/karma.conf.js +100 -0
  96. package/lerna.json +8 -0
  97. package/notes/README.md +88 -0
  98. package/package.json +91 -0
  99. package/packages/arcgis-rest-auth/README.md +64 -0
  100. package/packages/arcgis-rest-auth/package-lock.json +11 -0
  101. package/packages/arcgis-rest-auth/package.json +51 -0
  102. package/packages/arcgis-rest-auth/src/ApplicationSession.ts +91 -0
  103. package/packages/arcgis-rest-auth/src/UserSession.ts +829 -0
  104. package/packages/arcgis-rest-auth/src/authenticated-request-options.ts +21 -0
  105. package/packages/arcgis-rest-auth/src/fetch-token.ts +55 -0
  106. package/packages/arcgis-rest-auth/src/generate-token.ts +36 -0
  107. package/packages/arcgis-rest-auth/src/index.ts +5 -0
  108. package/packages/arcgis-rest-auth/test/ApplicationSession.test.ts +121 -0
  109. package/packages/arcgis-rest-auth/test/UserSession.test.ts +883 -0
  110. package/packages/arcgis-rest-auth/test/fetchToken.test.ts +76 -0
  111. package/packages/arcgis-rest-auth/test/generateToken.test.ts +36 -0
  112. package/packages/arcgis-rest-auth/test/utils.ts +11 -0
  113. package/packages/arcgis-rest-auth/tsconfig.json +6 -0
  114. package/packages/arcgis-rest-common-types/README.md +61 -0
  115. package/packages/arcgis-rest-common-types/package.json +38 -0
  116. package/packages/arcgis-rest-common-types/src/group.ts +51 -0
  117. package/packages/arcgis-rest-common-types/src/index.ts +467 -0
  118. package/packages/arcgis-rest-common-types/src/item.ts +45 -0
  119. package/packages/arcgis-rest-common-types/src/webmap.ts +1225 -0
  120. package/packages/arcgis-rest-common-types/tsconfig.json +11 -0
  121. package/packages/arcgis-rest-feature-service/README.md +70 -0
  122. package/packages/arcgis-rest-feature-service/package-lock.json +11 -0
  123. package/packages/arcgis-rest-feature-service/package.json +50 -0
  124. package/packages/arcgis-rest-feature-service/src/add.ts +82 -0
  125. package/packages/arcgis-rest-feature-service/src/addAttachment.ts +65 -0
  126. package/packages/arcgis-rest-feature-service/src/delete.ts +85 -0
  127. package/packages/arcgis-rest-feature-service/src/deleteAttachments.ts +68 -0
  128. package/packages/arcgis-rest-feature-service/src/getAttachments.ts +64 -0
  129. package/packages/arcgis-rest-feature-service/src/helpers.ts +77 -0
  130. package/packages/arcgis-rest-feature-service/src/index.ts +8 -0
  131. package/packages/arcgis-rest-feature-service/src/query.ts +174 -0
  132. package/packages/arcgis-rest-feature-service/src/update.ts +81 -0
  133. package/packages/arcgis-rest-feature-service/src/updateAttachment.ts +74 -0
  134. package/packages/arcgis-rest-feature-service/test/attachments.test.ts +179 -0
  135. package/packages/arcgis-rest-feature-service/test/features.test.ts +172 -0
  136. package/packages/arcgis-rest-feature-service/test/mocks/feature.ts +220 -0
  137. package/packages/arcgis-rest-feature-service/test/mocks/foo.txt +1 -0
  138. package/packages/arcgis-rest-feature-service/tsconfig.json +6 -0
  139. package/packages/arcgis-rest-geocoder/README.md +73 -0
  140. package/packages/arcgis-rest-geocoder/package-lock.json +11 -0
  141. package/packages/arcgis-rest-geocoder/package.json +52 -0
  142. package/packages/arcgis-rest-geocoder/src/bulk.ts +102 -0
  143. package/packages/arcgis-rest-geocoder/src/geocode.ts +117 -0
  144. package/packages/arcgis-rest-geocoder/src/helpers.ts +81 -0
  145. package/packages/arcgis-rest-geocoder/src/index.ts +4 -0
  146. package/packages/arcgis-rest-geocoder/src/reverse.ts +84 -0
  147. package/packages/arcgis-rest-geocoder/src/suggest.ts +72 -0
  148. package/packages/arcgis-rest-geocoder/test/geocoder.test.ts +510 -0
  149. package/packages/arcgis-rest-geocoder/test/mocks/responses.ts +588 -0
  150. package/packages/arcgis-rest-geocoder/tsconfig.json +6 -0
  151. package/packages/arcgis-rest-groups/README.md +64 -0
  152. package/packages/arcgis-rest-groups/package-lock.json +11 -0
  153. package/packages/arcgis-rest-groups/package.json +52 -0
  154. package/packages/arcgis-rest-groups/src/groups.ts +272 -0
  155. package/packages/arcgis-rest-groups/src/index.ts +1 -0
  156. package/packages/arcgis-rest-groups/test/groups.test.ts +280 -0
  157. package/packages/arcgis-rest-groups/test/mocks/responses.ts +137 -0
  158. package/packages/arcgis-rest-groups/tsconfig.json +6 -0
  159. package/packages/arcgis-rest-items/README.md +66 -0
  160. package/packages/arcgis-rest-items/package-lock.json +11 -0
  161. package/packages/arcgis-rest-items/package.json +52 -0
  162. package/packages/arcgis-rest-items/src/index.ts +1 -0
  163. package/packages/arcgis-rest-items/src/items.ts +498 -0
  164. package/packages/arcgis-rest-items/test/items.test.ts +1153 -0
  165. package/packages/arcgis-rest-items/test/mocks/foo.zip +0 -0
  166. package/packages/arcgis-rest-items/test/mocks/item.ts +30 -0
  167. package/packages/arcgis-rest-items/test/mocks/resources.ts +28 -0
  168. package/packages/arcgis-rest-items/test/mocks/search.ts +60 -0
  169. package/packages/arcgis-rest-items/tsconfig.json +6 -0
  170. package/packages/arcgis-rest-request/README.md +65 -0
  171. package/packages/arcgis-rest-request/package-lock.json +11 -0
  172. package/packages/arcgis-rest-request/package.json +42 -0
  173. package/packages/arcgis-rest-request/src/index.ts +10 -0
  174. package/packages/arcgis-rest-request/src/request.ts +259 -0
  175. package/packages/arcgis-rest-request/src/utils/ArcGISAuthError.ts +67 -0
  176. package/packages/arcgis-rest-request/src/utils/ArcGISRequestError.ts +73 -0
  177. package/packages/arcgis-rest-request/src/utils/ErrorTypes.ts +29 -0
  178. package/packages/arcgis-rest-request/src/utils/check-for-errors.ts +65 -0
  179. package/packages/arcgis-rest-request/src/utils/encode-form-data.ts +29 -0
  180. package/packages/arcgis-rest-request/src/utils/encode-query-string.ts +23 -0
  181. package/packages/arcgis-rest-request/src/utils/get-portal-url.ts +25 -0
  182. package/packages/arcgis-rest-request/src/utils/get-portal.ts +45 -0
  183. package/packages/arcgis-rest-request/src/utils/process-params.ts +99 -0
  184. package/packages/arcgis-rest-request/test/mocks/errors.ts +59 -0
  185. package/packages/arcgis-rest-request/test/mocks/geojson-feature-collection.ts +10 -0
  186. package/packages/arcgis-rest-request/test/mocks/portal.ts +109 -0
  187. package/packages/arcgis-rest-request/test/mocks/sharing-rest-info.ts +38 -0
  188. package/packages/arcgis-rest-request/test/mocks/webmap.ts +38 -0
  189. package/packages/arcgis-rest-request/test/request.test.ts +296 -0
  190. package/packages/arcgis-rest-request/test/utils/ArcGISAuthError.test.ts +167 -0
  191. package/packages/arcgis-rest-request/test/utils/ArcGISRequestError.test.ts +40 -0
  192. package/packages/arcgis-rest-request/test/utils/check-for-errors.test.ts +101 -0
  193. package/packages/arcgis-rest-request/test/utils/encode-form-data.test.ts +112 -0
  194. package/packages/arcgis-rest-request/test/utils/get-portal-url.test.ts +34 -0
  195. package/packages/arcgis-rest-request/test/utils/portal.test.ts +94 -0
  196. package/packages/arcgis-rest-request/test/utils/process-params.test.ts +190 -0
  197. package/packages/arcgis-rest-request/tsconfig.json +6 -0
  198. package/packages/arcgis-rest-sharing/README.md +67 -0
  199. package/packages/arcgis-rest-sharing/package-lock.json +11 -0
  200. package/packages/arcgis-rest-sharing/package.json +55 -0
  201. package/packages/arcgis-rest-sharing/src/access.ts +91 -0
  202. package/packages/arcgis-rest-sharing/src/group-sharing.ts +212 -0
  203. package/packages/arcgis-rest-sharing/src/helpers.ts +92 -0
  204. package/packages/arcgis-rest-sharing/src/index.ts +2 -0
  205. package/packages/arcgis-rest-sharing/test/access.test.ts +153 -0
  206. package/packages/arcgis-rest-sharing/test/group-sharing.test.ts +436 -0
  207. package/packages/arcgis-rest-sharing/test/mocks/sharing.ts +15 -0
  208. package/packages/arcgis-rest-sharing/tsconfig.json +6 -0
  209. package/packages/arcgis-rest-users/README.md +71 -0
  210. package/packages/arcgis-rest-users/package-lock.json +11 -0
  211. package/packages/arcgis-rest-users/package.json +51 -0
  212. package/packages/arcgis-rest-users/src/index.ts +1 -0
  213. package/packages/arcgis-rest-users/src/users.ts +70 -0
  214. package/packages/arcgis-rest-users/test/mocks/responses.ts +170 -0
  215. package/packages/arcgis-rest-users/test/users.test.ts +97 -0
  216. package/packages/arcgis-rest-users/tsconfig.json +6 -0
  217. package/support/FormData.d.ts +1 -0
  218. package/support/changelog.js +388 -0
  219. package/support/commit-template.txt +19 -0
  220. package/support/deploy-doc-site.js +16 -0
  221. package/support/publish.sh +40 -0
  222. package/support/test-helpers.js +8 -0
  223. package/tsconfig.json +69 -0
  224. package/tslint.json +14 -0
  225. package/umd-base-profile.js +82 -0
  226. package/umd-production-profile.js +13 -0
@@ -0,0 +1,220 @@
1
+ import { IFeature } from "@esri/arcgis-rest-common-types";
2
+
3
+ export const featureResponse = {
4
+ feature: {
5
+ attributes: {
6
+ FID: 42
7
+ },
8
+ geometry: {
9
+ x: -9177311.62541634,
10
+ y: 4247151.205222242
11
+ }
12
+ }
13
+ };
14
+
15
+ export const queryResponse = {
16
+ objectIdFieldName: "FID",
17
+ globalIdFieldName: "",
18
+ geometryType: "esriGeometryPoint",
19
+ spatialReference: {
20
+ wkid: 102100,
21
+ latestWkid: 3857
22
+ },
23
+ // fields: [],
24
+ features: [
25
+ {
26
+ attributes: {
27
+ FID: 1,
28
+ Tree_ID: 102,
29
+ Collected: 1349395200000,
30
+ Crew: "Linden+ Forrest+ Johnny",
31
+ Status: "P",
32
+ Spp_Code: "ULPU",
33
+ Land_Use: "I",
34
+ Ht_DBH_ft: 4.5,
35
+ DBH1: 41,
36
+ DBH2: 0,
37
+ DBH3: 0,
38
+ DBH4: 0,
39
+ DBH5: 0,
40
+ DBH6: " ",
41
+ Height: 74,
42
+ Live_Top: 74,
43
+ Crown_Base: 21,
44
+ Width_NS: 75,
45
+ Width_EW: 40,
46
+ Cn_Missing: 10,
47
+ Cn_DieBack: 15,
48
+ CLE: 2,
49
+ Tree_Site: "S",
50
+ Tree_Age: " ",
51
+ Notes: " ",
52
+ Cmn_Name: "Siberian elm",
53
+ Sci_Name: "Ulmus pumila",
54
+ GroundArea: 2596,
55
+ Condition: "Fair",
56
+ Leaf_Area: 10295,
57
+ Leaf_Bmass: 144,
58
+ LAI: 3.96,
59
+ C_Storage: 6771,
60
+ C_Seq: 95,
61
+ S_Value: "3,079.00",
62
+ Street: "YES",
63
+ Native: "NO",
64
+ CO_Rmvd: 5.06,
65
+ O3_Rmvd: 470.97,
66
+ NO2_Rmvd: 39.24,
67
+ PM10_Rmvd: 343.45,
68
+ SO2_Rmvd: 27.64,
69
+ PM2p5_Rmvd: 47.84,
70
+ CO_RVlu: 0.01,
71
+ O3_Rvlu: 0.42,
72
+ NO2_Rvlu: 0,
73
+ PM10_Rvlu: 3.73,
74
+ SO2_Rvlu: 0,
75
+ PM2p5_RVlu: 1.99,
76
+ Isoprene_E: 2.7,
77
+ Monoterp_E: 13.2,
78
+ Vocs_E: 15.9,
79
+ Dedication: " ",
80
+ Longitude: -82.441189,
81
+ Latitude: 35.610441,
82
+ Crown_Height: 53
83
+ }
84
+ },
85
+ {
86
+ attributes: {
87
+ FID: 2,
88
+ Tree_ID: 103,
89
+ Collected: 1349395200000,
90
+ Crew: "Linden+ Forrest+ Johnny",
91
+ Status: "P",
92
+ Spp_Code: "ULPU",
93
+ Land_Use: "I",
94
+ Ht_DBH_ft: 4.5,
95
+ DBH1: 55,
96
+ DBH2: 0,
97
+ DBH3: 0,
98
+ DBH4: 0,
99
+ DBH5: 0,
100
+ DBH6: " ",
101
+ Height: 70,
102
+ Live_Top: 70,
103
+ Crown_Base: 21,
104
+ Width_NS: 90,
105
+ Width_EW: 71,
106
+ Cn_Missing: 5,
107
+ Cn_DieBack: 15,
108
+ CLE: 3,
109
+ Tree_Site: "S",
110
+ Tree_Age: " ",
111
+ Notes: " ",
112
+ Cmn_Name: "Siberian elm",
113
+ Sci_Name: "Ulmus pumila",
114
+ GroundArea: 5089,
115
+ Condition: "Fair",
116
+ Leaf_Area: 17078,
117
+ Leaf_Bmass: 238,
118
+ LAI: 3.36,
119
+ C_Storage: 13228,
120
+ C_Seq: 22,
121
+ S_Value: "4,187.00",
122
+ Street: "YES",
123
+ Native: "NO",
124
+ CO_Rmvd: 8.4,
125
+ O3_Rmvd: 781.35,
126
+ NO2_Rmvd: 65.1,
127
+ PM10_Rmvd: 600.8,
128
+ SO2_Rmvd: 45.86,
129
+ PM2p5_Rmvd: 83.68,
130
+ CO_RVlu: 0.01,
131
+ O3_Rvlu: 0.69,
132
+ NO2_Rvlu: 0.01,
133
+ PM10_Rvlu: 6.53,
134
+ SO2_Rvlu: 0,
135
+ PM2p5_RVlu: 3.48,
136
+ Isoprene_E: 4.47,
137
+ Monoterp_E: 21.9,
138
+ Vocs_E: 26.38,
139
+ Dedication: " ",
140
+ Longitude: -82.441107,
141
+ Latitude: 35.610472,
142
+ Crown_Height: 49
143
+ }
144
+ }
145
+ ]
146
+ };
147
+
148
+ export const addFeaturesResponse = {
149
+ addResults: [
150
+ {
151
+ objectId: 1001,
152
+ success: true
153
+ }
154
+ ]
155
+ };
156
+
157
+ export const updateFeaturesResponse = {
158
+ updateResults: [
159
+ {
160
+ objectId: 1001,
161
+ success: true
162
+ }
163
+ ]
164
+ };
165
+
166
+ export const deleteFeaturesResponse = {
167
+ deleteResults: [
168
+ {
169
+ objectId: 1001,
170
+ success: true
171
+ }
172
+ ]
173
+ };
174
+
175
+ export const getAttachmentsResponse = {
176
+ attachmentInfos: [
177
+ {
178
+ id: 409,
179
+ contentType: "application/pdf",
180
+ size: 400633,
181
+ name: "Permit_Application_20180416"
182
+ },
183
+ {
184
+ id: 822,
185
+ contentType: "application/pdf",
186
+ size: 619543,
187
+ name: "Planning_Review_20180604"
188
+ }
189
+ ]
190
+ };
191
+
192
+ export const addAttachmentResponse = {
193
+ addAttachmentResult: {
194
+ objectId: 1001,
195
+ success: true
196
+ }
197
+ };
198
+
199
+ export const updateAttachmentResponse = {
200
+ updateAttachmentResult: {
201
+ objectId: 1001,
202
+ success: true
203
+ }
204
+ };
205
+
206
+ export const deleteAttachmentsResponse = {
207
+ deleteAttachmentResults: [
208
+ {
209
+ objectId: 1001,
210
+ success: true
211
+ }
212
+ ]
213
+ };
214
+
215
+ export const genericInvalidResponse = {
216
+ error: {
217
+ code: 400,
218
+ message: "Invalid or missing input parameters."
219
+ }
220
+ };
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "include": [
4
+ "src/**/*.ts"
5
+ ]
6
+ }
@@ -0,0 +1,73 @@
1
+ [![npm version][npm-img]][npm-url]
2
+ [![build status][travis-img]][travis-url]
3
+ [![apache licensed](https://img.shields.io/badge/license-Apache-green.svg?style=flat-square)](https://raw.githubusercontent.com/Esri/arcgis-rest-js/master/LICENSE)
4
+
5
+ [npm-img]: https://img.shields.io/npm/v/@esri/arcgis-rest-geocoder.svg?style=flat-square
6
+ [npm-url]: https://www.npmjs.com/package/@esri/arcgis-rest-geocoder
7
+ [travis-img]: https://img.shields.io/travis/Esri/arcgis-rest-js/master.svg?style=flat-square
8
+ [travis-url]: https://travis-ci.org/Esri/arcgis-rest-js
9
+
10
+ # @esri/arcgis-rest-geocoder
11
+
12
+ > Geocoding helpers for [`@esri/arcgis-rest-request`](https://github.com/Esri/arcgis-rest-js).
13
+
14
+ ### Example
15
+
16
+ ```bash
17
+ npm install @esri/arcgis-rest-request
18
+ npm install @esri/arcgis-rest-geocoder
19
+ ```
20
+
21
+ ```js
22
+ import { geocode } from '@esri/arcgis-rest-geocoder';
23
+
24
+ geocode("LAX")
25
+ .then((response) => {
26
+ response.candidates[0].location;
27
+ // => { x: -118.409, y: 33.943 }
28
+ });
29
+ ```
30
+
31
+ ### [API Reference](https://esri.github.io/arcgis-rest-js/api/geocoder/)
32
+
33
+ * [`geocode("1 World Way Los Angeles 90045")`](https://esri.github.io/arcgis-rest-js/api/geocoder/geocode/)
34
+
35
+ * [`suggest("Starb")`](https://esri.github.io/arcgis-rest-js/api/geocoder/suggest/)
36
+
37
+ * [`reverseGeocode([-118.409,33.943 ])`](https://esri.github.io/arcgis-rest-js/api/geocoder/reverseGeocode/)
38
+
39
+ * [`bulkGeocode()`](https://esri.github.io/arcgis-rest-js/api/geocoder/bulkGeocode/)
40
+
41
+ ### Issues
42
+
43
+ If something isn't working the way you expected, please take a look at [previously logged issues](https://github.com/Esri/arcgis-rest-js/issues) first. Have you found a new bug? Want to request a new feature? We'd [**love**](https://github.com/Esri/arcgis-rest-js/issues/new) to hear from you.
44
+
45
+ If you're looking for help you can also post issues on [GIS Stackexchange](http://gis.stackexchange.com/questions/ask?tags=esri-oss).
46
+
47
+ ### Versioning
48
+
49
+ For transparency into the release cycle and in striving to maintain backward compatibility, @esri/arcgis-rest-js is maintained under Semantic Versioning guidelines and will adhere to these rules whenever possible.
50
+
51
+ For more information on SemVer, please visit <http://semver.org/>.
52
+
53
+ ### Contributing
54
+
55
+ Esri welcomes contributions from anyone and everyone. Please see our [guidelines for contributing](CONTRIBUTING.md).
56
+
57
+ ### License
58
+
59
+ Copyright &copy; 2017-2018 Esri
60
+
61
+ Licensed under the Apache License, Version 2.0 (the "License");
62
+ you may not use this file except in compliance with the License.
63
+ You may obtain a copy of the License at
64
+
65
+ > http://www.apache.org/licenses/LICENSE-2.0
66
+
67
+ Unless required by applicable law or agreed to in writing, software
68
+ distributed under the License is distributed on an "AS IS" BASIS,
69
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
70
+ See the License for the specific language governing permissions and
71
+ limitations under the License.
72
+
73
+ A copy of the license is available in the repository's [LICENSE](../../LICENSE) file.
@@ -0,0 +1,11 @@
1
+ {
2
+ "requires": true,
3
+ "lockfileVersion": 1,
4
+ "dependencies": {
5
+ "tslib": {
6
+ "version": "1.7.1",
7
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.7.1.tgz",
8
+ "integrity": "sha1-vIAEFkaRkjp5/oN4u+s9ogF1OOw="
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@esri/arcgis-rest-geocoder",
3
+ "version": "1.6.0",
4
+ "description": "Geocoding helpers for @esri/arcgis-rest-request",
5
+ "main": "dist/node/index.js",
6
+ "browser": "dist/umd/geocoder.umd.js",
7
+ "module": "dist/esm/index.js",
8
+ "js:next": "dist/esm/index.js",
9
+ "types": "dist/esm/index.d.ts",
10
+ "license": "Apache-2.0",
11
+ "files": [
12
+ "dist/**"
13
+ ],
14
+ "dependencies": {
15
+ "tslib": "^1.7.1"
16
+ },
17
+ "peerDependencies": {
18
+ "@esri/arcgis-rest-auth": "^1.5.1",
19
+ "@esri/arcgis-rest-common-types": "^1.5.1",
20
+ "@esri/arcgis-rest-request": "^1.5.1"
21
+ },
22
+ "devDependencies": {
23
+ "@esri/arcgis-rest-auth": "^1.6.0",
24
+ "@esri/arcgis-rest-common-types": "^1.6.0",
25
+ "@esri/arcgis-rest-request": "^1.6.0"
26
+ },
27
+ "scripts": {
28
+ "prepare": "npm run build",
29
+ "build": "npm run build:node && npm run build:umd && npm run build:esm",
30
+ "build:esm": "tsc -p ./tsconfig.json --module es2015 --outDir ./dist/esm --declaration",
31
+ "build:umd": "rollup -c ../../umd-base-profile.js && rollup -c ../../umd-production-profile.js",
32
+ "build:node": "tsc -p ./tsconfig.json --module commonjs --outDir ./dist/node"
33
+ },
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "git+https://github.com/Esri/arcgis-rest-js.git"
40
+ },
41
+ "contributors": [
42
+ {
43
+ "name": "Patrick Arlt",
44
+ "email": "parlt@esri.com",
45
+ "url": "http://patrickarlt.com/"
46
+ }
47
+ ],
48
+ "bugs": {
49
+ "url": "https://github.com/Esri/arcgis-rest-js/issues"
50
+ },
51
+ "homepage": "https://github.com/Esri/arcgis-rest-js#readme"
52
+ }
@@ -0,0 +1,102 @@
1
+ /* Copyright (c) 2017 Environmental Systems Research Institute, Inc.
2
+ * Apache-2.0 */
3
+
4
+ import { request } from "@esri/arcgis-rest-request";
5
+
6
+ import { ISpatialReference, IPoint } from "@esri/arcgis-rest-common-types";
7
+
8
+ import { worldGeocoder, IEndpointRequestOptions } from "./helpers";
9
+
10
+ // it'd be better if doc didnt display these properties in alphabetical order
11
+ export interface IAddressBulk {
12
+ /**
13
+ * A unique id must be passed along for each individual address.
14
+ */
15
+ OBJECTID: number;
16
+ address?: string;
17
+ address2?: string;
18
+ address3?: string;
19
+ neighborhood?: string;
20
+ city?: string;
21
+ subregion?: string;
22
+ /**
23
+ * The World Geocoding Service considers US states regions.
24
+ */
25
+ region?: string;
26
+ postal?: number;
27
+ postalExt?: number;
28
+ countryCode?: string;
29
+ }
30
+
31
+ export interface IBulkGeocodeRequestOptions extends IEndpointRequestOptions {
32
+ addresses: IAddressBulk[];
33
+ }
34
+
35
+ export interface IBulkGeocodeResponse {
36
+ spatialReference: ISpatialReference;
37
+ locations: Array<{
38
+ address: string;
39
+ location: IPoint;
40
+ score: number;
41
+ attributes: object;
42
+ }>;
43
+ }
44
+
45
+ /**
46
+ * Used to geocode a batch of addresses
47
+ *
48
+ * ```js
49
+ * import { bulkGeocode } from '@esri/arcgis-rest-geocoder';
50
+ * import { ApplicationSession } from '@esri/arcgis-rest-auth';
51
+ *
52
+ * const addresses = [
53
+ * { "OBJECTID": 1, "SingleLine": "380 New York Street 92373" },
54
+ * { "OBJECTID": 2, "SingleLine": "1 World Way Los Angeles 90045" }
55
+ * ];
56
+ *
57
+ * bulkGeocode({ addresses, authentication: session })
58
+ * .then((response) => {
59
+ * response.locations[0].location; // => { x: -117, y: 34, spatialReference: { wkid: 4326 } }
60
+ * });
61
+ * ```
62
+ *
63
+ * @param requestOptions - Request options to pass to the geocoder, including an array of addresses and authentication session.
64
+ * @returns A Promise that will resolve with the data from the response.
65
+ */
66
+ export function bulkGeocode(
67
+ requestOptions: IBulkGeocodeRequestOptions // must POST
68
+ ) {
69
+ const options: IBulkGeocodeRequestOptions = {
70
+ endpoint: worldGeocoder,
71
+ params: {
72
+ forStorage: true,
73
+ addresses: { records: [] }
74
+ },
75
+ ...requestOptions
76
+ };
77
+
78
+ requestOptions.addresses.forEach(address => {
79
+ options.params.addresses.records.push({ attributes: address });
80
+ });
81
+
82
+ // the SAS service doesnt support anonymous requests
83
+ if (!requestOptions.authentication && options.endpoint === worldGeocoder) {
84
+ return Promise.reject(
85
+ "bulk geocoding using the ArcGIS service requires authentication"
86
+ );
87
+ }
88
+
89
+ return request(options.endpoint + "geocodeAddresses", options).then(
90
+ response => {
91
+ const sr = response.spatialReference;
92
+ response.locations.forEach(function(address: { location: IPoint }) {
93
+ address.location.spatialReference = sr;
94
+ });
95
+ return response;
96
+ }
97
+ );
98
+ }
99
+
100
+ export default {
101
+ bulkGeocode
102
+ };
@@ -0,0 +1,117 @@
1
+ /* Copyright (c) 2017 Environmental Systems Research Institute, Inc.
2
+ * Apache-2.0 */
3
+
4
+ import { request, IParams } from "@esri/arcgis-rest-request";
5
+
6
+ import {
7
+ IExtent,
8
+ ISpatialReference,
9
+ IPoint
10
+ } from "@esri/arcgis-rest-common-types";
11
+
12
+ import { worldGeocoder, IEndpointRequestOptions } from "./helpers";
13
+
14
+ export interface IGeocodeParams extends IParams {
15
+ /**
16
+ * You can create an autocomplete experience by making a call to suggest with partial text and then passing through the magicKey and complete address that are returned to geocode.
17
+ * ```js
18
+ * import { suggest, geocode } from '@esri/arcgis-rest-geocoder';
19
+ * suggest("LAX")
20
+ * .then((response) => {
21
+ * response.suggestions[2].magicKey; // => "dHA9MCNsb2M9Mjk3ODc2MCNsbmc9MzMjcGw9ODkxNDg4I2xicz0xNDoxNDc4MTI1MA=="
22
+ * });
23
+ * geocode("LAX, 1 World Way, Los Angeles, CA, 90045, USA", {magicKey: "dHA9MCN..."})
24
+ * ```
25
+ */
26
+ magicKey?: string;
27
+ }
28
+
29
+ export interface IGeocodeRequestOptions extends IEndpointRequestOptions {
30
+ address?: string;
31
+ address2?: string;
32
+ address3?: string;
33
+ neighborhood?: string;
34
+ city?: string;
35
+ subregion?: string;
36
+ /**
37
+ * The World Geocoding Service expects US states to be passed in as a 'region'.
38
+ */
39
+ region?: string;
40
+ postal?: number;
41
+ postalExt?: number;
42
+ countryCode?: string;
43
+ }
44
+
45
+ export interface IGeocodeResponse {
46
+ spatialReference: ISpatialReference;
47
+ candidates: Array<{
48
+ address: string;
49
+ location: IPoint;
50
+ extent: IExtent;
51
+ attributes: object;
52
+ }>;
53
+ }
54
+
55
+ /**
56
+ * Used to determine the location of a single address or point of interest
57
+ *
58
+ * ```js
59
+ * import { geocode } from '@esri/arcgis-rest-geocoder';
60
+ *
61
+ * geocode("LAX")
62
+ * .then((response) => {
63
+ * response.candidates[0].location; // => { x: -118.409, y: 33.943, spatialReference: { wkid: 4326 } }
64
+ * });
65
+ *
66
+ * geocode({
67
+ * params: {
68
+ * address: "1600 Pennsylvania Ave",
69
+ * postal: 20500,
70
+ * countryCode: "USA"
71
+ * }
72
+ * })
73
+ * .then((response) => {
74
+ * response.candidates[0].location; // => { x: -77.036533, y: 38.898719, spatialReference: { wkid: 4326 } }
75
+ * });
76
+ * ```
77
+ *
78
+ * @param address String representing the address or point of interest or RequestOptions to pass to the endpoint.
79
+ * @returns A Promise that will resolve with address candidates for the request.
80
+ */
81
+ export function geocode(
82
+ address: string | IGeocodeRequestOptions
83
+ ): Promise<IGeocodeResponse> {
84
+ let options: IGeocodeRequestOptions = {
85
+ endpoint: worldGeocoder,
86
+ params: {}
87
+ };
88
+
89
+ if (typeof address === "string") {
90
+ options.params.singleLine = address;
91
+ } else {
92
+ options.endpoint = address.endpoint || worldGeocoder;
93
+ options = {
94
+ ...options,
95
+ ...address
96
+ };
97
+ }
98
+
99
+ // add spatialReference property to individual matches
100
+ return request(options.endpoint + "findAddressCandidates", options).then(
101
+ response => {
102
+ const sr = response.spatialReference;
103
+ response.candidates.forEach(function(candidate: {
104
+ location: IPoint;
105
+ extent: IExtent;
106
+ }) {
107
+ candidate.location.spatialReference = sr;
108
+ candidate.extent.spatialReference = sr;
109
+ });
110
+ return response;
111
+ }
112
+ );
113
+ }
114
+
115
+ export default {
116
+ geocode
117
+ };
@@ -0,0 +1,81 @@
1
+ /* Copyright (c) 2017 Environmental Systems Research Institute, Inc.
2
+ * Apache-2.0 */
3
+
4
+ import { request, IRequestOptions, warn } from "@esri/arcgis-rest-request";
5
+
6
+ import { IPoint } from "@esri/arcgis-rest-common-types";
7
+
8
+ // https always
9
+ export const worldGeocoder =
10
+ "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/";
11
+
12
+ export interface ILocation {
13
+ latitude?: number;
14
+ longitude?: number;
15
+ lat?: number;
16
+ long?: number;
17
+ }
18
+
19
+ // nice to have: verify custom endpoints contain 'GeocodeServer' and end in a '/'
20
+ export interface IEndpointRequestOptions extends IRequestOptions {
21
+ /**
22
+ * Any ArcGIS Geocoding service (example: http://sampleserver6.arcgisonline.com/arcgis/rest/services/Locators/SanDiego/GeocodeServer )
23
+ */
24
+ endpoint?: string;
25
+ }
26
+
27
+ export interface IGetGeocodeServiceResponse {
28
+ currentVersion: number;
29
+ serviceDescription: string;
30
+ addressFields: any[];
31
+ countries: string[];
32
+ capabilities: string;
33
+ }
34
+
35
+ /**
36
+ * Used to fetch metadata from a geocoding service.
37
+ *
38
+ * ```js
39
+ * import { getGeocoderServiceInfo } from '@esri/arcgis-rest-geocoder';
40
+ *
41
+ * getGeocoderServiceInfo()
42
+ * .then((response) => {
43
+ * response.serviceDescription; // => 'World Geocoder'
44
+ * });
45
+ * ```
46
+ *
47
+ * @param requestOptions - Request options can contain a custom geocoding service to fetch metadata from.
48
+ * @returns A Promise that will resolve with the data from the response.
49
+ */
50
+ export function getGeocodeService(
51
+ requestOptions?: IEndpointRequestOptions
52
+ ): Promise<IGetGeocodeServiceResponse> {
53
+ const url = (requestOptions && requestOptions.endpoint) || worldGeocoder;
54
+
55
+ const options: IEndpointRequestOptions = {
56
+ httpMethod: "GET",
57
+ maxUrlLength: 2000,
58
+ ...requestOptions
59
+ };
60
+
61
+ return request(url, options);
62
+ }
63
+
64
+ /**
65
+ * Deprecated. Please use [`getGeocodeService()`](../getGeocodeService/) instead.
66
+ *
67
+ * @param requestOptions - Request options can contain a custom geocoding service to fetch metadata from.
68
+ * @returns A Promise that will resolve with the data from the response.
69
+ */
70
+ export function serviceInfo(
71
+ requestOptions?: IEndpointRequestOptions
72
+ ): Promise<IGetGeocodeServiceResponse> {
73
+ warn(
74
+ "serviceInfo() will be deprecated in the next major release. please use getGeocoderServiceInfo() instead."
75
+ );
76
+ return getGeocodeService(requestOptions);
77
+ }
78
+
79
+ export default {
80
+ getGeocodeService
81
+ };
@@ -0,0 +1,4 @@
1
+ export * from "./geocode";
2
+ export * from "./suggest";
3
+ export * from "./reverse";
4
+ export * from "./bulk";