@esri/solution-common 5.5.0 → 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 +6 -8
- package/package.json +13 -13
package/dist/cjs/restHelpers.js
CHANGED
|
@@ -41,12 +41,11 @@ function addItemData(id, data, authentication) {
|
|
|
41
41
|
const addDataOptions = {
|
|
42
42
|
id,
|
|
43
43
|
data,
|
|
44
|
-
authentication
|
|
44
|
+
authentication,
|
|
45
45
|
};
|
|
46
46
|
return (0, arcgis_rest_portal_1.addItemData)(addDataOptions);
|
|
47
47
|
}
|
|
48
48
|
exports.addItemData = addItemData;
|
|
49
|
-
;
|
|
50
49
|
/**
|
|
51
50
|
* Creates a UserSession via a function so that the global arcgisSolution variable can access authentication.
|
|
52
51
|
*
|
|
@@ -67,22 +66,22 @@ exports.getUserSession = getUserSession;
|
|
|
67
66
|
* @returns A Promise to add item resources.
|
|
68
67
|
*/
|
|
69
68
|
function addForwardItemRelationship(originItemId, destinationItemId, relationshipType, authentication) {
|
|
70
|
-
return new Promise(resolve => {
|
|
69
|
+
return new Promise((resolve) => {
|
|
71
70
|
const requestOptions = {
|
|
72
71
|
originItemId,
|
|
73
72
|
destinationItemId,
|
|
74
73
|
relationshipType,
|
|
75
|
-
authentication
|
|
74
|
+
authentication,
|
|
76
75
|
};
|
|
77
|
-
(0, arcgis_rest_portal_1.addItemRelationship)(requestOptions).then(response => {
|
|
76
|
+
(0, arcgis_rest_portal_1.addItemRelationship)(requestOptions).then((response) => {
|
|
78
77
|
resolve({
|
|
79
78
|
success: response.success,
|
|
80
|
-
itemId: originItemId
|
|
79
|
+
itemId: originItemId,
|
|
81
80
|
});
|
|
82
81
|
}, () => {
|
|
83
82
|
resolve({
|
|
84
83
|
success: false,
|
|
85
|
-
itemId: originItemId
|
|
84
|
+
itemId: originItemId,
|
|
86
85
|
});
|
|
87
86
|
});
|
|
88
87
|
});
|
|
@@ -97,11 +96,11 @@ exports.addForwardItemRelationship = addForwardItemRelationship;
|
|
|
97
96
|
* @returns A Promise to add item resources.
|
|
98
97
|
*/
|
|
99
98
|
function addForwardItemRelationships(originItemId, destinationRelationships, authentication) {
|
|
100
|
-
return new Promise(resolve => {
|
|
99
|
+
return new Promise((resolve) => {
|
|
101
100
|
// Set up relationships using updated relationship information
|
|
102
101
|
const relationshipPromises = new Array();
|
|
103
|
-
destinationRelationships.forEach(relationship => {
|
|
104
|
-
relationship.relatedItemIds.forEach(relatedItemId => {
|
|
102
|
+
destinationRelationships.forEach((relationship) => {
|
|
103
|
+
relationship.relatedItemIds.forEach((relatedItemId) => {
|
|
105
104
|
relationshipPromises.push(addForwardItemRelationship(originItemId, relatedItemId, relationship.relationshipType, authentication));
|
|
106
105
|
});
|
|
107
106
|
});
|
|
@@ -119,12 +118,12 @@ exports.addForwardItemRelationships = addForwardItemRelationships;
|
|
|
119
118
|
* unless either the URL doesn't exist or the token can't be generated
|
|
120
119
|
*/
|
|
121
120
|
function addTokenToUrl(url, authentication) {
|
|
122
|
-
return new Promise(resolve => {
|
|
121
|
+
return new Promise((resolve) => {
|
|
123
122
|
if (!url || !authentication) {
|
|
124
123
|
resolve(url);
|
|
125
124
|
}
|
|
126
125
|
else {
|
|
127
|
-
authentication.getToken(url).then(token => {
|
|
126
|
+
authentication.getToken(url).then((token) => {
|
|
128
127
|
/* istanbul ignore else */
|
|
129
128
|
if (token) {
|
|
130
129
|
url = (0, generalHelpers_1.appendQueryParam)(url, "token=" + token);
|
|
@@ -155,10 +154,10 @@ function addToServiceDefinition(url, options, skipRetry = false, useAsync = fals
|
|
|
155
154
|
}
|
|
156
155
|
return new Promise((resolve, reject) => {
|
|
157
156
|
(0, arcgis_rest_service_admin_1.addToServiceDefinition)(url, options).then((result) => {
|
|
158
|
-
checkRequestStatus(result, options.authentication).then(() => resolve(null), e => reject((0, generalHelpers_1.fail)(e)));
|
|
159
|
-
}, e => {
|
|
157
|
+
checkRequestStatus(result, options.authentication).then(() => resolve(null), (e) => reject((0, generalHelpers_1.fail)(e)));
|
|
158
|
+
}, (e) => {
|
|
160
159
|
if (!skipRetry) {
|
|
161
|
-
addToServiceDefinition(url, options, true, true).then(() => resolve(null), e => reject(e));
|
|
160
|
+
addToServiceDefinition(url, options, true, true).then(() => resolve(null), (e) => reject(e));
|
|
162
161
|
}
|
|
163
162
|
else {
|
|
164
163
|
reject((0, generalHelpers_1.fail)(e));
|
|
@@ -180,7 +179,7 @@ function checkRequestStatus(result, authentication) {
|
|
|
180
179
|
const url = result.statusURL || result.statusUrl;
|
|
181
180
|
if (url) {
|
|
182
181
|
const checkStatus = setInterval(() => {
|
|
183
|
-
(0, arcgis_rest_request_1.request)(url, { authentication }).then(r => {
|
|
182
|
+
(0, arcgis_rest_request_1.request)(url, { authentication }).then((r) => {
|
|
184
183
|
/* istanbul ignore else */
|
|
185
184
|
if (["completed", "success"].indexOf(r.status.toLowerCase()) > -1) {
|
|
186
185
|
clearInterval(checkStatus);
|
|
@@ -190,7 +189,7 @@ function checkRequestStatus(result, authentication) {
|
|
|
190
189
|
clearInterval(checkStatus);
|
|
191
190
|
reject(r);
|
|
192
191
|
}
|
|
193
|
-
}, e => {
|
|
192
|
+
}, (e) => {
|
|
194
193
|
clearInterval(checkStatus);
|
|
195
194
|
reject(e);
|
|
196
195
|
});
|
|
@@ -213,7 +212,7 @@ function convertToISearchOptions(search) {
|
|
|
213
212
|
let searchOptions = {
|
|
214
213
|
q: "",
|
|
215
214
|
start: 1,
|
|
216
|
-
num: 100
|
|
215
|
+
num: 100,
|
|
217
216
|
};
|
|
218
217
|
if (typeof search === "string") {
|
|
219
218
|
// Insert query into defaults
|
|
@@ -223,10 +222,11 @@ function convertToISearchOptions(search) {
|
|
|
223
222
|
// Insert query into defaults
|
|
224
223
|
searchOptions.q = search.toParam();
|
|
225
224
|
}
|
|
226
|
-
else {
|
|
225
|
+
else {
|
|
226
|
+
// search is ISearchOptions
|
|
227
227
|
searchOptions = {
|
|
228
228
|
...searchOptions,
|
|
229
|
-
...search // request
|
|
229
|
+
...search, // request
|
|
230
230
|
};
|
|
231
231
|
}
|
|
232
232
|
// Remove the sortField if it's "relevance"; that's the default option and is not meant to be specified
|
|
@@ -283,9 +283,9 @@ function convertExtentWithFallback(extent, fallbackExtent, outSR, geometryServic
|
|
|
283
283
|
xmax: 179,
|
|
284
284
|
ymin: -89,
|
|
285
285
|
ymax: 89,
|
|
286
|
-
spatialReference: { wkid: 4326 }
|
|
286
|
+
spatialReference: { wkid: 4326 },
|
|
287
287
|
};
|
|
288
|
-
convertExtent(_validateExtent(extent), outSR, geometryServiceUrl, authentication).then(extentResponse => {
|
|
288
|
+
convertExtent(_validateExtent(extent), outSR, geometryServiceUrl, authentication).then((extentResponse) => {
|
|
289
289
|
// in some cases project will complete successfully but return "NaN" values
|
|
290
290
|
// check for this and call convert again if it does
|
|
291
291
|
const extentResponseString = JSON.stringify(extentResponse);
|
|
@@ -294,12 +294,12 @@ function convertExtentWithFallback(extent, fallbackExtent, outSR, geometryServic
|
|
|
294
294
|
resolve(extentResponse);
|
|
295
295
|
}
|
|
296
296
|
else {
|
|
297
|
-
convertExtent(fallbackExtent || defaultExtent, outSR, geometryServiceUrl, authentication).then(resolve, e => reject((0, generalHelpers_1.fail)(e)));
|
|
297
|
+
convertExtent(fallbackExtent || defaultExtent, outSR, geometryServiceUrl, authentication).then(resolve, (e) => reject((0, generalHelpers_1.fail)(e)));
|
|
298
298
|
}
|
|
299
299
|
},
|
|
300
300
|
// if convert fails try again with default global extent
|
|
301
301
|
() => {
|
|
302
|
-
convertExtent(defaultExtent, outSR, geometryServiceUrl, authentication).then(resolve, e => reject((0, generalHelpers_1.fail)(e)));
|
|
302
|
+
convertExtent(defaultExtent, outSR, geometryServiceUrl, authentication).then(resolve, (e) => reject((0, generalHelpers_1.fail)(e)));
|
|
303
303
|
});
|
|
304
304
|
});
|
|
305
305
|
}
|
|
@@ -324,12 +324,10 @@ function convertExtent(extent, outSR, geometryServiceUrl, authentication) {
|
|
|
324
324
|
f: "json",
|
|
325
325
|
inSR: extent.spatialReference.wkid,
|
|
326
326
|
outSR: outSR.wkid,
|
|
327
|
-
extentOfInterest: JSON.stringify(extent)
|
|
327
|
+
extentOfInterest: JSON.stringify(extent),
|
|
328
328
|
};
|
|
329
|
-
(0, arcgis_rest_request_1.request)((0, generalHelpers_1.checkUrlPathTermination)(geometryServiceUrl) + "findTransformations", _requestOptions).then(response => {
|
|
330
|
-
const transformations = response && response.transformations
|
|
331
|
-
? response.transformations
|
|
332
|
-
: undefined;
|
|
329
|
+
(0, arcgis_rest_request_1.request)((0, generalHelpers_1.checkUrlPathTermination)(geometryServiceUrl) + "findTransformations", _requestOptions).then((response) => {
|
|
330
|
+
const transformations = response && response.transformations ? response.transformations : undefined;
|
|
333
331
|
let transformation;
|
|
334
332
|
if (transformations && transformations.length > 0) {
|
|
335
333
|
// if a forward single transformation is found use that...otherwise check for and use composite
|
|
@@ -347,29 +345,27 @@ function convertExtent(extent, outSR, geometryServiceUrl, authentication) {
|
|
|
347
345
|
geometryType: "esriGeometryPoint",
|
|
348
346
|
geometries: [
|
|
349
347
|
{ x: extent.xmin, y: extent.ymin },
|
|
350
|
-
{ x: extent.xmax, y: extent.ymax }
|
|
351
|
-
]
|
|
348
|
+
{ x: extent.xmax, y: extent.ymax },
|
|
349
|
+
],
|
|
352
350
|
},
|
|
353
|
-
transformation: transformation
|
|
351
|
+
transformation: transformation,
|
|
354
352
|
};
|
|
355
|
-
(0, arcgis_rest_request_1.request)((0, generalHelpers_1.checkUrlPathTermination)(geometryServiceUrl) + "project", _requestOptions).then(projectResponse => {
|
|
356
|
-
const projectGeom = projectResponse.geometries.length === 2
|
|
357
|
-
? projectResponse.geometries
|
|
358
|
-
: undefined;
|
|
353
|
+
(0, arcgis_rest_request_1.request)((0, generalHelpers_1.checkUrlPathTermination)(geometryServiceUrl) + "project", _requestOptions).then((projectResponse) => {
|
|
354
|
+
const projectGeom = projectResponse.geometries.length === 2 ? projectResponse.geometries : undefined;
|
|
359
355
|
if (projectGeom) {
|
|
360
356
|
resolve({
|
|
361
357
|
xmin: projectGeom[0].x,
|
|
362
358
|
ymin: projectGeom[0].y,
|
|
363
359
|
xmax: projectGeom[1].x,
|
|
364
360
|
ymax: projectGeom[1].y,
|
|
365
|
-
spatialReference: outSR
|
|
361
|
+
spatialReference: outSR,
|
|
366
362
|
});
|
|
367
363
|
}
|
|
368
364
|
else {
|
|
369
365
|
resolve(undefined);
|
|
370
366
|
}
|
|
371
|
-
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
372
|
-
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
367
|
+
}, (e) => reject((0, generalHelpers_1.fail)(e)));
|
|
368
|
+
}, (e) => reject((0, generalHelpers_1.fail)(e)));
|
|
373
369
|
}
|
|
374
370
|
});
|
|
375
371
|
}
|
|
@@ -385,14 +381,14 @@ exports.convertExtent = convertExtent;
|
|
|
385
381
|
function createFeatureService(newItemTemplate, authentication, templateDictionary) {
|
|
386
382
|
return new Promise((resolve, reject) => {
|
|
387
383
|
// Create item
|
|
388
|
-
_getCreateServiceOptions(newItemTemplate, authentication, templateDictionary).then(createOptions => {
|
|
389
|
-
(0, arcgis_rest_service_admin_1.createFeatureService)(createOptions).then(createResponse => {
|
|
384
|
+
_getCreateServiceOptions(newItemTemplate, authentication, templateDictionary).then((createOptions) => {
|
|
385
|
+
(0, arcgis_rest_service_admin_1.createFeatureService)(createOptions).then((createResponse) => {
|
|
390
386
|
// Federated servers may have inconsistent casing, so lowerCase it
|
|
391
387
|
createResponse.encodedServiceURL = _lowercaseDomain(createResponse.encodedServiceURL);
|
|
392
388
|
createResponse.serviceurl = _lowercaseDomain(createResponse.serviceurl);
|
|
393
389
|
resolve(createResponse);
|
|
394
|
-
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
395
|
-
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
390
|
+
}, (e) => reject((0, generalHelpers_1.fail)(e)));
|
|
391
|
+
}, (e) => reject((0, generalHelpers_1.fail)(e)));
|
|
396
392
|
});
|
|
397
393
|
}
|
|
398
394
|
exports.createFeatureService = createFeatureService;
|
|
@@ -416,18 +412,18 @@ function createFullItem(itemInfo, folderId, destinationAuthentication, itemThumb
|
|
|
416
412
|
// Create item
|
|
417
413
|
const createOptions = {
|
|
418
414
|
item: {
|
|
419
|
-
...itemInfo
|
|
415
|
+
...itemInfo,
|
|
420
416
|
},
|
|
421
417
|
folderId,
|
|
422
|
-
authentication: destinationAuthentication
|
|
418
|
+
authentication: destinationAuthentication,
|
|
423
419
|
};
|
|
424
420
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
425
|
-
addTokenToUrl(itemThumbnailUrl, itemThumbnailAuthentication).then(updatedThumbnailUrl => {
|
|
421
|
+
addTokenToUrl(itemThumbnailUrl, itemThumbnailAuthentication).then((updatedThumbnailUrl) => {
|
|
426
422
|
/* istanbul ignore else */
|
|
427
423
|
if (updatedThumbnailUrl) {
|
|
428
424
|
createOptions.item.thumbnailUrl = (0, generalHelpers_1.appendQueryParam)(updatedThumbnailUrl, "w=400");
|
|
429
425
|
}
|
|
430
|
-
(0, arcgis_rest_portal_1.createItemInFolder)(createOptions).then(createResponse => {
|
|
426
|
+
(0, arcgis_rest_portal_1.createItemInFolder)(createOptions).then((createResponse) => {
|
|
431
427
|
if (createResponse.success) {
|
|
432
428
|
let accessDef;
|
|
433
429
|
// Set access if it is not AGOL default
|
|
@@ -437,13 +433,13 @@ function createFullItem(itemInfo, folderId, destinationAuthentication, itemThumb
|
|
|
437
433
|
const accessOptions = {
|
|
438
434
|
id: createResponse.id,
|
|
439
435
|
access: access === "public" ? "public" : "org",
|
|
440
|
-
authentication: destinationAuthentication
|
|
436
|
+
authentication: destinationAuthentication,
|
|
441
437
|
};
|
|
442
438
|
accessDef = (0, arcgis_rest_portal_1.setItemAccess)(accessOptions);
|
|
443
439
|
}
|
|
444
440
|
else {
|
|
445
441
|
accessDef = Promise.resolve({
|
|
446
|
-
itemId: createResponse.id
|
|
442
|
+
itemId: createResponse.id,
|
|
447
443
|
});
|
|
448
444
|
}
|
|
449
445
|
// Now add attached items
|
|
@@ -455,8 +451,7 @@ function createFullItem(itemInfo, folderId, destinationAuthentication, itemThumb
|
|
|
455
451
|
}
|
|
456
452
|
// Add the resources via a zip because AGO sometimes loses resources if many are added at the
|
|
457
453
|
// same time to the same item
|
|
458
|
-
if (Array.isArray(resourcesFiles) &&
|
|
459
|
-
resourcesFiles.length > 0) {
|
|
454
|
+
if (Array.isArray(resourcesFiles) && resourcesFiles.length > 0) {
|
|
460
455
|
updateDefs.push(new Promise((rsrcResolve, rsrcReject) => {
|
|
461
456
|
(0, libConnectors_1.createZip)("resources.zip", resourcesFiles).then((zipfile) => {
|
|
462
457
|
const addResourceOptions = {
|
|
@@ -464,8 +459,8 @@ function createFullItem(itemInfo, folderId, destinationAuthentication, itemThumb
|
|
|
464
459
|
resource: zipfile,
|
|
465
460
|
authentication: destinationAuthentication,
|
|
466
461
|
params: {
|
|
467
|
-
archive: true
|
|
468
|
-
}
|
|
462
|
+
archive: true,
|
|
463
|
+
},
|
|
469
464
|
};
|
|
470
465
|
(0, arcgis_rest_portal_1.addItemResource)(addResourceOptions).then(rsrcResolve, rsrcReject);
|
|
471
466
|
}, rsrcReject);
|
|
@@ -476,13 +471,13 @@ function createFullItem(itemInfo, folderId, destinationAuthentication, itemThumb
|
|
|
476
471
|
updateDefs.push(_addItemMetadataFile(createResponse.id, metadataFile, destinationAuthentication));
|
|
477
472
|
}
|
|
478
473
|
// Wait until all adds are done
|
|
479
|
-
Promise.all(updateDefs).then(() => resolve(createResponse), e => reject((0, generalHelpers_1.fail)(e)));
|
|
480
|
-
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
474
|
+
Promise.all(updateDefs).then(() => resolve(createResponse), (e) => reject((0, generalHelpers_1.fail)(e)));
|
|
475
|
+
}, (e) => reject((0, generalHelpers_1.fail)(e)));
|
|
481
476
|
}
|
|
482
477
|
else {
|
|
483
478
|
reject((0, generalHelpers_1.fail)());
|
|
484
479
|
}
|
|
485
|
-
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
480
|
+
}, (e) => reject((0, generalHelpers_1.fail)(e)));
|
|
486
481
|
});
|
|
487
482
|
});
|
|
488
483
|
}
|
|
@@ -505,19 +500,19 @@ function createItemWithData(itemInfo, dataInfo, authentication, folderId, access
|
|
|
505
500
|
item: {
|
|
506
501
|
title: "_",
|
|
507
502
|
...itemInfo,
|
|
508
|
-
data: dataInfo
|
|
503
|
+
data: dataInfo,
|
|
509
504
|
},
|
|
510
505
|
folderId,
|
|
511
|
-
authentication: authentication
|
|
506
|
+
authentication: authentication,
|
|
512
507
|
};
|
|
513
508
|
if (itemInfo.thumbnail) {
|
|
514
509
|
createOptions.params = {
|
|
515
510
|
// Pass thumbnail file in via params because item property is serialized, which discards a blob
|
|
516
|
-
thumbnail: itemInfo.thumbnail
|
|
511
|
+
thumbnail: itemInfo.thumbnail,
|
|
517
512
|
};
|
|
518
513
|
delete createOptions.item.thumbnail;
|
|
519
514
|
}
|
|
520
|
-
(0, arcgis_rest_portal_1.createItemInFolder)(createOptions).then(createResponse => {
|
|
515
|
+
(0, arcgis_rest_portal_1.createItemInFolder)(createOptions).then((createResponse) => {
|
|
521
516
|
if (createResponse.success) {
|
|
522
517
|
if (access !== "private") {
|
|
523
518
|
// Set access if it is not AGOL default
|
|
@@ -525,28 +520,28 @@ function createItemWithData(itemInfo, dataInfo, authentication, folderId, access
|
|
|
525
520
|
const accessOptions = {
|
|
526
521
|
id: createResponse.id,
|
|
527
522
|
access: access === "public" ? "public" : "org",
|
|
528
|
-
authentication: authentication
|
|
523
|
+
authentication: authentication,
|
|
529
524
|
};
|
|
530
525
|
(0, arcgis_rest_portal_1.setItemAccess)(accessOptions).then(() => {
|
|
531
526
|
resolve({
|
|
532
527
|
folder: createResponse.folder,
|
|
533
528
|
id: createResponse.id,
|
|
534
|
-
success: true
|
|
529
|
+
success: true,
|
|
535
530
|
});
|
|
536
|
-
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
531
|
+
}, (e) => reject((0, generalHelpers_1.fail)(e)));
|
|
537
532
|
}
|
|
538
533
|
else {
|
|
539
534
|
resolve({
|
|
540
535
|
folder: createResponse.folder,
|
|
541
536
|
id: createResponse.id,
|
|
542
|
-
success: true
|
|
537
|
+
success: true,
|
|
543
538
|
});
|
|
544
539
|
}
|
|
545
540
|
}
|
|
546
541
|
else {
|
|
547
542
|
reject((0, generalHelpers_1.fail)());
|
|
548
543
|
}
|
|
549
|
-
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
544
|
+
}, (e) => reject((0, generalHelpers_1.fail)(e)));
|
|
550
545
|
});
|
|
551
546
|
}
|
|
552
547
|
exports.createItemWithData = createItemWithData;
|
|
@@ -566,9 +561,9 @@ function createUniqueFolder(title, templateDictionary, authentication) {
|
|
|
566
561
|
const folderTitle = (0, generalHelpers_1.getUniqueTitle)(title, templateDictionary, "user.folders");
|
|
567
562
|
const folderCreationParam = {
|
|
568
563
|
title: folderTitle,
|
|
569
|
-
authentication: authentication
|
|
564
|
+
authentication: authentication,
|
|
570
565
|
};
|
|
571
|
-
(0, arcgis_rest_portal_1.createFolder)(folderCreationParam).then(ok => resolve(ok), err => {
|
|
566
|
+
(0, arcgis_rest_portal_1.createFolder)(folderCreationParam).then((ok) => resolve(ok), (err) => {
|
|
572
567
|
// If the name already exists, we'll try again
|
|
573
568
|
const errorDetails = (0, generalHelpers_1.getProp)(err, "response.error.details");
|
|
574
569
|
if (Array.isArray(errorDetails) && errorDetails.length > 0) {
|
|
@@ -580,7 +575,7 @@ function createUniqueFolder(title, templateDictionary, authentication) {
|
|
|
580
575
|
(0, generalHelpers_1.setCreateProp)(templateDictionary, "user.folders", []);
|
|
581
576
|
}
|
|
582
577
|
templateDictionary.user.folders.push({
|
|
583
|
-
title: folderTitle
|
|
578
|
+
title: folderTitle,
|
|
584
579
|
});
|
|
585
580
|
createUniqueFolder(title, templateDictionary, authentication).then(resolve, reject);
|
|
586
581
|
}
|
|
@@ -620,25 +615,22 @@ function createUniqueGroup(title, groupItem, templateDictionary, authentication,
|
|
|
620
615
|
groupsPromise = Promise.resolve([]);
|
|
621
616
|
}
|
|
622
617
|
// first get the tracker owner groups
|
|
623
|
-
groupsPromise.then(groups => {
|
|
624
|
-
templateDictionary["allGroups"] =
|
|
625
|
-
groups.concat((0, generalHelpers_1.getProp)(templateDictionary, "user.groups"));
|
|
618
|
+
groupsPromise.then((groups) => {
|
|
619
|
+
templateDictionary["allGroups"] = groups.concat((0, generalHelpers_1.getProp)(templateDictionary, "user.groups"));
|
|
626
620
|
// Get a title that is not already in use
|
|
627
621
|
groupItem.title = (0, generalHelpers_1.getUniqueTitle)(title, templateDictionary, "allGroups");
|
|
628
622
|
const groupCreationParam = {
|
|
629
623
|
group: groupItem,
|
|
630
|
-
authentication: authentication
|
|
624
|
+
authentication: authentication,
|
|
631
625
|
};
|
|
632
|
-
(0, arcgis_rest_portal_1.createGroup)(groupCreationParam).then(resolve, err => {
|
|
626
|
+
(0, arcgis_rest_portal_1.createGroup)(groupCreationParam).then(resolve, (err) => {
|
|
633
627
|
// If the name already exists, we'll try again
|
|
634
628
|
const errorDetails = (0, generalHelpers_1.getProp)(err, "response.error.details");
|
|
635
629
|
if (Array.isArray(errorDetails) && errorDetails.length > 0) {
|
|
636
|
-
const nameNotAvailMsg = "You already have a group named '" +
|
|
637
|
-
groupItem.title +
|
|
638
|
-
"'. Try a different name.";
|
|
630
|
+
const nameNotAvailMsg = "You already have a group named '" + groupItem.title + "'. Try a different name.";
|
|
639
631
|
if (errorDetails.indexOf(nameNotAvailMsg) >= 0) {
|
|
640
632
|
templateDictionary.user.groups.push({
|
|
641
|
-
title: groupItem.title
|
|
633
|
+
title: groupItem.title,
|
|
642
634
|
});
|
|
643
635
|
createUniqueGroup(title, groupItem, templateDictionary, authentication).then(resolve, reject);
|
|
644
636
|
}
|
|
@@ -651,7 +643,7 @@ function createUniqueGroup(title, groupItem, templateDictionary, authentication,
|
|
|
651
643
|
reject(err);
|
|
652
644
|
}
|
|
653
645
|
});
|
|
654
|
-
}, e => reject(e));
|
|
646
|
+
}, (e) => reject(e));
|
|
655
647
|
});
|
|
656
648
|
}
|
|
657
649
|
exports.createUniqueGroup = createUniqueGroup;
|
|
@@ -670,19 +662,19 @@ function extractDependencies(itemTemplate, authentication) {
|
|
|
670
662
|
// This step is skipped for tracker views as they will already have a source service in the org
|
|
671
663
|
if (itemTemplate.properties.service.isView && itemTemplate.item.url && !(0, trackingHelpers_1.isTrackingViewTemplate)(itemTemplate)) {
|
|
672
664
|
(0, arcgis_rest_request_1.request)((0, generalHelpers_1.checkUrlPathTermination)(itemTemplate.item.url) + "sources?f=json", {
|
|
673
|
-
authentication: authentication
|
|
674
|
-
}).then(response => {
|
|
665
|
+
authentication: authentication,
|
|
666
|
+
}).then((response) => {
|
|
675
667
|
/* istanbul ignore else */
|
|
676
668
|
if (response && response.services) {
|
|
677
669
|
response.services.forEach((layer) => {
|
|
678
670
|
dependencies.push({
|
|
679
671
|
id: layer.serviceItemId,
|
|
680
|
-
name: layer.name
|
|
672
|
+
name: layer.name,
|
|
681
673
|
});
|
|
682
674
|
});
|
|
683
675
|
}
|
|
684
676
|
resolve(dependencies);
|
|
685
|
-
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
677
|
+
}, (e) => reject((0, generalHelpers_1.fail)(e)));
|
|
686
678
|
}
|
|
687
679
|
else if ((0, workforceHelpers_1.isWorkforceProject)(itemTemplate)) {
|
|
688
680
|
resolve((0, workforceHelpers_1.getWorkforceDependencies)(itemTemplate, dependencies));
|
|
@@ -709,14 +701,14 @@ function getLayers(serviceUrl, layerList, authentication) {
|
|
|
709
701
|
// get the admin URL
|
|
710
702
|
serviceUrl = serviceUrl.replace("/rest/services", "/rest/admin/services");
|
|
711
703
|
const requestsDfd = [];
|
|
712
|
-
layerList.forEach(layer => {
|
|
704
|
+
layerList.forEach((layer) => {
|
|
713
705
|
const requestOptions = {
|
|
714
|
-
authentication: authentication
|
|
706
|
+
authentication: authentication,
|
|
715
707
|
};
|
|
716
708
|
requestsDfd.push((0, arcgis_rest_request_1.request)((0, generalHelpers_1.checkUrlPathTermination)(serviceUrl) + layer["id"] + "?f=json", requestOptions));
|
|
717
709
|
});
|
|
718
710
|
// Wait until all layers are heard from
|
|
719
|
-
Promise.all(requestsDfd).then(layers => resolve(layers), e => reject((0, generalHelpers_1.fail)(e)));
|
|
711
|
+
Promise.all(requestsDfd).then((layers) => resolve(layers), (e) => reject((0, generalHelpers_1.fail)(e)));
|
|
720
712
|
});
|
|
721
713
|
}
|
|
722
714
|
exports.getLayers = getLayers;
|
|
@@ -734,7 +726,7 @@ function getLayerUpdates(args, isPortal) {
|
|
|
734
726
|
const updates = [];
|
|
735
727
|
const refresh = _getUpdate(adminUrl, null, null, args, "refresh");
|
|
736
728
|
updates.push(refresh);
|
|
737
|
-
Object.keys(args.objects).forEach(id => {
|
|
729
|
+
Object.keys(args.objects).forEach((id) => {
|
|
738
730
|
const obj = Object.assign({}, args.objects[id]);
|
|
739
731
|
// These properties cannot be set in the update definition when working with portal
|
|
740
732
|
if (isPortal) {
|
|
@@ -756,7 +748,7 @@ function getLayerUpdates(args, isPortal) {
|
|
|
756
748
|
message: "updated layer relationships",
|
|
757
749
|
objects: args.objects,
|
|
758
750
|
itemTemplate: args.itemTemplate,
|
|
759
|
-
authentication: args.authentication
|
|
751
|
+
authentication: args.authentication,
|
|
760
752
|
});
|
|
761
753
|
// issue: #724
|
|
762
754
|
// In portal the order the relationships are added needs to follow the layer order
|
|
@@ -772,11 +764,11 @@ function getLayerUpdates(args, isPortal) {
|
|
|
772
764
|
message: "add layer contingent values",
|
|
773
765
|
objects: args.objects,
|
|
774
766
|
itemTemplate: args.itemTemplate,
|
|
775
|
-
authentication: args.authentication
|
|
767
|
+
authentication: args.authentication,
|
|
776
768
|
});
|
|
777
769
|
/* istanbul ignore else */
|
|
778
770
|
if (contingentValuesUpdates.length > 0) {
|
|
779
|
-
contingentValuesUpdates.forEach(conUpdate => {
|
|
771
|
+
contingentValuesUpdates.forEach((conUpdate) => {
|
|
780
772
|
updates.push(_getUpdate(adminUrl + conUpdate.id, null, conUpdate.contingentValues, args, "add"));
|
|
781
773
|
});
|
|
782
774
|
}
|
|
@@ -796,7 +788,7 @@ async function moveItemToFolder(itemId, folderId, authentication) {
|
|
|
796
788
|
const moveOptions = {
|
|
797
789
|
itemId,
|
|
798
790
|
folderId,
|
|
799
|
-
authentication
|
|
791
|
+
authentication,
|
|
800
792
|
};
|
|
801
793
|
return (0, arcgis_rest_portal_1.moveItem)(moveOptions);
|
|
802
794
|
}
|
|
@@ -811,7 +803,7 @@ exports.moveItemToFolder = moveItemToFolder;
|
|
|
811
803
|
*/
|
|
812
804
|
async function moveItemsToFolder(itemIds, folderId, authentication) {
|
|
813
805
|
const movePromises = new Array();
|
|
814
|
-
itemIds.forEach(itemId => {
|
|
806
|
+
itemIds.forEach((itemId) => {
|
|
815
807
|
movePromises.push(moveItemToFolder(itemId, folderId, authentication));
|
|
816
808
|
});
|
|
817
809
|
return Promise.all(movePromises);
|
|
@@ -832,7 +824,7 @@ function _sortRelationships(layers, tables, relUpdates) {
|
|
|
832
824
|
// In portal the order the relationships are added needs to follow the layer order
|
|
833
825
|
// otherwise the relationship IDs will be reset
|
|
834
826
|
const _relUpdateLayers = [];
|
|
835
|
-
ids.forEach(id => {
|
|
827
|
+
ids.forEach((id) => {
|
|
836
828
|
relUpdates.layers.some((relUpdate) => {
|
|
837
829
|
if (id === relUpdate.id) {
|
|
838
830
|
_relUpdateLayers.push(relUpdate);
|
|
@@ -862,7 +854,7 @@ function getRequest(update, skipRetry = false, useAsync = false) {
|
|
|
862
854
|
return new Promise((resolve, reject) => {
|
|
863
855
|
const options = {
|
|
864
856
|
params: update.params,
|
|
865
|
-
authentication: update.args.authentication
|
|
857
|
+
authentication: update.args.authentication,
|
|
866
858
|
};
|
|
867
859
|
/* istanbul ignore else */
|
|
868
860
|
if ((useAsync && update.url.indexOf("addToDefinition") > -1) ||
|
|
@@ -870,11 +862,11 @@ function getRequest(update, skipRetry = false, useAsync = false) {
|
|
|
870
862
|
update.url.indexOf("deleteFromDefinition") > -1) {
|
|
871
863
|
options.params = { ...options.params, async: true };
|
|
872
864
|
}
|
|
873
|
-
(0, arcgis_rest_request_1.request)(update.url, options).then(result => {
|
|
874
|
-
checkRequestStatus(result, options.authentication).then(() => resolve(null), e => reject((0, generalHelpers_1.fail)(e)));
|
|
865
|
+
(0, arcgis_rest_request_1.request)(update.url, options).then((result) => {
|
|
866
|
+
checkRequestStatus(result, options.authentication).then(() => resolve(null), (e) => reject((0, generalHelpers_1.fail)(e)));
|
|
875
867
|
}, (e) => {
|
|
876
868
|
if (!skipRetry) {
|
|
877
|
-
getRequest(update, true, true).then(() => resolve(), e => reject(e));
|
|
869
|
+
getRequest(update, true, true).then(() => resolve(), (e) => reject(e));
|
|
878
870
|
}
|
|
879
871
|
else {
|
|
880
872
|
reject(e);
|
|
@@ -900,10 +892,10 @@ function getServiceLayersAndTables(itemTemplate, authentication) {
|
|
|
900
892
|
const isWorkforceService = (0, workforceHelpers_1.isWorkforceProject)(itemTemplate);
|
|
901
893
|
// Get the service description
|
|
902
894
|
if (itemTemplate.item.url) {
|
|
903
|
-
getFeatureServiceProperties(itemTemplate.item.url, authentication, isWorkforceService).then(properties => {
|
|
895
|
+
getFeatureServiceProperties(itemTemplate.item.url, authentication, isWorkforceService).then((properties) => {
|
|
904
896
|
itemTemplate.properties = properties;
|
|
905
897
|
resolve(itemTemplate);
|
|
906
|
-
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
898
|
+
}, (e) => reject((0, generalHelpers_1.fail)(e)));
|
|
907
899
|
}
|
|
908
900
|
else {
|
|
909
901
|
resolve(itemTemplate);
|
|
@@ -925,21 +917,20 @@ function getFeatureServiceProperties(serviceUrl, authentication, workforceServic
|
|
|
925
917
|
const properties = {
|
|
926
918
|
service: {},
|
|
927
919
|
layers: [],
|
|
928
|
-
tables: []
|
|
920
|
+
tables: [],
|
|
929
921
|
};
|
|
930
922
|
// get the admin URL
|
|
931
923
|
serviceUrl = serviceUrl.replace("/rest/services", "/rest/admin/services");
|
|
932
924
|
// Get the service description
|
|
933
925
|
(0, arcgis_rest_request_1.request)(serviceUrl + "?f=json", {
|
|
934
|
-
authentication: authentication
|
|
935
|
-
}).then(serviceData => {
|
|
926
|
+
authentication: authentication,
|
|
927
|
+
}).then((serviceData) => {
|
|
936
928
|
properties.service = _parseAdminServiceData(serviceData);
|
|
937
929
|
// Copy cacheMaxAge to top level so that AGO sees it when deploying the service
|
|
938
930
|
// serviceData may have set it if there isn't an adminServiceInfo
|
|
939
931
|
/* istanbul ignore else */
|
|
940
932
|
if (serviceData.adminServiceInfo?.cacheMaxAge) {
|
|
941
|
-
properties.service.cacheMaxAge =
|
|
942
|
-
serviceData.adminServiceInfo.cacheMaxAge;
|
|
933
|
+
properties.service.cacheMaxAge = serviceData.adminServiceInfo.cacheMaxAge;
|
|
943
934
|
}
|
|
944
935
|
// Move the layers and tables out of the service's data section
|
|
945
936
|
/* istanbul ignore else */
|
|
@@ -947,7 +938,7 @@ function getFeatureServiceProperties(serviceUrl, authentication, workforceServic
|
|
|
947
938
|
properties.layers = serviceData.layers;
|
|
948
939
|
// Fill in properties that the service layer doesn't provide
|
|
949
940
|
// and remove properties that should not exist in the template
|
|
950
|
-
properties.layers.forEach(layer => {
|
|
941
|
+
properties.layers.forEach((layer) => {
|
|
951
942
|
layer.serviceItemId = properties.service.serviceItemId;
|
|
952
943
|
layer.extent = null;
|
|
953
944
|
(0, featureServiceHelpers_1.removeLayerOptimization)(layer);
|
|
@@ -958,7 +949,7 @@ function getFeatureServiceProperties(serviceUrl, authentication, workforceServic
|
|
|
958
949
|
if (serviceData.tables) {
|
|
959
950
|
properties.tables = serviceData.tables;
|
|
960
951
|
// Fill in properties that the service layer doesn't provide
|
|
961
|
-
properties.tables.forEach(table => {
|
|
952
|
+
properties.tables.forEach((table) => {
|
|
962
953
|
table.serviceItemId = properties.service.serviceItemId;
|
|
963
954
|
table.extent = null;
|
|
964
955
|
});
|
|
@@ -992,13 +983,13 @@ async function getWorkflowConfigurationZip(itemId, workflowBaseUrl, authenticati
|
|
|
992
983
|
return (0, arcgis_rest_request_1.request)(url, {
|
|
993
984
|
authentication,
|
|
994
985
|
headers: {
|
|
995
|
-
Accept: "application/octet-stream",
|
|
996
|
-
Authorization: `Bearer ${authentication.token}`,
|
|
997
|
-
"X-Esri-Authorization": `Bearer ${authentication.token}
|
|
986
|
+
"Accept": "application/octet-stream",
|
|
987
|
+
"Authorization": `Bearer ${authentication.token}`,
|
|
988
|
+
"X-Esri-Authorization": `Bearer ${authentication.token}`,
|
|
998
989
|
},
|
|
999
990
|
params: {
|
|
1000
|
-
f: "zip"
|
|
1001
|
-
}
|
|
991
|
+
f: "zip",
|
|
992
|
+
},
|
|
1002
993
|
});
|
|
1003
994
|
}
|
|
1004
995
|
exports.getWorkflowConfigurationZip = getWorkflowConfigurationZip;
|
|
@@ -1017,13 +1008,13 @@ async function setWorkflowConfigurationZip(itemId, configurationZipFile, workflo
|
|
|
1017
1008
|
return (0, arcgis_rest_request_1.request)(url, {
|
|
1018
1009
|
authentication,
|
|
1019
1010
|
headers: {
|
|
1020
|
-
Accept: "application/octet-stream",
|
|
1021
|
-
Authorization: `Bearer ${authentication.token}`,
|
|
1022
|
-
"X-Esri-Authorization": `Bearer ${authentication.token}
|
|
1011
|
+
"Accept": "application/octet-stream",
|
|
1012
|
+
"Authorization": `Bearer ${authentication.token}`,
|
|
1013
|
+
"X-Esri-Authorization": `Bearer ${authentication.token}`,
|
|
1023
1014
|
},
|
|
1024
1015
|
params: {
|
|
1025
|
-
file: configurationZipFile
|
|
1026
|
-
}
|
|
1016
|
+
file: configurationZipFile,
|
|
1017
|
+
},
|
|
1027
1018
|
});
|
|
1028
1019
|
}
|
|
1029
1020
|
exports.setWorkflowConfigurationZip = setWorkflowConfigurationZip;
|
|
@@ -1038,10 +1029,10 @@ exports.setWorkflowConfigurationZip = setWorkflowConfigurationZip;
|
|
|
1038
1029
|
function _parseAdminServiceData(adminData) {
|
|
1039
1030
|
const layers = adminData.layers || [];
|
|
1040
1031
|
const tables = adminData.tables || [];
|
|
1041
|
-
(0, generalHelpers_1.setCreateProp)(adminData, "layers", layers.filter(l => l.type === "Feature Layer"));
|
|
1032
|
+
(0, generalHelpers_1.setCreateProp)(adminData, "layers", layers.filter((l) => l.type === "Feature Layer"));
|
|
1042
1033
|
// TODO understand if the concat is necessary.
|
|
1043
1034
|
// Not sure if the admin api will ever actually return a tables collection here.
|
|
1044
|
-
(0, generalHelpers_1.setCreateProp)(adminData, "tables", tables.concat(layers.filter(l => l.type === "Table")));
|
|
1035
|
+
(0, generalHelpers_1.setCreateProp)(adminData, "tables", tables.concat(layers.filter((l) => l.type === "Table")));
|
|
1045
1036
|
return adminData;
|
|
1046
1037
|
}
|
|
1047
1038
|
exports._parseAdminServiceData = _parseAdminServiceData;
|
|
@@ -1054,9 +1045,7 @@ exports._parseAdminServiceData = _parseAdminServiceData;
|
|
|
1054
1045
|
*/
|
|
1055
1046
|
function hasInvalidGroupDesignations(groupDesignations) {
|
|
1056
1047
|
const invalidGroupDesignations = ["livingatlas"];
|
|
1057
|
-
return groupDesignations
|
|
1058
|
-
? invalidGroupDesignations.indexOf(groupDesignations) > -1
|
|
1059
|
-
: false;
|
|
1048
|
+
return groupDesignations ? invalidGroupDesignations.indexOf(groupDesignations) > -1 : false;
|
|
1060
1049
|
}
|
|
1061
1050
|
exports.hasInvalidGroupDesignations = hasInvalidGroupDesignations;
|
|
1062
1051
|
/**
|
|
@@ -1070,9 +1059,9 @@ function removeFolder(folderId, authentication) {
|
|
|
1070
1059
|
return new Promise((resolve, reject) => {
|
|
1071
1060
|
const requestOptions = {
|
|
1072
1061
|
folderId: folderId,
|
|
1073
|
-
authentication: authentication
|
|
1062
|
+
authentication: authentication,
|
|
1074
1063
|
};
|
|
1075
|
-
(0, arcgis_rest_portal_1.removeFolder)(requestOptions).then(result => (result.success ? resolve(result) : reject(result)), reject);
|
|
1064
|
+
(0, arcgis_rest_portal_1.removeFolder)(requestOptions).then((result) => (result.success ? resolve(result) : reject(result)), reject);
|
|
1076
1065
|
});
|
|
1077
1066
|
}
|
|
1078
1067
|
exports.removeFolder = removeFolder;
|
|
@@ -1087,9 +1076,9 @@ function removeGroup(groupId, authentication) {
|
|
|
1087
1076
|
return new Promise((resolve, reject) => {
|
|
1088
1077
|
const requestOptions = {
|
|
1089
1078
|
id: groupId,
|
|
1090
|
-
authentication: authentication
|
|
1079
|
+
authentication: authentication,
|
|
1091
1080
|
};
|
|
1092
|
-
(0, arcgis_rest_portal_1.removeGroup)(requestOptions).then(result => (result.success ? resolve(result) : reject(result)), reject);
|
|
1081
|
+
(0, arcgis_rest_portal_1.removeGroup)(requestOptions).then((result) => (result.success ? resolve(result) : reject(result)), reject);
|
|
1093
1082
|
});
|
|
1094
1083
|
}
|
|
1095
1084
|
exports.removeGroup = removeGroup;
|
|
@@ -1108,10 +1097,10 @@ function removeItem(itemId, authentication, permanentDelete = true) {
|
|
|
1108
1097
|
id: itemId,
|
|
1109
1098
|
authentication: authentication,
|
|
1110
1099
|
params: {
|
|
1111
|
-
permanentDelete
|
|
1112
|
-
}
|
|
1100
|
+
permanentDelete,
|
|
1101
|
+
},
|
|
1113
1102
|
};
|
|
1114
|
-
(0, arcgis_rest_portal_1.removeItem)(requestOptions).then(result => (result.success ? resolve(result) : reject(result)), reject);
|
|
1103
|
+
(0, arcgis_rest_portal_1.removeItem)(requestOptions).then((result) => (result.success ? resolve(result) : reject(result)), reject);
|
|
1115
1104
|
});
|
|
1116
1105
|
}
|
|
1117
1106
|
exports.removeItem = removeItem;
|
|
@@ -1126,7 +1115,7 @@ exports.removeItem = removeItem;
|
|
|
1126
1115
|
*/
|
|
1127
1116
|
function removeItemOrGroup(itemId, authentication, permanentDelete = true) {
|
|
1128
1117
|
return new Promise((resolve, reject) => {
|
|
1129
|
-
removeItem(itemId, authentication, permanentDelete).then(resolve, error => {
|
|
1118
|
+
removeItem(itemId, authentication, permanentDelete).then(resolve, (error) => {
|
|
1130
1119
|
removeGroup(itemId, authentication).then(resolve, () => reject(error));
|
|
1131
1120
|
});
|
|
1132
1121
|
});
|
|
@@ -1155,16 +1144,18 @@ function searchAllItems(search, accumulatedResponse) {
|
|
|
1155
1144
|
// Convert the search into an ISearchOptions
|
|
1156
1145
|
const searchOptions = convertToISearchOptions(search);
|
|
1157
1146
|
// Provide a base into which results can be concatenated
|
|
1158
|
-
const completeResponse = accumulatedResponse
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1147
|
+
const completeResponse = accumulatedResponse
|
|
1148
|
+
? accumulatedResponse
|
|
1149
|
+
: {
|
|
1150
|
+
query: searchOptions.q,
|
|
1151
|
+
start: 1,
|
|
1152
|
+
num: 100,
|
|
1153
|
+
nextStart: -1,
|
|
1154
|
+
total: 0,
|
|
1155
|
+
results: [],
|
|
1156
|
+
};
|
|
1166
1157
|
return new Promise((resolve, reject) => {
|
|
1167
|
-
searchItems(search).then(response => {
|
|
1158
|
+
searchItems(search).then((response) => {
|
|
1168
1159
|
completeResponse.results = completeResponse.results.concat(response.results);
|
|
1169
1160
|
completeResponse.num = completeResponse.total = completeResponse.results.length;
|
|
1170
1161
|
if (response.nextStart > 0) {
|
|
@@ -1175,7 +1166,7 @@ function searchAllItems(search, accumulatedResponse) {
|
|
|
1175
1166
|
else {
|
|
1176
1167
|
resolve(completeResponse);
|
|
1177
1168
|
}
|
|
1178
|
-
}, e => reject(e));
|
|
1169
|
+
}, (e) => reject(e));
|
|
1179
1170
|
});
|
|
1180
1171
|
}
|
|
1181
1172
|
exports.searchAllItems = searchAllItems;
|
|
@@ -1194,9 +1185,9 @@ function searchGroups(searchString, authentication, additionalSearchOptions) {
|
|
|
1194
1185
|
const searchOptions = {
|
|
1195
1186
|
q: searchString,
|
|
1196
1187
|
params: {
|
|
1197
|
-
...additionalSearchOptions
|
|
1188
|
+
...additionalSearchOptions,
|
|
1198
1189
|
},
|
|
1199
|
-
authentication: authentication
|
|
1190
|
+
authentication: authentication,
|
|
1200
1191
|
};
|
|
1201
1192
|
return (0, arcgis_rest_portal_1.searchGroups)(searchOptions);
|
|
1202
1193
|
}
|
|
@@ -1212,19 +1203,21 @@ exports.searchGroups = searchGroups;
|
|
|
1212
1203
|
* @returns A promise that will resolve with all groups that meet the search criteria
|
|
1213
1204
|
*/
|
|
1214
1205
|
function searchAllGroups(searchString, authentication, groups, inPagingParams) {
|
|
1215
|
-
const pagingParams = inPagingParams
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1206
|
+
const pagingParams = inPagingParams
|
|
1207
|
+
? inPagingParams
|
|
1208
|
+
: {
|
|
1209
|
+
start: 1,
|
|
1210
|
+
num: 24,
|
|
1211
|
+
};
|
|
1219
1212
|
const additionalSearchOptions = {
|
|
1220
1213
|
sortField: "title",
|
|
1221
1214
|
sortOrder: "asc",
|
|
1222
|
-
...pagingParams
|
|
1215
|
+
...pagingParams,
|
|
1223
1216
|
};
|
|
1224
1217
|
// Provide a base onto which results can be concatenated
|
|
1225
1218
|
let finalResults = groups ? groups : [];
|
|
1226
1219
|
return new Promise((resolve, reject) => {
|
|
1227
|
-
searchGroups(searchString, authentication, additionalSearchOptions).then(response => {
|
|
1220
|
+
searchGroups(searchString, authentication, additionalSearchOptions).then((response) => {
|
|
1228
1221
|
finalResults = finalResults.concat(response.results);
|
|
1229
1222
|
if (response.nextStart > 0) {
|
|
1230
1223
|
pagingParams.start = response.nextStart;
|
|
@@ -1233,7 +1226,7 @@ function searchAllGroups(searchString, authentication, groups, inPagingParams) {
|
|
|
1233
1226
|
else {
|
|
1234
1227
|
resolve(finalResults);
|
|
1235
1228
|
}
|
|
1236
|
-
}, e => reject(e));
|
|
1229
|
+
}, (e) => reject(e));
|
|
1237
1230
|
});
|
|
1238
1231
|
}
|
|
1239
1232
|
exports.searchAllGroups = searchAllGroups;
|
|
@@ -1255,20 +1248,22 @@ exports.searchAllGroups = searchAllGroups;
|
|
|
1255
1248
|
function searchGroupAllContents(groupId, searchString, authentication, additionalSearchOptions, portalUrl, accumulatedResponse) {
|
|
1256
1249
|
additionalSearchOptions = additionalSearchOptions ? additionalSearchOptions : {};
|
|
1257
1250
|
// Provide a base into which results can be concatenated
|
|
1258
|
-
const completeResponse = accumulatedResponse
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1251
|
+
const completeResponse = accumulatedResponse
|
|
1252
|
+
? accumulatedResponse
|
|
1253
|
+
: {
|
|
1254
|
+
query: searchString,
|
|
1255
|
+
start: 1,
|
|
1256
|
+
num: 100,
|
|
1257
|
+
nextStart: -1,
|
|
1258
|
+
total: 0,
|
|
1259
|
+
results: [],
|
|
1260
|
+
};
|
|
1266
1261
|
// Remove the sortField if it's "relevance"; that's the default option and is not meant to be specified
|
|
1267
1262
|
if (additionalSearchOptions.sortField === "relevance") {
|
|
1268
1263
|
delete additionalSearchOptions.sortField;
|
|
1269
1264
|
}
|
|
1270
1265
|
return new Promise((resolve, reject) => {
|
|
1271
|
-
searchGroupContents(groupId, searchString, authentication, additionalSearchOptions, portalUrl).then(response => {
|
|
1266
|
+
searchGroupContents(groupId, searchString, authentication, additionalSearchOptions, portalUrl).then((response) => {
|
|
1272
1267
|
completeResponse.results = completeResponse.results.concat(response.results);
|
|
1273
1268
|
completeResponse.num = completeResponse.total = completeResponse.results.length;
|
|
1274
1269
|
if (response.nextStart > 0) {
|
|
@@ -1278,7 +1273,7 @@ function searchGroupAllContents(groupId, searchString, authentication, additiona
|
|
|
1278
1273
|
else {
|
|
1279
1274
|
resolve(completeResponse);
|
|
1280
1275
|
}
|
|
1281
|
-
}, e => reject(e));
|
|
1276
|
+
}, (e) => reject(e));
|
|
1282
1277
|
});
|
|
1283
1278
|
}
|
|
1284
1279
|
exports.searchGroupAllContents = searchGroupAllContents;
|
|
@@ -1301,15 +1296,15 @@ function searchGroupContents(groupId, searchString, authentication, additionalSe
|
|
|
1301
1296
|
groupId,
|
|
1302
1297
|
q: searchString,
|
|
1303
1298
|
params: Object.assign({
|
|
1304
|
-
num: 100
|
|
1299
|
+
num: 100,
|
|
1305
1300
|
}, additionalSearchOptions),
|
|
1306
1301
|
authentication: authentication,
|
|
1307
|
-
portal: portalUrl
|
|
1302
|
+
portal: portalUrl,
|
|
1308
1303
|
};
|
|
1309
1304
|
// If search options include `categories`, switch to new arcgis-rest-js format
|
|
1310
1305
|
/* istanbul ignore else */
|
|
1311
1306
|
if (Array.isArray(searchOptions.params.categories)) {
|
|
1312
|
-
searchOptions.params.categories = searchOptions.params.categories.map(andGroup => andGroup.split(","));
|
|
1307
|
+
searchOptions.params.categories = searchOptions.params.categories.map((andGroup) => andGroup.split(","));
|
|
1313
1308
|
}
|
|
1314
1309
|
return (0, arcgis_rest_portal_1.searchGroupContent)(searchOptions);
|
|
1315
1310
|
}
|
|
@@ -1328,8 +1323,8 @@ function reassignGroup(groupId, userName, authentication) {
|
|
|
1328
1323
|
const requestOptions = {
|
|
1329
1324
|
authentication: authentication,
|
|
1330
1325
|
params: {
|
|
1331
|
-
targetUsername: userName
|
|
1332
|
-
}
|
|
1326
|
+
targetUsername: userName,
|
|
1327
|
+
},
|
|
1333
1328
|
};
|
|
1334
1329
|
return (0, arcgis_rest_request_1.request)(`${authentication.portal}/community/groups/${groupId}/reassign`, requestOptions);
|
|
1335
1330
|
}
|
|
@@ -1348,7 +1343,7 @@ function removeUsers(groupId, users, authentication) {
|
|
|
1348
1343
|
return (0, arcgis_rest_portal_1.removeGroupUsers)({
|
|
1349
1344
|
id: groupId,
|
|
1350
1345
|
users,
|
|
1351
|
-
authentication
|
|
1346
|
+
authentication,
|
|
1352
1347
|
});
|
|
1353
1348
|
}
|
|
1354
1349
|
exports.removeUsers = removeUsers;
|
|
@@ -1368,7 +1363,7 @@ function shareItem(groupId, id, destinationAuthentication, owner) {
|
|
|
1368
1363
|
const shareOptions = {
|
|
1369
1364
|
groupId,
|
|
1370
1365
|
id,
|
|
1371
|
-
authentication: destinationAuthentication
|
|
1366
|
+
authentication: destinationAuthentication,
|
|
1372
1367
|
};
|
|
1373
1368
|
/* istanbul ignore else */
|
|
1374
1369
|
if (owner) {
|
|
@@ -1395,10 +1390,10 @@ function updateItem(itemInfo, authentication, folderId, additionalParams) {
|
|
|
1395
1390
|
folderId: folderId,
|
|
1396
1391
|
authentication: authentication,
|
|
1397
1392
|
params: {
|
|
1398
|
-
...(additionalParams ?? {})
|
|
1399
|
-
}
|
|
1393
|
+
...(additionalParams ?? {}),
|
|
1394
|
+
},
|
|
1400
1395
|
};
|
|
1401
|
-
(0, arcgis_rest_portal_1.updateItem)(updateOptions).then(response => (response.success ? resolve(response) : reject(response)), err => reject(err));
|
|
1396
|
+
(0, arcgis_rest_portal_1.updateItem)(updateOptions).then((response) => (response.success ? resolve(response) : reject(response)), (err) => reject(err));
|
|
1402
1397
|
});
|
|
1403
1398
|
}
|
|
1404
1399
|
exports.updateItem = updateItem;
|
|
@@ -1417,10 +1412,10 @@ function updateGroup(groupInfo, authentication, additionalParams) {
|
|
|
1417
1412
|
group: groupInfo,
|
|
1418
1413
|
authentication,
|
|
1419
1414
|
params: {
|
|
1420
|
-
...(additionalParams ?? {})
|
|
1421
|
-
}
|
|
1415
|
+
...(additionalParams ?? {}),
|
|
1416
|
+
},
|
|
1422
1417
|
};
|
|
1423
|
-
(0, arcgis_rest_portal_1.updateGroup)(updateOptions).then(response => (response.success ? resolve(response) : reject(response)), err => reject(err));
|
|
1418
|
+
(0, arcgis_rest_portal_1.updateGroup)(updateOptions).then((response) => (response.success ? resolve(response) : reject(response)), (err) => reject(err));
|
|
1424
1419
|
});
|
|
1425
1420
|
}
|
|
1426
1421
|
exports.updateGroup = updateGroup;
|
|
@@ -1439,9 +1434,9 @@ function updateItemExtended(itemInfo, data, authentication, thumbnail, access, t
|
|
|
1439
1434
|
const updateOptions = {
|
|
1440
1435
|
item: itemInfo,
|
|
1441
1436
|
params: {
|
|
1442
|
-
text: data || {} // AGO ignores update if `data` is empty
|
|
1437
|
+
text: data || {}, // AGO ignores update if `data` is empty
|
|
1443
1438
|
},
|
|
1444
|
-
authentication: authentication
|
|
1439
|
+
authentication: authentication,
|
|
1445
1440
|
};
|
|
1446
1441
|
if (thumbnail) {
|
|
1447
1442
|
updateOptions.params.thumbnail = thumbnail;
|
|
@@ -1449,21 +1444,21 @@ function updateItemExtended(itemInfo, data, authentication, thumbnail, access, t
|
|
|
1449
1444
|
if ((0, trackingHelpers_1.isTrackingViewTemplate)(undefined, itemInfo) && templateDictionary) {
|
|
1450
1445
|
updateOptions.owner = templateDictionary.locationTracking.owner;
|
|
1451
1446
|
}
|
|
1452
|
-
(0, arcgis_rest_portal_1.updateItem)(updateOptions).then(result => {
|
|
1447
|
+
(0, arcgis_rest_portal_1.updateItem)(updateOptions).then((result) => {
|
|
1453
1448
|
if (access && access !== "private") {
|
|
1454
1449
|
// Set access if it is not AGOL default
|
|
1455
1450
|
// Set the access manually since the access value in createItem appears to be ignored
|
|
1456
1451
|
const accessOptions = {
|
|
1457
1452
|
id: itemInfo.id,
|
|
1458
1453
|
access: access === "public" ? "public" : "org",
|
|
1459
|
-
authentication: authentication
|
|
1454
|
+
authentication: authentication,
|
|
1460
1455
|
};
|
|
1461
|
-
(0, arcgis_rest_portal_1.setItemAccess)(accessOptions).then(() => resolve(result), e => reject((0, generalHelpers_1.fail)(e)));
|
|
1456
|
+
(0, arcgis_rest_portal_1.setItemAccess)(accessOptions).then(() => resolve(result), (e) => reject((0, generalHelpers_1.fail)(e)));
|
|
1462
1457
|
}
|
|
1463
1458
|
else {
|
|
1464
1459
|
resolve(result);
|
|
1465
1460
|
}
|
|
1466
|
-
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
1461
|
+
}, (e) => reject((0, generalHelpers_1.fail)(e)));
|
|
1467
1462
|
});
|
|
1468
1463
|
}
|
|
1469
1464
|
exports.updateItemExtended = updateItemExtended;
|
|
@@ -1478,10 +1473,7 @@ exports.updateItemExtended = updateItemExtended;
|
|
|
1478
1473
|
function updateItemTemplateFromDictionary(itemId, templateDictionary, authentication) {
|
|
1479
1474
|
return new Promise((resolve, reject) => {
|
|
1480
1475
|
// Fetch the items as stored in AGO
|
|
1481
|
-
Promise.all([
|
|
1482
|
-
(0, restHelpersGet_1.getItemBase)(itemId, authentication),
|
|
1483
|
-
(0, restHelpersGet_1.getItemDataAsJson)(itemId, authentication)
|
|
1484
|
-
])
|
|
1476
|
+
Promise.all([(0, restHelpersGet_1.getItemBase)(itemId, authentication), (0, restHelpersGet_1.getItemDataAsJson)(itemId, authentication)])
|
|
1485
1477
|
.then(([item, data]) => {
|
|
1486
1478
|
// Do they have any variables?
|
|
1487
1479
|
if ((0, templatization_1.hasUnresolvedVariables)(item) || (0, templatization_1.hasUnresolvedVariables)(data)) {
|
|
@@ -1494,12 +1486,12 @@ function updateItemTemplateFromDictionary(itemId, templateDictionary, authentica
|
|
|
1494
1486
|
// Shortcut out if not
|
|
1495
1487
|
return Promise.resolve({
|
|
1496
1488
|
success: true,
|
|
1497
|
-
id: itemId
|
|
1489
|
+
id: itemId,
|
|
1498
1490
|
});
|
|
1499
1491
|
}
|
|
1500
1492
|
})
|
|
1501
|
-
.then(result => resolve(result))
|
|
1502
|
-
.catch(error => reject(error));
|
|
1493
|
+
.then((result) => resolve(result))
|
|
1494
|
+
.catch((error) => reject(error));
|
|
1503
1495
|
});
|
|
1504
1496
|
}
|
|
1505
1497
|
exports.updateItemTemplateFromDictionary = updateItemTemplateFromDictionary;
|
|
@@ -1558,13 +1550,13 @@ function _addItemMetadataFile(itemId, metadataFile, authentication) {
|
|
|
1558
1550
|
return new Promise((resolve, reject) => {
|
|
1559
1551
|
const addMetadataOptions = {
|
|
1560
1552
|
item: {
|
|
1561
|
-
id: itemId
|
|
1553
|
+
id: itemId,
|
|
1562
1554
|
},
|
|
1563
1555
|
params: {
|
|
1564
1556
|
// Pass metadata in via params because item property is serialized, which discards a blob
|
|
1565
|
-
metadata: metadataFile
|
|
1557
|
+
metadata: metadataFile,
|
|
1566
1558
|
},
|
|
1567
|
-
authentication: authentication
|
|
1559
|
+
authentication: authentication,
|
|
1568
1560
|
};
|
|
1569
1561
|
(0, arcgis_rest_portal_1.updateItem)(addMetadataOptions).then(resolve, reject);
|
|
1570
1562
|
});
|
|
@@ -1578,8 +1570,7 @@ exports._addItemMetadataFile = _addItemMetadataFile;
|
|
|
1578
1570
|
* @private
|
|
1579
1571
|
*/
|
|
1580
1572
|
function _countRelationships(layers) {
|
|
1581
|
-
const reducer = (accumulator, currentLayer) => accumulator +
|
|
1582
|
-
(currentLayer.relationships ? currentLayer.relationships.length : 0);
|
|
1573
|
+
const reducer = (accumulator, currentLayer) => accumulator + (currentLayer.relationships ? currentLayer.relationships.length : 0);
|
|
1583
1574
|
return layers.reduce(reducer, 0);
|
|
1584
1575
|
}
|
|
1585
1576
|
exports._countRelationships = _countRelationships;
|
|
@@ -1603,23 +1594,23 @@ function _getCreateServiceOptions(newItemTemplate, authentication, templateDicti
|
|
|
1603
1594
|
const params = {};
|
|
1604
1595
|
const itemInfo = {
|
|
1605
1596
|
title: newItemTemplate.item.title,
|
|
1606
|
-
name: newItemTemplate.item.name
|
|
1597
|
+
name: newItemTemplate.item.name,
|
|
1607
1598
|
};
|
|
1608
1599
|
const _item = {
|
|
1609
1600
|
...itemInfo,
|
|
1610
|
-
preserveLayerIds: true
|
|
1601
|
+
preserveLayerIds: true,
|
|
1611
1602
|
};
|
|
1612
1603
|
const createOptions = {
|
|
1613
1604
|
item: _item,
|
|
1614
1605
|
folderId,
|
|
1615
1606
|
params,
|
|
1616
|
-
authentication: authentication
|
|
1607
|
+
authentication: authentication,
|
|
1617
1608
|
};
|
|
1618
|
-
createOptions.item = !(0, trackingHelpers_1.isTrackingViewTemplate)(newItemTemplate)
|
|
1619
|
-
_setItemProperties(createOptions.item, newItemTemplate, serviceInfo, params, isPortal)
|
|
1620
|
-
(0, trackingHelpers_1.setTrackingOptions)(newItemTemplate, createOptions, templateDictionary);
|
|
1609
|
+
createOptions.item = !(0, trackingHelpers_1.isTrackingViewTemplate)(newItemTemplate)
|
|
1610
|
+
? _setItemProperties(createOptions.item, newItemTemplate, serviceInfo, params, isPortal)
|
|
1611
|
+
: (0, trackingHelpers_1.setTrackingOptions)(newItemTemplate, createOptions, templateDictionary);
|
|
1621
1612
|
// project the portals extent to match that of the service
|
|
1622
|
-
convertExtentWithFallback(templateDictionary.organization.defaultExtent, fallbackExtent, serviceInfo.service.spatialReference, templateDictionary.organization.helperServices.geometry.url, authentication).then(extent => {
|
|
1613
|
+
convertExtentWithFallback(templateDictionary.organization.defaultExtent, fallbackExtent, serviceInfo.service.spatialReference, templateDictionary.organization.helperServices.geometry.url, authentication).then((extent) => {
|
|
1623
1614
|
templateDictionary[itemId].solutionExtent = extent;
|
|
1624
1615
|
(0, featureServiceHelpers_1.setDefaultSpatialReference)(templateDictionary, itemId, extent.spatialReference);
|
|
1625
1616
|
createOptions.item = (0, templatization_1.replaceInTemplate)(createOptions.item, templateDictionary);
|
|
@@ -1629,7 +1620,7 @@ function _getCreateServiceOptions(newItemTemplate, authentication, templateDicti
|
|
|
1629
1620
|
createOptions.params.thumbnail = newItemTemplate.item.thumbnail;
|
|
1630
1621
|
}
|
|
1631
1622
|
resolve(createOptions);
|
|
1632
|
-
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
1623
|
+
}, (e) => reject((0, generalHelpers_1.fail)(e)));
|
|
1633
1624
|
});
|
|
1634
1625
|
}
|
|
1635
1626
|
exports._getCreateServiceOptions = _getCreateServiceOptions;
|
|
@@ -1665,7 +1656,7 @@ exports._getFallbackExtent = _getFallbackExtent;
|
|
|
1665
1656
|
*/
|
|
1666
1657
|
function _getRelationshipUpdates(args) {
|
|
1667
1658
|
const rels = {
|
|
1668
|
-
layers: []
|
|
1659
|
+
layers: [],
|
|
1669
1660
|
};
|
|
1670
1661
|
Object.keys(args.objects).forEach((k) => {
|
|
1671
1662
|
const obj = args.objects[k];
|
|
@@ -1673,7 +1664,7 @@ function _getRelationshipUpdates(args) {
|
|
|
1673
1664
|
if (obj.relationships && obj.relationships.length > 0) {
|
|
1674
1665
|
rels.layers.push({
|
|
1675
1666
|
id: obj.id,
|
|
1676
|
-
relationships: obj.relationships
|
|
1667
|
+
relationships: obj.relationships,
|
|
1677
1668
|
});
|
|
1678
1669
|
}
|
|
1679
1670
|
(0, generalHelpers_1.deleteProp)(obj, "relationships");
|
|
@@ -1696,7 +1687,7 @@ function _getContingentValuesUpdates(args) {
|
|
|
1696
1687
|
if (obj.contingentValues) {
|
|
1697
1688
|
contingentValues.push({
|
|
1698
1689
|
id: obj.id,
|
|
1699
|
-
contingentValues: obj.contingentValues
|
|
1690
|
+
contingentValues: obj.contingentValues,
|
|
1700
1691
|
});
|
|
1701
1692
|
}
|
|
1702
1693
|
(0, generalHelpers_1.deleteProp)(obj, "contingentValues");
|
|
@@ -1721,34 +1712,33 @@ function _getUpdate(url, id, obj, args, type) {
|
|
|
1721
1712
|
url: (0, generalHelpers_1.checkUrlPathTermination)(url) + id + "/deleteFromDefinition",
|
|
1722
1713
|
params: {
|
|
1723
1714
|
deleteFromDefinition: {
|
|
1724
|
-
fields: obj && obj.hasOwnProperty("deleteFields") ? obj.deleteFields : []
|
|
1725
|
-
}
|
|
1726
|
-
}
|
|
1715
|
+
fields: obj && obj.hasOwnProperty("deleteFields") ? obj.deleteFields : [],
|
|
1716
|
+
},
|
|
1717
|
+
},
|
|
1727
1718
|
},
|
|
1728
1719
|
update: {
|
|
1729
|
-
url: (0, generalHelpers_1.checkUrlPathTermination)(url) +
|
|
1730
|
-
(id ? `${id}/updateDefinition` : "updateDefinition"),
|
|
1720
|
+
url: (0, generalHelpers_1.checkUrlPathTermination)(url) + (id ? `${id}/updateDefinition` : "updateDefinition"),
|
|
1731
1721
|
params: {
|
|
1732
|
-
updateDefinition: obj
|
|
1733
|
-
}
|
|
1722
|
+
updateDefinition: obj,
|
|
1723
|
+
},
|
|
1734
1724
|
},
|
|
1735
1725
|
add: {
|
|
1736
1726
|
url: (0, generalHelpers_1.checkUrlPathTermination)(url) + "addToDefinition",
|
|
1737
1727
|
params: {
|
|
1738
|
-
addToDefinition: obj
|
|
1739
|
-
}
|
|
1728
|
+
addToDefinition: obj,
|
|
1729
|
+
},
|
|
1740
1730
|
},
|
|
1741
1731
|
refresh: {
|
|
1742
1732
|
url: (0, generalHelpers_1.checkUrlPathTermination)(url) + "refresh",
|
|
1743
1733
|
params: {
|
|
1744
|
-
f: "json"
|
|
1745
|
-
}
|
|
1746
|
-
}
|
|
1734
|
+
f: "json",
|
|
1735
|
+
},
|
|
1736
|
+
},
|
|
1747
1737
|
};
|
|
1748
1738
|
return {
|
|
1749
1739
|
url: ops[type].url,
|
|
1750
1740
|
params: ops[type].params,
|
|
1751
|
-
args: args
|
|
1741
|
+
args: args,
|
|
1752
1742
|
};
|
|
1753
1743
|
}
|
|
1754
1744
|
exports._getUpdate = _getUpdate;
|
|
@@ -1786,19 +1776,11 @@ function _reportVariablesInItem(itemId, itemType, base, data) {
|
|
|
1786
1776
|
// Provide feedback about any remaining unresolved variables
|
|
1787
1777
|
/* istanbul ignore else */
|
|
1788
1778
|
if (base && (0, templatization_1.hasUnresolvedVariables)(base)) {
|
|
1789
|
-
console.log(itemId +
|
|
1790
|
-
" (" +
|
|
1791
|
-
itemType +
|
|
1792
|
-
") contains variables in base: " +
|
|
1793
|
-
JSON.stringify(getUnresolved(base)));
|
|
1779
|
+
console.log(itemId + " (" + itemType + ") contains variables in base: " + JSON.stringify(getUnresolved(base)));
|
|
1794
1780
|
}
|
|
1795
1781
|
/* istanbul ignore else */
|
|
1796
1782
|
if (data && (0, templatization_1.hasUnresolvedVariables)(data)) {
|
|
1797
|
-
console.log(itemId +
|
|
1798
|
-
" (" +
|
|
1799
|
-
itemType +
|
|
1800
|
-
") contains variables in data: " +
|
|
1801
|
-
JSON.stringify(getUnresolved(data)));
|
|
1783
|
+
console.log(itemId + " (" + itemType + ") contains variables in data: " + JSON.stringify(getUnresolved(data)));
|
|
1802
1784
|
}
|
|
1803
1785
|
}
|
|
1804
1786
|
exports._reportVariablesInItem = _reportVariablesInItem;
|
|
@@ -1815,16 +1797,7 @@ exports._reportVariablesInItem = _reportVariablesInItem;
|
|
|
1815
1797
|
*/
|
|
1816
1798
|
function _setItemProperties(item, itemTemplate, serviceInfo, params, isPortal) {
|
|
1817
1799
|
// Set the capabilities
|
|
1818
|
-
const portalCapabilities = [
|
|
1819
|
-
"Create",
|
|
1820
|
-
"Query",
|
|
1821
|
-
"Editing",
|
|
1822
|
-
"Update",
|
|
1823
|
-
"Delete",
|
|
1824
|
-
"Uploads",
|
|
1825
|
-
"Sync",
|
|
1826
|
-
"Extract"
|
|
1827
|
-
];
|
|
1800
|
+
const portalCapabilities = ["Create", "Query", "Editing", "Update", "Delete", "Uploads", "Sync", "Extract"];
|
|
1828
1801
|
const capabilities = (0, generalHelpers_1.getProp)(serviceInfo, "service.capabilities") || (isPortal ? "" : []);
|
|
1829
1802
|
item.capabilities = isPortal
|
|
1830
1803
|
? capabilities
|
|
@@ -1844,7 +1817,7 @@ function _setItemProperties(item, itemTemplate, serviceInfo, params, isPortal) {
|
|
|
1844
1817
|
"sourceSchemaChangesAllowed",
|
|
1845
1818
|
"isUpdatableView",
|
|
1846
1819
|
"capabilities",
|
|
1847
|
-
"isMultiServicesView"
|
|
1820
|
+
"isMultiServicesView",
|
|
1848
1821
|
];
|
|
1849
1822
|
const deleteKeys = ["layers", "tables"];
|
|
1850
1823
|
/* istanbul ignore else */
|
|
@@ -1854,7 +1827,7 @@ function _setItemProperties(item, itemTemplate, serviceInfo, params, isPortal) {
|
|
|
1854
1827
|
}
|
|
1855
1828
|
const itemKeys = Object.keys(item);
|
|
1856
1829
|
const serviceKeys = Object.keys(serviceInfo.service);
|
|
1857
|
-
serviceKeys.forEach(k => {
|
|
1830
|
+
serviceKeys.forEach((k) => {
|
|
1858
1831
|
/* istanbul ignore else */
|
|
1859
1832
|
if (itemKeys.indexOf(k) === -1 && deleteKeys.indexOf(k) < 0) {
|
|
1860
1833
|
item[k] = serviceInfo.service[k];
|
|
@@ -1868,8 +1841,7 @@ function _setItemProperties(item, itemTemplate, serviceInfo, params, isPortal) {
|
|
|
1868
1841
|
});
|
|
1869
1842
|
// Enable editor tracking on layer with related tables is not supported.
|
|
1870
1843
|
/* istanbul ignore else */
|
|
1871
|
-
if (item.isMultiServicesView &&
|
|
1872
|
-
(0, generalHelpers_1.getProp)(item, "editorTrackingInfo.enableEditorTracking")) {
|
|
1844
|
+
if (item.isMultiServicesView && (0, generalHelpers_1.getProp)(item, "editorTrackingInfo.enableEditorTracking")) {
|
|
1873
1845
|
item.editorTrackingInfo.enableEditorTracking = false;
|
|
1874
1846
|
params["editorTrackingInfo"] = item.editorTrackingInfo;
|
|
1875
1847
|
}
|
|
@@ -1878,8 +1850,7 @@ function _setItemProperties(item, itemTemplate, serviceInfo, params, isPortal) {
|
|
|
1878
1850
|
// portal will fail when initialExtent is defined but null
|
|
1879
1851
|
// removed for issue #449 causing FS to fail to create on portal
|
|
1880
1852
|
/* istanbul ignore else */
|
|
1881
|
-
if (Object.keys(item).indexOf("initialExtent") > -1 &&
|
|
1882
|
-
!item.initialExtent) {
|
|
1853
|
+
if (Object.keys(item).indexOf("initialExtent") > -1 && !item.initialExtent) {
|
|
1883
1854
|
(0, generalHelpers_1.deleteProp)(item, "initialExtent");
|
|
1884
1855
|
}
|
|
1885
1856
|
}
|
|
@@ -1894,26 +1865,21 @@ exports._setItemProperties = _setItemProperties;
|
|
|
1894
1865
|
*/
|
|
1895
1866
|
function _updateIndexesForRelationshipKeyFields(serviceInfo) {
|
|
1896
1867
|
const layersAndTables = (serviceInfo.layers || []).concat(serviceInfo.tables || []);
|
|
1897
|
-
layersAndTables.forEach(item => {
|
|
1868
|
+
layersAndTables.forEach((item) => {
|
|
1898
1869
|
const relationships = item.relationships;
|
|
1899
1870
|
const indexes = item.indexes;
|
|
1900
1871
|
/* istanbul ignore else */
|
|
1901
|
-
if (relationships &&
|
|
1902
|
-
relationships.length > 0 &&
|
|
1903
|
-
indexes &&
|
|
1904
|
-
indexes.length > 0) {
|
|
1872
|
+
if (relationships && relationships.length > 0 && indexes && indexes.length > 0) {
|
|
1905
1873
|
const keyFields = relationships.reduce((acc, v) => {
|
|
1906
1874
|
/* istanbul ignore else */
|
|
1907
|
-
if (v.role === "esriRelRoleOrigin" &&
|
|
1908
|
-
v.keyField &&
|
|
1909
|
-
acc.indexOf(v.keyField) < 0) {
|
|
1875
|
+
if (v.role === "esriRelRoleOrigin" && v.keyField && acc.indexOf(v.keyField) < 0) {
|
|
1910
1876
|
acc.push(v.keyField);
|
|
1911
1877
|
}
|
|
1912
1878
|
return acc;
|
|
1913
1879
|
}, []);
|
|
1914
|
-
indexes.map(i => {
|
|
1880
|
+
indexes.map((i) => {
|
|
1915
1881
|
/* istanbul ignore else */
|
|
1916
|
-
if (keyFields.some(k => {
|
|
1882
|
+
if (keyFields.some((k) => {
|
|
1917
1883
|
const regEx = new RegExp(`\\b${k}\\b`);
|
|
1918
1884
|
return regEx.test(i.fields);
|
|
1919
1885
|
})) {
|
|
@@ -1942,7 +1908,7 @@ function _updateItemURL(id, url, authentication, numAttempts = 1) {
|
|
|
1942
1908
|
return new Promise((resolve, reject) => {
|
|
1943
1909
|
// Update the item's URL
|
|
1944
1910
|
const options = { item: { id, url }, authentication: authentication };
|
|
1945
|
-
(0, arcgis_rest_portal_1.updateItem)(options).then(result => {
|
|
1911
|
+
(0, arcgis_rest_portal_1.updateItem)(options).then((result) => {
|
|
1946
1912
|
if (!result.success) {
|
|
1947
1913
|
reject((0, generalHelpers_1.fail)(result));
|
|
1948
1914
|
}
|
|
@@ -1950,7 +1916,7 @@ function _updateItemURL(id, url, authentication, numAttempts = 1) {
|
|
|
1950
1916
|
// Get the item to see if the URL really changed; we'll delay a bit before testing because AGO
|
|
1951
1917
|
// has a timing problem with URL updates
|
|
1952
1918
|
setTimeout(() => {
|
|
1953
|
-
(0, arcgis_rest_portal_1.getItem)(id, { authentication: authentication }).then(item => {
|
|
1919
|
+
(0, arcgis_rest_portal_1.getItem)(id, { authentication: authentication }).then((item) => {
|
|
1954
1920
|
const iBrace = item.url.indexOf("{");
|
|
1955
1921
|
if (iBrace > -1) {
|
|
1956
1922
|
console.warn(id + " has template variable: " + item.url.substr(iBrace));
|
|
@@ -1960,15 +1926,7 @@ function _updateItemURL(id, url, authentication, numAttempts = 1) {
|
|
|
1960
1926
|
}
|
|
1961
1927
|
else {
|
|
1962
1928
|
// If it fails, try again if we have sufficient attempts remaining
|
|
1963
|
-
const errorMsg = "URL not updated for " +
|
|
1964
|
-
item.type +
|
|
1965
|
-
" " +
|
|
1966
|
-
item.id +
|
|
1967
|
-
": " +
|
|
1968
|
-
item.url +
|
|
1969
|
-
" (" +
|
|
1970
|
-
numAttempts +
|
|
1971
|
-
")";
|
|
1929
|
+
const errorMsg = "URL not updated for " + item.type + " " + item.id + ": " + item.url + " (" + numAttempts + ")";
|
|
1972
1930
|
if (--numAttempts > 0) {
|
|
1973
1931
|
_updateItemURL(id, url, authentication, numAttempts).then(resolve, reject);
|
|
1974
1932
|
}
|
|
@@ -1977,10 +1935,10 @@ function _updateItemURL(id, url, authentication, numAttempts = 1) {
|
|
|
1977
1935
|
reject(errorMsg);
|
|
1978
1936
|
}
|
|
1979
1937
|
}
|
|
1980
|
-
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
1938
|
+
}, (e) => reject((0, generalHelpers_1.fail)(e)));
|
|
1981
1939
|
}, msLag);
|
|
1982
1940
|
}
|
|
1983
|
-
}, e => reject((0, generalHelpers_1.fail)(e)));
|
|
1941
|
+
}, (e) => reject((0, generalHelpers_1.fail)(e)));
|
|
1984
1942
|
});
|
|
1985
1943
|
}
|
|
1986
1944
|
exports._updateItemURL = _updateItemURL;
|