@esri/solution-deployer 6.5.0-next.20260120 → 6.5.0-next.20260122

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.
@@ -232,3 +232,22 @@ export declare function _createItemFromTemplateWhenReady(template: common.IItemT
232
232
  */
233
233
  export declare function _estimateDeploymentCost(templates: common.IItemTemplate[]): number;
234
234
  export declare function _getGroupUpdates(template: common.IItemTemplate, authentication: common.UserSession, templateDictionary: any): Array<Promise<any>>;
235
+ /**
236
+ * Gets the deployed item ids from the template dictionary
237
+ *
238
+ * @param templates Templates to extract ids
239
+ * @param templateDictionary Hash of facts: using the templates id as a lookup into this hash
240
+ * @returns An array of strings that represent item ids
241
+ * @private
242
+ */
243
+ export declare function _getItemIdsFromTemplateDictionary(templates: common.IItemTemplate[], templateDictionary: any): Array<string>;
244
+ /**
245
+ * Finds items older than timestamp that might signify item reuse
246
+ *
247
+ * @param checkTime Current time stamp
248
+ * @param resultSets Existing items in the org
249
+ * @param controlList List of items that the Solution will deploy
250
+ * @returns An array of items left than checkTime
251
+ * @private
252
+ */
253
+ export declare function _findExistingItemsCreatedPrevious(checkTime: number, resultSets: Array<any>, controlList: Array<string>): Array<string>;
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports._getGroupUpdates = exports._estimateDeploymentCost = exports._createItemFromTemplateWhenReady = exports._findExistingItem = exports._findExistingItemByKeyword = exports._updateTemplateDictionaryById = exports._handleExistingItems = exports._updateTemplateDictionaryForError = exports._setFields = exports._updateTemplateDictionary = exports._setTypekeywordForExisting = exports._useExistingItems = exports._reuseDeployedItems = exports._getViews = exports._getViewHash = exports._updateViewTemplates = exports._evaluateSharedViewSources = exports._flagPatchItemsForPostProcessing = exports._evaluateWebMapResources = exports.deploySolutionItems = void 0;
18
+ exports._findExistingItemsCreatedPrevious = exports._getItemIdsFromTemplateDictionary = exports._getGroupUpdates = exports._estimateDeploymentCost = exports._createItemFromTemplateWhenReady = exports._findExistingItem = exports._findExistingItemByKeyword = exports._updateTemplateDictionaryById = exports._handleExistingItems = exports._updateTemplateDictionaryForError = exports._setFields = exports._updateTemplateDictionary = exports._setTypekeywordForExisting = exports._useExistingItems = exports._reuseDeployedItems = exports._getViews = exports._getViewHash = exports._updateViewTemplates = exports._evaluateSharedViewSources = exports._flagPatchItemsForPostProcessing = exports._evaluateWebMapResources = exports.deploySolutionItems = void 0;
19
19
  const tslib_1 = require("tslib");
20
20
  /**
21
21
  * Manages deployment of items via the REST API.
@@ -41,6 +41,8 @@ const UNSUPPORTED = null;
41
41
  */
42
42
  function deploySolutionItems(portalSharingUrl, storageItemId, templates, storageAuthentication, templateDictionary, deployedSolutionId, destinationAuthentication, options) {
43
43
  return new Promise((resolve, reject) => {
44
+ const timeStamp = Date.now();
45
+ let cancelExecuting = false;
44
46
  /**
45
47
  * function to abort the current process. Will delete solution and reject the promise
46
48
  *
@@ -48,15 +50,28 @@ function deploySolutionItems(portalSharingUrl, storageItemId, templates, storage
48
50
  */
49
51
  function checkCancelled() {
50
52
  if (options && options.abortController) {
51
- if (options.abortController.signal.aborted) {
52
- // Delete created items
53
+ if (!cancelExecuting && options.abortController.signal.aborted) {
54
+ cancelExecuting = true;
55
+ const deployedItemIdsList = _getItemIdsFromTemplateDictionary(templates, templateDictionary);
56
+ const existingItems = _findExistingItemByKeyword(templates, templateDictionary, destinationAuthentication);
53
57
  const progressOptions = {
54
58
  consoleProgress: true,
55
59
  };
56
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
57
- common
58
- .deleteSolutionByComponents(deployedSolutionId, deployedItemIds, templates, templateDictionary, destinationAuthentication, progressOptions)
59
- .then(() => reject(common.failWithIds(failedTemplateItemIds)));
60
+ Promise.all(existingItems.existingItemsDefs).then((defs) => {
61
+ const FilteredListToDelete = _findExistingItemsCreatedPrevious(timeStamp, defs, deployedItemIdsList);
62
+ common
63
+ .deleteSolutionByComponents(deployedSolutionId, FilteredListToDelete, templates, templateDictionary, destinationAuthentication, progressOptions)
64
+ .then(async () => {
65
+ //because of possible deletion lag and agol query, try to delete folder again if it was still around.
66
+ try {
67
+ await common.deleteSolutionFolder(FilteredListToDelete, templateDictionary.folderId, destinationAuthentication);
68
+ }
69
+ catch (err) {
70
+ console.warn("deleteSolutionFolder failed (ignored during cleanup):", err);
71
+ }
72
+ reject(common.failWithIds(failedTemplateItemIds));
73
+ });
74
+ });
60
75
  }
61
76
  }
62
77
  }
@@ -932,3 +947,44 @@ function _getGroupUpdates(template, authentication, templateDictionary) {
932
947
  });
933
948
  }
934
949
  exports._getGroupUpdates = _getGroupUpdates;
950
+ /**
951
+ * Gets the deployed item ids from the template dictionary
952
+ *
953
+ * @param templates Templates to extract ids
954
+ * @param templateDictionary Hash of facts: using the templates id as a lookup into this hash
955
+ * @returns An array of strings that represent item ids
956
+ * @private
957
+ */
958
+ function _getItemIdsFromTemplateDictionary(templates, templateDictionary) {
959
+ return templates
960
+ .map((template) => {
961
+ return template.itemId;
962
+ })
963
+ .map((template) => {
964
+ return templateDictionary[template].itemId;
965
+ });
966
+ }
967
+ exports._getItemIdsFromTemplateDictionary = _getItemIdsFromTemplateDictionary;
968
+ /**
969
+ * Finds items older than timestamp that might signify item reuse
970
+ *
971
+ * @param checkTime Current time stamp
972
+ * @param resultSets Existing items in the org
973
+ * @param controlList List of items that the Solution will deploy
974
+ * @returns An array of items left than checkTime
975
+ * @private
976
+ */
977
+ function _findExistingItemsCreatedPrevious(checkTime, resultSets, controlList) {
978
+ const olderItems = [];
979
+ resultSets.filter((set) => {
980
+ set.results.forEach((result) => {
981
+ if (result.created < checkTime) {
982
+ olderItems.push(result.id);
983
+ }
984
+ });
985
+ });
986
+ const olderItemsSet = new Set(olderItems);
987
+ controlList = controlList.filter((item) => !olderItemsSet.has(item));
988
+ return controlList.filter((item) => item !== undefined);
989
+ }
990
+ exports._findExistingItemsCreatedPrevious = _findExistingItemsCreatedPrevious;
@@ -232,3 +232,22 @@ export declare function _createItemFromTemplateWhenReady(template: common.IItemT
232
232
  */
233
233
  export declare function _estimateDeploymentCost(templates: common.IItemTemplate[]): number;
234
234
  export declare function _getGroupUpdates(template: common.IItemTemplate, authentication: common.UserSession, templateDictionary: any): Array<Promise<any>>;
235
+ /**
236
+ * Gets the deployed item ids from the template dictionary
237
+ *
238
+ * @param templates Templates to extract ids
239
+ * @param templateDictionary Hash of facts: using the templates id as a lookup into this hash
240
+ * @returns An array of strings that represent item ids
241
+ * @private
242
+ */
243
+ export declare function _getItemIdsFromTemplateDictionary(templates: common.IItemTemplate[], templateDictionary: any): Array<string>;
244
+ /**
245
+ * Finds items older than timestamp that might signify item reuse
246
+ *
247
+ * @param checkTime Current time stamp
248
+ * @param resultSets Existing items in the org
249
+ * @param controlList List of items that the Solution will deploy
250
+ * @returns An array of items left than checkTime
251
+ * @private
252
+ */
253
+ export declare function _findExistingItemsCreatedPrevious(checkTime: number, resultSets: Array<any>, controlList: Array<string>): Array<string>;
@@ -37,6 +37,8 @@ const UNSUPPORTED = null;
37
37
  */
38
38
  export function deploySolutionItems(portalSharingUrl, storageItemId, templates, storageAuthentication, templateDictionary, deployedSolutionId, destinationAuthentication, options) {
39
39
  return new Promise((resolve, reject) => {
40
+ const timeStamp = Date.now();
41
+ let cancelExecuting = false;
40
42
  /**
41
43
  * function to abort the current process. Will delete solution and reject the promise
42
44
  *
@@ -44,15 +46,28 @@ export function deploySolutionItems(portalSharingUrl, storageItemId, templates,
44
46
  */
45
47
  function checkCancelled() {
46
48
  if (options && options.abortController) {
47
- if (options.abortController.signal.aborted) {
48
- // Delete created items
49
+ if (!cancelExecuting && options.abortController.signal.aborted) {
50
+ cancelExecuting = true;
51
+ const deployedItemIdsList = _getItemIdsFromTemplateDictionary(templates, templateDictionary);
52
+ const existingItems = _findExistingItemByKeyword(templates, templateDictionary, destinationAuthentication);
49
53
  const progressOptions = {
50
54
  consoleProgress: true,
51
55
  };
52
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
53
- common
54
- .deleteSolutionByComponents(deployedSolutionId, deployedItemIds, templates, templateDictionary, destinationAuthentication, progressOptions)
55
- .then(() => reject(common.failWithIds(failedTemplateItemIds)));
56
+ Promise.all(existingItems.existingItemsDefs).then((defs) => {
57
+ const FilteredListToDelete = _findExistingItemsCreatedPrevious(timeStamp, defs, deployedItemIdsList);
58
+ common
59
+ .deleteSolutionByComponents(deployedSolutionId, FilteredListToDelete, templates, templateDictionary, destinationAuthentication, progressOptions)
60
+ .then(async () => {
61
+ //because of possible deletion lag and agol query, try to delete folder again if it was still around.
62
+ try {
63
+ await common.deleteSolutionFolder(FilteredListToDelete, templateDictionary.folderId, destinationAuthentication);
64
+ }
65
+ catch (err) {
66
+ console.warn("deleteSolutionFolder failed (ignored during cleanup):", err);
67
+ }
68
+ reject(common.failWithIds(failedTemplateItemIds));
69
+ });
70
+ });
56
71
  }
57
72
  }
58
73
  }
@@ -908,3 +923,42 @@ export function _getGroupUpdates(template, authentication, templateDictionary) {
908
923
  return common.shareItem(templateDictionary[sourceGroupId].itemId, template.itemId, authentication, common.isTrackingViewTemplate(template) ? templateDictionary.locationTracking.owner : undefined);
909
924
  });
910
925
  }
926
+ /**
927
+ * Gets the deployed item ids from the template dictionary
928
+ *
929
+ * @param templates Templates to extract ids
930
+ * @param templateDictionary Hash of facts: using the templates id as a lookup into this hash
931
+ * @returns An array of strings that represent item ids
932
+ * @private
933
+ */
934
+ export function _getItemIdsFromTemplateDictionary(templates, templateDictionary) {
935
+ return templates
936
+ .map((template) => {
937
+ return template.itemId;
938
+ })
939
+ .map((template) => {
940
+ return templateDictionary[template].itemId;
941
+ });
942
+ }
943
+ /**
944
+ * Finds items older than timestamp that might signify item reuse
945
+ *
946
+ * @param checkTime Current time stamp
947
+ * @param resultSets Existing items in the org
948
+ * @param controlList List of items that the Solution will deploy
949
+ * @returns An array of items left than checkTime
950
+ * @private
951
+ */
952
+ export function _findExistingItemsCreatedPrevious(checkTime, resultSets, controlList) {
953
+ const olderItems = [];
954
+ resultSets.filter((set) => {
955
+ set.results.forEach((result) => {
956
+ if (result.created < checkTime) {
957
+ olderItems.push(result.id);
958
+ }
959
+ });
960
+ });
961
+ const olderItemsSet = new Set(olderItems);
962
+ controlList = controlList.filter((item) => !olderItemsSet.has(item));
963
+ return controlList.filter((item) => item !== undefined);
964
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esri/solution-deployer",
3
- "version": "6.5.0-next.20260120",
3
+ "version": "6.5.0-next.20260122",
4
4
  "description": "Manages the deployment of a Solution for @esri/solution.js.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -24,18 +24,18 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@esri/hub-common": "^17.0.2",
27
- "@esri/solution-common": "^6.5.0-next.20260120",
28
- "@esri/solution-feature-layer": "^6.5.0-next.20260120",
29
- "@esri/solution-file": "^6.5.0-next.20260120",
30
- "@esri/solution-form": "^6.5.0-next.20260120",
31
- "@esri/solution-group": "^6.5.0-next.20260120",
32
- "@esri/solution-hub-types": "^6.5.0-next.20260120",
33
- "@esri/solution-simple-types": "^6.5.0-next.20260120",
34
- "@esri/solution-storymap": "^6.5.0-next.20260120",
35
- "@esri/solution-velocity": "^6.5.0-next.20260120",
36
- "@esri/solution-web-experience": "^6.5.0-next.20260120",
37
- "@esri/solution-web-tool": "^6.5.0-next.20260120",
38
- "@esri/solution-workflow": "^6.5.0-next.20260120",
27
+ "@esri/solution-common": "^6.5.0-next.20260122",
28
+ "@esri/solution-feature-layer": "^6.5.0-next.20260122",
29
+ "@esri/solution-file": "^6.5.0-next.20260122",
30
+ "@esri/solution-form": "^6.5.0-next.20260122",
31
+ "@esri/solution-group": "^6.5.0-next.20260122",
32
+ "@esri/solution-hub-types": "^6.5.0-next.20260122",
33
+ "@esri/solution-simple-types": "^6.5.0-next.20260122",
34
+ "@esri/solution-storymap": "^6.5.0-next.20260122",
35
+ "@esri/solution-velocity": "^6.5.0-next.20260122",
36
+ "@esri/solution-web-experience": "^6.5.0-next.20260122",
37
+ "@esri/solution-web-tool": "^6.5.0-next.20260122",
38
+ "@esri/solution-workflow": "^6.5.0-next.20260122",
39
39
  "tslib": "1.14.1"
40
40
  },
41
41
  "scripts": {
@@ -90,5 +90,5 @@
90
90
  "esri",
91
91
  "ES6"
92
92
  ],
93
- "gitHead": "63a939e1972eec7b4fb1a434aaa12646a45dffe0"
93
+ "gitHead": "77c94253272430ecb85f1cc53019530adcddc932"
94
94
  }