From 3703e4fb7fd128968c60e74a14ebe53ff062f472 Mon Sep 17 00:00:00 2001 From: Ana Silva Date: Mon, 2 Sep 2024 13:45:11 +0200 Subject: [PATCH 1/2] removed unecessary methods declaration --- src/devtools/commands/DevToolsAdminCommands.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/devtools/commands/DevToolsAdminCommands.ts b/src/devtools/commands/DevToolsAdminCommands.ts index 1d2c98d..165efe2 100644 --- a/src/devtools/commands/DevToolsAdminCommands.ts +++ b/src/devtools/commands/DevToolsAdminCommands.ts @@ -34,8 +34,6 @@ class DevToolsAdminCommands extends DevToolsCommands { } } - getMetadataTypes(): SupportedMetadataTypes[] | void {} - setMetadataTypes(_: SupportedMetadataTypes[]): void {} isSupportedMetadataType(_action: string, _metadataType: string): boolean | void {} async init( From 0c9216301396d7f2cbc7898fe1d5ed5617de2428 Mon Sep 17 00:00:00 2001 From: Ana Silva Date: Wed, 4 Sep 2024 15:19:31 +0200 Subject: [PATCH 2/2] explainTypes called in a non blocking way --- src/config/metadatatypes.config.ts | 4 +++- .../commands/DevToolsAdminCommands.ts | 1 - src/devtools/commands/DevToolsCommands.ts | 20 +++++++++++++++---- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/config/metadatatypes.config.ts b/src/config/metadatatypes.config.ts index 35952b5..b38a381 100644 --- a/src/config/metadatatypes.config.ts +++ b/src/config/metadatatypes.config.ts @@ -1,4 +1,6 @@ -export const metadatatypes = [ +import SupportedMetadataTypes from "../shared/interfaces/supportedMetadataTypes"; + +export const metadatatypes: SupportedMetadataTypes[] = [ { name: "Asset-[Subtype]", apiName: "asset", diff --git a/src/devtools/commands/DevToolsAdminCommands.ts b/src/devtools/commands/DevToolsAdminCommands.ts index 165efe2..d482f7c 100644 --- a/src/devtools/commands/DevToolsAdminCommands.ts +++ b/src/devtools/commands/DevToolsAdminCommands.ts @@ -1,7 +1,6 @@ import DevToolsCommands from "./DevToolsCommands"; import DevToolsCommandSetting from "../../shared/interfaces/devToolsCommandSetting"; import DevToolsCommandRunner from "../../shared/interfaces/devToolsCommandRunner"; -import SupportedMetadataTypes from "../../shared/interfaces/supportedMetadataTypes"; import { log } from "../../editor/output"; class DevToolsAdminCommands extends DevToolsCommands { diff --git a/src/devtools/commands/DevToolsCommands.ts b/src/devtools/commands/DevToolsCommands.ts index 65a1221..34e9b9c 100644 --- a/src/devtools/commands/DevToolsCommands.ts +++ b/src/devtools/commands/DevToolsCommands.ts @@ -99,11 +99,23 @@ abstract class DevToolsCommands { }, {}); } - // Sets the metadata types sorted by name - const sortedSuppMdtByName: SupportedMetadataTypes[] = metadatatypes.sort((a, b) => - a.name.localeCompare(b.name) + // sets default metadata type file + this.setMetadataTypes(metadatatypes); + + // Updates metadatypes with the result from explainTypes command, not blocking code execution + this.runCommand( + "admin", + "etypes", + "", + { json: true }, + { + handleCommandResult: ({ success, data }: { success: boolean; data: string }) => { + if (success) { + this.setMetadataTypes(JSON.parse(data) as SupportedMetadataTypes[]); + } + } + } ); - this.setMetadataTypes(sortedSuppMdtByName); } static async runCommand(