@esri/solution-storymap 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 (45) hide show
  1. package/dist/cjs/classic-storymap-processor.d.ts +24 -24
  2. package/dist/cjs/classic-storymap-processor.js +68 -68
  3. package/dist/cjs/helpers/convert-storymap-to-template.d.ts +24 -24
  4. package/dist/cjs/helpers/convert-storymap-to-template.js +98 -98
  5. package/dist/cjs/helpers/create-storymap-model-from-template.d.ts +22 -22
  6. package/dist/cjs/helpers/create-storymap-model-from-template.js +42 -42
  7. package/dist/cjs/helpers/create-storymap.d.ts +25 -25
  8. package/dist/cjs/helpers/create-storymap.js +111 -111
  9. package/dist/cjs/helpers/get-portal-env.d.ts +17 -17
  10. package/dist/cjs/helpers/get-portal-env.js +18 -18
  11. package/dist/cjs/helpers/get-storymap-base-url.d.ts +23 -23
  12. package/dist/cjs/helpers/get-storymap-base-url.js +25 -25
  13. package/dist/cjs/helpers/get-storymap-dependencies.d.ts +23 -23
  14. package/dist/cjs/helpers/get-storymap-dependencies.js +35 -35
  15. package/dist/cjs/helpers/get-storymap-subdomain.d.ts +17 -17
  16. package/dist/cjs/helpers/get-storymap-subdomain.js +19 -19
  17. package/dist/cjs/helpers/remap-webmap-keys.d.ts +24 -24
  18. package/dist/cjs/helpers/remap-webmap-keys.js +43 -43
  19. package/dist/cjs/index.d.ts +23 -23
  20. package/dist/cjs/index.js +28 -28
  21. package/dist/cjs/storymap-processor.d.ts +40 -40
  22. package/dist/cjs/storymap-processor.js +140 -140
  23. package/dist/esm/classic-storymap-processor.d.ts +24 -24
  24. package/dist/esm/classic-storymap-processor.js +61 -61
  25. package/dist/esm/helpers/convert-storymap-to-template.d.ts +24 -24
  26. package/dist/esm/helpers/convert-storymap-to-template.js +94 -94
  27. package/dist/esm/helpers/create-storymap-model-from-template.d.ts +22 -22
  28. package/dist/esm/helpers/create-storymap-model-from-template.js +38 -38
  29. package/dist/esm/helpers/create-storymap.d.ts +25 -25
  30. package/dist/esm/helpers/create-storymap.js +107 -107
  31. package/dist/esm/helpers/get-portal-env.d.ts +17 -17
  32. package/dist/esm/helpers/get-portal-env.js +14 -14
  33. package/dist/esm/helpers/get-storymap-base-url.d.ts +23 -23
  34. package/dist/esm/helpers/get-storymap-base-url.js +21 -21
  35. package/dist/esm/helpers/get-storymap-dependencies.d.ts +23 -23
  36. package/dist/esm/helpers/get-storymap-dependencies.js +31 -31
  37. package/dist/esm/helpers/get-storymap-subdomain.d.ts +17 -17
  38. package/dist/esm/helpers/get-storymap-subdomain.js +15 -15
  39. package/dist/esm/helpers/remap-webmap-keys.d.ts +24 -24
  40. package/dist/esm/helpers/remap-webmap-keys.js +39 -39
  41. package/dist/esm/index.d.ts +23 -23
  42. package/dist/esm/index.js +23 -23
  43. package/dist/esm/storymap-processor.d.ts +40 -40
  44. package/dist/esm/storymap-processor.js +134 -134
  45. package/package.json +3 -3
