@esri/solution-hub-types 3.0.1 → 4.0.0-alpha.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 (37) hide show
  1. package/package.json +8 -14
  2. package/dist/node/helpers/_post-process-page.d.ts +0 -17
  3. package/dist/node/helpers/_post-process-page.js +0 -33
  4. package/dist/node/helpers/_post-process-page.js.map +0 -1
  5. package/dist/node/helpers/_post-process-site.d.ts +0 -29
  6. package/dist/node/helpers/_post-process-site.js +0 -51
  7. package/dist/node/helpers/_post-process-site.js.map +0 -1
  8. package/dist/node/helpers/_update-site-pages.d.ts +0 -24
  9. package/dist/node/helpers/_update-site-pages.js +0 -43
  10. package/dist/node/helpers/_update-site-pages.js.map +0 -1
  11. package/dist/node/helpers/move-model-to-folder.d.ts +0 -26
  12. package/dist/node/helpers/move-model-to-folder.js +0 -50
  13. package/dist/node/helpers/move-model-to-folder.js.map +0 -1
  14. package/dist/node/helpers/replace-item-ids.d.ts +0 -17
  15. package/dist/node/helpers/replace-item-ids.js +0 -37
  16. package/dist/node/helpers/replace-item-ids.js.map +0 -1
  17. package/dist/node/hub-page-processor.d.ts +0 -63
  18. package/dist/node/hub-page-processor.js +0 -228
  19. package/dist/node/hub-page-processor.js.map +0 -1
  20. package/dist/node/hub-site-processor.d.ts +0 -65
  21. package/dist/node/hub-site-processor.js +0 -232
  22. package/dist/node/hub-site-processor.js.map +0 -1
  23. package/dist/node/index.d.ts +0 -23
  24. package/dist/node/index.js +0 -29
  25. package/dist/node/index.js.map +0 -1
  26. package/dist/umd/hub-types/src/helpers/_post-process-page.d.ts +0 -17
  27. package/dist/umd/hub-types/src/helpers/_post-process-site.d.ts +0 -29
  28. package/dist/umd/hub-types/src/helpers/_update-site-pages.d.ts +0 -24
  29. package/dist/umd/hub-types/src/helpers/move-model-to-folder.d.ts +0 -26
  30. package/dist/umd/hub-types/src/helpers/replace-item-ids.d.ts +0 -17
  31. package/dist/umd/hub-types/src/hub-page-processor.d.ts +0 -63
  32. package/dist/umd/hub-types/src/hub-site-processor.d.ts +0 -65
  33. package/dist/umd/hub-types/src/index.d.ts +0 -23
  34. package/dist/umd/hub-types.umd.js +0 -653
  35. package/dist/umd/hub-types.umd.js.map +0 -1
  36. package/dist/umd/hub-types.umd.min.js +0 -19
  37. package/dist/umd/hub-types.umd.min.js.map +0 -1
