<commit_before>import { isObject, isNone } from './lib/objects';

export interface RecordIdentity {
  type: string;
  id: string;
}

export interface Record extends RecordIdentity {
  keys?: Object; // TODO
  attributes?: Object;
  relationships?: Object; // TODO
}

export function serializeRecordIdentity(identity: RecordIdentity): string {
  if (isNone(identity)) {
    return null;
  }
  const { type, id } = identity;
  if (isNone(type) || isNone(id)) {
    return null;
  } else {
    return `${type}:${id}`;
  }
}

export function deserializeRecordIdentity(identity: string): RecordIdentity {
  const [type, id] = identity.split(':');
  return { type, id };
}

export function cloneRecordIdentity(identity: RecordIdentity): RecordIdentity {<commit_msg>Expand record-related interfaces.<commit_after>import { isObject, isNone } from './lib/objects';
import { Dict } from './lib/dict';

export interface RecordIdentity {
  type: string;
  id: string;
}

export interface RecordKey {
  string;
}

export interface RecordIdentifier {
  string;
}

export interface RecordAttribute {
  any;
}

export interface RecordHasOneRelationship {
  data: null | RecordIdentifier;
}

export interface RecordHasManyRelationship {
  data: Dict<RecordIdentifier>;
}

export type RecordRelationship = RecordHasOneRelationship | RecordHasManyRelationship;

export interface Record extends RecordIdentity {
  keys?: Dict<RecordKey>;
  attributes?: Dict<RecordAttribute>;
  relationships?: Dict<RecordRelationship>;
}

export function serializeRecordIdentity(identity: RecordIdentity): string {
  if (isNone(identity)) {
    return null;
  }
  const { type, id } = identity;
  if (isNone(type) || isNone(id)) {
    return null;
  } else {
    return `${type}:${id}`;
  }
}

export function deserializeRecordIdentity(identity: string): RecordIdentity {
  const [type, id] = identity.split(':');
  return { type, id };
}

export function cloneRecordIdentity(identity: RecordIdentity): RecordIdentity {
{'fraction_non_alphanumeric': 0.11850731215330308, 'fraction_numerical': 0.0, 'mean_word_length': 4.818181818181818, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '7097952', 'n_tokens_mistral': 568, 'n_tokens_neox': 571, 'n_words': 158}