@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
package/dist/node/restHelpers.js
CHANGED
|
@@ -15,26 +15,38 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
19
|
-
|
|
18
|
+
exports._updateIndexesForRelationshipKeyFields = exports._setItemProperties = exports._reportVariablesInItem = exports._getUpdate = exports._getRelationshipUpdates = exports._getFallbackExtent = exports._getCreateServiceOptions = exports._countRelationships = exports._addItemMetadataFile = exports._addItemDataFile = exports.updateItemURL = exports.updateItemTemplateFromDictionary = exports.updateItemExtended = exports.updateItem = exports.shareItem = exports.removeUsers = exports.reassignGroup = exports.searchGroupContents = exports.searchAllGroups = exports.searchGroups = exports.removeItemOrGroup = exports.removeItem = exports.removeGroup = exports.removeFolder = exports.hasInvalidGroupDesignations = exports._parseAdminServiceData = exports.getFeatureServiceProperties = exports.getServiceLayersAndTables = exports.getRequest = exports.getFinalServiceUpdates = exports._sortRelationships = exports.getLayerUpdates = exports.getLayers = exports.extractDependencies = exports.createUniqueGroup = exports.createUniqueFolder = exports.createItemWithData = exports.createFullItem = exports.createFeatureService = exports.convertExtent = exports.convertExtentWithFallback = exports._validateExtent = exports.checkRequestStatus = exports.addToServiceDefinition = exports.addTokenToUrl = exports.addForwardItemRelationships = exports.addForwardItemRelationship = exports.searchItems = exports.getUserSession = exports.rest_request = void 0;
|
|
19
|
+
exports._updateItemURL = void 0;
|
|
20
20
|
/**
|
|
21
21
|
* Provides common functions involving the arcgis-rest-js library.
|
|
22
22
|
*
|
|
23
23
|
* @module restHelpers
|
|
24
24
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
const featureServiceHelpers_1 = require("./featureServiceHelpers");
|
|
26
|
+
const generalHelpers_1 = require("./generalHelpers");
|
|
27
|
+
const interfaces_1 = require("./interfaces");
|
|
28
|
+
const libConnectors_1 = require("./libConnectors");
|
|
29
|
+
const restHelpersGet_1 = require("./restHelpersGet");
|
|
30
|
+
const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
|
|
31
|
+
const arcgis_rest_request_1 = require("@esri/arcgis-rest-request");
|
|
32
|
+
const arcgis_rest_service_admin_1 = require("@esri/arcgis-rest-service-admin");
|
|
33
|
+
const workforceHelpers_1 = require("./workforceHelpers");
|
|
34
|
+
const templatization_1 = require("./templatization");
|
|
35
|
+
const trackingHelpers_1 = require("./trackingHelpers");
|
|
34
36
|
// ------------------------------------------------------------------------------------------------------------------ //
|
|
35
37
|
var arcgis_rest_request_2 = require("@esri/arcgis-rest-request");
|
|
36
38
|
Object.defineProperty(exports, "rest_request", { enumerable: true, get: function () { return arcgis_rest_request_2.request; } });
|
|
37
39
|
// ------------------------------------------------------------------------------------------------------------------ //
|
|
40
|
+
/**
|
|
41
|
+
* Creates a UserSession via a function so that the global arcgisSolution variable can access authentication.
|
|
42
|
+
*
|
|
43
|
+
* @param options See https://esri.github.io/arcgis-rest-js/api/auth/IUserSessionOptions/
|
|
44
|
+
* @return UserSession
|
|
45
|
+
*/
|
|
46
|
+
function getUserSession(options = {}) {
|
|
47
|
+
return new interfaces_1.UserSession(options);
|
|
48
|
+
}
|
|
49
|
+
exports.getUserSession = getUserSession;
|
|
38
50
|
/**
|
|
39
51
|
* Searches for items matching a query and that the caller has access to.
|
|
40
52
|
*
|
|
@@ -56,19 +68,19 @@ exports.searchItems = searchItems;
|
|
|
56
68
|
* @return A Promise to add item resources.
|
|
57
69
|
*/
|
|
58
70
|
function addForwardItemRelationship(originItemId, destinationItemId, relationshipType, authentication) {
|
|
59
|
-
return new Promise(
|
|
60
|
-
|
|
61
|
-
originItemId
|
|
62
|
-
destinationItemId
|
|
63
|
-
relationshipType
|
|
64
|
-
authentication
|
|
71
|
+
return new Promise(resolve => {
|
|
72
|
+
const requestOptions = {
|
|
73
|
+
originItemId,
|
|
74
|
+
destinationItemId,
|
|
75
|
+
relationshipType,
|
|
76
|
+
authentication
|
|
65
77
|
};
|
|
66
|
-
(0, arcgis_rest_portal_1.addItemRelationship)(requestOptions).then(
|
|
78
|
+
(0, arcgis_rest_portal_1.addItemRelationship)(requestOptions).then(response => {
|
|
67
79
|
resolve({
|
|
68
80
|
success: response.success,
|
|
69
81
|
itemId: originItemId
|
|
70
82
|
});
|
|
71
|
-
},
|
|
83
|
+
}, () => {
|
|
72
84
|
resolve({
|
|
73
85
|
success: false,
|
|
74
86
|
itemId: originItemId
|
|
@@ -86,18 +98,16 @@ exports.addForwardItemRelationship = addForwardItemRelationship;
|
|
|
86
98
|
* @return A Promise to add item resources.
|
|
87
99
|
*/
|
|
88
100
|
function addForwardItemRelationships(originItemId, destinationRelationships, authentication) {
|
|
89
|
-
return new Promise(
|
|
101
|
+
return new Promise(resolve => {
|
|
90
102
|
// Set up relationships using updated relationship information
|
|
91
|
-
|
|
92
|
-
destinationRelationships.forEach(
|
|
93
|
-
relationship.relatedItemIds.forEach(
|
|
103
|
+
const relationshipPromises = new Array();
|
|
104
|
+
destinationRelationships.forEach(relationship => {
|
|
105
|
+
relationship.relatedItemIds.forEach(relatedItemId => {
|
|
94
106
|
relationshipPromises.push(addForwardItemRelationship(originItemId, relatedItemId, relationship.relationshipType, authentication));
|
|
95
107
|
});
|
|
96
108
|
});
|
|
97
109
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
98
|
-
Promise.all(relationshipPromises).then(
|
|
99
|
-
return resolve(responses);
|
|
100
|
-
});
|
|
110
|
+
Promise.all(relationshipPromises).then((responses) => resolve(responses));
|
|
101
111
|
});
|
|
102
112
|
}
|
|
103
113
|
exports.addForwardItemRelationships = addForwardItemRelationships;
|
|
@@ -110,18 +120,18 @@ exports.addForwardItemRelationships = addForwardItemRelationships;
|
|
|
110
120
|
* unless either the URL doesn't exist or the token can't be generated
|
|
111
121
|
*/
|
|
112
122
|
function addTokenToUrl(url, authentication) {
|
|
113
|
-
return new Promise(
|
|
123
|
+
return new Promise(resolve => {
|
|
114
124
|
if (!url || !authentication) {
|
|
115
125
|
resolve(url);
|
|
116
126
|
}
|
|
117
127
|
else {
|
|
118
|
-
authentication.getToken(url).then(
|
|
128
|
+
authentication.getToken(url).then(token => {
|
|
119
129
|
/* istanbul ignore else */
|
|
120
130
|
if (token) {
|
|
121
131
|
url = (0, generalHelpers_1.appendQueryParam)(url, "token=" + token);
|
|
122
132
|
}
|
|
123
133
|
resolve(url);
|
|
124
|
-
},
|
|
134
|
+
}, () => resolve(url));
|
|
125
135
|
}
|
|
126
136
|
});
|
|
127
137
|
}
|
|
@@ -139,19 +149,17 @@ exports.addTokenToUrl = addTokenToUrl;
|
|
|
139
149
|
* @param useAsync a boolean to control if we will use an async request
|
|
140
150
|
* @return A promise that will resolve when the request has completed
|
|
141
151
|
*/
|
|
142
|
-
function addToServiceDefinition(url, options, skipRetry, useAsync) {
|
|
143
|
-
if (skipRetry === void 0) { skipRetry = false; }
|
|
144
|
-
if (useAsync === void 0) { useAsync = false; }
|
|
152
|
+
function addToServiceDefinition(url, options, skipRetry = false, useAsync = false) {
|
|
145
153
|
/* istanbul ignore else */
|
|
146
154
|
if (useAsync) {
|
|
147
|
-
options.params =
|
|
155
|
+
options.params = { ...options.params, async: true };
|
|
148
156
|
}
|
|
149
|
-
return new Promise(
|
|
150
|
-
(0, arcgis_rest_service_admin_1.addToServiceDefinition)(url, options).then(
|
|
151
|
-
checkRequestStatus(result, options.authentication).then(
|
|
152
|
-
},
|
|
157
|
+
return new Promise((resolve, reject) => {
|
|
158
|
+
(0, arcgis_rest_service_admin_1.addToServiceDefinition)(url, options).then((result) => {
|
|
159
|
+
checkRequestStatus(result, options.authentication).then(() => resolve(null), e => reject((0, generalHelpers_1.fail)(e)));
|
|
160
|
+
}, e => {
|
|
153
161
|
if (!skipRetry) {
|
|
154
|
-
addToServiceDefinition(url, options, true, true).then(
|
|
162
|
+
addToServiceDefinition(url, options, true, true).then(() => resolve(null), e => reject(e));
|
|
155
163
|
}
|
|
156
164
|
else {
|
|
157
165
|
reject((0, generalHelpers_1.fail)(e));
|
|
@@ -169,21 +177,21 @@ exports.addToServiceDefinition = addToServiceDefinition;
|
|
|
169
177
|
* @return A promise that will resolve when the request has completed
|
|
170
178
|
*/
|
|
171
179
|
function checkRequestStatus(result, authentication) {
|
|
172
|
-
return new Promise(
|
|
180
|
+
return new Promise((resolve, reject) => {
|
|
173
181
|
if (result.statusURL) {
|
|
174
|
-
|
|
175
|
-
(0, arcgis_rest_request_1.request)(result.statusURL, { authentication
|
|
182
|
+
const checkStatus = setInterval(() => {
|
|
183
|
+
(0, arcgis_rest_request_1.request)(result.statusURL, { authentication }).then(r => {
|
|
176
184
|
/* istanbul ignore else */
|
|
177
185
|
if (r.status === "Completed") {
|
|
178
|
-
clearInterval(
|
|
186
|
+
clearInterval(checkStatus);
|
|
179
187
|
resolve();
|
|
180
188
|
}
|
|
181
189
|
else if (r.status === "Failed") {
|
|
182
|
-
clearInterval(
|
|
190
|
+
clearInterval(checkStatus);
|
|
183
191
|
reject(r);
|
|
184
192
|
}
|
|
185
|
-
},
|
|
186
|
-
clearInterval(
|
|
193
|
+
}, e => {
|
|
194
|
+
clearInterval(checkStatus);
|
|
187
195
|
reject(e);
|
|
188
196
|
});
|
|
189
197
|
}, 2000);
|
|
@@ -206,7 +214,7 @@ function _validateExtent(extent) {
|
|
|
206
214
|
// in some cases orgs can have invalid extents defined
|
|
207
215
|
// this is a simple validate function that will ensure coordiantes are numbers
|
|
208
216
|
// using -179,-89,179,89 because the project call is returning "NaN" when using -180,-90,180,90
|
|
209
|
-
|
|
217
|
+
const hasInvalid = typeof extent.xmin !== "number" ||
|
|
210
218
|
typeof extent.xmax !== "number" ||
|
|
211
219
|
typeof extent.ymax !== "number" ||
|
|
212
220
|
typeof extent.ymin !== "number";
|
|
@@ -235,29 +243,29 @@ exports._validateExtent = _validateExtent;
|
|
|
235
243
|
* @private
|
|
236
244
|
*/
|
|
237
245
|
function convertExtentWithFallback(extent, fallbackExtent, outSR, geometryServiceUrl, authentication) {
|
|
238
|
-
return new Promise(
|
|
239
|
-
|
|
246
|
+
return new Promise((resolve, reject) => {
|
|
247
|
+
const defaultExtent = {
|
|
240
248
|
xmin: -179,
|
|
241
249
|
xmax: 179,
|
|
242
250
|
ymin: -89,
|
|
243
251
|
ymax: 89,
|
|
244
252
|
spatialReference: { wkid: 4326 }
|
|
245
253
|
};
|
|
246
|
-
convertExtent(_validateExtent(extent), outSR, geometryServiceUrl, authentication).then(
|
|
254
|
+
convertExtent(_validateExtent(extent), outSR, geometryServiceUrl, authentication).then(extentResponse => {
|
|
247
255
|
// in some cases project will complete successfully but return "NaN" values
|
|
248
256
|
// check for this and call convert again if it does
|
|
249
|
-
|
|
250
|
-
|
|
257
|
+
const extentResponseString = JSON.stringify(extentResponse);
|
|
258
|
+
const validatedExtent = JSON.stringify(_validateExtent(extentResponse));
|
|
251
259
|
if (extentResponseString === validatedExtent) {
|
|
252
260
|
resolve(extentResponse);
|
|
253
261
|
}
|
|
254
262
|
else {
|
|
255
|
-
convertExtent(fallbackExtent || defaultExtent, outSR, geometryServiceUrl, authentication).then(resolve,
|
|
263
|
+
convertExtent(fallbackExtent || defaultExtent, outSR, geometryServiceUrl, authentication).then(resolve, e => reject((0, generalHelpers_1.fail)(e)));
|
|
256
264
|
}
|
|
257
265
|
},
|
|
258
266
|
// if convert fails try again with default global extent
|
|
259
|
-
|
|
260
|
-
convertExtent(defaultExtent, outSR, geometryServiceUrl, authentication).then(resolve,
|
|
267
|
+
() => {
|
|
268
|
+
convertExtent(defaultExtent, outSR, geometryServiceUrl, authentication).then(resolve, e => reject((0, generalHelpers_1.fail)(e)));
|
|
261
269
|
});
|
|
262
270
|
});
|
|
263
271
|
}
|
|
@@ -272,10 +280,10 @@ exports.convertExtentWithFallback = convertExtentWithFallback;
|
|
|
272
280
|
* @return Original extent if it's already using outSR or the extents projected into the outSR
|
|
273
281
|
*/
|
|
274
282
|
function convertExtent(extent, outSR, geometryServiceUrl, authentication) {
|
|
275
|
-
|
|
276
|
-
return new Promise(
|
|
283
|
+
const _requestOptions = Object.assign({}, authentication);
|
|
284
|
+
return new Promise((resolve, reject) => {
|
|
277
285
|
// tslint:disable-next-line:no-unnecessary-type-assertion
|
|
278
|
-
if (extent.spatialReference.wkid ===
|
|
286
|
+
if (extent.spatialReference.wkid === outSR?.wkid || !outSR) {
|
|
279
287
|
resolve(extent);
|
|
280
288
|
}
|
|
281
289
|
else {
|
|
@@ -286,11 +294,11 @@ function convertExtent(extent, outSR, geometryServiceUrl, authentication) {
|
|
|
286
294
|
outSR: outSR.wkid,
|
|
287
295
|
extentOfInterest: JSON.stringify(extent)
|
|
288
296
|
};
|
|
289
|
-
(0, arcgis_rest_request_1.request)((0, generalHelpers_1.checkUrlPathTermination)(geometryServiceUrl) + "findTransformations", _requestOptions).then(
|
|
290
|
-
|
|
297
|
+
(0, arcgis_rest_request_1.request)((0, generalHelpers_1.checkUrlPathTermination)(geometryServiceUrl) + "findTransformations", _requestOptions).then(response => {
|
|
298
|
+
const transformations = response && response.transformations
|
|
291
299
|
? response.transformations
|
|
292
300
|
: undefined;
|
|
293
|
-
|
|
301
|
+
let transformation;
|
|
294
302
|
if (transformations && transformations.length > 0) {
|
|
295
303
|
// if a forward single transformation is found use that...otherwise check for and use composite
|
|
296
304
|
transformation = transformations[0].wkid
|
|
@@ -313,8 +321,8 @@ function convertExtent(extent, outSR, geometryServiceUrl, authentication) {
|
|
|
313
321
|
},
|
|
314
322
|
transformation: transformation
|
|
315
323
|
};
|
|
316
|
-
(0, arcgis_rest_request_1.request)((0, generalHelpers_1.checkUrlPathTermination)(geometryServiceUrl) + "project", _requestOptions).then(
|
|
317
|
-
|
|
324
|
+
(0, arcgis_rest_request_1.request)((0, generalHelpers_1.checkUrlPathTermination)(geometryServiceUrl) + "project", _requestOptions).then(projectResponse => {
|
|
325
|
+
const projectGeom = projectResponse.geometries.length === 2
|
|
318
326
|
? projectResponse.geometries
|
|
319
327
|
: undefined;
|
|
320
328
|
if (projectGeom) {
|
|
@@ -329,8 +337,8 @@ function convertExtent(extent, outSR, geometryServiceUrl, authentication) {
|
|
|
329
337
|
else {
|
|
330
338
|
resolve(undefined);
|
|
331
339
|
}
|
|
332
|
-
},
|
|
333
|
-
},
|
|
340
|
+
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
341
|
+
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
334
342
|
}
|
|
335
343
|
});
|
|
336
344
|
}
|
|
@@ -344,13 +352,13 @@ exports.convertExtent = convertExtent;
|
|
|
344
352
|
* @return A promise that will resolve with an object reporting success and the Solution id
|
|
345
353
|
*/
|
|
346
354
|
function createFeatureService(newItemTemplate, authentication, templateDictionary) {
|
|
347
|
-
return new Promise(
|
|
355
|
+
return new Promise((resolve, reject) => {
|
|
348
356
|
// Create item
|
|
349
|
-
_getCreateServiceOptions(newItemTemplate, authentication, templateDictionary).then(
|
|
350
|
-
(0, arcgis_rest_service_admin_1.createFeatureService)(createOptions).then(
|
|
357
|
+
_getCreateServiceOptions(newItemTemplate, authentication, templateDictionary).then(createOptions => {
|
|
358
|
+
(0, arcgis_rest_service_admin_1.createFeatureService)(createOptions).then(createResponse => {
|
|
351
359
|
resolve(createResponse);
|
|
352
|
-
},
|
|
353
|
-
},
|
|
360
|
+
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
361
|
+
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
354
362
|
});
|
|
355
363
|
}
|
|
356
364
|
exports.createFeatureService = createFeatureService;
|
|
@@ -369,29 +377,30 @@ exports.createFeatureService = createFeatureService;
|
|
|
369
377
|
* @param access Access to set for item: "public", "org", "private"
|
|
370
378
|
* @return A promise that will resolve with an object reporting success or failure and the Solution id
|
|
371
379
|
*/
|
|
372
|
-
function createFullItem(itemInfo, folderId, destinationAuthentication, itemThumbnailUrl, itemThumbnailAuthentication, dataFile, metadataFile, resourcesFiles, access) {
|
|
373
|
-
|
|
374
|
-
return new Promise(function (resolve, reject) {
|
|
380
|
+
function createFullItem(itemInfo, folderId, destinationAuthentication, itemThumbnailUrl, itemThumbnailAuthentication, dataFile, metadataFile, resourcesFiles, access = "private") {
|
|
381
|
+
return new Promise((resolve, reject) => {
|
|
375
382
|
// Create item
|
|
376
|
-
|
|
377
|
-
item:
|
|
378
|
-
|
|
383
|
+
const createOptions = {
|
|
384
|
+
item: {
|
|
385
|
+
...itemInfo
|
|
386
|
+
},
|
|
387
|
+
folderId,
|
|
379
388
|
authentication: destinationAuthentication
|
|
380
389
|
};
|
|
381
390
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
382
|
-
addTokenToUrl(itemThumbnailUrl, itemThumbnailAuthentication).then(
|
|
391
|
+
addTokenToUrl(itemThumbnailUrl, itemThumbnailAuthentication).then(updatedThumbnailUrl => {
|
|
383
392
|
/* istanbul ignore else */
|
|
384
393
|
if (updatedThumbnailUrl) {
|
|
385
394
|
createOptions.item.thumbnailurl = (0, generalHelpers_1.appendQueryParam)(updatedThumbnailUrl, "w=400");
|
|
386
395
|
}
|
|
387
|
-
(0, arcgis_rest_portal_1.createItemInFolder)(createOptions).then(
|
|
396
|
+
(0, arcgis_rest_portal_1.createItemInFolder)(createOptions).then(createResponse => {
|
|
388
397
|
if (createResponse.success) {
|
|
389
|
-
|
|
398
|
+
let accessDef;
|
|
390
399
|
// Set access if it is not AGOL default
|
|
391
400
|
// Set the access manually since the access value in createItem appears to be ignored
|
|
392
401
|
// Need to run serially; will not work reliably if done in parallel with adding the data section
|
|
393
402
|
if (access !== "private") {
|
|
394
|
-
|
|
403
|
+
const accessOptions = {
|
|
395
404
|
id: createResponse.id,
|
|
396
405
|
access: access === "public" ? "public" : "org",
|
|
397
406
|
authentication: destinationAuthentication
|
|
@@ -404,8 +413,8 @@ function createFullItem(itemInfo, folderId, destinationAuthentication, itemThumb
|
|
|
404
413
|
});
|
|
405
414
|
}
|
|
406
415
|
// Now add attached items
|
|
407
|
-
accessDef.then(
|
|
408
|
-
|
|
416
|
+
accessDef.then(() => {
|
|
417
|
+
const updateDefs = [];
|
|
409
418
|
// Add the data section
|
|
410
419
|
if (dataFile) {
|
|
411
420
|
updateDefs.push(_addItemDataFile(createResponse.id, dataFile, destinationAuthentication));
|
|
@@ -414,9 +423,9 @@ function createFullItem(itemInfo, folderId, destinationAuthentication, itemThumb
|
|
|
414
423
|
// same time to the same item
|
|
415
424
|
if (Array.isArray(resourcesFiles) &&
|
|
416
425
|
resourcesFiles.length > 0) {
|
|
417
|
-
updateDefs.push(new Promise(
|
|
418
|
-
(0, libConnectors_1.createZip)("resources.zip", resourcesFiles).then(
|
|
419
|
-
|
|
426
|
+
updateDefs.push(new Promise((rsrcResolve, rsrcReject) => {
|
|
427
|
+
(0, libConnectors_1.createZip)("resources.zip", resourcesFiles).then((zipfile) => {
|
|
428
|
+
const addResourceOptions = {
|
|
420
429
|
id: createResponse.id,
|
|
421
430
|
resource: zipfile,
|
|
422
431
|
authentication: destinationAuthentication,
|
|
@@ -433,13 +442,13 @@ function createFullItem(itemInfo, folderId, destinationAuthentication, itemThumb
|
|
|
433
442
|
updateDefs.push(_addItemMetadataFile(createResponse.id, metadataFile, destinationAuthentication));
|
|
434
443
|
}
|
|
435
444
|
// Wait until all adds are done
|
|
436
|
-
Promise.all(updateDefs).then(
|
|
437
|
-
},
|
|
445
|
+
Promise.all(updateDefs).then(() => resolve(createResponse), e => reject((0, generalHelpers_1.fail)(e)));
|
|
446
|
+
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
438
447
|
}
|
|
439
448
|
else {
|
|
440
449
|
reject((0, generalHelpers_1.fail)());
|
|
441
450
|
}
|
|
442
|
-
},
|
|
451
|
+
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
443
452
|
});
|
|
444
453
|
});
|
|
445
454
|
}
|
|
@@ -455,13 +464,16 @@ exports.createFullItem = createFullItem;
|
|
|
455
464
|
* @param access Access to set for item: "public", "org", "private"
|
|
456
465
|
* @return A promise that will resolve with an object reporting success and the Solution id
|
|
457
466
|
*/
|
|
458
|
-
function createItemWithData(itemInfo, dataInfo, authentication, folderId, access) {
|
|
459
|
-
|
|
460
|
-
return new Promise(function (resolve, reject) {
|
|
467
|
+
function createItemWithData(itemInfo, dataInfo, authentication, folderId, access = "private") {
|
|
468
|
+
return new Promise((resolve, reject) => {
|
|
461
469
|
// Create item
|
|
462
|
-
|
|
463
|
-
item:
|
|
464
|
-
|
|
470
|
+
const createOptions = {
|
|
471
|
+
item: {
|
|
472
|
+
title: "_",
|
|
473
|
+
...itemInfo,
|
|
474
|
+
data: dataInfo
|
|
475
|
+
},
|
|
476
|
+
folderId,
|
|
465
477
|
authentication: authentication
|
|
466
478
|
};
|
|
467
479
|
if (itemInfo.thumbnail) {
|
|
@@ -471,23 +483,23 @@ function createItemWithData(itemInfo, dataInfo, authentication, folderId, access
|
|
|
471
483
|
};
|
|
472
484
|
delete createOptions.item.thumbnail;
|
|
473
485
|
}
|
|
474
|
-
(0, arcgis_rest_portal_1.createItemInFolder)(createOptions).then(
|
|
486
|
+
(0, arcgis_rest_portal_1.createItemInFolder)(createOptions).then(createResponse => {
|
|
475
487
|
if (createResponse.success) {
|
|
476
488
|
if (access !== "private") {
|
|
477
489
|
// Set access if it is not AGOL default
|
|
478
490
|
// Set the access manually since the access value in createItem appears to be ignored
|
|
479
|
-
|
|
491
|
+
const accessOptions = {
|
|
480
492
|
id: createResponse.id,
|
|
481
493
|
access: access === "public" ? "public" : "org",
|
|
482
494
|
authentication: authentication
|
|
483
495
|
};
|
|
484
|
-
(0, arcgis_rest_portal_1.setItemAccess)(accessOptions).then(
|
|
496
|
+
(0, arcgis_rest_portal_1.setItemAccess)(accessOptions).then(() => {
|
|
485
497
|
resolve({
|
|
486
498
|
folder: createResponse.folder,
|
|
487
499
|
id: createResponse.id,
|
|
488
500
|
success: true
|
|
489
501
|
});
|
|
490
|
-
},
|
|
502
|
+
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
491
503
|
}
|
|
492
504
|
else {
|
|
493
505
|
resolve({
|
|
@@ -500,7 +512,7 @@ function createItemWithData(itemInfo, dataInfo, authentication, folderId, access
|
|
|
500
512
|
else {
|
|
501
513
|
reject((0, generalHelpers_1.fail)());
|
|
502
514
|
}
|
|
503
|
-
},
|
|
515
|
+
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
504
516
|
});
|
|
505
517
|
}
|
|
506
518
|
exports.createItemWithData = createItemWithData;
|
|
@@ -515,18 +527,18 @@ exports.createItemWithData = createItemWithData;
|
|
|
515
527
|
* @return Id of created folder
|
|
516
528
|
*/
|
|
517
529
|
function createUniqueFolder(title, templateDictionary, authentication) {
|
|
518
|
-
return new Promise(
|
|
530
|
+
return new Promise((resolve, reject) => {
|
|
519
531
|
// Get a title that is not already in use
|
|
520
|
-
|
|
521
|
-
|
|
532
|
+
const folderTitle = (0, generalHelpers_1.getUniqueTitle)(title, templateDictionary, "user.folders");
|
|
533
|
+
const folderCreationParam = {
|
|
522
534
|
title: folderTitle,
|
|
523
535
|
authentication: authentication
|
|
524
536
|
};
|
|
525
|
-
(0, arcgis_rest_portal_1.createFolder)(folderCreationParam).then(
|
|
537
|
+
(0, arcgis_rest_portal_1.createFolder)(folderCreationParam).then(ok => resolve(ok), err => {
|
|
526
538
|
// If the name already exists, we'll try again
|
|
527
|
-
|
|
539
|
+
const errorDetails = (0, generalHelpers_1.getProp)(err, "response.error.details");
|
|
528
540
|
if (Array.isArray(errorDetails) && errorDetails.length > 0) {
|
|
529
|
-
|
|
541
|
+
const nameNotAvailMsg = "Folder title '" + folderTitle + "' not available.";
|
|
530
542
|
if (errorDetails.indexOf(nameNotAvailMsg) >= 0) {
|
|
531
543
|
// Create the user.folders property if it doesn't exist
|
|
532
544
|
/* istanbul ignore else */
|
|
@@ -556,38 +568,56 @@ exports.createUniqueFolder = createUniqueFolder;
|
|
|
556
568
|
* @param title Group title, used as-is if possible and with suffix otherwise
|
|
557
569
|
* @param templateDictionary Hash of facts: org URL, adlib replacements, user
|
|
558
570
|
* @param authentication Credentials for creating group
|
|
571
|
+
* @param owner Optional arg for the Tracking owner
|
|
572
|
+
* If the tracking owner is not the one deploying the solution
|
|
573
|
+
* tracker groups will be created under the deployment user but
|
|
574
|
+
* will be reassigned to the tracking owner.
|
|
559
575
|
* @return Information about created group
|
|
560
576
|
*/
|
|
561
|
-
function createUniqueGroup(title, groupItem, templateDictionary, authentication) {
|
|
562
|
-
return new Promise(
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
577
|
+
function createUniqueGroup(title, groupItem, templateDictionary, authentication, owner) {
|
|
578
|
+
return new Promise((resolve, reject) => {
|
|
579
|
+
let groupsPromise;
|
|
580
|
+
// when working with tracker we need to consider the groups of the deploying user as well as the groups
|
|
581
|
+
// of the tracking user...must be unique for both
|
|
582
|
+
if (owner && owner !== authentication.username) {
|
|
583
|
+
groupsPromise = searchAllGroups(`(owner:${owner}) orgid:${templateDictionary.organization.id}`, authentication);
|
|
584
|
+
}
|
|
585
|
+
else {
|
|
586
|
+
groupsPromise = Promise.resolve([]);
|
|
587
|
+
}
|
|
588
|
+
// first get the tracker owner groups
|
|
589
|
+
groupsPromise.then(groups => {
|
|
590
|
+
templateDictionary["allGroups"] =
|
|
591
|
+
groups.concat((0, generalHelpers_1.getProp)(templateDictionary, "user.groups"));
|
|
592
|
+
// Get a title that is not already in use
|
|
593
|
+
groupItem.title = (0, generalHelpers_1.getUniqueTitle)(title, templateDictionary, "allGroups");
|
|
594
|
+
const groupCreationParam = {
|
|
595
|
+
group: groupItem,
|
|
596
|
+
authentication: authentication
|
|
597
|
+
};
|
|
598
|
+
(0, arcgis_rest_portal_1.createGroup)(groupCreationParam).then(resolve, err => {
|
|
599
|
+
// If the name already exists, we'll try again
|
|
600
|
+
const errorDetails = (0, generalHelpers_1.getProp)(err, "response.error.details");
|
|
601
|
+
if (Array.isArray(errorDetails) && errorDetails.length > 0) {
|
|
602
|
+
const nameNotAvailMsg = "You already have a group named '" +
|
|
603
|
+
groupItem.title +
|
|
604
|
+
"'. Try a different name.";
|
|
605
|
+
if (errorDetails.indexOf(nameNotAvailMsg) >= 0) {
|
|
606
|
+
templateDictionary.user.groups.push({
|
|
607
|
+
title: groupItem.title
|
|
608
|
+
});
|
|
609
|
+
createUniqueGroup(title, groupItem, templateDictionary, authentication).then(resolve, reject);
|
|
610
|
+
}
|
|
611
|
+
else {
|
|
612
|
+
reject(err);
|
|
613
|
+
}
|
|
581
614
|
}
|
|
582
615
|
else {
|
|
616
|
+
// Otherwise, error out
|
|
583
617
|
reject(err);
|
|
584
618
|
}
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
// Otherwise, error out
|
|
588
|
-
reject(err);
|
|
589
|
-
}
|
|
590
|
-
});
|
|
619
|
+
});
|
|
620
|
+
}, e => reject(e));
|
|
591
621
|
});
|
|
592
622
|
}
|
|
593
623
|
exports.createUniqueGroup = createUniqueGroup;
|
|
@@ -600,16 +630,17 @@ exports.createUniqueGroup = createUniqueGroup;
|
|
|
600
630
|
* @return A promise that will resolve a list of dependencies
|
|
601
631
|
*/
|
|
602
632
|
function extractDependencies(itemTemplate, authentication) {
|
|
603
|
-
|
|
604
|
-
return new Promise(
|
|
633
|
+
const dependencies = [];
|
|
634
|
+
return new Promise((resolve, reject) => {
|
|
605
635
|
// Get service dependencies when the item is a view
|
|
606
|
-
|
|
636
|
+
// This step is skipped for tracker views as they will already have a source service in the org
|
|
637
|
+
if (itemTemplate.properties.service.isView && itemTemplate.item.url && !(0, trackingHelpers_1.isTrackingViewTemplate)(itemTemplate)) {
|
|
607
638
|
(0, arcgis_rest_request_1.request)((0, generalHelpers_1.checkUrlPathTermination)(itemTemplate.item.url) + "sources?f=json", {
|
|
608
639
|
authentication: authentication
|
|
609
|
-
}).then(
|
|
640
|
+
}).then(response => {
|
|
610
641
|
/* istanbul ignore else */
|
|
611
642
|
if (response && response.services) {
|
|
612
|
-
response.services.forEach(
|
|
643
|
+
response.services.forEach((layer) => {
|
|
613
644
|
dependencies.push({
|
|
614
645
|
id: layer.serviceItemId,
|
|
615
646
|
name: layer.name
|
|
@@ -617,7 +648,7 @@ function extractDependencies(itemTemplate, authentication) {
|
|
|
617
648
|
});
|
|
618
649
|
}
|
|
619
650
|
resolve(dependencies);
|
|
620
|
-
},
|
|
651
|
+
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
621
652
|
}
|
|
622
653
|
else if ((0, workforceHelpers_1.isWorkforceProject)(itemTemplate)) {
|
|
623
654
|
resolve((0, workforceHelpers_1.getWorkforceDependencies)(itemTemplate, dependencies));
|
|
@@ -637,21 +668,21 @@ exports.extractDependencies = extractDependencies;
|
|
|
637
668
|
* @return A promise that will resolve a list of dependencies
|
|
638
669
|
*/
|
|
639
670
|
function getLayers(serviceUrl, layerList, authentication) {
|
|
640
|
-
return new Promise(
|
|
671
|
+
return new Promise((resolve, reject) => {
|
|
641
672
|
if (layerList.length === 0) {
|
|
642
673
|
resolve([]);
|
|
643
674
|
}
|
|
644
675
|
// get the admin URL
|
|
645
676
|
serviceUrl = serviceUrl.replace("/rest/services", "/rest/admin/services");
|
|
646
|
-
|
|
647
|
-
layerList.forEach(
|
|
648
|
-
|
|
677
|
+
const requestsDfd = [];
|
|
678
|
+
layerList.forEach(layer => {
|
|
679
|
+
const requestOptions = {
|
|
649
680
|
authentication: authentication
|
|
650
681
|
};
|
|
651
682
|
requestsDfd.push((0, arcgis_rest_request_1.request)((0, generalHelpers_1.checkUrlPathTermination)(serviceUrl) + layer["id"] + "?f=json", requestOptions));
|
|
652
683
|
});
|
|
653
684
|
// Wait until all layers are heard from
|
|
654
|
-
Promise.all(requestsDfd).then(
|
|
685
|
+
Promise.all(requestsDfd).then(layers => resolve(layers), e => reject((0, generalHelpers_1.fail)(e)));
|
|
655
686
|
});
|
|
656
687
|
}
|
|
657
688
|
exports.getLayers = getLayers;
|
|
@@ -659,16 +690,18 @@ exports.getLayers = getLayers;
|
|
|
659
690
|
* Add additional options to a layers definition.
|
|
660
691
|
*
|
|
661
692
|
* @param args The IPostProcessArgs for the request(s)
|
|
693
|
+
* @param isPortal boolean to indicate if we are deploying to portal
|
|
694
|
+
*
|
|
662
695
|
* @return An array of update instructions
|
|
663
696
|
* @private
|
|
664
697
|
*/
|
|
665
698
|
function getLayerUpdates(args, isPortal) {
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
699
|
+
const adminUrl = args.itemTemplate.item.url.replace("rest/services", "rest/admin/services");
|
|
700
|
+
const updates = [];
|
|
701
|
+
const refresh = _getUpdate(adminUrl, null, null, args, "refresh");
|
|
669
702
|
updates.push(refresh);
|
|
670
|
-
Object.keys(args.objects).forEach(
|
|
671
|
-
|
|
703
|
+
Object.keys(args.objects).forEach(id => {
|
|
704
|
+
const obj = Object.assign({}, args.objects[id]);
|
|
672
705
|
// These properties cannot be set in the update definition when working with portal
|
|
673
706
|
if (isPortal) {
|
|
674
707
|
(0, generalHelpers_1.deleteProps)(obj, ["type", "id", "relationships", "sourceServiceFields"]);
|
|
@@ -687,13 +720,20 @@ function getLayerUpdates(args, isPortal) {
|
|
|
687
720
|
updates.push(refresh);
|
|
688
721
|
}
|
|
689
722
|
});
|
|
723
|
+
// issue: #706
|
|
724
|
+
// Add source service relationships
|
|
725
|
+
// views will now always add all layers in a single call and will inherit the relationships from the source service
|
|
690
726
|
if (!args.itemTemplate.properties.service.isView) {
|
|
691
|
-
|
|
727
|
+
const relUpdates = _getRelationshipUpdates({
|
|
692
728
|
message: "updated layer relationships",
|
|
693
729
|
objects: args.objects,
|
|
694
730
|
itemTemplate: args.itemTemplate,
|
|
695
731
|
authentication: args.authentication
|
|
696
732
|
});
|
|
733
|
+
// issue: #724
|
|
734
|
+
// In portal the order the relationships are added needs to follow the layer order
|
|
735
|
+
// otherwise the relationship IDs will be reset
|
|
736
|
+
relUpdates.layers = _sortRelationships(args.itemTemplate.properties.layers, args.itemTemplate.properties.tables, relUpdates);
|
|
697
737
|
/* istanbul ignore else */
|
|
698
738
|
if (relUpdates.layers.length > 0) {
|
|
699
739
|
updates.push(_getUpdate(adminUrl, null, relUpdates, args, "add"));
|
|
@@ -703,6 +743,34 @@ function getLayerUpdates(args, isPortal) {
|
|
|
703
743
|
return updates;
|
|
704
744
|
}
|
|
705
745
|
exports.getLayerUpdates = getLayerUpdates;
|
|
746
|
+
/**
|
|
747
|
+
* Sorts relationships based on order of supporting layers and tables in the service definition
|
|
748
|
+
*
|
|
749
|
+
* @param layers the layers from the service
|
|
750
|
+
* @param tables the tables from the service
|
|
751
|
+
* @param relUpdates the relationships to add for the service
|
|
752
|
+
*
|
|
753
|
+
* @return An array with relationships that have been sorted
|
|
754
|
+
*/
|
|
755
|
+
function _sortRelationships(layers, tables, relUpdates) {
|
|
756
|
+
const ids = [].concat(layers.map((l) => l.id), tables.map((t) => t.id));
|
|
757
|
+
// In portal the order the relationships are added needs to follow the layer order
|
|
758
|
+
// otherwise the relationship IDs will be reset
|
|
759
|
+
const _relUpdateLayers = [];
|
|
760
|
+
ids.forEach(id => {
|
|
761
|
+
relUpdates.layers.some((relUpdate) => {
|
|
762
|
+
if (id === relUpdate.id) {
|
|
763
|
+
_relUpdateLayers.push(relUpdate);
|
|
764
|
+
return true;
|
|
765
|
+
}
|
|
766
|
+
else {
|
|
767
|
+
return false;
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
});
|
|
771
|
+
return _relUpdateLayers;
|
|
772
|
+
}
|
|
773
|
+
exports._sortRelationships = _sortRelationships;
|
|
706
774
|
/**
|
|
707
775
|
* Update view service when sourceSchemaChangesAllowed is true.
|
|
708
776
|
*
|
|
@@ -715,16 +783,16 @@ exports.getLayerUpdates = getLayerUpdates;
|
|
|
715
783
|
* @return An array of update instructions
|
|
716
784
|
*/
|
|
717
785
|
function getFinalServiceUpdates(itemTemplate, authentication, updates) {
|
|
718
|
-
|
|
719
|
-
|
|
786
|
+
const sourceSchemaChangesAllowed = (0, generalHelpers_1.getProp)(itemTemplate, "properties.service.sourceSchemaChangesAllowed");
|
|
787
|
+
const isView = (0, generalHelpers_1.getProp)(itemTemplate, "properties.service.isView");
|
|
720
788
|
/* istanbul ignore else */
|
|
721
789
|
if (sourceSchemaChangesAllowed && isView) {
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
authentication
|
|
790
|
+
const adminUrl = itemTemplate.item.url.replace("rest/services", "rest/admin/services");
|
|
791
|
+
const args = {
|
|
792
|
+
authentication,
|
|
725
793
|
message: "final service update"
|
|
726
794
|
};
|
|
727
|
-
|
|
795
|
+
const serviceUpdates = { sourceSchemaChangesAllowed };
|
|
728
796
|
updates.push(_getUpdate(adminUrl, null, serviceUpdates, args, "update"));
|
|
729
797
|
}
|
|
730
798
|
return updates;
|
|
@@ -742,11 +810,9 @@ exports.getFinalServiceUpdates = getFinalServiceUpdates;
|
|
|
742
810
|
* @private
|
|
743
811
|
*/
|
|
744
812
|
/* istanbul ignore else */
|
|
745
|
-
function getRequest(update, skipRetry, useAsync) {
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
return new Promise(function (resolve, reject) {
|
|
749
|
-
var options = {
|
|
813
|
+
function getRequest(update, skipRetry = false, useAsync = false) {
|
|
814
|
+
return new Promise((resolve, reject) => {
|
|
815
|
+
const options = {
|
|
750
816
|
params: update.params,
|
|
751
817
|
authentication: update.args.authentication
|
|
752
818
|
};
|
|
@@ -754,13 +820,13 @@ function getRequest(update, skipRetry, useAsync) {
|
|
|
754
820
|
if ((useAsync && update.url.indexOf("addToDefinition") > -1) ||
|
|
755
821
|
update.url.indexOf("updateDefinition") > -1 ||
|
|
756
822
|
update.url.indexOf("deleteFromDefinition") > -1) {
|
|
757
|
-
options.params =
|
|
823
|
+
options.params = { ...options.params, async: true };
|
|
758
824
|
}
|
|
759
|
-
(0, arcgis_rest_request_1.request)(update.url, options).then(
|
|
760
|
-
checkRequestStatus(result, options.authentication).then(
|
|
761
|
-
},
|
|
825
|
+
(0, arcgis_rest_request_1.request)(update.url, options).then(result => {
|
|
826
|
+
checkRequestStatus(result, options.authentication).then(() => resolve(null), e => reject((0, generalHelpers_1.fail)(e)));
|
|
827
|
+
}, (e) => {
|
|
762
828
|
if (!skipRetry) {
|
|
763
|
-
getRequest(update, true, true).then(
|
|
829
|
+
getRequest(update, true, true).then(() => resolve(), e => reject(e));
|
|
764
830
|
}
|
|
765
831
|
else {
|
|
766
832
|
reject(e);
|
|
@@ -778,18 +844,18 @@ exports.getRequest = getRequest;
|
|
|
778
844
|
* @private
|
|
779
845
|
*/
|
|
780
846
|
function getServiceLayersAndTables(itemTemplate, authentication) {
|
|
781
|
-
return new Promise(
|
|
847
|
+
return new Promise((resolve, reject) => {
|
|
782
848
|
// To have enough information for reconstructing the service, we'll supplement
|
|
783
849
|
// the item and data sections with sections for the service, full layers, and
|
|
784
850
|
// full tables
|
|
785
851
|
// Extra steps must be taken for workforce version 2
|
|
786
|
-
|
|
852
|
+
const isWorkforceService = (0, workforceHelpers_1.isWorkforceProject)(itemTemplate);
|
|
787
853
|
// Get the service description
|
|
788
854
|
if (itemTemplate.item.url) {
|
|
789
|
-
getFeatureServiceProperties(itemTemplate.item.url, authentication, isWorkforceService).then(
|
|
855
|
+
getFeatureServiceProperties(itemTemplate.item.url, authentication, isWorkforceService).then(properties => {
|
|
790
856
|
itemTemplate.properties = properties;
|
|
791
857
|
resolve(itemTemplate);
|
|
792
|
-
},
|
|
858
|
+
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
793
859
|
}
|
|
794
860
|
else {
|
|
795
861
|
resolve(itemTemplate);
|
|
@@ -806,10 +872,9 @@ exports.getServiceLayersAndTables = getServiceLayersAndTables;
|
|
|
806
872
|
* @return A promise that will resolve with the service properties
|
|
807
873
|
* @private
|
|
808
874
|
*/
|
|
809
|
-
function getFeatureServiceProperties(serviceUrl, authentication, workforceService) {
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
var properties = {
|
|
875
|
+
function getFeatureServiceProperties(serviceUrl, authentication, workforceService = false) {
|
|
876
|
+
return new Promise((resolve, reject) => {
|
|
877
|
+
const properties = {
|
|
813
878
|
service: {},
|
|
814
879
|
layers: [],
|
|
815
880
|
tables: []
|
|
@@ -819,13 +884,12 @@ function getFeatureServiceProperties(serviceUrl, authentication, workforceServic
|
|
|
819
884
|
// Get the service description
|
|
820
885
|
(0, arcgis_rest_request_1.request)(serviceUrl + "?f=json", {
|
|
821
886
|
authentication: authentication
|
|
822
|
-
}).then(
|
|
823
|
-
var _a;
|
|
887
|
+
}).then(serviceData => {
|
|
824
888
|
properties.service = _parseAdminServiceData(serviceData);
|
|
825
889
|
// Copy cacheMaxAge to top level so that AGO sees it when deploying the service
|
|
826
890
|
// serviceData may have set it if there isn't an adminServiceInfo
|
|
827
891
|
/* istanbul ignore else */
|
|
828
|
-
if (
|
|
892
|
+
if (serviceData.adminServiceInfo?.cacheMaxAge) {
|
|
829
893
|
properties.service.cacheMaxAge =
|
|
830
894
|
serviceData.adminServiceInfo.cacheMaxAge;
|
|
831
895
|
}
|
|
@@ -835,7 +899,7 @@ function getFeatureServiceProperties(serviceUrl, authentication, workforceServic
|
|
|
835
899
|
properties.layers = serviceData.layers;
|
|
836
900
|
// Fill in properties that the service layer doesn't provide
|
|
837
901
|
// and remove properties that should not exist in the template
|
|
838
|
-
properties.layers.forEach(
|
|
902
|
+
properties.layers.forEach(layer => {
|
|
839
903
|
layer.serviceItemId = properties.service.serviceItemId;
|
|
840
904
|
layer.extent = null;
|
|
841
905
|
(0, featureServiceHelpers_1.removeLayerOptimization)(layer);
|
|
@@ -846,7 +910,7 @@ function getFeatureServiceProperties(serviceUrl, authentication, workforceServic
|
|
|
846
910
|
if (serviceData.tables) {
|
|
847
911
|
properties.tables = serviceData.tables;
|
|
848
912
|
// Fill in properties that the service layer doesn't provide
|
|
849
|
-
properties.tables.forEach(
|
|
913
|
+
properties.tables.forEach(table => {
|
|
850
914
|
table.serviceItemId = properties.service.serviceItemId;
|
|
851
915
|
table.extent = null;
|
|
852
916
|
});
|
|
@@ -860,7 +924,7 @@ function getFeatureServiceProperties(serviceUrl, authentication, workforceServic
|
|
|
860
924
|
else {
|
|
861
925
|
resolve(properties);
|
|
862
926
|
}
|
|
863
|
-
},
|
|
927
|
+
}, (e) => reject((0, generalHelpers_1.fail)(e)));
|
|
864
928
|
});
|
|
865
929
|
}
|
|
866
930
|
exports.getFeatureServiceProperties = getFeatureServiceProperties;
|
|
@@ -872,12 +936,12 @@ exports.getFeatureServiceProperties = getFeatureServiceProperties;
|
|
|
872
936
|
* @return A mutated version of the provided adminData
|
|
873
937
|
*/
|
|
874
938
|
function _parseAdminServiceData(adminData) {
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
(0, generalHelpers_1.setCreateProp)(adminData, "layers", layers.filter(
|
|
939
|
+
const layers = adminData.layers || [];
|
|
940
|
+
const tables = adminData.tables || [];
|
|
941
|
+
(0, generalHelpers_1.setCreateProp)(adminData, "layers", layers.filter(l => l.type === "Feature Layer"));
|
|
878
942
|
// TODO understand if the concat is necessary.
|
|
879
943
|
// Not sure if the admin api will ever actually return a tables collection here.
|
|
880
|
-
(0, generalHelpers_1.setCreateProp)(adminData, "tables", tables.concat(layers.filter(
|
|
944
|
+
(0, generalHelpers_1.setCreateProp)(adminData, "tables", tables.concat(layers.filter(l => l.type === "Table")));
|
|
881
945
|
return adminData;
|
|
882
946
|
}
|
|
883
947
|
exports._parseAdminServiceData = _parseAdminServiceData;
|
|
@@ -889,7 +953,7 @@ exports._parseAdminServiceData = _parseAdminServiceData;
|
|
|
889
953
|
* @return A boolean indicating if the invalid designation is found in the item info
|
|
890
954
|
*/
|
|
891
955
|
function hasInvalidGroupDesignations(groupDesignations) {
|
|
892
|
-
|
|
956
|
+
const invalidGroupDesignations = ["livingatlas"];
|
|
893
957
|
return groupDesignations
|
|
894
958
|
? invalidGroupDesignations.indexOf(groupDesignations) > -1
|
|
895
959
|
: false;
|
|
@@ -903,12 +967,12 @@ exports.hasInvalidGroupDesignations = hasInvalidGroupDesignations;
|
|
|
903
967
|
* @return A promise that will resolve with the result of the request
|
|
904
968
|
*/
|
|
905
969
|
function removeFolder(folderId, authentication) {
|
|
906
|
-
return new Promise(
|
|
907
|
-
|
|
970
|
+
return new Promise((resolve, reject) => {
|
|
971
|
+
const requestOptions = {
|
|
908
972
|
folderId: folderId,
|
|
909
973
|
authentication: authentication
|
|
910
974
|
};
|
|
911
|
-
(0, arcgis_rest_portal_1.removeFolder)(requestOptions).then(
|
|
975
|
+
(0, arcgis_rest_portal_1.removeFolder)(requestOptions).then(result => (result.success ? resolve(result) : reject(result)), reject);
|
|
912
976
|
});
|
|
913
977
|
}
|
|
914
978
|
exports.removeFolder = removeFolder;
|
|
@@ -920,12 +984,12 @@ exports.removeFolder = removeFolder;
|
|
|
920
984
|
* @return A promise that will resolve with the result of the request
|
|
921
985
|
*/
|
|
922
986
|
function removeGroup(groupId, authentication) {
|
|
923
|
-
return new Promise(
|
|
924
|
-
|
|
987
|
+
return new Promise((resolve, reject) => {
|
|
988
|
+
const requestOptions = {
|
|
925
989
|
id: groupId,
|
|
926
990
|
authentication: authentication
|
|
927
991
|
};
|
|
928
|
-
(0, arcgis_rest_portal_1.removeGroup)(requestOptions).then(
|
|
992
|
+
(0, arcgis_rest_portal_1.removeGroup)(requestOptions).then(result => (result.success ? resolve(result) : reject(result)), reject);
|
|
929
993
|
});
|
|
930
994
|
}
|
|
931
995
|
exports.removeGroup = removeGroup;
|
|
@@ -937,12 +1001,12 @@ exports.removeGroup = removeGroup;
|
|
|
937
1001
|
* @return A promise that will resolve with the result of the request
|
|
938
1002
|
*/
|
|
939
1003
|
function removeItem(itemId, authentication) {
|
|
940
|
-
return new Promise(
|
|
941
|
-
|
|
1004
|
+
return new Promise((resolve, reject) => {
|
|
1005
|
+
const requestOptions = {
|
|
942
1006
|
id: itemId,
|
|
943
1007
|
authentication: authentication
|
|
944
1008
|
};
|
|
945
|
-
(0, arcgis_rest_portal_1.removeItem)(requestOptions).then(
|
|
1009
|
+
(0, arcgis_rest_portal_1.removeItem)(requestOptions).then(result => (result.success ? resolve(result) : reject(result)), reject);
|
|
946
1010
|
});
|
|
947
1011
|
}
|
|
948
1012
|
exports.removeItem = removeItem;
|
|
@@ -954,9 +1018,9 @@ exports.removeItem = removeItem;
|
|
|
954
1018
|
* @return A promise that will resolve with the result of the request
|
|
955
1019
|
*/
|
|
956
1020
|
function removeItemOrGroup(itemId, authentication) {
|
|
957
|
-
return new Promise(
|
|
958
|
-
removeItem(itemId, authentication).then(resolve,
|
|
959
|
-
removeGroup(itemId, authentication).then(resolve,
|
|
1021
|
+
return new Promise((resolve, reject) => {
|
|
1022
|
+
removeItem(itemId, authentication).then(resolve, error => {
|
|
1023
|
+
removeGroup(itemId, authentication).then(resolve, () => reject(error));
|
|
960
1024
|
});
|
|
961
1025
|
});
|
|
962
1026
|
}
|
|
@@ -973,14 +1037,51 @@ exports.removeItemOrGroup = removeItemOrGroup;
|
|
|
973
1037
|
* @see https://developers.arcgis.com/rest/users-groups-and-items/search-reference.htm
|
|
974
1038
|
*/
|
|
975
1039
|
function searchGroups(searchString, authentication, additionalSearchOptions) {
|
|
976
|
-
|
|
1040
|
+
const searchOptions = {
|
|
977
1041
|
q: searchString,
|
|
978
|
-
params:
|
|
1042
|
+
params: {
|
|
1043
|
+
...additionalSearchOptions
|
|
1044
|
+
},
|
|
979
1045
|
authentication: authentication
|
|
980
1046
|
};
|
|
981
1047
|
return (0, arcgis_rest_portal_1.searchGroups)(searchOptions);
|
|
982
1048
|
}
|
|
983
1049
|
exports.searchGroups = searchGroups;
|
|
1050
|
+
/**
|
|
1051
|
+
* Searches for groups matching criteria recurusively.
|
|
1052
|
+
*
|
|
1053
|
+
* @param searchString Text for which to search, e.g., 'redlands+map', 'type:"Web Map" -type:"Web Mapping Application"'
|
|
1054
|
+
* @param authentication Credentials for the request to AGO
|
|
1055
|
+
* @param groups List of groups that have been found from previous requests
|
|
1056
|
+
* @param inPagingParams The paging params for the recurisve searching
|
|
1057
|
+
*
|
|
1058
|
+
* @return A promise that will resolve with all groups that meet the search criteria
|
|
1059
|
+
*/
|
|
1060
|
+
function searchAllGroups(searchString, authentication, groups, inPagingParams) {
|
|
1061
|
+
const pagingParams = inPagingParams ? inPagingParams : {
|
|
1062
|
+
start: 0,
|
|
1063
|
+
num: 24
|
|
1064
|
+
};
|
|
1065
|
+
const additionalSearchOptions = {
|
|
1066
|
+
sortField: "title",
|
|
1067
|
+
sortOrder: "asc",
|
|
1068
|
+
...pagingParams
|
|
1069
|
+
};
|
|
1070
|
+
let finalResults = groups ? groups : [];
|
|
1071
|
+
return new Promise((resolve, reject) => {
|
|
1072
|
+
searchGroups(searchString, authentication, additionalSearchOptions).then(response => {
|
|
1073
|
+
finalResults = finalResults.concat(response.results);
|
|
1074
|
+
if (response.nextStart > 0) {
|
|
1075
|
+
pagingParams.start = response.nextStart;
|
|
1076
|
+
resolve(searchAllGroups(searchString, authentication, finalResults, pagingParams));
|
|
1077
|
+
}
|
|
1078
|
+
else {
|
|
1079
|
+
resolve(finalResults);
|
|
1080
|
+
}
|
|
1081
|
+
}, e => reject(e));
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
exports.searchAllGroups = searchAllGroups;
|
|
984
1085
|
/**
|
|
985
1086
|
* Searches for group contents matching criteria.
|
|
986
1087
|
*
|
|
@@ -996,8 +1097,8 @@ exports.searchGroups = searchGroups;
|
|
|
996
1097
|
* @see https://developers.arcgis.com/rest/users-groups-and-items/search-reference.htm
|
|
997
1098
|
*/
|
|
998
1099
|
function searchGroupContents(groupId, searchString, authentication, additionalSearchOptions, portalUrl) {
|
|
999
|
-
|
|
1000
|
-
groupId
|
|
1100
|
+
const searchOptions = {
|
|
1101
|
+
groupId,
|
|
1001
1102
|
q: searchString,
|
|
1002
1103
|
params: Object.assign({
|
|
1003
1104
|
num: 100
|
|
@@ -1008,28 +1109,72 @@ function searchGroupContents(groupId, searchString, authentication, additionalSe
|
|
|
1008
1109
|
// If search options include `categories`, switch to new arcgis-rest-js format
|
|
1009
1110
|
/* istanbul ignore else */
|
|
1010
1111
|
if (Array.isArray(searchOptions.params.categories)) {
|
|
1011
|
-
searchOptions.params.categories = searchOptions.params.categories.map(
|
|
1112
|
+
searchOptions.params.categories = searchOptions.params.categories.map(andGroup => andGroup.split(","));
|
|
1012
1113
|
}
|
|
1013
1114
|
return (0, arcgis_rest_portal_1.searchGroupContent)(searchOptions);
|
|
1014
1115
|
}
|
|
1015
1116
|
exports.searchGroupContents = searchGroupContents;
|
|
1117
|
+
/**
|
|
1118
|
+
* Reassign ownership of a group
|
|
1119
|
+
*
|
|
1120
|
+
* @param groupId Group to remove users from
|
|
1121
|
+
* @param userName The new owner for the group
|
|
1122
|
+
* @param authentication Credentials for the request to
|
|
1123
|
+
*
|
|
1124
|
+
* @return A promise that will resolve after the group ownership has been assigned
|
|
1125
|
+
*
|
|
1126
|
+
*/
|
|
1127
|
+
function reassignGroup(groupId, userName, authentication) {
|
|
1128
|
+
const requestOptions = {
|
|
1129
|
+
authentication: authentication,
|
|
1130
|
+
params: {
|
|
1131
|
+
targetUsername: userName
|
|
1132
|
+
}
|
|
1133
|
+
};
|
|
1134
|
+
return (0, arcgis_rest_request_1.request)(`${authentication.portal}/community/groups/${groupId}/reassign`, requestOptions);
|
|
1135
|
+
}
|
|
1136
|
+
exports.reassignGroup = reassignGroup;
|
|
1137
|
+
/**
|
|
1138
|
+
* Remove users from a group
|
|
1139
|
+
*
|
|
1140
|
+
* @param groupId Group to remove users from
|
|
1141
|
+
* @param users List of users to remove from the group
|
|
1142
|
+
* @param authentication Credentials for the request to
|
|
1143
|
+
*
|
|
1144
|
+
* @return A promise that will resolve after the users have been removed
|
|
1145
|
+
*
|
|
1146
|
+
*/
|
|
1147
|
+
function removeUsers(groupId, users, authentication) {
|
|
1148
|
+
return (0, arcgis_rest_portal_1.removeGroupUsers)({
|
|
1149
|
+
id: groupId,
|
|
1150
|
+
users,
|
|
1151
|
+
authentication
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1154
|
+
exports.removeUsers = removeUsers;
|
|
1016
1155
|
/**
|
|
1017
1156
|
* Shares an item to the defined group
|
|
1018
1157
|
*
|
|
1019
1158
|
* @param groupId Group to share with
|
|
1020
1159
|
* @param id the item id to share with the group
|
|
1021
1160
|
* @param destinationAuthentication Credentials for the request to AGO
|
|
1161
|
+
* @param owner owner of the group when sharing tracking items (can be different from the deploying user)
|
|
1162
|
+
*
|
|
1022
1163
|
* @return A promise that will resolve after the item has been shared
|
|
1023
1164
|
*
|
|
1024
1165
|
*/
|
|
1025
|
-
function shareItem(groupId, id, destinationAuthentication) {
|
|
1026
|
-
return new Promise(
|
|
1027
|
-
|
|
1028
|
-
groupId
|
|
1029
|
-
id
|
|
1166
|
+
function shareItem(groupId, id, destinationAuthentication, owner) {
|
|
1167
|
+
return new Promise((resolve, reject) => {
|
|
1168
|
+
const shareOptions = {
|
|
1169
|
+
groupId,
|
|
1170
|
+
id,
|
|
1030
1171
|
authentication: destinationAuthentication
|
|
1031
1172
|
};
|
|
1032
|
-
|
|
1173
|
+
/* istanbul ignore else */
|
|
1174
|
+
if (owner) {
|
|
1175
|
+
shareOptions.owner = owner;
|
|
1176
|
+
}
|
|
1177
|
+
(0, arcgis_rest_portal_1.shareItemWithGroup)(shareOptions).then(() => resolve(null), (e) => reject((0, generalHelpers_1.fail)(e)));
|
|
1033
1178
|
});
|
|
1034
1179
|
}
|
|
1035
1180
|
exports.shareItem = shareItem;
|
|
@@ -1044,14 +1189,16 @@ exports.shareItem = shareItem;
|
|
|
1044
1189
|
* @return
|
|
1045
1190
|
*/
|
|
1046
1191
|
function updateItem(itemInfo, authentication, folderId, additionalParams) {
|
|
1047
|
-
return new Promise(
|
|
1048
|
-
|
|
1192
|
+
return new Promise((resolve, reject) => {
|
|
1193
|
+
const updateOptions = {
|
|
1049
1194
|
item: itemInfo,
|
|
1050
1195
|
folderId: folderId,
|
|
1051
1196
|
authentication: authentication,
|
|
1052
|
-
params:
|
|
1197
|
+
params: {
|
|
1198
|
+
...(additionalParams ?? {})
|
|
1199
|
+
}
|
|
1053
1200
|
};
|
|
1054
|
-
(0, arcgis_rest_portal_1.updateItem)(updateOptions).then(
|
|
1201
|
+
(0, arcgis_rest_portal_1.updateItem)(updateOptions).then(response => (response.success ? resolve(response) : reject(response)), err => reject(err));
|
|
1055
1202
|
});
|
|
1056
1203
|
}
|
|
1057
1204
|
exports.updateItem = updateItem;
|
|
@@ -1065,9 +1212,9 @@ exports.updateItem = updateItem;
|
|
|
1065
1212
|
* @param access "public" or "org"
|
|
1066
1213
|
* @return
|
|
1067
1214
|
*/
|
|
1068
|
-
function updateItemExtended(itemInfo, data, authentication, thumbnail, access) {
|
|
1069
|
-
return new Promise(
|
|
1070
|
-
|
|
1215
|
+
function updateItemExtended(itemInfo, data, authentication, thumbnail, access, templateDictionary) {
|
|
1216
|
+
return new Promise((resolve, reject) => {
|
|
1217
|
+
const updateOptions = {
|
|
1071
1218
|
item: itemInfo,
|
|
1072
1219
|
params: {
|
|
1073
1220
|
text: data || {} // AGO ignores update if `data` is empty
|
|
@@ -1077,21 +1224,24 @@ function updateItemExtended(itemInfo, data, authentication, thumbnail, access) {
|
|
|
1077
1224
|
if (thumbnail) {
|
|
1078
1225
|
updateOptions.params.thumbnail = thumbnail;
|
|
1079
1226
|
}
|
|
1080
|
-
(0,
|
|
1227
|
+
if ((0, trackingHelpers_1.isTrackingViewTemplate)(undefined, itemInfo) && templateDictionary) {
|
|
1228
|
+
updateOptions.owner = templateDictionary.locationTracking.owner;
|
|
1229
|
+
}
|
|
1230
|
+
(0, arcgis_rest_portal_1.updateItem)(updateOptions).then(result => {
|
|
1081
1231
|
if (access && access !== "private") {
|
|
1082
1232
|
// Set access if it is not AGOL default
|
|
1083
1233
|
// Set the access manually since the access value in createItem appears to be ignored
|
|
1084
|
-
|
|
1234
|
+
const accessOptions = {
|
|
1085
1235
|
id: itemInfo.id,
|
|
1086
1236
|
access: access === "public" ? "public" : "org",
|
|
1087
1237
|
authentication: authentication
|
|
1088
1238
|
};
|
|
1089
|
-
(0, arcgis_rest_portal_1.setItemAccess)(accessOptions).then(
|
|
1239
|
+
(0, arcgis_rest_portal_1.setItemAccess)(accessOptions).then(() => resolve(result), e => reject((0, generalHelpers_1.fail)(e)));
|
|
1090
1240
|
}
|
|
1091
1241
|
else {
|
|
1092
1242
|
resolve(result);
|
|
1093
1243
|
}
|
|
1094
|
-
},
|
|
1244
|
+
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
1095
1245
|
});
|
|
1096
1246
|
}
|
|
1097
1247
|
exports.updateItemExtended = updateItemExtended;
|
|
@@ -1104,18 +1254,17 @@ exports.updateItemExtended = updateItemExtended;
|
|
|
1104
1254
|
* @returns Promise resolving to successfulness of update
|
|
1105
1255
|
*/
|
|
1106
1256
|
function updateItemTemplateFromDictionary(itemId, templateDictionary, authentication) {
|
|
1107
|
-
return new Promise(
|
|
1257
|
+
return new Promise((resolve, reject) => {
|
|
1108
1258
|
// Fetch the items as stored in AGO
|
|
1109
1259
|
Promise.all([
|
|
1110
1260
|
(0, restHelpersGet_1.getItemBase)(itemId, authentication),
|
|
1111
1261
|
(0, restHelpersGet_1.getItemDataAsJson)(itemId, authentication)
|
|
1112
1262
|
])
|
|
1113
|
-
.then(
|
|
1114
|
-
var _b = (0, tslib_1.__read)(_a, 2), item = _b[0], data = _b[1];
|
|
1263
|
+
.then(([item, data]) => {
|
|
1115
1264
|
// Do they have any variables?
|
|
1116
1265
|
if ((0, templatization_1.hasUnresolvedVariables)(item) || (0, templatization_1.hasUnresolvedVariables)(data)) {
|
|
1117
1266
|
// Update if so
|
|
1118
|
-
|
|
1267
|
+
const { item: updatedItem, data: updatedData } = (0, templatization_1.replaceInTemplate)({ item, data }, templateDictionary);
|
|
1119
1268
|
_reportVariablesInItem(itemId, item.type, updatedItem, updatedData);
|
|
1120
1269
|
return updateItemExtended(updatedItem, updatedData, authentication);
|
|
1121
1270
|
}
|
|
@@ -1127,8 +1276,8 @@ function updateItemTemplateFromDictionary(itemId, templateDictionary, authentica
|
|
|
1127
1276
|
});
|
|
1128
1277
|
}
|
|
1129
1278
|
})
|
|
1130
|
-
.then(
|
|
1131
|
-
.catch(
|
|
1279
|
+
.then(result => resolve(result))
|
|
1280
|
+
.catch(error => reject(error));
|
|
1132
1281
|
});
|
|
1133
1282
|
}
|
|
1134
1283
|
exports.updateItemTemplateFromDictionary = updateItemTemplateFromDictionary;
|
|
@@ -1142,7 +1291,7 @@ exports.updateItemTemplateFromDictionary = updateItemTemplateFromDictionary;
|
|
|
1142
1291
|
* response
|
|
1143
1292
|
*/
|
|
1144
1293
|
function updateItemURL(id, url, authentication) {
|
|
1145
|
-
|
|
1294
|
+
const numAttempts = 3;
|
|
1146
1295
|
return _updateItemURL(id, url, authentication, numAttempts);
|
|
1147
1296
|
}
|
|
1148
1297
|
exports.updateItemURL = updateItemURL;
|
|
@@ -1157,9 +1306,9 @@ exports.updateItemURL = updateItemURL;
|
|
|
1157
1306
|
* @private
|
|
1158
1307
|
*/
|
|
1159
1308
|
function _addItemDataFile(itemId, dataFile, authentication) {
|
|
1160
|
-
return new Promise(
|
|
1161
|
-
|
|
1162
|
-
|
|
1309
|
+
return new Promise((resolve, reject) => {
|
|
1310
|
+
const addItemData = (data) => {
|
|
1311
|
+
const addDataOptions = {
|
|
1163
1312
|
id: itemId,
|
|
1164
1313
|
data: data,
|
|
1165
1314
|
authentication: authentication
|
|
@@ -1189,8 +1338,8 @@ exports._addItemDataFile = _addItemDataFile;
|
|
|
1189
1338
|
* @private
|
|
1190
1339
|
*/
|
|
1191
1340
|
function _addItemMetadataFile(itemId, metadataFile, authentication) {
|
|
1192
|
-
return new Promise(
|
|
1193
|
-
|
|
1341
|
+
return new Promise((resolve, reject) => {
|
|
1342
|
+
const addMetadataOptions = {
|
|
1194
1343
|
item: {
|
|
1195
1344
|
id: itemId
|
|
1196
1345
|
},
|
|
@@ -1212,10 +1361,8 @@ exports._addItemMetadataFile = _addItemMetadataFile;
|
|
|
1212
1361
|
* @private
|
|
1213
1362
|
*/
|
|
1214
1363
|
function _countRelationships(layers) {
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
(currentLayer.relationships ? currentLayer.relationships.length : 0);
|
|
1218
|
-
};
|
|
1364
|
+
const reducer = (accumulator, currentLayer) => accumulator +
|
|
1365
|
+
(currentLayer.relationships ? currentLayer.relationships.length : 0);
|
|
1219
1366
|
return layers.reduce(reducer, 0);
|
|
1220
1367
|
}
|
|
1221
1368
|
exports._countRelationships = _countRelationships;
|
|
@@ -1229,28 +1376,33 @@ exports._countRelationships = _countRelationships;
|
|
|
1229
1376
|
* @private
|
|
1230
1377
|
*/
|
|
1231
1378
|
function _getCreateServiceOptions(newItemTemplate, authentication, templateDictionary) {
|
|
1232
|
-
return new Promise(
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1379
|
+
return new Promise((resolve, reject) => {
|
|
1380
|
+
const serviceInfo = newItemTemplate.properties;
|
|
1381
|
+
const folderId = templateDictionary.folderId;
|
|
1382
|
+
const isPortal = templateDictionary.isPortal;
|
|
1383
|
+
const itemId = newItemTemplate.itemId;
|
|
1237
1384
|
(0, featureServiceHelpers_1.validateSpatialReferenceAndExtent)(serviceInfo, newItemTemplate, templateDictionary);
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1385
|
+
const fallbackExtent = _getFallbackExtent(serviceInfo, templateDictionary);
|
|
1386
|
+
const params = {};
|
|
1387
|
+
const itemInfo = {
|
|
1241
1388
|
title: newItemTemplate.item.title,
|
|
1242
1389
|
name: newItemTemplate.item.name
|
|
1243
1390
|
};
|
|
1244
|
-
|
|
1245
|
-
|
|
1391
|
+
const _item = {
|
|
1392
|
+
...itemInfo,
|
|
1393
|
+
preserveLayerIds: true
|
|
1394
|
+
};
|
|
1395
|
+
const createOptions = {
|
|
1246
1396
|
item: _item,
|
|
1247
|
-
folderId
|
|
1248
|
-
params
|
|
1397
|
+
folderId,
|
|
1398
|
+
params,
|
|
1249
1399
|
authentication: authentication
|
|
1250
1400
|
};
|
|
1251
|
-
createOptions.item =
|
|
1401
|
+
createOptions.item = !(0, trackingHelpers_1.isTrackingViewTemplate)(newItemTemplate) ?
|
|
1402
|
+
_setItemProperties(createOptions.item, newItemTemplate, serviceInfo, params, isPortal) :
|
|
1403
|
+
(0, trackingHelpers_1.setTrackingOptions)(newItemTemplate, createOptions, templateDictionary);
|
|
1252
1404
|
// project the portals extent to match that of the service
|
|
1253
|
-
convertExtentWithFallback(templateDictionary.organization.defaultExtent, fallbackExtent, serviceInfo.service.spatialReference, templateDictionary.organization.helperServices.geometry.url, authentication).then(
|
|
1405
|
+
convertExtentWithFallback(templateDictionary.organization.defaultExtent, fallbackExtent, serviceInfo.service.spatialReference, templateDictionary.organization.helperServices.geometry.url, authentication).then(extent => {
|
|
1254
1406
|
templateDictionary[itemId].solutionExtent = extent;
|
|
1255
1407
|
(0, featureServiceHelpers_1.setDefaultSpatialReference)(templateDictionary, itemId, extent.spatialReference);
|
|
1256
1408
|
createOptions.item = (0, templatization_1.replaceInTemplate)(createOptions.item, templateDictionary);
|
|
@@ -1260,7 +1412,7 @@ function _getCreateServiceOptions(newItemTemplate, authentication, templateDicti
|
|
|
1260
1412
|
createOptions.params.thumbnail = newItemTemplate.item.thumbnail;
|
|
1261
1413
|
}
|
|
1262
1414
|
resolve(createOptions);
|
|
1263
|
-
},
|
|
1415
|
+
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
1264
1416
|
});
|
|
1265
1417
|
}
|
|
1266
1418
|
exports._getCreateServiceOptions = _getCreateServiceOptions;
|
|
@@ -1277,9 +1429,9 @@ exports._getCreateServiceOptions = _getCreateServiceOptions;
|
|
|
1277
1429
|
* @private
|
|
1278
1430
|
*/
|
|
1279
1431
|
function _getFallbackExtent(serviceInfo, templateDictionary) {
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1432
|
+
const serviceSR = serviceInfo.service.spatialReference;
|
|
1433
|
+
const serviceInfoWkid = (0, generalHelpers_1.getProp)(serviceInfo, "defaultExtent.spatialReference.wkid");
|
|
1434
|
+
const customDefaultExtent = (0, generalHelpers_1.getProp)(templateDictionary, "params.defaultExtent");
|
|
1283
1435
|
return serviceInfoWkid && serviceInfoWkid === serviceSR.wkid
|
|
1284
1436
|
? serviceInfo.defaultExtent
|
|
1285
1437
|
: customDefaultExtent
|
|
@@ -1295,11 +1447,11 @@ exports._getFallbackExtent = _getFallbackExtent;
|
|
|
1295
1447
|
* @private
|
|
1296
1448
|
*/
|
|
1297
1449
|
function _getRelationshipUpdates(args) {
|
|
1298
|
-
|
|
1450
|
+
const rels = {
|
|
1299
1451
|
layers: []
|
|
1300
1452
|
};
|
|
1301
|
-
Object.keys(args.objects).forEach(
|
|
1302
|
-
|
|
1453
|
+
Object.keys(args.objects).forEach((k) => {
|
|
1454
|
+
const obj = args.objects[k];
|
|
1303
1455
|
/* istanbul ignore else */
|
|
1304
1456
|
if (obj.relationships && obj.relationships.length > 0) {
|
|
1305
1457
|
rels.layers.push({
|
|
@@ -1324,7 +1476,7 @@ exports._getRelationshipUpdates = _getRelationshipUpdates;
|
|
|
1324
1476
|
* @private
|
|
1325
1477
|
*/
|
|
1326
1478
|
function _getUpdate(url, id, obj, args, type) {
|
|
1327
|
-
|
|
1479
|
+
const ops = {
|
|
1328
1480
|
delete: {
|
|
1329
1481
|
url: (0, generalHelpers_1.checkUrlPathTermination)(url) + id + "/deleteFromDefinition",
|
|
1330
1482
|
params: {
|
|
@@ -1335,7 +1487,7 @@ function _getUpdate(url, id, obj, args, type) {
|
|
|
1335
1487
|
},
|
|
1336
1488
|
update: {
|
|
1337
1489
|
url: (0, generalHelpers_1.checkUrlPathTermination)(url) +
|
|
1338
|
-
(id ? id
|
|
1490
|
+
(id ? `${id}/updateDefinition` : "updateDefinition"),
|
|
1339
1491
|
params: {
|
|
1340
1492
|
updateDefinition: obj
|
|
1341
1493
|
}
|
|
@@ -1367,7 +1519,7 @@ exports._getUpdate = _getUpdate;
|
|
|
1367
1519
|
* @param data Item's data section
|
|
1368
1520
|
*/
|
|
1369
1521
|
function _reportVariablesInItem(itemId, itemType, base, data) {
|
|
1370
|
-
|
|
1522
|
+
const getUnresolved = (v) => {
|
|
1371
1523
|
return JSON.stringify(v).match(/{{.+?}}/gim);
|
|
1372
1524
|
};
|
|
1373
1525
|
// Provide feedback about any remaining unresolved variables
|
|
@@ -1393,14 +1545,15 @@ exports._reportVariablesInItem = _reportVariablesInItem;
|
|
|
1393
1545
|
* Updates a feature service item.
|
|
1394
1546
|
*
|
|
1395
1547
|
* @param item Item to update
|
|
1548
|
+
* @param itemTemplate item template for the new item
|
|
1396
1549
|
* @param serviceInfo Service information
|
|
1397
1550
|
* @param params arcgis-rest-js params to update
|
|
1398
1551
|
* @param isPortal Is the service hosted in a portal?
|
|
1399
1552
|
* @return Updated item
|
|
1400
1553
|
*/
|
|
1401
|
-
function _setItemProperties(item, serviceInfo, params, isPortal) {
|
|
1554
|
+
function _setItemProperties(item, itemTemplate, serviceInfo, params, isPortal) {
|
|
1402
1555
|
// Set the capabilities
|
|
1403
|
-
|
|
1556
|
+
const portalCapabilities = [
|
|
1404
1557
|
"Create",
|
|
1405
1558
|
"Query",
|
|
1406
1559
|
"Editing",
|
|
@@ -1410,11 +1563,11 @@ function _setItemProperties(item, serviceInfo, params, isPortal) {
|
|
|
1410
1563
|
"Sync",
|
|
1411
1564
|
"Extract"
|
|
1412
1565
|
];
|
|
1413
|
-
|
|
1566
|
+
const capabilities = (0, generalHelpers_1.getProp)(serviceInfo, "service.capabilities") || (isPortal ? "" : []);
|
|
1414
1567
|
item.capabilities = isPortal
|
|
1415
1568
|
? capabilities
|
|
1416
1569
|
.split(",")
|
|
1417
|
-
.filter(
|
|
1570
|
+
.filter((c) => portalCapabilities.indexOf(c) > -1)
|
|
1418
1571
|
.join(",")
|
|
1419
1572
|
: capabilities;
|
|
1420
1573
|
if (serviceInfo.service.capabilities) {
|
|
@@ -1424,22 +1577,22 @@ function _setItemProperties(item, serviceInfo, params, isPortal) {
|
|
|
1424
1577
|
// have non-unique indexes on relationship key fields
|
|
1425
1578
|
_updateIndexesForRelationshipKeyFields(serviceInfo);
|
|
1426
1579
|
// set create options item properties
|
|
1427
|
-
|
|
1580
|
+
const keyProperties = [
|
|
1428
1581
|
"isView",
|
|
1429
1582
|
"sourceSchemaChangesAllowed",
|
|
1430
1583
|
"isUpdatableView",
|
|
1431
1584
|
"capabilities",
|
|
1432
1585
|
"isMultiServicesView"
|
|
1433
1586
|
];
|
|
1434
|
-
|
|
1587
|
+
const deleteKeys = ["layers", "tables"];
|
|
1435
1588
|
/* istanbul ignore else */
|
|
1436
1589
|
if (isPortal) {
|
|
1437
1590
|
// removed for issue #423 causing FS to fail to create
|
|
1438
1591
|
deleteKeys.push("adminServiceInfo");
|
|
1439
1592
|
}
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
serviceKeys.forEach(
|
|
1593
|
+
const itemKeys = Object.keys(item);
|
|
1594
|
+
const serviceKeys = Object.keys(serviceInfo.service);
|
|
1595
|
+
serviceKeys.forEach(k => {
|
|
1443
1596
|
/* istanbul ignore else */
|
|
1444
1597
|
if (itemKeys.indexOf(k) === -1 && deleteKeys.indexOf(k) < 0) {
|
|
1445
1598
|
item[k] = serviceInfo.service[k];
|
|
@@ -1478,16 +1631,16 @@ exports._setItemProperties = _setItemProperties;
|
|
|
1478
1631
|
* @protected
|
|
1479
1632
|
*/
|
|
1480
1633
|
function _updateIndexesForRelationshipKeyFields(serviceInfo) {
|
|
1481
|
-
|
|
1482
|
-
layersAndTables.forEach(
|
|
1483
|
-
|
|
1484
|
-
|
|
1634
|
+
const layersAndTables = (serviceInfo.layers || []).concat(serviceInfo.tables || []);
|
|
1635
|
+
layersAndTables.forEach(item => {
|
|
1636
|
+
const relationships = item.relationships;
|
|
1637
|
+
const indexes = item.indexes;
|
|
1485
1638
|
/* istanbul ignore else */
|
|
1486
1639
|
if (relationships &&
|
|
1487
1640
|
relationships.length > 0 &&
|
|
1488
1641
|
indexes &&
|
|
1489
1642
|
indexes.length > 0) {
|
|
1490
|
-
|
|
1643
|
+
const keyFields = relationships.reduce((acc, v) => {
|
|
1491
1644
|
/* istanbul ignore else */
|
|
1492
1645
|
if (v.role === "esriRelRoleOrigin" &&
|
|
1493
1646
|
v.keyField &&
|
|
@@ -1496,10 +1649,10 @@ function _updateIndexesForRelationshipKeyFields(serviceInfo) {
|
|
|
1496
1649
|
}
|
|
1497
1650
|
return acc;
|
|
1498
1651
|
}, []);
|
|
1499
|
-
indexes.map(
|
|
1652
|
+
indexes.map(i => {
|
|
1500
1653
|
/* istanbul ignore else */
|
|
1501
|
-
if (
|
|
1502
|
-
|
|
1654
|
+
if (keyFields.some(k => {
|
|
1655
|
+
const regEx = new RegExp(`\\b${k}\\b`);
|
|
1503
1656
|
return regEx.test(i.fields);
|
|
1504
1657
|
})) {
|
|
1505
1658
|
i.isUnique = true;
|
|
@@ -1520,23 +1673,22 @@ exports._updateIndexesForRelationshipKeyFields = _updateIndexesForRelationshipKe
|
|
|
1520
1673
|
* @return A promise that will resolve with the item id when the item has been updated or an AGO-style JSON failure
|
|
1521
1674
|
* response
|
|
1522
1675
|
*/
|
|
1523
|
-
function _updateItemURL(id, url, authentication, numAttempts) {
|
|
1524
|
-
if (numAttempts === void 0) { numAttempts = 1; }
|
|
1676
|
+
function _updateItemURL(id, url, authentication, numAttempts = 1) {
|
|
1525
1677
|
// Introduce a lag because AGO update appears to choke with rapid subsequent calls
|
|
1526
|
-
|
|
1527
|
-
return new Promise(
|
|
1678
|
+
const msLag = 1000;
|
|
1679
|
+
return new Promise((resolve, reject) => {
|
|
1528
1680
|
// Update the item's URL
|
|
1529
|
-
|
|
1530
|
-
(0, arcgis_rest_portal_1.updateItem)(options).then(
|
|
1681
|
+
const options = { item: { id, url }, authentication: authentication };
|
|
1682
|
+
(0, arcgis_rest_portal_1.updateItem)(options).then(result => {
|
|
1531
1683
|
if (!result.success) {
|
|
1532
1684
|
reject((0, generalHelpers_1.fail)(result));
|
|
1533
1685
|
}
|
|
1534
1686
|
else {
|
|
1535
1687
|
// Get the item to see if the URL really changed; we'll delay a bit before testing because AGO
|
|
1536
1688
|
// has a timing problem with URL updates
|
|
1537
|
-
setTimeout(
|
|
1538
|
-
(0, arcgis_rest_portal_1.getItem)(id, { authentication: authentication }).then(
|
|
1539
|
-
|
|
1689
|
+
setTimeout(() => {
|
|
1690
|
+
(0, arcgis_rest_portal_1.getItem)(id, { authentication: authentication }).then(item => {
|
|
1691
|
+
const iBrace = item.url.indexOf("{");
|
|
1540
1692
|
if (iBrace > -1) {
|
|
1541
1693
|
console.warn(id + " has template variable: " + item.url.substr(iBrace));
|
|
1542
1694
|
}
|
|
@@ -1545,7 +1697,7 @@ function _updateItemURL(id, url, authentication, numAttempts) {
|
|
|
1545
1697
|
}
|
|
1546
1698
|
else {
|
|
1547
1699
|
// If it fails, try again if we have sufficient attempts remaining
|
|
1548
|
-
|
|
1700
|
+
const errorMsg = "URL not updated for " +
|
|
1549
1701
|
item.type +
|
|
1550
1702
|
" " +
|
|
1551
1703
|
item.id +
|
|
@@ -1562,10 +1714,10 @@ function _updateItemURL(id, url, authentication, numAttempts) {
|
|
|
1562
1714
|
reject(errorMsg);
|
|
1563
1715
|
}
|
|
1564
1716
|
}
|
|
1565
|
-
},
|
|
1717
|
+
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
1566
1718
|
}, msLag);
|
|
1567
1719
|
}
|
|
1568
|
-
},
|
|
1720
|
+
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
1569
1721
|
});
|
|
1570
1722
|
}
|
|
1571
1723
|
exports._updateItemURL = _updateItemURL;
|