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