All files / src/utils/hooks/slash alias.ts

100% Statements 16/16
100% Branches 4/4
100% Functions 4/4
100% Lines 14/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 11667x 12x                                                                                                                                                               12x   12x 924x       1848x     12x     67x 12x 12x 12x 528x 9x     3x                          
const getClassNameAlias = (): Map<string, string[]> => {
  const classNames: string[] = [
    "AuditTrail",
    "AuthenticationToken",
    "ChatMessage",
    "Conversation",
    "DefaultDynamicEntityInstance",
    "DefaultDynamicEntityType",
    "DomainClass",
    "DomainClassField",
    "DomainColumnClientSideTypeConfig",
    "DomainComment",
    "DummyDomain",
    "DynamicAction",
    "DynamicActionDomainClass",
    "DynamicActionExecRecord",
    "DynamicActionGroup",
    "DynamicConfig",
    "DynamicConfigRevision",
    "DynamicConfigTrash",
    "DynamicDashboardWidget",
    "DynamicFieldDefinition",
    "DynamicFieldHook",
    "DynamicFieldHookExecRecord",
    "DynamicFieldInstance",
    "DynamicFieldValue",
    "DynamicFilter",
    "DynamicForm",
    "DynamicFormField",
    "DynamicFormGroup",
    "DynamicFormWizardStep",
    "DynamicIntegration",
    "DynamicIntegrationDomainClass",
    "DynamicIntegrationExecRecord",
    "DynamicLogic",
    "DynamicLogicEngine",
    "DynamicLogicRevision",
    "DynamicLogicTrash",
    "DynamicLogicType",
    "DynamicMenu",
    "DynamicObjectHook",
    "DynamicObjectHookExecRecord",
    "DynamicPrompt",
    "DynamicTask",
    "DynamicTaskExecRecord",
    "DynamicTheme",
    "EmailSendingRecord",
    "Equipment",
    "EquipmentClass",
    "EquipmentSpecification",
    "Feedback",
    "Group",
    "GroupRole",
    "I18n",
    "I18nType",
    "ImportRecord",
    "Message",
    "Organization",
    "ProductionLine",
    "RegisterInvitation",
    "RegisterInvitationCode",
    "RequestMap",
    "Role",
    "RoleHierarchyEntry",
    "SampleContract",
    "SampleContractLine",
    "SampleContractLineType",
    "SampleMilestone",
    "SampleProject",
    "SampleTask",
    "StorageFieldValue",
    "User",
    "UserGroup",
    "UserRole",
    "WizardStepExecRecord",
    "AppVersion",
    "DynamicReport",
    "DynamicServiceProvider",
    "DynamicServiceExecRecord",
  ];
 
  const classNameAliasMap: Map<string, string[]> = new Map();
 
  for (const className of classNames) {
    const alias = className
      .replace('Default', '')
      .replace('Dynamic', '');
 
    classNameAliasMap.set(className, [className, alias].map(str => str.toLowerCase()));
  }
 
  return classNameAliasMap;
};
 
export const getOriginalClassName = (alias: string, classNameAliasMap?: Map<string, string[]>): string | undefined => {
  const map = classNameAliasMap || getClassNameAlias();
  const lowerCaseAlias = alias.toLowerCase();
  for (const [key, value] of map.entries()) {
    if (value.map(val => val.toLowerCase()).includes(lowerCaseAlias)) {
      return key;
    }
  }
  return undefined;
};
 
// Example usage
// const classNameAliasMap = getClassNameAlias();
// const alias = "Action"; // Enter the alias here
// const originalClassName = getOriginalClassName(alias, classNameAliasMap);
 
// if (originalClassName) {
//   console.log(`The original class name for alias "${alias}" is "${originalClassName}"`);
// } else {
//   console.log(`No original class name found for alias "${alias}"`);
// }