From 5fa827fd1812ff94c518393ae419f738b1dadc97 Mon Sep 17 00:00:00 2001 From: Aman Desai <39585600+amandesai01@users.noreply.github.com> Date: Wed, 4 Dec 2024 18:56:20 +0530 Subject: [PATCH] fix(extensions): typings for KvStore (#9932) * fix(extensions): typings for KvStore * Update useExtensions.ts --- packages/nc-gui/composables/useExtensions.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/nc-gui/composables/useExtensions.ts b/packages/nc-gui/composables/useExtensions.ts index 5bff28067e..b053683366 100644 --- a/packages/nc-gui/composables/useExtensions.ts +++ b/packages/nc-gui/composables/useExtensions.ts @@ -45,6 +45,13 @@ export interface ExtensionManifest { disabled?: boolean } +export interface IKvStore> { + get(key: K): T[K] | null; + set(key: K, value: T[K]): Promise; + delete(key: K): Promise; + serialize(): Record; +} + abstract class ExtensionType { abstract id: string abstract uiKey: number @@ -52,7 +59,7 @@ abstract class ExtensionType { abstract fkUserId: string abstract extensionId: string abstract title: string - abstract kvStore: any + abstract kvStore: IKvStore abstract meta: any abstract order: number abstract setTitle(title: string): Promise @@ -284,11 +291,11 @@ export const useExtensions = createSharedComposable(() => { } } - class KvStore { + class KvStore implements IKvStore { private _id: string - private data: Record + private data: Record - constructor(id: string, data: any) { + constructor(id: string, data: Record) { this._id = id this.data = data || {} } @@ -302,9 +309,9 @@ export const useExtensions = createSharedComposable(() => { return updateExtension(this._id, { kv_store: this.data }) } - delete(key: string) { + async delete(key: string) { delete this.data[key] - return updateExtension(this._id, { kv_store: this.data }) + await updateExtension(this._id, { kv_store: this.data }) } serialize() {