From 0a00bd0a5dab59f94c7b5578dbf8c4fa39f38e35 Mon Sep 17 00:00:00 2001 From: Spoffy Date: Mon, 1 Jul 2024 21:26:19 +0100 Subject: [PATCH] Enables config values to be backed by optional persistence --- app/server/lib/config.ts | 8 ++++---- app/server/lib/configCore.ts | 2 +- app/server/lib/configCoreFileFormats-ti.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/server/lib/config.ts b/app/server/lib/config.ts index d51e2f07ae..b09b2b3bee 100644 --- a/app/server/lib/config.ts +++ b/app/server/lib/config.ts @@ -117,12 +117,12 @@ export function fileConfigAccessorFactory( */ export function createConfigValue( defaultValue: ValueType, - persistence?: ConfigAccessors, + persistence?: ConfigAccessors | ConfigAccessors, ): IWritableConfigValue { - let inMemoryValue = (persistence && persistence.get()) ?? defaultValue; + let inMemoryValue = (persistence && persistence.get()); return { - get() { - return inMemoryValue; + get(): ValueType { + return inMemoryValue ?? defaultValue; }, async set(value: ValueType) { if (persistence && persistence.set) { diff --git a/app/server/lib/configCore.ts b/app/server/lib/configCore.ts index 7f889e9b68..884e2cf742 100644 --- a/app/server/lib/configCore.ts +++ b/app/server/lib/configCore.ts @@ -23,6 +23,6 @@ export async function loadGristCoreConfigFile(configPath?: string): Promise): IGristCoreConfig { const fileConfigValue = fileConfigAccessorFactory(fileConfig); return { - edition: createConfigValue("core", fileConfigValue("edition")) + edition: createConfigValue("core", fileConfigValue("edition")) }; } diff --git a/app/server/lib/configCoreFileFormats-ti.ts b/app/server/lib/configCoreFileFormats-ti.ts index 7a50fdc944..7bb3974001 100644 --- a/app/server/lib/configCoreFileFormats-ti.ts +++ b/app/server/lib/configCoreFileFormats-ti.ts @@ -8,7 +8,7 @@ export const IGristCoreConfigFileLatest = t.name("IGristCoreConfigFileV1"); export const IGristCoreConfigFileV1 = t.iface([], { "version": t.lit("1"), - "edition": t.union(t.lit("core"), t.lit("enterprise")), + "edition": t.opt(t.union(t.lit("core"), t.lit("enterprise"))), }); export const IGristCoreConfigFileV0 = t.iface([], {