@esri/solution-common 5.5.1 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/completeItem.js +2 -2
- package/dist/cjs/completeItem.js.map +1 -1
- package/dist/cjs/create-hub-request-options.js +1 -1
- package/dist/cjs/deleteHelpers/deleteEmptyGroups.js +1 -1
- package/dist/cjs/deleteHelpers/deleteEmptyGroups.js.map +1 -1
- package/dist/cjs/deleteHelpers/deleteGroupIfEmpty.js +6 -6
- package/dist/cjs/deleteHelpers/deleteGroupIfEmpty.js.map +1 -1
- package/dist/cjs/deleteHelpers/deleteSolutionContents.js +7 -11
- package/dist/cjs/deleteHelpers/deleteSolutionContents.js.map +1 -1
- package/dist/cjs/deleteHelpers/deleteSolutionFolder.js +6 -6
- package/dist/cjs/deleteHelpers/deleteSolutionFolder.js.map +1 -1
- package/dist/cjs/deleteHelpers/deleteSolutionItem.js +4 -4
- package/dist/cjs/deleteHelpers/deleteSolutionItem.js.map +1 -1
- package/dist/cjs/deleteHelpers/reconstructBuildOrderIds.js.map +1 -1
- package/dist/cjs/deleteHelpers/removeItems.js +5 -6
- package/dist/cjs/deleteHelpers/removeItems.js.map +1 -1
- package/dist/cjs/deleteHelpers/reportProgress.js +1 -1
- package/dist/cjs/deleteHelpers/reportProgress.js.map +1 -1
- package/dist/cjs/deleteSolution.js +7 -7
- package/dist/cjs/deleteSolution.js.map +1 -1
- package/dist/cjs/dependencies.js +5 -5
- package/dist/cjs/dependencies.js.map +1 -1
- package/dist/cjs/featureServiceHelpers.js +132 -165
- package/dist/cjs/featureServiceHelpers.js.map +1 -1
- package/dist/cjs/formHelpers.js +1 -1
- package/dist/cjs/formHelpers.js.map +1 -1
- package/dist/cjs/generalHelpers.js +25 -40
- package/dist/cjs/generalHelpers.js.map +1 -1
- package/dist/cjs/get-subscription-info.js +1 -1
- package/dist/cjs/get-subscription-info.js.map +1 -1
- package/dist/cjs/getDeletableSolutionInfo.js.map +1 -1
- package/dist/cjs/getItemTypeAbbrev.js +27 -27
- package/dist/cjs/getItemTypeAbbrev.js.map +1 -1
- package/dist/cjs/getSolutionSummary.js +50 -51
- package/dist/cjs/getSolutionSummary.js.map +1 -1
- package/dist/cjs/interfaces.d.ts +2 -2
- package/dist/cjs/interfaces.js +1 -1
- package/dist/cjs/interfaces.js.map +1 -1
- package/dist/cjs/item-reuse.js +27 -24
- package/dist/cjs/item-reuse.js.map +1 -1
- package/dist/cjs/libConnectors.js +1 -1
- package/dist/cjs/libConnectors.js.map +1 -1
- package/dist/cjs/migrations/apply-schema.js +1 -1
- package/dist/cjs/migrations/is-legacy-solution.js +1 -2
- package/dist/cjs/migrations/is-legacy-solution.js.map +1 -1
- package/dist/cjs/migrations/upgrade-two-dot-five.js +2 -2
- package/dist/cjs/migrations/upgrade-two-dot-five.js.map +1 -1
- package/dist/cjs/migrations/upgrade-two-dot-four.js +4 -4
- package/dist/cjs/migrations/upgrade-two-dot-four.js.map +1 -1
- package/dist/cjs/migrations/upgrade-two-dot-seven.js.map +1 -1
- package/dist/cjs/migrations/upgrade-two-dot-six.js +2 -2
- package/dist/cjs/migrations/upgrade-two-dot-six.js.map +1 -1
- package/dist/cjs/migrations/upgrade-two-dot-three.js +3 -3
- package/dist/cjs/migrations/upgrade-two-dot-three.js.map +1 -1
- package/dist/cjs/migrations/upgrade-two-dot-two.js +3 -3
- package/dist/cjs/migrations/upgrade-two-dot-two.js.map +1 -1
- package/dist/cjs/migrations/upgrade-two-dot-zero.js +3 -3
- package/dist/cjs/migrations/upgrade-two-dot-zero.js.map +1 -1
- package/dist/cjs/migrator.js +1 -3
- package/dist/cjs/migrator.js.map +1 -1
- package/dist/cjs/resourceHelpers.js +24 -29
- package/dist/cjs/resourceHelpers.js.map +1 -1
- package/dist/cjs/resources/add-resource-from-blob.js +2 -2
- package/dist/cjs/resources/add-resource-from-blob.js.map +1 -1
- package/dist/cjs/resources/addMetadataFromBlob.js +3 -3
- package/dist/cjs/resources/addMetadataFromBlob.js.map +1 -1
- package/dist/cjs/resources/copyAssociatedFiles.js +25 -31
- package/dist/cjs/resources/copyAssociatedFiles.js.map +1 -1
- package/dist/cjs/resources/copyDataIntoItem.js +7 -9
- package/dist/cjs/resources/copyDataIntoItem.js.map +1 -1
- package/dist/cjs/resources/copyMetadataIntoItem.js +4 -6
- package/dist/cjs/resources/copyMetadataIntoItem.js.map +1 -1
- package/dist/cjs/resources/copyResourceIntoZip.js +3 -7
- package/dist/cjs/resources/copyResourceIntoZip.js.map +1 -1
- package/dist/cjs/resources/copyZipIntoItem.js +4 -5
- package/dist/cjs/resources/copyZipIntoItem.js.map +1 -1
- package/dist/cjs/resources/createCopyResults.js +1 -1
- package/dist/cjs/resources/get-blob.js +2 -2
- package/dist/cjs/resources/get-blob.js.map +1 -1
- package/dist/cjs/resources/getItemResourcesFilesFromPaths.js +5 -5
- package/dist/cjs/resources/getItemResourcesFilesFromPaths.js.map +1 -1
- package/dist/cjs/resources/getItemResourcesPaths.js +1 -1
- package/dist/cjs/resources/getItemResourcesPaths.js.map +1 -1
- package/dist/cjs/resources/transform-resource-paths-to-solution-resources.js +5 -11
- package/dist/cjs/resources/transform-resource-paths-to-solution-resources.js.map +1 -1
- package/dist/cjs/restHelpers.js +219 -261
- package/dist/cjs/restHelpers.js.map +1 -1
- package/dist/cjs/restHelpersGet.js +55 -63
- package/dist/cjs/restHelpersGet.js.map +1 -1
- package/dist/cjs/sharing/share-item-to-groups.js +2 -2
- package/dist/cjs/sharing/share-item-to-groups.js.map +1 -1
- package/dist/cjs/templatization.js +10 -12
- package/dist/cjs/templatization.js.map +1 -1
- package/dist/cjs/trackingHelpers.js +10 -15
- package/dist/cjs/trackingHelpers.js.map +1 -1
- package/dist/cjs/velocityHelpers.js +7 -11
- package/dist/cjs/velocityHelpers.js.map +1 -1
- package/dist/cjs/workflowHelpers.js +15 -17
- package/dist/cjs/workflowHelpers.js.map +1 -1
- package/dist/cjs/workforceHelpers.js +75 -103
- package/dist/cjs/workforceHelpers.js.map +1 -1
- package/dist/cjs/zip-utils.js +3 -3
- package/dist/cjs/zip-utils.js.map +1 -1
- package/dist/esm/completeItem.js +2 -2
- package/dist/esm/completeItem.js.map +1 -1
- package/dist/esm/create-hub-request-options.js +1 -1
- package/dist/esm/deleteHelpers/deleteEmptyGroups.js +1 -1
- package/dist/esm/deleteHelpers/deleteEmptyGroups.js.map +1 -1
- package/dist/esm/deleteHelpers/deleteGroupIfEmpty.js +6 -6
- package/dist/esm/deleteHelpers/deleteGroupIfEmpty.js.map +1 -1
- package/dist/esm/deleteHelpers/deleteSolutionContents.js +8 -12
- package/dist/esm/deleteHelpers/deleteSolutionContents.js.map +1 -1
- package/dist/esm/deleteHelpers/deleteSolutionFolder.js +6 -6
- 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.map +1 -1
- package/dist/esm/deleteHelpers/removeItems.js +5 -6
- package/dist/esm/deleteHelpers/removeItems.js.map +1 -1
- package/dist/esm/deleteHelpers/reportProgress.js +1 -1
- package/dist/esm/deleteHelpers/reportProgress.js.map +1 -1
- package/dist/esm/deleteSolution.js +7 -7
- package/dist/esm/deleteSolution.js.map +1 -1
- package/dist/esm/dependencies.js +5 -5
- package/dist/esm/dependencies.js.map +1 -1
- package/dist/esm/featureServiceHelpers.js +134 -167
- package/dist/esm/featureServiceHelpers.js.map +1 -1
- package/dist/esm/formHelpers.js +1 -1
- package/dist/esm/formHelpers.js.map +1 -1
- package/dist/esm/generalHelpers.js +25 -40
- package/dist/esm/generalHelpers.js.map +1 -1
- package/dist/esm/get-subscription-info.js +1 -1
- package/dist/esm/get-subscription-info.js.map +1 -1
- package/dist/esm/getDeletableSolutionInfo.js.map +1 -1
- package/dist/esm/getItemTypeAbbrev.js +27 -27
- package/dist/esm/getItemTypeAbbrev.js.map +1 -1
- package/dist/esm/getSolutionSummary.js +51 -52
- package/dist/esm/getSolutionSummary.js.map +1 -1
- package/dist/esm/interfaces.d.ts +2 -2
- package/dist/esm/interfaces.js +2 -2
- package/dist/esm/interfaces.js.map +1 -1
- package/dist/esm/item-reuse.js +27 -24
- package/dist/esm/item-reuse.js.map +1 -1
- package/dist/esm/libConnectors.js +1 -1
- package/dist/esm/libConnectors.js.map +1 -1
- package/dist/esm/migrations/apply-schema.js +1 -1
- package/dist/esm/migrations/is-legacy-solution.js +1 -2
- package/dist/esm/migrations/is-legacy-solution.js.map +1 -1
- package/dist/esm/migrations/upgrade-two-dot-five.js +2 -2
- package/dist/esm/migrations/upgrade-two-dot-five.js.map +1 -1
- package/dist/esm/migrations/upgrade-two-dot-four.js +4 -4
- package/dist/esm/migrations/upgrade-two-dot-four.js.map +1 -1
- package/dist/esm/migrations/upgrade-two-dot-seven.js.map +1 -1
- package/dist/esm/migrations/upgrade-two-dot-six.js +2 -2
- 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 +3 -3
- package/dist/esm/migrations/upgrade-two-dot-zero.js.map +1 -1
- package/dist/esm/migrator.js +1 -3
- package/dist/esm/migrator.js.map +1 -1
- package/dist/esm/resourceHelpers.js +26 -31
- 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 +3 -3
- package/dist/esm/resources/addMetadataFromBlob.js.map +1 -1
- package/dist/esm/resources/copyAssociatedFiles.js +26 -32
- package/dist/esm/resources/copyAssociatedFiles.js.map +1 -1
- package/dist/esm/resources/copyDataIntoItem.js +7 -9
- package/dist/esm/resources/copyDataIntoItem.js.map +1 -1
- package/dist/esm/resources/copyMetadataIntoItem.js +4 -6
- package/dist/esm/resources/copyMetadataIntoItem.js.map +1 -1
- package/dist/esm/resources/copyResourceIntoZip.js +3 -7
- package/dist/esm/resources/copyResourceIntoZip.js.map +1 -1
- package/dist/esm/resources/copyZipIntoItem.js +4 -5
- package/dist/esm/resources/copyZipIntoItem.js.map +1 -1
- package/dist/esm/resources/createCopyResults.js +1 -1
- package/dist/esm/resources/get-blob.js +2 -2
- package/dist/esm/resources/get-blob.js.map +1 -1
- package/dist/esm/resources/getItemResourcesFilesFromPaths.js +5 -5
- package/dist/esm/resources/getItemResourcesFilesFromPaths.js.map +1 -1
- package/dist/esm/resources/getItemResourcesPaths.js +1 -1
- package/dist/esm/resources/getItemResourcesPaths.js.map +1 -1
- package/dist/esm/resources/transform-resource-paths-to-solution-resources.js +5 -11
- package/dist/esm/resources/transform-resource-paths-to-solution-resources.js.map +1 -1
- package/dist/esm/restHelpers.js +224 -266
- package/dist/esm/restHelpers.js.map +1 -1
- package/dist/esm/restHelpersGet.js +56 -64
- package/dist/esm/restHelpersGet.js.map +1 -1
- package/dist/esm/sharing/share-item-to-groups.js +2 -2
- package/dist/esm/sharing/share-item-to-groups.js.map +1 -1
- package/dist/esm/templatization.js +10 -12
- package/dist/esm/templatization.js.map +1 -1
- package/dist/esm/trackingHelpers.js +10 -15
- package/dist/esm/trackingHelpers.js.map +1 -1
- package/dist/esm/velocityHelpers.js +7 -11
- package/dist/esm/velocityHelpers.js.map +1 -1
- package/dist/esm/workflowHelpers.js +15 -17
- package/dist/esm/workflowHelpers.js.map +1 -1
- package/dist/esm/workforceHelpers.js +75 -103
- package/dist/esm/workforceHelpers.js.map +1 -1
- package/dist/esm/zip-utils.js +3 -3
- package/dist/esm/zip-utils.js.map +1 -1
- package/dist/solution.js_commit.txt +5 -5
- package/package.json +5 -5
package/dist/esm/restHelpers.js
CHANGED
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
*
|
|
19
19
|
* @module restHelpers
|
|
20
20
|
*/
|
|
21
|
-
import { removeLayerOptimization, setDefaultSpatialReference, validateSpatialReferenceAndExtent, processContingentValues } from "./featureServiceHelpers";
|
|
22
|
-
import { appendQueryParam, blobToJson, blobToText, checkUrlPathTermination, deleteProp, deleteProps, fail, getProp, getUniqueTitle, setCreateProp } from "./generalHelpers";
|
|
23
|
-
import { UserSession } from "./interfaces";
|
|
21
|
+
import { removeLayerOptimization, setDefaultSpatialReference, validateSpatialReferenceAndExtent, processContingentValues, } from "./featureServiceHelpers";
|
|
22
|
+
import { appendQueryParam, blobToJson, blobToText, checkUrlPathTermination, deleteProp, deleteProps, fail, getProp, getUniqueTitle, setCreateProp, } from "./generalHelpers";
|
|
23
|
+
import { UserSession, } from "./interfaces";
|
|
24
24
|
import { createZip } from "./libConnectors";
|
|
25
25
|
import { getItemBase, getItemDataAsJson } from "./restHelpersGet";
|
|
26
|
-
import { addItemData as portalAddItemData, addItemRelationship, addItemResource, createFolder, createGroup, createItemInFolder, getItem, moveItem as portalMoveItem, removeFolder as portalRemoveFolder, removeGroup as portalRemoveGroup, removeGroupUsers as portalRemoveGroupUsers, removeItem as portalRemoveItem, searchGroupContent, searchGroups as portalSearchGroups, searchItems as portalSearchItems, SearchQueryBuilder, setItemAccess, shareItemWithGroup, updateItem as portalUpdateItem, updateGroup as portalUpdateGroup } from "@esri/arcgis-rest-portal";
|
|
26
|
+
import { addItemData as portalAddItemData, addItemRelationship, addItemResource, createFolder, createGroup, createItemInFolder, getItem, moveItem as portalMoveItem, removeFolder as portalRemoveFolder, removeGroup as portalRemoveGroup, removeGroupUsers as portalRemoveGroupUsers, removeItem as portalRemoveItem, searchGroupContent, searchGroups as portalSearchGroups, searchItems as portalSearchItems, SearchQueryBuilder, setItemAccess, shareItemWithGroup, updateItem as portalUpdateItem, updateGroup as portalUpdateGroup, } from "@esri/arcgis-rest-portal";
|
|
27
27
|
import { request } from "@esri/arcgis-rest-request";
|
|
28
|
-
import { addToServiceDefinition as svcAdminAddToServiceDefinition, createFeatureService as svcAdminCreateFeatureService } from "@esri/arcgis-rest-service-admin";
|
|
28
|
+
import { addToServiceDefinition as svcAdminAddToServiceDefinition, createFeatureService as svcAdminCreateFeatureService, } from "@esri/arcgis-rest-service-admin";
|
|
29
29
|
import { getWorkforceDependencies, isWorkforceProject, getWorkforceServiceInfo } from "./workforceHelpers";
|
|
30
30
|
import { hasUnresolvedVariables, replaceInTemplate } from "./templatization";
|
|
31
31
|
import { isTrackingViewTemplate, setTrackingOptions } from "./trackingHelpers";
|
|
@@ -36,11 +36,10 @@ export function addItemData(id, data, authentication) {
|
|
|
36
36
|
const addDataOptions = {
|
|
37
37
|
id,
|
|
38
38
|
data,
|
|
39
|
-
authentication
|
|
39
|
+
authentication,
|
|
40
40
|
};
|
|
41
41
|
return portalAddItemData(addDataOptions);
|
|
42
42
|
}
|
|
43
|
-
;
|
|
44
43
|
/**
|
|
45
44
|
* Creates a UserSession via a function so that the global arcgisSolution variable can access authentication.
|
|
46
45
|
*
|
|
@@ -60,22 +59,22 @@ export function getUserSession(options = {}) {
|
|
|
60
59
|
* @returns A Promise to add item resources.
|
|
61
60
|
*/
|
|
62
61
|
export function addForwardItemRelationship(originItemId, destinationItemId, relationshipType, authentication) {
|
|
63
|
-
return new Promise(resolve => {
|
|
62
|
+
return new Promise((resolve) => {
|
|
64
63
|
const requestOptions = {
|
|
65
64
|
originItemId,
|
|
66
65
|
destinationItemId,
|
|
67
66
|
relationshipType,
|
|
68
|
-
authentication
|
|
67
|
+
authentication,
|
|
69
68
|
};
|
|
70
|
-
addItemRelationship(requestOptions).then(response => {
|
|
69
|
+
addItemRelationship(requestOptions).then((response) => {
|
|
71
70
|
resolve({
|
|
72
71
|
success: response.success,
|
|
73
|
-
itemId: originItemId
|
|
72
|
+
itemId: originItemId,
|
|
74
73
|
});
|
|
75
74
|
}, () => {
|
|
76
75
|
resolve({
|
|
77
76
|
success: false,
|
|
78
|
-
itemId: originItemId
|
|
77
|
+
itemId: originItemId,
|
|
79
78
|
});
|
|
80
79
|
});
|
|
81
80
|
});
|
|
@@ -89,11 +88,11 @@ export function addForwardItemRelationship(originItemId, destinationItemId, rela
|
|
|
89
88
|
* @returns A Promise to add item resources.
|
|
90
89
|
*/
|
|
91
90
|
export function addForwardItemRelationships(originItemId, destinationRelationships, authentication) {
|
|
92
|
-
return new Promise(resolve => {
|
|
91
|
+
return new Promise((resolve) => {
|
|
93
92
|
// Set up relationships using updated relationship information
|
|
94
93
|
const relationshipPromises = new Array();
|
|
95
|
-
destinationRelationships.forEach(relationship => {
|
|
96
|
-
relationship.relatedItemIds.forEach(relatedItemId => {
|
|
94
|
+
destinationRelationships.forEach((relationship) => {
|
|
95
|
+
relationship.relatedItemIds.forEach((relatedItemId) => {
|
|
97
96
|
relationshipPromises.push(addForwardItemRelationship(originItemId, relatedItemId, relationship.relationshipType, authentication));
|
|
98
97
|
});
|
|
99
98
|
});
|
|
@@ -110,12 +109,12 @@ export function addForwardItemRelationships(originItemId, destinationRelationshi
|
|
|
110
109
|
* unless either the URL doesn't exist or the token can't be generated
|
|
111
110
|
*/
|
|
112
111
|
export function addTokenToUrl(url, authentication) {
|
|
113
|
-
return new Promise(resolve => {
|
|
112
|
+
return new Promise((resolve) => {
|
|
114
113
|
if (!url || !authentication) {
|
|
115
114
|
resolve(url);
|
|
116
115
|
}
|
|
117
116
|
else {
|
|
118
|
-
authentication.getToken(url).then(token => {
|
|
117
|
+
authentication.getToken(url).then((token) => {
|
|
119
118
|
/* istanbul ignore else */
|
|
120
119
|
if (token) {
|
|
121
120
|
url = appendQueryParam(url, "token=" + token);
|
|
@@ -145,10 +144,10 @@ export function addToServiceDefinition(url, options, skipRetry = false, useAsync
|
|
|
145
144
|
}
|
|
146
145
|
return new Promise((resolve, reject) => {
|
|
147
146
|
svcAdminAddToServiceDefinition(url, options).then((result) => {
|
|
148
|
-
checkRequestStatus(result, options.authentication).then(() => resolve(null), e => reject(fail(e)));
|
|
149
|
-
}, e => {
|
|
147
|
+
checkRequestStatus(result, options.authentication).then(() => resolve(null), (e) => reject(fail(e)));
|
|
148
|
+
}, (e) => {
|
|
150
149
|
if (!skipRetry) {
|
|
151
|
-
addToServiceDefinition(url, options, true, true).then(() => resolve(null), e => reject(e));
|
|
150
|
+
addToServiceDefinition(url, options, true, true).then(() => resolve(null), (e) => reject(e));
|
|
152
151
|
}
|
|
153
152
|
else {
|
|
154
153
|
reject(fail(e));
|
|
@@ -169,7 +168,7 @@ export function checkRequestStatus(result, authentication) {
|
|
|
169
168
|
const url = result.statusURL || result.statusUrl;
|
|
170
169
|
if (url) {
|
|
171
170
|
const checkStatus = setInterval(() => {
|
|
172
|
-
request(url, { authentication }).then(r => {
|
|
171
|
+
request(url, { authentication }).then((r) => {
|
|
173
172
|
/* istanbul ignore else */
|
|
174
173
|
if (["completed", "success"].indexOf(r.status.toLowerCase()) > -1) {
|
|
175
174
|
clearInterval(checkStatus);
|
|
@@ -179,7 +178,7 @@ export function checkRequestStatus(result, authentication) {
|
|
|
179
178
|
clearInterval(checkStatus);
|
|
180
179
|
reject(r);
|
|
181
180
|
}
|
|
182
|
-
}, e => {
|
|
181
|
+
}, (e) => {
|
|
183
182
|
clearInterval(checkStatus);
|
|
184
183
|
reject(e);
|
|
185
184
|
});
|
|
@@ -201,7 +200,7 @@ export function convertToISearchOptions(search) {
|
|
|
201
200
|
let searchOptions = {
|
|
202
201
|
q: "",
|
|
203
202
|
start: 1,
|
|
204
|
-
num: 100
|
|
203
|
+
num: 100,
|
|
205
204
|
};
|
|
206
205
|
if (typeof search === "string") {
|
|
207
206
|
// Insert query into defaults
|
|
@@ -211,10 +210,11 @@ export function convertToISearchOptions(search) {
|
|
|
211
210
|
// Insert query into defaults
|
|
212
211
|
searchOptions.q = search.toParam();
|
|
213
212
|
}
|
|
214
|
-
else {
|
|
213
|
+
else {
|
|
214
|
+
// search is ISearchOptions
|
|
215
215
|
searchOptions = {
|
|
216
216
|
...searchOptions,
|
|
217
|
-
...search // request
|
|
217
|
+
...search, // request
|
|
218
218
|
};
|
|
219
219
|
}
|
|
220
220
|
// Remove the sortField if it's "relevance"; that's the default option and is not meant to be specified
|
|
@@ -269,9 +269,9 @@ export function convertExtentWithFallback(extent, fallbackExtent, outSR, geometr
|
|
|
269
269
|
xmax: 179,
|
|
270
270
|
ymin: -89,
|
|
271
271
|
ymax: 89,
|
|
272
|
-
spatialReference: { wkid: 4326 }
|
|
272
|
+
spatialReference: { wkid: 4326 },
|
|
273
273
|
};
|
|
274
|
-
convertExtent(_validateExtent(extent), outSR, geometryServiceUrl, authentication).then(extentResponse => {
|
|
274
|
+
convertExtent(_validateExtent(extent), outSR, geometryServiceUrl, authentication).then((extentResponse) => {
|
|
275
275
|
// in some cases project will complete successfully but return "NaN" values
|
|
276
276
|
// check for this and call convert again if it does
|
|
277
277
|
const extentResponseString = JSON.stringify(extentResponse);
|
|
@@ -280,12 +280,12 @@ export function convertExtentWithFallback(extent, fallbackExtent, outSR, geometr
|
|
|
280
280
|
resolve(extentResponse);
|
|
281
281
|
}
|
|
282
282
|
else {
|
|
283
|
-
convertExtent(fallbackExtent || defaultExtent, outSR, geometryServiceUrl, authentication).then(resolve, e => reject(fail(e)));
|
|
283
|
+
convertExtent(fallbackExtent || defaultExtent, outSR, geometryServiceUrl, authentication).then(resolve, (e) => reject(fail(e)));
|
|
284
284
|
}
|
|
285
285
|
},
|
|
286
286
|
// if convert fails try again with default global extent
|
|
287
287
|
() => {
|
|
288
|
-
convertExtent(defaultExtent, outSR, geometryServiceUrl, authentication).then(resolve, e => reject(fail(e)));
|
|
288
|
+
convertExtent(defaultExtent, outSR, geometryServiceUrl, authentication).then(resolve, (e) => reject(fail(e)));
|
|
289
289
|
});
|
|
290
290
|
});
|
|
291
291
|
}
|
|
@@ -309,12 +309,10 @@ export function convertExtent(extent, outSR, geometryServiceUrl, authentication)
|
|
|
309
309
|
f: "json",
|
|
310
310
|
inSR: extent.spatialReference.wkid,
|
|
311
311
|
outSR: outSR.wkid,
|
|
312
|
-
extentOfInterest: JSON.stringify(extent)
|
|
312
|
+
extentOfInterest: JSON.stringify(extent),
|
|
313
313
|
};
|
|
314
|
-
request(checkUrlPathTermination(geometryServiceUrl) + "findTransformations", _requestOptions).then(response => {
|
|
315
|
-
const transformations = response && response.transformations
|
|
316
|
-
? response.transformations
|
|
317
|
-
: undefined;
|
|
314
|
+
request(checkUrlPathTermination(geometryServiceUrl) + "findTransformations", _requestOptions).then((response) => {
|
|
315
|
+
const transformations = response && response.transformations ? response.transformations : undefined;
|
|
318
316
|
let transformation;
|
|
319
317
|
if (transformations && transformations.length > 0) {
|
|
320
318
|
// if a forward single transformation is found use that...otherwise check for and use composite
|
|
@@ -332,29 +330,27 @@ export function convertExtent(extent, outSR, geometryServiceUrl, authentication)
|
|
|
332
330
|
geometryType: "esriGeometryPoint",
|
|
333
331
|
geometries: [
|
|
334
332
|
{ x: extent.xmin, y: extent.ymin },
|
|
335
|
-
{ x: extent.xmax, y: extent.ymax }
|
|
336
|
-
]
|
|
333
|
+
{ x: extent.xmax, y: extent.ymax },
|
|
334
|
+
],
|
|
337
335
|
},
|
|
338
|
-
transformation: transformation
|
|
336
|
+
transformation: transformation,
|
|
339
337
|
};
|
|
340
|
-
request(checkUrlPathTermination(geometryServiceUrl) + "project", _requestOptions).then(projectResponse => {
|
|
341
|
-
const projectGeom = projectResponse.geometries.length === 2
|
|
342
|
-
? projectResponse.geometries
|
|
343
|
-
: undefined;
|
|
338
|
+
request(checkUrlPathTermination(geometryServiceUrl) + "project", _requestOptions).then((projectResponse) => {
|
|
339
|
+
const projectGeom = projectResponse.geometries.length === 2 ? projectResponse.geometries : undefined;
|
|
344
340
|
if (projectGeom) {
|
|
345
341
|
resolve({
|
|
346
342
|
xmin: projectGeom[0].x,
|
|
347
343
|
ymin: projectGeom[0].y,
|
|
348
344
|
xmax: projectGeom[1].x,
|
|
349
345
|
ymax: projectGeom[1].y,
|
|
350
|
-
spatialReference: outSR
|
|
346
|
+
spatialReference: outSR,
|
|
351
347
|
});
|
|
352
348
|
}
|
|
353
349
|
else {
|
|
354
350
|
resolve(undefined);
|
|
355
351
|
}
|
|
356
|
-
}, e => reject(fail(e)));
|
|
357
|
-
}, e => reject(fail(e)));
|
|
352
|
+
}, (e) => reject(fail(e)));
|
|
353
|
+
}, (e) => reject(fail(e)));
|
|
358
354
|
}
|
|
359
355
|
});
|
|
360
356
|
}
|
|
@@ -369,14 +365,14 @@ export function convertExtent(extent, outSR, geometryServiceUrl, authentication)
|
|
|
369
365
|
export function createFeatureService(newItemTemplate, authentication, templateDictionary) {
|
|
370
366
|
return new Promise((resolve, reject) => {
|
|
371
367
|
// Create item
|
|
372
|
-
_getCreateServiceOptions(newItemTemplate, authentication, templateDictionary).then(createOptions => {
|
|
373
|
-
svcAdminCreateFeatureService(createOptions).then(createResponse => {
|
|
368
|
+
_getCreateServiceOptions(newItemTemplate, authentication, templateDictionary).then((createOptions) => {
|
|
369
|
+
svcAdminCreateFeatureService(createOptions).then((createResponse) => {
|
|
374
370
|
// Federated servers may have inconsistent casing, so lowerCase it
|
|
375
371
|
createResponse.encodedServiceURL = _lowercaseDomain(createResponse.encodedServiceURL);
|
|
376
372
|
createResponse.serviceurl = _lowercaseDomain(createResponse.serviceurl);
|
|
377
373
|
resolve(createResponse);
|
|
378
|
-
}, e => reject(fail(e)));
|
|
379
|
-
}, e => reject(fail(e)));
|
|
374
|
+
}, (e) => reject(fail(e)));
|
|
375
|
+
}, (e) => reject(fail(e)));
|
|
380
376
|
});
|
|
381
377
|
}
|
|
382
378
|
/**
|
|
@@ -399,18 +395,18 @@ export function createFullItem(itemInfo, folderId, destinationAuthentication, it
|
|
|
399
395
|
// Create item
|
|
400
396
|
const createOptions = {
|
|
401
397
|
item: {
|
|
402
|
-
...itemInfo
|
|
398
|
+
...itemInfo,
|
|
403
399
|
},
|
|
404
400
|
folderId,
|
|
405
|
-
authentication: destinationAuthentication
|
|
401
|
+
authentication: destinationAuthentication,
|
|
406
402
|
};
|
|
407
403
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
408
|
-
addTokenToUrl(itemThumbnailUrl, itemThumbnailAuthentication).then(updatedThumbnailUrl => {
|
|
404
|
+
addTokenToUrl(itemThumbnailUrl, itemThumbnailAuthentication).then((updatedThumbnailUrl) => {
|
|
409
405
|
/* istanbul ignore else */
|
|
410
406
|
if (updatedThumbnailUrl) {
|
|
411
407
|
createOptions.item.thumbnailUrl = appendQueryParam(updatedThumbnailUrl, "w=400");
|
|
412
408
|
}
|
|
413
|
-
createItemInFolder(createOptions).then(createResponse => {
|
|
409
|
+
createItemInFolder(createOptions).then((createResponse) => {
|
|
414
410
|
if (createResponse.success) {
|
|
415
411
|
let accessDef;
|
|
416
412
|
// Set access if it is not AGOL default
|
|
@@ -420,13 +416,13 @@ export function createFullItem(itemInfo, folderId, destinationAuthentication, it
|
|
|
420
416
|
const accessOptions = {
|
|
421
417
|
id: createResponse.id,
|
|
422
418
|
access: access === "public" ? "public" : "org",
|
|
423
|
-
authentication: destinationAuthentication
|
|
419
|
+
authentication: destinationAuthentication,
|
|
424
420
|
};
|
|
425
421
|
accessDef = setItemAccess(accessOptions);
|
|
426
422
|
}
|
|
427
423
|
else {
|
|
428
424
|
accessDef = Promise.resolve({
|
|
429
|
-
itemId: createResponse.id
|
|
425
|
+
itemId: createResponse.id,
|
|
430
426
|
});
|
|
431
427
|
}
|
|
432
428
|
// Now add attached items
|
|
@@ -438,8 +434,7 @@ export function createFullItem(itemInfo, folderId, destinationAuthentication, it
|
|
|
438
434
|
}
|
|
439
435
|
// Add the resources via a zip because AGO sometimes loses resources if many are added at the
|
|
440
436
|
// same time to the same item
|
|
441
|
-
if (Array.isArray(resourcesFiles) &&
|
|
442
|
-
resourcesFiles.length > 0) {
|
|
437
|
+
if (Array.isArray(resourcesFiles) && resourcesFiles.length > 0) {
|
|
443
438
|
updateDefs.push(new Promise((rsrcResolve, rsrcReject) => {
|
|
444
439
|
createZip("resources.zip", resourcesFiles).then((zipfile) => {
|
|
445
440
|
const addResourceOptions = {
|
|
@@ -447,8 +442,8 @@ export function createFullItem(itemInfo, folderId, destinationAuthentication, it
|
|
|
447
442
|
resource: zipfile,
|
|
448
443
|
authentication: destinationAuthentication,
|
|
449
444
|
params: {
|
|
450
|
-
archive: true
|
|
451
|
-
}
|
|
445
|
+
archive: true,
|
|
446
|
+
},
|
|
452
447
|
};
|
|
453
448
|
addItemResource(addResourceOptions).then(rsrcResolve, rsrcReject);
|
|
454
449
|
}, rsrcReject);
|
|
@@ -459,13 +454,13 @@ export function createFullItem(itemInfo, folderId, destinationAuthentication, it
|
|
|
459
454
|
updateDefs.push(_addItemMetadataFile(createResponse.id, metadataFile, destinationAuthentication));
|
|
460
455
|
}
|
|
461
456
|
// Wait until all adds are done
|
|
462
|
-
Promise.all(updateDefs).then(() => resolve(createResponse), e => reject(fail(e)));
|
|
463
|
-
}, e => reject(fail(e)));
|
|
457
|
+
Promise.all(updateDefs).then(() => resolve(createResponse), (e) => reject(fail(e)));
|
|
458
|
+
}, (e) => reject(fail(e)));
|
|
464
459
|
}
|
|
465
460
|
else {
|
|
466
461
|
reject(fail());
|
|
467
462
|
}
|
|
468
|
-
}, e => reject(fail(e)));
|
|
463
|
+
}, (e) => reject(fail(e)));
|
|
469
464
|
});
|
|
470
465
|
});
|
|
471
466
|
}
|
|
@@ -487,19 +482,19 @@ export function createItemWithData(itemInfo, dataInfo, authentication, folderId,
|
|
|
487
482
|
item: {
|
|
488
483
|
title: "_",
|
|
489
484
|
...itemInfo,
|
|
490
|
-
data: dataInfo
|
|
485
|
+
data: dataInfo,
|
|
491
486
|
},
|
|
492
487
|
folderId,
|
|
493
|
-
authentication: authentication
|
|
488
|
+
authentication: authentication,
|
|
494
489
|
};
|
|
495
490
|
if (itemInfo.thumbnail) {
|
|
496
491
|
createOptions.params = {
|
|
497
492
|
// Pass thumbnail file in via params because item property is serialized, which discards a blob
|
|
498
|
-
thumbnail: itemInfo.thumbnail
|
|
493
|
+
thumbnail: itemInfo.thumbnail,
|
|
499
494
|
};
|
|
500
495
|
delete createOptions.item.thumbnail;
|
|
501
496
|
}
|
|
502
|
-
createItemInFolder(createOptions).then(createResponse => {
|
|
497
|
+
createItemInFolder(createOptions).then((createResponse) => {
|
|
503
498
|
if (createResponse.success) {
|
|
504
499
|
if (access !== "private") {
|
|
505
500
|
// Set access if it is not AGOL default
|
|
@@ -507,28 +502,28 @@ export function createItemWithData(itemInfo, dataInfo, authentication, folderId,
|
|
|
507
502
|
const accessOptions = {
|
|
508
503
|
id: createResponse.id,
|
|
509
504
|
access: access === "public" ? "public" : "org",
|
|
510
|
-
authentication: authentication
|
|
505
|
+
authentication: authentication,
|
|
511
506
|
};
|
|
512
507
|
setItemAccess(accessOptions).then(() => {
|
|
513
508
|
resolve({
|
|
514
509
|
folder: createResponse.folder,
|
|
515
510
|
id: createResponse.id,
|
|
516
|
-
success: true
|
|
511
|
+
success: true,
|
|
517
512
|
});
|
|
518
|
-
}, e => reject(fail(e)));
|
|
513
|
+
}, (e) => reject(fail(e)));
|
|
519
514
|
}
|
|
520
515
|
else {
|
|
521
516
|
resolve({
|
|
522
517
|
folder: createResponse.folder,
|
|
523
518
|
id: createResponse.id,
|
|
524
|
-
success: true
|
|
519
|
+
success: true,
|
|
525
520
|
});
|
|
526
521
|
}
|
|
527
522
|
}
|
|
528
523
|
else {
|
|
529
524
|
reject(fail());
|
|
530
525
|
}
|
|
531
|
-
}, e => reject(fail(e)));
|
|
526
|
+
}, (e) => reject(fail(e)));
|
|
532
527
|
});
|
|
533
528
|
}
|
|
534
529
|
/**
|
|
@@ -547,9 +542,9 @@ export function createUniqueFolder(title, templateDictionary, authentication) {
|
|
|
547
542
|
const folderTitle = getUniqueTitle(title, templateDictionary, "user.folders");
|
|
548
543
|
const folderCreationParam = {
|
|
549
544
|
title: folderTitle,
|
|
550
|
-
authentication: authentication
|
|
545
|
+
authentication: authentication,
|
|
551
546
|
};
|
|
552
|
-
createFolder(folderCreationParam).then(ok => resolve(ok), err => {
|
|
547
|
+
createFolder(folderCreationParam).then((ok) => resolve(ok), (err) => {
|
|
553
548
|
// If the name already exists, we'll try again
|
|
554
549
|
const errorDetails = getProp(err, "response.error.details");
|
|
555
550
|
if (Array.isArray(errorDetails) && errorDetails.length > 0) {
|
|
@@ -561,7 +556,7 @@ export function createUniqueFolder(title, templateDictionary, authentication) {
|
|
|
561
556
|
setCreateProp(templateDictionary, "user.folders", []);
|
|
562
557
|
}
|
|
563
558
|
templateDictionary.user.folders.push({
|
|
564
|
-
title: folderTitle
|
|
559
|
+
title: folderTitle,
|
|
565
560
|
});
|
|
566
561
|
createUniqueFolder(title, templateDictionary, authentication).then(resolve, reject);
|
|
567
562
|
}
|
|
@@ -600,25 +595,22 @@ export function createUniqueGroup(title, groupItem, templateDictionary, authenti
|
|
|
600
595
|
groupsPromise = Promise.resolve([]);
|
|
601
596
|
}
|
|
602
597
|
// first get the tracker owner groups
|
|
603
|
-
groupsPromise.then(groups => {
|
|
604
|
-
templateDictionary["allGroups"] =
|
|
605
|
-
groups.concat(getProp(templateDictionary, "user.groups"));
|
|
598
|
+
groupsPromise.then((groups) => {
|
|
599
|
+
templateDictionary["allGroups"] = groups.concat(getProp(templateDictionary, "user.groups"));
|
|
606
600
|
// Get a title that is not already in use
|
|
607
601
|
groupItem.title = getUniqueTitle(title, templateDictionary, "allGroups");
|
|
608
602
|
const groupCreationParam = {
|
|
609
603
|
group: groupItem,
|
|
610
|
-
authentication: authentication
|
|
604
|
+
authentication: authentication,
|
|
611
605
|
};
|
|
612
|
-
createGroup(groupCreationParam).then(resolve, err => {
|
|
606
|
+
createGroup(groupCreationParam).then(resolve, (err) => {
|
|
613
607
|
// If the name already exists, we'll try again
|
|
614
608
|
const errorDetails = getProp(err, "response.error.details");
|
|
615
609
|
if (Array.isArray(errorDetails) && errorDetails.length > 0) {
|
|
616
|
-
const nameNotAvailMsg = "You already have a group named '" +
|
|
617
|
-
groupItem.title +
|
|
618
|
-
"'. Try a different name.";
|
|
610
|
+
const nameNotAvailMsg = "You already have a group named '" + groupItem.title + "'. Try a different name.";
|
|
619
611
|
if (errorDetails.indexOf(nameNotAvailMsg) >= 0) {
|
|
620
612
|
templateDictionary.user.groups.push({
|
|
621
|
-
title: groupItem.title
|
|
613
|
+
title: groupItem.title,
|
|
622
614
|
});
|
|
623
615
|
createUniqueGroup(title, groupItem, templateDictionary, authentication).then(resolve, reject);
|
|
624
616
|
}
|
|
@@ -631,7 +623,7 @@ export function createUniqueGroup(title, groupItem, templateDictionary, authenti
|
|
|
631
623
|
reject(err);
|
|
632
624
|
}
|
|
633
625
|
});
|
|
634
|
-
}, e => reject(e));
|
|
626
|
+
}, (e) => reject(e));
|
|
635
627
|
});
|
|
636
628
|
}
|
|
637
629
|
/**
|
|
@@ -649,19 +641,19 @@ export function extractDependencies(itemTemplate, authentication) {
|
|
|
649
641
|
// This step is skipped for tracker views as they will already have a source service in the org
|
|
650
642
|
if (itemTemplate.properties.service.isView && itemTemplate.item.url && !isTrackingViewTemplate(itemTemplate)) {
|
|
651
643
|
request(checkUrlPathTermination(itemTemplate.item.url) + "sources?f=json", {
|
|
652
|
-
authentication: authentication
|
|
653
|
-
}).then(response => {
|
|
644
|
+
authentication: authentication,
|
|
645
|
+
}).then((response) => {
|
|
654
646
|
/* istanbul ignore else */
|
|
655
647
|
if (response && response.services) {
|
|
656
648
|
response.services.forEach((layer) => {
|
|
657
649
|
dependencies.push({
|
|
658
650
|
id: layer.serviceItemId,
|
|
659
|
-
name: layer.name
|
|
651
|
+
name: layer.name,
|
|
660
652
|
});
|
|
661
653
|
});
|
|
662
654
|
}
|
|
663
655
|
resolve(dependencies);
|
|
664
|
-
}, e => reject(fail(e)));
|
|
656
|
+
}, (e) => reject(fail(e)));
|
|
665
657
|
}
|
|
666
658
|
else if (isWorkforceProject(itemTemplate)) {
|
|
667
659
|
resolve(getWorkforceDependencies(itemTemplate, dependencies));
|
|
@@ -687,14 +679,14 @@ export function getLayers(serviceUrl, layerList, authentication) {
|
|
|
687
679
|
// get the admin URL
|
|
688
680
|
serviceUrl = serviceUrl.replace("/rest/services", "/rest/admin/services");
|
|
689
681
|
const requestsDfd = [];
|
|
690
|
-
layerList.forEach(layer => {
|
|
682
|
+
layerList.forEach((layer) => {
|
|
691
683
|
const requestOptions = {
|
|
692
|
-
authentication: authentication
|
|
684
|
+
authentication: authentication,
|
|
693
685
|
};
|
|
694
686
|
requestsDfd.push(request(checkUrlPathTermination(serviceUrl) + layer["id"] + "?f=json", requestOptions));
|
|
695
687
|
});
|
|
696
688
|
// Wait until all layers are heard from
|
|
697
|
-
Promise.all(requestsDfd).then(layers => resolve(layers), e => reject(fail(e)));
|
|
689
|
+
Promise.all(requestsDfd).then((layers) => resolve(layers), (e) => reject(fail(e)));
|
|
698
690
|
});
|
|
699
691
|
}
|
|
700
692
|
/**
|
|
@@ -711,7 +703,7 @@ export function getLayerUpdates(args, isPortal) {
|
|
|
711
703
|
const updates = [];
|
|
712
704
|
const refresh = _getUpdate(adminUrl, null, null, args, "refresh");
|
|
713
705
|
updates.push(refresh);
|
|
714
|
-
Object.keys(args.objects).forEach(id => {
|
|
706
|
+
Object.keys(args.objects).forEach((id) => {
|
|
715
707
|
const obj = Object.assign({}, args.objects[id]);
|
|
716
708
|
// These properties cannot be set in the update definition when working with portal
|
|
717
709
|
if (isPortal) {
|
|
@@ -733,7 +725,7 @@ export function getLayerUpdates(args, isPortal) {
|
|
|
733
725
|
message: "updated layer relationships",
|
|
734
726
|
objects: args.objects,
|
|
735
727
|
itemTemplate: args.itemTemplate,
|
|
736
|
-
authentication: args.authentication
|
|
728
|
+
authentication: args.authentication,
|
|
737
729
|
});
|
|
738
730
|
// issue: #724
|
|
739
731
|
// In portal the order the relationships are added needs to follow the layer order
|
|
@@ -749,11 +741,11 @@ export function getLayerUpdates(args, isPortal) {
|
|
|
749
741
|
message: "add layer contingent values",
|
|
750
742
|
objects: args.objects,
|
|
751
743
|
itemTemplate: args.itemTemplate,
|
|
752
|
-
authentication: args.authentication
|
|
744
|
+
authentication: args.authentication,
|
|
753
745
|
});
|
|
754
746
|
/* istanbul ignore else */
|
|
755
747
|
if (contingentValuesUpdates.length > 0) {
|
|
756
|
-
contingentValuesUpdates.forEach(conUpdate => {
|
|
748
|
+
contingentValuesUpdates.forEach((conUpdate) => {
|
|
757
749
|
updates.push(_getUpdate(adminUrl + conUpdate.id, null, conUpdate.contingentValues, args, "add"));
|
|
758
750
|
});
|
|
759
751
|
}
|
|
@@ -772,7 +764,7 @@ export async function moveItemToFolder(itemId, folderId, authentication) {
|
|
|
772
764
|
const moveOptions = {
|
|
773
765
|
itemId,
|
|
774
766
|
folderId,
|
|
775
|
-
authentication
|
|
767
|
+
authentication,
|
|
776
768
|
};
|
|
777
769
|
return portalMoveItem(moveOptions);
|
|
778
770
|
}
|
|
@@ -786,7 +778,7 @@ export async function moveItemToFolder(itemId, folderId, authentication) {
|
|
|
786
778
|
*/
|
|
787
779
|
export async function moveItemsToFolder(itemIds, folderId, authentication) {
|
|
788
780
|
const movePromises = new Array();
|
|
789
|
-
itemIds.forEach(itemId => {
|
|
781
|
+
itemIds.forEach((itemId) => {
|
|
790
782
|
movePromises.push(moveItemToFolder(itemId, folderId, authentication));
|
|
791
783
|
});
|
|
792
784
|
return Promise.all(movePromises);
|
|
@@ -806,7 +798,7 @@ export function _sortRelationships(layers, tables, relUpdates) {
|
|
|
806
798
|
// In portal the order the relationships are added needs to follow the layer order
|
|
807
799
|
// otherwise the relationship IDs will be reset
|
|
808
800
|
const _relUpdateLayers = [];
|
|
809
|
-
ids.forEach(id => {
|
|
801
|
+
ids.forEach((id) => {
|
|
810
802
|
relUpdates.layers.some((relUpdate) => {
|
|
811
803
|
if (id === relUpdate.id) {
|
|
812
804
|
_relUpdateLayers.push(relUpdate);
|
|
@@ -835,7 +827,7 @@ export function getRequest(update, skipRetry = false, useAsync = false) {
|
|
|
835
827
|
return new Promise((resolve, reject) => {
|
|
836
828
|
const options = {
|
|
837
829
|
params: update.params,
|
|
838
|
-
authentication: update.args.authentication
|
|
830
|
+
authentication: update.args.authentication,
|
|
839
831
|
};
|
|
840
832
|
/* istanbul ignore else */
|
|
841
833
|
if ((useAsync && update.url.indexOf("addToDefinition") > -1) ||
|
|
@@ -843,11 +835,11 @@ export function getRequest(update, skipRetry = false, useAsync = false) {
|
|
|
843
835
|
update.url.indexOf("deleteFromDefinition") > -1) {
|
|
844
836
|
options.params = { ...options.params, async: true };
|
|
845
837
|
}
|
|
846
|
-
request(update.url, options).then(result => {
|
|
847
|
-
checkRequestStatus(result, options.authentication).then(() => resolve(null), e => reject(fail(e)));
|
|
838
|
+
request(update.url, options).then((result) => {
|
|
839
|
+
checkRequestStatus(result, options.authentication).then(() => resolve(null), (e) => reject(fail(e)));
|
|
848
840
|
}, (e) => {
|
|
849
841
|
if (!skipRetry) {
|
|
850
|
-
getRequest(update, true, true).then(() => resolve(), e => reject(e));
|
|
842
|
+
getRequest(update, true, true).then(() => resolve(), (e) => reject(e));
|
|
851
843
|
}
|
|
852
844
|
else {
|
|
853
845
|
reject(e);
|
|
@@ -872,10 +864,10 @@ export function getServiceLayersAndTables(itemTemplate, authentication) {
|
|
|
872
864
|
const isWorkforceService = isWorkforceProject(itemTemplate);
|
|
873
865
|
// Get the service description
|
|
874
866
|
if (itemTemplate.item.url) {
|
|
875
|
-
getFeatureServiceProperties(itemTemplate.item.url, authentication, isWorkforceService).then(properties => {
|
|
867
|
+
getFeatureServiceProperties(itemTemplate.item.url, authentication, isWorkforceService).then((properties) => {
|
|
876
868
|
itemTemplate.properties = properties;
|
|
877
869
|
resolve(itemTemplate);
|
|
878
|
-
}, e => reject(fail(e)));
|
|
870
|
+
}, (e) => reject(fail(e)));
|
|
879
871
|
}
|
|
880
872
|
else {
|
|
881
873
|
resolve(itemTemplate);
|
|
@@ -896,21 +888,20 @@ export function getFeatureServiceProperties(serviceUrl, authentication, workforc
|
|
|
896
888
|
const properties = {
|
|
897
889
|
service: {},
|
|
898
890
|
layers: [],
|
|
899
|
-
tables: []
|
|
891
|
+
tables: [],
|
|
900
892
|
};
|
|
901
893
|
// get the admin URL
|
|
902
894
|
serviceUrl = serviceUrl.replace("/rest/services", "/rest/admin/services");
|
|
903
895
|
// Get the service description
|
|
904
896
|
request(serviceUrl + "?f=json", {
|
|
905
|
-
authentication: authentication
|
|
906
|
-
}).then(serviceData => {
|
|
897
|
+
authentication: authentication,
|
|
898
|
+
}).then((serviceData) => {
|
|
907
899
|
properties.service = _parseAdminServiceData(serviceData);
|
|
908
900
|
// Copy cacheMaxAge to top level so that AGO sees it when deploying the service
|
|
909
901
|
// serviceData may have set it if there isn't an adminServiceInfo
|
|
910
902
|
/* istanbul ignore else */
|
|
911
903
|
if (serviceData.adminServiceInfo?.cacheMaxAge) {
|
|
912
|
-
properties.service.cacheMaxAge =
|
|
913
|
-
serviceData.adminServiceInfo.cacheMaxAge;
|
|
904
|
+
properties.service.cacheMaxAge = serviceData.adminServiceInfo.cacheMaxAge;
|
|
914
905
|
}
|
|
915
906
|
// Move the layers and tables out of the service's data section
|
|
916
907
|
/* istanbul ignore else */
|
|
@@ -918,7 +909,7 @@ export function getFeatureServiceProperties(serviceUrl, authentication, workforc
|
|
|
918
909
|
properties.layers = serviceData.layers;
|
|
919
910
|
// Fill in properties that the service layer doesn't provide
|
|
920
911
|
// and remove properties that should not exist in the template
|
|
921
|
-
properties.layers.forEach(layer => {
|
|
912
|
+
properties.layers.forEach((layer) => {
|
|
922
913
|
layer.serviceItemId = properties.service.serviceItemId;
|
|
923
914
|
layer.extent = null;
|
|
924
915
|
removeLayerOptimization(layer);
|
|
@@ -929,7 +920,7 @@ export function getFeatureServiceProperties(serviceUrl, authentication, workforc
|
|
|
929
920
|
if (serviceData.tables) {
|
|
930
921
|
properties.tables = serviceData.tables;
|
|
931
922
|
// Fill in properties that the service layer doesn't provide
|
|
932
|
-
properties.tables.forEach(table => {
|
|
923
|
+
properties.tables.forEach((table) => {
|
|
933
924
|
table.serviceItemId = properties.service.serviceItemId;
|
|
934
925
|
table.extent = null;
|
|
935
926
|
});
|
|
@@ -962,13 +953,13 @@ export async function getWorkflowConfigurationZip(itemId, workflowBaseUrl, authe
|
|
|
962
953
|
return request(url, {
|
|
963
954
|
authentication,
|
|
964
955
|
headers: {
|
|
965
|
-
Accept: "application/octet-stream",
|
|
966
|
-
Authorization: `Bearer ${authentication.token}`,
|
|
967
|
-
"X-Esri-Authorization": `Bearer ${authentication.token}
|
|
956
|
+
"Accept": "application/octet-stream",
|
|
957
|
+
"Authorization": `Bearer ${authentication.token}`,
|
|
958
|
+
"X-Esri-Authorization": `Bearer ${authentication.token}`,
|
|
968
959
|
},
|
|
969
960
|
params: {
|
|
970
|
-
f: "zip"
|
|
971
|
-
}
|
|
961
|
+
f: "zip",
|
|
962
|
+
},
|
|
972
963
|
});
|
|
973
964
|
}
|
|
974
965
|
/**
|
|
@@ -986,13 +977,13 @@ export async function setWorkflowConfigurationZip(itemId, configurationZipFile,
|
|
|
986
977
|
return request(url, {
|
|
987
978
|
authentication,
|
|
988
979
|
headers: {
|
|
989
|
-
Accept: "application/octet-stream",
|
|
990
|
-
Authorization: `Bearer ${authentication.token}`,
|
|
991
|
-
"X-Esri-Authorization": `Bearer ${authentication.token}
|
|
980
|
+
"Accept": "application/octet-stream",
|
|
981
|
+
"Authorization": `Bearer ${authentication.token}`,
|
|
982
|
+
"X-Esri-Authorization": `Bearer ${authentication.token}`,
|
|
992
983
|
},
|
|
993
984
|
params: {
|
|
994
|
-
file: configurationZipFile
|
|
995
|
-
}
|
|
985
|
+
file: configurationZipFile,
|
|
986
|
+
},
|
|
996
987
|
});
|
|
997
988
|
}
|
|
998
989
|
/**
|
|
@@ -1006,10 +997,10 @@ export async function setWorkflowConfigurationZip(itemId, configurationZipFile,
|
|
|
1006
997
|
export function _parseAdminServiceData(adminData) {
|
|
1007
998
|
const layers = adminData.layers || [];
|
|
1008
999
|
const tables = adminData.tables || [];
|
|
1009
|
-
setCreateProp(adminData, "layers", layers.filter(l => l.type === "Feature Layer"));
|
|
1000
|
+
setCreateProp(adminData, "layers", layers.filter((l) => l.type === "Feature Layer"));
|
|
1010
1001
|
// TODO understand if the concat is necessary.
|
|
1011
1002
|
// Not sure if the admin api will ever actually return a tables collection here.
|
|
1012
|
-
setCreateProp(adminData, "tables", tables.concat(layers.filter(l => l.type === "Table")));
|
|
1003
|
+
setCreateProp(adminData, "tables", tables.concat(layers.filter((l) => l.type === "Table")));
|
|
1013
1004
|
return adminData;
|
|
1014
1005
|
}
|
|
1015
1006
|
/**
|
|
@@ -1021,9 +1012,7 @@ export function _parseAdminServiceData(adminData) {
|
|
|
1021
1012
|
*/
|
|
1022
1013
|
export function hasInvalidGroupDesignations(groupDesignations) {
|
|
1023
1014
|
const invalidGroupDesignations = ["livingatlas"];
|
|
1024
|
-
return groupDesignations
|
|
1025
|
-
? invalidGroupDesignations.indexOf(groupDesignations) > -1
|
|
1026
|
-
: false;
|
|
1015
|
+
return groupDesignations ? invalidGroupDesignations.indexOf(groupDesignations) > -1 : false;
|
|
1027
1016
|
}
|
|
1028
1017
|
/**
|
|
1029
1018
|
* Removes a folder from AGO.
|
|
@@ -1036,9 +1025,9 @@ export function removeFolder(folderId, authentication) {
|
|
|
1036
1025
|
return new Promise((resolve, reject) => {
|
|
1037
1026
|
const requestOptions = {
|
|
1038
1027
|
folderId: folderId,
|
|
1039
|
-
authentication: authentication
|
|
1028
|
+
authentication: authentication,
|
|
1040
1029
|
};
|
|
1041
|
-
portalRemoveFolder(requestOptions).then(result => (result.success ? resolve(result) : reject(result)), reject);
|
|
1030
|
+
portalRemoveFolder(requestOptions).then((result) => (result.success ? resolve(result) : reject(result)), reject);
|
|
1042
1031
|
});
|
|
1043
1032
|
}
|
|
1044
1033
|
/**
|
|
@@ -1052,9 +1041,9 @@ export function removeGroup(groupId, authentication) {
|
|
|
1052
1041
|
return new Promise((resolve, reject) => {
|
|
1053
1042
|
const requestOptions = {
|
|
1054
1043
|
id: groupId,
|
|
1055
|
-
authentication: authentication
|
|
1044
|
+
authentication: authentication,
|
|
1056
1045
|
};
|
|
1057
|
-
portalRemoveGroup(requestOptions).then(result => (result.success ? resolve(result) : reject(result)), reject);
|
|
1046
|
+
portalRemoveGroup(requestOptions).then((result) => (result.success ? resolve(result) : reject(result)), reject);
|
|
1058
1047
|
});
|
|
1059
1048
|
}
|
|
1060
1049
|
/**
|
|
@@ -1072,10 +1061,10 @@ export function removeItem(itemId, authentication, permanentDelete = true) {
|
|
|
1072
1061
|
id: itemId,
|
|
1073
1062
|
authentication: authentication,
|
|
1074
1063
|
params: {
|
|
1075
|
-
permanentDelete
|
|
1076
|
-
}
|
|
1064
|
+
permanentDelete,
|
|
1065
|
+
},
|
|
1077
1066
|
};
|
|
1078
|
-
portalRemoveItem(requestOptions).then(result => (result.success ? resolve(result) : reject(result)), reject);
|
|
1067
|
+
portalRemoveItem(requestOptions).then((result) => (result.success ? resolve(result) : reject(result)), reject);
|
|
1079
1068
|
});
|
|
1080
1069
|
}
|
|
1081
1070
|
/**
|
|
@@ -1089,7 +1078,7 @@ export function removeItem(itemId, authentication, permanentDelete = true) {
|
|
|
1089
1078
|
*/
|
|
1090
1079
|
export function removeItemOrGroup(itemId, authentication, permanentDelete = true) {
|
|
1091
1080
|
return new Promise((resolve, reject) => {
|
|
1092
|
-
removeItem(itemId, authentication, permanentDelete).then(resolve, error => {
|
|
1081
|
+
removeItem(itemId, authentication, permanentDelete).then(resolve, (error) => {
|
|
1093
1082
|
removeGroup(itemId, authentication).then(resolve, () => reject(error));
|
|
1094
1083
|
});
|
|
1095
1084
|
});
|
|
@@ -1116,16 +1105,18 @@ export function searchAllItems(search, accumulatedResponse) {
|
|
|
1116
1105
|
// Convert the search into an ISearchOptions
|
|
1117
1106
|
const searchOptions = convertToISearchOptions(search);
|
|
1118
1107
|
// Provide a base into which results can be concatenated
|
|
1119
|
-
const completeResponse = accumulatedResponse
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1108
|
+
const completeResponse = accumulatedResponse
|
|
1109
|
+
? accumulatedResponse
|
|
1110
|
+
: {
|
|
1111
|
+
query: searchOptions.q,
|
|
1112
|
+
start: 1,
|
|
1113
|
+
num: 100,
|
|
1114
|
+
nextStart: -1,
|
|
1115
|
+
total: 0,
|
|
1116
|
+
results: [],
|
|
1117
|
+
};
|
|
1127
1118
|
return new Promise((resolve, reject) => {
|
|
1128
|
-
searchItems(search).then(response => {
|
|
1119
|
+
searchItems(search).then((response) => {
|
|
1129
1120
|
completeResponse.results = completeResponse.results.concat(response.results);
|
|
1130
1121
|
completeResponse.num = completeResponse.total = completeResponse.results.length;
|
|
1131
1122
|
if (response.nextStart > 0) {
|
|
@@ -1136,7 +1127,7 @@ export function searchAllItems(search, accumulatedResponse) {
|
|
|
1136
1127
|
else {
|
|
1137
1128
|
resolve(completeResponse);
|
|
1138
1129
|
}
|
|
1139
|
-
}, e => reject(e));
|
|
1130
|
+
}, (e) => reject(e));
|
|
1140
1131
|
});
|
|
1141
1132
|
}
|
|
1142
1133
|
/**
|
|
@@ -1154,9 +1145,9 @@ export function searchGroups(searchString, authentication, additionalSearchOptio
|
|
|
1154
1145
|
const searchOptions = {
|
|
1155
1146
|
q: searchString,
|
|
1156
1147
|
params: {
|
|
1157
|
-
...additionalSearchOptions
|
|
1148
|
+
...additionalSearchOptions,
|
|
1158
1149
|
},
|
|
1159
|
-
authentication: authentication
|
|
1150
|
+
authentication: authentication,
|
|
1160
1151
|
};
|
|
1161
1152
|
return portalSearchGroups(searchOptions);
|
|
1162
1153
|
}
|
|
@@ -1171,19 +1162,21 @@ export function searchGroups(searchString, authentication, additionalSearchOptio
|
|
|
1171
1162
|
* @returns A promise that will resolve with all groups that meet the search criteria
|
|
1172
1163
|
*/
|
|
1173
1164
|
export function searchAllGroups(searchString, authentication, groups, inPagingParams) {
|
|
1174
|
-
const pagingParams = inPagingParams
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1165
|
+
const pagingParams = inPagingParams
|
|
1166
|
+
? inPagingParams
|
|
1167
|
+
: {
|
|
1168
|
+
start: 1,
|
|
1169
|
+
num: 24,
|
|
1170
|
+
};
|
|
1178
1171
|
const additionalSearchOptions = {
|
|
1179
1172
|
sortField: "title",
|
|
1180
1173
|
sortOrder: "asc",
|
|
1181
|
-
...pagingParams
|
|
1174
|
+
...pagingParams,
|
|
1182
1175
|
};
|
|
1183
1176
|
// Provide a base onto which results can be concatenated
|
|
1184
1177
|
let finalResults = groups ? groups : [];
|
|
1185
1178
|
return new Promise((resolve, reject) => {
|
|
1186
|
-
searchGroups(searchString, authentication, additionalSearchOptions).then(response => {
|
|
1179
|
+
searchGroups(searchString, authentication, additionalSearchOptions).then((response) => {
|
|
1187
1180
|
finalResults = finalResults.concat(response.results);
|
|
1188
1181
|
if (response.nextStart > 0) {
|
|
1189
1182
|
pagingParams.start = response.nextStart;
|
|
@@ -1192,7 +1185,7 @@ export function searchAllGroups(searchString, authentication, groups, inPagingPa
|
|
|
1192
1185
|
else {
|
|
1193
1186
|
resolve(finalResults);
|
|
1194
1187
|
}
|
|
1195
|
-
}, e => reject(e));
|
|
1188
|
+
}, (e) => reject(e));
|
|
1196
1189
|
});
|
|
1197
1190
|
}
|
|
1198
1191
|
/**
|
|
@@ -1213,20 +1206,22 @@ export function searchAllGroups(searchString, authentication, groups, inPagingPa
|
|
|
1213
1206
|
export function searchGroupAllContents(groupId, searchString, authentication, additionalSearchOptions, portalUrl, accumulatedResponse) {
|
|
1214
1207
|
additionalSearchOptions = additionalSearchOptions ? additionalSearchOptions : {};
|
|
1215
1208
|
// Provide a base into which results can be concatenated
|
|
1216
|
-
const completeResponse = accumulatedResponse
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1209
|
+
const completeResponse = accumulatedResponse
|
|
1210
|
+
? accumulatedResponse
|
|
1211
|
+
: {
|
|
1212
|
+
query: searchString,
|
|
1213
|
+
start: 1,
|
|
1214
|
+
num: 100,
|
|
1215
|
+
nextStart: -1,
|
|
1216
|
+
total: 0,
|
|
1217
|
+
results: [],
|
|
1218
|
+
};
|
|
1224
1219
|
// Remove the sortField if it's "relevance"; that's the default option and is not meant to be specified
|
|
1225
1220
|
if (additionalSearchOptions.sortField === "relevance") {
|
|
1226
1221
|
delete additionalSearchOptions.sortField;
|
|
1227
1222
|
}
|
|
1228
1223
|
return new Promise((resolve, reject) => {
|
|
1229
|
-
searchGroupContents(groupId, searchString, authentication, additionalSearchOptions, portalUrl).then(response => {
|
|
1224
|
+
searchGroupContents(groupId, searchString, authentication, additionalSearchOptions, portalUrl).then((response) => {
|
|
1230
1225
|
completeResponse.results = completeResponse.results.concat(response.results);
|
|
1231
1226
|
completeResponse.num = completeResponse.total = completeResponse.results.length;
|
|
1232
1227
|
if (response.nextStart > 0) {
|
|
@@ -1236,7 +1231,7 @@ export function searchGroupAllContents(groupId, searchString, authentication, ad
|
|
|
1236
1231
|
else {
|
|
1237
1232
|
resolve(completeResponse);
|
|
1238
1233
|
}
|
|
1239
|
-
}, e => reject(e));
|
|
1234
|
+
}, (e) => reject(e));
|
|
1240
1235
|
});
|
|
1241
1236
|
}
|
|
1242
1237
|
/**
|
|
@@ -1258,15 +1253,15 @@ export function searchGroupContents(groupId, searchString, authentication, addit
|
|
|
1258
1253
|
groupId,
|
|
1259
1254
|
q: searchString,
|
|
1260
1255
|
params: Object.assign({
|
|
1261
|
-
num: 100
|
|
1256
|
+
num: 100,
|
|
1262
1257
|
}, additionalSearchOptions),
|
|
1263
1258
|
authentication: authentication,
|
|
1264
|
-
portal: portalUrl
|
|
1259
|
+
portal: portalUrl,
|
|
1265
1260
|
};
|
|
1266
1261
|
// If search options include `categories`, switch to new arcgis-rest-js format
|
|
1267
1262
|
/* istanbul ignore else */
|
|
1268
1263
|
if (Array.isArray(searchOptions.params.categories)) {
|
|
1269
|
-
searchOptions.params.categories = searchOptions.params.categories.map(andGroup => andGroup.split(","));
|
|
1264
|
+
searchOptions.params.categories = searchOptions.params.categories.map((andGroup) => andGroup.split(","));
|
|
1270
1265
|
}
|
|
1271
1266
|
return searchGroupContent(searchOptions);
|
|
1272
1267
|
}
|
|
@@ -1284,8 +1279,8 @@ export function reassignGroup(groupId, userName, authentication) {
|
|
|
1284
1279
|
const requestOptions = {
|
|
1285
1280
|
authentication: authentication,
|
|
1286
1281
|
params: {
|
|
1287
|
-
targetUsername: userName
|
|
1288
|
-
}
|
|
1282
|
+
targetUsername: userName,
|
|
1283
|
+
},
|
|
1289
1284
|
};
|
|
1290
1285
|
return request(`${authentication.portal}/community/groups/${groupId}/reassign`, requestOptions);
|
|
1291
1286
|
}
|
|
@@ -1303,7 +1298,7 @@ export function removeUsers(groupId, users, authentication) {
|
|
|
1303
1298
|
return portalRemoveGroupUsers({
|
|
1304
1299
|
id: groupId,
|
|
1305
1300
|
users,
|
|
1306
|
-
authentication
|
|
1301
|
+
authentication,
|
|
1307
1302
|
});
|
|
1308
1303
|
}
|
|
1309
1304
|
/**
|
|
@@ -1322,7 +1317,7 @@ export function shareItem(groupId, id, destinationAuthentication, owner) {
|
|
|
1322
1317
|
const shareOptions = {
|
|
1323
1318
|
groupId,
|
|
1324
1319
|
id,
|
|
1325
|
-
authentication: destinationAuthentication
|
|
1320
|
+
authentication: destinationAuthentication,
|
|
1326
1321
|
};
|
|
1327
1322
|
/* istanbul ignore else */
|
|
1328
1323
|
if (owner) {
|
|
@@ -1348,10 +1343,10 @@ export function updateItem(itemInfo, authentication, folderId, additionalParams)
|
|
|
1348
1343
|
folderId: folderId,
|
|
1349
1344
|
authentication: authentication,
|
|
1350
1345
|
params: {
|
|
1351
|
-
...(additionalParams ?? {})
|
|
1352
|
-
}
|
|
1346
|
+
...(additionalParams ?? {}),
|
|
1347
|
+
},
|
|
1353
1348
|
};
|
|
1354
|
-
portalUpdateItem(updateOptions).then(response => (response.success ? resolve(response) : reject(response)), err => reject(err));
|
|
1349
|
+
portalUpdateItem(updateOptions).then((response) => (response.success ? resolve(response) : reject(response)), (err) => reject(err));
|
|
1355
1350
|
});
|
|
1356
1351
|
}
|
|
1357
1352
|
/**
|
|
@@ -1369,10 +1364,10 @@ export function updateGroup(groupInfo, authentication, additionalParams) {
|
|
|
1369
1364
|
group: groupInfo,
|
|
1370
1365
|
authentication,
|
|
1371
1366
|
params: {
|
|
1372
|
-
...(additionalParams ?? {})
|
|
1373
|
-
}
|
|
1367
|
+
...(additionalParams ?? {}),
|
|
1368
|
+
},
|
|
1374
1369
|
};
|
|
1375
|
-
portalUpdateGroup(updateOptions).then(response => (response.success ? resolve(response) : reject(response)), err => reject(err));
|
|
1370
|
+
portalUpdateGroup(updateOptions).then((response) => (response.success ? resolve(response) : reject(response)), (err) => reject(err));
|
|
1376
1371
|
});
|
|
1377
1372
|
}
|
|
1378
1373
|
/**
|
|
@@ -1390,9 +1385,9 @@ export function updateItemExtended(itemInfo, data, authentication, thumbnail, ac
|
|
|
1390
1385
|
const updateOptions = {
|
|
1391
1386
|
item: itemInfo,
|
|
1392
1387
|
params: {
|
|
1393
|
-
text: data || {} // AGO ignores update if `data` is empty
|
|
1388
|
+
text: data || {}, // AGO ignores update if `data` is empty
|
|
1394
1389
|
},
|
|
1395
|
-
authentication: authentication
|
|
1390
|
+
authentication: authentication,
|
|
1396
1391
|
};
|
|
1397
1392
|
if (thumbnail) {
|
|
1398
1393
|
updateOptions.params.thumbnail = thumbnail;
|
|
@@ -1400,21 +1395,21 @@ export function updateItemExtended(itemInfo, data, authentication, thumbnail, ac
|
|
|
1400
1395
|
if (isTrackingViewTemplate(undefined, itemInfo) && templateDictionary) {
|
|
1401
1396
|
updateOptions.owner = templateDictionary.locationTracking.owner;
|
|
1402
1397
|
}
|
|
1403
|
-
portalUpdateItem(updateOptions).then(result => {
|
|
1398
|
+
portalUpdateItem(updateOptions).then((result) => {
|
|
1404
1399
|
if (access && access !== "private") {
|
|
1405
1400
|
// Set access if it is not AGOL default
|
|
1406
1401
|
// Set the access manually since the access value in createItem appears to be ignored
|
|
1407
1402
|
const accessOptions = {
|
|
1408
1403
|
id: itemInfo.id,
|
|
1409
1404
|
access: access === "public" ? "public" : "org",
|
|
1410
|
-
authentication: authentication
|
|
1405
|
+
authentication: authentication,
|
|
1411
1406
|
};
|
|
1412
|
-
setItemAccess(accessOptions).then(() => resolve(result), e => reject(fail(e)));
|
|
1407
|
+
setItemAccess(accessOptions).then(() => resolve(result), (e) => reject(fail(e)));
|
|
1413
1408
|
}
|
|
1414
1409
|
else {
|
|
1415
1410
|
resolve(result);
|
|
1416
1411
|
}
|
|
1417
|
-
}, e => reject(fail(e)));
|
|
1412
|
+
}, (e) => reject(fail(e)));
|
|
1418
1413
|
});
|
|
1419
1414
|
}
|
|
1420
1415
|
/**
|
|
@@ -1428,10 +1423,7 @@ export function updateItemExtended(itemInfo, data, authentication, thumbnail, ac
|
|
|
1428
1423
|
export function updateItemTemplateFromDictionary(itemId, templateDictionary, authentication) {
|
|
1429
1424
|
return new Promise((resolve, reject) => {
|
|
1430
1425
|
// Fetch the items as stored in AGO
|
|
1431
|
-
Promise.all([
|
|
1432
|
-
getItemBase(itemId, authentication),
|
|
1433
|
-
getItemDataAsJson(itemId, authentication)
|
|
1434
|
-
])
|
|
1426
|
+
Promise.all([getItemBase(itemId, authentication), getItemDataAsJson(itemId, authentication)])
|
|
1435
1427
|
.then(([item, data]) => {
|
|
1436
1428
|
// Do they have any variables?
|
|
1437
1429
|
if (hasUnresolvedVariables(item) || hasUnresolvedVariables(data)) {
|
|
@@ -1444,12 +1436,12 @@ export function updateItemTemplateFromDictionary(itemId, templateDictionary, aut
|
|
|
1444
1436
|
// Shortcut out if not
|
|
1445
1437
|
return Promise.resolve({
|
|
1446
1438
|
success: true,
|
|
1447
|
-
id: itemId
|
|
1439
|
+
id: itemId,
|
|
1448
1440
|
});
|
|
1449
1441
|
}
|
|
1450
1442
|
})
|
|
1451
|
-
.then(result => resolve(result))
|
|
1452
|
-
.catch(error => reject(error));
|
|
1443
|
+
.then((result) => resolve(result))
|
|
1444
|
+
.catch((error) => reject(error));
|
|
1453
1445
|
});
|
|
1454
1446
|
}
|
|
1455
1447
|
/**
|
|
@@ -1505,13 +1497,13 @@ export function _addItemMetadataFile(itemId, metadataFile, authentication) {
|
|
|
1505
1497
|
return new Promise((resolve, reject) => {
|
|
1506
1498
|
const addMetadataOptions = {
|
|
1507
1499
|
item: {
|
|
1508
|
-
id: itemId
|
|
1500
|
+
id: itemId,
|
|
1509
1501
|
},
|
|
1510
1502
|
params: {
|
|
1511
1503
|
// Pass metadata in via params because item property is serialized, which discards a blob
|
|
1512
|
-
metadata: metadataFile
|
|
1504
|
+
metadata: metadataFile,
|
|
1513
1505
|
},
|
|
1514
|
-
authentication: authentication
|
|
1506
|
+
authentication: authentication,
|
|
1515
1507
|
};
|
|
1516
1508
|
portalUpdateItem(addMetadataOptions).then(resolve, reject);
|
|
1517
1509
|
});
|
|
@@ -1524,8 +1516,7 @@ export function _addItemMetadataFile(itemId, metadataFile, authentication) {
|
|
|
1524
1516
|
* @private
|
|
1525
1517
|
*/
|
|
1526
1518
|
export function _countRelationships(layers) {
|
|
1527
|
-
const reducer = (accumulator, currentLayer) => accumulator +
|
|
1528
|
-
(currentLayer.relationships ? currentLayer.relationships.length : 0);
|
|
1519
|
+
const reducer = (accumulator, currentLayer) => accumulator + (currentLayer.relationships ? currentLayer.relationships.length : 0);
|
|
1529
1520
|
return layers.reduce(reducer, 0);
|
|
1530
1521
|
}
|
|
1531
1522
|
/**
|
|
@@ -1548,23 +1539,23 @@ export function _getCreateServiceOptions(newItemTemplate, authentication, templa
|
|
|
1548
1539
|
const params = {};
|
|
1549
1540
|
const itemInfo = {
|
|
1550
1541
|
title: newItemTemplate.item.title,
|
|
1551
|
-
name: newItemTemplate.item.name
|
|
1542
|
+
name: newItemTemplate.item.name,
|
|
1552
1543
|
};
|
|
1553
1544
|
const _item = {
|
|
1554
1545
|
...itemInfo,
|
|
1555
|
-
preserveLayerIds: true
|
|
1546
|
+
preserveLayerIds: true,
|
|
1556
1547
|
};
|
|
1557
1548
|
const createOptions = {
|
|
1558
1549
|
item: _item,
|
|
1559
1550
|
folderId,
|
|
1560
1551
|
params,
|
|
1561
|
-
authentication: authentication
|
|
1552
|
+
authentication: authentication,
|
|
1562
1553
|
};
|
|
1563
|
-
createOptions.item = !isTrackingViewTemplate(newItemTemplate)
|
|
1564
|
-
_setItemProperties(createOptions.item, newItemTemplate, serviceInfo, params, isPortal)
|
|
1565
|
-
setTrackingOptions(newItemTemplate, createOptions, templateDictionary);
|
|
1554
|
+
createOptions.item = !isTrackingViewTemplate(newItemTemplate)
|
|
1555
|
+
? _setItemProperties(createOptions.item, newItemTemplate, serviceInfo, params, isPortal)
|
|
1556
|
+
: setTrackingOptions(newItemTemplate, createOptions, templateDictionary);
|
|
1566
1557
|
// project the portals extent to match that of the service
|
|
1567
|
-
convertExtentWithFallback(templateDictionary.organization.defaultExtent, fallbackExtent, serviceInfo.service.spatialReference, templateDictionary.organization.helperServices.geometry.url, authentication).then(extent => {
|
|
1558
|
+
convertExtentWithFallback(templateDictionary.organization.defaultExtent, fallbackExtent, serviceInfo.service.spatialReference, templateDictionary.organization.helperServices.geometry.url, authentication).then((extent) => {
|
|
1568
1559
|
templateDictionary[itemId].solutionExtent = extent;
|
|
1569
1560
|
setDefaultSpatialReference(templateDictionary, itemId, extent.spatialReference);
|
|
1570
1561
|
createOptions.item = replaceInTemplate(createOptions.item, templateDictionary);
|
|
@@ -1574,7 +1565,7 @@ export function _getCreateServiceOptions(newItemTemplate, authentication, templa
|
|
|
1574
1565
|
createOptions.params.thumbnail = newItemTemplate.item.thumbnail;
|
|
1575
1566
|
}
|
|
1576
1567
|
resolve(createOptions);
|
|
1577
|
-
}, e => reject(fail(e)));
|
|
1568
|
+
}, (e) => reject(fail(e)));
|
|
1578
1569
|
});
|
|
1579
1570
|
}
|
|
1580
1571
|
/**
|
|
@@ -1608,7 +1599,7 @@ export function _getFallbackExtent(serviceInfo, templateDictionary) {
|
|
|
1608
1599
|
*/
|
|
1609
1600
|
export function _getRelationshipUpdates(args) {
|
|
1610
1601
|
const rels = {
|
|
1611
|
-
layers: []
|
|
1602
|
+
layers: [],
|
|
1612
1603
|
};
|
|
1613
1604
|
Object.keys(args.objects).forEach((k) => {
|
|
1614
1605
|
const obj = args.objects[k];
|
|
@@ -1616,7 +1607,7 @@ export function _getRelationshipUpdates(args) {
|
|
|
1616
1607
|
if (obj.relationships && obj.relationships.length > 0) {
|
|
1617
1608
|
rels.layers.push({
|
|
1618
1609
|
id: obj.id,
|
|
1619
|
-
relationships: obj.relationships
|
|
1610
|
+
relationships: obj.relationships,
|
|
1620
1611
|
});
|
|
1621
1612
|
}
|
|
1622
1613
|
deleteProp(obj, "relationships");
|
|
@@ -1638,7 +1629,7 @@ export function _getContingentValuesUpdates(args) {
|
|
|
1638
1629
|
if (obj.contingentValues) {
|
|
1639
1630
|
contingentValues.push({
|
|
1640
1631
|
id: obj.id,
|
|
1641
|
-
contingentValues: obj.contingentValues
|
|
1632
|
+
contingentValues: obj.contingentValues,
|
|
1642
1633
|
});
|
|
1643
1634
|
}
|
|
1644
1635
|
deleteProp(obj, "contingentValues");
|
|
@@ -1662,34 +1653,33 @@ export function _getUpdate(url, id, obj, args, type) {
|
|
|
1662
1653
|
url: checkUrlPathTermination(url) + id + "/deleteFromDefinition",
|
|
1663
1654
|
params: {
|
|
1664
1655
|
deleteFromDefinition: {
|
|
1665
|
-
fields: obj && obj.hasOwnProperty("deleteFields") ? obj.deleteFields : []
|
|
1666
|
-
}
|
|
1667
|
-
}
|
|
1656
|
+
fields: obj && obj.hasOwnProperty("deleteFields") ? obj.deleteFields : [],
|
|
1657
|
+
},
|
|
1658
|
+
},
|
|
1668
1659
|
},
|
|
1669
1660
|
update: {
|
|
1670
|
-
url: checkUrlPathTermination(url) +
|
|
1671
|
-
(id ? `${id}/updateDefinition` : "updateDefinition"),
|
|
1661
|
+
url: checkUrlPathTermination(url) + (id ? `${id}/updateDefinition` : "updateDefinition"),
|
|
1672
1662
|
params: {
|
|
1673
|
-
updateDefinition: obj
|
|
1674
|
-
}
|
|
1663
|
+
updateDefinition: obj,
|
|
1664
|
+
},
|
|
1675
1665
|
},
|
|
1676
1666
|
add: {
|
|
1677
1667
|
url: checkUrlPathTermination(url) + "addToDefinition",
|
|
1678
1668
|
params: {
|
|
1679
|
-
addToDefinition: obj
|
|
1680
|
-
}
|
|
1669
|
+
addToDefinition: obj,
|
|
1670
|
+
},
|
|
1681
1671
|
},
|
|
1682
1672
|
refresh: {
|
|
1683
1673
|
url: checkUrlPathTermination(url) + "refresh",
|
|
1684
1674
|
params: {
|
|
1685
|
-
f: "json"
|
|
1686
|
-
}
|
|
1687
|
-
}
|
|
1675
|
+
f: "json",
|
|
1676
|
+
},
|
|
1677
|
+
},
|
|
1688
1678
|
};
|
|
1689
1679
|
return {
|
|
1690
1680
|
url: ops[type].url,
|
|
1691
1681
|
params: ops[type].params,
|
|
1692
|
-
args: args
|
|
1682
|
+
args: args,
|
|
1693
1683
|
};
|
|
1694
1684
|
}
|
|
1695
1685
|
/**
|
|
@@ -1725,19 +1715,11 @@ export function _reportVariablesInItem(itemId, itemType, base, data) {
|
|
|
1725
1715
|
// Provide feedback about any remaining unresolved variables
|
|
1726
1716
|
/* istanbul ignore else */
|
|
1727
1717
|
if (base && hasUnresolvedVariables(base)) {
|
|
1728
|
-
console.log(itemId +
|
|
1729
|
-
" (" +
|
|
1730
|
-
itemType +
|
|
1731
|
-
") contains variables in base: " +
|
|
1732
|
-
JSON.stringify(getUnresolved(base)));
|
|
1718
|
+
console.log(itemId + " (" + itemType + ") contains variables in base: " + JSON.stringify(getUnresolved(base)));
|
|
1733
1719
|
}
|
|
1734
1720
|
/* istanbul ignore else */
|
|
1735
1721
|
if (data && hasUnresolvedVariables(data)) {
|
|
1736
|
-
console.log(itemId +
|
|
1737
|
-
" (" +
|
|
1738
|
-
itemType +
|
|
1739
|
-
") contains variables in data: " +
|
|
1740
|
-
JSON.stringify(getUnresolved(data)));
|
|
1722
|
+
console.log(itemId + " (" + itemType + ") contains variables in data: " + JSON.stringify(getUnresolved(data)));
|
|
1741
1723
|
}
|
|
1742
1724
|
}
|
|
1743
1725
|
/**
|
|
@@ -1753,16 +1735,7 @@ export function _reportVariablesInItem(itemId, itemType, base, data) {
|
|
|
1753
1735
|
*/
|
|
1754
1736
|
export function _setItemProperties(item, itemTemplate, serviceInfo, params, isPortal) {
|
|
1755
1737
|
// Set the capabilities
|
|
1756
|
-
const portalCapabilities = [
|
|
1757
|
-
"Create",
|
|
1758
|
-
"Query",
|
|
1759
|
-
"Editing",
|
|
1760
|
-
"Update",
|
|
1761
|
-
"Delete",
|
|
1762
|
-
"Uploads",
|
|
1763
|
-
"Sync",
|
|
1764
|
-
"Extract"
|
|
1765
|
-
];
|
|
1738
|
+
const portalCapabilities = ["Create", "Query", "Editing", "Update", "Delete", "Uploads", "Sync", "Extract"];
|
|
1766
1739
|
const capabilities = getProp(serviceInfo, "service.capabilities") || (isPortal ? "" : []);
|
|
1767
1740
|
item.capabilities = isPortal
|
|
1768
1741
|
? capabilities
|
|
@@ -1782,7 +1755,7 @@ export function _setItemProperties(item, itemTemplate, serviceInfo, params, isPo
|
|
|
1782
1755
|
"sourceSchemaChangesAllowed",
|
|
1783
1756
|
"isUpdatableView",
|
|
1784
1757
|
"capabilities",
|
|
1785
|
-
"isMultiServicesView"
|
|
1758
|
+
"isMultiServicesView",
|
|
1786
1759
|
];
|
|
1787
1760
|
const deleteKeys = ["layers", "tables"];
|
|
1788
1761
|
/* istanbul ignore else */
|
|
@@ -1792,7 +1765,7 @@ export function _setItemProperties(item, itemTemplate, serviceInfo, params, isPo
|
|
|
1792
1765
|
}
|
|
1793
1766
|
const itemKeys = Object.keys(item);
|
|
1794
1767
|
const serviceKeys = Object.keys(serviceInfo.service);
|
|
1795
|
-
serviceKeys.forEach(k => {
|
|
1768
|
+
serviceKeys.forEach((k) => {
|
|
1796
1769
|
/* istanbul ignore else */
|
|
1797
1770
|
if (itemKeys.indexOf(k) === -1 && deleteKeys.indexOf(k) < 0) {
|
|
1798
1771
|
item[k] = serviceInfo.service[k];
|
|
@@ -1806,8 +1779,7 @@ export function _setItemProperties(item, itemTemplate, serviceInfo, params, isPo
|
|
|
1806
1779
|
});
|
|
1807
1780
|
// Enable editor tracking on layer with related tables is not supported.
|
|
1808
1781
|
/* istanbul ignore else */
|
|
1809
|
-
if (item.isMultiServicesView &&
|
|
1810
|
-
getProp(item, "editorTrackingInfo.enableEditorTracking")) {
|
|
1782
|
+
if (item.isMultiServicesView && getProp(item, "editorTrackingInfo.enableEditorTracking")) {
|
|
1811
1783
|
item.editorTrackingInfo.enableEditorTracking = false;
|
|
1812
1784
|
params["editorTrackingInfo"] = item.editorTrackingInfo;
|
|
1813
1785
|
}
|
|
@@ -1816,8 +1788,7 @@ export function _setItemProperties(item, itemTemplate, serviceInfo, params, isPo
|
|
|
1816
1788
|
// portal will fail when initialExtent is defined but null
|
|
1817
1789
|
// removed for issue #449 causing FS to fail to create on portal
|
|
1818
1790
|
/* istanbul ignore else */
|
|
1819
|
-
if (Object.keys(item).indexOf("initialExtent") > -1 &&
|
|
1820
|
-
!item.initialExtent) {
|
|
1791
|
+
if (Object.keys(item).indexOf("initialExtent") > -1 && !item.initialExtent) {
|
|
1821
1792
|
deleteProp(item, "initialExtent");
|
|
1822
1793
|
}
|
|
1823
1794
|
}
|
|
@@ -1831,26 +1802,21 @@ export function _setItemProperties(item, itemTemplate, serviceInfo, params, isPo
|
|
|
1831
1802
|
*/
|
|
1832
1803
|
export function _updateIndexesForRelationshipKeyFields(serviceInfo) {
|
|
1833
1804
|
const layersAndTables = (serviceInfo.layers || []).concat(serviceInfo.tables || []);
|
|
1834
|
-
layersAndTables.forEach(item => {
|
|
1805
|
+
layersAndTables.forEach((item) => {
|
|
1835
1806
|
const relationships = item.relationships;
|
|
1836
1807
|
const indexes = item.indexes;
|
|
1837
1808
|
/* istanbul ignore else */
|
|
1838
|
-
if (relationships &&
|
|
1839
|
-
relationships.length > 0 &&
|
|
1840
|
-
indexes &&
|
|
1841
|
-
indexes.length > 0) {
|
|
1809
|
+
if (relationships && relationships.length > 0 && indexes && indexes.length > 0) {
|
|
1842
1810
|
const keyFields = relationships.reduce((acc, v) => {
|
|
1843
1811
|
/* istanbul ignore else */
|
|
1844
|
-
if (v.role === "esriRelRoleOrigin" &&
|
|
1845
|
-
v.keyField &&
|
|
1846
|
-
acc.indexOf(v.keyField) < 0) {
|
|
1812
|
+
if (v.role === "esriRelRoleOrigin" && v.keyField && acc.indexOf(v.keyField) < 0) {
|
|
1847
1813
|
acc.push(v.keyField);
|
|
1848
1814
|
}
|
|
1849
1815
|
return acc;
|
|
1850
1816
|
}, []);
|
|
1851
|
-
indexes.map(i => {
|
|
1817
|
+
indexes.map((i) => {
|
|
1852
1818
|
/* istanbul ignore else */
|
|
1853
|
-
if (keyFields.some(k => {
|
|
1819
|
+
if (keyFields.some((k) => {
|
|
1854
1820
|
const regEx = new RegExp(`\\b${k}\\b`);
|
|
1855
1821
|
return regEx.test(i.fields);
|
|
1856
1822
|
})) {
|
|
@@ -1878,7 +1844,7 @@ export function _updateItemURL(id, url, authentication, numAttempts = 1) {
|
|
|
1878
1844
|
return new Promise((resolve, reject) => {
|
|
1879
1845
|
// Update the item's URL
|
|
1880
1846
|
const options = { item: { id, url }, authentication: authentication };
|
|
1881
|
-
portalUpdateItem(options).then(result => {
|
|
1847
|
+
portalUpdateItem(options).then((result) => {
|
|
1882
1848
|
if (!result.success) {
|
|
1883
1849
|
reject(fail(result));
|
|
1884
1850
|
}
|
|
@@ -1886,7 +1852,7 @@ export function _updateItemURL(id, url, authentication, numAttempts = 1) {
|
|
|
1886
1852
|
// Get the item to see if the URL really changed; we'll delay a bit before testing because AGO
|
|
1887
1853
|
// has a timing problem with URL updates
|
|
1888
1854
|
setTimeout(() => {
|
|
1889
|
-
getItem(id, { authentication: authentication }).then(item => {
|
|
1855
|
+
getItem(id, { authentication: authentication }).then((item) => {
|
|
1890
1856
|
const iBrace = item.url.indexOf("{");
|
|
1891
1857
|
if (iBrace > -1) {
|
|
1892
1858
|
console.warn(id + " has template variable: " + item.url.substr(iBrace));
|
|
@@ -1896,15 +1862,7 @@ export function _updateItemURL(id, url, authentication, numAttempts = 1) {
|
|
|
1896
1862
|
}
|
|
1897
1863
|
else {
|
|
1898
1864
|
// If it fails, try again if we have sufficient attempts remaining
|
|
1899
|
-
const errorMsg = "URL not updated for " +
|
|
1900
|
-
item.type +
|
|
1901
|
-
" " +
|
|
1902
|
-
item.id +
|
|
1903
|
-
": " +
|
|
1904
|
-
item.url +
|
|
1905
|
-
" (" +
|
|
1906
|
-
numAttempts +
|
|
1907
|
-
")";
|
|
1865
|
+
const errorMsg = "URL not updated for " + item.type + " " + item.id + ": " + item.url + " (" + numAttempts + ")";
|
|
1908
1866
|
if (--numAttempts > 0) {
|
|
1909
1867
|
_updateItemURL(id, url, authentication, numAttempts).then(resolve, reject);
|
|
1910
1868
|
}
|
|
@@ -1913,10 +1871,10 @@ export function _updateItemURL(id, url, authentication, numAttempts = 1) {
|
|
|
1913
1871
|
reject(errorMsg);
|
|
1914
1872
|
}
|
|
1915
1873
|
}
|
|
1916
|
-
}, e => reject(fail(e)));
|
|
1874
|
+
}, (e) => reject(fail(e)));
|
|
1917
1875
|
}, msLag);
|
|
1918
1876
|
}
|
|
1919
|
-
}, e => reject(fail(e)));
|
|
1877
|
+
}, (e) => reject(fail(e)));
|
|
1920
1878
|
});
|
|
1921
1879
|
}
|
|
1922
1880
|
//# sourceMappingURL=restHelpers.js.map
|