/** * Copyright 2022 Gravwell, Inc. All rights reserved. * * Contact: [legal@gravwell.io](mailto:legal@gravwell.io) * * This software may be modified and distributed under the terms of the MIT * license. See the LICENSE file for details. */ import { APIContext } from '../utils/api-context'; import { makeDeleteOneGroup } from './delete-one-group'; import { makeGetAllGroups } from './get-all-groups'; export const makeDeleteAllGroups = (context: APIContext): (() => Promise) => { const deleteOneGroup = makeDeleteOneGroup(context); const getAllGroups = makeGetAllGroups(context); return async (): Promise => { const groups = await getAllGroups(); const deletePs = groups.map(q => deleteOneGroup(q.id)); await Promise.all(deletePs); }; };