@esri/solution-common 5.2.3 → 5.2.4

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 (192) hide show
  1. package/dist/cjs/completeItem.d.ts +29 -0
  2. package/dist/cjs/completeItem.js +92 -0
  3. package/dist/cjs/completeItem.js.map +1 -0
  4. package/dist/cjs/create-hub-request-options.d.ts +29 -0
  5. package/dist/cjs/create-hub-request-options.js +64 -0
  6. package/dist/cjs/create-hub-request-options.js.map +1 -0
  7. package/dist/cjs/deleteHelpers/deleteEmptyGroups.d.ts +24 -0
  8. package/dist/cjs/deleteHelpers/deleteEmptyGroups.js +42 -0
  9. package/dist/cjs/deleteHelpers/deleteEmptyGroups.js.map +1 -0
  10. package/dist/cjs/deleteHelpers/deleteGroupIfEmpty.d.ts +27 -0
  11. package/dist/cjs/deleteHelpers/deleteGroupIfEmpty.js +97 -0
  12. package/dist/cjs/deleteHelpers/deleteGroupIfEmpty.js.map +1 -0
  13. package/dist/cjs/deleteHelpers/deleteSolutionContents.d.ts +38 -0
  14. package/dist/cjs/deleteHelpers/deleteSolutionContents.js +130 -0
  15. package/dist/cjs/deleteHelpers/deleteSolutionContents.js.map +1 -0
  16. package/dist/cjs/deleteHelpers/deleteSolutionFolder.d.ts +29 -0
  17. package/dist/cjs/deleteHelpers/deleteSolutionFolder.js +79 -0
  18. package/dist/cjs/deleteHelpers/deleteSolutionFolder.js.map +1 -0
  19. package/dist/cjs/deleteHelpers/deleteSolutionItem.d.ts +30 -0
  20. package/dist/cjs/deleteHelpers/deleteSolutionItem.js +54 -0
  21. package/dist/cjs/deleteHelpers/deleteSolutionItem.js.map +1 -0
  22. package/dist/cjs/deleteHelpers/index.d.ts +22 -0
  23. package/dist/cjs/deleteHelpers/index.js +26 -0
  24. package/dist/cjs/deleteHelpers/index.js.map +1 -0
  25. package/dist/cjs/deleteHelpers/reconstructBuildOrderIds.d.ts +27 -0
  26. package/dist/cjs/deleteHelpers/reconstructBuildOrderIds.js +34 -0
  27. package/dist/cjs/deleteHelpers/reconstructBuildOrderIds.js.map +1 -0
  28. package/dist/cjs/deleteHelpers/removeItems.d.ts +34 -0
  29. package/dist/cjs/deleteHelpers/removeItems.js +112 -0
  30. package/dist/cjs/deleteHelpers/removeItems.js.map +1 -0
  31. package/dist/cjs/deleteHelpers/reportProgress.d.ts +27 -0
  32. package/dist/cjs/deleteHelpers/reportProgress.js +46 -0
  33. package/dist/cjs/deleteHelpers/reportProgress.js.map +1 -0
  34. package/dist/cjs/deleteSolution.d.ts +55 -0
  35. package/dist/cjs/deleteSolution.js +107 -0
  36. package/dist/cjs/deleteSolution.js.map +1 -0
  37. package/dist/cjs/dependencies.d.ts +26 -0
  38. package/dist/cjs/dependencies.js +171 -0
  39. package/dist/cjs/dependencies.js.map +1 -0
  40. package/dist/cjs/featureServiceHelpers.d.ts +799 -0
  41. package/dist/cjs/featureServiceHelpers.js +2438 -0
  42. package/dist/cjs/featureServiceHelpers.js.map +1 -0
  43. package/dist/cjs/formHelpers.d.ts +41 -0
  44. package/dist/cjs/formHelpers.js +78 -0
  45. package/dist/cjs/formHelpers.js.map +1 -0
  46. package/dist/cjs/generalHelpers.d.ts +433 -0
  47. package/dist/cjs/generalHelpers.js +925 -0
  48. package/dist/cjs/generalHelpers.js.map +1 -0
  49. package/dist/cjs/get-subscription-info.d.ts +27 -0
  50. package/dist/cjs/get-subscription-info.js +39 -0
  51. package/dist/cjs/get-subscription-info.js.map +1 -0
  52. package/dist/cjs/getDeletableSolutionInfo.d.ts +29 -0
  53. package/dist/cjs/getDeletableSolutionInfo.js +53 -0
  54. package/dist/cjs/getDeletableSolutionInfo.js.map +1 -0
  55. package/dist/cjs/getItemTypeAbbrev.d.ts +19 -0
  56. package/dist/cjs/getItemTypeAbbrev.js +186 -0
  57. package/dist/cjs/getItemTypeAbbrev.js.map +1 -0
  58. package/dist/cjs/getSolutionSummary.d.ts +27 -0
  59. package/dist/cjs/getSolutionSummary.js +101 -0
  60. package/dist/cjs/getSolutionSummary.js.map +1 -0
  61. package/dist/cjs/index.d.ts +46 -0
  62. package/dist/cjs/index.js +50 -0
  63. package/dist/cjs/index.js.map +1 -0
  64. package/dist/cjs/interfaces.d.ts +1362 -0
  65. package/dist/cjs/interfaces.js +77 -0
  66. package/dist/cjs/interfaces.js.map +1 -0
  67. package/dist/cjs/libConnectors.d.ts +73 -0
  68. package/dist/cjs/libConnectors.js +115 -0
  69. package/dist/cjs/libConnectors.js.map +1 -0
  70. package/dist/cjs/migrations/apply-schema.d.ts +24 -0
  71. package/dist/cjs/migrations/apply-schema.js +36 -0
  72. package/dist/cjs/migrations/apply-schema.js.map +1 -0
  73. package/dist/cjs/migrations/is-legacy-solution.d.ts +24 -0
  74. package/dist/cjs/migrations/is-legacy-solution.js +40 -0
  75. package/dist/cjs/migrations/is-legacy-solution.js.map +1 -0
  76. package/dist/cjs/migrations/upgrade-three-dot-one.d.ts +27 -0
  77. package/dist/cjs/migrations/upgrade-three-dot-one.js +49 -0
  78. package/dist/cjs/migrations/upgrade-three-dot-one.js.map +1 -0
  79. package/dist/cjs/migrations/upgrade-three-dot-zero.d.ts +27 -0
  80. package/dist/cjs/migrations/upgrade-three-dot-zero.js +43 -0
  81. package/dist/cjs/migrations/upgrade-three-dot-zero.js.map +1 -0
  82. package/dist/cjs/migrations/upgrade-two-dot-five.d.ts +24 -0
  83. package/dist/cjs/migrations/upgrade-two-dot-five.js +73 -0
  84. package/dist/cjs/migrations/upgrade-two-dot-five.js.map +1 -0
  85. package/dist/cjs/migrations/upgrade-two-dot-four.d.ts +24 -0
  86. package/dist/cjs/migrations/upgrade-two-dot-four.js +72 -0
  87. package/dist/cjs/migrations/upgrade-two-dot-four.js.map +1 -0
  88. package/dist/cjs/migrations/upgrade-two-dot-one.d.ts +7 -0
  89. package/dist/cjs/migrations/upgrade-two-dot-one.js +39 -0
  90. package/dist/cjs/migrations/upgrade-two-dot-one.js.map +1 -0
  91. package/dist/cjs/migrations/upgrade-two-dot-seven.d.ts +23 -0
  92. package/dist/cjs/migrations/upgrade-two-dot-seven.js +58 -0
  93. package/dist/cjs/migrations/upgrade-two-dot-seven.js.map +1 -0
  94. package/dist/cjs/migrations/upgrade-two-dot-six.d.ts +27 -0
  95. package/dist/cjs/migrations/upgrade-two-dot-six.js +61 -0
  96. package/dist/cjs/migrations/upgrade-two-dot-six.js.map +1 -0
  97. package/dist/cjs/migrations/upgrade-two-dot-three.d.ts +23 -0
  98. package/dist/cjs/migrations/upgrade-two-dot-three.js +55 -0
  99. package/dist/cjs/migrations/upgrade-two-dot-three.js.map +1 -0
  100. package/dist/cjs/migrations/upgrade-two-dot-two.d.ts +23 -0
  101. package/dist/cjs/migrations/upgrade-two-dot-two.js +58 -0
  102. package/dist/cjs/migrations/upgrade-two-dot-two.js.map +1 -0
  103. package/dist/cjs/migrations/upgrade-two-dot-zero.d.ts +44 -0
  104. package/dist/cjs/migrations/upgrade-two-dot-zero.js +95 -0
  105. package/dist/cjs/migrations/upgrade-two-dot-zero.js.map +1 -0
  106. package/dist/cjs/migrator.d.ts +25 -0
  107. package/dist/cjs/migrator.js +77 -0
  108. package/dist/cjs/migrator.js.map +1 -0
  109. package/dist/cjs/package.json +3 -0
  110. package/dist/cjs/resourceHelpers.d.ts +191 -0
  111. package/dist/cjs/resourceHelpers.js +384 -0
  112. package/dist/cjs/resourceHelpers.js.map +1 -0
  113. package/dist/cjs/resources/add-resource-from-blob.d.ts +26 -0
  114. package/dist/cjs/resources/add-resource-from-blob.js +52 -0
  115. package/dist/cjs/resources/add-resource-from-blob.js.map +1 -0
  116. package/dist/cjs/resources/addMetadataFromBlob.d.ts +25 -0
  117. package/dist/cjs/resources/addMetadataFromBlob.js +43 -0
  118. package/dist/cjs/resources/addMetadataFromBlob.js.map +1 -0
  119. package/dist/cjs/resources/convert-item-resource-to-storage-resource.d.ts +32 -0
  120. package/dist/cjs/resources/convert-item-resource-to-storage-resource.js +70 -0
  121. package/dist/cjs/resources/convert-item-resource-to-storage-resource.js.map +1 -0
  122. package/dist/cjs/resources/convert-storage-resource-to-item-resource.d.ts +29 -0
  123. package/dist/cjs/resources/convert-storage-resource-to-item-resource.js +70 -0
  124. package/dist/cjs/resources/convert-storage-resource-to-item-resource.js.map +1 -0
  125. package/dist/cjs/resources/copyAssociatedFiles.d.ts +67 -0
  126. package/dist/cjs/resources/copyAssociatedFiles.js +304 -0
  127. package/dist/cjs/resources/copyAssociatedFiles.js.map +1 -0
  128. package/dist/cjs/resources/copyDataIntoItem.d.ts +33 -0
  129. package/dist/cjs/resources/copyDataIntoItem.js +62 -0
  130. package/dist/cjs/resources/copyDataIntoItem.js.map +1 -0
  131. package/dist/cjs/resources/copyMetadataIntoItem.d.ts +26 -0
  132. package/dist/cjs/resources/copyMetadataIntoItem.js +46 -0
  133. package/dist/cjs/resources/copyMetadataIntoItem.js.map +1 -0
  134. package/dist/cjs/resources/copyResourceIntoZip.d.ts +33 -0
  135. package/dist/cjs/resources/copyResourceIntoZip.js +78 -0
  136. package/dist/cjs/resources/copyResourceIntoZip.js.map +1 -0
  137. package/dist/cjs/resources/copyZipIntoItem.d.ts +25 -0
  138. package/dist/cjs/resources/copyZipIntoItem.js +54 -0
  139. package/dist/cjs/resources/copyZipIntoItem.js.map +1 -0
  140. package/dist/cjs/resources/createCopyResults.d.ts +25 -0
  141. package/dist/cjs/resources/createCopyResults.js +36 -0
  142. package/dist/cjs/resources/createCopyResults.js.map +1 -0
  143. package/dist/cjs/resources/get-blob.d.ts +26 -0
  144. package/dist/cjs/resources/get-blob.js +27 -0
  145. package/dist/cjs/resources/get-blob.js.map +1 -0
  146. package/dist/cjs/resources/getItemResourcesFilesFromPaths.d.ts +24 -0
  147. package/dist/cjs/resources/getItemResourcesFilesFromPaths.js +49 -0
  148. package/dist/cjs/resources/getItemResourcesFilesFromPaths.js.map +1 -0
  149. package/dist/cjs/resources/getItemResourcesPaths.d.ts +26 -0
  150. package/dist/cjs/resources/getItemResourcesPaths.js +76 -0
  151. package/dist/cjs/resources/getItemResourcesPaths.js.map +1 -0
  152. package/dist/cjs/resources/index.d.ts +29 -0
  153. package/dist/cjs/resources/index.js +33 -0
  154. package/dist/cjs/resources/index.js.map +1 -0
  155. package/dist/cjs/resources/solution-resource.d.ts +35 -0
  156. package/dist/cjs/resources/solution-resource.js +31 -0
  157. package/dist/cjs/resources/solution-resource.js.map +1 -0
  158. package/dist/cjs/resources/transform-resource-paths-to-solution-resources.d.ts +56 -0
  159. package/dist/cjs/resources/transform-resource-paths-to-solution-resources.js +146 -0
  160. package/dist/cjs/resources/transform-resource-paths-to-solution-resources.js.map +1 -0
  161. package/dist/cjs/restHelpers.d.ts +607 -0
  162. package/dist/cjs/restHelpers.js +1954 -0
  163. package/dist/cjs/restHelpers.js.map +1 -0
  164. package/dist/cjs/restHelpersGet.d.ts +288 -0
  165. package/dist/cjs/restHelpersGet.js +804 -0
  166. package/dist/cjs/restHelpersGet.js.map +1 -0
  167. package/dist/cjs/sharing/index.d.ts +16 -0
  168. package/dist/cjs/sharing/index.js +20 -0
  169. package/dist/cjs/sharing/index.js.map +1 -0
  170. package/dist/cjs/sharing/share-item-to-groups.d.ts +26 -0
  171. package/dist/cjs/sharing/share-item-to-groups.js +44 -0
  172. package/dist/cjs/sharing/share-item-to-groups.js.map +1 -0
  173. package/dist/cjs/templatization.d.ts +139 -0
  174. package/dist/cjs/templatization.js +316 -0
  175. package/dist/cjs/templatization.js.map +1 -0
  176. package/dist/cjs/trackingHelpers.d.ts +116 -0
  177. package/dist/cjs/trackingHelpers.js +217 -0
  178. package/dist/cjs/trackingHelpers.js.map +1 -0
  179. package/dist/cjs/velocityHelpers.d.ts +57 -0
  180. package/dist/cjs/velocityHelpers.js +135 -0
  181. package/dist/cjs/velocityHelpers.js.map +1 -0
  182. package/dist/cjs/workflowHelpers.d.ts +37 -0
  183. package/dist/cjs/workflowHelpers.js +77 -0
  184. package/dist/cjs/workflowHelpers.js.map +1 -0
  185. package/dist/cjs/workforceHelpers.d.ts +115 -0
  186. package/dist/cjs/workforceHelpers.js +749 -0
  187. package/dist/cjs/workforceHelpers.js.map +1 -0
  188. package/dist/cjs/zip-utils.d.ts +76 -0
  189. package/dist/cjs/zip-utils.js +142 -0
  190. package/dist/cjs/zip-utils.js.map +1 -0
  191. package/dist/esm/package.json +3 -0
  192. package/package.json +2 -2
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._convertIndicatorField = exports._convertIndicatorToDefinition = exports._convertIndicatorsToDefinitions = exports._upgradeTwoDotZero = void 0;
4
+ /** @license
5
+ * Copyright 2020 Esri
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ const hub_common_1 = require("@esri/hub-common");
20
+ /**
21
+ * Convert indicator "definitions" from the CAS style to the Indicator schema
22
+ * see https://github.com/ArcGIS/Hub/blob/master/indicators.md
23
+ *
24
+ * @param model
25
+ * @private
26
+ */
27
+ function _upgradeTwoDotZero(model) {
28
+ if ((0, hub_common_1.getProp)(model, "item.properties.schemaVersion") >= 2) {
29
+ return model;
30
+ }
31
+ // get the indicators from the .configurationSettings...
32
+ const clone = (0, hub_common_1.cloneObject)(model);
33
+ const configSettings = (0, hub_common_1.getProp)(clone, "data.configurationSettings") || [];
34
+ const indicatorsHash = configSettings.find((e) => e.category === "Indicators");
35
+ clone.data.indicators = _convertIndicatorsToDefinitions(indicatorsHash);
36
+ // remove CAS structure
37
+ delete clone.data.configurationSettings;
38
+ // set the schemaVersion...
39
+ clone.item.properties.schemaVersion = 2;
40
+ return clone;
41
+ }
42
+ exports._upgradeTwoDotZero = _upgradeTwoDotZero;
43
+ /**
44
+ * Given the Indicators entry from a CAS configurationSettings array,
45
+ * convert to an indicators object in the new schema
46
+ *
47
+ * @private
48
+ */
49
+ function _convertIndicatorsToDefinitions(indicatorsHash = {}) {
50
+ // the incoming structure should have a .fields property, and what we want will be in there...
51
+ if (!indicatorsHash.fields || !Array.isArray(indicatorsHash.fields)) {
52
+ indicatorsHash.fields = [];
53
+ }
54
+ const defs = indicatorsHash.fields.map(exports._convertIndicatorToDefinition);
55
+ // now we need to create an object which has props for each def
56
+ return defs;
57
+ }
58
+ exports._convertIndicatorsToDefinitions = _convertIndicatorsToDefinitions;
59
+ /**
60
+ * Convert a CAS formatted indicator to the .definition in the new schama
61
+ *
62
+ * @private
63
+ */
64
+ const _convertIndicatorToDefinition = function (ind) {
65
+ const def = {
66
+ id: ind.fieldName,
67
+ type: "Data",
68
+ name: ind.label || ind.fieldName,
69
+ optional: ind.optional || false,
70
+ definition: {
71
+ description: ind.label || ind.fieldName,
72
+ supportedTypes: [].concat(ind.layerOptions.supportedTypes),
73
+ geometryTypes: [].concat(ind.layerOptions.geometryTypes),
74
+ fields: ind.fields.map(exports._convertIndicatorField)
75
+ }
76
+ };
77
+ return def;
78
+ };
79
+ exports._convertIndicatorToDefinition = _convertIndicatorToDefinition;
80
+ /**
81
+ * Convert the CAS formatted "field" into the new schema
82
+ *
83
+ * @private
84
+ */
85
+ const _convertIndicatorField = function (field) {
86
+ return {
87
+ id: field.fieldName,
88
+ name: field.label,
89
+ optional: field.optional || false,
90
+ description: field.tooltip,
91
+ supportedTypes: [].concat(field.supportedTypes)
92
+ };
93
+ };
94
+ exports._convertIndicatorField = _convertIndicatorField;
95
+ //# sourceMappingURL=upgrade-two-dot-zero.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade-two-dot-zero.js","sourceRoot":"","sources":["../../../src/migrations/upgrade-two-dot-zero.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,iDAAwD;AAExD;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAAC,KAAU;IAC3C,IAAI,IAAA,oBAAO,EAAC,KAAK,EAAE,+BAA+B,CAAC,IAAI,CAAC,EAAE;QACxD,OAAO,KAAK,CAAC;KACd;IACD,wDAAwD;IACxD,MAAM,KAAK,GAAG,IAAA,wBAAW,EAAC,KAAK,CAAC,CAAC;IACjC,MAAM,cAAc,GAAG,IAAA,oBAAO,EAAC,KAAK,EAAE,4BAA4B,CAAC,IAAI,EAAE,CAAC;IAE1E,MAAM,cAAc,GAAG,cAAc,CAAC,IAAI,CACxC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,YAAY,CACxC,CAAC;IACF,KAAK,CAAC,IAAI,CAAC,UAAU,GAAG,+BAA+B,CAAC,cAAc,CAAC,CAAC;IACxE,uBAAuB;IACvB,OAAO,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC;IAExC,2BAA2B;IAC3B,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,GAAG,CAAC,CAAC;IACxC,OAAO,KAAK,CAAC;AACf,CAAC;AAlBD,gDAkBC;AAED;;;;;GAKG;AACH,SAAgB,+BAA+B,CAAC,iBAAsB,EAAE;IACtE,8FAA8F;IAC9F,IAAI,CAAC,cAAc,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE;QACnE,cAAc,CAAC,MAAM,GAAG,EAAE,CAAC;KAC5B;IACD,MAAM,IAAI,GAAG,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,qCAA6B,CAAC,CAAC;IACtE,+DAA+D;IAC/D,OAAO,IAAI,CAAC;AACd,CAAC;AARD,0EAQC;AAED;;;;GAIG;AACI,MAAM,6BAA6B,GAAG,UAAS,GAAQ;IAC5D,MAAM,GAAG,GAAG;QACV,EAAE,EAAE,GAAG,CAAC,SAAS;QACjB,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,SAAS;QAChC,QAAQ,EAAE,GAAG,CAAC,QAAQ,IAAI,KAAK;QAC/B,UAAU,EAAE;YACV,WAAW,EAAE,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,SAAS;YACvC,cAAc,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,cAAc,CAAC;YAC1D,aAAa,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,aAAa,CAAC;YACxD,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,8BAAsB,CAAC;SAC/C;KACF,CAAC;IACF,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAdW,QAAA,6BAA6B,iCAcxC;AAEF;;;;GAIG;AACI,MAAM,sBAAsB,GAAG,UAAS,KAAU;IACvD,OAAO;QACL,EAAE,EAAE,KAAK,CAAC,SAAS;QACnB,IAAI,EAAE,KAAK,CAAC,KAAK;QACjB,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,KAAK;QACjC,WAAW,EAAE,KAAK,CAAC,OAAO;QAC1B,cAAc,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC;KAChD,CAAC;AACJ,CAAC,CAAC;AARW,QAAA,sBAAsB,0BAQjC"}
@@ -0,0 +1,25 @@
1
+ /** @license
2
+ * Copyright 2018 Esri
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { ISolutionItem } from "./interfaces";
17
+ export declare const CURRENT_SCHEMA_VERSION = 3;
18
+ /**
19
+ * Apply schema migrations to a Solution item
20
+ * This system allows the schema of the Solution item to change over time
21
+ * while abstracting those changes into a single set of functional transforms
22
+ *
23
+ * @param model ISolutionItem
24
+ */
25
+ export declare function migrateSchema(model: ISolutionItem): Promise<ISolutionItem>;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ /** @license
3
+ * Copyright 2018 Esri
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.migrateSchema = exports.CURRENT_SCHEMA_VERSION = void 0;
19
+ const is_legacy_solution_1 = require("./migrations/is-legacy-solution");
20
+ const apply_schema_1 = require("./migrations/apply-schema");
21
+ const upgrade_two_dot_zero_1 = require("./migrations/upgrade-two-dot-zero");
22
+ const upgrade_two_dot_one_1 = require("./migrations/upgrade-two-dot-one");
23
+ const upgrade_two_dot_two_1 = require("./migrations/upgrade-two-dot-two");
24
+ const upgrade_two_dot_three_1 = require("./migrations/upgrade-two-dot-three");
25
+ const upgrade_two_dot_four_1 = require("./migrations/upgrade-two-dot-four");
26
+ const upgrade_two_dot_five_1 = require("./migrations/upgrade-two-dot-five");
27
+ const upgrade_two_dot_six_1 = require("./migrations/upgrade-two-dot-six");
28
+ const upgrade_two_dot_seven_1 = require("./migrations/upgrade-two-dot-seven");
29
+ const upgrade_three_dot_zero_1 = require("./migrations/upgrade-three-dot-zero");
30
+ const hub_common_1 = require("@esri/hub-common");
31
+ // Starting at 3.0 because Hub has been versioning Solution items up to 2.x
32
+ exports.CURRENT_SCHEMA_VERSION = 3.0;
33
+ /**
34
+ * Apply schema migrations to a Solution item
35
+ * This system allows the schema of the Solution item to change over time
36
+ * while abstracting those changes into a single set of functional transforms
37
+ *
38
+ * @param model ISolutionItem
39
+ */
40
+ function migrateSchema(model) {
41
+ // ensure properties
42
+ if (!(0, hub_common_1.getProp)(model, "item.properties")) {
43
+ model.item.properties = {};
44
+ }
45
+ const modelVersion = (0, hub_common_1.getProp)(model, "item.properties.schemaVersion");
46
+ // if it's already on the current version, return it
47
+ if (modelVersion === exports.CURRENT_SCHEMA_VERSION) {
48
+ return Promise.resolve(model);
49
+ }
50
+ else {
51
+ // check if this is a legacy solution created by Hub
52
+ const isLegacy = (0, is_legacy_solution_1._isLegacySolution)(model);
53
+ const schemaUpgrades = [];
54
+ // if this is a Solution.js "native" item, it is already at 3.0
55
+ if (!modelVersion && !isLegacy) {
56
+ // apply the 3.0+ transforms
57
+ // TEMP to allow merge to develop w/o breaking things
58
+ schemaUpgrades.push(upgrade_three_dot_zero_1._upgradeThreeDotZero);
59
+ // schemaUpgrades.push(_upgradeThreeDotZero, _upgradeThreeDotOne);
60
+ }
61
+ else {
62
+ // Hub created a set of Solution items that are not 100% compatible
63
+ // with the Solution.js deployer.
64
+ schemaUpgrades.push(apply_schema_1._applySchema, upgrade_two_dot_zero_1._upgradeTwoDotZero, upgrade_two_dot_one_1._upgradeTwoDotOne, upgrade_two_dot_two_1._upgradeTwoDotTwo, upgrade_two_dot_three_1._upgradeTwoDotThree, upgrade_two_dot_four_1._upgradeTwoDotFour, upgrade_two_dot_five_1._upgradeTwoDotFive, upgrade_two_dot_six_1._upgradeTwoDotSix, upgrade_two_dot_seven_1._upgradeTwoDotSeven);
65
+ // Apply the 3.x upgrades
66
+ schemaUpgrades.push(upgrade_three_dot_zero_1._upgradeThreeDotZero
67
+ // _upgradeThreeDotOne // Not ready for prod yet
68
+ );
69
+ }
70
+ // Run any migrations serially. Since we start with a promise,
71
+ // individual migrations are free to return either ISolutionItem
72
+ // or Promise<ISolutionItem>
73
+ return schemaUpgrades.reduce((promise, upgradeFn) => promise.then((updatedModel) => upgradeFn(updatedModel)), Promise.resolve(model));
74
+ }
75
+ }
76
+ exports.migrateSchema = migrateSchema;
77
+ //# sourceMappingURL=migrator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrator.js","sourceRoot":"","sources":["../../src/migrator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAGH,wEAAoE;AACpE,4DAAyD;AACzD,4EAAuE;AACvE,0EAAqE;AACrE,0EAAqE;AACrE,8EAAyE;AACzE,4EAAuE;AACvE,4EAAuE;AACvE,0EAAqE;AACrE,8EAAyE;AACzE,gFAA2E;AAI3E,iDAA2C;AAE3C,2EAA2E;AAC9D,QAAA,sBAAsB,GAAG,GAAG,CAAC;AAE1C;;;;;;GAMG;AACH,SAAgB,aAAa,CAAC,KAAoB;IAChD,oBAAoB;IACpB,IAAI,CAAC,IAAA,oBAAO,EAAC,KAAK,EAAE,iBAAiB,CAAC,EAAE;QACtC,KAAK,CAAC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;KAC5B;IAED,MAAM,YAAY,GAAG,IAAA,oBAAO,EAAC,KAAK,EAAE,+BAA+B,CAAC,CAAC;IACrE,oDAAoD;IACpD,IAAI,YAAY,KAAK,8BAAsB,EAAE;QAC3C,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;KAC/B;SAAM;QACL,oDAAoD;QACpD,MAAM,QAAQ,GAAG,IAAA,sCAAiB,EAAC,KAAK,CAAC,CAAC;QAC1C,MAAM,cAAc,GAAG,EAAE,CAAC;QAE1B,+DAA+D;QAC/D,IAAI,CAAC,YAAY,IAAI,CAAC,QAAQ,EAAE;YAC9B,4BAA4B;YAC5B,qDAAqD;YACrD,cAAc,CAAC,IAAI,CAAC,6CAAoB,CAAC,CAAC;YAC1C,kEAAkE;SACnE;aAAM;YACL,mEAAmE;YACnE,iCAAiC;YACjC,cAAc,CAAC,IAAI,CACjB,2BAAY,EACZ,yCAAkB,EAClB,uCAAiB,EACjB,uCAAiB,EACjB,2CAAmB,EACnB,yCAAkB,EAClB,yCAAkB,EAClB,uCAAiB,EACjB,2CAAmB,CACpB,CAAC;YACF,yBAAyB;YACzB,cAAc,CAAC,IAAI,CACjB,6CAAoB;YACpB,gDAAgD;aACjD,CAAC;SACH;QACD,8DAA8D;QAC9D,gEAAgE;QAChE,4BAA4B;QAC5B,OAAO,cAAc,CAAC,MAAM,CAC1B,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,CACrB,OAAO,CAAC,IAAI,CAAC,CAAC,YAA2B,EAAE,EAAE,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,EACxE,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CACvB,CAAC;KACH;AACH,CAAC;AAlDD,sCAkDC"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,191 @@
1
+ /** @license
2
+ * Copyright 2018 Esri
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Provides common functions involving the management of item and group resources.
18
+ *
19
+ * @module resourceHelpers
20
+ *
21
+ * How it works
22
+ *
23
+ * An item may have resources that are listed as a set of filenames and/or folder/filename combinations. It may have
24
+ * a thumbnail, listed in its item info as a filename or folder/filename combination. It may have metadata, which is
25
+ * not listed, but has a distinct URL. A group may have a thumbnail, but not the others.
26
+ *
27
+ * For storing these files in a common storage item, a new folder and filename combination is created for each. The
28
+ * filename is kept as-is. The folder consists of the source item's id and an optional suffix. For thumbnails, the
29
+ * suffix is "_info_thumbnail"; for metadata, the suffix is "_info_metadata"; for resources, the suffix is "_" plus
30
+ * the resource's folder's name; if the resource doesn't have a folder, there is no suffix.
31
+ *
32
+ * Note that "thumbnail" is included in an item's thumbnail property like a folder (e.g., "thumbnail/thumbnail.png"),
33
+ * and the item's thumbnail is accessed using a path such as "%lt;itemId&gt;/info/thumbnail/thumbnail.png". Groups,
34
+ * on the other hand, have a property with a simple name (e.g., "thumbnail.png") and it is accessed using a path
35
+ * such as "%lt;groupId&gt;/info/thumbnail.png".
36
+ *
37
+ * For copying these files from the common storage item to another item, one converts the unique names back into the
38
+ * original names (or the special cases for thumbnails and metadata).
39
+ *
40
+ * Routines are provided to
41
+ * 1. create full URLs to resources, thumbnails, and metadata.
42
+ * 2. create a folder and filename combination that uniquely identifies these files for
43
+ * storing them in a single, shared storage item
44
+ * 3. copy a set of resources, thumbnails, and metadata for an item to a storage item
45
+ * 4. copy a file by URL to an item using specified folder and filename
46
+ * 5. undo the unique folder and filename into the original folder and filename
47
+ */
48
+ import { IDeployFileCopyPath, IFileMimeTyped, ISourceFile, ISourceFileCopyPath, UserSession } from "./interfaces";
49
+ import { IItemResourceResponse } from "@esri/arcgis-rest-portal";
50
+ export declare function addThumbnailFromBlob(blob: any, itemId: string, authentication: UserSession, isGroup?: boolean): Promise<any>;
51
+ export declare function convertBlobToSupportableResource(blob: Blob, filename?: string): IFileMimeTyped;
52
+ /**
53
+ * Copies the files described by a list of full URLs and folder/filename combinations for
54
+ * the resources and metadata of an item or group to an item.
55
+ *
56
+ * @param storageAuthentication Credentials for the request to the storage
57
+ * @param filePaths List of item files' URLs and folder/filenames for storing the files
58
+ * @param sourceItemId Id of item supplying resource/metadata
59
+ * @param destinationFolderId Id of folder
60
+ * @param destinationItemId Id of item to receive copy of resource/metadata
61
+ * @param destinationAuthentication Credentials for the request to the destination
62
+ * @param template Description of item that will receive files
63
+ * @returns A promise which resolves to a boolean indicating if the copies were successful
64
+ */
65
+ export declare function copyFilesFromStorageItem(storageAuthentication: UserSession, filePaths: IDeployFileCopyPath[], sourceItemId: string, destinationFolderId: string, destinationItemId: string, destinationAuthentication: UserSession, template?: any): Promise<boolean>;
66
+ /**
67
+ * Copies the files for storing the resources, metadata, and thumbnail of an item or group to a storage item
68
+ * with a specified path.
69
+ *
70
+ * @param files List of item files and paths for storing the files
71
+ * @param storageItemId Id of item to receive copy of resource/metadata
72
+ * @param storageAuthentication Credentials for the request to the storage
73
+ * @returns A promise which resolves to a list of the filenames under which the resource/metadata are stored
74
+ */
75
+ export declare function copyFilesToStorageItem(files: ISourceFile[], storageItemId: string, storageAuthentication: UserSession): Promise<string[]>;
76
+ /**
77
+ * Generates a folder and filename for storing a copy of an item's metadata in a storage item.
78
+ *
79
+ * @param itemId Id of item
80
+ * @returns Folder and filename for storage; folder is the itemID suffixed with "_info_metadata"
81
+ * @see convertStorageResourceToItemResource
82
+ */
83
+ export declare function generateMetadataStorageFilename(itemId: string): {
84
+ folder: string;
85
+ filename: string;
86
+ };
87
+ /**
88
+ * Generates a list of full URLs and storage folder/filename combinations for storing the resources, metadata,
89
+ * and thumbnail of an item.
90
+ *
91
+ * @param portalSharingUrl Server/sharing
92
+ * @param itemId Id of item
93
+ * @param thumbnailUrlPart Partial path to the thumbnail held in an item's JSON
94
+ * @param resourceFilenames List of resource filenames for an item, e.g., ["file1", "myFolder/file2"]
95
+ * @param isGroup Boolean to indicate if the files are associated with a group or item
96
+ * @param storageVersion Version of the Solution template
97
+ * @returns List of item files' URLs and folder/filenames for storing the files
98
+ */
99
+ export declare function generateSourceFilePaths(portalSharingUrl: string, itemId: string, thumbnailUrlPart: string, resourceFilenames: string[], isGroup?: boolean, storageVersion?: number): ISourceFileCopyPath[];
100
+ /**
101
+ * Generates the full URL and storage folder/filename for storing an item's thumbnail.
102
+ *
103
+ * @param portalSharingUrl Server/sharing
104
+ * @param itemId Id of item
105
+ * @param thumbnailUrlPart Partial path to the thumbnail held in an item's JSON
106
+ * @param isGroup Boolean to indicate if the files are associated with a group or item
107
+ * @returns URL and folder/filename for storing the thumbnail
108
+ */
109
+ export declare function generateSourceThumbnailPath(portalSharingUrl: string, itemId: string, thumbnailUrlPart: string, isGroup?: boolean): ISourceFileCopyPath;
110
+ /**
111
+ * Generates the URL for reading an item's metadata.
112
+ *
113
+ * @param sourcePortalSharingUrl Server/sharing
114
+ * @param itemId Id of item
115
+ * @param isGroup Boolean to indicate if the files are associated with a group or item
116
+ * @returns URL string
117
+ */
118
+ export declare function generateSourceMetadataUrl(sourcePortalSharingUrl: string, itemId: string, isGroup?: boolean): string;
119
+ /**
120
+ * Generates the URL for reading an item's resource given the filename of the resource.
121
+ *
122
+ * @param sourcePortalSharingUrl Server/sharing
123
+ * @param itemId Id of item
124
+ * @param sourceResourceFilename Either filename or folder/filename to resource
125
+ * @returns URL string
126
+ */
127
+ export declare function generateSourceResourceUrl(sourcePortalSharingUrl: string, itemId: string, sourceResourceFilename: string): string;
128
+ /**
129
+ * Generates the URL for reading an item's thumbnail.
130
+ *
131
+ * @param sourcePortalSharingUrl Server/sharing
132
+ * @param itemId Id of item
133
+ * @param thumbnailUrlPart Partial path to the thumbnail held in an item's JSON
134
+ * @param isGroup Boolean to indicate if the files are associated with a group or item
135
+ * @returns URL string
136
+ */
137
+ export declare function generateSourceThumbnailUrl(sourcePortalSharingUrl: string, itemId: string, thumbnailUrlPart: string, isGroup?: boolean): string;
138
+ /**
139
+ * Generates a list of full URLs and folder/filename combinations used to store the resources, metadata,
140
+ * and thumbnail of an item.
141
+ *
142
+ * @param portalSharingUrl Server/sharing
143
+ * @param storageItemId Id of storage item
144
+ * @param resourceFilenames List of resource filenames for an item, e.g., ["file1", "myFolder/file2"]
145
+ * @param storageVersion Version of the Solution template
146
+ * @returns List of item files' URLs and folder/filenames for storing the files
147
+ */
148
+ export declare function generateStorageFilePaths(portalSharingUrl: string, storageItemId: string, resourceFilenames?: string[], storageVersion?: number): IDeployFileCopyPath[];
149
+ /**
150
+ * Generates a folder and filename for storing a copy of an item's thumbnail in a storage item.
151
+ *
152
+ * @param itemId Id of item
153
+ * @param thumbnailUrlPart Partial path to the thumbnail held in an item's JSON; can also be a filename
154
+ * @returns Folder and filename for storage; folder is the itemID suffixed with "_info_thumbnail";
155
+ * file is URI-encoded thumbnailUrlPart
156
+ * @see convertStorageResourceToItemResource
157
+ */
158
+ export declare function generateThumbnailStorageFilename(itemId: string, thumbnailurl: string): {
159
+ folder: string;
160
+ filename: string;
161
+ };
162
+ export declare function isSupportedFileType(filename: string): boolean;
163
+ /**
164
+ * Gets the thumbnail of an item or group.
165
+ *
166
+ * @param authentication Credentials for the request to the storage
167
+ * @param filePaths List of item files' URLs and folder/filenames for storing the files
168
+ * @returns A promise which resolves to a boolean indicating if the copies were successful
169
+ */
170
+ export declare function getThumbnailFromStorageItem(authentication: UserSession, filePaths: IDeployFileCopyPath[]): Promise<File>;
171
+ /**
172
+ * Removes the item's resource that matches the filename with new content
173
+ *
174
+ * @param itemId Id of the item to remove
175
+ * @param filename Name of the resource file to remove
176
+ * @param authentication Credentials for the request to the storage
177
+ * @returns A promise which resolves with a success true/false response
178
+ */
179
+ export declare function removeItemResourceFile(itemId: string, filename: string, authentication: UserSession): Promise<{
180
+ success: boolean;
181
+ }>;
182
+ /**
183
+ * Updates the item's resource that matches the filename with new content
184
+ *
185
+ * @param itemId Id of the item to update
186
+ * @param filename Name of the resource file to update; prefix optional (e.g., a/b/file.txt)
187
+ * @param resource The new content to update the resource with
188
+ * @param authentication Credentials for the request to the storage
189
+ * @returns A promise which resolves with a success true/false response
190
+ */
191
+ export declare function updateItemResourceFile(itemId: string, filename: string, resource: File, authentication: UserSession): Promise<IItemResourceResponse>;