@@ -1,44 +1,44 @@
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
- exports.remapWebmapKeys = void 0;
19
- const hub_common_1 = require("@esri/hub-common");
20
- /**
21
- * For some reason, the webmap resource key names are fancier than other resource keys
22
- * They look like this: r-<webmap-item-id>-<timestamp>
23
- * This interpolation is hard to accomplish given our current setup, so we're just overwriting
24
- * them with "webmap0", "webmap1" and so forth. This _seems_ to make no difference.
25
- *
26
- * @param model
27
- */
28
- function remapWebmapKeys(resources = {}) {
29
- let webmapCounter = 0;
30
- return Object.keys(resources).reduce((acc, key) => {
31
- if ((0, hub_common_1.getProp)(resources, `${key}.type`) === "webmap") {
32
- if (key !== `webmap${webmapCounter}`) {
33
- acc.push({
34
- original: key,
35
- updated: `webmap${webmapCounter}`
36
- });
37
- webmapCounter++;
38
- }
39
- }
40
- return acc;
41
- }, []);
42
- }
43
- exports.remapWebmapKeys = remapWebmapKeys;
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
+ exports.remapWebmapKeys = void 0;
19
+ const hub_common_1 = require("@esri/hub-common");
20
+ /**
21
+ * For some reason, the webmap resource key names are fancier than other resource keys
22
+ * They look like this: r-<webmap-item-id>-<timestamp>
23
+ * This interpolation is hard to accomplish given our current setup, so we're just overwriting
24
+ * them with "webmap0", "webmap1" and so forth. This _seems_ to make no difference.
25
+ *
26
+ * @param model
27
+ */
28
+ function remapWebmapKeys(resources = {}) {
29
+ let webmapCounter = 0;
30
+ return Object.keys(resources).reduce((acc, key) => {
31
+ if ((0, hub_common_1.getProp)(resources, `${key}.type`) === "webmap") {
32
+ if (key !== `webmap${webmapCounter}`) {
33
+ acc.push({
34
+ original: key,
35
+ updated: `webmap${webmapCounter}`
36
+ });
37
+ webmapCounter++;
38
+ }
39
+ }
40
+ return acc;
41
+ }, []);
42
+ }
43
+ exports.remapWebmapKeys = remapWebmapKeys;
44
44
  //# sourceMappingURL=remap-webmap-keys.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 Story Map item types.
18
- *
19
- * @module storymap
20
- */
21
- import * as StoryMapProcessor from "./storymap-processor";
22
- import * as ClassicStoryMapProcessor from "./classic-storymap-processor";
23
- export { StoryMapProcessor, ClassicStoryMapProcessor };
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 Story Map item types.
18
+ *
19
+ * @module storymap
20
+ */
21
+ import * as StoryMapProcessor from "./storymap-processor";
22
+ import * as ClassicStoryMapProcessor from "./classic-storymap-processor";
23
+ export { StoryMapProcessor, ClassicStoryMapProcessor };
package/dist/cjs/index.js CHANGED
@@ -1,29 +1,29 @@
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
- exports.ClassicStoryMapProcessor = exports.StoryMapProcessor = void 0;
19
- const tslib_1 = require("tslib");
20
- /**
21
- * Manages the creation and deployment of Story Map item types.
22
- *
23
- * @module storymap
24
- */
25
- const StoryMapProcessor = tslib_1.__importStar(require("./storymap-processor"));
26
- exports.StoryMapProcessor = StoryMapProcessor;
27
- const ClassicStoryMapProcessor = tslib_1.__importStar(require("./classic-storymap-processor"));
28
- exports.ClassicStoryMapProcessor = ClassicStoryMapProcessor;
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
+ exports.ClassicStoryMapProcessor = exports.StoryMapProcessor = void 0;
19
+ const tslib_1 = require("tslib");
20
+ /**
21
+ * Manages the creation and deployment of Story Map item types.
22
+ *
23
+ * @module storymap
24
+ */
25
+ const StoryMapProcessor = tslib_1.__importStar(require("./storymap-processor"));
26
+ exports.StoryMapProcessor = StoryMapProcessor;
27
+ const ClassicStoryMapProcessor = tslib_1.__importStar(require("./classic-storymap-processor"));
28
+ exports.ClassicStoryMapProcessor = ClassicStoryMapProcessor;
29
29
  //# sourceMappingURL=index.js.map
