@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 @@
1
+ {"version":3,"file":"convert-item-resource-to-storage-resource.js","sourceRoot":"","sources":["../../../src/resources/convert-item-resource-to-storage-resource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,oCAAoC,CAClD,MAAc,EACd,sBAA8B,EAC9B,cAAc,GAAG,CAAC,EAClB,eAAsC;IAKtC,0BAA0B;IAC1B,IAAI,eAAe,KAAK,SAAS,EAAE;QACjC,QAAQ,eAAe,EAAE;YACvB,KAAK,oBAAoB,CAAC,IAAI;gBAC5B,MAAM,GAAG,GAAG,MAAM,YAAY,CAAC;gBAC/B,MAAM;YACR,KAAK,oBAAoB,CAAC,OAAO;gBAC/B,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC;gBAChC,MAAM;YACR,KAAK,oBAAoB,CAAC,IAAI;gBAC5B,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC;gBAC1B,MAAM;YACR,KAAK,oBAAoB,CAAC,QAAQ;gBAChC,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC;gBACnC,MAAM;YACR,KAAK,oBAAoB,CAAC,SAAS;gBACjC,MAAM,GAAG,GAAG,MAAM,iBAAiB,CAAC;gBACpC,MAAM;SACT;KACF;IAED,IAAI,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,QAAQ,GAAG,sBAAsB,CAAC;IACtC,MAAM,UAAU,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC7C,IAAI,UAAU,IAAI,CAAC,EAAE;QACnB,IAAI,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;QAC7C,IAAI,cAAc,KAAK,CAAC,EAAE;YACxB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YACpC,MAAM,IAAI,GAAG,GAAG,OAAO,CAAC;SACzB;aAAM;YACL,MAAM,IAAI,GAAG,GAAG,OAAO,CAAC;SACzB;QACD,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;KAC5C;IAED,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,29 @@
1
+ /** @license
2
+ * Copyright 2020 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
+ import { IDeployFilename } from "../interfaces";
17
+ /**
18
+ * Extracts an item's resource folder and filename from the filename used to store a copy in a storage item.
19
+ *
20
+ * @param storageResourceFilename Filename used to store the resource, metadata, or thumbnail of an item
21
+ * @param storageVersion Version of the Solution template
22
+ * @returns Folder and filename for storing information in an item, as well as the type (resource, metadata,
23
+ * or thumbnail) of the information; the folder property is only meaningful for the resource type
24
+ * @see generateResourceStorageFilename
25
+ * @see generateMetadataStorageFilename
26
+ * @see generateThumbnailStorageFilename
27
+ * @see convertItemResourceToStorageResource
28
+ */
29
+ export declare function convertStorageResourceToItemResource(storageResourceFilename: string, storageVersion?: number): IDeployFilename;
@@ -0,0 +1,66 @@
1
+ /** @license
2
+ * Copyright 2020 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
+ import { EFileType } from "../interfaces";
17
+ /**
18
+ * Extracts an item's resource folder and filename from the filename used to store a copy in a storage item.
19
+ *
20
+ * @param storageResourceFilename Filename used to store the resource, metadata, or thumbnail of an item
21
+ * @param storageVersion Version of the Solution template
22
+ * @returns Folder and filename for storing information in an item, as well as the type (resource, metadata,
23
+ * or thumbnail) of the information; the folder property is only meaningful for the resource type
24
+ * @see generateResourceStorageFilename
25
+ * @see generateMetadataStorageFilename
26
+ * @see generateThumbnailStorageFilename
27
+ * @see convertItemResourceToStorageResource
28
+ */
29
+ export function convertStorageResourceToItemResource(storageResourceFilename, storageVersion = 0) {
30
+ const nameParts = storageResourceFilename.split("/");
31
+ let filename = nameParts.pop();
32
+ let folder = "";
33
+ const firstPrefixPart = nameParts.shift(); // undefined if there's no folder
34
+ // Handle special "folders"
35
+ let type = EFileType.Resource;
36
+ if (firstPrefixPart) {
37
+ if (firstPrefixPart.endsWith("_info_thumbnail")) {
38
+ type = EFileType.Thumbnail;
39
+ }
40
+ else if (firstPrefixPart.endsWith("_info_metadata")) {
41
+ type = EFileType.Metadata;
42
+ filename = "metadata.xml";
43
+ }
44
+ else if (firstPrefixPart.endsWith("_info_data")) {
45
+ type = EFileType.Data;
46
+ }
47
+ else if (firstPrefixPart.endsWith("_info_dataz")) {
48
+ filename = filename.replace(/\.zip$/, "");
49
+ type = EFileType.Data;
50
+ // Otherwise, strip off item id
51
+ }
52
+ else if (storageVersion < 1) {
53
+ // Version 0
54
+ const folderStart = firstPrefixPart.indexOf("_");
55
+ if (folderStart > 0) {
56
+ folder = firstPrefixPart.substr(folderStart + 1);
57
+ }
58
+ }
59
+ else {
60
+ // Version ≥ 1
61
+ folder = nameParts.join("/"); // folder is optional, in which case this will be ""
62
+ }
63
+ }
64
+ return { type, folder, filename };
65
+ }
66
+ //# sourceMappingURL=convert-storage-resource-to-item-resource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-storage-resource-to-item-resource.js","sourceRoot":"","sources":["../../../src/resources/convert-storage-resource-to-item-resource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAmB,SAAS,EAAE,MAAM,eAAe,CAAC;AAE3D;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,oCAAoC,CAClD,uBAA+B,EAC/B,cAAc,GAAG,CAAC;IAElB,MAAM,SAAS,GAAG,uBAAuB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrD,IAAI,QAAQ,GAAG,SAAS,CAAC,GAAG,EAAE,CAAC;IAC/B,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,MAAM,eAAe,GAAG,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,iCAAiC;IAE5E,2BAA2B;IAC3B,IAAI,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC;IAC9B,IAAI,eAAe,EAAE;QACnB,IAAI,eAAe,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE;YAC/C,IAAI,GAAG,SAAS,CAAC,SAAS,CAAC;SAC5B;aAAM,IAAI,eAAe,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE;YACrD,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC;YAC1B,QAAQ,GAAG,cAAc,CAAC;SAC3B;aAAM,IAAI,eAAe,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE;YACjD,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC;SACvB;aAAM,IAAI,eAAe,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE;YAClD,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YAC1C,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC;YAEtB,+BAA+B;SAChC;aAAM,IAAI,cAAc,GAAG,CAAC,EAAE;YAC7B,YAAY;YACZ,MAAM,WAAW,GAAG,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YACjD,IAAI,WAAW,GAAG,CAAC,EAAE;gBACnB,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;aAClD;SACF;aAAM;YACL,cAAc;YACd,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,oDAAoD;SACnF;KACF;IAED,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AACpC,CAAC"}
@@ -0,0 +1,79 @@
1
+ /** @license
2
+ * Copyright 2021 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 functions for sending resources to AGO.
18
+ */
19
+ import { UserSession } from "../arcgisRestJS";
20
+ import { IAssociatedFileCopyResults, IAssociatedFileInfo, IItemTemplate, ISourceFile, IZipInfo } from "../interfaces";
21
+ /**
22
+ * Copies the files for storing the resources, metadata, and thumbnail of an item or group to a storage item
23
+ * with a specified path by collecting files into zip files.
24
+ *
25
+ * @param files List of item files' URLs and folder/filenames for storing the files
26
+ * @param destinationItemId Id of item to receive copy of resource/metadata/thumbnail
27
+ * @param destinationAuthentication Credentials for the request to the storage
28
+ * @param maxFilesPerZip Number of files to include per zip file; AGO limits zips to 50 files
29
+ * @returns A promise which resolves to a list of the result of the copies
30
+ */
31
+ export declare function copyFilesAsResources(files: ISourceFile[], destinationItemId: string, destinationAuthentication: UserSession, maxFilesPerZip?: number): Promise<IAssociatedFileCopyResults[]>;
32
+ /**
33
+ * Copies the files described by a list of full URLs and storage folder/filename combinations for storing
34
+ * the resources, metadata, and thumbnail of an item or group to a storage item with different
35
+ * handling based on the type of file.
36
+ *
37
+ * @param fileInfos List of item files' URLs and folder/filenames for storing the files
38
+ * @param sourceAuthentication Credentials for the request to the source
39
+ * @param sourceItemId Id of item supplying resource/metadata
40
+ * @param destinationItemId Id of item to receive copy of resource/metadata/thumbnail
41
+ * @param destinationAuthentication Credentials for the request to the storage
42
+ * @param template Description of item that will receive files
43
+ * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
44
+ * @returns A promise which resolves to a list of the result of the copies
45
+ */
46
+ export declare function copyAssociatedFilesByType(fileInfos: IAssociatedFileInfo[], sourceAuthentication: UserSession, sourceItemId: string, destinationItemId: string, destinationAuthentication: UserSession, template?: any, templateDictionary?: any): Promise<IAssociatedFileCopyResults[]>;
47
+ /**
48
+ * Copies one or more zipfiles to a storage item.
49
+ *
50
+ * @param zipInfos List of zip files containing files to store
51
+ * @param destinationItemId Id of item to receive copy of resource/metadata/thumbnail
52
+ * @param destinationAuthentication Credentials for the request to the storage
53
+ * @returns A promise which resolves to a list of the result of the copies
54
+ * @private
55
+ */
56
+ export declare function _copyAssociatedFileZips(zipInfos: IZipInfo[], destinationItemId: string, destinationAuthentication: UserSession): Promise<IAssociatedFileCopyResults[]>;
57
+ /**
58
+ * Replace templatizations in an item's resources
59
+ *
60
+ * @param sourceAuthentication Credentials for the request to the source
61
+ * @param sourceItemId Id of item supplying resource/metadata
62
+ * @param itemTemplate Item being created
63
+ * @param fileInfos Resources for the item; these resources are modified as needed
64
+ * by removing the templatization: the `url` property is replaced by the `file` property
65
+ * @param destinationAuthentication Credentials for the request to the storage
66
+ * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
67
+ *
68
+ * @returns A promise that resolves when all de-templatization has completed
69
+ */
70
+ export declare function _detemplatizeResources(sourceAuthentication: UserSession, sourceItemId: string, itemTemplate: IItemTemplate, fileInfos: IAssociatedFileInfo[], destinationAuthentication: UserSession, templateDictionary?: any): Promise<void[]>;
71
+ /**
72
+ * Copies one or more zipfiles to a storage item in a serial fashion, waiting a bit between sends.
73
+ *
74
+ * @param zipInfos List of zip files containing files to store
75
+ * @param destinationItemId Id of item to receive copy of resource/metadata/thumbnail
76
+ * @param destinationAuthentication Credentials for the request to the storage
77
+ * @returns A promise which resolves to a list of the result of the copies
78
+ */
79
+ export declare function _sendZipsSeriallyToItem(zipInfos: IZipInfo[], destinationItemId: string, destinationAuthentication: UserSession): Promise<IAssociatedFileCopyResults[]>;
@@ -0,0 +1,339 @@
1
+ /** @license
2
+ * Copyright 2021 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
+ import { EFileType, } from "../interfaces";
17
+ import { chunkArray } from "@esri/hub-common";
18
+ import { copyDataIntoItem } from "./copyDataIntoItem";
19
+ import { copyMetadataIntoItem } from "./copyMetadataIntoItem";
20
+ import { copyResourceIntoZip, copyResourceIntoZipFromInfo } from "./copyResourceIntoZip";
21
+ import { copyZipIntoItem } from "./copyZipIntoItem";
22
+ import { createCopyResults } from "./createCopyResults";
23
+ import { blobToJson, jsonToFile } from "../generalHelpers";
24
+ import { getBlobAsFile } from "../restHelpersGet";
25
+ import JSZip from "jszip";
26
+ // ------------------------------------------------------------------------------------------------------------------ //
27
+ /**
28
+ * Copies the files for storing the resources, metadata, and thumbnail of an item or group to a storage item
29
+ * with a specified path by collecting files into zip files.
30
+ *
31
+ * @param files List of item files' URLs and folder/filenames for storing the files
32
+ * @param destinationItemId Id of item to receive copy of resource/metadata/thumbnail
33
+ * @param destinationAuthentication Credentials for the request to the storage
34
+ * @param maxFilesPerZip Number of files to include per zip file; AGO limits zips to 50 files
35
+ * @returns A promise which resolves to a list of the result of the copies
36
+ */
37
+ export function copyFilesAsResources(files, destinationItemId, destinationAuthentication, maxFilesPerZip = 40) {
38
+ return new Promise((resolve) => {
39
+ const awaitAllItems = [];
40
+ const zipInfos = [];
41
+ if (files.length > 0) {
42
+ // Bundle the resources into chunked zip updates because AGO tends to have problems with
43
+ // many updates in a row to the same item: it claims success despite randomly failing.
44
+ // Note that AGO imposes a limit of 50 files per zip and a maximum upload file size under
45
+ // 50MB, so we break the list of resource file info into chunks below this threshold and
46
+ // start a zip for each.
47
+ // https://developers.arcgis.com/rest/users-groups-and-items/add-resources.htm
48
+ const maxZipSize = 49999000; // bytes
49
+ let zipIndex = 0;
50
+ let currentZipInfo = _createEmptyZipInfo(zipIndex);
51
+ zipInfos.push(currentZipInfo);
52
+ let currentZipSize = 0;
53
+ files.forEach((file) => {
54
+ if (currentZipInfo.filelist.length >= maxFilesPerZip || currentZipSize + file.file.size >= maxZipSize) {
55
+ // Create a new zip for the next chunk
56
+ zipIndex++;
57
+ currentZipInfo = _createEmptyZipInfo(zipIndex);
58
+ zipInfos.push(currentZipInfo);
59
+ currentZipSize = 0;
60
+ }
61
+ awaitAllItems.push(copyResourceIntoZip(file, currentZipInfo));
62
+ currentZipSize += file.file.size;
63
+ });
64
+ }
65
+ if (awaitAllItems.length > 0) {
66
+ // Wait until the Resource zip file(s) are prepared
67
+ void Promise.all(awaitAllItems).then((results) => {
68
+ // We have three types of results:
69
+ // | fetchedFromSource | copiedToDestination | interpretation | |
70
+ // +-------------------+---------------------+------------------------------------------------+
71
+ // | false | * | could not fetch file from source |
72
+ // | true | true | file has been fetched and sent to AGO |
73
+ // | true | undefined | file has been fetched and will be sent via zip |
74
+ // Filter out copiedToDestination===undefined; we'll get their status when we send their zip
75
+ results = results.filter((result) => !(result.fetchedFromSource && typeof result.copiedToDestination === "undefined"));
76
+ // Now send the resources to AGO
77
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
78
+ _copyAssociatedFileZips(zipInfos, destinationItemId, destinationAuthentication).then((zipResults) => {
79
+ resolve(results.concat(zipResults));
80
+ });
81
+ });
82
+ }
83
+ else {
84
+ // No data, metadata, or resources to send; we're done
85
+ resolve([]);
86
+ }
87
+ });
88
+ }
89
+ /**
90
+ * Copies the files described by a list of full URLs and storage folder/filename combinations for storing
91
+ * the resources, metadata, and thumbnail of an item or group to a storage item with different
92
+ * handling based on the type of file.
93
+ *
94
+ * @param fileInfos List of item files' URLs and folder/filenames for storing the files
95
+ * @param sourceAuthentication Credentials for the request to the source
96
+ * @param sourceItemId Id of item supplying resource/metadata
97
+ * @param destinationItemId Id of item to receive copy of resource/metadata/thumbnail
98
+ * @param destinationAuthentication Credentials for the request to the storage
99
+ * @param template Description of item that will receive files
100
+ * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
101
+ * @returns A promise which resolves to a list of the result of the copies
102
+ */
103
+ export async function copyAssociatedFilesByType(fileInfos, sourceAuthentication, sourceItemId, destinationItemId, destinationAuthentication, template = {}, templateDictionary = {}) {
104
+ return new Promise((resolve) => {
105
+ let awaitAllItems = [];
106
+ let resourceFileInfos = fileInfos;
107
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
108
+ awaitAllItems = fileInfos
109
+ .filter((fileInfo) => fileInfo.type === EFileType.Data || fileInfo.type === EFileType.Metadata)
110
+ .map((fileInfo) => {
111
+ // Handle Data and Metadata first
112
+ switch (fileInfo.type) {
113
+ case EFileType.Data:
114
+ // We are updating an item with a zip file, which is written to AGO. If the updated
115
+ // item is in a folder, the zip file is moved to the item's folder after being written.
116
+ // Without the folder information in the URL, AGO writes the zip to the root folder,
117
+ // which causes a conflict if an item with the same data is already in that root folder.
118
+ return copyDataIntoItem(fileInfo, sourceAuthentication, destinationItemId, destinationAuthentication);
119
+ case EFileType.Metadata:
120
+ return copyMetadataIntoItem(fileInfo, sourceAuthentication, destinationItemId, destinationAuthentication);
121
+ }
122
+ });
123
+ // Now add in the Resources
124
+ resourceFileInfos = fileInfos.filter((fileInfo) => fileInfo.type === EFileType.Info || fileInfo.type === EFileType.Resource);
125
+ const zipInfos = [];
126
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
127
+ const awaitAllResources = new Promise((resolve2) => {
128
+ if (resourceFileInfos.length > 0) {
129
+ // De-templatize as needed in files before adding them to the zip
130
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
131
+ _detemplatizeResources(sourceAuthentication, sourceItemId, template, resourceFileInfos, destinationAuthentication, templateDictionary).then(() => {
132
+ // Bundle the resources into chunked zip updates because AGO tends to have problems with
133
+ // many updates in a row to the same item: it claims success despite randomly failing.
134
+ // Note that AGO imposes a limit of 50 files per zip, so we break the list of resource
135
+ // file info into chunks below this threshold and start a zip for each
136
+ // https://developers.arcgis.com/rest/users-groups-and-items/add-resources.htm
137
+ const chunkedResourceFileInfo = chunkArray(resourceFileInfos, 40); // leave a bit of room below threshold
138
+ chunkedResourceFileInfo.forEach((chunk, index) => {
139
+ // Create a zip for this chunk
140
+ const zipInfo = {
141
+ filename: `resources${index}.zip`,
142
+ zip: new JSZip(),
143
+ filelist: [],
144
+ };
145
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
146
+ awaitAllItems = awaitAllItems.concat(chunk.map((fileInfo) => {
147
+ return copyResourceIntoZipFromInfo(fileInfo, sourceAuthentication, zipInfo);
148
+ }));
149
+ zipInfos.push(zipInfo);
150
+ });
151
+ resolve2(null);
152
+ });
153
+ }
154
+ else {
155
+ resolve2(null);
156
+ }
157
+ });
158
+ // Wait until the Resource zip file(s) have been prepared
159
+ void awaitAllResources.then(() => {
160
+ if (awaitAllItems.length > 0) {
161
+ // Wait until all Data and Metadata files have been copied
162
+ void Promise.all(awaitAllItems).then((results) => {
163
+ // We have three types of results:
164
+ // | fetchedFromSource | copiedToDestination | interpretation | |
165
+ // +-------------------+---------------------+------------------------------------------------+
166
+ // | false | * | could not fetch file from source |
167
+ // | true | true | file has been fetched and sent to AGO |
168
+ // | true | undefined | file has been fetched and will be sent via zip |
169
+ // Filter out copiedToDestination===undefined; we'll get their status when we send their zip
170
+ results = results.filter((result) => !(result.fetchedFromSource && typeof result.copiedToDestination === "undefined"));
171
+ // Now send the resources to AGO
172
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
173
+ _copyAssociatedFileZips(zipInfos, destinationItemId, destinationAuthentication).then((zipResults) => {
174
+ resolve(results.concat(zipResults));
175
+ });
176
+ });
177
+ }
178
+ else {
179
+ // No data, metadata, or resources to send; we're done
180
+ resolve([]);
181
+ }
182
+ });
183
+ });
184
+ }
185
+ /**
186
+ * Copies one or more zipfiles to a storage item.
187
+ *
188
+ * @param zipInfos List of zip files containing files to store
189
+ * @param destinationItemId Id of item to receive copy of resource/metadata/thumbnail
190
+ * @param destinationAuthentication Credentials for the request to the storage
191
+ * @returns A promise which resolves to a list of the result of the copies
192
+ * @private
193
+ */
194
+ export function _copyAssociatedFileZips(zipInfos, destinationItemId, destinationAuthentication) {
195
+ return new Promise((resolve) => {
196
+ const results = [];
197
+ // Filter out empty zips, which can happen when none of the files in the chunk going into a zip
198
+ // can be fetched; e.g., the only file is metadata.xml, and the source item doesn't have metadata
199
+ const nonEmptyZipInfos = zipInfos.filter((zipInfo) => Object.keys(zipInfo.zip.files).length > 0);
200
+ if (nonEmptyZipInfos.length > 0) {
201
+ // Send the zip(s) to AGO
202
+ void _sendZipsSeriallyToItem(nonEmptyZipInfos, destinationItemId, destinationAuthentication).then((zipResults) => {
203
+ resolve(zipResults);
204
+ });
205
+ }
206
+ else {
207
+ // No resources to send; we're done
208
+ resolve(results);
209
+ }
210
+ });
211
+ }
212
+ /**
213
+ * Creates an empty zip info object.
214
+ *
215
+ * @param index Index of the zip info object, used as a suffix for the filename
216
+ * @returns An empty zip info object
217
+ */
218
+ function _createEmptyZipInfo(index) {
219
+ return {
220
+ filename: `resources${index}.zip`,
221
+ zip: new JSZip(),
222
+ filelist: [],
223
+ };
224
+ }
225
+ /**
226
+ * Replace templatizations in an item's resources
227
+ *
228
+ * @param sourceAuthentication Credentials for the request to the source
229
+ * @param sourceItemId Id of item supplying resource/metadata
230
+ * @param itemTemplate Item being created
231
+ * @param fileInfos Resources for the item; these resources are modified as needed
232
+ * by removing the templatization: the `url` property is replaced by the `file` property
233
+ * @param destinationAuthentication Credentials for the request to the storage
234
+ * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
235
+ *
236
+ * @returns A promise that resolves when all de-templatization has completed
237
+ */
238
+ export function _detemplatizeResources(sourceAuthentication, sourceItemId, itemTemplate, fileInfos, destinationAuthentication, templateDictionary = {}) {
239
+ const synchronizePromises = [];
240
+ if (itemTemplate.type === "Vector Tile Service") {
241
+ // Get the root.json files
242
+ const rootJsonResources = fileInfos.filter((file) => file.filename === "root.json");
243
+ const templatizedResourcePath = "{{" + sourceItemId + ".url}}";
244
+ const resourcePath = destinationAuthentication.portal + "/content/items/" + itemTemplate.itemId;
245
+ const replacer = new RegExp(templatizedResourcePath, "g");
246
+ // Templatize the paths in the files that reference the source item id
247
+ rootJsonResources.forEach((rootFileResource) => {
248
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
249
+ synchronizePromises.push(new Promise((resolve) => {
250
+ // Fetch the file
251
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
252
+ getBlobAsFile(rootFileResource.url, rootFileResource.filename, sourceAuthentication).then((file) => {
253
+ // Read the file
254
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
255
+ blobToJson(file).then((fileJson) => {
256
+ // Templatize by turning JSON into string, replacing paths with template, and re-JSONing
257
+ const updatedFileJson = JSON.parse(JSON.stringify(fileJson).replace(replacer, resourcePath));
258
+ // Write the changes back into the file
259
+ rootFileResource.file = jsonToFile(updatedFileJson, rootFileResource.filename);
260
+ rootFileResource.url = "";
261
+ resolve(null);
262
+ });
263
+ });
264
+ }));
265
+ });
266
+ }
267
+ else if (itemTemplate.type === "Geoprocessing Service") {
268
+ const paths = {};
269
+ paths[`{{${sourceItemId}.itemId}}`] = itemTemplate.itemId;
270
+ itemTemplate.dependencies.forEach((id) => {
271
+ paths[`{{${id}.itemId}}`] = templateDictionary[id].itemId;
272
+ });
273
+ fileInfos.forEach((fileResource) => {
274
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
275
+ synchronizePromises.push(new Promise((resolve) => {
276
+ // Fetch the file
277
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
278
+ getBlobAsFile(fileResource.url, fileResource.filename, sourceAuthentication).then((file) => {
279
+ // Read the file
280
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
281
+ blobToJson(file).then((fileJson) => {
282
+ // DeTemplatize by turning JSON into string, replacing paths with new value, and re-JSONing
283
+ let fileString = JSON.stringify(fileJson);
284
+ Object.keys(paths).forEach((k) => {
285
+ const replacer = new RegExp(k, "g");
286
+ fileString = fileString.replace(replacer, paths[k]);
287
+ });
288
+ const updatedFileJson = JSON.parse(fileString);
289
+ // Write the changes back into the file
290
+ fileResource.file = jsonToFile(updatedFileJson, fileResource.filename);
291
+ fileResource.url = "";
292
+ resolve(null);
293
+ });
294
+ });
295
+ }));
296
+ });
297
+ }
298
+ return Promise.all(synchronizePromises);
299
+ }
300
+ /**
301
+ * Copies one or more zipfiles to a storage item in a serial fashion, waiting a bit between sends.
302
+ *
303
+ * @param zipInfos List of zip files containing files to store
304
+ * @param destinationItemId Id of item to receive copy of resource/metadata/thumbnail
305
+ * @param destinationAuthentication Credentials for the request to the storage
306
+ * @returns A promise which resolves to a list of the result of the copies
307
+ */
308
+ export function _sendZipsSeriallyToItem(zipInfos, destinationItemId, destinationAuthentication) {
309
+ return new Promise((resolve) => {
310
+ let allResults = [];
311
+ // Remove zip from bottom of list
312
+ const zipInfoToSend = zipInfos.pop();
313
+ // Send predecessors in list
314
+ let sendOthersPromise = Promise.resolve([]);
315
+ if (zipInfos.length > 0) {
316
+ sendOthersPromise = _sendZipsSeriallyToItem(zipInfos, destinationItemId, destinationAuthentication);
317
+ }
318
+ void sendOthersPromise
319
+ .then((response) => {
320
+ allResults = response;
321
+ // Stall a little to give AGO time to catch up
322
+ return new Promise((resolveSleep) => {
323
+ setTimeout(() => resolveSleep(), 1000);
324
+ });
325
+ })
326
+ .then(() => {
327
+ // Now send the zip removed from bottom of the input list
328
+ return copyZipIntoItem(zipInfoToSend, destinationItemId, destinationAuthentication);
329
+ })
330
+ .then((zipResult) => {
331
+ // Save the result of copying this zip as a status for each of the files that it contains
332
+ zipResult.filelist.forEach((fileInfo) => {
333
+ allResults.push(createCopyResults(fileInfo, true, zipResult.copiedToDestination));
334
+ });
335
+ resolve(allResults);
336
+ });
337
+ });
338
+ }
339
+ //# sourceMappingURL=copyAssociatedFiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copyAssociatedFiles.js","sourceRoot":"","sources":["../../../src/resources/copyAssociatedFiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,EACL,SAAS,GAOV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,wHAAwH;AAExH;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAoB,EACpB,iBAAyB,EACzB,yBAAsC,EACtC,cAAc,GAAG,EAAE;IAEnB,OAAO,IAAI,OAAO,CAA+B,CAAC,OAAO,EAAE,EAAE;QAC3D,MAAM,aAAa,GAAiC,EAAE,CAAC;QAEvD,MAAM,QAAQ,GAAe,EAAE,CAAC;QAChC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YACpB,wFAAwF;YACxF,sFAAsF;YACtF,yFAAyF;YACzF,wFAAwF;YACxF,wBAAwB;YACxB,8EAA8E;YAC9E,MAAM,UAAU,GAAG,QAAQ,CAAC,CAAC,QAAQ;YACrC,IAAI,QAAQ,GAAG,CAAC,CAAC;YACjB,IAAI,cAAc,G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** @license
2
+ * Copyright 2021 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
+ import { UserSession } from "../arcgisRestJS";
17
+ import { IAssociatedFileCopyResults, IAssociatedFileInfo, IFileMimeTyped } from "../interfaces";
18
+ /**
19
+ * Copies data into an AGO item.
20
+ *
21
+ * @param fileInfo Information about the source and destination of the file such as its URL, folder, filename
22
+ * @param sourceAuthentication Credentials for the request to the source
23
+ * @param destinationItemId Id of item to receive copy of resource/metadata/thumbnail
24
+ * @param destinationAuthentication Credentials for the request to the storage
25
+ * @returns A promise which resolves to the result of the copy
26
+ */
27
+ export declare function copyDataIntoItem(fileInfo: IAssociatedFileInfo, sourceAuthentication: UserSession, destinationItemId: string, destinationAuthentication: UserSession): Promise<IAssociatedFileCopyResults>;
28
+ /**
29
+ * Creates a file with a specified mime type.
30
+ *
31
+ * @param fileDescription Structure containing a file and the desired mime type
32
+ * @returns Created file
33
+ */
34
+ export declare function createMimeTypedFile(fileDescription: IFileMimeTyped): File;
@@ -0,0 +1,40 @@
1
+ import { createCopyResults } from "./createCopyResults";
2
+ import { getBlob } from "./get-blob";
3
+ import { updateItem as helpersUpdateItem } from "../restHelpers";
4
+ // ------------------------------------------------------------------------------------------------------------------ //
5
+ /**
6
+ * Copies data into an AGO item.
7
+ *
8
+ * @param fileInfo Information about the source and destination of the file such as its URL, folder, filename
9
+ * @param sourceAuthentication Credentials for the request to the source
10
+ * @param destinationItemId Id of item to receive copy of resource/metadata/thumbnail
11
+ * @param destinationAuthentication Credentials for the request to the storage
12
+ * @returns A promise which resolves to the result of the copy
13
+ */
14
+ export function copyDataIntoItem(fileInfo, sourceAuthentication, destinationItemId, destinationAuthentication) {
15
+ return new Promise((resolve) => {
16
+ getBlob(fileInfo.url, sourceAuthentication).then((blob) => {
17
+ const update = {
18
+ id: destinationItemId,
19
+ data: createMimeTypedFile({
20
+ blob: blob,
21
+ filename: fileInfo.filename,
22
+ mimeType: fileInfo.mimeType || blob.type,
23
+ }),
24
+ };
25
+ helpersUpdateItem(update, destinationAuthentication, fileInfo.folder).then(() => resolve(createCopyResults(fileInfo, true, true)), () => resolve(createCopyResults(fileInfo, true, false)));
26
+ }, () => resolve(createCopyResults(fileInfo, false)));
27
+ });
28
+ }
29
+ /**
30
+ * Creates a file with a specified mime type.
31
+ *
32
+ * @param fileDescription Structure containing a file and the desired mime type
33
+ * @returns Created file
34
+ */
35
+ export function createMimeTypedFile(fileDescription) {
36
+ return new File([fileDescription.blob], fileDescription.filename, {
37
+ type: fileDescription.mimeType,
38
+ });
39
+ }
40
+ //# sourceMappingURL=copyDataIntoItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copyDataIntoItem.js","sourceRoot":"","sources":["../../../src/resources/copyDataIntoItem.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,IAAI,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEjE,wHAAwH;AAExH;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAA6B,EAC7B,oBAAiC,EACjC,iBAAyB,EACzB,yBAAsC;IAEtC,OAAO,IAAI,OAAO,CAA6B,CAAC,OAAO,EAAE,EAAE;QACzD,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC,IAAI,CAC9C,CAAC,IAAI,EAAE,EAAE;YACP,MAAM,MAAM,GAAgB;gBAC1B,EAAE,E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