@esri/solution-velocity 4.1.2-alpha.0 → 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/get-velocity-dependencies.d.ts +57 -57
- package/dist/cjs/helpers/get-velocity-dependencies.js +119 -119
- package/dist/cjs/helpers/velocity-helpers.d.ts +244 -244
- package/dist/cjs/helpers/velocity-helpers.js +571 -571
- package/dist/cjs/helpers/velocity-templatize.d.ts +71 -71
- package/dist/cjs/helpers/velocity-templatize.js +113 -113
- package/dist/cjs/index.d.ts +17 -17
- package/dist/cjs/index.js +21 -21
- package/dist/cjs/velocity-processor.d.ts +61 -61
- package/dist/cjs/velocity-processor.js +135 -135
- package/dist/esm/helpers/get-velocity-dependencies.d.ts +57 -57
- package/dist/esm/helpers/get-velocity-dependencies.js +112 -112
- package/dist/esm/helpers/velocity-helpers.d.ts +244 -244
- package/dist/esm/helpers/velocity-helpers.js +549 -549
- package/dist/esm/helpers/velocity-templatize.d.ts +71 -71
- package/dist/esm/helpers/velocity-templatize.js +105 -105
- package/dist/esm/index.d.ts +17 -17
- package/dist/esm/index.js +17 -17
- package/dist/esm/velocity-processor.d.ts +61 -61
- package/dist/esm/velocity-processor.js +129 -129
- package/package.json +4 -4
|
@@ -1,130 +1,130 @@
|
|
|
1
|
-
/** @license
|
|
2
|
-
* Copyright 2021 Esri
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
/**
|
|
17
|
-
* Manages the creation and deployment of velocity item types.
|
|
18
|
-
*
|
|
19
|
-
* @module velocity
|
|
20
|
-
*/
|
|
21
|
-
import { EItemProgressStatus, generateEmptyCreationResponse, createInitializedItemTemplate, fail, removeItem, updateVelocityReferences, updateItem } from "@esri/solution-common";
|
|
22
|
-
import { templatizeVelocity } from "./helpers/velocity-templatize";
|
|
23
|
-
import { getVelocityDependencies } from "./helpers/get-velocity-dependencies";
|
|
24
|
-
import { cleanDataSourcesAndFeeds, getVelocityUrl, postVelocityData } from "./helpers/velocity-helpers";
|
|
25
|
-
import { moveItem } from "@esri/arcgis-rest-portal";
|
|
26
|
-
/**
|
|
27
|
-
* Convert a Velocity item into a Template
|
|
28
|
-
*
|
|
29
|
-
* @param solutionItemId The solution to contain the item
|
|
30
|
-
* @param itemInfo The basic item info
|
|
31
|
-
* @param destAuthentication Credentials for requests to the destination organization
|
|
32
|
-
* @param srcAuthentication Credentials for requests to source items
|
|
33
|
-
* @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
|
|
34
|
-
*
|
|
35
|
-
* @returns a promise that will resolve the constructed IItemTemplate from the input itemInfo
|
|
36
|
-
*
|
|
37
|
-
*/
|
|
38
|
-
export function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary) {
|
|
39
|
-
const template = createInitializedItemTemplate(itemInfo);
|
|
40
|
-
return getVelocityUrl(srcAuthentication, templateDictionary, itemInfo.type, itemInfo.id).then((url) => {
|
|
41
|
-
if (url) {
|
|
42
|
-
return fetch(url)
|
|
43
|
-
.then(data => data.json())
|
|
44
|
-
.then(data_json => {
|
|
45
|
-
template.item.title = data_json.label;
|
|
46
|
-
template.data = data_json;
|
|
47
|
-
return getVelocityDependencies(template, srcAuthentication).then(deps => {
|
|
48
|
-
template.dependencies = deps;
|
|
49
|
-
cleanDataSourcesAndFeeds(template, templateDictionary.velocityUrl);
|
|
50
|
-
templatizeVelocity(template);
|
|
51
|
-
template.item = updateVelocityReferences(template.item, template.type, templateDictionary);
|
|
52
|
-
return Promise.resolve(template);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
// In case the org used to have velocity and they still have items
|
|
58
|
-
return Promise.reject("Velocity NOT Supported by Organization");
|
|
59
|
-
}
|
|
60
|
-
}, e => Promise.reject(fail(e)));
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Create Velocity analytics and feeds from a Template
|
|
64
|
-
*
|
|
65
|
-
* @param template The template for the volocity items
|
|
66
|
-
* @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
|
|
67
|
-
* @param destinationAuthentication Credentials for the deployment requests
|
|
68
|
-
* @param itemProgressCallback Function for reporting progress updates from type-specific template handlers
|
|
69
|
-
*
|
|
70
|
-
* @returns a promise that will resolve with the new item info, id, type, and postProcess flag
|
|
71
|
-
*
|
|
72
|
-
*/
|
|
73
|
-
export function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
|
|
74
|
-
// let the progress system know we've started...
|
|
75
|
-
const startStatus = itemProgressCallback(template.itemId, EItemProgressStatus.Started, 0);
|
|
76
|
-
// and if it returned false, just resolve out
|
|
77
|
-
/* istanbul ignore else */
|
|
78
|
-
if (!startStatus) {
|
|
79
|
-
return Promise.resolve(generateEmptyCreationResponse(template.type));
|
|
80
|
-
}
|
|
81
|
-
const orgId = template.itemId;
|
|
82
|
-
return postVelocityData(destinationAuthentication, template, template.data, templateDictionary).then(result => {
|
|
83
|
-
const finalStatus = itemProgressCallback(orgId, EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor || 2, result.id);
|
|
84
|
-
if (!finalStatus) {
|
|
85
|
-
return removeItem(result.id, destinationAuthentication).then(() => Promise.resolve(generateEmptyCreationResponse(template.type)), () => Promise.resolve(generateEmptyCreationResponse(template.type)));
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
const response = {
|
|
89
|
-
item: {
|
|
90
|
-
...template,
|
|
91
|
-
...result
|
|
92
|
-
},
|
|
93
|
-
id: result.item.id,
|
|
94
|
-
type: template.type,
|
|
95
|
-
postProcess: true
|
|
96
|
-
};
|
|
97
|
-
response.item.itemId = result.item.id;
|
|
98
|
-
return response;
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Velocity post-processing actions
|
|
104
|
-
*
|
|
105
|
-
* Move all velocity items to the deployment folder.
|
|
106
|
-
*
|
|
107
|
-
* @param {string} itemId The item ID
|
|
108
|
-
* @param {string} type The template type
|
|
109
|
-
* @param {any[]} itemInfos Array of \{id: 'ef3', type: 'Web Map'\} objects
|
|
110
|
-
* @param {IItemTemplate} template The item template
|
|
111
|
-
* @param {IItemTemplate[]} templates The full collection of item templates
|
|
112
|
-
* @param {any} templateDictionary Hash of facts such as the folder id for the deployment
|
|
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
|
-
const itemUpdate = itemInfos.filter(ii => ii.id === itemId);
|
|
118
|
-
const item = itemUpdate[0].item.item;
|
|
119
|
-
delete item.url;
|
|
120
|
-
delete item.origUrl;
|
|
121
|
-
return updateItem(item, authentication).then(() => {
|
|
122
|
-
return moveItem({
|
|
123
|
-
owner: authentication.username,
|
|
124
|
-
itemId,
|
|
125
|
-
folderId: templateDictionary.folderId,
|
|
126
|
-
authentication
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
}
|
|
1
|
+
/** @license
|
|
2
|
+
* Copyright 2021 Esri
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Manages the creation and deployment of velocity item types.
|
|
18
|
+
*
|
|
19
|
+
* @module velocity
|
|
20
|
+
*/
|
|
21
|
+
import { EItemProgressStatus, generateEmptyCreationResponse, createInitializedItemTemplate, fail, removeItem, updateVelocityReferences, updateItem } from "@esri/solution-common";
|
|
22
|
+
import { templatizeVelocity } from "./helpers/velocity-templatize";
|
|
23
|
+
import { getVelocityDependencies } from "./helpers/get-velocity-dependencies";
|
|
24
|
+
import { cleanDataSourcesAndFeeds, getVelocityUrl, postVelocityData } from "./helpers/velocity-helpers";
|
|
25
|
+
import { moveItem } from "@esri/arcgis-rest-portal";
|
|
26
|
+
/**
|
|
27
|
+
* Convert a Velocity item into a Template
|
|
28
|
+
*
|
|
29
|
+
* @param solutionItemId The solution to contain the item
|
|
30
|
+
* @param itemInfo The basic item info
|
|
31
|
+
* @param destAuthentication Credentials for requests to the destination organization
|
|
32
|
+
* @param srcAuthentication Credentials for requests to source items
|
|
33
|
+
* @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
|
|
34
|
+
*
|
|
35
|
+
* @returns a promise that will resolve the constructed IItemTemplate from the input itemInfo
|
|
36
|
+
*
|
|
37
|
+
*/
|
|
38
|
+
export function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary) {
|
|
39
|
+
const template = createInitializedItemTemplate(itemInfo);
|
|
40
|
+
return getVelocityUrl(srcAuthentication, templateDictionary, itemInfo.type, itemInfo.id).then((url) => {
|
|
41
|
+
if (url) {
|
|
42
|
+
return fetch(url)
|
|
43
|
+
.then(data => data.json())
|
|
44
|
+
.then(data_json => {
|
|
45
|
+
template.item.title = data_json.label;
|
|
46
|
+
template.data = data_json;
|
|
47
|
+
return getVelocityDependencies(template, srcAuthentication).then(deps => {
|
|
48
|
+
template.dependencies = deps;
|
|
49
|
+
cleanDataSourcesAndFeeds(template, templateDictionary.velocityUrl);
|
|
50
|
+
templatizeVelocity(template);
|
|
51
|
+
template.item = updateVelocityReferences(template.item, template.type, templateDictionary);
|
|
52
|
+
return Promise.resolve(template);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
// In case the org used to have velocity and they still have items
|
|
58
|
+
return Promise.reject("Velocity NOT Supported by Organization");
|
|
59
|
+
}
|
|
60
|
+
}, e => Promise.reject(fail(e)));
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Create Velocity analytics and feeds from a Template
|
|
64
|
+
*
|
|
65
|
+
* @param template The template for the volocity items
|
|
66
|
+
* @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
|
|
67
|
+
* @param destinationAuthentication Credentials for the deployment requests
|
|
68
|
+
* @param itemProgressCallback Function for reporting progress updates from type-specific template handlers
|
|
69
|
+
*
|
|
70
|
+
* @returns a promise that will resolve with the new item info, id, type, and postProcess flag
|
|
71
|
+
*
|
|
72
|
+
*/
|
|
73
|
+
export function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
|
|
74
|
+
// let the progress system know we've started...
|
|
75
|
+
const startStatus = itemProgressCallback(template.itemId, EItemProgressStatus.Started, 0);
|
|
76
|
+
// and if it returned false, just resolve out
|
|
77
|
+
/* istanbul ignore else */
|
|
78
|
+
if (!startStatus) {
|
|
79
|
+
return Promise.resolve(generateEmptyCreationResponse(template.type));
|
|
80
|
+
}
|
|
81
|
+
const orgId = template.itemId;
|
|
82
|
+
return postVelocityData(destinationAuthentication, template, template.data, templateDictionary).then(result => {
|
|
83
|
+
const finalStatus = itemProgressCallback(orgId, EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor || 2, result.id);
|
|
84
|
+
if (!finalStatus) {
|
|
85
|
+
return removeItem(result.id, destinationAuthentication).then(() => Promise.resolve(generateEmptyCreationResponse(template.type)), () => Promise.resolve(generateEmptyCreationResponse(template.type)));
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
const response = {
|
|
89
|
+
item: {
|
|
90
|
+
...template,
|
|
91
|
+
...result
|
|
92
|
+
},
|
|
93
|
+
id: result.item.id,
|
|
94
|
+
type: template.type,
|
|
95
|
+
postProcess: true
|
|
96
|
+
};
|
|
97
|
+
response.item.itemId = result.item.id;
|
|
98
|
+
return response;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Velocity post-processing actions
|
|
104
|
+
*
|
|
105
|
+
* Move all velocity items to the deployment folder.
|
|
106
|
+
*
|
|
107
|
+
* @param {string} itemId The item ID
|
|
108
|
+
* @param {string} type The template type
|
|
109
|
+
* @param {any[]} itemInfos Array of \{id: 'ef3', type: 'Web Map'\} objects
|
|
110
|
+
* @param {IItemTemplate} template The item template
|
|
111
|
+
* @param {IItemTemplate[]} templates The full collection of item templates
|
|
112
|
+
* @param {any} templateDictionary Hash of facts such as the folder id for the deployment
|
|
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
|
+
const itemUpdate = itemInfos.filter(ii => ii.id === itemId);
|
|
118
|
+
const item = itemUpdate[0].item.item;
|
|
119
|
+
delete item.url;
|
|
120
|
+
delete item.origUrl;
|
|
121
|
+
return updateItem(item, authentication).then(() => {
|
|
122
|
+
return moveItem({
|
|
123
|
+
owner: authentication.username,
|
|
124
|
+
itemId,
|
|
125
|
+
folderId: templateDictionary.folderId,
|
|
126
|
+
authentication
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
130
|
//# sourceMappingURL=velocity-processor.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esri/solution-velocity",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Manages the creation and deployment of Velocity item types for @esri/solution.js.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"@esri/hub-initiatives": "^13.0.0",
|
|
28
28
|
"@esri/hub-sites": "^13.0.1",
|
|
29
29
|
"@esri/hub-teams": "^13.0.0",
|
|
30
|
-
"@esri/solution-common": "^
|
|
31
|
-
"@esri/solution-simple-types": "^
|
|
30
|
+
"@esri/solution-common": "^5.0.0",
|
|
31
|
+
"@esri/solution-simple-types": "^5.0.0",
|
|
32
32
|
"rollup": "2.79.1"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"esri",
|
|
80
80
|
"ES6"
|
|
81
81
|
],
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "a6cbcc049fb712d19e98b7d59a94734aad4dd17f"
|
|
83
83
|
}
|