@esri/solution-common 5.2.1 → 5.2.3

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 (212) hide show
  1. package/README.md +4 -7
  2. package/dist/esm/completeItem.js +3 -3
  3. package/dist/esm/completeItem.js.map +1 -1
  4. package/dist/esm/formHelpers.d.ts +41 -0
  5. package/dist/esm/formHelpers.js +71 -0
  6. package/dist/esm/formHelpers.js.map +1 -0
  7. package/dist/esm/generalHelpers.d.ts +33 -0
  8. package/dist/esm/generalHelpers.js +44 -1
  9. package/dist/esm/generalHelpers.js.map +1 -1
  10. package/dist/esm/index.d.ts +2 -0
  11. package/dist/esm/index.js +2 -0
  12. package/dist/esm/index.js.map +1 -1
  13. package/dist/esm/interfaces.d.ts +19 -1
  14. package/dist/esm/interfaces.js.map +1 -1
  15. package/dist/esm/restHelpers.d.ts +10 -1
  16. package/dist/esm/restHelpers.js +25 -1
  17. package/dist/esm/restHelpers.js.map +1 -1
  18. package/dist/esm/templatization.js +5 -3
  19. package/dist/esm/templatization.js.map +1 -1
  20. package/dist/esm/workflowHelpers.d.ts +21 -1
  21. package/dist/esm/workflowHelpers.js +48 -48
  22. package/dist/esm/workflowHelpers.js.map +1 -1
  23. package/dist/esm/zip-utils.d.ts +44 -17
  24. package/dist/esm/zip-utils.js +73 -24
  25. package/dist/esm/zip-utils.js.map +1 -1
  26. package/package.json +3 -3
  27. package/dist/cjs/completeItem.d.ts +0 -29
  28. package/dist/cjs/completeItem.js +0 -92
  29. package/dist/cjs/completeItem.js.map +0 -1
  30. package/dist/cjs/create-hub-request-options.d.ts +0 -29
  31. package/dist/cjs/create-hub-request-options.js +0 -64
  32. package/dist/cjs/create-hub-request-options.js.map +0 -1
  33. package/dist/cjs/deleteHelpers/deleteEmptyGroups.d.ts +0 -24
  34. package/dist/cjs/deleteHelpers/deleteEmptyGroups.js +0 -42
  35. package/dist/cjs/deleteHelpers/deleteEmptyGroups.js.map +0 -1
  36. package/dist/cjs/deleteHelpers/deleteGroupIfEmpty.d.ts +0 -27
  37. package/dist/cjs/deleteHelpers/deleteGroupIfEmpty.js +0 -97
  38. package/dist/cjs/deleteHelpers/deleteGroupIfEmpty.js.map +0 -1
  39. package/dist/cjs/deleteHelpers/deleteSolutionContents.d.ts +0 -38
  40. package/dist/cjs/deleteHelpers/deleteSolutionContents.js +0 -130
  41. package/dist/cjs/deleteHelpers/deleteSolutionContents.js.map +0 -1
  42. package/dist/cjs/deleteHelpers/deleteSolutionFolder.d.ts +0 -29
  43. package/dist/cjs/deleteHelpers/deleteSolutionFolder.js +0 -79
  44. package/dist/cjs/deleteHelpers/deleteSolutionFolder.js.map +0 -1
  45. package/dist/cjs/deleteHelpers/deleteSolutionItem.d.ts +0 -30
  46. package/dist/cjs/deleteHelpers/deleteSolutionItem.js +0 -54
  47. package/dist/cjs/deleteHelpers/deleteSolutionItem.js.map +0 -1
  48. package/dist/cjs/deleteHelpers/index.d.ts +0 -22
  49. package/dist/cjs/deleteHelpers/index.js +0 -26
  50. package/dist/cjs/deleteHelpers/index.js.map +0 -1
  51. package/dist/cjs/deleteHelpers/reconstructBuildOrderIds.d.ts +0 -27
  52. package/dist/cjs/deleteHelpers/reconstructBuildOrderIds.js +0 -34
  53. package/dist/cjs/deleteHelpers/reconstructBuildOrderIds.js.map +0 -1
  54. package/dist/cjs/deleteHelpers/removeItems.d.ts +0 -34
  55. package/dist/cjs/deleteHelpers/removeItems.js +0 -112
  56. package/dist/cjs/deleteHelpers/removeItems.js.map +0 -1
  57. package/dist/cjs/deleteHelpers/reportProgress.d.ts +0 -27
  58. package/dist/cjs/deleteHelpers/reportProgress.js +0 -46
  59. package/dist/cjs/deleteHelpers/reportProgress.js.map +0 -1
  60. package/dist/cjs/deleteSolution.d.ts +0 -55
  61. package/dist/cjs/deleteSolution.js +0 -107
  62. package/dist/cjs/deleteSolution.js.map +0 -1
  63. package/dist/cjs/dependencies.d.ts +0 -26
  64. package/dist/cjs/dependencies.js +0 -171
  65. package/dist/cjs/dependencies.js.map +0 -1
  66. package/dist/cjs/featureServiceHelpers.d.ts +0 -799
  67. package/dist/cjs/featureServiceHelpers.js +0 -2438
  68. package/dist/cjs/featureServiceHelpers.js.map +0 -1
  69. package/dist/cjs/generalHelpers.d.ts +0 -400
  70. package/dist/cjs/generalHelpers.js +0 -877
  71. package/dist/cjs/generalHelpers.js.map +0 -1
  72. package/dist/cjs/get-subscription-info.d.ts +0 -27
  73. package/dist/cjs/get-subscription-info.js +0 -39
  74. package/dist/cjs/get-subscription-info.js.map +0 -1
  75. package/dist/cjs/getDeletableSolutionInfo.d.ts +0 -29
  76. package/dist/cjs/getDeletableSolutionInfo.js +0 -53
  77. package/dist/cjs/getDeletableSolutionInfo.js.map +0 -1
  78. package/dist/cjs/getItemTypeAbbrev.d.ts +0 -19
  79. package/dist/cjs/getItemTypeAbbrev.js +0 -186
  80. package/dist/cjs/getItemTypeAbbrev.js.map +0 -1
  81. package/dist/cjs/getSolutionSummary.d.ts +0 -27
  82. package/dist/cjs/getSolutionSummary.js +0 -101
  83. package/dist/cjs/getSolutionSummary.js.map +0 -1
  84. package/dist/cjs/index.d.ts +0 -44
  85. package/dist/cjs/index.js +0 -48
  86. package/dist/cjs/index.js.map +0 -1
  87. package/dist/cjs/interfaces.d.ts +0 -1344
  88. package/dist/cjs/interfaces.js +0 -77
  89. package/dist/cjs/interfaces.js.map +0 -1
  90. package/dist/cjs/libConnectors.d.ts +0 -73
  91. package/dist/cjs/libConnectors.js +0 -115
  92. package/dist/cjs/libConnectors.js.map +0 -1
  93. package/dist/cjs/migrations/apply-schema.d.ts +0 -24
  94. package/dist/cjs/migrations/apply-schema.js +0 -36
  95. package/dist/cjs/migrations/apply-schema.js.map +0 -1
  96. package/dist/cjs/migrations/is-legacy-solution.d.ts +0 -24
  97. package/dist/cjs/migrations/is-legacy-solution.js +0 -40
  98. package/dist/cjs/migrations/is-legacy-solution.js.map +0 -1
  99. package/dist/cjs/migrations/upgrade-three-dot-one.d.ts +0 -27
  100. package/dist/cjs/migrations/upgrade-three-dot-one.js +0 -49
  101. package/dist/cjs/migrations/upgrade-three-dot-one.js.map +0 -1
  102. package/dist/cjs/migrations/upgrade-three-dot-zero.d.ts +0 -27
  103. package/dist/cjs/migrations/upgrade-three-dot-zero.js +0 -43
  104. package/dist/cjs/migrations/upgrade-three-dot-zero.js.map +0 -1
  105. package/dist/cjs/migrations/upgrade-two-dot-five.d.ts +0 -24
  106. package/dist/cjs/migrations/upgrade-two-dot-five.js +0 -73
  107. package/dist/cjs/migrations/upgrade-two-dot-five.js.map +0 -1
  108. package/dist/cjs/migrations/upgrade-two-dot-four.d.ts +0 -24
  109. package/dist/cjs/migrations/upgrade-two-dot-four.js +0 -72
  110. package/dist/cjs/migrations/upgrade-two-dot-four.js.map +0 -1
  111. package/dist/cjs/migrations/upgrade-two-dot-one.d.ts +0 -7
  112. package/dist/cjs/migrations/upgrade-two-dot-one.js +0 -39
  113. package/dist/cjs/migrations/upgrade-two-dot-one.js.map +0 -1
  114. package/dist/cjs/migrations/upgrade-two-dot-seven.d.ts +0 -23
  115. package/dist/cjs/migrations/upgrade-two-dot-seven.js +0 -58
  116. package/dist/cjs/migrations/upgrade-two-dot-seven.js.map +0 -1
  117. package/dist/cjs/migrations/upgrade-two-dot-six.d.ts +0 -27
  118. package/dist/cjs/migrations/upgrade-two-dot-six.js +0 -61
  119. package/dist/cjs/migrations/upgrade-two-dot-six.js.map +0 -1
  120. package/dist/cjs/migrations/upgrade-two-dot-three.d.ts +0 -23
  121. package/dist/cjs/migrations/upgrade-two-dot-three.js +0 -55
  122. package/dist/cjs/migrations/upgrade-two-dot-three.js.map +0 -1
  123. package/dist/cjs/migrations/upgrade-two-dot-two.d.ts +0 -23
  124. package/dist/cjs/migrations/upgrade-two-dot-two.js +0 -58
  125. package/dist/cjs/migrations/upgrade-two-dot-two.js.map +0 -1
  126. package/dist/cjs/migrations/upgrade-two-dot-zero.d.ts +0 -44
  127. package/dist/cjs/migrations/upgrade-two-dot-zero.js +0 -95
  128. package/dist/cjs/migrations/upgrade-two-dot-zero.js.map +0 -1
  129. package/dist/cjs/migrator.d.ts +0 -25
  130. package/dist/cjs/migrator.js +0 -77
  131. package/dist/cjs/migrator.js.map +0 -1
  132. package/dist/cjs/resourceHelpers.d.ts +0 -191
  133. package/dist/cjs/resourceHelpers.js +0 -384
  134. package/dist/cjs/resourceHelpers.js.map +0 -1
  135. package/dist/cjs/resources/add-resource-from-blob.d.ts +0 -26
  136. package/dist/cjs/resources/add-resource-from-blob.js +0 -52
  137. package/dist/cjs/resources/add-resource-from-blob.js.map +0 -1
  138. package/dist/cjs/resources/addMetadataFromBlob.d.ts +0 -25
  139. package/dist/cjs/resources/addMetadataFromBlob.js +0 -43
  140. package/dist/cjs/resources/addMetadataFromBlob.js.map +0 -1
  141. package/dist/cjs/resources/convert-item-resource-to-storage-resource.d.ts +0 -32
  142. package/dist/cjs/resources/convert-item-resource-to-storage-resource.js +0 -70
  143. package/dist/cjs/resources/convert-item-resource-to-storage-resource.js.map +0 -1
  144. package/dist/cjs/resources/convert-storage-resource-to-item-resource.d.ts +0 -29
  145. package/dist/cjs/resources/convert-storage-resource-to-item-resource.js +0 -70
  146. package/dist/cjs/resources/convert-storage-resource-to-item-resource.js.map +0 -1
  147. package/dist/cjs/resources/copyAssociatedFiles.d.ts +0 -67
  148. package/dist/cjs/resources/copyAssociatedFiles.js +0 -304
  149. package/dist/cjs/resources/copyAssociatedFiles.js.map +0 -1
  150. package/dist/cjs/resources/copyDataIntoItem.d.ts +0 -33
  151. package/dist/cjs/resources/copyDataIntoItem.js +0 -62
  152. package/dist/cjs/resources/copyDataIntoItem.js.map +0 -1
  153. package/dist/cjs/resources/copyMetadataIntoItem.d.ts +0 -26
  154. package/dist/cjs/resources/copyMetadataIntoItem.js +0 -46
  155. package/dist/cjs/resources/copyMetadataIntoItem.js.map +0 -1
  156. package/dist/cjs/resources/copyResourceIntoZip.d.ts +0 -33
  157. package/dist/cjs/resources/copyResourceIntoZip.js +0 -78
  158. package/dist/cjs/resources/copyResourceIntoZip.js.map +0 -1
  159. package/dist/cjs/resources/copyZipIntoItem.d.ts +0 -25
  160. package/dist/cjs/resources/copyZipIntoItem.js +0 -54
  161. package/dist/cjs/resources/copyZipIntoItem.js.map +0 -1
  162. package/dist/cjs/resources/createCopyResults.d.ts +0 -25
  163. package/dist/cjs/resources/createCopyResults.js +0 -36
  164. package/dist/cjs/resources/createCopyResults.js.map +0 -1
  165. package/dist/cjs/resources/get-blob.d.ts +0 -26
  166. package/dist/cjs/resources/get-blob.js +0 -27
  167. package/dist/cjs/resources/get-blob.js.map +0 -1
  168. package/dist/cjs/resources/getItemResourcesFilesFromPaths.d.ts +0 -24
  169. package/dist/cjs/resources/getItemResourcesFilesFromPaths.js +0 -49
  170. package/dist/cjs/resources/getItemResourcesFilesFromPaths.js.map +0 -1
  171. package/dist/cjs/resources/getItemResourcesPaths.d.ts +0 -26
  172. package/dist/cjs/resources/getItemResourcesPaths.js +0 -76
  173. package/dist/cjs/resources/getItemResourcesPaths.js.map +0 -1
  174. package/dist/cjs/resources/index.d.ts +0 -29
  175. package/dist/cjs/resources/index.js +0 -33
  176. package/dist/cjs/resources/index.js.map +0 -1
  177. package/dist/cjs/resources/solution-resource.d.ts +0 -35
  178. package/dist/cjs/resources/solution-resource.js +0 -31
  179. package/dist/cjs/resources/solution-resource.js.map +0 -1
  180. package/dist/cjs/resources/transform-resource-paths-to-solution-resources.d.ts +0 -56
  181. package/dist/cjs/resources/transform-resource-paths-to-solution-resources.js +0 -146
  182. package/dist/cjs/resources/transform-resource-paths-to-solution-resources.js.map +0 -1
  183. package/dist/cjs/restHelpers.d.ts +0 -598
  184. package/dist/cjs/restHelpers.js +0 -1929
  185. package/dist/cjs/restHelpers.js.map +0 -1
  186. package/dist/cjs/restHelpersGet.d.ts +0 -288
  187. package/dist/cjs/restHelpersGet.js +0 -804
  188. package/dist/cjs/restHelpersGet.js.map +0 -1
  189. package/dist/cjs/sharing/index.d.ts +0 -16
  190. package/dist/cjs/sharing/index.js +0 -20
  191. package/dist/cjs/sharing/index.js.map +0 -1
  192. package/dist/cjs/sharing/share-item-to-groups.d.ts +0 -26
  193. package/dist/cjs/sharing/share-item-to-groups.js +0 -44
  194. package/dist/cjs/sharing/share-item-to-groups.js.map +0 -1
  195. package/dist/cjs/templatization.d.ts +0 -139
  196. package/dist/cjs/templatization.js +0 -314
  197. package/dist/cjs/templatization.js.map +0 -1
  198. package/dist/cjs/trackingHelpers.d.ts +0 -116
  199. package/dist/cjs/trackingHelpers.js +0 -217
  200. package/dist/cjs/trackingHelpers.js.map +0 -1
  201. package/dist/cjs/velocityHelpers.d.ts +0 -57
  202. package/dist/cjs/velocityHelpers.js +0 -135
  203. package/dist/cjs/velocityHelpers.js.map +0 -1
  204. package/dist/cjs/workflowHelpers.d.ts +0 -17
  205. package/dist/cjs/workflowHelpers.js +0 -76
  206. package/dist/cjs/workflowHelpers.js.map +0 -1
  207. package/dist/cjs/workforceHelpers.d.ts +0 -115
  208. package/dist/cjs/workforceHelpers.js +0 -749
  209. package/dist/cjs/workforceHelpers.js.map +0 -1
  210. package/dist/cjs/zip-utils.d.ts +0 -49
  211. package/dist/cjs/zip-utils.js +0 -89
  212. package/dist/cjs/zip-utils.js.map +0 -1
