-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
beb6c48
commit 4a4d79b
Showing
4 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) 2020, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
import { JsonMap } from '@salesforce/ts-types'; | ||
|
||
export abstract class Deauthorizer<T = JsonMap> { | ||
public async removeAll(): Promise<Deauthorizer.Result> { | ||
const result = { | ||
successes: [], | ||
failures: [], | ||
} as Deauthorizer.Result; | ||
|
||
const environments = await this.find(); | ||
for (const id of Object.keys(environments)) { | ||
try { | ||
await this.remove(id); | ||
result.successes.push(id); | ||
} catch { | ||
result.failures.push(id); | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
public abstract find(): Promise<Record<string, T>>; | ||
public abstract remove(id: string): Promise<boolean>; | ||
} | ||
|
||
export namespace Deauthorizer { | ||
export type Result = { | ||
successes: string[]; | ||
failures: string[]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters