@esri/solution-storymap 4.1.2 → 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,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;
|
|
@@ -1,69 +1,69 @@
|
|
|
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
|
-
const tslib_1 = require("tslib");
|
|
20
|
-
/**
|
|
21
|
-
* Manages the creation and deployment of Story Map item types.
|
|
22
|
-
*
|
|
23
|
-
* @module storymap
|
|
24
|
-
*/
|
|
25
|
-
const common = tslib_1.__importStar(require("@esri/solution-common"));
|
|
26
|
-
// ------------------------------------------------------------------------------------------------------------------ //
|
|
27
|
-
function convertItemToTemplate(solutionItemId, itemInfo) {
|
|
28
|
-
return new Promise((resolve, reject) => {
|
|
29
|
-
if (isAStoryMap(itemInfo.type, itemInfo.url)) {
|
|
30
|
-
reject(common.fail("Classic StoryMap is not yet implemented"));
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
reject(common.fail(itemInfo.id + " is not a StoryMap"));
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
exports.convertItemToTemplate = convertItemToTemplate;
|
|
38
|
-
function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
|
|
39
|
-
return new Promise(resolve => {
|
|
40
|
-
if (isAStoryMap(template.type, template.item.url)) {
|
|
41
|
-
// Not yet implemented
|
|
42
|
-
itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
|
|
43
|
-
resolve(common.generateEmptyCreationResponse(template.type));
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
// Not valid
|
|
47
|
-
itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
|
|
48
|
-
resolve(common.generateEmptyCreationResponse(template.type));
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
exports.createItemFromTemplate = createItemFromTemplate;
|
|
53
|
-
function isAStoryMap(itemType, itemUrl) {
|
|
54
|
-
if (itemUrl) {
|
|
55
|
-
return [
|
|
56
|
-
/\/apps\/Cascade\//i,
|
|
57
|
-
/\/apps\/MapJournal\//i,
|
|
58
|
-
/\/apps\/MapSeries\//i,
|
|
59
|
-
/\/apps\/MapTour\//i,
|
|
60
|
-
/\/apps\/Shortlist\//i,
|
|
61
|
-
/\/apps\/StoryMap\//i,
|
|
62
|
-
/\/apps\/StoryMapBasic\//i,
|
|
63
|
-
/\/apps\/StorytellingSwipe\//i
|
|
64
|
-
].some(pattern => pattern.test(itemUrl));
|
|
65
|
-
}
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
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
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
/**
|
|
21
|
+
* Manages the creation and deployment of Story Map item types.
|
|
22
|
+
*
|
|
23
|
+
* @module storymap
|
|
24
|
+
*/
|
|
25
|
+
const common = tslib_1.__importStar(require("@esri/solution-common"));
|
|
26
|
+
// ------------------------------------------------------------------------------------------------------------------ //
|
|
27
|
+
function convertItemToTemplate(solutionItemId, itemInfo) {
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
if (isAStoryMap(itemInfo.type, itemInfo.url)) {
|
|
30
|
+
reject(common.fail("Classic StoryMap is not yet implemented"));
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
reject(common.fail(itemInfo.id + " is not a StoryMap"));
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
exports.convertItemToTemplate = convertItemToTemplate;
|
|
38
|
+
function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
|
|
39
|
+
return new Promise(resolve => {
|
|
40
|
+
if (isAStoryMap(template.type, template.item.url)) {
|
|
41
|
+
// Not yet implemented
|
|
42
|
+
itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
|
|
43
|
+
resolve(common.generateEmptyCreationResponse(template.type));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
// Not valid
|
|
47
|
+
itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
|
|
48
|
+
resolve(common.generateEmptyCreationResponse(template.type));
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
exports.createItemFromTemplate = createItemFromTemplate;
|
|
53
|
+
function isAStoryMap(itemType, itemUrl) {
|
|
54
|
+
if (itemUrl) {
|
|
55
|
+
return [
|
|
56
|
+
/\/apps\/Cascade\//i,
|
|
57
|
+
/\/apps\/MapJournal\//i,
|
|
58
|
+
/\/apps\/MapSeries\//i,
|
|
59
|
+
/\/apps\/MapTour\//i,
|
|
60
|
+
/\/apps\/Shortlist\//i,
|
|
61
|
+
/\/apps\/StoryMap\//i,
|
|
62
|
+
/\/apps\/StoryMapBasic\//i,
|
|
63
|
+
/\/apps\/StorytellingSwipe\//i
|
|
64
|
+
].some(pattern => pattern.test(itemUrl));
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
exports.isAStoryMap = isAStoryMap;
|
|
69
69
|
//# sourceMappingURL=classic-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
|
-
import { IModel } from "@esri/hub-common";
|
|
17
|
-
import { IItemTemplate } from "@esri/solution-common";
|
|
18
|
-
/**
|
|
19
|
-
* Convert a StoryMap IModel to an IItemTemplate
|
|
20
|
-
*
|
|
21
|
-
* @param model
|
|
22
|
-
* @param authentication
|
|
23
|
-
*/
|
|
24
|
-
export declare function convertStoryMapToTemplate(model: IModel): Promise<IItemTemplate>;
|
|
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 { IModel } from "@esri/hub-common";
|
|
17
|
+
import { IItemTemplate } from "@esri/solution-common";
|
|
18
|
+
/**
|
|
19
|
+
* Convert a StoryMap IModel to an IItemTemplate
|
|
20
|
+
*
|
|
21
|
+
* @param model
|
|
22
|
+
* @param authentication
|
|
23
|
+
*/
|
|
24
|
+
export declare function convertStoryMapToTemplate(model: IModel): Promise<IItemTemplate>;
|
|
@@ -1,99 +1,99 @@
|
|
|
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.convertStoryMapToTemplate = void 0;
|
|
19
|
-
const hub_common_1 = require("@esri/hub-common");
|
|
20
|
-
const solution_common_1 = require("@esri/solution-common");
|
|
21
|
-
const remap_webmap_keys_1 = require("./remap-webmap-keys");
|
|
22
|
-
const get_storymap_dependencies_1 = require("./get-storymap-dependencies");
|
|
23
|
-
/**
|
|
24
|
-
* Convert a StoryMap IModel to an IItemTemplate
|
|
25
|
-
*
|
|
26
|
-
* @param model
|
|
27
|
-
* @param authentication
|
|
28
|
-
*/
|
|
29
|
-
function convertStoryMapToTemplate(model) {
|
|
30
|
-
const tmpl = (0, solution_common_1.createPlaceholderTemplate)(model.item.id, model.item.type);
|
|
31
|
-
tmpl.key = `${(0, hub_common_1.propifyString)(model.item.title)}_${(0, hub_common_1.createId)("i")}`;
|
|
32
|
-
const clone = (0, hub_common_1.cloneObject)(model);
|
|
33
|
-
tmpl.data = clone.data;
|
|
34
|
-
// We need to save these properties in order to restore them after hub.js deletes them
|
|
35
|
-
const created = clone.item.created;
|
|
36
|
-
const modified = clone.item.modified;
|
|
37
|
-
tmpl.item = (0, hub_common_1.normalizeSolutionTemplateItem)(clone.item);
|
|
38
|
-
tmpl.item.created = created;
|
|
39
|
-
tmpl.item.modified = modified;
|
|
40
|
-
// templatize the url
|
|
41
|
-
tmpl.item.url = "{{storyMapTemplateUrl}}";
|
|
42
|
-
// Storymap Webmap Resources have complex keys that we need to remap
|
|
43
|
-
const webmapRemaps = (0, remap_webmap_keys_1.remapWebmapKeys)(tmpl.data.resources);
|
|
44
|
-
// and then replace in the rest of the structure
|
|
45
|
-
webmapRemaps.forEach(remap => {
|
|
46
|
-
tmpl.data.resources[remap.updated] = (0, hub_common_1.cloneObject)(tmpl.data.resources[remap.original]);
|
|
47
|
-
delete tmpl.data.resources[remap.original];
|
|
48
|
-
tmpl.data.nodes = (0, hub_common_1.deepStringReplace)(tmpl.data.nodes, remap.original, remap.updated);
|
|
49
|
-
});
|
|
50
|
-
// use typeKeyword to mark item as published
|
|
51
|
-
// Note: Hub team decided to discard unpublished drafts when creating a template
|
|
52
|
-
const typeKeywords = tmpl.item.typeKeywords;
|
|
53
|
-
if (typeKeywords.indexOf(unPublishedChangesKW) !== -1) {
|
|
54
|
-
tmpl.item.typeKeywords = [publishedChangesKW].concat(tmpl.item.typeKeywords.filter((word) => word !== unPublishedChangesKW));
|
|
55
|
-
}
|
|
56
|
-
tmpl.properties = {};
|
|
57
|
-
tmpl.properties.draftFileName = "draft_{{timestamp}}.json";
|
|
58
|
-
Object.assign(tmpl.properties, oEmbedTemplates);
|
|
59
|
-
tmpl.dependencies = (0, get_storymap_dependencies_1.getStoryMapDependencies)(model);
|
|
60
|
-
return Promise.resolve(tmpl);
|
|
61
|
-
// TODO: For now, we let the generic process handle item resources
|
|
62
|
-
// However, many newer item types have complex type-specific resource handling
|
|
63
|
-
// requirements so this code may be useful in the future
|
|
64
|
-
// ------------------------------------------------------
|
|
65
|
-
// return getItemResources(tmpl.itemId, hubRequestOptions)
|
|
66
|
-
// .then((response) => {
|
|
67
|
-
// tmpl.resources = response.resources.map(e => e.resource)
|
|
68
|
-
// // Don't directly copy oembed resources because we need to template these
|
|
69
|
-
// // Also, discard draft version of the storymap itself
|
|
70
|
-
// .filter(filename => !filename.includes('oembed') && filename.search(/draft_[0-9]+.json/) === -1);
|
|
71
|
-
// return tmpl;
|
|
72
|
-
// });
|
|
73
|
-
}
|
|
74
|
-
exports.convertStoryMapToTemplate = convertStoryMapToTemplate;
|
|
75
|
-
// Internal constants
|
|
76
|
-
const unPublishedChangesKW = "smstatusunpublishedchanges";
|
|
77
|
-
const publishedChangesKW = "smstatuspublished";
|
|
78
|
-
/**
|
|
79
|
-
* Template for oEmbed
|
|
80
|
-
*/
|
|
81
|
-
const oEmbedTemplates = {
|
|
82
|
-
oembed: {
|
|
83
|
-
version: "1.0",
|
|
84
|
-
type: "rich",
|
|
85
|
-
title: "Example StoryMap",
|
|
86
|
-
url: "{{storyMapTemplateUrl}}",
|
|
87
|
-
provider_name: "ArcGIS StoryMaps",
|
|
88
|
-
provider_url: "{{storyMapBaseUrl}}",
|
|
89
|
-
width: 800,
|
|
90
|
-
height: 600,
|
|
91
|
-
thumbnail_url: "{{storyMapThumbnailUrl}}",
|
|
92
|
-
thumbnail_height: "100.5",
|
|
93
|
-
thumbnail_width: "400",
|
|
94
|
-
html: '<iframe src="{{storyMapTemplateUrl}}" width="800" height="600" scrolling="yes" frameborder="0" allowfullscreen></iframe>',
|
|
95
|
-
cache_age: 86400
|
|
96
|
-
},
|
|
97
|
-
oembedXML: '<?xml version="1.0" encoding="utf-8" standalone="yes"?>\n <oembed>\n <version>1.0</version>\n <type>rich</type>\n <title>Example StoryMap</title>\n <url>{{storyMapTemplateUrl}}</url>\n <author_name>undefined</author_name>\n <provider_name>ArcGIS StoryMaps</provider_name>\n <provider_url>{{storyMapBaseUrl}}</provider_url>\n <width>800</width>\n <height>600</height>\n <thumbnail_url>{{storyMapThumbnailUrl}}</thumbnail_url>\n <thumbnail_height>100.5</thumbnail_height>\n <thumbnail_width>400</thumbnail_width>\n <html><iframe src="{{storyMapTemplateUrl}}" width="800" height="600" scrolling="yes" frameborder="0" allowfullscreen="true"></iframe></html>\n <cache_age>86400</cache_age>\n </oembed>'
|
|
98
|
-
};
|
|
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.convertStoryMapToTemplate = void 0;
|
|
19
|
+
const hub_common_1 = require("@esri/hub-common");
|
|
20
|
+
const solution_common_1 = require("@esri/solution-common");
|
|
21
|
+
const remap_webmap_keys_1 = require("./remap-webmap-keys");
|
|
22
|
+
const get_storymap_dependencies_1 = require("./get-storymap-dependencies");
|
|
23
|
+
/**
|
|
24
|
+
* Convert a StoryMap IModel to an IItemTemplate
|
|
25
|
+
*
|
|
26
|
+
* @param model
|
|
27
|
+
* @param authentication
|
|
28
|
+
*/
|
|
29
|
+
function convertStoryMapToTemplate(model) {
|
|
30
|
+
const tmpl = (0, solution_common_1.createPlaceholderTemplate)(model.item.id, model.item.type);
|
|
31
|
+
tmpl.key = `${(0, hub_common_1.propifyString)(model.item.title)}_${(0, hub_common_1.createId)("i")}`;
|
|
32
|
+
const clone = (0, hub_common_1.cloneObject)(model);
|
|
33
|
+
tmpl.data = clone.data;
|
|
34
|
+
// We need to save these properties in order to restore them after hub.js deletes them
|
|
35
|
+
const created = clone.item.created;
|
|
36
|
+
const modified = clone.item.modified;
|
|
37
|
+
tmpl.item = (0, hub_common_1.normalizeSolutionTemplateItem)(clone.item);
|
|
38
|
+
tmpl.item.created = created;
|
|
39
|
+
tmpl.item.modified = modified;
|
|
40
|
+
// templatize the url
|
|
41
|
+
tmpl.item.url = "{{storyMapTemplateUrl}}";
|
|
42
|
+
// Storymap Webmap Resources have complex keys that we need to remap
|
|
43
|
+
const webmapRemaps = (0, remap_webmap_keys_1.remapWebmapKeys)(tmpl.data.resources);
|
|
44
|
+
// and then replace in the rest of the structure
|
|
45
|
+
webmapRemaps.forEach(remap => {
|
|
46
|
+
tmpl.data.resources[remap.updated] = (0, hub_common_1.cloneObject)(tmpl.data.resources[remap.original]);
|
|
47
|
+
delete tmpl.data.resources[remap.original];
|
|
48
|
+
tmpl.data.nodes = (0, hub_common_1.deepStringReplace)(tmpl.data.nodes, remap.original, remap.updated);
|
|
49
|
+
});
|
|
50
|
+
// use typeKeyword to mark item as published
|
|
51
|
+
// Note: Hub team decided to discard unpublished drafts when creating a template
|
|
52
|
+
const typeKeywords = tmpl.item.typeKeywords;
|
|
53
|
+
if (typeKeywords.indexOf(unPublishedChangesKW) !== -1) {
|
|
54
|
+
tmpl.item.typeKeywords = [publishedChangesKW].concat(tmpl.item.typeKeywords.filter((word) => word !== unPublishedChangesKW));
|
|
55
|
+
}
|
|
56
|
+
tmpl.properties = {};
|
|
57
|
+
tmpl.properties.draftFileName = "draft_{{timestamp}}.json";
|
|
58
|
+
Object.assign(tmpl.properties, oEmbedTemplates);
|
|
59
|
+
tmpl.dependencies = (0, get_storymap_dependencies_1.getStoryMapDependencies)(model);
|
|
60
|
+
return Promise.resolve(tmpl);
|
|
61
|
+
// TODO: For now, we let the generic process handle item resources
|
|
62
|
+
// However, many newer item types have complex type-specific resource handling
|
|
63
|
+
// requirements so this code may be useful in the future
|
|
64
|
+
// ------------------------------------------------------
|
|
65
|
+
// return getItemResources(tmpl.itemId, hubRequestOptions)
|
|
66
|
+
// .then((response) => {
|
|
67
|
+
// tmpl.resources = response.resources.map(e => e.resource)
|
|
68
|
+
// // Don't directly copy oembed resources because we need to template these
|
|
69
|
+
// // Also, discard draft version of the storymap itself
|
|
70
|
+
// .filter(filename => !filename.includes('oembed') && filename.search(/draft_[0-9]+.json/) === -1);
|
|
71
|
+
// return tmpl;
|
|
72
|
+
// });
|
|
73
|
+
}
|
|
74
|
+
exports.convertStoryMapToTemplate = convertStoryMapToTemplate;
|
|
75
|
+
// Internal constants
|
|
76
|
+
const unPublishedChangesKW = "smstatusunpublishedchanges";
|
|
77
|
+
const publishedChangesKW = "smstatuspublished";
|
|
78
|
+
/**
|
|
79
|
+
* Template for oEmbed
|
|
80
|
+
*/
|
|
81
|
+
const oEmbedTemplates = {
|
|
82
|
+
oembed: {
|
|
83
|
+
version: "1.0",
|
|
84
|
+
type: "rich",
|
|
85
|
+
title: "Example StoryMap",
|
|
86
|
+
url: "{{storyMapTemplateUrl}}",
|
|
87
|
+
provider_name: "ArcGIS StoryMaps",
|
|
88
|
+
provider_url: "{{storyMapBaseUrl}}",
|
|
89
|
+
width: 800,
|
|
90
|
+
height: 600,
|
|
91
|
+
thumbnail_url: "{{storyMapThumbnailUrl}}",
|
|
92
|
+
thumbnail_height: "100.5",
|
|
93
|
+
thumbnail_width: "400",
|
|
94
|
+
html: '<iframe src="{{storyMapTemplateUrl}}" width="800" height="600" scrolling="yes" frameborder="0" allowfullscreen></iframe>',
|
|
95
|
+
cache_age: 86400
|
|
96
|
+
},
|
|
97
|
+
oembedXML: '<?xml version="1.0" encoding="utf-8" standalone="yes"?>\n <oembed>\n <version>1.0</version>\n <type>rich</type>\n <title>Example StoryMap</title>\n <url>{{storyMapTemplateUrl}}</url>\n <author_name>undefined</author_name>\n <provider_name>ArcGIS StoryMaps</provider_name>\n <provider_url>{{storyMapBaseUrl}}</provider_url>\n <width>800</width>\n <height>600</height>\n <thumbnail_url>{{storyMapThumbnailUrl}}</thumbnail_url>\n <thumbnail_height>100.5</thumbnail_height>\n <thumbnail_width>400</thumbnail_width>\n <html><iframe src="{{storyMapTemplateUrl}}" width="800" height="600" scrolling="yes" frameborder="0" allowfullscreen="true"></iframe></html>\n <cache_age>86400</cache_age>\n </oembed>'
|
|
98
|
+
};
|
|
99
99
|
//# sourceMappingURL=convert-storymap-to-template.js.map
|
|
@@ -1,22 +1,22 @@
|
|
|
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
|
-
* Given a template, process it and interpolate it such that
|
|
18
|
-
* we have a model that is ready to be sent to the Portal API
|
|
19
|
-
*/
|
|
20
|
-
import { IModelTemplate } from "@esri/hub-common";
|
|
21
|
-
import { UserSession } from "@esri/solution-common";
|
|
22
|
-
export declare function createStoryMapModelFromTemplate(templateModel: IModelTemplate, settings: any, transforms: any, authentication: UserSession): Promise<any>;
|
|
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
|
+
* Given a template, process it and interpolate it such that
|
|
18
|
+
* we have a model that is ready to be sent to the Portal API
|
|
19
|
+
*/
|
|
20
|
+
import { IModelTemplate } from "@esri/hub-common";
|
|
21
|
+
import { UserSession } from "@esri/solution-common";
|
|
22
|
+
export declare function createStoryMapModelFromTemplate(templateModel: IModelTemplate, settings: any, transforms: any, authentication: UserSession): Promise<any>;
|
|
@@ -1,43 +1,43 @@
|
|
|
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
|
-
/**
|
|
18
|
-
* Given a template, process it and interpolate it such that
|
|
19
|
-
* we have a model that is ready to be sent to the Portal API
|
|
20
|
-
*/
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.createStoryMapModelFromTemplate = void 0;
|
|
23
|
-
const hub_common_1 = require("@esri/hub-common");
|
|
24
|
-
const get_portal_env_1 = require("./get-portal-env");
|
|
25
|
-
const get_storymap_base_url_1 = require("./get-storymap-base-url");
|
|
26
|
-
const get_storymap_subdomain_1 = require("./get-storymap-subdomain");
|
|
27
|
-
function createStoryMapModelFromTemplate(templateModel, settings, transforms, authentication) {
|
|
28
|
-
const timestamp = new Date().getTime();
|
|
29
|
-
// Keep these around in case we encounter some old templates
|
|
30
|
-
settings.agoenv = (0, get_portal_env_1.getPortalEnv)(authentication);
|
|
31
|
-
settings.smBase = (0, get_storymap_subdomain_1.getStoryMapSubdomain)(authentication);
|
|
32
|
-
settings.timestamp = new Date().getTime();
|
|
33
|
-
// These are used in the oembed resource, as well as the item url
|
|
34
|
-
// they have `{{appid}}` in them so that the id of the created item
|
|
35
|
-
// will be interpolated into it after the item is created
|
|
36
|
-
settings.storyMapBaseUrl = (0, get_storymap_base_url_1.getStoryMapBaseUrl)(authentication);
|
|
37
|
-
settings.storyMapTemplateUrl = `${settings.storyMapBaseUrl}/stories/{{appid}}`;
|
|
38
|
-
settings.storyMapThumnailUrl = `${authentication.portal}/content/items/{{appid}}/info/thumbnail/thumbnail.jpg/?w=400&d=${timestamp}`;
|
|
39
|
-
const model = (0, hub_common_1.interpolate)(templateModel, settings, transforms);
|
|
40
|
-
return Promise.resolve(model);
|
|
41
|
-
}
|
|
42
|
-
exports.createStoryMapModelFromTemplate = createStoryMapModelFromTemplate;
|
|
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
|
+
/**
|
|
18
|
+
* Given a template, process it and interpolate it such that
|
|
19
|
+
* we have a model that is ready to be sent to the Portal API
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.createStoryMapModelFromTemplate = void 0;
|
|
23
|
+
const hub_common_1 = require("@esri/hub-common");
|
|
24
|
+
const get_portal_env_1 = require("./get-portal-env");
|
|
25
|
+
const get_storymap_base_url_1 = require("./get-storymap-base-url");
|
|
26
|
+
const get_storymap_subdomain_1 = require("./get-storymap-subdomain");
|
|
27
|
+
function createStoryMapModelFromTemplate(templateModel, settings, transforms, authentication) {
|
|
28
|
+
const timestamp = new Date().getTime();
|
|
29
|
+
// Keep these around in case we encounter some old templates
|
|
30
|
+
settings.agoenv = (0, get_portal_env_1.getPortalEnv)(authentication);
|
|
31
|
+
settings.smBase = (0, get_storymap_subdomain_1.getStoryMapSubdomain)(authentication);
|
|
32
|
+
settings.timestamp = new Date().getTime();
|
|
33
|
+
// These are used in the oembed resource, as well as the item url
|
|
34
|
+
// they have `{{appid}}` in them so that the id of the created item
|
|
35
|
+
// will be interpolated into it after the item is created
|
|
36
|
+
settings.storyMapBaseUrl = (0, get_storymap_base_url_1.getStoryMapBaseUrl)(authentication);
|
|
37
|
+
settings.storyMapTemplateUrl = `${settings.storyMapBaseUrl}/stories/{{appid}}`;
|
|
38
|
+
settings.storyMapThumnailUrl = `${authentication.portal}/content/items/{{appid}}/info/thumbnail/thumbnail.jpg/?w=400&d=${timestamp}`;
|
|
39
|
+
const model = (0, hub_common_1.interpolate)(templateModel, settings, transforms);
|
|
40
|
+
return Promise.resolve(model);
|
|
41
|
+
}
|
|
42
|
+
exports.createStoryMapModelFromTemplate = createStoryMapModelFromTemplate;
|
|
43
43
|
//# sourceMappingURL=create-storymap-model-from-template.js.map
|
|
@@ -1,25 +1,25 @@
|
|
|
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
|
-
import { IModel } from "@esri/hub-common";
|
|
17
|
-
import { UserSession } from "@esri/solution-common";
|
|
18
|
-
/**
|
|
19
|
-
* Create a StoryMap from an interpolated template
|
|
20
|
-
*
|
|
21
|
-
* @param model
|
|
22
|
-
* @param options
|
|
23
|
-
* @param authentication
|
|
24
|
-
*/
|
|
25
|
-
export declare function createStoryMap(model: IModel, folderId: string, options: any, authentication: UserSession): Promise<IModel>;
|
|
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
|
+
import { IModel } from "@esri/hub-common";
|
|
17
|
+
import { UserSession } from "@esri/solution-common";
|
|
18
|
+
/**
|
|
19
|
+
* Create a StoryMap from an interpolated template
|
|
20
|
+
*
|
|
21
|
+
* @param model
|
|
22
|
+
* @param options
|
|
23
|
+
* @param authentication
|
|
24
|
+
*/
|
|
25
|
+
export declare function createStoryMap(model: IModel, folderId: string, options: any, authentication: UserSession): Promise<IModel>;
|