@@ -1,29 +0,0 @@
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;
@@ -1,70 +0,0 @@
1
- "use strict";
2
- /** @license
3
- * Copyright 2020 Esri
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.convertStorageResourceToItemResource = void 0;
19
- const interfaces_1 = require("../interfaces");
20
- /**
21
- * Extracts an item's resource folder and filename from the filename used to store a copy in a storage item.
22
- *
23
- * @param storageResourceFilename Filename used to store the resource, metadata, or thumbnail of an item
24
- * @param storageVersion Version of the Solution template
25
- * @returns Folder and filename for storing information in an item, as well as the type (resource, metadata,
26
- * or thumbnail) of the information; the folder property is only meaningful for the resource type
27
- * @see generateResourceStorageFilename
28
- * @see generateMetadataStorageFilename
29
- * @see generateThumbnailStorageFilename
30
- * @see convertItemResourceToStorageResource
31
- */
32
- function convertStorageResourceToItemResource(storageResourceFilename, storageVersion = 0) {
33
- const nameParts = storageResourceFilename.split("/");
34
- let filename = nameParts.pop();
35
- let folder = "";
36
- const firstPrefixPart = nameParts.shift(); // undefined if there's no folder
37
- // Handle special "folders"
38
- let type = interfaces_1.EFileType.Resource;
39
- if (firstPrefixPart) {
40
- if (firstPrefixPart.endsWith("_info_thumbnail")) {
41
- type = interfaces_1.EFileType.Thumbnail;
42
- }
43
- else if (firstPrefixPart.endsWith("_info_metadata")) {
44
- type = interfaces_1.EFileType.Metadata;
45
- filename = "metadata.xml";
46
- }
47
- else if (firstPrefixPart.endsWith("_info_data")) {
48
- type = interfaces_1.EFileType.Data;
49
- }
50
- else if (firstPrefixPart.endsWith("_info_dataz")) {
51
- filename = filename.replace(/\.zip$/, "");
52
- type = interfaces_1.EFileType.Data;
53
- // Otherwise, strip off item id
54
- }
55
- else if (storageVersion < 1) {
56
- // Version 0
57
- const folderStart = firstPrefixPart.indexOf("_");
58
- if (folderStart > 0) {
59
- folder = firstPrefixPart.substr(folderStart + 1);
60
- }
61
- }
62
- else {
63
- // Version ≥ 1
64
- folder = nameParts.join("/"); // folder is optional, in which case this will be ""
65
- }
66
- }
67
- return { type, folder, filename };
68
- }
69
- exports.convertStorageResourceToItemResource = convertStorageResourceToItemResource;
70
- //# sourceMappingURL=convert-storage-resource-to-item-resource.js.map
@@ -1 +0,0 @@
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,8CAA2D;AAE3D;;;;;;;;;;;GAWG;AACH,SAAgB,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,sBAAS,CAAC,QAAQ,CAAC;IAC9B,IAAI,eAAe,EAAE;QACnB,IAAI,eAAe,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE;YAC/C,IAAI,GAAG,sBAAS,CAAC,SAAS,CAAC;SAC5B;aAAM,IAAI,eAAe,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE;YACrD,IAAI,GAAG,sBAAS,CAAC,QAAQ,CAAC;YAC1B,QAAQ,GAAG,cAAc,CAAC;SAC3B;aAAM,IAAI,eAAe,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE;YACjD,IAAI,GAAG,sBAAS,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,sBAAS,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;AArCD,oFAqCC"}
@@ -1,67 +0,0 @@
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 { IAssociatedFileCopyResults, IAssociatedFileInfo, IItemTemplate, ISourceFile, IZipInfo, UserSession } from "../interfaces";
20
- /**
21
- * Copies the files for storing the resources, metadata, and thumbnail of an item or group to a storage item
22
- * with a specified path by collecting files into zip files.
23
- *
24
- * @param files List of item files' URLs and folder/filenames for storing the files
25
- * @param destinationItemId Id of item to receive copy of resource/metadata/thumbnail
26
- * @param destinationAuthentication Credentials for the request to the storage
27
- * @param filesPerZip Number of files to include per zip file; AGO limits zips to 50 files
28
- * @returns A promise which resolves to a list of the result of the copies
29
- */
30
- export declare function copyFilesAsResources(files: ISourceFile[], destinationItemId: string, destinationAuthentication: UserSession, filesPerZip?: number): Promise<IAssociatedFileCopyResults[]>;
31
- /**
32
- * Copies the files described by a list of full URLs and storage folder/filename combinations for storing
33
- * the resources, metadata, and thumbnail of an item or group to a storage item with different
34
- * handling based on the type of file.
35
- *
36
- * @param fileInfos List of item files' URLs and folder/filenames for storing the files
37
- * @param sourceAuthentication Credentials for the request to the source
38
- * @param sourceItemId Id of item supplying resource/metadata
39
- * @param destinationItemId Id of item to receive copy of resource/metadata/thumbnail
40
- * @param destinationAuthentication Credentials for the request to the storage
41
- * @param template Description of item that will receive files
42
- * @returns A promise which resolves to a list of the result of the copies
43
- */
44
- export declare function copyAssociatedFilesByType(fileInfos: IAssociatedFileInfo[], sourceAuthentication: UserSession, sourceItemId: string, destinationItemId: string, destinationAuthentication: UserSession, template?: any): Promise<IAssociatedFileCopyResults[]>;
45
- /**
46
- * Copies one or more zipfiles to a storage item.
47
- *
48
- * @param zipInfos List of zip files containing files to store
49
- * @param destinationItemId Id of item to receive copy of resource/metadata/thumbnail
50
- * @param destinationAuthentication Credentials for the request to the storage
51
- * @returns A promise which resolves to a list of the result of the copies
52
- * @private
53
- */
54
- export declare function _copyAssociatedFileZips(zipInfos: IZipInfo[], destinationItemId: string, destinationAuthentication: UserSession): Promise<IAssociatedFileCopyResults[]>;
55
- /**
56
- * Replace templatizations in an item's resources
57
- *
58
- * @param sourceAuthentication Credentials for the request to the source
59
- * @param sourceItemId Id of item supplying resource/metadata
60
- * @param itemTemplate Item being created
61
- * @param fileInfos Resources for the item; these resources are modified as needed
62
- * by removing the templatization: the `url` property is replaced by the `file` property
63
- * @param destinationAuthentication Credentials for the request to the storage
64
- *
65
- * @returns A promise that resolves when all de-templatization has completed
66
- */
67
- export declare function _detemplatizeResources(sourceAuthentication: UserSession, sourceItemId: string, itemTemplate: IItemTemplate, fileInfos: IAssociatedFileInfo[], destinationAuthentication: UserSession): Promise<void[]>;
@@ -1,304 +0,0 @@
1
- "use strict";
2
- /** @license
3
- * Copyright 2021 Esri
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports._detemplatizeResources = exports._copyAssociatedFileZips = exports.copyAssociatedFilesByType = exports.copyFilesAsResources = void 0;
19
- const tslib_1 = require("tslib");
20
- /**
21
- * Provides functions for sending resources to AGO.
22
- */
23
- const interfaces_1 = require("../interfaces");
24
- const hub_common_1 = require("@esri/hub-common");
25
- const copyDataIntoItem_1 = require("./copyDataIntoItem");
26
- const copyMetadataIntoItem_1 = require("./copyMetadataIntoItem");
27
- const copyResourceIntoZip_1 = require("./copyResourceIntoZip");
28
- const copyZipIntoItem_1 = require("./copyZipIntoItem");
29
- const createCopyResults_1 = require("./createCopyResults");
30
- const generalHelpers_1 = require("../generalHelpers");
31
- const restHelpersGet_1 = require("../restHelpersGet");
32
- const jszip_1 = tslib_1.__importDefault(require("jszip"));
33
- // ------------------------------------------------------------------------------------------------------------------ //
34
- /**
35
- * Copies the files for storing the resources, metadata, and thumbnail of an item or group to a storage item
36
- * with a specified path by collecting files into zip files.
37
- *
38
- * @param files List of item files' URLs and folder/filenames for storing the files
39
- * @param destinationItemId Id of item to receive copy of resource/metadata/thumbnail
40
- * @param destinationAuthentication Credentials for the request to the storage
41
- * @param filesPerZip Number of files to include per zip file; AGO limits zips to 50 files
42
- * @returns A promise which resolves to a list of the result of the copies
43
- */
44
- function copyFilesAsResources(files, destinationItemId, destinationAuthentication, filesPerZip = 40) {
45
- return new Promise(resolve => {
46
- let awaitAllItems = [];
47
- const zipInfos = [];
48
- if (files.length > 0) {
49
- // Bundle the resources into chunked zip updates because AGO tends to have problems with
50
- // many updates in a row to the same item: it claims success despite randomly failing.
51
- // Note that AGO imposes a limit of 50 files per zip, so we break the list of resource
52
- // file info into chunks below this threshold and start a zip for each
53
- // https://developers.arcgis.com/rest/users-groups-and-items/add-resources.htm
54
- const chunkedResourceFiles = (0, hub_common_1.chunkArray)(files, filesPerZip);
55
- chunkedResourceFiles.forEach((chunk, index) => {
56
- // Create a zip for this chunk
57
- const zipInfo = {
58
- filename: `resources${index}.zip`,
59
- zip: new jszip_1.default(),
60
- filelist: []
61
- };
62
- awaitAllItems = awaitAllItems.concat(chunk.map(file => (0, copyResourceIntoZip_1.copyResourceIntoZip)(file, zipInfo)));
63
- zipInfos.push(zipInfo);
64
- });
65
- }
66
- if (awaitAllItems.length > 0) {
67
- // Wait until the Resource zip file(s) are prepared
68
- void Promise.all(awaitAllItems).then((results) => {
69
- // We have three types of results:
70
- // | fetchedFromSource | copiedToDestination | interpretation | |
71
- // +-------------------+---------------------+------------------------------------------------+
72
- // | false | * | could not fetch file from source |
73
- // | true | true | file has been fetched and sent to AGO |
74
- // | true | undefined | file has been fetched and will be sent via zip |
75
- // Filter out copiedToDestination===undefined; we'll get their status when we send their zip
76
- results = results.filter((result) => !(result.fetchedFromSource &&
77
- typeof result.copiedToDestination === "undefined"));
78
- // Now send the resources to AGO
79
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
80
- _copyAssociatedFileZips(zipInfos, destinationItemId, destinationAuthentication).then((zipResults) => {
81
- resolve(results.concat(zipResults));
82
- });
83
- });
84
- }
85
- else {
86
- // No data, metadata, or resources to send; we're done
87
- resolve([]);
88
- }
89
- });
90
- }
91
- exports.copyFilesAsResources = copyFilesAsResources;
92
- /**
93
- * Copies the files described by a list of full URLs and storage folder/filename combinations for storing
94
- * the resources, metadata, and thumbnail of an item or group to a storage item with different
95
- * handling based on the type of file.
96
- *
97
- * @param fileInfos List of item files' URLs and folder/filenames for storing the files
98
- * @param sourceAuthentication Credentials for the request to the source
99
- * @param sourceItemId Id of item supplying resource/metadata
100
- * @param destinationItemId Id of item to receive copy of resource/metadata/thumbnail
101
- * @param destinationAuthentication Credentials for the request to the storage
102
- * @param template Description of item that will receive files
103
- * @returns A promise which resolves to a list of the result of the copies
104
- */
105
- async function copyAssociatedFilesByType(fileInfos, sourceAuthentication, sourceItemId, destinationItemId, destinationAuthentication, template = {}) {
106
- return new Promise(resolve => {
107
- let awaitAllItems = [];
108
- let resourceFileInfos = fileInfos;
109
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
110
- awaitAllItems = fileInfos
111
- .filter(fileInfo => fileInfo.type === interfaces_1.EFileType.Data ||
112
- fileInfo.type === interfaces_1.EFileType.Metadata)
113
- .map(fileInfo => {
114
- // Handle Data and Metadata first
115
- switch (fileInfo.type) {
116
- case interfaces_1.EFileType.Data:
117
- // We are updating an item with a zip file, which is written to AGO. If the updated
118
- // item is in a folder, the zip file is moved to the item's folder after being written.
119
- // Without the folder information in the URL, AGO writes the zip to the root folder,
120
- // which causes a conflict if an item with the same data is already in that root folder.
121
- return (0, copyDataIntoItem_1.copyDataIntoItem)(fileInfo, sourceAuthentication, destinationItemId, destinationAuthentication);
122
- case interfaces_1.EFileType.Metadata:
123
- return (0, copyMetadataIntoItem_1.copyMetadataIntoItem)(fileInfo, sourceAuthentication, destinationItemId, destinationAuthentication);
124
- }
125
- });
126
- // Now add in the Resources
127
- resourceFileInfos = fileInfos.filter(fileInfo => fileInfo.type === interfaces_1.EFileType.Info || fileInfo.type === interfaces_1.EFileType.Resource);
128
- const zipInfos = [];
129
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
130
- const awaitAllResources = new Promise(resolve2 => {
131
- if (resourceFileInfos.length > 0) {
132
- // De-templatize as needed in files before adding them to the zip
133
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
134
- _detemplatizeResources(sourceAuthentication, sourceItemId, template, resourceFileInfos, destinationAuthentication)
135
- .then(() => {
136
- // Bundle the resources into chunked zip updates because AGO tends to have problems with
137
- // many updates in a row to the same item: it claims success despite randomly failing.
138
- // Note that AGO imposes a limit of 50 files per zip, so we break the list of resource
139
- // file info into chunks below this threshold and start a zip for each
140
- // https://developers.arcgis.com/rest/users-groups-and-items/add-resources.htm
141
- const chunkedResourceFileInfo = (0, hub_common_1.chunkArray)(resourceFileInfos, 40); // leave a bit of room below threshold
142
- chunkedResourceFileInfo.forEach((chunk, index) => {
143
- // Create a zip for this chunk
144
- const zipInfo = {
145
- filename: `resources${index}.zip`,
146
- zip: new jszip_1.default(),
147
- filelist: []
148
- };
149
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
150
- awaitAllItems = awaitAllItems.concat(chunk.map(fileInfo => {
151
- return (0, copyResourceIntoZip_1.copyResourceIntoZipFromInfo)(fileInfo, sourceAuthentication, zipInfo);
152
- }));
153
- zipInfos.push(zipInfo);
154
- });
155
- resolve2(null);
156
- });
157
- }
158
- else {
159
- resolve2(null);
160
- }
161
- });
162
- // Wait until the Resource zip file(s) have been prepared
163
- void awaitAllResources.then(() => {
164
- if (awaitAllItems.length > 0) {
165
- // Wait until all Data and Metadata files have been copied
166
- void Promise.all(awaitAllItems).then((results) => {
167
- // We have three types of results:
168
- // | fetchedFromSource | copiedToDestination | interpretation | |
169
- // +-------------------+---------------------+------------------------------------------------+
170
- // | false | * | could not fetch file from source |
171
- // | true | true | file has been fetched and sent to AGO |
172
- // | true | undefined | file has been fetched and will be sent via zip |
173
- // Filter out copiedToDestination===undefined; we'll get their status when we send their zip
174
- results = results.filter((result) => !(result.fetchedFromSource &&
175
- typeof result.copiedToDestination === "undefined"));
176
- // Now send the resources to AGO
177
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
178
- _copyAssociatedFileZips(zipInfos, destinationItemId, destinationAuthentication).then((zipResults) => {
179
- resolve(results.concat(zipResults));
180
- });
181
- });
182
- }
183
- else {
184
- // No data, metadata, or resources to send; we're done
185
- resolve([]);
186
- }
187
- });
188
- });
189
- }
190
- exports.copyAssociatedFilesByType = copyAssociatedFilesByType;
191
- /**
192
- * Copies one or more zipfiles to a storage item.
193
- *
194
- * @param zipInfos List of zip files containing files to store
195
- * @param destinationItemId Id of item to receive copy of resource/metadata/thumbnail
196
- * @param destinationAuthentication Credentials for the request to the storage
197
- * @returns A promise which resolves to a list of the result of the copies
198
- * @private
199
- */
200
- function _copyAssociatedFileZips(zipInfos, destinationItemId, destinationAuthentication) {
201
- return new Promise(resolve => {
202
- const results = [];
203
- // Filter out empty zips, which can happen when none of the files in the chunk going into a zip
204
- // can be fetched; e.g., the only file is metadata.xml, and the source item doesn't have metadata
205
- const nonEmptyZipInfos = zipInfos.filter((zipInfo) => Object.keys(zipInfo.zip.files).length > 0);
206
- if (nonEmptyZipInfos.length > 0) {
207
- // Send the zip(s) to AGO
208
- void _sendZipsSeriallyToItem(nonEmptyZipInfos, destinationItemId, destinationAuthentication).then((zipResults) => {
209
- resolve(zipResults);
210
- });
211
- }
212
- else {
213
- // No resources to send; we're done
214
- resolve(results);
215
- }
216
- });
217
- }
218
- exports._copyAssociatedFileZips = _copyAssociatedFileZips;
219
- /**
220
- * Replace templatizations in an item's resources
221
- *
222
- * @param sourceAuthentication Credentials for the request to the source
223
- * @param sourceItemId Id of item supplying resource/metadata
224
- * @param itemTemplate Item being created
225
- * @param fileInfos Resources for the item; these resources are modified as needed
226
- * by removing the templatization: the `url` property is replaced by the `file` property
227
- * @param destinationAuthentication Credentials for the request to the storage
228
- *
229
- * @returns A promise that resolves when all de-templatization has completed
230
- */
231
- function _detemplatizeResources(sourceAuthentication, sourceItemId, itemTemplate, fileInfos, destinationAuthentication) {
232
- const synchronizePromises = [];
233
- if (itemTemplate.type === "Vector Tile Service") {
234
- // Get the root.json files
235
- const rootJsonResources = fileInfos.filter(file => file.filename === "root.json");
236
- const templatizedResourcePath = "{{" + sourceItemId + ".url}}";
237
- const resourcePath = destinationAuthentication.portal + "/content/items/" + itemTemplate.itemId;
238
- const replacer = new RegExp(templatizedResourcePath, "g");
239
- // Templatize the paths in the files that reference the source item id
240
- rootJsonResources.forEach(rootFileResource => {
241
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
242
- synchronizePromises.push(new Promise(resolve => {
243
- // Fetch the file
244
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
245
- (0, restHelpersGet_1.getBlobAsFile)(rootFileResource.url, rootFileResource.filename, sourceAuthentication).then((file) => {
246
- // Read the file
247
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
248
- (0, generalHelpers_1.blobToJson)(file)
249
- .then(fileJson => {
250
- // Templatize by turning JSON into string, replacing paths with template, and re-JSONing
251
- const updatedFileJson = JSON.parse(JSON.stringify(fileJson)
252
- .replace(replacer, resourcePath));
253
- // Write the changes back into the file
254
- rootFileResource.file = (0, generalHelpers_1.jsonToFile)(updatedFileJson, rootFileResource.filename);
255
- rootFileResource.url = "";
256
- resolve(null);
257
- });
258
- });
259
- }));
260
- });
261
- }
262
- return Promise.all(synchronizePromises);
263
- }
264
- exports._detemplatizeResources = _detemplatizeResources;
265
- /**
266
- * Copies one or more zipfiles to a storage item in a serial fashion, waiting a bit between sends.
267
- *
268
- * @param zipInfos List of zip files containing files to store
269
- * @param destinationItemId Id of item to receive copy of resource/metadata/thumbnail
270
- * @param destinationAuthentication Credentials for the request to the storage
271
- * @returns A promise which resolves to a list of the result of the copies
272
- */
273
- function _sendZipsSeriallyToItem(zipInfos, destinationItemId, destinationAuthentication) {
274
- return new Promise(resolve => {
275
- let allResults = [];
276
- // Remove zip from bottom of list
277
- const zipInfoToSend = zipInfos.pop();
278
- // Send predecessors in list
279
- let sendOthersPromise = Promise.resolve([]);
280
- if (zipInfos.length > 0) {
281
- sendOthersPromise = _sendZipsSeriallyToItem(zipInfos, destinationItemId, destinationAuthentication);
282
- }
283
- void sendOthersPromise
284
- .then((response) => {
285
- allResults = response;
286
- // Stall a little to give AGO time to catch up
287
- return new Promise(resolveSleep => {
288
- setTimeout(() => resolveSleep(), 1000);
289
- });
290
- })
291
- .then(() => {
292
- // Now send the zip removed from bottom of the input list
293
- return (0, copyZipIntoItem_1.copyZipIntoItem)(zipInfoToSend, destinationItemId, destinationAuthentication);
294
- })
295
- .then((zipResult) => {
296
- // Save the result of copying this zip as a status for each of the files that it contains
297
- zipResult.filelist.forEach((fileInfo) => {
298
- allResults.push((0, createCopyResults_1.createCopyResults)(fileInfo, true, zipResult.copiedToDestination));
299
- });
300
- resolve(allResults);
301
- });
302
- });
303
- }
304
- //# sourceMappingURL=copyAssociatedFiles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"copyAssociatedFiles.js","sourceRoot":"","sources":["../../../src/resources/copyAssociatedFiles.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH;;GAEG;AAEH,8CASuB;AACvB,iDAA8C;AAC9C,yDAAsD;AACtD,iEAA8D;AAC9D,+DAG+B;AAC/B,uDAAoD;AACpD,2DAAwD;AACxD,sDAA2D;AAC3D,sDAAkD;AAClD,0DAA0B;AAE1B,wHAAwH;AAExH;;;;;;;;;GASG;AACH,SAAgB,oBAAoB,CAClC,KAAoB,EACpB,iBAAyB,EACzB,yBAAsC,EACtC,WAAW,GAAG,EAAE;IAEhB,OA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uB,CACzC,QAAQ,EACR,iBAAiB,EACjB,yBAAyB,CAC1B,CAAC;SACH;QACD,KAAK,iBAAiB;aACnB,IAAI,CAAC,CAAC,QAAsC,EAAE,EAAE;YAC/C,UAAU,GAAG,QAAQ,CAAC;YAEtB,8CAA8C;YAC9C,OAAO,IAAI,OAAO,CAAO,YAAY,CAAC,EAAE;gBACtC,UAAU,CAAC,GAAG,EAAE,CAAC,YAAY,EAAE,EAAE,IAAI,CAAC,CAAC;YACzC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;aACD,IAAI,CAAC,GAAG,EAAE;YACT,yDAAyD;YACzD,OAAO,IAAA,iCAAe,EACpB,aAAa,EACb,iBAAiB,EACjB,yBAAyB,CAC1B,CAAC;QACJ,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,SAA0B,EAAE,EAAE;YACnC,yFAAyF;YACzF,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,QAA6B,EAAE,EAAE;gBAC3D,UAAU,CAAC,IAAI,CACb,IAAA,qCAAiB,EACf,QAAQ,EACR,IAAI,EACJ,SAAS,CAAC,mBAAmB,CACA,CAChC,CAAC;YACJ,CAAC,CAAC,CAAC;YAEH,OAAO,CAAC,UAAU,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,33 +0,0 @@
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 { IAssociatedFileCopyResults, IAssociatedFileInfo, IFileMimeTyped, UserSession } from "../interfaces";
17
- /**
18
- * Copies data into an AGO item.
19
- *
20
- * @param fileInfo Information about the source and destination of the file such as its URL, folder, filename
21
- * @param sourceAuthentication Credentials for the request to the source
22
- * @param destinationItemId Id of item to receive copy of resource/metadata/thumbnail
23
- * @param destinationAuthentication Credentials for the request to the storage
24
- * @returns A promise which resolves to the result of the copy
25
- */
26
- export declare function copyDataIntoItem(fileInfo: IAssociatedFileInfo, sourceAuthentication: UserSession, destinationItemId: string, destinationAuthentication: UserSession): Promise<IAssociatedFileCopyResults>;
27
- /**
28
- * Creates a file with a specified mime type.
29
- *
30
- * @param fileDescription Structure containing a file and the desired mime type
31
- * @returns Created file
32
- */
33
- export declare function createMimeTypedFile(fileDescription: IFileMimeTyped): File;
@@ -1,62 +0,0 @@
1
- "use strict";
2
- /** @license
3
- * Copyright 2021 Esri
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.createMimeTypedFile = exports.copyDataIntoItem = void 0;
19
- const createCopyResults_1 = require("./createCopyResults");
20
- const get_blob_1 = require("./get-blob");
21
- const restHelpers_1 = require("../restHelpers");
22
- // ------------------------------------------------------------------------------------------------------------------ //
23
- /**
24
- * Copies data into an AGO item.
25
- *
26
- * @param fileInfo Information about the source and destination of the file such as its URL, folder, filename
27
- * @param sourceAuthentication Credentials for the request to the source
28
- * @param destinationItemId Id of item to receive copy of resource/metadata/thumbnail
29
- * @param destinationAuthentication Credentials for the request to the storage
30
- * @returns A promise which resolves to the result of the copy
31
- */
32
- function copyDataIntoItem(fileInfo, sourceAuthentication, destinationItemId, destinationAuthentication) {
33
- return new Promise(resolve => {
34
- (0, get_blob_1.getBlob)(fileInfo.url, sourceAuthentication).then(blob => {
35
- const update = {
36
- id: destinationItemId,
37
- data: createMimeTypedFile({
38
- blob: blob,
39
- filename: fileInfo.filename,
40
- mimeType: fileInfo.mimeType || blob.type
41
- })
42
- };
43
- (0, restHelpers_1.updateItem)(update, destinationAuthentication, fileInfo.folder).then(() => resolve((0, createCopyResults_1.createCopyResults)(fileInfo, true, true)), () => resolve((0, createCopyResults_1.createCopyResults)(fileInfo, true, false)) // unable to add resource
44
- );
45
- }, () => resolve((0, createCopyResults_1.createCopyResults)(fileInfo, false)) // unable to get resource
46
- );
47
- });
48
- }
49
- exports.copyDataIntoItem = copyDataIntoItem;
50
- /**
51
- * Creates a file with a specified mime type.
52
- *
53
- * @param fileDescription Structure containing a file and the desired mime type
54
- * @returns Created file
55
- */
56
- function createMimeTypedFile(fileDescription) {
57
- return new File([fileDescription.blob], fileDescription.filename, {
58
- type: fileDescription.mimeType
59
- });
60
- }
61
- exports.createMimeTypedFile = createMimeTypedFile;
62
- //# sourceMappingURL=copyDataIntoItem.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"copyDataIntoItem.js","sourceRoot":"","sources":["../../../src/resources/copyDataIntoItem.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AASH,2DAAwD;AACxD,yCAAqC;AACrC,gDAAiE;AAEjE,wHAAwH;AAExH;;;;;;;;GAQG;AACH,SAAgB,gBAAgB,CAC9B,QAA6B,EAC7B,oBAAiC,EACjC,iBAAyB,EACzB,yBAAsC;IAEtC,OAAO,IAAI,OAAO,CAA6B,OAAO,CAAC,EAAE;QACvD,IAAA,kBAAO,EAAC,QAAQ,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC,IAAI,CAC9C,IAAI,CAAC,EAAE;YACL,MAAM,MAAM,GAAgB;gBAC1B,EAAE,EAAE,iBAAiB;gBACrB,IAAI,EAAE,mBAAmB,CAAC;oBACxB,IAAI,EAAE,IAAI;oBACV,QAAQ,EAAE,QAAQ,CAAC,QAAQ;oBAC3B,QAAQ,EAAE,QAAQ,CAAC,QAAQ,IAAI,IAAI,CAAC,IAAI;iBACzC,CAAC;aACH,CAAC;YAEF,IAAA,wBAAiB,EACf,MAAM,EACN,yBAAyB,EACzB,QAAQ,CAAC,MAAM,CAChB,CAAC,IAAI,CACJ,GAAG,EAAE,CACH,OAAO,CACL,IAAA,qCAAiB,EACf,QAAQ,EACR,IAAI,EACJ,IAAI,CACyB,CAChC,EACH,GAAG,EAAE,CACH,OAAO,CACL,IAAA,qCAAiB,EACf,QAAQ,EACR,IAAI,EACJ,KAAK,CACwB,CAChC,CAAC,yBAAyB;aAC9B,CAAC;QACJ,CAAC,EACD,GAAG,EAAE,CACH,OAAO,CACL,IAAA,qCAAiB,EAAC,QAAQ,EAAE,KAAK,CAA+B,CACjE,CAAC,yBAAyB;SAC9B,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AA/CD,4CA+CC;AAED;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,eAA+B;IACjE,OAAO,IAAI,IAAI,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,eAAe,CAAC,QAAQ,EAAE;QAChE,IAAI,EAAE,eAAe,CAAC,QAAQ;KAC/B,CAAC,CAAC;AACL,CAAC;AAJD,kDAIC"}
@@ -1,26 +0,0 @@
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 { IAssociatedFileCopyResults, IAssociatedFileInfo, UserSession } from "../interfaces";
17
- /**
18
- * Copies metadata into an AGO item.
19
- *
20
- * @param fileInfo Information about the source and destination of the file such as its URL, folder, filename
21
- * @param sourceAuthentication Credentials for the request to the source
22
- * @param destinationItemId Id of item to receive copy of resource/metadata/thumbnail
23
- * @param destinationAuthentication Credentials for the request to the storage
24
- * @returns A promise which resolves to the result of the copy
25
- */
26
- export declare function copyMetadataIntoItem(fileInfo: IAssociatedFileInfo, sourceAuthentication: UserSession, destinationItemId: string, destinationAuthentication: UserSession): Promise<IAssociatedFileCopyResults>;