@esri/solution-storymap 5.2.3 → 5.2.4
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 -0
- package/dist/cjs/classic-storymap-processor.js +69 -0
- package/dist/cjs/classic-storymap-processor.js.map +1 -0
- package/dist/cjs/helpers/convert-storymap-to-template.d.ts +24 -0
- package/dist/cjs/helpers/convert-storymap-to-template.js +99 -0
- package/dist/cjs/helpers/convert-storymap-to-template.js.map +1 -0
- package/dist/cjs/helpers/create-storymap-model-from-template.d.ts +22 -0
- package/dist/cjs/helpers/create-storymap-model-from-template.js +43 -0
- package/dist/cjs/helpers/create-storymap-model-from-template.js.map +1 -0
- package/dist/cjs/helpers/create-storymap.d.ts +25 -0
- package/dist/cjs/helpers/create-storymap.js +119 -0
- package/dist/cjs/helpers/create-storymap.js.map +1 -0
- package/dist/cjs/helpers/get-portal-env.d.ts +17 -0
- package/dist/cjs/helpers/get-portal-env.js +19 -0
- package/dist/cjs/helpers/get-portal-env.js.map +1 -0
- package/dist/cjs/helpers/get-storymap-base-url.d.ts +23 -0
- package/dist/cjs/helpers/get-storymap-base-url.js +26 -0
- package/dist/cjs/helpers/get-storymap-base-url.js.map +1 -0
- package/dist/cjs/helpers/get-storymap-dependencies.d.ts +23 -0
- package/dist/cjs/helpers/get-storymap-dependencies.js +36 -0
- package/dist/cjs/helpers/get-storymap-dependencies.js.map +1 -0
- package/dist/cjs/helpers/get-storymap-subdomain.d.ts +17 -0
- package/dist/cjs/helpers/get-storymap-subdomain.js +20 -0
- package/dist/cjs/helpers/get-storymap-subdomain.js.map +1 -0
- package/dist/cjs/helpers/remap-webmap-keys.d.ts +24 -0
- package/dist/cjs/helpers/remap-webmap-keys.js +44 -0
- package/dist/cjs/helpers/remap-webmap-keys.js.map +1 -0
- package/dist/cjs/index.d.ts +23 -0
- package/dist/cjs/index.js +29 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/storymap-processor.d.ts +39 -0
- package/dist/cjs/storymap-processor.js +140 -0
- package/dist/cjs/storymap-processor.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/package.json +3 -3
|
@@ -0,0 +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(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;
|
|
@@ -0,0 +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(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
|
+
//# sourceMappingURL=classic-storymap-processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classic-storymap-processor.js","sourceRoot":"","sources":["../../src/classic-storymap-processor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH;;;;GAIG;AAEH,sEAAgD;AAEhD,wHAAwH;AAExH,SAAgB,qBAAqB,CACnC,QAAa;IAEb,OAAO,IAAI,OAAO,CAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3D,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE;YAC5C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAC,CAAC;SAChE;aAAM;YACL,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,GAAG,oBAAoB,CAAC,CAAC,CAAC;SACzD;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAVD,sDAUC;AAED,SAAgB,sBAAsB,CACpC,QAA8B,EAC9B,kBAAuB,EACvB,yBAA6C,EAC7C,oBAAkD;IAElD,OAAO,IAAI,OAAO,CAAyC,OAAO,CAAC,EAAE;QACnE,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YACjD,sBAAsB;YACtB,oBAAoB,CAClB,QAAQ,CAAC,MAAM,EACf,MAAM,CAAC,mBAAmB,CAAC,MAAM,EACjC,CAAC,CACF,CAAC;YACF,OAAO,CAAC,MAAM,CAAC,6BAA6B,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;SAC9D;aAAM;YACL,YAAY;YACZ,oBAAoB,CAClB,QAAQ,CAAC,MAAM,EACf,MAAM,CAAC,mBAAmB,CAAC,MAAM,EACjC,CAAC,CACF,CAAC;YACF,OAAO,CAAC,MAAM,CAAC,6BAA6B,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;SAC9D;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAzBD,wDAyBC;AAED,SAAgB,WAAW,CAAC,QAAgB,EAAE,OAAgB;IAC5D,IAAI,OAAO,EAAE;QACX,OAAO;YACL,oBAAoB;YACpB,uBAAuB;YACvB,sBAAsB;YACtB,oBAAoB;YACpB,sBAAsB;YACtB,qBAAqB;YACrB,0BAA0B;YAC1B,8BAA8B;SAC/B,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;KAC1C;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAdD,kCAcC"}
|
|
@@ -0,0 +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>;
|
|
@@ -0,0 +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
|
+
};
|
|
99
|
+
//# sourceMappingURL=convert-storymap-to-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-storymap-to-template.js","sourceRoot":"","sources":["../../../src/helpers/convert-storymap-to-template.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,iDAO0B;AAE1B,2DAG+B;AAC/B,2DAAsD;AACtD,2EAAsE;AAEtE;;;;;GAKG;AACH,SAAgB,yBAAyB,CACvC,KAAa;IAEb,MAAM,IAAI,GAAG,IAAA,2CAAyB,EAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvE,IAAI,CAAC,GAAG,GAAG,GAAG,IAAA,0BAAa,EAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAA,qBAAQ,EAAC,GAAG,CAAC,EAAE,CAAC;IAEjE,MAAM,KAAK,GAAG,IAAA,wBAAW,EAAC,KAAK,CAAC,CAAC;IACjC,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|
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>;
|
|
@@ -0,0 +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;
|
|
43
|
+
//# sourceMappingURL=create-storymap-model-from-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-storymap-model-from-template.js","sourceRoot":"","sources":["../../../src/helpers/create-storymap-model-from-template.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AACH;;;GAGG;;;AAEH,iDAA+D;AAE/D,qDAAgD;AAChD,mEAA6D;AAC7D,qEAAgE;AAEhE,SAAgB,+BAA+B,CAC7C,aAA6B,EAC7B,QAAa,EACb,UAAe,EACf,cAA2B;IAE3B,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;IACvC,4DAA4D;IAC5D,QAAQ,CAAC,MAAM,GAAG,IAAA,6BAAY,EAAC,cAAc,CAAC,CAAC;IAC/C,QAAQ,CAAC,MAAM,GAAG,IAAA,6CAAoB,EAAC,cAAc,CAAC,CAAC;IACvD,QAAQ,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;IAC1C,iEAAiE;IACjE,mEAAmE;IACnE,yDAAyD;IACzD,QAAQ,CAAC,eAAe,GAAG,IAAA,0CAAkB,EAAC,cAAc,CAAC,CAAC;IAC9D,QAAQ,CAAC,mBAAmB,GAAG,GAAG,QAAQ,CAAC,eAAe,oBAAoB,CAAC;IAC/E,QAAQ,CAAC,mBAAmB,GAAG,GAAG,cAAc,CAAC,MAAM,kEAAkE,SAAS,EAAE,CAAC;IAErI,MAAM,KAAK,GAAG,IAAA,wBAAW,EAAC,aAAa,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;IAE/D,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC;AArBD,0EAqBC"}
|
|
@@ -0,0 +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>;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** @license
|
|
3
|
+
* Copyright 2020 Esri
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.createStoryMap = void 0;
|
|
19
|
+
// TODO ENSURE THIS CREATES IN THE TARGET FOLDER
|
|
20
|
+
const hub_common_1 = require("@esri/hub-common");
|
|
21
|
+
const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
|
|
22
|
+
/**
|
|
23
|
+
* Create a StoryMap from an interpolated template
|
|
24
|
+
*
|
|
25
|
+
* @param model
|
|
26
|
+
* @param options
|
|
27
|
+
* @param authentication
|
|
28
|
+
*/
|
|
29
|
+
function createStoryMap(model, folderId, options, authentication) {
|
|
30
|
+
// create an array to hold well-known resources
|
|
31
|
+
// that we have to generate from the passed in model
|
|
32
|
+
const resources = [];
|
|
33
|
+
// The data section has been de-templatized. Some entries need to be encoded URLs, so we'll find and encode them.
|
|
34
|
+
model.data = JSON.parse(JSON.stringify(model.data).replace(/portalUrl=https:\/\//g, "portalUrl=https%3A%2F%2F"));
|
|
35
|
+
// For unknown reasons we can not seem to spy on createItemInFolder
|
|
36
|
+
// so we will create-then-move for now
|
|
37
|
+
const createOptions = {
|
|
38
|
+
// need to serialize
|
|
39
|
+
item: (0, hub_common_1.serializeModel)(model),
|
|
40
|
+
authentication
|
|
41
|
+
};
|
|
42
|
+
/* istanbul ignore else */
|
|
43
|
+
if (model.item.thumbnail) {
|
|
44
|
+
createOptions.params = {
|
|
45
|
+
// Pass thumbnail file in via params because item property is serialized, which discards a blob
|
|
46
|
+
thumbnail: model.item.thumbnail
|
|
47
|
+
};
|
|
48
|
+
delete createOptions.item.thumbnail;
|
|
49
|
+
}
|
|
50
|
+
// Create the item
|
|
51
|
+
return (0, arcgis_rest_portal_1.createItem)(createOptions)
|
|
52
|
+
.then((createResponse) => {
|
|
53
|
+
// hold the id in the model
|
|
54
|
+
model.item.id = createResponse.id;
|
|
55
|
+
// and re-interpolate the item id
|
|
56
|
+
model = (0, hub_common_1.interpolateItemId)(model);
|
|
57
|
+
// Compute the item url based on current environment
|
|
58
|
+
// Storymaps store draft data in a timestamped resource attached to the item
|
|
59
|
+
// We'll just use the published data for the first "draft"
|
|
60
|
+
const dataBlob = (0, hub_common_1.stringToBlob)(JSON.stringify(model.data));
|
|
61
|
+
resources.push({
|
|
62
|
+
name: model.properties.draftFileName,
|
|
63
|
+
file: dataBlob
|
|
64
|
+
});
|
|
65
|
+
resources.push({
|
|
66
|
+
name: "oembed.json",
|
|
67
|
+
file: (0, hub_common_1.stringToBlob)(JSON.stringify(model.properties.oembed))
|
|
68
|
+
});
|
|
69
|
+
resources.push({
|
|
70
|
+
name: "oembed.xml",
|
|
71
|
+
file: (0, hub_common_1.stringToBlob)(model.properties.oembedXML)
|
|
72
|
+
});
|
|
73
|
+
resources.push({
|
|
74
|
+
name: "published_data.json",
|
|
75
|
+
file: dataBlob
|
|
76
|
+
});
|
|
77
|
+
// remove the properties hash now that we've gotten what we need
|
|
78
|
+
delete model.properties;
|
|
79
|
+
// update the item with the newly re-interpolated model
|
|
80
|
+
return Promise.all([
|
|
81
|
+
(0, arcgis_rest_portal_1.updateItem)({
|
|
82
|
+
item: (0, hub_common_1.serializeModel)(model),
|
|
83
|
+
authentication
|
|
84
|
+
}),
|
|
85
|
+
authentication.getUsername()
|
|
86
|
+
]);
|
|
87
|
+
})
|
|
88
|
+
.then((responses) => {
|
|
89
|
+
const username = responses[1];
|
|
90
|
+
// add the resources
|
|
91
|
+
const failSafeAddItemResource = (0, hub_common_1.failSafe)(arcgis_rest_portal_1.addItemResource, {
|
|
92
|
+
success: true
|
|
93
|
+
});
|
|
94
|
+
const resourcePromises = resources.map(resource => {
|
|
95
|
+
return failSafeAddItemResource({
|
|
96
|
+
id: model.item.id,
|
|
97
|
+
owner: username,
|
|
98
|
+
resource: resource.file,
|
|
99
|
+
name: resource.name,
|
|
100
|
+
authentication
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
// Fire and forget as these are not critical-path
|
|
104
|
+
return Promise.all(resourcePromises);
|
|
105
|
+
})
|
|
106
|
+
.then(() => {
|
|
107
|
+
// Move it
|
|
108
|
+
return (0, arcgis_rest_portal_1.moveItem)({
|
|
109
|
+
itemId: model.item.id,
|
|
110
|
+
folderId,
|
|
111
|
+
authentication
|
|
112
|
+
});
|
|
113
|
+
})
|
|
114
|
+
.then(() => {
|
|
115
|
+
return model;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
exports.createStoryMap = createStoryMap;
|
|
119
|
+
//# sourceMappingURL=create-storymap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+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,CAAC,IAAI;gBACvB,IAAI,EAAE,QAAQ,CAAC,IAAI;gBACnB,cAAc;aACf,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,iDAAiD;QACjD,OAAO,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACvC,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,EAAE;QACT,UAAU;QACV,OAAO,IAAA,6BAAQ,EAAC;YACd,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE;YACrB,QAAQ;YACR,cAAc;SACf,CAAC,CAAC;IACL,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,EAAE;QACT,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACP,CAAC;AAlGD,wCAkGC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
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 { UserSession } from "@esri/solution-common";
|
|
17
|
+
export declare function getPortalEnv(authentication: UserSession): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPortalEnv = void 0;
|
|
4
|
+
function getPortalEnv(authentication) {
|
|
5
|
+
const portalUrl = authentication.portal || "https://www.arcgis.com/sharing/rest";
|
|
6
|
+
let result = "portal";
|
|
7
|
+
if (portalUrl.match(/(qaext|\.mapsqa)\.arcgis.com/)) {
|
|
8
|
+
result = "qaext";
|
|
9
|
+
}
|
|
10
|
+
else if (portalUrl.match(/(devext|\.mapsdevext)\.arcgis.com/)) {
|
|
11
|
+
result = "devext";
|
|
12
|
+
}
|
|
13
|
+
else if (portalUrl.match(/(www|\.maps)\.arcgis.com/)) {
|
|
14
|
+
result = "www";
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
exports.getPortalEnv = getPortalEnv;
|
|
19
|
+
//# sourceMappingURL=get-portal-env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-portal-env.js","sourceRoot":"","sources":["../../../src/helpers/get-portal-env.ts"],"names":[],"mappings":";;;AAiBA,SAAgB,YAAY,CAAC,cAA2B;IACtD,MAAM,SAAS,GACb,cAAc,CAAC,MAAM,IAAI,qCAAqC,CAAC;IACjE,IAAI,MAAM,GAAG,QAAQ,CAAC;IACtB,IAAI,SAAS,CAAC,KAAK,CAAC,8BAA8B,CAAC,EAAE;QACnD,MAAM,GAAG,OAAO,CAAC;KAClB;SAAM,IAAI,SAAS,CAAC,KAAK,CAAC,mCAAmC,CAAC,EAAE;QAC/D,MAAM,GAAG,QAAQ,CAAC;KACnB;SAAM,IAAI,SAAS,CAAC,KAAK,CAAC,0BAA0B,CAAC,EAAE;QACtD,MAAM,GAAG,KAAK,CAAC;KAChB;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAZD,oCAYC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
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 { UserSession } from "@esri/solution-common";
|
|
17
|
+
/**
|
|
18
|
+
* For a given environment Prod/qa/dev/portal
|
|
19
|
+
* return the correct storymaps base url
|
|
20
|
+
*
|
|
21
|
+
* @param authentication
|
|
22
|
+
*/
|
|
23
|
+
export declare function getStoryMapBaseUrl(authentication: UserSession): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getStoryMapBaseUrl = void 0;
|
|
4
|
+
const get_storymap_subdomain_1 = require("./get-storymap-subdomain");
|
|
5
|
+
/**
|
|
6
|
+
* For a given environment Prod/qa/dev/portal
|
|
7
|
+
* return the correct storymaps base url
|
|
8
|
+
*
|
|
9
|
+
* @param authentication
|
|
10
|
+
*/
|
|
11
|
+
function getStoryMapBaseUrl(authentication) {
|
|
12
|
+
let baseUrl = "";
|
|
13
|
+
const subdomain = (0, get_storymap_subdomain_1.getStoryMapSubdomain)(authentication);
|
|
14
|
+
if (subdomain) {
|
|
15
|
+
baseUrl = `https://${subdomain}.arcgis.com`;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
// we're on portal
|
|
19
|
+
// chop off the /sharing/rest to get the baseUrl
|
|
20
|
+
const portalBaseUrl = authentication.portal.replace("/sharing/rest", "");
|
|
21
|
+
baseUrl = `${portalBaseUrl}/apps/storymaps`;
|
|
22
|
+
}
|
|
23
|
+
return baseUrl;
|
|
24
|
+
}
|
|
25
|
+
exports.getStoryMapBaseUrl = getStoryMapBaseUrl;
|
|
26
|
+
//# sourceMappingURL=get-storymap-base-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-storymap-base-url.js","sourceRoot":"","sources":["../../../src/helpers/get-storymap-base-url.ts"],"names":[],"mappings":";;;AAgBA,qEAAgE;AAChE;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,cAA2B;IAC5D,IAAI,OAAO,GAAG,EAAE,CAAC;IAEjB,MAAM,SAAS,GAAG,IAAA,6CAAoB,EAAC,cAAc,CAAC,CAAC;IACvD,IAAI,SAAS,EAAE;QACb,OAAO,GAAG,WAAW,SAAS,aAAa,CAAC;KAC7C;SAAM;QACL,kBAAkB;QAClB,gDAAgD;QAChD,MAAM,aAAa,GAAG,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;QACzE,OAAO,GAAG,GAAG,aAAa,iBAAiB,CAAC;KAC7C;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAdD,gDAcC"}
|
|
@@ -0,0 +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
|
+
import { IModel } from "@esri/hub-common";
|
|
17
|
+
/**
|
|
18
|
+
* Extract a list of Items this storymap depends on
|
|
19
|
+
* At this point we are just extracting webmaps
|
|
20
|
+
*
|
|
21
|
+
* @param model IModel
|
|
22
|
+
*/
|
|
23
|
+
export declare function getStoryMapDependencies(model: IModel): any[];
|
|
@@ -0,0 +1,36 @@
|
|
|
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.getStoryMapDependencies = void 0;
|
|
19
|
+
const hub_common_1 = require("@esri/hub-common");
|
|
20
|
+
/**
|
|
21
|
+
* Extract a list of Items this storymap depends on
|
|
22
|
+
* At this point we are just extracting webmaps
|
|
23
|
+
*
|
|
24
|
+
* @param model IModel
|
|
25
|
+
*/
|
|
26
|
+
function getStoryMapDependencies(model) {
|
|
27
|
+
const resources = (0, hub_common_1.getProp)(model, "data.resources") || {};
|
|
28
|
+
return Object.keys(resources).reduce((acc, key) => {
|
|
29
|
+
if ((0, hub_common_1.getProp)(resources, `${key}.type`) === "webmap") {
|
|
30
|
+
acc.push((0, hub_common_1.getProp)(resources, `${key}.data.itemId`));
|
|
31
|
+
}
|
|
32
|
+
return acc;
|
|
33
|
+
}, []);
|
|
34
|
+
}
|
|
35
|
+
exports.getStoryMapDependencies = getStoryMapDependencies;
|
|
36
|
+
//# sourceMappingURL=get-storymap-dependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-storymap-dependencies.js","sourceRoot":"","sources":["../../../src/helpers/get-storymap-dependencies.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,iDAAmD;AAEnD;;;;;GAKG;AACH,SAAgB,uBAAuB,CAAC,KAAa;IACnD,MAAM,SAAS,GAAG,IAAA,oBAAO,EAAC,KAAK,EAAE,gBAAgB,CAAC,IAAI,EAAE,CAAC;IACzD,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAChD,IAAI,IAAA,oBAAO,EAAC,SAAS,EAAE,GAAG,GAAG,OAAO,CAAC,KAAK,QAAQ,EAAE;YAClD,GAAG,CAAC,IAAI,CAAC,IAAA,oBAAO,EAAC,SAAS,EAAE,GAAG,GAAG,cAAc,CAAC,CAAC,CAAC;SACpD;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AARD,0DAQC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
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 { UserSession } from "@esri/solution-common";
|
|
17
|
+
export declare function getStoryMapSubdomain(authentication: UserSession): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getStoryMapSubdomain = void 0;
|
|
4
|
+
function getStoryMapSubdomain(authentication) {
|
|
5
|
+
const portalUrl = authentication.portal || "https://www.arcgis.com/sharing/rest";
|
|
6
|
+
// TODO: Sort out how we locate storymaps on portal?
|
|
7
|
+
let result;
|
|
8
|
+
if (portalUrl.match(/(qaext|\.mapsqa)\.arcgis.com/)) {
|
|
9
|
+
result = "storymapsqa";
|
|
10
|
+
}
|
|
11
|
+
else if (portalUrl.match(/(devext|\.mapsdevext)\.arcgis.com/)) {
|
|
12
|
+
result = "storymapsdev";
|
|
13
|
+
}
|
|
14
|
+
else if (portalUrl.match(/(www|\.maps)\.arcgis.com/)) {
|
|
15
|
+
result = "storymaps";
|
|
16
|
+
}
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
exports.getStoryMapSubdomain = getStoryMapSubdomain;
|
|
20
|
+
//# sourceMappingURL=get-storymap-subdomain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-storymap-subdomain.js","sourceRoot":"","sources":["../../../src/helpers/get-storymap-subdomain.ts"],"names":[],"mappings":";;;AAiBA,SAAgB,oBAAoB,CAAC,cAA2B;IAC9D,MAAM,SAAS,GACb,cAAc,CAAC,MAAM,IAAI,qCAAqC,CAAC;IACjE,oDAAoD;IACpD,IAAI,MAAM,CAAC;IACX,IAAI,SAAS,CAAC,KAAK,CAAC,8BAA8B,CAAC,EAAE;QACnD,MAAM,GAAG,aAAa,CAAC;KACxB;SAAM,IAAI,SAAS,CAAC,KAAK,CAAC,mCAAmC,CAAC,EAAE;QAC/D,MAAM,GAAG,cAAc,CAAC;KACzB;SAAM,IAAI,SAAS,CAAC,KAAK,CAAC,0BAA0B,CAAC,EAAE;QACtD,MAAM,GAAG,WAAW,CAAC;KACtB;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAbD,oDAaC"}
|
|
@@ -0,0 +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
|
+
* For some reason, the webmap resource key names are fancier than other resource keys
|
|
18
|
+
* They look like this: r-<webmap-item-id>-<timestamp>
|
|
19
|
+
* This interpolation is hard to accomplish given our current setup, so we're just overwriting
|
|
20
|
+
* them with "webmap0", "webmap1" and so forth. This _seems_ to make no difference.
|
|
21
|
+
*
|
|
22
|
+
* @param model
|
|
23
|
+
*/
|
|
24
|
+
export declare function remapWebmapKeys(resources?: any): any[];
|
|
@@ -0,0 +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;
|
|
44
|
+
//# sourceMappingURL=remap-webmap-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remap-webmap-keys.js","sourceRoot":"","sources":["../../../src/helpers/remap-webmap-keys.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,iDAA2C;AAE3C;;;;;;;GAOG;AACH,SAAgB,eAAe,CAAC,YAAiB,EAAE;IACjD,IAAI,aAAa,GAAG,CAAC,CAAC;IACtB,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAChD,IAAI,IAAA,oBAAO,EAAC,SAAS,EAAE,GAAG,GAAG,OAAO,CAAC,KAAK,QAAQ,EAAE;YAClD,IAAI,GAAG,KAAK,SAAS,aAAa,EAAE,EAAE;gBACpC,GAAG,CAAC,IAAI,CAAC;oBACP,QAAQ,EAAE,GAAG;oBACb,OAAO,EAAE,SAAS,aAAa,EAAE;iBAClC,CAAC,CAAC;gBACH,aAAa,EAAE,CAAC;aACjB;SACF;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AAdD,0CAcC"}
|
|
@@ -0,0 +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 };
|
|
@@ -0,0 +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;
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH;;;;GAIG;AAEH,gFAA0D;AAGjD,8CAAiB;AAF1B,+FAAyE;AAE7C,4DAAwB"}
|
|
@@ -0,0 +1,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
|
+
/**
|
|
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 itemInfo
|
|
26
|
+
* @param destAuthentication Credentials for requests to the destination organization
|
|
27
|
+
* @param srcAuthentication Credentials for requests to source items
|
|
28
|
+
*/
|
|
29
|
+
export declare function convertItemToTemplate(itemInfo: any, destAuthentication: UserSession, srcAuthentication: UserSession): Promise<IItemTemplate>;
|
|
30
|
+
/**
|
|
31
|
+
* Create a StoryMap from the passed in template
|
|
32
|
+
*
|
|
33
|
+
* @param template
|
|
34
|
+
* @param templateDictionary
|
|
35
|
+
* @param destinationAuthentication
|
|
36
|
+
* @param itemProgressCallback
|
|
37
|
+
*/
|
|
38
|
+
export declare function createItemFromTemplate(template: IItemTemplate, templateDictionary: any, destinationAuthentication: UserSession, itemProgressCallback: IItemProgressCallback): Promise<ICreateItemFromTemplateResponse>;
|
|
39
|
+
export declare function isAStoryMap(itemType: string): boolean;
|
|
@@ -0,0 +1,140 @@
|
|
|
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 itemInfo
|
|
34
|
+
* @param destAuthentication Credentials for requests to the destination organization
|
|
35
|
+
* @param srcAuthentication Credentials for requests to source items
|
|
36
|
+
*/
|
|
37
|
+
function convertItemToTemplate(itemInfo, destAuthentication, srcAuthentication) {
|
|
38
|
+
const model = {
|
|
39
|
+
item: itemInfo,
|
|
40
|
+
data: {}
|
|
41
|
+
};
|
|
42
|
+
// fetch the data.json
|
|
43
|
+
return (0, arcgis_rest_portal_1.getItemData)(itemInfo.id, { authentication: srcAuthentication })
|
|
44
|
+
.then(data => {
|
|
45
|
+
// append into the model
|
|
46
|
+
model.data = data;
|
|
47
|
+
// and use that to create a template
|
|
48
|
+
return (0, convert_storymap_to_template_1.convertStoryMapToTemplate)(model);
|
|
49
|
+
})
|
|
50
|
+
.then(tmpl => {
|
|
51
|
+
return tmpl;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
exports.convertItemToTemplate = convertItemToTemplate;
|
|
55
|
+
/**
|
|
56
|
+
* Create a StoryMap from the passed in template
|
|
57
|
+
*
|
|
58
|
+
* @param template
|
|
59
|
+
* @param templateDictionary
|
|
60
|
+
* @param destinationAuthentication
|
|
61
|
+
* @param itemProgressCallback
|
|
62
|
+
*/
|
|
63
|
+
function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
|
|
64
|
+
// let the progress system know we've started...
|
|
65
|
+
const startStatus = itemProgressCallback(template.itemId, solution_common_1.EItemProgressStatus.Started, 0);
|
|
66
|
+
// and if it returned false, just resolve out
|
|
67
|
+
if (!startStatus) {
|
|
68
|
+
return Promise.resolve((0, solution_common_1.generateEmptyCreationResponse)(template.type));
|
|
69
|
+
}
|
|
70
|
+
// ensure we have a solution object in the templateDictionary hash
|
|
71
|
+
if (!templateDictionary.solution) {
|
|
72
|
+
templateDictionary.solution = {};
|
|
73
|
+
}
|
|
74
|
+
// .title should always be set on the templateDictionary
|
|
75
|
+
templateDictionary.solution.title = templateDictionary.title;
|
|
76
|
+
// TODO: Determine if we need any transforms in this new env
|
|
77
|
+
const transforms = {};
|
|
78
|
+
// create an object to hold the created site through
|
|
79
|
+
// subsequent promise calls
|
|
80
|
+
let model;
|
|
81
|
+
// Create the "siteModel" from the template. Does not save the site item yet
|
|
82
|
+
// Note: depending on licensing and user privs, will also create the team groups
|
|
83
|
+
// and initiative item.
|
|
84
|
+
return (0, create_storymap_model_from_template_1.createStoryMapModelFromTemplate)(template, templateDictionary, transforms, destinationAuthentication)
|
|
85
|
+
.then(interpolated => {
|
|
86
|
+
const options = {
|
|
87
|
+
assets: interpolated.assets || []
|
|
88
|
+
};
|
|
89
|
+
return (0, create_storymap_1.createStoryMap)(interpolated, templateDictionary.folderId, options, destinationAuthentication);
|
|
90
|
+
})
|
|
91
|
+
.then(createdModel => {
|
|
92
|
+
model = createdModel;
|
|
93
|
+
// Update the template dictionary
|
|
94
|
+
// TODO: This should be done in whatever receives
|
|
95
|
+
// the outcome of this promise chain
|
|
96
|
+
templateDictionary[template.itemId] = {
|
|
97
|
+
itemId: model.item.id
|
|
98
|
+
};
|
|
99
|
+
// call the progress callback, which also mutates templateDictionary
|
|
100
|
+
const finalStatus = itemProgressCallback(template.itemId, solution_common_1.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor || 2, model.item.id);
|
|
101
|
+
if (!finalStatus) {
|
|
102
|
+
// clean up the site we just created
|
|
103
|
+
const failSafeRemove = (0, hub_common_1.failSafe)(arcgis_rest_portal_1.removeItem, { success: true });
|
|
104
|
+
return failSafeRemove({
|
|
105
|
+
id: model.item.id,
|
|
106
|
+
authentication: destinationAuthentication
|
|
107
|
+
}).then(() => {
|
|
108
|
+
return Promise.resolve((0, solution_common_1.generateEmptyCreationResponse)(template.type));
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
// finally, return ICreateItemFromTemplateResponse
|
|
113
|
+
const response = {
|
|
114
|
+
item: {
|
|
115
|
+
...template,
|
|
116
|
+
...(0, solution_common_1.convertIModel)(model)
|
|
117
|
+
},
|
|
118
|
+
id: model.item.id,
|
|
119
|
+
type: template.type,
|
|
120
|
+
postProcess: false
|
|
121
|
+
};
|
|
122
|
+
response.item.itemId = model.item.id;
|
|
123
|
+
return response;
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
.catch(ex => {
|
|
127
|
+
itemProgressCallback(template.itemId, solution_common_1.EItemProgressStatus.Failed, 0);
|
|
128
|
+
throw ex;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
exports.createItemFromTemplate = createItemFromTemplate;
|
|
132
|
+
function isAStoryMap(itemType) {
|
|
133
|
+
let result = false;
|
|
134
|
+
if (itemType === "StoryMap") {
|
|
135
|
+
result = true;
|
|
136
|
+
}
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
exports.isAStoryMap = isAStoryMap;
|
|
140
|
+
//# sourceMappingURL=storymap-processor.js.map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B,cAAc,EAAE,yBAAyB;aAC1C,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;gBACX,OAAO,OAAO,CAAC,OAAO,CAAC,IAAA,+CAA6B,EAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;YACvE,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,kDAAkD;YAClD,MAAM,QAAQ,GAAoC;gBAChD,IAAI,EAAE;oBACJ,GAAG,QAAQ;oBACX,GAAG,IAAA,+BAAa,EAAC,KAAK,CAAC;iBACxB;gBACD,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE;gBACjB,IAAI,EAAE,QAAQ,CAAC,IAAI;gBACnB,WAAW,EAAE,KAAK;aACnB,CAAC;YACF,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACrC,OAAO,QAAQ,CAAC;SACjB;IACH,CAAC,CAAC;SACD,KAAK,CAAC,EAAE,CAAC,EAAE;QACV,oBAAoB,CAAC,QAAQ,CAAC,MAAM,EAAE,qCAAmB,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACrE,MAAM,EAAE,CAAC;IACX,CAAC,CAAC,CAAC;AACP,CAAC;AA/FD,wDA+FC;AAED,SAAgB,WAAW,CAAC,QAAgB;IAC1C,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,IAAI,QAAQ,KAAK,UAAU,EAAE;QAC3B,MAAM,GAAG,IAAI,CAAC;KACf;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAND,kCAMC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esri/solution-storymap",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.4",
|
|
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.7.0",
|
|
24
24
|
"@esri/arcgis-rest-request": "^3.7.0",
|
|
25
25
|
"@esri/hub-common": "^14.97.0",
|
|
26
|
-
"@esri/solution-common": "^5.2.
|
|
26
|
+
"@esri/solution-common": "^5.2.4",
|
|
27
27
|
"@types/jasmine": "^5.1.4",
|
|
28
28
|
"fetch-mock": "^7.7.3",
|
|
29
29
|
"jasmine": "^5.1.0",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"esri",
|
|
85
85
|
"ES6"
|
|
86
86
|
],
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "c3329c6814c1d7b898eb130bf3a7feeda12f074f"
|
|
88
88
|
}
|