@esri/solution-group 4.1.2 → 5.0.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.
@@ -1,45 +1,45 @@
1
- /** @license
2
- * Copyright 2019 Esri
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- /**
17
- * Manages the creation and deployment of groups.
18
- *
19
- * @module group
20
- */
21
- import * as common from "@esri/solution-common";
22
- /**
23
- * Converts a group item into a template.
24
- *
25
- * @param solutionItemId The solution to contain the template
26
- * @param itemInfo Info about the item
27
- * @param destAuthentication Credentials for requests to the destination organization
28
- * @param srcAuthentication Credentials for requests to source items
29
- * @returns A promise that will resolve when the template has been created
30
- */
31
- export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, destAuthentication: common.UserSession, srcAuthentication: common.UserSession): Promise<common.IItemTemplate>;
32
- export declare function createItemFromTemplate(template: common.IItemTemplate, templateDictionary: any, destinationAuthentication: common.UserSession, itemProgressCallback: common.IItemProgressCallback): Promise<common.ICreateItemFromTemplateResponse>;
33
- /**
34
- * Group post-processing actions
35
- *
36
- * @param {string} id The item ID
37
- * @param {string} type The template type
38
- * @param {any[]} itemInfos Array of \{id: 'ef3', type: 'Web Map'\} objects
39
- * @param {common.IItemTemplate} template The original template
40
- * @param {common.IItemTemplate[]} templates The original templates
41
- * @param {any} templateDictionary The template dictionary
42
- * @param {UserSession} authentication The destination session info
43
- * @returns Promise resolving to successfulness of update
44
- */
45
- export declare function postProcess(id: string, type: string, itemInfos: any[], template: common.IItemTemplate, templates: common.IItemTemplate[], templateDictionary: any, authentication: any): Promise<any>;
1
+ /** @license
2
+ * Copyright 2019 Esri
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Manages the creation and deployment of groups.
18
+ *
19
+ * @module group
20
+ */
21
+ import * as common from "@esri/solution-common";
22
+ /**
23
+ * Converts a group item into a template.
24
+ *
25
+ * @param solutionItemId The solution to contain the template
26
+ * @param itemInfo Info about the item
27
+ * @param destAuthentication Credentials for requests to the destination organization
28
+ * @param srcAuthentication Credentials for requests to source items
29
+ * @returns A promise that will resolve when the template has been created
30
+ */
31
+ export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, destAuthentication: common.UserSession, srcAuthentication: common.UserSession): Promise<common.IItemTemplate>;
32
+ export declare function createItemFromTemplate(template: common.IItemTemplate, templateDictionary: any, destinationAuthentication: common.UserSession, itemProgressCallback: common.IItemProgressCallback): Promise<common.ICreateItemFromTemplateResponse>;
33
+ /**
34
+ * Group post-processing actions
35
+ *
36
+ * @param {string} id The item ID
37
+ * @param {string} type The template type
38
+ * @param {any[]} itemInfos Array of \{id: 'ef3', type: 'Web Map'\} objects
39
+ * @param {common.IItemTemplate} template The original template
40
+ * @param {common.IItemTemplate[]} templates The original templates
41
+ * @param {any} templateDictionary The template dictionary
42
+ * @param {UserSession} authentication The destination session info
43
+ * @returns Promise resolving to successfulness of update
44
+ */
45
+ export declare function postProcess(id: string, type: string, itemInfos: any[], template: common.IItemTemplate, templates: common.IItemTemplate[], templateDictionary: any, authentication: any): Promise<any>;
package/dist/esm/group.js CHANGED
@@ -1,216 +1,216 @@
1
- /** @license
2
- * Copyright 2019 Esri
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- /**
17
- * Manages the creation and deployment of groups.
18
- *
19
- * @module group
20
- */
21
- import * as common from "@esri/solution-common";
22
- // ------------------------------------------------------------------------------------------------------------------ //
23
- /**
24
- * Converts a group item into a template.
25
- *
26
- * @param solutionItemId The solution to contain the template
27
- * @param itemInfo Info about the item
28
- * @param destAuthentication Credentials for requests to the destination organization
29
- * @param srcAuthentication Credentials for requests to source items
30
- * @returns A promise that will resolve when the template has been created
31
- */
32
- export function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication) {
33
- return new Promise(resolve => {
34
- // Init template
35
- const itemTemplate = common.createInitializedGroupTemplate(itemInfo);
36
- // Templatize item info property values
37
- itemTemplate.item.id = common.templatizeTerm(itemTemplate.item.id, itemTemplate.item.id, ".itemId");
38
- // Get the group's items--its dependencies
39
- common.getGroupContents(itemInfo.id, srcAuthentication).then(groupContents => {
40
- itemTemplate.type = "Group";
41
- itemTemplate.dependencies = groupContents;
42
- common.getGroupBase(itemInfo.id, srcAuthentication).then(groupResponse => {
43
- groupResponse.id = itemTemplate.item.id;
44
- itemTemplate.item = {
45
- ...groupResponse,
46
- type: "Group"
47
- };
48
- resolve(itemTemplate);
49
- }, () => resolve(itemTemplate));
50
- }, () => resolve(itemTemplate));
51
- });
52
- }
53
- export function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
54
- return new Promise(resolve => {
55
- // Interrupt process if progress callback returns `false`
56
- if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Started, 0)) {
57
- itemProgressCallback(template.itemId, common.EItemProgressStatus.Ignored, 0);
58
- resolve(common.generateEmptyCreationResponse(template.type));
59
- return;
60
- }
61
- // Replace the templatized symbols in a copy of the template
62
- let newItemTemplate = common.cloneObject(template);
63
- newItemTemplate = common.replaceInTemplate(newItemTemplate, templateDictionary);
64
- // Need to manually reset thumbnail because adlib in replaceInTemplate breaks it
65
- newItemTemplate.item.thumbnail = template.item.thumbnail;
66
- // Set up properties needed to create group
67
- const newGroup = {
68
- title: newItemTemplate.item.title || "",
69
- access: "private",
70
- owner: newItemTemplate.item.owner,
71
- tags: newItemTemplate.item.tags,
72
- typeKeywords: newItemTemplate.item.typeKeywords,
73
- description: newItemTemplate.item.description,
74
- thumbnail: newItemTemplate.item.thumbnail,
75
- snippet: newItemTemplate.item.snippet
76
- };
77
- const props = [
78
- "isInvitationOnly", "autoJoin", "membershipAccess", "isViewOnly", "sortField", "sortOrder", "isOpenData", "displaySettings"
79
- ];
80
- props.forEach(p => {
81
- /* istanbul ignore else */
82
- if (newItemTemplate.item.hasOwnProperty(p)) {
83
- newGroup[p] = newItemTemplate.item[p];
84
- }
85
- });
86
- // Create a group, appending a sequential suffix to its name if the group exists, e.g.,
87
- // * Manage Right of Way Activities
88
- // * Manage Right of Way Activities 1
89
- // * Manage Right of Way Activities 2
90
- common
91
- .createUniqueGroup(newGroup.title, newGroup, templateDictionary, destinationAuthentication, common.isTrackingViewGroup(newItemTemplate) ? templateDictionary.locationTracking.owner : undefined)
92
- .then((createResponse) => {
93
- if (createResponse.success) {
94
- // Interrupt process if progress callback returns `false`
95
- if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.group.id)) {
96
- itemProgressCallback(template.itemId, common.EItemProgressStatus.Cancelled, 0);
97
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
98
- common
99
- .removeGroup(createResponse.group.id, destinationAuthentication)
100
- .then(() => resolve(common.generateEmptyCreationResponse(template.type)), () => resolve(common.generateEmptyCreationResponse(template.type)));
101
- }
102
- else {
103
- newItemTemplate.itemId = createResponse.group.id;
104
- templateDictionary[template.itemId] = {
105
- itemId: createResponse.group.id
106
- };
107
- // Update the template again now that we have the new item id
108
- newItemTemplate = common.replaceInTemplate(newItemTemplate, templateDictionary);
109
- // Update the template dictionary with the new id
110
- templateDictionary[template.itemId].itemId =
111
- createResponse.group.id;
112
- // Interrupt process if progress callback returns `false`
113
- if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor / 2, createResponse.group.id)) {
114
- itemProgressCallback(template.itemId, common.EItemProgressStatus.Cancelled, 0);
115
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
116
- common
117
- .removeGroup(createResponse.group.id, destinationAuthentication)
118
- .then(() => resolve(common.generateEmptyCreationResponse(template.type)), () => resolve(common.generateEmptyCreationResponse(template.type)));
119
- }
120
- else {
121
- if (common.isTrackingViewGroup(newItemTemplate)) {
122
- const owner = templateDictionary.locationTracking.owner;
123
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
124
- common.reassignGroup(createResponse.group.id, owner, destinationAuthentication).then(assignResults => {
125
- if (assignResults.success) {
126
- if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.group.id)) {
127
- itemProgressCallback(template.itemId, common.EItemProgressStatus.Cancelled, 0);
128
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
129
- common
130
- .removeGroup(createResponse.group.id, destinationAuthentication)
131
- .then(() => resolve(common.generateEmptyCreationResponse(template.type)), () => resolve(common.generateEmptyCreationResponse(template.type)));
132
- }
133
- else {
134
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
135
- common.removeUsers(createResponse.group.id, [destinationAuthentication.username], destinationAuthentication).then(removeResults => {
136
- if (Array.isArray(removeResults.notRemoved) && removeResults.notRemoved.length === 0) {
137
- if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.group.id)) {
138
- itemProgressCallback(template.itemId, common.EItemProgressStatus.Cancelled, 0);
139
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
140
- common
141
- .removeGroup(createResponse.group.id, destinationAuthentication)
142
- .then(() => resolve(common.generateEmptyCreationResponse(template.type)), () => resolve(common.generateEmptyCreationResponse(template.type)));
143
- }
144
- else {
145
- resolve({
146
- item: newItemTemplate,
147
- id: createResponse.group.id,
148
- type: newItemTemplate.type,
149
- postProcess: common.hasUnresolvedVariables(newItemTemplate)
150
- });
151
- }
152
- }
153
- else {
154
- itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
155
- resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item
156
- }
157
- });
158
- }
159
- }
160
- else {
161
- itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
162
- resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item
163
- }
164
- });
165
- }
166
- else {
167
- resolve({
168
- item: newItemTemplate,
169
- id: createResponse.group.id,
170
- type: newItemTemplate.type,
171
- postProcess: common.hasUnresolvedVariables(newItemTemplate)
172
- });
173
- }
174
- }
175
- }
176
- }
177
- else {
178
- itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
179
- resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item
180
- }
181
- }, () => {
182
- itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
183
- resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item
184
- });
185
- });
186
- }
187
- /**
188
- * Group post-processing actions
189
- *
190
- * @param {string} id The item ID
191
- * @param {string} type The template type
192
- * @param {any[]} itemInfos Array of \{id: 'ef3', type: 'Web Map'\} objects
193
- * @param {common.IItemTemplate} template The original template
194
- * @param {common.IItemTemplate[]} templates The original templates
195
- * @param {any} templateDictionary The template dictionary
196
- * @param {UserSession} authentication The destination session info
197
- * @returns Promise resolving to successfulness of update
198
- */
199
- export function postProcess(id, type, itemInfos, template, templates, templateDictionary, authentication) {
200
- let promise = Promise.resolve({ success: true });
201
- itemInfos.some(t => {
202
- /* istanbul ignore else */
203
- if (t.id === id) {
204
- let group = t.item.item;
205
- /* istanbul ignore else */
206
- if (common.hasUnresolvedVariables(group)) {
207
- group = common.replaceInTemplate(group, templateDictionary);
208
- // update the group
209
- promise = common.updateGroup(group, authentication);
210
- }
211
- return true;
212
- }
213
- });
214
- return promise;
215
- }
1
+ /** @license
2
+ * Copyright 2019 Esri
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Manages the creation and deployment of groups.
18
+ *
19
+ * @module group
20
+ */
21
+ import * as common from "@esri/solution-common";
22
+ // ------------------------------------------------------------------------------------------------------------------ //
23
+ /**
24
+ * Converts a group item into a template.
25
+ *
26
+ * @param solutionItemId The solution to contain the template
27
+ * @param itemInfo Info about the item
28
+ * @param destAuthentication Credentials for requests to the destination organization
29
+ * @param srcAuthentication Credentials for requests to source items
30
+ * @returns A promise that will resolve when the template has been created
31
+ */
32
+ export function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication) {
33
+ return new Promise(resolve => {
34
+ // Init template
35
+ const itemTemplate = common.createInitializedGroupTemplate(itemInfo);
36
+ // Templatize item info property values
37
+ itemTemplate.item.id = common.templatizeTerm(itemTemplate.item.id, itemTemplate.item.id, ".itemId");
38
+ // Get the group's items--its dependencies
39
+ common.getGroupContents(itemInfo.id, srcAuthentication).then(groupContents => {
40
+ itemTemplate.type = "Group";
41
+ itemTemplate.dependencies = groupContents;
42
+ common.getGroupBase(itemInfo.id, srcAuthentication).then(groupResponse => {
43
+ groupResponse.id = itemTemplate.item.id;
44
+ itemTemplate.item = {
45
+ ...groupResponse,
46
+ type: "Group"
47
+ };
48
+ resolve(itemTemplate);
49
+ }, () => resolve(itemTemplate));
50
+ }, () => resolve(itemTemplate));
51
+ });
52
+ }
53
+ export function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
54
+ return new Promise(resolve => {
55
+ // Interrupt process if progress callback returns `false`
56
+ if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Started, 0)) {
57
+ itemProgressCallback(template.itemId, common.EItemProgressStatus.Ignored, 0);
58
+ resolve(common.generateEmptyCreationResponse(template.type));
59
+ return;
60
+ }
61
+ // Replace the templatized symbols in a copy of the template
62
+ let newItemTemplate = common.cloneObject(template);
63
+ newItemTemplate = common.replaceInTemplate(newItemTemplate, templateDictionary);
64
+ // Need to manually reset thumbnail because adlib in replaceInTemplate breaks it
65
+ newItemTemplate.item.thumbnail = template.item.thumbnail;
66
+ // Set up properties needed to create group
67
+ const newGroup = {
68
+ title: newItemTemplate.item.title || "",
69
+ access: "private",
70
+ owner: newItemTemplate.item.owner,
71
+ tags: newItemTemplate.item.tags,
72
+ typeKeywords: newItemTemplate.item.typeKeywords,
73
+ description: newItemTemplate.item.description,
74
+ thumbnail: newItemTemplate.item.thumbnail,
75
+ snippet: newItemTemplate.item.snippet
76
+ };
77
+ const props = [
78
+ "isInvitationOnly", "autoJoin", "membershipAccess", "isViewOnly", "sortField", "sortOrder", "isOpenData", "displaySettings"
79
+ ];
80
+ props.forEach(p => {
81
+ /* istanbul ignore else */
82
+ if (newItemTemplate.item.hasOwnProperty(p)) {
83
+ newGroup[p] = newItemTemplate.item[p];
84
+ }
85
+ });
86
+ // Create a group, appending a sequential suffix to its name if the group exists, e.g.,
87
+ // * Manage Right of Way Activities
88
+ // * Manage Right of Way Activities 1
89
+ // * Manage Right of Way Activities 2
90
+ common
91
+ .createUniqueGroup(newGroup.title, newGroup, templateDictionary, destinationAuthentication, common.isTrackingViewGroup(newItemTemplate) ? templateDictionary.locationTracking.owner : undefined)
92
+ .then((createResponse) => {
93
+ if (createResponse.success) {
94
+ // Interrupt process if progress callback returns `false`
95
+ if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.group.id)) {
96
+ itemProgressCallback(template.itemId, common.EItemProgressStatus.Cancelled, 0);
97
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
98
+ common
99
+ .removeGroup(createResponse.group.id, destinationAuthentication)
100
+ .then(() => resolve(common.generateEmptyCreationResponse(template.type)), () => resolve(common.generateEmptyCreationResponse(template.type)));
101
+ }
102
+ else {
103
+ newItemTemplate.itemId = createResponse.group.id;
104
+ templateDictionary[template.itemId] = {
105
+ itemId: createResponse.group.id
106
+ };
107
+ // Update the template again now that we have the new item id
108
+ newItemTemplate = common.replaceInTemplate(newItemTemplate, templateDictionary);
109
+ // Update the template dictionary with the new id
110
+ templateDictionary[template.itemId].itemId =
111
+ createResponse.group.id;
112
+ // Interrupt process if progress callback returns `false`
113
+ if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor / 2, createResponse.group.id)) {
114
+ itemProgressCallback(template.itemId, common.EItemProgressStatus.Cancelled, 0);
115
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
116
+ common
117
+ .removeGroup(createResponse.group.id, destinationAuthentication)
118
+ .then(() => resolve(common.generateEmptyCreationResponse(template.type)), () => resolve(common.generateEmptyCreationResponse(template.type)));
119
+ }
120
+ else {
121
+ if (common.isTrackingViewGroup(newItemTemplate)) {
122
+ const owner = templateDictionary.locationTracking.owner;
123
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
124
+ common.reassignGroup(createResponse.group.id, owner, destinationAuthentication).then(assignResults => {
125
+ if (assignResults.success) {
126
+ if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.group.id)) {
127
+ itemProgressCallback(template.itemId, common.EItemProgressStatus.Cancelled, 0);
128
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
129
+ common
130
+ .removeGroup(createResponse.group.id, destinationAuthentication)
131
+ .then(() => resolve(common.generateEmptyCreationResponse(template.type)), () => resolve(common.generateEmptyCreationResponse(template.type)));
132
+ }
133
+ else {
134
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
135
+ common.removeUsers(createResponse.group.id, [destinationAuthentication.username], destinationAuthentication).then(removeResults => {
136
+ if (Array.isArray(removeResults.notRemoved) && removeResults.notRemoved.length === 0) {
137
+ if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.group.id)) {
138
+ itemProgressCallback(template.itemId, common.EItemProgressStatus.Cancelled, 0);
139
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
140
+ common
141
+ .removeGroup(createResponse.group.id, destinationAuthentication)
142
+ .then(() => resolve(common.generateEmptyCreationResponse(template.type)), () => resolve(common.generateEmptyCreationResponse(template.type)));
143
+ }
144
+ else {
145
+ resolve({
146
+ item: newItemTemplate,
147
+ id: createResponse.group.id,
148
+ type: newItemTemplate.type,
149
+ postProcess: common.hasUnresolvedVariables(newItemTemplate)
150
+ });
151
+ }
152
+ }
153
+ else {
154
+ itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
155
+ resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item
156
+ }
157
+ });
158
+ }
159
+ }
160
+ else {
161
+ itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
162
+ resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item
163
+ }
164
+ });
165
+ }
166
+ else {
167
+ resolve({
168
+ item: newItemTemplate,
169
+ id: createResponse.group.id,
170
+ type: newItemTemplate.type,
171
+ postProcess: common.hasUnresolvedVariables(newItemTemplate)
172
+ });
173
+ }
174
+ }
175
+ }
176
+ }
177
+ else {
178
+ itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
179
+ resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item
180
+ }
181
+ }, () => {
182
+ itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
183
+ resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item
184
+ });
185
+ });
186
+ }
187
+ /**
188
+ * Group post-processing actions
189
+ *
190
+ * @param {string} id The item ID
191
+ * @param {string} type The template type
192
+ * @param {any[]} itemInfos Array of \{id: 'ef3', type: 'Web Map'\} objects
193
+ * @param {common.IItemTemplate} template The original template
194
+ * @param {common.IItemTemplate[]} templates The original templates
195
+ * @param {any} templateDictionary The template dictionary
196
+ * @param {UserSession} authentication The destination session info
197
+ * @returns Promise resolving to successfulness of update
198
+ */
199
+ export function postProcess(id, type, itemInfos, template, templates, templateDictionary, authentication) {
200
+ let promise = Promise.resolve({ success: true });
201
+ itemInfos.some(t => {
202
+ /* istanbul ignore else */
203
+ if (t.id === id) {
204
+ let group = t.item.item;
205
+ /* istanbul ignore else */
206
+ if (common.hasUnresolvedVariables(group)) {
207
+ group = common.replaceInTemplate(group, templateDictionary);
208
+ // update the group
209
+ promise = common.updateGroup(group, authentication);
210
+ }
211
+ return true;
212
+ }
213
+ });
214
+ return promise;
215
+ }
216
216
  //# sourceMappingURL=group.js.map
