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