<commit_before>import { StreamClient, APIResponse, UR, DefaultGenerics } from './client';
import { StreamFeed } from './feed';
import { SiteError } from './errors';
import { EnrichedUser } from './user';

export type TargetFeeds = (string | StreamFeed)[];

export type TargetFeed = string | StreamFeed;

export type TargetFeedsExtraData = Record<string, unknown>;

type ReactionBody<T> = {
  activity_id?: string; // only required for reactions
  data?: T | UR;
  id?: string; // api will generate an id if it's missing
  kind?: string; // required only for add/addChile, not update
  parent?: string; // only required for child reactions
  target_feeds?: string[];
  target_feeds_extra_data?: TargetFeedsExtraData;
  user_id?: string; // optional when using client tokens
};

export type Reaction<T extends UR = UR> = {
  activity_id: string;
  created_at: string;
  data: T;
  id: string;
  kind: string;
  parent: string;
  updated_at: string;
  user_id: string;
  target_feeds?: string[];
  target_feeds_extra_data?: TargetFeedsExtraData;
};

export type ReactionAPIResponse<T extends UR = UR> = APIResponse & Reaction<T>;

export type ChildReactionsRecords<
  StreamFeedGenerics extends DefaultGenerics = DefaultGenerics,
  // eslint-disable-next-line no-use-before-define
> = Record<string, EnrichedReaction<StreamFeedGenerics>[]>;

export type EnrichedReaction<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = Reaction<
  StreamFeedGenerics['reactionType'] | StreamFeedGenerics['childReactionType']
> & {
  children_counts: Record<string, number>;
  latest_children: ChildReactionsRecords<StreamFeedGenerics>;
  latest_children_extra?: Record<string, { next?: string }>;
  own_children?: ChildReactionsRecords<StreamFeedGenerics>;
  user?: EnrichedUser<StreamFeedGenerics>;
};

export type EnrichedReactionAPIResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = APIResponse &
  EnrichedReaction<StreamFeedGenerics>;

export type ReactionFilterAPIResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = APIResponse & {
  next: string;
  results:
    | ReactionAPIResponse<StreamFeedGenerics['reactionType'] | StreamFeedGenerics['childReactionType']>[]
    | EnrichedReactionAPIResponse<StreamFeedGenerics>[];
  activity?: StreamFeedGenerics['childReactionType'];
};

export type ReactionFilterConditions = {
  activity_id?: string;
  id_gt?: string;
  id_gte?: string;
  id_lt?: string;<commit_msg>Add filter types for reactions (#507)<commit_after>import { StreamClient, APIResponse, UR, DefaultGenerics } from './client';
import { StreamFeed } from './feed';
import { SiteError } from './errors';
import { EnrichedUser } from './user';

export type TargetFeeds = (string | StreamFeed)[];

export type TargetFeed = string | StreamFeed;

export type TargetFeedsExtraData = Record<string, unknown>;

type ReactionBody<T> = {
  activity_id?: string; // only required for reactions
  data?: T | UR;
  id?: string; // api will generate an id if it's missing
  kind?: string; // required only for add/addChile, not update
  parent?: string; // only required for child reactions
  target_feeds?: string[];
  target_feeds_extra_data?: TargetFeedsExtraData;
  user_id?: string; // optional when using client tokens
};

export type Reaction<T extends UR = UR> = {
  activity_id: string;
  created_at: string;
  data: T;
  id: string;
  kind: string;
  parent: string;
  updated_at: string;
  user_id: string;
  target_feeds?: string[];
  target_feeds_extra_data?: TargetFeedsExtraData;
};

export type ReactionAPIResponse<T extends UR = UR> = APIResponse & Reaction<T>;

export type ChildReactionsRecords<
  StreamFeedGenerics extends DefaultGenerics = DefaultGenerics,
  // eslint-disable-next-line no-use-before-define
> = Record<string, EnrichedReaction<StreamFeedGenerics>[]>;

export type EnrichedReaction<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = Reaction<
  StreamFeedGenerics['reactionType'] | StreamFeedGenerics['childReactionType']
> & {
  children_counts: Record<string, number>;
  latest_children: ChildReactionsRecords<StreamFeedGenerics>;
  latest_children_extra?: Record<string, { next?: string }>;
  own_children?: ChildReactionsRecords<StreamFeedGenerics>;
  user?: EnrichedUser<StreamFeedGenerics>;
};

export type EnrichedReactionAPIResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = APIResponse &
  EnrichedReaction<StreamFeedGenerics>;

export type ReactionFilterAPIResponse<StreamFeedGenerics extends DefaultGenerics = DefaultGenerics> = APIResponse & {
  next: string;
  results:
    | ReactionAPIResponse<StreamFeedGenerics['reactionType'] | StreamFeedGenerics['childReactionType']>[]
    | EnrichedReactionAPIResponse<StreamFeedGenerics>[];
  activity?: StreamFeedGenerics['childReactionType'];
};

export type ReactionFilterConditions = {
  activity_id?: string;
  children_user_id?: string;
  filter_user_id?: string;
  id_gt?: string;
  id_gte?: string;
  id_lt?: string;
{'fraction_non_alphanumeric': 0.10717147435897435, 'fraction_numerical': 0.0006009615384615385, 'mean_word_length': 5.992997198879552, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 43, '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': '5852187', 'n_tokens_mistral': 1495, 'n_tokens_neox': 1445, 'n_words': 372}