@esri/solution-simple-types 6.4.0-next.20250806 → 6.4.0-next.20250808

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.
@@ -14,4 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import * as common from "@esri/solution-common";
17
- export declare function createItemFromTemplate(template: common.IItemTemplate, templateDictionary: any, destinationAuthentication: common.UserSession, itemProgressCallback: common.IItemProgressCallback): Promise<common.ICreateItemFromTemplateResponse>;
17
+ export declare function createItemFromTemplate(template: common.IItemTemplate, templateDictionary: any, destinationAuthentication: common.UserSession, itemProgressCallback: common.IItemProgressCallback, abortController?: AbortController): Promise<common.ICreateItemFromTemplateResponse>;
@@ -21,8 +21,21 @@ const common = tslib_1.__importStar(require("@esri/solution-common"));
21
21
  const notebook = tslib_1.__importStar(require("../notebook"));
22
22
  const webmappingapplication = tslib_1.__importStar(require("../webmappingapplication"));
23
23
  const workforce = tslib_1.__importStar(require("../workforce"));
24
- function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
25
- return new Promise((resolve) => {
24
+ function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback, abortController) {
25
+ return new Promise((resolve, reject) => {
26
+ /**
27
+ * function to abort the current process. Will delete solution and reject the promise
28
+ *
29
+ * @return a reject on the parent promise.
30
+ */
31
+ function checkCancelled() {
32
+ if (abortController) {
33
+ if (abortController.signal.aborted) {
34
+ reject(new Error(`Operation was cancelled`));
35
+ }
36
+ }
37
+ }
38
+ checkCancelled();
26
39
  // Interrupt process if progress callback returns `false`
27
40
  if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Started, 0)) {
28
41
  itemProgressCallback(template.itemId, common.EItemProgressStatus.Ignored, 0);
@@ -53,6 +66,7 @@ function createItemFromTemplate(template, templateDictionary, destinationAuthent
53
66
  common
54
67
  .createItemWithData(newItemTemplate.item, newItemTemplate.data, destinationAuthentication, templateDictionary.folderId)
55
68
  .then((createResponse) => {
69
+ checkCancelled();
56
70
  // Interrupt process if progress callback returns `false`
57
71
  if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.id)) {
58
72
  itemProgressCallback(template.itemId, common.EItemProgressStatus.Cancelled, 0);
@@ -74,6 +88,7 @@ function createItemFromTemplate(template, templateDictionary, destinationAuthent
74
88
  // Update the template again now that we have the new item id
75
89
  const originalURL = newItemTemplate.item.url;
76
90
  newItemTemplate = common.replaceInTemplate(newItemTemplate, templateDictionary);
91
+ checkCancelled();
77
92
  // Update relationships
78
93
  let relationshipsDef = Promise.resolve([]);
79
94
  if (newItemTemplate.relatedItems) {
@@ -82,6 +97,7 @@ function createItemFromTemplate(template, templateDictionary, destinationAuthent
82
97
  // Add the relationships
83
98
  relationshipsDef = common.addForwardItemRelationships(newItemTemplate.itemId, updatedRelatedItems, destinationAuthentication);
84
99
  }
100
+ checkCancelled();
85
101
  // Check for extra processing for web mapping application et al.
86
102
  let customProcDef;
87
103
  if (template.type === "Web Mapping Application" &&
@@ -105,6 +121,7 @@ function createItemFromTemplate(template, templateDictionary, destinationAuthent
105
121
  customProcDef = notebook.fineTuneCreatedItem(template, newItemTemplate, templateDictionary, destinationAuthentication);
106
122
  }
107
123
  else if (originalURL !== newItemTemplate.item.url) {
124
+ checkCancelled();
108
125
  // For web mapping applications that are not Web AppBuilder apps
109
126
  customProcDef = new Promise((resolve2, reject2) => {
110
127
  common
@@ -115,6 +132,7 @@ function createItemFromTemplate(template, templateDictionary, destinationAuthent
115
132
  else {
116
133
  customProcDef = Promise.resolve(null);
117
134
  }
135
+ checkCancelled();
118
136
  Promise.all([relationshipsDef, customProcDef]).then(() => {
119
137
  // Interrupt process if progress callback returns `false`
120
138
  if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor / 2, createResponse.id)) {
@@ -32,7 +32,7 @@ export declare function convertItemToTemplate(itemInfo: any, destAuthentication:
32
32
  * @param destinationAuthentication
33
33
  * @param itemProgressCallback
34
34
  */
35
- export declare function createItemFromTemplate(template: IItemTemplate, templateDictionary: any, destinationAuthentication: UserSession, itemProgressCallback: IItemProgressCallback): Promise<ICreateItemFromTemplateResponse>;
35
+ export declare function createItemFromTemplate(template: IItemTemplate, templateDictionary: any, destinationAuthentication: UserSession, itemProgressCallback: IItemProgressCallback, abortController?: AbortController): Promise<ICreateItemFromTemplateResponse>;
36
36
  /**
37
37
  * Templatizes field references within specific template types.
38
38
  * Currently only handles web mapping applications
@@ -49,7 +49,10 @@ exports.convertItemToTemplate = convertItemToTemplate;
49
49
  * @param destinationAuthentication
50
50
  * @param itemProgressCallback
51
51
  */
52
- function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
52
+ function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback, abortController) {
53
+ if (abortController) {
54
+ return simpleTypeHelpers.createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback, abortController);
55
+ }
53
56
  return simpleTypeHelpers.createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback);
54
57
  }
55
58
  exports.createItemFromTemplate = createItemFromTemplate;
@@ -14,4 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import * as common from "@esri/solution-common";
17
- export declare function createItemFromTemplate(template: common.IItemTemplate, templateDictionary: any, destinationAuthentication: common.UserSession, itemProgressCallback: common.IItemProgressCallback): Promise<common.ICreateItemFromTemplateResponse>;
17
+ export declare function createItemFromTemplate(template: common.IItemTemplate, templateDictionary: any, destinationAuthentication: common.UserSession, itemProgressCallback: common.IItemProgressCallback, abortController?: AbortController): Promise<common.ICreateItemFromTemplateResponse>;
@@ -17,8 +17,21 @@ import * as common from "@esri/solution-common";
17
17
  import * as notebook from "../notebook";
18
18
  import * as webmappingapplication from "../webmappingapplication";
19
19
  import * as workforce from "../workforce";
20
- export function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
21
- return new Promise((resolve) => {
20
+ export function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback, abortController) {
21
+ return new Promise((resolve, reject) => {
22
+ /**
23
+ * function to abort the current process. Will delete solution and reject the promise
24
+ *
25
+ * @return a reject on the parent promise.
26
+ */
27
+ function checkCancelled() {
28
+ if (abortController) {
29
+ if (abortController.signal.aborted) {
30
+ reject(new Error(`Operation was cancelled`));
31
+ }
32
+ }
33
+ }
34
+ checkCancelled();
22
35
  // Interrupt process if progress callback returns `false`
23
36
  if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Started, 0)) {
24
37
  itemProgressCallback(template.itemId, common.EItemProgressStatus.Ignored, 0);
@@ -49,6 +62,7 @@ export function createItemFromTemplate(template, templateDictionary, destination
49
62
  common
50
63
  .createItemWithData(newItemTemplate.item, newItemTemplate.data, destinationAuthentication, templateDictionary.folderId)
51
64
  .then((createResponse) => {
65
+ checkCancelled();
52
66
  // Interrupt process if progress callback returns `false`
53
67
  if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.id)) {
54
68
  itemProgressCallback(template.itemId, common.EItemProgressStatus.Cancelled, 0);
@@ -70,6 +84,7 @@ export function createItemFromTemplate(template, templateDictionary, destination
70
84
  // Update the template again now that we have the new item id
71
85
  const originalURL = newItemTemplate.item.url;
72
86
  newItemTemplate = common.replaceInTemplate(newItemTemplate, templateDictionary);
87
+ checkCancelled();
73
88
  // Update relationships
74
89
  let relationshipsDef = Promise.resolve([]);
75
90
  if (newItemTemplate.relatedItems) {
@@ -78,6 +93,7 @@ export function createItemFromTemplate(template, templateDictionary, destination
78
93
  // Add the relationships
79
94
  relationshipsDef = common.addForwardItemRelationships(newItemTemplate.itemId, updatedRelatedItems, destinationAuthentication);
80
95
  }
96
+ checkCancelled();
81
97
  // Check for extra processing for web mapping application et al.
82
98
  let customProcDef;
83
99
  if (template.type === "Web Mapping Application" &&
@@ -101,6 +117,7 @@ export function createItemFromTemplate(template, templateDictionary, destination
101
117
  customProcDef = notebook.fineTuneCreatedItem(template, newItemTemplate, templateDictionary, destinationAuthentication);
102
118
  }
103
119
  else if (originalURL !== newItemTemplate.item.url) {
120
+ checkCancelled();
104
121
  // For web mapping applications that are not Web AppBuilder apps
105
122
  customProcDef = new Promise((resolve2, reject2) => {
106
123
  common
@@ -111,6 +128,7 @@ export function createItemFromTemplate(template, templateDictionary, destination
111
128
  else {
112
129
  customProcDef = Promise.resolve(null);
113
130
  }
131
+ checkCancelled();
114
132
  Promise.all([relationshipsDef, customProcDef]).then(() => {
115
133
  // Interrupt process if progress callback returns `false`
116
134
  if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor / 2, createResponse.id)) {
@@ -32,7 +32,7 @@ export declare function convertItemToTemplate(itemInfo: any, destAuthentication:
32
32
  * @param destinationAuthentication
33
33
  * @param itemProgressCallback
34
34
  */
35
- export declare function createItemFromTemplate(template: IItemTemplate, templateDictionary: any, destinationAuthentication: UserSession, itemProgressCallback: IItemProgressCallback): Promise<ICreateItemFromTemplateResponse>;
35
+ export declare function createItemFromTemplate(template: IItemTemplate, templateDictionary: any, destinationAuthentication: UserSession, itemProgressCallback: IItemProgressCallback, abortController?: AbortController): Promise<ICreateItemFromTemplateResponse>;
36
36
  /**
37
37
  * Templatizes field references within specific template types.
38
38
  * Currently only handles web mapping applications
@@ -44,7 +44,10 @@ export function convertItemToTemplate(itemInfo, destAuthentication, srcAuthentic
44
44
  * @param destinationAuthentication
45
45
  * @param itemProgressCallback
46
46
  */
47
- export function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
47
+ export function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback, abortController) {
48
+ if (abortController) {
49
+ return simpleTypeHelpers.createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback, abortController);
50
+ }
48
51
  return simpleTypeHelpers.createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback);
49
52
  }
50
53
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esri/solution-simple-types",
3
- "version": "6.4.0-next.20250806",
3
+ "version": "6.4.0-next.20250808",
4
4
  "description": "Manages the creation and deployment of simple item types for @esri/solution.js.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -22,7 +22,7 @@
22
22
  "npm-check-updates": "^17.1.0"
23
23
  },
24
24
  "dependencies": {
25
- "@esri/solution-common": "^6.4.0-next.20250806",
25
+ "@esri/solution-common": "^6.4.0-next.20250808",
26
26
  "tslib": "1.14.1"
27
27
  },
28
28
  "scripts": {
@@ -77,5 +77,5 @@
77
77
  "esri",
78
78
  "ES6"
79
79
  ],
80
- "gitHead": "231a47edad8afb71cb1d33e6a1b83679ec428193"
80
+ "gitHead": "fc677f0f21a1a090d65743f08073eeed47e22ef0"
81
81
  }