@esri/solution-group 4.1.2 → 5.0.1

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