<commit_before>/** Responsible for identifying the user to the Roundware server and retrieving an auth token **/

import { IApiClient } from "./types/api-client";
import { IUser, IUserResponse } from "./types/user";

export class User implements IUser {
  /** Create a User
   * @param {Object} options - Various configuration parameters for this user
   * @param {apiClient} options.apiClient - the API client object to use for server API calls
   * @param {String} options.deviceId - this value distinguishes a particular user, who may be anonymous, to the server; by default we will fingerprint the browser to get this value, but you can supply your own value (useful if your app has a preexisting authorization scheme)
   * @param {String} [options.clientType = "web"]
   **/
  apiClient: IApiClient;
  deviceId: string;
  clientType: string;
  userName: string;
  constructor({
    apiClient,
    deviceId = "00000000000000",
    clientType = "web",
  }: {
    apiClient: IApiClient;
    deviceId: string;
    clientType: string;
  }) {
    // TODO need to try to persist deviceId as a random value that can partially serve as "a unique identifier generated by the client" that can
    // used to claim a anonymous user's contributions. Some ideas for implementation: https://clientjs.org/ and https://github.com/Valve/fingerprintjs2
    this.apiClient = apiClient;
    this.deviceId = deviceId;
    this.clientType = clientType;
    this.userName = "(unknown)";
  }

  /** @returns {String} human-readable representation of this user **/
  toString(): string {
    return `User ${this.userName} (deviceId ${this.deviceId})`;
  }

  /** Make an API call to associate the (possibly anonymous) application user with a Roundware user account.
   * Upon success, this function receives an auth token, which is passed onto the apiClient object.
   * @returns {Promise} represents the pending API call **/
  async connect(): Promise<IUserResponse | {}> {
    const data = {
      device_id: this.deviceId,
      client_type: this.clientType,<commit_msg>Removed IUser ,use object types<commit_after>/** Responsible for identifying the user to the Roundware server and retrieving an auth token **/

import { ApiClient } from "./api-client";
import { IUserResponse } from "./types/user";

export class User {
  /** Create a User
   * @param {Object} options - Various configuration parameters for this user
   * @param {apiClient} options.apiClient - the API client object to use for server API calls
   * @param {String} options.deviceId - this value distinguishes a particular user, who may be anonymous, to the server; by default we will fingerprint the browser to get this value, but you can supply your own value (useful if your app has a preexisting authorization scheme)
   * @param {String} [options.clientType = "web"]
   **/
  apiClient: ApiClient;
  deviceId: string;
  clientType: string;
  userName: string;
  constructor({
    apiClient,
    deviceId = "00000000000000",
    clientType = "web",
  }: {
    apiClient: ApiClient;
    deviceId: string;
    clientType: string;
  }) {
    // TODO need to try to persist deviceId as a random value that can partially serve as "a unique identifier generated by the client" that can
    // used to claim a anonymous user's contributions. Some ideas for implementation: https://clientjs.org/ and https://github.com/Valve/fingerprintjs2
    this.apiClient = apiClient;
    this.deviceId = deviceId;
    this.clientType = clientType;
    this.userName = "(unknown)";
  }

  /** @returns {String} human-readable representation of this user **/
  toString(): string {
    return `User ${this.userName} (deviceId ${this.deviceId})`;
  }

  /** Make an API call to associate the (possibly anonymous) application user with a Roundware user account.
   * Upon success, this function receives an auth token, which is passed onto the apiClient object.
   * @returns {Promise} represents the pending API call **/
  async connect(): Promise<IUserResponse | {}> {
    const data = {
      device_id: this.deviceId,
      client_type: this.clientType,
{'fraction_non_alphanumeric': 0.09611151870873075, 'fraction_numerical': 0.007336757153338224, 'mean_word_length': 3.6742857142857144, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3247563', 'n_tokens_mistral': 1145, 'n_tokens_neox': 1091, 'n_words': 458}