/**
 * @fileoverview added by tsickle
 * Generated from: common/activity-reporter/activity-promise-resolver.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import { __assign } from "tslib";
/*!
 * Copyright 2020 VMware, Inc.
 * SPDX-License-Identifier: BSD-2-Clause
 */
/**
 * The response that was given with some resource.
 * @record
 */
export function ActivityResponse() { }
if (false) {
    /**
     * The error message, if any, from the activity.
     *
     * A response without an error is assumed to have succeeded.
     * @type {?|undefined}
     */
    ActivityResponse.prototype.error;
    /**
     * The response message, if any, from the activity.
     * @type {?|undefined}
     */
    ActivityResponse.prototype.success;
}
/**
 * A combination of some object and the response that gave that object.
 * @record
 * @template T
 */
export function ObjectAndResponse() { }
if (false) {
    /**
     * The data that was returned from a given activity, if any.
     * @type {?|undefined}
     */
    ObjectAndResponse.prototype.object;
    /**
     * The response that an activity returned.
     * @type {?}
     */
    ObjectAndResponse.prototype.response;
}
/**
 * A class that understands how to take a promise and turn it into some response message for display.
 * A client of this library will override {\@link ActivityPromiseResolver} to process their specific type of promise.
 * This override will know how to generate a {\@link ObjectAndResponse} from the type of promise it processes.
 *
 * @param T The type that is returned from a promise that this resolver processes.
 * @template T
 */
var /**
 * A class that understands how to take a promise and turn it into some response message for display.
 * A client of this library will override {\@link ActivityPromiseResolver} to process their specific type of promise.
 * This override will know how to generate a {\@link ObjectAndResponse} from the type of promise it processes.
 *
 * @param T The type that is returned from a promise that this resolver processes.
 * @template T
 */
ActivityPromiseResolver = /** @class */ (function () {
    function ActivityPromiseResolver() {
    }
    /**
     * Takes a Promise and turns it to some activity status
     * @param activityResolutionPromise The activity that this resolver will generate a response from. It generates
     * either a sucesss or a failure condition.
     * @param successMessage The success message this method should return if the activity succeeds. If undefined is passed,
     * a succeeded promise will return an empty response parameter which is assumed to mean success.
     */
    /**
     * Takes a Promise and turns it to some activity status
     * @param {?} activityResolutionPromise The activity that this resolver will generate a response from. It generates
     * either a sucesss or a failure condition.
     * @param {?=} successMessage The success message this method should return if the activity succeeds. If undefined is passed,
     * a succeeded promise will return an empty response parameter which is assumed to mean success.
     * @return {?}
     */
    ActivityPromiseResolver.prototype.resolveActivity = /**
     * Takes a Promise and turns it to some activity status
     * @param {?} activityResolutionPromise The activity that this resolver will generate a response from. It generates
     * either a sucesss or a failure condition.
     * @param {?=} successMessage The success message this method should return if the activity succeeds. If undefined is passed,
     * a succeeded promise will return an empty response parameter which is assumed to mean success.
     * @return {?}
     */
    function (activityResolutionPromise, successMessage) {
        return activityResolutionPromise
            .then((/**
         * @param {?} result
         * @return {?}
         */
        function (result) {
            return {
                object: result,
                response: __assign(__assign({}, result), { success: successMessage || result }),
            };
        }))
            .catch((/**
         * @param {?} error
         * @return {?}
         */
        function (error) {
            return { response: { error: error } };
        }));
    };
    /**
     * Takes a Promise of many items and turns it to some activity status
     * @param activityResolutionPromise The activity that this resolver will generate a response from. It generates
     * either a sucesss or a failure condition. There are many entities contained in this response.
     * @param successMessage The success message this method should return if the activity succeeds. If undefined is passed,
     * a succeeded promise will return an empty response parameter which is assumed to mean success.
     */
    /**
     * Takes a Promise of many items and turns it to some activity status
     * @param {?} activityResolutionPromises
     * @param {?=} successMessage The success message this method should return if the activity succeeds. If undefined is passed,
     * a succeeded promise will return an empty response parameter which is assumed to mean success.
     * @return {?}
     */
    ActivityPromiseResolver.prototype.resolveActivities = /**
     * Takes a Promise of many items and turns it to some activity status
     * @param {?} activityResolutionPromises
     * @param {?=} successMessage The success message this method should return if the activity succeeds. If undefined is passed,
     * a succeeded promise will return an empty response parameter which is assumed to mean success.
     * @return {?}
     */
    function (activityResolutionPromises, successMessage) {
        return activityResolutionPromises
            .then((/**
         * @param {?} result
         * @return {?}
         */
        function (result) {
            return [
                {
                    object: result[0],
                    response: __assign(__assign({}, result), { success: successMessage }),
                },
            ];
        }))
            .catch((/**
         * @param {?} error
         * @return {?}
         */
        function (error) {
            return [{ response: { error: error } }];
        }));
    };
    return ActivityPromiseResolver;
}());
/**
 * A class that understands how to take a promise and turn it into some response message for display.
 * A client of this library will override {\@link ActivityPromiseResolver} to process their specific type of promise.
 * This override will know how to generate a {\@link ObjectAndResponse} from the type of promise it processes.
 *
 * @param T The type that is returned from a promise that this resolver processes.
 * @template T
 */
export { ActivityPromiseResolver };
//# sourceMappingURL=data:application/json;base64, 