@@ -1,21 +1,21 @@
1
- /** @license
2
- * Copyright 2018 Esri
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- /**
17
- * Manages the creation and deployment of simple item types.
18
- *
19
- * @module simple-types
20
- */
21
- export * from "./group";
1
+ /** @license
2
+ * Copyright 2018 Esri
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Manages the creation and deployment of simple item types.
18
+ *
19
+ * @module simple-types
20
+ */
21
+ export * from "./group";
package/dist/esm/index.js CHANGED
@@ -1,22 +1,22 @@
1
- /** @license
2
- * Copyright 2018 Esri
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- /**
17
- * Manages the creation and deployment of simple item types.
18
- *
19
- * @module simple-types
20
- */
21
- export * from "./group";
1
+ /** @license
2
+ * Copyright 2018 Esri
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Manages the creation and deployment of simple item types.
18
+ *
19
+ * @module simple-types
20
+ */
21
+ export * from "./group";
22
22
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esri/solution-group",
3
- "version": "4.1.2",
3
+ "version": "5.0.0",
4
4
  "description": "Manages the creation and deployment of group item types for @esri/solution.js.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -27,7 +27,7 @@
27
27
  "@esri/hub-initiatives": "^13.0.0",
28
28
  "@esri/hub-sites": "^13.0.1",
29
29
  "@esri/hub-teams": "^13.0.0",
30
- "@esri/solution-common": "^4.1.2",
30
+ "@esri/solution-common": "^5.0.0",
31
31
  "rollup": "2.79.1"
32
32
  },
33
33
  "dependencies": {
@@ -85,5 +85,5 @@
85
85
  "esri",
86
86
  "ES6"
87
87
  ],
88
- "gitHead": "13ea49fdd2fc75cabe55a19c3620580c4c47643d"
88
+ "gitHead": "a6cbcc049fb712d19e98b7d59a94734aad4dd17f"
89
89
  }