From 81bd0f635e520e6064d5f7f9c46919798f90ed6a Mon Sep 17 00:00:00 2001 From: Asier Isayas Date: Thu, 20 Mar 2025 15:32:44 -0400 Subject: [PATCH] decorator debug --- src/SelfServe/Decorators.tsx | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/SelfServe/Decorators.tsx b/src/SelfServe/Decorators.tsx index 84a56055f..4879dd739 100644 --- a/src/SelfServe/Decorators.tsx +++ b/src/SelfServe/Decorators.tsx @@ -2,7 +2,16 @@ * @module SelfServe/Decorators */ -import { ChoiceItem, Description, Info, NumberUiType, OnChangeCallback, RefreshParams } from "./SelfServeTypes"; +import MaterializedViewsBuilder from "SelfServe/MaterializedViewsBuilder/MaterializedViewsBuilder"; +import { + ChoiceItem, + Description, + Info, + NumberUiType, + OnChangeCallback, + RefreshParams, + SelfServeBaseClass, +} from "./SelfServeTypes"; import { addPropertyToMap, buildSmartUiDescriptor, DecoratorProperties } from "./SelfServeUtils"; type ValueOf = T[keyof T]; @@ -128,14 +137,23 @@ const isDescriptionDisplayOptions = (inputOptions: InputOptions): inputOptions i }; const addToMap = (...decorators: Decorator[]): PropertyDecorator => { - return (target, property) => { - let className = target.constructor.name; + //eslint-disable-next-line @typescript-eslint/ban-types + return (target: SelfServeBaseClass | Function, property) => { + //eslint-disable-next-line @typescript-eslint/no-unused-vars + const instanceOfSelfServebaseClass: boolean = target instanceof SelfServeBaseClass; + //eslint-disable-next-line @typescript-eslint/no-unused-vars + const instanceOfMaterializedViewBuilder: boolean = target instanceof MaterializedViewsBuilder; + //eslint-disable-next-line @typescript-eslint/no-unused-vars + const classNameV2: string = new MaterializedViewsBuilder().getSelfServeType(); + let className: string = target.constructor.name; const propertyName = property.toString(); - if (className === "Function") { + if (target instanceof Function) { //eslint-disable-next-line @typescript-eslint/ban-types className = (target as Function).name; throw new Error(`Property '${propertyName}' in class '${className}'should be not be static.`); } + //eslint-disable-next-line @typescript-eslint/ban-types + // className = (target as MaterializedViewsBuilder).getSelfServeType(); const propertyType = (Reflect.getMetadata("design:type", target, property)?.name as string)?.toLowerCase(); addPropertyToMap(target, propertyName, className, "type", propertyType);