delectusnon 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (276) hide show
  1. package/.prettierignore +2 -0
  2. package/.travis.yml +33 -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 +15 -0
  18. package/demos/batch-geocoder-node/batch-geocode.js +118 -0
  19. package/demos/batch-geocoder-node/config-template.js +18 -0
  20. package/demos/batch-geocoder-node/package-lock.json +116 -0
  21. package/demos/batch-geocoder-node/package.json +39 -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 +473 -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 +182 -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/oauth2-browser-retry/README.md +25 -0
  51. package/demos/oauth2-browser-retry/authenticate.html +21 -0
  52. package/demos/oauth2-browser-retry/index.html +116 -0
  53. package/demos/oauth2-browser-retry/logo.svg +4 -0
  54. package/demos/vue/.env.example +11 -0
  55. package/demos/vue/.eslintrc.js +17 -0
  56. package/demos/vue/.postcssrc.js +5 -0
  57. package/demos/vue/README.md +17 -0
  58. package/demos/vue/babel.config.js +3 -0
  59. package/demos/vue/package-lock.json +11323 -0
  60. package/demos/vue/package.json +33 -0
  61. package/demos/vue/public/favicon.ico +0 -0
  62. package/demos/vue/public/index.html +24 -0
  63. package/demos/vue/src/assets/logo.svg +29 -0
  64. package/demos/vue/src/components/App.vue +308 -0
  65. package/demos/vue/src/components/Authenticate.vue +65 -0
  66. package/demos/vue/src/components/Loader.vue +230 -0
  67. package/demos/vue/src/main.js +92 -0
  68. package/docs/FAQ.md +28 -0
  69. package/docs/HISTORY.md +62 -0
  70. package/docs/acetate.config.js +223 -0
  71. package/docs/build-typedoc.js +301 -0
  72. package/docs/src/_layout.html +82 -0
  73. package/docs/src/api/_declaration.html +496 -0
  74. package/docs/src/api/_layout.html +127 -0
  75. package/docs/src/api/_package.html +13 -0
  76. package/docs/src/api/index.html +23 -0
  77. package/docs/src/guides/_layout.html +24 -0
  78. package/docs/src/guides/amd-requirejs-dojo.md +40 -0
  79. package/docs/src/guides/babel-and-rollup.md +30 -0
  80. package/docs/src/guides/babel-and-webpack.md +30 -0
  81. package/docs/src/guides/browser-authentication.md +31 -0
  82. package/docs/src/guides/browserify.md +9 -0
  83. package/docs/src/guides/cli-authentication.md +9 -0
  84. package/docs/src/guides/client-server-authentication.md +9 -0
  85. package/docs/src/guides/from-a-cdn.md +36 -0
  86. package/docs/src/guides/index.md +52 -0
  87. package/docs/src/guides/node.md +70 -0
  88. package/docs/src/guides/package-overview.md +8 -0
  89. package/docs/src/guides/server-authentication.md +9 -0
  90. package/docs/src/guides/typescript-and-webpack.md +9 -0
  91. package/docs/src/img/icons.png +0 -0
  92. package/docs/src/img/icons@2x.png +0 -0
  93. package/docs/src/index.html +12 -0
  94. package/docs/src/js/api-search.js +112 -0
  95. package/docs/src/js/nav-toggle.js +41 -0
  96. package/docs/src/sass/_highlight.scss +96 -0
  97. package/docs/src/sass/_icons.scss +157 -0
  98. package/docs/src/sass/style.scss +169 -0
  99. package/jasmine.json +7 -0
  100. package/karma.conf.js +100 -0
  101. package/lerna.json +8 -0
  102. package/notes/README.md +88 -0
  103. package/package.json +88 -0
  104. package/packages/arcgis-rest-auth/README.md +64 -0
  105. package/packages/arcgis-rest-auth/package-lock.json +11 -0
  106. package/packages/arcgis-rest-auth/package.json +51 -0
  107. package/packages/arcgis-rest-auth/src/ApplicationSession.ts +109 -0
  108. package/packages/arcgis-rest-auth/src/UserSession.ts +873 -0
  109. package/packages/arcgis-rest-auth/src/authenticated-request-options.ts +24 -0
  110. package/packages/arcgis-rest-auth/src/fetch-token.ts +52 -0
  111. package/packages/arcgis-rest-auth/src/generate-token.ts +39 -0
  112. package/packages/arcgis-rest-auth/src/index.ts +8 -0
  113. package/packages/arcgis-rest-auth/test/ApplicationSession.test.ts +124 -0
  114. package/packages/arcgis-rest-auth/test/UserSession.test.ts +995 -0
  115. package/packages/arcgis-rest-auth/test/fetchToken.test.ts +112 -0
  116. package/packages/arcgis-rest-auth/test/generateToken.test.ts +130 -0
  117. package/packages/arcgis-rest-auth/test/utils.ts +14 -0
  118. package/packages/arcgis-rest-auth/tsconfig.json +6 -0
  119. package/packages/arcgis-rest-common-types/README.md +61 -0
  120. package/packages/arcgis-rest-common-types/package.json +38 -0
  121. package/packages/arcgis-rest-common-types/src/group.ts +54 -0
  122. package/packages/arcgis-rest-common-types/src/index.ts +467 -0
  123. package/packages/arcgis-rest-common-types/src/item.ts +45 -0
  124. package/packages/arcgis-rest-common-types/src/webmap.ts +1232 -0
  125. package/packages/arcgis-rest-common-types/tsconfig.json +11 -0
  126. package/packages/arcgis-rest-feature-service/README.md +70 -0
  127. package/packages/arcgis-rest-feature-service/package-lock.json +11 -0
  128. package/packages/arcgis-rest-feature-service/package.json +50 -0
  129. package/packages/arcgis-rest-feature-service/src/add.ts +81 -0
  130. package/packages/arcgis-rest-feature-service/src/addAttachment.ts +65 -0
  131. package/packages/arcgis-rest-feature-service/src/delete.ts +85 -0
  132. package/packages/arcgis-rest-feature-service/src/deleteAttachments.ts +68 -0
  133. package/packages/arcgis-rest-feature-service/src/getAttachments.ts +64 -0
  134. package/packages/arcgis-rest-feature-service/src/helpers.ts +80 -0
  135. package/packages/arcgis-rest-feature-service/src/index.ts +12 -0
  136. package/packages/arcgis-rest-feature-service/src/query.ts +172 -0
  137. package/packages/arcgis-rest-feature-service/src/queryRelated.ts +91 -0
  138. package/packages/arcgis-rest-feature-service/src/update.ts +81 -0
  139. package/packages/arcgis-rest-feature-service/src/updateAttachment.ts +74 -0
  140. package/packages/arcgis-rest-feature-service/test/attachments.test.ts +203 -0
  141. package/packages/arcgis-rest-feature-service/test/features.test.ts +252 -0
  142. package/packages/arcgis-rest-feature-service/test/mocks/feature.ts +279 -0
  143. package/packages/arcgis-rest-feature-service/test/mocks/foo.txt +1 -0
  144. package/packages/arcgis-rest-feature-service/tsconfig.json +6 -0
  145. package/packages/arcgis-rest-feature-service-admin/README.md +66 -0
  146. package/packages/arcgis-rest-feature-service-admin/package-lock.json +11 -0
  147. package/packages/arcgis-rest-feature-service-admin/package.json +53 -0
  148. package/packages/arcgis-rest-feature-service-admin/src/addTo.ts +70 -0
  149. package/packages/arcgis-rest-feature-service-admin/src/create.ts +195 -0
  150. package/packages/arcgis-rest-feature-service-admin/src/index.ts +2 -0
  151. package/packages/arcgis-rest-feature-service-admin/test/addTo.test.ts +310 -0
  152. package/packages/arcgis-rest-feature-service-admin/test/create.test.ts +412 -0
  153. package/packages/arcgis-rest-feature-service-admin/test/mocks/move.ts +14 -0
  154. package/packages/arcgis-rest-feature-service-admin/test/mocks/service.ts +72 -0
  155. package/packages/arcgis-rest-feature-service-admin/tsconfig.json +6 -0
  156. package/packages/arcgis-rest-geocoder/README.md +79 -0
  157. package/packages/arcgis-rest-geocoder/package-lock.json +11 -0
  158. package/packages/arcgis-rest-geocoder/package.json +52 -0
  159. package/packages/arcgis-rest-geocoder/src/bulk.ts +102 -0
  160. package/packages/arcgis-rest-geocoder/src/geocode.ts +117 -0
  161. package/packages/arcgis-rest-geocoder/src/helpers.ts +79 -0
  162. package/packages/arcgis-rest-geocoder/src/index.ts +8 -0
  163. package/packages/arcgis-rest-geocoder/src/reverse.ts +84 -0
  164. package/packages/arcgis-rest-geocoder/src/suggest.ts +72 -0
  165. package/packages/arcgis-rest-geocoder/test/bulk.test.ts +113 -0
  166. package/packages/arcgis-rest-geocoder/test/geocode.test.ts +121 -0
  167. package/packages/arcgis-rest-geocoder/test/helpers.test.ts +113 -0
  168. package/packages/arcgis-rest-geocoder/test/mocks/responses.ts +591 -0
  169. package/packages/arcgis-rest-geocoder/test/reverse.test.ts +126 -0
  170. package/packages/arcgis-rest-geocoder/test/suggest.test.ts +77 -0
  171. package/packages/arcgis-rest-geocoder/tsconfig.json +6 -0
  172. package/packages/arcgis-rest-groups/README.md +64 -0
  173. package/packages/arcgis-rest-groups/package-lock.json +11 -0
  174. package/packages/arcgis-rest-groups/package.json +52 -0
  175. package/packages/arcgis-rest-groups/src/create.ts +34 -0
  176. package/packages/arcgis-rest-groups/src/get.ts +95 -0
  177. package/packages/arcgis-rest-groups/src/helpers.ts +26 -0
  178. package/packages/arcgis-rest-groups/src/index.ts +11 -0
  179. package/packages/arcgis-rest-groups/src/notification.ts +77 -0
  180. package/packages/arcgis-rest-groups/src/protect.ts +40 -0
  181. package/packages/arcgis-rest-groups/src/remove.ts +23 -0
  182. package/packages/arcgis-rest-groups/src/search.ts +64 -0
  183. package/packages/arcgis-rest-groups/src/update.ts +36 -0
  184. package/packages/arcgis-rest-groups/test/crud.test.ts +104 -0
  185. package/packages/arcgis-rest-groups/test/get.test.ts +101 -0
  186. package/packages/arcgis-rest-groups/test/mocks/responses.ts +141 -0
  187. package/packages/arcgis-rest-groups/test/notification.test.ts +102 -0
  188. package/packages/arcgis-rest-groups/test/protect.test.ts +64 -0
  189. package/packages/arcgis-rest-groups/test/search.test.ts +85 -0
  190. package/packages/arcgis-rest-groups/tsconfig.json +6 -0
  191. package/packages/arcgis-rest-items/README.md +66 -0
  192. package/packages/arcgis-rest-items/package-lock.json +11 -0
  193. package/packages/arcgis-rest-items/package.json +52 -0
  194. package/packages/arcgis-rest-items/src/add.ts +103 -0
  195. package/packages/arcgis-rest-items/src/create.ts +110 -0
  196. package/packages/arcgis-rest-items/src/get.ts +79 -0
  197. package/packages/arcgis-rest-items/src/helpers.ts +147 -0
  198. package/packages/arcgis-rest-items/src/index.ts +11 -0
  199. package/packages/arcgis-rest-items/src/protect.ts +38 -0
  200. package/packages/arcgis-rest-items/src/remove.ts +58 -0
  201. package/packages/arcgis-rest-items/src/search.ts +78 -0
  202. package/packages/arcgis-rest-items/src/update.ts +134 -0
  203. package/packages/arcgis-rest-items/test/add.test.ts +256 -0
  204. package/packages/arcgis-rest-items/test/create.test.ts +371 -0
  205. package/packages/arcgis-rest-items/test/get.test.ts +181 -0
  206. package/packages/arcgis-rest-items/test/mocks/foo.zip +0 -0
  207. package/packages/arcgis-rest-items/test/mocks/item.ts +33 -0
  208. package/packages/arcgis-rest-items/test/mocks/resources.ts +31 -0
  209. package/packages/arcgis-rest-items/test/mocks/search.ts +63 -0
  210. package/packages/arcgis-rest-items/test/protect.test.ts +122 -0
  211. package/packages/arcgis-rest-items/test/remove.test.ts +161 -0
  212. package/packages/arcgis-rest-items/test/search.test.ts +159 -0
  213. package/packages/arcgis-rest-items/test/update.test.ts +450 -0
  214. package/packages/arcgis-rest-items/tsconfig.json +6 -0
  215. package/packages/arcgis-rest-request/README.md +65 -0
  216. package/packages/arcgis-rest-request/package-lock.json +11 -0
  217. package/packages/arcgis-rest-request/package.json +42 -0
  218. package/packages/arcgis-rest-request/src/index.ts +13 -0
  219. package/packages/arcgis-rest-request/src/request.ts +293 -0
  220. package/packages/arcgis-rest-request/src/utils/ArcGISAuthError.ts +67 -0
  221. package/packages/arcgis-rest-request/src/utils/ArcGISRequestError.ts +76 -0
  222. package/packages/arcgis-rest-request/src/utils/ErrorTypes.ts +29 -0
  223. package/packages/arcgis-rest-request/src/utils/check-for-errors.ts +65 -0
  224. package/packages/arcgis-rest-request/src/utils/encode-form-data.ts +34 -0
  225. package/packages/arcgis-rest-request/src/utils/encode-query-string.ts +23 -0
  226. package/packages/arcgis-rest-request/src/utils/get-portal-url.ts +25 -0
  227. package/packages/arcgis-rest-request/src/utils/get-portal.ts +45 -0
  228. package/packages/arcgis-rest-request/src/utils/process-params.ts +99 -0
  229. package/packages/arcgis-rest-request/test/mocks/errors.ts +68 -0
  230. package/packages/arcgis-rest-request/test/mocks/geojson-feature-collection.ts +13 -0
  231. package/packages/arcgis-rest-request/test/mocks/portal.ts +112 -0
  232. package/packages/arcgis-rest-request/test/mocks/sharing-rest-info.ts +41 -0
  233. package/packages/arcgis-rest-request/test/mocks/webmap.ts +41 -0
  234. package/packages/arcgis-rest-request/test/request.test.ts +299 -0
  235. package/packages/arcgis-rest-request/test/utils/ArcGISAuthError.test.ts +170 -0
  236. package/packages/arcgis-rest-request/test/utils/ArcGISRequestError.test.ts +51 -0
  237. package/packages/arcgis-rest-request/test/utils/check-for-errors.test.ts +111 -0
  238. package/packages/arcgis-rest-request/test/utils/encode-form-data.test.ts +133 -0
  239. package/packages/arcgis-rest-request/test/utils/get-portal-url.test.ts +37 -0
  240. package/packages/arcgis-rest-request/test/utils/portal.test.ts +97 -0
  241. package/packages/arcgis-rest-request/test/utils/process-params.test.ts +193 -0
  242. package/packages/arcgis-rest-request/tsconfig.json +6 -0
  243. package/packages/arcgis-rest-sharing/README.md +67 -0
  244. package/packages/arcgis-rest-sharing/package-lock.json +11 -0
  245. package/packages/arcgis-rest-sharing/package.json +57 -0
  246. package/packages/arcgis-rest-sharing/src/access.ts +85 -0
  247. package/packages/arcgis-rest-sharing/src/group-sharing.ts +211 -0
  248. package/packages/arcgis-rest-sharing/src/helpers.ts +82 -0
  249. package/packages/arcgis-rest-sharing/src/index.ts +5 -0
  250. package/packages/arcgis-rest-sharing/test/access.test.ts +154 -0
  251. package/packages/arcgis-rest-sharing/test/group-sharing.test.ts +566 -0
  252. package/packages/arcgis-rest-sharing/test/helpers.test.ts +55 -0
  253. package/packages/arcgis-rest-sharing/test/mocks/sharing.ts +18 -0
  254. package/packages/arcgis-rest-sharing/tsconfig.json +6 -0
  255. package/packages/arcgis-rest-users/README.md +71 -0
  256. package/packages/arcgis-rest-users/package-lock.json +11 -0
  257. package/packages/arcgis-rest-users/package.json +51 -0
  258. package/packages/arcgis-rest-users/src/get.ts +69 -0
  259. package/packages/arcgis-rest-users/src/index.ts +6 -0
  260. package/packages/arcgis-rest-users/src/invitation.ts +166 -0
  261. package/packages/arcgis-rest-users/src/notification.ts +73 -0
  262. package/packages/arcgis-rest-users/test/get.test.ts +99 -0
  263. package/packages/arcgis-rest-users/test/invitation.test.ts +169 -0
  264. package/packages/arcgis-rest-users/test/mocks/invitation.ts +70 -0
  265. package/packages/arcgis-rest-users/test/mocks/notification.ts +34 -0
  266. package/packages/arcgis-rest-users/test/mocks/user.ts +173 -0
  267. package/packages/arcgis-rest-users/test/notification.test.ts +83 -0
  268. package/packages/arcgis-rest-users/tsconfig.json +6 -0
  269. package/support/changelog.js +394 -0
  270. package/support/deploy-doc-site.js +16 -0
  271. package/support/publish.sh +43 -0
  272. package/support/test-helpers.js +8 -0
  273. package/tsconfig.json +69 -0
  274. package/tslint.json +15 -0
  275. package/umd-base-profile.js +82 -0
  276. package/umd-production-profile.js +13 -0
