@esri/solution-common 6.1.3 → 6.1.5

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/dist/cjs/arcgisRestJS.d.ts +63 -0
  2. package/dist/cjs/arcgisRestJS.js +158 -0
  3. package/dist/cjs/arcgisRestJS.js.map +1 -0
  4. package/dist/cjs/completeItem.d.ts +30 -0
  5. package/dist/cjs/completeItem.js +72 -0
  6. package/dist/cjs/completeItem.js.map +1 -0
  7. package/dist/cjs/create-hub-request-options.d.ts +29 -0
  8. package/dist/cjs/create-hub-request-options.js +64 -0
  9. package/dist/cjs/create-hub-request-options.js.map +1 -0
  10. package/dist/cjs/deleteHelpers/deleteEmptyGroups.d.ts +24 -0
  11. package/dist/cjs/deleteHelpers/deleteEmptyGroups.js +42 -0
  12. package/dist/cjs/deleteHelpers/deleteEmptyGroups.js.map +1 -0
  13. package/dist/cjs/deleteHelpers/deleteGroupIfEmpty.d.ts +27 -0
  14. package/dist/cjs/deleteHelpers/deleteGroupIfEmpty.js +99 -0
  15. package/dist/cjs/deleteHelpers/deleteGroupIfEmpty.js.map +1 -0
  16. package/dist/cjs/deleteHelpers/deleteSolutionContents.d.ts +39 -0
  17. package/dist/cjs/deleteHelpers/deleteSolutionContents.js +127 -0
  18. package/dist/cjs/deleteHelpers/deleteSolutionContents.js.map +1 -0
  19. package/dist/cjs/deleteHelpers/deleteSolutionFolder.d.ts +29 -0
  20. package/dist/cjs/deleteHelpers/deleteSolutionFolder.js +81 -0
  21. package/dist/cjs/deleteHelpers/deleteSolutionFolder.js.map +1 -0
  22. package/dist/cjs/deleteHelpers/deleteSolutionItem.d.ts +31 -0
  23. package/dist/cjs/deleteHelpers/deleteSolutionItem.js +52 -0
  24. package/dist/cjs/deleteHelpers/deleteSolutionItem.js.map +1 -0
  25. package/dist/cjs/deleteHelpers/index.d.ts +22 -0
  26. package/dist/cjs/deleteHelpers/index.js +26 -0
  27. package/dist/cjs/deleteHelpers/index.js.map +1 -0
  28. package/dist/cjs/deleteHelpers/reconstructBuildOrderIds.d.ts +27 -0
  29. package/dist/cjs/deleteHelpers/reconstructBuildOrderIds.js +34 -0
  30. package/dist/cjs/deleteHelpers/reconstructBuildOrderIds.js.map +1 -0
  31. package/dist/cjs/deleteHelpers/removeItems.d.ts +35 -0
  32. package/dist/cjs/deleteHelpers/removeItems.js +116 -0
  33. package/dist/cjs/deleteHelpers/removeItems.js.map +1 -0
  34. package/dist/cjs/deleteHelpers/reportProgress.d.ts +27 -0
  35. package/dist/cjs/deleteHelpers/reportProgress.js +46 -0
  36. package/dist/cjs/deleteHelpers/reportProgress.js.map +1 -0
  37. package/dist/cjs/deleteSolution.d.ts +56 -0
  38. package/dist/cjs/deleteSolution.js +107 -0
  39. package/dist/cjs/deleteSolution.js.map +1 -0
  40. package/dist/cjs/dependencies.d.ts +26 -0
  41. package/dist/cjs/dependencies.js +171 -0
  42. package/dist/cjs/dependencies.js.map +1 -0
  43. package/dist/cjs/featureServiceHelpers.d.ts +847 -0
  44. package/dist/cjs/featureServiceHelpers.js +2553 -0
  45. package/dist/cjs/featureServiceHelpers.js.map +1 -0
  46. package/dist/cjs/formHelpers.d.ts +26 -0
  47. package/dist/cjs/formHelpers.js +40 -0
  48. package/dist/cjs/formHelpers.js.map +1 -0
  49. package/dist/cjs/generalHelpers.d.ts +447 -0
  50. package/dist/cjs/generalHelpers.js +959 -0
  51. package/dist/cjs/generalHelpers.js.map +1 -0
  52. package/dist/cjs/get-subscription-info.d.ts +27 -0
  53. package/dist/cjs/get-subscription-info.js +38 -0
  54. package/dist/cjs/get-subscription-info.js.map +1 -0
  55. package/dist/cjs/getDeletableSolutionInfo.d.ts +30 -0
  56. package/dist/cjs/getDeletableSolutionInfo.js +53 -0
  57. package/dist/cjs/getDeletableSolutionInfo.js.map +1 -0
  58. package/dist/cjs/getItemTypeAbbrev.d.ts +19 -0
  59. package/dist/cjs/getItemTypeAbbrev.js +186 -0
  60. package/dist/cjs/getItemTypeAbbrev.js.map +1 -0
  61. package/dist/cjs/getSolutionSummary.d.ts +28 -0
  62. package/dist/cjs/getSolutionSummary.js +100 -0
  63. package/dist/cjs/getSolutionSummary.js.map +1 -0
  64. package/dist/cjs/index.d.ts +49 -0
  65. package/dist/cjs/index.js +53 -0
  66. package/dist/cjs/index.js.map +1 -0
  67. package/dist/cjs/interfaces.d.ts +1446 -0
  68. package/dist/cjs/interfaces.js +72 -0
  69. package/dist/cjs/interfaces.js.map +1 -0
  70. package/dist/cjs/item-reuse.d.ts +140 -0
  71. package/dist/cjs/item-reuse.js +176 -0
  72. package/dist/cjs/item-reuse.js.map +1 -0
  73. package/dist/cjs/libConnectors.d.ts +73 -0
  74. package/dist/cjs/libConnectors.js +115 -0
  75. package/dist/cjs/libConnectors.js.map +1 -0
  76. package/dist/cjs/migrations/apply-schema.d.ts +24 -0
  77. package/dist/cjs/migrations/apply-schema.js +36 -0
  78. package/dist/cjs/migrations/apply-schema.js.map +1 -0
  79. package/dist/cjs/migrations/is-legacy-solution.d.ts +24 -0
  80. package/dist/cjs/migrations/is-legacy-solution.js +39 -0
  81. package/dist/cjs/migrations/is-legacy-solution.js.map +1 -0
  82. package/dist/cjs/migrations/upgrade-three-dot-one.d.ts +26 -0
  83. package/dist/cjs/migrations/upgrade-three-dot-one.js +48 -0
  84. package/dist/cjs/migrations/upgrade-three-dot-one.js.map +1 -0
  85. package/dist/cjs/migrations/upgrade-three-dot-zero.d.ts +27 -0
  86. package/dist/cjs/migrations/upgrade-three-dot-zero.js +43 -0
  87. package/dist/cjs/migrations/upgrade-three-dot-zero.js.map +1 -0
  88. package/dist/cjs/migrations/upgrade-two-dot-five.d.ts +24 -0
  89. package/dist/cjs/migrations/upgrade-two-dot-five.js +73 -0
  90. package/dist/cjs/migrations/upgrade-two-dot-five.js.map +1 -0
  91. package/dist/cjs/migrations/upgrade-two-dot-four.d.ts +24 -0
  92. package/dist/cjs/migrations/upgrade-two-dot-four.js +72 -0
  93. package/dist/cjs/migrations/upgrade-two-dot-four.js.map +1 -0
  94. package/dist/cjs/migrations/upgrade-two-dot-one.d.ts +7 -0
  95. package/dist/cjs/migrations/upgrade-two-dot-one.js +39 -0
  96. package/dist/cjs/migrations/upgrade-two-dot-one.js.map +1 -0
  97. package/dist/cjs/migrations/upgrade-two-dot-seven.d.ts +23 -0
  98. package/dist/cjs/migrations/upgrade-two-dot-seven.js +58 -0
  99. package/dist/cjs/migrations/upgrade-two-dot-seven.js.map +1 -0
  100. package/dist/cjs/migrations/upgrade-two-dot-six.d.ts +27 -0
  101. package/dist/cjs/migrations/upgrade-two-dot-six.js +61 -0
  102. package/dist/cjs/migrations/upgrade-two-dot-six.js.map +1 -0
  103. package/dist/cjs/migrations/upgrade-two-dot-three.d.ts +23 -0
  104. package/dist/cjs/migrations/upgrade-two-dot-three.js +55 -0
  105. package/dist/cjs/migrations/upgrade-two-dot-three.js.map +1 -0
  106. package/dist/cjs/migrations/upgrade-two-dot-two.d.ts +23 -0
  107. package/dist/cjs/migrations/upgrade-two-dot-two.js +58 -0
  108. package/dist/cjs/migrations/upgrade-two-dot-two.js.map +1 -0
  109. package/dist/cjs/migrations/upgrade-two-dot-zero.d.ts +44 -0
  110. package/dist/cjs/migrations/upgrade-two-dot-zero.js +95 -0
  111. package/dist/cjs/migrations/upgrade-two-dot-zero.js.map +1 -0
  112. package/dist/cjs/migrator.d.ts +25 -0
  113. package/dist/cjs/migrator.js +75 -0
  114. package/dist/cjs/migrator.js.map +1 -0
  115. package/dist/cjs/resourceHelpers.d.ts +192 -0
  116. package/dist/cjs/resourceHelpers.js +380 -0
  117. package/dist/cjs/resourceHelpers.js.map +1 -0
  118. package/dist/cjs/resources/add-resource.d.ts +38 -0
  119. package/dist/cjs/resources/add-resource.js +84 -0
  120. package/dist/cjs/resources/add-resource.js.map +1 -0
  121. package/dist/cjs/resources/addMetadataFromBlob.d.ts +25 -0
  122. package/dist/cjs/resources/addMetadataFromBlob.js +43 -0
  123. package/dist/cjs/resources/addMetadataFromBlob.js.map +1 -0
  124. package/dist/cjs/resources/convert-item-resource-to-storage-resource.d.ts +32 -0
  125. package/dist/cjs/resources/convert-item-resource-to-storage-resource.js +70 -0
  126. package/dist/cjs/resources/convert-item-resource-to-storage-resource.js.map +1 -0
  127. package/dist/cjs/resources/convert-storage-resource-to-item-resource.d.ts +29 -0
  128. package/dist/cjs/resources/convert-storage-resource-to-item-resource.js +70 -0
  129. package/dist/cjs/resources/convert-storage-resource-to-item-resource.js.map +1 -0
  130. package/dist/cjs/resources/copyAssociatedFiles.d.ts +79 -0
  131. package/dist/cjs/resources/copyAssociatedFiles.js +348 -0
  132. package/dist/cjs/resources/copyAssociatedFiles.js.map +1 -0
  133. package/dist/cjs/resources/copyDataIntoItem.d.ts +34 -0
  134. package/dist/cjs/resources/copyDataIntoItem.js +45 -0
  135. package/dist/cjs/resources/copyDataIntoItem.js.map +1 -0
  136. package/dist/cjs/resources/copyMetadataIntoItem.d.ts +27 -0
  137. package/dist/cjs/resources/copyMetadataIntoItem.js +44 -0
  138. package/dist/cjs/resources/copyMetadataIntoItem.js.map +1 -0
  139. package/dist/cjs/resources/copyResourceIntoZip.d.ts +34 -0
  140. package/dist/cjs/resources/copyResourceIntoZip.js +74 -0
  141. package/dist/cjs/resources/copyResourceIntoZip.js.map +1 -0
  142. package/dist/cjs/resources/copyZipIntoItem.d.ts +26 -0
  143. package/dist/cjs/resources/copyZipIntoItem.js +53 -0
  144. package/dist/cjs/resources/copyZipIntoItem.js.map +1 -0
  145. package/dist/cjs/resources/createCopyResults.d.ts +25 -0
  146. package/dist/cjs/resources/createCopyResults.js +36 -0
  147. package/dist/cjs/resources/createCopyResults.js.map +1 -0
  148. package/dist/cjs/resources/get-blob.d.ts +25 -0
  149. package/dist/cjs/resources/get-blob.js +42 -0
  150. package/dist/cjs/resources/get-blob.js.map +1 -0
  151. package/dist/cjs/resources/getItemResourcesFilesFromPaths.d.ts +25 -0
  152. package/dist/cjs/resources/getItemResourcesFilesFromPaths.js +49 -0
  153. package/dist/cjs/resources/getItemResourcesFilesFromPaths.js.map +1 -0
  154. package/dist/cjs/resources/getItemResourcesPaths.d.ts +27 -0
  155. package/dist/cjs/resources/getItemResourcesPaths.js +80 -0
  156. package/dist/cjs/resources/getItemResourcesPaths.js.map +1 -0
  157. package/dist/cjs/resources/index.d.ts +30 -0
  158. package/dist/cjs/resources/index.js +34 -0
  159. package/dist/cjs/resources/index.js.map +1 -0
  160. package/dist/cjs/resources/solution-resource.d.ts +35 -0
  161. package/dist/cjs/resources/solution-resource.js +31 -0
  162. package/dist/cjs/resources/solution-resource.js.map +1 -0
  163. package/dist/cjs/resources/transform-resource-paths-to-solution-resources.d.ts +56 -0
  164. package/dist/cjs/resources/transform-resource-paths-to-solution-resources.js +140 -0
  165. package/dist/cjs/resources/transform-resource-paths-to-solution-resources.js.map +1 -0
  166. package/dist/cjs/resources/update-resource.d.ts +27 -0
  167. package/dist/cjs/resources/update-resource.js +52 -0
  168. package/dist/cjs/resources/update-resource.js.map +1 -0
  169. package/dist/cjs/restHelpers.d.ts +634 -0
  170. package/dist/cjs/restHelpers.js +2008 -0
  171. package/dist/cjs/restHelpers.js.map +1 -0
  172. package/dist/cjs/restHelpersGet.d.ts +303 -0
  173. package/dist/cjs/restHelpersGet.js +835 -0
  174. package/dist/cjs/restHelpersGet.js.map +1 -0
  175. package/dist/cjs/sharing/index.d.ts +16 -0
  176. package/dist/cjs/sharing/index.js +20 -0
  177. package/dist/cjs/sharing/index.js.map +1 -0
  178. package/dist/cjs/sharing/share-item-to-groups.d.ts +26 -0
  179. package/dist/cjs/sharing/share-item-to-groups.js +44 -0
  180. package/dist/cjs/sharing/share-item-to-groups.js.map +1 -0
  181. package/dist/cjs/templatization.d.ts +139 -0
  182. package/dist/cjs/templatization.js +311 -0
  183. package/dist/cjs/templatization.js.map +1 -0
  184. package/dist/cjs/trackingHelpers.d.ts +115 -0
  185. package/dist/cjs/trackingHelpers.js +212 -0
  186. package/dist/cjs/trackingHelpers.js.map +1 -0
  187. package/dist/cjs/velocityHelpers.d.ts +68 -0
  188. package/dist/cjs/velocityHelpers.js +151 -0
  189. package/dist/cjs/velocityHelpers.js.map +1 -0
  190. package/dist/cjs/webtoolHelpers.d.ts +57 -0
  191. package/dist/cjs/webtoolHelpers.js +102 -0
  192. package/dist/cjs/webtoolHelpers.js.map +1 -0
  193. package/dist/cjs/workflowHelpers.d.ts +112 -0
  194. package/dist/cjs/workflowHelpers.js +284 -0
  195. package/dist/cjs/workflowHelpers.js.map +1 -0
  196. package/dist/cjs/workforceHelpers.d.ts +121 -0
  197. package/dist/cjs/workforceHelpers.js +720 -0
  198. package/dist/cjs/workforceHelpers.js.map +1 -0
  199. package/dist/cjs/zip-utils.d.ts +85 -0
  200. package/dist/cjs/zip-utils.js +154 -0
  201. package/dist/cjs/zip-utils.js.map +1 -0
  202. package/dist/esm/arcgisRestJS.d.ts +63 -0
  203. package/dist/esm/arcgisRestJS.js +110 -0
  204. package/dist/esm/arcgisRestJS.js.map +1 -0
  205. package/dist/esm/completeItem.d.ts +30 -0
  206. package/dist/esm/completeItem.js +67 -0
  207. package/dist/esm/completeItem.js.map +1 -0
  208. package/dist/esm/create-hub-request-options.d.ts +29 -0
  209. package/dist/esm/create-hub-request-options.js +60 -0
  210. package/dist/esm/create-hub-request-options.js.map +1 -0
  211. package/dist/esm/deleteHelpers/deleteEmptyGroups.d.ts +24 -0
  212. package/dist/esm/deleteHelpers/deleteEmptyGroups.js +38 -0
  213. package/dist/esm/deleteHelpers/deleteEmptyGroups.js.map +1 -0
  214. package/dist/esm/deleteHelpers/deleteGroupIfEmpty.d.ts +27 -0
  215. package/dist/esm/deleteHelpers/deleteGroupIfEmpty.js +95 -0
  216. package/dist/esm/deleteHelpers/deleteGroupIfEmpty.js.map +1 -0
  217. package/dist/esm/deleteHelpers/deleteSolutionContents.d.ts +39 -0
  218. package/dist/esm/deleteHelpers/deleteSolutionContents.js +122 -0
  219. package/dist/esm/deleteHelpers/deleteSolutionContents.js.map +1 -0
  220. package/dist/esm/deleteHelpers/deleteSolutionFolder.d.ts +29 -0
  221. package/dist/esm/deleteHelpers/deleteSolutionFolder.js +77 -0
  222. package/dist/esm/deleteHelpers/deleteSolutionFolder.js.map +1 -0
  223. package/dist/esm/deleteHelpers/deleteSolutionItem.d.ts +31 -0
  224. package/dist/esm/deleteHelpers/deleteSolutionItem.js +48 -0
  225. package/dist/esm/deleteHelpers/deleteSolutionItem.js.map +1 -0
  226. package/dist/esm/deleteHelpers/index.d.ts +22 -0
  227. package/dist/esm/deleteHelpers/index.js +23 -0
  228. package/dist/esm/deleteHelpers/index.js.map +1 -0
  229. package/dist/esm/deleteHelpers/reconstructBuildOrderIds.d.ts +27 -0
  230. package/dist/esm/deleteHelpers/reconstructBuildOrderIds.js +29 -0
  231. package/dist/esm/deleteHelpers/reconstructBuildOrderIds.js.map +1 -0
  232. package/dist/esm/deleteHelpers/removeItems.d.ts +35 -0
  233. package/dist/esm/deleteHelpers/removeItems.js +111 -0
  234. package/dist/esm/deleteHelpers/removeItems.js.map +1 -0
  235. package/dist/esm/deleteHelpers/reportProgress.d.ts +27 -0
  236. package/dist/esm/deleteHelpers/reportProgress.js +42 -0
  237. package/dist/esm/deleteHelpers/reportProgress.js.map +1 -0
  238. package/dist/esm/deleteSolution.d.ts +56 -0
  239. package/dist/esm/deleteSolution.js +101 -0
  240. package/dist/esm/deleteSolution.js.map +1 -0
  241. package/dist/esm/dependencies.d.ts +26 -0
  242. package/dist/esm/dependencies.js +167 -0
  243. package/dist/esm/dependencies.js.map +1 -0
  244. package/dist/esm/featureServiceHelpers.d.ts +847 -0
  245. package/dist/esm/featureServiceHelpers.js +2466 -0
  246. package/dist/esm/featureServiceHelpers.js.map +1 -0
  247. package/dist/esm/formHelpers.d.ts +26 -0
  248. package/dist/esm/formHelpers.js +35 -0
  249. package/dist/esm/formHelpers.js.map +1 -0
  250. package/dist/esm/generalHelpers.d.ts +447 -0
  251. package/dist/esm/generalHelpers.js +903 -0
  252. package/dist/esm/generalHelpers.js.map +1 -0
  253. package/dist/esm/get-subscription-info.d.ts +27 -0
  254. package/dist/esm/get-subscription-info.js +34 -0
  255. package/dist/esm/get-subscription-info.js.map +1 -0
  256. package/dist/esm/getDeletableSolutionInfo.d.ts +30 -0
  257. package/dist/esm/getDeletableSolutionInfo.js +48 -0
  258. package/dist/esm/getDeletableSolutionInfo.js.map +1 -0
  259. package/dist/esm/getItemTypeAbbrev.d.ts +19 -0
  260. package/dist/esm/getItemTypeAbbrev.js +182 -0
  261. package/dist/esm/getItemTypeAbbrev.js.map +1 -0
  262. package/dist/esm/getSolutionSummary.d.ts +28 -0
  263. package/dist/esm/getSolutionSummary.js +95 -0
  264. package/dist/esm/getSolutionSummary.js.map +1 -0
  265. package/dist/esm/index.d.ts +49 -0
  266. package/dist/esm/index.js +50 -0
  267. package/dist/esm/index.js.map +1 -0
  268. package/dist/esm/interfaces.d.ts +1446 -0
  269. package/dist/esm/interfaces.js +69 -0
  270. package/dist/esm/interfaces.js.map +1 -0
  271. package/dist/esm/item-reuse.d.ts +140 -0
  272. package/dist/esm/item-reuse.js +167 -0
  273. package/dist/esm/item-reuse.js.map +1 -0
  274. package/dist/esm/libConnectors.d.ts +73 -0
  275. package/dist/esm/libConnectors.js +105 -0
  276. package/dist/esm/libConnectors.js.map +1 -0
  277. package/dist/esm/migrations/apply-schema.d.ts +24 -0
  278. package/dist/esm/migrations/apply-schema.js +32 -0
  279. package/dist/esm/migrations/apply-schema.js.map +1 -0
  280. package/dist/esm/migrations/is-legacy-solution.d.ts +24 -0
  281. package/dist/esm/migrations/is-legacy-solution.js +35 -0
  282. package/dist/esm/migrations/is-legacy-solution.js.map +1 -0
  283. package/dist/esm/migrations/upgrade-three-dot-one.d.ts +26 -0
  284. package/dist/esm/migrations/upgrade-three-dot-one.js +44 -0
  285. package/dist/esm/migrations/upgrade-three-dot-one.js.map +1 -0
  286. package/dist/esm/migrations/upgrade-three-dot-zero.d.ts +27 -0
  287. package/dist/esm/migrations/upgrade-three-dot-zero.js +39 -0
  288. package/dist/esm/migrations/upgrade-three-dot-zero.js.map +1 -0
  289. package/dist/esm/migrations/upgrade-two-dot-five.d.ts +24 -0
  290. package/dist/esm/migrations/upgrade-two-dot-five.js +69 -0
  291. package/dist/esm/migrations/upgrade-two-dot-five.js.map +1 -0
  292. package/dist/esm/migrations/upgrade-two-dot-four.d.ts +24 -0
  293. package/dist/esm/migrations/upgrade-two-dot-four.js +68 -0
  294. package/dist/esm/migrations/upgrade-two-dot-four.js.map +1 -0
  295. package/dist/esm/migrations/upgrade-two-dot-one.d.ts +7 -0
  296. package/dist/esm/migrations/upgrade-two-dot-one.js +35 -0
  297. package/dist/esm/migrations/upgrade-two-dot-one.js.map +1 -0
  298. package/dist/esm/migrations/upgrade-two-dot-seven.d.ts +23 -0
  299. package/dist/esm/migrations/upgrade-two-dot-seven.js +54 -0
  300. package/dist/esm/migrations/upgrade-two-dot-seven.js.map +1 -0
  301. package/dist/esm/migrations/upgrade-two-dot-six.d.ts +27 -0
  302. package/dist/esm/migrations/upgrade-two-dot-six.js +57 -0
  303. package/dist/esm/migrations/upgrade-two-dot-six.js.map +1 -0
  304. package/dist/esm/migrations/upgrade-two-dot-three.d.ts +23 -0
  305. package/dist/esm/migrations/upgrade-two-dot-three.js +51 -0
  306. package/dist/esm/migrations/upgrade-two-dot-three.js.map +1 -0
  307. package/dist/esm/migrations/upgrade-two-dot-two.d.ts +23 -0
  308. package/dist/esm/migrations/upgrade-two-dot-two.js +54 -0
  309. package/dist/esm/migrations/upgrade-two-dot-two.js.map +1 -0
  310. package/dist/esm/migrations/upgrade-two-dot-zero.d.ts +44 -0
  311. package/dist/esm/migrations/upgrade-two-dot-zero.js +88 -0
  312. package/dist/esm/migrations/upgrade-two-dot-zero.js.map +1 -0
  313. package/dist/esm/migrator.d.ts +25 -0
  314. package/dist/esm/migrator.js +71 -0
  315. package/dist/esm/migrator.js.map +1 -0
  316. package/dist/esm/resourceHelpers.d.ts +192 -0
  317. package/dist/esm/resourceHelpers.js +361 -0
  318. package/dist/esm/resourceHelpers.js.map +1 -0
  319. package/dist/esm/resources/add-resource.d.ts +38 -0
  320. package/dist/esm/resources/add-resource.js +79 -0
  321. package/dist/esm/resources/add-resource.js.map +1 -0
  322. package/dist/esm/resources/addMetadataFromBlob.d.ts +25 -0
  323. package/dist/esm/resources/addMetadataFromBlob.js +39 -0
  324. package/dist/esm/resources/addMetadataFromBlob.js.map +1 -0
  325. package/dist/esm/resources/convert-item-resource-to-storage-resource.d.ts +32 -0
  326. package/dist/esm/resources/convert-item-resource-to-storage-resource.js +66 -0
  327. package/dist/esm/resources/convert-item-resource-to-storage-resource.js.map +1 -0
  328. package/dist/esm/resources/convert-storage-resource-to-item-resource.d.ts +29 -0
  329. package/dist/esm/resources/convert-storage-resource-to-item-resource.js +66 -0
  330. package/dist/esm/resources/convert-storage-resource-to-item-resource.js.map +1 -0
  331. package/dist/esm/resources/copyAssociatedFiles.d.ts +79 -0
  332. package/dist/esm/resources/copyAssociatedFiles.js +339 -0
  333. package/dist/esm/resources/copyAssociatedFiles.js.map +1 -0
  334. package/dist/esm/resources/copyDataIntoItem.d.ts +34 -0
  335. package/dist/esm/resources/copyDataIntoItem.js +40 -0
  336. package/dist/esm/resources/copyDataIntoItem.js.map +1 -0
  337. package/dist/esm/resources/copyMetadataIntoItem.d.ts +27 -0
  338. package/dist/esm/resources/copyMetadataIntoItem.js +40 -0
  339. package/dist/esm/resources/copyMetadataIntoItem.js.map +1 -0
  340. package/dist/esm/resources/copyResourceIntoZip.d.ts +34 -0
  341. package/dist/esm/resources/copyResourceIntoZip.js +69 -0
  342. package/dist/esm/resources/copyResourceIntoZip.js.map +1 -0
  343. package/dist/esm/resources/copyZipIntoItem.d.ts +26 -0
  344. package/dist/esm/resources/copyZipIntoItem.js +49 -0
  345. package/dist/esm/resources/copyZipIntoItem.js.map +1 -0
  346. package/dist/esm/resources/createCopyResults.d.ts +25 -0
  347. package/dist/esm/resources/createCopyResults.js +32 -0
  348. package/dist/esm/resources/createCopyResults.js.map +1 -0
  349. package/dist/esm/resources/get-blob.d.ts +25 -0
  350. package/dist/esm/resources/get-blob.js +38 -0
  351. package/dist/esm/resources/get-blob.js.map +1 -0
  352. package/dist/esm/resources/getItemResourcesFilesFromPaths.d.ts +25 -0
  353. package/dist/esm/resources/getItemResourcesFilesFromPaths.js +45 -0
  354. package/dist/esm/resources/getItemResourcesFilesFromPaths.js.map +1 -0
  355. package/dist/esm/resources/getItemResourcesPaths.d.ts +27 -0
  356. package/dist/esm/resources/getItemResourcesPaths.js +76 -0
  357. package/dist/esm/resources/getItemResourcesPaths.js.map +1 -0
  358. package/dist/esm/resources/index.d.ts +30 -0
  359. package/dist/esm/resources/index.js +31 -0
  360. package/dist/esm/resources/index.js.map +1 -0
  361. package/dist/esm/resources/solution-resource.d.ts +35 -0
  362. package/dist/esm/resources/solution-resource.js +28 -0
  363. package/dist/esm/resources/solution-resource.js.map +1 -0
  364. package/dist/esm/resources/transform-resource-paths-to-solution-resources.d.ts +56 -0
  365. package/dist/esm/resources/transform-resource-paths-to-solution-resources.js +132 -0
  366. package/dist/esm/resources/transform-resource-paths-to-solution-resources.js.map +1 -0
  367. package/dist/esm/resources/update-resource.d.ts +27 -0
  368. package/dist/esm/resources/update-resource.js +48 -0
  369. package/dist/esm/resources/update-resource.js.map +1 -0
  370. package/dist/esm/restHelpers.d.ts +634 -0
  371. package/dist/esm/restHelpers.js +1943 -0
  372. package/dist/esm/restHelpers.js.map +1 -0
  373. package/dist/esm/restHelpersGet.d.ts +303 -0
  374. package/dist/esm/restHelpersGet.js +793 -0
  375. package/dist/esm/restHelpersGet.js.map +1 -0
  376. package/dist/esm/sharing/index.d.ts +16 -0
  377. package/dist/esm/sharing/index.js +17 -0
  378. package/dist/esm/sharing/index.js.map +1 -0
  379. package/dist/esm/sharing/share-item-to-groups.d.ts +26 -0
  380. package/dist/esm/sharing/share-item-to-groups.js +40 -0
  381. package/dist/esm/sharing/share-item-to-groups.js.map +1 -0
  382. package/dist/esm/templatization.d.ts +139 -0
  383. package/dist/esm/templatization.js +291 -0
  384. package/dist/esm/templatization.js.map +1 -0
  385. package/dist/esm/trackingHelpers.d.ts +115 -0
  386. package/dist/esm/trackingHelpers.js +200 -0
  387. package/dist/esm/trackingHelpers.js.map +1 -0
  388. package/dist/esm/velocityHelpers.d.ts +68 -0
  389. package/dist/esm/velocityHelpers.js +144 -0
  390. package/dist/esm/velocityHelpers.js.map +1 -0
  391. package/dist/esm/webtoolHelpers.d.ts +57 -0
  392. package/dist/esm/webtoolHelpers.js +95 -0
  393. package/dist/esm/webtoolHelpers.js.map +1 -0
  394. package/dist/esm/workflowHelpers.d.ts +112 -0
  395. package/dist/esm/workflowHelpers.js +270 -0
  396. package/dist/esm/workflowHelpers.js.map +1 -0
  397. package/dist/esm/workforceHelpers.d.ts +121 -0
  398. package/dist/esm/workforceHelpers.js +691 -0
  399. package/dist/esm/workforceHelpers.js.map +1 -0
  400. package/dist/esm/zip-utils.d.ts +85 -0
  401. package/dist/esm/zip-utils.js +142 -0
  402. package/dist/esm/zip-utils.js.map +1 -0
  403. package/dist/solution.js_commit.txt +7 -0
  404. package/package.json +2 -2