@@ -1,653 +0,0 @@
1
- /* @preserve
2
- * @esri/solution-hub-types - v1.7.0 - Apache-2.0
3
- * Copyright (c) 2018-2023 Esri, Inc.
4
- * Fri Apr 28 2023 11:21:40 GMT-0700 (Pacific Daylight Time)
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
- (function (global, factory) {
19
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@esri/solution-common'), require('@esri/arcgis-rest-portal'), require('@esri/hub-common'), require('@esri/hub-sites')) :
20
- typeof define === 'function' && define.amd ? define(['exports', '@esri/solution-common', '@esri/arcgis-rest-portal', '@esri/hub-common', '@esri/hub-sites'], factory) :
21
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.arcgisSolution = global.arcgisSolution || {}, global.arcgisSolution, global.arcgisRest, global.arcgisHub, global.arcgisHub));
22
- })(this, (function (exports, solutionCommon, arcgisRestPortal, hubCommon, hubSites) { 'use strict';
23
-
24
- /** @license
25
- * Copyright 2020 Esri
26
- *
27
- * Licensed under the Apache License, Version 2.0 (the "License");
28
- * you may not use this file except in compliance with the License.
29
- * You may obtain a copy of the License at
30
- *
31
- * http://www.apache.org/licenses/LICENSE-2.0
32
- *
33
- * Unless required by applicable law or agreed to in writing, software
34
- * distributed under the License is distributed on an "AS IS" BASIS,
35
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
36
- * See the License for the specific language governing permissions and
37
- * limitations under the License.
38
- */
39
- //???
40
- function _postProcessPage(pageModel, itemInfos, templateDictionary, hubRequestOptions) {
41
- // re-interpolate the siteModel using the itemInfos; no patches supplied
42
- pageModel = hubCommon.interpolate(pageModel, templateDictionary, {});
43
- return hubSites.updatePage(pageModel, {
44
- ...hubRequestOptions,
45
- allowList: []
46
- }).then(() => {
47
- return true;
48
- });
49
- }
50
-
51
- /** @license
52
- * Copyright 2020 Esri
53
- *
54
- * Licensed under the Apache License, Version 2.0 (the "License");
55
- * you may not use this file except in compliance with the License.
56
- * You may obtain a copy of the License at
57
- *
58
- * http://www.apache.org/licenses/LICENSE-2.0
59
- *
60
- * Unless required by applicable law or agreed to in writing, software
61
- * distributed under the License is distributed on an "AS IS" BASIS,
62
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
63
- * See the License for the specific language governing permissions and
64
- * limitations under the License.
65
- */
66
- function replaceItemIds(template) {
67
- const clone = hubCommon.cloneObject(template);
68
- const deps = template.dependencies || [];
69
- // iterate the dependencies
70
- deps.forEach(depId => {
71
- const re = new RegExp(depId, "g");
72
- const replacement = `{{${depId}.itemId}}`;
73
- // we have to do this property-by-property or we would replace the `itemId` prop itself
74
- clone.item = hubCommon.deepStringReplace(clone.item, re, replacement);
75
- clone.data = hubCommon.deepStringReplace(clone.data, re, replacement);
76
- if (template.properties) {
77
- clone.properties = hubCommon.deepStringReplace(clone.properties, re, replacement);
78
- }
79
- });
80
- return clone;
81
- }
82
-
83
- /** @license
84
- * Copyright 2018 Esri
85
- *
86
- * Licensed under the Apache License, Version 2.0 (the "License");
87
- * you may not use this file except in compliance with the License.
88
- * You may obtain a copy of the License at
89
- *
90
- * http://www.apache.org/licenses/LICENSE-2.0
91
- *
92
- * Unless required by applicable law or agreed to in writing, software
93
- * distributed under the License is distributed on an "AS IS" BASIS,
94
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
95
- * See the License for the specific language governing permissions and
96
- * limitations under the License.
97
- */
98
- /**
99
- * Move the created site item, and optionally the Initiative, into
100
- * the solution folder
101
- *
102
- * @param siteModel
103
- * @param folderId
104
- * @param authentication
105
- */
106
- function moveModelToFolder(siteModel, folderId, authentication) {
107
- // Fail-Safe the move call as it's not critical if it fails
108
- const failSafeMove = hubCommon.failSafe(arcgisRestPortal.moveItem, { success: true });
109
- const movePromises = [
110
- failSafeMove({
111
- itemId: siteModel.item.id,
112
- folderId,
113
- authentication
114
- })
115
- ];
116
- // if an initiative was created...
117
- if (hubCommon.getProp(siteModel, "item.properties.parentInitiativeId")) {
118
- movePromises.push(failSafeMove({
119
- itemId: siteModel.item.properties.parentInitiativeId,
120
- folderId,
121
- authentication
122
- }));
123
- }
124
- return Promise.all(movePromises);
125
- }
126
-
127
- /** @license
128
- * Copyright 2018 Esri
129
- *
130
- * Licensed under the Apache License, Version 2.0 (the "License");
131
- * you may not use this file except in compliance with the License.
132
- * You may obtain a copy of the License at
133
- *
134
- * http://www.apache.org/licenses/LICENSE-2.0
135
- *
136
- * Unless required by applicable law or agreed to in writing, software
137
- * distributed under the License is distributed on an "AS IS" BASIS,
138
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139
- * See the License for the specific language governing permissions and
140
- * limitations under the License.
141
- */
142
- /**
143
- * Converts a Hub Page item into a template.
144
- *
145
- * @param solutionItemId The solution to contain the template
146
- * @param itemInfo Info about the item
147
- * @param destAuthentication Credentials for requests to the destination organization
148
- * @param srcAuthentication Credentials for requests to source items (placeholder--not used)
149
- * @returns A promise that will resolve when the template has been created
150
- */
151
- function convertItemToTemplate$1(solutionItemId, itemInfo, destAuthentication, srcAuthentication = null // eslint-disable-line @typescript-eslint/no-unused-vars
152
- ) {
153
- let created = 0;
154
- let modified = 0;
155
- // get the page model and hubRequestOptions
156
- return Promise.all([
157
- hubCommon.getModel(itemInfo.id, { authentication: destAuthentication }),
158
- solutionCommon.createHubRequestOptions(destAuthentication)
159
- ])
160
- .then(([pageModel, ro]) => {
161
- // We need to save these properties in order to restore them after hub.js deletes them
162
- created = pageModel.item.created;
163
- modified = pageModel.item.modified;
164
- return hubSites.convertPageToTemplate(pageModel, ro);
165
- })
166
- .then(tmpl => {
167
- // add in some stuff Hub.js does not yet add
168
- tmpl.item.created = created;
169
- tmpl.item.modified = modified;
170
- tmpl.item.typeKeywords = hubCommon.without(tmpl.item.typeKeywords, "doNotDelete");
171
- tmpl.groups = [];
172
- tmpl.estimatedDeploymentCostFactor = 2;
173
- tmpl.resources = [];
174
- if (!hubCommon.getProp(tmpl, "properties")) {
175
- tmpl.properties = {};
176
- }
177
- // swap out dependency id's to {{<depid>.itemId}}
178
- // so it will be re-interpolated
179
- tmpl = replaceItemIds(tmpl);
180
- // and return it
181
- return tmpl;
182
- });
183
- }
184
- /**
185
- * Handle deployment of Page item templates
186
- *
187
- * @export
188
- * @param {IItemTemplate} template
189
- * @param {*} templateDictionary
190
- * @param {UserSession} destinationAuthentication
191
- * @param {IItemProgressCallback} itemProgressCallback
192
- * @returns {Promise<ICreateItemFromTemplateResponse>}
193
- */
194
- function createItemFromTemplate$1(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
195
- // let the progress system know we've started...
196
- const startStatus = itemProgressCallback(template.itemId, solutionCommon.EItemProgressStatus.Started, 0);
197
- // and if it returned false, just resolve out
198
- if (!startStatus) {
199
- return Promise.resolve(solutionCommon.generateEmptyCreationResponse(template.type));
200
- }
201
- // TODO: Reassess with resource unification
202
- if (template.assets && template.resources) {
203
- delete template.assets;
204
- }
205
- // solutionItemExtent is in geographic, but it's a string, and we want/need a bbox
206
- // and Hub templates expect it in organization.defaultExtentBBox
207
- if (templateDictionary.solutionItemExtent) {
208
- const parts = templateDictionary.solutionItemExtent.split(",");
209
- templateDictionary.organization.defaultExtentBBox = [
210
- [parts[0], parts[1]],
211
- [parts[2], parts[3]]
212
- ];
213
- }
214
- // TODO: Determine if we need any transforms in this new env
215
- const transforms = {};
216
- // create an object to hold the created site through
217
- // subsequent promise calls
218
- let pageModel;
219
- let hubRo;
220
- const thumbnail = template.item.thumbnail; // createPageModelFromTemplate trashes thumbnail
221
- return solutionCommon.createHubRequestOptions(destinationAuthentication, templateDictionary)
222
- .then(ro => {
223
- hubRo = ro;
224
- return hubSites.createPageModelFromTemplate(template, templateDictionary, transforms, hubRo);
225
- })
226
- .then((interpolated) => {
227
- // --------------------------------------------
228
- // TODO: Update hub.js to take an IModel in createPage
229
- // then remove this silliness
230
- const modelTmpl = interpolated;
231
- const options = {
232
- assets: modelTmpl.assets || []
233
- };
234
- // --------------------------------------------
235
- return hubSites.createPage(modelTmpl, options, hubRo);
236
- })
237
- .then(page => {
238
- pageModel = page;
239
- // Move the site and initiative to the solution folder
240
- // this is essentially fire and forget. We fail-safe the actual moveItem
241
- // call since it's not critical to the outcome
242
- return moveModelToFolder(page, templateDictionary.folderId, destinationAuthentication);
243
- })
244
- .then(() => {
245
- // Fix the thumbnail
246
- const updateOptions = {
247
- item: {
248
- id: pageModel.item.id
249
- },
250
- params: {
251
- // Pass thumbnail in via params because item property is serialized, which discards a blob
252
- thumbnail
253
- },
254
- authentication: destinationAuthentication
255
- };
256
- return arcgisRestPortal.updateItem(updateOptions);
257
- })
258
- .then(() => {
259
- // Update the template dictionary
260
- // TODO: This should be done in whatever recieves
261
- // the outcome of this promise chain
262
- templateDictionary[template.itemId] = {
263
- itemId: pageModel.item.id
264
- };
265
- // call the progress callback, which also mutates templateDictionary
266
- const finalStatus = itemProgressCallback(template.itemId, solutionCommon.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor || 2, pageModel.item.id);
267
- if (!finalStatus) {
268
- // clean up the site we just created
269
- const failSafeRemove = hubCommon.failSafe(hubSites.removePage, { success: true });
270
- return failSafeRemove(pageModel, hubRo).then(() => {
271
- return Promise.resolve(solutionCommon.generateEmptyCreationResponse(template.type));
272
- });
273
- }
274
- else {
275
- // finally, return ICreateItemFromTemplateResponse
276
- const response = {
277
- item: {
278
- ...template,
279
- ...pageModel
280
- },
281
- id: pageModel.item.id,
282
- type: template.type,
283
- postProcess: true
284
- };
285
- response.item.itemId = pageModel.item.id;
286
- return response;
287
- }
288
- })
289
- .catch(ex => {
290
- itemProgressCallback(template.itemId, solutionCommon.EItemProgressStatus.Failed, 0);
291
- throw ex;
292
- });
293
- }
294
- /**
295
- * Post-Process a Page
296
- * Re-interpolate the page item + data w/ the full template dictionary hash
297
- *
298
- * @param id
299
- * @param type
300
- * @param itemInfos
301
- * @param template
302
- * @param templates
303
- * @param templateDictionary
304
- * @param authentication
305
- */
306
- function postProcess$1(id, type, itemInfos, template, templates, templateDictionary, authentication) {
307
- // create the requestOptions
308
- let hubRo;
309
- // get hubRequestOptions
310
- return solutionCommon.createHubRequestOptions(authentication)
311
- .then(ro => {
312
- hubRo = ro;
313
- // get the site model
314
- return hubCommon.getModel(id, { authentication });
315
- })
316
- .then(pageModel => {
317
- // post process the page
318
- return _postProcessPage(pageModel, itemInfos, templateDictionary, hubRo);
319
- });
320
- }
321
- /**
322
- * Check of an item type is a Page
323
- * Hub Page is for ArcGIS Online
324
- * Site Page is for ArcGIS Enterprise
325
- *
326
- * @param itemType
327
- */
328
- function isAPage(itemType) {
329
- let result = false;
330
- if (itemType === "Hub Page" || itemType === "Site Page") {
331
- result = true;
332
- }
333
- return result;
334
- }
335
-
336
- var hubPageProcessor = /*#__PURE__*/Object.freeze({
337
- __proto__: null,
338
- convertItemToTemplate: convertItemToTemplate$1,
339
- createItemFromTemplate: createItemFromTemplate$1,
340
- postProcess: postProcess$1,
341
- isAPage: isAPage
342
- });
343
-
344
- /** @license
345
- * Copyright 2020 Esri
346
- *
347
- * Licensed under the Apache License, Version 2.0 (the "License");
348
- * you may not use this file except in compliance with the License.
349
- * You may obtain a copy of the License at
350
- *
351
- * http://www.apache.org/licenses/LICENSE-2.0
352
- *
353
- * Unless required by applicable law or agreed to in writing, software
354
- * distributed under the License is distributed on an "AS IS" BASIS,
355
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
356
- * See the License for the specific language governing permissions and
357
- * limitations under the License.
358
- */
359
- /**
360
- *
361
- * @param siteModel
362
- * @param itemInfos
363
- * @param hubRequestOptions
364
- * @private
365
- */
366
- function _updateSitePages(siteModel, itemInfos, hubRequestOptions) {
367
- const pageIds = itemInfos
368
- .filter(e => {
369
- return e.type.indexOf("Page") > -1;
370
- })
371
- .map(e => e.id);
372
- // now get all those models
373
- return Promise.all(pageIds.map(id => {
374
- return hubCommon.getModel(id, hubRequestOptions);
375
- })).then((pageModels) => {
376
- // now delegate back to hub.js internal _updatePages fn
377
- return hubSites._updatePages(siteModel, pageModels, hubRequestOptions);
378
- });
379
- }
380
-
381
- /**
382
- * Post Process a Site
383
- * - share all items to the Hub teams created as part of the site
384
- * - link any created page to the site item
385
- * - re-interpolate any remaining item ids that were not direct deps of the site
386
- *
387
- * @param siteModel
388
- * @param itemInfos
389
- * @param templateDictionary
390
- * @param hubRequestOptions
391
- * @private
392
- */
393
- function _postProcessSite(siteModel, itemInfos, templateDictionary, hubRequestOptions) {
394
- const infosWithoutSite = itemInfos.filter(info => info.id !== siteModel.item.id);
395
- // convert the itemInfo's into things that look enough like a model
396
- // that we can call shareItemsToSiteGroups
397
- const pseudoModels = infosWithoutSite.map(e => {
398
- return {
399
- item: {
400
- id: e.id,
401
- type: e.type
402
- }
403
- };
404
- });
405
- let secondPassPromises = [];
406
- secondPassPromises = secondPassPromises.concat(hubSites.shareItemsToSiteGroups(siteModel, pseudoModels, hubRequestOptions));
407
- // we can't use that same trick w/ the page sharing
408
- // because we really need the models themselves
409
- // so we delegate to a local function
410
- secondPassPromises = secondPassPromises.concat(_updateSitePages(siteModel, infosWithoutSite, hubRequestOptions));
411
- // need to get all the child items and add into site.item.properties.children
412
- const childItemIds = infosWithoutSite.map(i => i.id);
413
- siteModel.item.properties.children = childItemIds;
414
- // re-interpolate the siteModel using the itemInfos
415
- siteModel = hubSites.interpolateSite(siteModel, templateDictionary, {});
416
- // and update the model
417
- secondPassPromises.push(hubSites.updateSite(siteModel, {
418
- ...hubRequestOptions,
419
- allowList: null
420
- }));
421
- return Promise.all(secondPassPromises).then(() => {
422
- return true;
423
- });
424
- }
425
-
426
- /** @license
427
- * Copyright 2020 Esri
428
- *
429
- * Licensed under the Apache License, Version 2.0 (the "License");
430
- * you may not use this file except in compliance with the License.
431
- * You may obtain a copy of the License at
432
- *
433
- * http://www.apache.org/licenses/LICENSE-2.0
434
- *
435
- * Unless required by applicable law or agreed to in writing, software
436
- * distributed under the License is distributed on an "AS IS" BASIS,
437
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
438
- * See the License for the specific language governing permissions and
439
- * limitations under the License.
440
- */
441
- /**
442
- * Converts a Site item into a template.
443
- *
444
- * @param solutionItemId The solution to contain the template
445
- * @param itemInfo Info about the item
446
- * @param destAuthentication Credentials for requests to the destination organization
447
- * @param srcAuthentication Credentials for requests to source items (placeholder--not used)
448
- * @returns A promise that will resolve when the template has been created
449
- */
450
- function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication = null // eslint-disable-line @typescript-eslint/no-unused-vars
451
- ) {
452
- let created = 0;
453
- let modified = 0;
454
- let hubRo;
455
- // get hubRequestOptions
456
- return solutionCommon.createHubRequestOptions(destAuthentication)
457
- .then(ro => {
458
- hubRo = ro;
459
- return hubSites.getSiteById(itemInfo.id, hubRo);
460
- })
461
- .then(siteModel => {
462
- // We need to save these properties in order to restore them after hub.js deletes them
463
- created = siteModel.item.created;
464
- modified = siteModel.item.modified;
465
- return hubSites.convertSiteToTemplate(siteModel, hubRo);
466
- })
467
- .then(tmpl => {
468
- // add in some stuff Hub.js does not yet add
469
- tmpl.item.created = created;
470
- tmpl.item.modified = modified;
471
- tmpl.item.typeKeywords = hubCommon.without(tmpl.item.typeKeywords, "doNotDelete");
472
- tmpl.groups = [];
473
- tmpl.estimatedDeploymentCostFactor = 2;
474
- tmpl.resources = [];
475
- if (!solutionCommon.getProp(tmpl, "properties")) {
476
- tmpl.properties = {};
477
- }
478
- // swap out dependency id's to {{<depid>.itemId}}
479
- // so it will be re-interpolated
480
- tmpl.dependencies = solutionCommon.dedupe(tmpl.dependencies);
481
- tmpl = replaceItemIds(tmpl);
482
- // and return it
483
- return tmpl;
484
- });
485
- }
486
- /**
487
- * Handle deployment of Site item templates
488
- *
489
- * @export
490
- * @param {IItemTemplate} template
491
- * @param {*} templateDictionary
492
- * @param {UserSession} destinationAuthentication
493
- * @param {IItemProgressCallback} itemProgressCallback
494
- * @returns {Promise<ICreateItemFromTemplateResponse>}
495
- */
496
- function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
497
- // let the progress system know we've started...
498
- const startStatus = itemProgressCallback(template.itemId, solutionCommon.EItemProgressStatus.Started, 0);
499
- // if it returned false, just resolve out
500
- if (!startStatus) {
501
- return Promise.resolve(solutionCommon.generateEmptyCreationResponse(template.type));
502
- }
503
- // TODO: Reassess with resource unification
504
- if (template.assets && template.resources) {
505
- delete template.assets;
506
- }
507
- // ensure we have a solution object in the templateDictionary hash
508
- if (!templateDictionary.solution) {
509
- templateDictionary.solution = {};
510
- }
511
- // .title should always be set on the templateDictionary
512
- templateDictionary.solution.title = templateDictionary.title;
513
- // TODO: Determine if we need any transforms in this new env
514
- const transforms = {};
515
- // create an object to hold the created site through
516
- // subsequent promise calls
517
- let siteModel;
518
- // Create the "siteModel" from the template. Does not save the site item yet
519
- // Note: depending on licensing and user privs, will also create the team groups
520
- // and initiative item.
521
- let hubRo;
522
- const thumbnail = template.item.thumbnail; // createSiteModelFromTemplate trashes thumbnail
523
- return solutionCommon.createHubRequestOptions(destinationAuthentication, templateDictionary)
524
- .then(ro => {
525
- hubRo = ro;
526
- return hubSites.createSiteModelFromTemplate(template, templateDictionary, transforms, hubRo);
527
- })
528
- .then(interpolated => {
529
- const options = {
530
- assets: interpolated.assets || []
531
- };
532
- // Now create the item, register for oAuth, register domain etc
533
- return hubSites.createSite(interpolated, options, hubRo);
534
- })
535
- .then(site => {
536
- // hold onto the site
537
- siteModel = site;
538
- // Move the site and initiative to the solution folder
539
- // this is essentially fire and forget. We fail-safe the actual moveItem
540
- // call since it's not critical to the outcome
541
- return moveModelToFolder(site, templateDictionary.folderId, destinationAuthentication);
542
- })
543
- .then(() => {
544
- // Fix the thumbnail
545
- const updateOptions = {
546
- item: {
547
- id: siteModel.item.id
548
- },
549
- params: {
550
- // Pass thumbnail in via params because item property is serialized, which discards a blob
551
- thumbnail
552
- },
553
- authentication: destinationAuthentication
554
- };
555
- return arcgisRestPortal.updateItem(updateOptions);
556
- })
557
- .then(() => {
558
- // Update the template dictionary
559
- // TODO: This should be done in whatever recieves
560
- // the outcome of this promise chain
561
- templateDictionary[template.itemId] = {
562
- itemId: siteModel.item.id
563
- };
564
- // call the progress callback, which also mutates templateDictionary
565
- const finalStatus = itemProgressCallback(template.itemId, solutionCommon.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor || 2, siteModel.item.id);
566
- if (!finalStatus) {
567
- // clean up the site we just created
568
- const failSafeRemove = hubCommon.failSafe(hubSites.removeSite, { success: true });
569
- return failSafeRemove(siteModel, hubRo).then(() => {
570
- return Promise.resolve(solutionCommon.generateEmptyCreationResponse(template.type));
571
- });
572
- }
573
- else {
574
- // finally, return ICreateItemFromTemplateResponse
575
- const response = {
576
- item: {
577
- ...template,
578
- ...siteModel
579
- },
580
- id: siteModel.item.id,
581
- type: template.type,
582
- postProcess: true
583
- };
584
- response.item.itemId = siteModel.item.id;
585
- return response;
586
- }
587
- })
588
- .catch(ex => {
589
- itemProgressCallback(template.itemId, solutionCommon.EItemProgressStatus.Failed, 0);
590
- throw ex;
591
- });
592
- }
593
- /**
594
- * Deployer life-cycle hook allowing the Site Processor
595
- * a chance to apply final processes to all the items that
596
- * were created as part of the solution.
597
- * Specifically this will:
598
- * - share all items to the content team, and (if created)
599
- * the core team (depends on user privs)
600
- * - link all Page items that were created, to the Site
601
- *
602
- * @param model
603
- * @param items
604
- * @param authentication
605
- * @param templateDictionary
606
- */
607
- function postProcess(id, type, itemInfos, template, templates, templateDictionary, authentication) {
608
- let hubRo;
609
- return solutionCommon.createHubRequestOptions(authentication, templateDictionary)
610
- .then(ro => {
611
- hubRo = ro;
612
- // get the site model
613
- return hubSites.getSiteById(id, hubRo);
614
- })
615
- .then(siteModel => {
616
- // Hub.js does not expect the same structures, so we delegat to a local fn
617
- return _postProcessSite(siteModel, itemInfos, templateDictionary, hubRo);
618
- })
619
- .then(() => {
620
- // resolve w/ a boolean
621
- return Promise.resolve(true);
622
- });
623
- }
624
- /**
625
- * Check of an item type is a Site
626
- * Hub Site Application is for ArcGIS Online
627
- * Site Application is for ArcGIS Enterprise
628
- *
629
- * @param itemType
630
- */
631
- function isASite(itemType) {
632
- let result = false;
633
- if (itemType === "Hub Site Application" || itemType === "Site Application") {
634
- result = true;
635
- }
636
- return result;
637
- }
638
-
639
- var hubSiteProcessor = /*#__PURE__*/Object.freeze({
640
- __proto__: null,
641
- convertItemToTemplate: convertItemToTemplate,
642
- createItemFromTemplate: createItemFromTemplate,
643
- postProcess: postProcess,
644
- isASite: isASite
645
- });
646
-
647
- exports.HubPageProcessor = hubPageProcessor;
648
- exports.HubSiteProcessor = hubSiteProcessor;
649
-
650
- Object.defineProperty(exports, '__esModule', { value: true });
651
-
652
- }));
653
- //# sourceMappingURL=hub-types.umd.js.map