fix: Create or update Vault:

Updating the thing to always return a string.
Make sure the key is in the vault
This commit is contained in:
BluJ
2023-05-19 11:27:37 -06:00
parent 3f51b4f948
commit 4ee030de1c

View File

@@ -63,10 +63,10 @@ export type Utils<Store, Vault, WrapperOverWrite = { const: never }> = {
search: Record<string, string> search: Record<string, string>
}) => NetworkInterfaceBuilder }) => NetworkInterfaceBuilder
createOrUpdateVault: (opts: { createOrUpdateVault: (opts: {
key: string key: keyof Vault & string
value: string | null | undefined value: string | null | undefined
generator: DefaultString generator: DefaultString
}) => Promise<null | string> }) => Promise<string>
getSystemSmtp: () => GetSystemSmtp & WrapperOverWrite getSystemSmtp: () => GetSystemSmtp & WrapperOverWrite
host: { host: {
static: (id: string) => StaticHost static: (id: string) => StaticHost
@@ -129,7 +129,7 @@ export const utils = <
value, value,
generator, generator,
}: { }: {
key: string key: keyof Vault & string
value: string | null | undefined value: string | null | undefined
generator: DefaultString generator: DefaultString
}) => { }) => {
@@ -137,8 +137,9 @@ export const utils = <
await effects.vault.set({ key, value }) await effects.vault.set({ key, value })
return value return value
} }
if (await effects.vault.get({ key, callback: noop })) { const oldValue = await effects.vault.get({ key, callback: noop })
return null if (oldValue) {
return oldValue
} }
const newValue = getDefaultString(generator) const newValue = getDefaultString(generator)
await effects.vault.set({ key, value: newValue }) await effects.vault.set({ key, value: newValue })