@esri/solution-common 1.3.13 → 1.3.16
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/featureServiceHelpers.d.ts +33 -51
- package/dist/esm/featureServiceHelpers.js +122 -178
- package/dist/esm/featureServiceHelpers.js.map +1 -1
- package/dist/esm/interfaces.d.ts +1 -0
- package/dist/esm/interfaces.js.map +1 -1
- package/dist/esm/restHelpers.d.ts +17 -12
- package/dist/esm/restHelpers.js +67 -40
- package/dist/esm/restHelpers.js.map +1 -1
- package/dist/node/featureServiceHelpers.d.ts +33 -51
- package/dist/node/featureServiceHelpers.js +126 -184
- package/dist/node/featureServiceHelpers.js.map +1 -1
- package/dist/node/interfaces.d.ts +1 -0
- package/dist/node/interfaces.js.map +1 -1
- package/dist/node/restHelpers.d.ts +17 -12
- package/dist/node/restHelpers.js +70 -42
- package/dist/node/restHelpers.js.map +1 -1
- package/dist/umd/common.umd.js +194 -224
- 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/featureServiceHelpers.d.ts +33 -51
- package/dist/umd/interfaces.d.ts +1 -0
- package/dist/umd/restHelpers.d.ts +17 -12
- package/package.json +3 -3
package/dist/umd/common.umd.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/solution-common - v1.3.
|
|
2
|
+
* @esri/solution-common - v1.3.16 - Apache-2.0
|
|
3
3
|
* Copyright (c) 2018-2022 Esri, Inc.
|
|
4
|
-
*
|
|
4
|
+
* Wed Jun 08 2022 10:52:31 GMT-0700 (Pacific Daylight Time)
|
|
5
5
|
*
|
|
6
6
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
7
|
* you may not use this file except in compliance with the License.
|
|
@@ -6991,10 +6991,9 @@
|
|
|
6991
6991
|
*
|
|
6992
6992
|
* @param layer The data layer instance with field name references within
|
|
6993
6993
|
* @param fieldInfos the object that stores the cached field infos
|
|
6994
|
-
* @param isPortal Controls what properties should be removed.
|
|
6995
6994
|
* @returns An updated instance of the fieldInfos
|
|
6996
6995
|
*/
|
|
6997
|
-
function cacheFieldInfos(layer, fieldInfos
|
|
6996
|
+
function cacheFieldInfos(layer, fieldInfos) {
|
|
6998
6997
|
// cache the source fields as they are in the original source
|
|
6999
6998
|
if (layer && layer.fields) {
|
|
7000
6999
|
fieldInfos[layer.id] = {
|
|
@@ -7007,19 +7006,34 @@
|
|
|
7007
7006
|
// and will have associated updateDefinition calls when deploying to portal
|
|
7008
7007
|
// as well as online for relationships...as relationships added with addToDef will cause failure
|
|
7009
7008
|
const props = {
|
|
7010
|
-
editFieldsInfo:
|
|
7011
|
-
types:
|
|
7012
|
-
templates:
|
|
7009
|
+
editFieldsInfo: false,
|
|
7010
|
+
types: false,
|
|
7011
|
+
templates: false,
|
|
7013
7012
|
relationships: true,
|
|
7014
|
-
drawingInfo:
|
|
7015
|
-
timeInfo:
|
|
7016
|
-
viewDefinitionQuery:
|
|
7013
|
+
drawingInfo: false,
|
|
7014
|
+
timeInfo: false,
|
|
7015
|
+
viewDefinitionQuery: false
|
|
7017
7016
|
};
|
|
7018
7017
|
Object.keys(props).forEach(k => {
|
|
7019
7018
|
_cacheFieldInfo(layer, k, fieldInfos, props[k]);
|
|
7020
7019
|
});
|
|
7021
7020
|
return fieldInfos;
|
|
7022
7021
|
}
|
|
7022
|
+
/**
|
|
7023
|
+
* Cache the stored contingent values so we can add them in subsequent addToDef calls
|
|
7024
|
+
*
|
|
7025
|
+
* @param id The layer id for the associated values to be stored with
|
|
7026
|
+
* @param fieldInfos The object that stores the cached field infos
|
|
7027
|
+
* @param itemTemplate The current itemTemplate being processed
|
|
7028
|
+
* @returns An updated instance of the fieldInfos
|
|
7029
|
+
*/
|
|
7030
|
+
function cacheContingentValues(id, fieldInfos, itemTemplate) {
|
|
7031
|
+
const contingentValues = getProp(itemTemplate, 'properties.contingentValues');
|
|
7032
|
+
if (contingentValues && contingentValues[id]) {
|
|
7033
|
+
fieldInfos[id]['contingentValues'] = contingentValues[id];
|
|
7034
|
+
}
|
|
7035
|
+
return fieldInfos;
|
|
7036
|
+
}
|
|
7023
7037
|
/**
|
|
7024
7038
|
* Helper function to cache a single property into the fieldInfos object
|
|
7025
7039
|
* This property will be removed from the layer instance.
|
|
@@ -7039,7 +7053,7 @@
|
|
|
7039
7053
|
// editFieldsInfo does not come through unless its with the layer
|
|
7040
7054
|
// when it's being added
|
|
7041
7055
|
/* istanbul ignore else */
|
|
7042
|
-
if (removeProp
|
|
7056
|
+
if (removeProp) {
|
|
7043
7057
|
layer[prop] = null;
|
|
7044
7058
|
}
|
|
7045
7059
|
}
|
|
@@ -7265,6 +7279,57 @@
|
|
|
7265
7279
|
}
|
|
7266
7280
|
});
|
|
7267
7281
|
}
|
|
7282
|
+
/**
|
|
7283
|
+
* Get the contingent values for each layer in the service.
|
|
7284
|
+
* Remove key props that cannot be included with the addToDef call on deploy.
|
|
7285
|
+
* Store the values alongside other key feature service properties in the template
|
|
7286
|
+
*
|
|
7287
|
+
* @param properties the current feature services properties
|
|
7288
|
+
* @param adminUrl the current feature service url
|
|
7289
|
+
* @param authentication Credentials for the request to AGOL
|
|
7290
|
+
* @returns A promise that will resolve when the contingent values have been fetched.
|
|
7291
|
+
* This function will update the provided properties argument when contingent values are found.
|
|
7292
|
+
*/
|
|
7293
|
+
function processContingentValues(properties, adminUrl, authentication) {
|
|
7294
|
+
return new Promise((resolve, reject) => {
|
|
7295
|
+
if (getProp(properties, 'service.isView')) {
|
|
7296
|
+
// views will inherit from the source service
|
|
7297
|
+
resolve();
|
|
7298
|
+
}
|
|
7299
|
+
else {
|
|
7300
|
+
const layersAndTables = (properties.layers || []).concat(properties.tables || []);
|
|
7301
|
+
const layerIds = [];
|
|
7302
|
+
const contingentValuePromises = layersAndTables.reduce((prev, cur) => {
|
|
7303
|
+
/* istanbul ignore else */
|
|
7304
|
+
if (cur.hasContingentValuesDefinition) {
|
|
7305
|
+
prev.push(arcgisRestRequest.request(`${adminUrl}/${cur['id']}/contingentValues?f=json`, { authentication }));
|
|
7306
|
+
layerIds.push(cur['id']);
|
|
7307
|
+
}
|
|
7308
|
+
return prev;
|
|
7309
|
+
}, []);
|
|
7310
|
+
if (contingentValuePromises.length > 0) {
|
|
7311
|
+
Promise.all(contingentValuePromises).then((results) => {
|
|
7312
|
+
const contingentValues = {};
|
|
7313
|
+
results.forEach((r, i) => {
|
|
7314
|
+
deleteProp(r, 'typeCodes');
|
|
7315
|
+
/* istanbul ignore else */
|
|
7316
|
+
if (getProp(r, 'stringDicts') && getProp(r, 'contingentValuesDefinition')) {
|
|
7317
|
+
r.contingentValuesDefinition['stringDicts'] = r.stringDicts;
|
|
7318
|
+
deleteProp(r, 'stringDicts');
|
|
7319
|
+
}
|
|
7320
|
+
deleteProps(getProp(r, 'contingentValuesDefinition'), ['layerID', 'layerName', 'geometryType', 'hasSubType']);
|
|
7321
|
+
contingentValues[layerIds[i]] = r;
|
|
7322
|
+
});
|
|
7323
|
+
properties.contingentValues = contingentValues;
|
|
7324
|
+
resolve();
|
|
7325
|
+
}, reject);
|
|
7326
|
+
}
|
|
7327
|
+
else {
|
|
7328
|
+
resolve();
|
|
7329
|
+
}
|
|
7330
|
+
}
|
|
7331
|
+
});
|
|
7332
|
+
}
|
|
7268
7333
|
/**
|
|
7269
7334
|
* Replace the field name reference templates with the new field names after deployment.
|
|
7270
7335
|
*
|
|
@@ -7373,16 +7438,12 @@
|
|
|
7373
7438
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
7374
7439
|
updateLayerFieldReferences(itemTemplate, fieldInfos, popupInfos, adminLayerInfos, templateDictionary).then(r => {
|
|
7375
7440
|
// Update relationships and layer definitions
|
|
7376
|
-
|
|
7441
|
+
const updates = getLayerUpdates({
|
|
7377
7442
|
message: "updated layer definition",
|
|
7378
7443
|
objects: r.layerInfos.fieldInfos,
|
|
7379
7444
|
itemTemplate: r.itemTemplate,
|
|
7380
7445
|
authentication
|
|
7381
7446
|
}, templateDictionary.isPortal);
|
|
7382
|
-
// Get any updates for the service that should be performed after updates to the layers
|
|
7383
|
-
if (templateDictionary.isPortal) {
|
|
7384
|
-
updates = getFinalServiceUpdates(r.itemTemplate, authentication, updates);
|
|
7385
|
-
}
|
|
7386
7447
|
// Process the updates sequentially
|
|
7387
7448
|
updates
|
|
7388
7449
|
.reduce((prev, update) => {
|
|
@@ -7439,7 +7500,9 @@
|
|
|
7439
7500
|
listToAdd.forEach((toAdd, i) => {
|
|
7440
7501
|
let item = toAdd.item;
|
|
7441
7502
|
const originalId = item.id;
|
|
7442
|
-
fieldInfos = cacheFieldInfos(item, fieldInfos
|
|
7503
|
+
fieldInfos = cacheFieldInfos(item, fieldInfos);
|
|
7504
|
+
// cache the values to be added in seperate addToDef calls
|
|
7505
|
+
fieldInfos = cacheContingentValues(item.id, fieldInfos, itemTemplate);
|
|
7443
7506
|
/* istanbul ignore else */
|
|
7444
7507
|
if (item.isView) {
|
|
7445
7508
|
deleteViewProps(item);
|
|
@@ -7455,9 +7518,7 @@
|
|
|
7455
7518
|
// update adminLayerInfo before add to definition with view source fieldInfo settings
|
|
7456
7519
|
item.adminLayerInfo = replaceInTemplate(item.adminLayerInfo, templateDictionary);
|
|
7457
7520
|
/* istanbul ignore else */
|
|
7458
|
-
if (
|
|
7459
|
-
fieldInfos &&
|
|
7460
|
-
fieldInfos.hasOwnProperty(item.id)) {
|
|
7521
|
+
if (fieldInfos && fieldInfos.hasOwnProperty(item.id)) {
|
|
7461
7522
|
Object.keys(templateDictionary).some(k => {
|
|
7462
7523
|
if (templateDictionary[k].itemId === itemTemplate.itemId) {
|
|
7463
7524
|
fieldInfos[item.id]["sourceServiceFields"] =
|
|
@@ -7470,7 +7531,7 @@
|
|
|
7470
7531
|
});
|
|
7471
7532
|
// view field domain and alias can contain different values than the source field
|
|
7472
7533
|
// we need to set isViewOverride when added fields that differ from the source field
|
|
7473
|
-
|
|
7534
|
+
_validateViewFieldInfos(fieldInfos[item.id], item);
|
|
7474
7535
|
}
|
|
7475
7536
|
}
|
|
7476
7537
|
/* istanbul ignore else */
|
|
@@ -7622,7 +7683,6 @@
|
|
|
7622
7683
|
}
|
|
7623
7684
|
// not allowed to set sourceSchemaChangesAllowed or isView for portal
|
|
7624
7685
|
// these are set when you create the service
|
|
7625
|
-
deleteProp(item, "sourceSchemaChangesAllowed");
|
|
7626
7686
|
deleteProp(item, "isView");
|
|
7627
7687
|
return item;
|
|
7628
7688
|
}
|
|
@@ -7898,25 +7958,10 @@
|
|
|
7898
7958
|
// more than case change when deployed to protal so keep track of the new names
|
|
7899
7959
|
layerInfo["newEditFieldsInfo"] = JSON.parse(JSON.stringify(item.editFieldsInfo));
|
|
7900
7960
|
}
|
|
7901
|
-
// fields that are marked as visible false on a view are all set to
|
|
7902
|
-
// visible true when added with the layer definition
|
|
7903
|
-
// update the field visibility to match that of the source
|
|
7904
7961
|
/* istanbul ignore else */
|
|
7905
7962
|
if (isView && templateInfo && templateDictionary.isPortal) {
|
|
7906
7963
|
// when the item is a view bring over the source service fields so we can compare the domains
|
|
7907
7964
|
layerInfo["sourceServiceFields"] = templateInfo.sourceServiceFields;
|
|
7908
|
-
let fieldUpdates = _getFieldVisibilityUpdates(layerInfo);
|
|
7909
|
-
// view field domains can contain different values than the source field domains
|
|
7910
|
-
// use the cached view domain when it differs from the source view domain
|
|
7911
|
-
fieldUpdates = _validateDomains(layerInfo, fieldUpdates);
|
|
7912
|
-
/* istanbul ignore else */
|
|
7913
|
-
if (fieldUpdates.length > 0) {
|
|
7914
|
-
layerInfo.fields = fieldUpdates;
|
|
7915
|
-
}
|
|
7916
|
-
layerInfo.typeIdField = _getTypeIdField(item);
|
|
7917
|
-
const fieldNames = layerInfo.newFields.map((f) => f.name);
|
|
7918
|
-
_validateTemplatesFields(layerInfo, fieldNames);
|
|
7919
|
-
_validateTypesTemplates(layerInfo, fieldNames);
|
|
7920
7965
|
}
|
|
7921
7966
|
}
|
|
7922
7967
|
});
|
|
@@ -7932,141 +7977,35 @@
|
|
|
7932
7977
|
});
|
|
7933
7978
|
}
|
|
7934
7979
|
/**
|
|
7935
|
-
*
|
|
7936
|
-
*
|
|
7937
|
-
*
|
|
7938
|
-
* @param item current layer or table
|
|
7939
|
-
* @returns name of field to set for typeIdField in the update call
|
|
7940
|
-
* @private
|
|
7941
|
-
*/
|
|
7942
|
-
function _getTypeIdField(item) {
|
|
7943
|
-
const typeIdFields = item.fields.filter((f) => {
|
|
7944
|
-
return (f.name &&
|
|
7945
|
-
item.typeIdField &&
|
|
7946
|
-
f.name.toLowerCase() === item.typeIdField.toLowerCase());
|
|
7947
|
-
});
|
|
7948
|
-
return Array.isArray(typeIdFields) && typeIdFields.length === 1
|
|
7949
|
-
? typeIdFields[0].name
|
|
7950
|
-
: item.typeIdField;
|
|
7951
|
-
}
|
|
7952
|
-
/**
|
|
7953
|
-
* Update a views field visibility to match that of the source
|
|
7954
|
-
* Fields that are marked as visible false on a view are all set to
|
|
7955
|
-
* visible true when added with the layer definition
|
|
7980
|
+
* View field domain, alias, editable, and visible props can contain
|
|
7981
|
+
* different values from the source.
|
|
7956
7982
|
*
|
|
7957
|
-
*
|
|
7958
|
-
* @returns Array of fields that should not be visible in the view
|
|
7959
|
-
* @private
|
|
7960
|
-
*/
|
|
7961
|
-
function _getFieldVisibilityUpdates(fieldInfo) {
|
|
7962
|
-
const visibilityUpdates = [];
|
|
7963
|
-
if (fieldInfo && fieldInfo["sourceFields"] && fieldInfo["newFields"]) {
|
|
7964
|
-
const sourceFields = fieldInfo["sourceFields"].reduce((hash, f) => {
|
|
7965
|
-
hash[String(f.name).toLocaleLowerCase()] = f.visible;
|
|
7966
|
-
return hash;
|
|
7967
|
-
}, {});
|
|
7968
|
-
fieldInfo["newFields"].forEach((f) => {
|
|
7969
|
-
const name = String(f.name).toLocaleLowerCase();
|
|
7970
|
-
// only add fields that are not visible
|
|
7971
|
-
if (sourceFields.hasOwnProperty(name) && !sourceFields[name]) {
|
|
7972
|
-
visibilityUpdates.push({
|
|
7973
|
-
name: f.name,
|
|
7974
|
-
visible: sourceFields[name]
|
|
7975
|
-
});
|
|
7976
|
-
}
|
|
7977
|
-
});
|
|
7978
|
-
}
|
|
7979
|
-
return visibilityUpdates;
|
|
7980
|
-
}
|
|
7981
|
-
/**
|
|
7982
|
-
* view field domains can contain different values than the source feature service field domains
|
|
7983
|
-
* use the cached domain when it differs from the source view field domain
|
|
7983
|
+
* We need to check and set isFieldOverride to true when this occurs and false when it does not
|
|
7984
7984
|
*
|
|
7985
7985
|
* @param fieldInfo current view layer or table fieldInfo
|
|
7986
|
-
* @param
|
|
7987
|
-
* @returns Array of fields to be updated
|
|
7988
|
-
* @private
|
|
7989
|
-
*/
|
|
7990
|
-
function _validateDomains(fieldInfo, fieldUpdates) {
|
|
7991
|
-
const domainAliasInfos = _getDomainAndAliasInfos(fieldInfo);
|
|
7992
|
-
const domainFields = domainAliasInfos.domainFields;
|
|
7993
|
-
const domainNames = domainAliasInfos.domainNames;
|
|
7994
|
-
const aliasFields = domainAliasInfos.aliasFields;
|
|
7995
|
-
const aliasNames = domainAliasInfos.aliasNames;
|
|
7996
|
-
// loop through the fields from the new view service
|
|
7997
|
-
// add an update when the domains don't match
|
|
7998
|
-
fieldInfo.newFields.forEach((field) => {
|
|
7999
|
-
_getPortalViewFieldUpdates(field, domainNames, domainFields, "domain", fieldUpdates);
|
|
8000
|
-
_getPortalViewFieldUpdates(field, aliasNames, aliasFields, "alias", fieldUpdates);
|
|
8001
|
-
});
|
|
8002
|
-
return fieldUpdates;
|
|
8003
|
-
}
|
|
8004
|
-
/**
|
|
8005
|
-
* Get portal field updates to be added with an updateDefinition call after the
|
|
8006
|
-
* initial addToDef
|
|
7986
|
+
* @param item that stores the view fields
|
|
8007
7987
|
*
|
|
8008
|
-
*
|
|
8009
|
-
* @param names the alias of domain field names
|
|
8010
|
-
* @param fields the alias or domain fields
|
|
8011
|
-
* @param key the field key to evaluate
|
|
8012
|
-
* @param fieldUpdates any existing field updates
|
|
7988
|
+
* This function will update the item that is provided
|
|
8013
7989
|
* @private
|
|
8014
7990
|
*/
|
|
8015
|
-
function
|
|
8016
|
-
|
|
8017
|
-
const i = names.indexOf(String(field.name).toLocaleLowerCase());
|
|
8018
|
-
if (JSON.stringify(field[key]) !== (i > -1 ? JSON.stringify(fields[i]) : "")) {
|
|
8019
|
-
// should mixin the update if the field already has some other update
|
|
8020
|
-
let hasUpdate = false;
|
|
8021
|
-
fieldUpdates.some((update) => {
|
|
8022
|
-
if (update.name === field.name) {
|
|
8023
|
-
hasUpdate = true;
|
|
8024
|
-
update[key] = field[key];
|
|
8025
|
-
}
|
|
8026
|
-
return hasUpdate;
|
|
8027
|
-
});
|
|
8028
|
-
if (!hasUpdate) {
|
|
8029
|
-
const update = { name: field.name };
|
|
8030
|
-
update[key] = field[key];
|
|
8031
|
-
fieldUpdates.push(update);
|
|
8032
|
-
}
|
|
8033
|
-
}
|
|
8034
|
-
}
|
|
8035
|
-
}
|
|
8036
|
-
/**
|
|
8037
|
-
* view field domains can contain different values than the source feature service field domains
|
|
8038
|
-
* use the cached domain when it differs from the source view field domain
|
|
8039
|
-
*
|
|
8040
|
-
* @param fieldInfo current view layer or table fieldInfo
|
|
8041
|
-
* @param fieldUpdates any existing field updates
|
|
8042
|
-
* @returns Array of fields to be updated
|
|
8043
|
-
* @private
|
|
8044
|
-
*/
|
|
8045
|
-
function _validateViewDomainsAndAlias(fieldInfo, item) {
|
|
8046
|
-
const domainAliasInfos = _getDomainAndAliasInfos(fieldInfo);
|
|
8047
|
-
const domainFields = domainAliasInfos.domainFields;
|
|
8048
|
-
const domainNames = domainAliasInfos.domainNames;
|
|
8049
|
-
const aliasFields = domainAliasInfos.aliasFields;
|
|
8050
|
-
const aliasNames = domainAliasInfos.aliasNames;
|
|
8051
|
-
// loop through the fields from the item
|
|
8052
|
-
// add isViewOverride when the domains or alias don't match
|
|
7991
|
+
function _validateViewFieldInfos(fieldInfo, item) {
|
|
7992
|
+
const fieldInfos = _getViewFieldInfos(fieldInfo);
|
|
8053
7993
|
item.fields.map((field) => {
|
|
8054
|
-
|
|
8055
|
-
|
|
7994
|
+
Object.keys(fieldInfos).forEach(fi => {
|
|
7995
|
+
_isViewFieldOverride(field, fieldInfos[fi].names, fieldInfos[fi].vals, fi);
|
|
7996
|
+
});
|
|
8056
7997
|
return field;
|
|
8057
7998
|
});
|
|
8058
7999
|
}
|
|
8059
8000
|
/**
|
|
8060
|
-
* Get
|
|
8001
|
+
* Get arrays of fields and names for domain, alias, and editable props
|
|
8061
8002
|
*
|
|
8062
8003
|
* @param fieldInfo current view layer or table fieldInfo
|
|
8063
8004
|
* @private
|
|
8064
8005
|
*/
|
|
8065
|
-
function
|
|
8066
|
-
const
|
|
8067
|
-
const
|
|
8068
|
-
const aliasFields = [];
|
|
8069
|
-
const aliasNames = [];
|
|
8006
|
+
function _getViewFieldInfos(fieldInfo) {
|
|
8007
|
+
const fieldInfos = {};
|
|
8008
|
+
const fieldOverrideKeys = ["domain", "alias", "editable"];
|
|
8070
8009
|
/* istanbul ignore else */
|
|
8071
8010
|
if (fieldInfo.sourceServiceFields) {
|
|
8072
8011
|
Object.keys(fieldInfo.sourceServiceFields).forEach(k => {
|
|
@@ -8074,44 +8013,49 @@
|
|
|
8074
8013
|
if (fieldInfo.sourceServiceFields[k]) {
|
|
8075
8014
|
Object.keys(fieldInfo.sourceServiceFields[k]).forEach(_k => {
|
|
8076
8015
|
fieldInfo.sourceServiceFields[k][_k].forEach((field) => {
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
|
|
8080
|
-
|
|
8081
|
-
|
|
8082
|
-
|
|
8083
|
-
|
|
8084
|
-
|
|
8085
|
-
|
|
8086
|
-
|
|
8016
|
+
fieldOverrideKeys.forEach(o_k => {
|
|
8017
|
+
/* istanbul ignore else */
|
|
8018
|
+
if (field.hasOwnProperty(o_k)) {
|
|
8019
|
+
const name = String(field.name).toLocaleLowerCase();
|
|
8020
|
+
const v = field[o_k];
|
|
8021
|
+
if (getProp(fieldInfos, o_k)) {
|
|
8022
|
+
fieldInfos[o_k].names.push(name);
|
|
8023
|
+
fieldInfos[o_k].vals.push(v);
|
|
8024
|
+
}
|
|
8025
|
+
else {
|
|
8026
|
+
fieldInfos[o_k] = {
|
|
8027
|
+
names: [name],
|
|
8028
|
+
vals: [v]
|
|
8029
|
+
};
|
|
8030
|
+
}
|
|
8031
|
+
}
|
|
8032
|
+
});
|
|
8087
8033
|
});
|
|
8088
8034
|
});
|
|
8089
8035
|
}
|
|
8090
8036
|
});
|
|
8091
8037
|
}
|
|
8092
|
-
return
|
|
8093
|
-
aliasFields,
|
|
8094
|
-
aliasNames,
|
|
8095
|
-
domainFields,
|
|
8096
|
-
domainNames
|
|
8097
|
-
};
|
|
8038
|
+
return fieldInfos;
|
|
8098
8039
|
}
|
|
8099
8040
|
/**
|
|
8100
8041
|
* Set isViewOverride for view fields when they have differences from the source FS field
|
|
8101
8042
|
*
|
|
8102
8043
|
* @param field the field instance we are testing
|
|
8103
8044
|
* @param names array of field names
|
|
8104
|
-
* @param
|
|
8045
|
+
* @param vals array of values
|
|
8105
8046
|
* @param key the field key to compare
|
|
8106
8047
|
* @private
|
|
8107
8048
|
*/
|
|
8108
|
-
function _isViewFieldOverride(field, names,
|
|
8049
|
+
function _isViewFieldOverride(field, names, vals, key) {
|
|
8109
8050
|
/* istanbul ignore else */
|
|
8110
|
-
if (field.hasOwnProperty(key)
|
|
8051
|
+
if (field.hasOwnProperty(key)) {
|
|
8111
8052
|
const i = names.indexOf(String(field.name).toLocaleLowerCase());
|
|
8053
|
+
const isOverride = JSON.stringify(field[key]) !== (i > -1 ? JSON.stringify(vals[i]) : "");
|
|
8054
|
+
const overrideSet = field.hasOwnProperty('isViewOverride');
|
|
8055
|
+
// need to skip this check if isViewOverride has already been set to true
|
|
8112
8056
|
/* istanbul ignore else */
|
|
8113
|
-
if (
|
|
8114
|
-
field.isViewOverride =
|
|
8057
|
+
if (((overrideSet && !field.isViewOverride) || !overrideSet)) {
|
|
8058
|
+
field.isViewOverride = isOverride;
|
|
8115
8059
|
}
|
|
8116
8060
|
}
|
|
8117
8061
|
}
|
|
@@ -10363,6 +10307,9 @@
|
|
|
10363
10307
|
// Create item
|
|
10364
10308
|
_getCreateServiceOptions(newItemTemplate, authentication, templateDictionary).then(createOptions => {
|
|
10365
10309
|
arcgisRestServiceAdmin.createFeatureService(createOptions).then(createResponse => {
|
|
10310
|
+
// Federated servers may have inconsistent casing, so lowerCase it
|
|
10311
|
+
createResponse.encodedServiceURL = _lowercaseDomain(createResponse.encodedServiceURL);
|
|
10312
|
+
createResponse.serviceurl = _lowercaseDomain(createResponse.serviceurl);
|
|
10366
10313
|
resolve(createResponse);
|
|
10367
10314
|
}, e => reject(fail(e)));
|
|
10368
10315
|
}, e => reject(fail(e)));
|
|
@@ -10713,12 +10660,6 @@
|
|
|
10713
10660
|
deleteProp(obj, "deleteFields");
|
|
10714
10661
|
updates.push(_getUpdate(adminUrl, null, null, args, "refresh"));
|
|
10715
10662
|
}
|
|
10716
|
-
// handle definition updates
|
|
10717
|
-
// for portal only as online will now all be handled in addToDef
|
|
10718
|
-
if (isPortal) {
|
|
10719
|
-
updates.push(_getUpdate(adminUrl, id, obj, args, "update"));
|
|
10720
|
-
updates.push(refresh);
|
|
10721
|
-
}
|
|
10722
10663
|
});
|
|
10723
10664
|
// issue: #706
|
|
10724
10665
|
// Add source service relationships
|
|
@@ -10739,8 +10680,21 @@
|
|
|
10739
10680
|
updates.push(_getUpdate(adminUrl, null, relUpdates, args, "add"));
|
|
10740
10681
|
updates.push(refresh);
|
|
10741
10682
|
}
|
|
10683
|
+
// handle contingent values
|
|
10684
|
+
const contingentValuesUpdates = _getContingentValuesUpdates({
|
|
10685
|
+
message: "add layer contingent values",
|
|
10686
|
+
objects: args.objects,
|
|
10687
|
+
itemTemplate: args.itemTemplate,
|
|
10688
|
+
authentication: args.authentication
|
|
10689
|
+
});
|
|
10690
|
+
/* istanbul ignore else */
|
|
10691
|
+
if (contingentValuesUpdates.length > 0) {
|
|
10692
|
+
contingentValuesUpdates.forEach(conUpdate => {
|
|
10693
|
+
updates.push(_getUpdate(adminUrl + conUpdate.id, null, conUpdate.contingentValues, args, "add"));
|
|
10694
|
+
});
|
|
10695
|
+
}
|
|
10742
10696
|
}
|
|
10743
|
-
return updates;
|
|
10697
|
+
return updates.length === 1 ? [] : updates;
|
|
10744
10698
|
}
|
|
10745
10699
|
/**
|
|
10746
10700
|
* Sorts relationships based on order of supporting layers and tables in the service definition
|
|
@@ -10770,32 +10724,6 @@
|
|
|
10770
10724
|
});
|
|
10771
10725
|
return _relUpdateLayers;
|
|
10772
10726
|
}
|
|
10773
|
-
/**
|
|
10774
|
-
* Update view service when sourceSchemaChangesAllowed is true.
|
|
10775
|
-
*
|
|
10776
|
-
* This property needs to be set after the fact when deploying to portal as it does not honor
|
|
10777
|
-
* when set during service creation.
|
|
10778
|
-
*
|
|
10779
|
-
* @param itemTemplate Template of item being deployed
|
|
10780
|
-
* @param authentication Credentials for the request
|
|
10781
|
-
* @param updates An array of update instructions
|
|
10782
|
-
* @returns An array of update instructions
|
|
10783
|
-
*/
|
|
10784
|
-
function getFinalServiceUpdates(itemTemplate, authentication, updates) {
|
|
10785
|
-
const sourceSchemaChangesAllowed = getProp(itemTemplate, "properties.service.sourceSchemaChangesAllowed");
|
|
10786
|
-
const isView = getProp(itemTemplate, "properties.service.isView");
|
|
10787
|
-
/* istanbul ignore else */
|
|
10788
|
-
if (sourceSchemaChangesAllowed && isView) {
|
|
10789
|
-
const adminUrl = itemTemplate.item.url.replace("rest/services", "rest/admin/services");
|
|
10790
|
-
const args = {
|
|
10791
|
-
authentication,
|
|
10792
|
-
message: "final service update"
|
|
10793
|
-
};
|
|
10794
|
-
const serviceUpdates = { sourceSchemaChangesAllowed };
|
|
10795
|
-
updates.push(_getUpdate(adminUrl, null, serviceUpdates, args, "update"));
|
|
10796
|
-
}
|
|
10797
|
-
return updates;
|
|
10798
|
-
}
|
|
10799
10727
|
/**
|
|
10800
10728
|
* Add additional options to a layers definition
|
|
10801
10729
|
*
|
|
@@ -10914,12 +10842,14 @@
|
|
|
10914
10842
|
delete serviceData.tables;
|
|
10915
10843
|
// Ensure solution items have unique indexes on relationship key fields
|
|
10916
10844
|
_updateIndexesForRelationshipKeyFields(properties);
|
|
10917
|
-
|
|
10918
|
-
|
|
10919
|
-
|
|
10920
|
-
|
|
10921
|
-
|
|
10922
|
-
|
|
10845
|
+
processContingentValues(properties, serviceUrl, authentication).then(() => {
|
|
10846
|
+
if (workforceService) {
|
|
10847
|
+
getWorkforceServiceInfo(properties, serviceUrl, authentication).then(resolve, reject);
|
|
10848
|
+
}
|
|
10849
|
+
else {
|
|
10850
|
+
resolve(properties);
|
|
10851
|
+
}
|
|
10852
|
+
}, (e) => reject(fail(e)));
|
|
10923
10853
|
}, (e) => reject(fail(e)));
|
|
10924
10854
|
});
|
|
10925
10855
|
}
|
|
@@ -11545,6 +11475,28 @@
|
|
|
11545
11475
|
});
|
|
11546
11476
|
return rels;
|
|
11547
11477
|
}
|
|
11478
|
+
/**
|
|
11479
|
+
* Get the stored contingent values and structure them to be added to the services layers.
|
|
11480
|
+
*
|
|
11481
|
+
* @param args The IPostProcessArgs for the request(s)
|
|
11482
|
+
* @returns Any contingent values that should be added to the service.
|
|
11483
|
+
* @private
|
|
11484
|
+
*/
|
|
11485
|
+
function _getContingentValuesUpdates(args) {
|
|
11486
|
+
const contingentValues = [];
|
|
11487
|
+
Object.keys(args.objects).forEach((k) => {
|
|
11488
|
+
const obj = args.objects[k];
|
|
11489
|
+
/* istanbul ignore else */
|
|
11490
|
+
if (obj.contingentValues) {
|
|
11491
|
+
contingentValues.push({
|
|
11492
|
+
id: obj.id,
|
|
11493
|
+
contingentValues: obj.contingentValues
|
|
11494
|
+
});
|
|
11495
|
+
}
|
|
11496
|
+
deleteProp(obj, "contingentValues");
|
|
11497
|
+
});
|
|
11498
|
+
return contingentValues;
|
|
11499
|
+
}
|
|
11548
11500
|
/**
|
|
11549
11501
|
* Get refresh, add, update, or delete definition info
|
|
11550
11502
|
*
|
|
@@ -11592,6 +11544,25 @@
|
|
|
11592
11544
|
args: args
|
|
11593
11545
|
};
|
|
11594
11546
|
}
|
|
11547
|
+
/**
|
|
11548
|
+
* Changes just the domain part of a URL to lowercase.
|
|
11549
|
+
*
|
|
11550
|
+
* @param url URL to modify
|
|
11551
|
+
* @return Adjusted URL
|
|
11552
|
+
* @see From `getServerRootUrl` in arcgis-rest-js' ArcGISIdentityManager.ts
|
|
11553
|
+
* @private
|
|
11554
|
+
*/
|
|
11555
|
+
function _lowercaseDomain(url) {
|
|
11556
|
+
if (!url) {
|
|
11557
|
+
return url;
|
|
11558
|
+
}
|
|
11559
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
11560
|
+
const [_, protocol, domainAndPath] = url.match(/(https?:\/\/)(.+)/);
|
|
11561
|
+
const [domain, ...path] = domainAndPath.split("/");
|
|
11562
|
+
// Only the domain is lowercased because in some cases an org id might be
|
|
11563
|
+
// in the path which cannot be lowercased.
|
|
11564
|
+
return `${protocol}${domain.toLowerCase()}/${path.join("/")}`;
|
|
11565
|
+
}
|
|
11595
11566
|
/**
|
|
11596
11567
|
* Checks the two main parts of an item for unresolved variables and reports any found.
|
|
11597
11568
|
*
|
|
@@ -14991,25 +14962,24 @@
|
|
|
14991
14962
|
exports._getAddFeatures = _getAddFeatures;
|
|
14992
14963
|
exports._getAssignmentIntegrationInfos = _getAssignmentIntegrationInfos;
|
|
14993
14964
|
exports._getAssignmentTypeInfos = _getAssignmentTypeInfos;
|
|
14965
|
+
exports._getContingentValuesUpdates = _getContingentValuesUpdates;
|
|
14994
14966
|
exports._getCreateServiceOptions = _getCreateServiceOptions;
|
|
14995
14967
|
exports._getDependantItemId = _getDependantItemId;
|
|
14996
|
-
exports._getDomainAndAliasInfos = _getDomainAndAliasInfos;
|
|
14997
14968
|
exports._getFallbackExtent = _getFallbackExtent;
|
|
14998
14969
|
exports._getField = _getField;
|
|
14999
14970
|
exports._getFieldNames = _getFieldNames;
|
|
15000
|
-
exports._getFieldVisibilityUpdates = _getFieldVisibilityUpdates;
|
|
15001
14971
|
exports._getFields = _getFields;
|
|
15002
14972
|
exports._getGroupContentsTranche = _getGroupContentsTranche;
|
|
15003
14973
|
exports._getItemResourcesTranche = _getItemResourcesTranche;
|
|
15004
14974
|
exports._getLayerChunkSize = _getLayerChunkSize;
|
|
15005
14975
|
exports._getNameMapping = _getNameMapping;
|
|
15006
|
-
exports._getPortalViewFieldUpdates = _getPortalViewFieldUpdates;
|
|
15007
14976
|
exports._getRandomNumberInRange = _getRandomNumberInRange;
|
|
15008
14977
|
exports._getRelationshipUpdates = _getRelationshipUpdates;
|
|
15009
|
-
exports._getTypeIdField = _getTypeIdField;
|
|
15010
14978
|
exports._getURLs = _getURLs;
|
|
15011
14979
|
exports._getUpdate = _getUpdate;
|
|
14980
|
+
exports._getViewFieldInfos = _getViewFieldInfos;
|
|
15012
14981
|
exports._isViewFieldOverride = _isViewFieldOverride;
|
|
14982
|
+
exports._lowercaseDomain = _lowercaseDomain;
|
|
15013
14983
|
exports._padPositiveNum = _padPositiveNum;
|
|
15014
14984
|
exports._parseAdminServiceData = _parseAdminServiceData;
|
|
15015
14985
|
exports._processAdminObject = _processAdminObject;
|
|
@@ -15066,7 +15036,6 @@
|
|
|
15066
15036
|
exports._updateTypeKeywords = _updateTypeKeywords;
|
|
15067
15037
|
exports._updateUrl = _updateUrl;
|
|
15068
15038
|
exports._validateDisplayField = _validateDisplayField;
|
|
15069
|
-
exports._validateDomains = _validateDomains;
|
|
15070
15039
|
exports._validateEditFieldsInfo = _validateEditFieldsInfo;
|
|
15071
15040
|
exports._validateExtent = _validateExtent;
|
|
15072
15041
|
exports._validateFields = _validateFields;
|
|
@@ -15074,7 +15043,7 @@
|
|
|
15074
15043
|
exports._validateTemplatesFields = _validateTemplatesFields;
|
|
15075
15044
|
exports._validateTrackingTemplates = _validateTrackingTemplates;
|
|
15076
15045
|
exports._validateTypesTemplates = _validateTypesTemplates;
|
|
15077
|
-
exports.
|
|
15046
|
+
exports._validateViewFieldInfos = _validateViewFieldInfos;
|
|
15078
15047
|
exports.addFeatureServiceDefinition = addFeatureServiceDefinition;
|
|
15079
15048
|
exports.addFeatureServiceLayersAndTables = addFeatureServiceLayersAndTables;
|
|
15080
15049
|
exports.addForwardItemRelationship = addForwardItemRelationship;
|
|
@@ -15088,6 +15057,7 @@
|
|
|
15088
15057
|
exports.blobToFile = blobToFile;
|
|
15089
15058
|
exports.blobToJson = blobToJson;
|
|
15090
15059
|
exports.blobToText = blobToText;
|
|
15060
|
+
exports.cacheContingentValues = cacheContingentValues;
|
|
15091
15061
|
exports.cacheFieldInfos = cacheFieldInfos;
|
|
15092
15062
|
exports.cachePopupInfos = cachePopupInfos;
|
|
15093
15063
|
exports.checkJsonForError = checkJsonForError;
|
|
@@ -15168,7 +15138,6 @@
|
|
|
15168
15138
|
exports.getExistingLayersAndTables = getExistingLayersAndTables;
|
|
15169
15139
|
exports.getFeatureServiceProperties = getFeatureServiceProperties;
|
|
15170
15140
|
exports.getFilenameFromUrl = getFilenameFromUrl;
|
|
15171
|
-
exports.getFinalServiceUpdates = getFinalServiceUpdates;
|
|
15172
15141
|
exports.getFoldersAndGroups = getFoldersAndGroups;
|
|
15173
15142
|
exports.getGroupBase = getGroupBase;
|
|
15174
15143
|
exports.getGroupCategorySchema = getGroupCategorySchema;
|
|
@@ -15246,6 +15215,7 @@
|
|
|
15246
15215
|
exports.placeholder = placeholder;
|
|
15247
15216
|
exports.postProcessFields = postProcessFields;
|
|
15248
15217
|
exports.postProcessWorkforceTemplates = postProcessWorkforceTemplates;
|
|
15218
|
+
exports.processContingentValues = processContingentValues;
|
|
15249
15219
|
exports.reassignGroup = reassignGroup;
|
|
15250
15220
|
exports.reconstructBuildOrderIds = reconstructBuildOrderIds;
|
|
15251
15221
|
exports.regExTest = regExTest;
|