@@ -0,0 +1,793 @@
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 item fetch functions involving the arcgis-rest-js library.
18
+ *
19
+ * @module restHelpersGet
20
+ */
21
+ import { blobToFile, blobToJson, blobToText, checkUrlPathTermination, getProp } from "./generalHelpers";
22
+ import { getGroup, getGroupContent, getItem, getRelatedItems, request, restGetGroupCategorySchema as portalGetGroupCategorySchema, restGetItemResources as portalGetItemResources, restGetPortal as portalGetPortal, } from "./arcgisRestJS";
23
+ import { getBlob } from "./resources/get-blob";
24
+ import { searchGroups, searchGroupContents } from "./restHelpers";
25
+ // ------------------------------------------------------------------------------------------------------------------ //
26
+ const ZIP_FILE_HEADER_SIGNATURE = "PK";
27
+ export function checkJsonForError(json) {
28
+ return typeof json?.error !== "undefined";
29
+ }
30
+ export function getPortal(id, authentication) {
31
+ const requestOptions = {
32
+ authentication: authentication,
33
+ };
34
+ return portalGetPortal(id, requestOptions);
35
+ }
36
+ /**
37
+ * Get the urls available on the portal self.
38
+ *
39
+ * @param authentication Credentials for the request to AGO
40
+ * @returns List of http and https helper urls
41
+ */
42
+ export function getPortalUrls(authentication) {
43
+ return new Promise((resolve) => {
44
+ const requestOptions = {
45
+ httpMethod: "GET",
46
+ authentication: authentication,
47
+ rawResponse: false,
48
+ };
49
+ const url = `${authentication.portal}/portals/self/urls`;
50
+ request(url, requestOptions).then((response) => {
51
+ resolve(response);
52
+ }, () => resolve({}));
53
+ });
54
+ }
55
+ export function getUser(authentication) {
56
+ return authentication.getUser();
57
+ }
58
+ export function getUsername(authentication) {
59
+ return new Promise((resolve, reject) => {
60
+ getUser(authentication).then((user) => resolve(user.username), reject);
61
+ });
62
+ }
63
+ export function getFoldersAndGroups(authentication) {
64
+ return new Promise((resolve, reject) => {
65
+ const requestOptions = {
66
+ httpMethod: "GET",
67
+ authentication: authentication,
68
+ rawResponse: false,
69
+ };
70
+ // Folders
71
+ const foldersUrl = `${authentication.portal}/content/users/${encodeURIComponent(authentication.username)}`;
72
+ // Groups
73
+ const groupsUrl = `${authentication.portal}/community/users/${encodeURIComponent(authentication.username)}`;
74
+ Promise.all([request(foldersUrl, requestOptions), request(groupsUrl, requestOptions)]).then((responses) => {
75
+ resolve({
76
+ folders: responses[0].folders || [],
77
+ groups: responses[1].groups || [],
78
+ });
79
+ }, (e) => reject(e));
80
+ });
81
+ }
82
+ /**
83
+ * Gets a Blob from a web site and casts it as a file using the supplied name.
84
+ *
85
+ * @param url Address of Blob
86
+ * @param filename Name to use for file
87
+ * @param authentication Credentials for the request
88
+ * @returns Promise that will resolve with a File, undefined if the Blob is null, or an AGO-style JSON failure response
89
+ */
90
+ export function getBlobAsFile(url, filename, authentication, ignoreErrors = [], mimeType) {
91
+ return new Promise((resolve, reject) => {
92
+ // Get the blob from the URL
93
+ getBlobCheckForError(url, authentication, ignoreErrors).then((blob) => (!blob ? resolve(null) : resolve(blobToFile(blob, filename, mimeType))), reject);
94
+ });
95
+ }
96
+ /**
97
+ * Gets a Blob from a web site and checks for a JSON error packet in the Blob.
98
+ *
99
+ * @param url Address of Blob
100
+ * @param authentication Credentials for the request
101
+ * @param ignoreErrors List of HTTP error codes that should be ignored
102
+ * @returns Promise that will resolve with Blob or an AGO-REST JSON failure response
103
+ */
104
+ export function getBlobCheckForError(url, authentication, ignoreErrors = []) {
105
+ return new Promise((resolve, reject) => {
106
+ // Get the blob from the URL
107
+ getBlob(url, authentication).then((blob) => {
108
+ // Reclassify text/plain blobs as needed
109
+ _fixTextBlobType(blob).then((adjustedBlob) => {
110
+ if (adjustedBlob.type === "application/json") {
111
+ // Blob may be an error
112
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
113
+ blobToJson(adjustedBlob).then((json) => {
114
+ // Check for valid JSON with an error
115
+ if (json?.error) {
116
+ const code = json.error.code;
117
+ if (code !== undefined && ignoreErrors.indexOf(code) >= 0) {
118
+ resolve(null); // Error, but ignored
119
+ }
120
+ else {
121
+ reject(json); // Other error; fail with error
122
+ }
123
+ }
124
+ else {
125
+ resolve(adjustedBlob);
126
+ }
127
+ });
128
+ }
129
+ else {
130
+ resolve(adjustedBlob);
131
+ }
132
+ }, reject);
133
+ }, reject);
134
+ });
135
+ }
136
+ /**
137
+ * Get the servers available on the Enterprise portal.
138
+ *
139
+ * @param portalRestUrl URL of the portal REST endpoint, e.g., "https://gisserver.domain.com/server/rest/services"
140
+ * @param authentication Credentials for the request to AGO
141
+ * @returns List of servers available on the portal
142
+ */
143
+ export async function getEnterpriseServers(portalRestUrl, authentication) {
144
+ // Get the servers
145
+ const getServersURL = `${portalRestUrl}/portals/self/servers`;
146
+ const serversJSON = await request(getServersURL, {
147
+ authentication,
148
+ httpMethod: "GET",
149
+ params: {
150
+ f: "json",
151
+ },
152
+ });
153
+ return serversJSON.servers;
154
+ }
155
+ /**
156
+ * Extracts the text in a url between the last forward slash and the beginning of the url's parameters.
157
+ *
158
+ * @param url URL to work with
159
+ * @returns Text extracted; empty if url ends with a forward slash or has a "?" immediately after the last
160
+ * forward slash
161
+ */
162
+ export function getFilenameFromUrl(url) {
163
+ if (!url) {
164
+ return "";
165
+ }
166
+ let iParamsStart = url.indexOf("?");
167
+ /* istanbul ignore else */
168
+ if (iParamsStart < 0) {
169
+ iParamsStart = url.length;
170
+ }
171
+ const iFilenameStart = url.lastIndexOf("/", iParamsStart) + 1;
172
+ return iFilenameStart < iParamsStart ? url.substring(iFilenameStart, iParamsStart) : "";
173
+ }
174
+ /**
175
+ * Gets the primary information of an AGO group.
176
+ *
177
+ * @param groupId Id of an group whose primary information is sought
178
+ * @param authentication Credentials for the request to AGO
179
+ * @returns A promise that will resolve with group's JSON or error JSON or throws ArcGISRequestError in case of HTTP error
180
+ * or response error code
181
+ */
182
+ export function getGroupBase(groupId, authentication) {
183
+ const requestOptions = {
184
+ authentication: authentication,
185
+ };
186
+ return getGroup(groupId, requestOptions);
187
+ }
188
+ /**
189
+ * Gets the category schema set on a group.
190
+ *
191
+ * @param groupId Id of an group whose category schema information is sought
192
+ * @param authentication Credentials for the request to AGO
193
+ * @returns A promise that will resolve with JSON of group's category schema
194
+ * @see https://developers.arcgis.com/rest/users-groups-and-items/group-category-schema.htm
195
+ */
196
+ export function getGroupCategorySchema(groupId, authentication) {
197
+ const requestOptions = {
198
+ authentication: authentication,
199
+ };
200
+ return portalGetGroupCategorySchema(groupId, requestOptions);
201
+ }
202
+ /**
203
+ * Gets the ids of the dependencies (contents) of an AGO group.
204
+ *
205
+ * @param groupId Id of a group whose contents are sought
206
+ * @param authentication Credentials for the request to AGO
207
+ * @returns A promise that will resolve with list of dependent ids or an empty list
208
+ */
209
+ export function getGroupContents(groupId, authentication) {
210
+ return new Promise((resolve, reject) => {
211
+ const pagingParams = {
212
+ start: 1,
213
+ num: 100, // max allowed by REST API
214
+ };
215
+ // Fetch group items
216
+ _getGroupContentsTranche(groupId, pagingParams, authentication).then((contents) => {
217
+ resolve(contents);
218
+ }, reject);
219
+ });
220
+ }
221
+ /**
222
+ * Gets the primary information of an AGO item.
223
+ *
224
+ * @param itemId Id of an item whose primary information is sought
225
+ * @param authentication Credentials for the request to AGO
226
+ * @returns A promise that will resolve with item's JSON or error JSON or throws ArcGISRequestError in case of HTTP error
227
+ * or response error code
228
+ */
229
+ export function getItemBase(itemId, authentication) {
230
+ const itemParam = {
231
+ authentication: authentication,
232
+ };
233
+ return getItem(itemId, itemParam);
234
+ }
235
+ /**
236
+ * Gets the data information of an AGO item in its raw (Blob) form and casts it as a file using the supplied name.
237
+ *
238
+ * @param itemId Id of an item whose data information is sought
239
+ * @param filename Name to use for file
240
+ * @param authentication Credentials for the request to AGO
241
+ * @returns Promise that will resolve with a File, undefined if the Blob is null, or an AGO-style JSON failure response
242
+ */
243
+ export function getItemDataAsFile(itemId, filename, authentication) {
244
+ return new Promise((resolve) => {
245
+ getItemDataBlob(itemId, authentication).then((blob) => resolve(blobToFile(blob, filename)), () => resolve(null));
246
+ });
247
+ }
248
+ /**
249
+ * Gets the data information of an AGO item in its JSON form.
250
+ *
251
+ * @param itemId Id of an item whose data information is sought
252
+ * @param filename Name to use for file
253
+ * @param authentication Credentials for the request to AGO
254
+ * @returns Promise that will resolve with JSON, or an AGO-style JSON failure response
255
+ */
256
+ export function getItemDataAsJson(itemId, authentication) {
257
+ return new Promise((resolve) => {
258
+ getItemDataBlob(itemId, authentication).then((blob) => resolve(blobToJson(blob)), () => resolve(null));
259
+ });
260
+ }
261
+ /**
262
+ * Gets the data information of an AGO item in its raw (Blob) form.
263
+ *
264
+ * @param itemId Id of an item whose data information is sought
265
+ * @param authentication Credentials for the request to AGO
266
+ * @returns A promise that will resolve with the data Blob or null if the item doesn't have a data section
267
+ */
268
+ export function getItemDataBlob(itemId, authentication) {
269
+ return new Promise((resolve) => {
270
+ const url = getItemDataBlobUrl(itemId, authentication);
271
+ getBlobCheckForError(url, authentication, [400, 500]).then((blob) => resolve(_fixTextBlobType(blob)), () => resolve(null));
272
+ });
273
+ }
274
+ /**
275
+ * Gets the URL to the data information of an AGO item in its raw (Blob) form.
276
+ *
277
+ * @param itemId Id of an item whose data information is sought
278
+ * @param authentication Credentials for the request to AGO
279
+ * @returns URL string
280
+ */
281
+ export function getItemDataBlobUrl(itemId, authentication) {
282
+ return `${getPortalSharingUrlFromAuth(authentication)}/content/items/${itemId}/data`;
283
+ }
284
+ /**
285
+ * Gets the URL to an information item in an AGO item.
286
+ *
287
+ * @param itemId Id of an item whose data information is sought
288
+ * @param authentication Credentials for the request to AGO
289
+ * @returns URL string
290
+ */
291
+ export function getItemInfoFileUrlPrefix(itemId, authentication) {
292
+ return `${getPortalSharingUrlFromAuth(authentication)}/content/items/${itemId}/info/`;
293
+ }
294
+ /**
295
+ * Gets the metadata information of an AGO item.
296
+ *
297
+ * @param itemId Id of an item whose data information is sought
298
+ * @param authentication Credentials for the request to AGO
299
+ * @returns Promise that will resolve with `undefined` or a File containing the metadata
300
+ */
301
+ export function getItemMetadataAsFile(itemId, authentication) {
302
+ return new Promise((resolve) => {
303
+ getItemMetadataBlob(itemId, authentication).then((blob) => {
304
+ if (!blob || (blob && blob.type.startsWith("application/json"))) {
305
+ resolve(null); // JSON error
306
+ }
307
+ else {
308
+ resolve(blobToFile(blob, "metadata.xml"));
309
+ }
310
+ }, () => resolve(null));
311
+ });
312
+ }
313
+ /**
314
+ * Gets the metadata information of an AGO item.
315
+ *
316
+ * @param itemId Id of an item whose data information is sought
317
+ * @param authentication Credentials for the request to AGO
318
+ * @returns A promise that will resolve with the metadata Blob or null if the item doesn't have a metadata file
319
+ */
320
+ export function getItemMetadataBlob(itemId, authentication) {
321
+ return new Promise((resolve, reject) => {
322
+ const url = getItemMetadataBlobUrl(itemId, authentication);
323
+ getBlobCheckForError(url, authentication, [400]).then(resolve, reject);
324
+ });
325
+ }
326
+ /**
327
+ * Gets the URL to the metadata information of an AGO item.
328
+ *
329
+ * @param itemId Id of an item whose data information is sought
330
+ * @param authentication Credentials for the request to AGO
331
+ * @returns URL string
332
+ */
333
+ export function getItemMetadataBlobUrl(itemId, authentication) {
334
+ return getItemInfoFileUrlPrefix(itemId, authentication) + "metadata/metadata.xml";
335
+ }
336
+ /**
337
+ * Gets the related items of an AGO item.
338
+ *
339
+ * @param itemId Id of an item whose related items are sought
340
+ * @param relationshipType Tag for relationship type, e.g., "Solution2Item"
341
+ * @param direction Relationship direction
342
+ * @param authentication Credentials for the request to AGO
343
+ * @param num Number of related items to request per batch; maximum is 100
344
+ * @returns A promise that will resolve with the list of related items
345
+ */
346
+ export function getItemRelatedItems(itemId, relationshipType, direction, authentication, num = 100) {
347
+ return new Promise((resolve) => {
348
+ const itemRelatedItemsParam = {
349
+ id: itemId,
350
+ relationshipType,
351
+ authentication: authentication,
352
+ params: {
353
+ direction,
354
+ start: 1,
355
+ num,
356
+ },
357
+ };
358
+ // Fetch related items
359
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
360
+ _getItemRelatedItemsTranche(itemRelatedItemsParam).then((response) => {
361
+ resolve(response);
362
+ });
363
+ });
364
+ }
365
+ /**
366
+ * Gets all of the related items of an AGO item in the specified direction.
367
+ *
368
+ * @param itemId Id of an item whose related items are sought
369
+ * @param direction
370
+ * @param authentication Credentials for the request to AGO
371
+ * @returns A promise that will resolve with a list of IRelatedItems
372
+ */
373
+ export function getItemRelatedItemsInSameDirection(itemId, direction, authentication) {
374
+ return new Promise((resolve) => {
375
+ const relationshipTypes = [
376
+ // from ItemRelationshipType
377
+ "APIKey2Item",
378
+ "Area2CustomPackage",
379
+ "Area2Package",
380
+ "Item2Attachment",
381
+ "Item2Report",
382
+ "Listed2Provisioned",
383
+ "Map2AppConfig",
384
+ "Map2Area",
385
+ "Map2FeatureCollection",
386
+ "Map2Service",
387
+ "MobileApp2Code",
388
+ "Service2Data",
389
+ "Service2Layer",
390
+ "Service2Route",
391
+ "Service2Service",
392
+ "Service2Style",
393
+ "Solution2Item",
394
+ "Style2Style",
395
+ "Survey2Data",
396
+ "Survey2Service",
397
+ "SurveyAddIn2Data",
398
+ "Theme2Story",
399
+ "TrackView2Map",
400
+ "WebStyle2DesktopStyle",
401
+ "WMA2Code",
402
+ "WorkforceMap2FeatureService",
403
+ ];
404
+ const relatedItemDefs = relationshipTypes.map((relationshipType) => getItemRelatedItems(itemId, relationshipType, direction, authentication));
405
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
406
+ Promise.all(relatedItemDefs).then((relationshipResponses) => {
407
+ const relatedItems = [];
408
+ for (let i = 0; i < relationshipTypes.length; ++i) {
409
+ if (relationshipResponses[i].total > 0) {
410
+ relatedItems.push({
411
+ relationshipType: relationshipTypes[i],
412
+ relatedItemIds: relationshipResponses[i].relatedItems.map((item) => item.id),
413
+ });
414
+ }
415
+ }
416
+ resolve(relatedItems);
417
+ });
418
+ });
419
+ }
420
+ export function getItemResources(id, authentication) {
421
+ return new Promise((resolve) => {
422
+ const requestOptions = {
423
+ authentication: authentication,
424
+ };
425
+ portalGetItemResources(id, requestOptions).then(resolve, () => {
426
+ resolve({
427
+ total: 0,
428
+ start: 1,
429
+ num: 0,
430
+ nextStart: -1,
431
+ resources: [],
432
+ });
433
+ });
434
+ });
435
+ }
436
+ /**
437
+ * Gets the resources of an AGO item.
438
+ *
439
+ * @param itemId Id of an item whose resources are sought
440
+ * @param authentication Credentials for the request to AGO
441
+ * @returns Promise that will resolve with a list of Files or an AGO-style JSON failure response
442
+ */
443
+ export function getItemResourcesFiles(itemId, authentication) {
444
+ return new Promise((resolve, reject) => {
445
+ const pagingParams = {
446
+ start: 1,
447
+ num: 100, // max allowed by REST API
448
+ };
449
+ // Fetch resources
450
+ _getItemResourcesTranche(itemId, pagingParams, authentication).then((itemResourcesDef) => {
451
+ Promise.all(itemResourcesDef).then(resolve, reject);
452
+ }, reject);
453
+ });
454
+ }
455
+ /**
456
+ * Gets all of the items associated with a Solution via a Solution2Item relationship.
457
+ *
458
+ * @param solutionItemId Id of a deployed Solution
459
+ * @param authentication Credentials for the request
460
+ * @returns Promise resolving to a list of detailed item information
461
+ */
462
+ export function getItemsRelatedToASolution(solutionItemId, authentication) {
463
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
464
+ return getItemRelatedItems(solutionItemId, "Solution2Item", "forward", authentication).then((relationshipResponse) => {
465
+ return relationshipResponse.relatedItems;
466
+ });
467
+ }
468
+ /**
469
+ * Gets the thumbnail of an AGO item.
470
+ *
471
+ * @param itemId Id of an item whose resources are sought
472
+ * @param thumbnailUrlPart The partial name of the item's thumbnail as reported by the `thumbnail` property
473
+ * in the item's base section
474
+ * @param isGroup Switch indicating if the item is a group
475
+ * @param authentication Credentials for the request to AGO
476
+ * @returns Promise that will resolve with an image Blob or an AGO-style JSON failure response
477
+ */
478
+ export function getItemThumbnail(itemId, thumbnailUrlPart, isGroup, authentication) {
479
+ return new Promise((resolve, reject) => {
480
+ if (!thumbnailUrlPart) {
481
+ resolve(null);
482
+ return;
483
+ }
484
+ const url = getItemThumbnailUrl(itemId, thumbnailUrlPart, isGroup, authentication);
485
+ getBlobCheckForError(url, authentication, [500]).then((blob) => resolve(_fixTextBlobType(blob)), reject);
486
+ });
487
+ }
488
+ /**
489
+ * Gets the thumbnail of an AGO item.
490
+ *
491
+ * @param itemId Id of an item whose resources are sought
492
+ * @param thumbnailUrlPart The partial name of the item's thumbnail as reported by the `thumbnail` property
493
+ * in the item's base section
494
+ * @param isGroup Switch indicating if the item is a group
495
+ * @param authentication Credentials for the request to AGO
496
+ * @returns Promise that will resolve with an image Blob or an AGO-style JSON failure response
497
+ */
498
+ export function getItemThumbnailAsFile(itemId, thumbnailUrlPart, isGroup, authentication) {
499
+ return new Promise((resolve, reject) => {
500
+ /* istanbul ignore else */
501
+ if (!thumbnailUrlPart) {
502
+ resolve(null);
503
+ return;
504
+ }
505
+ const url = getItemThumbnailUrl(itemId, thumbnailUrlPart, isGroup, authentication);
506
+ const iFilenameStart = thumbnailUrlPart.lastIndexOf("/") + 1;
507
+ const filename = thumbnailUrlPart.substring(iFilenameStart);
508
+ getBlobAsFile(url, filename, authentication, [400, 500]).then(resolve, reject);
509
+ });
510
+ }
511
+ /**
512
+ * Gets the URL to the thumbnail of an AGO item.
513
+ *
514
+ * @param itemId Id of an item whose resources are sought
515
+ * @param thumbnailUrlPart The partial name of the item's thumbnail as reported by the `thumbnail` property
516
+ * in the item's base section
517
+ * @param isGroup Switch indicating if the item is a group
518
+ * @param authentication Credentials for the request to AGO
519
+ * @returns URL string
520
+ */
521
+ export function getItemThumbnailUrl(itemId, thumbnailUrlPart, isGroup, authentication) {
522
+ return (checkUrlPathTermination(getPortalSharingUrlFromAuth(authentication)) +
523
+ (isGroup ? "community/groups/" : "content/items/") +
524
+ itemId +
525
+ "/info/" +
526
+ thumbnailUrlPart);
527
+ }
528
+ /**
529
+ * Gets a JSON from a web site.
530
+ *
531
+ * @param url Address of JSON
532
+ * @param authentication Credentials for the request
533
+ * @returns Promise that will resolve with JSON
534
+ */
535
+ export function getJson(url, authentication) {
536
+ // Get the blob from the URL
537
+ const requestOptions = { httpMethod: "GET" };
538
+ return getBlob(url, authentication, requestOptions)
539
+ .then((blob) => {
540
+ // Reclassify text/plain blobs as needed
541
+ return _fixTextBlobType(blob);
542
+ })
543
+ .then((adjustedBlob) => {
544
+ if (adjustedBlob.type === "application/json") {
545
+ // Blob may be an error
546
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
547
+ return blobToJson(adjustedBlob);
548
+ }
549
+ else {
550
+ return Promise.resolve(null);
551
+ }
552
+ });
553
+ }
554
+ /**
555
+ * Extracts the portal sharing url from a supplied authentication.
556
+ *
557
+ * @param authentication Credentials for the request to AGO
558
+ * @returns Portal sharing url to be used in API requests, defaulting to `https://www.arcgis.com/sharing/rest`
559
+ */
560
+ export function getPortalSharingUrlFromAuth(authentication) {
561
+ // If auth was passed, use that portal
562
+ return getProp(authentication, "portal") || "https://www.arcgis.com/sharing/rest";
563
+ }
564
+ /**
565
+ * Extracts the portal url from a supplied authentication.
566
+ *
567
+ * @param authentication Credentials for the request to AGO
568
+ * @returns Portal url to be used in API requests, defaulting to `https://www.arcgis.com`
569
+ */
570
+ export function getPortalUrlFromAuth(authentication) {
571
+ return getPortalSharingUrlFromAuth(authentication).replace("/sharing/rest", "");
572
+ }
573
+ /**
574
+ * Gets the ids of all Solution items associated with an AGO item via a Solution2Item relationship.
575
+ *
576
+ * @param itemId Id of an AGO item to query
577
+ * @param authentication Credentials for the request
578
+ * @returns Promise resolving to a list of Solution item ids
579
+ */
580
+ export function getSolutionsRelatedToAnItem(itemId, authentication) {
581
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
582
+ return getItemRelatedItems(itemId, "Solution2Item", "reverse", authentication).then((relationshipResponse) => {
583
+ return relationshipResponse.relatedItems.map((item) => item.id);
584
+ });
585
+ }
586
+ export function getThumbnailFile(url, filename, authentication) {
587
+ return new Promise((resolve) => {
588
+ getBlobAsFile(url, filename, authentication, [500]).then(resolve, () => resolve(null));
589
+ });
590
+ }
591
+ // ------------------------------------------------------------------------------------------------------------------ //
592
+ /**
593
+ * Fixes the types of Blobs incorrectly typed as text/plain.
594
+ *
595
+ * @param blob Blob to check
596
+ * @returns Promise resolving to original Blob, unless it's originally typed as text/plain but is
597
+ * really JSON, ZIP, or XML
598
+ * @private
599
+ */
600
+ export function _fixTextBlobType(blob) {
601
+ return new Promise((resolve, reject) => {
602
+ if (blob && blob.size > 0 && (blob.type.startsWith("text/plain") || blob.type.startsWith("application/json"))) {
603
+ blobToText(blob).then((blobText) => {
604
+ // Convertible to JSON?
605
+ try {
606
+ JSON.parse(blobText);
607
+ // Yes; reclassify as JSON
608
+ resolve(new Blob([blob], { type: "application/json" }));
609
+ }
610
+ catch (ignored) {
611
+ // Nope; test for ZIP file
612
+ if (blobText.length > 4 && blobText.substr(0, 4) === ZIP_FILE_HEADER_SIGNATURE) {
613
+ // Yes; reclassify as ZIP
614
+ resolve(new Blob([blob], { type: "application/zip" }));
615
+ }
616
+ else if (blobText.startsWith("<")) {
617
+ // Reclassify as XML; since the blob started out as text/plain, it's more likely that is
618
+ // meant to be human-readable, so we'll use text/xml instead of application/xml
619
+ resolve(new Blob([blob], { type: "text/xml" }));
620
+ }
621
+ else {
622
+ // Leave as text
623
+ resolve(blob);
624
+ }
625
+ }
626
+ },
627
+ // Faulty blob
628
+ reject);
629
+ }
630
+ else {
631
+ // Empty or not typed as plain text, so simply return
632
+ if (blob) {
633
+ resolve(blob);
634
+ }
635
+ else {
636
+ reject();
637
+ }
638
+ }
639
+ });
640
+ }
641
+ /**
642
+ * Gets some of the ids of the dependencies (contents) of an AGO group.
643
+ *
644
+ * @param groupId Id of a group whose contents are sought
645
+ * @param pagingParams Structure with start and num properties for the tranche to fetch
646
+ * @param authentication Credentials for the request to AGO
647
+ * @returns A promise that will resolve with list of dependent ids or an empty list
648
+ * @private
649
+ */
650
+ export function _getGroupContentsTranche(groupId, pagingParams, authentication) {
651
+ return new Promise((resolve, reject) => {
652
+ // Fetch group items
653
+ const pagingRequest = {
654
+ paging: pagingParams,
655
+ authentication: authentication,
656
+ };
657
+ getGroupContent(groupId, pagingRequest).then((contents) => {
658
+ if (contents.num > 0) {
659
+ // Extract the list of content ids from the JSON returned
660
+ const trancheIds = contents.items.map((item) => item.id);
661
+ // Are there more contents to fetch?
662
+ if (contents.nextStart > 0) {
663
+ pagingRequest.paging.start = contents.nextStart;
664
+ _getGroupContentsTranche(groupId, pagingParams, authentication).then((allSubsequentTrancheIds) => {
665
+ // Append all of the following tranches to the current tranche and return it
666
+ resolve(trancheIds.concat(allSubsequentTrancheIds));
667
+ }, reject);
668
+ }
669
+ else {
670
+ resolve(trancheIds);
671
+ }
672
+ }
673
+ else {
674
+ resolve([]);
675
+ }
676
+ }, reject);
677
+ });
678
+ }
679
+ /**
680
+ * Gets some of the related items of an AGO item.
681
+ *
682
+ * @param requestOptions Item id, relationship type, relationship direction, authentication, and paging
683
+ * @returns A promise that will resolve with the list of related items
684
+ * @private
685
+ */
686
+ function _getItemRelatedItemsTranche(requestOptions) {
687
+ return new Promise((resolve) => {
688
+ const response = {
689
+ total: 0,
690
+ relatedItems: [],
691
+ };
692
+ getRelatedItems(requestOptions).then(
693
+ // Have to use `any` because `IGetRelatedItemsResponse` doesn't include all of the response properties
694
+ (results) => {
695
+ // IGetRelatedItemsResponseFull
696
+ // Are there any results?
697
+ if (results.aggregations.total.count > 0) {
698
+ response.total = results.aggregations.total.count;
699
+ response.relatedItems = results.relatedItems;
700
+ // Are there more items to fetch?
701
+ if (results.nextkey) {
702
+ requestOptions.params.start += requestOptions.params.num;
703
+ requestOptions.params.nextkey = results.nextkey;
704
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
705
+ _getItemRelatedItemsTranche(requestOptions).then((allSubsequentResults) => {
706
+ // Append all of the following tranches to the current tranche and return it
707
+ response.total += allSubsequentResults.total;
708
+ response.relatedItems = response.relatedItems.concat(allSubsequentResults.relatedItems);
709
+ resolve(response);
710
+ });
711
+ }
712
+ else {
713
+ resolve(response);
714
+ }
715
+ }
716
+ else {
717
+ resolve(response);
718
+ }
719
+ }, () => {
720
+ resolve(response);
721
+ });
722
+ });
723
+ }
724
+ /**
725
+ * Gets some of the resources of an AGO item.
726
+ *
727
+ * @param itemId Id of an item whose resources are sought
728
+ * @param pagingParams Structure with start and num properties for the tranche to fetch
729
+ * @param authentication Credentials for the request to AGO
730
+ * @returns Promise that will resolve with a list of File promises or an AGO-style JSON failure response
731
+ * @private
732
+ */
733
+ export function _getItemResourcesTranche(itemId, pagingParams, authentication) {
734
+ return new Promise((resolve, reject) => {
735
+ // Fetch resources
736
+ const portalSharingUrl = getPortalSharingUrlFromAuth(authentication);
737
+ const trancheUrl = `${portalSharingUrl}/content/items/${itemId}/resources`;
738
+ const itemResourcesDef = [];
739
+ const options = {
740
+ params: {
741
+ ...pagingParams,
742
+ },
743
+ authentication: authentication,
744
+ };
745
+ request(trancheUrl, options).then((contents) => {
746
+ if (contents.num > 0) {
747
+ // Extract the list of resource filenames from the JSON returned
748
+ contents.resources.forEach((resource) => {
749
+ const itemResourceUrl = `${portalSharingUrl}/content/items/${itemId}/resources/${resource.resource}`;
750
+ itemResourcesDef.push(getBlobAsFile(itemResourceUrl, resource.resource, authentication));
751
+ });
752
+ // Are there more resources to fetch?
753
+ if (contents.nextStart > 0) {
754
+ pagingParams.start = contents.nextStart;
755
+ _getItemResourcesTranche(itemId, pagingParams, authentication).then((allSubsequentTrancheDefs) => {
756
+ // Append all of the following tranches to the current tranche and return it
757
+ resolve(itemResourcesDef.concat(allSubsequentTrancheDefs));
758
+ }, reject);
759
+ }
760
+ else {
761
+ resolve(itemResourcesDef);
762
+ }
763
+ }
764
+ else {
765
+ resolve([]);
766
+ }
767
+ }, reject);
768
+ });
769
+ }
770
+ /**
771
+ * Retrieves the default basemap for the given & basemapGalleryGroupQuery, basemapTitle
772
+ *
773
+ * @param {string} basemapGalleryGroupQuery The default basemap group query
774
+ * @param {string} basemapTitle The default basemap title
775
+ * @param {UserSession} authentication The session info
776
+ * @returns {IItem}
777
+ */
778
+ export function getPortalDefaultBasemap(basemapGalleryGroupQuery, basemapTitle, authentication) {
779
+ return searchGroups(basemapGalleryGroupQuery, authentication, { num: 1 })
780
+ .then(({ results: [basemapGroup] }) => {
781
+ if (!basemapGroup) {
782
+ throw new Error("No basemap group found");
783
+ }
784
+ return searchGroupContents(basemapGroup.id, `title:${basemapTitle}`, authentication, { num: 1 });
785
+ })
786
+ .then(({ results: [defaultBasemap] }) => {
787
+ if (!defaultBasemap) {
788
+ throw new Error("No basemap found");
789
+ }
790
+ return defaultBasemap;
791
+ });
792
+ }
793
+ //# sourceMappingURL=restHelpersGet.js.map