@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,116 @@
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 { IItemTemplate, UserSession } from "./interfaces";
17
+ import { IItemUpdate } from "@esri/arcgis-rest-types";
18
+ import { ICreateServiceParams } from "@esri/arcgis-rest-service-admin";
19
+ /**
20
+ * Used by deploy to evaluate if we have everything we need to deploy tracking views.
21
+ *
22
+ * This function will update the input templateDictionary with a boolean
23
+ * indicating if tracking is enabled on the org and the user is an admin.
24
+ *
25
+ * @param portalResponse portal self response
26
+ * @param userResponse portal user response
27
+ * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
28
+ * @param templates the list of IItemTemplates from the solution
29
+ *
30
+ * @private
31
+ */
32
+ export declare function setLocationTrackingEnabled(portalResponse: any, userResponse: any, templateDictionary: any, templates?: IItemTemplate[]): void;
33
+ /**
34
+ * Used by deploy to evaluate if we have everything we need to deploy tracking views.
35
+ *
36
+ * An error is thrown to prevent additional deployment work if we have Tracking items and tracking is
37
+ * not enabled or the deployment user is not an admin in the organization.
38
+ *
39
+ * @param templates the list of IItemTemplates from the solution
40
+ * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
41
+ *
42
+ * @private
43
+ */
44
+ export declare function _validateTrackingTemplates(templates: IItemTemplate[], templateDictionary: any): void;
45
+ /**
46
+ * Used by deploy to determine the owner of the tracking service.
47
+ * Only one tracking service per org and all tracking views and tracking groups must be owned by the tracking service owner.
48
+ *
49
+ * This function will update the input templateDictionary with the owner as well as
50
+ * the item id for the source tracking service.
51
+ *
52
+ * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
53
+ * @param authentication Credentials for the requests
54
+ *
55
+ * @private
56
+ */
57
+ export declare function getTackingServiceOwner(templateDictionary: any, authentication: UserSession): Promise<boolean>;
58
+ /**
59
+ * Check key properties to understand if we are dealing with a tracking template
60
+ *
61
+ * @param itemTemplate the template to evaluate
62
+ * @param itemUpdate the item update to evaluate
63
+ *
64
+ * @private
65
+ */
66
+ export declare function isTrackingViewTemplate(itemTemplate?: IItemTemplate, itemUpdate?: IItemUpdate): boolean;
67
+ /**
68
+ * Check key properties to understand if we are dealing with a tracking group template
69
+ *
70
+ * @param itemTemplate the template to evaluate
71
+ *
72
+ * @private
73
+ */
74
+ export declare function isTrackingViewGroup(itemTemplate: IItemTemplate): boolean;
75
+ /**
76
+ * Templatize the tracker view group id and view name for location tracking views.
77
+ * This function will update the itemTemplate that is passed in when it's a tracking view.
78
+ *
79
+ * @param itemTemplate Template for feature service item
80
+ *
81
+ * @private
82
+ */
83
+ export declare function templatizeTracker(itemTemplate: IItemTemplate): void;
84
+ /**
85
+ * Templatize the tracker view group id and view name for location tracking views.
86
+ * This function will update the itemTemplate that is passed in when it's a tracking view.
87
+ *
88
+ * @param itemTemplate Template for the tracker view
89
+ * @param path the path to the property that stores the current name
90
+ * @param groupId the id of the associated tracker group
91
+ * @param groupIdVar the variable to replace the existing name with
92
+ *
93
+ * @private
94
+ */
95
+ export declare function _setName(itemTemplate: IItemTemplate, path: string, groupId: string, groupIdVar: string): void;
96
+ /**
97
+ * Templatize the tracker view serviceItemId
98
+ *
99
+ * This function will update the input obj with the templatized variable
100
+ *
101
+ * @param obj the object that stores the serviceItemId
102
+ * @param path the path to the property that stores the serviceItemId
103
+ *
104
+ * @private
105
+ */
106
+ export declare function templatizeServiceItemId(obj: any, path: string): void;
107
+ /**
108
+ * Used by deploy to update the request options with key details for deploying tracker views
109
+ *
110
+ * @param itemTemplate Template for feature service item
111
+ * @param options the current request options to update
112
+ * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
113
+ *
114
+ * @private
115
+ */
116
+ export declare function setTrackingOptions(itemTemplate: IItemTemplate, options: any, templateDictionary: any): ICreateServiceParams;
@@ -0,0 +1,217 @@
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.setTrackingOptions = exports.templatizeServiceItemId = exports._setName = exports.templatizeTracker = exports.isTrackingViewGroup = exports.isTrackingViewTemplate = exports.getTackingServiceOwner = exports._validateTrackingTemplates = exports.setLocationTrackingEnabled = void 0;
19
+ const generalHelpers_1 = require("./generalHelpers");
20
+ const restHelpersGet_1 = require("./restHelpersGet");
21
+ const templatization_1 = require("./templatization");
22
+ /**
23
+ * Used by deploy to evaluate if we have everything we need to deploy tracking views.
24
+ *
25
+ * This function will update the input templateDictionary with a boolean
26
+ * indicating if tracking is enabled on the org and the user is an admin.
27
+ *
28
+ * @param portalResponse portal self response
29
+ * @param userResponse portal user response
30
+ * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
31
+ * @param templates the list of IItemTemplates from the solution
32
+ *
33
+ * @private
34
+ */
35
+ function setLocationTrackingEnabled(portalResponse, userResponse, templateDictionary, templates) {
36
+ // set locationTracking...contains service url and id
37
+ const locationTracking = (0, generalHelpers_1.getProp)(portalResponse, "helperServices.locationTracking");
38
+ /* istanbul ignore else */
39
+ if (locationTracking) {
40
+ templateDictionary.locationTracking = locationTracking;
41
+ }
42
+ // verify we have location tracking service and the user is an admin
43
+ templateDictionary.locationTrackingEnabled =
44
+ templateDictionary.locationTracking &&
45
+ (0, generalHelpers_1.getProp)(userResponse, "role") === "org_admin"
46
+ ? true
47
+ : false;
48
+ if (templates) {
49
+ _validateTrackingTemplates(templates, templateDictionary);
50
+ }
51
+ }
52
+ exports.setLocationTrackingEnabled = setLocationTrackingEnabled;
53
+ /**
54
+ * Used by deploy to evaluate if we have everything we need to deploy tracking views.
55
+ *
56
+ * An error is thrown to prevent additional deployment work if we have Tracking items and tracking is
57
+ * not enabled or the deployment user is not an admin in the organization.
58
+ *
59
+ * @param templates the list of IItemTemplates from the solution
60
+ * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
61
+ *
62
+ * @private
63
+ */
64
+ function _validateTrackingTemplates(templates, templateDictionary) {
65
+ /* istanbul ignore else */
66
+ if (!templateDictionary.locationTrackingEnabled &&
67
+ templates.some(template => {
68
+ const typeKeywords = (0, generalHelpers_1.getProp)(template, "item.typeKeywords") || [];
69
+ return typeKeywords.indexOf("Location Tracking View") > -1;
70
+ })) {
71
+ console.error("Location tracking not enabled or user is not admin.");
72
+ throw new Error("Location tracking not enabled or user is not admin.");
73
+ }
74
+ }
75
+ exports._validateTrackingTemplates = _validateTrackingTemplates;
76
+ /**
77
+ * Used by deploy to determine the owner of the tracking service.
78
+ * Only one tracking service per org and all tracking views and tracking groups must be owned by the tracking service owner.
79
+ *
80
+ * This function will update the input templateDictionary with the owner as well as
81
+ * the item id for the source tracking service.
82
+ *
83
+ * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
84
+ * @param authentication Credentials for the requests
85
+ *
86
+ * @private
87
+ */
88
+ function getTackingServiceOwner(templateDictionary, authentication) {
89
+ if (templateDictionary.locationTrackingEnabled) {
90
+ const locationTrackingId = templateDictionary.locationTracking.id;
91
+ return (0, restHelpersGet_1.getItemBase)(locationTrackingId, authentication).then(itemBase => {
92
+ templateDictionary.locationTracking.owner = itemBase.owner;
93
+ templateDictionary[itemBase.id] = {
94
+ itemId: itemBase.id
95
+ };
96
+ return Promise.resolve(itemBase && itemBase.owner === authentication.username);
97
+ }, () => Promise.resolve(false));
98
+ }
99
+ else {
100
+ return Promise.resolve(false);
101
+ }
102
+ }
103
+ exports.getTackingServiceOwner = getTackingServiceOwner;
104
+ /**
105
+ * Check key properties to understand if we are dealing with a tracking template
106
+ *
107
+ * @param itemTemplate the template to evaluate
108
+ * @param itemUpdate the item update to evaluate
109
+ *
110
+ * @private
111
+ */
112
+ function isTrackingViewTemplate(itemTemplate, itemUpdate) {
113
+ const typeKeywords = (0, generalHelpers_1.getProp)(itemTemplate, "item.typeKeywords") ||
114
+ (0, generalHelpers_1.getProp)(itemUpdate, "typeKeywords");
115
+ const trackViewGroup = (0, generalHelpers_1.getProp)(itemTemplate, "item.properties.trackViewGroup") ||
116
+ (0, generalHelpers_1.getProp)(itemUpdate, "properties.trackViewGroup");
117
+ return (typeKeywords && typeKeywords.indexOf("Location Tracking View") > -1 && trackViewGroup) ? true : false;
118
+ }
119
+ exports.isTrackingViewTemplate = isTrackingViewTemplate;
120
+ /**
121
+ * Check key properties to understand if we are dealing with a tracking group template
122
+ *
123
+ * @param itemTemplate the template to evaluate
124
+ *
125
+ * @private
126
+ */
127
+ function isTrackingViewGroup(itemTemplate) {
128
+ const typeKeywords = (0, generalHelpers_1.getProp)(itemTemplate, "item.tags");
129
+ return (typeKeywords && typeKeywords.indexOf("Location Tracking Group") > -1) ? true : false;
130
+ }
131
+ exports.isTrackingViewGroup = isTrackingViewGroup;
132
+ /**
133
+ * Templatize the tracker view group id and view name for location tracking views.
134
+ * This function will update the itemTemplate that is passed in when it's a tracking view.
135
+ *
136
+ * @param itemTemplate Template for feature service item
137
+ *
138
+ * @private
139
+ */
140
+ function templatizeTracker(itemTemplate) {
141
+ /* istanbul ignore else */
142
+ if (isTrackingViewTemplate(itemTemplate)) {
143
+ const trackViewGroup = (0, generalHelpers_1.getProp)(itemTemplate, "item.properties.trackViewGroup");
144
+ itemTemplate.groups.push(trackViewGroup);
145
+ itemTemplate.dependencies.push(trackViewGroup);
146
+ const groupIdVar = (0, templatization_1.templatizeTerm)(trackViewGroup, trackViewGroup, ".itemId");
147
+ (0, generalHelpers_1.setProp)(itemTemplate, "item.properties.trackViewGroup", groupIdVar);
148
+ _setName(itemTemplate, "item.name", trackViewGroup, groupIdVar);
149
+ _setName(itemTemplate, "properties.service.adminServiceInfo.name", trackViewGroup, groupIdVar);
150
+ const layersAndTables = (itemTemplate.properties.layers || []).concat(itemTemplate.properties.tables || []);
151
+ layersAndTables.forEach(l => {
152
+ templatizeServiceItemId(l, "adminLayerInfo.viewLayerDefinition.sourceServiceItemId");
153
+ });
154
+ }
155
+ }
156
+ exports.templatizeTracker = templatizeTracker;
157
+ /**
158
+ * Templatize the tracker view group id and view name for location tracking views.
159
+ * This function will update the itemTemplate that is passed in when it's a tracking view.
160
+ *
161
+ * @param itemTemplate Template for the tracker view
162
+ * @param path the path to the property that stores the current name
163
+ * @param groupId the id of the associated tracker group
164
+ * @param groupIdVar the variable to replace the existing name with
165
+ *
166
+ * @private
167
+ */
168
+ function _setName(itemTemplate, path, groupId, groupIdVar) {
169
+ const name = (0, generalHelpers_1.getProp)(itemTemplate, path);
170
+ /* istanbul ignore else */
171
+ if (name) {
172
+ (0, generalHelpers_1.setProp)(itemTemplate, path, name.replace(groupId, groupIdVar));
173
+ }
174
+ }
175
+ exports._setName = _setName;
176
+ /**
177
+ * Templatize the tracker view serviceItemId
178
+ *
179
+ * This function will update the input obj with the templatized variable
180
+ *
181
+ * @param obj the object that stores the serviceItemId
182
+ * @param path the path to the property that stores the serviceItemId
183
+ *
184
+ * @private
185
+ */
186
+ function templatizeServiceItemId(obj, path) {
187
+ const serviceItemId = (0, generalHelpers_1.getProp)(obj, path);
188
+ /* istanbul ignore else */
189
+ if (serviceItemId) {
190
+ (0, generalHelpers_1.setProp)(obj, path, (0, templatization_1.templatizeTerm)(serviceItemId, serviceItemId, ".itemId"));
191
+ }
192
+ }
193
+ exports.templatizeServiceItemId = templatizeServiceItemId;
194
+ /**
195
+ * Used by deploy to update the request options with key details for deploying tracker views
196
+ *
197
+ * @param itemTemplate Template for feature service item
198
+ * @param options the current request options to update
199
+ * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
200
+ *
201
+ * @private
202
+ */
203
+ function setTrackingOptions(itemTemplate, options, templateDictionary) {
204
+ /* istanbul ignore else */
205
+ if (isTrackingViewTemplate(itemTemplate)) {
206
+ (0, generalHelpers_1.setCreateProp)(options, "owner", templateDictionary.locationTracking.owner);
207
+ (0, generalHelpers_1.setCreateProp)(options.item, "name", itemTemplate.item.name);
208
+ (0, generalHelpers_1.setCreateProp)(options.item, "isView", true);
209
+ (0, generalHelpers_1.setCreateProp)(options.item, "owner", templateDictionary.locationTracking.owner);
210
+ (0, generalHelpers_1.setCreateProp)(options.params, "isView", true);
211
+ (0, generalHelpers_1.setCreateProp)(options.params, "outputType", "locationTrackingService");
212
+ delete (options.folderId);
213
+ }
214
+ return options.item;
215
+ }
216
+ exports.setTrackingOptions = setTrackingOptions;
217
+ //# sourceMappingURL=trackingHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trackingHelpers.js","sourceRoot":"","sources":["../../src/trackingHelpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAKH,qDAAmE;AACnE,qDAA+C;AAC/C,qDAAkD;AAIlD;;;;;;;;;;;;GAYG;AACH,SAAgB,0BAA0B,CACxC,cAAmB,EACnB,YAAiB,EACjB,kBAAuB,EACvB,SAA2B;IAE3B,qD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@ -0,0 +1,57 @@
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 { UserSession } from "./interfaces";
17
+ export declare const BASE_NAMES: string[];
18
+ export declare const PROP_NAMES: string[];
19
+ /**
20
+ * Get the base velocity url from the current orgs subscription info
21
+ *
22
+ * This function will update the input templateDictionary arg with the velocity url
23
+ * so we can reuse it without pinging the org again for subsequent requests to the
24
+ * velocity api.
25
+ *
26
+ * @param authentication Credentials for the requests
27
+ * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
28
+ *
29
+ * @returns a promise that will resolve with the velocity url or an empty string when the org does not support velocity
30
+ *
31
+ */
32
+ export declare function getVelocityUrlBase(authentication: UserSession, templateDictionary: any): Promise<string>;
33
+ /**
34
+ * Update any velocity urls found in the data
35
+ *
36
+ * This function can be extended to support any item type specific functions such as
37
+ * removing the itemId from operational layers in a webmap
38
+ *
39
+ * @param data The data object of the item
40
+ * @param type The item type
41
+ * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
42
+ *
43
+ * @returns an updated instance of the data object that was supplied.
44
+ *
45
+ */
46
+ export declare function updateVelocityReferences(data: any, type: string, templateDictionary: any): any;
47
+ /**
48
+ * Helper function to update velocity urls found in the data
49
+ *
50
+ *
51
+ * @param data The data object of the item
52
+ * @param velocityUrl The velocity url from the current organization
53
+ *
54
+ * @returns an updated instance of the data object that was supplied.
55
+ * @private
56
+ */
57
+ export declare function _replaceVelocityUrls(data: any, velocityUrl: string): any;
@@ -0,0 +1,135 @@
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._replaceVelocityUrls = exports.updateVelocityReferences = exports.getVelocityUrlBase = exports.PROP_NAMES = exports.BASE_NAMES = void 0;
19
+ const get_subscription_info_1 = require("./get-subscription-info");
20
+ const generalHelpers_1 = require("./generalHelpers");
21
+ // Known base names if output, source, or feed name is missing
22
+ exports.BASE_NAMES = [
23
+ "feat-lyr-new",
24
+ "feat-lyr-existing",
25
+ "stream-lyr-new"
26
+ ];
27
+ // Known prop paths that can contain item Ids
28
+ exports.PROP_NAMES = [
29
+ ".portal.mapServicePortalItemID",
30
+ ".portal.featureServicePortalItemID",
31
+ ".portal.streamServicePortalItemID",
32
+ ".portalItemId"
33
+ ];
34
+ /**
35
+ * Get the base velocity url from the current orgs subscription info
36
+ *
37
+ * This function will update the input templateDictionary arg with the velocity url
38
+ * so we can reuse it without pinging the org again for subsequent requests to the
39
+ * velocity api.
40
+ *
41
+ * @param authentication Credentials for the requests
42
+ * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
43
+ *
44
+ * @returns a promise that will resolve with the velocity url or an empty string when the org does not support velocity
45
+ *
46
+ */
47
+ function getVelocityUrlBase(authentication, templateDictionary) {
48
+ // if we already have the base url no need to make any additional requests
49
+ if (templateDictionary.hasOwnProperty("velocityUrl")) {
50
+ return Promise.resolve(templateDictionary.velocityUrl);
51
+ }
52
+ else {
53
+ // get the url from the orgs subscription info
54
+ return (0, get_subscription_info_1.getSubscriptionInfo)({ authentication }).then((subscriptionInfo) => {
55
+ let velocityUrl = "";
56
+ const orgCapabilities = (0, generalHelpers_1.getProp)(subscriptionInfo, "orgCapabilities");
57
+ /* istanbul ignore else */
58
+ if (Array.isArray(orgCapabilities)) {
59
+ orgCapabilities.some(c => {
60
+ /* istanbul ignore else */
61
+ if (c.id === "velocity" && c.status === "active" && c.velocityUrl) {
62
+ velocityUrl = c.velocityUrl;
63
+ }
64
+ return velocityUrl;
65
+ });
66
+ }
67
+ // add the base url to the templateDictionary for reuse
68
+ templateDictionary.velocityUrl = velocityUrl;
69
+ return Promise.resolve(velocityUrl);
70
+ });
71
+ }
72
+ }
73
+ exports.getVelocityUrlBase = getVelocityUrlBase;
74
+ /**
75
+ * Update any velocity urls found in the data
76
+ *
77
+ * This function can be extended to support any item type specific functions such as
78
+ * removing the itemId from operational layers in a webmap
79
+ *
80
+ * @param data The data object of the item
81
+ * @param type The item type
82
+ * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
83
+ *
84
+ * @returns an updated instance of the data object that was supplied.
85
+ *
86
+ */
87
+ function updateVelocityReferences(data, type, templateDictionary) {
88
+ const velocityUrl = templateDictionary.velocityUrl;
89
+ if (data && type === "Web Map" && velocityUrl) {
90
+ const layersAndTables = (data.operationalLayers || []).concat(data.tables || []);
91
+ (layersAndTables).forEach((l) => {
92
+ if (l.url && l.url.indexOf(velocityUrl) > -1 && l.itemId) {
93
+ delete l.itemId;
94
+ }
95
+ });
96
+ }
97
+ return velocityUrl && data ? _replaceVelocityUrls(data, velocityUrl) : data;
98
+ }
99
+ exports.updateVelocityReferences = updateVelocityReferences;
100
+ /**
101
+ * Helper function to update velocity urls found in the data
102
+ *
103
+ *
104
+ * @param data The data object of the item
105
+ * @param velocityUrl The velocity url from the current organization
106
+ *
107
+ * @returns an updated instance of the data object that was supplied.
108
+ * @private
109
+ */
110
+ function _replaceVelocityUrls(data, velocityUrl) {
111
+ let dataString = JSON.stringify(data);
112
+ if (dataString.indexOf(velocityUrl) > -1) {
113
+ // replace any instance of the velocity base url
114
+ dataString = dataString.replace(new RegExp(`${velocityUrl}`, "gi"), "{{velocityUrl}}");
115
+ // add solutionItemId to any velocity service names
116
+ const regex = new RegExp("{{velocityUrl}}.+?(?=/[A-Za-z]+Server)", "gi");
117
+ const results = dataString.match(regex);
118
+ /* istanbul ignore else */
119
+ if (results) {
120
+ const uniqueResults = results.filter((v, i, self) => self.indexOf(v) === i);
121
+ uniqueResults.forEach(result => {
122
+ // these names can contain reserved characters for regex
123
+ // for example: http://something/name(something else)
124
+ // TypeScript for es2015 doesn't have a definition for `replaceAll`
125
+ dataString = dataString.replaceAll(result, `${result}_{{solutionItemId}}`);
126
+ });
127
+ }
128
+ return JSON.parse(dataString);
129
+ }
130
+ else {
131
+ return data;
132
+ }
133
+ }
134
+ exports._replaceVelocityUrls = _replaceVelocityUrls;
135
+ //# sourceMappingURL=velocityHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"velocityHelpers.js","sourceRoot":"","sources":["../../src/velocityHelpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAGH,mEAGiC;AACjC,qDAA2C;AAE3C,8DAA8D;AACjD,QAAA,UAAU,GAAa;IAClC,cAAc;IACd,mBAAmB;IACnB,gBAAgB;CACjB,CAAC;AAEF,6CAA6C;AAChC,QAAA,UAAU,GAAc;IACnC,gCAAgC;IAChC,oCAAoC;IACpC,mCAAmC;IACnC,eAAe;CAChB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,SAAgB,kBAAkB,CAChC,cAA2B,EAC3B,kBAAuB;IAEvB,0EAA0E;IAC1E,IAAI,kBAAkB,CAAC,cAAc,CAAC,aAAa,CAAC,EAAE;QACpD,OAAO,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;KACxD;SAAM;QACL,8CAA8C;QAC9C,OAAO,IAAA,2CAAmB,EAAC,EAAE,cAAc,EAAE,CAAC,CAAC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37 @@
1
+ /** @license
2
+ * Copyright 2024 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
+ * Compresses a workflow configuration into a zip file.
18
+ *
19
+ * @param workflowConfig Workflow configuration
20
+ * @returns Promise resolving with a zip file
21
+ */
22
+ export declare function compressWorkflowIntoZipFile(workflowConfig: any): Promise<File>;
23
+ /**
24
+ * Extracts a workflow configuration from a zip file into a JSON object.
25
+ *
26
+ * @param zipFile Zip file containing a workflow configuration
27
+ * @returns Promise resolving with a workflow configuration as JSON object, with each file being a key
28
+ */
29
+ export declare function extractWorkflowFromZipFile(zipFile: File): Promise<any>;
30
+ /**
31
+ * Extracts a workflow configuration from a zip file into a JSON object, with all AGO ids in the
32
+ * configuration templatized.
33
+ *
34
+ * @param zipFile Zip file containing a workflow configuration
35
+ * @returns Promise resolving with a workflow configuration as JSON object, with each file being a key
36
+ */
37
+ export declare function extractAndTemplatizeWorkflowFromZipFile(zipFile: File): Promise<any>;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ /** @license
3
+ * Copyright 2024 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.extractAndTemplatizeWorkflowFromZipFile = exports.extractWorkflowFromZipFile = exports.compressWorkflowIntoZipFile = void 0;
19
+ const tslib_1 = require("tslib");
20
+ const zipUtils = tslib_1.__importStar(require("./zip-utils"));
21
+ const copyDataIntoItem_1 = require("./resources/copyDataIntoItem");
22
+ const generalHelpers_1 = require("./generalHelpers");
23
+ const jszip_1 = tslib_1.__importDefault(require("jszip"));
24
+ // ------------------------------------------------------------------------------------------------------------------ //
25
+ /**
26
+ * Compresses a workflow configuration into a zip file.
27
+ *
28
+ * @param workflowConfig Workflow configuration
29
+ * @returns Promise resolving with a zip file
30
+ */
31
+ async function compressWorkflowIntoZipFile(workflowConfig) {
32
+ const zip = new jszip_1.default();
33
+ Object.keys(workflowConfig).forEach((key) => {
34
+ zip.file(key, JSON.stringify(workflowConfig[key]));
35
+ });
36
+ const zipFile = (0, copyDataIntoItem_1.createMimeTypedFile)({
37
+ blob: await zip.generateAsync({ type: "blob" }),
38
+ filename: `workflow_configuration.zip`,
39
+ mimeType: "application/zip"
40
+ });
41
+ return Promise.resolve(zipFile);
42
+ }
43
+ exports.compressWorkflowIntoZipFile = compressWorkflowIntoZipFile;
44
+ /**
45
+ * Extracts a workflow configuration from a zip file into a JSON object.
46
+ *
47
+ * @param zipFile Zip file containing a workflow configuration
48
+ * @returns Promise resolving with a workflow configuration as JSON object, with each file being a key
49
+ */
50
+ async function extractWorkflowFromZipFile(zipFile) {
51
+ const zippedFiles = await zipUtils.getZipObjectContents(await zipUtils.blobToZipObject(zipFile));
52
+ const workflowConfig = {};
53
+ zippedFiles.forEach((zippedFile) => {
54
+ workflowConfig[zippedFile.file] = zippedFile.content;
55
+ });
56
+ return Promise.resolve(workflowConfig);
57
+ }
58
+ exports.extractWorkflowFromZipFile = extractWorkflowFromZipFile;
59
+ /**
60
+ * Extracts a workflow configuration from a zip file into a JSON object, with all AGO ids in the
61
+ * configuration templatized.
62
+ *
63
+ * @param zipFile Zip file containing a workflow configuration
64
+ * @returns Promise resolving with a workflow configuration as JSON object, with each file being a key
65
+ */
66
+ async function extractAndTemplatizeWorkflowFromZipFile(zipFile) {
67
+ const workflowConfig = await extractWorkflowFromZipFile(zipFile);
68
+ // Replace AGO ids with templatized versions
69
+ let workflowConfigStr = JSON.stringify(workflowConfig);
70
+ const matches = workflowConfigStr.match((0, generalHelpers_1.getAgoIdRegEx)()) || [];
71
+ matches.forEach((match) => {
72
+ workflowConfigStr = workflowConfigStr.replace(new RegExp(match, "g"), `{{${match}}}`);
73
+ });
74
+ return Promise.resolve(JSON.parse(workflowConfigStr));
75
+ }
76
+ exports.extractAndTemplatizeWorkflowFromZipFile = extractAndTemplatizeWorkflowFromZipFile;
77
+ //# sourceMappingURL=workflowHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflowHelpers.js","sourceRoot":"","sources":["../../src/workflowHelpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AASH,8DAAwC;AACxC,mEAAmE;AACnE,qDAAiD;AACjD,0DAA0B;AAE1B,wHAAwH;AAExH;;;;;GAKG;AACI,KAAK,UAAU,2BAA2B,CAC/C,cAAmB;IAEnB,MAAM,GAAG,GAAG,IAAI,eAAK,EAAE,CAAC;IACxB,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,GAAW,EAAE,EAAE;QAClD,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,IAAA,sCAAmB,EAAC;QAClC,IAAI,EAAE,MAAM,GAAG,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAC/C,QAAQ,EAAE,4BAA4B;QACtC,QAAQ,EAAE,iBAAiB;KAC5B,CAAC,CAAA;IAEF,OAAO,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