From 1d5357cfc74ad082adfacd7201e3a4587c90f5b4 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Sat, 6 May 2023 15:33:30 -0600 Subject: [PATCH] add vault.get --- lib/types.ts | 1 + lib/util/index.ts | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/types.ts b/lib/types.ts index abc120a..1d7744a 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -392,6 +392,7 @@ export type Effects = { vault: { list(): Promise + get(opt: { key: string }): Promise set(opt: { key: string; value: string }): Promise move(opt: { fromKey: string; toKey: string }): Promise delete(opt: { key: string }): Promise diff --git a/lib/util/index.ts b/lib/util/index.ts index 296fb00..19eceb5 100644 --- a/lib/util/index.ts +++ b/lib/util/index.ts @@ -101,14 +101,14 @@ export const utils = ( generator: DefaultString }) => { if (value) { - await effects.vaultSet({ key, value }) + await effects.vault.set({ key, value }) return value } - if (await effects.vaultList().then((x) => x.includes(key))) { + if (await effects.vault.get({ key })) { return null } const newValue = getDefaultString(generator) - await effects.vaultSet({ key, value: newValue }) + await effects.vault.set({ key, value: newValue }) return newValue }, getSystemSmtp: () =>