<commit_before>import StreamClient, { APIResponse } from './client';

/**
 * Manage api calls for personalization
 * The collection object contains convenience functions such as  get, post, delete
 * @class Personalization
 */

export default class Personalization<PersonalizationType> {
  client: StreamClient;

  constructor(client: StreamClient) {
    /**
     * Initialize the Personalization class
     *
     * @method constructor
     * @memberof Personalization.prototype
     * @param {StreamClient} client - The stream client
     */
    this.client = client;
  }

  get(resource: string, options: Record<string, string> & { token?: string } = {}): Promise<APIResponse> {
    /**
     * Get personalized activities for this feed
     *
     * @method get
     * @memberof Personalization.prototype
     * @param {string} resource - personalized resource endpoint i.e "follow_recommendations"
     * @param {object} options  Additional options
     * @return {Promise} Promise object. Personalized feed
     * @example client.personalization.get('follow_recommendations', {foo: 'bar', baz: 'qux'})
     */
    return this.client.get<APIResponse>({
      url: `${resource}/`,
      serviceName: 'personalization',
      qs: options,
      signature: options.token || this.client.getPersonalizationToken(),
    });
  }

  post(
    resource: string,
    options: Record<string, string> = {},
    data: Record<string, unknown> = {},
  ): Promise<APIResponse> {
    /**
     * Post data to personalization endpoint
     *
     * @method post
     * @memberof Personalization.prototype
     * @param {string} resource - personalized resource endpoint i.e "follow_recommendations"
     * @param {object} options - Additional options
     * @param {object} data - Data to send in the payload
     * @return {Promise} Promise object. Data that was posted if successful, or an error.
     * @example client.personalization.post('follow_recommendations', {foo: 'bar', baz: 'qux'})
     */
    return this.client.post<APIResponse>({
      url: `${resource}/`,
      serviceName: 'personalization',
      qs: options,
      body: data,
      signature: this.client.getPersonalizationToken(),
    });
  }

  delete(resource: string, options: Record<string, string> = {}): Promise<APIResponse> {
    /**
     * Delete metadata or activities
     *
     * @method delete
     * @memberof Personalization.prototype
     * @param {object} resource - personalized resource endpoint i.e "follow_recommendations"
     * @param {object} options - Additional options
     * @return {Promise} Promise object. Data that was deleted if successful, or an error.
     * @example client.personalization.delete('follow_recommendations', {foo: 'bar', baz: 'qux'})
     */
    return this.client.delete<APIResponse>({
      url: `${resource}/`,
      serviceName: 'personalization',
      qs: options,
      signature: this.client.getPersonalizationToken(),
    });
  }
}<commit_msg>add Personalization api response types<commit_after>import StreamClient, { APIResponse } from './client';

/**
 * Manage api calls for personalization
 * The collection object contains convenience functions such as  get, post, delete
 * @class Personalization
 */

type BasePersonalizationAPIResponse = APIResponse & {
  app_id: string;
  results: unknown[];
  next: string;
  offset?: number;
  limit?: number;
  version?: string;
};

export default class Personalization<PersonalizationType> {
  client: StreamClient;

  constructor(client: StreamClient) {
    /**
     * Initialize the Personalization class
     *
     * @method constructor
     * @memberof Personalization.prototype
     * @param {StreamClient} client - The stream client
     */
    this.client = client;
  }

  get(
    resource: string,
    options: Record<string, string> & { token?: string } = {},
  ): Promise<BasePersonalizationAPIResponse> {
    /**
     * Get personalized activities for this feed
     *
     * @method get
     * @memberof Personalization.prototype
     * @param {string} resource - personalized resource endpoint i.e "follow_recommendations"
     * @param {object} options  Additional options
     * @return {Promise} Promise object. Personalized feed
     * @example client.personalization.get('follow_recommendations', {foo: 'bar', baz: 'qux'})
     */
    return this.client.get<BasePersonalizationAPIResponse>({
      url: `${resource}/`,
      serviceName: 'personalization',
      qs: options,
      signature: options.token || this.client.getPersonalizationToken(),
    });
  }

  post(
    resource: string,
    options: Record<string, string> = {},
    data: Record<string, unknown> = {},
  ): Promise<BasePersonalizationAPIResponse> {
    /**
     * Post data to personalization endpoint
     *
     * @method post
     * @memberof Personalization.prototype
     * @param {string} resource - personalized resource endpoint i.e "follow_recommendations"
     * @param {object} options - Additional options
     * @param {object} data - Data to send in the payload
     * @return {Promise} Promise object. Data that was posted if successful, or an error.
     * @example client.personalization.post('follow_recommendations', {foo: 'bar', baz: 'qux'})
     */
    return this.client.post<BasePersonalizationAPIResponse>({
      url: `${resource}/`,
      serviceName: 'personalization',
      qs: options,
      body: data,
      signature: this.client.getPersonalizationToken(),
    });
  }

  delete(resource: string, options: Record<string, string> = {}): Promise<BasePersonalizationAPIResponse> {
    /**
     * Delete metadata or activities
     *
     * @method delete
     * @memberof Personalization.prototype
     * @param {object} resource - personalized resource endpoint i.e "follow_recommendations"
     * @param {object} options - Additional options
     * @return {Promise} Promise object. Data that was deleted if successful, or an error.
     * @example client.personalization.delete('follow_recommendations', {foo: 'bar', baz: 'qux'})
     */
    return this.client.delete<BasePersonalizationAPIResponse>({
      url: `${resource}/`,
      serviceName: 'personalization',
      qs: options,
      signature: this.client.getPersonalizationToken(),
    });
  }
}
{'fraction_non_alphanumeric': 0.11865492393915132, 'fraction_numerical': 0.0, 'mean_word_length': 3.3284823284823286, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '3596667', 'n_tokens_mistral': 1722, 'n_tokens_neox': 1678, 'n_words': 478}