@esri/solution-web-experience 4.1.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/helpers/convert-web-experience-to-template.d.ts +27 -27
- package/dist/cjs/helpers/convert-web-experience-to-template.js +66 -66
- package/dist/cjs/helpers/create-web-experience-model-from-template.d.ts +26 -26
- package/dist/cjs/helpers/create-web-experience-model-from-template.js +41 -41
- package/dist/cjs/helpers/create-web-experience.d.ts +25 -25
- package/dist/cjs/helpers/create-web-experience.js +121 -121
- package/dist/cjs/helpers/get-experience-subdomain.d.ts +23 -23
- package/dist/cjs/helpers/get-experience-subdomain.js +25 -25
- package/dist/cjs/helpers/get-web-experience-dependencies.d.ts +23 -23
- package/dist/cjs/helpers/get-web-experience-dependencies.js +32 -32
- package/dist/cjs/helpers/get-web-experience-url-template.d.ts +23 -23
- package/dist/cjs/helpers/get-web-experience-url-template.js +25 -25
- package/dist/cjs/index.d.ts +17 -17
- package/dist/cjs/index.js +21 -21
- package/dist/cjs/web-experience-processor.d.ts +51 -51
- package/dist/cjs/web-experience-processor.js +125 -125
- package/dist/esm/helpers/convert-web-experience-to-template.d.ts +27 -27
- package/dist/esm/helpers/convert-web-experience-to-template.js +62 -62
- package/dist/esm/helpers/create-web-experience-model-from-template.d.ts +26 -26
- package/dist/esm/helpers/create-web-experience-model-from-template.js +37 -37
- package/dist/esm/helpers/create-web-experience.d.ts +25 -25
- package/dist/esm/helpers/create-web-experience.js +117 -117
- package/dist/esm/helpers/get-experience-subdomain.d.ts +23 -23
- package/dist/esm/helpers/get-experience-subdomain.js +21 -21
- package/dist/esm/helpers/get-web-experience-dependencies.d.ts +23 -23
- package/dist/esm/helpers/get-web-experience-dependencies.js +28 -28
- package/dist/esm/helpers/get-web-experience-url-template.d.ts +23 -23
- package/dist/esm/helpers/get-web-experience-url-template.js +21 -21
- package/dist/esm/index.d.ts +17 -17
- package/dist/esm/index.js +17 -17
- package/dist/esm/web-experience-processor.d.ts +51 -51
- package/dist/esm/web-experience-processor.js +119 -119
- package/package.json +4 -4
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/** @license
|
|
3
|
-
* Copyright 2018 Esri
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.postProcess = exports.createItemFromTemplate = exports.convertItemToTemplate = void 0;
|
|
19
|
-
/**
|
|
20
|
-
* Manages the creation and deployment of web-experience item types.
|
|
21
|
-
*
|
|
22
|
-
* @module solution-web-experience
|
|
23
|
-
*/
|
|
24
|
-
const solution_common_1 = require("@esri/solution-common");
|
|
25
|
-
const hub_common_1 = require("@esri/hub-common");
|
|
26
|
-
const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
|
|
27
|
-
const 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");
|
|
30
|
-
/**
|
|
31
|
-
* Convert a Web Experience item into a Template
|
|
32
|
-
*
|
|
33
|
-
* @param solutionItemId
|
|
34
|
-
* @param itemInfo
|
|
35
|
-
* @param destAuthentication Credentials for requests to the destination organization
|
|
36
|
-
* @param srcAuthentication Credentials for requests to source items
|
|
37
|
-
* @param isGroup
|
|
38
|
-
*/
|
|
39
|
-
function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication) {
|
|
40
|
-
// use the itemInfo to setup a model
|
|
41
|
-
const model = {
|
|
42
|
-
item: itemInfo,
|
|
43
|
-
data: {}
|
|
44
|
-
};
|
|
45
|
-
// fetch the data.json
|
|
46
|
-
return (0, arcgis_rest_portal_1.getItemData)(itemInfo.id, { authentication: srcAuthentication }).then(data => {
|
|
47
|
-
// append into the model
|
|
48
|
-
model.data = data;
|
|
49
|
-
// and use that to create a template
|
|
50
|
-
return (0, convert_web_experience_to_template_1.convertWebExperienceToTemplate)(model);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
exports.convertItemToTemplate = convertItemToTemplate;
|
|
54
|
-
/**
|
|
55
|
-
* Create a Web Experience from a Template
|
|
56
|
-
*
|
|
57
|
-
* @param template
|
|
58
|
-
* @param templateDictionary
|
|
59
|
-
* @param destinationAuthentication
|
|
60
|
-
* @param itemProgressCallback
|
|
61
|
-
*/
|
|
62
|
-
function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
|
|
63
|
-
// let the progress system know we've started...
|
|
64
|
-
const startStatus = itemProgressCallback(template.itemId, solution_common_1.EItemProgressStatus.Started, 0);
|
|
65
|
-
// and if it returned false, just resolve out
|
|
66
|
-
if (!startStatus) {
|
|
67
|
-
return Promise.resolve((0, solution_common_1.generateEmptyCreationResponse)(template.type));
|
|
68
|
-
}
|
|
69
|
-
let exbModel;
|
|
70
|
-
return (0, create_web_experience_model_from_template_1.createWebExperienceModelFromTemplate)(template, templateDictionary, {}, destinationAuthentication)
|
|
71
|
-
.then(model => {
|
|
72
|
-
exbModel = model;
|
|
73
|
-
return (0, create_web_experience_1.createWebExperience)(model, templateDictionary.folderId, {}, destinationAuthentication);
|
|
74
|
-
})
|
|
75
|
-
.then(createdModel => {
|
|
76
|
-
exbModel.item.id = createdModel.item.id;
|
|
77
|
-
exbModel.item.url = createdModel.item.url;
|
|
78
|
-
// Update the template dictionary
|
|
79
|
-
// TODO: This should be done in whatever recieves
|
|
80
|
-
// the outcome of this promise chain
|
|
81
|
-
templateDictionary[template.itemId] = {
|
|
82
|
-
itemId: createdModel.item.id
|
|
83
|
-
};
|
|
84
|
-
const finalStatus = itemProgressCallback(template.itemId, solution_common_1.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor || 2, createdModel.item.id);
|
|
85
|
-
if (!finalStatus) {
|
|
86
|
-
// clean up the site we just created
|
|
87
|
-
const failSafeRemove = (0, hub_common_1.failSafe)(arcgis_rest_portal_1.removeItem, { success: true });
|
|
88
|
-
return failSafeRemove({
|
|
89
|
-
id: exbModel.item.id,
|
|
90
|
-
authentication: destinationAuthentication
|
|
91
|
-
}).then(() => {
|
|
92
|
-
return Promise.resolve((0, solution_common_1.generateEmptyCreationResponse)(template.type));
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
// finally, return ICreateItemFromTemplateResponse
|
|
97
|
-
const response = {
|
|
98
|
-
item: {
|
|
99
|
-
...template,
|
|
100
|
-
...(0, solution_common_1.convertIModel)(exbModel)
|
|
101
|
-
},
|
|
102
|
-
id: exbModel.item.id,
|
|
103
|
-
type: template.type,
|
|
104
|
-
postProcess: false
|
|
105
|
-
};
|
|
106
|
-
response.item.itemId = exbModel.item.id;
|
|
107
|
-
return response;
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
}
|
|
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;
|
|
1
|
+
"use strict";
|
|
2
|
+
/** @license
|
|
3
|
+
* Copyright 2018 Esri
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.postProcess = exports.createItemFromTemplate = exports.convertItemToTemplate = void 0;
|
|
19
|
+
/**
|
|
20
|
+
* Manages the creation and deployment of web-experience item types.
|
|
21
|
+
*
|
|
22
|
+
* @module solution-web-experience
|
|
23
|
+
*/
|
|
24
|
+
const solution_common_1 = require("@esri/solution-common");
|
|
25
|
+
const hub_common_1 = require("@esri/hub-common");
|
|
26
|
+
const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
|
|
27
|
+
const 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");
|
|
30
|
+
/**
|
|
31
|
+
* Convert a Web Experience item into a Template
|
|
32
|
+
*
|
|
33
|
+
* @param solutionItemId
|
|
34
|
+
* @param itemInfo
|
|
35
|
+
* @param destAuthentication Credentials for requests to the destination organization
|
|
36
|
+
* @param srcAuthentication Credentials for requests to source items
|
|
37
|
+
* @param isGroup
|
|
38
|
+
*/
|
|
39
|
+
function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication) {
|
|
40
|
+
// use the itemInfo to setup a model
|
|
41
|
+
const model = {
|
|
42
|
+
item: itemInfo,
|
|
43
|
+
data: {}
|
|
44
|
+
};
|
|
45
|
+
// fetch the data.json
|
|
46
|
+
return (0, arcgis_rest_portal_1.getItemData)(itemInfo.id, { authentication: srcAuthentication }).then(data => {
|
|
47
|
+
// append into the model
|
|
48
|
+
model.data = data;
|
|
49
|
+
// and use that to create a template
|
|
50
|
+
return (0, convert_web_experience_to_template_1.convertWebExperienceToTemplate)(model);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
exports.convertItemToTemplate = convertItemToTemplate;
|
|
54
|
+
/**
|
|
55
|
+
* Create a Web Experience from a Template
|
|
56
|
+
*
|
|
57
|
+
* @param template
|
|
58
|
+
* @param templateDictionary
|
|
59
|
+
* @param destinationAuthentication
|
|
60
|
+
* @param itemProgressCallback
|
|
61
|
+
*/
|
|
62
|
+
function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
|
|
63
|
+
// let the progress system know we've started...
|
|
64
|
+
const startStatus = itemProgressCallback(template.itemId, solution_common_1.EItemProgressStatus.Started, 0);
|
|
65
|
+
// and if it returned false, just resolve out
|
|
66
|
+
if (!startStatus) {
|
|
67
|
+
return Promise.resolve((0, solution_common_1.generateEmptyCreationResponse)(template.type));
|
|
68
|
+
}
|
|
69
|
+
let exbModel;
|
|
70
|
+
return (0, create_web_experience_model_from_template_1.createWebExperienceModelFromTemplate)(template, templateDictionary, {}, destinationAuthentication)
|
|
71
|
+
.then(model => {
|
|
72
|
+
exbModel = model;
|
|
73
|
+
return (0, create_web_experience_1.createWebExperience)(model, templateDictionary.folderId, {}, destinationAuthentication);
|
|
74
|
+
})
|
|
75
|
+
.then(createdModel => {
|
|
76
|
+
exbModel.item.id = createdModel.item.id;
|
|
77
|
+
exbModel.item.url = createdModel.item.url;
|
|
78
|
+
// Update the template dictionary
|
|
79
|
+
// TODO: This should be done in whatever recieves
|
|
80
|
+
// the outcome of this promise chain
|
|
81
|
+
templateDictionary[template.itemId] = {
|
|
82
|
+
itemId: createdModel.item.id
|
|
83
|
+
};
|
|
84
|
+
const finalStatus = itemProgressCallback(template.itemId, solution_common_1.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor || 2, createdModel.item.id);
|
|
85
|
+
if (!finalStatus) {
|
|
86
|
+
// clean up the site we just created
|
|
87
|
+
const failSafeRemove = (0, hub_common_1.failSafe)(arcgis_rest_portal_1.removeItem, { success: true });
|
|
88
|
+
return failSafeRemove({
|
|
89
|
+
id: exbModel.item.id,
|
|
90
|
+
authentication: destinationAuthentication
|
|
91
|
+
}).then(() => {
|
|
92
|
+
return Promise.resolve((0, solution_common_1.generateEmptyCreationResponse)(template.type));
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
// finally, return ICreateItemFromTemplateResponse
|
|
97
|
+
const response = {
|
|
98
|
+
item: {
|
|
99
|
+
...template,
|
|
100
|
+
...(0, solution_common_1.convertIModel)(exbModel)
|
|
101
|
+
},
|
|
102
|
+
id: exbModel.item.id,
|
|
103
|
+
type: template.type,
|
|
104
|
+
postProcess: false
|
|
105
|
+
};
|
|
106
|
+
response.item.itemId = exbModel.item.id;
|
|
107
|
+
return response;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
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;
|
|
126
126
|
//# sourceMappingURL=web-experience-processor.js.map
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
/** @license
|
|
2
|
-
* Copyright 2020 Esri
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { IModel } from "@esri/hub-common";
|
|
17
|
-
import { IItemTemplate } from "@esri/solution-common";
|
|
18
|
-
/**
|
|
19
|
-
* Convert an Experience item into a template
|
|
20
|
-
*
|
|
21
|
-
* Pretty simpler conversion - remove extra item props, extract out
|
|
22
|
-
* items from the data.dataSources hash.
|
|
23
|
-
*
|
|
24
|
-
* @param model
|
|
25
|
-
* @param authentication
|
|
26
|
-
*/
|
|
27
|
-
export declare function convertWebExperienceToTemplate(model: IModel): Promise<IItemTemplate>;
|
|
1
|
+
/** @license
|
|
2
|
+
* Copyright 2020 Esri
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { IModel } from "@esri/hub-common";
|
|
17
|
+
import { IItemTemplate } from "@esri/solution-common";
|
|
18
|
+
/**
|
|
19
|
+
* Convert an Experience item into a template
|
|
20
|
+
*
|
|
21
|
+
* Pretty simpler conversion - remove extra item props, extract out
|
|
22
|
+
* items from the data.dataSources hash.
|
|
23
|
+
*
|
|
24
|
+
* @param model
|
|
25
|
+
* @param authentication
|
|
26
|
+
*/
|
|
27
|
+
export declare function convertWebExperienceToTemplate(model: IModel): Promise<IItemTemplate>;
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
/** @license
|
|
2
|
-
* Copyright 2020 Esri
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { normalizeSolutionTemplateItem, cloneObject, propifyString, createId } from "@esri/hub-common";
|
|
17
|
-
import { createPlaceholderTemplate } from "@esri/solution-common";
|
|
18
|
-
import { getWebExperienceDependencies } from "./get-web-experience-dependencies";
|
|
19
|
-
/**
|
|
20
|
-
* Convert an Experience item into a template
|
|
21
|
-
*
|
|
22
|
-
* Pretty simpler conversion - remove extra item props, extract out
|
|
23
|
-
* items from the data.dataSources hash.
|
|
24
|
-
*
|
|
25
|
-
* @param model
|
|
26
|
-
* @param authentication
|
|
27
|
-
*/
|
|
28
|
-
export function convertWebExperienceToTemplate(model) {
|
|
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
|
-
tmpl.data = clone.data;
|
|
33
|
-
// We need to save these properties in order to restore them after hub.js deletes them
|
|
34
|
-
const created = clone.item.created;
|
|
35
|
-
const modified = clone.item.modified;
|
|
36
|
-
tmpl.item = normalizeSolutionTemplateItem(clone.item);
|
|
37
|
-
tmpl.item.created = created;
|
|
38
|
-
tmpl.item.modified = modified;
|
|
39
|
-
// templatize the url. This is updated during the createModelFromTemplate phase
|
|
40
|
-
// of the deployment process
|
|
41
|
-
tmpl.item.url = "{{experienceUrlTemplate}}";
|
|
42
|
-
// use typeKeyword to mark item as published (we decided to discard unpublished drafts)
|
|
43
|
-
const typeKeywords = tmpl.item.typeKeywords;
|
|
44
|
-
if (typeKeywords.indexOf(changedTypeKW) !== -1) {
|
|
45
|
-
tmpl.item.typeKeywords = [publishedTypeKW].concat(tmpl.item.typeKeywords.filter(word => word !== changedTypeKW));
|
|
46
|
-
}
|
|
47
|
-
tmpl.dependencies = getWebExperienceDependencies(model);
|
|
48
|
-
return Promise.resolve(tmpl);
|
|
49
|
-
// TODO: For now, we let the generic process handle item resources
|
|
50
|
-
// However, many newer item types have complex type-specific resource handling
|
|
51
|
-
// requirements so this code may be useful in the future
|
|
52
|
-
// ------------------------------------------------------
|
|
53
|
-
// return getItemResources(tmpl.itemId, authentication)
|
|
54
|
-
// .then((response) => {
|
|
55
|
-
// tmpl.resources = response.resources.map(e => e.resource)
|
|
56
|
-
// // Discard draft version
|
|
57
|
-
// .filter(filename => filename !== 'config.json');
|
|
58
|
-
// return tmpl;
|
|
59
|
-
// });
|
|
60
|
-
}
|
|
61
|
-
const publishedTypeKW = "status: Published";
|
|
62
|
-
const changedTypeKW = "status: Changed";
|
|
1
|
+
/** @license
|
|
2
|
+
* Copyright 2020 Esri
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { normalizeSolutionTemplateItem, cloneObject, propifyString, createId } from "@esri/hub-common";
|
|
17
|
+
import { createPlaceholderTemplate } from "@esri/solution-common";
|
|
18
|
+
import { getWebExperienceDependencies } from "./get-web-experience-dependencies";
|
|
19
|
+
/**
|
|
20
|
+
* Convert an Experience item into a template
|
|
21
|
+
*
|
|
22
|
+
* Pretty simpler conversion - remove extra item props, extract out
|
|
23
|
+
* items from the data.dataSources hash.
|
|
24
|
+
*
|
|
25
|
+
* @param model
|
|
26
|
+
* @param authentication
|
|
27
|
+
*/
|
|
28
|
+
export function convertWebExperienceToTemplate(model) {
|
|
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
|
+
tmpl.data = clone.data;
|
|
33
|
+
// We need to save these properties in order to restore them after hub.js deletes them
|
|
34
|
+
const created = clone.item.created;
|
|
35
|
+
const modified = clone.item.modified;
|
|
36
|
+
tmpl.item = normalizeSolutionTemplateItem(clone.item);
|
|
37
|
+
tmpl.item.created = created;
|
|
38
|
+
tmpl.item.modified = modified;
|
|
39
|
+
// templatize the url. This is updated during the createModelFromTemplate phase
|
|
40
|
+
// of the deployment process
|
|
41
|
+
tmpl.item.url = "{{experienceUrlTemplate}}";
|
|
42
|
+
// use typeKeyword to mark item as published (we decided to discard unpublished drafts)
|
|
43
|
+
const typeKeywords = tmpl.item.typeKeywords;
|
|
44
|
+
if (typeKeywords.indexOf(changedTypeKW) !== -1) {
|
|
45
|
+
tmpl.item.typeKeywords = [publishedTypeKW].concat(tmpl.item.typeKeywords.filter(word => word !== changedTypeKW));
|
|
46
|
+
}
|
|
47
|
+
tmpl.dependencies = getWebExperienceDependencies(model);
|
|
48
|
+
return Promise.resolve(tmpl);
|
|
49
|
+
// TODO: For now, we let the generic process handle item resources
|
|
50
|
+
// However, many newer item types have complex type-specific resource handling
|
|
51
|
+
// requirements so this code may be useful in the future
|
|
52
|
+
// ------------------------------------------------------
|
|
53
|
+
// return getItemResources(tmpl.itemId, authentication)
|
|
54
|
+
// .then((response) => {
|
|
55
|
+
// tmpl.resources = response.resources.map(e => e.resource)
|
|
56
|
+
// // Discard draft version
|
|
57
|
+
// .filter(filename => filename !== 'config.json');
|
|
58
|
+
// return tmpl;
|
|
59
|
+
// });
|
|
60
|
+
}
|
|
61
|
+
const publishedTypeKW = "status: Published";
|
|
62
|
+
const changedTypeKW = "status: Changed";
|
|
63
63
|
//# sourceMappingURL=convert-web-experience-to-template.js.map
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
/** @license
|
|
2
|
-
* Copyright 2020 Esri
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { IModelTemplate } from "@esri/hub-common";
|
|
17
|
-
import { UserSession } from "@esri/solution-common";
|
|
18
|
-
/**
|
|
19
|
-
* Convert a Web Experience template into a Model that can be persisted to the Portal API
|
|
20
|
-
*
|
|
21
|
-
* @param templateModel Template
|
|
22
|
-
* @param settings Hash of values to interpolate into the template
|
|
23
|
-
* @param transforms Hash of transform functions to use in the interpolation
|
|
24
|
-
* @param authentication UserSession
|
|
25
|
-
*/
|
|
26
|
-
export declare function createWebExperienceModelFromTemplate(templateModel: IModelTemplate, settings: any, transforms: any, authentication: UserSession): Promise<any>;
|
|
1
|
+
/** @license
|
|
2
|
+
* Copyright 2020 Esri
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { IModelTemplate } from "@esri/hub-common";
|
|
17
|
+
import { UserSession } from "@esri/solution-common";
|
|
18
|
+
/**
|
|
19
|
+
* Convert a Web Experience template into a Model that can be persisted to the Portal API
|
|
20
|
+
*
|
|
21
|
+
* @param templateModel Template
|
|
22
|
+
* @param settings Hash of values to interpolate into the template
|
|
23
|
+
* @param transforms Hash of transform functions to use in the interpolation
|
|
24
|
+
* @param authentication UserSession
|
|
25
|
+
*/
|
|
26
|
+
export declare function createWebExperienceModelFromTemplate(templateModel: IModelTemplate, settings: any, transforms: any, authentication: UserSession): Promise<any>;
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
/** @license
|
|
2
|
-
* Copyright 2020 Esri
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { interpolate } from "@esri/hub-common";
|
|
17
|
-
import { getWebExperiencepUrlTemplate } from "./get-web-experience-url-template";
|
|
18
|
-
/**
|
|
19
|
-
* Convert a Web Experience template into a Model that can be persisted to the Portal API
|
|
20
|
-
*
|
|
21
|
-
* @param templateModel Template
|
|
22
|
-
* @param settings Hash of values to interpolate into the template
|
|
23
|
-
* @param transforms Hash of transform functions to use in the interpolation
|
|
24
|
-
* @param authentication UserSession
|
|
25
|
-
*/
|
|
26
|
-
export function createWebExperienceModelFromTemplate(templateModel, settings, transforms, authentication) {
|
|
27
|
-
// get the experience base url
|
|
28
|
-
settings.experienceUrlTemplate = getWebExperiencepUrlTemplate(authentication);
|
|
29
|
-
const model = interpolate(templateModel, settings, transforms);
|
|
30
|
-
// ensure this is set - there may be some templates w/o `{{experienceTemplateUrl}}
|
|
31
|
-
model.item.url = settings.experienceUrlTemplate;
|
|
32
|
-
/* istanbul ignore else */
|
|
33
|
-
if (templateModel.item.thumbnail) {
|
|
34
|
-
model.item.thumbnail = templateModel.item.thumbnail; // interpolation trashes thumbnail binary
|
|
35
|
-
}
|
|
36
|
-
return Promise.resolve(model);
|
|
37
|
-
}
|
|
1
|
+
/** @license
|
|
2
|
+
* Copyright 2020 Esri
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { interpolate } from "@esri/hub-common";
|
|
17
|
+
import { getWebExperiencepUrlTemplate } from "./get-web-experience-url-template";
|
|
18
|
+
/**
|
|
19
|
+
* Convert a Web Experience template into a Model that can be persisted to the Portal API
|
|
20
|
+
*
|
|
21
|
+
* @param templateModel Template
|
|
22
|
+
* @param settings Hash of values to interpolate into the template
|
|
23
|
+
* @param transforms Hash of transform functions to use in the interpolation
|
|
24
|
+
* @param authentication UserSession
|
|
25
|
+
*/
|
|
26
|
+
export function createWebExperienceModelFromTemplate(templateModel, settings, transforms, authentication) {
|
|
27
|
+
// get the experience base url
|
|
28
|
+
settings.experienceUrlTemplate = getWebExperiencepUrlTemplate(authentication);
|
|
29
|
+
const model = interpolate(templateModel, settings, transforms);
|
|
30
|
+
// ensure this is set - there may be some templates w/o `{{experienceTemplateUrl}}
|
|
31
|
+
model.item.url = settings.experienceUrlTemplate;
|
|
32
|
+
/* istanbul ignore else */
|
|
33
|
+
if (templateModel.item.thumbnail) {
|
|
34
|
+
model.item.thumbnail = templateModel.item.thumbnail; // interpolation trashes thumbnail binary
|
|
35
|
+
}
|
|
36
|
+
return Promise.resolve(model);
|
|
37
|
+
}
|
|
38
38
|
//# sourceMappingURL=create-web-experience-model-from-template.js.map
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/** @license
|
|
2
|
-
* Copyright 2020 Esri
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { IModel } from "@esri/hub-common";
|
|
17
|
-
import { UserSession } from "@esri/solution-common";
|
|
18
|
-
/**
|
|
19
|
-
* Given a Model for a Web Experience, create the item in the Portal API
|
|
20
|
-
*
|
|
21
|
-
* @param model
|
|
22
|
-
* @param options
|
|
23
|
-
* @param authentication
|
|
24
|
-
*/
|
|
25
|
-
export declare function createWebExperience(model: IModel, folderId: string, options: any, authentication: UserSession): Promise<IModel>;
|
|
1
|
+
/** @license
|
|
2
|
+
* Copyright 2020 Esri
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { IModel } from "@esri/hub-common";
|
|
17
|
+
import { UserSession } from "@esri/solution-common";
|
|
18
|
+
/**
|
|
19
|
+
* Given a Model for a Web Experience, create the item in the Portal API
|
|
20
|
+
*
|
|
21
|
+
* @param model
|
|
22
|
+
* @param options
|
|
23
|
+
* @param authentication
|
|
24
|
+
*/
|
|
25
|
+
export declare function createWebExperience(model: IModel, folderId: string, options: any, authentication: UserSession): Promise<IModel>;
|