<commit_before>import Promise, {props} from 'bluebird';
import {IDatabase} from 'pg-promise';
import {merge}     from 'ramda';

import tables, {TableDescription}     from './inspectors/tables';
import schema, {SchemaDocument}       from './inspectors/schema';
import relationships, {Relationships} from './inspectors/relationships';

/**
 * Extended description of a Table that includes information about the table
 * schema and relationships to other tables
 */
export interface FullTableDescription extends TableDescription {
  schema: SchemaDocument;
  relationships: Relationships[];
}

/**
 * Inspect all enumerable table in a database, and return a promise that will
 * resolve to information about each table.
 *
 * @param db A pg-promise database instance
 * @returns  A promise that will resolve to the information for each table
 */
export function inspect(db: IDatabase<any>): Promise<FullTableDescription[]> {
  function inspectors(table: TableDescription) {
    var queries = {
      schema: schema(db, table.name),
      relationships: relationships(db, table.name)
    };

    return <Promise<FullTableDescription>> props(queries).then(merge(table));
  }
<commit_msg>fix: Change array-based relationship defintion<commit_after>import Promise, {props} from 'bluebird';
import {IDatabase} from 'pg-promise';
import {merge}     from 'ramda';

import tables, {TableDescription}     from './inspectors/tables';
import schema, {SchemaDocument}       from './inspectors/schema';
import relationships, {Relationships} from './inspectors/relationships';

/**
 * Extended description of a Table that includes information about the table
 * schema and relationships to other tables
 */
export interface FullTableDescription extends TableDescription {
  schema: SchemaDocument;
  relationships: Relationships;
}

/**
 * Inspect all enumerable table in a database, and return a promise that will
 * resolve to information about each table.
 *
 * @param db A pg-promise database instance
 * @returns  A promise that will resolve to the information for each table
 */
export function inspect(db: IDatabase<any>): Promise<FullTableDescription[]> {
  function inspectors(table: TableDescription) {
    var queries = {
      schema: schema(db, table.name),
      relationships: relationships(db, table.name)
    };

    return <Promise<FullTableDescription>> props(queries).then(merge(table));
  }

{'fraction_non_alphanumeric': 0.10020876826722339, 'fraction_numerical': 0.0, 'mean_word_length': 4.677725118483412, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '2710741', 'n_tokens_mistral': 624, 'n_tokens_neox': 618, 'n_words': 224}