<commit_before>/* @flow */

const DirMetadataBuilder = require('./metadata/dir')
const FileMetadataBuilder = require('./metadata/file')
const RemoteDirBuilder = require('./remote/dir')
const RemoteFileBuilder = require('./remote/file')
const StreamBuilder = require('./stream')

/*::
import type { Cozy } from 'cozy-client-js'
import type { Metadata } from '../../../core/metadata'
import type Pouch from '../../../core/pouch'
import type { Warning } from '../../../core/remote/warning'
*/

// Test data builders facade.
//
//     builders.metafile()...
//     builders.remoteDir()...
//     builders.stream()...
//
module.exports = class Builders {
  /*::
  cozy: ?Cozy
  pouch: ?Pouch
  */

  constructor ({cozy, pouch} /*: {cozy?: Cozy, pouch?: Pouch} */ = {}) {
    this.cozy = cozy
    this.pouch = pouch
  }

  metadata () /*: DirMetadataBuilder|FileMetadataBuilder */ {
    return this.metadir()
  }

  metadir (old /*: ?Metadata */) /*: DirMetadataBuilder */ {
    return new DirMetadataBuilder(this.pouch, old)
  }

  metafile (old /*: ?Metadata */) /*: FileMetadataBuilder */ {
    return new FileMetadataBuilder(this.pouch, old)
  }

  remoteDir () /*: RemoteDirBuilder */ {
    return new RemoteDirBuilder(this.cozy)
  }

  remoteFile () /*: RemoteFileBuilder */ {
    return new RemoteFileBuilder(this.cozy)
  }

  remoteWarnings () /*: Warning[] */ {
    return [
      {
        error: 'tos-updated',
        title: 'TOS Updated',
        detail: 'TOS have been updated',
        links: {
          self: 'https://manager.cozycloud.cc/cozy/tos?domain=...'
        }
      }
    ]
  }<commit_msg>test/support/builders: Add optional old to #metadata()<commit_after>/* @flow */

const DirMetadataBuilder = require('./metadata/dir')
const FileMetadataBuilder = require('./metadata/file')
const RemoteDirBuilder = require('./remote/dir')
const RemoteFileBuilder = require('./remote/file')
const StreamBuilder = require('./stream')

/*::
import type { Cozy } from 'cozy-client-js'
import type { Metadata } from '../../../core/metadata'
import type Pouch from '../../../core/pouch'
import type { Warning } from '../../../core/remote/warning'
*/

// Test data builders facade.
//
//     builders.metafile()...
//     builders.remoteDir()...
//     builders.stream()...
//
module.exports = class Builders {
  /*::
  cozy: ?Cozy
  pouch: ?Pouch
  */

  constructor ({cozy, pouch} /*: {cozy?: Cozy, pouch?: Pouch} */ = {}) {
    this.cozy = cozy
    this.pouch = pouch
  }

  metadata (old /*: ?Metadata */) /*: DirMetadataBuilder|FileMetadataBuilder */ {
    return this.metadir(old)
  }

  metadir (old /*: ?Metadata */) /*: DirMetadataBuilder */ {
    return new DirMetadataBuilder(this.pouch, old)
  }

  metafile (old /*: ?Metadata */) /*: FileMetadataBuilder */ {
    return new FileMetadataBuilder(this.pouch, old)
  }

  remoteDir () /*: RemoteDirBuilder */ {
    return new RemoteDirBuilder(this.cozy)
  }

  remoteFile () /*: RemoteFileBuilder */ {
    return new RemoteFileBuilder(this.cozy)
  }

  remoteWarnings () /*: Warning[] */ {
    return [
      {
        error: 'tos-updated',
        title: 'TOS Updated',
        detail: 'TOS have been updated',
        links: {
          self: 'https://manager.cozycloud.cc/cozy/tos?domain=...'
        }
      }
    ]
  }
{'fraction_non_alphanumeric': 0.18087697929354446, 'fraction_numerical': 0.0, 'mean_word_length': 2.621830209481808, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '2111545', 'n_tokens_mistral': 1049, 'n_tokens_neox': 1033, 'n_words': 223}