@esri/solution-web-experience 1.1.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/helpers/convert-web-experience-to-template.js +12 -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 +27 -28
- 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 +15 -3
- package/dist/esm/web-experience-processor.js +31 -15
- package/dist/esm/web-experience-processor.js.map +1 -1
- package/dist/node/helpers/convert-web-experience-to-template.js +15 -10
- package/dist/node/helpers/convert-web-experience-to-template.js.map +1 -1
- package/dist/node/helpers/create-web-experience-model-from-template.js +3 -3
- package/dist/node/helpers/create-web-experience-model-from-template.js.map +1 -1
- package/dist/node/helpers/create-web-experience.js +28 -29
- 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 +15 -3
- package/dist/node/web-experience-processor.js +38 -21
- package/dist/node/web-experience-processor.js.map +1 -1
- package/dist/umd/web-experience-processor.d.ts +15 -3
- package/dist/umd/web-experience.umd.js +400 -404
- 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 +21 -21
|
@@ -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
34
|
item: (0, hub_common_1.serializeModel)(model),
|
|
35
|
-
authentication
|
|
35
|
+
authentication
|
|
36
36
|
};
|
|
37
37
|
/* istanbul ignore else */
|
|
38
38
|
if (model.item.thumbnail) {
|
|
@@ -44,21 +44,22 @@ function createWebExperience(model, folderId, options, authentication) {
|
|
|
44
44
|
}
|
|
45
45
|
// Create the item
|
|
46
46
|
return ((0, arcgis_rest_portal_1.createItem)(createOptions)
|
|
47
|
-
.then(
|
|
47
|
+
.then((createResponse) => {
|
|
48
48
|
model.item.id = createResponse.id;
|
|
49
|
-
|
|
49
|
+
const savedThumbnail = model.item.thumbnail;
|
|
50
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
|
+
// changed from stringToBlob to objectToJsonBlob for issue #742
|
|
55
|
+
const draftResourceModel = (0, hub_common_1.cloneObject)(model.data);
|
|
55
56
|
resources.push({
|
|
56
57
|
name: "config.json",
|
|
57
58
|
prefix: "config",
|
|
58
|
-
file: (0, hub_common_1.
|
|
59
|
+
file: (0, hub_common_1.objectToJsonBlob)(draftResourceModel)
|
|
59
60
|
});
|
|
60
61
|
// there may also be this image resources list
|
|
61
|
-
|
|
62
|
+
const imageListModel = (0, hub_common_1.cloneObject)(model.properties.imageResourcesList);
|
|
62
63
|
if (imageListModel) {
|
|
63
64
|
resources.push({
|
|
64
65
|
name: "image-resources-list.json",
|
|
@@ -68,9 +69,9 @@ function createWebExperience(model, folderId, options, authentication) {
|
|
|
68
69
|
}
|
|
69
70
|
delete model.properties;
|
|
70
71
|
// update the experience with the newly interpolated model
|
|
71
|
-
|
|
72
|
+
const updateOptions = {
|
|
72
73
|
item: (0, hub_common_1.serializeModel)(model),
|
|
73
|
-
authentication
|
|
74
|
+
authentication
|
|
74
75
|
};
|
|
75
76
|
if (model.item.thumbnail) {
|
|
76
77
|
updateOptions.params = {
|
|
@@ -84,22 +85,20 @@ function createWebExperience(model, folderId, options, authentication) {
|
|
|
84
85
|
authentication.getUsername()
|
|
85
86
|
]);
|
|
86
87
|
})
|
|
87
|
-
.then(
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
.then((responses) => {
|
|
89
|
+
const username = responses[1];
|
|
90
|
+
const failSafeAddItemResource = (0, hub_common_1.failSafe)(arcgis_rest_portal_1.addItemResource, {
|
|
90
91
|
success: true
|
|
91
92
|
});
|
|
92
93
|
// upload the data and oembed resources
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
});
|
|
102
|
-
});
|
|
94
|
+
const resourceUploadPromises = resources.map(resource => failSafeAddItemResource({
|
|
95
|
+
id: model.item.id,
|
|
96
|
+
owner: username,
|
|
97
|
+
resource: resource.file,
|
|
98
|
+
name: resource.name,
|
|
99
|
+
prefix: resource.prefix,
|
|
100
|
+
authentication
|
|
101
|
+
}));
|
|
103
102
|
// fire and forget
|
|
104
103
|
return Promise.all(resourceUploadPromises);
|
|
105
104
|
})
|
|
@@ -107,15 +106,15 @@ function createWebExperience(model, folderId, options, authentication) {
|
|
|
107
106
|
// // TODO: Can we leave this to the main process?
|
|
108
107
|
// return uploadResourcesFromUrl(model, options.assets || [], authentication);
|
|
109
108
|
// })
|
|
110
|
-
.then(
|
|
109
|
+
.then(() => {
|
|
111
110
|
// Move it
|
|
112
111
|
return (0, arcgis_rest_portal_1.moveItem)({
|
|
113
112
|
itemId: model.item.id,
|
|
114
|
-
folderId
|
|
115
|
-
authentication
|
|
113
|
+
folderId,
|
|
114
|
+
authentication
|
|
116
115
|
});
|
|
117
116
|
})
|
|
118
|
-
.then(
|
|
117
|
+
.then(() => {
|
|
119
118
|
return model;
|
|
120
119
|
}));
|
|
121
120
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-web-experience.js","sourceRoot":"","sources":["../../../src/helpers/create-web-experience.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH
|
|
1
|
+
{"version":3,"file":"create-web-experience.js","sourceRoot":"","sources":["../../../src/helpers/create-web-experience.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,iDAQ0B;AAI1B,iEAQkC;AAElC;;;;;;GAMG;AACH,SAAgB,mBAAmB,CACjC,KAAa,EACb,QAAgB,EAChB,OAAY,EACZ,cAA2B;IAE3B,MAAM,SAAS,GAAU,EAAE,CAAC;IAE5B,kEAAkE;IAClE,sCAAsC;IACtC,MAAM,aAAa,GAAuB;QACxC,oB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A,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,CACL,CAAC;AACJ,CAAC;AA5GD,kDA4GC"}
|
|
@@ -8,9 +8,9 @@ exports.getExperienceSubdomain = void 0;
|
|
|
8
8
|
* @param authentication UserSession
|
|
9
9
|
*/
|
|
10
10
|
function getExperienceSubdomain(authentication) {
|
|
11
|
-
|
|
11
|
+
const portalUrl = authentication.portal || "https://www.arcgis.com/sharing/rest";
|
|
12
12
|
// TODO: Sort out how we locate experiences on portal?
|
|
13
|
-
|
|
13
|
+
let result;
|
|
14
14
|
if (portalUrl.match(/(qaext|\.mapsqa)\.arcgis.com/)) {
|
|
15
15
|
result = "experienceqa";
|
|
16
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-experience-subdomain.js","sourceRoot":"","sources":["../../../src/helpers/get-experience-subdomain.ts"],"names":[],"mappings":";;;AAiBA;;;;;GAKG;AACH,SAAgB,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,SAAgB,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;AAbD,wDAaC"}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.getWebExperienceDependencies = void 0;
|
|
19
|
-
|
|
19
|
+
const hub_common_1 = require("@esri/hub-common");
|
|
20
20
|
/**
|
|
21
21
|
* Given an Web Experience model, extract out all the
|
|
22
22
|
* items it depends on from the `dataSources` hash
|
|
@@ -24,9 +24,9 @@ var hub_common_1 = require("@esri/hub-common");
|
|
|
24
24
|
* @param model IModel
|
|
25
25
|
*/
|
|
26
26
|
function getWebExperienceDependencies(model) {
|
|
27
|
-
|
|
28
|
-
return Object.keys(dataSources).reduce(
|
|
29
|
-
return (0, hub_common_1.maybePush)((0, hub_common_1.getProp)(dataSources, key
|
|
27
|
+
const dataSources = (0, hub_common_1.getProp)(model, "data.dataSources") || {};
|
|
28
|
+
return Object.keys(dataSources).reduce((acc, key) => {
|
|
29
|
+
return (0, hub_common_1.maybePush)((0, hub_common_1.getProp)(dataSources, `${key}.itemId`), acc);
|
|
30
30
|
}, []);
|
|
31
31
|
}
|
|
32
32
|
exports.getWebExperienceDependencies = getWebExperienceDependencies;
|
|
@@ -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
|
|
1
|
+
{"version":3,"file":"get-web-experience-dependencies.js","sourceRoot":"","sources":["../../../src/helpers/get-web-experience-dependencies.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,iDAA8D;AAE9D;;;;;GAKG;AACH,SAAgB,4BAA4B,CAAC,KAAa;IACxD,MAAM,WAAW,GAAG,IAAA,oBAAO,EAAC,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,IAAA,sBAAS,EAAC,IAAA,oBAAO,EAAC,WAAW,EAAE,GAAG,GAAG,SAAS,CAAC,EAAE,GAAG,CAAC,CAAC;IAC/D,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AALD,oEAKC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getWebExperiencepUrlTemplate = void 0;
|
|
4
|
-
|
|
4
|
+
const get_experience_subdomain_1 = require("./get-experience-subdomain");
|
|
5
5
|
/**
|
|
6
6
|
* For a given environment Prod/qa/dev/portal
|
|
7
7
|
* return the correct storymaps base url
|
|
@@ -9,16 +9,16 @@ var get_experience_subdomain_1 = require("./get-experience-subdomain");
|
|
|
9
9
|
* @param authentication
|
|
10
10
|
*/
|
|
11
11
|
function getWebExperiencepUrlTemplate(authentication) {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
let baseUrl = "";
|
|
13
|
+
const subdomain = (0, get_experience_subdomain_1.getExperienceSubdomain)(authentication);
|
|
14
14
|
if (subdomain) {
|
|
15
|
-
baseUrl =
|
|
15
|
+
baseUrl = `https://${subdomain}.arcgis.com/experience/{{appid}}`;
|
|
16
16
|
}
|
|
17
17
|
else {
|
|
18
18
|
// we're on portal
|
|
19
19
|
// chop off the /sharing/rest to get the baseUrl
|
|
20
|
-
|
|
21
|
-
baseUrl = portalBaseUrl
|
|
20
|
+
const portalBaseUrl = authentication.portal.replace("/sharing/rest", "");
|
|
21
|
+
baseUrl = `${portalBaseUrl}/apps/experiencebuilder/?id={{appid}}`;
|
|
22
22
|
}
|
|
23
23
|
return baseUrl;
|
|
24
24
|
}
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"get-web-experience-url-template.js","sourceRoot":"","sources":["../../../src/helpers/get-web-experience-url-template.ts"],"names":[],"mappings":";;;AAgBA,yEAAoE;AACpE;;;;;GAKG;AACH,SAAgB,4BAA4B,CAC1C,cAA2B;IAE3B,IAAI,OAAO,GAAG,EAAE,CAAC;IAEjB,MAAM,SAAS,GAAG,IAAA,iDAAsB,EAAC,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;AAhBD,oEAgBC"}
|
package/dist/node/index.js
CHANGED
|
@@ -16,6 +16,6 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.WebExperienceProcessor = void 0;
|
|
19
|
-
|
|
19
|
+
const WebExperienceProcessor = require("./web-experience-processor");
|
|
20
20
|
exports.WebExperienceProcessor = WebExperienceProcessor;
|
|
21
21
|
//# sourceMappingURL=index.js.map
|
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,qEAAqE;AAE5D,wDAAsB"}
|
|
@@ -18,16 +18,17 @@
|
|
|
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
|
*
|
|
25
25
|
* @param solutionItemId
|
|
26
26
|
* @param itemInfo
|
|
27
|
-
* @param
|
|
27
|
+
* @param destAuthentication Credentials for requests to the destination organization
|
|
28
|
+
* @param srcAuthentication Credentials for requests to source items
|
|
28
29
|
* @param isGroup
|
|
29
30
|
*/
|
|
30
|
-
export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any,
|
|
31
|
+
export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, destAuthentication: UserSession, srcAuthentication: UserSession): Promise<IItemTemplate>;
|
|
31
32
|
/**
|
|
32
33
|
* Create a Web Experience from a Template
|
|
33
34
|
*
|
|
@@ -37,3 +38,14 @@ export declare function convertItemToTemplate(solutionItemId: string, itemInfo:
|
|
|
37
38
|
* @param itemProgressCallback
|
|
38
39
|
*/
|
|
39
40
|
export declare function createItemFromTemplate(template: IItemTemplate, templateDictionary: any, destinationAuthentication: UserSession, itemProgressCallback: IItemProgressCallback): Promise<ICreateItemFromTemplateResponse>;
|
|
41
|
+
/**
|
|
42
|
+
* Post-Process an Experience
|
|
43
|
+
*
|
|
44
|
+
* @param {string} itemId The item ID
|
|
45
|
+
* @param {string} type The template type
|
|
46
|
+
* @param {any[]} itemInfos Array of {id: 'ef3', type: 'Web Map'} objects
|
|
47
|
+
* @param {any} templateDictionary The template dictionary
|
|
48
|
+
* @param {UserSession} authentication The destination session info
|
|
49
|
+
* @returns Promise resolving to successfulness of update
|
|
50
|
+
*/
|
|
51
|
+
export declare function postProcess(itemId: string, type: string, itemInfos: any[], template: IItemTemplate, templates: IItemTemplate[], templateDictionary: any, authentication: UserSession): Promise<IUpdateItemResponse>;
|
|
@@ -15,35 +15,35 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.createItemFromTemplate = exports.convertItemToTemplate = void 0;
|
|
19
|
-
var tslib_1 = require("tslib");
|
|
18
|
+
exports.postProcess = exports.createItemFromTemplate = exports.convertItemToTemplate = void 0;
|
|
20
19
|
/**
|
|
21
20
|
* Manages the creation and deployment of web-experience item types.
|
|
22
21
|
*
|
|
23
22
|
* @module solution-web-experience
|
|
24
23
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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 create_web_experience_model_from_template_1 = require("./helpers/create-web-experience-model-from-template");
|
|
28
|
+
const create_web_experience_1 = require("./helpers/create-web-experience");
|
|
29
|
+
const convert_web_experience_to_template_1 = require("./helpers/convert-web-experience-to-template");
|
|
31
30
|
/**
|
|
32
31
|
* Convert a Web Experience item into a Template
|
|
33
32
|
*
|
|
34
33
|
* @param solutionItemId
|
|
35
34
|
* @param itemInfo
|
|
36
|
-
* @param
|
|
35
|
+
* @param destAuthentication Credentials for requests to the destination organization
|
|
36
|
+
* @param srcAuthentication Credentials for requests to source items
|
|
37
37
|
* @param isGroup
|
|
38
38
|
*/
|
|
39
|
-
function convertItemToTemplate(solutionItemId, itemInfo,
|
|
39
|
+
function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication) {
|
|
40
40
|
// use the itemInfo to setup a model
|
|
41
|
-
|
|
41
|
+
const model = {
|
|
42
42
|
item: itemInfo,
|
|
43
43
|
data: {}
|
|
44
44
|
};
|
|
45
45
|
// fetch the data.json
|
|
46
|
-
return (0, arcgis_rest_portal_1.getItemData)(itemInfo.id, { authentication:
|
|
46
|
+
return (0, arcgis_rest_portal_1.getItemData)(itemInfo.id, { authentication: srcAuthentication }).then(data => {
|
|
47
47
|
// append into the model
|
|
48
48
|
model.data = data;
|
|
49
49
|
// and use that to create a template
|
|
@@ -61,18 +61,18 @@ exports.convertItemToTemplate = convertItemToTemplate;
|
|
|
61
61
|
*/
|
|
62
62
|
function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
|
|
63
63
|
// let the progress system know we've started...
|
|
64
|
-
|
|
64
|
+
const startStatus = itemProgressCallback(template.itemId, solution_common_1.EItemProgressStatus.Started, 0);
|
|
65
65
|
// and if it returned false, just resolve out
|
|
66
66
|
if (!startStatus) {
|
|
67
67
|
return Promise.resolve((0, solution_common_1.generateEmptyCreationResponse)(template.type));
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
let exbModel;
|
|
70
70
|
return (0, create_web_experience_model_from_template_1.createWebExperienceModelFromTemplate)(template, templateDictionary, {}, destinationAuthentication)
|
|
71
|
-
.then(
|
|
71
|
+
.then(model => {
|
|
72
72
|
exbModel = model;
|
|
73
73
|
return (0, create_web_experience_1.createWebExperience)(model, templateDictionary.folderId, {}, destinationAuthentication);
|
|
74
74
|
})
|
|
75
|
-
.then(
|
|
75
|
+
.then(createdModel => {
|
|
76
76
|
exbModel.item.id = createdModel.item.id;
|
|
77
77
|
exbModel.item.url = createdModel.item.url;
|
|
78
78
|
// Update the template dictionary
|
|
@@ -81,21 +81,24 @@ function createItemFromTemplate(template, templateDictionary, destinationAuthent
|
|
|
81
81
|
templateDictionary[template.itemId] = {
|
|
82
82
|
itemId: createdModel.item.id
|
|
83
83
|
};
|
|
84
|
-
|
|
84
|
+
const finalStatus = itemProgressCallback(template.itemId, solution_common_1.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor || 2, createdModel.item.id);
|
|
85
85
|
if (!finalStatus) {
|
|
86
86
|
// clean up the site we just created
|
|
87
|
-
|
|
87
|
+
const failSafeRemove = (0, hub_common_1.failSafe)(arcgis_rest_portal_1.removeItem, { success: true });
|
|
88
88
|
return failSafeRemove({
|
|
89
89
|
id: exbModel.item.id,
|
|
90
90
|
authentication: destinationAuthentication
|
|
91
|
-
}).then(
|
|
91
|
+
}).then(() => {
|
|
92
92
|
return Promise.resolve((0, solution_common_1.generateEmptyCreationResponse)(template.type));
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
else {
|
|
96
96
|
// finally, return ICreateItemFromTemplateResponse
|
|
97
|
-
|
|
98
|
-
item:
|
|
97
|
+
const response = {
|
|
98
|
+
item: {
|
|
99
|
+
...template,
|
|
100
|
+
...exbModel
|
|
101
|
+
},
|
|
99
102
|
id: exbModel.item.id,
|
|
100
103
|
type: template.type,
|
|
101
104
|
postProcess: false
|
|
@@ -106,4 +109,18 @@ function createItemFromTemplate(template, templateDictionary, destinationAuthent
|
|
|
106
109
|
});
|
|
107
110
|
}
|
|
108
111
|
exports.createItemFromTemplate = createItemFromTemplate;
|
|
112
|
+
/**
|
|
113
|
+
* Post-Process an Experience
|
|
114
|
+
*
|
|
115
|
+
* @param {string} itemId The item ID
|
|
116
|
+
* @param {string} type The template type
|
|
117
|
+
* @param {any[]} itemInfos Array of {id: 'ef3', type: 'Web Map'} objects
|
|
118
|
+
* @param {any} templateDictionary The template dictionary
|
|
119
|
+
* @param {UserSession} authentication The destination session info
|
|
120
|
+
* @returns Promise resolving to successfulness of update
|
|
121
|
+
*/
|
|
122
|
+
function postProcess(itemId, type, itemInfos, template, templates, templateDictionary, authentication) {
|
|
123
|
+
return (0, solution_common_1.updateItemTemplateFromDictionary)(itemId, templateDictionary, authentication);
|
|
124
|
+
}
|
|
125
|
+
exports.postProcess = postProcess;
|
|
109
126
|
//# 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,2DAS+B;AAC/B,iDAAoD;AACpD,iEAAmE;AACnE,mHAA2G;AAC3G,2EAAsE;AACtE,qGAA8F;AAE9F;;;;;;;;GAQG;AACH,SAAgB,qBAAqB,CACnC,cAAsB,EACtB,QAAa,EACb,kBAA+B,EAC/B,iBAA8B;IAE9B,oCAAoC;IACpC,MAAM,KAAK,GAAG;QACZ,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,EAAE;KACC,CAAC;IACZ,sBAAsB;IACtB,OAAO,IAAA,gCAAW,EAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,cAAc,EAAE,iBAAiB,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACjF,wBAAwB;QACxB,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;QAClB,oCAAoC;QACpC,OAAO,IAAA,mEAA8B,EAAC,KAAK,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC;AAlBD,sDAkBC;AAED;;;;;;;GAOG;AACH,SAAgB,sBAAsB,CACpC,QAAuB,EACvB,kBAAuB,EACvB,yBAAsC,EACtC,oBAA2C;IAE3C,gDAAgD;IAChD,MAAM,WAAW,GAAG,oBAAoB,CACtC,QAAQ,CAAC,MAAM,EACf,qCAAmB,CAAC,OAAO,EAC3B,CAAC,CACF,CAAC;IAEF,6CAA6C;IAC7C,IAAI,CAAC,WAAW,EAAE;QAChB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAA,+CAA6B,EAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;KACtE;IAED,IAAI,QAAgB,CAAC;IACrB,OAAO,IAAA,gFAAoC,EACzC,QAAQ,EACR,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E;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;AA1ED,wDA0EC;AAED;;;;;;;;;GASG;AACH,SAAgB,WAAW,CACzB,MAAc,EACd,IAAY,EACZ,SAAgB,EAChB,QAAuB,EACvB,SAA0B,EAC1B,kBAAuB,EACvB,cAA2B;IAE3B,OAAO,IAAA,kDAAgC,EACrC,MAAM,EACN,kBAAkB,EAClB,cAAc,CACf,CAAC;AACJ,CAAC;AAdD,kCAcC"}
|
|
@@ -18,16 +18,17 @@
|
|
|
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
|
*
|
|
25
25
|
* @param solutionItemId
|
|
26
26
|
* @param itemInfo
|
|
27
|
-
* @param
|
|
27
|
+
* @param destAuthentication Credentials for requests to the destination organization
|
|
28
|
+
* @param srcAuthentication Credentials for requests to source items
|
|
28
29
|
* @param isGroup
|
|
29
30
|
*/
|
|
30
|
-
export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any,
|
|
31
|
+
export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, destAuthentication: UserSession, srcAuthentication: UserSession): Promise<IItemTemplate>;
|
|
31
32
|
/**
|
|
32
33
|
* Create a Web Experience from a Template
|
|
33
34
|
*
|
|
@@ -37,3 +38,14 @@ export declare function convertItemToTemplate(solutionItemId: string, itemInfo:
|
|
|
37
38
|
* @param itemProgressCallback
|
|
38
39
|
*/
|
|
39
40
|
export declare function createItemFromTemplate(template: IItemTemplate, templateDictionary: any, destinationAuthentication: UserSession, itemProgressCallback: IItemProgressCallback): Promise<ICreateItemFromTemplateResponse>;
|
|
41
|
+
/**
|
|
42
|
+
* Post-Process an Experience
|
|
43
|
+
*
|
|
44
|
+
* @param {string} itemId The item ID
|
|
45
|
+
* @param {string} type The template type
|
|
46
|
+
* @param {any[]} itemInfos Array of {id: 'ef3', type: 'Web Map'} objects
|
|
47
|
+
* @param {any} templateDictionary The template dictionary
|
|
48
|
+
* @param {UserSession} authentication The destination session info
|
|
49
|
+
* @returns Promise resolving to successfulness of update
|
|
50
|
+
*/
|
|
51
|
+
export declare function postProcess(itemId: string, type: string, itemInfos: any[], template: IItemTemplate, templates: IItemTemplate[], templateDictionary: any, authentication: UserSession): Promise<IUpdateItemResponse>;
|