@esri/solution-hub-types 4.1.2-alpha.0 → 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.
Files changed (35) hide show
  1. package/dist/cjs/helpers/_post-process-page.d.ts +17 -17
  2. package/dist/cjs/helpers/_post-process-page.js +32 -32
  3. package/dist/cjs/helpers/_post-process-page.js.map +1 -1
  4. package/dist/cjs/helpers/_post-process-site.d.ts +29 -29
  5. package/dist/cjs/helpers/_post-process-site.js +50 -50
  6. package/dist/cjs/helpers/_update-site-pages.d.ts +24 -24
  7. package/dist/cjs/helpers/_update-site-pages.js +42 -42
  8. package/dist/cjs/helpers/move-model-to-folder.d.ts +26 -26
  9. package/dist/cjs/helpers/move-model-to-folder.js +49 -49
  10. package/dist/cjs/helpers/replace-item-ids.d.ts +17 -17
  11. package/dist/cjs/helpers/replace-item-ids.js +36 -36
  12. package/dist/cjs/hub-page-processor.d.ts +63 -63
  13. package/dist/cjs/hub-page-processor.js +227 -227
  14. package/dist/cjs/hub-site-processor.d.ts +65 -65
  15. package/dist/cjs/hub-site-processor.js +231 -231
  16. package/dist/cjs/index.d.ts +23 -23
  17. package/dist/cjs/index.js +28 -28
  18. package/dist/esm/helpers/_post-process-page.d.ts +17 -17
  19. package/dist/esm/helpers/_post-process-page.js +28 -28
  20. package/dist/esm/helpers/_post-process-page.js.map +1 -1
  21. package/dist/esm/helpers/_post-process-site.d.ts +29 -29
  22. package/dist/esm/helpers/_post-process-site.js +46 -46
  23. package/dist/esm/helpers/_update-site-pages.d.ts +24 -24
  24. package/dist/esm/helpers/_update-site-pages.js +38 -38
  25. package/dist/esm/helpers/move-model-to-folder.d.ts +26 -26
  26. package/dist/esm/helpers/move-model-to-folder.js +45 -45
  27. package/dist/esm/helpers/replace-item-ids.d.ts +17 -17
  28. package/dist/esm/helpers/replace-item-ids.js +32 -32
  29. package/dist/esm/hub-page-processor.d.ts +63 -63
  30. package/dist/esm/hub-page-processor.js +220 -220
  31. package/dist/esm/hub-site-processor.d.ts +65 -65
  32. package/dist/esm/hub-site-processor.js +224 -224
  33. package/dist/esm/index.d.ts +23 -23
  34. package/dist/esm/index.js +24 -24
  35. package/package.json +3 -3
