@esri/solution-web-experience 0.24.0 → 1.1.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/esm/helpers/convert-web-experience-to-template.js +7 -7
- package/dist/esm/helpers/convert-web-experience-to-template.js.map +1 -1
- package/dist/esm/helpers/create-web-experience-model-from-template.js +1 -1
- package/dist/esm/helpers/create-web-experience-model-from-template.js.map +1 -1
- package/dist/esm/helpers/create-web-experience.js +24 -26
- package/dist/esm/helpers/create-web-experience.js.map +1 -1
- package/dist/esm/helpers/get-experience-subdomain.js +2 -2
- package/dist/esm/helpers/get-experience-subdomain.js.map +1 -1
- package/dist/esm/helpers/get-web-experience-dependencies.js +3 -3
- package/dist/esm/helpers/get-web-experience-dependencies.js.map +1 -1
- package/dist/esm/helpers/get-web-experience-url-template.js +5 -5
- package/dist/esm/helpers/get-web-experience-url-template.js.map +1 -1
- package/dist/esm/web-experience-processor.d.ts +12 -1
- package/dist/esm/web-experience-processor.js +28 -13
- package/dist/esm/web-experience-processor.js.map +1 -1
- package/dist/node/helpers/convert-web-experience-to-template.js +12 -12
- package/dist/node/helpers/convert-web-experience-to-template.js.map +1 -1
- package/dist/node/helpers/create-web-experience-model-from-template.js +4 -4
- package/dist/node/helpers/create-web-experience-model-from-template.js.map +1 -1
- package/dist/node/helpers/create-web-experience.js +34 -36
- package/dist/node/helpers/create-web-experience.js.map +1 -1
- package/dist/node/helpers/get-experience-subdomain.js +2 -2
- package/dist/node/helpers/get-experience-subdomain.js.map +1 -1
- package/dist/node/helpers/get-web-experience-dependencies.js +4 -4
- package/dist/node/helpers/get-web-experience-dependencies.js.map +1 -1
- package/dist/node/helpers/get-web-experience-url-template.js +6 -6
- package/dist/node/helpers/get-web-experience-url-template.js.map +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/index.js.map +1 -1
- package/dist/node/web-experience-processor.d.ts +12 -1
- package/dist/node/web-experience-processor.js +40 -24
- package/dist/node/web-experience-processor.js.map +1 -1
- package/dist/umd/web-experience-processor.d.ts +12 -1
- package/dist/umd/web-experience.umd.js +391 -402
- package/dist/umd/web-experience.umd.js.map +1 -1
- package/dist/umd/web-experience.umd.min.js +3 -3
- package/dist/umd/web-experience.umd.min.js.map +1 -1
- package/package.json +19 -19
|
@@ -26,18 +26,18 @@ import { getWebExperienceDependencies } from "./get-web-experience-dependencies"
|
|
|
26
26
|
* @param authentication
|
|
27
27
|
*/
|
|
28
28
|
export function convertWebExperienceToTemplate(model) {
|
|
29
|
-
|
|
30
|
-
tmpl.key = propifyString(model.item.title)
|
|
31
|
-
|
|
29
|
+
const tmpl = createPlaceholderTemplate(model.item.id, model.item.type);
|
|
30
|
+
tmpl.key = `${propifyString(model.item.title)}_${createId("i")}`;
|
|
31
|
+
const clone = cloneObject(model);
|
|
32
32
|
tmpl.data = clone.data;
|
|
33
33
|
tmpl.item = normalizeSolutionTemplateItem(clone.item);
|
|
34
34
|
// templatize the url. This is updated during the createModelFromTemplate phase
|
|
35
35
|
// of the deployment process
|
|
36
36
|
tmpl.item.url = "{{experienceUrlTemplate}}";
|
|
37
37
|
// use typeKeyword to mark item as published (we decided to discard unpublished drafts)
|
|
38
|
-
|
|
38
|
+
const typeKeywords = tmpl.item.typeKeywords;
|
|
39
39
|
if (typeKeywords.indexOf(changedTypeKW) !== -1) {
|
|
40
|
-
tmpl.item.typeKeywords = [publishedTypeKW].concat(tmpl.item.typeKeywords.filter(
|
|
40
|
+
tmpl.item.typeKeywords = [publishedTypeKW].concat(tmpl.item.typeKeywords.filter(word => word !== changedTypeKW));
|
|
41
41
|
}
|
|
42
42
|
tmpl.dependencies = getWebExperienceDependencies(model);
|
|
43
43
|
return Promise.resolve(tmpl);
|
|
@@ -53,6 +53,6 @@ export function convertWebExperienceToTemplate(model) {
|
|
|
53
53
|
// return tmpl;
|
|
54
54
|
// });
|
|
55
55
|
}
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
const publishedTypeKW = "status: Published";
|
|
57
|
+
const changedTypeKW = "status: Changed";
|
|
58
58
|
//# sourceMappingURL=convert-web-experience-to-template.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-web-experience-to-template.js","sourceRoot":"","sources":["../../../src/helpers/convert-web-experience-to-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAEL,6BAA6B,EAC7B,WAAW,EACX,aAAa,EACb,QAAQ,EACT,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAEL,yBAAyB,EAC1B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAEjF;;;;;;;;GAQG;AACH,MAAM,UAAU,8BAA8B,CAC5C,KAAa;IAEb,
|
|
1
|
+
{"version":3,"file":"convert-web-experience-to-template.js","sourceRoot":"","sources":["../../../src/helpers/convert-web-experience-to-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAEL,6BAA6B,EAC7B,WAAW,EACX,aAAa,EACb,QAAQ,EACT,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAEL,yBAAyB,EAC1B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAEjF;;;;;;;;GAQG;AACH,MAAM,UAAU,8BAA8B,CAC5C,KAAa;IAEb,MAAM,IAAI,GAAG,yBAAyB,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvE,IAAI,CAAC,GAAG,GAAG,GAAG,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;IAEjE,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IACjC,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IACvB,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC,KAAK,CAAC,IAAI,CAAU,CAAC;IAC/D,+EAA+E;IAC/E,4BAA4B;IAC5B,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,2BAA2B,CAAC;IAE5C,uFAAuF;IACvF,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;IAC5C,IAAI,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE;QAC9C,IAAI,CAAC,IAAI,CAAC,YAAY,GAAG,CAAC,eAAe,CAAC,CAAC,MAAM,CAC/C,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,aAAa,CAAC,CAC9D,CAAC;KACH;IAED,IAAI,CAAC,YAAY,GAAG,4BAA4B,CAAC,KAAK,CAAC,CAAC;IAExD,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,kEAAkE;IAClE,8EAA8E;IAC9E,wDAAwD;IACxD,yDAAyD;IACzD,uDAAuD;IACvD,0BAA0B;IAC1B,+DAA+D;IAC/D,iCAAiC;IACjC,yDAAyD;IACzD,mBAAmB;IACnB,QAAQ;AACV,CAAC;AAED,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAC5C,MAAM,aAAa,GAAG,iBAAiB,CAAC"}
|
|
@@ -26,7 +26,7 @@ import { getWebExperiencepUrlTemplate } from "./get-web-experience-url-template"
|
|
|
26
26
|
export function createWebExperienceModelFromTemplate(templateModel, settings, transforms, authentication) {
|
|
27
27
|
// get the experience base url
|
|
28
28
|
settings.experienceUrlTemplate = getWebExperiencepUrlTemplate(authentication);
|
|
29
|
-
|
|
29
|
+
const model = interpolate(templateModel, settings, transforms);
|
|
30
30
|
// ensure this is set - there may be some templates w/o `{{experienceTemplateUrl}}
|
|
31
31
|
model.item.url = settings.experienceUrlTemplate;
|
|
32
32
|
/* istanbul ignore else */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-web-experience-model-from-template.js","sourceRoot":"","sources":["../../../src/helpers/create-web-experience-model-from-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,WAAW,EAAkB,MAAM,kBAAkB,CAAC;AAE/D,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACjF;;;;;;;GAOG;AACH,MAAM,UAAU,oCAAoC,CAClD,aAA6B,EAC7B,QAAa,EACb,UAAe,EACf,cAA2B;IAE3B,8BAA8B;IAC9B,QAAQ,CAAC,qBAAqB,GAAG,4BAA4B,CAAC,cAAc,CAAC,CAAC;IAC9E,
|
|
1
|
+
{"version":3,"file":"create-web-experience-model-from-template.js","sourceRoot":"","sources":["../../../src/helpers/create-web-experience-model-from-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,WAAW,EAAkB,MAAM,kBAAkB,CAAC;AAE/D,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AACjF;;;;;;;GAOG;AACH,MAAM,UAAU,oCAAoC,CAClD,aAA6B,EAC7B,QAAa,EACb,UAAe,EACf,cAA2B;IAE3B,8BAA8B;IAC9B,QAAQ,CAAC,qBAAqB,GAAG,4BAA4B,CAAC,cAAc,CAAC,CAAC;IAC9E,MAAM,KAAK,GAAG,WAAW,CAAC,aAAa,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC/D,kFAAkF;IAClF,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,qBAAqB,CAAC;IAChD,0BAA0B;IAC1B,IAAI,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE;QAChC,KAAK,CAAC,IAAI,CAAC,SAAS,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,yCAAyC;KAC/F;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -23,13 +23,13 @@ import { createItem, updateItem, addItemResource, moveItem } from "@esri/arcgis-
|
|
|
23
23
|
* @param authentication
|
|
24
24
|
*/
|
|
25
25
|
export function createWebExperience(model, folderId, options, authentication) {
|
|
26
|
-
|
|
26
|
+
const resources = [];
|
|
27
27
|
// For unkown reasons we can not seem to spy on createItemInFolder
|
|
28
28
|
// so we will create-then-move for now
|
|
29
|
-
|
|
29
|
+
const createOptions = {
|
|
30
30
|
// need to serialize
|
|
31
31
|
item: serializeModel(model),
|
|
32
|
-
authentication
|
|
32
|
+
authentication
|
|
33
33
|
};
|
|
34
34
|
/* istanbul ignore else */
|
|
35
35
|
if (model.item.thumbnail) {
|
|
@@ -41,21 +41,21 @@ export function createWebExperience(model, folderId, options, authentication) {
|
|
|
41
41
|
}
|
|
42
42
|
// Create the item
|
|
43
43
|
return (createItem(createOptions)
|
|
44
|
-
.then(
|
|
44
|
+
.then((createResponse) => {
|
|
45
45
|
model.item.id = createResponse.id;
|
|
46
|
-
|
|
46
|
+
const savedThumbnail = model.item.thumbnail;
|
|
47
47
|
model = interpolateItemId(model);
|
|
48
48
|
model.item.thumbnail = savedThumbnail; // interpolation trashes thumbnail binary
|
|
49
49
|
// Experiences store draft data in a resource attached to the item
|
|
50
50
|
// We'll just use the published data for the first "draft"
|
|
51
|
-
|
|
51
|
+
const draftResourceModel = cloneObject(model.data);
|
|
52
52
|
resources.push({
|
|
53
53
|
name: "config.json",
|
|
54
54
|
prefix: "config",
|
|
55
55
|
file: stringToBlob(JSON.stringify(draftResourceModel))
|
|
56
56
|
});
|
|
57
57
|
// there may also be this image resources list
|
|
58
|
-
|
|
58
|
+
const imageListModel = cloneObject(model.properties.imageResourcesList);
|
|
59
59
|
if (imageListModel) {
|
|
60
60
|
resources.push({
|
|
61
61
|
name: "image-resources-list.json",
|
|
@@ -65,9 +65,9 @@ export function createWebExperience(model, folderId, options, authentication) {
|
|
|
65
65
|
}
|
|
66
66
|
delete model.properties;
|
|
67
67
|
// update the experience with the newly interpolated model
|
|
68
|
-
|
|
68
|
+
const updateOptions = {
|
|
69
69
|
item: serializeModel(model),
|
|
70
|
-
authentication
|
|
70
|
+
authentication
|
|
71
71
|
};
|
|
72
72
|
if (model.item.thumbnail) {
|
|
73
73
|
updateOptions.params = {
|
|
@@ -81,22 +81,20 @@ export function createWebExperience(model, folderId, options, authentication) {
|
|
|
81
81
|
authentication.getUsername()
|
|
82
82
|
]);
|
|
83
83
|
})
|
|
84
|
-
.then(
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
.then((responses) => {
|
|
85
|
+
const username = responses[1];
|
|
86
|
+
const failSafeAddItemResource = failSafe(addItemResource, {
|
|
87
87
|
success: true
|
|
88
88
|
});
|
|
89
89
|
// upload the data and oembed resources
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
});
|
|
99
|
-
});
|
|
90
|
+
const resourceUploadPromises = resources.map(resource => failSafeAddItemResource({
|
|
91
|
+
id: model.item.id,
|
|
92
|
+
owner: username,
|
|
93
|
+
resource: resource.file,
|
|
94
|
+
name: resource.name,
|
|
95
|
+
prefix: resource.prefix,
|
|
96
|
+
authentication
|
|
97
|
+
}));
|
|
100
98
|
// fire and forget
|
|
101
99
|
return Promise.all(resourceUploadPromises);
|
|
102
100
|
})
|
|
@@ -104,15 +102,15 @@ export function createWebExperience(model, folderId, options, authentication) {
|
|
|
104
102
|
// // TODO: Can we leave this to the main process?
|
|
105
103
|
// return uploadResourcesFromUrl(model, options.assets || [], authentication);
|
|
106
104
|
// })
|
|
107
|
-
.then(
|
|
105
|
+
.then(() => {
|
|
108
106
|
// Move it
|
|
109
107
|
return moveItem({
|
|
110
108
|
itemId: model.item.id,
|
|
111
|
-
folderId
|
|
112
|
-
authentication
|
|
109
|
+
folderId,
|
|
110
|
+
authentication
|
|
113
111
|
});
|
|
114
112
|
})
|
|
115
|
-
.then(
|
|
113
|
+
.then(() => {
|
|
116
114
|
return model;
|
|
117
115
|
}));
|
|
118
116
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-web-experience.js","sourceRoot":"","sources":["../../../src/helpers/create-web-experience.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAEL,WAAW,EACX,QAAQ,EACR,cAAc,EACd,iBAAiB,EACjB,YAAY,EACb,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EACL,UAAU,EACV,UAAU,EACV,eAAe,EAIf,QAAQ,EACT,MAAM,0BAA0B,CAAC;AAElC;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAa,EACb,QAAgB,EAChB,OAAY,EACZ,cAA2B;IAE3B,
|
|
1
|
+
{"version":3,"file":"create-web-experience.js","sourceRoot":"","sources":["../../../src/helpers/create-web-experience.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAEL,WAAW,EACX,QAAQ,EACR,cAAc,EACd,iBAAiB,EACjB,YAAY,EACb,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EACL,UAAU,EACV,UAAU,EACV,eAAe,EAIf,QAAQ,EACT,MAAM,0BAA0B,CAAC;AAElC;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAa,EACb,QAAgB,EAChB,OAAY,EACZ,cAA2B;IAE3B,MAAM,SAAS,GAAU,EAAE,CAAC;IAE5B,kEAAkE;IAClE,sCAAsC;IACtC,MAAM,aAAa,GAAuB;QACxC,oBAAoB;QACpB,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC;QAC3B,cAAc;KACf,CAAC;IAEF,0BAA0B;IAC1B,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE;QACxB,aAAa,CAAC,MAAM,GAAG;YACrB,+FAA+F;YAC/F,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,SAAS;SAChC,CAAC;QAC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entication) {
|
|
8
|
-
|
|
8
|
+
const portalUrl = authentication.portal || "https://www.arcgis.com/sharing/rest";
|
|
9
9
|
// TODO: Sort out how we locate experiences on portal?
|
|
10
|
-
|
|
10
|
+
let result;
|
|
11
11
|
if (portalUrl.match(/(qaext|\.mapsqa)\.arcgis.com/)) {
|
|
12
12
|
result = "experienceqa";
|
|
13
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-experience-subdomain.js","sourceRoot":"","sources":["../../../src/helpers/get-experience-subdomain.ts"],"names":[],"mappings":"AAiBA;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,cAA2B;IAChE,
|
|
1
|
+
{"version":3,"file":"get-experience-subdomain.js","sourceRoot":"","sources":["../../../src/helpers/get-experience-subdomain.ts"],"names":[],"mappings":"AAiBA;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,cAA2B;IAChE,MAAM,SAAS,GACb,cAAc,CAAC,MAAM,IAAI,qCAAqC,CAAC;IACjE,sDAAsD;IACtD,IAAI,MAAM,CAAC;IACX,IAAI,SAAS,CAAC,KAAK,CAAC,8BAA8B,CAAC,EAAE;QACnD,MAAM,GAAG,cAAc,CAAC;KACzB;SAAM,IAAI,SAAS,CAAC,KAAK,CAAC,mCAAmC,CAAC,EAAE;QAC/D,MAAM,GAAG,eAAe,CAAC;KAC1B;SAAM,IAAI,SAAS,CAAC,KAAK,CAAC,0BAA0B,CAAC,EAAE;QACtD,MAAM,GAAG,YAAY,CAAC;KACvB;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -21,9 +21,9 @@ import { getProp, maybePush } from "@esri/hub-common";
|
|
|
21
21
|
* @param model IModel
|
|
22
22
|
*/
|
|
23
23
|
export function getWebExperienceDependencies(model) {
|
|
24
|
-
|
|
25
|
-
return Object.keys(dataSources).reduce(
|
|
26
|
-
return maybePush(getProp(dataSources, key
|
|
24
|
+
const dataSources = getProp(model, "data.dataSources") || {};
|
|
25
|
+
return Object.keys(dataSources).reduce((acc, key) => {
|
|
26
|
+
return maybePush(getProp(dataSources, `${key}.itemId`), acc);
|
|
27
27
|
}, []);
|
|
28
28
|
}
|
|
29
29
|
//# sourceMappingURL=get-web-experience-dependencies.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-web-experience-dependencies.js","sourceRoot":"","sources":["../../../src/helpers/get-web-experience-dependencies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAU,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAAC,KAAa;IACxD,
|
|
1
|
+
{"version":3,"file":"get-web-experience-dependencies.js","sourceRoot":"","sources":["../../../src/helpers/get-web-experience-dependencies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAU,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAAC,KAAa;IACxD,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,EAAE,kBAAkB,CAAC,IAAI,EAAE,CAAC;IAC7D,OAAO,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAClD,OAAO,SAAS,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,GAAG,SAAS,CAAC,EAAE,GAAG,CAAC,CAAC;IAC/D,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC"}
|
|
@@ -6,16 +6,16 @@ import { getExperienceSubdomain } from "./get-experience-subdomain";
|
|
|
6
6
|
* @param authentication
|
|
7
7
|
*/
|
|
8
8
|
export function getWebExperiencepUrlTemplate(authentication) {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
let baseUrl = "";
|
|
10
|
+
const subdomain = getExperienceSubdomain(authentication);
|
|
11
11
|
if (subdomain) {
|
|
12
|
-
baseUrl =
|
|
12
|
+
baseUrl = `https://${subdomain}.arcgis.com/experience/{{appid}}`;
|
|
13
13
|
}
|
|
14
14
|
else {
|
|
15
15
|
// we're on portal
|
|
16
16
|
// chop off the /sharing/rest to get the baseUrl
|
|
17
|
-
|
|
18
|
-
baseUrl = portalBaseUrl
|
|
17
|
+
const portalBaseUrl = authentication.portal.replace("/sharing/rest", "");
|
|
18
|
+
baseUrl = `${portalBaseUrl}/apps/experiencebuilder/?id={{appid}}`;
|
|
19
19
|
}
|
|
20
20
|
return baseUrl;
|
|
21
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-web-experience-url-template.js","sourceRoot":"","sources":["../../../src/helpers/get-web-experience-url-template.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAC1C,cAA2B;IAE3B,IAAI,OAAO,GAAG,EAAE,CAAC;IAEjB,
|
|
1
|
+
{"version":3,"file":"get-web-experience-url-template.js","sourceRoot":"","sources":["../../../src/helpers/get-web-experience-url-template.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAC1C,cAA2B;IAE3B,IAAI,OAAO,GAAG,EAAE,CAAC;IAEjB,MAAM,SAAS,GAAG,sBAAsB,CAAC,cAAc,CAAC,CAAC;IACzD,IAAI,SAAS,EAAE;QACb,OAAO,GAAG,WAAW,SAAS,kCAAkC,CAAC;KAClE;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,uCAAuC,CAAC;KACnE;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*
|
|
19
19
|
* @module solution-web-experience
|
|
20
20
|
*/
|
|
21
|
-
import { UserSession, IItemProgressCallback, IItemTemplate, ICreateItemFromTemplateResponse } from "@esri/solution-common";
|
|
21
|
+
import { UserSession, IItemProgressCallback, IItemTemplate, ICreateItemFromTemplateResponse, IUpdateItemResponse } from "@esri/solution-common";
|
|
22
22
|
/**
|
|
23
23
|
* Convert a Web Experience item into a Template
|
|
24
24
|
*
|
|
@@ -37,3 +37,14 @@ export declare function convertItemToTemplate(solutionItemId: string, itemInfo:
|
|
|
37
37
|
* @param itemProgressCallback
|
|
38
38
|
*/
|
|
39
39
|
export declare function createItemFromTemplate(template: IItemTemplate, templateDictionary: any, destinationAuthentication: UserSession, itemProgressCallback: IItemProgressCallback): Promise<ICreateItemFromTemplateResponse>;
|
|
40
|
+
/**
|
|
41
|
+
* Post-Process an Experience
|
|
42
|
+
*
|
|
43
|
+
* @param {string} itemId The item ID
|
|
44
|
+
* @param {string} type The template type
|
|
45
|
+
* @param {any[]} itemInfos Array of {id: 'ef3', type: 'Web Map'} objects
|
|
46
|
+
* @param {any} templateDictionary The template dictionary
|
|
47
|
+
* @param {UserSession} authentication The destination session info
|
|
48
|
+
* @returns Promise resolving to successfulness of update
|
|
49
|
+
*/
|
|
50
|
+
export declare function postProcess(itemId: string, type: string, itemInfos: any[], template: IItemTemplate, templates: IItemTemplate[], templateDictionary: any, authentication: UserSession): Promise<IUpdateItemResponse>;
|
|
@@ -13,13 +13,12 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { __assign } from "tslib";
|
|
17
16
|
/**
|
|
18
17
|
* Manages the creation and deployment of web-experience item types.
|
|
19
18
|
*
|
|
20
19
|
* @module solution-web-experience
|
|
21
20
|
*/
|
|
22
|
-
import { EItemProgressStatus, generateEmptyCreationResponse } from "@esri/solution-common";
|
|
21
|
+
import { EItemProgressStatus, generateEmptyCreationResponse, updateItemTemplateFromDictionary } from "@esri/solution-common";
|
|
23
22
|
import { failSafe } from "@esri/hub-common";
|
|
24
23
|
import { getItemData, removeItem } from "@esri/arcgis-rest-portal";
|
|
25
24
|
import { createWebExperienceModelFromTemplate } from "./helpers/create-web-experience-model-from-template";
|
|
@@ -35,12 +34,12 @@ import { convertWebExperienceToTemplate } from "./helpers/convert-web-experience
|
|
|
35
34
|
*/
|
|
36
35
|
export function convertItemToTemplate(solutionItemId, itemInfo, authentication) {
|
|
37
36
|
// use the itemInfo to setup a model
|
|
38
|
-
|
|
37
|
+
const model = {
|
|
39
38
|
item: itemInfo,
|
|
40
39
|
data: {}
|
|
41
40
|
};
|
|
42
41
|
// fetch the data.json
|
|
43
|
-
return getItemData(itemInfo.id, { authentication
|
|
42
|
+
return getItemData(itemInfo.id, { authentication }).then(data => {
|
|
44
43
|
// append into the model
|
|
45
44
|
model.data = data;
|
|
46
45
|
// and use that to create a template
|
|
@@ -57,18 +56,18 @@ export function convertItemToTemplate(solutionItemId, itemInfo, authentication)
|
|
|
57
56
|
*/
|
|
58
57
|
export function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
|
|
59
58
|
// let the progress system know we've started...
|
|
60
|
-
|
|
59
|
+
const startStatus = itemProgressCallback(template.itemId, EItemProgressStatus.Started, 0);
|
|
61
60
|
// and if it returned false, just resolve out
|
|
62
61
|
if (!startStatus) {
|
|
63
62
|
return Promise.resolve(generateEmptyCreationResponse(template.type));
|
|
64
63
|
}
|
|
65
|
-
|
|
64
|
+
let exbModel;
|
|
66
65
|
return createWebExperienceModelFromTemplate(template, templateDictionary, {}, destinationAuthentication)
|
|
67
|
-
.then(
|
|
66
|
+
.then(model => {
|
|
68
67
|
exbModel = model;
|
|
69
68
|
return createWebExperience(model, templateDictionary.folderId, {}, destinationAuthentication);
|
|
70
69
|
})
|
|
71
|
-
.then(
|
|
70
|
+
.then(createdModel => {
|
|
72
71
|
exbModel.item.id = createdModel.item.id;
|
|
73
72
|
exbModel.item.url = createdModel.item.url;
|
|
74
73
|
// Update the template dictionary
|
|
@@ -77,21 +76,24 @@ export function createItemFromTemplate(template, templateDictionary, destination
|
|
|
77
76
|
templateDictionary[template.itemId] = {
|
|
78
77
|
itemId: createdModel.item.id
|
|
79
78
|
};
|
|
80
|
-
|
|
79
|
+
const finalStatus = itemProgressCallback(template.itemId, EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor || 2, createdModel.item.id);
|
|
81
80
|
if (!finalStatus) {
|
|
82
81
|
// clean up the site we just created
|
|
83
|
-
|
|
82
|
+
const failSafeRemove = failSafe(removeItem, { success: true });
|
|
84
83
|
return failSafeRemove({
|
|
85
84
|
id: exbModel.item.id,
|
|
86
85
|
authentication: destinationAuthentication
|
|
87
|
-
}).then(
|
|
86
|
+
}).then(() => {
|
|
88
87
|
return Promise.resolve(generateEmptyCreationResponse(template.type));
|
|
89
88
|
});
|
|
90
89
|
}
|
|
91
90
|
else {
|
|
92
91
|
// finally, return ICreateItemFromTemplateResponse
|
|
93
|
-
|
|
94
|
-
item:
|
|
92
|
+
const response = {
|
|
93
|
+
item: {
|
|
94
|
+
...template,
|
|
95
|
+
...exbModel
|
|
96
|
+
},
|
|
95
97
|
id: exbModel.item.id,
|
|
96
98
|
type: template.type,
|
|
97
99
|
postProcess: false
|
|
@@ -101,4 +103,17 @@ export function createItemFromTemplate(template, templateDictionary, destination
|
|
|
101
103
|
}
|
|
102
104
|
});
|
|
103
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Post-Process an Experience
|
|
108
|
+
*
|
|
109
|
+
* @param {string} itemId The item ID
|
|
110
|
+
* @param {string} type The template type
|
|
111
|
+
* @param {any[]} itemInfos Array of {id: 'ef3', type: 'Web Map'} objects
|
|
112
|
+
* @param {any} templateDictionary The template dictionary
|
|
113
|
+
* @param {UserSession} authentication The destination session info
|
|
114
|
+
* @returns Promise resolving to successfulness of update
|
|
115
|
+
*/
|
|
116
|
+
export function postProcess(itemId, type, itemInfos, template, templates, templateDictionary, authentication) {
|
|
117
|
+
return updateItemTemplateFromDictionary(itemId, templateDictionary, authentication);
|
|
118
|
+
}
|
|
104
119
|
//# sourceMappingURL=web-experience-processor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-experience-processor.js","sourceRoot":"","sources":["../../src/web-experience-processor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG
|
|
1
|
+
{"version":3,"file":"web-experience-processor.js","sourceRoot":"","sources":["../../src/web-experience-processor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AAEH,OAAO,EAEL,mBAAmB,EAKnB,6BAA6B,EAC7B,gCAAgC,EACjC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAU,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,oCAAoC,EAAE,MAAM,qDAAqD,CAAC;AAC3G,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,8BAA8B,EAAE,MAAM,8CAA8C,CAAC;AAE9F;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CACnC,cAAsB,EACtB,QAAa,EACb,cAA2B;IAE3B,oCAAoC;IACpC,MAAM,KAAK,GAAG;QACZ,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,EAAE;KACC,CAAC;IACZ,sBAAsB;IACtB,OAAO,WAAW,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QAC9D,wBAAwB;QACxB,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;QAClB,oCAAoC;QACpC,OAAO,8BAA8B,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC,CAAC,CA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YACpC,MAAM,cAAc,GAAG,QAAQ,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;YAC/D,OAAO,cAAc,CAAC;gBACpB,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE;gBACpB,cAAc,EAAE,yBAAyB;aAC1C,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;gBACX,OAAO,OAAO,CAAC,OAAO,CAAC,6BAA6B,CAAC,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,QAAQ;iBACZ;gBACD,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE;gBACpB,IAAI,EAAE,QAAQ,CAAC,IAAI;gBACnB,WAAW,EAAE,KAAK;aACnB,CAAC;YACF,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACxC,OAAO,QAAQ,CAAC;SACjB;IACH,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CACzB,MAAc,EACd,IAAY,EACZ,SAAgB,EAChB,QAAuB,EACvB,SAA0B,EAC1B,kBAAuB,EACvB,cAA2B;IAE3B,OAAO,gCAAgC,CACrC,MAAM,EACN,kBAAkB,EAClB,cAAc,CACf,CAAC;AACJ,CAAC"}
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.convertWebExperienceToTemplate = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const hub_common_1 = require("@esri/hub-common");
|
|
20
|
+
const solution_common_1 = require("@esri/solution-common");
|
|
21
|
+
const get_web_experience_dependencies_1 = require("./get-web-experience-dependencies");
|
|
22
22
|
/**
|
|
23
23
|
* Convert an Experience item into a template
|
|
24
24
|
*
|
|
@@ -29,20 +29,20 @@ var get_web_experience_dependencies_1 = require("./get-web-experience-dependenci
|
|
|
29
29
|
* @param authentication
|
|
30
30
|
*/
|
|
31
31
|
function convertWebExperienceToTemplate(model) {
|
|
32
|
-
|
|
33
|
-
tmpl.key = hub_common_1.propifyString(model.item.title)
|
|
34
|
-
|
|
32
|
+
const tmpl = (0, solution_common_1.createPlaceholderTemplate)(model.item.id, model.item.type);
|
|
33
|
+
tmpl.key = `${(0, hub_common_1.propifyString)(model.item.title)}_${(0, hub_common_1.createId)("i")}`;
|
|
34
|
+
const clone = (0, hub_common_1.cloneObject)(model);
|
|
35
35
|
tmpl.data = clone.data;
|
|
36
|
-
tmpl.item = hub_common_1.normalizeSolutionTemplateItem(clone.item);
|
|
36
|
+
tmpl.item = (0, hub_common_1.normalizeSolutionTemplateItem)(clone.item);
|
|
37
37
|
// templatize the url. This is updated during the createModelFromTemplate phase
|
|
38
38
|
// of the deployment process
|
|
39
39
|
tmpl.item.url = "{{experienceUrlTemplate}}";
|
|
40
40
|
// use typeKeyword to mark item as published (we decided to discard unpublished drafts)
|
|
41
|
-
|
|
41
|
+
const typeKeywords = tmpl.item.typeKeywords;
|
|
42
42
|
if (typeKeywords.indexOf(changedTypeKW) !== -1) {
|
|
43
|
-
tmpl.item.typeKeywords = [publishedTypeKW].concat(tmpl.item.typeKeywords.filter(
|
|
43
|
+
tmpl.item.typeKeywords = [publishedTypeKW].concat(tmpl.item.typeKeywords.filter(word => word !== changedTypeKW));
|
|
44
44
|
}
|
|
45
|
-
tmpl.dependencies = get_web_experience_dependencies_1.getWebExperienceDependencies(model);
|
|
45
|
+
tmpl.dependencies = (0, get_web_experience_dependencies_1.getWebExperienceDependencies)(model);
|
|
46
46
|
return Promise.resolve(tmpl);
|
|
47
47
|
// TODO: For now, we let the generic process handle item resources
|
|
48
48
|
// However, many newer item types have complex type-specific resource handling
|
|
@@ -57,6 +57,6 @@ function convertWebExperienceToTemplate(model) {
|
|
|
57
57
|
// });
|
|
58
58
|
}
|
|
59
59
|
exports.convertWebExperienceToTemplate = convertWebExperienceToTemplate;
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
const publishedTypeKW = "status: Published";
|
|
61
|
+
const changedTypeKW = "status: Changed";
|
|
62
62
|
//# sourceMappingURL=convert-web-experience-to-template.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-web-experience-to-template.js","sourceRoot":"","sources":["../../../src/helpers/convert-web-experience-to-template.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH
|
|
1
|
+
{"version":3,"file":"convert-web-experience-to-template.js","sourceRoot":"","sources":["../../../src/helpers/convert-web-experience-to-template.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,iDAM0B;AAE1B,2DAG+B;AAE/B,uFAAiF;AAEjF;;;;;;;;GAQG;AACH,SAAgB,8BAA8B,CAC5C,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,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IACvB,IAAI,CAAC,IAAI,GAAG,IAAA,0CAA6B,EAAC,KAAK,CAAC,IAAI,CAAU,CAAC;IAC/D,+EAA+E;IAC/E,4BAA4B;IAC5B,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,2BAA2B,CAAC;IAE5C,uFAAuF;IACvF,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;IAC5C,IAAI,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE;QAC9C,IAAI,CAAC,IAAI,CAAC,YAAY,GAAG,CAAC,eAAe,CAAC,CAAC,MAAM,CAC/C,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,aAAa,CAAC,CAC9D,CAAC;KACH;IAED,IAAI,CAAC,YAAY,GAAG,IAAA,8DAA4B,EAAC,KAAK,CAAC,CAAC;IAExD,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,kEAAkE;IAClE,8EAA8E;IAC9E,wDAAwD;IACxD,yDAAyD;IACzD,uDAAuD;IACvD,0BAA0B;IAC1B,+DAA+D;IAC/D,iCAAiC;IACjC,yDAAyD;IACzD,mBAAmB;IACnB,QAAQ;AACV,CAAC;AAnCD,wEAmCC;AAED,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAC5C,MAAM,aAAa,GAAG,iBAAiB,CAAC"}
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.createWebExperienceModelFromTemplate = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const hub_common_1 = require("@esri/hub-common");
|
|
20
|
+
const get_web_experience_url_template_1 = require("./get-web-experience-url-template");
|
|
21
21
|
/**
|
|
22
22
|
* Convert a Web Experience template into a Model that can be persisted to the Portal API
|
|
23
23
|
*
|
|
@@ -28,8 +28,8 @@ var get_web_experience_url_template_1 = require("./get-web-experience-url-templa
|
|
|
28
28
|
*/
|
|
29
29
|
function createWebExperienceModelFromTemplate(templateModel, settings, transforms, authentication) {
|
|
30
30
|
// get the experience base url
|
|
31
|
-
settings.experienceUrlTemplate = get_web_experience_url_template_1.getWebExperiencepUrlTemplate(authentication);
|
|
32
|
-
|
|
31
|
+
settings.experienceUrlTemplate = (0, get_web_experience_url_template_1.getWebExperiencepUrlTemplate)(authentication);
|
|
32
|
+
const model = (0, hub_common_1.interpolate)(templateModel, settings, transforms);
|
|
33
33
|
// ensure this is set - there may be some templates w/o `{{experienceTemplateUrl}}
|
|
34
34
|
model.item.url = settings.experienceUrlTemplate;
|
|
35
35
|
/* istanbul ignore else */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-web-experience-model-from-template.js","sourceRoot":"","sources":["../../../src/helpers/create-web-experience-model-from-template.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH
|
|
1
|
+
{"version":3,"file":"create-web-experience-model-from-template.js","sourceRoot":"","sources":["../../../src/helpers/create-web-experience-model-from-template.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,iDAA+D;AAE/D,uFAAiF;AACjF;;;;;;;GAOG;AACH,SAAgB,oCAAoC,CAClD,aAA6B,EAC7B,QAAa,EACb,UAAe,EACf,cAA2B;IAE3B,8BAA8B;IAC9B,QAAQ,CAAC,qBAAqB,GAAG,IAAA,8DAA4B,EAAC,cAAc,CAAC,CAAC;IAC9E,MAAM,KAAK,GAAG,IAAA,wBAAW,EAAC,aAAa,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC/D,kFAAkF;IAClF,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,qBAAqB,CAAC;IAChD,0BAA0B;IAC1B,IAAI,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE;QAChC,KAAK,CAAC,IAAI,CAAC,SAAS,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,yCAAyC;KAC/F;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC;AAjBD,oFAiBC"}
|
|
@@ -16,8 +16,8 @@ exports.createWebExperience = void 0;
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const hub_common_1 = require("@esri/hub-common");
|
|
20
|
+
const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
|
|
21
21
|
/**
|
|
22
22
|
* Given a Model for a Web Experience, create the item in the Portal API
|
|
23
23
|
*
|
|
@@ -26,13 +26,13 @@ var arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
|
|
|
26
26
|
* @param authentication
|
|
27
27
|
*/
|
|
28
28
|
function createWebExperience(model, folderId, options, authentication) {
|
|
29
|
-
|
|
29
|
+
const resources = [];
|
|
30
30
|
// For unkown reasons we can not seem to spy on createItemInFolder
|
|
31
31
|
// so we will create-then-move for now
|
|
32
|
-
|
|
32
|
+
const createOptions = {
|
|
33
33
|
// need to serialize
|
|
34
|
-
item: hub_common_1.serializeModel(model),
|
|
35
|
-
authentication
|
|
34
|
+
item: (0, hub_common_1.serializeModel)(model),
|
|
35
|
+
authentication
|
|
36
36
|
};
|
|
37
37
|
/* istanbul ignore else */
|
|
38
38
|
if (model.item.thumbnail) {
|
|
@@ -43,34 +43,34 @@ function createWebExperience(model, folderId, options, authentication) {
|
|
|
43
43
|
delete createOptions.item.thumbnail;
|
|
44
44
|
}
|
|
45
45
|
// Create the item
|
|
46
|
-
return (arcgis_rest_portal_1.createItem(createOptions)
|
|
47
|
-
.then(
|
|
46
|
+
return ((0, arcgis_rest_portal_1.createItem)(createOptions)
|
|
47
|
+
.then((createResponse) => {
|
|
48
48
|
model.item.id = createResponse.id;
|
|
49
|
-
|
|
50
|
-
model = hub_common_1.interpolateItemId(model);
|
|
49
|
+
const savedThumbnail = model.item.thumbnail;
|
|
50
|
+
model = (0, hub_common_1.interpolateItemId)(model);
|
|
51
51
|
model.item.thumbnail = savedThumbnail; // interpolation trashes thumbnail binary
|
|
52
52
|
// Experiences store draft data in a resource attached to the item
|
|
53
53
|
// We'll just use the published data for the first "draft"
|
|
54
|
-
|
|
54
|
+
const draftResourceModel = (0, hub_common_1.cloneObject)(model.data);
|
|
55
55
|
resources.push({
|
|
56
56
|
name: "config.json",
|
|
57
57
|
prefix: "config",
|
|
58
|
-
file: hub_common_1.stringToBlob(JSON.stringify(draftResourceModel))
|
|
58
|
+
file: (0, hub_common_1.stringToBlob)(JSON.stringify(draftResourceModel))
|
|
59
59
|
});
|
|
60
60
|
// there may also be this image resources list
|
|
61
|
-
|
|
61
|
+
const imageListModel = (0, hub_common_1.cloneObject)(model.properties.imageResourcesList);
|
|
62
62
|
if (imageListModel) {
|
|
63
63
|
resources.push({
|
|
64
64
|
name: "image-resources-list.json",
|
|
65
65
|
prefix: "images",
|
|
66
|
-
file: hub_common_1.stringToBlob(JSON.stringify(imageListModel))
|
|
66
|
+
file: (0, hub_common_1.stringToBlob)(JSON.stringify(imageListModel))
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
delete model.properties;
|
|
70
70
|
// update the experience with the newly interpolated model
|
|
71
|
-
|
|
72
|
-
item: hub_common_1.serializeModel(model),
|
|
73
|
-
authentication
|
|
71
|
+
const updateOptions = {
|
|
72
|
+
item: (0, hub_common_1.serializeModel)(model),
|
|
73
|
+
authentication
|
|
74
74
|
};
|
|
75
75
|
if (model.item.thumbnail) {
|
|
76
76
|
updateOptions.params = {
|
|
@@ -80,26 +80,24 @@ function createWebExperience(model, folderId, options, authentication) {
|
|
|
80
80
|
delete updateOptions.item.thumbnail;
|
|
81
81
|
}
|
|
82
82
|
return Promise.all([
|
|
83
|
-
arcgis_rest_portal_1.updateItem(updateOptions),
|
|
83
|
+
(0, arcgis_rest_portal_1.updateItem)(updateOptions),
|
|
84
84
|
authentication.getUsername()
|
|
85
85
|
]);
|
|
86
86
|
})
|
|
87
|
-
.then(
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
.then((responses) => {
|
|
88
|
+
const username = responses[1];
|
|
89
|
+
const failSafeAddItemResource = (0, hub_common_1.failSafe)(arcgis_rest_portal_1.addItemResource, {
|
|
90
90
|
success: true
|
|
91
91
|
});
|
|
92
92
|
// upload the data and oembed resources
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
});
|
|
102
|
-
});
|
|
93
|
+
const resourceUploadPromises = resources.map(resource => failSafeAddItemResource({
|
|
94
|
+
id: model.item.id,
|
|
95
|
+
owner: username,
|
|
96
|
+
resource: resource.file,
|
|
97
|
+
name: resource.name,
|
|
98
|
+
prefix: resource.prefix,
|
|
99
|
+
authentication
|
|
100
|
+
}));
|
|
103
101
|
// fire and forget
|
|
104
102
|
return Promise.all(resourceUploadPromises);
|
|
105
103
|
})
|
|
@@ -107,15 +105,15 @@ function createWebExperience(model, folderId, options, authentication) {
|
|
|
107
105
|
// // TODO: Can we leave this to the main process?
|
|
108
106
|
// return uploadResourcesFromUrl(model, options.assets || [], authentication);
|
|
109
107
|
// })
|
|
110
|
-
.then(
|
|
108
|
+
.then(() => {
|
|
111
109
|
// Move it
|
|
112
|
-
return arcgis_rest_portal_1.moveItem({
|
|
110
|
+
return (0, arcgis_rest_portal_1.moveItem)({
|
|
113
111
|
itemId: model.item.id,
|
|
114
|
-
folderId
|
|
115
|
-
authentication
|
|
112
|
+
folderId,
|
|
113
|
+
authentication
|
|
116
114
|
});
|
|
117
115
|
})
|
|
118
|
-
.then(
|
|
116
|
+
.then(() => {
|
|
119
117
|
return model;
|
|
120
118
|
}));
|
|
121
119
|
}
|