@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.
@@ -1,136 +1,136 @@
1
- "use strict";
2
- /** @license
3
- * Copyright 2021 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 velocity item types.
21
- *
22
- * @module velocity
23
- */
24
- const solution_common_1 = require("@esri/solution-common");
25
- const velocity_templatize_1 = require("./helpers/velocity-templatize");
26
- const get_velocity_dependencies_1 = require("./helpers/get-velocity-dependencies");
27
- const velocity_helpers_1 = require("./helpers/velocity-helpers");
28
- const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
29
- /**
30
- * Convert a Velocity item into a Template
31
- *
32
- * @param solutionItemId The solution to contain the item
33
- * @param itemInfo The basic item info
34
- * @param destAuthentication Credentials for requests to the destination organization
35
- * @param srcAuthentication Credentials for requests to source items
36
- * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
37
- *
38
- * @returns a promise that will resolve the constructed IItemTemplate from the input itemInfo
39
- *
40
- */
41
- function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary) {
42
- const template = (0, solution_common_1.createInitializedItemTemplate)(itemInfo);
43
- return (0, velocity_helpers_1.getVelocityUrl)(srcAuthentication, templateDictionary, itemInfo.type, itemInfo.id).then((url) => {
44
- if (url) {
45
- return fetch(url)
46
- .then(data => data.json())
47
- .then(data_json => {
48
- template.item.title = data_json.label;
49
- template.data = data_json;
50
- return (0, get_velocity_dependencies_1.getVelocityDependencies)(template, srcAuthentication).then(deps => {
51
- template.dependencies = deps;
52
- (0, velocity_helpers_1.cleanDataSourcesAndFeeds)(template, templateDictionary.velocityUrl);
53
- (0, velocity_templatize_1.templatizeVelocity)(template);
54
- template.item = (0, solution_common_1.updateVelocityReferences)(template.item, template.type, templateDictionary);
55
- return Promise.resolve(template);
56
- });
57
- });
58
- }
59
- else {
60
- // In case the org used to have velocity and they still have items
61
- return Promise.reject("Velocity NOT Supported by Organization");
62
- }
63
- }, e => Promise.reject((0, solution_common_1.fail)(e)));
64
- }
65
- exports.convertItemToTemplate = convertItemToTemplate;
66
- /**
67
- * Create Velocity analytics and feeds from a Template
68
- *
69
- * @param template The template for the volocity items
70
- * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
71
- * @param destinationAuthentication Credentials for the deployment requests
72
- * @param itemProgressCallback Function for reporting progress updates from type-specific template handlers
73
- *
74
- * @returns a promise that will resolve with the new item info, id, type, and postProcess flag
75
- *
76
- */
77
- function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
78
- // let the progress system know we've started...
79
- const startStatus = itemProgressCallback(template.itemId, solution_common_1.EItemProgressStatus.Started, 0);
80
- // and if it returned false, just resolve out
81
- /* istanbul ignore else */
82
- if (!startStatus) {
83
- return Promise.resolve((0, solution_common_1.generateEmptyCreationResponse)(template.type));
84
- }
85
- const orgId = template.itemId;
86
- return (0, velocity_helpers_1.postVelocityData)(destinationAuthentication, template, template.data, templateDictionary).then(result => {
87
- const finalStatus = itemProgressCallback(orgId, solution_common_1.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor || 2, result.id);
88
- if (!finalStatus) {
89
- return (0, solution_common_1.removeItem)(result.id, destinationAuthentication).then(() => Promise.resolve((0, solution_common_1.generateEmptyCreationResponse)(template.type)), () => Promise.resolve((0, solution_common_1.generateEmptyCreationResponse)(template.type)));
90
- }
91
- else {
92
- const response = {
93
- item: {
94
- ...template,
95
- ...result
96
- },
97
- id: result.item.id,
98
- type: template.type,
99
- postProcess: true
100
- };
101
- response.item.itemId = result.item.id;
102
- return response;
103
- }
104
- });
105
- }
106
- exports.createItemFromTemplate = createItemFromTemplate;
107
- /**
108
- * Velocity post-processing actions
109
- *
110
- * Move all velocity items to the deployment folder.
111
- *
112
- * @param {string} itemId The item ID
113
- * @param {string} type The template type
114
- * @param {any[]} itemInfos Array of \{id: 'ef3', type: 'Web Map'\} objects
115
- * @param {IItemTemplate} template The item template
116
- * @param {IItemTemplate[]} templates The full collection of item templates
117
- * @param {any} templateDictionary Hash of facts such as the folder id for the deployment
118
- * @param {UserSession} authentication The destination session info
119
- * @returns Promise resolving to successfulness of update
120
- */
121
- function postProcess(itemId, type, itemInfos, template, templates, templateDictionary, authentication) {
122
- const itemUpdate = itemInfos.filter(ii => ii.id === itemId);
123
- const item = itemUpdate[0].item.item;
124
- delete item.url;
125
- delete item.origUrl;
126
- return (0, solution_common_1.updateItem)(item, authentication).then(() => {
127
- return (0, arcgis_rest_portal_1.moveItem)({
128
- owner: authentication.username,
129
- itemId,
130
- folderId: templateDictionary.folderId,
131
- authentication
132
- });
133
- });
134
- }
135
- exports.postProcess = postProcess;
1
+ "use strict";
2
+ /** @license
3
+ * Copyright 2021 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 velocity item types.
21
+ *
22
+ * @module velocity
23
+ */
24
+ const solution_common_1 = require("@esri/solution-common");
25
+ const velocity_templatize_1 = require("./helpers/velocity-templatize");
26
+ const get_velocity_dependencies_1 = require("./helpers/get-velocity-dependencies");
27
+ const velocity_helpers_1 = require("./helpers/velocity-helpers");
28
+ const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
29
+ /**
30
+ * Convert a Velocity item into a Template
31
+ *
32
+ * @param solutionItemId The solution to contain the item
33
+ * @param itemInfo The basic item info
34
+ * @param destAuthentication Credentials for requests to the destination organization
35
+ * @param srcAuthentication Credentials for requests to source items
36
+ * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
37
+ *
38
+ * @returns a promise that will resolve the constructed IItemTemplate from the input itemInfo
39
+ *
40
+ */
41
+ function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary) {
42
+ const template = (0, solution_common_1.createInitializedItemTemplate)(itemInfo);
43
+ return (0, velocity_helpers_1.getVelocityUrl)(srcAuthentication, templateDictionary, itemInfo.type, itemInfo.id).then((url) => {
44
+ if (url) {
45
+ return fetch(url)
46
+ .then(data => data.json())
47
+ .then(data_json => {
48
+ template.item.title = data_json.label;
49
+ template.data = data_json;
50
+ return (0, get_velocity_dependencies_1.getVelocityDependencies)(template, srcAuthentication).then(deps => {
51
+ template.dependencies = deps;
52
+ (0, velocity_helpers_1.cleanDataSourcesAndFeeds)(template, templateDictionary.velocityUrl);
53
+ (0, velocity_templatize_1.templatizeVelocity)(template);
54
+ template.item = (0, solution_common_1.updateVelocityReferences)(template.item, template.type, templateDictionary);
55
+ return Promise.resolve(template);
56
+ });
57
+ });
58
+ }
59
+ else {
60
+ // In case the org used to have velocity and they still have items
61
+ return Promise.reject("Velocity NOT Supported by Organization");
62
+ }
63
+ }, e => Promise.reject((0, solution_common_1.fail)(e)));
64
+ }
65
+ exports.convertItemToTemplate = convertItemToTemplate;
66
+ /**
67
+ * Create Velocity analytics and feeds from a Template
68
+ *
69
+ * @param template The template for the volocity items
70
+ * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
71
+ * @param destinationAuthentication Credentials for the deployment requests
72
+ * @param itemProgressCallback Function for reporting progress updates from type-specific template handlers
73
+ *
74
+ * @returns a promise that will resolve with the new item info, id, type, and postProcess flag
75
+ *
76
+ */
77
+ function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
78
+ // let the progress system know we've started...
79
+ const startStatus = itemProgressCallback(template.itemId, solution_common_1.EItemProgressStatus.Started, 0);
80
+ // and if it returned false, just resolve out
81
+ /* istanbul ignore else */
82
+ if (!startStatus) {
83
+ return Promise.resolve((0, solution_common_1.generateEmptyCreationResponse)(template.type));
84
+ }
85
+ const orgId = template.itemId;
86
+ return (0, velocity_helpers_1.postVelocityData)(destinationAuthentication, template, template.data, templateDictionary).then(result => {
87
+ const finalStatus = itemProgressCallback(orgId, solution_common_1.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor || 2, result.id);
88
+ if (!finalStatus) {
89
+ return (0, solution_common_1.removeItem)(result.id, destinationAuthentication).then(() => Promise.resolve((0, solution_common_1.generateEmptyCreationResponse)(template.type)), () => Promise.resolve((0, solution_common_1.generateEmptyCreationResponse)(template.type)));
90
+ }
91
+ else {
92
+ const response = {
93
+ item: {
94
+ ...template,
95
+ ...result
96
+ },
97
+ id: result.item.id,
98
+ type: template.type,
99
+ postProcess: true
100
+ };
101
+ response.item.itemId = result.item.id;
102
+ return response;
103
+ }
104
+ });
105
+ }
106
+ exports.createItemFromTemplate = createItemFromTemplate;
107
+ /**
108
+ * Velocity post-processing actions
109
+ *
110
+ * Move all velocity items to the deployment folder.
111
+ *
112
+ * @param {string} itemId The item ID
113
+ * @param {string} type The template type
114
+ * @param {any[]} itemInfos Array of \{id: 'ef3', type: 'Web Map'\} objects
115
+ * @param {IItemTemplate} template The item template
116
+ * @param {IItemTemplate[]} templates The full collection of item templates
117
+ * @param {any} templateDictionary Hash of facts such as the folder id for the deployment
118
+ * @param {UserSession} authentication The destination session info
119
+ * @returns Promise resolving to successfulness of update
120
+ */
121
+ function postProcess(itemId, type, itemInfos, template, templates, templateDictionary, authentication) {
122
+ const itemUpdate = itemInfos.filter(ii => ii.id === itemId);
123
+ const item = itemUpdate[0].item.item;
124
+ delete item.url;
125
+ delete item.origUrl;
126
+ return (0, solution_common_1.updateItem)(item, authentication).then(() => {
127
+ return (0, arcgis_rest_portal_1.moveItem)({
128
+ owner: authentication.username,
129
+ itemId,
130
+ folderId: templateDictionary.folderId,
131
+ authentication
132
+ });
133
+ });
134
+ }
135
+ exports.postProcess = postProcess;
136
136
  //# sourceMappingURL=velocity-processor.js.map