@@ -1,65 +1,65 @@
1
- /** @license
2
- * Copyright 2020 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 Hub Site item types.
18
- *
19
- * @module hub-site-processor
20
- */
21
- import { IItemTemplate, IItemProgressCallback, ICreateItemFromTemplateResponse, UserSession } from "@esri/solution-common";
22
- /**
23
- * Converts a Site 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 (placeholder--not used)
29
- * @returns A promise that will resolve when the template has been created
30
- */
31
- export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, destAuthentication: UserSession, srcAuthentication?: UserSession): Promise<IItemTemplate>;
32
- /**
33
- * Handle deployment of Site item templates
34
- *
35
- * @export
36
- * @param {IItemTemplate} template
37
- * @param {*} templateDictionary
38
- * @param {UserSession} destinationAuthentication
39
- * @param {IItemProgressCallback} itemProgressCallback
40
- * @returns {Promise<ICreateItemFromTemplateResponse>}
41
- */
42
- export declare function createItemFromTemplate(template: IItemTemplate, templateDictionary: any, destinationAuthentication: UserSession, itemProgressCallback: IItemProgressCallback): Promise<ICreateItemFromTemplateResponse>;
43
- /**
44
- * Deployer life-cycle hook allowing the Site Processor
45
- * a chance to apply final processes to all the items that
46
- * were created as part of the solution.
47
- * Specifically this will:
48
- * - share all items to the content team, and (if created)
49
- * the core team (depends on user privs)
50
- * - link all Page items that were created, to the Site
51
- *
52
- * @param model
53
- * @param items
54
- * @param authentication
55
- * @param templateDictionary
56
- */
57
- export declare function postProcess(id: string, type: string, itemInfos: any[], template: any, templates: IItemTemplate[], templateDictionary: any, authentication: UserSession): Promise<boolean>;
58
- /**
59
- * Check of an item type is a Site
60
- * Hub Site Application is for ArcGIS Online
61
- * Site Application is for ArcGIS Enterprise
62
- *
63
- * @param itemType
64
- */
65
- export declare function isASite(itemType: string): boolean;
1
+ /** @license
2
+ * Copyright 2020 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 Hub Site item types.
18
+ *
19
+ * @module hub-site-processor
20
+ */
21
+ import { IItemTemplate, IItemProgressCallback, ICreateItemFromTemplateResponse, UserSession } from "@esri/solution-common";
22
+ /**
23
+ * Converts a Site 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 (placeholder--not used)
29
+ * @returns A promise that will resolve when the template has been created
30
+ */
31
+ export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, destAuthentication: UserSession, srcAuthentication?: UserSession): Promise<IItemTemplate>;
32
+ /**
33
+ * Handle deployment of Site item templates
34
+ *
35
+ * @export
36
+ * @param {IItemTemplate} template
37
+ * @param {*} templateDictionary
38
+ * @param {UserSession} destinationAuthentication
39
+ * @param {IItemProgressCallback} itemProgressCallback
40
+ * @returns {Promise<ICreateItemFromTemplateResponse>}
41
+ */
42
+ export declare function createItemFromTemplate(template: IItemTemplate, templateDictionary: any, destinationAuthentication: UserSession, itemProgressCallback: IItemProgressCallback): Promise<ICreateItemFromTemplateResponse>;
43
+ /**
44
+ * Deployer life-cycle hook allowing the Site Processor
45
+ * a chance to apply final processes to all the items that
46
+ * were created as part of the solution.
47
+ * Specifically this will:
48
+ * - share all items to the content team, and (if created)
49
+ * the core team (depends on user privs)
50
+ * - link all Page items that were created, to the Site
51
+ *
52
+ * @param model
53
+ * @param items
54
+ * @param authentication
55
+ * @param templateDictionary
56
+ */
57
+ export declare function postProcess(id: string, type: string, itemInfos: any[], template: any, templates: IItemTemplate[], templateDictionary: any, authentication: UserSession): Promise<boolean>;
58
+ /**
59
+ * Check of an item type is a Site
60
+ * Hub Site Application is for ArcGIS Online
61
+ * Site Application is for ArcGIS Enterprise
62
+ *
63
+ * @param itemType
64
+ */
65
+ export declare function isASite(itemType: string): boolean;
@@ -1,232 +1,232 @@
1
- "use strict";
2
- /** @license
3
- * Copyright 2020 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.isASite = exports.postProcess = exports.createItemFromTemplate = exports.convertItemToTemplate = void 0;
19
- /**
20
- * Manages the creation and deployment of Hub Site item types.
21
- *
22
- * @module hub-site-processor
23
- */
24
- const solution_common_1 = require("@esri/solution-common");
25
- const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
26
- const hub_sites_1 = require("@esri/hub-sites");
27
- const hub_common_1 = require("@esri/hub-common");
28
- const move_model_to_folder_1 = require("./helpers/move-model-to-folder");
29
- const _post_process_site_1 = require("./helpers/_post-process-site");
30
- const replace_item_ids_1 = require("./helpers/replace-item-ids");
31
- /**
32
- * Converts a Site item into a template.
33
- *
34
- * @param solutionItemId The solution to contain the template
35
- * @param itemInfo Info about the item
36
- * @param destAuthentication Credentials for requests to the destination organization
37
- * @param srcAuthentication Credentials for requests to source items (placeholder--not used)
38
- * @returns A promise that will resolve when the template has been created
39
- */
40
- function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication = null // eslint-disable-line @typescript-eslint/no-unused-vars
41
- ) {
42
- let created = 0;
43
- let modified = 0;
44
- let hubRo;
45
- // get hubRequestOptions
46
- return (0, solution_common_1.createHubRequestOptions)(destAuthentication)
47
- .then(ro => {
48
- hubRo = ro;
49
- return (0, hub_sites_1.getSiteById)(itemInfo.id, hubRo);
50
- })
51
- .then(siteModel => {
52
- // We need to save these properties in order to restore them after hub.js deletes them
53
- created = siteModel.item.created;
54
- modified = siteModel.item.modified;
55
- return (0, hub_sites_1.convertSiteToTemplate)(siteModel, hubRo);
56
- })
57
- .then(tmpl => {
58
- // add in some stuff Hub.js does not yet add
59
- tmpl.item.created = created;
60
- tmpl.item.modified = modified;
61
- tmpl.item.typeKeywords = (0, hub_common_1.without)(tmpl.item.typeKeywords, "doNotDelete");
62
- tmpl.groups = [];
63
- tmpl.estimatedDeploymentCostFactor = 2;
64
- tmpl.resources = [];
65
- if (!(0, solution_common_1.getProp)(tmpl, "properties")) {
66
- tmpl.properties = {};
67
- }
68
- // swap out dependency id's to {{<depid>.itemId}}
69
- // so it will be re-interpolated
70
- tmpl.dependencies = (0, solution_common_1.dedupe)(tmpl.dependencies);
71
- tmpl = (0, replace_item_ids_1.replaceItemIds)(tmpl);
72
- // and return it
73
- return tmpl;
74
- });
75
- }
76
- exports.convertItemToTemplate = convertItemToTemplate;
77
- /**
78
- * Handle deployment of Site item templates
79
- *
80
- * @export
81
- * @param {IItemTemplate} template
82
- * @param {*} templateDictionary
83
- * @param {UserSession} destinationAuthentication
84
- * @param {IItemProgressCallback} itemProgressCallback
85
- * @returns {Promise<ICreateItemFromTemplateResponse>}
86
- */
87
- function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
88
- // let the progress system know we've started...
89
- const startStatus = itemProgressCallback(template.itemId, solution_common_1.EItemProgressStatus.Started, 0);
90
- // if it returned false, just resolve out
91
- if (!startStatus) {
92
- return Promise.resolve((0, solution_common_1.generateEmptyCreationResponse)(template.type));
93
- }
94
- // TODO: Reassess with resource unification
95
- if (template.assets && template.resources) {
96
- delete template.assets;
97
- }
98
- // ensure we have a solution object in the templateDictionary hash
99
- if (!templateDictionary.solution) {
100
- templateDictionary.solution = {};
101
- }
102
- // .title should always be set on the templateDictionary
103
- templateDictionary.solution.title = templateDictionary.title;
104
- // TODO: Determine if we need any transforms in this new env
105
- const transforms = {};
106
- // create an object to hold the created site through
107
- // subsequent promise calls
108
- let siteModel;
109
- // Create the "siteModel" from the template. Does not save the site item yet
110
- // Note: depending on licensing and user privs, will also create the team groups
111
- // and initiative item.
112
- let hubRo;
113
- const thumbnail = template.item.thumbnail; // createSiteModelFromTemplate trashes thumbnail
114
- return (0, solution_common_1.createHubRequestOptions)(destinationAuthentication, templateDictionary)
115
- .then(ro => {
116
- hubRo = ro;
117
- return (0, hub_sites_1.createSiteModelFromTemplate)(template, templateDictionary, transforms, hubRo);
118
- })
119
- .then(interpolated => {
120
- const options = {
121
- assets: interpolated.assets || []
122
- };
123
- // Now create the item, register for oAuth, register domain etc
124
- return (0, hub_sites_1.createSite)(interpolated, options, hubRo);
125
- })
126
- .then(site => {
127
- // hold onto the site
128
- siteModel = site;
129
- // Move the site and initiative to the solution folder
130
- // this is essentially fire and forget. We fail-safe the actual moveItem
131
- // call since it's not critical to the outcome
132
- return (0, move_model_to_folder_1.moveModelToFolder)(site, templateDictionary.folderId, destinationAuthentication);
133
- })
134
- .then(() => {
135
- // Fix the thumbnail
136
- const updateOptions = {
137
- item: {
138
- id: siteModel.item.id
139
- },
140
- params: {
141
- // Pass thumbnail in via params because item property is serialized, which discards a blob
142
- thumbnail
143
- },
144
- authentication: destinationAuthentication
145
- };
146
- return (0, arcgis_rest_portal_1.updateItem)(updateOptions);
147
- })
148
- .then(() => {
149
- // Update the template dictionary
150
- // TODO: This should be done in whatever recieves
151
- // the outcome of this promise chain
152
- templateDictionary[template.itemId] = {
153
- itemId: siteModel.item.id
154
- };
155
- // call the progress callback, which also mutates templateDictionary
156
- const finalStatus = itemProgressCallback(template.itemId, solution_common_1.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor || 2, siteModel.item.id);
157
- if (!finalStatus) {
158
- // clean up the site we just created
159
- const failSafeRemove = (0, hub_common_1.failSafe)(hub_sites_1.removeSite, { success: true });
160
- return failSafeRemove(siteModel, hubRo).then(() => {
161
- return Promise.resolve((0, solution_common_1.generateEmptyCreationResponse)(template.type));
162
- });
163
- }
164
- else {
165
- // finally, return ICreateItemFromTemplateResponse
166
- const response = {
167
- item: {
168
- ...template,
169
- ...(0, solution_common_1.convertIModel)(siteModel)
170
- },
171
- id: siteModel.item.id,
172
- type: template.type,
173
- postProcess: true
174
- };
175
- response.item.itemId = siteModel.item.id;
176
- return response;
177
- }
178
- })
179
- .catch(ex => {
180
- itemProgressCallback(template.itemId, solution_common_1.EItemProgressStatus.Failed, 0);
181
- throw ex;
182
- });
183
- }
184
- exports.createItemFromTemplate = createItemFromTemplate;
185
- /**
186
- * Deployer life-cycle hook allowing the Site Processor
187
- * a chance to apply final processes to all the items that
188
- * were created as part of the solution.
189
- * Specifically this will:
190
- * - share all items to the content team, and (if created)
191
- * the core team (depends on user privs)
192
- * - link all Page items that were created, to the Site
193
- *
194
- * @param model
195
- * @param items
196
- * @param authentication
197
- * @param templateDictionary
198
- */
199
- function postProcess(id, type, itemInfos, template, templates, templateDictionary, authentication) {
200
- let hubRo;
201
- return (0, solution_common_1.createHubRequestOptions)(authentication, templateDictionary)
202
- .then(ro => {
203
- hubRo = ro;
204
- // get the site model
205
- return (0, hub_sites_1.getSiteById)(id, hubRo);
206
- })
207
- .then(siteModel => {
208
- // Hub.js does not expect the same structures, so we delegat to a local fn
209
- return (0, _post_process_site_1._postProcessSite)(siteModel, itemInfos, templateDictionary, hubRo);
210
- })
211
- .then(() => {
212
- // resolve w/ a boolean
213
- return Promise.resolve(true);
214
- });
215
- }
216
- exports.postProcess = postProcess;
217
- /**
218
- * Check of an item type is a Site
219
- * Hub Site Application is for ArcGIS Online
220
- * Site Application is for ArcGIS Enterprise
221
- *
222
- * @param itemType
223
- */
224
- function isASite(itemType) {
225
- let result = false;
226
- if (itemType === "Hub Site Application" || itemType === "Site Application") {
227
- result = true;
228
- }
229
- return result;
230
- }
231
- exports.isASite = isASite;
1
+ "use strict";
2
+ /** @license
3
+ * Copyright 2020 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.isASite = exports.postProcess = exports.createItemFromTemplate = exports.convertItemToTemplate = void 0;
19
+ /**
20
+ * Manages the creation and deployment of Hub Site item types.
21
+ *
22
+ * @module hub-site-processor
23
+ */
24
+ const solution_common_1 = require("@esri/solution-common");
25
+ const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
26
+ const hub_sites_1 = require("@esri/hub-sites");
27
+ const hub_common_1 = require("@esri/hub-common");
28
+ const move_model_to_folder_1 = require("./helpers/move-model-to-folder");
29
+ const _post_process_site_1 = require("./helpers/_post-process-site");
30
+ const replace_item_ids_1 = require("./helpers/replace-item-ids");
31
+ /**
32
+ * Converts a Site item into a template.
33
+ *
34
+ * @param solutionItemId The solution to contain the template
35
+ * @param itemInfo Info about the item
36
+ * @param destAuthentication Credentials for requests to the destination organization
37
+ * @param srcAuthentication Credentials for requests to source items (placeholder--not used)
38
+ * @returns A promise that will resolve when the template has been created
39
+ */
40
+ function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication = null // eslint-disable-line @typescript-eslint/no-unused-vars
41
+ ) {
42
+ let created = 0;
43
+ let modified = 0;
44
+ let hubRo;
45
+ // get hubRequestOptions
46
+ return (0, solution_common_1.createHubRequestOptions)(destAuthentication)
47
+ .then(ro => {
48
+ hubRo = ro;
49
+ return (0, hub_sites_1.getSiteById)(itemInfo.id, hubRo);
50
+ })
51
+ .then(siteModel => {
52
+ // We need to save these properties in order to restore them after hub.js deletes them
53
+ created = siteModel.item.created;
54
+ modified = siteModel.item.modified;
55
+ return (0, hub_sites_1.convertSiteToTemplate)(siteModel, hubRo);
56
+ })
57
+ .then(tmpl => {
58
+ // add in some stuff Hub.js does not yet add
59
+ tmpl.item.created = created;
60
+ tmpl.item.modified = modified;
61
+ tmpl.item.typeKeywords = (0, hub_common_1.without)(tmpl.item.typeKeywords, "doNotDelete");
62
+ tmpl.groups = [];
63
+ tmpl.estimatedDeploymentCostFactor = 2;
64
+ tmpl.resources = [];
65
+ if (!(0, solution_common_1.getProp)(tmpl, "properties")) {
66
+ tmpl.properties = {};
67
+ }
68
+ // swap out dependency id's to {{<depid>.itemId}}
69
+ // so it will be re-interpolated
70
+ tmpl.dependencies = (0, solution_common_1.dedupe)(tmpl.dependencies);
71
+ tmpl = (0, replace_item_ids_1.replaceItemIds)(tmpl);
72
+ // and return it
73
+ return tmpl;
74
+ });
75
+ }
76
+ exports.convertItemToTemplate = convertItemToTemplate;
77
+ /**
78
+ * Handle deployment of Site item templates
79
+ *
80
+ * @export
81
+ * @param {IItemTemplate} template
82
+ * @param {*} templateDictionary
83
+ * @param {UserSession} destinationAuthentication
84
+ * @param {IItemProgressCallback} itemProgressCallback
85
+ * @returns {Promise<ICreateItemFromTemplateResponse>}
86
+ */
87
+ function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
88
+ // let the progress system know we've started...
89
+ const startStatus = itemProgressCallback(template.itemId, solution_common_1.EItemProgressStatus.Started, 0);
90
+ // if it returned false, just resolve out
91
+ if (!startStatus) {
92
+ return Promise.resolve((0, solution_common_1.generateEmptyCreationResponse)(template.type));
93
+ }
94
+ // TODO: Reassess with resource unification
95
+ if (template.assets && template.resources) {
96
+ delete template.assets;
97
+ }
98
+ // ensure we have a solution object in the templateDictionary hash
99
+ if (!templateDictionary.solution) {
100
+ templateDictionary.solution = {};
101
+ }
102
+ // .title should always be set on the templateDictionary
103
+ templateDictionary.solution.title = templateDictionary.title;
104
+ // TODO: Determine if we need any transforms in this new env
105
+ const transforms = {};
106
+ // create an object to hold the created site through
107
+ // subsequent promise calls
108
+ let siteModel;
109
+ // Create the "siteModel" from the template. Does not save the site item yet
110
+ // Note: depending on licensing and user privs, will also create the team groups
111
+ // and initiative item.
112
+ let hubRo;
113
+ const thumbnail = template.item.thumbnail; // createSiteModelFromTemplate trashes thumbnail
114
+ return (0, solution_common_1.createHubRequestOptions)(destinationAuthentication, templateDictionary)
115
+ .then(ro => {
116
+ hubRo = ro;
117
+ return (0, hub_sites_1.createSiteModelFromTemplate)(template, templateDictionary, transforms, hubRo);
118
+ })
119
+ .then(interpolated => {
120
+ const options = {
121
+ assets: interpolated.assets || []
122
+ };
123
+ // Now create the item, register for oAuth, register domain etc
124
+ return (0, hub_sites_1.createSite)(interpolated, options, hubRo);
125
+ })
126
+ .then(site => {
127
+ // hold onto the site
128
+ siteModel = site;
129
+ // Move the site and initiative to the solution folder
130
+ // this is essentially fire and forget. We fail-safe the actual moveItem
131
+ // call since it's not critical to the outcome
132
+ return (0, move_model_to_folder_1.moveModelToFolder)(site, templateDictionary.folderId, destinationAuthentication);
133
+ })
134
+ .then(() => {
135
+ // Fix the thumbnail
136
+ const updateOptions = {
137
+ item: {
138
+ id: siteModel.item.id
139
+ },
140
+ params: {
141
+ // Pass thumbnail in via params because item property is serialized, which discards a blob
142
+ thumbnail
143
+ },
144
+ authentication: destinationAuthentication
145
+ };
146
+ return (0, arcgis_rest_portal_1.updateItem)(updateOptions);
147
+ })
148
+ .then(() => {
149
+ // Update the template dictionary
150
+ // TODO: This should be done in whatever recieves
151
+ // the outcome of this promise chain
152
+ templateDictionary[template.itemId] = {
153
+ itemId: siteModel.item.id
154
+ };
155
+ // call the progress callback, which also mutates templateDictionary
156
+ const finalStatus = itemProgressCallback(template.itemId, solution_common_1.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor || 2, siteModel.item.id);
157
+ if (!finalStatus) {
158
+ // clean up the site we just created
159
+ const failSafeRemove = (0, hub_common_1.failSafe)(hub_sites_1.removeSite, { success: true });
160
+ return failSafeRemove(siteModel, hubRo).then(() => {
161
+ return Promise.resolve((0, solution_common_1.generateEmptyCreationResponse)(template.type));
162
+ });
163
+ }
164
+ else {
165
+ // finally, return ICreateItemFromTemplateResponse
166
+ const response = {
167
+ item: {
168
+ ...template,
169
+ ...(0, solution_common_1.convertIModel)(siteModel)
170
+ },
171
+ id: siteModel.item.id,
172
+ type: template.type,
173
+ postProcess: true
174
+ };
175
+ response.item.itemId = siteModel.item.id;
176
+ return response;
177
+ }
178
+ })
179
+ .catch(ex => {
180
+ itemProgressCallback(template.itemId, solution_common_1.EItemProgressStatus.Failed, 0);
181
+ throw ex;
182
+ });
183
+ }
184
+ exports.createItemFromTemplate = createItemFromTemplate;
185
+ /**
186
+ * Deployer life-cycle hook allowing the Site Processor
187
+ * a chance to apply final processes to all the items that
188
+ * were created as part of the solution.
189
+ * Specifically this will:
190
+ * - share all items to the content team, and (if created)
191
+ * the core team (depends on user privs)
192
+ * - link all Page items that were created, to the Site
193
+ *
194
+ * @param model
195
+ * @param items
196
+ * @param authentication
197
+ * @param templateDictionary
198
+ */
199
+ function postProcess(id, type, itemInfos, template, templates, templateDictionary, authentication) {
200
+ let hubRo;
201
+ return (0, solution_common_1.createHubRequestOptions)(authentication, templateDictionary)
202
+ .then(ro => {
203
+ hubRo = ro;
204
+ // get the site model
205
+ return (0, hub_sites_1.getSiteById)(id, hubRo);
206
+ })
207
+ .then(siteModel => {
208
+ // Hub.js does not expect the same structures, so we delegat to a local fn
209
+ return (0, _post_process_site_1._postProcessSite)(siteModel, itemInfos, templateDictionary, hubRo);
210
+ })
211
+ .then(() => {
212
+ // resolve w/ a boolean
213
+ return Promise.resolve(true);
214
+ });
215
+ }
216
+ exports.postProcess = postProcess;
217
+ /**
218
+ * Check of an item type is a Site
219
+ * Hub Site Application is for ArcGIS Online
220
+ * Site Application is for ArcGIS Enterprise
221
+ *
222
+ * @param itemType
223
+ */
224
+ function isASite(itemType) {
225
+ let result = false;
226
+ if (itemType === "Hub Site Application" || itemType === "Site Application") {
227
+ result = true;
228
+ }
229
+ return result;
230
+ }
231
+ exports.isASite = isASite;
232
232
  //# sourceMappingURL=hub-site-processor.js.map
@@ -1,23 +1,23 @@
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 Hub Site and Page item types.
18
- *
19
- * @module hubTypes
20
- */
21
- import * as HubPageProcessor from "./hub-page-processor";
22
- import * as HubSiteProcessor from "./hub-site-processor";
23
- export { HubPageProcessor, HubSiteProcessor };
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 Hub Site and Page item types.
18
+ *
19
+ * @module hubTypes
20
+ */
21
+ import * as HubPageProcessor from "./hub-page-processor";
22
+ import * as HubSiteProcessor from "./hub-site-processor";
23
+ export { HubPageProcessor, HubSiteProcessor };