@esri/solution-common 6.0.5-alpha.0 → 6.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (404) hide show
  1. package/package.json +6 -6
  2. package/dist/cjs/arcgisRestJS.d.ts +0 -58
  3. package/dist/cjs/arcgisRestJS.js +0 -142
  4. package/dist/cjs/arcgisRestJS.js.map +0 -1
  5. package/dist/cjs/completeItem.d.ts +0 -30
  6. package/dist/cjs/completeItem.js +0 -72
  7. package/dist/cjs/completeItem.js.map +0 -1
  8. package/dist/cjs/create-hub-request-options.d.ts +0 -29
  9. package/dist/cjs/create-hub-request-options.js +0 -64
  10. package/dist/cjs/create-hub-request-options.js.map +0 -1
  11. package/dist/cjs/deleteHelpers/deleteEmptyGroups.d.ts +0 -24
  12. package/dist/cjs/deleteHelpers/deleteEmptyGroups.js +0 -42
  13. package/dist/cjs/deleteHelpers/deleteEmptyGroups.js.map +0 -1
  14. package/dist/cjs/deleteHelpers/deleteGroupIfEmpty.d.ts +0 -27
  15. package/dist/cjs/deleteHelpers/deleteGroupIfEmpty.js +0 -99
  16. package/dist/cjs/deleteHelpers/deleteGroupIfEmpty.js.map +0 -1
  17. package/dist/cjs/deleteHelpers/deleteSolutionContents.d.ts +0 -39
  18. package/dist/cjs/deleteHelpers/deleteSolutionContents.js +0 -127
  19. package/dist/cjs/deleteHelpers/deleteSolutionContents.js.map +0 -1
  20. package/dist/cjs/deleteHelpers/deleteSolutionFolder.d.ts +0 -29
  21. package/dist/cjs/deleteHelpers/deleteSolutionFolder.js +0 -81
  22. package/dist/cjs/deleteHelpers/deleteSolutionFolder.js.map +0 -1
  23. package/dist/cjs/deleteHelpers/deleteSolutionItem.d.ts +0 -31
  24. package/dist/cjs/deleteHelpers/deleteSolutionItem.js +0 -52
  25. package/dist/cjs/deleteHelpers/deleteSolutionItem.js.map +0 -1
  26. package/dist/cjs/deleteHelpers/index.d.ts +0 -22
  27. package/dist/cjs/deleteHelpers/index.js +0 -26
  28. package/dist/cjs/deleteHelpers/index.js.map +0 -1
  29. package/dist/cjs/deleteHelpers/reconstructBuildOrderIds.d.ts +0 -27
  30. package/dist/cjs/deleteHelpers/reconstructBuildOrderIds.js +0 -34
  31. package/dist/cjs/deleteHelpers/reconstructBuildOrderIds.js.map +0 -1
  32. package/dist/cjs/deleteHelpers/removeItems.d.ts +0 -35
  33. package/dist/cjs/deleteHelpers/removeItems.js +0 -116
  34. package/dist/cjs/deleteHelpers/removeItems.js.map +0 -1
  35. package/dist/cjs/deleteHelpers/reportProgress.d.ts +0 -27
  36. package/dist/cjs/deleteHelpers/reportProgress.js +0 -46
  37. package/dist/cjs/deleteHelpers/reportProgress.js.map +0 -1
  38. package/dist/cjs/deleteSolution.d.ts +0 -56
  39. package/dist/cjs/deleteSolution.js +0 -107
  40. package/dist/cjs/deleteSolution.js.map +0 -1
  41. package/dist/cjs/dependencies.d.ts +0 -26
  42. package/dist/cjs/dependencies.js +0 -171
  43. package/dist/cjs/dependencies.js.map +0 -1
  44. package/dist/cjs/featureServiceHelpers.d.ts +0 -833
  45. package/dist/cjs/featureServiceHelpers.js +0 -2524
  46. package/dist/cjs/featureServiceHelpers.js.map +0 -1
  47. package/dist/cjs/formHelpers.d.ts +0 -26
  48. package/dist/cjs/formHelpers.js +0 -40
  49. package/dist/cjs/formHelpers.js.map +0 -1
  50. package/dist/cjs/generalHelpers.d.ts +0 -447
  51. package/dist/cjs/generalHelpers.js +0 -959
  52. package/dist/cjs/generalHelpers.js.map +0 -1
  53. package/dist/cjs/get-subscription-info.d.ts +0 -27
  54. package/dist/cjs/get-subscription-info.js +0 -38
  55. package/dist/cjs/get-subscription-info.js.map +0 -1
  56. package/dist/cjs/getDeletableSolutionInfo.d.ts +0 -30
  57. package/dist/cjs/getDeletableSolutionInfo.js +0 -53
  58. package/dist/cjs/getDeletableSolutionInfo.js.map +0 -1
  59. package/dist/cjs/getItemTypeAbbrev.d.ts +0 -19
  60. package/dist/cjs/getItemTypeAbbrev.js +0 -186
  61. package/dist/cjs/getItemTypeAbbrev.js.map +0 -1
  62. package/dist/cjs/getSolutionSummary.d.ts +0 -28
  63. package/dist/cjs/getSolutionSummary.js +0 -100
  64. package/dist/cjs/getSolutionSummary.js.map +0 -1
  65. package/dist/cjs/index.d.ts +0 -49
  66. package/dist/cjs/index.js +0 -53
  67. package/dist/cjs/index.js.map +0 -1
  68. package/dist/cjs/interfaces.d.ts +0 -1446
  69. package/dist/cjs/interfaces.js +0 -72
  70. package/dist/cjs/interfaces.js.map +0 -1
  71. package/dist/cjs/item-reuse.d.ts +0 -140
  72. package/dist/cjs/item-reuse.js +0 -176
  73. package/dist/cjs/item-reuse.js.map +0 -1
  74. package/dist/cjs/libConnectors.d.ts +0 -73
  75. package/dist/cjs/libConnectors.js +0 -115
  76. package/dist/cjs/libConnectors.js.map +0 -1
  77. package/dist/cjs/migrations/apply-schema.d.ts +0 -24
  78. package/dist/cjs/migrations/apply-schema.js +0 -36
  79. package/dist/cjs/migrations/apply-schema.js.map +0 -1
  80. package/dist/cjs/migrations/is-legacy-solution.d.ts +0 -24
  81. package/dist/cjs/migrations/is-legacy-solution.js +0 -39
  82. package/dist/cjs/migrations/is-legacy-solution.js.map +0 -1
  83. package/dist/cjs/migrations/upgrade-three-dot-one.d.ts +0 -26
  84. package/dist/cjs/migrations/upgrade-three-dot-one.js +0 -48
  85. package/dist/cjs/migrations/upgrade-three-dot-one.js.map +0 -1
  86. package/dist/cjs/migrations/upgrade-three-dot-zero.d.ts +0 -27
  87. package/dist/cjs/migrations/upgrade-three-dot-zero.js +0 -43
  88. package/dist/cjs/migrations/upgrade-three-dot-zero.js.map +0 -1
  89. package/dist/cjs/migrations/upgrade-two-dot-five.d.ts +0 -24
  90. package/dist/cjs/migrations/upgrade-two-dot-five.js +0 -73
  91. package/dist/cjs/migrations/upgrade-two-dot-five.js.map +0 -1
  92. package/dist/cjs/migrations/upgrade-two-dot-four.d.ts +0 -24
  93. package/dist/cjs/migrations/upgrade-two-dot-four.js +0 -72
  94. package/dist/cjs/migrations/upgrade-two-dot-four.js.map +0 -1
  95. package/dist/cjs/migrations/upgrade-two-dot-one.d.ts +0 -7
  96. package/dist/cjs/migrations/upgrade-two-dot-one.js +0 -39
  97. package/dist/cjs/migrations/upgrade-two-dot-one.js.map +0 -1
  98. package/dist/cjs/migrations/upgrade-two-dot-seven.d.ts +0 -23
  99. package/dist/cjs/migrations/upgrade-two-dot-seven.js +0 -58
  100. package/dist/cjs/migrations/upgrade-two-dot-seven.js.map +0 -1
  101. package/dist/cjs/migrations/upgrade-two-dot-six.d.ts +0 -27
  102. package/dist/cjs/migrations/upgrade-two-dot-six.js +0 -61
  103. package/dist/cjs/migrations/upgrade-two-dot-six.js.map +0 -1
  104. package/dist/cjs/migrations/upgrade-two-dot-three.d.ts +0 -23
  105. package/dist/cjs/migrations/upgrade-two-dot-three.js +0 -55
  106. package/dist/cjs/migrations/upgrade-two-dot-three.js.map +0 -1
  107. package/dist/cjs/migrations/upgrade-two-dot-two.d.ts +0 -23
  108. package/dist/cjs/migrations/upgrade-two-dot-two.js +0 -58
  109. package/dist/cjs/migrations/upgrade-two-dot-two.js.map +0 -1
  110. package/dist/cjs/migrations/upgrade-two-dot-zero.d.ts +0 -44
  111. package/dist/cjs/migrations/upgrade-two-dot-zero.js +0 -95
  112. package/dist/cjs/migrations/upgrade-two-dot-zero.js.map +0 -1
  113. package/dist/cjs/migrator.d.ts +0 -25
  114. package/dist/cjs/migrator.js +0 -75
  115. package/dist/cjs/migrator.js.map +0 -1
  116. package/dist/cjs/resourceHelpers.d.ts +0 -192
  117. package/dist/cjs/resourceHelpers.js +0 -380
  118. package/dist/cjs/resourceHelpers.js.map +0 -1
  119. package/dist/cjs/resources/add-resource.d.ts +0 -38
  120. package/dist/cjs/resources/add-resource.js +0 -84
  121. package/dist/cjs/resources/add-resource.js.map +0 -1
  122. package/dist/cjs/resources/addMetadataFromBlob.d.ts +0 -25
  123. package/dist/cjs/resources/addMetadataFromBlob.js +0 -43
  124. package/dist/cjs/resources/addMetadataFromBlob.js.map +0 -1
  125. package/dist/cjs/resources/convert-item-resource-to-storage-resource.d.ts +0 -32
  126. package/dist/cjs/resources/convert-item-resource-to-storage-resource.js +0 -70
  127. package/dist/cjs/resources/convert-item-resource-to-storage-resource.js.map +0 -1
  128. package/dist/cjs/resources/convert-storage-resource-to-item-resource.d.ts +0 -29
  129. package/dist/cjs/resources/convert-storage-resource-to-item-resource.js +0 -70
  130. package/dist/cjs/resources/convert-storage-resource-to-item-resource.js.map +0 -1
  131. package/dist/cjs/resources/copyAssociatedFiles.d.ts +0 -79
  132. package/dist/cjs/resources/copyAssociatedFiles.js +0 -348
  133. package/dist/cjs/resources/copyAssociatedFiles.js.map +0 -1
  134. package/dist/cjs/resources/copyDataIntoItem.d.ts +0 -34
  135. package/dist/cjs/resources/copyDataIntoItem.js +0 -45
  136. package/dist/cjs/resources/copyDataIntoItem.js.map +0 -1
  137. package/dist/cjs/resources/copyMetadataIntoItem.d.ts +0 -27
  138. package/dist/cjs/resources/copyMetadataIntoItem.js +0 -44
  139. package/dist/cjs/resources/copyMetadataIntoItem.js.map +0 -1
  140. package/dist/cjs/resources/copyResourceIntoZip.d.ts +0 -34
  141. package/dist/cjs/resources/copyResourceIntoZip.js +0 -74
  142. package/dist/cjs/resources/copyResourceIntoZip.js.map +0 -1
  143. package/dist/cjs/resources/copyZipIntoItem.d.ts +0 -26
  144. package/dist/cjs/resources/copyZipIntoItem.js +0 -53
  145. package/dist/cjs/resources/copyZipIntoItem.js.map +0 -1
  146. package/dist/cjs/resources/createCopyResults.d.ts +0 -25
  147. package/dist/cjs/resources/createCopyResults.js +0 -36
  148. package/dist/cjs/resources/createCopyResults.js.map +0 -1
  149. package/dist/cjs/resources/get-blob.d.ts +0 -25
  150. package/dist/cjs/resources/get-blob.js +0 -42
  151. package/dist/cjs/resources/get-blob.js.map +0 -1
  152. package/dist/cjs/resources/getItemResourcesFilesFromPaths.d.ts +0 -25
  153. package/dist/cjs/resources/getItemResourcesFilesFromPaths.js +0 -49
  154. package/dist/cjs/resources/getItemResourcesFilesFromPaths.js.map +0 -1
  155. package/dist/cjs/resources/getItemResourcesPaths.d.ts +0 -27
  156. package/dist/cjs/resources/getItemResourcesPaths.js +0 -80
  157. package/dist/cjs/resources/getItemResourcesPaths.js.map +0 -1
  158. package/dist/cjs/resources/index.d.ts +0 -30
  159. package/dist/cjs/resources/index.js +0 -34
  160. package/dist/cjs/resources/index.js.map +0 -1
  161. package/dist/cjs/resources/solution-resource.d.ts +0 -35
  162. package/dist/cjs/resources/solution-resource.js +0 -31
  163. package/dist/cjs/resources/solution-resource.js.map +0 -1
  164. package/dist/cjs/resources/transform-resource-paths-to-solution-resources.d.ts +0 -56
  165. package/dist/cjs/resources/transform-resource-paths-to-solution-resources.js +0 -140
  166. package/dist/cjs/resources/transform-resource-paths-to-solution-resources.js.map +0 -1
  167. package/dist/cjs/resources/update-resource.d.ts +0 -27
  168. package/dist/cjs/resources/update-resource.js +0 -52
  169. package/dist/cjs/resources/update-resource.js.map +0 -1
  170. package/dist/cjs/restHelpers.d.ts +0 -634
  171. package/dist/cjs/restHelpers.js +0 -2044
  172. package/dist/cjs/restHelpers.js.map +0 -1
  173. package/dist/cjs/restHelpersGet.d.ts +0 -303
  174. package/dist/cjs/restHelpersGet.js +0 -835
  175. package/dist/cjs/restHelpersGet.js.map +0 -1
  176. package/dist/cjs/sharing/index.d.ts +0 -16
  177. package/dist/cjs/sharing/index.js +0 -20
  178. package/dist/cjs/sharing/index.js.map +0 -1
  179. package/dist/cjs/sharing/share-item-to-groups.d.ts +0 -26
  180. package/dist/cjs/sharing/share-item-to-groups.js +0 -44
  181. package/dist/cjs/sharing/share-item-to-groups.js.map +0 -1
  182. package/dist/cjs/templatization.d.ts +0 -139
  183. package/dist/cjs/templatization.js +0 -311
  184. package/dist/cjs/templatization.js.map +0 -1
  185. package/dist/cjs/trackingHelpers.d.ts +0 -115
  186. package/dist/cjs/trackingHelpers.js +0 -212
  187. package/dist/cjs/trackingHelpers.js.map +0 -1
  188. package/dist/cjs/velocityHelpers.d.ts +0 -68
  189. package/dist/cjs/velocityHelpers.js +0 -151
  190. package/dist/cjs/velocityHelpers.js.map +0 -1
  191. package/dist/cjs/webtoolHelpers.d.ts +0 -57
  192. package/dist/cjs/webtoolHelpers.js +0 -102
  193. package/dist/cjs/webtoolHelpers.js.map +0 -1
  194. package/dist/cjs/workflowHelpers.d.ts +0 -112
  195. package/dist/cjs/workflowHelpers.js +0 -284
  196. package/dist/cjs/workflowHelpers.js.map +0 -1
  197. package/dist/cjs/workforceHelpers.d.ts +0 -121
  198. package/dist/cjs/workforceHelpers.js +0 -720
  199. package/dist/cjs/workforceHelpers.js.map +0 -1
  200. package/dist/cjs/zip-utils.d.ts +0 -85
  201. package/dist/cjs/zip-utils.js +0 -154
  202. package/dist/cjs/zip-utils.js.map +0 -1
  203. package/dist/esm/arcgisRestJS.d.ts +0 -58
  204. package/dist/esm/arcgisRestJS.js +0 -94
  205. package/dist/esm/arcgisRestJS.js.map +0 -1
  206. package/dist/esm/completeItem.d.ts +0 -30
  207. package/dist/esm/completeItem.js +0 -67
  208. package/dist/esm/completeItem.js.map +0 -1
  209. package/dist/esm/create-hub-request-options.d.ts +0 -29
  210. package/dist/esm/create-hub-request-options.js +0 -60
  211. package/dist/esm/create-hub-request-options.js.map +0 -1
  212. package/dist/esm/deleteHelpers/deleteEmptyGroups.d.ts +0 -24
  213. package/dist/esm/deleteHelpers/deleteEmptyGroups.js +0 -38
  214. package/dist/esm/deleteHelpers/deleteEmptyGroups.js.map +0 -1
  215. package/dist/esm/deleteHelpers/deleteGroupIfEmpty.d.ts +0 -27
  216. package/dist/esm/deleteHelpers/deleteGroupIfEmpty.js +0 -95
  217. package/dist/esm/deleteHelpers/deleteGroupIfEmpty.js.map +0 -1
  218. package/dist/esm/deleteHelpers/deleteSolutionContents.d.ts +0 -39
  219. package/dist/esm/deleteHelpers/deleteSolutionContents.js +0 -122
  220. package/dist/esm/deleteHelpers/deleteSolutionContents.js.map +0 -1
  221. package/dist/esm/deleteHelpers/deleteSolutionFolder.d.ts +0 -29
  222. package/dist/esm/deleteHelpers/deleteSolutionFolder.js +0 -77
  223. package/dist/esm/deleteHelpers/deleteSolutionFolder.js.map +0 -1
  224. package/dist/esm/deleteHelpers/deleteSolutionItem.d.ts +0 -31
  225. package/dist/esm/deleteHelpers/deleteSolutionItem.js +0 -48
  226. package/dist/esm/deleteHelpers/deleteSolutionItem.js.map +0 -1
  227. package/dist/esm/deleteHelpers/index.d.ts +0 -22
  228. package/dist/esm/deleteHelpers/index.js +0 -23
  229. package/dist/esm/deleteHelpers/index.js.map +0 -1
  230. package/dist/esm/deleteHelpers/reconstructBuildOrderIds.d.ts +0 -27
  231. package/dist/esm/deleteHelpers/reconstructBuildOrderIds.js +0 -29
  232. package/dist/esm/deleteHelpers/reconstructBuildOrderIds.js.map +0 -1
  233. package/dist/esm/deleteHelpers/removeItems.d.ts +0 -35
  234. package/dist/esm/deleteHelpers/removeItems.js +0 -111
  235. package/dist/esm/deleteHelpers/removeItems.js.map +0 -1
  236. package/dist/esm/deleteHelpers/reportProgress.d.ts +0 -27
  237. package/dist/esm/deleteHelpers/reportProgress.js +0 -42
  238. package/dist/esm/deleteHelpers/reportProgress.js.map +0 -1
  239. package/dist/esm/deleteSolution.d.ts +0 -56
  240. package/dist/esm/deleteSolution.js +0 -101
  241. package/dist/esm/deleteSolution.js.map +0 -1
  242. package/dist/esm/dependencies.d.ts +0 -26
  243. package/dist/esm/dependencies.js +0 -167
  244. package/dist/esm/dependencies.js.map +0 -1
  245. package/dist/esm/featureServiceHelpers.d.ts +0 -833
  246. package/dist/esm/featureServiceHelpers.js +0 -2438
  247. package/dist/esm/featureServiceHelpers.js.map +0 -1
  248. package/dist/esm/formHelpers.d.ts +0 -26
  249. package/dist/esm/formHelpers.js +0 -35
  250. package/dist/esm/formHelpers.js.map +0 -1
  251. package/dist/esm/generalHelpers.d.ts +0 -447
  252. package/dist/esm/generalHelpers.js +0 -903
  253. package/dist/esm/generalHelpers.js.map +0 -1
  254. package/dist/esm/get-subscription-info.d.ts +0 -27
  255. package/dist/esm/get-subscription-info.js +0 -34
  256. package/dist/esm/get-subscription-info.js.map +0 -1
  257. package/dist/esm/getDeletableSolutionInfo.d.ts +0 -30
  258. package/dist/esm/getDeletableSolutionInfo.js +0 -48
  259. package/dist/esm/getDeletableSolutionInfo.js.map +0 -1
  260. package/dist/esm/getItemTypeAbbrev.d.ts +0 -19
  261. package/dist/esm/getItemTypeAbbrev.js +0 -182
  262. package/dist/esm/getItemTypeAbbrev.js.map +0 -1
  263. package/dist/esm/getSolutionSummary.d.ts +0 -28
  264. package/dist/esm/getSolutionSummary.js +0 -95
  265. package/dist/esm/getSolutionSummary.js.map +0 -1
  266. package/dist/esm/index.d.ts +0 -49
  267. package/dist/esm/index.js +0 -50
  268. package/dist/esm/index.js.map +0 -1
  269. package/dist/esm/interfaces.d.ts +0 -1446
  270. package/dist/esm/interfaces.js +0 -69
  271. package/dist/esm/interfaces.js.map +0 -1
  272. package/dist/esm/item-reuse.d.ts +0 -140
  273. package/dist/esm/item-reuse.js +0 -167
  274. package/dist/esm/item-reuse.js.map +0 -1
  275. package/dist/esm/libConnectors.d.ts +0 -73
  276. package/dist/esm/libConnectors.js +0 -105
  277. package/dist/esm/libConnectors.js.map +0 -1
  278. package/dist/esm/migrations/apply-schema.d.ts +0 -24
  279. package/dist/esm/migrations/apply-schema.js +0 -32
  280. package/dist/esm/migrations/apply-schema.js.map +0 -1
  281. package/dist/esm/migrations/is-legacy-solution.d.ts +0 -24
  282. package/dist/esm/migrations/is-legacy-solution.js +0 -35
  283. package/dist/esm/migrations/is-legacy-solution.js.map +0 -1
  284. package/dist/esm/migrations/upgrade-three-dot-one.d.ts +0 -26
  285. package/dist/esm/migrations/upgrade-three-dot-one.js +0 -44
  286. package/dist/esm/migrations/upgrade-three-dot-one.js.map +0 -1
  287. package/dist/esm/migrations/upgrade-three-dot-zero.d.ts +0 -27
  288. package/dist/esm/migrations/upgrade-three-dot-zero.js +0 -39
  289. package/dist/esm/migrations/upgrade-three-dot-zero.js.map +0 -1
  290. package/dist/esm/migrations/upgrade-two-dot-five.d.ts +0 -24
  291. package/dist/esm/migrations/upgrade-two-dot-five.js +0 -69
  292. package/dist/esm/migrations/upgrade-two-dot-five.js.map +0 -1
  293. package/dist/esm/migrations/upgrade-two-dot-four.d.ts +0 -24
  294. package/dist/esm/migrations/upgrade-two-dot-four.js +0 -68
  295. package/dist/esm/migrations/upgrade-two-dot-four.js.map +0 -1
  296. package/dist/esm/migrations/upgrade-two-dot-one.d.ts +0 -7
  297. package/dist/esm/migrations/upgrade-two-dot-one.js +0 -35
  298. package/dist/esm/migrations/upgrade-two-dot-one.js.map +0 -1
  299. package/dist/esm/migrations/upgrade-two-dot-seven.d.ts +0 -23
  300. package/dist/esm/migrations/upgrade-two-dot-seven.js +0 -54
  301. package/dist/esm/migrations/upgrade-two-dot-seven.js.map +0 -1
  302. package/dist/esm/migrations/upgrade-two-dot-six.d.ts +0 -27
  303. package/dist/esm/migrations/upgrade-two-dot-six.js +0 -57
  304. package/dist/esm/migrations/upgrade-two-dot-six.js.map +0 -1
  305. package/dist/esm/migrations/upgrade-two-dot-three.d.ts +0 -23
  306. package/dist/esm/migrations/upgrade-two-dot-three.js +0 -51
  307. package/dist/esm/migrations/upgrade-two-dot-three.js.map +0 -1
  308. package/dist/esm/migrations/upgrade-two-dot-two.d.ts +0 -23
  309. package/dist/esm/migrations/upgrade-two-dot-two.js +0 -54
  310. package/dist/esm/migrations/upgrade-two-dot-two.js.map +0 -1
  311. package/dist/esm/migrations/upgrade-two-dot-zero.d.ts +0 -44
  312. package/dist/esm/migrations/upgrade-two-dot-zero.js +0 -88
  313. package/dist/esm/migrations/upgrade-two-dot-zero.js.map +0 -1
  314. package/dist/esm/migrator.d.ts +0 -25
  315. package/dist/esm/migrator.js +0 -71
  316. package/dist/esm/migrator.js.map +0 -1
  317. package/dist/esm/resourceHelpers.d.ts +0 -192
  318. package/dist/esm/resourceHelpers.js +0 -361
  319. package/dist/esm/resourceHelpers.js.map +0 -1
  320. package/dist/esm/resources/add-resource.d.ts +0 -38
  321. package/dist/esm/resources/add-resource.js +0 -79
  322. package/dist/esm/resources/add-resource.js.map +0 -1
  323. package/dist/esm/resources/addMetadataFromBlob.d.ts +0 -25
  324. package/dist/esm/resources/addMetadataFromBlob.js +0 -39
  325. package/dist/esm/resources/addMetadataFromBlob.js.map +0 -1
  326. package/dist/esm/resources/convert-item-resource-to-storage-resource.d.ts +0 -32
  327. package/dist/esm/resources/convert-item-resource-to-storage-resource.js +0 -66
  328. package/dist/esm/resources/convert-item-resource-to-storage-resource.js.map +0 -1
  329. package/dist/esm/resources/convert-storage-resource-to-item-resource.d.ts +0 -29
  330. package/dist/esm/resources/convert-storage-resource-to-item-resource.js +0 -66
  331. package/dist/esm/resources/convert-storage-resource-to-item-resource.js.map +0 -1
  332. package/dist/esm/resources/copyAssociatedFiles.d.ts +0 -79
  333. package/dist/esm/resources/copyAssociatedFiles.js +0 -339
  334. package/dist/esm/resources/copyAssociatedFiles.js.map +0 -1
  335. package/dist/esm/resources/copyDataIntoItem.d.ts +0 -34
  336. package/dist/esm/resources/copyDataIntoItem.js +0 -40
  337. package/dist/esm/resources/copyDataIntoItem.js.map +0 -1
  338. package/dist/esm/resources/copyMetadataIntoItem.d.ts +0 -27
  339. package/dist/esm/resources/copyMetadataIntoItem.js +0 -40
  340. package/dist/esm/resources/copyMetadataIntoItem.js.map +0 -1
  341. package/dist/esm/resources/copyResourceIntoZip.d.ts +0 -34
  342. package/dist/esm/resources/copyResourceIntoZip.js +0 -69
  343. package/dist/esm/resources/copyResourceIntoZip.js.map +0 -1
  344. package/dist/esm/resources/copyZipIntoItem.d.ts +0 -26
  345. package/dist/esm/resources/copyZipIntoItem.js +0 -49
  346. package/dist/esm/resources/copyZipIntoItem.js.map +0 -1
  347. package/dist/esm/resources/createCopyResults.d.ts +0 -25
  348. package/dist/esm/resources/createCopyResults.js +0 -32
  349. package/dist/esm/resources/createCopyResults.js.map +0 -1
  350. package/dist/esm/resources/get-blob.d.ts +0 -25
  351. package/dist/esm/resources/get-blob.js +0 -38
  352. package/dist/esm/resources/get-blob.js.map +0 -1
  353. package/dist/esm/resources/getItemResourcesFilesFromPaths.d.ts +0 -25
  354. package/dist/esm/resources/getItemResourcesFilesFromPaths.js +0 -45
  355. package/dist/esm/resources/getItemResourcesFilesFromPaths.js.map +0 -1
  356. package/dist/esm/resources/getItemResourcesPaths.d.ts +0 -27
  357. package/dist/esm/resources/getItemResourcesPaths.js +0 -76
  358. package/dist/esm/resources/getItemResourcesPaths.js.map +0 -1
  359. package/dist/esm/resources/index.d.ts +0 -30
  360. package/dist/esm/resources/index.js +0 -31
  361. package/dist/esm/resources/index.js.map +0 -1
  362. package/dist/esm/resources/solution-resource.d.ts +0 -35
  363. package/dist/esm/resources/solution-resource.js +0 -28
  364. package/dist/esm/resources/solution-resource.js.map +0 -1
  365. package/dist/esm/resources/transform-resource-paths-to-solution-resources.d.ts +0 -56
  366. package/dist/esm/resources/transform-resource-paths-to-solution-resources.js +0 -132
  367. package/dist/esm/resources/transform-resource-paths-to-solution-resources.js.map +0 -1
  368. package/dist/esm/resources/update-resource.d.ts +0 -27
  369. package/dist/esm/resources/update-resource.js +0 -48
  370. package/dist/esm/resources/update-resource.js.map +0 -1
  371. package/dist/esm/restHelpers.d.ts +0 -634
  372. package/dist/esm/restHelpers.js +0 -1979
  373. package/dist/esm/restHelpers.js.map +0 -1
  374. package/dist/esm/restHelpersGet.d.ts +0 -303
  375. package/dist/esm/restHelpersGet.js +0 -793
  376. package/dist/esm/restHelpersGet.js.map +0 -1
  377. package/dist/esm/sharing/index.d.ts +0 -16
  378. package/dist/esm/sharing/index.js +0 -17
  379. package/dist/esm/sharing/index.js.map +0 -1
  380. package/dist/esm/sharing/share-item-to-groups.d.ts +0 -26
  381. package/dist/esm/sharing/share-item-to-groups.js +0 -40
  382. package/dist/esm/sharing/share-item-to-groups.js.map +0 -1
  383. package/dist/esm/templatization.d.ts +0 -139
  384. package/dist/esm/templatization.js +0 -291
  385. package/dist/esm/templatization.js.map +0 -1
  386. package/dist/esm/trackingHelpers.d.ts +0 -115
  387. package/dist/esm/trackingHelpers.js +0 -200
  388. package/dist/esm/trackingHelpers.js.map +0 -1
  389. package/dist/esm/velocityHelpers.d.ts +0 -68
  390. package/dist/esm/velocityHelpers.js +0 -144
  391. package/dist/esm/velocityHelpers.js.map +0 -1
  392. package/dist/esm/webtoolHelpers.d.ts +0 -57
  393. package/dist/esm/webtoolHelpers.js +0 -95
  394. package/dist/esm/webtoolHelpers.js.map +0 -1
  395. package/dist/esm/workflowHelpers.d.ts +0 -112
  396. package/dist/esm/workflowHelpers.js +0 -270
  397. package/dist/esm/workflowHelpers.js.map +0 -1
  398. package/dist/esm/workforceHelpers.d.ts +0 -121
  399. package/dist/esm/workforceHelpers.js +0 -691
  400. package/dist/esm/workforceHelpers.js.map +0 -1
  401. package/dist/esm/zip-utils.d.ts +0 -85
  402. package/dist/esm/zip-utils.js +0 -142
  403. package/dist/esm/zip-utils.js.map +0 -1
  404. package/dist/solution.js_commit.txt +0 -7