@@ -1,57 +1,57 @@
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
- import { IItemTemplate, UserSession } from "@esri/solution-common";
17
- /**
18
- * Get the dependencies from the velocity data sources, feeds, and outputs.
19
- * Only dependencies that do NOT have the typeKeyword "IoTFeatureLayer" are returned.
20
- *
21
- * @param template The template that for the velocity item
22
- * @param authentication The credentials for any requests
23
- *
24
- * @returns a list of dependency ids
25
- */
26
- export declare function getVelocityDependencies(template: IItemTemplate, authentication: UserSession): Promise<string[]>;
27
- /**
28
- * Any feature services with the typeKeyword "IoTFeatureLayer" should not be templatized or
29
- * listed as a dependency.
30
- * We can’t create Velocity feature layers in their spatiotemporal datastore as we have no api.
31
- *
32
- * @param dependencies Any dependencies that have been found for this item
33
- * @param authentication The credentials for any requests
34
- *
35
- * @returns a list of dependency ids
36
- * @private
37
- */
38
- export declare function _validateDependencies(dependencies: string[], authentication: UserSession): Promise<string[]>;
39
- /**
40
- * Get the dependencies from the velocity feeds
41
- * This function will update the input dependencies argument
42
- *
43
- * @param feeds The list of feeds from the velocity template
44
- * @param dependencies The current list of dependencies
45
- * @private
46
- */
47
- export declare function _getFeedDependencies(feeds: any[], dependencies: string[]): void;
48
- /**
49
- * Get the dependencies from the velocity outputs or dataSources.
50
- * This function will update the input dependencies argument
51
- *
52
- * @param outputs The list of outputs from the velocity item
53
- * @param dependencies The current list of dependencies
54
- * @param prop The individual prop to evaluate
55
- * @private
56
- */
57
- export declare function _getDependencies(outputs: any[], dependencies: string[]): void;
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
+ import { IItemTemplate, UserSession } from "@esri/solution-common";
17
+ /**
18
+ * Get the dependencies from the velocity data sources, feeds, and outputs.
19
+ * Only dependencies that do NOT have the typeKeyword "IoTFeatureLayer" are returned.
20
+ *
21
+ * @param template The template that for the velocity item
22
+ * @param authentication The credentials for any requests
23
+ *
24
+ * @returns a list of dependency ids
25
+ */
26
+ export declare function getVelocityDependencies(template: IItemTemplate, authentication: UserSession): Promise<string[]>;
27
+ /**
28
+ * Any feature services with the typeKeyword "IoTFeatureLayer" should not be templatized or
29
+ * listed as a dependency.
30
+ * We can’t create Velocity feature layers in their spatiotemporal datastore as we have no api.
31
+ *
32
+ * @param dependencies Any dependencies that have been found for this item
33
+ * @param authentication The credentials for any requests
34
+ *
35
+ * @returns a list of dependency ids
36
+ * @private
37
+ */
38
+ export declare function _validateDependencies(dependencies: string[], authentication: UserSession): Promise<string[]>;
39
+ /**
40
+ * Get the dependencies from the velocity feeds
41
+ * This function will update the input dependencies argument
42
+ *
43
+ * @param feeds The list of feeds from the velocity template
44
+ * @param dependencies The current list of dependencies
45
+ * @private
46
+ */
47
+ export declare function _getFeedDependencies(feeds: any[], dependencies: string[]): void;
48
+ /**
49
+ * Get the dependencies from the velocity outputs or dataSources.
50
+ * This function will update the input dependencies argument
51
+ *
52
+ * @param outputs The list of outputs from the velocity item
53
+ * @param dependencies The current list of dependencies
54
+ * @param prop The individual prop to evaluate
55
+ * @private
56
+ */
57
+ export declare function _getDependencies(outputs: any[], dependencies: string[]): void;
@@ -1,113 +1,113 @@
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
- import { getProp, getItemBase, BASE_NAMES, PROP_NAMES } from "@esri/solution-common";
17
- /**
18
- * Get the dependencies from the velocity data sources, feeds, and outputs.
19
- * Only dependencies that do NOT have the typeKeyword "IoTFeatureLayer" are returned.
20
- *
21
- * @param template The template that for the velocity item
22
- * @param authentication The credentials for any requests
23
- *
24
- * @returns a list of dependency ids
25
- */
26
- export function getVelocityDependencies(template, authentication) {
27
- const dependencies = [];
28
- [
29
- getProp(template, "data.feeds") ? template.data.feeds : [],
30
- getProp(template, "data.feed") ? [template.data.feed] : []
31
- ].forEach(f => _getFeedDependencies(f, dependencies));
32
- [
33
- getProp(template, "data.sources") ? template.data.sources : [],
34
- getProp(template, "data.source") ? [template.data.source] : [],
35
- getProp(template, "data.outputs") ? template.data.outputs : [],
36
- getProp(template, "data.output") ? [template.data.output] : []
37
- ].forEach(d => _getDependencies(d, dependencies));
38
- return _validateDependencies(dependencies, authentication);
39
- }
40
- /**
41
- * Any feature services with the typeKeyword "IoTFeatureLayer" should not be templatized or
42
- * listed as a dependency.
43
- * We can’t create Velocity feature layers in their spatiotemporal datastore as we have no api.
44
- *
45
- * @param dependencies Any dependencies that have been found for this item
46
- * @param authentication The credentials for any requests
47
- *
48
- * @returns a list of dependency ids
49
- * @private
50
- */
51
- export function _validateDependencies(dependencies, authentication) {
52
- const defs = dependencies.map(d => {
53
- return getItemBase(d, authentication);
54
- });
55
- return Promise.all(defs).then(itemInfos => {
56
- return Promise.resolve(itemInfos.reduce((prev, cur) => {
57
- if (cur.typeKeywords.indexOf("IoTFeatureLayer") < 0) {
58
- prev.push(cur.id);
59
- }
60
- return prev;
61
- }, []));
62
- });
63
- }
64
- /**
65
- * Get the dependencies from the velocity feeds
66
- * This function will update the input dependencies argument
67
- *
68
- * @param feeds The list of feeds from the velocity template
69
- * @param dependencies The current list of dependencies
70
- * @private
71
- */
72
- export function _getFeedDependencies(feeds, dependencies) {
73
- feeds.reduce((prev, cur) => {
74
- const id = cur.id || undefined;
75
- /* istanbul ignore else */
76
- if (id && prev.indexOf(id) < 0) {
77
- prev.push(id);
78
- }
79
- return prev;
80
- }, dependencies);
81
- // run through standard dependency check as well
82
- // in some cases the feed does not have the id property but will have
83
- // a portalItemId value in the properties
84
- _getDependencies(feeds, dependencies);
85
- }
86
- /**
87
- * Get the dependencies from the velocity outputs or dataSources.
88
- * This function will update the input dependencies argument
89
- *
90
- * @param outputs The list of outputs from the velocity item
91
- * @param dependencies The current list of dependencies
92
- * @param prop The individual prop to evaluate
93
- * @private
94
- */
95
- export function _getDependencies(outputs, dependencies) {
96
- outputs.reduce((prev, cur) => {
97
- const names = getProp(cur, "name") ? [cur.name] : BASE_NAMES;
98
- names.forEach(n => {
99
- PROP_NAMES.forEach(p => {
100
- // skip map service and stream service ids
101
- /* istanbul ignore else */
102
- if (p.indexOf("mapServicePortalItemID") < 0 && p.indexOf("streamServicePortalItemID") < 0) {
103
- const id = cur.properties ? cur.properties[n + p] : undefined;
104
- if (id && prev.indexOf(id) < 0) {
105
- prev.push(id);
106
- }
107
- }
108
- });
109
- });
110
- return prev;
111
- }, dependencies);
112
- }
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
+ import { getProp, getItemBase, BASE_NAMES, PROP_NAMES } from "@esri/solution-common";
17
+ /**
18
+ * Get the dependencies from the velocity data sources, feeds, and outputs.
19
+ * Only dependencies that do NOT have the typeKeyword "IoTFeatureLayer" are returned.
20
+ *
21
+ * @param template The template that for the velocity item
22
+ * @param authentication The credentials for any requests
23
+ *
24
+ * @returns a list of dependency ids
25
+ */
26
+ export function getVelocityDependencies(template, authentication) {
27
+ const dependencies = [];
28
+ [
29
+ getProp(template, "data.feeds") ? template.data.feeds : [],
30
+ getProp(template, "data.feed") ? [template.data.feed] : []
31
+ ].forEach(f => _getFeedDependencies(f, dependencies));
32
+ [
33
+ getProp(template, "data.sources") ? template.data.sources : [],
34
+ getProp(template, "data.source") ? [template.data.source] : [],
35
+ getProp(template, "data.outputs") ? template.data.outputs : [],
36
+ getProp(template, "data.output") ? [template.data.output] : []
37
+ ].forEach(d => _getDependencies(d, dependencies));
38
+ return _validateDependencies(dependencies, authentication);
39
+ }
40
+ /**
41
+ * Any feature services with the typeKeyword "IoTFeatureLayer" should not be templatized or
42
+ * listed as a dependency.
43
+ * We can’t create Velocity feature layers in their spatiotemporal datastore as we have no api.
44
+ *
45
+ * @param dependencies Any dependencies that have been found for this item
46
+ * @param authentication The credentials for any requests
47
+ *
48
+ * @returns a list of dependency ids
49
+ * @private
50
+ */
51
+ export function _validateDependencies(dependencies, authentication) {
52
+ const defs = dependencies.map(d => {
53
+ return getItemBase(d, authentication);
54
+ });
55
+ return Promise.all(defs).then(itemInfos => {
56
+ return Promise.resolve(itemInfos.reduce((prev, cur) => {
57
+ if (cur.typeKeywords.indexOf("IoTFeatureLayer") < 0) {
58
+ prev.push(cur.id);
59
+ }
60
+ return prev;
61
+ }, []));
62
+ });
63
+ }
64
+ /**
65
+ * Get the dependencies from the velocity feeds
66
+ * This function will update the input dependencies argument
67
+ *
68
+ * @param feeds The list of feeds from the velocity template
69
+ * @param dependencies The current list of dependencies
70
+ * @private
71
+ */
72
+ export function _getFeedDependencies(feeds, dependencies) {
73
+ feeds.reduce((prev, cur) => {
74
+ const id = cur.id || undefined;
75
+ /* istanbul ignore else */
76
+ if (id && prev.indexOf(id) < 0) {
77
+ prev.push(id);
78
+ }
79
+ return prev;
80
+ }, dependencies);
81
+ // run through standard dependency check as well
82
+ // in some cases the feed does not have the id property but will have
83
+ // a portalItemId value in the properties
84
+ _getDependencies(feeds, dependencies);
85
+ }
86
+ /**
87
+ * Get the dependencies from the velocity outputs or dataSources.
88
+ * This function will update the input dependencies argument
89
+ *
90
+ * @param outputs The list of outputs from the velocity item
91
+ * @param dependencies The current list of dependencies
92
+ * @param prop The individual prop to evaluate
93
+ * @private
94
+ */
95
+ export function _getDependencies(outputs, dependencies) {
96
+ outputs.reduce((prev, cur) => {
97
+ const names = getProp(cur, "name") ? [cur.name] : BASE_NAMES;
98
+ names.forEach(n => {
99
+ PROP_NAMES.forEach(p => {
100
+ // skip map service and stream service ids
101
+ /* istanbul ignore else */
102
+ if (p.indexOf("mapServicePortalItemID") < 0 && p.indexOf("streamServicePortalItemID") < 0) {
103
+ const id = cur.properties ? cur.properties[n + p] : undefined;
104
+ if (id && prev.indexOf(id) < 0) {
105
+ prev.push(id);
106
+ }
107
+ }
108
+ });
109
+ });
110
+ return prev;
111
+ }, dependencies);
112
+ }
113
113
  //# sourceMappingURL=get-velocity-dependencies.js.map