/// import { ApiPayload, GqlError, LabelsPayload, MutationError, RemoveCompassComponentLabelsInput, RemoveComponentLabels, SdkError, } from '@atlassian/forge-graphql-types'; import { CompassRequests } from '../../compass-requests'; import { mapGqlErrors, mapMutationErrors, parsingResponseError, } from '../../helpers'; declare module '../../compass-requests' { interface CompassRequests { /** * Removes a collection of existing labels from a component. * * **Required Oauth Scopes:** `write:component:compass` */ removeLabels( input: RemoveCompassComponentLabelsInput, ): Promise>; } } CompassRequests.prototype.removeLabels = async function ( this: CompassRequests, input, ) { let labelNames = null; let gqlErrors: Array; let mutationErrors: Array; let errorsResp: Array = []; let data; try { const resp = await this.api.requestGraph( RemoveComponentLabels, { input }, 'removeLabels', ); ({ errors: gqlErrors, data } = await resp.json()); errorsResp = errorsResp.concat(mapGqlErrors(gqlErrors)); ({ removeComponentLabels: { removedLabelNames: labelNames, errors: mutationErrors, }, } = data.compass); errorsResp = errorsResp.concat(mapMutationErrors(mutationErrors)); } catch (e) { if (errorsResp.length === 0) { errorsResp.push(parsingResponseError(e)); } } return { errors: mapGqlErrors(errorsResp), success: errorsResp.length === 0, data: { labelNames }, }; };