<commit_before>// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import { URLExt } from '@jupyterlab/coreutils';

import { ServerConnection } from '../serverconnection';

/**
 * The url for the lab nbconvert service.
 */
const NBCONVERT_SETTINGS_URL = 'api/nbconvert';

/**
 * The nbconvert API service manager.
 */
export class NbConvertManager {
  /**
   * Create a new nbconvert manager.
   */
  constructor(options: NbConvertManager.IOptions = {}) {
    this.serverSettings =
      options.serverSettings || ServerConnection.makeSettings();
  }

  /**
   * The server settings used to make API requests.
   */
  readonly serverSettings: ServerConnection.ISettings;

  /**
   * Get whether the application should be built.
   */
  getExportFormats(): Promise<NbConvertManager.IExportFormats> {
    const base = this.serverSettings.baseUrl;
    const url = URLExt.join(base, NBCONVERT_SETTINGS_URL);
    const { serverSettings } = this;
    const promise = ServerConnection.makeRequest(url, {}, serverSettings);

    return promise
      .then(response => {
        if (response.status !== 200) {
          throw new ServerConnection.ResponseError(response);
        }

        return response.json();
      })
      .then(data => {
        return data;
      });
  }
}

/**
 * A namespace for `BuildManager` statics.
 */
export namespace NbConvertManager {
  /**
   * The instantiation options for a setting manager.
   */
  export interface IOptions {
    /**<commit_msg>adding mapping/type checks to response object in getExportFormats<commit_after>// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import { URLExt } from '@jupyterlab/coreutils';

import { ServerConnection } from '../serverconnection';

/**
 * The url for the lab nbconvert service.
 */
const NBCONVERT_SETTINGS_URL = 'api/nbconvert';

/**
 * The nbconvert API service manager.
 */
export class NbConvertManager {
  /**
   * Create a new nbconvert manager.
   */
  constructor(options: NbConvertManager.IOptions = {}) {
    this.serverSettings =
      options.serverSettings || ServerConnection.makeSettings();
  }

  /**
   * The server settings used to make API requests.
   */
  readonly serverSettings: ServerConnection.ISettings;

  /**
   * Get whether the application should be built.
   */
  getExportFormats(): Promise<NbConvertManager.IExportFormats> {
    const base = this.serverSettings.baseUrl;
    const url = URLExt.join(base, NBCONVERT_SETTINGS_URL);
    const { serverSettings } = this;
    const promise = ServerConnection.makeRequest(url, {}, serverSettings);

    return promise
      .then(response => {
        if (response.status !== 200) {
          throw new ServerConnection.ResponseError(response);
        }

        return response.json();
      })
      .then(data => {
        let exportList: NbConvertManager.IExportFormats = {};
        let keys = Object.keys(data);
        keys.forEach(function(key) {
          let mimeType: string = data[key].output_mimetype;
          exportList[key] = { output_mimetype: mimeType };
        });
        return exportList;
      });
  }
}

/**
 * A namespace for `BuildManager` statics.
 */
export namespace NbConvertManager {
  /**
   * The instantiation options for a setting manager.
   */
  export interface IOptions {
    /**
{'fraction_non_alphanumeric': 0.11199763593380614, 'fraction_numerical': 0.0017730496453900709, 'mean_word_length': 3.0011820330969265, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3617385', 'n_tokens_mistral': 974, 'n_tokens_neox': 953, 'n_words': 255}