@esri/solution-common 5.2.3 → 5.2.4
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.d.ts +29 -0
- package/dist/cjs/completeItem.js +92 -0
- package/dist/cjs/completeItem.js.map +1 -0
- package/dist/cjs/create-hub-request-options.d.ts +29 -0
- package/dist/cjs/create-hub-request-options.js +64 -0
- package/dist/cjs/create-hub-request-options.js.map +1 -0
- package/dist/cjs/deleteHelpers/deleteEmptyGroups.d.ts +24 -0
- package/dist/cjs/deleteHelpers/deleteEmptyGroups.js +42 -0
- package/dist/cjs/deleteHelpers/deleteEmptyGroups.js.map +1 -0
- package/dist/cjs/deleteHelpers/deleteGroupIfEmpty.d.ts +27 -0
- package/dist/cjs/deleteHelpers/deleteGroupIfEmpty.js +97 -0
- package/dist/cjs/deleteHelpers/deleteGroupIfEmpty.js.map +1 -0
- package/dist/cjs/deleteHelpers/deleteSolutionContents.d.ts +38 -0
- package/dist/cjs/deleteHelpers/deleteSolutionContents.js +130 -0
- package/dist/cjs/deleteHelpers/deleteSolutionContents.js.map +1 -0
- package/dist/cjs/deleteHelpers/deleteSolutionFolder.d.ts +29 -0
- package/dist/cjs/deleteHelpers/deleteSolutionFolder.js +79 -0
- package/dist/cjs/deleteHelpers/deleteSolutionFolder.js.map +1 -0
- package/dist/cjs/deleteHelpers/deleteSolutionItem.d.ts +30 -0
- package/dist/cjs/deleteHelpers/deleteSolutionItem.js +54 -0
- package/dist/cjs/deleteHelpers/deleteSolutionItem.js.map +1 -0
- package/dist/cjs/deleteHelpers/index.d.ts +22 -0
- package/dist/cjs/deleteHelpers/index.js +26 -0
- package/dist/cjs/deleteHelpers/index.js.map +1 -0
- package/dist/cjs/deleteHelpers/reconstructBuildOrderIds.d.ts +27 -0
- package/dist/cjs/deleteHelpers/reconstructBuildOrderIds.js +34 -0
- package/dist/cjs/deleteHelpers/reconstructBuildOrderIds.js.map +1 -0
- package/dist/cjs/deleteHelpers/removeItems.d.ts +34 -0
- package/dist/cjs/deleteHelpers/removeItems.js +112 -0
- package/dist/cjs/deleteHelpers/removeItems.js.map +1 -0
- package/dist/cjs/deleteHelpers/reportProgress.d.ts +27 -0
- package/dist/cjs/deleteHelpers/reportProgress.js +46 -0
- package/dist/cjs/deleteHelpers/reportProgress.js.map +1 -0
- package/dist/cjs/deleteSolution.d.ts +55 -0
- package/dist/cjs/deleteSolution.js +107 -0
- package/dist/cjs/deleteSolution.js.map +1 -0
- package/dist/cjs/dependencies.d.ts +26 -0
- package/dist/cjs/dependencies.js +171 -0
- package/dist/cjs/dependencies.js.map +1 -0
- package/dist/cjs/featureServiceHelpers.d.ts +799 -0
- package/dist/cjs/featureServiceHelpers.js +2438 -0
- package/dist/cjs/featureServiceHelpers.js.map +1 -0
- package/dist/cjs/formHelpers.d.ts +41 -0
- package/dist/cjs/formHelpers.js +78 -0
- package/dist/cjs/formHelpers.js.map +1 -0
- package/dist/cjs/generalHelpers.d.ts +433 -0
- package/dist/cjs/generalHelpers.js +925 -0
- package/dist/cjs/generalHelpers.js.map +1 -0
- package/dist/cjs/get-subscription-info.d.ts +27 -0
- package/dist/cjs/get-subscription-info.js +39 -0
- package/dist/cjs/get-subscription-info.js.map +1 -0
- package/dist/cjs/getDeletableSolutionInfo.d.ts +29 -0
- package/dist/cjs/getDeletableSolutionInfo.js +53 -0
- package/dist/cjs/getDeletableSolutionInfo.js.map +1 -0
- package/dist/cjs/getItemTypeAbbrev.d.ts +19 -0
- package/dist/cjs/getItemTypeAbbrev.js +186 -0
- package/dist/cjs/getItemTypeAbbrev.js.map +1 -0
- package/dist/cjs/getSolutionSummary.d.ts +27 -0
- package/dist/cjs/getSolutionSummary.js +101 -0
- package/dist/cjs/getSolutionSummary.js.map +1 -0
- package/dist/cjs/index.d.ts +46 -0
- package/dist/cjs/index.js +50 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/interfaces.d.ts +1362 -0
- package/dist/cjs/interfaces.js +77 -0
- package/dist/cjs/interfaces.js.map +1 -0
- package/dist/cjs/libConnectors.d.ts +73 -0
- package/dist/cjs/libConnectors.js +115 -0
- package/dist/cjs/libConnectors.js.map +1 -0
- package/dist/cjs/migrations/apply-schema.d.ts +24 -0
- package/dist/cjs/migrations/apply-schema.js +36 -0
- package/dist/cjs/migrations/apply-schema.js.map +1 -0
- package/dist/cjs/migrations/is-legacy-solution.d.ts +24 -0
- package/dist/cjs/migrations/is-legacy-solution.js +40 -0
- package/dist/cjs/migrations/is-legacy-solution.js.map +1 -0
- package/dist/cjs/migrations/upgrade-three-dot-one.d.ts +27 -0
- package/dist/cjs/migrations/upgrade-three-dot-one.js +49 -0
- package/dist/cjs/migrations/upgrade-three-dot-one.js.map +1 -0
- package/dist/cjs/migrations/upgrade-three-dot-zero.d.ts +27 -0
- package/dist/cjs/migrations/upgrade-three-dot-zero.js +43 -0
- package/dist/cjs/migrations/upgrade-three-dot-zero.js.map +1 -0
- package/dist/cjs/migrations/upgrade-two-dot-five.d.ts +24 -0
- package/dist/cjs/migrations/upgrade-two-dot-five.js +73 -0
- package/dist/cjs/migrations/upgrade-two-dot-five.js.map +1 -0
- package/dist/cjs/migrations/upgrade-two-dot-four.d.ts +24 -0
- package/dist/cjs/migrations/upgrade-two-dot-four.js +72 -0
- package/dist/cjs/migrations/upgrade-two-dot-four.js.map +1 -0
- package/dist/cjs/migrations/upgrade-two-dot-one.d.ts +7 -0
- package/dist/cjs/migrations/upgrade-two-dot-one.js +39 -0
- package/dist/cjs/migrations/upgrade-two-dot-one.js.map +1 -0
- package/dist/cjs/migrations/upgrade-two-dot-seven.d.ts +23 -0
- package/dist/cjs/migrations/upgrade-two-dot-seven.js +58 -0
- package/dist/cjs/migrations/upgrade-two-dot-seven.js.map +1 -0
- package/dist/cjs/migrations/upgrade-two-dot-six.d.ts +27 -0
- package/dist/cjs/migrations/upgrade-two-dot-six.js +61 -0
- package/dist/cjs/migrations/upgrade-two-dot-six.js.map +1 -0
- package/dist/cjs/migrations/upgrade-two-dot-three.d.ts +23 -0
- package/dist/cjs/migrations/upgrade-two-dot-three.js +55 -0
- package/dist/cjs/migrations/upgrade-two-dot-three.js.map +1 -0
- package/dist/cjs/migrations/upgrade-two-dot-two.d.ts +23 -0
- package/dist/cjs/migrations/upgrade-two-dot-two.js +58 -0
- package/dist/cjs/migrations/upgrade-two-dot-two.js.map +1 -0
- package/dist/cjs/migrations/upgrade-two-dot-zero.d.ts +44 -0
- package/dist/cjs/migrations/upgrade-two-dot-zero.js +95 -0
- package/dist/cjs/migrations/upgrade-two-dot-zero.js.map +1 -0
- package/dist/cjs/migrator.d.ts +25 -0
- package/dist/cjs/migrator.js +77 -0
- package/dist/cjs/migrator.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/resourceHelpers.d.ts +191 -0
- package/dist/cjs/resourceHelpers.js +384 -0
- package/dist/cjs/resourceHelpers.js.map +1 -0
- package/dist/cjs/resources/add-resource-from-blob.d.ts +26 -0
- package/dist/cjs/resources/add-resource-from-blob.js +52 -0
- package/dist/cjs/resources/add-resource-from-blob.js.map +1 -0
- package/dist/cjs/resources/addMetadataFromBlob.d.ts +25 -0
- package/dist/cjs/resources/addMetadataFromBlob.js +43 -0
- package/dist/cjs/resources/addMetadataFromBlob.js.map +1 -0
- package/dist/cjs/resources/convert-item-resource-to-storage-resource.d.ts +32 -0
- package/dist/cjs/resources/convert-item-resource-to-storage-resource.js +70 -0
- package/dist/cjs/resources/convert-item-resource-to-storage-resource.js.map +1 -0
- package/dist/cjs/resources/convert-storage-resource-to-item-resource.d.ts +29 -0
- package/dist/cjs/resources/convert-storage-resource-to-item-resource.js +70 -0
- package/dist/cjs/resources/convert-storage-resource-to-item-resource.js.map +1 -0
- package/dist/cjs/resources/copyAssociatedFiles.d.ts +67 -0
- package/dist/cjs/resources/copyAssociatedFiles.js +304 -0
- package/dist/cjs/resources/copyAssociatedFiles.js.map +1 -0
- package/dist/cjs/resources/copyDataIntoItem.d.ts +33 -0
- package/dist/cjs/resources/copyDataIntoItem.js +62 -0
- package/dist/cjs/resources/copyDataIntoItem.js.map +1 -0
- package/dist/cjs/resources/copyMetadataIntoItem.d.ts +26 -0
- package/dist/cjs/resources/copyMetadataIntoItem.js +46 -0
- package/dist/cjs/resources/copyMetadataIntoItem.js.map +1 -0
- package/dist/cjs/resources/copyResourceIntoZip.d.ts +33 -0
- package/dist/cjs/resources/copyResourceIntoZip.js +78 -0
- package/dist/cjs/resources/copyResourceIntoZip.js.map +1 -0
- package/dist/cjs/resources/copyZipIntoItem.d.ts +25 -0
- package/dist/cjs/resources/copyZipIntoItem.js +54 -0
- package/dist/cjs/resources/copyZipIntoItem.js.map +1 -0
- package/dist/cjs/resources/createCopyResults.d.ts +25 -0
- package/dist/cjs/resources/createCopyResults.js +36 -0
- package/dist/cjs/resources/createCopyResults.js.map +1 -0
- package/dist/cjs/resources/get-blob.d.ts +26 -0
- package/dist/cjs/resources/get-blob.js +27 -0
- package/dist/cjs/resources/get-blob.js.map +1 -0
- package/dist/cjs/resources/getItemResourcesFilesFromPaths.d.ts +24 -0
- package/dist/cjs/resources/getItemResourcesFilesFromPaths.js +49 -0
- package/dist/cjs/resources/getItemResourcesFilesFromPaths.js.map +1 -0
- package/dist/cjs/resources/getItemResourcesPaths.d.ts +26 -0
- package/dist/cjs/resources/getItemResourcesPaths.js +76 -0
- package/dist/cjs/resources/getItemResourcesPaths.js.map +1 -0
- package/dist/cjs/resources/index.d.ts +29 -0
- package/dist/cjs/resources/index.js +33 -0
- package/dist/cjs/resources/index.js.map +1 -0
- package/dist/cjs/resources/solution-resource.d.ts +35 -0
- package/dist/cjs/resources/solution-resource.js +31 -0
- package/dist/cjs/resources/solution-resource.js.map +1 -0
- package/dist/cjs/resources/transform-resource-paths-to-solution-resources.d.ts +56 -0
- package/dist/cjs/resources/transform-resource-paths-to-solution-resources.js +146 -0
- package/dist/cjs/resources/transform-resource-paths-to-solution-resources.js.map +1 -0
- package/dist/cjs/restHelpers.d.ts +607 -0
- package/dist/cjs/restHelpers.js +1954 -0
- package/dist/cjs/restHelpers.js.map +1 -0
- package/dist/cjs/restHelpersGet.d.ts +288 -0
- package/dist/cjs/restHelpersGet.js +804 -0
- package/dist/cjs/restHelpersGet.js.map +1 -0
- package/dist/cjs/sharing/index.d.ts +16 -0
- package/dist/cjs/sharing/index.js +20 -0
- package/dist/cjs/sharing/index.js.map +1 -0
- package/dist/cjs/sharing/share-item-to-groups.d.ts +26 -0
- package/dist/cjs/sharing/share-item-to-groups.js +44 -0
- package/dist/cjs/sharing/share-item-to-groups.js.map +1 -0
- package/dist/cjs/templatization.d.ts +139 -0
- package/dist/cjs/templatization.js +316 -0
- package/dist/cjs/templatization.js.map +1 -0
- package/dist/cjs/trackingHelpers.d.ts +116 -0
- package/dist/cjs/trackingHelpers.js +217 -0
- package/dist/cjs/trackingHelpers.js.map +1 -0
- package/dist/cjs/velocityHelpers.d.ts +57 -0
- package/dist/cjs/velocityHelpers.js +135 -0
- package/dist/cjs/velocityHelpers.js.map +1 -0
- package/dist/cjs/workflowHelpers.d.ts +37 -0
- package/dist/cjs/workflowHelpers.js +77 -0
- package/dist/cjs/workflowHelpers.js.map +1 -0
- package/dist/cjs/workforceHelpers.d.ts +115 -0
- package/dist/cjs/workforceHelpers.js +749 -0
- package/dist/cjs/workforceHelpers.js.map +1 -0
- package/dist/cjs/zip-utils.d.ts +76 -0
- package/dist/cjs/zip-utils.js +142 -0
- package/dist/cjs/zip-utils.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/package.json +2 -2
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** @license
|
|
2
|
+
* Copyright 2021 Esri
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Provides functions for accessing a complete item.
|
|
18
|
+
*
|
|
19
|
+
* @module completeItem
|
|
20
|
+
*/
|
|
21
|
+
import { ICompleteItem, UserSession } from "./interfaces";
|
|
22
|
+
/**
|
|
23
|
+
* Gets everything about an item.
|
|
24
|
+
*
|
|
25
|
+
* @param itemId Id of an item whose information is sought
|
|
26
|
+
* @param authentication Credentials for the request
|
|
27
|
+
* @returns Promise that will resolve with everything known about the item
|
|
28
|
+
*/
|
|
29
|
+
export declare function getCompleteItem(itemId: string, authentication: UserSession): Promise<ICompleteItem>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** @license
|
|
3
|
+
* Copyright 2021 Esri
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.getCompleteItem = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const restHelpers = tslib_1.__importStar(require("./restHelpers"));
|
|
21
|
+
const restHelpersGet = tslib_1.__importStar(require("./restHelpersGet"));
|
|
22
|
+
const workflowHelpers = tslib_1.__importStar(require("./workflowHelpers"));
|
|
23
|
+
// ------------------------------------------------------------------------------------------------------------------ //
|
|
24
|
+
/**
|
|
25
|
+
* Gets everything about an item.
|
|
26
|
+
*
|
|
27
|
+
* @param itemId Id of an item whose information is sought
|
|
28
|
+
* @param authentication Credentials for the request
|
|
29
|
+
* @returns Promise that will resolve with everything known about the item
|
|
30
|
+
*/
|
|
31
|
+
function getCompleteItem(itemId, authentication) {
|
|
32
|
+
let itemBase;
|
|
33
|
+
let completeItem;
|
|
34
|
+
return restHelpersGet
|
|
35
|
+
.getItemBase(itemId, authentication)
|
|
36
|
+
.then((response) => {
|
|
37
|
+
itemBase = response;
|
|
38
|
+
return Promise.all([
|
|
39
|
+
restHelpersGet.getItemDataAsFile(itemId, itemBase.name, authentication),
|
|
40
|
+
restHelpersGet.getItemThumbnailAsFile(itemId, itemBase.thumbnail, false, authentication),
|
|
41
|
+
restHelpersGet.getItemMetadataAsFile(itemId, authentication),
|
|
42
|
+
restHelpersGet.getItemResourcesFiles(itemId, authentication),
|
|
43
|
+
restHelpersGet.getItemRelatedItemsInSameDirection(itemId, "forward", authentication),
|
|
44
|
+
restHelpersGet.getItemRelatedItemsInSameDirection(itemId, "reverse", authentication)
|
|
45
|
+
]);
|
|
46
|
+
})
|
|
47
|
+
.then(responses => {
|
|
48
|
+
const [itemData, itemThumbnail, itemMetadata, itemResources, itemFwdRelatedItems, itemRevRelatedItems] = responses;
|
|
49
|
+
// Summarize what we have
|
|
50
|
+
// ----------------------
|
|
51
|
+
// (itemBase: IItem) text/plain JSON
|
|
52
|
+
// (itemData: File) */*
|
|
53
|
+
// (itemThumbnail: File) image/*
|
|
54
|
+
// (itemMetadata: File) application/xml
|
|
55
|
+
// (itemResources: File[]) list of */*
|
|
56
|
+
// (itemFwdRelatedItems: IRelatedItems[]) list of forward relationshipType/relatedItems[] pairs
|
|
57
|
+
// (itemRevRelatedItems: IRelatedItems[]) list of reverse relationshipType/relatedItems[] pairs
|
|
58
|
+
completeItem = {
|
|
59
|
+
base: itemBase,
|
|
60
|
+
data: itemData,
|
|
61
|
+
thumbnail: itemThumbnail,
|
|
62
|
+
metadata: itemMetadata,
|
|
63
|
+
resources: itemResources,
|
|
64
|
+
fwdRelatedItems: itemFwdRelatedItems,
|
|
65
|
+
revRelatedItems: itemRevRelatedItems
|
|
66
|
+
};
|
|
67
|
+
if (itemBase.type === "Feature Service") {
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
69
|
+
return restHelpers.getFeatureServiceProperties(itemBase.url, authentication);
|
|
70
|
+
}
|
|
71
|
+
else if (itemBase.type === "Workflow") {
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
73
|
+
return restHelpers.getWorkflowConfigurationZip(itemBase.id, authentication);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
return Promise.resolve(null);
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
.then(async (properties) => {
|
|
80
|
+
if (properties) {
|
|
81
|
+
if (completeItem.base.type === "Feature Service") {
|
|
82
|
+
completeItem.featureServiceProperties = properties;
|
|
83
|
+
}
|
|
84
|
+
else if (completeItem.base.type === "Workflow") {
|
|
85
|
+
completeItem.workflowConfiguration = await workflowHelpers.extractWorkflowFromZipFile(properties);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return Promise.resolve(completeItem);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
exports.getCompleteItem = getCompleteItem;
|
|
92
|
+
//# sourceMappingURL=completeItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completeItem.js","sourceRoot":"","sources":["../../src/completeItem.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAaH,mEAA6C;AAC7C,yEAAmD;AACnD,2EAAqD;AAErD,wHAAwH;AAExH;;;;;;GAMG;AACH,SAAgB,e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E;YACvC,mEAAmE;YACnE,OAAO,WAAW,CAAC,2BAA2B,CAC5C,QAAQ,CAAC,GAAG,EACZ,cAAc,CACf,CAAC;SAEH;aAAM,IAAI,QAAQ,CAAC,IAAI,KAAK,UAAU,EAAE;YACvC,mEAAmE;YACnE,OAAO,WAAW,CAAC,2BAA2B,CAC5C,QAAQ,CAAC,EAAE,EACX,cAAc,CACf,CAAC;SAEH;aAAM;YACL,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAC9B;IACH,CAAC,CAAC;SACD,IAAI,CAAC,KAAK,EAAE,UAA4C,EAAE,EAAE;QAC3D,IAAI,UAAU,EAAE;YACd,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,KAAK,iBAAiB,EAAE;gBAChD,YAAY,CAAC,wBAAwB,GAAG,UAAU,CAAC;aACpD;iBAAM,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE;gBAChD,YAAY,CAAC,qBAAqB,GAAG,MAAM,eAAe,CAAC,0BAA0B,CAAC,UAAkB,CAAC,CAAC;aAC3G;SACF;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACP,CAAC;AA1FD,0CA0FC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** @license
|
|
2
|
+
* Copyright 2018 Esri
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { UserSession } from "./interfaces";
|
|
17
|
+
import { IHubUserRequestOptions } from "@esri/hub-common";
|
|
18
|
+
/**
|
|
19
|
+
* Create a IHubUserRequestOptions object from
|
|
20
|
+
* the UserSession
|
|
21
|
+
* If passed, it will use `templateDictionary`
|
|
22
|
+
* values instead of making additional requests
|
|
23
|
+
*
|
|
24
|
+
* @export
|
|
25
|
+
* @param {UserSession} authentication
|
|
26
|
+
* @param {*} templateDictionary
|
|
27
|
+
* @returns {IHubUserRequestOptions}
|
|
28
|
+
*/
|
|
29
|
+
export declare function createHubRequestOptions(authentication: UserSession, templateDictionary?: any): Promise<IHubUserRequestOptions>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** @license
|
|
3
|
+
* Copyright 2018 Esri
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.createHubRequestOptions = void 0;
|
|
19
|
+
const hub_common_1 = require("@esri/hub-common");
|
|
20
|
+
const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
|
|
21
|
+
/**
|
|
22
|
+
* Create a IHubUserRequestOptions object from
|
|
23
|
+
* the UserSession
|
|
24
|
+
* If passed, it will use `templateDictionary`
|
|
25
|
+
* values instead of making additional requests
|
|
26
|
+
*
|
|
27
|
+
* @export
|
|
28
|
+
* @param {UserSession} authentication
|
|
29
|
+
* @param {*} templateDictionary
|
|
30
|
+
* @returns {IHubUserRequestOptions}
|
|
31
|
+
*/
|
|
32
|
+
function createHubRequestOptions(authentication, templateDictionary = {}) {
|
|
33
|
+
// We used to pull the user
|
|
34
|
+
// the template dictionary, but ran into issues
|
|
35
|
+
// with the user.groups being filtered to groups
|
|
36
|
+
// the user owns, vs all groups the user belongs to
|
|
37
|
+
// this was problematic as we need to check if the user
|
|
38
|
+
// can add more groups, based on how close they are to
|
|
39
|
+
// the max 512 group limit.
|
|
40
|
+
// At this time we are simply fetching the user directly
|
|
41
|
+
const promises = [];
|
|
42
|
+
if (templateDictionary.organization) {
|
|
43
|
+
promises.push(Promise.resolve(templateDictionary.organization));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
promises.push((0, arcgis_rest_portal_1.getSelf)({ authentication }));
|
|
47
|
+
}
|
|
48
|
+
// always get the user
|
|
49
|
+
promises.push((0, arcgis_rest_portal_1.getUser)({ authentication }));
|
|
50
|
+
return Promise.all(promises).then(([pSelf, user]) => {
|
|
51
|
+
pSelf.user = user;
|
|
52
|
+
const ro = {
|
|
53
|
+
authentication,
|
|
54
|
+
portalSelf: pSelf,
|
|
55
|
+
isPortal: pSelf.isPortal
|
|
56
|
+
};
|
|
57
|
+
if (!pSelf.isPortal) {
|
|
58
|
+
ro.hubApiUrl = (0, hub_common_1.getHubUrlFromPortal)(pSelf);
|
|
59
|
+
}
|
|
60
|
+
return ro;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
exports.createHubRequestOptions = createHubRequestOptions;
|
|
64
|
+
//# sourceMappingURL=create-hub-request-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-hub-request-options.js","sourceRoot":"","sources":["../../src/create-hub-request-options.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAIH,iDAA+E;AAE/E,iEAA4D;AAE5D;;;;;;;;;;GAUG;AACH,SAAgB,uBAAuB,CACrC,cAA2B,EAC3B,qBAA0B,EAAE;IAE5B,2BAA2B;IAC3B,+CAA+C;IAC/C,gDAAgD;IAChD,mDAAmD;IACnD,uDAAuD;IACvD,sDAAsD;IACtD,2BAA2B;IAE3B,wDAAwD;IACxD,MAAM,QAAQ,GAAG,EAAE,CAAC;IACpB,IAAI,kBAAkB,CAAC,YAAY,EAAE;QACnC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC,CAAC;KACjE;SAAM;QACL,QAAQ,CAAC,IAAI,CAAC,IAAA,4BAAO,EAAC,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC;KAC5C;IACD,sBAAsB;IACtB,QAAQ,CAAC,IAAI,CAAC,IAAA,4BAAO,EAAC,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC;IAE3C,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE;QAClD,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;QAClB,MAAM,EAAE,GAAG;YACT,cAAc;YACd,UAAU,EAAE,KAAK;YACjB,QAAQ,EAAE,KAAK,CAAC,QAAQ;SACC,CAAC;QAE5B,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YACnB,EAAE,CAAC,SAAS,GAAG,IAAA,gCAAmB,EAAC,KAAK,CAAC,CAAC;SAC3C;QAED,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC;AApCD,0DAoCC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** @license
|
|
2
|
+
* Copyright 2021 Esri
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { UserSession } from "../interfaces";
|
|
17
|
+
/**
|
|
18
|
+
* Deletes a set of empty groups if they're empty and belong to the user in the authentication.
|
|
19
|
+
*
|
|
20
|
+
* @param groups Ids of the groups to be deleted
|
|
21
|
+
* @param authentication Credentials for the request
|
|
22
|
+
* @returns Promise that will resolve with the list of successfully deleted groups
|
|
23
|
+
*/
|
|
24
|
+
export declare function deleteEmptyGroups(groups: string[], authentication: UserSession): Promise<string[]>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** @license
|
|
3
|
+
* Copyright 2021 Esri
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.deleteEmptyGroups = void 0;
|
|
19
|
+
/**
|
|
20
|
+
* @module deleteEmptyGroups
|
|
21
|
+
*/
|
|
22
|
+
const deleteGroupIfEmpty_1 = require("./deleteGroupIfEmpty");
|
|
23
|
+
// ------------------------------------------------------------------------------------------------------------------ //
|
|
24
|
+
/**
|
|
25
|
+
* Deletes a set of empty groups if they're empty and belong to the user in the authentication.
|
|
26
|
+
*
|
|
27
|
+
* @param groups Ids of the groups to be deleted
|
|
28
|
+
* @param authentication Credentials for the request
|
|
29
|
+
* @returns Promise that will resolve with the list of successfully deleted groups
|
|
30
|
+
*/
|
|
31
|
+
function deleteEmptyGroups(groups, authentication) {
|
|
32
|
+
if (groups.length === 0) {
|
|
33
|
+
return Promise.resolve([]);
|
|
34
|
+
}
|
|
35
|
+
// Attempt to delete each group
|
|
36
|
+
return Promise.all(groups.map(groupId => (0, deleteGroupIfEmpty_1.deleteGroupIfEmpty)(groupId, authentication))).then((responses) => {
|
|
37
|
+
// Return just the group ids that succeeded
|
|
38
|
+
return groups.filter((groupId, index) => responses[index]);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
exports.deleteEmptyGroups = deleteEmptyGroups;
|
|
42
|
+
//# sourceMappingURL=deleteEmptyGroups.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteEmptyGroups.js","sourceRoot":"","sources":["../../../src/deleteHelpers/deleteEmptyGroups.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;GAEG;AAEH,6DAA0D;AAG1D,wHAAwH;AAExH;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAC/B,MAAgB,EAChB,cAA2B;IAE3B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;QACvB,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;KAC5B;IAED,+BAA+B;IAC/B,OAAO,OAAO,CAAC,GAAG,CAChB,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,IAAA,uCAAkB,EAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CACnE,CAAC,IAAI,CAAC,CAAC,SAAoB,EAAE,EAAE;QAC9B,2CAA2C;QAC3C,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,OAAe,EAAE,KAAa,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;AACL,CAAC;AAfD,8CAeC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** @license
|
|
2
|
+
* Copyright 2021 Esri
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* @module deleteGroupIfEmpty
|
|
18
|
+
*/
|
|
19
|
+
import { UserSession } from "../interfaces";
|
|
20
|
+
/**
|
|
21
|
+
* Deletes a group if it's empty and belongs to the specified user.
|
|
22
|
+
*
|
|
23
|
+
* @param groupId Id of the group to be deleted
|
|
24
|
+
* @param authentication Credentials for the request
|
|
25
|
+
* @returns Promise indicating if group was deleted
|
|
26
|
+
*/
|
|
27
|
+
export declare function deleteGroupIfEmpty(groupId: string, authentication: UserSession): Promise<boolean>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** @license
|
|
3
|
+
* Copyright 2021 Esri
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.deleteGroupIfEmpty = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const portal = tslib_1.__importStar(require("@esri/arcgis-rest-portal"));
|
|
21
|
+
// ------------------------------------------------------------------------------------------------------------------ //
|
|
22
|
+
/**
|
|
23
|
+
* Deletes a group if it's empty and belongs to the specified user.
|
|
24
|
+
*
|
|
25
|
+
* @param groupId Id of the group to be deleted
|
|
26
|
+
* @param authentication Credentials for the request
|
|
27
|
+
* @returns Promise indicating if group was deleted
|
|
28
|
+
*/
|
|
29
|
+
function deleteGroupIfEmpty(groupId, authentication) {
|
|
30
|
+
let username;
|
|
31
|
+
let isGroupProtected;
|
|
32
|
+
// Get the owner tied to the authentication
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
34
|
+
return authentication
|
|
35
|
+
.getUsername()
|
|
36
|
+
.then(response => {
|
|
37
|
+
username = response;
|
|
38
|
+
// We need to know the owner and protection status of the group
|
|
39
|
+
return portal.getGroup(groupId, { authentication });
|
|
40
|
+
})
|
|
41
|
+
.then((group) => {
|
|
42
|
+
if (group.owner !== username) {
|
|
43
|
+
return Promise.resolve(null); // don't delete a group we don't own
|
|
44
|
+
}
|
|
45
|
+
isGroupProtected = group.protected; // do we need to unprotect before deleting?
|
|
46
|
+
// Get the number of items in the group
|
|
47
|
+
const groupContentOptions = {
|
|
48
|
+
paging: {
|
|
49
|
+
num: 1 // only need 1 item to show that group is not empty
|
|
50
|
+
},
|
|
51
|
+
authentication
|
|
52
|
+
};
|
|
53
|
+
return portal.getGroupContent(groupId, groupContentOptions);
|
|
54
|
+
})
|
|
55
|
+
.then((groupContent) => {
|
|
56
|
+
// should be IGroupContentResult; see https://github.com/Esri/arcgis-rest-js/pull/858/files
|
|
57
|
+
// If groupContent is null, then we don't own the group; if the group is not empty, then we can't delete it
|
|
58
|
+
if (!groupContent || groupContent.total > 0) {
|
|
59
|
+
return Promise.resolve({ success: false }); // don't delete a group that's not empty
|
|
60
|
+
}
|
|
61
|
+
// We're going ahead with deletion; first unprotect it if necessary
|
|
62
|
+
if (isGroupProtected) {
|
|
63
|
+
const groupOptions = {
|
|
64
|
+
id: groupId,
|
|
65
|
+
authentication
|
|
66
|
+
};
|
|
67
|
+
return portal.unprotectGroup(groupOptions);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
return Promise.resolve({ success: true });
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
.then(response => {
|
|
74
|
+
if (response.success) {
|
|
75
|
+
// All is good so far: we own the group, it's empty, and it's unprotected; proceed with deletion
|
|
76
|
+
const groupOptions = {
|
|
77
|
+
id: groupId,
|
|
78
|
+
authentication
|
|
79
|
+
};
|
|
80
|
+
return portal.removeGroup(groupOptions);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
// We should not delete the group
|
|
84
|
+
return Promise.resolve({ success: false });
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
.then((response) => {
|
|
88
|
+
// Return a simple response
|
|
89
|
+
return Promise.resolve(response.success);
|
|
90
|
+
})
|
|
91
|
+
.catch(() => {
|
|
92
|
+
// In case getGroup or getGroupContent fails
|
|
93
|
+
return Promise.resolve(false);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
exports.deleteGroupIfEmpty = deleteGroupIfEmpty;
|
|
97
|
+
//# sourceMappingURL=deleteGroupIfEmpty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteGroupIfEmpty.js","sourceRoot":"","sources":["../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AAE,EAAE,OAAO;gBACX,cAAc;aACf,CAAC;YACF,OAAO,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;SAC5C;aAAM;YACL,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;SAC3C;IACH,CAAC,CAAC;SACD,IAAI,CAAC,QAAQ,CAAC,EAAE;QACf,IAAI,QAAQ,CAAC,OAAO,EAAE;YACpB,gGAAgG;YAChG,MAAM,YAAY,GAA6B;gBAC7C,EAAE,EAAE,OAAO;gBACX,cAAc;aACf,CAAC;YACF,OAAO,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;SACzC;aAAM;YACL,iCAAiC;YACjC,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;SAC5C;IACH,CAAC,CAAC;SACD,IAAI,CAAC,CAAC,QAA8B,EAAE,EAAE;QACvC,2BAA2B;QAC3B,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC,CAAC;SACD,KAAK,CAAC,GAAG,EAAE;QACV,4CAA4C;QAC5C,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACP,CAAC;AAvED,gDAuEC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** @license
|
|
2
|
+
* Copyright 2021 Esri
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Provides a function for deleting a deployed Solution item and all of the items that were created
|
|
18
|
+
* as part of that deployment.
|
|
19
|
+
*
|
|
20
|
+
* @module deleteSolution
|
|
21
|
+
*/
|
|
22
|
+
import { IDeleteSolutionOptions, ISolutionPrecis, UserSession } from "../interfaces";
|
|
23
|
+
/**
|
|
24
|
+
* Deletes a deployed Solution item and and all of the items that were created
|
|
25
|
+
* as part of that deployment.
|
|
26
|
+
*
|
|
27
|
+
* @param solutionItemId Id of a deployed Solution
|
|
28
|
+
* @param solutionSummary List of items in the solution that would be deleted
|
|
29
|
+
* @param authentication Credentials for the request
|
|
30
|
+
* @param options Progress reporting options
|
|
31
|
+
* @returns Promise that will resolve with a list of two solution summaries: successful deletions
|
|
32
|
+
* and failed deletions. Ignored items (e.g., already deleted) and items shared with more than
|
|
33
|
+
* one Solution will not be in either list.
|
|
34
|
+
* Note that Solution item and its deployment folder will only be deleted if all of its deployed
|
|
35
|
+
* items were deleted (the failure list is empty). This makes it possible to re-attempted
|
|
36
|
+
* deletion using the solutionItemId.
|
|
37
|
+
*/
|
|
38
|
+
export declare function deleteSolutionContents(solutionItemId: string, solutionSummary: ISolutionPrecis, authentication: UserSession, options?: IDeleteSolutionOptions): Promise<ISolutionPrecis[]>;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** @license
|
|
3
|
+
* Copyright 2021 Esri
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.deleteSolutionContents = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
/**
|
|
21
|
+
* Provides a function for deleting a deployed Solution item and all of the items that were created
|
|
22
|
+
* as part of that deployment.
|
|
23
|
+
*
|
|
24
|
+
* @module deleteSolution
|
|
25
|
+
*/
|
|
26
|
+
const interfaces_1 = require("../interfaces");
|
|
27
|
+
const deleteEmptyGroups = tslib_1.__importStar(require("./deleteEmptyGroups"));
|
|
28
|
+
const deleteSolutionFolder = tslib_1.__importStar(require("./deleteSolutionFolder"));
|
|
29
|
+
const deleteSolutionItem = tslib_1.__importStar(require("./deleteSolutionItem"));
|
|
30
|
+
const removeItems = tslib_1.__importStar(require("./removeItems"));
|
|
31
|
+
const reportProgress = tslib_1.__importStar(require("./reportProgress"));
|
|
32
|
+
// ------------------------------------------------------------------------------------------------------------------ //
|
|
33
|
+
/**
|
|
34
|
+
* Deletes a deployed Solution item and and all of the items that were created
|
|
35
|
+
* as part of that deployment.
|
|
36
|
+
*
|
|
37
|
+
* @param solutionItemId Id of a deployed Solution
|
|
38
|
+
* @param solutionSummary List of items in the solution that would be deleted
|
|
39
|
+
* @param authentication Credentials for the request
|
|
40
|
+
* @param options Progress reporting options
|
|
41
|
+
* @returns Promise that will resolve with a list of two solution summaries: successful deletions
|
|
42
|
+
* and failed deletions. Ignored items (e.g., already deleted) and items shared with more than
|
|
43
|
+
* one Solution will not be in either list.
|
|
44
|
+
* Note that Solution item and its deployment folder will only be deleted if all of its deployed
|
|
45
|
+
* items were deleted (the failure list is empty). This makes it possible to re-attempted
|
|
46
|
+
* deletion using the solutionItemId.
|
|
47
|
+
*/
|
|
48
|
+
function deleteSolutionContents(solutionItemId, solutionSummary, authentication, options) {
|
|
49
|
+
const deleteOptions = options || {};
|
|
50
|
+
let progressPercentStep = 0;
|
|
51
|
+
let percentDone = 0;
|
|
52
|
+
let solutionDeletedSummary;
|
|
53
|
+
let solutionFailureSummary;
|
|
54
|
+
let solutionIds = [];
|
|
55
|
+
return new Promise(resolve => {
|
|
56
|
+
let removalPromise = Promise.resolve([
|
|
57
|
+
{
|
|
58
|
+
id: solutionSummary.id,
|
|
59
|
+
title: solutionSummary.title,
|
|
60
|
+
folder: solutionSummary.folder,
|
|
61
|
+
items: [],
|
|
62
|
+
groups: []
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: solutionSummary.id,
|
|
66
|
+
title: solutionSummary.title,
|
|
67
|
+
folder: solutionSummary.folder,
|
|
68
|
+
items: [],
|
|
69
|
+
groups: []
|
|
70
|
+
}
|
|
71
|
+
]);
|
|
72
|
+
if (solutionSummary.items.length > 0) {
|
|
73
|
+
// Save a copy of the Solution item ids for the deleteSolutionFolder call because removeItems
|
|
74
|
+
// destroys the solutionSummary.items list
|
|
75
|
+
solutionIds = solutionSummary.items
|
|
76
|
+
.map(item => item.id)
|
|
77
|
+
.concat([solutionItemId]);
|
|
78
|
+
const hubSiteItemIds = solutionSummary.items
|
|
79
|
+
.filter((item) => item.type === "Hub Site Application")
|
|
80
|
+
.map((item) => item.id);
|
|
81
|
+
// Delete the items
|
|
82
|
+
progressPercentStep = 100 / (solutionSummary.items.length + 2); // one extra for starting plus one extra for solution itself
|
|
83
|
+
reportProgress.reportProgress((percentDone += progressPercentStep), deleteOptions); // let the caller know that we've started
|
|
84
|
+
// Proceed with the deletion
|
|
85
|
+
removalPromise = removeItems.removeItems(solutionSummary, hubSiteItemIds, authentication, percentDone, progressPercentStep, deleteOptions);
|
|
86
|
+
}
|
|
87
|
+
removalPromise
|
|
88
|
+
.then((results) => {
|
|
89
|
+
[solutionDeletedSummary, solutionFailureSummary] = results;
|
|
90
|
+
// Attempt to delete groups; we won't be checking success
|
|
91
|
+
return new Promise(resolve2 => {
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
93
|
+
deleteEmptyGroups
|
|
94
|
+
.deleteEmptyGroups(solutionSummary.groups, authentication)
|
|
95
|
+
.then(() => {
|
|
96
|
+
resolve2(results);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
})
|
|
100
|
+
.then(() => {
|
|
101
|
+
// If there were no failed deletes, it's OK to delete Solution item
|
|
102
|
+
if (solutionFailureSummary.items.length === 0) {
|
|
103
|
+
return deleteSolutionItem.deleteSolutionItem(solutionItemId, authentication);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
// Not all items were deleted, so don't delete solution
|
|
107
|
+
return Promise.resolve({ success: false, itemId: solutionItemId });
|
|
108
|
+
}
|
|
109
|
+
})
|
|
110
|
+
.then((solutionItemDeleteStatus) => {
|
|
111
|
+
// If all deletes succeeded, see if we can delete the folder that contained them
|
|
112
|
+
if (solutionItemDeleteStatus.success) {
|
|
113
|
+
reportProgress.reportProgress(99, deleteOptions, solutionItemId, interfaces_1.EItemProgressStatus.Finished);
|
|
114
|
+
// Can't delete if folder contains non-solution items
|
|
115
|
+
return deleteSolutionFolder.deleteSolutionFolder(solutionIds, solutionSummary.folder, authentication);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
return Promise.resolve(false);
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
.then(() => {
|
|
122
|
+
resolve([solutionDeletedSummary, solutionFailureSummary]);
|
|
123
|
+
})
|
|
124
|
+
.catch(() => {
|
|
125
|
+
resolve([solutionDeletedSummary, solutionFailureSummary]);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
exports.deleteSolutionContents = deleteSolutionContents;
|
|
130
|
+
//# sourceMappingURL=deleteSolutionContents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteSolutionContents.js","sourceRoot":"","sources":["../../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AAK,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;aACpE;QACH,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,wBAAyC,EAAE,EAAE;YAClD,gFAAgF;YAChF,IAAI,wBAAwB,CAAC,OAAO,EAAE;gBACpC,cAAc,CAAC,cAAc,CAC3B,EAAE,EACF,aAAa,EACb,cAAc,EACd,gCAAmB,CAAC,QAAQ,CAC7B,CAAC;gBAEF,qDAAqD;gBACrD,OAAO,oBAAoB,CAAC,oBAAoB,CAC9C,WAAW,EACX,eAAe,CAAC,MAAM,EACtB,cAAc,CACf,CAAC;aACH;iBAAM;gBACL,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;aAC/B;QACH,CAAC,CAAC;aACD,IAAI,CAAC,GAAG,EAAE;YACT,OAAO,CAAC,CAAC,sBAAsB,EAAE,sBAAsB,CAAC,CAAC,CAAC;QAC5D,CAAC,CAAC;aACD,KAAK,CAAC,GAAG,EAAE;YACV,OAAO,CAAC,CAAC,sBAAsB,EAAE,sBAAsB,CAAC,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACL,CAAC;AAjHD,wDAiHC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** @license
|
|
2
|
+
* Copyright 2018 Esri
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* @module deleteSolutionFolder
|
|
18
|
+
*/
|
|
19
|
+
import { UserSession } from "../interfaces";
|
|
20
|
+
/**
|
|
21
|
+
* Deletes a deployed Solution's folder if the folder is empty.
|
|
22
|
+
*
|
|
23
|
+
* @param solutionFolderId Id of the folder of a deployed Solution
|
|
24
|
+
* @param deletedItemIds Ids in the Solution, including the Solution item; used to deal with lagging folder deletion
|
|
25
|
+
* @param authentication Credentials for the request
|
|
26
|
+
* @returns Promise that will resolve if deletion was successful and fail if any part of it failed;
|
|
27
|
+
* if the folder has a non-Solution item, it will not be deleted, but the function will return true
|
|
28
|
+
*/
|
|
29
|
+
export declare function deleteSolutionFolder(solutionIds: string[], folderId: string, authentication: UserSession): Promise<boolean>;
|