@esri/solution-storymap 3.0.1 → 4.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -9
- package/dist/node/classic-storymap-processor.d.ts +0 -24
- package/dist/node/classic-storymap-processor.js +0 -69
- package/dist/node/classic-storymap-processor.js.map +0 -1
- package/dist/node/helpers/convert-storymap-to-template.d.ts +0 -24
- package/dist/node/helpers/convert-storymap-to-template.js +0 -99
- package/dist/node/helpers/convert-storymap-to-template.js.map +0 -1
- package/dist/node/helpers/create-storymap-model-from-template.d.ts +0 -22
- package/dist/node/helpers/create-storymap-model-from-template.js +0 -43
- package/dist/node/helpers/create-storymap-model-from-template.js.map +0 -1
- package/dist/node/helpers/create-storymap.d.ts +0 -25
- package/dist/node/helpers/create-storymap.js +0 -112
- package/dist/node/helpers/create-storymap.js.map +0 -1
- package/dist/node/helpers/get-portal-env.d.ts +0 -17
- package/dist/node/helpers/get-portal-env.js +0 -19
- package/dist/node/helpers/get-portal-env.js.map +0 -1
- package/dist/node/helpers/get-storymap-base-url.d.ts +0 -23
- package/dist/node/helpers/get-storymap-base-url.js +0 -26
- package/dist/node/helpers/get-storymap-base-url.js.map +0 -1
- package/dist/node/helpers/get-storymap-dependencies.d.ts +0 -23
- package/dist/node/helpers/get-storymap-dependencies.js +0 -36
- package/dist/node/helpers/get-storymap-dependencies.js.map +0 -1
- package/dist/node/helpers/get-storymap-subdomain.d.ts +0 -17
- package/dist/node/helpers/get-storymap-subdomain.js +0 -20
- package/dist/node/helpers/get-storymap-subdomain.js.map +0 -1
- package/dist/node/helpers/remap-webmap-keys.d.ts +0 -24
- package/dist/node/helpers/remap-webmap-keys.js +0 -44
- package/dist/node/helpers/remap-webmap-keys.js.map +0 -1
- package/dist/node/index.d.ts +0 -23
- package/dist/node/index.js +0 -29
- package/dist/node/index.js.map +0 -1
- package/dist/node/storymap-processor.d.ts +0 -40
- package/dist/node/storymap-processor.js +0 -141
- package/dist/node/storymap-processor.js.map +0 -1
- package/dist/umd/storymap/src/classic-storymap-processor.d.ts +0 -24
- package/dist/umd/storymap/src/helpers/convert-storymap-to-template.d.ts +0 -24
- package/dist/umd/storymap/src/helpers/create-storymap-model-from-template.d.ts +0 -22
- package/dist/umd/storymap/src/helpers/create-storymap.d.ts +0 -25
- package/dist/umd/storymap/src/helpers/get-portal-env.d.ts +0 -17
- package/dist/umd/storymap/src/helpers/get-storymap-base-url.d.ts +0 -23
- package/dist/umd/storymap/src/helpers/get-storymap-dependencies.d.ts +0 -23
- package/dist/umd/storymap/src/helpers/get-storymap-subdomain.d.ts +0 -17
- package/dist/umd/storymap/src/helpers/remap-webmap-keys.d.ts +0 -24
- package/dist/umd/storymap/src/index.d.ts +0 -23
- package/dist/umd/storymap/src/storymap-processor.d.ts +0 -40
- package/dist/umd/storymap.umd.js +0 -593
- package/dist/umd/storymap.umd.js.map +0 -1
- package/dist/umd/storymap.umd.min.js +0 -19
- package/dist/umd/storymap.umd.min.js.map +0 -1
package/dist/umd/storymap.umd.js
DELETED
|
@@ -1,593 +0,0 @@
|
|
|
1
|
-
/* @preserve
|
|
2
|
-
* @esri/solution-storymap - v1.7.0 - Apache-2.0
|
|
3
|
-
* Copyright (c) 2018-2023 Esri, Inc.
|
|
4
|
-
* Fri Apr 28 2023 11:21:59 GMT-0700 (Pacific Daylight Time)
|
|
5
|
-
*
|
|
6
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
* you may not use this file except in compliance with the License.
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
* See the License for the specific language governing permissions and
|
|
16
|
-
* limitations under the License.
|
|
17
|
-
*/
|
|
18
|
-
(function (global, factory) {
|
|
19
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@esri/solution-common'), require('@esri/hub-common'), require('@esri/arcgis-rest-portal')) :
|
|
20
|
-
typeof define === 'function' && define.amd ? define(['exports', '@esri/solution-common', '@esri/hub-common', '@esri/arcgis-rest-portal'], factory) :
|
|
21
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.arcgisSolution = global.arcgisSolution || {}, global.arcgisSolution, global.arcgisHub, global.arcgisRest));
|
|
22
|
-
})(this, (function (exports, common, hubCommon, arcgisRestPortal) { 'use strict';
|
|
23
|
-
|
|
24
|
-
function _interopNamespace(e) {
|
|
25
|
-
if (e && e.__esModule) return e;
|
|
26
|
-
var n = Object.create(null);
|
|
27
|
-
if (e) {
|
|
28
|
-
Object.keys(e).forEach(function (k) {
|
|
29
|
-
if (k !== 'default') {
|
|
30
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
31
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
get: function () { return e[k]; }
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
n["default"] = e;
|
|
39
|
-
return Object.freeze(n);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
var common__namespace = /*#__PURE__*/_interopNamespace(common);
|
|
43
|
-
|
|
44
|
-
/** @license
|
|
45
|
-
* Copyright 2018 Esri
|
|
46
|
-
*
|
|
47
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
48
|
-
* you may not use this file except in compliance with the License.
|
|
49
|
-
* You may obtain a copy of the License at
|
|
50
|
-
*
|
|
51
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
52
|
-
*
|
|
53
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
54
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
55
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
56
|
-
* See the License for the specific language governing permissions and
|
|
57
|
-
* limitations under the License.
|
|
58
|
-
*/
|
|
59
|
-
/**
|
|
60
|
-
* For some reason, the webmap resource key names are fancier than other resource keys
|
|
61
|
-
* They look like this: r-<webmap-item-id>-<timestamp>
|
|
62
|
-
* This interpolation is hard to accomplish given our current setup, so we're just overwriting
|
|
63
|
-
* them with "webmap0", "webmap1" and so forth. This _seems_ to make no difference.
|
|
64
|
-
*
|
|
65
|
-
* @param model
|
|
66
|
-
*/
|
|
67
|
-
function remapWebmapKeys(resources = {}) {
|
|
68
|
-
let webmapCounter = 0;
|
|
69
|
-
return Object.keys(resources).reduce((acc, key) => {
|
|
70
|
-
if (hubCommon.getProp(resources, `${key}.type`) === "webmap") {
|
|
71
|
-
if (key !== `webmap${webmapCounter}`) {
|
|
72
|
-
acc.push({
|
|
73
|
-
original: key,
|
|
74
|
-
updated: `webmap${webmapCounter}`
|
|
75
|
-
});
|
|
76
|
-
webmapCounter++;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return acc;
|
|
80
|
-
}, []);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/** @license
|
|
84
|
-
* Copyright 2018 Esri
|
|
85
|
-
*
|
|
86
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
87
|
-
* you may not use this file except in compliance with the License.
|
|
88
|
-
* You may obtain a copy of the License at
|
|
89
|
-
*
|
|
90
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
91
|
-
*
|
|
92
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
93
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
94
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
95
|
-
* See the License for the specific language governing permissions and
|
|
96
|
-
* limitations under the License.
|
|
97
|
-
*/
|
|
98
|
-
/**
|
|
99
|
-
* Extract a list of Items this storymap depends on
|
|
100
|
-
* At this point we are just extracting webmaps
|
|
101
|
-
*
|
|
102
|
-
* @param model IModel
|
|
103
|
-
*/
|
|
104
|
-
function getStoryMapDependencies(model) {
|
|
105
|
-
const resources = hubCommon.getProp(model, "data.resources") || {};
|
|
106
|
-
return Object.keys(resources).reduce((acc, key) => {
|
|
107
|
-
if (hubCommon.getProp(resources, `${key}.type`) === "webmap") {
|
|
108
|
-
acc.push(hubCommon.getProp(resources, `${key}.data.itemId`));
|
|
109
|
-
}
|
|
110
|
-
return acc;
|
|
111
|
-
}, []);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/** @license
|
|
115
|
-
* Copyright 2018 Esri
|
|
116
|
-
*
|
|
117
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
118
|
-
* you may not use this file except in compliance with the License.
|
|
119
|
-
* You may obtain a copy of the License at
|
|
120
|
-
*
|
|
121
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
122
|
-
*
|
|
123
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
124
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
125
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
126
|
-
* See the License for the specific language governing permissions and
|
|
127
|
-
* limitations under the License.
|
|
128
|
-
*/
|
|
129
|
-
/**
|
|
130
|
-
* Convert a StoryMap IModel to an IItemTemplate
|
|
131
|
-
*
|
|
132
|
-
* @param model
|
|
133
|
-
* @param authentication
|
|
134
|
-
*/
|
|
135
|
-
function convertStoryMapToTemplate(model) {
|
|
136
|
-
const tmpl = common.createPlaceholderTemplate(model.item.id, model.item.type);
|
|
137
|
-
tmpl.key = `${hubCommon.propifyString(model.item.title)}_${hubCommon.createId("i")}`;
|
|
138
|
-
const clone = hubCommon.cloneObject(model);
|
|
139
|
-
tmpl.data = clone.data;
|
|
140
|
-
// We need to save these properties in order to restore them after hub.js deletes them
|
|
141
|
-
const created = clone.item.created;
|
|
142
|
-
const modified = clone.item.modified;
|
|
143
|
-
tmpl.item = hubCommon.normalizeSolutionTemplateItem(clone.item);
|
|
144
|
-
tmpl.item.created = created;
|
|
145
|
-
tmpl.item.modified = modified;
|
|
146
|
-
// templatize the url
|
|
147
|
-
tmpl.item.url = "{{storyMapTemplateUrl}}";
|
|
148
|
-
// Storymap Webmap Resources have complex keys that we need to remap
|
|
149
|
-
const webmapRemaps = remapWebmapKeys(tmpl.data.resources);
|
|
150
|
-
// and then replace in the rest of the structure
|
|
151
|
-
webmapRemaps.forEach(remap => {
|
|
152
|
-
tmpl.data.resources[remap.updated] = hubCommon.cloneObject(tmpl.data.resources[remap.original]);
|
|
153
|
-
delete tmpl.data.resources[remap.original];
|
|
154
|
-
tmpl.data.nodes = hubCommon.deepStringReplace(tmpl.data.nodes, remap.original, remap.updated);
|
|
155
|
-
});
|
|
156
|
-
// use typeKeyword to mark item as published
|
|
157
|
-
// Note: Hub team decided to discard unpublished drafts when creating a template
|
|
158
|
-
const typeKeywords = tmpl.item.typeKeywords;
|
|
159
|
-
if (typeKeywords.indexOf(unPublishedChangesKW) !== -1) {
|
|
160
|
-
tmpl.item.typeKeywords = [publishedChangesKW].concat(tmpl.item.typeKeywords.filter((word) => word !== unPublishedChangesKW));
|
|
161
|
-
}
|
|
162
|
-
tmpl.properties = {};
|
|
163
|
-
tmpl.properties.draftFileName = "draft_{{timestamp}}.json";
|
|
164
|
-
Object.assign(tmpl.properties, oEmbedTemplates);
|
|
165
|
-
tmpl.dependencies = getStoryMapDependencies(model);
|
|
166
|
-
return Promise.resolve(tmpl);
|
|
167
|
-
// TODO: For now, we let the generic process handle item resources
|
|
168
|
-
// However, many newer item types have complex type-specific resource handling
|
|
169
|
-
// requirements so this code may be useful in the future
|
|
170
|
-
// ------------------------------------------------------
|
|
171
|
-
// return getItemResources(tmpl.itemId, hubRequestOptions)
|
|
172
|
-
// .then((response) => {
|
|
173
|
-
// tmpl.resources = response.resources.map(e => e.resource)
|
|
174
|
-
// // Don't directly copy oembed resources because we need to template these
|
|
175
|
-
// // Also, discard draft version of the storymap itself
|
|
176
|
-
// .filter(filename => !filename.includes('oembed') && filename.search(/draft_[0-9]+.json/) === -1);
|
|
177
|
-
// return tmpl;
|
|
178
|
-
// });
|
|
179
|
-
}
|
|
180
|
-
// Internal constants
|
|
181
|
-
const unPublishedChangesKW = "smstatusunpublishedchanges";
|
|
182
|
-
const publishedChangesKW = "smstatuspublished";
|
|
183
|
-
/**
|
|
184
|
-
* Template for oEmbed
|
|
185
|
-
*/
|
|
186
|
-
const oEmbedTemplates = {
|
|
187
|
-
oembed: {
|
|
188
|
-
version: "1.0",
|
|
189
|
-
type: "rich",
|
|
190
|
-
title: "Example StoryMap",
|
|
191
|
-
url: "{{storyMapTemplateUrl}}",
|
|
192
|
-
provider_name: "ArcGIS StoryMaps",
|
|
193
|
-
provider_url: "{{storyMapBaseUrl}}",
|
|
194
|
-
width: 800,
|
|
195
|
-
height: 600,
|
|
196
|
-
thumbnail_url: "{{storyMapThumbnailUrl}}",
|
|
197
|
-
thumbnail_height: "100.5",
|
|
198
|
-
thumbnail_width: "400",
|
|
199
|
-
html: '<iframe src="{{storyMapTemplateUrl}}" width="800" height="600" scrolling="yes" frameborder="0" allowfullscreen></iframe>',
|
|
200
|
-
cache_age: 86400
|
|
201
|
-
},
|
|
202
|
-
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>'
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
function getPortalEnv(authentication) {
|
|
206
|
-
const portalUrl = authentication.portal || "https://www.arcgis.com/sharing/rest";
|
|
207
|
-
let result = "portal";
|
|
208
|
-
if (portalUrl.match(/(qaext|\.mapsqa)\.arcgis.com/)) {
|
|
209
|
-
result = "qaext";
|
|
210
|
-
}
|
|
211
|
-
else if (portalUrl.match(/(devext|\.mapsdevext)\.arcgis.com/)) {
|
|
212
|
-
result = "devext";
|
|
213
|
-
}
|
|
214
|
-
else if (portalUrl.match(/(www|\.maps)\.arcgis.com/)) {
|
|
215
|
-
result = "www";
|
|
216
|
-
}
|
|
217
|
-
return result;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function getStoryMapSubdomain(authentication) {
|
|
221
|
-
const portalUrl = authentication.portal || "https://www.arcgis.com/sharing/rest";
|
|
222
|
-
// TODO: Sort out how we locate storymaps on portal?
|
|
223
|
-
let result;
|
|
224
|
-
if (portalUrl.match(/(qaext|\.mapsqa)\.arcgis.com/)) {
|
|
225
|
-
result = "storymapsqa";
|
|
226
|
-
}
|
|
227
|
-
else if (portalUrl.match(/(devext|\.mapsdevext)\.arcgis.com/)) {
|
|
228
|
-
result = "storymapsdev";
|
|
229
|
-
}
|
|
230
|
-
else if (portalUrl.match(/(www|\.maps)\.arcgis.com/)) {
|
|
231
|
-
result = "storymaps";
|
|
232
|
-
}
|
|
233
|
-
return result;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* For a given environment Prod/qa/dev/portal
|
|
238
|
-
* return the correct storymaps base url
|
|
239
|
-
*
|
|
240
|
-
* @param authentication
|
|
241
|
-
*/
|
|
242
|
-
function getStoryMapBaseUrl(authentication) {
|
|
243
|
-
let baseUrl = "";
|
|
244
|
-
const subdomain = getStoryMapSubdomain(authentication);
|
|
245
|
-
if (subdomain) {
|
|
246
|
-
baseUrl = `https://${subdomain}.arcgis.com`;
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
// we're on portal
|
|
250
|
-
// chop off the /sharing/rest to get the baseUrl
|
|
251
|
-
const portalBaseUrl = authentication.portal.replace("/sharing/rest", "");
|
|
252
|
-
baseUrl = `${portalBaseUrl}/apps/storymaps`;
|
|
253
|
-
}
|
|
254
|
-
return baseUrl;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
/** @license
|
|
258
|
-
* Copyright 2020 Esri
|
|
259
|
-
*
|
|
260
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
261
|
-
* you may not use this file except in compliance with the License.
|
|
262
|
-
* You may obtain a copy of the License at
|
|
263
|
-
*
|
|
264
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
265
|
-
*
|
|
266
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
267
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
268
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
269
|
-
* See the License for the specific language governing permissions and
|
|
270
|
-
* limitations under the License.
|
|
271
|
-
*/
|
|
272
|
-
function createStoryMapModelFromTemplate(templateModel, settings, transforms, authentication) {
|
|
273
|
-
const timestamp = new Date().getTime();
|
|
274
|
-
// Keep these around in case we encounter some old templates
|
|
275
|
-
settings.agoenv = getPortalEnv(authentication);
|
|
276
|
-
settings.smBase = getStoryMapSubdomain(authentication);
|
|
277
|
-
settings.timestamp = new Date().getTime();
|
|
278
|
-
// These are used in the oembed resource, as well as the item url
|
|
279
|
-
// they have `{{appid}}` in them so that the id of the created item
|
|
280
|
-
// will be interpolated into it after the item is created
|
|
281
|
-
settings.storyMapBaseUrl = getStoryMapBaseUrl(authentication);
|
|
282
|
-
settings.storyMapTemplateUrl = `${settings.storyMapBaseUrl}/stories/{{appid}}`;
|
|
283
|
-
settings.storyMapThumnailUrl = `${authentication.portal}/content/items/{{appid}}/info/thumbnail/thumbnail.jpg/?w=400&d=${timestamp}`;
|
|
284
|
-
const model = hubCommon.interpolate(templateModel, settings, transforms);
|
|
285
|
-
return Promise.resolve(model);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/** @license
|
|
289
|
-
* Copyright 2020 Esri
|
|
290
|
-
*
|
|
291
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
292
|
-
* you may not use this file except in compliance with the License.
|
|
293
|
-
* You may obtain a copy of the License at
|
|
294
|
-
*
|
|
295
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
296
|
-
*
|
|
297
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
298
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
299
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
300
|
-
* See the License for the specific language governing permissions and
|
|
301
|
-
* limitations under the License.
|
|
302
|
-
*/
|
|
303
|
-
/**
|
|
304
|
-
* Create a StoryMap from an interpolated template
|
|
305
|
-
*
|
|
306
|
-
* @param model
|
|
307
|
-
* @param options
|
|
308
|
-
* @param authentication
|
|
309
|
-
*/
|
|
310
|
-
function createStoryMap(model, folderId, options, authentication) {
|
|
311
|
-
// create an array to hold well-known resources
|
|
312
|
-
// that we have to generate from the passed in model
|
|
313
|
-
const resources = [];
|
|
314
|
-
// For unknown reasons we can not seem to spy on createItemInFolder
|
|
315
|
-
// so we will create-then-move for now
|
|
316
|
-
const createOptions = {
|
|
317
|
-
// need to serialize
|
|
318
|
-
item: hubCommon.serializeModel(model),
|
|
319
|
-
authentication
|
|
320
|
-
};
|
|
321
|
-
/* istanbul ignore else */
|
|
322
|
-
if (model.item.thumbnail) {
|
|
323
|
-
createOptions.params = {
|
|
324
|
-
// Pass thumbnail file in via params because item property is serialized, which discards a blob
|
|
325
|
-
thumbnail: model.item.thumbnail
|
|
326
|
-
};
|
|
327
|
-
delete createOptions.item.thumbnail;
|
|
328
|
-
}
|
|
329
|
-
// Create the item
|
|
330
|
-
return arcgisRestPortal.createItem(createOptions)
|
|
331
|
-
.then((createResponse) => {
|
|
332
|
-
// hold the id in the model
|
|
333
|
-
model.item.id = createResponse.id;
|
|
334
|
-
// and re-interpolate the item id
|
|
335
|
-
model = hubCommon.interpolateItemId(model);
|
|
336
|
-
// Compute the item url based on current environment
|
|
337
|
-
// Storymaps store draft data in a timestamped resource attached to the item
|
|
338
|
-
// We'll just use the published data for the first "draft"
|
|
339
|
-
resources.push({
|
|
340
|
-
name: model.properties.draftFileName,
|
|
341
|
-
file: hubCommon.stringToBlob(JSON.stringify(model.data))
|
|
342
|
-
});
|
|
343
|
-
resources.push({
|
|
344
|
-
name: "oembed.json",
|
|
345
|
-
file: hubCommon.stringToBlob(JSON.stringify(model.properties.oembed))
|
|
346
|
-
});
|
|
347
|
-
resources.push({
|
|
348
|
-
name: "oembed.xml",
|
|
349
|
-
file: hubCommon.stringToBlob(model.properties.oembedXML)
|
|
350
|
-
});
|
|
351
|
-
// remove the properties hash now that we've gotten what we need
|
|
352
|
-
delete model.properties;
|
|
353
|
-
// update the item with the newly re-interpolated model
|
|
354
|
-
return Promise.all([
|
|
355
|
-
arcgisRestPortal.updateItem({
|
|
356
|
-
item: hubCommon.serializeModel(model),
|
|
357
|
-
authentication
|
|
358
|
-
}),
|
|
359
|
-
authentication.getUsername()
|
|
360
|
-
]);
|
|
361
|
-
})
|
|
362
|
-
.then((responses) => {
|
|
363
|
-
const username = responses[1];
|
|
364
|
-
// add the resources
|
|
365
|
-
const failSafeAddItemResource = hubCommon.failSafe(arcgisRestPortal.addItemResource, {
|
|
366
|
-
success: true
|
|
367
|
-
});
|
|
368
|
-
const resourcePromises = resources.map(resource => {
|
|
369
|
-
return failSafeAddItemResource({
|
|
370
|
-
id: model.item.id,
|
|
371
|
-
owner: username,
|
|
372
|
-
resource: resource.file,
|
|
373
|
-
name: resource.name,
|
|
374
|
-
authentication
|
|
375
|
-
});
|
|
376
|
-
});
|
|
377
|
-
// Fire and forget as these are not critical-path
|
|
378
|
-
return Promise.all(resourcePromises);
|
|
379
|
-
})
|
|
380
|
-
.then(() => {
|
|
381
|
-
// Move it
|
|
382
|
-
return arcgisRestPortal.moveItem({
|
|
383
|
-
itemId: model.item.id,
|
|
384
|
-
folderId,
|
|
385
|
-
authentication
|
|
386
|
-
});
|
|
387
|
-
})
|
|
388
|
-
.then(() => {
|
|
389
|
-
return model;
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
/** @license
|
|
394
|
-
* Copyright 2018 Esri
|
|
395
|
-
*
|
|
396
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
397
|
-
* you may not use this file except in compliance with the License.
|
|
398
|
-
* You may obtain a copy of the License at
|
|
399
|
-
*
|
|
400
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
401
|
-
*
|
|
402
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
403
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
404
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
405
|
-
* See the License for the specific language governing permissions and
|
|
406
|
-
* limitations under the License.
|
|
407
|
-
*/
|
|
408
|
-
/**
|
|
409
|
-
* Convert a StoryMap to a template
|
|
410
|
-
*
|
|
411
|
-
* @param solutionItemId
|
|
412
|
-
* @param itemInfo
|
|
413
|
-
* @param destAuthentication Credentials for requests to the destination organization
|
|
414
|
-
* @param srcAuthentication Credentials for requests to source items
|
|
415
|
-
*/
|
|
416
|
-
function convertItemToTemplate$1(solutionItemId, itemInfo, destAuthentication, srcAuthentication) {
|
|
417
|
-
const model = {
|
|
418
|
-
item: itemInfo,
|
|
419
|
-
data: {}
|
|
420
|
-
};
|
|
421
|
-
// fetch the data.json
|
|
422
|
-
return arcgisRestPortal.getItemData(itemInfo.id, { authentication: srcAuthentication })
|
|
423
|
-
.then(data => {
|
|
424
|
-
// append into the model
|
|
425
|
-
model.data = data;
|
|
426
|
-
// and use that to create a template
|
|
427
|
-
return convertStoryMapToTemplate(model);
|
|
428
|
-
})
|
|
429
|
-
.then(tmpl => {
|
|
430
|
-
return tmpl;
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* Create a StoryMap from the passed in template
|
|
435
|
-
*
|
|
436
|
-
* @param template
|
|
437
|
-
* @param templateDictionary
|
|
438
|
-
* @param destinationAuthentication
|
|
439
|
-
* @param itemProgressCallback
|
|
440
|
-
*/
|
|
441
|
-
function createItemFromTemplate$1(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
|
|
442
|
-
// let the progress system know we've started...
|
|
443
|
-
const startStatus = itemProgressCallback(template.itemId, common.EItemProgressStatus.Started, 0);
|
|
444
|
-
// and if it returned false, just resolve out
|
|
445
|
-
if (!startStatus) {
|
|
446
|
-
return Promise.resolve(common.generateEmptyCreationResponse(template.type));
|
|
447
|
-
}
|
|
448
|
-
// ensure we have a solution object in the templateDictionary hash
|
|
449
|
-
if (!templateDictionary.solution) {
|
|
450
|
-
templateDictionary.solution = {};
|
|
451
|
-
}
|
|
452
|
-
// .title should always be set on the templateDictionary
|
|
453
|
-
templateDictionary.solution.title = templateDictionary.title;
|
|
454
|
-
// TODO: Determine if we need any transforms in this new env
|
|
455
|
-
const transforms = {};
|
|
456
|
-
// create an object to hold the created site through
|
|
457
|
-
// subsequent promise calls
|
|
458
|
-
let model;
|
|
459
|
-
// Create the "siteModel" from the template. Does not save the site item yet
|
|
460
|
-
// Note: depending on licensing and user privs, will also create the team groups
|
|
461
|
-
// and initiative item.
|
|
462
|
-
return createStoryMapModelFromTemplate(template, templateDictionary, transforms, destinationAuthentication)
|
|
463
|
-
.then(interpolated => {
|
|
464
|
-
const options = {
|
|
465
|
-
assets: interpolated.assets || []
|
|
466
|
-
};
|
|
467
|
-
return createStoryMap(interpolated, templateDictionary.folderId, options, destinationAuthentication);
|
|
468
|
-
})
|
|
469
|
-
.then(createdModel => {
|
|
470
|
-
model = createdModel;
|
|
471
|
-
// Update the template dictionary
|
|
472
|
-
// TODO: This should be done in whatever receives
|
|
473
|
-
// the outcome of this promise chain
|
|
474
|
-
templateDictionary[template.itemId] = {
|
|
475
|
-
itemId: model.item.id
|
|
476
|
-
};
|
|
477
|
-
// call the progress callback, which also mutates templateDictionary
|
|
478
|
-
const finalStatus = itemProgressCallback(template.itemId, common.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor || 2, model.item.id);
|
|
479
|
-
if (!finalStatus) {
|
|
480
|
-
// clean up the site we just created
|
|
481
|
-
const failSafeRemove = hubCommon.failSafe(arcgisRestPortal.removeItem, { success: true });
|
|
482
|
-
return failSafeRemove({
|
|
483
|
-
id: model.item.id,
|
|
484
|
-
authentication: destinationAuthentication
|
|
485
|
-
}).then(() => {
|
|
486
|
-
return Promise.resolve(common.generateEmptyCreationResponse(template.type));
|
|
487
|
-
});
|
|
488
|
-
}
|
|
489
|
-
else {
|
|
490
|
-
// finally, return ICreateItemFromTemplateResponse
|
|
491
|
-
const response = {
|
|
492
|
-
item: {
|
|
493
|
-
...template,
|
|
494
|
-
...model
|
|
495
|
-
},
|
|
496
|
-
id: model.item.id,
|
|
497
|
-
type: template.type,
|
|
498
|
-
postProcess: false
|
|
499
|
-
};
|
|
500
|
-
response.item.itemId = model.item.id;
|
|
501
|
-
return response;
|
|
502
|
-
}
|
|
503
|
-
})
|
|
504
|
-
.catch(ex => {
|
|
505
|
-
itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
|
|
506
|
-
throw ex;
|
|
507
|
-
});
|
|
508
|
-
}
|
|
509
|
-
function isAStoryMap$1(itemType) {
|
|
510
|
-
let result = false;
|
|
511
|
-
if (itemType === "StoryMap") {
|
|
512
|
-
result = true;
|
|
513
|
-
}
|
|
514
|
-
return result;
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
var storymapProcessor = /*#__PURE__*/Object.freeze({
|
|
518
|
-
__proto__: null,
|
|
519
|
-
convertItemToTemplate: convertItemToTemplate$1,
|
|
520
|
-
createItemFromTemplate: createItemFromTemplate$1,
|
|
521
|
-
isAStoryMap: isAStoryMap$1
|
|
522
|
-
});
|
|
523
|
-
|
|
524
|
-
/** @license
|
|
525
|
-
* Copyright 2018 Esri
|
|
526
|
-
*
|
|
527
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
528
|
-
* you may not use this file except in compliance with the License.
|
|
529
|
-
* You may obtain a copy of the License at
|
|
530
|
-
*
|
|
531
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
532
|
-
*
|
|
533
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
534
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
535
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
536
|
-
* See the License for the specific language governing permissions and
|
|
537
|
-
* limitations under the License.
|
|
538
|
-
*/
|
|
539
|
-
// ------------------------------------------------------------------------------------------------------------------ //
|
|
540
|
-
function convertItemToTemplate(solutionItemId, itemInfo) {
|
|
541
|
-
return new Promise((resolve, reject) => {
|
|
542
|
-
if (isAStoryMap(itemInfo.type, itemInfo.url)) {
|
|
543
|
-
reject(common__namespace.fail("Classic StoryMap is not yet implemented"));
|
|
544
|
-
}
|
|
545
|
-
else {
|
|
546
|
-
reject(common__namespace.fail(itemInfo.id + " is not a StoryMap"));
|
|
547
|
-
}
|
|
548
|
-
});
|
|
549
|
-
}
|
|
550
|
-
function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
|
|
551
|
-
return new Promise(resolve => {
|
|
552
|
-
if (isAStoryMap(template.type, template.item.url)) {
|
|
553
|
-
// Not yet implemented
|
|
554
|
-
itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Failed, 0);
|
|
555
|
-
resolve(common__namespace.generateEmptyCreationResponse(template.type));
|
|
556
|
-
}
|
|
557
|
-
else {
|
|
558
|
-
// Not valid
|
|
559
|
-
itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Failed, 0);
|
|
560
|
-
resolve(common__namespace.generateEmptyCreationResponse(template.type));
|
|
561
|
-
}
|
|
562
|
-
});
|
|
563
|
-
}
|
|
564
|
-
function isAStoryMap(itemType, itemUrl) {
|
|
565
|
-
if (itemUrl) {
|
|
566
|
-
return [
|
|
567
|
-
/\/apps\/Cascade\//i,
|
|
568
|
-
/\/apps\/MapJournal\//i,
|
|
569
|
-
/\/apps\/MapSeries\//i,
|
|
570
|
-
/\/apps\/MapTour\//i,
|
|
571
|
-
/\/apps\/Shortlist\//i,
|
|
572
|
-
/\/apps\/StoryMap\//i,
|
|
573
|
-
/\/apps\/StoryMapBasic\//i,
|
|
574
|
-
/\/apps\/StorytellingSwipe\//i
|
|
575
|
-
].some(pattern => pattern.test(itemUrl));
|
|
576
|
-
}
|
|
577
|
-
return false;
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
var classicStorymapProcessor = /*#__PURE__*/Object.freeze({
|
|
581
|
-
__proto__: null,
|
|
582
|
-
convertItemToTemplate: convertItemToTemplate,
|
|
583
|
-
createItemFromTemplate: createItemFromTemplate,
|
|
584
|
-
isAStoryMap: isAStoryMap
|
|
585
|
-
});
|
|
586
|
-
|
|
587
|
-
exports.ClassicStoryMapProcessor = classicStorymapProcessor;
|
|
588
|
-
exports.StoryMapProcessor = storymapProcessor;
|
|
589
|
-
|
|
590
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
591
|
-
|
|
592
|
-
}));
|
|
593
|
-
//# sourceMappingURL=storymap.umd.js.map
|