@@ -1,40 +1,40 @@
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 Story Map item types.
18
- *
19
- * @module storymap
20
- */
21
- import { IItemTemplate, IItemProgressCallback, ICreateItemFromTemplateResponse, UserSession } from "@esri/solution-common";
22
- /**
23
- * Convert a StoryMap to a template
24
- *
25
- * @param solutionItemId
26
- * @param itemInfo
27
- * @param destAuthentication Credentials for requests to the destination organization
28
- * @param srcAuthentication Credentials for requests to source items
29
- */
30
- export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, destAuthentication: UserSession, srcAuthentication: UserSession): Promise<IItemTemplate>;
31
- /**
32
- * Create a StoryMap from the passed in template
33
- *
34
- * @param template
35
- * @param templateDictionary
36
- * @param destinationAuthentication
37
- * @param itemProgressCallback
38
- */
39
- export declare function createItemFromTemplate(template: IItemTemplate, templateDictionary: any, destinationAuthentication: UserSession, itemProgressCallback: IItemProgressCallback): Promise<ICreateItemFromTemplateResponse>;
40
- export declare function isAStoryMap(itemType: string): boolean;
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 Story Map item types.
18
+ *
19
+ * @module storymap
20
+ */
21
+ import { IItemTemplate, IItemProgressCallback, ICreateItemFromTemplateResponse, UserSession } from "@esri/solution-common";
22
+ /**
23
+ * Convert a StoryMap to a template
24
+ *
25
+ * @param solutionItemId
26
+ * @param itemInfo
27
+ * @param destAuthentication Credentials for requests to the destination organization
28
+ * @param srcAuthentication Credentials for requests to source items
29
+ */
30
+ export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, destAuthentication: UserSession, srcAuthentication: UserSession): Promise<IItemTemplate>;
31
+ /**
32
+ * Create a StoryMap from the passed in template
33
+ *
34
+ * @param template
35
+ * @param templateDictionary
36
+ * @param destinationAuthentication
37
+ * @param itemProgressCallback
38
+ */
39
+ export declare function createItemFromTemplate(template: IItemTemplate, templateDictionary: any, destinationAuthentication: UserSession, itemProgressCallback: IItemProgressCallback): Promise<ICreateItemFromTemplateResponse>;
40
+ export declare function isAStoryMap(itemType: string): boolean;
@@ -1,141 +1,141 @@
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
- exports.isAStoryMap = exports.createItemFromTemplate = exports.convertItemToTemplate = void 0;
19
- /**
20
- * Manages the creation and deployment of Story Map item types.
21
- *
22
- * @module storymap
23
- */
24
- const solution_common_1 = require("@esri/solution-common");
25
- const hub_common_1 = require("@esri/hub-common");
26
- const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
27
- const convert_storymap_to_template_1 = require("./helpers/convert-storymap-to-template");
28
- const create_storymap_model_from_template_1 = require("./helpers/create-storymap-model-from-template");
29
- const create_storymap_1 = require("./helpers/create-storymap");
30
- /**
31
- * Convert a StoryMap to a template
32
- *
33
- * @param solutionItemId
34
- * @param itemInfo
35
- * @param destAuthentication Credentials for requests to the destination organization
36
- * @param srcAuthentication Credentials for requests to source items
37
- */
38
- function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication) {
39
- const model = {
40
- item: itemInfo,
41
- data: {}
42
- };
43
- // fetch the data.json
44
- return (0, arcgis_rest_portal_1.getItemData)(itemInfo.id, { authentication: srcAuthentication })
45
- .then(data => {
46
- // append into the model
47
- model.data = data;
48
- // and use that to create a template
49
- return (0, convert_storymap_to_template_1.convertStoryMapToTemplate)(model);
50
- })
51
- .then(tmpl => {
52
- return tmpl;
53
- });
54
- }
55
- exports.convertItemToTemplate = convertItemToTemplate;
56
- /**
57
- * Create a StoryMap from the passed in template
58
- *
59
- * @param template
60
- * @param templateDictionary
61
- * @param destinationAuthentication
62
- * @param itemProgressCallback
63
- */
64
- function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
65
- // let the progress system know we've started...
66
- const startStatus = itemProgressCallback(template.itemId, solution_common_1.EItemProgressStatus.Started, 0);
67
- // and if it returned false, just resolve out
68
- if (!startStatus) {
69
- return Promise.resolve((0, solution_common_1.generateEmptyCreationResponse)(template.type));
70
- }
71
- // ensure we have a solution object in the templateDictionary hash
72
- if (!templateDictionary.solution) {
73
- templateDictionary.solution = {};
74
- }
75
- // .title should always be set on the templateDictionary
76
- templateDictionary.solution.title = templateDictionary.title;
77
- // TODO: Determine if we need any transforms in this new env
78
- const transforms = {};
79
- // create an object to hold the created site through
80
- // subsequent promise calls
81
- let model;
82
- // Create the "siteModel" from the template. Does not save the site item yet
83
- // Note: depending on licensing and user privs, will also create the team groups
84
- // and initiative item.
85
- return (0, create_storymap_model_from_template_1.createStoryMapModelFromTemplate)(template, templateDictionary, transforms, destinationAuthentication)
86
- .then(interpolated => {
87
- const options = {
88
- assets: interpolated.assets || []
89
- };
90
- return (0, create_storymap_1.createStoryMap)(interpolated, templateDictionary.folderId, options, destinationAuthentication);
91
- })
92
- .then(createdModel => {
93
- model = createdModel;
94
- // Update the template dictionary
95
- // TODO: This should be done in whatever receives
96
- // the outcome of this promise chain
97
- templateDictionary[template.itemId] = {
98
- itemId: model.item.id
99
- };
100
- // call the progress callback, which also mutates templateDictionary
101
- const finalStatus = itemProgressCallback(template.itemId, solution_common_1.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor || 2, model.item.id);
102
- if (!finalStatus) {
103
- // clean up the site we just created
104
- const failSafeRemove = (0, hub_common_1.failSafe)(arcgis_rest_portal_1.removeItem, { success: true });
105
- return failSafeRemove({
106
- id: model.item.id,
107
- authentication: destinationAuthentication
108
- }).then(() => {
109
- return Promise.resolve((0, solution_common_1.generateEmptyCreationResponse)(template.type));
110
- });
111
- }
112
- else {
113
- // finally, return ICreateItemFromTemplateResponse
114
- const response = {
115
- item: {
116
- ...template,
117
- ...(0, solution_common_1.convertIModel)(model)
118
- },
119
- id: model.item.id,
120
- type: template.type,
121
- postProcess: false
122
- };
123
- response.item.itemId = model.item.id;
124
- return response;
125
- }
126
- })
127
- .catch(ex => {
128
- itemProgressCallback(template.itemId, solution_common_1.EItemProgressStatus.Failed, 0);
129
- throw ex;
130
- });
131
- }
132
- exports.createItemFromTemplate = createItemFromTemplate;
133
- function isAStoryMap(itemType) {
134
- let result = false;
135
- if (itemType === "StoryMap") {
136
- result = true;
137
- }
138
- return result;
139
- }
140
- exports.isAStoryMap = isAStoryMap;
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
+ exports.isAStoryMap = exports.createItemFromTemplate = exports.convertItemToTemplate = void 0;
19
+ /**
20
+ * Manages the creation and deployment of Story Map item types.
21
+ *
22
+ * @module storymap
23
+ */
24
+ const solution_common_1 = require("@esri/solution-common");
25
+ const hub_common_1 = require("@esri/hub-common");
26
+ const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
27
+ const convert_storymap_to_template_1 = require("./helpers/convert-storymap-to-template");
28
+ const create_storymap_model_from_template_1 = require("./helpers/create-storymap-model-from-template");
29
+ const create_storymap_1 = require("./helpers/create-storymap");
30
+ /**
31
+ * Convert a StoryMap to a template
32
+ *
33
+ * @param solutionItemId
34
+ * @param itemInfo
35
+ * @param destAuthentication Credentials for requests to the destination organization
36
+ * @param srcAuthentication Credentials for requests to source items
37
+ */
38
+ function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication) {
39
+ const model = {
40
+ item: itemInfo,
41
+ data: {}
42
+ };
43
+ // fetch the data.json
44
+ return (0, arcgis_rest_portal_1.getItemData)(itemInfo.id, { authentication: srcAuthentication })
45
+ .then(data => {
46
+ // append into the model
47
+ model.data = data;
48
+ // and use that to create a template
49
+ return (0, convert_storymap_to_template_1.convertStoryMapToTemplate)(model);
50
+ })
51
+ .then(tmpl => {
52
+ return tmpl;
53
+ });
54
+ }
55
+ exports.convertItemToTemplate = convertItemToTemplate;
56
+ /**
57
+ * Create a StoryMap from the passed in template
58
+ *
59
+ * @param template
60
+ * @param templateDictionary
61
+ * @param destinationAuthentication
62
+ * @param itemProgressCallback
63
+ */
64
+ function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
65
+ // let the progress system know we've started...
66
+ const startStatus = itemProgressCallback(template.itemId, solution_common_1.EItemProgressStatus.Started, 0);
67
+ // and if it returned false, just resolve out
68
+ if (!startStatus) {
69
+ return Promise.resolve((0, solution_common_1.generateEmptyCreationResponse)(template.type));
70
+ }
71
+ // ensure we have a solution object in the templateDictionary hash
72
+ if (!templateDictionary.solution) {
73
+ templateDictionary.solution = {};
74
+ }
75
+ // .title should always be set on the templateDictionary
76
+ templateDictionary.solution.title = templateDictionary.title;
77
+ // TODO: Determine if we need any transforms in this new env
78
+ const transforms = {};
79
+ // create an object to hold the created site through
80
+ // subsequent promise calls
81
+ let model;
82
+ // Create the "siteModel" from the template. Does not save the site item yet
83
+ // Note: depending on licensing and user privs, will also create the team groups
84
+ // and initiative item.
85
+ return (0, create_storymap_model_from_template_1.createStoryMapModelFromTemplate)(template, templateDictionary, transforms, destinationAuthentication)
86
+ .then(interpolated => {
87
+ const options = {
88
+ assets: interpolated.assets || []
89
+ };
90
+ return (0, create_storymap_1.createStoryMap)(interpolated, templateDictionary.folderId, options, destinationAuthentication);
91
+ })
92
+ .then(createdModel => {
93
+ model = createdModel;
94
+ // Update the template dictionary
95
+ // TODO: This should be done in whatever receives
96
+ // the outcome of this promise chain
97
+ templateDictionary[template.itemId] = {
98
+ itemId: model.item.id
99
+ };
100
+ // call the progress callback, which also mutates templateDictionary
101
+ const finalStatus = itemProgressCallback(template.itemId, solution_common_1.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor || 2, model.item.id);
102
+ if (!finalStatus) {
103
+ // clean up the site we just created
104
+ const failSafeRemove = (0, hub_common_1.failSafe)(arcgis_rest_portal_1.removeItem, { success: true });
105
+ return failSafeRemove({
106
+ id: model.item.id,
107
+ authentication: destinationAuthentication
108
+ }).then(() => {
109
+ return Promise.resolve((0, solution_common_1.generateEmptyCreationResponse)(template.type));
110
+ });
111
+ }
112
+ else {
113
+ // finally, return ICreateItemFromTemplateResponse
114
+ const response = {
115
+ item: {
116
+ ...template,
117
+ ...(0, solution_common_1.convertIModel)(model)
118
+ },
119
+ id: model.item.id,
120
+ type: template.type,
121
+ postProcess: false
122
+ };
123
+ response.item.itemId = model.item.id;
124
+ return response;
125
+ }
126
+ })
127
+ .catch(ex => {
128
+ itemProgressCallback(template.itemId, solution_common_1.EItemProgressStatus.Failed, 0);
129
+ throw ex;
130
+ });
131
+ }
132
+ exports.createItemFromTemplate = createItemFromTemplate;
133
+ function isAStoryMap(itemType) {
134
+ let result = false;
135
+ if (itemType === "StoryMap") {
136
+ result = true;
137
+ }
138
+ return result;
139
+ }
140
+ exports.isAStoryMap = isAStoryMap;
141
141
  //# sourceMappingURL=storymap-processor.js.map
@@ -1,24 +1,24 @@
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 Story Map item types.
18
- *
19
- * @module storymap
20
- */
21
- import * as common from "@esri/solution-common";
22
- export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any): Promise<common.IItemTemplate>;
23
- export declare function createItemFromTemplate(template: common.IItemTemplate, templateDictionary: any, destinationAuthentication: common.UserSession, itemProgressCallback: common.IItemProgressCallback): Promise<common.ICreateItemFromTemplateResponse>;
24
- export declare function isAStoryMap(itemType: string, itemUrl?: string): boolean;
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 Story Map item types.
18
+ *
19
+ * @module storymap
20
+ */
21
+ import * as common from "@esri/solution-common";
22
+ export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any): Promise<common.IItemTemplate>;
23
+ export declare function createItemFromTemplate(template: common.IItemTemplate, templateDictionary: any, destinationAuthentication: common.UserSession, itemProgressCallback: common.IItemProgressCallback): Promise<common.ICreateItemFromTemplateResponse>;
24
+ export declare function isAStoryMap(itemType: string, itemUrl?: string): boolean;