@@ -0,0 +1,252 @@
1
+ /* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
2
+ * Apache-2.0 */
3
+
4
+ import {
5
+ getFeature,
6
+ queryFeatures,
7
+ addFeatures,
8
+ updateFeatures,
9
+ deleteFeatures,
10
+ queryRelated,
11
+ IDeleteFeaturesRequestOptions,
12
+ IUpdateFeaturesRequestOptions,
13
+ IQueryRelatedRequestOptions
14
+ } from "../src/index";
15
+
16
+ import * as fetchMock from "fetch-mock";
17
+
18
+ import {
19
+ featureResponse,
20
+ queryResponse,
21
+ addFeaturesResponse,
22
+ updateFeaturesResponse,
23
+ deleteFeaturesResponse,
24
+ queryRelatedResponse
25
+ } from "./mocks/feature";
26
+
27
+ const serviceUrl =
28
+ "https://services.arcgis.com/f8b/arcgis/rest/services/Custom/FeatureServer/0";
29
+
30
+ describe("feature", () => {
31
+ afterEach(fetchMock.restore);
32
+
33
+ it("should return a feature by id", done => {
34
+ const requestOptions = {
35
+ url: serviceUrl,
36
+ id: 42
37
+ };
38
+ fetchMock.once("*", featureResponse);
39
+ getFeature(requestOptions)
40
+ .then(response => {
41
+ expect(fetchMock.called()).toBeTruthy();
42
+ const [url, options]: [string, RequestInit] = fetchMock.lastCall("*");
43
+ expect(url).toEqual(`${requestOptions.url}/42?f=json`);
44
+ expect(options.method).toBe("GET");
45
+ expect(response.attributes.FID).toEqual(42);
46
+ done();
47
+ })
48
+ .catch(e => {
49
+ fail(e);
50
+ });
51
+ });
52
+
53
+ it("should supply default query parameters", done => {
54
+ const requestOptions = {
55
+ url: serviceUrl
56
+ };
57
+ fetchMock.once("*", queryResponse);
58
+ queryFeatures(requestOptions)
59
+ .then(() => {
60
+ expect(fetchMock.called()).toBeTruthy();
61
+ const [url, options]: [string, RequestInit] = fetchMock.lastCall("*");
62
+ expect(url).toEqual(
63
+ `${requestOptions.url}/query?f=json&where=1%3D1&outFields=*`
64
+ );
65
+ expect(options.method).toBe("GET");
66
+ done();
67
+ })
68
+ .catch(e => {
69
+ fail(e);
70
+ });
71
+ });
72
+
73
+ it("should use passed in query parameters", done => {
74
+ const requestOptions = {
75
+ url: serviceUrl,
76
+ where: "Condition='Poor'",
77
+ outFields: ["FID", "Tree_ID", "Cmn_Name", "Condition"]
78
+ };
79
+ fetchMock.once("*", queryResponse);
80
+ queryFeatures(requestOptions)
81
+ .then(() => {
82
+ expect(fetchMock.called()).toBeTruthy();
83
+ const [url, options]: [string, RequestInit] = fetchMock.lastCall("*");
84
+ expect(url).toEqual(
85
+ `${
86
+ requestOptions.url
87
+ }/query?f=json&where=Condition%3D'Poor'&outFields=FID%2CTree_ID%2CCmn_Name%2CCondition`
88
+ );
89
+ expect(options.method).toBe("GET");
90
+ // expect(response.attributes.FID).toEqual(42);
91
+ done();
92
+ })
93
+ .catch(e => {
94
+ fail(e);
95
+ });
96
+ });
97
+
98
+ it("should return objectId of the added feature and a truthy success", done => {
99
+ const requestOptions = {
100
+ url: serviceUrl,
101
+ adds: [
102
+ {
103
+ geometry: {
104
+ x: -9177311.62541634,
105
+ y: 4247151.205222242,
106
+ spatialReference: {
107
+ wkid: 102100,
108
+ latestWkid: 3857
109
+ }
110
+ },
111
+ attributes: {
112
+ Tree_ID: 102,
113
+ Collected: 1349395200000,
114
+ Crew: "Linden+ Forrest+ Johnny"
115
+ }
116
+ }
117
+ ]
118
+ };
119
+ fetchMock.once("*", addFeaturesResponse);
120
+ addFeatures(requestOptions)
121
+ .then(response => {
122
+ expect(fetchMock.called()).toBeTruthy();
123
+ const [url, options]: [string, RequestInit] = fetchMock.lastCall("*");
124
+ expect(url).toEqual(`${requestOptions.url}/addFeatures`);
125
+ expect(options.body).toContain(
126
+ "features=" +
127
+ encodeURIComponent(
128
+ '[{"geometry":{"x":-9177311.62541634,"y":4247151.205222242,"spatialReference":{"wkid":102100,"latestWkid":3857}},"attributes":{"Tree_ID":102,"Collected":1349395200000,"Crew":"Linden+ Forrest+ Johnny"}}]'
129
+ )
130
+ );
131
+ expect(options.method).toBe("POST");
132
+ expect(response.addResults[0].objectId).toEqual(1001);
133
+ expect(response.addResults[0].success).toEqual(true);
134
+ done();
135
+ })
136
+ .catch(e => {
137
+ fail(e);
138
+ });
139
+ });
140
+
141
+ it("should return objectId of the updated feature and a truthy success", done => {
142
+ const requestOptions = {
143
+ url: serviceUrl,
144
+ updates: [
145
+ {
146
+ attributes: {
147
+ OBJECTID: 1001,
148
+ Street: "NO",
149
+ Native: "YES"
150
+ }
151
+ }
152
+ ],
153
+ rollbackOnFailure: false
154
+ } as IUpdateFeaturesRequestOptions;
155
+ fetchMock.once("*", updateFeaturesResponse);
156
+ updateFeatures(requestOptions)
157
+ .then(response => {
158
+ expect(fetchMock.called()).toBeTruthy();
159
+ const [url, options]: [string, RequestInit] = fetchMock.lastCall("*");
160
+ expect(url).toEqual(`${requestOptions.url}/updateFeatures`);
161
+ expect(options.method).toBe("POST");
162
+ expect(options.body).toContain(
163
+ "features=" +
164
+ encodeURIComponent(
165
+ '[{"attributes":{"OBJECTID":1001,"Street":"NO","Native":"YES"}}]'
166
+ )
167
+ );
168
+ expect(options.body).toContain("rollbackOnFailure=false");
169
+ expect(response.updateResults[0].success).toEqual(true);
170
+ done();
171
+ })
172
+ .catch(e => {
173
+ fail(e);
174
+ });
175
+ });
176
+
177
+ it("should return objectId of the deleted feature and a truthy success", done => {
178
+ const requestOptions = {
179
+ url: serviceUrl,
180
+ deletes: [1001],
181
+ where: "1=1"
182
+ } as IDeleteFeaturesRequestOptions;
183
+ fetchMock.once("*", deleteFeaturesResponse);
184
+ deleteFeatures(requestOptions)
185
+ .then(response => {
186
+ expect(fetchMock.called()).toBeTruthy();
187
+ const [url, options]: [string, RequestInit] = fetchMock.lastCall("*");
188
+ expect(url).toEqual(`${requestOptions.url}/deleteFeatures`);
189
+ expect(options.body).toContain("objectIds=1001");
190
+ expect(options.body).toContain("where=1%3D1");
191
+ expect(options.method).toBe("POST");
192
+ expect(response.deleteResults[0].objectId).toEqual(
193
+ requestOptions.deletes[0]
194
+ );
195
+ expect(response.deleteResults[0].success).toEqual(true);
196
+ done();
197
+ })
198
+ .catch(e => {
199
+ fail(e);
200
+ });
201
+ });
202
+
203
+ it("should supply default query related parameters", done => {
204
+ const requestOptions = {
205
+ url: serviceUrl
206
+ };
207
+ fetchMock.once("*", queryRelatedResponse);
208
+ queryRelated(requestOptions)
209
+ .then(() => {
210
+ expect(fetchMock.called()).toBeTruthy();
211
+ const [url, options]: [string, RequestInit] = fetchMock.lastCall("*");
212
+ expect(url).toEqual(
213
+ `${
214
+ requestOptions.url
215
+ }/queryRelatedRecords?f=json&definitionExpression=1%3D1&outFields=*&relationshipId=0`
216
+ );
217
+ expect(options.method).toBe("GET");
218
+ done();
219
+ })
220
+ .catch(e => {
221
+ fail(e);
222
+ });
223
+ });
224
+
225
+ it("should use passed in query related parameters", done => {
226
+ const requestOptions = {
227
+ url: serviceUrl,
228
+ relationshipId: 1,
229
+ definitionExpression: "APPROXACRE<10000",
230
+ outFields: ["APPROXACRE", "FIELD_NAME"],
231
+ httpMethod: "POST"
232
+ } as IQueryRelatedRequestOptions;
233
+ fetchMock.once("*", queryRelatedResponse);
234
+ queryRelated(requestOptions)
235
+ .then(() => {
236
+ expect(fetchMock.called()).toBeTruthy();
237
+ const [url, options]: [string, RequestInit] = fetchMock.lastCall("*");
238
+ expect(url).toEqual(`${requestOptions.url}/queryRelatedRecords`);
239
+ expect(options.method).toBe("POST");
240
+ expect(options.body).toContain("f=json");
241
+ expect(options.body).toContain("relationshipId=1");
242
+ expect(options.body).toContain(
243
+ "definitionExpression=APPROXACRE%3C10000"
244
+ );
245
+ expect(options.body).toContain("outFields=APPROXACRE%2CFIELD_NAME");
246
+ done();
247
+ })
248
+ .catch(e => {
249
+ fail(e);
250
+ });
251
+ });
252
+ });
@@ -0,0 +1,279 @@
1
+ /* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
2
+ * Apache-2.0 */
3
+
4
+ export const featureResponse = {
5
+ feature: {
6
+ attributes: {
7
+ FID: 42
8
+ },
9
+ geometry: {
10
+ x: -9177311.62541634,
11
+ y: 4247151.205222242
12
+ }
13
+ }
14
+ };
15
+
16
+ export const queryResponse = {
17
+ objectIdFieldName: "FID",
18
+ globalIdFieldName: "",
19
+ geometryType: "esriGeometryPoint",
20
+ spatialReference: {
21
+ wkid: 102100,
22
+ latestWkid: 3857
23
+ },
24
+ // fields: [],
25
+ features: [
26
+ {
27
+ attributes: {
28
+ FID: 1,
29
+ Tree_ID: 102,
30
+ Collected: 1349395200000,
31
+ Crew: "Linden+ Forrest+ Johnny",
32
+ Status: "P",
33
+ Spp_Code: "ULPU",
34
+ Land_Use: "I",
35
+ Ht_DBH_ft: 4.5,
36
+ DBH1: 41,
37
+ DBH2: 0,
38
+ DBH3: 0,
39
+ DBH4: 0,
40
+ DBH5: 0,
41
+ DBH6: " ",
42
+ Height: 74,
43
+ Live_Top: 74,
44
+ Crown_Base: 21,
45
+ Width_NS: 75,
46
+ Width_EW: 40,
47
+ Cn_Missing: 10,
48
+ Cn_DieBack: 15,
49
+ CLE: 2,
50
+ Tree_Site: "S",
51
+ Tree_Age: " ",
52
+ Notes: " ",
53
+ Cmn_Name: "Siberian elm",
54
+ Sci_Name: "Ulmus pumila",
55
+ GroundArea: 2596,
56
+ Condition: "Fair",
57
+ Leaf_Area: 10295,
58
+ Leaf_Bmass: 144,
59
+ LAI: 3.96,
60
+ C_Storage: 6771,
61
+ C_Seq: 95,
62
+ S_Value: "3,079.00",
63
+ Street: "YES",
64
+ Native: "NO",
65
+ CO_Rmvd: 5.06,
66
+ O3_Rmvd: 470.97,
67
+ NO2_Rmvd: 39.24,
68
+ PM10_Rmvd: 343.45,
69
+ SO2_Rmvd: 27.64,
70
+ PM2p5_Rmvd: 47.84,
71
+ CO_RVlu: 0.01,
72
+ O3_Rvlu: 0.42,
73
+ NO2_Rvlu: 0,
74
+ PM10_Rvlu: 3.73,
75
+ SO2_Rvlu: 0,
76
+ PM2p5_RVlu: 1.99,
77
+ Isoprene_E: 2.7,
78
+ Monoterp_E: 13.2,
79
+ Vocs_E: 15.9,
80
+ Dedication: " ",
81
+ Longitude: -82.441189,
82
+ Latitude: 35.610441,
83
+ Crown_Height: 53
84
+ }
85
+ },
86
+ {
87
+ attributes: {
88
+ FID: 2,
89
+ Tree_ID: 103,
90
+ Collected: 1349395200000,
91
+ Crew: "Linden+ Forrest+ Johnny",
92
+ Status: "P",
93
+ Spp_Code: "ULPU",
94
+ Land_Use: "I",
95
+ Ht_DBH_ft: 4.5,
96
+ DBH1: 55,
97
+ DBH2: 0,
98
+ DBH3: 0,
99
+ DBH4: 0,
100
+ DBH5: 0,
101
+ DBH6: " ",
102
+ Height: 70,
103
+ Live_Top: 70,
104
+ Crown_Base: 21,
105
+ Width_NS: 90,
106
+ Width_EW: 71,
107
+ Cn_Missing: 5,
108
+ Cn_DieBack: 15,
109
+ CLE: 3,
110
+ Tree_Site: "S",
111
+ Tree_Age: " ",
112
+ Notes: " ",
113
+ Cmn_Name: "Siberian elm",
114
+ Sci_Name: "Ulmus pumila",
115
+ GroundArea: 5089,
116
+ Condition: "Fair",
117
+ Leaf_Area: 17078,
118
+ Leaf_Bmass: 238,
119
+ LAI: 3.36,
120
+ C_Storage: 13228,
121
+ C_Seq: 22,
122
+ S_Value: "4,187.00",
123
+ Street: "YES",
124
+ Native: "NO",
125
+ CO_Rmvd: 8.4,
126
+ O3_Rmvd: 781.35,
127
+ NO2_Rmvd: 65.1,
128
+ PM10_Rmvd: 600.8,
129
+ SO2_Rmvd: 45.86,
130
+ PM2p5_Rmvd: 83.68,
131
+ CO_RVlu: 0.01,
132
+ O3_Rvlu: 0.69,
133
+ NO2_Rvlu: 0.01,
134
+ PM10_Rvlu: 6.53,
135
+ SO2_Rvlu: 0,
136
+ PM2p5_RVlu: 3.48,
137
+ Isoprene_E: 4.47,
138
+ Monoterp_E: 21.9,
139
+ Vocs_E: 26.38,
140
+ Dedication: " ",
141
+ Longitude: -82.441107,
142
+ Latitude: 35.610472,
143
+ Crown_Height: 49
144
+ }
145
+ }
146
+ ]
147
+ };
148
+
149
+ export const addFeaturesResponse = {
150
+ addResults: [
151
+ {
152
+ objectId: 1001,
153
+ success: true
154
+ }
155
+ ]
156
+ };
157
+
158
+ export const updateFeaturesResponse = {
159
+ updateResults: [
160
+ {
161
+ objectId: 1001,
162
+ success: true
163
+ }
164
+ ]
165
+ };
166
+
167
+ export const deleteFeaturesResponse = {
168
+ deleteResults: [
169
+ {
170
+ objectId: 1001,
171
+ success: true
172
+ }
173
+ ]
174
+ };
175
+
176
+ export const getAttachmentsResponse = {
177
+ attachmentInfos: [
178
+ {
179
+ id: 409,
180
+ contentType: "application/pdf",
181
+ size: 400633,
182
+ name: "Permit_Application_20180416"
183
+ },
184
+ {
185
+ id: 822,
186
+ contentType: "application/pdf",
187
+ size: 619543,
188
+ name: "Planning_Review_20180604"
189
+ }
190
+ ]
191
+ };
192
+
193
+ export const addAttachmentResponse = {
194
+ addAttachmentResult: {
195
+ objectId: 1001,
196
+ success: true
197
+ }
198
+ };
199
+
200
+ export const updateAttachmentResponse = {
201
+ updateAttachmentResult: {
202
+ objectId: 1001,
203
+ success: true
204
+ }
205
+ };
206
+
207
+ export const deleteAttachmentsResponse = {
208
+ deleteAttachmentResults: [
209
+ {
210
+ objectId: 1001,
211
+ success: true
212
+ }
213
+ ]
214
+ };
215
+
216
+ export const genericInvalidResponse = {
217
+ error: {
218
+ code: 400,
219
+ message: "Invalid or missing input parameters."
220
+ }
221
+ };
222
+
223
+ export const queryRelatedResponse = {
224
+ geometryType: "esriGeometryPolygon",
225
+ spatialReference: {
226
+ wkid: 4267
227
+ },
228
+ fields: [
229
+ {
230
+ name: "OBJECTID",
231
+ type: "esriFieldTypeOID",
232
+ alias: "OBJECTID"
233
+ },
234
+ {
235
+ name: "FIELD_KID",
236
+ type: "esriFieldTypeString",
237
+ alias: "FIELD_KID",
238
+ length: 25
239
+ },
240
+ {
241
+ name: "APPROXACRE",
242
+ type: "esriFieldTypeDouble",
243
+ alias: "APPROXACRE"
244
+ },
245
+ {
246
+ name: "FIELD_NAME",
247
+ type: "esriFieldTypeString",
248
+ alias: "FIELD_NAME",
249
+ length: 150
250
+ }
251
+ ],
252
+ relatedRecordGroups: [
253
+ {
254
+ objectId: 3,
255
+ relatedRecords: [
256
+ {
257
+ attributes: {
258
+ OBJECTID: 5540,
259
+ FIELD_KID: "1000147595",
260
+ APPROXACRE: 95929,
261
+ FIELD_NAME: "LOST SPRINGS"
262
+ },
263
+ geometry: {
264
+ rings: [
265
+ [
266
+ [-96.929599633999942, 38.52426809800005],
267
+ [-96.929602437999961, 38.522448437000037],
268
+ [-96.92959118999994, 38.529723252000053],
269
+ [-96.929594022999936, 38.527905578000059],
270
+ [-96.929596839999988, 38.526087119000067],
271
+ [-96.929599633999942, 38.52426809800005]
272
+ ]
273
+ ]
274
+ }
275
+ }
276
+ ]
277
+ }
278
+ ]
279
+ };
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "include": [
4
+ "src/**/*.ts"
5
+ ]
6
+ }
@@ -0,0 +1,66 @@
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-feature-service-admin.svg?style=flat-square
6
+ [npm-url]: https://www.npmjs.com/package/@esri/arcgis-rest-feature-service-admin
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-feature-service-admin
11
+
12
+ > A module for administering ArcGIS feature services that runs in Node.js and modern browsers.
13
+
14
+ ### Example
15
+
16
+ ```bash
17
+ npm install @esri/arcgis-rest-request
18
+ npm install @esri/arcgis-rest-auth
19
+ npm install @esri/arcgis-rest-items
20
+ npm install @esri/arcgis-rest-feature-service-admin
21
+ ```
22
+
23
+ ```js
24
+ import { createFeatureService } from '@esri/arcgis-rest-feature-service-admin';
25
+
26
+ createFeatureService({
27
+ authentication,
28
+ item: { name: "GreenField" }
29
+ })
30
+ ```
31
+
32
+ ### [API Reference](https://esri.github.io/arcgis-rest-js/api/feature-service-admin/)
33
+
34
+ ### Issues
35
+
36
+ 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.
37
+
38
+ If you're looking for help you can also post issues on [GIS Stackexchange](http://gis.stackexchange.com/questions/ask?tags=esri-oss).
39
+
40
+ ### Versioning
41
+
42
+ 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.
43
+
44
+ For more information on SemVer, please visit <http://semver.org/>.
45
+
46
+ ### Contributing
47
+
48
+ Esri welcomes contributions from anyone and everyone. Please see our [guidelines for contributing](CONTRIBUTING.md).
49
+
50
+ ### License
51
+
52
+ Copyright &copy; 2018 Esri
53
+
54
+ Licensed under the Apache License, Version 2.0 (the "License");
55
+ you may not use this file except in compliance with the License.
56
+ You may obtain a copy of the License at
57
+
58
+ > http://www.apache.org/licenses/LICENSE-2.0
59
+
60
+ Unless required by applicable law or agreed to in writing, software
61
+ distributed under the License is distributed on an "AS IS" BASIS,
62
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
63
+ See the License for the specific language governing permissions and
64
+ limitations under the License.
65
+
66
+ 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.9.3",
7
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz",
8
+ "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ=="
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@esri/arcgis-rest-feature-service-admin",
3
+ "version": "1.13.0",
4
+ "description": "Feature service administration helpers for @esri/arcgis-rest-request",
5
+ "main": "dist/node/index.js",
6
+ "browser": "dist/umd/feature-service-admin.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.11.0",
19
+ "@esri/arcgis-rest-common-types": "^1.11.0",
20
+ "@esri/arcgis-rest-items": "^1.11.0",
21
+ "@esri/arcgis-rest-request": "^1.11.0"
22
+ },
23
+ "devDependencies": {
24
+ "@esri/arcgis-rest-auth": "^1.13.0",
25
+ "@esri/arcgis-rest-common-types": "^1.13.0",
26
+ "@esri/arcgis-rest-items": "^1.13.0",
27
+ "@esri/arcgis-rest-request": "^1.13.0"
28
+ },
29
+ "scripts": {
30
+ "prepare": "npm run build",
31
+ "build": "npm run build:node && npm run build:umd && npm run build:esm",
32
+ "build:esm": "tsc -p ./tsconfig.json --module es2015 --outDir ./dist/esm --declaration",
33
+ "build:umd": "rollup -c ../../umd-base-profile.js && rollup -c ../../umd-production-profile.js",
34
+ "build:node": "tsc -p ./tsconfig.json --module commonjs --outDir ./dist/node"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/Esri/arcgis-rest-js.git"
42
+ },
43
+ "contributors": [
44
+ {
45
+ "name": "Mike Tschudi",
46
+ "email": "mtschudi@esri.com"
47
+ }
48
+ ],
49
+ "bugs": {
50
+ "url": "https://github.com/Esri/arcgis-rest-js/issues"
51
+ },
52
+ "homepage": "https://github.com/Esri/arcgis-rest-js#readme"
53
+ }