@esri/solution-group 1.1.2 → 1.2.0
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.
- package/dist/esm/group.d.ts +3 -2
- package/dist/esm/group.js +74 -32
- package/dist/esm/group.js.map +1 -1
- package/dist/node/group.d.ts +3 -2
- package/dist/node/group.js +75 -33
- package/dist/node/group.js.map +1 -1
- package/dist/node/index.js +1 -1
- package/dist/umd/group.d.ts +3 -2
- package/dist/umd/group.umd.js +199 -159
- package/dist/umd/group.umd.js.map +1 -1
- package/dist/umd/group.umd.min.js +3 -3
- package/dist/umd/group.umd.min.js.map +1 -1
- package/package.json +24 -24
package/dist/esm/group.d.ts
CHANGED
|
@@ -24,8 +24,9 @@ import * as common from "@esri/solution-common";
|
|
|
24
24
|
*
|
|
25
25
|
* @param solutionItemId The solution to contain the template
|
|
26
26
|
* @param itemInfo Info about the item
|
|
27
|
-
* @param
|
|
27
|
+
* @param destAuthentication Credentials for requests to the destination organization
|
|
28
|
+
* @param srcAuthentication Credentials for requests to source items
|
|
28
29
|
* @return A promise that will resolve when the template has been created
|
|
29
30
|
*/
|
|
30
|
-
export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any,
|
|
31
|
+
export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, destAuthentication: common.UserSession, srcAuthentication: common.UserSession): Promise<common.IItemTemplate>;
|
|
31
32
|
export declare function createItemFromTemplate(template: common.IItemTemplate, templateDictionary: any, destinationAuthentication: common.UserSession, itemProgressCallback: common.IItemProgressCallback): Promise<common.ICreateItemFromTemplateResponse>;
|
package/dist/esm/group.js
CHANGED
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { __assign } from "tslib";
|
|
17
16
|
/**
|
|
18
17
|
* Manages the creation and deployment of groups.
|
|
19
18
|
*
|
|
@@ -26,29 +25,33 @@ import * as common from "@esri/solution-common";
|
|
|
26
25
|
*
|
|
27
26
|
* @param solutionItemId The solution to contain the template
|
|
28
27
|
* @param itemInfo Info about the item
|
|
29
|
-
* @param
|
|
28
|
+
* @param destAuthentication Credentials for requests to the destination organization
|
|
29
|
+
* @param srcAuthentication Credentials for requests to source items
|
|
30
30
|
* @return A promise that will resolve when the template has been created
|
|
31
31
|
*/
|
|
32
|
-
export function convertItemToTemplate(solutionItemId, itemInfo,
|
|
33
|
-
return new Promise(
|
|
32
|
+
export function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication) {
|
|
33
|
+
return new Promise(resolve => {
|
|
34
34
|
// Init template
|
|
35
|
-
|
|
35
|
+
const itemTemplate = common.createInitializedGroupTemplate(itemInfo);
|
|
36
36
|
// Templatize item info property values
|
|
37
37
|
itemTemplate.item.id = common.templatizeTerm(itemTemplate.item.id, itemTemplate.item.id, ".itemId");
|
|
38
38
|
// Get the group's items--its dependencies
|
|
39
|
-
common.getGroupContents(itemInfo.id,
|
|
39
|
+
common.getGroupContents(itemInfo.id, srcAuthentication).then(groupContents => {
|
|
40
40
|
itemTemplate.type = "Group";
|
|
41
41
|
itemTemplate.dependencies = groupContents;
|
|
42
|
-
common.getGroupBase(itemInfo.id,
|
|
42
|
+
common.getGroupBase(itemInfo.id, srcAuthentication).then(groupResponse => {
|
|
43
43
|
groupResponse.id = itemTemplate.item.id;
|
|
44
|
-
itemTemplate.item =
|
|
44
|
+
itemTemplate.item = {
|
|
45
|
+
...groupResponse,
|
|
46
|
+
type: "Group"
|
|
47
|
+
};
|
|
45
48
|
resolve(itemTemplate);
|
|
46
|
-
},
|
|
47
|
-
},
|
|
49
|
+
}, () => resolve(itemTemplate));
|
|
50
|
+
}, () => resolve(itemTemplate));
|
|
48
51
|
});
|
|
49
52
|
}
|
|
50
53
|
export function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
|
|
51
|
-
return new Promise(
|
|
54
|
+
return new Promise(resolve => {
|
|
52
55
|
// Interrupt process if progress callback returns `false`
|
|
53
56
|
if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Started, 0)) {
|
|
54
57
|
itemProgressCallback(template.itemId, common.EItemProgressStatus.Ignored, 0);
|
|
@@ -56,12 +59,12 @@ export function createItemFromTemplate(template, templateDictionary, destination
|
|
|
56
59
|
return;
|
|
57
60
|
}
|
|
58
61
|
// Replace the templatized symbols in a copy of the template
|
|
59
|
-
|
|
62
|
+
let newItemTemplate = common.cloneObject(template);
|
|
60
63
|
newItemTemplate = common.replaceInTemplate(newItemTemplate, templateDictionary);
|
|
61
64
|
// Need to manually reset thumbnail because adlib in replaceInTemplate breaks it
|
|
62
65
|
newItemTemplate.item.thumbnail = template.item.thumbnail;
|
|
63
66
|
// Set up properties needed to create group
|
|
64
|
-
|
|
67
|
+
const newGroup = {
|
|
65
68
|
title: newItemTemplate.item.title || "",
|
|
66
69
|
access: "private",
|
|
67
70
|
owner: newItemTemplate.item.owner,
|
|
@@ -75,8 +78,8 @@ export function createItemFromTemplate(template, templateDictionary, destination
|
|
|
75
78
|
// * Manage Right of Way Activities 1
|
|
76
79
|
// * Manage Right of Way Activities 2
|
|
77
80
|
common
|
|
78
|
-
.createUniqueGroup(newGroup.title, newGroup, templateDictionary, destinationAuthentication)
|
|
79
|
-
.then(
|
|
81
|
+
.createUniqueGroup(newGroup.title, newGroup, templateDictionary, destinationAuthentication, common.isTrackingViewGroup(newItemTemplate) ? templateDictionary.locationTracking.owner : undefined)
|
|
82
|
+
.then((createResponse) => {
|
|
80
83
|
if (createResponse.success) {
|
|
81
84
|
// Interrupt process if progress callback returns `false`
|
|
82
85
|
if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.group.id)) {
|
|
@@ -84,11 +87,7 @@ export function createItemFromTemplate(template, templateDictionary, destination
|
|
|
84
87
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
85
88
|
common
|
|
86
89
|
.removeGroup(createResponse.group.id, destinationAuthentication)
|
|
87
|
-
.then(
|
|
88
|
-
return resolve(common.generateEmptyCreationResponse(template.type));
|
|
89
|
-
}, function () {
|
|
90
|
-
return resolve(common.generateEmptyCreationResponse(template.type));
|
|
91
|
-
});
|
|
90
|
+
.then(() => resolve(common.generateEmptyCreationResponse(template.type)), () => resolve(common.generateEmptyCreationResponse(template.type)));
|
|
92
91
|
}
|
|
93
92
|
else {
|
|
94
93
|
newItemTemplate.itemId = createResponse.group.id;
|
|
@@ -106,19 +105,62 @@ export function createItemFromTemplate(template, templateDictionary, destination
|
|
|
106
105
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
107
106
|
common
|
|
108
107
|
.removeGroup(createResponse.group.id, destinationAuthentication)
|
|
109
|
-
.then(
|
|
110
|
-
return resolve(common.generateEmptyCreationResponse(template.type));
|
|
111
|
-
}, function () {
|
|
112
|
-
return resolve(common.generateEmptyCreationResponse(template.type));
|
|
113
|
-
});
|
|
108
|
+
.then(() => resolve(common.generateEmptyCreationResponse(template.type)), () => resolve(common.generateEmptyCreationResponse(template.type)));
|
|
114
109
|
}
|
|
115
110
|
else {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
111
|
+
if (common.isTrackingViewGroup(newItemTemplate)) {
|
|
112
|
+
const owner = templateDictionary.locationTracking.owner;
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
114
|
+
common.reassignGroup(createResponse.group.id, owner, destinationAuthentication).then(assignResults => {
|
|
115
|
+
if (assignResults.success) {
|
|
116
|
+
if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.group.id)) {
|
|
117
|
+
itemProgressCallback(template.itemId, common.EItemProgressStatus.Cancelled, 0);
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
119
|
+
common
|
|
120
|
+
.removeGroup(createResponse.group.id, destinationAuthentication)
|
|
121
|
+
.then(() => resolve(common.generateEmptyCreationResponse(template.type)), () => resolve(common.generateEmptyCreationResponse(template.type)));
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
125
|
+
common.removeUsers(createResponse.group.id, [destinationAuthentication.username], destinationAuthentication).then(removeResults => {
|
|
126
|
+
if (Array.isArray(removeResults.notRemoved) && removeResults.notRemoved.length === 0) {
|
|
127
|
+
if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.group.id)) {
|
|
128
|
+
itemProgressCallback(template.itemId, common.EItemProgressStatus.Cancelled, 0);
|
|
129
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
130
|
+
common
|
|
131
|
+
.removeGroup(createResponse.group.id, destinationAuthentication)
|
|
132
|
+
.then(() => resolve(common.generateEmptyCreationResponse(template.type)), () => resolve(common.generateEmptyCreationResponse(template.type)));
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
resolve({
|
|
136
|
+
item: newItemTemplate,
|
|
137
|
+
id: createResponse.group.id,
|
|
138
|
+
type: newItemTemplate.type,
|
|
139
|
+
postProcess: false
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
|
|
145
|
+
resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
|
|
152
|
+
resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
resolve({
|
|
158
|
+
item: newItemTemplate,
|
|
159
|
+
id: createResponse.group.id,
|
|
160
|
+
type: newItemTemplate.type,
|
|
161
|
+
postProcess: false
|
|
162
|
+
});
|
|
163
|
+
}
|
|
122
164
|
}
|
|
123
165
|
}
|
|
124
166
|
}
|
|
@@ -126,7 +168,7 @@ export function createItemFromTemplate(template, templateDictionary, destination
|
|
|
126
168
|
itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
|
|
127
169
|
resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item
|
|
128
170
|
}
|
|
129
|
-
},
|
|
171
|
+
}, () => {
|
|
130
172
|
itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
|
|
131
173
|
resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item
|
|
132
174
|
});
|
package/dist/esm/group.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group.js","sourceRoot":"","sources":["../../src/group.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG
|
|
1
|
+
{"version":3,"file":"group.js","sourceRoot":"","sources":["../../src/group.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAEhD,wHAAwH;AAExH;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CACnC,cAAsB,EACtB,QAAa,EACb,kBAAsC,EACtC,iBAAqC;IAErC,OAAO,IAAI,OAAO,CAAuB,OAAO,CAAC,EAAE;QACjD,gBAAgB;QAChB,MAAM,YAAY,GAAyB,MAAM,CAAC,8BAA8B,CAC9E,QAAQ,CACT,CAAC;QAEF,uCAAuC;QACvC,YAAY,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,cAAc,CAC1C,YAAY,CAAC,IAAI,CAAC,EAAE,EACpB,YAAY,CAAC,IAAI,CAAC,EAAE,EACpB,SAAS,CACV,CAAC;QAEF,0CAA0C;QAC1C,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAA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,CAAC;gCACN,IAAI,EAAE,eAAe;gCACrB,EAAE,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE;gCAC3B,IAAI,EAAE,eAAe,CAAC,IAAI;gCAC1B,WAAW,EAAE,KAAK;6BACnB,CAAC,CAAC;yBACJ;qBACF;iBACF;aACF;iBAAM;gBACL,oBAAoB,CAClB,QAAQ,CAAC,MAAM,EACf,MAAM,CAAC,mBAAmB,CAAC,MAAM,EACjC,CAAC,CACF,CAAC;gBACF,OAAO,CAAC,MAAM,CAAC,6BAA6B,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,uBAAuB;aACtF;QACH,CAAC,EACD,GAAG,EAAE;YACH,oBAAoB,CAClB,QAAQ,CAAC,MAAM,EACf,MAAM,CAAC,mBAAmB,CAAC,MAAM,EACjC,CAAC,CACF,CAAC;YACF,OAAO,CAAC,MAAM,CAAC,6BAA6B,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,uBAAuB;QACvF,CAAC,CACF,CAAC;IACN,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/node/group.d.ts
CHANGED
|
@@ -24,8 +24,9 @@ import * as common from "@esri/solution-common";
|
|
|
24
24
|
*
|
|
25
25
|
* @param solutionItemId The solution to contain the template
|
|
26
26
|
* @param itemInfo Info about the item
|
|
27
|
-
* @param
|
|
27
|
+
* @param destAuthentication Credentials for requests to the destination organization
|
|
28
|
+
* @param srcAuthentication Credentials for requests to source items
|
|
28
29
|
* @return A promise that will resolve when the template has been created
|
|
29
30
|
*/
|
|
30
|
-
export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any,
|
|
31
|
+
export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, destAuthentication: common.UserSession, srcAuthentication: common.UserSession): Promise<common.IItemTemplate>;
|
|
31
32
|
export declare function createItemFromTemplate(template: common.IItemTemplate, templateDictionary: any, destinationAuthentication: common.UserSession, itemProgressCallback: common.IItemProgressCallback): Promise<common.ICreateItemFromTemplateResponse>;
|
package/dist/node/group.js
CHANGED
|
@@ -16,43 +16,46 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.createItemFromTemplate = exports.convertItemToTemplate = void 0;
|
|
19
|
-
var tslib_1 = require("tslib");
|
|
20
19
|
/**
|
|
21
20
|
* Manages the creation and deployment of groups.
|
|
22
21
|
*
|
|
23
22
|
* @module group
|
|
24
23
|
*/
|
|
25
|
-
|
|
24
|
+
const common = require("@esri/solution-common");
|
|
26
25
|
// ------------------------------------------------------------------------------------------------------------------ //
|
|
27
26
|
/**
|
|
28
27
|
* Converts a group item into a template.
|
|
29
28
|
*
|
|
30
29
|
* @param solutionItemId The solution to contain the template
|
|
31
30
|
* @param itemInfo Info about the item
|
|
32
|
-
* @param
|
|
31
|
+
* @param destAuthentication Credentials for requests to the destination organization
|
|
32
|
+
* @param srcAuthentication Credentials for requests to source items
|
|
33
33
|
* @return A promise that will resolve when the template has been created
|
|
34
34
|
*/
|
|
35
|
-
function convertItemToTemplate(solutionItemId, itemInfo,
|
|
36
|
-
return new Promise(
|
|
35
|
+
function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication) {
|
|
36
|
+
return new Promise(resolve => {
|
|
37
37
|
// Init template
|
|
38
|
-
|
|
38
|
+
const itemTemplate = common.createInitializedGroupTemplate(itemInfo);
|
|
39
39
|
// Templatize item info property values
|
|
40
40
|
itemTemplate.item.id = common.templatizeTerm(itemTemplate.item.id, itemTemplate.item.id, ".itemId");
|
|
41
41
|
// Get the group's items--its dependencies
|
|
42
|
-
common.getGroupContents(itemInfo.id,
|
|
42
|
+
common.getGroupContents(itemInfo.id, srcAuthentication).then(groupContents => {
|
|
43
43
|
itemTemplate.type = "Group";
|
|
44
44
|
itemTemplate.dependencies = groupContents;
|
|
45
|
-
common.getGroupBase(itemInfo.id,
|
|
45
|
+
common.getGroupBase(itemInfo.id, srcAuthentication).then(groupResponse => {
|
|
46
46
|
groupResponse.id = itemTemplate.item.id;
|
|
47
|
-
itemTemplate.item =
|
|
47
|
+
itemTemplate.item = {
|
|
48
|
+
...groupResponse,
|
|
49
|
+
type: "Group"
|
|
50
|
+
};
|
|
48
51
|
resolve(itemTemplate);
|
|
49
|
-
},
|
|
50
|
-
},
|
|
52
|
+
}, () => resolve(itemTemplate));
|
|
53
|
+
}, () => resolve(itemTemplate));
|
|
51
54
|
});
|
|
52
55
|
}
|
|
53
56
|
exports.convertItemToTemplate = convertItemToTemplate;
|
|
54
57
|
function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
|
|
55
|
-
return new Promise(
|
|
58
|
+
return new Promise(resolve => {
|
|
56
59
|
// Interrupt process if progress callback returns `false`
|
|
57
60
|
if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Started, 0)) {
|
|
58
61
|
itemProgressCallback(template.itemId, common.EItemProgressStatus.Ignored, 0);
|
|
@@ -60,12 +63,12 @@ function createItemFromTemplate(template, templateDictionary, destinationAuthent
|
|
|
60
63
|
return;
|
|
61
64
|
}
|
|
62
65
|
// Replace the templatized symbols in a copy of the template
|
|
63
|
-
|
|
66
|
+
let newItemTemplate = common.cloneObject(template);
|
|
64
67
|
newItemTemplate = common.replaceInTemplate(newItemTemplate, templateDictionary);
|
|
65
68
|
// Need to manually reset thumbnail because adlib in replaceInTemplate breaks it
|
|
66
69
|
newItemTemplate.item.thumbnail = template.item.thumbnail;
|
|
67
70
|
// Set up properties needed to create group
|
|
68
|
-
|
|
71
|
+
const newGroup = {
|
|
69
72
|
title: newItemTemplate.item.title || "",
|
|
70
73
|
access: "private",
|
|
71
74
|
owner: newItemTemplate.item.owner,
|
|
@@ -79,8 +82,8 @@ function createItemFromTemplate(template, templateDictionary, destinationAuthent
|
|
|
79
82
|
// * Manage Right of Way Activities 1
|
|
80
83
|
// * Manage Right of Way Activities 2
|
|
81
84
|
common
|
|
82
|
-
.createUniqueGroup(newGroup.title, newGroup, templateDictionary, destinationAuthentication)
|
|
83
|
-
.then(
|
|
85
|
+
.createUniqueGroup(newGroup.title, newGroup, templateDictionary, destinationAuthentication, common.isTrackingViewGroup(newItemTemplate) ? templateDictionary.locationTracking.owner : undefined)
|
|
86
|
+
.then((createResponse) => {
|
|
84
87
|
if (createResponse.success) {
|
|
85
88
|
// Interrupt process if progress callback returns `false`
|
|
86
89
|
if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.group.id)) {
|
|
@@ -88,11 +91,7 @@ function createItemFromTemplate(template, templateDictionary, destinationAuthent
|
|
|
88
91
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
89
92
|
common
|
|
90
93
|
.removeGroup(createResponse.group.id, destinationAuthentication)
|
|
91
|
-
.then(
|
|
92
|
-
return resolve(common.generateEmptyCreationResponse(template.type));
|
|
93
|
-
}, function () {
|
|
94
|
-
return resolve(common.generateEmptyCreationResponse(template.type));
|
|
95
|
-
});
|
|
94
|
+
.then(() => resolve(common.generateEmptyCreationResponse(template.type)), () => resolve(common.generateEmptyCreationResponse(template.type)));
|
|
96
95
|
}
|
|
97
96
|
else {
|
|
98
97
|
newItemTemplate.itemId = createResponse.group.id;
|
|
@@ -110,19 +109,62 @@ function createItemFromTemplate(template, templateDictionary, destinationAuthent
|
|
|
110
109
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
111
110
|
common
|
|
112
111
|
.removeGroup(createResponse.group.id, destinationAuthentication)
|
|
113
|
-
.then(
|
|
114
|
-
return resolve(common.generateEmptyCreationResponse(template.type));
|
|
115
|
-
}, function () {
|
|
116
|
-
return resolve(common.generateEmptyCreationResponse(template.type));
|
|
117
|
-
});
|
|
112
|
+
.then(() => resolve(common.generateEmptyCreationResponse(template.type)), () => resolve(common.generateEmptyCreationResponse(template.type)));
|
|
118
113
|
}
|
|
119
114
|
else {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
115
|
+
if (common.isTrackingViewGroup(newItemTemplate)) {
|
|
116
|
+
const owner = templateDictionary.locationTracking.owner;
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
118
|
+
common.reassignGroup(createResponse.group.id, owner, destinationAuthentication).then(assignResults => {
|
|
119
|
+
if (assignResults.success) {
|
|
120
|
+
if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.group.id)) {
|
|
121
|
+
itemProgressCallback(template.itemId, common.EItemProgressStatus.Cancelled, 0);
|
|
122
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
123
|
+
common
|
|
124
|
+
.removeGroup(createResponse.group.id, destinationAuthentication)
|
|
125
|
+
.then(() => resolve(common.generateEmptyCreationResponse(template.type)), () => resolve(common.generateEmptyCreationResponse(template.type)));
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
129
|
+
common.removeUsers(createResponse.group.id, [destinationAuthentication.username], destinationAuthentication).then(removeResults => {
|
|
130
|
+
if (Array.isArray(removeResults.notRemoved) && removeResults.notRemoved.length === 0) {
|
|
131
|
+
if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.group.id)) {
|
|
132
|
+
itemProgressCallback(template.itemId, common.EItemProgressStatus.Cancelled, 0);
|
|
133
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
134
|
+
common
|
|
135
|
+
.removeGroup(createResponse.group.id, destinationAuthentication)
|
|
136
|
+
.then(() => resolve(common.generateEmptyCreationResponse(template.type)), () => resolve(common.generateEmptyCreationResponse(template.type)));
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
resolve({
|
|
140
|
+
item: newItemTemplate,
|
|
141
|
+
id: createResponse.group.id,
|
|
142
|
+
type: newItemTemplate.type,
|
|
143
|
+
postProcess: false
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
|
|
149
|
+
resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
|
|
156
|
+
resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
resolve({
|
|
162
|
+
item: newItemTemplate,
|
|
163
|
+
id: createResponse.group.id,
|
|
164
|
+
type: newItemTemplate.type,
|
|
165
|
+
postProcess: false
|
|
166
|
+
});
|
|
167
|
+
}
|
|
126
168
|
}
|
|
127
169
|
}
|
|
128
170
|
}
|
|
@@ -130,7 +172,7 @@ function createItemFromTemplate(template, templateDictionary, destinationAuthent
|
|
|
130
172
|
itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
|
|
131
173
|
resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item
|
|
132
174
|
}
|
|
133
|
-
},
|
|
175
|
+
}, () => {
|
|
134
176
|
itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
|
|
135
177
|
resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item
|
|
136
178
|
});
|
package/dist/node/group.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group.js","sourceRoot":"","sources":["../../src/group.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG
|
|
1
|
+
{"version":3,"file":"group.js","sourceRoot":"","sources":["../../src/group.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;;;GAIG;AAEH,gDAAgD;AAEhD,wHAAwH;AAExH;;;;;;;;GAQG;AACH,S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|
|
|
24
24
|
*
|
|
25
25
|
* @param solutionItemId The solution to contain the template
|
|
26
26
|
* @param itemInfo Info about the item
|
|
27
|
-
* @param
|
|
27
|
+
* @param destAuthentication Credentials for requests to the destination organization
|
|
28
|
+
* @param srcAuthentication Credentials for requests to source items
|
|
28
29
|
* @return A promise that will resolve when the template has been created
|
|
29
30
|
*/
|
|
30
|
-
export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any,
|
|
31
|
+
export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, destAuthentication: common.UserSession, srcAuthentication: common.UserSession): Promise<common.IItemTemplate>;
|
|
31
32
|
export declare function createItemFromTemplate(template: common.IItemTemplate, templateDictionary: any, destinationAuthentication: common.UserSession, itemProgressCallback: common.IItemProgressCallback): Promise<common.ICreateItemFromTemplateResponse>;
|
package/dist/umd/group.umd.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/solution-group - v1.
|
|
2
|
+
* @esri/solution-group - v1.2.0 - Apache-2.0
|
|
3
3
|
* Copyright (c) 2018-2021 Esri, Inc.
|
|
4
|
-
*
|
|
4
|
+
* Thu Dec 09 2021 16:01:52 GMT-0800 (Pacific Standard Time)
|
|
5
5
|
*
|
|
6
6
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
7
|
* you may not use this file except in compliance with the License.
|
|
@@ -16,166 +16,206 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
(function (global, factory) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}(this, (function (exports, common) { 'use strict';
|
|
19
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@esri/solution-common')) :
|
|
20
|
+
typeof define === 'function' && define.amd ? define(['exports', '@esri/solution-common'], factory) :
|
|
21
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.arcgisSolution = global.arcgisSolution || {}, global.arcgisSolution));
|
|
22
|
+
})(this, (function (exports, common) { 'use strict';
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
***************************************************************************** */
|
|
38
|
-
|
|
39
|
-
var __assign = function() {
|
|
40
|
-
__assign = Object.assign || function __assign(t) {
|
|
41
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
42
|
-
s = arguments[i];
|
|
43
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
44
|
-
}
|
|
45
|
-
return t;
|
|
46
|
-
};
|
|
47
|
-
return __assign.apply(this, arguments);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/** @license
|
|
51
|
-
* Copyright 2019 Esri
|
|
52
|
-
*
|
|
53
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
54
|
-
* you may not use this file except in compliance with the License.
|
|
55
|
-
* You may obtain a copy of the License at
|
|
56
|
-
*
|
|
57
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
58
|
-
*
|
|
59
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
60
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
61
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
62
|
-
* See the License for the specific language governing permissions and
|
|
63
|
-
* limitations under the License.
|
|
64
|
-
*/
|
|
65
|
-
// ------------------------------------------------------------------------------------------------------------------ //
|
|
66
|
-
/**
|
|
67
|
-
* Converts a group item into a template.
|
|
68
|
-
*
|
|
69
|
-
* @param solutionItemId The solution to contain the template
|
|
70
|
-
* @param itemInfo Info about the item
|
|
71
|
-
* @param authentication Credentials for working with AGO
|
|
72
|
-
* @return A promise that will resolve when the template has been created
|
|
73
|
-
*/
|
|
74
|
-
function convertItemToTemplate(solutionItemId, itemInfo, authentication) {
|
|
75
|
-
return new Promise(function (resolve) {
|
|
76
|
-
// Init template
|
|
77
|
-
var itemTemplate = common.createInitializedGroupTemplate(itemInfo);
|
|
78
|
-
// Templatize item info property values
|
|
79
|
-
itemTemplate.item.id = common.templatizeTerm(itemTemplate.item.id, itemTemplate.item.id, ".itemId");
|
|
80
|
-
// Get the group's items--its dependencies
|
|
81
|
-
common.getGroupContents(itemInfo.id, authentication).then(function (groupContents) {
|
|
82
|
-
itemTemplate.type = "Group";
|
|
83
|
-
itemTemplate.dependencies = groupContents;
|
|
84
|
-
common.getGroupBase(itemInfo.id, authentication).then(function (groupResponse) {
|
|
85
|
-
groupResponse.id = itemTemplate.item.id;
|
|
86
|
-
itemTemplate.item = __assign(__assign({}, groupResponse), { type: "Group" });
|
|
87
|
-
resolve(itemTemplate);
|
|
88
|
-
}, function () { return resolve(itemTemplate); });
|
|
89
|
-
}, function () { return resolve(itemTemplate); });
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
|
|
93
|
-
return new Promise(function (resolve) {
|
|
94
|
-
// Interrupt process if progress callback returns `false`
|
|
95
|
-
if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Started, 0)) {
|
|
96
|
-
itemProgressCallback(template.itemId, common.EItemProgressStatus.Ignored, 0);
|
|
97
|
-
resolve(common.generateEmptyCreationResponse(template.type));
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
// Replace the templatized symbols in a copy of the template
|
|
101
|
-
var newItemTemplate = common.cloneObject(template);
|
|
102
|
-
newItemTemplate = common.replaceInTemplate(newItemTemplate, templateDictionary);
|
|
103
|
-
// Need to manually reset thumbnail because adlib in replaceInTemplate breaks it
|
|
104
|
-
newItemTemplate.item.thumbnail = template.item.thumbnail;
|
|
105
|
-
// Set up properties needed to create group
|
|
106
|
-
var newGroup = {
|
|
107
|
-
title: newItemTemplate.item.title || "",
|
|
108
|
-
access: "private",
|
|
109
|
-
owner: newItemTemplate.item.owner,
|
|
110
|
-
tags: newItemTemplate.item.tags,
|
|
111
|
-
description: newItemTemplate.item.description,
|
|
112
|
-
thumbnail: newItemTemplate.item.thumbnail,
|
|
113
|
-
snippet: newItemTemplate.item.snippet
|
|
114
|
-
};
|
|
115
|
-
// Create a group, appending a sequential suffix to its name if the group exists, e.g.,
|
|
116
|
-
// * Manage Right of Way Activities
|
|
117
|
-
// * Manage Right of Way Activities 1
|
|
118
|
-
// * Manage Right of Way Activities 2
|
|
119
|
-
common.createUniqueGroup(newGroup.title, newGroup, templateDictionary, destinationAuthentication)
|
|
120
|
-
.then(function (createResponse) {
|
|
121
|
-
if (createResponse.success) {
|
|
122
|
-
// Interrupt process if progress callback returns `false`
|
|
123
|
-
if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.group.id)) {
|
|
124
|
-
itemProgressCallback(template.itemId, common.EItemProgressStatus.Cancelled, 0);
|
|
125
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
126
|
-
common.removeGroup(createResponse.group.id, destinationAuthentication)
|
|
127
|
-
.then(function () {
|
|
128
|
-
return resolve(common.generateEmptyCreationResponse(template.type));
|
|
129
|
-
}, function () {
|
|
130
|
-
return resolve(common.generateEmptyCreationResponse(template.type));
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
newItemTemplate.itemId = createResponse.group.id;
|
|
135
|
-
templateDictionary[template.itemId] = {
|
|
136
|
-
itemId: createResponse.group.id
|
|
137
|
-
};
|
|
138
|
-
// Update the template again now that we have the new item id
|
|
139
|
-
newItemTemplate = common.replaceInTemplate(newItemTemplate, templateDictionary);
|
|
140
|
-
// Update the template dictionary with the new id
|
|
141
|
-
templateDictionary[template.itemId].itemId =
|
|
142
|
-
createResponse.group.id;
|
|
143
|
-
// Interrupt process if progress callback returns `false`
|
|
144
|
-
if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor / 2, createResponse.group.id)) {
|
|
145
|
-
itemProgressCallback(template.itemId, common.EItemProgressStatus.Cancelled, 0);
|
|
146
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
147
|
-
common.removeGroup(createResponse.group.id, destinationAuthentication)
|
|
148
|
-
.then(function () {
|
|
149
|
-
return resolve(common.generateEmptyCreationResponse(template.type));
|
|
150
|
-
}, function () {
|
|
151
|
-
return resolve(common.generateEmptyCreationResponse(template.type));
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
resolve({
|
|
156
|
-
item: newItemTemplate,
|
|
157
|
-
id: createResponse.group.id,
|
|
158
|
-
type: newItemTemplate.type,
|
|
159
|
-
postProcess: false
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
|
|
166
|
-
resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item
|
|
167
|
-
}
|
|
168
|
-
}, function () {
|
|
169
|
-
itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
|
|
170
|
-
resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item
|
|
171
|
-
});
|
|
172
|
-
});
|
|
24
|
+
function _interopNamespace(e) {
|
|
25
|
+
if (e && e.__esModule) return e;
|
|
26
|
+
var n = Object.create(null);
|
|
27
|
+
if (e) {
|
|
28
|
+
Object.keys(e).forEach(function (k) {
|
|
29
|
+
if (k !== 'default') {
|
|
30
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
31
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () { return e[k]; }
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
173
37
|
}
|
|
38
|
+
n["default"] = e;
|
|
39
|
+
return Object.freeze(n);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var common__namespace = /*#__PURE__*/_interopNamespace(common);
|
|
43
|
+
|
|
44
|
+
/** @license
|
|
45
|
+
* Copyright 2019 Esri
|
|
46
|
+
*
|
|
47
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
48
|
+
* you may not use this file except in compliance with the License.
|
|
49
|
+
* You may obtain a copy of the License at
|
|
50
|
+
*
|
|
51
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
52
|
+
*
|
|
53
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
54
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
55
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
56
|
+
* See the License for the specific language governing permissions and
|
|
57
|
+
* limitations under the License.
|
|
58
|
+
*/
|
|
59
|
+
// ------------------------------------------------------------------------------------------------------------------ //
|
|
60
|
+
/**
|
|
61
|
+
* Converts a group item into a template.
|
|
62
|
+
*
|
|
63
|
+
* @param solutionItemId The solution to contain the template
|
|
64
|
+
* @param itemInfo Info about the item
|
|
65
|
+
* @param destAuthentication Credentials for requests to the destination organization
|
|
66
|
+
* @param srcAuthentication Credentials for requests to source items
|
|
67
|
+
* @return A promise that will resolve when the template has been created
|
|
68
|
+
*/
|
|
69
|
+
function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication) {
|
|
70
|
+
return new Promise(resolve => {
|
|
71
|
+
// Init template
|
|
72
|
+
const itemTemplate = common__namespace.createInitializedGroupTemplate(itemInfo);
|
|
73
|
+
// Templatize item info property values
|
|
74
|
+
itemTemplate.item.id = common__namespace.templatizeTerm(itemTemplate.item.id, itemTemplate.item.id, ".itemId");
|
|
75
|
+
// Get the group's items--its dependencies
|
|
76
|
+
common__namespace.getGroupContents(itemInfo.id, srcAuthentication).then(groupContents => {
|
|
77
|
+
itemTemplate.type = "Group";
|
|
78
|
+
itemTemplate.dependencies = groupContents;
|
|
79
|
+
common__namespace.getGroupBase(itemInfo.id, srcAuthentication).then(groupResponse => {
|
|
80
|
+
groupResponse.id = itemTemplate.item.id;
|
|
81
|
+
itemTemplate.item = {
|
|
82
|
+
...groupResponse,
|
|
83
|
+
type: "Group"
|
|
84
|
+
};
|
|
85
|
+
resolve(itemTemplate);
|
|
86
|
+
}, () => resolve(itemTemplate));
|
|
87
|
+
}, () => resolve(itemTemplate));
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
|
|
91
|
+
return new Promise(resolve => {
|
|
92
|
+
// Interrupt process if progress callback returns `false`
|
|
93
|
+
if (!itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Started, 0)) {
|
|
94
|
+
itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Ignored, 0);
|
|
95
|
+
resolve(common__namespace.generateEmptyCreationResponse(template.type));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
// Replace the templatized symbols in a copy of the template
|
|
99
|
+
let newItemTemplate = common__namespace.cloneObject(template);
|
|
100
|
+
newItemTemplate = common__namespace.replaceInTemplate(newItemTemplate, templateDictionary);
|
|
101
|
+
// Need to manually reset thumbnail because adlib in replaceInTemplate breaks it
|
|
102
|
+
newItemTemplate.item.thumbnail = template.item.thumbnail;
|
|
103
|
+
// Set up properties needed to create group
|
|
104
|
+
const newGroup = {
|
|
105
|
+
title: newItemTemplate.item.title || "",
|
|
106
|
+
access: "private",
|
|
107
|
+
owner: newItemTemplate.item.owner,
|
|
108
|
+
tags: newItemTemplate.item.tags,
|
|
109
|
+
description: newItemTemplate.item.description,
|
|
110
|
+
thumbnail: newItemTemplate.item.thumbnail,
|
|
111
|
+
snippet: newItemTemplate.item.snippet
|
|
112
|
+
};
|
|
113
|
+
// Create a group, appending a sequential suffix to its name if the group exists, e.g.,
|
|
114
|
+
// * Manage Right of Way Activities
|
|
115
|
+
// * Manage Right of Way Activities 1
|
|
116
|
+
// * Manage Right of Way Activities 2
|
|
117
|
+
common__namespace
|
|
118
|
+
.createUniqueGroup(newGroup.title, newGroup, templateDictionary, destinationAuthentication, common__namespace.isTrackingViewGroup(newItemTemplate) ? templateDictionary.locationTracking.owner : undefined)
|
|
119
|
+
.then((createResponse) => {
|
|
120
|
+
if (createResponse.success) {
|
|
121
|
+
// Interrupt process if progress callback returns `false`
|
|
122
|
+
if (!itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.group.id)) {
|
|
123
|
+
itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Cancelled, 0);
|
|
124
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
125
|
+
common__namespace
|
|
126
|
+
.removeGroup(createResponse.group.id, destinationAuthentication)
|
|
127
|
+
.then(() => resolve(common__namespace.generateEmptyCreationResponse(template.type)), () => resolve(common__namespace.generateEmptyCreationResponse(template.type)));
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
newItemTemplate.itemId = createResponse.group.id;
|
|
131
|
+
templateDictionary[template.itemId] = {
|
|
132
|
+
itemId: createResponse.group.id
|
|
133
|
+
};
|
|
134
|
+
// Update the template again now that we have the new item id
|
|
135
|
+
newItemTemplate = common__namespace.replaceInTemplate(newItemTemplate, templateDictionary);
|
|
136
|
+
// Update the template dictionary with the new id
|
|
137
|
+
templateDictionary[template.itemId].itemId =
|
|
138
|
+
createResponse.group.id;
|
|
139
|
+
// Interrupt process if progress callback returns `false`
|
|
140
|
+
if (!itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor / 2, createResponse.group.id)) {
|
|
141
|
+
itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Cancelled, 0);
|
|
142
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
143
|
+
common__namespace
|
|
144
|
+
.removeGroup(createResponse.group.id, destinationAuthentication)
|
|
145
|
+
.then(() => resolve(common__namespace.generateEmptyCreationResponse(template.type)), () => resolve(common__namespace.generateEmptyCreationResponse(template.type)));
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
if (common__namespace.isTrackingViewGroup(newItemTemplate)) {
|
|
149
|
+
const owner = templateDictionary.locationTracking.owner;
|
|
150
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
151
|
+
common__namespace.reassignGroup(createResponse.group.id, owner, destinationAuthentication).then(assignResults => {
|
|
152
|
+
if (assignResults.success) {
|
|
153
|
+
if (!itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.group.id)) {
|
|
154
|
+
itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Cancelled, 0);
|
|
155
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
156
|
+
common__namespace
|
|
157
|
+
.removeGroup(createResponse.group.id, destinationAuthentication)
|
|
158
|
+
.then(() => resolve(common__namespace.generateEmptyCreationResponse(template.type)), () => resolve(common__namespace.generateEmptyCreationResponse(template.type)));
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
162
|
+
common__namespace.removeUsers(createResponse.group.id, [destinationAuthentication.username], destinationAuthentication).then(removeResults => {
|
|
163
|
+
if (Array.isArray(removeResults.notRemoved) && removeResults.notRemoved.length === 0) {
|
|
164
|
+
if (!itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.group.id)) {
|
|
165
|
+
itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Cancelled, 0);
|
|
166
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
167
|
+
common__namespace
|
|
168
|
+
.removeGroup(createResponse.group.id, destinationAuthentication)
|
|
169
|
+
.then(() => resolve(common__namespace.generateEmptyCreationResponse(template.type)), () => resolve(common__namespace.generateEmptyCreationResponse(template.type)));
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
resolve({
|
|
173
|
+
item: newItemTemplate,
|
|
174
|
+
id: createResponse.group.id,
|
|
175
|
+
type: newItemTemplate.type,
|
|
176
|
+
postProcess: false
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Failed, 0);
|
|
182
|
+
resolve(common__namespace.generateEmptyCreationResponse(template.type)); // fails to create item
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Failed, 0);
|
|
189
|
+
resolve(common__namespace.generateEmptyCreationResponse(template.type)); // fails to create item
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
resolve({
|
|
195
|
+
item: newItemTemplate,
|
|
196
|
+
id: createResponse.group.id,
|
|
197
|
+
type: newItemTemplate.type,
|
|
198
|
+
postProcess: false
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Failed, 0);
|
|
206
|
+
resolve(common__namespace.generateEmptyCreationResponse(template.type)); // fails to create item
|
|
207
|
+
}
|
|
208
|
+
}, () => {
|
|
209
|
+
itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Failed, 0);
|
|
210
|
+
resolve(common__namespace.generateEmptyCreationResponse(template.type)); // fails to create item
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
}
|
|
174
214
|
|
|
175
|
-
|
|
176
|
-
|
|
215
|
+
exports.convertItemToTemplate = convertItemToTemplate;
|
|
216
|
+
exports.createItemFromTemplate = createItemFromTemplate;
|
|
177
217
|
|
|
178
|
-
|
|
218
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
179
219
|
|
|
180
|
-
}))
|
|
220
|
+
}));
|
|
181
221
|
//# sourceMappingURL=group.umd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group.umd.js","sources":["../../src/group.ts"],"sourcesContent":["/** @license\r\n * Copyright 2019 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the creation and deployment of groups.\r\n *\r\n * @module group\r\n */\r\n\r\nimport * as common from \"@esri/solution-common\";\r\n\r\n// ------------------------------------------------------------------------------------------------------------------ //\r\n\r\n/**\r\n * Converts a group item into a template.\r\n *\r\n * @param solutionItemId The solution to contain the template\r\n * @param itemInfo Info about the item\r\n * @param authentication Credentials for working with AGO\r\n * @return A promise that will resolve when the template has been created\r\n */\r\nexport function convertItemToTemplate(\r\n solutionItemId: string,\r\n itemInfo: any,\r\n authentication: common.UserSession\r\n): Promise<common.IItemTemplate> {\r\n return new Promise<common.IItemTemplate>(resolve => {\r\n // Init template\r\n const itemTemplate: common.IItemTemplate = common.createInitializedGroupTemplate(\r\n itemInfo\r\n );\r\n\r\n // Templatize item info property values\r\n itemTemplate.item.id = common.templatizeTerm(\r\n itemTemplate.item.id,\r\n itemTemplate.item.id,\r\n \".itemId\"\r\n );\r\n\r\n // Get the group's items--its dependencies\r\n common.getGroupContents(itemInfo.id, authentication).then(\r\n groupContents => {\r\n itemTemplate.type = \"Group\";\r\n itemTemplate.dependencies = groupContents;\r\n common.getGroupBase(itemInfo.id, authentication).then(\r\n groupResponse => {\r\n groupResponse.id = itemTemplate.item.id;\r\n itemTemplate.item = {\r\n ...groupResponse,\r\n type: \"Group\"\r\n };\r\n resolve(itemTemplate);\r\n },\r\n () => resolve(itemTemplate)\r\n );\r\n },\r\n () => resolve(itemTemplate)\r\n );\r\n });\r\n}\r\n\r\nexport function createItemFromTemplate(\r\n template: common.IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: common.UserSession,\r\n itemProgressCallback: common.IItemProgressCallback\r\n): Promise<common.ICreateItemFromTemplateResponse> {\r\n return new Promise<common.ICreateItemFromTemplateResponse>(resolve => {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Started,\r\n 0\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Ignored,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type));\r\n return;\r\n }\r\n\r\n // Replace the templatized symbols in a copy of the template\r\n let newItemTemplate: common.IItemTemplate = common.cloneObject(template);\r\n newItemTemplate = common.replaceInTemplate(\r\n newItemTemplate,\r\n templateDictionary\r\n );\r\n // Need to manually reset thumbnail because adlib in replaceInTemplate breaks it\r\n newItemTemplate.item.thumbnail = template.item.thumbnail;\r\n\r\n // Set up properties needed to create group\r\n const newGroup: common.IGroupAdd = {\r\n title: newItemTemplate.item.title || \"\",\r\n access: \"private\",\r\n owner: newItemTemplate.item.owner,\r\n tags: newItemTemplate.item.tags,\r\n description: newItemTemplate.item.description,\r\n thumbnail: newItemTemplate.item.thumbnail,\r\n snippet: newItemTemplate.item.snippet\r\n };\r\n\r\n // Create a group, appending a sequential suffix to its name if the group exists, e.g.,\r\n // * Manage Right of Way Activities\r\n // * Manage Right of Way Activities 1\r\n // * Manage Right of Way Activities 2\r\n common\r\n .createUniqueGroup(\r\n newGroup.title,\r\n newGroup,\r\n templateDictionary,\r\n destinationAuthentication\r\n )\r\n .then(\r\n (createResponse: common.IAddGroupResponse) => {\r\n if (createResponse.success) {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Created,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.group.id\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Cancelled,\r\n 0\r\n );\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common\r\n .removeGroup(createResponse.group.id, destinationAuthentication)\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n ),\r\n () =>\r\n resolve(common.generateEmptyCreationResponse(template.type))\r\n );\r\n } else {\r\n newItemTemplate.itemId = createResponse.group.id;\r\n templateDictionary[template.itemId] = {\r\n itemId: createResponse.group.id\r\n };\r\n\r\n // Update the template again now that we have the new item id\r\n newItemTemplate = common.replaceInTemplate(\r\n newItemTemplate,\r\n templateDictionary\r\n );\r\n\r\n // Update the template dictionary with the new id\r\n templateDictionary[template.itemId].itemId =\r\n createResponse.group.id;\r\n\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Finished,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.group.id\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Cancelled,\r\n 0\r\n );\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common\r\n .removeGroup(\r\n createResponse.group.id,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n ),\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n )\r\n );\r\n } else {\r\n resolve({\r\n item: newItemTemplate,\r\n id: createResponse.group.id,\r\n type: newItemTemplate.type,\r\n postProcess: false\r\n });\r\n }\r\n }\r\n } else {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item\r\n }\r\n },\r\n () => {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item\r\n }\r\n );\r\n });\r\n}\r\n"],"names":["common.createInitializedGroupTemplate","common.templatizeTerm","common.getGroupContents","common.getGroupBase","common.EItemProgressStatus","common.generateEmptyCreationResponse","common.cloneObject","common.replaceInTemplate","common\r\n .createUniqueGroup","common\r\n .removeGroup","common\r\n .removeGroup"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAA;;;;;;;;;;;;;;;IAwBA;IAEA;;;;;;;;aAQgB,qBAAqB,CACnC,cAAsB,EACtB,QAAa,EACb,cAAkC;QAElC,OAAO,IAAI,OAAO,CAAuB,UAAA,OAAO;;YAE9C,IAAM,YAAY,GAAyBA,qCAAqC,CAC9E,QAAQ,CACT,CAAC;;YAGF,YAAY,CAAC,IAAI,CAAC,EAAE,GAAGC,qBAAqB,CAC1C,YAAY,CAAC,IAAI,CAAC,EAAE,EACpB,YAAY,CAAC,IAAI,CAAC,EAAE,EACpB,SAAS,CACV,CAAC;;YAGFC,uBAAuB,CAAC,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC,IAAI,CACvD,UAAA,aAAa;gBACX,YAAY,CAAC,IAAI,GAAG,OAAO,CAAC;gBAC5B,YAAY,CAAC,YAAY,GAAG,aAAa,CAAC;gBAC1CC,mBAAmB,CAAC,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC,IAAI,CACnD,UAAA,aAAa;oBACX,aAAa,CAAC,EAAE,GAAG,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;oBACxC,YAAY,CAAC,IAAI,yBACZ,aAAa,KAChB,IAAI,EAAE,OAAO,GACd,CAAC;oBACF,OAAO,C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AAC;;4BAEFM,kBACc,CACV,cAAc,CAAC,KAAK,CAAC,EAAE,EACvB,yBAAyB,CAC1B;iCACA,IAAI,CACH;gCACE,OAAA,OAAO,CACLL,oCAAoC,CAAC,QAAQ,CAAC,IAAI,CAAC,CACpD;6BAAA,EACH;gCACE,OAAA,OAAO,CACLA,oCAAoC,CAAC,QAAQ,CAAC,IAAI,CAAC,CACpD;6BAAA,CACJ,CAAC;yBACL;6BAAM;4BACL,OAAO,CAAC;gCACN,IAAI,EAAE,eAAe;gCACrB,EAAE,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE;gCAC3B,IAAI,EAAE,eAAe,CAAC,IAAI;gCAC1B,WAAW,EAAE,KAAK;6BACnB,CAAC,CAAC;yBACJ;qBACF;iBACF;qBAAM;oBACL,oBAAoB,CAClB,QAAQ,CAAC,MAAM,EACfD,0BAA0B,CAAC,MAAM,EACjC,CAAC,CACF,CAAC;oBACF,OAAO,CAACC,oCAAoC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;iBAC9D;aACF,EACD;gBACE,oBAAoB,CAClB,QAAQ,CAAC,MAAM,EACfD,0BAA0B,CAAC,MAAM,EACjC,CAAC,CACF,CAAC;gBACF,OAAO,CAACC,oCAAoC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;aAC9D,CACF,CAAC;SACL,CAAC,CAAC;IACL;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"group.umd.js","sources":["../../src/group.ts"],"sourcesContent":["/** @license\r\n * Copyright 2019 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the creation and deployment of groups.\r\n *\r\n * @module group\r\n */\r\n\r\nimport * as common from \"@esri/solution-common\";\r\n\r\n// ------------------------------------------------------------------------------------------------------------------ //\r\n\r\n/**\r\n * Converts a group item into a template.\r\n *\r\n * @param solutionItemId The solution to contain the template\r\n * @param itemInfo Info about the item\r\n * @param destAuthentication Credentials for requests to the destination organization\r\n * @param srcAuthentication Credentials for requests to source items\r\n * @return A promise that will resolve when the template has been created\r\n */\r\nexport function convertItemToTemplate(\r\n solutionItemId: string,\r\n itemInfo: any,\r\n destAuthentication: common.UserSession,\r\n srcAuthentication: common.UserSession\r\n): Promise<common.IItemTemplate> {\r\n return new Promise<common.IItemTemplate>(resolve => {\r\n // Init template\r\n const itemTemplate: common.IItemTemplate = common.createInitializedGroupTemplate(\r\n itemInfo\r\n );\r\n\r\n // Templatize item info property values\r\n itemTemplate.item.id = common.templatizeTerm(\r\n itemTemplate.item.id,\r\n itemTemplate.item.id,\r\n \".itemId\"\r\n );\r\n\r\n // Get the group's items--its dependencies\r\n common.getGroupContents(itemInfo.id, srcAuthentication).then(\r\n groupContents => {\r\n itemTemplate.type = \"Group\";\r\n itemTemplate.dependencies = groupContents;\r\n common.getGroupBase(itemInfo.id, srcAuthentication).then(\r\n groupResponse => {\r\n groupResponse.id = itemTemplate.item.id;\r\n itemTemplate.item = {\r\n ...groupResponse,\r\n type: \"Group\"\r\n };\r\n resolve(itemTemplate);\r\n },\r\n () => resolve(itemTemplate)\r\n );\r\n },\r\n () => resolve(itemTemplate)\r\n );\r\n });\r\n}\r\n\r\nexport function createItemFromTemplate(\r\n template: common.IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: common.UserSession,\r\n itemProgressCallback: common.IItemProgressCallback\r\n): Promise<common.ICreateItemFromTemplateResponse> {\r\n return new Promise<common.ICreateItemFromTemplateResponse>(resolve => {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Started,\r\n 0\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Ignored,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type));\r\n return;\r\n }\r\n\r\n // Replace the templatized symbols in a copy of the template\r\n let newItemTemplate: common.IItemTemplate = common.cloneObject(template);\r\n newItemTemplate = common.replaceInTemplate(\r\n newItemTemplate,\r\n templateDictionary\r\n );\r\n // Need to manually reset thumbnail because adlib in replaceInTemplate breaks it\r\n newItemTemplate.item.thumbnail = template.item.thumbnail;\r\n\r\n // Set up properties needed to create group\r\n const newGroup: common.IGroupAdd = {\r\n title: newItemTemplate.item.title || \"\",\r\n access: \"private\",\r\n owner: newItemTemplate.item.owner,\r\n tags: newItemTemplate.item.tags,\r\n description: newItemTemplate.item.description,\r\n thumbnail: newItemTemplate.item.thumbnail,\r\n snippet: newItemTemplate.item.snippet\r\n };\r\n\r\n // Create a group, appending a sequential suffix to its name if the group exists, e.g.,\r\n // * Manage Right of Way Activities\r\n // * Manage Right of Way Activities 1\r\n // * Manage Right of Way Activities 2\r\n common\r\n .createUniqueGroup(\r\n newGroup.title,\r\n newGroup,\r\n templateDictionary,\r\n destinationAuthentication,\r\n common.isTrackingViewGroup(newItemTemplate) ? templateDictionary.locationTracking.owner : undefined\r\n )\r\n .then(\r\n (createResponse: common.IAddGroupResponse) => {\r\n if (createResponse.success) {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Created,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.group.id\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Cancelled,\r\n 0\r\n );\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common\r\n .removeGroup(createResponse.group.id, destinationAuthentication)\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n ),\r\n () =>\r\n resolve(common.generateEmptyCreationResponse(template.type))\r\n );\r\n } else {\r\n newItemTemplate.itemId = createResponse.group.id;\r\n templateDictionary[template.itemId] = {\r\n itemId: createResponse.group.id\r\n };\r\n\r\n // Update the template again now that we have the new item id\r\n newItemTemplate = common.replaceInTemplate(\r\n newItemTemplate,\r\n templateDictionary\r\n );\r\n\r\n // Update the template dictionary with the new id\r\n templateDictionary[template.itemId].itemId =\r\n createResponse.group.id;\r\n\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Finished,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.group.id\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Cancelled,\r\n 0\r\n );\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common\r\n .removeGroup(\r\n createResponse.group.id,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n ),\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n )\r\n );\r\n } else {\r\n if (common.isTrackingViewGroup(newItemTemplate)) {\r\n const owner: string = templateDictionary.locationTracking.owner;\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common.reassignGroup(\r\n createResponse.group.id,\r\n owner,\r\n destinationAuthentication\r\n ).then(assignResults => {\r\n if (assignResults.success) {\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Created,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.group.id\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Cancelled,\r\n 0\r\n );\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common\r\n .removeGroup(createResponse.group.id, destinationAuthentication)\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n ),\r\n () =>\r\n resolve(common.generateEmptyCreationResponse(template.type))\r\n );\r\n } else {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common.removeUsers(\r\n createResponse.group.id,\r\n [destinationAuthentication.username],\r\n destinationAuthentication\r\n ).then(removeResults => {\r\n if (Array.isArray(removeResults.notRemoved) && removeResults.notRemoved.length === 0) {\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Created,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.group.id\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Cancelled,\r\n 0\r\n );\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common\r\n .removeGroup(createResponse.group.id, destinationAuthentication)\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n ),\r\n () =>\r\n resolve(common.generateEmptyCreationResponse(template.type))\r\n );\r\n } else {\r\n resolve({\r\n item: newItemTemplate,\r\n id: createResponse.group.id,\r\n type: newItemTemplate.type,\r\n postProcess: false\r\n });\r\n }\r\n } else {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item\r\n }\r\n });\r\n }\r\n } else {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item\r\n }\r\n })\r\n } else {\r\n resolve({\r\n item: newItemTemplate,\r\n id: createResponse.group.id,\r\n type: newItemTemplate.type,\r\n postProcess: false\r\n });\r\n }\r\n }\r\n }\r\n } else {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item\r\n }\r\n },\r\n () => {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item\r\n }\r\n );\r\n });\r\n}\r\n"],"names":["common"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;;;;;;;;;EAwBA;EAEA;;;;;;;;;WASgB,qBAAqB,CACnC,cAAsB,EACtB,QAAa,EACb,kBAAsC,EACtC,iBAAqC;MAErC,OAAO,IAAI,OAAO,CAAuB,OAAO;;UAE9C,MAAM,YAAY,GAAyBA,iBAAM,CAAC,8BAA8B,CAC9E,QAAQ,CACT,CAAC;;UAGF,YAAY,CAAC,IAAI,CAAC,EAAE,GAAGA,iBAAM,CAAC,cAAc,CAC1C,YAAY,CAAC,IAAI,CAAC,EAAE,EACpB,YAAY,CAAC,IAAI,CAAC,EAAE,EACpB,SAAS,CACV,CAAC;;UAGFA,iBAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,EAAE,iBAAiB,CAAC,CAAC,IAAI,CAC1D,aAAa;cACX,YAAY,CAAC,IAAI,GAAG,OAAO,CAAC;cAC5B,YAAY,CAAC,YAAY,GAAG,aAAa,CAAC;cAC1CA,iBAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,EAAE,iBAAiB,CAAC,CAAC,IAAI,CACtD,aAAa;kBACX,aAAa,CAAC,EAAE,GAAG,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;kBACxC,YAAY,CAAC,IAAI,GAAG;sBAClB,GAAG,aAAa;sBAChB,IAAI,EAAE,OAAO;mBACd,CAAC;kBACF,OAAO,CAAC,YAAY,CAAC,CAAC;eACvB,EACD,MAAM,OAAO,CAAC,YAAY,CAAC,CAC5B,CAAC;WACH,EACD,MAAM,OAAO,CAAC,YAAY,CAAC,CAC5B,CAAC;OACH,CAAC,CAAC;EACL,CAAC;WAEe,sBAAsB,CACpC,QAA8B,EAC9B,kBAAuB,EACvB,yBAA6C,EAC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,MAAM,EACjC,CAAC,CACF,CAAC;sCACF,OAAO,CAACA,iBAAM,CAAC,6BAA6B,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;mCAC9D;+BACF,CAAC,CAAA;2BACH;+BAAM;8BACL,OAAO,CAAC;kCACN,IAAI,EAAE,eAAe;kCACrB,EAAE,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE;kCAC3B,IAAI,EAAE,eAAe,CAAC,IAAI;kCAC1B,WAAW,EAAE,KAAK;+BACnB,CAAC,CAAC;2BACJ;uBACF;mBACF;eACF;mBAAM;kBACL,oBAAoB,CAClB,QAAQ,CAAC,MAAM,EACfA,iBAAM,CAAC,mBAAmB,CAAC,MAAM,EACjC,CAAC,CACF,CAAC;kBACF,OAAO,CAACA,iBAAM,CAAC,6BAA6B,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;eAC9D;WACF,EACD;cACE,oBAAoB,CAClB,QAAQ,CAAC,MAAM,EACfA,iBAAM,CAAC,mBAAmB,CAAC,MAAM,EACjC,CAAC,CACF,CAAC;cACF,OAAO,CAACA,iBAAM,CAAC,6BAA6B,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;WAC9D,CACF,CAAC;OACL,CAAC,CAAC;EACL;;;;;;;;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/solution-group - v1.
|
|
2
|
+
* @esri/solution-group - v1.2.0 - Apache-2.0
|
|
3
3
|
* Copyright (c) 2018-2021 Esri, Inc.
|
|
4
|
-
*
|
|
4
|
+
* Thu Dec 09 2021 16:01:58 GMT-0800 (Pacific Standard Time)
|
|
5
5
|
*
|
|
6
6
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
7
|
* you may not use this file except in compliance with the License.
|
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@esri/solution-common")):"function"==typeof define&&define.amd?define(["exports","@esri/solution-common"],t):t((e=e||self).arcgisSolution=e.arcgisSolution||{},e.arcgisSolution)}(this,function(e,t){"use strict";
|
|
18
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@esri/solution-common")):"function"==typeof define&&define.amd?define(["exports","@esri/solution-common"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).arcgisSolution=e.arcgisSolution||{},e.arcgisSolution)}(this,(function(e,t){"use strict";function r(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var i=r(t);e.convertItemToTemplate=function(e,t,r,o){return new Promise((e=>{const r=i.createInitializedGroupTemplate(t);r.item.id=i.templatizeTerm(r.item.id,r.item.id,".itemId"),i.getGroupContents(t.id,o).then((n=>{r.type="Group",r.dependencies=n,i.getGroupBase(t.id,o).then((t=>{t.id=r.item.id,r.item={...t,type:"Group"},e(r)}),(()=>e(r)))}),(()=>e(r)))}))},e.createItemFromTemplate=function(e,t,r,o){return new Promise((n=>{if(!o(e.itemId,i.EItemProgressStatus.Started,0))return o(e.itemId,i.EItemProgressStatus.Ignored,0),void n(i.generateEmptyCreationResponse(e.type));let s=i.cloneObject(e);s=i.replaceInTemplate(s,t),s.item.thumbnail=e.item.thumbnail;const a={title:s.item.title||"",access:"private",owner:s.item.owner,tags:s.item.tags,description:s.item.description,thumbnail:s.item.thumbnail,snippet:s.item.snippet};i.createUniqueGroup(a.title,a,t,r,i.isTrackingViewGroup(s)?t.locationTracking.owner:void 0).then((a=>{if(a.success)if(o(e.itemId,i.EItemProgressStatus.Created,e.estimatedDeploymentCostFactor/2,a.group.id))if(s.itemId=a.group.id,t[e.itemId]={itemId:a.group.id},s=i.replaceInTemplate(s,t),t[e.itemId].itemId=a.group.id,o(e.itemId,i.EItemProgressStatus.Finished,e.estimatedDeploymentCostFactor/2,a.group.id))if(i.isTrackingViewGroup(s)){const p=t.locationTracking.owner;i.reassignGroup(a.group.id,p,r).then((t=>{t.success?o(e.itemId,i.EItemProgressStatus.Created,e.estimatedDeploymentCostFactor/2,a.group.id)?i.removeUsers(a.group.id,[r.username],r).then((t=>{Array.isArray(t.notRemoved)&&0===t.notRemoved.length?o(e.itemId,i.EItemProgressStatus.Created,e.estimatedDeploymentCostFactor/2,a.group.id)?n({item:s,id:a.group.id,type:s.type,postProcess:!1}):(o(e.itemId,i.EItemProgressStatus.Cancelled,0),i.removeGroup(a.group.id,r).then((()=>n(i.generateEmptyCreationResponse(e.type))),(()=>n(i.generateEmptyCreationResponse(e.type))))):(o(e.itemId,i.EItemProgressStatus.Failed,0),n(i.generateEmptyCreationResponse(e.type)))})):(o(e.itemId,i.EItemProgressStatus.Cancelled,0),i.removeGroup(a.group.id,r).then((()=>n(i.generateEmptyCreationResponse(e.type))),(()=>n(i.generateEmptyCreationResponse(e.type))))):(o(e.itemId,i.EItemProgressStatus.Failed,0),n(i.generateEmptyCreationResponse(e.type)))}))}else n({item:s,id:a.group.id,type:s.type,postProcess:!1});else o(e.itemId,i.EItemProgressStatus.Cancelled,0),i.removeGroup(a.group.id,r).then((()=>n(i.generateEmptyCreationResponse(e.type))),(()=>n(i.generateEmptyCreationResponse(e.type))));else o(e.itemId,i.EItemProgressStatus.Cancelled,0),i.removeGroup(a.group.id,r).then((()=>n(i.generateEmptyCreationResponse(e.type))),(()=>n(i.generateEmptyCreationResponse(e.type))));else o(e.itemId,i.EItemProgressStatus.Failed,0),n(i.generateEmptyCreationResponse(e.type))}),(()=>{o(e.itemId,i.EItemProgressStatus.Failed,0),n(i.generateEmptyCreationResponse(e.type))}))}))},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
19
19
|
//# sourceMappingURL=group.umd.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group.umd.min.js","sources":["../../src/group.ts"],"sourcesContent":["/** @license\r\n * Copyright 2019 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the creation and deployment of groups.\r\n *\r\n * @module group\r\n */\r\n\r\nimport * as common from \"@esri/solution-common\";\r\n\r\n// ------------------------------------------------------------------------------------------------------------------ //\r\n\r\n/**\r\n * Converts a group item into a template.\r\n *\r\n * @param solutionItemId The solution to contain the template\r\n * @param itemInfo Info about the item\r\n * @param authentication Credentials for working with AGO\r\n * @return A promise that will resolve when the template has been created\r\n */\r\nexport function convertItemToTemplate(\r\n solutionItemId: string,\r\n itemInfo: any,\r\n authentication: common.UserSession\r\n): Promise<common.IItemTemplate> {\r\n return new Promise<common.IItemTemplate>(resolve => {\r\n // Init template\r\n const itemTemplate: common.IItemTemplate = common.createInitializedGroupTemplate(\r\n itemInfo\r\n );\r\n\r\n // Templatize item info property values\r\n itemTemplate.item.id = common.templatizeTerm(\r\n itemTemplate.item.id,\r\n itemTemplate.item.id,\r\n \".itemId\"\r\n );\r\n\r\n // Get the group's items--its dependencies\r\n common.getGroupContents(itemInfo.id, authentication).then(\r\n groupContents => {\r\n itemTemplate.type = \"Group\";\r\n itemTemplate.dependencies = groupContents;\r\n common.getGroupBase(itemInfo.id, authentication).then(\r\n groupResponse => {\r\n groupResponse.id = itemTemplate.item.id;\r\n itemTemplate.item = {\r\n ...groupResponse,\r\n type: \"Group\"\r\n };\r\n resolve(itemTemplate);\r\n },\r\n () => resolve(itemTemplate)\r\n );\r\n },\r\n () => resolve(itemTemplate)\r\n );\r\n });\r\n}\r\n\r\nexport function createItemFromTemplate(\r\n template: common.IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: common.UserSession,\r\n itemProgressCallback: common.IItemProgressCallback\r\n): Promise<common.ICreateItemFromTemplateResponse> {\r\n return new Promise<common.ICreateItemFromTemplateResponse>(resolve => {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Started,\r\n 0\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Ignored,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type));\r\n return;\r\n }\r\n\r\n // Replace the templatized symbols in a copy of the template\r\n let newItemTemplate: common.IItemTemplate = common.cloneObject(template);\r\n newItemTemplate = common.replaceInTemplate(\r\n newItemTemplate,\r\n templateDictionary\r\n );\r\n // Need to manually reset thumbnail because adlib in replaceInTemplate breaks it\r\n newItemTemplate.item.thumbnail = template.item.thumbnail;\r\n\r\n // Set up properties needed to create group\r\n const newGroup: common.IGroupAdd = {\r\n title: newItemTemplate.item.title || \"\",\r\n access: \"private\",\r\n owner: newItemTemplate.item.owner,\r\n tags: newItemTemplate.item.tags,\r\n description: newItemTemplate.item.description,\r\n thumbnail: newItemTemplate.item.thumbnail,\r\n snippet: newItemTemplate.item.snippet\r\n };\r\n\r\n // Create a group, appending a sequential suffix to its name if the group exists, e.g.,\r\n // * Manage Right of Way Activities\r\n // * Manage Right of Way Activities 1\r\n // * Manage Right of Way Activities 2\r\n common\r\n .createUniqueGroup(\r\n newGroup.title,\r\n newGroup,\r\n templateDictionary,\r\n destinationAuthentication\r\n )\r\n .then(\r\n (createResponse: common.IAddGroupResponse) => {\r\n if (createResponse.success) {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Created,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.group.id\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Cancelled,\r\n 0\r\n );\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common\r\n .removeGroup(createResponse.group.id, destinationAuthentication)\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n ),\r\n () =>\r\n resolve(common.generateEmptyCreationResponse(template.type))\r\n );\r\n } else {\r\n newItemTemplate.itemId = createResponse.group.id;\r\n templateDictionary[template.itemId] = {\r\n itemId: createResponse.group.id\r\n };\r\n\r\n // Update the template again now that we have the new item id\r\n newItemTemplate = common.replaceInTemplate(\r\n newItemTemplate,\r\n templateDictionary\r\n );\r\n\r\n // Update the template dictionary with the new id\r\n templateDictionary[template.itemId].itemId =\r\n createResponse.group.id;\r\n\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Finished,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.group.id\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Cancelled,\r\n 0\r\n );\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common\r\n .removeGroup(\r\n createResponse.group.id,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n ),\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n )\r\n );\r\n } else {\r\n resolve({\r\n item: newItemTemplate,\r\n id: createResponse.group.id,\r\n type: newItemTemplate.type,\r\n postProcess: false\r\n });\r\n }\r\n }\r\n } else {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item\r\n }\r\n },\r\n () => {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item\r\n }\r\n );\r\n });\r\n}\r\n"],"names":["solutionItemId","itemInfo","authentication","Promise","resolve","itemTemplate","common.createInitializedGroupTemplate","item","id","common.templatizeTerm","common.getGroupContents","then","groupContents","type","dependencies","common.getGroupBase","groupResponse","template","templateDictionary","destinationAuthentication","itemProgressCallback","itemId","common.EItemProgressStatus","Started","Ignored","common.generateEmptyCreationResponse","newItemTemplate","common.cloneObject","common.replaceInTemplate","thumbnail","newGroup","title","access","owner","tags","description","snippet","common\r\n .createUniqueGroup","createResponse","success","Created","estimatedDeploymentCostFactor","group","Finished","postProcess","Cancelled","common\r\n .removeGroup","common\r\n .removeGroup","Failed"],"mappings":";;;;;;;;;;;;;;;;;6hBAmCEA,EACAC,EACAC,GAEA,OAAO,IAAIC,QAA8B,SAAAC,GAEvC,IAAMC,EAAqCC,iCACzCL,GAIFI,EAAaE,KAAKC,GAAKC,iBACrBJ,EAAaE,KAAKC,GAClBH,EAAaE,KAAKC,GAClB,WAIFE,mBAAwBT,EAASO,GAAIN,GAAgBS,KACnD,SAAAC,GACEP,EAAaQ,KAAO,QACpBR,EAAaS,aAAeF,EAC5BG,eAAoBd,EAASO,GAAIN,GAAgBS,KAC/C,SAAAK,GACEA,EAAcR,GAAKH,EAAaE,KAAKC,GACrCH,EAAaE,YACRS,IACHH,KAAM,UAERT,EAAQC,IAEV,WAAM,OAAAD,EAAQC,MAGlB,WAAM,OAAAD,EAAQC,0CAMlBY,EACAC,EACAC,EACAC,GAEA,OAAO,IAAIjB,QAAgD,SAAAC,GAEzD,IACGgB,EACCH,EAASI,OACTC,sBAA2BC,QAC3B,GASF,OANAH,EACEH,EAASI,OACTC,sBAA2BE,QAC3B,QAEFpB,EAAQqB,gCAAqCR,EAASJ,OAKxD,IAAIa,EAAwCC,cAAmBV,IAC/DS,EAAkBE,oBAChBF,EACAR,IAGcX,KAAKsB,UAAYZ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H,EAASI,OACTC,sBAA2B0B,OAC3B,GAEF5C,EAAQqB,gCAAqCR,EAASJ"}
|
|
1
|
+
{"version":3,"file":"group.umd.min.js","sources":["../../src/group.ts"],"sourcesContent":["/** @license\r\n * Copyright 2019 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the creation and deployment of groups.\r\n *\r\n * @module group\r\n */\r\n\r\nimport * as common from \"@esri/solution-common\";\r\n\r\n// ------------------------------------------------------------------------------------------------------------------ //\r\n\r\n/**\r\n * Converts a group item into a template.\r\n *\r\n * @param solutionItemId The solution to contain the template\r\n * @param itemInfo Info about the item\r\n * @param destAuthentication Credentials for requests to the destination organization\r\n * @param srcAuthentication Credentials for requests to source items\r\n * @return A promise that will resolve when the template has been created\r\n */\r\nexport function convertItemToTemplate(\r\n solutionItemId: string,\r\n itemInfo: any,\r\n destAuthentication: common.UserSession,\r\n srcAuthentication: common.UserSession\r\n): Promise<common.IItemTemplate> {\r\n return new Promise<common.IItemTemplate>(resolve => {\r\n // Init template\r\n const itemTemplate: common.IItemTemplate = common.createInitializedGroupTemplate(\r\n itemInfo\r\n );\r\n\r\n // Templatize item info property values\r\n itemTemplate.item.id = common.templatizeTerm(\r\n itemTemplate.item.id,\r\n itemTemplate.item.id,\r\n \".itemId\"\r\n );\r\n\r\n // Get the group's items--its dependencies\r\n common.getGroupContents(itemInfo.id, srcAuthentication).then(\r\n groupContents => {\r\n itemTemplate.type = \"Group\";\r\n itemTemplate.dependencies = groupContents;\r\n common.getGroupBase(itemInfo.id, srcAuthentication).then(\r\n groupResponse => {\r\n groupResponse.id = itemTemplate.item.id;\r\n itemTemplate.item = {\r\n ...groupResponse,\r\n type: \"Group\"\r\n };\r\n resolve(itemTemplate);\r\n },\r\n () => resolve(itemTemplate)\r\n );\r\n },\r\n () => resolve(itemTemplate)\r\n );\r\n });\r\n}\r\n\r\nexport function createItemFromTemplate(\r\n template: common.IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: common.UserSession,\r\n itemProgressCallback: common.IItemProgressCallback\r\n): Promise<common.ICreateItemFromTemplateResponse> {\r\n return new Promise<common.ICreateItemFromTemplateResponse>(resolve => {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Started,\r\n 0\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Ignored,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type));\r\n return;\r\n }\r\n\r\n // Replace the templatized symbols in a copy of the template\r\n let newItemTemplate: common.IItemTemplate = common.cloneObject(template);\r\n newItemTemplate = common.replaceInTemplate(\r\n newItemTemplate,\r\n templateDictionary\r\n );\r\n // Need to manually reset thumbnail because adlib in replaceInTemplate breaks it\r\n newItemTemplate.item.thumbnail = template.item.thumbnail;\r\n\r\n // Set up properties needed to create group\r\n const newGroup: common.IGroupAdd = {\r\n title: newItemTemplate.item.title || \"\",\r\n access: \"private\",\r\n owner: newItemTemplate.item.owner,\r\n tags: newItemTemplate.item.tags,\r\n description: newItemTemplate.item.description,\r\n thumbnail: newItemTemplate.item.thumbnail,\r\n snippet: newItemTemplate.item.snippet\r\n };\r\n\r\n // Create a group, appending a sequential suffix to its name if the group exists, e.g.,\r\n // * Manage Right of Way Activities\r\n // * Manage Right of Way Activities 1\r\n // * Manage Right of Way Activities 2\r\n common\r\n .createUniqueGroup(\r\n newGroup.title,\r\n newGroup,\r\n templateDictionary,\r\n destinationAuthentication,\r\n common.isTrackingViewGroup(newItemTemplate) ? templateDictionary.locationTracking.owner : undefined\r\n )\r\n .then(\r\n (createResponse: common.IAddGroupResponse) => {\r\n if (createResponse.success) {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Created,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.group.id\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Cancelled,\r\n 0\r\n );\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common\r\n .removeGroup(createResponse.group.id, destinationAuthentication)\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n ),\r\n () =>\r\n resolve(common.generateEmptyCreationResponse(template.type))\r\n );\r\n } else {\r\n newItemTemplate.itemId = createResponse.group.id;\r\n templateDictionary[template.itemId] = {\r\n itemId: createResponse.group.id\r\n };\r\n\r\n // Update the template again now that we have the new item id\r\n newItemTemplate = common.replaceInTemplate(\r\n newItemTemplate,\r\n templateDictionary\r\n );\r\n\r\n // Update the template dictionary with the new id\r\n templateDictionary[template.itemId].itemId =\r\n createResponse.group.id;\r\n\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Finished,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.group.id\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Cancelled,\r\n 0\r\n );\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common\r\n .removeGroup(\r\n createResponse.group.id,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n ),\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n )\r\n );\r\n } else {\r\n if (common.isTrackingViewGroup(newItemTemplate)) {\r\n const owner: string = templateDictionary.locationTracking.owner;\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common.reassignGroup(\r\n createResponse.group.id,\r\n owner,\r\n destinationAuthentication\r\n ).then(assignResults => {\r\n if (assignResults.success) {\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Created,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.group.id\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Cancelled,\r\n 0\r\n );\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common\r\n .removeGroup(createResponse.group.id, destinationAuthentication)\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n ),\r\n () =>\r\n resolve(common.generateEmptyCreationResponse(template.type))\r\n );\r\n } else {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common.removeUsers(\r\n createResponse.group.id,\r\n [destinationAuthentication.username],\r\n destinationAuthentication\r\n ).then(removeResults => {\r\n if (Array.isArray(removeResults.notRemoved) && removeResults.notRemoved.length === 0) {\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Created,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.group.id\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Cancelled,\r\n 0\r\n );\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common\r\n .removeGroup(createResponse.group.id, destinationAuthentication)\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n ),\r\n () =>\r\n resolve(common.generateEmptyCreationResponse(template.type))\r\n );\r\n } else {\r\n resolve({\r\n item: newItemTemplate,\r\n id: createResponse.group.id,\r\n type: newItemTemplate.type,\r\n postProcess: false\r\n });\r\n }\r\n } else {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item\r\n }\r\n });\r\n }\r\n } else {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item\r\n }\r\n })\r\n } else {\r\n resolve({\r\n item: newItemTemplate,\r\n id: createResponse.group.id,\r\n type: newItemTemplate.type,\r\n postProcess: false\r\n });\r\n }\r\n }\r\n }\r\n } else {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item\r\n }\r\n },\r\n () => {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item\r\n }\r\n );\r\n });\r\n}\r\n"],"names":["solutionItemId","itemInfo","destAuthentication","srcAuthentication","Promise","resolve","itemTemplate","common","createInitializedGroupTemplate","item","id","templatizeTerm","getGroupContents","then","groupContents","type","dependencies","getGroupBase","groupResponse","template","templateDictionary","destinationAuthentication","itemProgressCallback","itemId","EItemProgressStatus","Started","Ignored","generateEmptyCreationResponse","newItemTemplate","cloneObject","replaceInTemplate","thumbnail","newGroup","title","access","owner","tags","description","snippet","createUniqueGroup","isTrackingViewGroup","locationTracking","undefined","createResponse","success","Created","estimatedDeploymentCostFactor","group","Finished","reassignGroup","assignResults","removeUsers","username","removeResults","Array","isArray","notRemoved","length","postProcess","Cancelled","removeGroup","Failed"],"mappings":";;;;;;;;;;;;;;;;;+pBAoCEA,EACAC,EACAC,EACAC,GAEA,OAAO,IAAIC,SAA8BC,IAEvC,MAAMC,EAAqCC,EAAOC,+BAChDP,GAIFK,EAAaG,KAAKC,GAAKH,EAAOI,eAC5BL,EAAaG,KAAKC,GAClBJ,EAAaG,KAAKC,GAClB,WAIFH,EAAOK,iBAAiBX,EAASS,GAAIP,GAAmBU,MACtDC,IACER,EAAaS,KAAO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FxD,EAAQE,EAAOoB,8BAA8BR,EAASJ,gBAI1DV,EAAQ,CACNI,KAAMmB,EACNlB,GAAIiC,EAAeI,MAAMrC,GACzBK,KAAMa,EAAgBb,KACtB2C,aAAa,SAvHjBpC,EACEH,EAASI,OACThB,EAAOiB,oBAAoBmC,UAC3B,GAGFpD,EACGqD,YACCjB,EAAeI,MAAMrC,GACrBW,GAEDR,MACC,IACER,EACEE,EAAOoB,8BAA8BR,EAASJ,SAElD,IACEV,EACEE,EAAOoB,8BAA8BR,EAASJ,cA3DxDO,EACEH,EAASI,OACThB,EAAOiB,oBAAoBmC,UAC3B,GAGFpD,EACGqD,YAAYjB,EAAeI,MAAMrC,GAAIW,GACrCR,MACC,IACER,EACEE,EAAOoB,8BAA8BR,EAASJ,SAElD,IACEV,EAAQE,EAAOoB,8BAA8BR,EAASJ,cAwJ9DO,EACEH,EAASI,OACThB,EAAOiB,oBAAoBqC,OAC3B,GAEFxD,EAAQE,EAAOoB,8BAA8BR,EAASJ,UAG1D,KACEO,EACEH,EAASI,OACThB,EAAOiB,oBAAoBqC,OAC3B,GAEFxD,EAAQE,EAAOoB,8BAA8BR,EAASJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esri/solution-group",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Manages the creation and deployment of group item types for @esri/solution.js.",
|
|
5
5
|
"main": "dist/node/index.js",
|
|
6
6
|
"unpkg": "dist/umd/group.umd.min.js",
|
|
@@ -13,32 +13,32 @@
|
|
|
13
13
|
"dist/**"
|
|
14
14
|
],
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@esri/arcgis-rest-auth": "
|
|
17
|
-
"@esri/arcgis-rest-feature-layer": "
|
|
18
|
-
"@esri/arcgis-rest-portal": "
|
|
19
|
-
"@esri/arcgis-rest-request": "
|
|
20
|
-
"@esri/arcgis-rest-service-admin": "
|
|
21
|
-
"@esri/hub-common": "
|
|
22
|
-
"@esri/hub-initiatives": "
|
|
23
|
-
"@esri/hub-sites": "
|
|
24
|
-
"@esri/hub-teams": "
|
|
25
|
-
"rollup": "^
|
|
26
|
-
"typescript": "^4.
|
|
16
|
+
"@esri/arcgis-rest-auth": "3.4.3",
|
|
17
|
+
"@esri/arcgis-rest-feature-layer": "3.4.3",
|
|
18
|
+
"@esri/arcgis-rest-portal": "3.4.3",
|
|
19
|
+
"@esri/arcgis-rest-request": "3.4.3",
|
|
20
|
+
"@esri/arcgis-rest-service-admin": "3.4.3",
|
|
21
|
+
"@esri/hub-common": "9.7.2",
|
|
22
|
+
"@esri/hub-initiatives": "9.7.2",
|
|
23
|
+
"@esri/hub-sites": "9.7.2",
|
|
24
|
+
"@esri/hub-teams": "9.7.2",
|
|
25
|
+
"rollup": "^2.60.0",
|
|
26
|
+
"typescript": "^4.4.4"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@esri/arcgis-rest-auth": "
|
|
30
|
-
"@esri/arcgis-rest-feature-layer": "
|
|
31
|
-
"@esri/arcgis-rest-portal": "
|
|
32
|
-
"@esri/arcgis-rest-request": "
|
|
33
|
-
"@esri/arcgis-rest-service-admin": "
|
|
34
|
-
"@esri/hub-common": "
|
|
35
|
-
"@esri/hub-initiatives": "
|
|
36
|
-
"@esri/hub-sites": "
|
|
37
|
-
"@esri/hub-teams": "
|
|
29
|
+
"@esri/arcgis-rest-auth": "3.4.3",
|
|
30
|
+
"@esri/arcgis-rest-feature-layer": "3.4.3",
|
|
31
|
+
"@esri/arcgis-rest-portal": "3.4.3",
|
|
32
|
+
"@esri/arcgis-rest-request": "3.4.3",
|
|
33
|
+
"@esri/arcgis-rest-service-admin": "3.4.3",
|
|
34
|
+
"@esri/hub-common": "9.7.2",
|
|
35
|
+
"@esri/hub-initiatives": "9.7.2",
|
|
36
|
+
"@esri/hub-sites": "9.7.2",
|
|
37
|
+
"@esri/hub-teams": "9.7.2"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@esri/solution-common": "^1.
|
|
41
|
-
"tslib": "
|
|
40
|
+
"@esri/solution-common": "^1.2.0",
|
|
41
|
+
"tslib": "1.13.0"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"prepare": "npm run build",
|
|
@@ -90,5 +90,5 @@
|
|
|
90
90
|
"esri",
|
|
91
91
|
"ES6"
|
|
92
92
|
],
|
|
93
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "70f706fb28a50db0b9b13030f263f8e9e270b98d"
|
|
94
94
|
}
|