From 3f3045e3e560db256687403366647d723b57f2fa Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Thu, 5 Oct 2023 11:53:04 -0400 Subject: [PATCH] Consolidate definition of storage keys This way, external teams need only look at one file (perhaps to be changed to a directory in the future) to completely define a new storage location --- libs/common/src/platform/state/index.ts | 2 -- libs/common/src/platform/state/key-definition.ts | 4 +++- libs/common/src/platform/state/key-definitions.ts | 6 ++++-- libs/common/src/platform/state/state-definitions.ts | 4 ---- 4 files changed, 7 insertions(+), 9 deletions(-) delete mode 100644 libs/common/src/platform/state/state-definitions.ts diff --git a/libs/common/src/platform/state/index.ts b/libs/common/src/platform/state/index.ts index 61dc7fffb3..72096a8240 100644 --- a/libs/common/src/platform/state/index.ts +++ b/libs/common/src/platform/state/index.ts @@ -1,5 +1,3 @@ -// Export all established state definitions -export * from "./state-definitions"; // Export all established KeyDefinitions export * from "./key-definitions"; export { DefaultGlobalStateProvider } from "./default-global-state.provider"; diff --git a/libs/common/src/platform/state/key-definition.ts b/libs/common/src/platform/state/key-definition.ts index 310cf3c644..46f254c256 100644 --- a/libs/common/src/platform/state/key-definition.ts +++ b/libs/common/src/platform/state/key-definition.ts @@ -4,7 +4,9 @@ import { DeriveContext, DerivedStateDefinition } from "./derived-state-definitio import { StateDefinition } from "./state-definition"; /** - * + * KeyDefinitions describe the precise location to store data for a given piece of state. + * The StateDefinition is used to describe the domain of the state, and the KeyDefinition + * sub-divides that domain into specific keys. */ // TODO Import Purpose type export class KeyDefinition { diff --git a/libs/common/src/platform/state/key-definitions.ts b/libs/common/src/platform/state/key-definitions.ts index d522f1718f..383ff23581 100644 --- a/libs/common/src/platform/state/key-definitions.ts +++ b/libs/common/src/platform/state/key-definitions.ts @@ -2,9 +2,11 @@ import { FolderData } from "../../vault/models/data/folder.data"; import { FolderView } from "../../vault/models/view/folder.view"; import { KeyDefinition } from "./key-definition"; -import { FOLDER_SERVICE_DISK, FOLDER_SERVICE_MEMORY } from "./state-definitions"; +import { StateDefinition } from "./state-definition"; -// FolderService Keys +// FolderService +const FOLDER_SERVICE_DISK = new StateDefinition("folderService", "disk"); +const FOLDER_SERVICE_MEMORY = new StateDefinition("folderService", "memory"); export const FOLDERS = KeyDefinition.record( FOLDER_SERVICE_DISK, "folders", diff --git a/libs/common/src/platform/state/state-definitions.ts b/libs/common/src/platform/state/state-definitions.ts deleted file mode 100644 index fbb5f4454f..0000000000 --- a/libs/common/src/platform/state/state-definitions.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { StateDefinition } from "./state-definition"; - -export const FOLDER_SERVICE_DISK = new StateDefinition("FolderService", "disk"); -export const FOLDER_SERVICE_MEMORY = new StateDefinition("FolderService", "memory");