@esri/solution-common 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/completeItem.js +6 -7
- package/dist/esm/completeItem.js.map +1 -1
- package/dist/esm/create-hub-request-options.d.ts +4 -4
- package/dist/esm/create-hub-request-options.js +9 -12
- package/dist/esm/create-hub-request-options.js.map +1 -1
- package/dist/esm/deleteHelpers/deleteEmptyGroups.js +2 -2
- package/dist/esm/deleteHelpers/deleteEmptyGroups.js.map +1 -1
- package/dist/esm/deleteHelpers/deleteGroupIfEmpty.js +15 -15
- package/dist/esm/deleteHelpers/deleteGroupIfEmpty.js.map +1 -1
- package/dist/esm/deleteHelpers/deleteSolutionContents.js +20 -22
- package/dist/esm/deleteHelpers/deleteSolutionContents.js.map +1 -1
- package/dist/esm/deleteHelpers/deleteSolutionFolder.js +10 -10
- package/dist/esm/deleteHelpers/deleteSolutionFolder.js.map +1 -1
- package/dist/esm/deleteHelpers/deleteSolutionItem.js +4 -4
- package/dist/esm/deleteHelpers/deleteSolutionItem.js.map +1 -1
- package/dist/esm/deleteHelpers/reconstructBuildOrderIds.js +1 -1
- package/dist/esm/deleteHelpers/reconstructBuildOrderIds.js.map +1 -1
- package/dist/esm/deleteHelpers/removeItems.js +20 -29
- package/dist/esm/deleteHelpers/removeItems.js.map +1 -1
- package/dist/esm/deleteHelpers/reportProgress.js +3 -6
- package/dist/esm/deleteHelpers/reportProgress.js.map +1 -1
- package/dist/esm/deleteSolution.js +10 -12
- package/dist/esm/deleteSolution.js.map +1 -1
- package/dist/esm/dependencies.js +27 -19
- package/dist/esm/dependencies.js.map +1 -1
- package/dist/esm/featureServiceHelpers.d.ts +6 -0
- package/dist/esm/featureServiceHelpers.js +530 -500
- package/dist/esm/featureServiceHelpers.js.map +1 -1
- package/dist/esm/generalHelpers.js +72 -76
- package/dist/esm/generalHelpers.js.map +1 -1
- package/dist/esm/get-subscription-info.js +5 -3
- package/dist/esm/get-subscription-info.js.map +1 -1
- package/dist/esm/getDeletableSolutionInfo.js +6 -10
- package/dist/esm/getDeletableSolutionInfo.js.map +1 -1
- package/dist/esm/getSolutionSummary.js +15 -19
- package/dist/esm/getSolutionSummary.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interfaces.d.ts +39 -1
- package/dist/esm/interfaces.js +3 -3
- package/dist/esm/interfaces.js.map +1 -1
- package/dist/esm/libConnectors.js +5 -7
- package/dist/esm/libConnectors.js.map +1 -1
- package/dist/esm/migrations/apply-schema.js +3 -3
- package/dist/esm/migrations/apply-schema.js.map +1 -1
- package/dist/esm/migrations/is-legacy-solution.js +2 -2
- package/dist/esm/migrations/is-legacy-solution.js.map +1 -1
- package/dist/esm/migrations/upgrade-three-dot-one.js +3 -3
- package/dist/esm/migrations/upgrade-three-dot-one.js.map +1 -1
- package/dist/esm/migrations/upgrade-three-dot-zero.js +1 -1
- package/dist/esm/migrations/upgrade-three-dot-zero.js.map +1 -1
- package/dist/esm/migrations/upgrade-two-dot-five.js +17 -8
- package/dist/esm/migrations/upgrade-two-dot-five.js.map +1 -1
- package/dist/esm/migrations/upgrade-two-dot-four.js +12 -12
- package/dist/esm/migrations/upgrade-two-dot-four.js.map +1 -1
- package/dist/esm/migrations/upgrade-two-dot-one.js +1 -1
- package/dist/esm/migrations/upgrade-two-dot-one.js.map +1 -1
- package/dist/esm/migrations/upgrade-two-dot-seven.js +1 -1
- package/dist/esm/migrations/upgrade-two-dot-seven.js.map +1 -1
- package/dist/esm/migrations/upgrade-two-dot-six.js +9 -12
- package/dist/esm/migrations/upgrade-two-dot-six.js.map +1 -1
- package/dist/esm/migrations/upgrade-two-dot-three.js +3 -3
- package/dist/esm/migrations/upgrade-two-dot-three.js.map +1 -1
- package/dist/esm/migrations/upgrade-two-dot-two.js +3 -3
- package/dist/esm/migrations/upgrade-two-dot-two.js.map +1 -1
- package/dist/esm/migrations/upgrade-two-dot-zero.js +8 -9
- package/dist/esm/migrations/upgrade-two-dot-zero.js.map +1 -1
- package/dist/esm/migrator.js +5 -7
- package/dist/esm/migrator.js.map +1 -1
- package/dist/esm/polyfills.js +5 -5
- package/dist/esm/polyfills.js.map +1 -1
- package/dist/esm/resourceHelpers.js +54 -57
- package/dist/esm/resourceHelpers.js.map +1 -1
- package/dist/esm/resources/add-resource-from-blob.js +2 -2
- package/dist/esm/resources/add-resource-from-blob.js.map +1 -1
- package/dist/esm/resources/addMetadataFromBlob.js +1 -1
- package/dist/esm/resources/addMetadataFromBlob.js.map +1 -1
- package/dist/esm/resources/convert-item-resource-to-storage-resource.js +6 -7
- package/dist/esm/resources/convert-item-resource-to-storage-resource.js.map +1 -1
- package/dist/esm/resources/convert-storage-resource-to-item-resource.js +8 -9
- package/dist/esm/resources/convert-storage-resource-to-item-resource.js.map +1 -1
- package/dist/esm/resources/copyAssociatedFiles.js +44 -53
- package/dist/esm/resources/copyAssociatedFiles.js.map +1 -1
- package/dist/esm/resources/copyDataIntoItem.js +5 -11
- package/dist/esm/resources/copyDataIntoItem.js.map +1 -1
- package/dist/esm/resources/copyMetadataIntoItem.js +4 -10
- package/dist/esm/resources/copyMetadataIntoItem.js.map +1 -1
- package/dist/esm/resources/copyResourceIntoZip.js +5 -7
- package/dist/esm/resources/copyResourceIntoZip.js.map +1 -1
- package/dist/esm/resources/copyZipIntoItem.js +5 -9
- package/dist/esm/resources/copyZipIntoItem.js.map +1 -1
- package/dist/esm/resources/createCopyResults.js +5 -2
- package/dist/esm/resources/createCopyResults.js.map +1 -1
- package/dist/esm/resources/get-blob.js +7 -5
- package/dist/esm/resources/get-blob.js.map +1 -1
- package/dist/esm/resources/getItemResourcesFilesFromPaths.js +7 -7
- package/dist/esm/resources/getItemResourcesFilesFromPaths.js.map +1 -1
- package/dist/esm/resources/getItemResourcesPaths.js +7 -8
- package/dist/esm/resources/getItemResourcesPaths.js.map +1 -1
- package/dist/esm/resources/transform-resource-paths-to-solution-resources.js +8 -9
- package/dist/esm/resources/transform-resource-paths-to-solution-resources.js.map +1 -1
- package/dist/esm/restHelpers.d.ts +65 -5
- package/dist/esm/restHelpers.js +422 -276
- package/dist/esm/restHelpers.js.map +1 -1
- package/dist/esm/restHelpersGet.js +102 -111
- package/dist/esm/restHelpersGet.js.map +1 -1
- package/dist/esm/sharing/share-item-to-groups.d.ts +2 -1
- package/dist/esm/sharing/share-item-to-groups.js +12 -6
- package/dist/esm/sharing/share-item-to-groups.js.map +1 -1
- package/dist/esm/templatization.js +64 -40
- package/dist/esm/templatization.js.map +1 -1
- package/dist/esm/trackingHelpers.d.ts +116 -0
- package/dist/esm/trackingHelpers.js +205 -0
- package/dist/esm/trackingHelpers.js.map +1 -0
- package/dist/esm/velocityHelpers.d.ts +2 -0
- package/dist/esm/velocityHelpers.js +30 -12
- package/dist/esm/velocityHelpers.js.map +1 -1
- package/dist/esm/workforceHelpers.d.ts +11 -0
- package/dist/esm/workforceHelpers.js +208 -180
- package/dist/esm/workforceHelpers.js.map +1 -1
- package/dist/node/completeItem.js +8 -9
- package/dist/node/completeItem.js.map +1 -1
- package/dist/node/create-hub-request-options.d.ts +4 -4
- package/dist/node/create-hub-request-options.js +11 -14
- package/dist/node/create-hub-request-options.js.map +1 -1
- package/dist/node/deleteHelpers/deleteEmptyGroups.js +3 -3
- package/dist/node/deleteHelpers/deleteEmptyGroups.js.map +1 -1
- package/dist/node/deleteHelpers/deleteGroupIfEmpty.js +16 -16
- package/dist/node/deleteHelpers/deleteGroupIfEmpty.js.map +1 -1
- package/dist/node/deleteHelpers/deleteSolutionContents.js +26 -28
- package/dist/node/deleteHelpers/deleteSolutionContents.js.map +1 -1
- package/dist/node/deleteHelpers/deleteSolutionFolder.js +11 -11
- package/dist/node/deleteHelpers/deleteSolutionFolder.js.map +1 -1
- package/dist/node/deleteHelpers/deleteSolutionItem.js +6 -6
- package/dist/node/deleteHelpers/deleteSolutionItem.js.map +1 -1
- package/dist/node/deleteHelpers/index.js +1 -1
- package/dist/node/deleteHelpers/reconstructBuildOrderIds.js +2 -2
- package/dist/node/deleteHelpers/reconstructBuildOrderIds.js.map +1 -1
- package/dist/node/deleteHelpers/removeItems.js +26 -35
- package/dist/node/deleteHelpers/removeItems.js.map +1 -1
- package/dist/node/deleteHelpers/reportProgress.js +4 -7
- package/dist/node/deleteHelpers/reportProgress.js.map +1 -1
- package/dist/node/deleteSolution.js +12 -14
- package/dist/node/deleteSolution.js.map +1 -1
- package/dist/node/dependencies.js +29 -21
- package/dist/node/dependencies.js.map +1 -1
- package/dist/node/featureServiceHelpers.d.ts +6 -0
- package/dist/node/featureServiceHelpers.js +535 -504
- package/dist/node/featureServiceHelpers.js.map +1 -1
- package/dist/node/generalHelpers.js +75 -79
- package/dist/node/generalHelpers.js.map +1 -1
- package/dist/node/get-subscription-info.js +7 -5
- package/dist/node/get-subscription-info.js.map +1 -1
- package/dist/node/getDeletableSolutionInfo.js +8 -12
- package/dist/node/getDeletableSolutionInfo.js.map +1 -1
- package/dist/node/getSolutionSummary.js +19 -23
- package/dist/node/getSolutionSummary.js.map +1 -1
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +2 -1
- package/dist/node/index.js.map +1 -1
- package/dist/node/interfaces.d.ts +39 -1
- package/dist/node/interfaces.js.map +1 -1
- package/dist/node/libConnectors.js +8 -10
- package/dist/node/libConnectors.js.map +1 -1
- package/dist/node/migrations/apply-schema.js +4 -4
- package/dist/node/migrations/apply-schema.js.map +1 -1
- package/dist/node/migrations/is-legacy-solution.js +3 -3
- package/dist/node/migrations/is-legacy-solution.js.map +1 -1
- package/dist/node/migrations/upgrade-three-dot-one.js +5 -5
- package/dist/node/migrations/upgrade-three-dot-one.js.map +1 -1
- package/dist/node/migrations/upgrade-three-dot-zero.js +2 -2
- package/dist/node/migrations/upgrade-three-dot-zero.js.map +1 -1
- package/dist/node/migrations/upgrade-two-dot-five.js +18 -9
- package/dist/node/migrations/upgrade-two-dot-five.js.map +1 -1
- package/dist/node/migrations/upgrade-two-dot-four.js +13 -13
- package/dist/node/migrations/upgrade-two-dot-four.js.map +1 -1
- package/dist/node/migrations/upgrade-two-dot-one.js +2 -2
- package/dist/node/migrations/upgrade-two-dot-one.js.map +1 -1
- package/dist/node/migrations/upgrade-two-dot-seven.js +2 -2
- package/dist/node/migrations/upgrade-two-dot-seven.js.map +1 -1
- package/dist/node/migrations/upgrade-two-dot-six.js +10 -13
- package/dist/node/migrations/upgrade-two-dot-six.js.map +1 -1
- package/dist/node/migrations/upgrade-two-dot-three.js +5 -5
- package/dist/node/migrations/upgrade-two-dot-three.js.map +1 -1
- package/dist/node/migrations/upgrade-two-dot-two.js +5 -5
- package/dist/node/migrations/upgrade-two-dot-two.js.map +1 -1
- package/dist/node/migrations/upgrade-two-dot-zero.js +9 -10
- package/dist/node/migrations/upgrade-two-dot-zero.js.map +1 -1
- package/dist/node/migrator.js +16 -18
- package/dist/node/migrator.js.map +1 -1
- package/dist/node/polyfills.js +5 -5
- package/dist/node/polyfills.js.map +1 -1
- package/dist/node/resourceHelpers.js +62 -65
- package/dist/node/resourceHelpers.js.map +1 -1
- package/dist/node/resources/add-resource-from-blob.js +4 -4
- package/dist/node/resources/add-resource-from-blob.js.map +1 -1
- package/dist/node/resources/addMetadataFromBlob.js +2 -2
- package/dist/node/resources/addMetadataFromBlob.js.map +1 -1
- package/dist/node/resources/convert-item-resource-to-storage-resource.js +6 -7
- package/dist/node/resources/convert-item-resource-to-storage-resource.js.map +1 -1
- package/dist/node/resources/convert-storage-resource-to-item-resource.js +9 -10
- package/dist/node/resources/convert-storage-resource-to-item-resource.js.map +1 -1
- package/dist/node/resources/copyAssociatedFiles.js +52 -61
- package/dist/node/resources/copyAssociatedFiles.js.map +1 -1
- package/dist/node/resources/copyDataIntoItem.js +9 -15
- package/dist/node/resources/copyDataIntoItem.js.map +1 -1
- package/dist/node/resources/copyMetadataIntoItem.js +7 -13
- package/dist/node/resources/copyMetadataIntoItem.js.map +1 -1
- package/dist/node/resources/copyResourceIntoZip.js +7 -9
- package/dist/node/resources/copyResourceIntoZip.js.map +1 -1
- package/dist/node/resources/copyZipIntoItem.js +8 -12
- package/dist/node/resources/copyZipIntoItem.js.map +1 -1
- package/dist/node/resources/createCopyResults.js +5 -2
- package/dist/node/resources/createCopyResults.js.map +1 -1
- package/dist/node/resources/get-blob.js +8 -6
- package/dist/node/resources/get-blob.js.map +1 -1
- package/dist/node/resources/getItemResourcesFilesFromPaths.js +8 -8
- package/dist/node/resources/getItemResourcesFilesFromPaths.js.map +1 -1
- package/dist/node/resources/getItemResourcesPaths.js +9 -10
- package/dist/node/resources/getItemResourcesPaths.js.map +1 -1
- package/dist/node/resources/index.js +1 -1
- package/dist/node/resources/transform-resource-paths-to-solution-resources.js +10 -11
- package/dist/node/resources/transform-resource-paths-to-solution-resources.js.map +1 -1
- package/dist/node/restHelpers.d.ts +65 -5
- package/dist/node/restHelpers.js +437 -285
- package/dist/node/restHelpers.js.map +1 -1
- package/dist/node/restHelpersGet.js +107 -116
- package/dist/node/restHelpersGet.js.map +1 -1
- package/dist/node/sharing/index.js +1 -1
- package/dist/node/sharing/share-item-to-groups.d.ts +2 -1
- package/dist/node/sharing/share-item-to-groups.js +13 -7
- package/dist/node/sharing/share-item-to-groups.js.map +1 -1
- package/dist/node/templatization.js +61 -37
- package/dist/node/templatization.js.map +1 -1
- package/dist/node/trackingHelpers.d.ts +116 -0
- package/dist/node/trackingHelpers.js +217 -0
- package/dist/node/trackingHelpers.js.map +1 -0
- package/dist/node/velocityHelpers.d.ts +2 -0
- package/dist/node/velocityHelpers.js +33 -15
- package/dist/node/velocityHelpers.js.map +1 -1
- package/dist/node/workforceHelpers.d.ts +11 -0
- package/dist/node/workforceHelpers.js +214 -185
- package/dist/node/workforceHelpers.js.map +1 -1
- package/dist/umd/common.umd.js +14830 -14466
- package/dist/umd/common.umd.js.map +1 -1
- package/dist/umd/common.umd.min.js +3 -3
- package/dist/umd/common.umd.min.js.map +1 -1
- package/dist/umd/create-hub-request-options.d.ts +4 -4
- package/dist/umd/featureServiceHelpers.d.ts +6 -0
- package/dist/umd/index.d.ts +1 -0
- package/dist/umd/interfaces.d.ts +39 -1
- package/dist/umd/restHelpers.d.ts +65 -5
- package/dist/umd/sharing/share-item-to-groups.d.ts +2 -1
- package/dist/umd/trackingHelpers.d.ts +116 -0
- package/dist/umd/velocityHelpers.d.ts +2 -0
- package/dist/umd/workforceHelpers.d.ts +11 -0
- package/package.json +24 -24
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { __assign } from "tslib";
|
|
17
16
|
/**
|
|
18
17
|
* Provides general helper functions.
|
|
19
18
|
*
|
|
@@ -24,6 +23,7 @@ export { queryFeatures as rest_queryFeatures, addFeatures as rest_addFeatures }
|
|
|
24
23
|
import { checkUrlPathTermination, deleteProp, fail, getProp, setCreateProp, setProp } from "./generalHelpers";
|
|
25
24
|
import { replaceInTemplate, templatizeTerm, templatizeIds } from "./templatization";
|
|
26
25
|
import { getFinalServiceUpdates, addToServiceDefinition, getLayerUpdates, getRequest, rest_request } from "./restHelpers";
|
|
26
|
+
import { isTrackingViewTemplate, templatizeTracker } from "./trackingHelpers";
|
|
27
27
|
//#endregion ------------------------------------------------------------------------------------------------------------//
|
|
28
28
|
//#region Public functions ----------------------------------------------------------------------------------------------//
|
|
29
29
|
/**
|
|
@@ -39,29 +39,36 @@ import { getFinalServiceUpdates, addToServiceDefinition, getLayerUpdates, getReq
|
|
|
39
39
|
export function templatize(itemTemplate, dependencies, templatizeFieldReferences, templateDictionary) {
|
|
40
40
|
templateDictionary = templateDictionary || {};
|
|
41
41
|
// Common templatizations
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
itemTemplate.item =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
const id = itemTemplate.item.id;
|
|
43
|
+
const fsUrl = itemTemplate.item.url;
|
|
44
|
+
itemTemplate.item = {
|
|
45
|
+
...itemTemplate.item,
|
|
46
|
+
id: templatizeTerm(id, id, ".itemId"),
|
|
47
|
+
url: _templatize(id, "url"),
|
|
48
|
+
typeKeywords: templatizeIds(itemTemplate.item.typeKeywords)
|
|
49
|
+
};
|
|
50
|
+
// special handeling if we are dealing with a tracker view
|
|
51
|
+
templatizeTracker(itemTemplate);
|
|
52
|
+
const jsonLayers = itemTemplate.properties.layers || [];
|
|
53
|
+
const jsonTables = itemTemplate.properties.tables || [];
|
|
54
|
+
const jsonItems = jsonLayers.concat(jsonTables);
|
|
55
|
+
const data = itemTemplate.data || {};
|
|
56
|
+
const layers = data.layers || [];
|
|
57
|
+
const tables = data.tables || [];
|
|
58
|
+
const _items = layers.concat(tables);
|
|
52
59
|
// Set up symbols for the URL of the feature service and its layers and tables
|
|
53
60
|
templateDictionary[fsUrl] = itemTemplate.item.url; // map FS URL to its templatized form
|
|
54
|
-
jsonItems.concat(_items).forEach(
|
|
61
|
+
jsonItems.concat(_items).forEach(layer => {
|
|
55
62
|
templateDictionary[fsUrl + "/" + layer.id] = _templatize(id, "layer" + layer.id + ".url");
|
|
56
63
|
});
|
|
57
64
|
// templatize the service references serviceItemId
|
|
58
65
|
itemTemplate.properties.service.serviceItemId = templatizeTerm(itemTemplate.properties.service.serviceItemId, itemTemplate.properties.service.serviceItemId, ".itemId");
|
|
59
|
-
|
|
66
|
+
const initialExtent = getProp(itemTemplate, "properties.service.initialExtent");
|
|
60
67
|
/* istanbul ignore else */
|
|
61
68
|
if (initialExtent) {
|
|
62
69
|
itemTemplate.properties.service.initialExtent = templatizeTerm(id, id, ".solutionExtent");
|
|
63
70
|
}
|
|
64
|
-
|
|
71
|
+
const fullExtent = getProp(itemTemplate, "properties.service.fullExtent");
|
|
65
72
|
/* istanbul ignore else */
|
|
66
73
|
if (fullExtent) {
|
|
67
74
|
itemTemplate.properties.service.fullExtent = templatizeTerm(id, id, ".solutionExtent");
|
|
@@ -77,14 +84,14 @@ export function templatize(itemTemplate, dependencies, templatizeFieldReferences
|
|
|
77
84
|
}
|
|
78
85
|
// if any layer hasZ enabled then we need to set
|
|
79
86
|
// enableZDefaults and zDefault to deploy to enterprise
|
|
80
|
-
|
|
81
|
-
jsonItems.forEach(
|
|
87
|
+
let hasZ = false;
|
|
88
|
+
jsonItems.forEach((jsonItem) => {
|
|
82
89
|
// get the source service json for the given data item
|
|
83
|
-
|
|
90
|
+
const matchingItems = _items.filter(item => {
|
|
84
91
|
return jsonItem.id === item.id;
|
|
85
92
|
});
|
|
86
93
|
// templatize the source service json
|
|
87
|
-
|
|
94
|
+
const _item = matchingItems.length === 1 ? matchingItems[0] : undefined;
|
|
88
95
|
_templatizeLayer(_item, jsonItem, itemTemplate, dependencies, templatizeFieldReferences, templateDictionary);
|
|
89
96
|
hasZ = jsonItem.hasZ || (_item && _item.hasZ) ? true : hasZ;
|
|
90
97
|
});
|
|
@@ -100,8 +107,8 @@ export function templatize(itemTemplate, dependencies, templatizeFieldReferences
|
|
|
100
107
|
* @param layer The data layer instance with field name references within
|
|
101
108
|
*/
|
|
102
109
|
export function deleteViewProps(layer) {
|
|
103
|
-
|
|
104
|
-
props.forEach(
|
|
110
|
+
const props = ["definitionQuery"];
|
|
111
|
+
props.forEach(prop => {
|
|
105
112
|
deleteProp(layer, prop);
|
|
106
113
|
});
|
|
107
114
|
}
|
|
@@ -129,7 +136,7 @@ export function cacheFieldInfos(layer, fieldInfos, isPortal) {
|
|
|
129
136
|
// cache each of these properties as they each can contain field references
|
|
130
137
|
// and will have associated updateDefinition calls when deploying to portal
|
|
131
138
|
// as well as online for relationships...as relationships added with addToDef will cause failure
|
|
132
|
-
|
|
139
|
+
const props = {
|
|
133
140
|
editFieldsInfo: isPortal,
|
|
134
141
|
types: isPortal,
|
|
135
142
|
templates: isPortal,
|
|
@@ -138,7 +145,7 @@ export function cacheFieldInfos(layer, fieldInfos, isPortal) {
|
|
|
138
145
|
timeInfo: isPortal,
|
|
139
146
|
viewDefinitionQuery: isPortal
|
|
140
147
|
};
|
|
141
|
-
Object.keys(props).forEach(
|
|
148
|
+
Object.keys(props).forEach(k => {
|
|
142
149
|
_cacheFieldInfo(layer, k, fieldInfos, props[k]);
|
|
143
150
|
});
|
|
144
151
|
return fieldInfos;
|
|
@@ -174,7 +181,7 @@ export function _cacheFieldInfo(layer, prop, fieldInfos, removeProp) {
|
|
|
174
181
|
*/
|
|
175
182
|
export function cachePopupInfos(data) {
|
|
176
183
|
// store any popupInfo so we can update after any potential name changes
|
|
177
|
-
|
|
184
|
+
const popupInfos = {
|
|
178
185
|
layers: {},
|
|
179
186
|
tables: {}
|
|
180
187
|
};
|
|
@@ -195,7 +202,7 @@ export function cachePopupInfos(data) {
|
|
|
195
202
|
* @param _items list or either layers or tables
|
|
196
203
|
*/
|
|
197
204
|
export function _cachePopupInfo(popupInfos, type, _items) {
|
|
198
|
-
_items.forEach(
|
|
205
|
+
_items.forEach((item) => {
|
|
199
206
|
if (item && item.hasOwnProperty("popupInfo")) {
|
|
200
207
|
popupInfos[type][item.id] = item.popupInfo;
|
|
201
208
|
item.popupInfo = {};
|
|
@@ -235,10 +242,10 @@ export function updateTemplate(itemTemplate, templateDictionary, createResponse)
|
|
|
235
242
|
*/
|
|
236
243
|
export function _updateTypeKeywords(itemTemplate, createResponse) {
|
|
237
244
|
// https://github.com/Esri/solution.js/issues/589
|
|
238
|
-
|
|
239
|
-
|
|
245
|
+
const iKwords = getProp(itemTemplate, "item.typeKeywords");
|
|
246
|
+
const cKwords = getProp(createResponse, "typeKeywords");
|
|
240
247
|
if (iKwords && cKwords) {
|
|
241
|
-
setProp(itemTemplate, "item.typeKeywords", iKwords.concat(cKwords.filter(
|
|
248
|
+
setProp(itemTemplate, "item.typeKeywords", iKwords.concat(cKwords.filter(k => iKwords.indexOf(k) < 0)));
|
|
242
249
|
}
|
|
243
250
|
return itemTemplate;
|
|
244
251
|
}
|
|
@@ -253,21 +260,21 @@ export function _updateTypeKeywords(itemTemplate, createResponse) {
|
|
|
253
260
|
* @return The settings object that will be used to de-templatize the field references.
|
|
254
261
|
*/
|
|
255
262
|
export function getLayerSettings(layerInfos, url, itemId, enterpriseIDMapping) {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
ids.forEach(
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
263
|
+
const settings = {};
|
|
264
|
+
const ids = Object.keys(layerInfos);
|
|
265
|
+
ids.forEach((id) => {
|
|
266
|
+
const _layerId = getProp(layerInfos[id], "item.id");
|
|
267
|
+
const isNum = parseInt(_layerId, 10) > -1;
|
|
268
|
+
const layerId = isNum && enterpriseIDMapping
|
|
262
269
|
? enterpriseIDMapping[_layerId]
|
|
263
270
|
: isNum
|
|
264
271
|
? _layerId
|
|
265
272
|
: id;
|
|
266
|
-
settings[
|
|
273
|
+
settings[`layer${isNum ? _layerId : id}`] = {
|
|
267
274
|
fields: _getNameMapping(layerInfos, id),
|
|
268
275
|
url: checkUrlPathTermination(url) + layerId,
|
|
269
|
-
layerId
|
|
270
|
-
itemId
|
|
276
|
+
layerId,
|
|
277
|
+
itemId
|
|
271
278
|
};
|
|
272
279
|
deleteProp(layerInfos[id], "newFields");
|
|
273
280
|
deleteProp(layerInfos[id], "sourceFields");
|
|
@@ -285,24 +292,28 @@ export function getLayerSettings(layerInfos, url, itemId, enterpriseIDMapping) {
|
|
|
285
292
|
* @return An updated collection of AGO templates with unique feature service names.
|
|
286
293
|
*/
|
|
287
294
|
export function setNamesAndTitles(templates, solutionItemId) {
|
|
288
|
-
|
|
289
|
-
return templates.map(
|
|
295
|
+
const names = [];
|
|
296
|
+
return templates.map(t => {
|
|
297
|
+
/* istanbul ignore else */
|
|
290
298
|
if (t.item.type === "Feature Service") {
|
|
291
299
|
// Retain the existing title but swap with name if it's missing
|
|
292
300
|
t.item.title = t.item.title || t.item.name;
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
301
|
+
/* istanbul ignore else */
|
|
302
|
+
if (!isTrackingViewTemplate(t)) {
|
|
303
|
+
// Need to set the service name: name + "_" + newItemId
|
|
304
|
+
let baseName = t.item.name || t.item.title;
|
|
305
|
+
// If the name already contains a GUID remove it
|
|
306
|
+
baseName = baseName.replace(/_[0-9A-F]{32}/gi, "");
|
|
307
|
+
// The name length limit is 98
|
|
308
|
+
// Limit the baseName to 50 characters before the _<guid>
|
|
309
|
+
const name = baseName.substring(0, 50) + "_" + solutionItemId;
|
|
310
|
+
// If the name + GUID already exists then append "_occurrenceCount"
|
|
311
|
+
t.item.name =
|
|
312
|
+
names.indexOf(name) === -1
|
|
313
|
+
? name
|
|
314
|
+
: `${name}_${names.filter(n => n === name).length}`;
|
|
315
|
+
names.push(name);
|
|
316
|
+
}
|
|
306
317
|
}
|
|
307
318
|
return t;
|
|
308
319
|
});
|
|
@@ -317,22 +328,23 @@ export function setNamesAndTitles(templates, solutionItemId) {
|
|
|
317
328
|
* @param settings The settings object used to de-templatize the various templates within the item.
|
|
318
329
|
*/
|
|
319
330
|
export function updateSettingsFieldInfos(itemTemplate, settings) {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
settingsKeys.forEach(
|
|
331
|
+
const dependencies = itemTemplate.dependencies;
|
|
332
|
+
const id = itemTemplate.itemId;
|
|
333
|
+
const settingsKeys = Object.keys(settings);
|
|
334
|
+
settingsKeys.forEach((k) => {
|
|
324
335
|
if (id === settings[k].itemId) {
|
|
325
|
-
dependencies.forEach(
|
|
326
|
-
settingsKeys.forEach(
|
|
336
|
+
dependencies.forEach((d) => {
|
|
337
|
+
settingsKeys.forEach((_k) => {
|
|
327
338
|
/* istanbul ignore else */
|
|
328
339
|
if (d === _k) {
|
|
329
340
|
// combine for multi-source views
|
|
330
|
-
|
|
341
|
+
const fieldInfos = {};
|
|
331
342
|
fieldInfos[d] = getProp(settings[_k], "fieldInfos");
|
|
332
343
|
settings[k]["sourceServiceFields"] = settings[k]["sourceServiceFields"]
|
|
333
|
-
?
|
|
334
|
-
|
|
335
|
-
layerKeys.
|
|
344
|
+
? { ...settings[k]["sourceServiceFields"], ...fieldInfos }
|
|
345
|
+
: fieldInfos;
|
|
346
|
+
const layerKeys = Object.keys(settings[_k]);
|
|
347
|
+
layerKeys.forEach(layerKey => {
|
|
336
348
|
/* istanbul ignore else */
|
|
337
349
|
if (layerKey.startsWith("layer")) {
|
|
338
350
|
settings[k][layerKey] = settings[_k][layerKey];
|
|
@@ -354,17 +366,17 @@ export function updateSettingsFieldInfos(itemTemplate, settings) {
|
|
|
354
366
|
* @protected
|
|
355
367
|
*/
|
|
356
368
|
export function updateTemplateForInvalidDesignations(template, authentication) {
|
|
357
|
-
return new Promise(
|
|
369
|
+
return new Promise((resolve, reject) => {
|
|
358
370
|
template.properties.hasInvalidDesignations = true;
|
|
359
371
|
if (template.item.url) {
|
|
360
372
|
// get the admin URL
|
|
361
|
-
|
|
362
|
-
rest_request(
|
|
373
|
+
const url = template.item.url;
|
|
374
|
+
rest_request(url + "?f=json", {
|
|
363
375
|
authentication: authentication
|
|
364
|
-
}).then(
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
layersAndTables.forEach(
|
|
376
|
+
}).then(serviceData => {
|
|
377
|
+
const layerInfos = {};
|
|
378
|
+
const layersAndTables = (serviceData.layers || []).concat(serviceData.tables || []);
|
|
379
|
+
layersAndTables.forEach((l) => {
|
|
368
380
|
/* istanbul ignore else */
|
|
369
381
|
if (l && l.hasOwnProperty("id")) {
|
|
370
382
|
layerInfos[l.id] = l;
|
|
@@ -372,9 +384,9 @@ export function updateTemplateForInvalidDesignations(template, authentication) {
|
|
|
372
384
|
});
|
|
373
385
|
template.data[template.itemId] = Object.assign({
|
|
374
386
|
itemId: template.itemId
|
|
375
|
-
}, getLayerSettings(layerInfos,
|
|
387
|
+
}, getLayerSettings(layerInfos, url, template.itemId));
|
|
376
388
|
resolve(template);
|
|
377
|
-
},
|
|
389
|
+
}, e => reject(fail(e)));
|
|
378
390
|
}
|
|
379
391
|
else {
|
|
380
392
|
resolve(template);
|
|
@@ -391,8 +403,8 @@ export function updateTemplateForInvalidDesignations(template, authentication) {
|
|
|
391
403
|
* @return An object that contains updated instances of popupInfos, fieldInfos, and adminLayerInfos
|
|
392
404
|
*/
|
|
393
405
|
export function deTemplatizeFieldInfos(fieldInfos, popupInfos, adminLayerInfos, settings) {
|
|
394
|
-
|
|
395
|
-
fieldInfoKeys.forEach(
|
|
406
|
+
const fieldInfoKeys = Object.keys(fieldInfos);
|
|
407
|
+
fieldInfoKeys.forEach(id => {
|
|
396
408
|
if (fieldInfos[id].hasOwnProperty("templates")) {
|
|
397
409
|
fieldInfos[id].templates = JSON.parse(replaceInTemplate(JSON.stringify(fieldInfos[id].templates), settings));
|
|
398
410
|
}
|
|
@@ -421,8 +433,8 @@ export function deTemplatizeFieldInfos(fieldInfos, popupInfos, adminLayerInfos,
|
|
|
421
433
|
* @return array of layers and tables
|
|
422
434
|
*/
|
|
423
435
|
export function getLayersAndTables(itemTemplate) {
|
|
424
|
-
|
|
425
|
-
|
|
436
|
+
const properties = itemTemplate.properties;
|
|
437
|
+
const layersAndTables = [];
|
|
426
438
|
(properties.layers || []).forEach(function (layer) {
|
|
427
439
|
layersAndTables.push({
|
|
428
440
|
item: layer,
|
|
@@ -450,14 +462,14 @@ export function getLayersAndTables(itemTemplate) {
|
|
|
450
462
|
*/
|
|
451
463
|
export function getExistingLayersAndTables(url, ids, authentication) {
|
|
452
464
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
453
|
-
return new Promise(
|
|
454
|
-
|
|
465
|
+
return new Promise(resolve => {
|
|
466
|
+
const defs = ids.map(id => {
|
|
455
467
|
return rest_request(checkUrlPathTermination(url) + id, {
|
|
456
|
-
authentication
|
|
468
|
+
authentication
|
|
457
469
|
});
|
|
458
470
|
});
|
|
459
471
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
460
|
-
Promise.all(defs.map(
|
|
472
|
+
Promise.all(defs.map(p => p.catch(e => e))).then(resolve);
|
|
461
473
|
});
|
|
462
474
|
}
|
|
463
475
|
/**
|
|
@@ -472,44 +484,49 @@ export function getExistingLayersAndTables(url, ids, authentication) {
|
|
|
472
484
|
* @protected
|
|
473
485
|
*/
|
|
474
486
|
export function addFeatureServiceLayersAndTables(itemTemplate, templateDictionary, popupInfos, authentication) {
|
|
475
|
-
return new Promise(
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
var adminLayerInfos = {};
|
|
479
|
-
// Add the service's layers and tables to it
|
|
480
|
-
var layersAndTables = getLayersAndTables(itemTemplate);
|
|
481
|
-
if (layersAndTables.length > 0) {
|
|
482
|
-
addFeatureServiceDefinition(itemTemplate.item.url || "", layersAndTables, templateDictionary, authentication, itemTemplate.key, adminLayerInfos, fieldInfos, itemTemplate).then(function () {
|
|
483
|
-
// Detemplatize field references and update the layer properties
|
|
484
|
-
// Only failure path is handled by addFeatureServiceDefinition
|
|
485
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
486
|
-
updateLayerFieldReferences(itemTemplate, fieldInfos, popupInfos, adminLayerInfos, templateDictionary).then(function (r) {
|
|
487
|
-
// Update relationships and layer definitions
|
|
488
|
-
var updates = getLayerUpdates({
|
|
489
|
-
message: "updated layer definition",
|
|
490
|
-
objects: r.layerInfos.fieldInfos,
|
|
491
|
-
itemTemplate: r.itemTemplate,
|
|
492
|
-
authentication: authentication
|
|
493
|
-
}, templateDictionary.isPortal);
|
|
494
|
-
// Get any updates for the service that should be performed after updates to the layers
|
|
495
|
-
if (templateDictionary.isPortal) {
|
|
496
|
-
updates = getFinalServiceUpdates(r.itemTemplate, authentication, updates);
|
|
497
|
-
}
|
|
498
|
-
// Process the updates sequentially
|
|
499
|
-
updates
|
|
500
|
-
.reduce(function (prev, update) {
|
|
501
|
-
return prev.then(function () {
|
|
502
|
-
return getRequest(update);
|
|
503
|
-
});
|
|
504
|
-
}, Promise.resolve(null))
|
|
505
|
-
.then(function () { return resolve(null); }, function (e) { return reject(fail(e)); } // getRequest
|
|
506
|
-
);
|
|
507
|
-
});
|
|
508
|
-
}, function (e) { return reject(fail(e)); } // addFeatureServiceDefinition
|
|
509
|
-
);
|
|
487
|
+
return new Promise((resolve, reject) => {
|
|
488
|
+
if (isTrackingViewTemplate(itemTemplate)) {
|
|
489
|
+
resolve(null);
|
|
510
490
|
}
|
|
511
491
|
else {
|
|
512
|
-
|
|
492
|
+
// Create a hash of various properties that contain field references
|
|
493
|
+
const fieldInfos = {};
|
|
494
|
+
const adminLayerInfos = {};
|
|
495
|
+
// Add the service's layers and tables to it
|
|
496
|
+
const layersAndTables = getLayersAndTables(itemTemplate);
|
|
497
|
+
if (layersAndTables.length > 0) {
|
|
498
|
+
addFeatureServiceDefinition(itemTemplate.item.url || "", layersAndTables, templateDictionary, authentication, itemTemplate.key, adminLayerInfos, fieldInfos, itemTemplate).then(() => {
|
|
499
|
+
// Detemplatize field references and update the layer properties
|
|
500
|
+
// Only failure path is handled by addFeatureServiceDefinition
|
|
501
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
502
|
+
updateLayerFieldReferences(itemTemplate, fieldInfos, popupInfos, adminLayerInfos, templateDictionary).then(r => {
|
|
503
|
+
// Update relationships and layer definitions
|
|
504
|
+
let updates = getLayerUpdates({
|
|
505
|
+
message: "updated layer definition",
|
|
506
|
+
objects: r.layerInfos.fieldInfos,
|
|
507
|
+
itemTemplate: r.itemTemplate,
|
|
508
|
+
authentication
|
|
509
|
+
}, templateDictionary.isPortal);
|
|
510
|
+
// Get any updates for the service that should be performed after updates to the layers
|
|
511
|
+
if (templateDictionary.isPortal) {
|
|
512
|
+
updates = getFinalServiceUpdates(r.itemTemplate, authentication, updates);
|
|
513
|
+
}
|
|
514
|
+
// Process the updates sequentially
|
|
515
|
+
updates
|
|
516
|
+
.reduce((prev, update) => {
|
|
517
|
+
return prev.then(() => {
|
|
518
|
+
return getRequest(update);
|
|
519
|
+
});
|
|
520
|
+
}, Promise.resolve(null))
|
|
521
|
+
.then(() => resolve(null), (e) => reject(fail(e)) // getRequest
|
|
522
|
+
);
|
|
523
|
+
});
|
|
524
|
+
}, e => reject(fail(e)) // addFeatureServiceDefinition
|
|
525
|
+
);
|
|
526
|
+
}
|
|
527
|
+
else {
|
|
528
|
+
resolve(null);
|
|
529
|
+
}
|
|
513
530
|
}
|
|
514
531
|
});
|
|
515
532
|
}
|
|
@@ -529,83 +546,95 @@ export function addFeatureServiceLayersAndTables(itemTemplate, templateDictionar
|
|
|
529
546
|
* @protected
|
|
530
547
|
*/
|
|
531
548
|
export function addFeatureServiceDefinition(serviceUrl, listToAdd, templateDictionary, authentication, key, adminLayerInfos, fieldInfos, itemTemplate) {
|
|
532
|
-
return new Promise(
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
tables: [],
|
|
536
|
-
authentication: authentication
|
|
537
|
-
};
|
|
538
|
-
// if the service has veiws keep track of the fields so we can use them to
|
|
539
|
-
// compare with the view fields
|
|
540
|
-
/* istanbul ignore else */
|
|
541
|
-
if (getProp(itemTemplate, "properties.service.hasViews")) {
|
|
542
|
-
_updateTemplateDictionaryFields(itemTemplate, templateDictionary);
|
|
549
|
+
return new Promise((resolve, reject) => {
|
|
550
|
+
if (isTrackingViewTemplate(itemTemplate)) {
|
|
551
|
+
resolve(null);
|
|
543
552
|
}
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
553
|
+
else {
|
|
554
|
+
let options = {
|
|
555
|
+
layers: [],
|
|
556
|
+
tables: [],
|
|
557
|
+
authentication
|
|
558
|
+
};
|
|
559
|
+
// if the service has veiws keep track of the fields so we can use them to
|
|
560
|
+
// compare with the view fields
|
|
549
561
|
/* istanbul ignore else */
|
|
550
|
-
if (
|
|
551
|
-
|
|
562
|
+
if (getProp(itemTemplate, "properties.service.hasViews")) {
|
|
563
|
+
_updateTemplateDictionaryFields(itemTemplate, templateDictionary);
|
|
552
564
|
}
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
// bring over the fieldInfos from the source layer
|
|
560
|
-
updateSettingsFieldInfos(itemTemplate, templateDictionary);
|
|
561
|
-
// update adminLayerInfo before add to definition with view source fieldInfo settings
|
|
562
|
-
item.adminLayerInfo = replaceInTemplate(item.adminLayerInfo, templateDictionary);
|
|
565
|
+
const chunkSize = _getLayerChunkSize();
|
|
566
|
+
const layerChunks = [];
|
|
567
|
+
listToAdd.forEach((toAdd, i) => {
|
|
568
|
+
let item = toAdd.item;
|
|
569
|
+
const originalId = item.id;
|
|
570
|
+
fieldInfos = cacheFieldInfos(item, fieldInfos, templateDictionary.isPortal);
|
|
563
571
|
/* istanbul ignore else */
|
|
564
|
-
if (
|
|
565
|
-
|
|
566
|
-
fieldInfos.hasOwnProperty(item.id)) {
|
|
567
|
-
Object.keys(templateDictionary).some(function (k) {
|
|
568
|
-
if (templateDictionary[k].itemId === itemTemplate.itemId) {
|
|
569
|
-
fieldInfos[item.id]["sourceServiceFields"] =
|
|
570
|
-
templateDictionary[k].sourceServiceFields;
|
|
571
|
-
return true;
|
|
572
|
-
}
|
|
573
|
-
else {
|
|
574
|
-
return false;
|
|
575
|
-
}
|
|
576
|
-
});
|
|
577
|
-
// view field domain and alias can contain different values than the source field
|
|
578
|
-
// we need to set isViewOverride when added fields that differ from the source field
|
|
579
|
-
_validateViewDomainsAndAlias(fieldInfos[item.id], item);
|
|
572
|
+
if (item.isView) {
|
|
573
|
+
deleteViewProps(item);
|
|
580
574
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
575
|
+
// when the item is a view we need to grab the supporting fieldInfos
|
|
576
|
+
/* istanbul ignore else */
|
|
577
|
+
if (itemTemplate.properties.service.isView) {
|
|
578
|
+
_updateGeomFieldName(item.adminLayerInfo, templateDictionary);
|
|
579
|
+
adminLayerInfos[originalId] = item.adminLayerInfo;
|
|
580
|
+
// need to update adminLayerInfo before adding to the service def
|
|
581
|
+
// bring over the fieldInfos from the source layer
|
|
582
|
+
updateSettingsFieldInfos(itemTemplate, templateDictionary);
|
|
583
|
+
// update adminLayerInfo before add to definition with view source fieldInfo settings
|
|
584
|
+
item.adminLayerInfo = replaceInTemplate(item.adminLayerInfo, templateDictionary);
|
|
585
|
+
/* istanbul ignore else */
|
|
586
|
+
if (!templateDictionary.isPortal &&
|
|
587
|
+
fieldInfos &&
|
|
588
|
+
fieldInfos.hasOwnProperty(item.id)) {
|
|
589
|
+
Object.keys(templateDictionary).some(k => {
|
|
590
|
+
if (templateDictionary[k].itemId === itemTemplate.itemId) {
|
|
591
|
+
fieldInfos[item.id]["sourceServiceFields"] =
|
|
592
|
+
templateDictionary[k].sourceServiceFields;
|
|
593
|
+
return true;
|
|
594
|
+
}
|
|
595
|
+
else {
|
|
596
|
+
return false;
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
// view field domain and alias can contain different values than the source field
|
|
600
|
+
// we need to set isViewOverride when added fields that differ from the source field
|
|
601
|
+
_validateViewDomainsAndAlias(fieldInfos[item.id], item);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
/* istanbul ignore else */
|
|
605
|
+
if (templateDictionary.isPortal) {
|
|
606
|
+
item = _updateForPortal(item, itemTemplate, templateDictionary);
|
|
607
|
+
}
|
|
608
|
+
removeLayerOptimization(item);
|
|
609
|
+
// this can still chunk layers
|
|
610
|
+
options = _updateAddOptions(itemTemplate, item, options, layerChunks, authentication);
|
|
611
|
+
if (item.type === "Feature Layer") {
|
|
612
|
+
options.layers.push(item);
|
|
613
|
+
}
|
|
614
|
+
else {
|
|
615
|
+
options.tables.push(item);
|
|
616
|
+
}
|
|
617
|
+
// In general we are switching to not use chunking. Rather if we exceed the defined chunk size
|
|
618
|
+
// we will use an async request.
|
|
619
|
+
// Currently the only case that should chunk the requests is when we have a multisource view
|
|
620
|
+
// handled in _updateAddOptions above
|
|
621
|
+
/* istanbul ignore else */
|
|
622
|
+
if (i + 1 === listToAdd.length) {
|
|
623
|
+
layerChunks.push(Object.assign({}, options));
|
|
624
|
+
options = {
|
|
625
|
+
layers: [],
|
|
626
|
+
tables: [],
|
|
627
|
+
authentication
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
// will use async by default rather than chunk the layer requests when we have more layers
|
|
632
|
+
// than the defined chunk size
|
|
633
|
+
const useAsync = listToAdd.length > chunkSize;
|
|
634
|
+
layerChunks
|
|
635
|
+
.reduce((prev, curr) => prev.then(() => addToServiceDefinition(serviceUrl, curr, false, useAsync)), Promise.resolve(null))
|
|
636
|
+
.then(() => resolve(null), (e) => reject(fail(e)));
|
|
637
|
+
}
|
|
609
638
|
});
|
|
610
639
|
}
|
|
611
640
|
/**
|
|
@@ -622,17 +651,17 @@ export function addFeatureServiceDefinition(serviceUrl, listToAdd, templateDicti
|
|
|
622
651
|
* @protected
|
|
623
652
|
*/
|
|
624
653
|
export function _updateAddOptions(itemTemplate, item, options, layerChunks, authentication) {
|
|
625
|
-
|
|
626
|
-
|
|
654
|
+
const isMsView = getProp(itemTemplate, "properties.service.isMultiServicesView") || false;
|
|
655
|
+
const serviceName = getProp(itemTemplate, "item.name");
|
|
627
656
|
/* istanbul ignore else */
|
|
628
657
|
if (isMsView) {
|
|
629
|
-
|
|
658
|
+
const table = getProp(item, "adminLayerInfo.viewLayerDefinition.table");
|
|
630
659
|
/* istanbul ignore else */
|
|
631
660
|
if (table) {
|
|
632
|
-
|
|
661
|
+
const tableNames = (table.relatedTables || []).map((t) => t.sourceServiceName);
|
|
633
662
|
tableNames.push(table.sourceServiceName);
|
|
634
663
|
/* istanbul ignore else */
|
|
635
|
-
if (tableNames.some(
|
|
664
|
+
if (tableNames.some(n => n === serviceName)) {
|
|
636
665
|
// if we already have some layers or tables add them first
|
|
637
666
|
/* istanbul ignore else */
|
|
638
667
|
if (options.layers.length > 0 || options.tables.length > 0) {
|
|
@@ -640,7 +669,7 @@ export function _updateAddOptions(itemTemplate, item, options, layerChunks, auth
|
|
|
640
669
|
options = {
|
|
641
670
|
layers: [],
|
|
642
671
|
tables: [],
|
|
643
|
-
authentication
|
|
672
|
+
authentication
|
|
644
673
|
};
|
|
645
674
|
}
|
|
646
675
|
}
|
|
@@ -683,41 +712,41 @@ export function _updateForPortal(item, itemTemplate, templateDictionary) {
|
|
|
683
712
|
// Portal will fail if the sourceFields in the viewLayerDef contain fields that are not in the source service
|
|
684
713
|
/* istanbul ignore else */
|
|
685
714
|
if (item.isView) {
|
|
686
|
-
|
|
687
|
-
|
|
715
|
+
const viewLayerDefTable = getProp(item, "adminLayerInfo.viewLayerDefinition.table");
|
|
716
|
+
let fieldNames = [];
|
|
688
717
|
if (viewLayerDefTable) {
|
|
689
|
-
|
|
690
|
-
|
|
718
|
+
const tableFieldNames = _getFieldNames(viewLayerDefTable, itemTemplate, templateDictionary);
|
|
719
|
+
fieldNames = fieldNames.concat(tableFieldNames);
|
|
691
720
|
setProp(item, "adminLayerInfo.viewLayerDefinition.table", _updateSourceLayerFields(viewLayerDefTable, tableFieldNames));
|
|
692
721
|
// Handle related also
|
|
693
722
|
/* istanbul ignore else */
|
|
694
723
|
if (Array.isArray(viewLayerDefTable.relatedTables)) {
|
|
695
|
-
viewLayerDefTable.relatedTables.map(
|
|
696
|
-
|
|
697
|
-
|
|
724
|
+
viewLayerDefTable.relatedTables.map((relatedTable) => {
|
|
725
|
+
const relatedTableFieldNames = _getFieldNames(relatedTable, itemTemplate, templateDictionary);
|
|
726
|
+
fieldNames = fieldNames.concat(relatedTableFieldNames);
|
|
698
727
|
return _updateSourceLayerFields(relatedTable, relatedTableFieldNames);
|
|
699
728
|
});
|
|
700
729
|
}
|
|
701
730
|
}
|
|
702
731
|
else {
|
|
703
|
-
Object.keys(templateDictionary).some(
|
|
732
|
+
Object.keys(templateDictionary).some(k => {
|
|
704
733
|
/* istanbul ignore else */
|
|
705
734
|
if (templateDictionary[k].itemId === item.serviceItemId) {
|
|
706
|
-
|
|
735
|
+
const layerInfo = templateDictionary[k][`layer${item.id}`];
|
|
707
736
|
/* istanbul ignore else */
|
|
708
737
|
if (layerInfo && layerInfo.fields) {
|
|
709
738
|
if (Array.isArray(layerInfo.fields)) {
|
|
710
|
-
|
|
739
|
+
fieldNames = layerInfo.fields.map((f) => f.name);
|
|
711
740
|
}
|
|
712
741
|
else {
|
|
713
|
-
|
|
742
|
+
fieldNames = Object.keys(layerInfo.fields);
|
|
714
743
|
}
|
|
715
744
|
}
|
|
716
745
|
return true;
|
|
717
746
|
}
|
|
718
747
|
});
|
|
719
748
|
}
|
|
720
|
-
item = _updateItemFields(item,
|
|
749
|
+
item = _updateItemFields(item, fieldNames);
|
|
721
750
|
}
|
|
722
751
|
// not allowed to set sourceSchemaChangesAllowed or isView for portal
|
|
723
752
|
// these are set when you create the service
|
|
@@ -736,19 +765,19 @@ export function _updateForPortal(item, itemTemplate, templateDictionary) {
|
|
|
736
765
|
* @protected
|
|
737
766
|
*/
|
|
738
767
|
export function _getFieldNames(table, itemTemplate, templateDictionary) {
|
|
739
|
-
|
|
740
|
-
|
|
768
|
+
let sourceLayerFields = [];
|
|
769
|
+
const viewSourceLayerId = table.sourceLayerId;
|
|
741
770
|
/* istanbul ignore else */
|
|
742
771
|
if (typeof viewSourceLayerId === "number") {
|
|
743
772
|
// need to make sure these actually exist in the source..
|
|
744
|
-
itemTemplate.dependencies.forEach(
|
|
745
|
-
|
|
773
|
+
itemTemplate.dependencies.forEach(d => {
|
|
774
|
+
const layerInfo = templateDictionary[d][`layer${viewSourceLayerId}`];
|
|
746
775
|
/* istanbul ignore else */
|
|
747
776
|
if (layerInfo &&
|
|
748
777
|
layerInfo.fields &&
|
|
749
778
|
templateDictionary[d].name === table.sourceServiceName) {
|
|
750
779
|
if (Array.isArray(layerInfo.fields)) {
|
|
751
|
-
sourceLayerFields = sourceLayerFields.concat(layerInfo.fields.map(
|
|
780
|
+
sourceLayerFields = sourceLayerFields.concat(layerInfo.fields.map((f) => f.name));
|
|
752
781
|
}
|
|
753
782
|
else {
|
|
754
783
|
sourceLayerFields = sourceLayerFields.concat(Object.keys(layerInfo.fields));
|
|
@@ -772,11 +801,11 @@ export function _updateItemFields(item, fieldNames) {
|
|
|
772
801
|
if (fieldNames.length > 0) {
|
|
773
802
|
/* istanbul ignore else */
|
|
774
803
|
if (item.fields) {
|
|
775
|
-
item.fields = item.fields.filter(
|
|
804
|
+
item.fields = item.fields.filter((f) => fieldNames.indexOf(f.name) > -1);
|
|
776
805
|
}
|
|
777
806
|
/* istanbul ignore else */
|
|
778
807
|
if (item.indexes) {
|
|
779
|
-
item.indexes = item.indexes.filter(
|
|
808
|
+
item.indexes = item.indexes.filter((f) => fieldNames.indexOf(f.fields) > -1);
|
|
780
809
|
}
|
|
781
810
|
}
|
|
782
811
|
return item;
|
|
@@ -796,7 +825,7 @@ export function _updateSourceLayerFields(table, sourceLayerFields) {
|
|
|
796
825
|
// need to make sure these actually exist in the source..
|
|
797
826
|
/* istanbul ignore else */
|
|
798
827
|
if (sourceLayerFields.length > 0) {
|
|
799
|
-
setProp(table, "sourceLayerFields", table.sourceLayerFields.filter(
|
|
828
|
+
setProp(table, "sourceLayerFields", table.sourceLayerFields.filter((f) => sourceLayerFields.indexOf(f.source.toLowerCase()) > -1));
|
|
800
829
|
}
|
|
801
830
|
}
|
|
802
831
|
return table;
|
|
@@ -811,13 +840,13 @@ export function _updateSourceLayerFields(table, sourceLayerFields) {
|
|
|
811
840
|
*/
|
|
812
841
|
export function _updateGeomFieldName(adminLayerInfo, templateDictionary) {
|
|
813
842
|
// issue #471
|
|
814
|
-
|
|
815
|
-
|
|
843
|
+
const tableName = getProp(adminLayerInfo, "viewLayerDefinition.table.name");
|
|
844
|
+
const fieldName = getProp(adminLayerInfo, "geometryField.name");
|
|
816
845
|
/* istanbul ignore else */
|
|
817
846
|
if (fieldName && tableName) {
|
|
818
|
-
|
|
819
|
-
? tableName
|
|
820
|
-
: tableName
|
|
847
|
+
const geomName = templateDictionary.isPortal
|
|
848
|
+
? `${tableName}.shape`
|
|
849
|
+
: `${tableName}.Shape`;
|
|
821
850
|
setProp(adminLayerInfo, "geometryField.name", geomName);
|
|
822
851
|
}
|
|
823
852
|
else if (!fieldName && getProp(adminLayerInfo, "geometryField")) {
|
|
@@ -837,16 +866,15 @@ export function _updateGeomFieldName(adminLayerInfo, templateDictionary) {
|
|
|
837
866
|
* @param templateDictionary Hash mapping Solution source id to id of its clone (and name & URL for feature service)
|
|
838
867
|
* @protected
|
|
839
868
|
*/
|
|
840
|
-
export function _updateTemplateDictionaryFields(itemTemplate, templateDictionary, compareItemId) {
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
layersAndTables.forEach(function (layerOrTable) {
|
|
869
|
+
export function _updateTemplateDictionaryFields(itemTemplate, templateDictionary, compareItemId = true) {
|
|
870
|
+
const layers = itemTemplate.properties.layers;
|
|
871
|
+
const tables = itemTemplate.properties.tables;
|
|
872
|
+
const layersAndTables = layers.concat(tables);
|
|
873
|
+
const fieldInfos = {};
|
|
874
|
+
layersAndTables.forEach(layerOrTable => {
|
|
847
875
|
fieldInfos[layerOrTable.id] = layerOrTable.fields;
|
|
848
876
|
});
|
|
849
|
-
Object.keys(templateDictionary).some(
|
|
877
|
+
Object.keys(templateDictionary).some(k => {
|
|
850
878
|
if (compareItemId
|
|
851
879
|
? templateDictionary[k].itemId === itemTemplate.itemId
|
|
852
880
|
: k === itemTemplate.itemId) {
|
|
@@ -871,7 +899,7 @@ export function _updateTemplateDictionaryFields(itemTemplate, templateDictionary
|
|
|
871
899
|
export function setDefaultSpatialReference(templateDictionary, itemId, spatialReference) {
|
|
872
900
|
/* istanbul ignore else */
|
|
873
901
|
if (spatialReference) {
|
|
874
|
-
setCreateProp(templateDictionary, itemId
|
|
902
|
+
setCreateProp(templateDictionary, `${itemId}.defaultSpatialReference`, spatialReference);
|
|
875
903
|
}
|
|
876
904
|
}
|
|
877
905
|
/**
|
|
@@ -887,34 +915,34 @@ export function setDefaultSpatialReference(templateDictionary, itemId, spatialRe
|
|
|
887
915
|
export function validateSpatialReferenceAndExtent(serviceInfo, itemTemplate, templateDictionary) {
|
|
888
916
|
/* istanbul ignore else */
|
|
889
917
|
if (getProp(serviceInfo, "service.isView")) {
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
itemTemplate.dependencies.some(
|
|
893
|
-
|
|
894
|
-
|
|
918
|
+
let sourceSR;
|
|
919
|
+
let sourceExt;
|
|
920
|
+
itemTemplate.dependencies.some(id => {
|
|
921
|
+
const source = templateDictionary[id];
|
|
922
|
+
const sr = getProp(source, "defaultSpatialReference");
|
|
895
923
|
/* istanbul ignore else */
|
|
896
|
-
if (!
|
|
897
|
-
|
|
924
|
+
if (!sourceSR && sr) {
|
|
925
|
+
sourceSR = sr;
|
|
898
926
|
}
|
|
899
|
-
|
|
927
|
+
const ext = getProp(source, "defaultExtent");
|
|
900
928
|
/* istanbul ignore else */
|
|
901
|
-
if (!
|
|
902
|
-
|
|
929
|
+
if (!sourceExt && ext) {
|
|
930
|
+
sourceExt = ext;
|
|
903
931
|
}
|
|
904
|
-
return
|
|
932
|
+
return sourceSR && sourceExt;
|
|
905
933
|
});
|
|
906
|
-
|
|
907
|
-
|
|
934
|
+
const sourceWkid = getProp(sourceSR, "wkid");
|
|
935
|
+
const viewWkid = getProp(serviceInfo, "service.spatialReference.wkid");
|
|
908
936
|
/* istanbul ignore else */
|
|
909
937
|
if (sourceWkid && viewWkid && sourceWkid !== viewWkid) {
|
|
910
|
-
setCreateProp(serviceInfo, "service.spatialReference",
|
|
938
|
+
setCreateProp(serviceInfo, "service.spatialReference", sourceSR);
|
|
911
939
|
}
|
|
912
|
-
|
|
940
|
+
const viewExt = getProp(serviceInfo, "service.fullExtent");
|
|
913
941
|
/* istanbul ignore else */
|
|
914
|
-
if (
|
|
942
|
+
if (sourceExt &&
|
|
915
943
|
viewExt &&
|
|
916
|
-
JSON.stringify(
|
|
917
|
-
setCreateProp(serviceInfo, "defaultExtent",
|
|
944
|
+
JSON.stringify(sourceExt) !== JSON.stringify(viewExt)) {
|
|
945
|
+
setCreateProp(serviceInfo, "defaultExtent", sourceExt);
|
|
918
946
|
}
|
|
919
947
|
}
|
|
920
948
|
}
|
|
@@ -931,17 +959,17 @@ export function validateSpatialReferenceAndExtent(serviceInfo, itemTemplate, tem
|
|
|
931
959
|
* @protected
|
|
932
960
|
*/
|
|
933
961
|
export function updateLayerFieldReferences(itemTemplate, fieldInfos, popupInfos, adminLayerInfos, templateDictionary) {
|
|
934
|
-
return new Promise(
|
|
962
|
+
return new Promise((resolveFn, rejectFn) => {
|
|
935
963
|
// Will need to do some post processing for fields
|
|
936
964
|
// to handle any potential field name changes when deploying to portal
|
|
937
|
-
postProcessFields(itemTemplate, fieldInfos, popupInfos, adminLayerInfos, templateDictionary).then(
|
|
965
|
+
postProcessFields(itemTemplate, fieldInfos, popupInfos, adminLayerInfos, templateDictionary).then((layerInfos) => {
|
|
938
966
|
// Update the items text with detemplatized popupInfo
|
|
939
967
|
updatePopupInfo(itemTemplate, layerInfos.popupInfos);
|
|
940
968
|
resolveFn({
|
|
941
|
-
itemTemplate
|
|
942
|
-
layerInfos
|
|
969
|
+
itemTemplate,
|
|
970
|
+
layerInfos
|
|
943
971
|
});
|
|
944
|
-
},
|
|
972
|
+
}, e => rejectFn(fail(e)));
|
|
945
973
|
});
|
|
946
974
|
}
|
|
947
975
|
/**
|
|
@@ -958,17 +986,17 @@ export function updateLayerFieldReferences(itemTemplate, fieldInfos, popupInfos,
|
|
|
958
986
|
* @protected
|
|
959
987
|
*/
|
|
960
988
|
export function postProcessFields(itemTemplate, layerInfos, popupInfos, adminLayerInfos, templateDictionary) {
|
|
961
|
-
return new Promise(
|
|
989
|
+
return new Promise((resolveFn, rejectFn) => {
|
|
962
990
|
if (!itemTemplate.item.url) {
|
|
963
991
|
rejectFn(fail("Feature layer " + itemTemplate.itemId + " does not have a URL"));
|
|
964
992
|
}
|
|
965
993
|
else {
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
settingsKeys.some(
|
|
970
|
-
if (templateDictionary[k].itemId ===
|
|
971
|
-
|
|
994
|
+
const id = itemTemplate.itemId;
|
|
995
|
+
const settingsKeys = Object.keys(templateDictionary);
|
|
996
|
+
let templateInfo;
|
|
997
|
+
settingsKeys.some(k => {
|
|
998
|
+
if (templateDictionary[k].itemId === id) {
|
|
999
|
+
templateInfo = templateDictionary[k];
|
|
972
1000
|
return true;
|
|
973
1001
|
}
|
|
974
1002
|
else {
|
|
@@ -976,19 +1004,19 @@ export function postProcessFields(itemTemplate, layerInfos, popupInfos, adminLay
|
|
|
976
1004
|
}
|
|
977
1005
|
});
|
|
978
1006
|
// concat any layers and tables to process
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
1007
|
+
const layers = itemTemplate.properties.layers;
|
|
1008
|
+
const tables = itemTemplate.properties.tables;
|
|
1009
|
+
const layersAndTables = layers.concat(tables);
|
|
982
1010
|
// Set the newFields property for the layerInfos...this will contain all fields
|
|
983
1011
|
// as they are after being added to the definition.
|
|
984
1012
|
// This allows us to handle any potential field name changes after deploy to portal
|
|
985
|
-
layersAndTables.forEach(
|
|
1013
|
+
layersAndTables.forEach((item) => {
|
|
986
1014
|
// when deploying to portal "isView" is only set for create service and will fail when
|
|
987
1015
|
// present on addToDef so this property is removed from item and we should check the templates service info
|
|
988
|
-
|
|
1016
|
+
const isView = item.isView || itemTemplate.properties.service.isView;
|
|
989
1017
|
/* istanbul ignore else */
|
|
990
1018
|
if (layerInfos && layerInfos.hasOwnProperty(item.id)) {
|
|
991
|
-
|
|
1019
|
+
const layerInfo = layerInfos[item.id];
|
|
992
1020
|
layerInfo["isView"] = item.isView;
|
|
993
1021
|
layerInfo["newFields"] = item.fields;
|
|
994
1022
|
layerInfo["sourceSchemaChangesAllowed"] =
|
|
@@ -1002,10 +1030,10 @@ export function postProcessFields(itemTemplate, layerInfos, popupInfos, adminLay
|
|
|
1002
1030
|
// visible true when added with the layer definition
|
|
1003
1031
|
// update the field visibility to match that of the source
|
|
1004
1032
|
/* istanbul ignore else */
|
|
1005
|
-
if (isView &&
|
|
1033
|
+
if (isView && templateInfo && templateDictionary.isPortal) {
|
|
1006
1034
|
// when the item is a view bring over the source service fields so we can compare the domains
|
|
1007
|
-
layerInfo["sourceServiceFields"] =
|
|
1008
|
-
|
|
1035
|
+
layerInfo["sourceServiceFields"] = templateInfo.sourceServiceFields;
|
|
1036
|
+
let fieldUpdates = _getFieldVisibilityUpdates(layerInfo);
|
|
1009
1037
|
// view field domains can contain different values than the source field domains
|
|
1010
1038
|
// use the cached view domain when it differs from the source view domain
|
|
1011
1039
|
fieldUpdates = _validateDomains(layerInfo, fieldUpdates);
|
|
@@ -1014,16 +1042,16 @@ export function postProcessFields(itemTemplate, layerInfos, popupInfos, adminLay
|
|
|
1014
1042
|
layerInfo.fields = fieldUpdates;
|
|
1015
1043
|
}
|
|
1016
1044
|
layerInfo.typeIdField = _getTypeIdField(item);
|
|
1017
|
-
|
|
1045
|
+
const fieldNames = layerInfo.newFields.map((f) => f.name);
|
|
1018
1046
|
_validateTemplatesFields(layerInfo, fieldNames);
|
|
1019
1047
|
_validateTypesTemplates(layerInfo, fieldNames);
|
|
1020
1048
|
}
|
|
1021
1049
|
}
|
|
1022
1050
|
});
|
|
1023
1051
|
// Add the layerInfos to the settings object to be used while detemplatizing
|
|
1024
|
-
settingsKeys.forEach(
|
|
1025
|
-
if (
|
|
1026
|
-
templateDictionary[k] = Object.assign(templateDictionary[k], getLayerSettings(layerInfos, templateDictionary[k].url,
|
|
1052
|
+
settingsKeys.forEach((k) => {
|
|
1053
|
+
if (id === templateDictionary[k].itemId) {
|
|
1054
|
+
templateDictionary[k] = Object.assign(templateDictionary[k], getLayerSettings(layerInfos, templateDictionary[k].url, id));
|
|
1027
1055
|
}
|
|
1028
1056
|
});
|
|
1029
1057
|
// update the layerInfos object with current field names
|
|
@@ -1040,7 +1068,7 @@ export function postProcessFields(itemTemplate, layerInfos, popupInfos, adminLay
|
|
|
1040
1068
|
* @protected
|
|
1041
1069
|
*/
|
|
1042
1070
|
export function _getTypeIdField(item) {
|
|
1043
|
-
|
|
1071
|
+
const typeIdFields = item.fields.filter((f) => {
|
|
1044
1072
|
return (f.name &&
|
|
1045
1073
|
item.typeIdField &&
|
|
1046
1074
|
f.name.toLowerCase() === item.typeIdField.toLowerCase());
|
|
@@ -1059,19 +1087,19 @@ export function _getTypeIdField(item) {
|
|
|
1059
1087
|
* @protected
|
|
1060
1088
|
*/
|
|
1061
1089
|
export function _getFieldVisibilityUpdates(fieldInfo) {
|
|
1062
|
-
|
|
1090
|
+
const visibilityUpdates = [];
|
|
1063
1091
|
if (fieldInfo && fieldInfo["sourceFields"] && fieldInfo["newFields"]) {
|
|
1064
|
-
|
|
1092
|
+
const sourceFields = fieldInfo["sourceFields"].reduce((hash, f) => {
|
|
1065
1093
|
hash[String(f.name).toLocaleLowerCase()] = f.visible;
|
|
1066
1094
|
return hash;
|
|
1067
1095
|
}, {});
|
|
1068
|
-
fieldInfo["newFields"].forEach(
|
|
1069
|
-
|
|
1096
|
+
fieldInfo["newFields"].forEach((f) => {
|
|
1097
|
+
const name = String(f.name).toLocaleLowerCase();
|
|
1070
1098
|
// only add fields that are not visible
|
|
1071
|
-
if (
|
|
1099
|
+
if (sourceFields.hasOwnProperty(name) && !sourceFields[name]) {
|
|
1072
1100
|
visibilityUpdates.push({
|
|
1073
1101
|
name: f.name,
|
|
1074
|
-
visible:
|
|
1102
|
+
visible: sourceFields[name]
|
|
1075
1103
|
});
|
|
1076
1104
|
}
|
|
1077
1105
|
});
|
|
@@ -1088,14 +1116,14 @@ export function _getFieldVisibilityUpdates(fieldInfo) {
|
|
|
1088
1116
|
* @protected
|
|
1089
1117
|
*/
|
|
1090
1118
|
export function _validateDomains(fieldInfo, fieldUpdates) {
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1119
|
+
const domainAliasInfos = _getDomainAndAliasInfos(fieldInfo);
|
|
1120
|
+
const domainFields = domainAliasInfos.domainFields;
|
|
1121
|
+
const domainNames = domainAliasInfos.domainNames;
|
|
1122
|
+
const aliasFields = domainAliasInfos.aliasFields;
|
|
1123
|
+
const aliasNames = domainAliasInfos.aliasNames;
|
|
1096
1124
|
// loop through the fields from the new view service
|
|
1097
1125
|
// add an update when the domains don't match
|
|
1098
|
-
fieldInfo.newFields.forEach(
|
|
1126
|
+
fieldInfo.newFields.forEach((field) => {
|
|
1099
1127
|
_getPortalViewFieldUpdates(field, domainNames, domainFields, "domain", fieldUpdates);
|
|
1100
1128
|
_getPortalViewFieldUpdates(field, aliasNames, aliasFields, "alias", fieldUpdates);
|
|
1101
1129
|
});
|
|
@@ -1114,19 +1142,19 @@ export function _validateDomains(fieldInfo, fieldUpdates) {
|
|
|
1114
1142
|
*/
|
|
1115
1143
|
export function _getPortalViewFieldUpdates(field, names, fields, key, fieldUpdates) {
|
|
1116
1144
|
if (field.hasOwnProperty(key) && field[key]) {
|
|
1117
|
-
|
|
1145
|
+
const i = names.indexOf(String(field.name).toLocaleLowerCase());
|
|
1118
1146
|
if (JSON.stringify(field[key]) !== (i > -1 ? JSON.stringify(fields[i]) : "")) {
|
|
1119
1147
|
// should mixin the update if the field already has some other update
|
|
1120
|
-
|
|
1121
|
-
fieldUpdates.some(
|
|
1148
|
+
let hasUpdate = false;
|
|
1149
|
+
fieldUpdates.some((update) => {
|
|
1122
1150
|
if (update.name === field.name) {
|
|
1123
|
-
|
|
1151
|
+
hasUpdate = true;
|
|
1124
1152
|
update[key] = field[key];
|
|
1125
1153
|
}
|
|
1126
|
-
return
|
|
1154
|
+
return hasUpdate;
|
|
1127
1155
|
});
|
|
1128
|
-
if (!
|
|
1129
|
-
|
|
1156
|
+
if (!hasUpdate) {
|
|
1157
|
+
const update = { name: field.name };
|
|
1130
1158
|
update[key] = field[key];
|
|
1131
1159
|
fieldUpdates.push(update);
|
|
1132
1160
|
}
|
|
@@ -1143,14 +1171,14 @@ export function _getPortalViewFieldUpdates(field, names, fields, key, fieldUpdat
|
|
|
1143
1171
|
* @protected
|
|
1144
1172
|
*/
|
|
1145
1173
|
export function _validateViewDomainsAndAlias(fieldInfo, item) {
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1174
|
+
const domainAliasInfos = _getDomainAndAliasInfos(fieldInfo);
|
|
1175
|
+
const domainFields = domainAliasInfos.domainFields;
|
|
1176
|
+
const domainNames = domainAliasInfos.domainNames;
|
|
1177
|
+
const aliasFields = domainAliasInfos.aliasFields;
|
|
1178
|
+
const aliasNames = domainAliasInfos.aliasNames;
|
|
1151
1179
|
// loop through the fields from the item
|
|
1152
1180
|
// add isViewOverride when the domains or alias don't match
|
|
1153
|
-
item.fields.map(
|
|
1181
|
+
item.fields.map((field) => {
|
|
1154
1182
|
_isViewFieldOverride(field, domainNames, domainFields, "domain");
|
|
1155
1183
|
_isViewFieldOverride(field, aliasNames, aliasFields, "alias");
|
|
1156
1184
|
return field;
|
|
@@ -1163,17 +1191,17 @@ export function _validateViewDomainsAndAlias(fieldInfo, item) {
|
|
|
1163
1191
|
*
|
|
1164
1192
|
*/
|
|
1165
1193
|
export function _getDomainAndAliasInfos(fieldInfo) {
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1194
|
+
const domainFields = [];
|
|
1195
|
+
const domainNames = [];
|
|
1196
|
+
const aliasFields = [];
|
|
1197
|
+
const aliasNames = [];
|
|
1170
1198
|
/* istanbul ignore else */
|
|
1171
1199
|
if (fieldInfo.sourceServiceFields) {
|
|
1172
|
-
Object.keys(fieldInfo.sourceServiceFields).forEach(
|
|
1200
|
+
Object.keys(fieldInfo.sourceServiceFields).forEach(k => {
|
|
1173
1201
|
/* istanbul ignore else */
|
|
1174
1202
|
if (fieldInfo.sourceServiceFields[k]) {
|
|
1175
|
-
Object.keys(fieldInfo.sourceServiceFields[k]).forEach(
|
|
1176
|
-
fieldInfo.sourceServiceFields[k][_k].forEach(
|
|
1203
|
+
Object.keys(fieldInfo.sourceServiceFields[k]).forEach(_k => {
|
|
1204
|
+
fieldInfo.sourceServiceFields[k][_k].forEach((field) => {
|
|
1177
1205
|
/* istanbul ignore else */
|
|
1178
1206
|
if (field.hasOwnProperty("domain") && field.domain) {
|
|
1179
1207
|
domainFields.push(field.domain);
|
|
@@ -1190,10 +1218,10 @@ export function _getDomainAndAliasInfos(fieldInfo) {
|
|
|
1190
1218
|
});
|
|
1191
1219
|
}
|
|
1192
1220
|
return {
|
|
1193
|
-
aliasFields
|
|
1194
|
-
aliasNames
|
|
1195
|
-
domainFields
|
|
1196
|
-
domainNames
|
|
1221
|
+
aliasFields,
|
|
1222
|
+
aliasNames,
|
|
1223
|
+
domainFields,
|
|
1224
|
+
domainNames
|
|
1197
1225
|
};
|
|
1198
1226
|
}
|
|
1199
1227
|
/**
|
|
@@ -1208,7 +1236,7 @@ export function _getDomainAndAliasInfos(fieldInfo) {
|
|
|
1208
1236
|
export function _isViewFieldOverride(field, names, fields, key) {
|
|
1209
1237
|
/* istanbul ignore else */
|
|
1210
1238
|
if (field.hasOwnProperty(key) && field[key]) {
|
|
1211
|
-
|
|
1239
|
+
const i = names.indexOf(String(field.name).toLocaleLowerCase());
|
|
1212
1240
|
/* istanbul ignore else */
|
|
1213
1241
|
if (JSON.stringify(field[key]) !== (i > -1 ? JSON.stringify(fields[i]) : "")) {
|
|
1214
1242
|
field.isViewOverride = true;
|
|
@@ -1223,11 +1251,11 @@ export function _isViewFieldOverride(field, names, fields, key) {
|
|
|
1223
1251
|
* @protected
|
|
1224
1252
|
*/
|
|
1225
1253
|
export function updatePopupInfo(itemTemplate, popupInfos) {
|
|
1226
|
-
["layers", "tables"].forEach(
|
|
1227
|
-
|
|
1254
|
+
["layers", "tables"].forEach(type => {
|
|
1255
|
+
const _items = getProp(itemTemplate, "data." + type);
|
|
1228
1256
|
/* istanbul ignore else */
|
|
1229
1257
|
if (_items && Array.isArray(_items)) {
|
|
1230
|
-
_items.forEach(
|
|
1258
|
+
_items.forEach((item) => {
|
|
1231
1259
|
item.popupInfo = getProp(popupInfos, type + "." + item.id) || {};
|
|
1232
1260
|
});
|
|
1233
1261
|
}
|
|
@@ -1280,11 +1308,11 @@ export function _templatizeLayer(dataItem, adminItem, itemTemplate, dependencies
|
|
|
1280
1308
|
if (templatizeFieldReferences) {
|
|
1281
1309
|
_templatizeLayerFieldReferences(dataItem, itemTemplate.itemId, adminItem, dependencies);
|
|
1282
1310
|
}
|
|
1283
|
-
|
|
1311
|
+
const updates = [adminItem];
|
|
1284
1312
|
if (dataItem) {
|
|
1285
1313
|
updates.push(dataItem);
|
|
1286
1314
|
}
|
|
1287
|
-
updates.forEach(
|
|
1315
|
+
updates.forEach(update => {
|
|
1288
1316
|
if (update.hasOwnProperty("name")) {
|
|
1289
1317
|
// templatize the name but leave the current name as the optional default
|
|
1290
1318
|
update.name = templatizeTerm(update["serviceItemId"] + ".layer" + update.id, update["serviceItemId"] + ".layer" + update.id, ".name||" + update.name);
|
|
@@ -1307,7 +1335,7 @@ export function _templatizeLayer(dataItem, adminItem, itemTemplate, dependencies
|
|
|
1307
1335
|
* @param adminItem layer or table from the service
|
|
1308
1336
|
*/
|
|
1309
1337
|
export function _validateFields(adminItem) {
|
|
1310
|
-
|
|
1338
|
+
const fieldNames = (adminItem.fields || []).map((f) => f.name);
|
|
1311
1339
|
// Update primary display field if field isn't in the layer.
|
|
1312
1340
|
_validateDisplayField(adminItem, fieldNames);
|
|
1313
1341
|
// Remove indexes on fields that don't exist in the layer.
|
|
@@ -1327,9 +1355,9 @@ export function _validateFields(adminItem) {
|
|
|
1327
1355
|
* @param fieldNames string list of fields names
|
|
1328
1356
|
*/
|
|
1329
1357
|
export function _validateDisplayField(adminItem, fieldNames) {
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
if (fieldNames.some(
|
|
1358
|
+
const displayField = adminItem.displayField || "";
|
|
1359
|
+
let i = -1;
|
|
1360
|
+
if (fieldNames.some(name => {
|
|
1333
1361
|
i += 1;
|
|
1334
1362
|
return name === displayField || name === displayField.toLowerCase();
|
|
1335
1363
|
})) {
|
|
@@ -1337,19 +1365,19 @@ export function _validateDisplayField(adminItem, fieldNames) {
|
|
|
1337
1365
|
}
|
|
1338
1366
|
else {
|
|
1339
1367
|
// use the first non-OID non-globalId field we find
|
|
1340
|
-
|
|
1341
|
-
|
|
1368
|
+
const skipFields = [];
|
|
1369
|
+
const oidField = getProp(adminItem, "uniqueIdField.name");
|
|
1342
1370
|
/* istanbul ignore else */
|
|
1343
1371
|
if (oidField) {
|
|
1344
|
-
|
|
1372
|
+
skipFields.push(oidField);
|
|
1345
1373
|
}
|
|
1346
|
-
|
|
1374
|
+
const globalIdField = getProp(adminItem, "globalIdField");
|
|
1347
1375
|
/* istanbul ignore else */
|
|
1348
1376
|
if (globalIdField) {
|
|
1349
|
-
|
|
1377
|
+
skipFields.push(globalIdField);
|
|
1350
1378
|
}
|
|
1351
|
-
fieldNames.some(
|
|
1352
|
-
if (
|
|
1379
|
+
fieldNames.some(name => {
|
|
1380
|
+
if (skipFields.indexOf(name) === -1) {
|
|
1353
1381
|
adminItem.displayField = name;
|
|
1354
1382
|
return true;
|
|
1355
1383
|
}
|
|
@@ -1367,17 +1395,17 @@ export function _validateDisplayField(adminItem, fieldNames) {
|
|
|
1367
1395
|
* @param fieldNames string list of fields names
|
|
1368
1396
|
*/
|
|
1369
1397
|
export function _validateIndexes(adminItem, fieldNames) {
|
|
1370
|
-
|
|
1398
|
+
const indexes = adminItem.indexes;
|
|
1371
1399
|
/* istanbul ignore else */
|
|
1372
1400
|
if (indexes) {
|
|
1373
|
-
|
|
1374
|
-
adminItem.indexes = indexes.reduce(
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
indexFields.forEach(
|
|
1401
|
+
const indexedFields = [];
|
|
1402
|
+
adminItem.indexes = indexes.reduce((filtered, index) => {
|
|
1403
|
+
const indexFields = index.fields.split(",");
|
|
1404
|
+
const verifiedFields = [];
|
|
1405
|
+
indexFields.forEach(indexField => {
|
|
1378
1406
|
/* istanbul ignore else */
|
|
1379
|
-
if (
|
|
1380
|
-
|
|
1407
|
+
if (indexedFields.indexOf(indexField) === -1) {
|
|
1408
|
+
indexedFields.push(indexField);
|
|
1381
1409
|
// this is the first index with this field and it should be added if the field exists
|
|
1382
1410
|
/* istanbul ignore else */
|
|
1383
1411
|
if (fieldNames.indexOf(indexField) > -1) {
|
|
@@ -1402,14 +1430,14 @@ export function _validateIndexes(adminItem, fieldNames) {
|
|
|
1402
1430
|
* @param fieldNames string list of fields names
|
|
1403
1431
|
*/
|
|
1404
1432
|
export function _validateTemplatesFields(adminItem, fieldNames) {
|
|
1405
|
-
|
|
1433
|
+
const templates = adminItem.templates;
|
|
1406
1434
|
/* istanbul ignore else */
|
|
1407
1435
|
if (templates) {
|
|
1408
|
-
adminItem.templates = templates.map(
|
|
1409
|
-
|
|
1436
|
+
adminItem.templates = templates.map(template => {
|
|
1437
|
+
const attributes = getProp(template, "prototype.attributes");
|
|
1410
1438
|
/* istanbul ignore else */
|
|
1411
1439
|
if (attributes) {
|
|
1412
|
-
Object.keys(attributes).forEach(
|
|
1440
|
+
Object.keys(attributes).forEach(k => {
|
|
1413
1441
|
/* istanbul ignore else */
|
|
1414
1442
|
if (fieldNames.indexOf(k) === -1) {
|
|
1415
1443
|
delete attributes[k];
|
|
@@ -1428,10 +1456,10 @@ export function _validateTemplatesFields(adminItem, fieldNames) {
|
|
|
1428
1456
|
* @param fieldNames string list of fields names
|
|
1429
1457
|
*/
|
|
1430
1458
|
export function _validateTypesTemplates(adminItem, fieldNames) {
|
|
1431
|
-
|
|
1459
|
+
const types = adminItem.types;
|
|
1432
1460
|
/* istanbul ignore else */
|
|
1433
1461
|
if (types) {
|
|
1434
|
-
adminItem.types = types.map(
|
|
1462
|
+
adminItem.types = types.map(t => {
|
|
1435
1463
|
_validateTemplatesFields(t, fieldNames);
|
|
1436
1464
|
return t;
|
|
1437
1465
|
});
|
|
@@ -1444,15 +1472,15 @@ export function _validateTypesTemplates(adminItem, fieldNames) {
|
|
|
1444
1472
|
* @param fieldNames string list of fields names
|
|
1445
1473
|
*/
|
|
1446
1474
|
export function _validateEditFieldsInfo(adminItem, fieldNames) {
|
|
1447
|
-
|
|
1475
|
+
const editFieldsInfo = adminItem.editFieldsInfo;
|
|
1448
1476
|
/* istanbul ignore else */
|
|
1449
1477
|
if (editFieldsInfo) {
|
|
1450
|
-
|
|
1451
|
-
editFieldsInfoKeys.forEach(
|
|
1452
|
-
|
|
1478
|
+
const editFieldsInfoKeys = Object.keys(editFieldsInfo);
|
|
1479
|
+
editFieldsInfoKeys.forEach(k => {
|
|
1480
|
+
const editFieldName = editFieldsInfo[k];
|
|
1453
1481
|
/* istanbul ignore else */
|
|
1454
1482
|
if (editFieldName) {
|
|
1455
|
-
fieldNames.some(
|
|
1483
|
+
fieldNames.some(name => {
|
|
1456
1484
|
if (name === editFieldName) {
|
|
1457
1485
|
return true;
|
|
1458
1486
|
}
|
|
@@ -1482,9 +1510,9 @@ export function _validateEditFieldsInfo(adminItem, fieldNames) {
|
|
|
1482
1510
|
*/
|
|
1483
1511
|
export function _templatizeLayerFieldReferences(dataItem, itemID, layer, dependencies) {
|
|
1484
1512
|
// This is the value that will be used as the template for adlib replacement
|
|
1485
|
-
|
|
1513
|
+
const path = itemID + ".layer" + layer.id + ".fields";
|
|
1486
1514
|
// Get the field names for various tests
|
|
1487
|
-
|
|
1515
|
+
const fieldNames = layer.fields.map((f) => f.name);
|
|
1488
1516
|
// Update the layer from the items data property
|
|
1489
1517
|
if (dataItem) {
|
|
1490
1518
|
_templatizeAdminLayerInfoFields(dataItem, dependencies);
|
|
@@ -1512,14 +1540,14 @@ export function _templatizeLayerFieldReferences(dataItem, itemID, layer, depende
|
|
|
1512
1540
|
*/
|
|
1513
1541
|
export function _templatizeAdminLayerInfo(layer, dependencies, templateDictionary) {
|
|
1514
1542
|
// Create new instance of adminLayerInfo to update for clone
|
|
1515
|
-
|
|
1543
|
+
const adminLayerInfo = Object.assign({}, layer.adminLayerInfo);
|
|
1516
1544
|
_updateGeomFieldName(adminLayerInfo, templateDictionary);
|
|
1517
1545
|
deleteProp(adminLayerInfo, "xssTrustedFields");
|
|
1518
1546
|
deleteProp(adminLayerInfo, "tableName");
|
|
1519
1547
|
// Remove unnecessary properties and templatize key properties from viewLayerDefinition
|
|
1520
1548
|
/* istanbul ignore else */
|
|
1521
1549
|
if (adminLayerInfo.viewLayerDefinition) {
|
|
1522
|
-
|
|
1550
|
+
const viewDef = Object.assign({}, adminLayerInfo.viewLayerDefinition);
|
|
1523
1551
|
_processAdminObject(viewDef, dependencies);
|
|
1524
1552
|
// Remove unnecessary properties and templatize key properties from viewLayerDefinition.table
|
|
1525
1553
|
/* istanbul ignore else */
|
|
@@ -1527,7 +1555,7 @@ export function _templatizeAdminLayerInfo(layer, dependencies, templateDictionar
|
|
|
1527
1555
|
_processAdminObject(viewDef.table, dependencies);
|
|
1528
1556
|
/* istanbul ignore else */
|
|
1529
1557
|
if (viewDef.table.relatedTables) {
|
|
1530
|
-
viewDef.table.relatedTables.forEach(
|
|
1558
|
+
viewDef.table.relatedTables.forEach((table) => {
|
|
1531
1559
|
_processAdminObject(table, dependencies);
|
|
1532
1560
|
});
|
|
1533
1561
|
}
|
|
@@ -1558,7 +1586,7 @@ export function _processAdminObject(object, dependencies) {
|
|
|
1558
1586
|
* @protected
|
|
1559
1587
|
*/
|
|
1560
1588
|
export function _templatizeSourceServiceName(lookupName, dependencies) {
|
|
1561
|
-
|
|
1589
|
+
const deps = dependencies.filter(dependency => dependency.name === lookupName);
|
|
1562
1590
|
return deps.length === 1 ? _templatize(deps[0].id, "name") : undefined;
|
|
1563
1591
|
}
|
|
1564
1592
|
/**
|
|
@@ -1570,25 +1598,25 @@ export function _templatizeSourceServiceName(lookupName, dependencies) {
|
|
|
1570
1598
|
*/
|
|
1571
1599
|
export function _templatizeAdminLayerInfoFields(layer, dependencies) {
|
|
1572
1600
|
// templatize the source layer fields
|
|
1573
|
-
|
|
1601
|
+
const table = getProp(layer, "adminLayerInfo.viewLayerDefinition.table");
|
|
1574
1602
|
if (table) {
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
_templatizeAdminSourceLayerFields(table.sourceLayerFields || [],
|
|
1603
|
+
let id = _getDependantItemId(table.sourceServiceName, dependencies);
|
|
1604
|
+
const path = id + ".layer" + table.sourceLayerId + ".fields";
|
|
1605
|
+
_templatizeAdminSourceLayerFields(table.sourceLayerFields || [], path);
|
|
1578
1606
|
// templatize the releated table fields
|
|
1579
|
-
|
|
1607
|
+
const relatedTables = getProp(layer, "adminLayerInfo.viewLayerDefinition.table.relatedTables") || [];
|
|
1580
1608
|
if (relatedTables.length > 0) {
|
|
1581
|
-
relatedTables.forEach(
|
|
1582
|
-
|
|
1583
|
-
|
|
1609
|
+
relatedTables.forEach((t) => {
|
|
1610
|
+
id = _getDependantItemId(t.sourceServiceName, dependencies);
|
|
1611
|
+
const relatedPath = id + ".layer" + t.sourceLayerId + ".fields";
|
|
1584
1612
|
_templatizeTopFilter(t.topFilter || {}, relatedPath);
|
|
1585
1613
|
_templatizeAdminSourceLayerFields(t.sourceLayerFields || [], relatedPath);
|
|
1586
|
-
|
|
1587
|
-
t.parentKeyFields = parentKeyFields.map(
|
|
1588
|
-
return _templatize(
|
|
1614
|
+
const parentKeyFields = t.parentKeyFields || [];
|
|
1615
|
+
t.parentKeyFields = parentKeyFields.map((f) => {
|
|
1616
|
+
return _templatize(path, f, "name");
|
|
1589
1617
|
});
|
|
1590
|
-
|
|
1591
|
-
t.keyFields = keyFields.map(
|
|
1618
|
+
const keyFields = t.keyFields || [];
|
|
1619
|
+
t.keyFields = keyFields.map((f) => {
|
|
1592
1620
|
return _templatize(relatedPath, f, "name");
|
|
1593
1621
|
});
|
|
1594
1622
|
});
|
|
@@ -1602,7 +1630,7 @@ export function _templatizeAdminLayerInfoFields(layer, dependencies) {
|
|
|
1602
1630
|
* @param dependencies array of item dependencies
|
|
1603
1631
|
*/
|
|
1604
1632
|
export function _getDependantItemId(lookupName, dependencies) {
|
|
1605
|
-
|
|
1633
|
+
const deps = dependencies.filter(dependency => dependency.name === lookupName);
|
|
1606
1634
|
return deps.length === 1 ? deps[0].id : "";
|
|
1607
1635
|
}
|
|
1608
1636
|
/**
|
|
@@ -1612,7 +1640,7 @@ export function _getDependantItemId(lookupName, dependencies) {
|
|
|
1612
1640
|
* @param basePath path used to de-templatize while deploying
|
|
1613
1641
|
*/
|
|
1614
1642
|
export function _templatizeAdminSourceLayerFields(fields, basePath) {
|
|
1615
|
-
fields.forEach(
|
|
1643
|
+
fields.forEach(f => _templatizeProperty(f, "source", basePath, "name"));
|
|
1616
1644
|
}
|
|
1617
1645
|
/**
|
|
1618
1646
|
* templatize the topFilter property from adminLayerInfo related tables
|
|
@@ -1624,19 +1652,19 @@ export function _templatizeTopFilter(topFilter, basePath) {
|
|
|
1624
1652
|
/* istanbul ignore else */
|
|
1625
1653
|
if (topFilter) {
|
|
1626
1654
|
// templatize the orderByFields prop
|
|
1627
|
-
|
|
1655
|
+
const orderByFields = topFilter["orderByFields"] || "";
|
|
1628
1656
|
/* istanbul ignore else */
|
|
1629
1657
|
if (orderByFields !== "") {
|
|
1630
|
-
|
|
1658
|
+
const orderByField = orderByFields.split(" ")[0];
|
|
1631
1659
|
topFilter.orderByFields = topFilter.orderByFields.replace(orderByField, _templatize(basePath, orderByField, "name"));
|
|
1632
1660
|
}
|
|
1633
|
-
|
|
1661
|
+
const groupByFields = topFilter["groupByFields"] || "";
|
|
1634
1662
|
/* istanbul ignore else */
|
|
1635
1663
|
if (groupByFields !== "") {
|
|
1636
|
-
|
|
1664
|
+
const _groupByFields = groupByFields.split(",");
|
|
1637
1665
|
/* istanbul ignore else */
|
|
1638
1666
|
if (_groupByFields.length > 0) {
|
|
1639
|
-
|
|
1667
|
+
const mappedFields = _groupByFields.map((f) => {
|
|
1640
1668
|
return _templatize(basePath, f, "name");
|
|
1641
1669
|
});
|
|
1642
1670
|
topFilter.groupByFields = mappedFields.join(",");
|
|
@@ -1652,11 +1680,11 @@ export function _templatizeTopFilter(topFilter, basePath) {
|
|
|
1652
1680
|
*/
|
|
1653
1681
|
export function _templatizeRelationshipFields(layer, itemID) {
|
|
1654
1682
|
if (layer && layer.relationships) {
|
|
1655
|
-
|
|
1656
|
-
relationships.forEach(
|
|
1683
|
+
const relationships = layer.relationships;
|
|
1684
|
+
relationships.forEach(r => {
|
|
1657
1685
|
/* istanbul ignore else */
|
|
1658
1686
|
if (r.keyField) {
|
|
1659
|
-
|
|
1687
|
+
const basePath = itemID + ".layer" + layer.id + ".fields";
|
|
1660
1688
|
_templatizeProperty(r, "keyField", basePath, "name");
|
|
1661
1689
|
}
|
|
1662
1690
|
});
|
|
@@ -1675,16 +1703,16 @@ export function _templatizePopupInfo(layerDefinition, layer, basePath, itemID, f
|
|
|
1675
1703
|
// the data layer does not have the fields...will need to get those
|
|
1676
1704
|
// from the associated layer json
|
|
1677
1705
|
if (fieldNames && layerDefinition.popupInfo) {
|
|
1678
|
-
|
|
1706
|
+
const popupInfo = layerDefinition.popupInfo;
|
|
1679
1707
|
_templatizeName(popupInfo, "title", fieldNames, basePath);
|
|
1680
1708
|
_templatizeName(popupInfo, "description", fieldNames, basePath);
|
|
1681
|
-
|
|
1709
|
+
const fieldInfos = popupInfo.fieldInfos || [];
|
|
1682
1710
|
_templatizePopupInfoFieldInfos(fieldInfos, layer, itemID, basePath);
|
|
1683
|
-
|
|
1711
|
+
const expressionInfos = popupInfo.expressionInfos || [];
|
|
1684
1712
|
_templatizeExpressionInfos(expressionInfos, fieldNames, basePath);
|
|
1685
|
-
|
|
1713
|
+
const popupElements = popupInfo.popupElements || [];
|
|
1686
1714
|
_templatizePopupElements(popupElements, basePath, layer, itemID, fieldNames);
|
|
1687
|
-
|
|
1715
|
+
const mediaInfos = popupInfo.mediaInfos || [];
|
|
1688
1716
|
_templatizeMediaInfos(mediaInfos, fieldNames, basePath, layer, itemID);
|
|
1689
1717
|
}
|
|
1690
1718
|
}
|
|
@@ -1699,10 +1727,10 @@ export function _templatizePopupInfo(layerDefinition, layer, basePath, itemID, f
|
|
|
1699
1727
|
*/
|
|
1700
1728
|
export function _templatizeName(object, property, fieldNames, basePath) {
|
|
1701
1729
|
if (object.hasOwnProperty(property)) {
|
|
1702
|
-
fieldNames.forEach(
|
|
1730
|
+
fieldNames.forEach(name => {
|
|
1703
1731
|
// Only test and replace instance of the name so any enclosing characters
|
|
1704
1732
|
// will be retained
|
|
1705
|
-
|
|
1733
|
+
const regEx = new RegExp("(\\b" + name + "\\b(?![}]{2}))", "gm");
|
|
1706
1734
|
if (regEx.test(object[property])) {
|
|
1707
1735
|
object[property] = object[property].replace(regEx, _templatize(basePath, name, "name"));
|
|
1708
1736
|
}
|
|
@@ -1719,7 +1747,7 @@ export function _templatizeName(object, property, fieldNames, basePath) {
|
|
|
1719
1747
|
* @param basePath path used to de-templatize while deploying
|
|
1720
1748
|
*/
|
|
1721
1749
|
export function _templatizePopupInfoFieldInfos(fieldInfos, layer, itemID, basePath) {
|
|
1722
|
-
fieldInfos.forEach(
|
|
1750
|
+
fieldInfos.forEach((f) => {
|
|
1723
1751
|
f.fieldName = _templatizeFieldName(f.fieldName, layer, itemID, basePath);
|
|
1724
1752
|
});
|
|
1725
1753
|
}
|
|
@@ -1734,19 +1762,19 @@ export function _templatizePopupInfoFieldInfos(fieldInfos, layer, itemID, basePa
|
|
|
1734
1762
|
*/
|
|
1735
1763
|
export function _templatizeFieldName(name, layer, itemID, basePath) {
|
|
1736
1764
|
if (name.indexOf("relationships/") > -1) {
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1765
|
+
const rels = name.split("/");
|
|
1766
|
+
const relationshipId = rels[1];
|
|
1767
|
+
const adminRelatedTables = getProp(layer, "adminLayerInfo.viewLayerDefinition.table.relatedTables");
|
|
1768
|
+
const relatedTables = layer.relationships || adminRelatedTables;
|
|
1741
1769
|
/* istanbul ignore else */
|
|
1742
1770
|
if (relatedTables && relatedTables.length > parseInt(relationshipId, 10)) {
|
|
1743
|
-
|
|
1771
|
+
const relatedTable = relatedTables[relationshipId];
|
|
1744
1772
|
// the layers relationships stores the property as relatedTableId
|
|
1745
1773
|
// the layers adminLayerInfo relatedTables stores the property as sourceLayerId
|
|
1746
|
-
|
|
1774
|
+
const prop = getProp(relatedTable, "relatedTableId")
|
|
1747
1775
|
? "relatedTableId"
|
|
1748
1776
|
: "sourceLayerId";
|
|
1749
|
-
|
|
1777
|
+
const _basePath = itemID + ".layer" + relatedTable[prop] + ".fields";
|
|
1750
1778
|
rels[2] = _templatize(_basePath, rels[2], "name");
|
|
1751
1779
|
name = rels.join("/");
|
|
1752
1780
|
}
|
|
@@ -1768,8 +1796,8 @@ export function _templatizeFieldName(name, layer, itemID, basePath) {
|
|
|
1768
1796
|
* @param basePath path used to de-templatize while deploying
|
|
1769
1797
|
*/
|
|
1770
1798
|
export function _templatizeExpressionInfos(expressionInfos, fieldNames, basePath) {
|
|
1771
|
-
return expressionInfos.map(
|
|
1772
|
-
fieldNames.forEach(
|
|
1799
|
+
return expressionInfos.map((i) => {
|
|
1800
|
+
fieldNames.forEach(name => {
|
|
1773
1801
|
i.expression = _templatizeArcadeExpressions(i.expression, name, basePath);
|
|
1774
1802
|
});
|
|
1775
1803
|
return i;
|
|
@@ -1785,7 +1813,7 @@ export function _templatizeExpressionInfos(expressionInfos, fieldNames, basePath
|
|
|
1785
1813
|
* @param fieldNames array of field names
|
|
1786
1814
|
*/
|
|
1787
1815
|
export function _templatizePopupElements(popupElelments, basePath, layer, itemID, fieldNames) {
|
|
1788
|
-
popupElelments.forEach(
|
|
1816
|
+
popupElelments.forEach((pe) => {
|
|
1789
1817
|
if (pe.hasOwnProperty("fieldInfos")) {
|
|
1790
1818
|
_templatizePopupInfoFieldInfos(pe.fieldInfos, layer, itemID, basePath);
|
|
1791
1819
|
}
|
|
@@ -1805,16 +1833,14 @@ export function _templatizePopupElements(popupElelments, basePath, layer, itemID
|
|
|
1805
1833
|
*/
|
|
1806
1834
|
export function _templatizeMediaInfos(mediaInfos, fieldNames, basePath, layer, itemId) {
|
|
1807
1835
|
// templatize various properties of mediaInfos
|
|
1808
|
-
|
|
1809
|
-
props.forEach(
|
|
1810
|
-
mediaInfos.forEach(
|
|
1836
|
+
const props = ["title", "caption"];
|
|
1837
|
+
props.forEach(p => _templatizeName(mediaInfos, p, fieldNames, basePath));
|
|
1838
|
+
mediaInfos.forEach((mi) => {
|
|
1811
1839
|
/* istanbul ignore else */
|
|
1812
1840
|
if (mi.hasOwnProperty("value")) {
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
v.fields = vfields.map(
|
|
1816
|
-
return _templatizeFieldName(f, layer, itemId, basePath);
|
|
1817
|
-
});
|
|
1841
|
+
const v = mi.value;
|
|
1842
|
+
const vfields = v.fields || [];
|
|
1843
|
+
v.fields = vfields.map(f => _templatizeFieldName(f, layer, itemId, basePath));
|
|
1818
1844
|
if (v.hasOwnProperty("normalizeField")) {
|
|
1819
1845
|
_templatizeProperty(v, "normalizeField", basePath, "name");
|
|
1820
1846
|
}
|
|
@@ -1834,15 +1860,15 @@ export function _templatizeMediaInfos(mediaInfos, fieldNames, basePath, layer, i
|
|
|
1834
1860
|
*/
|
|
1835
1861
|
export function _templatizeDefinitionEditor(layer, basePath, fieldNames) {
|
|
1836
1862
|
if (layer) {
|
|
1837
|
-
|
|
1863
|
+
const defEditor = layer.definitionEditor || {};
|
|
1838
1864
|
/* istanbul ignore else */
|
|
1839
1865
|
if (defEditor) {
|
|
1840
|
-
|
|
1866
|
+
const inputs = defEditor.inputs;
|
|
1841
1867
|
if (inputs) {
|
|
1842
|
-
inputs.forEach(
|
|
1868
|
+
inputs.forEach(i => {
|
|
1843
1869
|
/* istanbul ignore else */
|
|
1844
1870
|
if (i.parameters) {
|
|
1845
|
-
i.parameters.forEach(
|
|
1871
|
+
i.parameters.forEach((p) => {
|
|
1846
1872
|
_templatizeProperty(p, "fieldName", basePath, "name");
|
|
1847
1873
|
});
|
|
1848
1874
|
}
|
|
@@ -1874,9 +1900,9 @@ export function _templatizeDefinitionExpression(layer, basePath, fieldNames) {
|
|
|
1874
1900
|
* @param fieldNames array of the layers field names
|
|
1875
1901
|
*/
|
|
1876
1902
|
export function _templatizeSimpleName(expression, basePath, fieldNames, suffix) {
|
|
1877
|
-
fieldNames.forEach(
|
|
1903
|
+
fieldNames.forEach(name => {
|
|
1878
1904
|
// look for the name but not if its followed by }}
|
|
1879
|
-
|
|
1905
|
+
const regEx = new RegExp("\\b" + name + "\\b(?![}]{2})", "gm");
|
|
1880
1906
|
if (expression && regEx.test(expression)) {
|
|
1881
1907
|
expression = expression.replace(regEx, _templatize(basePath, name, suffix));
|
|
1882
1908
|
}
|
|
@@ -1892,13 +1918,13 @@ export function _templatizeSimpleName(expression, basePath, fieldNames, suffix)
|
|
|
1892
1918
|
*/
|
|
1893
1919
|
export function _templatizeDrawingInfo(layer, basePath, fieldNames) {
|
|
1894
1920
|
if (layer) {
|
|
1895
|
-
|
|
1921
|
+
const drawingInfo = layer.drawingInfo;
|
|
1896
1922
|
if (drawingInfo) {
|
|
1897
1923
|
// templatize the renderer fields
|
|
1898
|
-
|
|
1924
|
+
const renderer = drawingInfo.renderer || {};
|
|
1899
1925
|
_templatizeRenderer(renderer, basePath, fieldNames);
|
|
1900
1926
|
// templatize the labelingInfo
|
|
1901
|
-
|
|
1927
|
+
const labelingInfo = drawingInfo.labelingInfo || [];
|
|
1902
1928
|
_templatizeLabelingInfo(labelingInfo, basePath, fieldNames);
|
|
1903
1929
|
}
|
|
1904
1930
|
}
|
|
@@ -1937,39 +1963,37 @@ export function _templatizeGenRenderer(renderer, basePath, fieldNames) {
|
|
|
1937
1963
|
/* istanbul ignore else */
|
|
1938
1964
|
if (renderer) {
|
|
1939
1965
|
// update authoringInfo
|
|
1940
|
-
|
|
1966
|
+
const authoringInfo = renderer.authoringInfo;
|
|
1941
1967
|
if (authoringInfo) {
|
|
1942
1968
|
_templatizeAuthoringInfo(authoringInfo, basePath, fieldNames);
|
|
1943
1969
|
}
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
fieldNameProps.forEach(
|
|
1948
|
-
return _templatizeProperty(renderer, fnP, basePath, "name");
|
|
1949
|
-
});
|
|
1970
|
+
const props = ["field", "normalizationField"];
|
|
1971
|
+
props.forEach(p => _templatizeProperty(renderer, p, basePath, "name"));
|
|
1972
|
+
const fieldNameProps = ["field1", "field2", "field3"];
|
|
1973
|
+
fieldNameProps.forEach(fnP => _templatizeProperty(renderer, fnP, basePath, "name"));
|
|
1950
1974
|
// When an attribute name is specified, it's enclosed in square brackets
|
|
1951
|
-
|
|
1952
|
-
if (
|
|
1953
|
-
fieldNames.forEach(
|
|
1954
|
-
|
|
1955
|
-
if (regEx.test(
|
|
1956
|
-
renderer.rotationExpression =
|
|
1975
|
+
const rExp = renderer.rotationExpression;
|
|
1976
|
+
if (rExp) {
|
|
1977
|
+
fieldNames.forEach(name => {
|
|
1978
|
+
const regEx = new RegExp("(\\[" + name + "\\])", "gm");
|
|
1979
|
+
if (regEx.test(rExp)) {
|
|
1980
|
+
renderer.rotationExpression = rExp.replace(regEx, "[" + _templatize(basePath, name, "name") + "]");
|
|
1957
1981
|
}
|
|
1958
1982
|
});
|
|
1959
1983
|
}
|
|
1960
1984
|
// update valueExpression
|
|
1961
1985
|
if (renderer.valueExpression) {
|
|
1962
|
-
fieldNames.forEach(
|
|
1986
|
+
fieldNames.forEach(name => {
|
|
1963
1987
|
renderer.valueExpression = _templatizeArcadeExpressions(renderer.valueExpression, name, basePath);
|
|
1964
1988
|
});
|
|
1965
1989
|
}
|
|
1966
1990
|
// update visualVariables
|
|
1967
|
-
|
|
1991
|
+
const visualVariables = renderer.visualVariables;
|
|
1968
1992
|
if (visualVariables) {
|
|
1969
|
-
visualVariables.forEach(
|
|
1970
|
-
|
|
1993
|
+
visualVariables.forEach(v => {
|
|
1994
|
+
props.forEach(p => _templatizeProperty(v, p, basePath, "name"));
|
|
1971
1995
|
if (v.valueExpression) {
|
|
1972
|
-
fieldNames.forEach(
|
|
1996
|
+
fieldNames.forEach(name => {
|
|
1973
1997
|
v.valueExpression = _templatizeArcadeExpressions(v.valueExpression, name, basePath);
|
|
1974
1998
|
});
|
|
1975
1999
|
}
|
|
@@ -1985,12 +2009,12 @@ export function _templatizeGenRenderer(renderer, basePath, fieldNames) {
|
|
|
1985
2009
|
* @param fieldNames array of field names that will be used to search expressions
|
|
1986
2010
|
*/
|
|
1987
2011
|
export function _templatizeTemporalRenderer(renderer, basePath, fieldNames) {
|
|
1988
|
-
|
|
2012
|
+
const renderers = [
|
|
1989
2013
|
renderer.latestObservationRenderer,
|
|
1990
2014
|
renderer.observationRenderer,
|
|
1991
2015
|
renderer.trackRenderer
|
|
1992
2016
|
];
|
|
1993
|
-
renderers.forEach(
|
|
2017
|
+
renderers.forEach(r => {
|
|
1994
2018
|
_templatizeRenderer(r, basePath, fieldNames);
|
|
1995
2019
|
});
|
|
1996
2020
|
}
|
|
@@ -2004,22 +2028,22 @@ export function _templatizeTemporalRenderer(renderer, basePath, fieldNames) {
|
|
|
2004
2028
|
export function _templatizeAuthoringInfo(authoringInfo, basePath, fieldNames) {
|
|
2005
2029
|
/* istanbul ignore else */
|
|
2006
2030
|
if (authoringInfo) {
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
props.forEach(
|
|
2010
|
-
|
|
2011
|
-
props.forEach(
|
|
2012
|
-
|
|
2031
|
+
const props = ["field", "normalizationField"];
|
|
2032
|
+
const field1 = authoringInfo.field1;
|
|
2033
|
+
props.forEach(p => _templatizeProperty(field1, p, basePath, "name"));
|
|
2034
|
+
const field2 = authoringInfo.field2;
|
|
2035
|
+
props.forEach(p => _templatizeProperty(field2, p, basePath, "name"));
|
|
2036
|
+
const fields = authoringInfo.fields;
|
|
2013
2037
|
if (fields) {
|
|
2014
|
-
authoringInfo.fields = fields.map(
|
|
2038
|
+
authoringInfo.fields = fields.map(f => _templatize(basePath, f, "name"));
|
|
2015
2039
|
}
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
if (
|
|
2019
|
-
vProps.forEach(
|
|
2040
|
+
const vProps = ["endTime", "field", "startTime"];
|
|
2041
|
+
const vVars = authoringInfo.visualVariables;
|
|
2042
|
+
if (vVars) {
|
|
2043
|
+
vProps.forEach(p => {
|
|
2020
2044
|
// endTime and startTime may or may not be a field name
|
|
2021
|
-
if (fieldNames.indexOf(
|
|
2022
|
-
_templatizeProperty(
|
|
2045
|
+
if (fieldNames.indexOf(vVars[p]) > -1) {
|
|
2046
|
+
_templatizeProperty(vVars, p, basePath, "name");
|
|
2023
2047
|
}
|
|
2024
2048
|
});
|
|
2025
2049
|
}
|
|
@@ -2033,12 +2057,12 @@ export function _templatizeAuthoringInfo(authoringInfo, basePath, fieldNames) {
|
|
|
2033
2057
|
* @param basePath path used to de-templatize while deploying
|
|
2034
2058
|
*/
|
|
2035
2059
|
export function _templatizeArcadeExpressions(text, fieldName, basePath) {
|
|
2036
|
-
|
|
2060
|
+
const t = _templatize(basePath, fieldName, "name");
|
|
2037
2061
|
if (text) {
|
|
2038
2062
|
// test for $feature. notation
|
|
2039
2063
|
// captures VOTED_DEM_2012 from $feature.VOTED_DEM_2012
|
|
2040
|
-
|
|
2041
|
-
|
|
2064
|
+
let exp = "(?:\\$feature\\.)(" + fieldName + ")\\b";
|
|
2065
|
+
let regEx = new RegExp(exp, "gm");
|
|
2042
2066
|
text = regEx.test(text) ? text.replace(regEx, "$feature." + t) : text;
|
|
2043
2067
|
// test for $feature[] notation
|
|
2044
2068
|
// captures VOTED_DEM_2012 from $feature["VOTED_DEM_2012"]
|
|
@@ -2046,7 +2070,7 @@ export function _templatizeArcadeExpressions(text, fieldName, basePath) {
|
|
|
2046
2070
|
// captures VOTED_DEM_2012 from $feature[VOTED_DEM_2012]
|
|
2047
2071
|
exp = "(?:[$]feature)(\\[\\\"?\\'?)" + fieldName + "(\\\"?\\'?\\])";
|
|
2048
2072
|
regEx = new RegExp(exp, "gm");
|
|
2049
|
-
|
|
2073
|
+
let result = regEx.exec(text);
|
|
2050
2074
|
if (result) {
|
|
2051
2075
|
text = text.replace(regEx, "$feature" + result[1] + t + result[2]);
|
|
2052
2076
|
}
|
|
@@ -2080,29 +2104,27 @@ export function _templatizeArcadeExpressions(text, fieldName, basePath) {
|
|
|
2080
2104
|
* @param fieldNames array of the layers field names
|
|
2081
2105
|
*/
|
|
2082
2106
|
export function _templatizeLabelingInfo(labelingInfo, basePath, fieldNames) {
|
|
2083
|
-
labelingInfo.forEach(
|
|
2107
|
+
labelingInfo.forEach((li) => {
|
|
2084
2108
|
/* istanbul ignore else */
|
|
2085
2109
|
if (li.hasOwnProperty("fieldInfos")) {
|
|
2086
|
-
|
|
2087
|
-
fieldInfos.forEach(
|
|
2088
|
-
return _templatizeProperty(fi, "fieldName", basePath, "name");
|
|
2089
|
-
});
|
|
2110
|
+
const fieldInfos = li.fieldInfos || [];
|
|
2111
|
+
fieldInfos.forEach(fi => _templatizeProperty(fi, "fieldName", basePath, "name"));
|
|
2090
2112
|
}
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
fieldNames.forEach(
|
|
2094
|
-
|
|
2113
|
+
const labelExp = li.labelExpression || "";
|
|
2114
|
+
const labelExpInfo = li.labelExpressionInfo || {};
|
|
2115
|
+
fieldNames.forEach(n => {
|
|
2116
|
+
const t = _templatize(basePath, n, "name");
|
|
2095
2117
|
// check for [fieldName] or ["fieldName"]
|
|
2096
|
-
|
|
2097
|
-
|
|
2118
|
+
const regExBracket = new RegExp('(\\[\\"*)+(' + n + ')(\\"*\\])+', "gm");
|
|
2119
|
+
let result = regExBracket.exec(labelExp);
|
|
2098
2120
|
if (result) {
|
|
2099
2121
|
li.labelExpression = labelExp.replace(regExBracket, result[1] + t + result[3]);
|
|
2100
2122
|
}
|
|
2101
2123
|
/* istanbul ignore else */
|
|
2102
2124
|
if (labelExpInfo.value) {
|
|
2103
|
-
|
|
2125
|
+
let v = labelExpInfo.value;
|
|
2104
2126
|
// check for {fieldName}
|
|
2105
|
-
|
|
2127
|
+
const regExCurly = new RegExp("(\\{" + n + "\\})", "gm");
|
|
2106
2128
|
v = regExCurly.test(v) ? v.replace(regExCurly, "{" + t + "}") : v;
|
|
2107
2129
|
// check for [fieldName] or ["fieldName"]
|
|
2108
2130
|
result = regExBracket.exec(v);
|
|
@@ -2123,10 +2145,10 @@ export function _templatizeLabelingInfo(labelingInfo, basePath, fieldNames) {
|
|
|
2123
2145
|
* @param basePath path used to de-templatize while deploying
|
|
2124
2146
|
*/
|
|
2125
2147
|
export function _templatizeTemplates(layer, basePath) {
|
|
2126
|
-
|
|
2127
|
-
templates.forEach(
|
|
2128
|
-
|
|
2129
|
-
|
|
2148
|
+
const templates = layer.templates || [];
|
|
2149
|
+
templates.forEach(t => {
|
|
2150
|
+
const attributes = getProp(t, "prototype.attributes");
|
|
2151
|
+
const _attributes = _templatizeKeys(attributes, basePath, "name");
|
|
2130
2152
|
/* istanbul ignore else */
|
|
2131
2153
|
if (_attributes) {
|
|
2132
2154
|
t.prototype.attributes = _attributes;
|
|
@@ -2140,20 +2162,20 @@ export function _templatizeTemplates(layer, basePath) {
|
|
|
2140
2162
|
* @param basePath path used to de-templatize while deploying
|
|
2141
2163
|
*/
|
|
2142
2164
|
export function _templatizeTypeTemplates(layer, basePath) {
|
|
2143
|
-
|
|
2165
|
+
const types = layer.types;
|
|
2144
2166
|
if (types && Array.isArray(types) && types.length > 0) {
|
|
2145
|
-
types.forEach(
|
|
2146
|
-
|
|
2167
|
+
types.forEach((type) => {
|
|
2168
|
+
const domains = _templatizeKeys(type.domains, basePath, "name");
|
|
2147
2169
|
/* istanbul ignore else */
|
|
2148
2170
|
if (domains) {
|
|
2149
2171
|
type.domains = domains;
|
|
2150
2172
|
}
|
|
2151
|
-
|
|
2173
|
+
const templates = type.templates;
|
|
2152
2174
|
/* istanbul ignore else */
|
|
2153
2175
|
if (templates && templates.length > 0) {
|
|
2154
|
-
templates.forEach(
|
|
2155
|
-
|
|
2156
|
-
|
|
2176
|
+
templates.forEach((t) => {
|
|
2177
|
+
const attributes = getProp(t, "prototype.attributes");
|
|
2178
|
+
const _attributes = _templatizeKeys(attributes, basePath, "name");
|
|
2157
2179
|
/* istanbul ignore else */
|
|
2158
2180
|
if (_attributes) {
|
|
2159
2181
|
t.prototype.attributes = _attributes;
|
|
@@ -2171,14 +2193,14 @@ export function _templatizeTypeTemplates(layer, basePath) {
|
|
|
2171
2193
|
* @param suffix expected suffix for template variable
|
|
2172
2194
|
*/
|
|
2173
2195
|
export function _templatizeKeys(obj, basePath, suffix) {
|
|
2174
|
-
|
|
2196
|
+
let _obj;
|
|
2175
2197
|
/* istanbul ignore else */
|
|
2176
2198
|
if (obj) {
|
|
2177
2199
|
_obj = {};
|
|
2178
|
-
|
|
2200
|
+
const objKeys = Object.keys(obj);
|
|
2179
2201
|
/* istanbul ignore else */
|
|
2180
2202
|
if (objKeys && objKeys.length > 0) {
|
|
2181
|
-
objKeys.forEach(
|
|
2203
|
+
objKeys.forEach(k => {
|
|
2182
2204
|
_obj[_templatize(basePath, k, suffix)] = obj[k];
|
|
2183
2205
|
});
|
|
2184
2206
|
}
|
|
@@ -2193,18 +2215,18 @@ export function _templatizeKeys(obj, basePath, suffix) {
|
|
|
2193
2215
|
*/
|
|
2194
2216
|
export function _templatizeTimeInfo(layer, basePath) {
|
|
2195
2217
|
if (layer.timeInfo) {
|
|
2196
|
-
|
|
2197
|
-
|
|
2218
|
+
const timeInfo = layer.timeInfo;
|
|
2219
|
+
const timeProps = [
|
|
2198
2220
|
"endTimeField",
|
|
2199
2221
|
"startTimeField",
|
|
2200
2222
|
"trackIdField"
|
|
2201
2223
|
];
|
|
2202
|
-
timeProps.forEach(
|
|
2203
|
-
if (
|
|
2204
|
-
_templatizeProperty(
|
|
2224
|
+
timeProps.forEach(t => {
|
|
2225
|
+
if (timeInfo[t] !== "") {
|
|
2226
|
+
_templatizeProperty(timeInfo, t, basePath, "name");
|
|
2205
2227
|
}
|
|
2206
2228
|
else {
|
|
2207
|
-
|
|
2229
|
+
timeInfo[t] = null;
|
|
2208
2230
|
}
|
|
2209
2231
|
});
|
|
2210
2232
|
}
|
|
@@ -2234,16 +2256,16 @@ export function _templatizeDefinitionQuery(layer, basePath, fieldNames) {
|
|
|
2234
2256
|
*/
|
|
2235
2257
|
export function _getNameMapping(fieldInfos, id) {
|
|
2236
2258
|
// create name mapping
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
? newFields.map(
|
|
2259
|
+
const fInfo = fieldInfos[id];
|
|
2260
|
+
const nameMapping = {};
|
|
2261
|
+
const newFields = fInfo.newFields;
|
|
2262
|
+
const newFieldNames = newFields
|
|
2263
|
+
? newFields.map((f) => f.name)
|
|
2242
2264
|
: [];
|
|
2243
|
-
|
|
2244
|
-
sourceFields.forEach(
|
|
2245
|
-
|
|
2246
|
-
newFields.forEach(
|
|
2265
|
+
const sourceFields = fInfo.sourceFields || [];
|
|
2266
|
+
sourceFields.forEach((field) => {
|
|
2267
|
+
const lName = String(field.name).toLowerCase();
|
|
2268
|
+
newFields.forEach((f) => {
|
|
2247
2269
|
// Names can change more than case
|
|
2248
2270
|
if (newFieldNames.indexOf(field.name) === -1 &&
|
|
2249
2271
|
newFieldNames.indexOf(lName) === -1) {
|
|
@@ -2267,13 +2289,13 @@ export function _getNameMapping(fieldInfos, id) {
|
|
|
2267
2289
|
});
|
|
2268
2290
|
// update for editFieldsInfo
|
|
2269
2291
|
if (fInfo.editFieldsInfo && fInfo.newEditFieldsInfo) {
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
Object.keys(
|
|
2274
|
-
|
|
2275
|
-
if ((
|
|
2276
|
-
nameMapping[lowerEfi].name !==
|
|
2292
|
+
const efi = JSON.parse(JSON.stringify(fInfo.editFieldsInfo));
|
|
2293
|
+
const newEfi = JSON.parse(JSON.stringify(fInfo.newEditFieldsInfo));
|
|
2294
|
+
const nameMappingKeys = Object.keys(nameMapping);
|
|
2295
|
+
Object.keys(efi).forEach(k => {
|
|
2296
|
+
const lowerEfi = String(efi[k]).toLowerCase();
|
|
2297
|
+
if ((nameMappingKeys.indexOf(lowerEfi) === -1 ||
|
|
2298
|
+
nameMapping[lowerEfi].name !== newEfi[k]) &&
|
|
2277
2299
|
newFieldNames.indexOf(lowerEfi) > -1) {
|
|
2278
2300
|
// Only add delete fields if source schema changes allowed
|
|
2279
2301
|
/* istanbul ignore else */
|
|
@@ -2287,17 +2309,17 @@ export function _getNameMapping(fieldInfos, id) {
|
|
|
2287
2309
|
fInfo.deleteFields.push(lowerEfi);
|
|
2288
2310
|
}
|
|
2289
2311
|
// editFieldsInfo only has the name and not the alias and type
|
|
2290
|
-
|
|
2291
|
-
fInfo.sourceFields.some(
|
|
2292
|
-
if (sf.name ===
|
|
2293
|
-
|
|
2312
|
+
let sourceEfiField;
|
|
2313
|
+
fInfo.sourceFields.some((sf) => {
|
|
2314
|
+
if (sf.name === efi[k]) {
|
|
2315
|
+
sourceEfiField = sf;
|
|
2294
2316
|
}
|
|
2295
|
-
return sf.name ===
|
|
2317
|
+
return sf.name === efi[k];
|
|
2296
2318
|
});
|
|
2297
2319
|
nameMapping[lowerEfi] = {
|
|
2298
|
-
name:
|
|
2299
|
-
alias:
|
|
2300
|
-
type:
|
|
2320
|
+
name: newEfi[k],
|
|
2321
|
+
alias: sourceEfiField && sourceEfiField.alias ? sourceEfiField.alias : "",
|
|
2322
|
+
type: sourceEfiField && sourceEfiField.type ? sourceEfiField.type : ""
|
|
2301
2323
|
};
|
|
2302
2324
|
}
|
|
2303
2325
|
});
|
|
@@ -2308,4 +2330,12 @@ export function _getNameMapping(fieldInfos, id) {
|
|
|
2308
2330
|
}
|
|
2309
2331
|
return nameMapping;
|
|
2310
2332
|
}
|
|
2333
|
+
/**
|
|
2334
|
+
* Helper function to ensure same chunk size value is used in multiple locations
|
|
2335
|
+
*
|
|
2336
|
+
* @return a number that represents how many layers should be included per addToDef call
|
|
2337
|
+
*/
|
|
2338
|
+
export function _getLayerChunkSize() {
|
|
2339
|
+
return 20;
|
|
2340
|
+
}
|
|
2311
2341
|
//# sourceMappingURL=featureServiceHelpers.js.map
|