ronantakizawa/codereview-bench huggingface dataset:
Repository: hasura/graphql-engine
File: cli/commands/init.go (Go)

Code before:
}

func (o *InitOptions) Run() error {
	var infoMsg string
	if o.InitDir == "." {
		dir, err := os.Getwd()
		if err != nil {
			return errors.Wrap(err, "error getting present working directory")
		}
		o.EC.ExecutionDirectory = dir
		infoMsg = fmt.Sprintf(`hasura project initialised. execute the following command to continue:
  hasura console
`)
	} else {
		// prompt for init directory if it's not set already
		if o.InitDir == "" {
			p := promptui.Prompt{
				Label:   "Name of project directory ",
				Default: defaultDirectory,
			}
			r, err := p.Run()
			if err != nil {
				return handlePromptError(err)
			}
			if strings.TrimSpace(r) != "" {
				o.InitDir = r
			} else {
				o.InitDir = defaultDirectory
			}
		}
		// create execution directory
		err := o.createExecutionDirectory()
		if err != nil {
			return err
		}
		infoMsg = fmt.Sprintf(`directory created. execute the following commands to continue:

  cd %s
  hasura console
`, o.EC.ExecutionDirectory)
	}

	// create template files
	err := o.createTemplateFiles()
	if err != nil {
		return err
	}

	// create other required files, like config.yaml, migrations directory
	err = o.createFiles()
	if err != nil {

Review comment (suggestion):
@ShraddhaAg Can we also handle if the user enters `.` in the promptui

Code after:
	InitDir     string

	Template string
}

func (o *InitOptions) Run() error {
	var infoMsg string
	// prompt for init directory if it's not set already
	if o.InitDir == "" {
		p := promptui.Prompt{
			Label:   "Name of project directory ",
			Default: defaultDirectory,
		}
		r, err := p.Run()
		if err != nil {
			return handlePromptError(err)
		}
		if strings.TrimSpace(r) != "" {
			o.InitDir = r
		} else {
			o.InitDir = defaultDirectory
		}
	}

	cwdir, err := os.Getwd()
	if err != nil {
		return errors.Wrap(err, "error getting current working directory")
	}
	initPath, err := filepath.Abs(o.InitDir)
	if err != nil {
		return err
	}
	if initPath == cwdir {
		// check if pwd is filesystem root
		if err := cli.CheckFilesystemBoundary(cwdir); err != nil {
			return errors.Wrap(err, "can't initialise hasura project in filesystem root")
		}
		// check if the current directory is already a hasura project
		if err := cli.ValidateDirectory(cwdir); err == nil {
			return errors.Errorf("current working directory is already a hasura project directory")
		}
		o.EC.ExecutionDirectory = cwdir
		infoMsg = fmt.Sprintf(`hasura project initialised. execute the following command to continue:
  hasura console
`)
	} else {
		// create execution directory
		err := o.createExecutionDirectory()
		if err != nil {
			return err
		}
Repository: hasura/graphql-engine
File: console/src/components/UIKit/atoms/Button/Button.ts (TypeScript)

Code before:
import styled, { css } from 'styled-components';
import {
  layout,
  space,
  color,
  border,
  typography,
  flexbox,
  LayoutProps,
  SpaceProps,
  TypographyProps,
  BorderProps,
  FlexboxProps,
  TextColorProps,
  BackgroundColorProps,
} from 'styled-system';
import { Theme } from '../../theme';

interface OmittedButtonProps
  extends Omit<
    React.ComponentPropsWithRef<'button'>,
    'type' | 'color' | 'disabled'
  > {}
const Button = ('button' as any) as React.FC<OmittedButtonProps>;

interface StyledButtonOwnProps
  extends LayoutProps,
    TextColorProps,
    BackgroundColorProps,
    TypographyProps,
    SpaceProps,
    FlexboxProps,
    BorderProps {
  boxShadowColor: string;
  type: keyof Theme['button'];
  disabled: boolean;
  opacity: string | undefined;
}

const hoverStyles = ({
  type,
  theme,
  disabled,
  boxShadowColor,
}: {
  type: keyof Theme['button'];
  theme: Theme;
  disabled: boolean;
  boxShadowColor: string;

Review comment (suggestion):
```suggestion
const Button = ('button' as any) as React.FC<ButtonProps>;
```

Code after:
import styled, { css } from 'styled-components';
import {
  layout,
  space,
  color,
  border,
  typography,
  flexbox,
  LayoutProps,
  SpaceProps,
  TypographyProps,
  BorderProps,
  FlexboxProps,
  TextColorProps,
  BackgroundColorProps,
} from 'styled-system';
import { Theme } from '../../theme';

interface ButtonProps
  extends Omit<
    React.ComponentPropsWithRef<'button'>,
    'type' | 'color' | 'disabled'
  > {}
const Button = ('button' as any) as React.FC<ButtonProps>;

interface StyledButtonOwnProps
  extends LayoutProps,
    TextColorProps,
    BackgroundColorProps,
    TypographyProps,
    SpaceProps,
    FlexboxProps,
    BorderProps {
  boxShadowColor: string;
  type: keyof Theme['button'];
  disabled: boolean;
  opacity?: string;
}

const hoverStyles = ({
  type,
  theme,
  disabled,
  boxShadowColor,
}: {
  type: keyof Theme['button'];
  theme: Theme;
  disabled: boolean;
  boxShadowColor: string;
Repository: hasura/graphql-engine
File: console/src/telemetryFilter.ts (TypeScript)

Code before:
      .replace(
        /(\/schema\/.*)\/functions\/([^/]*)(\/.*)?/,
        '$1/functions/FUNCTION_NAME$3'
      )
  );
};

const apiExplorerHandler = (): string => {
  return API_EXPLORER_PATH;
};

const remoteSchemasHandler = (path: string): string => {
  return (
    REMOTE_SCHEMAS_PATH +
    path.replace(/(\/manage\/)[^/]*(\/\w+.*)$/, '$1REMOTE_SCHEMA_NAME$2')
  );
};

const eventsHandler = (path: string): string => {
  return (
    EVENTS_PATH +
    path.replace(/(\/manage\/triggers\/)[^/]*(\/\w+.*)$/, '$1TRIGGER_NAME$2')
  );
};

const sanitiseUrl = (path: string): string => {
  path = path.replace(new RegExp(globals.urlPrefix, 'g'), '');
  if (path.indexOf(DATA_PATH) === 0) {
    return dataHandler(path.slice(DATA_PATH.length));
  }
  if (path.indexOf(API_EXPLORER_PATH) === 0) {
    return apiExplorerHandler();
  }
  if (path.indexOf(REMOTE_SCHEMAS_PATH) === 0) {
    return remoteSchemasHandler(path.slice(REMOTE_SCHEMAS_PATH.length));
  }
  if (path.indexOf(EVENTS_PATH) === 0) {
    return eventsHandler(path.slice(EVENTS_PATH.length));
  }
  return '/';
};

export { filterEventsBlockList, filterPayloadAllowList, sanitiseUrl };


Review comment (suggestion):
```suggestion
const sanitiseUrl = (path: string) => {
```

Code after:
        '$1/functions/FUNCTION_NAME$3'
      )
  );
};

const apiExplorerHandler = () => {
  return API_EXPLORER_PATH;
};

const remoteSchemasHandler = (path: string) => {
  return (
    REMOTE_SCHEMAS_PATH +
    path.replace(/(\/manage\/)[^/]*(\/\w+.*)$/, '$1REMOTE_SCHEMA_NAME$2')
  );
};

const eventsHandler = (path: string) => {
  return (
    EVENTS_PATH +
    path.replace(/(\/manage\/triggers\/)[^/]*(\/\w+.*)$/, '$1TRIGGER_NAME$2')
  );
};

const sanitiseUrl = (path: string) => {
  const newPath = path.replace(new RegExp(globals.urlPrefix, 'g'), '');
  if (newPath.indexOf(DATA_PATH) === 0) {
    return dataHandler(newPath.slice(DATA_PATH.length));
  }
  if (newPath.indexOf(API_EXPLORER_PATH) === 0) {
    return apiExplorerHandler();
  }
  if (newPath.indexOf(REMOTE_SCHEMAS_PATH) === 0) {
    return remoteSchemasHandler(newPath.slice(REMOTE_SCHEMAS_PATH.length));
  }
  if (newPath.indexOf(EVENTS_PATH) === 0) {
    return eventsHandler(newPath.slice(EVENTS_PATH.length));
  }
  return '/';
};

export { filterEventsBlockList, sanitiseUrl };
Repository: hasura/graphql-engine
File: console/src/telemetryFilter.ts (TypeScript)

Code before:
const API_EXPLORER_PATH = '/api-explorer';
const REMOTE_SCHEMAS_PATH = '/remote-schemas';
const EVENTS_PATH = '/events';

const dataHandler = (path: string): string => {
  return (
    DATA_PATH +
    path
      .replace(/\/schema\/([^/]*)(\/)?/, '/schema/SCHEMA_NAME$2')
      .replace(
        /(\/schema\/.*)\/tables\/([^/]*)(\/.*)?/,
        '$1/tables/TABLE_NAME$3'
      )
      .replace(/(\/schema\/.*)\/views\/([^/]*)(\/.*)?/, '$1/views/VIEW_NAME$3')
      .replace(
        /(\/schema\/.*)\/functions\/([^/]*)(\/.*)?/,
        '$1/functions/FUNCTION_NAME$3'
      )
  );
};

const apiExplorerHandler = (): string => {
  return API_EXPLORER_PATH;
};

const remoteSchemasHandler = (path: string): string => {
  return (
    REMOTE_SCHEMAS_PATH +
    path.replace(/(\/manage\/)[^/]*(\/\w+.*)$/, '$1REMOTE_SCHEMA_NAME$2')
  );
};

const eventsHandler = (path: string): string => {
  return (
    EVENTS_PATH +
    path.replace(/(\/manage\/triggers\/)[^/]*(\/\w+.*)$/, '$1TRIGGER_NAME$2')
  );
};

const sanitiseUrl = (path: string): string => {
  path = path.replace(new RegExp(globals.urlPrefix, 'g'), '');
  if (path.indexOf(DATA_PATH) === 0) {
    return dataHandler(path.slice(DATA_PATH.length));
  }
  if (path.indexOf(API_EXPLORER_PATH) === 0) {
    return apiExplorerHandler();
  }
  if (path.indexOf(REMOTE_SCHEMAS_PATH) === 0) {
    return remoteSchemasHandler(path.slice(REMOTE_SCHEMAS_PATH.length));
  }
  if (path.indexOf(EVENTS_PATH) === 0) {

Review comment (suggestion):
As TypeScript can infer that.
```suggestion
const remoteSchemasHandler = (path: string) => {
```

Code after:
const EVENTS_PATH = '/events' as const;

const dataHandler = (path: string) => {
  return (
    DATA_PATH +
    path
      .replace(/\/schema\/([^/]*)(\/)?/, '/schema/SCHEMA_NAME$2')
      .replace(
        /(\/schema\/.*)\/tables\/([^/]*)(\/.*)?/,
        '$1/tables/TABLE_NAME$3'
      )
      .replace(/(\/schema\/.*)\/views\/([^/]*)(\/.*)?/, '$1/views/VIEW_NAME$3')
      .replace(
        /(\/schema\/.*)\/functions\/([^/]*)(\/.*)?/,
        '$1/functions/FUNCTION_NAME$3'
      )
  );
};

const apiExplorerHandler = () => {
  return API_EXPLORER_PATH;
};

const remoteSchemasHandler = (path: string) => {
  return (
    REMOTE_SCHEMAS_PATH +
    path.replace(/(\/manage\/)[^/]*(\/\w+.*)$/, '$1REMOTE_SCHEMA_NAME$2')
  );
};

const eventsHandler = (path: string) => {
  return (
    EVENTS_PATH +
    path.replace(/(\/manage\/triggers\/)[^/]*(\/\w+.*)$/, '$1TRIGGER_NAME$2')
  );
};

const sanitiseUrl = (path: string) => {
  const newPath = path.replace(new RegExp(globals.urlPrefix, 'g'), '');
  if (newPath.indexOf(DATA_PATH) === 0) {
    return dataHandler(newPath.slice(DATA_PATH.length));
  }
  if (newPath.indexOf(API_EXPLORER_PATH) === 0) {
    return apiExplorerHandler();
  }
  if (newPath.indexOf(REMOTE_SCHEMAS_PATH) === 0) {
    return remoteSchemasHandler(newPath.slice(REMOTE_SCHEMAS_PATH.length));
  }
  if (newPath.indexOf(EVENTS_PATH) === 0) {
    return eventsHandler(newPath.slice(EVENTS_PATH.length));
  }
Repository: hasura/graphql-engine
File: console/src/telemetryFilter.ts (TypeScript)

Code before:
    path
      .replace(/\/schema\/([^/]*)(\/)?/, '/schema/SCHEMA_NAME$2')
      .replace(
        /(\/schema\/.*)\/tables\/([^/]*)(\/.*)?/,
        '$1/tables/TABLE_NAME$3'
      )
      .replace(/(\/schema\/.*)\/views\/([^/]*)(\/.*)?/, '$1/views/VIEW_NAME$3')
      .replace(
        /(\/schema\/.*)\/functions\/([^/]*)(\/.*)?/,
        '$1/functions/FUNCTION_NAME$3'
      )
  );
};

const apiExplorerHandler = (): string => {
  return API_EXPLORER_PATH;
};

const remoteSchemasHandler = (path: string): string => {
  return (
    REMOTE_SCHEMAS_PATH +
    path.replace(/(\/manage\/)[^/]*(\/\w+.*)$/, '$1REMOTE_SCHEMA_NAME$2')
  );
};

const eventsHandler = (path: string): string => {
  return (
    EVENTS_PATH +
    path.replace(/(\/manage\/triggers\/)[^/]*(\/\w+.*)$/, '$1TRIGGER_NAME$2')
  );
};

const sanitiseUrl = (path: string): string => {
  path = path.replace(new RegExp(globals.urlPrefix, 'g'), '');
  if (path.indexOf(DATA_PATH) === 0) {
    return dataHandler(path.slice(DATA_PATH.length));
  }
  if (path.indexOf(API_EXPLORER_PATH) === 0) {
    return apiExplorerHandler();
  }
  if (path.indexOf(REMOTE_SCHEMAS_PATH) === 0) {
    return remoteSchemasHandler(path.slice(REMOTE_SCHEMAS_PATH.length));
  }
  if (path.indexOf(EVENTS_PATH) === 0) {
    return eventsHandler(path.slice(EVENTS_PATH.length));
  }
  return '/';
};

export { filterEventsBlockList, filterPayloadAllowList, sanitiseUrl };


Review comment (suggestion):
As TypeScript can infer that.
```suggestion
const eventsHandler = (path: string) => {
```

Code after:
      .replace(
        /(\/schema\/.*)\/tables\/([^/]*)(\/.*)?/,
        '$1/tables/TABLE_NAME$3'
      )
      .replace(/(\/schema\/.*)\/views\/([^/]*)(\/.*)?/, '$1/views/VIEW_NAME$3')
      .replace(
        /(\/schema\/.*)\/functions\/([^/]*)(\/.*)?/,
        '$1/functions/FUNCTION_NAME$3'
      )
  );
};

const apiExplorerHandler = () => {
  return API_EXPLORER_PATH;
};

const remoteSchemasHandler = (path: string) => {
  return (
    REMOTE_SCHEMAS_PATH +
    path.replace(/(\/manage\/)[^/]*(\/\w+.*)$/, '$1REMOTE_SCHEMA_NAME$2')
  );
};

const eventsHandler = (path: string) => {
  return (
    EVENTS_PATH +
    path.replace(/(\/manage\/triggers\/)[^/]*(\/\w+.*)$/, '$1TRIGGER_NAME$2')
  );
};

const sanitiseUrl = (path: string) => {
  const newPath = path.replace(new RegExp(globals.urlPrefix, 'g'), '');
  if (newPath.indexOf(DATA_PATH) === 0) {
    return dataHandler(newPath.slice(DATA_PATH.length));
  }
  if (newPath.indexOf(API_EXPLORER_PATH) === 0) {
    return apiExplorerHandler();
  }
  if (newPath.indexOf(REMOTE_SCHEMAS_PATH) === 0) {
    return remoteSchemasHandler(newPath.slice(REMOTE_SCHEMAS_PATH.length));
  }
  if (newPath.indexOf(EVENTS_PATH) === 0) {
    return eventsHandler(newPath.slice(EVENTS_PATH.length));
  }
  return '/';
};

export { filterEventsBlockList, sanitiseUrl };
Repository: hasura/graphql-engine
File: console/src/telemetryFilter.ts (TypeScript)

Code before:
import globals from './Globals';

const filterEventsBlockList = [
  'App/ONGOING_REQUEST',
  'App/DONE_REQUEST',
  'App/FAILED_REQUEST',
  'App/ERROR_REQUEST',
  'RNS_SHOW_NOTIFICATION',
  'RNS_HIDE_NOTIFICATION',
  'RNS_REMOVE_ALL_NOTIFICATIONS',
];

const filterPayloadAllowList: unknown[] = [];

const DATA_PATH = '/data';
const API_EXPLORER_PATH = '/api-explorer';
const REMOTE_SCHEMAS_PATH = '/remote-schemas';
const EVENTS_PATH = '/events';

const dataHandler = (path: string): string => {
  return (
    DATA_PATH +
    path
      .replace(/\/schema\/([^/]*)(\/)?/, '/schema/SCHEMA_NAME$2')
      .replace(
        /(\/schema\/.*)\/tables\/([^/]*)(\/.*)?/,
        '$1/tables/TABLE_NAME$3'
      )
      .replace(/(\/schema\/.*)\/views\/([^/]*)(\/.*)?/, '$1/views/VIEW_NAME$3')
      .replace(
        /(\/schema\/.*)\/functions\/([^/]*)(\/.*)?/,
        '$1/functions/FUNCTION_NAME$3'
      )
  );
};

const apiExplorerHandler = (): string => {
  return API_EXPLORER_PATH;
};

const remoteSchemasHandler = (path: string): string => {
  return (
    REMOTE_SCHEMAS_PATH +
    path.replace(/(\/manage\/)[^/]*(\/\w+.*)$/, '$1REMOTE_SCHEMA_NAME$2')
  );

Review comment (suggestion):
```suggestion
const dataHandler = (path: string) => {
```

Code after:
import globals from './Globals';

const filterEventsBlockList = [
  'App/ONGOING_REQUEST',
  'App/DONE_REQUEST',
  'App/FAILED_REQUEST',
  'App/ERROR_REQUEST',
  'RNS_SHOW_NOTIFICATION',
  'RNS_HIDE_NOTIFICATION',
  'RNS_REMOVE_ALL_NOTIFICATIONS',
];

const DATA_PATH = '/data' as const;
const API_EXPLORER_PATH = '/api-explorer' as const;
const REMOTE_SCHEMAS_PATH = '/remote-schemas' as const;
const EVENTS_PATH = '/events' as const;

const dataHandler = (path: string) => {
  return (
    DATA_PATH +
    path
      .replace(/\/schema\/([^/]*)(\/)?/, '/schema/SCHEMA_NAME$2')
      .replace(
        /(\/schema\/.*)\/tables\/([^/]*)(\/.*)?/,
        '$1/tables/TABLE_NAME$3'
      )
      .replace(/(\/schema\/.*)\/views\/([^/]*)(\/.*)?/, '$1/views/VIEW_NAME$3')
      .replace(
        /(\/schema\/.*)\/functions\/([^/]*)(\/.*)?/,
        '$1/functions/FUNCTION_NAME$3'
      )
  );
};

const apiExplorerHandler = () => {
  return API_EXPLORER_PATH;
};

const remoteSchemasHandler = (path: string) => {
  return (
    REMOTE_SCHEMAS_PATH +
    path.replace(/(\/manage\/)[^/]*(\/\w+.*)$/, '$1REMOTE_SCHEMA_NAME$2')
  );
};
Repository: hasura/graphql-engine
File: cli/cli.go (Go)

Code before:
	ec.Telemetry.ExecutionID = ec.ID

	return nil
}

// setTLSConfig sets the TLS config
func (ec *ExecutionContext) setTLSConfig() error {
	if ec.InsecureSkipTLSVerify {
		ec.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
	} else if ec.CAPath != "" {
		// Get the SystemCertPool, continue with an empty pool on error
		rootCAs, _ := x509.SystemCertPool()
		if rootCAs == nil {
			rootCAs = x509.NewCertPool()
		}

		cert, err := ec.getCAData(ec.CAPath)
		if err != nil {
			return err
		}
		if ok := rootCAs.AppendCertsFromPEM(cert); !ok {
			return errors.Errorf("Unable to append given CA cert.")
		}
		ec.TLSClientConfig = &tls.Config{
			RootCAs:            rootCAs,
			InsecureSkipVerify: true,
		}
	} else {
		ec.TLSClientConfig = nil
	}
	return nil
}

// getCAData gets the cert from the given file location
func (ec *ExecutionContext) getCAData(name string) ([]byte, error) {
	ec.CAPath, _ = filepath.Abs(ec.CAPath)
	cert, err := ioutil.ReadFile(ec.CAPath)
	if err != nil {
		return nil, errors.Errorf("error reading CA %s", ec.CAPath)
	}
	return cert, nil
}

// setupPlugins create and returns the inferred paths for hasura. By default, it assumes
// $HOME/.hasura as the base path
func (ec *ExecutionContext) setupPlugins() error {
	base := filepath.Join(ec.GlobalConfigDir, "plugins")
	base, err := filepath.Abs(base)
	if err != nil {
		return errors.Wrap(err, "cannot get absolute path")
	}

Review comment (suggestion):
```suggestion
			InsecureSkipVerify: ec.InsecureSkipTLSVerify,
```

Code after:
	err = ec.setupCodegenAssetsRepo()
	if err != nil {
		return errors.Wrap(err, "setting up codegen-assets repo failed")
	}

	err = ec.setupInitTemplatesRepo()
	if err != nil {
		return errors.Wrap(err, "setting up init-templates repo failed")
	}

	ec.LastUpdateCheckFile = filepath.Join(ec.GlobalConfigDir, LastUpdateCheckFileName)

	// initialize a blank server config
	if ec.Config == nil {
		ec.Config = &Config{}
	}

	// generate an execution id
	if ec.ID == "" {
		id := "00000000-0000-0000-0000-000000000000"
		u, err := uuid.NewV4()
		if err == nil {
			id = u.String()
		} else {
			ec.Logger.Debugf("generating uuid for execution ID failed, %v", err)
		}
		ec.ID = id
		ec.Logger.Debugf("execution id: %v", ec.ID)
	}
	ec.Telemetry.ExecutionID = ec.ID

	return nil
}

// setupPlugins create and returns the inferred paths for hasura. By default, it assumes
// $HOME/.hasura as the base path
func (ec *ExecutionContext) setupPlugins() error {
	base := filepath.Join(ec.GlobalConfigDir, "plugins")
	base, err := filepath.Abs(base)
	if err != nil {
		return errors.Wrap(err, "cannot get absolute path")
	}
	ec.PluginsConfig = plugins.New(base)
	ec.PluginsConfig.Logger = ec.Logger
	ec.PluginsConfig.Repo.Logger = ec.Logger
	if ec.GlobalConfig.CLIEnvironment == ServerOnDockerEnvironment {
		ec.PluginsConfig.Repo.DisableCloneOrUpdate = true
	}
	return ec.PluginsConfig.Prepare()
}
Repository: hasura/graphql-engine
File: console/src/helpers/Html.tsx (TypeScript)

Code before:
import React from 'react';
import Helmet from 'react-helmet';
import { env } from './localDev';
/**
 * Wrapper component containing HTML metadata and boilerplate tags.
 * Used in server-side code only to wrap the string output of the
 * rendered route component.
 *
 * The only thing this component doesn't (and can't) include is the
 * HTML doctype declaration, which is added to the rendered output
 * by the server.js file.
 */

type IAssets = {
  [key in 'styles' | 'javascript']: {
    [key: string]: string;
  };
};

type HtmlProps = {
  assets: IAssets;
  component: React.ReactNode;
  baseDomain: string;
};

export default function Html(props: HtmlProps) {
  const { assets } = props;
  const head = Helmet.rewind();
  return (
    <html lang="en-US">
      <head>
        <link rel="icon" type="image/png" href="/rstatic/favicon_green.png" />
        {Object.keys(assets.styles).map((style, key) => (
          <link
            href={assets.styles[style]}
            // eslint-disable-next-line react/no-array-index-key
            key={key}
            media="screen, projection"
            rel="stylesheet"

Review comment (suggestion):
```suggestion
type Assets = {
```

As we stick to not prefixing type aliases or interfaces with `I`.

Code after:
import React from 'react';
import { env } from './localDev';
/**
 * Wrapper component containing HTML metadata and boilerplate tags.
 * Used in server-side code only to wrap the string output of the
 * rendered route component.
 *
 * The only thing this component doesn't (and can't) include is the
 * HTML doctype declaration, which is added to the rendered output
 * by the server.js file.
 */

type Assets = Record<'styles' | 'javascript', Record<string, string>>;

type HtmlProps = {
  assets: Assets;
  component: React.ReactNode;
  baseDomain: string;
};

const Html: React.FC<HtmlProps> = props => {
  const { assets } = props;
  return (
    <html lang="en-US">
      <head>
        <link rel="icon" type="image/png" href="/rstatic/favicon_green.png" />
        {Object.keys(assets.styles).map((style, key) => (
          <link
            href={assets.styles[style]}
            key={key}
            media="screen, projection"
            rel="stylesheet"
            type="text/css"
          />
        ))}

        <script
          dangerouslySetInnerHTML={{
            __html: env,
Repository: hasura/graphql-engine
File: console/src/helpers/versionUtils.ts (TypeScript)

Code before:
import globals from '../Globals';

const semver = require('semver');

export const READ_ONLY_RUN_SQL_QUERIES = 'readOnlyRunSqlQueries';

// list of feature launch versions
const featureLaunchVersions = {
  // feature: 'v1.0.1'
  [READ_ONLY_RUN_SQL_QUERIES]: 'v1.1.0',
};

type IFeature = keyof typeof featureLaunchVersions;

type IFeaturesCompatibility = {
  [key in IFeature]?: boolean;
};

export const checkValidServerVersion = (version: string) => {
  return semver.valid(version) !== null;
};

export const getFeaturesCompatibility = (serverVersion: string) => {
  const featuresCompatibility: IFeaturesCompatibility = {};

  const isValidServerVersion = checkValidServerVersion(serverVersion);

  Object.keys(featureLaunchVersions).forEach(_feature => {
    const feature = _feature as IFeature;
    featuresCompatibility[feature] = isValidServerVersion
      ? semver.satisfies(serverVersion, `>= ${featureLaunchVersions[feature]}`)
      : true;
  });

  return featuresCompatibility;
};

export const versionGT = (version1: string, version2: string) => {

Review comment (suggestion):
```suggestion
type Feature = keyof typeof featureLaunchVersions;
```

Code after:
import globals from '../Globals';

const semver = require('semver');

export const READ_ONLY_RUN_SQL_QUERIES = 'readOnlyRunSqlQueries';

// list of feature launch versions
const featureLaunchVersions = {
  // feature: 'v1.0.1'
  [READ_ONLY_RUN_SQL_QUERIES]: 'v1.1.0',
};

type Feature = keyof typeof featureLaunchVersions;

type FeaturesCompatibility = {
  [key in Feature]?: boolean;
};

export const checkValidServerVersion = (version: string) => {
  return semver.valid(version) !== null;
};

export const getFeaturesCompatibility = (serverVersion: string) => {
  const featuresCompatibility: FeaturesCompatibility = {};

  const isValidServerVersion = checkValidServerVersion(serverVersion);

  Object.keys(featureLaunchVersions).forEach(_feature => {
    const feature = _feature as Feature;
    featuresCompatibility[feature] = isValidServerVersion
      ? semver.satisfies(serverVersion, `>= ${featureLaunchVersions[feature]}`)
      : true;
  });

  return featuresCompatibility;
};

export const versionGT = (version1: string, version2: string) => {