/** * 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 { makeDeleteOneScheduledScript } from './delete-one-scheduled-script'; import { makeGetAllScheduledScripts } from './get-all-scheduled-scripts'; export const makeDeleteAllScheduledScripts = (context: APIContext): (() => Promise) => { const deleteOneScheduledScript = makeDeleteOneScheduledScript(context); const getAllScheduledScripts = makeGetAllScheduledScripts(context); return async (): Promise => { const scripts = await getAllScheduledScripts(); const deletePs = scripts.map(s => deleteOneScheduledScript(s.id)); await Promise.all(deletePs); }; };