@@ -1,2044 +0,0 @@
1
- "use strict";
2
- /** @license
3
- * Copyright 2018 Esri
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports._countRelationships = exports._addItemMetadataFile = exports._addItemDataFile = exports.updateItemURL = exports.updateItemTemplateFromDictionary = exports.updateItemExtended = exports.updateGroup = exports.updateItem = exports.shareItem = exports.removeUsers = exports.reassignGroup = exports.searchGroupContents = exports.searchGroupAllContents = exports.searchAllGroups = exports.searchGroups = exports.searchAllItems = exports.searchItems = exports.removeItemOrGroup = exports.removeItem = exports.removeGroup = exports.removeFolder = exports.hasInvalidGroupDesignations = exports._parseAdminServiceData = exports.setWorkflowConfigurationZip = exports.getWorkflowConfigurationZip = exports.getFeatureServiceProperties = exports.getServiceLayersAndTables = exports.getRequest = exports._sortRelationships = exports.moveItemsToFolder = exports.moveItemToFolder = exports.getLayerUpdates = exports.getLayers = exports.extractDependencies = exports.createUniqueGroup = exports.createUniqueFolder = exports.createItemWithData = exports.createFullItem = exports.createFeatureService = exports.convertExtent = exports.convertExtentWithFallback = exports._validateExtent = exports.convertToISearchOptions = exports.checkRequestStatus = exports.addToServiceDefinition = exports.addTokenToUrl = exports.addForwardItemRelationships = exports.addForwardItemRelationship = exports.getUserSession = exports.addItemData = void 0;
19
- exports._updateItemURL = exports._updateIndexesForRelationshipKeyFields = exports._setItemProperties = exports._reportVariablesInItem = exports._lowercaseDomain = exports._getUpdate = exports._getSubtypeUpdates = exports._getContingentValuesUpdates = exports._getRelationshipUpdates = exports._getFallbackExtent = exports._getCreateServiceOptions = void 0;
20
- /**
21
- * Provides common functions involving the arcgis-rest-js library.
22
- *
23
- * @module restHelpers
24
- */
25
- const featureServiceHelpers_1 = require("./featureServiceHelpers");
26
- const generalHelpers_1 = require("./generalHelpers");
27
- const arcgisRestJS_1 = require("./arcgisRestJS");
28
- const libConnectors_1 = require("./libConnectors");
29
- const restHelpersGet_1 = require("./restHelpersGet");
30
- const workforceHelpers_1 = require("./workforceHelpers");
31
- const templatization_1 = require("./templatization");
32
- const trackingHelpers_1 = require("./trackingHelpers");
33
- // ------------------------------------------------------------------------------------------------------------------ //
34
- function addItemData(id, file, authentication) {
35
- const addDataOptions = {
36
- id,
37
- file,
38
- authentication,
39
- };
40
- return (0, arcgisRestJS_1.restAddItemData)(addDataOptions);
41
- }
42
- exports.addItemData = addItemData;
43
- /**
44
- * Creates a ArcGISIdentityManager via a function so that the global arcgisSolution variable can access authentication.
45
- *
46
- * @param options See https://developers.arcgis.com/arcgis-rest-js/api-reference/arcgis-rest-request/IArcGISIdentityManagerOptions/
47
- * @returns UserSession (ArcGISIdentityManager)
48
- */
49
- function getUserSession(options = {}) {
50
- return new arcgisRestJS_1.UserSession(options);
51
- }
52
- exports.getUserSession = getUserSession;
53
- /**
54
- * Adds a forward relationship between two items.
55
- *
56
- * @param originItemId Origin of relationship
57
- * @param destinationItemId Destination of relationship
58
- * @param relationshipType Type of relationship
59
- * @param authentication Credentials for the request
60
- * @returns A Promise to add item resources.
61
- */
62
- function addForwardItemRelationship(originItemId, destinationItemId, relationshipType, authentication) {
63
- return new Promise((resolve) => {
64
- const requestOptions = {
65
- originItemId,
66
- destinationItemId,
67
- relationshipType,
68
- authentication,
69
- };
70
- (0, arcgisRestJS_1.addItemRelationship)(requestOptions).then((response) => {
71
- resolve({
72
- success: response.success,
73
- itemId: originItemId,
74
- });
75
- }, () => {
76
- resolve({
77
- success: false,
78
- itemId: originItemId,
79
- });
80
- });
81
- });
82
- }
83
- exports.addForwardItemRelationship = addForwardItemRelationship;
84
- /**
85
- * Adds forward relationships for an item.
86
- *
87
- * @param originItemId Origin of relationship
88
- * @param destinationRelationships Destinations
89
- * @param authentication Credentials for the request
90
- * @returns A Promise to add item resources.
91
- */
92
- function addForwardItemRelationships(originItemId, destinationRelationships, authentication) {
93
- return new Promise((resolve) => {
94
- // Set up relationships using updated relationship information
95
- const relationshipPromises = new Array();
96
- destinationRelationships.forEach((relationship) => {
97
- relationship.relatedItemIds.forEach((relatedItemId) => {
98
- relationshipPromises.push(addForwardItemRelationship(originItemId, relatedItemId, relationship.relationshipType, authentication));
99
- });
100
- });
101
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
102
- Promise.all(relationshipPromises).then((responses) => resolve(responses));
103
- });
104
- }
105
- exports.addForwardItemRelationships = addForwardItemRelationships;
106
- /**
107
- * Adds a token to the query parameters of a URL.
108
- *
109
- * @param url URL to use as base
110
- * @param authentication Credentials to be used to generate token for URL
111
- * @returns A promise that will resolve with the supplied URL with `token=<token>` added to its query params
112
- * unless either the URL doesn't exist or the token can't be generated
113
- */
114
- function addTokenToUrl(url, authentication) {
115
- return new Promise((resolve) => {
116
- if (!url || !authentication) {
117
- resolve(url);
118
- }
119
- else {
120
- authentication.getToken(url).then((token) => {
121
- /* istanbul ignore else */
122
- if (token) {
123
- url = (0, generalHelpers_1.appendQueryParam)(url, "token=" + token);
124
- }
125
- resolve(url);
126
- }, () => resolve(url));
127
- }
128
- });
129
- }
130
- exports.addTokenToUrl = addTokenToUrl;
131
- /**
132
- * Calls addToDefinition for the service.
133
- *
134
- * Added retry due to some solutions failing to deploy in specific orgs/hives due to timeouts.
135
- * On the first pass we will use the quicker sync request to add.
136
- * If it fails we will use an async request that will avoid the timeout errors.
137
- *
138
- * @param url URL to use as base
139
- * @param options the info to add to the services definition
140
- * @param skipRetry a boolean to control if retry logic will be used. Defaults to false.
141
- * @param useAsync a boolean to control if we will use an async request
142
- * @returns A promise that will resolve when the request has completed
143
- */
144
- function addToServiceDefinition(url, options, skipRetry = false, useAsync = false) {
145
- /* istanbul ignore else */
146
- if (useAsync) {
147
- options.params = { ...options.params, async: true };
148
- }
149
- return new Promise((resolve, reject) => {
150
- (0, arcgisRestJS_1.svcAdminAddToServiceDefinition)(url, options).then((result) => {
151
- checkRequestStatus(result, options.authentication).then(() => resolve(null), (e) => reject((0, generalHelpers_1.fail)(e)));
152
- }, (e) => {
153
- if (!skipRetry) {
154
- addToServiceDefinition(url, options, true, true).then(() => resolve(null), (e) => reject(e));
155
- }
156
- else {
157
- reject((0, generalHelpers_1.fail)(e));
158
- }
159
- });
160
- });
161
- }
162
- exports.addToServiceDefinition = addToServiceDefinition;
163
- /**
164
- * When using an async request we need to poll the status url to know when the request has completed or failed.
165
- *
166
- * @param result the result returned from the addToDefinition request.
167
- * This will contain a status url or the standard sync result.
168
- * @param authentication Credentials to be used to generate token for URL
169
- * @returns A promise that will resolve when the request has completed
170
- */
171
- function checkRequestStatus(result, authentication) {
172
- return new Promise((resolve, reject) => {
173
- const url = result.statusURL || result.statusUrl;
174
- if (url) {
175
- const checkStatus = setInterval(() => {
176
- (0, arcgisRestJS_1.request)(url, { authentication }).then((r) => {
177
- /* istanbul ignore else */
178
- if (["completed", "success"].indexOf(r.status.toLowerCase()) > -1) {
179
- clearInterval(checkStatus);
180
- resolve();
181
- }
182
- else if (r.status.toLowerCase() === "failed") {
183
- clearInterval(checkStatus);
184
- reject(r);
185
- }
186
- }, (e) => {
187
- clearInterval(checkStatus);
188
- reject(e);
189
- });
190
- }, 2000);
191
- }
192
- else {
193
- resolve();
194
- }
195
- });
196
- }
197
- exports.checkRequestStatus = checkRequestStatus;
198
- /**
199
- * Converts a general search into an ISearchOptions structure.
200
- *
201
- * @param search Search specified in one of three ways
202
- * @returns Recast search
203
- */
204
- function convertToISearchOptions(search) {
205
- // Convert the search into an ISearchOptions
206
- let searchOptions = {
207
- q: "",
208
- start: 1,
209
- num: 100,
210
- };
211
- if (typeof search === "string") {
212
- // Insert query into defaults
213
- searchOptions.q = search;
214
- }
215
- else if (search instanceof arcgisRestJS_1.SearchQueryBuilder) {
216
- // Insert query into defaults
217
- searchOptions.q = search.toParam();
218
- }
219
- else {
220
- // search is ISearchOptions
221
- searchOptions = {
222
- ...searchOptions,
223
- ...search, // request
224
- };
225
- }
226
- // Remove the sortField if it's "relevance"; that's the default option and is not meant to be specified
227
- if (searchOptions.sortField === "relevance") {
228
- delete searchOptions.sortField;
229
- }
230
- return searchOptions;
231
- }
232
- exports.convertToISearchOptions = convertToISearchOptions;
233
- /**
234
- * Simple validate function to ensure all coordinates are numbers
235
- * In some cases orgs can have null or undefined coordinate values associated with the org extent
236
- *
237
- * @param extent the extent to validate
238
- * @returns the provided extent or a default global extent if some coordinates are not numbers
239
- * @private
240
- */
241
- function _validateExtent(extent) {
242
- // in some cases orgs can have invalid extents defined
243
- // this is a simple validate function that will ensure coordiantes are numbers
244
- // using -179,-89,179,89 because the project call is returning "NaN" when using -180,-90,180,90
245
- const hasInvalid = typeof extent.xmin !== "number" ||
246
- typeof extent.xmax !== "number" ||
247
- typeof extent.ymax !== "number" ||
248
- typeof extent.ymin !== "number";
249
- if (hasInvalid) {
250
- extent.xmin = -179;
251
- extent.xmax = 179;
252
- extent.ymax = 89;
253
- extent.ymin = -89;
254
- extent.spatialReference = { wkid: 4326 };
255
- }
256
- return extent;
257
- }
258
- exports._validateExtent = _validateExtent;
259
- /**
260
- * If the request to convert the extent fails it has commonly been due to an invalid extent.
261
- * This function will first attempt to use the provided extent. If it fails it will default to
262
- * the source items extent and if that fails it will then use a default global extent.
263
- *
264
- * @param extent the extent to convert
265
- * @param fallbackExtent the extent to convert if the main extent does not project to the outSR
266
- * @param outSR the spatial reference to project to
267
- * @param geometryServiceUrl the service url for the geometry service to use
268
- * @param authentication the credentials for the requests
269
- * @returns the extent projected to the provided spatial reference
270
- * or the world extent projected to the provided spatial reference
271
- * @private
272
- */
273
- function convertExtentWithFallback(extent, fallbackExtent, outSR, geometryServiceUrl, authentication) {
274
- return new Promise((resolve, reject) => {
275
- const defaultExtent = {
276
- xmin: -179,
277
- xmax: 179,
278
- ymin: -89,
279
- ymax: 89,
280
- spatialReference: { wkid: 4326 },
281
- };
282
- convertExtent(_validateExtent(extent), outSR, geometryServiceUrl, authentication).then((extentResponse) => {
283
- // in some cases project will complete successfully but return "NaN" values
284
- // check for this and call convert again if it does
285
- const extentResponseString = JSON.stringify(extentResponse);
286
- const validatedExtent = JSON.stringify(_validateExtent(extentResponse));
287
- if (extentResponseString === validatedExtent) {
288
- resolve(extentResponse);
289
- }
290
- else {
291
- convertExtent(fallbackExtent || defaultExtent, outSR, geometryServiceUrl, authentication).then(resolve, (e) => reject((0, generalHelpers_1.fail)(e)));
292
- }
293
- },
294
- // if convert fails try again with default global extent
295
- () => {
296
- convertExtent(defaultExtent, outSR, geometryServiceUrl, authentication).then(resolve, (e) => reject((0, generalHelpers_1.fail)(e)));
297
- });
298
- });
299
- }
300
- exports.convertExtentWithFallback = convertExtentWithFallback;
301
- /**
302
- * Converts an extent to a specified spatial reference.
303
- *
304
- * @param extent Extent object to check and (possibly) to project
305
- * @param outSR Desired spatial reference
306
- * @param geometryServiceUrl Path to geometry service providing `findTransformations` and `project` services
307
- * @param authentication Credentials for the request
308
- * @returns Original extent if it's already using outSR or the extents projected into the outSR
309
- */
310
- function convertExtent(extent, outSR, geometryServiceUrl, authentication) {
311
- const _requestOptions = {
312
- authentication,
313
- httpMethod: "GET",
314
- };
315
- return new Promise((resolve, reject) => {
316
- if (extent.spatialReference.wkid === outSR?.wkid || !outSR) {
317
- resolve(extent);
318
- }
319
- else {
320
- _requestOptions.params = {
321
- f: "json",
322
- inSR: extent.spatialReference.wkid,
323
- outSR: outSR.wkid,
324
- extentOfInterest: JSON.stringify(extent),
325
- };
326
- (0, arcgisRestJS_1.request)((0, generalHelpers_1.checkUrlPathTermination)(geometryServiceUrl) + "findTransformations", _requestOptions).then((response) => {
327
- const transformations = response && response.transformations ? response.transformations : undefined;
328
- let transformation;
329
- if (transformations && transformations.length > 0) {
330
- // if a forward single transformation is found use that...otherwise check for and use composite
331
- transformation = transformations[0].wkid
332
- ? transformations[0].wkid
333
- : transformations[0].geoTransforms
334
- ? transformations[0]
335
- : undefined;
336
- }
337
- _requestOptions.params = {
338
- f: "json",
339
- outSR: outSR.wkid,
340
- inSR: extent.spatialReference.wkid,
341
- geometries: {
342
- geometryType: "esriGeometryPoint",
343
- geometries: [
344
- { x: extent.xmin, y: extent.ymin },
345
- { x: extent.xmax, y: extent.ymax },
346
- ],
347
- },
348
- transformation: transformation,
349
- };
350
- (0, arcgisRestJS_1.request)((0, generalHelpers_1.checkUrlPathTermination)(geometryServiceUrl) + "project", _requestOptions).then((projectResponse) => {
351
- const projectGeom = projectResponse.geometries.length === 2 ? projectResponse.geometries : undefined;
352
- if (projectGeom) {
353
- resolve({
354
- xmin: projectGeom[0].x,
355
- ymin: projectGeom[0].y,
356
- xmax: projectGeom[1].x,
357
- ymax: projectGeom[1].y,
358
- spatialReference: outSR,
359
- });
360
- }
361
- else {
362
- resolve(undefined);
363
- }
364
- }, (e) => reject((0, generalHelpers_1.fail)(e)));
365
- }, (e) => reject((0, generalHelpers_1.fail)(e)));
366
- }
367
- });
368
- }
369
- exports.convertExtent = convertExtent;
370
- /**
371
- * Publishes a feature service as an AGOL item; it does not include its layers and tables
372
- *
373
- * @param newItemTemplate Template of item to be created
374
- * @param authentication Credentials for the request
375
- * @param templateDictionary Hash of facts: org URL, adlib replacements, user; .user.folders property contains a list
376
- * @returns A promise that will resolve with an object reporting success and the Solution id
377
- */
378
- function createFeatureService(newItemTemplate, authentication, templateDictionary) {
379
- return new Promise((resolve, reject) => {
380
- // Create item
381
- _getCreateServiceOptions(newItemTemplate, authentication, templateDictionary).then((createOptions) => {
382
- (0, arcgisRestJS_1.svcAdminCreateFeatureService)(createOptions).then((createResponse) => {
383
- // Federated servers may have inconsistent casing, so lowerCase it
384
- createResponse.encodedServiceURL = _lowercaseDomain(createResponse.encodedServiceURL);
385
- createResponse.serviceurl = _lowercaseDomain(createResponse.serviceurl);
386
- resolve(createResponse);
387
- }, (e) => reject((0, generalHelpers_1.fail)(e)));
388
- }, (e) => reject((0, generalHelpers_1.fail)(e)));
389
- });
390
- }
391
- exports.createFeatureService = createFeatureService;
392
- /**
393
- * Publishes an item and its data, metadata, and resources as an AGOL item.
394
- *
395
- * @param itemInfo Item's `item` section
396
- * @param folderId Id of folder to receive item; null indicates that the item goes into the root
397
- * folder; ignored for Group item type
398
- * @param destinationAuthentication Credentials for for requests to where the item is to be created
399
- * @param itemThumbnailUrl URL to image to use for item thumbnail
400
- * @param itemThumbnailAuthentication Credentials for requests to the thumbnail source
401
- * @param dataFile Item's `data` section
402
- * @param metadataFile Item's metadata file
403
- * @param resourcesFiles Item's resources
404
- * @param access Access to set for item: "public", "org", "private"
405
- * @returns A promise that will resolve with an object reporting success or failure and the Solution id
406
- */
407
- function createFullItem(itemInfo, folderId, destinationAuthentication, itemThumbnailUrl, itemThumbnailAuthentication, dataFile, metadataFile, resourcesFiles, access = "private") {
408
- return new Promise((resolve, reject) => {
409
- // Create item
410
- const createOptions = {
411
- item: {
412
- ...itemInfo,
413
- },
414
- folderId,
415
- authentication: destinationAuthentication,
416
- };
417
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
418
- addTokenToUrl(itemThumbnailUrl, itemThumbnailAuthentication).then((updatedThumbnailUrl) => {
419
- /* istanbul ignore else */
420
- if (updatedThumbnailUrl) {
421
- createOptions.item.thumbnailUrl = (0, generalHelpers_1.appendQueryParam)(updatedThumbnailUrl, "w=400");
422
- }
423
- (0, arcgisRestJS_1.createItemInFolder)(createOptions).then((createResponse) => {
424
- if (createResponse.success) {
425
- let accessDef;
426
- // Set access if it is not AGOL default
427
- // Set the access manually since the access value in createItem appears to be ignored
428
- // Need to run serially; will not work reliably if done in parallel with adding the data section
429
- if (access !== "private") {
430
- const accessOptions = {
431
- id: createResponse.id,
432
- access: access === "public" ? "public" : "org",
433
- authentication: destinationAuthentication,
434
- };
435
- accessDef = (0, arcgisRestJS_1.setItemAccess)(accessOptions);
436
- }
437
- else {
438
- accessDef = Promise.resolve({
439
- itemId: createResponse.id,
440
- });
441
- }
442
- // Now add attached items
443
- accessDef.then(() => {
444
- const updateDefs = [];
445
- // Add the data section
446
- if (dataFile) {
447
- updateDefs.push(_addItemDataFile(createResponse.id, dataFile, destinationAuthentication));
448
- }
449
- // Add the resources via a zip because AGO sometimes loses resources if many are added at the
450
- // same time to the same item
451
- if (Array.isArray(resourcesFiles) && resourcesFiles.length > 0) {
452
- updateDefs.push(new Promise((rsrcResolve, rsrcReject) => {
453
- (0, libConnectors_1.createZip)("resources.zip", resourcesFiles).then((zipfile) => {
454
- const addResourceOptions = {
455
- id: createResponse.id,
456
- resource: zipfile,
457
- authentication: destinationAuthentication,
458
- params: {
459
- archive: true,
460
- },
461
- };
462
- (0, arcgisRestJS_1.addItemResource)(addResourceOptions).then(rsrcResolve, rsrcReject);
463
- }, rsrcReject);
464
- }));
465
- }
466
- // Add the metadata section
467
- if (metadataFile) {
468
- updateDefs.push(_addItemMetadataFile(createResponse.id, metadataFile, destinationAuthentication));
469
- }
470
- // Wait until all adds are done
471
- Promise.all(updateDefs).then(() => resolve(createResponse), (e) => reject((0, generalHelpers_1.fail)(e)));
472
- }, (e) => reject((0, generalHelpers_1.fail)(e)));
473
- }
474
- else {
475
- reject((0, generalHelpers_1.fail)());
476
- }
477
- }, (e) => reject((0, generalHelpers_1.fail)(e)));
478
- });
479
- });
480
- }
481
- exports.createFullItem = createFullItem;
482
- /**
483
- * Publishes an item and its data as an AGOL item.
484
- *
485
- * @param itemInfo Item's `item` section
486
- * @param dataInfo Item's `data` section
487
- * @param authentication Credentials for the request
488
- * @param folderId Id of folder to receive item; null indicates that the item goes into the root
489
- * folder; ignored for Group item type
490
- * @param access Access to set for item: "public", "org", "private"
491
- * @returns A promise that will resolve with an object reporting success and the Solution id
492
- */
493
- function createItemWithData(itemInfo, dataInfo, authentication, folderId, access = "private") {
494
- return new Promise((resolve, reject) => {
495
- // Create item
496
- const createOptions = {
497
- item: {
498
- title: "_",
499
- ...itemInfo,
500
- data: dataInfo,
501
- },
502
- folderId,
503
- authentication: authentication,
504
- };
505
- if (itemInfo.thumbnail) {
506
- createOptions.params = {
507
- // Pass thumbnail file in via params because item property is serialized, which discards a blob
508
- thumbnail: itemInfo.thumbnail,
509
- };
510
- delete createOptions.item.thumbnail;
511
- }
512
- if (createOptions.params && createOptions.params.data) {
513
- createOptions.params[createOptions.params.data instanceof File ? "file" : "text"] = createOptions.params.data;
514
- }
515
- else {
516
- if (createOptions.params) {
517
- if (dataInfo instanceof File) {
518
- createOptions.params["file"] = dataInfo;
519
- }
520
- else {
521
- createOptions.params["text"] = dataInfo;
522
- }
523
- }
524
- else {
525
- if (dataInfo instanceof File) {
526
- createOptions.params = {
527
- file: dataInfo,
528
- };
529
- }
530
- else {
531
- createOptions.params = {
532
- text: dataInfo ? dataInfo : {},
533
- };
534
- }
535
- }
536
- }
537
- (0, arcgisRestJS_1.createItemInFolder)(createOptions).then((createResponse) => {
538
- if (createResponse.success) {
539
- if (access !== "private") {
540
- // Set access if it is not AGOL default
541
- // Set the access manually since the access value in createItem appears to be ignored
542
- const accessOptions = {
543
- id: createResponse.id,
544
- access: access === "public" ? "public" : "org",
545
- authentication: authentication,
546
- };
547
- (0, arcgisRestJS_1.setItemAccess)(accessOptions).then(() => {
548
- resolve({
549
- folder: createResponse.folder,
550
- id: createResponse.id,
551
- success: true,
552
- });
553
- }, (e) => reject((0, generalHelpers_1.fail)(e)));
554
- }
555
- else {
556
- resolve({
557
- folder: createResponse.folder,
558
- id: createResponse.id,
559
- success: true,
560
- });
561
- }
562
- }
563
- else {
564
- reject((0, generalHelpers_1.fail)());
565
- }
566
- }, (e) => reject((0, generalHelpers_1.fail)(e)));
567
- });
568
- }
569
- exports.createItemWithData = createItemWithData;
570
- /**
571
- * Creates a folder using a numeric suffix to ensure uniqueness if necessary.
572
- *
573
- * @param title Folder title, used as-is if possible and with suffix otherwise
574
- * @param templateDictionary Hash of facts: org URL, adlib replacements, user; .user.folders property contains a list
575
- * of known folder names; function updates list with existing names not yet known, and creates .user.folders if it
576
- * doesn't exist in the dictionary
577
- * @param authentication Credentials for creating folder
578
- * @returns Id of created folder
579
- */
580
- function createUniqueFolder(title, templateDictionary, authentication) {
581
- return new Promise((resolve, reject) => {
582
- // Get a title that is not already in use
583
- const folderTitle = (0, generalHelpers_1.getUniqueTitle)(title, templateDictionary, "user.folders");
584
- const folderCreationParam = {
585
- title: folderTitle,
586
- authentication: authentication,
587
- };
588
- (0, arcgisRestJS_1.createFolder)(folderCreationParam).then((ok) => resolve(ok), (err) => {
589
- // If the name already exists, we'll try again
590
- const errorDetails = (0, generalHelpers_1.getProp)(err, "response.error.details");
591
- if (Array.isArray(errorDetails) && errorDetails.length > 0) {
592
- const nameNotAvailMsg = "Folder title '" + folderTitle + "' not available.";
593
- if (errorDetails.indexOf(nameNotAvailMsg) >= 0) {
594
- // Create the user.folders property if it doesn't exist
595
- /* istanbul ignore else */
596
- if (!(0, generalHelpers_1.getProp)(templateDictionary, "user.folders")) {
597
- (0, generalHelpers_1.setCreateProp)(templateDictionary, "user.folders", []);
598
- }
599
- templateDictionary.user.folders.push({
600
- title: folderTitle,
601
- });
602
- createUniqueFolder(title, templateDictionary, authentication).then(resolve, reject);
603
- }
604
- else {
605
- reject(err);
606
- }
607
- }
608
- else {
609
- // Otherwise, error out
610
- reject(err);
611
- }
612
- });
613
- });
614
- }
615
- exports.createUniqueFolder = createUniqueFolder;
616
- /**
617
- * Creates a group using numeric suffix to ensure uniqueness.
618
- *
619
- * @param title Group title, used as-is if possible and with suffix otherwise
620
- * @param templateDictionary Hash of facts: org URL, adlib replacements, user
621
- * @param authentication Credentials for creating group
622
- * @param owner Optional arg for the Tracking owner
623
- * If the tracking owner is not the one deploying the solution
624
- * tracker groups will be created under the deployment user but
625
- * will be reassigned to the tracking owner.
626
- * @returns Information about created group
627
- */
628
- function createUniqueGroup(title, groupItem, templateDictionary, authentication, owner) {
629
- return new Promise((resolve, reject) => {
630
- let groupsPromise;
631
- // when working with tracker we need to consider the groups of the deploying user as well as the groups
632
- // of the tracking user...must be unique for both
633
- if (owner && owner !== authentication.username) {
634
- groupsPromise = searchAllGroups(`(owner:${owner}) orgid:${templateDictionary.organization.id}`, authentication);
635
- }
636
- else {
637
- groupsPromise = Promise.resolve([]);
638
- }
639
- // first get the tracker owner groups
640
- groupsPromise.then((groups) => {
641
- templateDictionary["allGroups"] = groups.concat((0, generalHelpers_1.getProp)(templateDictionary, "user.groups"));
642
- // Get a title that is not already in use
643
- groupItem.title = (0, generalHelpers_1.getUniqueTitle)(title, templateDictionary, "allGroups");
644
- const groupCreationParam = {
645
- group: groupItem,
646
- authentication: authentication,
647
- };
648
- (0, arcgisRestJS_1.createGroup)(groupCreationParam).then(resolve, (err) => {
649
- // If the name already exists, we'll try again
650
- const errorDetails = (0, generalHelpers_1.getProp)(err, "response.error.details");
651
- if (Array.isArray(errorDetails) && errorDetails.length > 0) {
652
- const nameNotAvailMsg = "You already have a group named '" + groupItem.title + "'. Try a different name.";
653
- if (errorDetails.indexOf(nameNotAvailMsg) >= 0) {
654
- templateDictionary.user.groups.push({
655
- title: groupItem.title,
656
- });
657
- createUniqueGroup(title, groupItem, templateDictionary, authentication).then(resolve, reject);
658
- }
659
- else {
660
- reject(err);
661
- }
662
- }
663
- else {
664
- // Otherwise, error out
665
- reject(err);
666
- }
667
- });
668
- }, (e) => reject(e));
669
- });
670
- }
671
- exports.createUniqueGroup = createUniqueGroup;
672
- /**
673
- * Gets the ids of the dependencies of an AGOL feature service item.
674
- * Dependencies will only exist when the service is a view.
675
- *
676
- * @param itemTemplate Template of item to be created
677
- * @param authentication Credentials for the request
678
- * @returns A promise that will resolve a list of dependencies
679
- */
680
- function extractDependencies(itemTemplate, authentication) {
681
- const dependencies = [];
682
- return new Promise((resolve, reject) => {
683
- // Get service dependencies when the item is a view
684
- // This step is skipped for tracker views as they will already have a source service in the org
685
- if (itemTemplate.properties.service.isView && itemTemplate.item.url && !(0, trackingHelpers_1.isTrackingViewTemplate)(itemTemplate)) {
686
- (0, arcgisRestJS_1.request)((0, generalHelpers_1.checkUrlPathTermination)(itemTemplate.item.url) + "sources?f=json", {
687
- authentication: authentication,
688
- }).then((response) => {
689
- /* istanbul ignore else */
690
- if (response && response.services) {
691
- response.services.forEach((layer) => {
692
- dependencies.push({
693
- id: layer.serviceItemId,
694
- name: layer.name,
695
- });
696
- });
697
- }
698
- resolve(dependencies);
699
- }, (e) => reject((0, generalHelpers_1.fail)(e)));
700
- }
701
- else if ((0, workforceHelpers_1.isWorkforceProject)(itemTemplate)) {
702
- resolve((0, workforceHelpers_1.getWorkforceDependencies)(itemTemplate, dependencies));
703
- }
704
- else {
705
- resolve(dependencies);
706
- }
707
- });
708
- }
709
- exports.extractDependencies = extractDependencies;
710
- /**
711
- * Get json info for the services layers
712
- *
713
- * @param serviceUrl the url for the service
714
- * @param layerList list of base layer info
715
- * @param authentication Credentials for the request
716
- * @returns A promise that will resolve a list of dependencies
717
- */
718
- function getLayers(serviceUrl, layerList, authentication) {
719
- return new Promise((resolve, reject) => {
720
- if (layerList.length === 0) {
721
- resolve([]);
722
- }
723
- // get the admin URL
724
- serviceUrl = serviceUrl.replace("/rest/services", "/rest/admin/services");
725
- const requestsDfd = [];
726
- layerList.forEach((layer) => {
727
- const requestOptions = {
728
- authentication: authentication,
729
- };
730
- requestsDfd.push((0, arcgisRestJS_1.request)((0, generalHelpers_1.checkUrlPathTermination)(serviceUrl) + layer["id"] + "?f=json", requestOptions));
731
- });
732
- // Wait until all layers are heard from
733
- Promise.all(requestsDfd).then((layers) => resolve(layers), (e) => reject((0, generalHelpers_1.fail)(e)));
734
- });
735
- }
736
- exports.getLayers = getLayers;
737
- /**
738
- * Add additional options to a layers definition.
739
- *
740
- * @param args The IPostProcessArgs for the request(s)
741
- * @param isPortal boolean to indicate if we are deploying to portal
742
- *
743
- * @returns An array of update instructions
744
- * @private
745
- */
746
- function getLayerUpdates(args, isPortal) {
747
- const adminUrl = args.itemTemplate.item.url.replace("rest/services", "rest/admin/services");
748
- const updates = [];
749
- const refresh = _getUpdate(adminUrl, null, null, args, "refresh");
750
- updates.push(refresh);
751
- Object.keys(args.objects).forEach((id) => {
752
- const obj = Object.assign({}, args.objects[id]);
753
- // These properties cannot be set in the update definition when working with portal
754
- if (isPortal) {
755
- (0, generalHelpers_1.deleteProps)(obj, ["type", "id", "relationships", "sourceServiceFields"]);
756
- }
757
- // handle definition deletes
758
- // removes previous editFieldsInfo fields if their names were changed
759
- if (obj.hasOwnProperty("deleteFields")) {
760
- updates.push(_getUpdate(adminUrl, id, obj, args, "delete"));
761
- (0, generalHelpers_1.deleteProp)(obj, "deleteFields");
762
- updates.push(_getUpdate(adminUrl, null, null, args, "refresh"));
763
- }
764
- });
765
- const subtypeUpdates = _getSubtypeUpdates({
766
- message: "add subtype updates",
767
- objects: args.objects,
768
- itemTemplate: args.itemTemplate,
769
- authentication: args.authentication,
770
- });
771
- /* istanbul ignore else */
772
- if (subtypeUpdates.length > 0 && isPortal) {
773
- subtypeUpdates.forEach((subtypeUpdate) => {
774
- updates.push(_getUpdate(adminUrl + subtypeUpdate.id, null, { subtypeField: subtypeUpdate.subtypeField }, args, "update"));
775
- updates.push(_getUpdate(adminUrl + subtypeUpdate.id, null, { defaultSubtypeCode: subtypeUpdate.defaultSubtypeCode }, args, "update"));
776
- updates.push(_getUpdate(adminUrl + subtypeUpdate.id, null, { subtypes: subtypeUpdate.subtypes }, args, "add"));
777
- });
778
- }
779
- // issue: #706
780
- // Add source service relationships
781
- // views will now always add all layers in a single call and will inherit the relationships from the source service
782
- if (!args.itemTemplate.properties.service.isView) {
783
- const relUpdates = _getRelationshipUpdates({
784
- message: "updated layer relationships",
785
- objects: args.objects,
786
- itemTemplate: args.itemTemplate,
787
- authentication: args.authentication,
788
- });
789
- // issue: #724
790
- // In portal the order the relationships are added needs to follow the layer order
791
- // otherwise the relationship IDs will be reset
792
- relUpdates.layers = _sortRelationships(args.itemTemplate.properties.layers, args.itemTemplate.properties.tables, relUpdates);
793
- /* istanbul ignore else */
794
- if (relUpdates.layers.length > 0) {
795
- updates.push(_getUpdate(adminUrl, null, relUpdates, args, "add"));
796
- updates.push(refresh);
797
- }
798
- // handle contingent values
799
- const contingentValuesUpdates = _getContingentValuesUpdates({
800
- message: "add layer contingent values",
801
- objects: args.objects,
802
- itemTemplate: args.itemTemplate,
803
- authentication: args.authentication,
804
- });
805
- /* istanbul ignore else */
806
- if (contingentValuesUpdates.length > 0) {
807
- contingentValuesUpdates.forEach((conUpdate) => {
808
- updates.push(_getUpdate(adminUrl + conUpdate.id, null, conUpdate.contingentValues, args, "add"));
809
- });
810
- }
811
- }
812
- // issue: https://devtopia.esri.com/WebGIS/solution-deployment-apps/issues/273
813
- // For portal only...add specific indexes with existing supplementary addToDefinition call if it exists
814
- // or with a new addToDefinition call if one doesn't already exist
815
- if (isPortal) {
816
- Object.keys(args.objects).forEach((id) => {
817
- const obj = Object.assign({}, args.objects[id]);
818
- let update;
819
- if (Array.isArray(obj.indexes) && obj.indexes.length > 0) {
820
- const layerHasExistingAdd = updates.some((u) => {
821
- if (u.url.indexOf(`${id}/addToDefinition`) > -1) {
822
- update = u;
823
- return true;
824
- }
825
- });
826
- if (layerHasExistingAdd) {
827
- // append to existing addToDef
828
- update.params.addToDefinition = {
829
- ...update.params.addToDefinition,
830
- indexes: obj.indexes,
831
- };
832
- }
833
- else {
834
- // create new addToDef
835
- updates.push(_getUpdate((0, generalHelpers_1.checkUrlPathTermination)(adminUrl) + id, null, { indexes: obj.indexes }, args, "add"));
836
- }
837
- }
838
- });
839
- }
840
- return updates.length === 1 ? [] : updates;
841
- }
842
- exports.getLayerUpdates = getLayerUpdates;
843
- /**
844
- * Moves an AGO item to a specified folder.
845
- *
846
- * @param itemId Id of item to move
847
- * @param folderId Id of folder to receive item
848
- * @param authentication Credentials for the request
849
- * @returns A Promise resolving to the results of the move
850
- */
851
- async function moveItemToFolder(itemId, folderId, authentication) {
852
- const moveOptions = {
853
- itemId,
854
- folderId,
855
- authentication,
856
- };
857
- return (0, arcgisRestJS_1.moveItem)(moveOptions);
858
- }
859
- exports.moveItemToFolder = moveItemToFolder;
860
- /**
861
- * Moves a list of AGO items to a specified folder.
862
- *
863
- * @param itemIds Ids of items to move
864
- * @param folderId Id of folder to receive item
865
- * @param authentication Credentials for the request
866
- * @returns A Promise resolving to the results of the moves
867
- */
868
- async function moveItemsToFolder(itemIds, folderId, authentication) {
869
- const movePromises = new Array();
870
- itemIds.forEach((itemId) => {
871
- movePromises.push(moveItemToFolder(itemId, folderId, authentication));
872
- });
873
- return Promise.all(movePromises);
874
- }
875
- exports.moveItemsToFolder = moveItemsToFolder;
876
- /**
877
- * Sorts relationships based on order of supporting layers and tables in the service definition
878
- *
879
- * @param layers the layers from the service
880
- * @param tables the tables from the service
881
- * @param relUpdates the relationships to add for the service
882
- *
883
- * @returns An array with relationships that have been sorted
884
- * @private
885
- */
886
- function _sortRelationships(layers, tables, relUpdates) {
887
- const ids = [].concat(layers.map((l) => l.id), tables.map((t) => t.id));
888
- // In portal the order the relationships are added needs to follow the layer order
889
- // otherwise the relationship IDs will be reset
890
- const _relUpdateLayers = [];
891
- ids.forEach((id) => {
892
- relUpdates.layers.some((relUpdate) => {
893
- if (id === relUpdate.id) {
894
- _relUpdateLayers.push(relUpdate);
895
- return true;
896
- }
897
- else {
898
- return false;
899
- }
900
- });
901
- });
902
- return _relUpdateLayers;
903
- }
904
- exports._sortRelationships = _sortRelationships;
905
- /**
906
- * Add additional options to a layers definition
907
- *
908
- * Added retry due to some solutions failing to deploy in specific orgs/hives
909
- *
910
- *
911
- * @param Update will contain either add, update, or delete from service definition call
912
- * @param skipRetry defaults to false. when true the retry logic will be ignored
913
- * @returns A promise that will resolve when service definition call has completed
914
- * @private
915
- */
916
- /* istanbul ignore else */
917
- function getRequest(update, skipRetry = false, useAsync = false, isPortal = false) {
918
- return new Promise((resolve, reject) => {
919
- const options = {
920
- params: update.params,
921
- authentication: update.args.authentication,
922
- };
923
- /* istanbul ignore else */
924
- if ((useAsync && update.url.indexOf("addToDefinition") > -1) ||
925
- update.url.indexOf("updateDefinition") > -1 ||
926
- update.url.indexOf("deleteFromDefinition") > -1) {
927
- options.params = { ...options.params, async: true };
928
- }
929
- (0, arcgisRestJS_1.request)(update.url, options).then((result) => {
930
- checkRequestStatus(result, options.authentication).then(() => resolve(null), (e) => reject((0, generalHelpers_1.fail)(e)));
931
- }, (e) => {
932
- if (!skipRetry) {
933
- getRequest(update, true, true, isPortal).then(() => resolve(), (e) => reject(e));
934
- }
935
- else {
936
- reject(e);
937
- }
938
- });
939
- });
940
- }
941
- exports.getRequest = getRequest;
942
- /**
943
- * Fills in missing data, including full layer and table definitions, in a feature services' definition.
944
- *
945
- * @param itemTemplate Feature service item, data, dependencies definition to be modified
946
- * @param authentication Credentials for the request to AGOL
947
- * @returns A promise that will resolve when fullItem has been updated
948
- * @private
949
- */
950
- function getServiceLayersAndTables(itemTemplate, authentication) {
951
- return new Promise((resolve, reject) => {
952
- // To have enough information for reconstructing the service, we'll supplement
953
- // the item and data sections with sections for the service, full layers, and
954
- // full tables
955
- // Extra steps must be taken for workforce version 2
956
- const isWorkforceService = (0, workforceHelpers_1.isWorkforceProject)(itemTemplate);
957
- // Get the service description
958
- if (itemTemplate.item.url) {
959
- getFeatureServiceProperties(itemTemplate.item.url, authentication, isWorkforceService).then((properties) => {
960
- itemTemplate.properties = properties;
961
- resolve(itemTemplate);
962
- }, (e) => reject((0, generalHelpers_1.fail)(e)));
963
- }
964
- else {
965
- resolve(itemTemplate);
966
- }
967
- });
968
- }
969
- exports.getServiceLayersAndTables = getServiceLayersAndTables;
970
- /**
971
- * Get service properties for the given url and update key props
972
- *
973
- * @param serviceUrl the feature service url
974
- * @param authentication Credentials for the request to AGOL
975
- * @param workforceService boolean to indicate if extra workforce service steps should be handled
976
- * @returns A promise that will resolve with the service properties
977
- * @private
978
- */
979
- function getFeatureServiceProperties(serviceUrl, authentication, workforceService = false) {
980
- return new Promise((resolve, reject) => {
981
- const properties = {
982
- service: {},
983
- layers: [],
984
- tables: [],
985
- };
986
- // get the admin URL
987
- serviceUrl = serviceUrl.replace("/rest/services", "/rest/admin/services");
988
- // Get the service description
989
- (0, arcgisRestJS_1.request)(serviceUrl + "?f=json", {
990
- authentication: authentication,
991
- }).then((serviceData) => {
992
- properties.service = _parseAdminServiceData(serviceData);
993
- // Copy cacheMaxAge to top level so that AGO sees it when deploying the service
994
- // serviceData may have set it if there isn't an adminServiceInfo
995
- /* istanbul ignore else */
996
- if (serviceData.adminServiceInfo?.cacheMaxAge) {
997
- properties.service.cacheMaxAge = serviceData.adminServiceInfo.cacheMaxAge;
998
- }
999
- // Move the layers and tables out of the service's data section
1000
- /* istanbul ignore else */
1001
- if (serviceData.layers) {
1002
- properties.layers = serviceData.layers;
1003
- // Fill in properties that the service layer doesn't provide
1004
- // and remove properties that should not exist in the template
1005
- properties.layers.forEach((layer) => {
1006
- layer.serviceItemId = properties.service.serviceItemId;
1007
- layer.extent = null;
1008
- (0, featureServiceHelpers_1.removeLayerOptimization)(layer);
1009
- });
1010
- }
1011
- delete serviceData.layers;
1012
- /* istanbul ignore else */
1013
- if (serviceData.tables) {
1014
- properties.tables = serviceData.tables;
1015
- // Fill in properties that the service layer doesn't provide
1016
- properties.tables.forEach((table) => {
1017
- table.serviceItemId = properties.service.serviceItemId;
1018
- table.extent = null;
1019
- });
1020
- }
1021
- delete serviceData.tables;
1022
- // Ensure solution items have unique indexes on relationship key fields
1023
- _updateIndexesForRelationshipKeyFields(properties);
1024
- (0, featureServiceHelpers_1.processContingentValues)(properties, serviceUrl, authentication).then(() => {
1025
- if (workforceService) {
1026
- (0, workforceHelpers_1.getWorkforceServiceInfo)(properties, serviceUrl, authentication).then(resolve, reject);
1027
- }
1028
- else {
1029
- resolve(properties);
1030
- }
1031
- }, (e) => reject((0, generalHelpers_1.fail)(e)));
1032
- }, (e) => reject((0, generalHelpers_1.fail)(e)));
1033
- });
1034
- }
1035
- exports.getFeatureServiceProperties = getFeatureServiceProperties;
1036
- /**
1037
- * Fetches the configuration of a workflow.
1038
- *
1039
- * @param itemId Id of the workflow item
1040
- * @param workflowBaseUrl URL of the workflow manager, e.g., "https://workflow.arcgis.com/orgId"
1041
- * @param authentication Credentials for the request to AGOL
1042
- * @returns Promise resolving with the workflow configuration in a zip file
1043
- * @throws {WorkflowJsonExceptionDTO} if request to workflow manager fails
1044
- */
1045
- async function getWorkflowConfigurationZip(itemId, workflowBaseUrl, authentication) {
1046
- const url = `${workflowBaseUrl}/admin/${itemId}/export`;
1047
- return (0, arcgisRestJS_1.request)(url, {
1048
- authentication,
1049
- headers: {
1050
- "Accept": "application/octet-stream",
1051
- "Authorization": `Bearer ${authentication.token}`,
1052
- "X-Esri-Authorization": `Bearer ${authentication.token}`,
1053
- },
1054
- params: {
1055
- f: "zip",
1056
- },
1057
- });
1058
- }
1059
- exports.getWorkflowConfigurationZip = getWorkflowConfigurationZip;
1060
- /**
1061
- * Sets the configuration of a workflow.
1062
- *
1063
- * @param itemId Id of the workflow item
1064
- * @param configurationZipFile Configuration files in a zip file
1065
- * @param workflowBaseUrl URL of the workflow manager, e.g., "https://workflow.arcgis.com/orgId"
1066
- * @param authentication Credentials for the request to AGOL
1067
- * @returns Promise resolving with the workflow configuration in a zip file
1068
- * @throws {WorkflowJsonExceptionDTO} if request to workflow manager fails
1069
- */
1070
- async function setWorkflowConfigurationZip(itemId, configurationZipFile, workflowBaseUrl, authentication) {
1071
- const url = `${workflowBaseUrl}/admin/${itemId}/import`;
1072
- return (0, arcgisRestJS_1.request)(url, {
1073
- authentication,
1074
- headers: {
1075
- "Accept": "application/octet-stream",
1076
- "Authorization": `Bearer ${authentication.token}`,
1077
- "X-Esri-Authorization": `Bearer ${authentication.token}`,
1078
- },
1079
- params: {
1080
- file: configurationZipFile,
1081
- },
1082
- });
1083
- }
1084
- exports.setWorkflowConfigurationZip = setWorkflowConfigurationZip;
1085
- /**
1086
- * Parses the layers array and will filter subsets of Layers and Tables
1087
- * Layers and Tables are both returned in the layers array when we access a feature service from the admin api.
1088
- *
1089
- * @param adminData The data of the feature service
1090
- * @returns A mutated version of the provided adminData
1091
- * @private
1092
- */
1093
- function _parseAdminServiceData(adminData) {
1094
- const layers = adminData.layers || [];
1095
- const tables = adminData.tables || [];
1096
- (0, generalHelpers_1.setCreateProp)(adminData, "layers", layers.filter((l) => l.type === "Feature Layer"));
1097
- // TODO understand if the concat is necessary.
1098
- // Not sure if the admin api will ever actually return a tables collection here.
1099
- (0, generalHelpers_1.setCreateProp)(adminData, "tables", tables.concat(layers.filter((l) => l.type === "Table")));
1100
- return adminData;
1101
- }
1102
- exports._parseAdminServiceData = _parseAdminServiceData;
1103
- /**
1104
- * livingatlas designation test.
1105
- * These layers should not be templatized or depolyed
1106
- *
1107
- * @param groupDesignations the items group designations to evaluate
1108
- * @returns A boolean indicating if the invalid designation is found in the item info
1109
- */
1110
- function hasInvalidGroupDesignations(groupDesignations) {
1111
- const invalidGroupDesignations = ["livingatlas"];
1112
- return groupDesignations ? invalidGroupDesignations.indexOf(groupDesignations) > -1 : false;
1113
- }
1114
- exports.hasInvalidGroupDesignations = hasInvalidGroupDesignations;
1115
- /**
1116
- * Removes a folder from AGO.
1117
- *
1118
- * @param folderId Id of a folder to delete
1119
- * @param authentication Credentials for the request to AGO
1120
- * @returns A promise that will resolve with the result of the request
1121
- */
1122
- function removeFolder(folderId, authentication) {
1123
- return new Promise((resolve, reject) => {
1124
- const requestOptions = {
1125
- folderId: folderId,
1126
- authentication: authentication,
1127
- };
1128
- (0, arcgisRestJS_1.restRemoveFolder)(requestOptions).then((result) => (result.success ? resolve(result) : reject(result)), reject);
1129
- });
1130
- }
1131
- exports.removeFolder = removeFolder;
1132
- /**
1133
- * Removes a group from AGO.
1134
- *
1135
- * @param groupId Id of a group to delete
1136
- * @param authentication Credentials for the request to AGO
1137
- * @returns A promise that will resolve with the result of the request
1138
- */
1139
- function removeGroup(groupId, authentication) {
1140
- return new Promise((resolve, reject) => {
1141
- const requestOptions = {
1142
- id: groupId,
1143
- authentication: authentication,
1144
- };
1145
- (0, arcgisRestJS_1.restRemoveGroup)(requestOptions).then((result) => (result.success ? resolve(result) : reject(result)), reject);
1146
- });
1147
- }
1148
- exports.removeGroup = removeGroup;
1149
- /**
1150
- * Removes an item from AGO.
1151
- *
1152
- * @param itemId Id of an item to delete
1153
- * @param authentication Credentials for the request to AGO
1154
- * @param permanentDelete If true (the default), the item is permanently deleted; if false and the item type
1155
- * supports the recycle bin, the item will be put into the recycle bin
1156
- * @returns A promise that will resolve with the result of the request
1157
- */
1158
- function removeItem(itemId, authentication, permanentDelete = true) {
1159
- return new Promise((resolve, reject) => {
1160
- const requestOptions = {
1161
- id: itemId,
1162
- authentication: authentication,
1163
- params: {
1164
- permanentDelete,
1165
- },
1166
- };
1167
- (0, arcgisRestJS_1.restRemoveItem)(requestOptions).then((result) => (result.success ? resolve(result) : reject(result)), reject);
1168
- });
1169
- }
1170
- exports.removeItem = removeItem;
1171
- /**
1172
- * Removes an item or group from AGO.
1173
- *
1174
- * @param itemId Id of an item or group to delete
1175
- * @param authentication Credentials for the request to AGO
1176
- * @param permanentDelete If true (the default), the item is permanently deleted; if false and the item type
1177
- * supports the recycle bin, the item will be put into the recycle bin; note that this does not apply to groups
1178
- * @returns A promise that will resolve with the result of the request
1179
- */
1180
- function removeItemOrGroup(itemId, authentication, permanentDelete = true) {
1181
- return new Promise((resolve, reject) => {
1182
- removeItem(itemId, authentication, permanentDelete).then(resolve, (error) => {
1183
- removeGroup(itemId, authentication).then(resolve, () => reject(error));
1184
- });
1185
- });
1186
- }
1187
- exports.removeItemOrGroup = removeItemOrGroup;
1188
- /**
1189
- * Searches for items matching a query and that the caller has access to.
1190
- *
1191
- * @param search Search string (e.g., "q=redlands+map") or a more detailed structure that can include authentication
1192
- * @returns Promise resolving with search results
1193
- * @see https://developers.arcgis.com/rest/users-groups-and-items/search.htm
1194
- */
1195
- function searchItems(search) {
1196
- return (0, arcgisRestJS_1.restSearchItems)(search);
1197
- }
1198
- exports.searchItems = searchItems;
1199
- /**
1200
- * Searches for items matching a query and that the caller has access to, continuing recursively until done.
1201
- *
1202
- * @param search Search string (e.g., "q=redlands+map") or a more detailed structure that can include authentication
1203
- * @param accumulatedResponse Response built from previous requests
1204
- * @returns Promise resolving with search results
1205
- * @see https://developers.arcgis.com/rest/users-groups-and-items/search.htm
1206
- */
1207
- function searchAllItems(search, accumulatedResponse) {
1208
- // Convert the search into an ISearchOptions
1209
- const searchOptions = convertToISearchOptions(search);
1210
- // Provide a base into which results can be concatenated
1211
- const completeResponse = accumulatedResponse
1212
- ? accumulatedResponse
1213
- : {
1214
- query: searchOptions.q,
1215
- start: 1,
1216
- num: 100,
1217
- nextStart: -1,
1218
- total: 0,
1219
- results: [],
1220
- };
1221
- return new Promise((resolve, reject) => {
1222
- searchItems(search).then((response) => {
1223
- completeResponse.results = completeResponse.results.concat(response.results);
1224
- completeResponse.num = completeResponse.total = completeResponse.results.length;
1225
- if (response.nextStart > 0) {
1226
- // Insert nextStart into next query
1227
- searchOptions.start = response.nextStart;
1228
- resolve(searchAllItems(searchOptions, completeResponse));
1229
- }
1230
- else {
1231
- resolve(completeResponse);
1232
- }
1233
- }, (e) => reject(e));
1234
- });
1235
- }
1236
- exports.searchAllItems = searchAllItems;
1237
- /**
1238
- * Searches for groups matching criteria.
1239
- *
1240
- * @param searchString Text for which to search, e.g., 'redlands+map', 'type:"Web Map" -type:"Web Mapping Application"'
1241
- * @param authentication Credentials for the request to AGO
1242
- * @param additionalSearchOptions Adjustments to search, such as tranche size
1243
- * @returns A promise that will resolve with a structure with a tranche of results and
1244
- * describing how many items are available
1245
- * @see https://developers.arcgis.com/rest/users-groups-and-items/group-search.htm
1246
- * @see https://developers.arcgis.com/rest/users-groups-and-items/search-reference.htm
1247
- */
1248
- function searchGroups(searchString, authentication, additionalSearchOptions) {
1249
- const searchOptions = {
1250
- q: searchString,
1251
- params: {
1252
- ...additionalSearchOptions,
1253
- },
1254
- authentication: authentication,
1255
- };
1256
- return (0, arcgisRestJS_1.restSearchGroups)(searchOptions);
1257
- }
1258
- exports.searchGroups = searchGroups;
1259
- /**
1260
- * Searches for groups matching criteria recurusively.
1261
- *
1262
- * @param searchString Text for which to search, e.g., 'redlands+map', 'type:"Web Map" -type:"Web Mapping Application"'
1263
- * @param authentication Credentials for the request to AGO
1264
- * @param groups List of groups that have been found from previous requests
1265
- * @param inPagingParams The paging params for the recurisve searching
1266
- *
1267
- * @returns A promise that will resolve with all groups that meet the search criteria
1268
- */
1269
- function searchAllGroups(searchString, authentication, groups, inPagingParams) {
1270
- const pagingParams = inPagingParams
1271
- ? inPagingParams
1272
- : {
1273
- start: 1,
1274
- num: 24,
1275
- };
1276
- const additionalSearchOptions = {
1277
- sortField: "title",
1278
- sortOrder: "asc",
1279
- ...pagingParams,
1280
- };
1281
- // Provide a base onto which results can be concatenated
1282
- let finalResults = groups ? groups : [];
1283
- return new Promise((resolve, reject) => {
1284
- searchGroups(searchString, authentication, additionalSearchOptions).then((response) => {
1285
- finalResults = finalResults.concat(response.results);
1286
- if (response.nextStart > 0) {
1287
- pagingParams.start = response.nextStart;
1288
- resolve(searchAllGroups(searchString, authentication, finalResults, pagingParams));
1289
- }
1290
- else {
1291
- resolve(finalResults);
1292
- }
1293
- }, (e) => reject(e));
1294
- });
1295
- }
1296
- exports.searchAllGroups = searchAllGroups;
1297
- /**
1298
- * Searches for group contents matching criteria recursively.
1299
- *
1300
- * @param groupId Group whose contents are to be searched
1301
- * @param searchString Text for which to search, e.g., 'redlands+map', 'type:"Web Map" -type:"Web Mapping Application"'
1302
- * @param authentication Credentials for the request to AGO
1303
- * @param additionalSearchOptions Adjustments to search, such as tranche size and categories of interest; categories
1304
- * are supplied as an array: each array element consists of one or more categories to be ORed; array elements are ANDed
1305
- * @param portalUrl Rest Url of the portal to perform the search
1306
- * @param accumulatedResponse Response built from previous requests
1307
- * @returns A promise that will resolve with a structure with a tranche of results and
1308
- * describing how many items are available
1309
- * @see https://developers.arcgis.com/rest/users-groups-and-items/group-content-search.htm
1310
- * @see https://developers.arcgis.com/rest/users-groups-and-items/search-reference.htm
1311
- */
1312
- function searchGroupAllContents(groupId, searchString, authentication, additionalSearchOptions, portalUrl, accumulatedResponse) {
1313
- additionalSearchOptions = additionalSearchOptions ? additionalSearchOptions : {};
1314
- // Provide a base into which results can be concatenated
1315
- const completeResponse = accumulatedResponse
1316
- ? accumulatedResponse
1317
- : {
1318
- query: searchString,
1319
- start: 1,
1320
- num: 100,
1321
- nextStart: -1,
1322
- total: 0,
1323
- results: [],
1324
- };
1325
- // Remove the sortField if it's "relevance"; that's the default option and is not meant to be specified
1326
- if (additionalSearchOptions.sortField === "relevance") {
1327
- delete additionalSearchOptions.sortField;
1328
- }
1329
- return new Promise((resolve, reject) => {
1330
- searchGroupContents(groupId, searchString, authentication, additionalSearchOptions, portalUrl).then((response) => {
1331
- completeResponse.results = completeResponse.results.concat(response.results);
1332
- completeResponse.num = completeResponse.total = completeResponse.results.length;
1333
- if (response.nextStart > 0) {
1334
- additionalSearchOptions.start = response.nextStart;
1335
- resolve(searchGroupAllContents(groupId, searchString, authentication, additionalSearchOptions, portalUrl, completeResponse));
1336
- }
1337
- else {
1338
- resolve(completeResponse);
1339
- }
1340
- }, (e) => reject(e));
1341
- });
1342
- }
1343
- exports.searchGroupAllContents = searchGroupAllContents;
1344
- /**
1345
- * Searches for group contents matching criteria.
1346
- *
1347
- * @param groupId Group whose contents are to be searched
1348
- * @param searchString Text for which to search, e.g., 'redlands+map', 'type:"Web Map" -type:"Web Mapping Application"'
1349
- * @param authentication Credentials for the request to AGO
1350
- * @param additionalSearchOptions Adjustments to search, such as tranche size and categories of interest; categories
1351
- * are supplied as an array: each array element consists of one or more categories to be ORed; array elements are ANDed
1352
- * @param portalUrl Rest Url of the portal to perform the search
1353
- * @returns A promise that will resolve with a structure with a tranche of results and
1354
- * describing how many items are available
1355
- * @see https://developers.arcgis.com/rest/users-groups-and-items/group-content-search.htm
1356
- * @see https://developers.arcgis.com/rest/users-groups-and-items/search-reference.htm
1357
- */
1358
- function searchGroupContents(groupId, searchString, authentication, additionalSearchOptions, portalUrl) {
1359
- const searchOptions = {
1360
- groupId,
1361
- q: searchString,
1362
- params: Object.assign({
1363
- num: 100,
1364
- }, additionalSearchOptions),
1365
- authentication: authentication,
1366
- portal: portalUrl,
1367
- };
1368
- // If search options include `categories`, switch to new arcgis-rest-js format
1369
- /* istanbul ignore else */
1370
- if (Array.isArray(searchOptions.params.categories)) {
1371
- searchOptions.params.categories = searchOptions.params.categories.map((andGroup) => andGroup.split(","));
1372
- }
1373
- return (0, arcgisRestJS_1.searchGroupContent)(searchOptions);
1374
- }
1375
- exports.searchGroupContents = searchGroupContents;
1376
- /**
1377
- * Reassign ownership of a group
1378
- *
1379
- * @param groupId Group to remove users from
1380
- * @param userName The new owner for the group
1381
- * @param authentication Credentials for the request to
1382
- *
1383
- * @returns A promise that will resolve after the group ownership has been assigned
1384
- *
1385
- */
1386
- function reassignGroup(groupId, userName, authentication) {
1387
- const requestOptions = {
1388
- authentication: authentication,
1389
- params: {
1390
- targetUsername: userName,
1391
- },
1392
- };
1393
- return (0, arcgisRestJS_1.request)(`${authentication.portal}/community/groups/${groupId}/reassign`, requestOptions);
1394
- }
1395
- exports.reassignGroup = reassignGroup;
1396
- /**
1397
- * Remove users from a group
1398
- *
1399
- * @param groupId Group to remove users from
1400
- * @param users List of users to remove from the group
1401
- * @param authentication Credentials for the request to
1402
- *
1403
- * @returns A promise that will resolve after the users have been removed
1404
- *
1405
- */
1406
- function removeUsers(groupId, users, authentication) {
1407
- return (0, arcgisRestJS_1.removeGroupUsers)({
1408
- id: groupId,
1409
- users,
1410
- authentication,
1411
- });
1412
- }
1413
- exports.removeUsers = removeUsers;
1414
- /**
1415
- * Shares an item to the defined group
1416
- *
1417
- * @param groupId Group to share with
1418
- * @param id the item id to share with the group
1419
- * @param destinationAuthentication Credentials for the request to AGO
1420
- * @param owner owner of the group when sharing tracking items (can be different from the deploying user)
1421
- *
1422
- * @returns A promise that will resolve after the item has been shared
1423
- *
1424
- */
1425
- function shareItem(groupId, id, destinationAuthentication, owner) {
1426
- return new Promise((resolve, reject) => {
1427
- const shareOptions = {
1428
- groupId,
1429
- id,
1430
- authentication: destinationAuthentication,
1431
- };
1432
- /* istanbul ignore else */
1433
- if (owner) {
1434
- shareOptions.owner = owner;
1435
- }
1436
- (0, arcgisRestJS_1.shareItemWithGroup)(shareOptions).then(() => resolve(null), (e) => reject((0, generalHelpers_1.fail)(e)));
1437
- });
1438
- }
1439
- exports.shareItem = shareItem;
1440
- /**
1441
- * Updates an item.
1442
- *
1443
- * @param itemInfo The base info of an item; note that this content will be serialized, which doesn't work
1444
- * for binary content
1445
- * @param authentication Credentials for request
1446
- * @param folderId Item's folder
1447
- * @param additionalParams Updates that are put under the `params` property, which is not serialized
1448
- * @return
1449
- */
1450
- function updateItem(itemInfo, authentication, folderId, additionalParams) {
1451
- return new Promise((resolve, reject) => {
1452
- const updateOptions = {
1453
- item: itemInfo,
1454
- folderId: folderId,
1455
- authentication: authentication,
1456
- params: {
1457
- ...(additionalParams ?? {}),
1458
- },
1459
- };
1460
- if (itemInfo?.data instanceof File) {
1461
- //updateOptions.file = itemInfo.data;
1462
- updateOptions.params.file = itemInfo.data;
1463
- }
1464
- else {
1465
- //updateOptions.text = itemInfo.data;
1466
- updateOptions.params.text = itemInfo.data;
1467
- }
1468
- (0, arcgisRestJS_1.restUpdateItem)(updateOptions).then((response) => (response.success ? resolve(response) : reject(response)), (err) => reject(err));
1469
- });
1470
- }
1471
- exports.updateItem = updateItem;
1472
- /**
1473
- * Updates a group.
1474
- *
1475
- * @param groupInfo The base info of a group; note that this content will be serialized, which doesn't work
1476
- * for binary content
1477
- * @param authentication Credentials for request
1478
- * @param additionalParams Updates that are put under the `params` property, which is not serialized
1479
- * @returns A Promise that will resolve with the success/failure status of the request
1480
- */
1481
- function updateGroup(groupInfo, authentication, additionalParams) {
1482
- return new Promise((resolve, reject) => {
1483
- const updateOptions = {
1484
- group: groupInfo,
1485
- authentication,
1486
- params: {
1487
- ...(additionalParams ?? {}),
1488
- },
1489
- };
1490
- (0, arcgisRestJS_1.restUpdateGroup)(updateOptions).then((response) => (response.success ? resolve(response) : reject(response)), (err) => reject(err));
1491
- });
1492
- }
1493
- exports.updateGroup = updateGroup;
1494
- /**
1495
- * Updates an item.
1496
- *
1497
- * @param itemInfo The base info of an item
1498
- * @param data The items data section
1499
- * @param authentication Credentials for requests
1500
- * @param thumbnail optional thumbnail to update
1501
- * @param access "public" or "org"
1502
- * @return
1503
- */
1504
- function updateItemExtended(itemInfo, data, authentication, thumbnail, access, templateDictionary) {
1505
- return new Promise((resolve, reject) => {
1506
- const updateOptions = {
1507
- item: itemInfo,
1508
- params: {
1509
- text: data || {}, // AGO ignores update if `data` is empty
1510
- },
1511
- authentication: authentication,
1512
- };
1513
- if (thumbnail) {
1514
- updateOptions.params.thumbnail = thumbnail;
1515
- }
1516
- if ((0, trackingHelpers_1.isTrackingViewTemplate)(undefined, itemInfo) && templateDictionary) {
1517
- updateOptions.owner = templateDictionary.locationTracking.owner;
1518
- }
1519
- (0, arcgisRestJS_1.restUpdateItem)(updateOptions).then((result) => {
1520
- if (access && access !== "private") {
1521
- // Set access if it is not AGOL default
1522
- // Set the access manually since the access value in createItem appears to be ignored
1523
- const accessOptions = {
1524
- id: itemInfo.id,
1525
- access: access === "public" ? "public" : "org",
1526
- authentication: authentication,
1527
- };
1528
- (0, arcgisRestJS_1.setItemAccess)(accessOptions).then(() => resolve(result), (e) => reject((0, generalHelpers_1.fail)(e)));
1529
- }
1530
- else {
1531
- resolve(result);
1532
- }
1533
- }, (e) => reject((0, generalHelpers_1.fail)(e)));
1534
- });
1535
- }
1536
- exports.updateItemExtended = updateItemExtended;
1537
- /**
1538
- * Update an item's base and data using a dictionary.
1539
- *
1540
- * @param {string} itemId The item ID
1541
- * @param {any} templateDictionary The template dictionary
1542
- * @param {UserSession} authentication The destination session info
1543
- * @returns Promise resolving to successfulness of update
1544
- */
1545
- function updateItemTemplateFromDictionary(itemId, templateDictionary, authentication) {
1546
- return new Promise((resolve, reject) => {
1547
- // Fetch the items as stored in AGO
1548
- Promise.all([(0, restHelpersGet_1.getItemBase)(itemId, authentication), (0, restHelpersGet_1.getItemDataAsJson)(itemId, authentication)])
1549
- .then(([item, data]) => {
1550
- // Do they have any variables?
1551
- if ((0, templatization_1.hasUnresolvedVariables)(item) || (0, templatization_1.hasUnresolvedVariables)(data)) {
1552
- // Update if so
1553
- const { item: updatedItem, data: updatedData } = (0, templatization_1.replaceInTemplate)({ item, data }, templateDictionary);
1554
- _reportVariablesInItem(itemId, item.type, updatedItem, updatedData);
1555
- return updateItemExtended(updatedItem, updatedData, authentication);
1556
- }
1557
- else {
1558
- // Shortcut out if not
1559
- return Promise.resolve({
1560
- success: true,
1561
- id: itemId,
1562
- });
1563
- }
1564
- })
1565
- .then((result) => resolve(result))
1566
- .catch((error) => reject(error));
1567
- });
1568
- }
1569
- exports.updateItemTemplateFromDictionary = updateItemTemplateFromDictionary;
1570
- /**
1571
- * Updates the URL of an item.
1572
- *
1573
- * @param id AGOL id of item to update
1574
- * @param url URL to assign to item's base section
1575
- * @param authentication Credentials for the request
1576
- * @returns A promise that will resolve with the item id when the item has been updated or an AGO-style JSON failure
1577
- * response
1578
- */
1579
- function updateItemURL(id, url, authentication) {
1580
- const numAttempts = 3;
1581
- return _updateItemURL(id, url, authentication, numAttempts);
1582
- }
1583
- exports.updateItemURL = updateItemURL;
1584
- // ------------------------------------------------------------------------------------------------------------------ //
1585
- /**
1586
- * Adds a data section to an item.
1587
- *
1588
- * @param itemId Id of item to receive data file
1589
- * @param dataFile Data to be added
1590
- * @param authentication Credentials for the request
1591
- * @returns Promise reporting success or failure
1592
- * @private
1593
- */
1594
- function _addItemDataFile(itemId, dataFile, authentication) {
1595
- return new Promise((resolve, reject) => {
1596
- const _addItemData = (data) => {
1597
- addItemData(itemId, data, authentication).then(resolve, reject);
1598
- };
1599
- // Item data has to be submitted as text or JSON for those file types
1600
- if (dataFile.type.startsWith("text/plain")) {
1601
- (0, generalHelpers_1.blobToText)(dataFile).then(_addItemData, reject);
1602
- }
1603
- else if (dataFile.type === "application/json") {
1604
- (0, generalHelpers_1.blobToJson)(dataFile).then(_addItemData, reject);
1605
- }
1606
- else {
1607
- _addItemData(dataFile);
1608
- }
1609
- });
1610
- }
1611
- exports._addItemDataFile = _addItemDataFile;
1612
- /**
1613
- * Adds a metadata file to an item.
1614
- *
1615
- * @param itemId Id of item to receive data file
1616
- * @param metadataFile Metadata to be added
1617
- * @param authentication Credentials for the request
1618
- * @returns Promise reporting success or failure
1619
- * @private
1620
- */
1621
- function _addItemMetadataFile(itemId, metadataFile, authentication) {
1622
- return new Promise((resolve, reject) => {
1623
- const addMetadataOptions = {
1624
- item: {
1625
- id: itemId,
1626
- },
1627
- params: {
1628
- // Pass metadata in via params because item property is serialized, which discards a blob
1629
- metadata: metadataFile,
1630
- },
1631
- authentication: authentication,
1632
- };
1633
- (0, arcgisRestJS_1.restUpdateItem)(addMetadataOptions).then(resolve, reject);
1634
- });
1635
- }
1636
- exports._addItemMetadataFile = _addItemMetadataFile;
1637
- /**
1638
- * Accumulates the number of relationships in a collection of layers.
1639
- *
1640
- * @param List of layers to examine
1641
- * @returns The number of relationships
1642
- * @private
1643
- */
1644
- function _countRelationships(layers) {
1645
- const reducer = (accumulator, currentLayer) => accumulator + (currentLayer.relationships ? currentLayer.relationships.length : 0);
1646
- return layers.reduce(reducer, 0);
1647
- }
1648
- exports._countRelationships = _countRelationships;
1649
- /**
1650
- * Gets the full definitions of the layers affiliated with a hosted service.
1651
- *
1652
- * @param serviceUrl URL to hosted service
1653
- * @param layerList List of layers at that service...must contain id
1654
- * @param authentication Credentials for the request
1655
- * @returns A promise that will resolve with a list of the layers from the admin api
1656
- * @private
1657
- */
1658
- function _getCreateServiceOptions(newItemTemplate, authentication, templateDictionary) {
1659
- return new Promise((resolve, reject) => {
1660
- const serviceInfo = newItemTemplate.properties;
1661
- const folderId = templateDictionary.folderId;
1662
- const isPortal = templateDictionary.isPortal;
1663
- const itemId = newItemTemplate.itemId;
1664
- (0, featureServiceHelpers_1.validateSpatialReferenceAndExtent)(serviceInfo, newItemTemplate, templateDictionary);
1665
- const fallbackExtent = _getFallbackExtent(serviceInfo, templateDictionary);
1666
- const params = {};
1667
- const itemInfo = {
1668
- title: newItemTemplate.item.title,
1669
- name: newItemTemplate.item.name,
1670
- };
1671
- const _item = {
1672
- ...itemInfo,
1673
- preserveLayerIds: true,
1674
- };
1675
- const createOptions = {
1676
- item: _item,
1677
- folderId,
1678
- params,
1679
- authentication: authentication,
1680
- };
1681
- createOptions.item = !(0, trackingHelpers_1.isTrackingViewTemplate)(newItemTemplate)
1682
- ? _setItemProperties(createOptions.item, newItemTemplate, serviceInfo, params, isPortal)
1683
- : (0, trackingHelpers_1.setTrackingOptions)(newItemTemplate, createOptions, templateDictionary);
1684
- // project the portals extent to match that of the service
1685
- convertExtentWithFallback(templateDictionary.organization.defaultExtent, fallbackExtent, serviceInfo.service.spatialReference, templateDictionary.organization.helperServices.geometry.url, authentication).then((extent) => {
1686
- templateDictionary[itemId].solutionExtent = extent;
1687
- (0, featureServiceHelpers_1.setDefaultSpatialReference)(templateDictionary, itemId, extent.spatialReference);
1688
- createOptions.item = (0, templatization_1.replaceInTemplate)(createOptions.item, templateDictionary);
1689
- createOptions.params = (0, templatization_1.replaceInTemplate)(createOptions.params, templateDictionary);
1690
- if (newItemTemplate.item.thumbnail) {
1691
- // Pass thumbnail file in via params because item property is serialized, which discards a blob
1692
- createOptions.params.thumbnail = newItemTemplate.item.thumbnail;
1693
- }
1694
- resolve(createOptions);
1695
- }, (e) => reject((0, generalHelpers_1.fail)(e)));
1696
- });
1697
- }
1698
- exports._getCreateServiceOptions = _getCreateServiceOptions;
1699
- /**
1700
- * When the services spatial reference does not match that of it's default extent
1701
- * use the out SRs default extent if it exists in the templateDictionary
1702
- * this should be set when adding a custom out wkid to the params before calling deploy
1703
- * this will help avoid situations where the orgs default extent and default world extent
1704
- * will not project successfully to the out SR
1705
- *
1706
- * @param serviceInfo the object that contains the spatial reference to evaluate
1707
- * @param templateDictionary the template dictionary
1708
- * @returns the extent to use as the fallback
1709
- * @private
1710
- */
1711
- function _getFallbackExtent(serviceInfo, templateDictionary) {
1712
- const serviceSR = serviceInfo.service.spatialReference;
1713
- const serviceInfoWkid = (0, generalHelpers_1.getProp)(serviceInfo, "defaultExtent.spatialReference.wkid");
1714
- const customDefaultExtent = (0, generalHelpers_1.getProp)(templateDictionary, "params.defaultExtent");
1715
- return serviceInfoWkid && serviceInfoWkid === serviceSR.wkid
1716
- ? serviceInfo.defaultExtent
1717
- : customDefaultExtent
1718
- ? customDefaultExtent
1719
- : serviceInfo.defaultExtent;
1720
- }
1721
- exports._getFallbackExtent = _getFallbackExtent;
1722
- /**
1723
- * Add relationships to all layers in one call to retain fully functioning composite relationships
1724
- *
1725
- * @param args The IPostProcessArgs for the request(s)
1726
- * @returns Any relationships that should be updated for the service
1727
- * @private
1728
- */
1729
- function _getRelationshipUpdates(args) {
1730
- const rels = {
1731
- layers: [],
1732
- };
1733
- Object.keys(args.objects).forEach((k) => {
1734
- const obj = args.objects[k];
1735
- /* istanbul ignore else */
1736
- if (obj.relationships && obj.relationships.length > 0) {
1737
- rels.layers.push({
1738
- id: obj.id,
1739
- relationships: obj.relationships,
1740
- });
1741
- }
1742
- (0, generalHelpers_1.deleteProp)(obj, "relationships");
1743
- });
1744
- return rels;
1745
- }
1746
- exports._getRelationshipUpdates = _getRelationshipUpdates;
1747
- /**
1748
- * Get the stored contingent values and structure them to be added to the services layers.
1749
- *
1750
- * @param args The IPostProcessArgs for the request(s)
1751
- * @returns Any contingent values that should be added to the service.
1752
- * @private
1753
- */
1754
- function _getContingentValuesUpdates(args) {
1755
- const contingentValues = [];
1756
- Object.keys(args.objects).forEach((k) => {
1757
- const obj = args.objects[k];
1758
- /* istanbul ignore else */
1759
- if (obj.contingentValues) {
1760
- contingentValues.push({
1761
- id: obj.id,
1762
- contingentValues: obj.contingentValues,
1763
- });
1764
- }
1765
- (0, generalHelpers_1.deleteProp)(obj, "contingentValues");
1766
- });
1767
- return contingentValues;
1768
- }
1769
- exports._getContingentValuesUpdates = _getContingentValuesUpdates;
1770
- /**
1771
- * Get the stored subtype values and structure them to be added to the services layers.
1772
- *
1773
- * @param args The IPostProcessArgs for the request(s)
1774
- * @returns Any subtype values that should be added to the service.
1775
- * @private
1776
- */
1777
- function _getSubtypeUpdates(args) {
1778
- const subtypeUpdates = [];
1779
- Object.keys(args.objects).forEach((k) => {
1780
- const obj = args.objects[k];
1781
- /* istanbul ignore else */
1782
- if (obj.subtypeField) {
1783
- subtypeUpdates.push({
1784
- id: obj.id,
1785
- subtypeField: obj.subtypeField,
1786
- subtypes: obj.subtypes,
1787
- defaultSubtypeCode: obj.defaultSubtypeCode,
1788
- });
1789
- }
1790
- (0, generalHelpers_1.deleteProp)(obj, "subtypeField");
1791
- (0, generalHelpers_1.deleteProp)(obj, "subtypes");
1792
- (0, generalHelpers_1.deleteProp)(obj, "defaultSubtypeCode");
1793
- });
1794
- return subtypeUpdates;
1795
- }
1796
- exports._getSubtypeUpdates = _getSubtypeUpdates;
1797
- /**
1798
- * Get refresh, add, update, or delete definition info
1799
- *
1800
- * @param url the base admin url for the service
1801
- * @param id the id of the layer
1802
- * @param obj parameters for the request
1803
- * @param args various arguments to help support the request
1804
- * @param type type of update the request will handle
1805
- * @returns IUpdate that has the request url and arguments
1806
- * @private
1807
- */
1808
- function _getUpdate(url, id, obj, args, type) {
1809
- const ops = {
1810
- delete: {
1811
- url: (0, generalHelpers_1.checkUrlPathTermination)(url) + id + "/deleteFromDefinition",
1812
- params: {
1813
- deleteFromDefinition: {
1814
- fields: obj && obj.hasOwnProperty("deleteFields") ? obj.deleteFields : [],
1815
- },
1816
- },
1817
- },
1818
- update: {
1819
- url: (0, generalHelpers_1.checkUrlPathTermination)(url) + (id ? `${id}/updateDefinition` : "updateDefinition"),
1820
- params: {
1821
- updateDefinition: obj,
1822
- },
1823
- },
1824
- add: {
1825
- url: (0, generalHelpers_1.checkUrlPathTermination)(url) + "addToDefinition",
1826
- params: {
1827
- addToDefinition: obj,
1828
- },
1829
- },
1830
- refresh: {
1831
- url: (0, generalHelpers_1.checkUrlPathTermination)(url) + "refresh",
1832
- params: {
1833
- f: "json",
1834
- },
1835
- },
1836
- };
1837
- return {
1838
- url: ops[type].url,
1839
- params: ops[type].params,
1840
- args: args,
1841
- };
1842
- }
1843
- exports._getUpdate = _getUpdate;
1844
- /**
1845
- * Changes just the domain part of a URL to lowercase.
1846
- *
1847
- * @param url URL to modify
1848
- * @return Adjusted URL
1849
- * @see From `getServerRootUrl` in arcgis-rest-js' ArcGISIdentityManager.ts
1850
- * @private
1851
- */
1852
- function _lowercaseDomain(url) {
1853
- if (!url) {
1854
- return url;
1855
- }
1856
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1857
- const [_, protocol, domainAndPath] = url.match(/(https?:\/\/)(.+)/);
1858
- const [domain, ...path] = domainAndPath.split("/");
1859
- // Only the domain is lowercased because in some cases an org id might be
1860
- // in the path which cannot be lowercased.
1861
- return `${protocol}${domain.toLowerCase()}/${path.join("/")}`;
1862
- }
1863
- exports._lowercaseDomain = _lowercaseDomain;
1864
- /**
1865
- * Checks the two main parts of an item for unresolved variables and reports any found.
1866
- *
1867
- * @param base Item's base section
1868
- * @param data Item's data section
1869
- * @private
1870
- */
1871
- function _reportVariablesInItem(itemId, itemType, base, data) {
1872
- const getUnresolved = (v) => {
1873
- return JSON.stringify(v).match(/{{.+?}}/gim);
1874
- };
1875
- // Provide feedback about any remaining unresolved variables
1876
- /* istanbul ignore else */
1877
- if (base && (0, templatization_1.hasUnresolvedVariables)(base)) {
1878
- console.log(itemId + " (" + itemType + ") contains variables in base: " + JSON.stringify(getUnresolved(base)));
1879
- }
1880
- /* istanbul ignore else */
1881
- if (data && (0, templatization_1.hasUnresolvedVariables)(data)) {
1882
- console.log(itemId + " (" + itemType + ") contains variables in data: " + JSON.stringify(getUnresolved(data)));
1883
- }
1884
- }
1885
- exports._reportVariablesInItem = _reportVariablesInItem;
1886
- /**
1887
- * Updates a feature service item.
1888
- *
1889
- * @param item Item to update
1890
- * @param itemTemplate item template for the new item
1891
- * @param serviceInfo Service information
1892
- * @param params arcgis-rest-js params to update
1893
- * @param isPortal Is the service hosted in a portal?
1894
- * @returns Updated item
1895
- * @private
1896
- */
1897
- function _setItemProperties(item, itemTemplate, serviceInfo, params, isPortal) {
1898
- // Set the capabilities
1899
- const portalCapabilities = ["Create", "Query", "Editing", "Update", "Delete", "Uploads", "Sync", "Extract"];
1900
- const capabilities = (0, generalHelpers_1.getProp)(serviceInfo, "service.capabilities") || (isPortal ? "" : []);
1901
- item.capabilities = isPortal
1902
- ? capabilities
1903
- .split(",")
1904
- .filter((c) => portalCapabilities.indexOf(c) > -1)
1905
- .join(",")
1906
- : capabilities;
1907
- if (serviceInfo.service.capabilities) {
1908
- serviceInfo.service.capabilities = item.capabilities;
1909
- }
1910
- // Handle index update for any pre-published solution items that
1911
- // have non-unique indexes on relationship key fields
1912
- _updateIndexesForRelationshipKeyFields(serviceInfo);
1913
- // set create options item properties
1914
- const keyProperties = [
1915
- "isView",
1916
- "sourceSchemaChangesAllowed",
1917
- "isUpdatableView",
1918
- "capabilities",
1919
- "isMultiServicesView",
1920
- ];
1921
- const deleteKeys = ["layers", "tables"];
1922
- /* istanbul ignore else */
1923
- if (isPortal) {
1924
- // removed for issue #423 causing FS to fail to create
1925
- deleteKeys.push("adminServiceInfo");
1926
- }
1927
- const itemKeys = Object.keys(item);
1928
- const serviceKeys = Object.keys(serviceInfo.service);
1929
- serviceKeys.forEach((k) => {
1930
- /* istanbul ignore else */
1931
- if (itemKeys.indexOf(k) === -1 && deleteKeys.indexOf(k) < 0) {
1932
- item[k] = serviceInfo.service[k];
1933
- // These need to be included via params otherwise...
1934
- // addToDef calls fail when adding adminLayerInfo
1935
- /* istanbul ignore else */
1936
- if (serviceInfo.service.isView && keyProperties.indexOf(k) > -1) {
1937
- params[k] = serviceInfo.service[k];
1938
- }
1939
- }
1940
- });
1941
- // Enable editor tracking on layer with related tables is not supported.
1942
- /* istanbul ignore else */
1943
- if (item.isMultiServicesView && (0, generalHelpers_1.getProp)(item, "editorTrackingInfo.enableEditorTracking")) {
1944
- item.editorTrackingInfo.enableEditorTracking = false;
1945
- params["editorTrackingInfo"] = item.editorTrackingInfo;
1946
- }
1947
- /* istanbul ignore else */
1948
- if (isPortal) {
1949
- // portal will fail when initialExtent is defined but null
1950
- // removed for issue #449 causing FS to fail to create on portal
1951
- /* istanbul ignore else */
1952
- if (Object.keys(item).indexOf("initialExtent") > -1 && !item.initialExtent) {
1953
- (0, generalHelpers_1.deleteProp)(item, "initialExtent");
1954
- }
1955
- }
1956
- return item;
1957
- }
1958
- exports._setItemProperties = _setItemProperties;
1959
- /**
1960
- * Set isUnique as true for indexes that reference origin relationship keyFields.
1961
- *
1962
- * @param serviceInfo Service information
1963
- * @private
1964
- */
1965
- function _updateIndexesForRelationshipKeyFields(serviceInfo) {
1966
- const layersAndTables = (serviceInfo.layers || []).concat(serviceInfo.tables || []);
1967
- layersAndTables.forEach((item) => {
1968
- const relationships = item.relationships;
1969
- const indexes = item.indexes;
1970
- /* istanbul ignore else */
1971
- if (relationships && relationships.length > 0 && indexes && indexes.length > 0) {
1972
- const keyFields = relationships.reduce((acc, v) => {
1973
- /* istanbul ignore else */
1974
- if (v.role === "esriRelRoleOrigin" && v.keyField && acc.indexOf(v.keyField) < 0) {
1975
- acc.push(v.keyField);
1976
- }
1977
- return acc;
1978
- }, []);
1979
- indexes.map((i) => {
1980
- /* istanbul ignore else */
1981
- if (keyFields.some((k) => {
1982
- const regEx = new RegExp(`\\b${k}\\b`);
1983
- return regEx.test(i.fields);
1984
- })) {
1985
- i.isUnique = true;
1986
- }
1987
- return i;
1988
- });
1989
- }
1990
- });
1991
- }
1992
- exports._updateIndexesForRelationshipKeyFields = _updateIndexesForRelationshipKeyFields;
1993
- /**
1994
- * Updates the URL of an item.
1995
- *
1996
- * @param id AGOL id of item to update
1997
- * @param url URL to assign to item's base section
1998
- * @param authentication Credentials for the request
1999
- * @param numAttempts Number of times to try to set the URL if AGO says that it updated the URL, but really didn't
2000
- * @returns A promise that will resolve with the item id when the item has been updated or an AGO-style JSON failure
2001
- * response
2002
- * @private
2003
- */
2004
- function _updateItemURL(id, url, authentication, numAttempts = 1) {
2005
- // Introduce a lag because AGO update appears to choke with rapid subsequent calls
2006
- const msLag = 1000;
2007
- return new Promise((resolve, reject) => {
2008
- // Update the item's URL
2009
- const options = { item: { id, url }, authentication: authentication };
2010
- (0, arcgisRestJS_1.restUpdateItem)(options).then((result) => {
2011
- if (!result.success) {
2012
- reject((0, generalHelpers_1.fail)(result));
2013
- }
2014
- else {
2015
- // Get the item to see if the URL really changed; we'll delay a bit before testing because AGO
2016
- // has a timing problem with URL updates
2017
- setTimeout(() => {
2018
- (0, arcgisRestJS_1.getItem)(id, { authentication: authentication }).then((item) => {
2019
- const iBrace = item.url.indexOf("{");
2020
- if (iBrace > -1) {
2021
- console.warn(id + " has template variable: " + item.url.substr(iBrace));
2022
- }
2023
- if (url === item.url) {
2024
- resolve(id);
2025
- }
2026
- else {
2027
- // If it fails, try again if we have sufficient attempts remaining
2028
- const errorMsg = "URL not updated for " + item.type + " " + item.id + ": " + item.url + " (" + numAttempts + ")";
2029
- if (--numAttempts > 0) {
2030
- _updateItemURL(id, url, authentication, numAttempts).then(resolve, reject);
2031
- }
2032
- else {
2033
- console.error(id + ": " + errorMsg + "; FAILED");
2034
- reject(errorMsg);
2035
- }
2036
- }
2037
- }, (e) => reject((0, generalHelpers_1.fail)(e)));
2038
- }, msLag);
2039
- }
2040
- }, (e) => reject((0, generalHelpers_1.fail)(e)));
2041
- });
2042
- }
2043
- exports._updateItemURL = _updateItemURL;
2044
- //# sourceMappingURL=restHelpers.js.map