UNPKG

@esri/solution-common

Version:

Provides general helper functions for @esri/solution.js.

53 lines 2.57 kB
"use strict"; /** @license * Copyright 2018 Esri * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.getDeletableSolutionInfo = void 0; const tslib_1 = require("tslib"); const getSolutionSummary = tslib_1.__importStar(require("./getSolutionSummary")); const restHelpersGet = tslib_1.__importStar(require("./restHelpersGet")); // ------------------------------------------------------------------------------------------------------------------ // /** * Returns a list of items in a deployed Solution that would be deleted by the `deleteSolution` function; list * does not include the Solution folder, Solution items that are shared with any item other than the deployed * Solution, or the Solution item itself. * * @param solutionItemId Id of a deployed Solution * @param authentication Credentials for the request * @returns Promise resolving to the list of items in the solution that would be deleted. */ function getDeletableSolutionInfo(solutionItemId, authentication) { let solutionSummary; return new Promise((resolve, reject) => { getSolutionSummary .getSolutionSummary(solutionItemId, authentication) .then((response) => { // Fetch each item's relationships back to Solution items solutionSummary = response; const awaitAllItems = solutionSummary.items.map((item) => restHelpersGet.getSolutionsRelatedToAnItem(item.id, authentication)); // eslint-disable-next-line @typescript-eslint/no-floating-promises return Promise.all(awaitAllItems); }) .then((responses) => { // Filter out items that are shared with another Solution solutionSummary.items = solutionSummary.items.filter((item, index) => responses[index].length === 1); resolve(solutionSummary); }) .catch(reject); }); } exports.getDeletableSolutionInfo = getDeletableSolutionInfo; //# sourceMappingURL=getDeletableSolutionInfo.js.map